[FFmpeg-devel] [PATCH 29/31] vp9_metadata: Update AVCodecParameters during init

2019-07-08 Thread Andreas Rheinhardt
This commit changes vp9_metadata to update the AVCodecParameters to
reflect the output bitstream. This brings vp9_metadata in line with what
is expected of a bitstream filter.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vp9_metadata_bsf.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/libavcodec/vp9_metadata_bsf.c b/libavcodec/vp9_metadata_bsf.c
index 52e962b1c0..0ce017ffea 100644
--- a/libavcodec/vp9_metadata_bsf.c
+++ b/libavcodec/vp9_metadata_bsf.c
@@ -107,7 +107,23 @@ fail:
 
 static int vp9_metadata_init(AVBSFContext *bsf)
 {
+static const uint8_t conversion_table[8] = {
+AVCOL_SPC_UNSPECIFIED, AVCOL_SPC_BT470BG,
+AVCOL_SPC_BT709,   AVCOL_SPC_SMPTE170M,
+AVCOL_SPC_SMPTE240M,   AVCOL_SPC_BT2020_NCL,
+AVCOL_SPC_RESERVED,AVCOL_SPC_RGB
+};
 VP9MetadataContext *ctx = bsf->priv_data;
+AVCodecParameters  *par = bsf->par_out;
+
+if (ctx->color_space >= 0 && (par->profile & 1 ||
+  ctx->color_space != VP9_CS_RGB))
+par->color_space = conversion_table[ctx->color_space];
+
+if (par->color_space == AVCOL_SPC_RGB)
+par->color_range = AVCOL_RANGE_JPEG;
+else if (ctx->color_range >= 0)
+par->color_range = ctx->color_range + 1;
 
 return ff_cbs_init(>cbc, AV_CODEC_ID_VP9, bsf);
 }
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 31/31] hevc_metadata: Update AVCodecParameters during init

2019-07-08 Thread Andreas Rheinhardt
This commit makes hevc_metadata update the AVCodecParameters during init
to bring them in line with the changes to the bitstream.

Notice that for field-based HEVC the derived height is the height of a
frame, which deviates from current FFmpeg behaviour.

Signed-off-by: Andreas Rheinhardt 
---
I am unsure about the part about the height of field-based HEVC.

 libavcodec/h265_metadata_bsf.c | 37 --
 1 file changed, 31 insertions(+), 6 deletions(-)

diff --git a/libavcodec/h265_metadata_bsf.c b/libavcodec/h265_metadata_bsf.c
index b3a1fda144..01a955028b 100644
--- a/libavcodec/h265_metadata_bsf.c
+++ b/libavcodec/h265_metadata_bsf.c
@@ -193,8 +193,8 @@ static int h265_metadata_update_vps(AVBSFContext *bsf,
 return 0;
 }
 
-static int h265_metadata_update_sps(AVBSFContext *bsf,
-H265RawSPS *sps)
+static int h265_metadata_update_sps(AVBSFContext *bsf, H265RawSPS *sps,
+int *width, int *height)
 {
 H265MetadataContext *ctx = bsf->priv_data;
 int need_vui = 0;
@@ -328,6 +328,13 @@ static int h265_metadata_update_sps(AVBSFContext *bsf,
 CROP(bottom, crop_unit_y);
 #undef CROP
 
+if (width && height) {
+*width  = sps->pic_width_in_luma_samples  - crop_unit_x *
+  (sps->conf_win_left_offset + sps->conf_win_right_offset);
+*height = (1 + sps->vui.field_seq_flag) * 
(sps->pic_height_in_luma_samples
+- crop_unit_y * (sps->conf_win_top_offset + 
sps->conf_win_bottom_offset));
+}
+
 if (need_vui)
 sps->vui_parameters_present_flag = 1;
 
@@ -412,7 +419,8 @@ static int h265_metadata_filter(AVBSFContext *bsf, AVPacket 
*pkt)
 goto fail;
 }
 if (au->units[i].type == HEVC_NAL_SPS) {
-err = h265_metadata_update_sps(bsf, au->units[i].content);
+err = h265_metadata_update_sps(bsf, au->units[i].content,
+   NULL, NULL);
 if (err < 0)
 goto fail;
 }
@@ -438,7 +446,9 @@ static int h265_metadata_init(AVBSFContext *bsf)
 {
 H265MetadataContext *ctx = bsf->priv_data;
 CodedBitstreamFragment *au = >access_unit;
-int err, i;
+int err, i, width = -1, height = -1, level = ctx->level;
+int color_range = ctx->video_full_range_flag;
+int chroma_location = ctx->chroma_sample_loc_type;
 
 err = ff_cbs_init(>cbc, AV_CODEC_ID_HEVC, bsf);
 if (err < 0)
@@ -451,8 +461,10 @@ static int h265_metadata_init(AVBSFContext *bsf)
 goto fail;
 }
 
-if (ctx->level == LEVEL_AUTO)
+if (ctx->level == LEVEL_AUTO) {
 h265_metadata_guess_level(bsf, au);
+level = ctx->level_guess ? ctx->level_guess : level;
+}
 
 for (i = 0; i < au->nb_units; i++) {
 if (au->units[i].type == HEVC_NAL_VPS) {
@@ -461,7 +473,8 @@ static int h265_metadata_init(AVBSFContext *bsf)
 goto fail;
 }
 if (au->units[i].type == HEVC_NAL_SPS) {
-err = h265_metadata_update_sps(bsf, au->units[i].content);
+err = h265_metadata_update_sps(bsf, au->units[i].content,
+   , );
 if (err < 0)
 goto fail;
 }
@@ -474,6 +487,18 @@ static int h265_metadata_init(AVBSFContext *bsf)
 }
 }
 
+if (color_range >= 0)
+color_range++;
+if (chroma_location >= 0)
+chroma_location++;
+
+ff_cbs_update_video_parameters(ctx->cbc, bsf->par_out, -1, level,
+   width, height, -1, color_range,
+   ctx->colour_primaries,
+   ctx->transfer_characteristics,
+   ctx->matrix_coefficients,
+   chroma_location, -1);
+
 err = 0;
 fail:
 ff_cbs_fragment_reset(ctx->cbc, au);
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avfilter/vf_convolution: add x86 SIMD for filter_3x3()

2019-07-08 Thread Ruiling Song
Tested using a simple command (apply edge enhance):
./ffmpeg_g -i ~/Downloads/bbb_sunflower_1080p_30fps_normal.mp4 \
 -vf convolution="0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 
0 -1 1 0 0 0 0:5:1:1:1:0:128:128:128" \
 -an -vframes 1000 -f null /dev/null

The fps increase from 151 to 270 on my local machine.

Signed-off-by: Ruiling Song 
---
 libavfilter/convolution.h |  64 +++
 libavfilter/vf_convolution.c  |  41 +--
 libavfilter/x86/Makefile  |   2 +
 libavfilter/x86/vf_convolution.asm| 158 ++
 libavfilter/x86/vf_convolution_init.c |  46 
 5 files changed, 273 insertions(+), 38 deletions(-)
 create mode 100644 libavfilter/convolution.h
 create mode 100644 libavfilter/x86/vf_convolution.asm
 create mode 100644 libavfilter/x86/vf_convolution_init.c

diff --git a/libavfilter/convolution.h b/libavfilter/convolution.h
new file mode 100644
index 00..fc6aad58fd
--- /dev/null
+++ b/libavfilter/convolution.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2012-2013 Oka Motofumi (chikuzen.mo at gmail dot com)
+ * Copyright (c) 2015 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef AVFILTER_CONVOLUTION_H
+#define AVFILTER_CONVOLUTION_H
+#include "avfilter.h"
+
+enum MatrixMode {
+MATRIX_SQUARE,
+MATRIX_ROW,
+MATRIX_COLUMN,
+MATRIX_NBMODES,
+};
+
+typedef struct ConvolutionContext {
+const AVClass *class;
+
+char *matrix_str[4];
+float rdiv[4];
+float bias[4];
+int mode[4];
+float scale;
+float delta;
+int planes;
+
+int size[4];
+int depth;
+int max;
+int bpc;
+int nb_planes;
+int nb_threads;
+int planewidth[4];
+int planeheight[4];
+int matrix[4][49];
+int matrix_length[4];
+int copy[4];
+
+void (*setup[4])(int radius, const uint8_t *c[], const uint8_t *src, int 
stride,
+ int x, int width, int y, int height, int bpc);
+void (*filter[4])(uint8_t *dst, int width,
+  float rdiv, float bias, const int *const matrix,
+  const uint8_t *c[], int peak, int radius,
+  int dstride, int stride);
+} ConvolutionContext;
+
+void ff_convolution_init_x86(ConvolutionContext *s);
+#endif
diff --git a/libavfilter/vf_convolution.c b/libavfilter/vf_convolution.c
index 1305569c88..e3bf1df79f 100644
--- a/libavfilter/vf_convolution.c
+++ b/libavfilter/vf_convolution.c
@@ -25,48 +25,11 @@
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
+#include "convolution.h"
 #include "formats.h"
 #include "internal.h"
 #include "video.h"
 
-enum MatrixMode {
-MATRIX_SQUARE,
-MATRIX_ROW,
-MATRIX_COLUMN,
-MATRIX_NBMODES,
-};
-
-typedef struct ConvolutionContext {
-const AVClass *class;
-
-char *matrix_str[4];
-float rdiv[4];
-float bias[4];
-int mode[4];
-float scale;
-float delta;
-int planes;
-
-int size[4];
-int depth;
-int max;
-int bpc;
-int nb_planes;
-int nb_threads;
-int planewidth[4];
-int planeheight[4];
-int matrix[4][49];
-int matrix_length[4];
-int copy[4];
-
-void (*setup[4])(int radius, const uint8_t *c[], const uint8_t *src, int 
stride,
- int x, int width, int y, int height, int bpc);
-void (*filter[4])(uint8_t *dst, int width,
-  float rdiv, float bias, const int *const matrix,
-  const uint8_t *c[], int peak, int radius,
-  int dstride, int stride);
-} ConvolutionContext;
-
 #define OFFSET(x) offsetof(ConvolutionContext, x)
 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
@@ -625,6 +588,8 @@ static int config_input(AVFilterLink *inlink)
 s->filter[p] = filter16_7x7;
 }
 }
+if (ARCH_X86_64)
+ff_convolution_init_x86(s);
 } else if (!strcmp(ctx->filter->name, "prewitt")) {
 if (s->depth > 8)
 for (p = 0; p < s->nb_planes; p++)
diff --git a/libavfilter/x86/Makefile b/libavfilter/x86/Makefile
index 6b0361bed2..8dc0b0e6d4 100644
--- a/libavfilter/x86/Makefile
+++ b/libavfilter/x86/Makefile
@@ -5,6 +5,7 @@ 

[FFmpeg-devel] [PATCH 28/31] vp9_metadata: Improve spec-compliance and warnings

2019-07-08 Thread Andreas Rheinhardt
The earlier version had three deficits:
1. It allowed to set the stream to RGB although this is not allowed when
the profile is 0 or 2.
2. If it set the stream to RGB, then it did not automatically set the
range to full range; the result was that one got a warning every time a
frame with color_config element was processed if the frame originally
had TV range and the user didn't explicitly choose PC range. Now one
gets only one warning in such a situation.
3. Intra-only frames in profile 0 are automatically BT.601, but if the
user wished another color space, he was not informed about his wishes
being unfulfillable.

The commit also improves the documentation about this.

Signed-off-by: Andreas Rheinhardt 
---
 doc/bitstream_filters.texi|  8 ---
 libavcodec/vp9_metadata_bsf.c | 40 ---
 2 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi
index a6a5a331f5..47de4c7116 100644
--- a/doc/bitstream_filters.texi
+++ b/doc/bitstream_filters.texi
@@ -657,7 +657,9 @@ Modify metadata embedded in a VP9 stream.
 
 @table @option
 @item color_space
-Set the color space value in the frame header.
+Set the color space value in the frame header. Note that any frame
+set to RGB will be implicitly set to PC range and that RGB is
+incompatible with profiles 0 and 2.
 @table @samp
 @item unknown
 @item bt601
@@ -669,8 +671,8 @@ Set the color space value in the frame header.
 @end table
 
 @item color_range
-Set the color range value in the frame header.  Note that this cannot
-be set in RGB streams.
+Set the color range value in the frame header. Note that any value
+imposed by the color space will take precedence over this value.
 @table @samp
 @item tv
 @item pc
diff --git a/libavcodec/vp9_metadata_bsf.c b/libavcodec/vp9_metadata_bsf.c
index 1bde1b96aa..52e962b1c0 100644
--- a/libavcodec/vp9_metadata_bsf.c
+++ b/libavcodec/vp9_metadata_bsf.c
@@ -33,7 +33,7 @@ typedef struct VP9MetadataContext {
 int color_space;
 int color_range;
 
-int color_range_rgb_warned;
+int color_warnings;
 } VP9MetadataContext;
 
 
@@ -56,20 +56,36 @@ static int vp9_metadata_filter(AVBSFContext *bsf, AVPacket 
*pkt)
 for (i = 0; i < frag->nb_units; i++) {
 VP9RawFrame *frame = frag->units[i].content;
 VP9RawFrameHeader *header = >header;
+int profile = (header->profile_high_bit << 1) + 
header->profile_low_bit;
+
+if (header->frame_type == VP9_KEY_FRAME ||
+header->intra_only && profile > 0) {
+if (ctx->color_space >= 0) {
+if (!(profile & 1) && ctx->color_space == VP9_CS_RGB) {
+if (!(ctx->color_warnings & 2)) {
+av_log(bsf, AV_LOG_WARNING, "Warning: RGB "
+   "incompatible with profiles 0 and 2.\n");
+ctx->color_warnings |= 2;
+}
+} else
+header->color_space = ctx->color_space;
+}
 
-if (ctx->color_space >= 0) {
-header->color_space = ctx->color_space;
-}
-if (ctx->color_range >= 0) {
-if (ctx->color_range == 0 &&
-header->color_space == VP9_CS_RGB &&
-!ctx->color_range_rgb_warned) {
-av_log(bsf, AV_LOG_WARNING, "Warning: color_range cannot "
-   "be set to limited in RGB streams.\n");
-ctx->color_range_rgb_warned = 1;
-} else {
+if (ctx->color_range >= 0)
 header->color_range = ctx->color_range;
+if (header->color_space == VP9_CS_RGB) {
+if (!(ctx->color_warnings & 1) && !header->color_range) {
+av_log(bsf, AV_LOG_WARNING, "Warning: Color space RGB "
+   "implicitly sets color range to PC range.\n");
+ctx->color_warnings |= 1;
+}
+header->color_range = 1;
 }
+} else if (!(ctx->color_warnings & 4) && header->intra_only && 
!profile &&
+   ctx->color_space >= 0 && ctx->color_space != VP9_CS_BT_601) 
{
+av_log(bsf, AV_LOG_WARNING, "Warning: Intra-only frames in "
+   "profile 0 are automatically BT.601.\n");
+ctx->color_warnings |= 4;
 }
 }
 
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 30/31] h264_metadata: Update AVCodecParameters during init

2019-07-08 Thread Andreas Rheinhardt
This commit makes h264_metadata update the AVCodecParameters during init
to align them with the changes at the bitstream level.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/h264_metadata_bsf.c | 37 +-
 1 file changed, 32 insertions(+), 5 deletions(-)

diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index cbf2025fd4..1dfcee6a31 100644
--- a/libavcodec/h264_metadata_bsf.c
+++ b/libavcodec/h264_metadata_bsf.c
@@ -85,8 +85,8 @@ typedef struct H264MetadataContext {
 } H264MetadataContext;
 
 
-static int h264_metadata_update_sps(AVBSFContext *bsf,
-H264RawSPS *sps)
+static int h264_metadata_update_sps(AVBSFContext *bsf, H264RawSPS *sps,
+int *width, int *height, int *level)
 {
 H264MetadataContext *ctx = bsf->priv_data;
 int need_vui = 0;
@@ -201,6 +201,14 @@ static int h264_metadata_update_sps(AVBSFContext *bsf,
 CROP(bottom, crop_unit_y);
 #undef CROP
 
+if (width && height) {
+*width  = 16 * (sps->pic_width_in_mbs_minus1 + 1) - crop_unit_x *
+  (sps->frame_crop_left_offset + sps->frame_crop_right_offset);
+*height = 16 * (sps->pic_height_in_map_units_minus1 + 1)
+ * (2 - sps->frame_mbs_only_flag) - crop_unit_y *
+  (sps->frame_crop_top_offset + sps->frame_crop_bottom_offset);
+}
+
 if (ctx->level != LEVEL_UNSET) {
 int level_idc;
 
@@ -260,6 +268,9 @@ static int h264_metadata_update_sps(AVBSFContext *bsf,
 } else {
 sps->level_idc = level_idc;
 }
+
+if (level)
+*level = sps->level_idc;
 }
 
 if (need_vui)
@@ -347,7 +358,8 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket 
*pkt)
 has_sps = 0;
 for (i = 0; i < au->nb_units; i++) {
 if (au->units[i].type == H264_NAL_SPS) {
-err = h264_metadata_update_sps(bsf, au->units[i].content);
+err = h264_metadata_update_sps(bsf, au->units[i].content,
+   NULL, NULL, NULL);
 if (err < 0)
 goto fail;
 has_sps = 1;
@@ -571,7 +583,9 @@ static int h264_metadata_init(AVBSFContext *bsf)
 {
 H264MetadataContext *ctx = bsf->priv_data;
 CodedBitstreamFragment *au = >access_unit;
-int err, i;
+int err, i, width = -1, height = -1, level = -1;
+int chroma_location = ctx->chroma_sample_loc_type;
+int color_range = ctx->video_full_range_flag;
 
 err = ff_cbs_init(>cbc, AV_CODEC_ID_H264, bsf);
 if (err < 0)
@@ -586,7 +600,8 @@ static int h264_metadata_init(AVBSFContext *bsf)
 
 for (i = 0; i < au->nb_units; i++) {
 if (au->units[i].type == H264_NAL_SPS) {
-err = h264_metadata_update_sps(bsf, au->units[i].content);
+err = h264_metadata_update_sps(bsf, au->units[i].content,
+   , , );
 if (err < 0)
 goto fail;
 }
@@ -599,6 +614,18 @@ static int h264_metadata_init(AVBSFContext *bsf)
 }
 }
 
+if (color_range >= 0)
+color_range++;
+if (chroma_location >= 0)
+chroma_location++;
+
+ff_cbs_update_video_parameters(ctx->cbc, bsf->par_out, -1, level,
+   width, height, -1, color_range,
+   ctx->colour_primaries,
+   ctx->transfer_characteristics,
+   ctx->matrix_coefficients,
+   chroma_location, -1);
+
 err = 0;
 fail:
 ff_cbs_fragment_reset(ctx->cbc, au);
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 27/31] mpeg2_metadata: Update AVCodecParameters during init

2019-07-08 Thread Andreas Rheinhardt
Otherwise the muxer could add header data that is based on the old
AVCodecParameters that contradicts and potentially nullifies the
modifications made to the bitstream.

This brings mpeg2_metadata in line with what is expected of a bitstream
filter.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpeg2_metadata_bsf.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/mpeg2_metadata_bsf.c b/libavcodec/mpeg2_metadata_bsf.c
index 3f371a028d..458a1f2e61 100644
--- a/libavcodec/mpeg2_metadata_bsf.c
+++ b/libavcodec/mpeg2_metadata_bsf.c
@@ -249,6 +249,11 @@ static int mpeg2_metadata_init(AVBSFContext *bsf)
 }
 }
 
+ff_cbs_update_video_parameters(ctx->cbc, bsf->par_out, -1, -1, -1,
+   -1, -1, -1, ctx->colour_primaries,
+   ctx->transfer_characteristics,
+   ctx->matrix_coefficients, -1, -1);
+
 err = 0;
 fail:
 ff_cbs_fragment_reset(ctx->cbc, frag);
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 26/31] av1_metadata: Update codec parameters

2019-07-08 Thread Andreas Rheinhardt
Up until now, this BSF only changed the bitstream and the extradata,
not the rest of the AVCodecParameters. The result is that e.g. some
muxers use outdated information to write header information that
conflicts with (and potentially precedes) the new information at the
bitstream level, so that using the bitstream filter might not have the
desired effect.

This commit changes this and thereby brings av1_metadata in line with
the expected behaviour for bitstream filters.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/av1_metadata_bsf.c | 32 
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c
index dd0c9b6148..6821a3e102 100644
--- a/libavcodec/av1_metadata_bsf.c
+++ b/libavcodec/av1_metadata_bsf.c
@@ -52,7 +52,9 @@ typedef struct AV1MetadataContext {
 
 
 static int av1_metadata_update_sequence_header(AVBSFContext *bsf,
-   AV1RawSequenceHeader *seq)
+   AV1RawSequenceHeader *seq,
+   int *color_range,
+   int *chroma_sample_position)
 {
 AV1MetadataContext *ctx = bsf->priv_data;
 AV1RawColorConfig  *clc = >color_config;
@@ -79,6 +81,8 @@ static int av1_metadata_update_sequence_header(AVBSFContext 
*bsf,
"on RGB streams encoded in BT.709 sRGB.\n");
 } else {
 clc->color_range = ctx->color_range;
+if (color_range)
+*color_range = ctx->color_range + 1;
 }
 }
 
@@ -88,6 +92,8 @@ static int av1_metadata_update_sequence_header(AVBSFContext 
*bsf,
"can only be set for 4:2:0 streams.\n");
 } else {
 clc->chroma_sample_position = ctx->chroma_sample_position;
+if (chroma_sample_position)
+*chroma_sample_position = ctx->chroma_sample_position;
 }
 }
 
@@ -137,7 +143,8 @@ static int av1_metadata_filter(AVBSFContext *bsf, AVPacket 
*pkt)
 for (i = 0; i < frag->nb_units; i++) {
 if (frag->units[i].type == AV1_OBU_SEQUENCE_HEADER) {
 obu = frag->units[i].content;
-err = av1_metadata_update_sequence_header(bsf, 
>obu.sequence_header);
+err = av1_metadata_update_sequence_header(bsf, 
>obu.sequence_header,
+  NULL, NULL);
 if (err < 0)
 goto fail;
 }
@@ -188,7 +195,7 @@ static int av1_metadata_init(AVBSFContext *bsf)
 AV1MetadataContext *ctx = bsf->priv_data;
 CodedBitstreamFragment *frag = >access_unit;
 AV1RawOBU *obu;
-int err, i;
+int err, i, color_range = -1, chroma_sample_position = -1;
 
 err = ff_cbs_init(>cbc, AV_CODEC_ID_AV1, bsf);
 if (err < 0)
@@ -204,7 +211,8 @@ static int av1_metadata_init(AVBSFContext *bsf)
 for (i = 0; i < frag->nb_units; i++) {
 if (frag->units[i].type == AV1_OBU_SEQUENCE_HEADER) {
 obu = frag->units[i].content;
-err = av1_metadata_update_sequence_header(bsf, 
>obu.sequence_header);
+err = av1_metadata_update_sequence_header(bsf, 
>obu.sequence_header,
+  _range, 
_sample_position);
 if (err < 0)
 goto fail;
 }
@@ -217,6 +225,22 @@ static int av1_metadata_init(AVBSFContext *bsf)
 }
 }
 
+if (chroma_sample_position >= 0) {
+static const uint8_t conversion_table[4] = {
+AVCHROMA_LOC_UNSPECIFIED,
+AVCHROMA_LOC_LEFT,
+AVCHROMA_LOC_TOPLEFT,
+AVCHROMA_LOC_UNSPECIFIED
+};
+chroma_sample_position = conversion_table[chroma_sample_position];
+}
+
+ff_cbs_update_video_parameters(ctx->cbc, bsf->par_out, -1, -1, -1, -1,
+   -1, color_range, ctx->color_primaries,
+   ctx->transfer_characteristics,
+   ctx->matrix_coefficients,
+   chroma_sample_position, -1);
+
 err = 0;
 fail:
 ff_cbs_fragment_reset(ctx->cbc, frag);
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] configure, cbs_h2645: Remove unneeded golomb dependency

2019-07-08 Thread Mark Thompson
On 08/07/2019 17:38, Andreas Rheinhardt wrote:
> This has been forgotten in 44cde38c.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  configure  | 4 ++--
>  libavcodec/cbs_h2645.c | 1 -
>  2 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/configure b/configure
> index 7cea9d4d73..4005987409 100755
> --- a/configure
> +++ b/configure
> @@ -2586,8 +2586,8 @@ threads_if_any="$THREADS_LIST"
>  
>  # subsystems
>  cbs_av1_select="cbs"
> -cbs_h264_select="cbs golomb"
> -cbs_h265_select="cbs golomb"
> +cbs_h264_select="cbs"
> +cbs_h265_select="cbs"
>  cbs_jpeg_select="cbs"
>  cbs_mpeg2_select="cbs"
>  cbs_vp9_select="cbs"
> diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
> index 0456937710..81d8fc0d66 100644
> --- a/libavcodec/cbs_h2645.c
> +++ b/libavcodec/cbs_h2645.c
> @@ -24,7 +24,6 @@
>  #include "cbs_internal.h"
>  #include "cbs_h264.h"
>  #include "cbs_h265.h"
> -#include "golomb.h"
>  #include "h264.h"
>  #include "h264_sei.h"
>  #include "h2645_parse.h"

Yep, applied.

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 12/12] cbs_h264, h264_metadata: Deleting SEI messages never fails

2019-07-08 Thread Mark Thompson
On 08/07/2019 00:14, Andreas Rheinhardt wrote:
> ff_cbs_delete_unit never fails if the index of the unit to delete is
> valid, as it is with all current callers of the function. So just assert
> in ff_cbs_delete_unit that the index is valid and change the return
> value to void in order to remove the callers' checks for whether
> ff_cbs_delete_unit failed.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/av1_metadata_bsf.c   |  9 ++---
>  libavcodec/cbs.c| 12 +---
>  libavcodec/cbs.h|  8 +---
>  libavcodec/cbs_h2645.c  |  6 +++---
>  libavcodec/h264_metadata_bsf.c  |  8 +---
>  libavcodec/h264_redundant_pps_bsf.c |  4 +---
>  6 files changed, 17 insertions(+), 30 deletions(-)
> 
On 08/07/2019 00:14, Andreas Rheinhardt wrote:
> Given the recent changes to ff_cbs_delete_unit, it is no longer sensible
> to use a return value for ff_cbs_h264_delete_sei_message; instead, use
> asserts to ensure that the required conditions are met and remove the
> callers' checks for the return value. Also, document said conditions.
> 
> An assert that is essentially equivalent to the one used in
> ff_cbs_delete_unit has been removed, too.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/cbs_h264.h  | 11 +++
>  libavcodec/cbs_h2645.c | 11 ---
>  libavcodec/h264_metadata_bsf.c | 21 +
>  3 files changed, 16 insertions(+), 27 deletions(-)

LGTM; both applied.

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v3] libavcodec/vp9: fix ref-frame size judging method

2019-07-08 Thread Yan Cen
From: yancen 

There is no need all reference frame demension is valid in libvpx.

So this change contains three part:
1. Change each judgement's loglevel from "ERROR" to "WARNING"
2. Make sure at least one of frames that this frame references has valid 
dimension.
3. All judgements fail would report "ERROR".

Signed-off-by: Xiang Haihao 
Signed-off-by: Li Zhong 
Signed-off-by: Yan Cen 
---
 libavcodec/vp9.c | 51 +++
 1 file changed, 43 insertions(+), 8 deletions(-)

diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index acf3ffc..58e7312 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -555,11 +555,37 @@ static int decode_frame_header(AVCodecContext *avctx,
 s->s.h.signbias[1]= get_bits1(>gb) && !s->s.h.errorres;
 s->s.h.refidx[2]  = get_bits(>gb, 3);
 s->s.h.signbias[2]= get_bits1(>gb) && !s->s.h.errorres;
-if (!s->s.refs[s->s.h.refidx[0]].f->buf[0] ||
-!s->s.refs[s->s.h.refidx[1]].f->buf[0] ||
-!s->s.refs[s->s.h.refidx[2]].f->buf[0]) {
-av_log(avctx, AV_LOG_ERROR, "Not all references are 
available\n");
-return AVERROR_INVALIDDATA;
+if (0 == sizeof(s->s.refs[s->s.h.refidx[0]])) {
+if (0 == sizeof(s->s.refs[s->s.h.refidx[1]].f->buf[0])) {
+if (0 == s->s.refs[s->s.h.refidx[2]].f->buf[0]) {
+av_log(avctx, AV_LOG_ERROR, "All references are 
unavailable\n");
+return AVERROR_INVALIDDATA;
+} else {
+
av_frame_copy(s->s.refs[s->s.h.refidx[1]].f,s->s.refs[s->s.h.refidx[2]].f);
+
av_frame_copy(s->s.refs[s->s.h.refidx[0]].f,s->s.refs[s->s.h.refidx[2]].f);
+}
+} else {
+if (0 == sizeof(s->s.refs[s->s.h.refidx[2]].f->buf[0])) {
+
av_frame_copy(s->s.refs[s->s.h.refidx[0]].f,s->s.refs[s->s.h.refidx[1]].f);
+
av_frame_copy(s->s.refs[s->s.h.refidx[2]].f,s->s.refs[s->s.h.refidx[1]].f);
+} else {
+
av_frame_copy(s->s.refs[s->s.h.refidx[0]].f,s->s.refs[s->s.h.refidx[1]].f);
+}
+}
+} else {
+if (0 == sizeof(s->s.refs[s->s.h.refidx[1]].f->buf[0])) {
+if (0 == sizeof(s->s.refs[s->s.h.refidx[2]].f->buf[0])) {
+s->s.refs[s->s.h.refidx[1]].f = 
s->s.refs[s->s.h.refidx[2]].f = s->s.refs[s->s.h.refidx[0]].f;
+
av_frame_copy(s->s.refs[s->s.h.refidx[1]].f,s->s.refs[s->s.h.refidx[0]].f);
+
av_frame_copy(s->s.refs[s->s.h.refidx[2]].f,s->s.refs[s->s.h.refidx[0]].f);
+} else {
+
av_frame_copy(s->s.refs[s->s.h.refidx[1]].f,s->s.refs[s->s.h.refidx[0]].f);
+}
+} else {
+if (0 == sizeof(s->s.refs[s->s.h.refidx[2]].f->buf[0])) {
+
av_frame_copy(s->s.refs[s->s.h.refidx[2]].f,s->s.refs[s->s.h.refidx[1]].f);
+}
+}
 }
 if (get_bits1(>gb)) {
 w = s->s.refs[s->s.h.refidx[0]].f->width;
@@ -790,6 +816,7 @@ static int decode_frame_header(AVCodecContext *avctx,
 
 /* check reference frames */
 if (!s->s.h.keyframe && !s->s.h.intraonly) {
+int has_valid_ref_frame = 0;
 for (i = 0; i < 3; i++) {
 AVFrame *ref = s->s.refs[s->s.h.refidx[i]].f;
 int refw = ref->width, refh = ref->height;
@@ -802,12 +829,15 @@ static int decode_frame_header(AVCodecContext *avctx,
 return AVERROR_INVALIDDATA;
 } else if (refw == w && refh == h) {
 s->mvscale[i][0] = s->mvscale[i][1] = 0;
+has_valid_ref_frame = 1;
 } else {
-if (w * 2 < refw || h * 2 < refh || w > 16 * refw || h > 16 * 
refh) {
-av_log(avctx, AV_LOG_ERROR,
+int is_ref_frame_invalid = (w * 2 < refw || h * 2 < refh || w 
> 16 * refw || h > 16 * refh);
+if (is_ref_frame_invalid) {
+av_log(avctx, AV_LOG_WARNING,
"Invalid ref frame dimensions %dx%d for frame size 
%dx%d\n",
refw, refh, w, h);
-return AVERROR_INVALIDDATA;
+} else {
+has_valid_ref_frame = 1;
 }
 s->mvscale[i][0] = (refw << 14) / w;
 s->mvscale[i][1] = (refh << 14) / h;
@@ -815,6 +845,11 @@ static int decode_frame_header(AVCodecContext *avctx,
 s->mvstep[i][1] = 16 * s->mvscale[i][1] >> 14;
 }
 }
+if (!has_valid_ref_frame) {
+av_log(avctx, AV_LOG_ERROR,
+   "Referenced frame has invalid 

Re: [FFmpeg-devel] [PATCH 0/4] lavd/avfoundation: Support muxed device types

2019-07-08 Thread Thilo Borgmann
Am 04.07.19 um 16:28 schrieb Thilo Borgmann:
> Am 30.06.19 um 14:11 schrieb Thilo Borgmann:
>> Hi,
>>
>> some cleanup and $SUBJECT.
>>
>> Documentation and reindent follows afterwards.
> 
> Will add docs and push with remarks from Moritz soonish - if there are no 
> more comments coming in.

Pushed.

-Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] set AVFrame decode_error_flags in case of decoding error by h264dec

2019-07-08 Thread Amir Z
Thanks

On Sun, Jul 7, 2019 at 3:38 PM Michael Niedermayer 
wrote:

> On Fri, Jun 21, 2019 at 07:15:17AM -0700, Amir Pauker wrote:
> > set AVFrame decode_error_flags in case h->slice_ctx->er.error_occurred
> is set
> > after the call to ff_h264_execute_decode_slices. This allows the user to
> detect
> > concealed decoding errors in the call to avcodec_receive_frame
> >
> > Signed-off-by: Amir Pauker 
> > ---
> >  libavcodec/error_resilience.c | 2 ++
> >  libavcodec/h264dec.c  | 5 +
> >  2 files changed, 7 insertions(+)
> >
> > diff --git a/libavcodec/error_resilience.c
> b/libavcodec/error_resilience.c
> > index 35d0c60..ca22871 100644
> > --- a/libavcodec/error_resilience.c
> > +++ b/libavcodec/error_resilience.c
> > @@ -1121,6 +1121,8 @@ void ff_er_frame_end(ERContext *s)
> >  av_log(s->avctx, AV_LOG_INFO, "concealing %d DC, %d AC, %d MV
> errors in %c frame\n",
> > dc_error, ac_error, mv_error,
> av_get_picture_type_char(s->cur_pic.f->pict_type));
> >
> > +s->cur_pic.f->decode_error_flags |=
> FF_DECODE_ERROR_CONCEALMENT_ACTIVE;
> > +
> >  is_intra_likely = is_intra_more_likely(s);
> >
> >  /* set unknown mb-type to most likely */
> > diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
> > index 837c3b7..8d1bd16 100644
> > --- a/libavcodec/h264dec.c
> > +++ b/libavcodec/h264dec.c
> > @@ -761,6 +761,11 @@ static int decode_nal_units(H264Context *h, const
> uint8_t *buf, int buf_size)
> >  if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
> >  goto end;
> >
> > +// set decode_error_flags to allow users to detect concealed
> decoding errors
> > +if ((ret < 0 || h->slice_ctx->er.error_occurred) && h->cur_pic_ptr)
> {
> > +h->cur_pic_ptr->f->decode_error_flags |=
> FF_DECODE_ERROR_DECODE_SLICES;
> > +}
> > +
> >  ret = 0;
> >  end:
>
> will split and apply
>
> thx
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Whats the most studid thing your enemy could do ? Blow himself up
> Whats the most studid thing you could do ? Give up your rights and
> freedom because your enemy blew himself up.
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] configure, cbs_h2645: Remove unneeded golomb dependency

2019-07-08 Thread Andreas Rheinhardt
This has been forgotten in 44cde38c.

Signed-off-by: Andreas Rheinhardt 
---
 configure  | 4 ++--
 libavcodec/cbs_h2645.c | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 7cea9d4d73..4005987409 100755
--- a/configure
+++ b/configure
@@ -2586,8 +2586,8 @@ threads_if_any="$THREADS_LIST"
 
 # subsystems
 cbs_av1_select="cbs"
-cbs_h264_select="cbs golomb"
-cbs_h265_select="cbs golomb"
+cbs_h264_select="cbs"
+cbs_h265_select="cbs"
 cbs_jpeg_select="cbs"
 cbs_mpeg2_select="cbs"
 cbs_vp9_select="cbs"
diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 0456937710..81d8fc0d66 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -24,7 +24,6 @@
 #include "cbs_internal.h"
 #include "cbs_h264.h"
 #include "cbs_h265.h"
-#include "golomb.h"
 #include "h264.h"
 #include "h264_sei.h"
 #include "h2645_parse.h"
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avcodec/audiotoolboxdec: Fix decoding 24 Bit ALAC

2019-07-08 Thread Davis
"avctx->bits_per_raw_sample" always returns 0.
Tested with 24 Bit ALAC. The result is bit-perfect.
Fix #7287.
---
 libavcodec/audiotoolboxdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c
index 5c0a9de8f6..95bf9acc42 100644
--- a/libavcodec/audiotoolboxdec.c
+++ b/libavcodec/audiotoolboxdec.c
@@ -302,7 +302,7 @@ static av_cold int ffat_create_decoder(AVCodecContext 
*avctx, AVPacket *pkt)
 OSStatus status;
 int i;
 
-enum AVSampleFormat sample_fmt = (avctx->bits_per_raw_sample == 32) ?
+enum AVSampleFormat sample_fmt = (avctx->bits_per_coded_sample > 16) ?
  AV_SAMPLE_FMT_S32 : AV_SAMPLE_FMT_S16;
 
 AudioStreamBasicDescription in_format = {
-- 
2.20.1 (Apple Git-117)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] libavfilter/vf_scale: Ensure scaled video is divisible by n

2019-07-08 Thread Lars Kiesow
This patch adds a new option to the scale filter which ensures that the
output resolution is divisible by the given integer when used together
with `force_original_aspect_ratio`. This works similar to using `-n` in
the `w` and `h` options.

This option respects the value set for `force_original_aspect_ratio`,
increasing or decreasing the resolution accordingly.

The use case for this is to set a fixed target resolution using `w` and
`h`, to use the `force_original_aspect_ratio` option to make sure that
the video always fits in the defined bounding box regardless of aspect
ratio, but to also make sure that the calculated output resolution is
divisible by n so in can be encoded with certain encoders/options if
that is required.

Signed-off-by: Lars Kiesow 
---
 doc/filters.texi   | 12 
 libavfilter/vf_scale.c | 13 -
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index ee6a93ffbf..2de71d9820 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -15231,6 +15231,18 @@ Please note that this is a different thing than 
specifying -1 for @option{w}
 or @option{h}, you still need to specify the output resolution for this option
 to work.
 
+@item force_divisible_by Ensures that the output resolution is divisible by the
+given integer when used together with @option{force_original_aspect_ratio}. 
This
+works similar to using -n in the @option{w} and @option{h} options.
+
+This option respects the value set for @option{force_original_aspect_ratio},
+increasing or decreasing the resolution accordingly. This may slightly modify
+the video's aspect ration.
+
+This can be handy, for example, if you want to have a video fit within a 
defined
+resolution using the @option{force_original_aspect_ratio} option but have
+encoder restrictions when it comes to width or height.
+
 @end table
 
 The values of the @option{w} and @option{h} options are expressions
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 7aebf56ad8..3ce6cdd1d5 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -86,6 +86,7 @@ typedef struct ScaleContext {
 int in_v_chr_pos;
 
 int force_original_aspect_ratio;
+int force_divisible_by;
 
 int nb_slices;
 
@@ -237,7 +238,8 @@ static int config_props(AVFilterLink *outlink)
 goto fail;
 
 /* Note that force_original_aspect_ratio may overwrite the previous set
- * dimensions so that it is not divisible by the set factors anymore. */
+ * dimensions so that it is not divisible by the set factors anymore
+ * unless force_divisible_by is defined as well */
 if (scale->force_original_aspect_ratio) {
 int tmp_w = av_rescale(h, inlink->w, inlink->h);
 int tmp_h = av_rescale(w, inlink->h, inlink->w);
@@ -245,9 +247,17 @@ static int config_props(AVFilterLink *outlink)
 if (scale->force_original_aspect_ratio == 1) {
  w = FFMIN(tmp_w, w);
  h = FFMIN(tmp_h, h);
+ if (scale->force_divisible_by > 1) {
+ w = w / scale->force_divisible_by * scale->force_divisible_by;
+ h = h / scale->force_divisible_by * scale->force_divisible_by;
+ }
 } else {
  w = FFMAX(tmp_w, w);
  h = FFMAX(tmp_h, h);
+ if (scale->force_divisible_by > 1) {
+ w = ceil(w / (float)scale->force_divisible_by) * 
scale->force_divisible_by;
+ h = ceil(h / (float)scale->force_divisible_by) * 
scale->force_divisible_by;
+ }
 }
 }
 
@@ -600,6 +610,7 @@ static const AVOption scale_options[] = {
 { "disable",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, FLAGS, 
"force_oar" },
 { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, FLAGS, 
"force_oar" },
 { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2 }, 0, 0, FLAGS, 
"force_oar" },
+{ "force_divisible_by", "enforce that the output resolution is divisible 
by a defined integer when force_original_aspect_ratio is used", 
OFFSET(force_divisible_by), AV_OPT_TYPE_INT, { .i64 = 1}, 1, 256, FLAGS },
 { "param0", "Scaler param 0", OFFSET(param[0]),  
AV_OPT_TYPE_DOUBLE, { .dbl = SWS_PARAM_DEFAULT  }, INT_MIN, INT_MAX, FLAGS },
 { "param1", "Scaler param 1", OFFSET(param[1]),  
AV_OPT_TYPE_DOUBLE, { .dbl = SWS_PARAM_DEFAULT  }, INT_MIN, INT_MAX, FLAGS },
 { "nb_slices", "set the number of slices (debug purpose only)", 
OFFSET(nb_slices), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS },
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] Ensure scaled video is divisible by n

2019-07-08 Thread Lars Kiesow
Hi Michael,

> commit message should begin with a prefix like 
> avfilter/vf_scale: ...

Thanks for the hint. Will use that.

> what does this feature have to do with force_original_aspect_ratio ?
> i think it should not be under this if()

This really only makes sense when using force_original_aspect_ratio
since otherwise, you could just use something like scale=320:-2. The
force_original_aspect_ratio option is great to have a video fit within
a given maximum size but unfortunately, this may cause encoder issues
due to the resulting size.

But I guess that my documentation for this option wasn't the best. I'll
improve that so that it will hopefully become clear what the new option
is meant for.

> also the rounding is always down, it probably should be rounding to
> closest (for n=2 it doesnt matter but for larger divisibility like 16
> rounding down by 15 instead of rounding up by 1 seems not ideal

Good point. Thinking about this again, since I'm coupling this with
force_original_aspect_ratio anyway, it would definitely make sense to
have this comply to the `increase` or `decrease` options of that
setting, rounding up if `increase` is set, rounding down if `decrease`
is set.

I will update the code accordingly and send out a new patch in a moment.

Best regards,
Lars
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] lavf/vf_stack: add keep_dar option for vstack and hstack

2019-07-08 Thread Limin Wang
On Mon, Jul 08, 2019 at 01:52:16PM +0200, Moritz Barsnick wrote:
> On Mon, Jul 08, 2019 at 18:48:46 +0800, lance.lmw...@gmail.com wrote:
> > +@item keep_dar
> > +stack with 1/nb_inputs of each inputs screen to keep the same DAR, Default 
> > is 0.
>   ^
> Probably "input's". Is screen the correct term here at all? (In three
> places in the patch.)
> 
> > +{ "keep_dar", "stack with 1/nb_inputs of each inputs screen to keep 
> > the same DAR", OFFSET(keep_dar), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, .flags = 
> > FLAGS },
> 
> AV_OPT_TYPE_BOOL
> 
Yes, I'll update for my local, thank for the review.

> Not sure about the actual implementation, can't judge.
> 
> Cheers,
> Moritz
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] lavf/vf_stack: add keep_dar option for vstack and hstack

2019-07-08 Thread Paul B Mahol
>>
>> Keep DAR of which input i.e. what if the inputs have different DARs?
>
> I'm using it for comparing two same video quality, it's not general
> for all condition anyway.
>
>>
>> The user can already emulate this by cropping inputs befoehand.
> Yes, we can use the crop filter to get the same function, however the
> command line isn't very direct to use and difficult to recall.

Write scripts then.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] lavf/vf_stack: add keep_dar option for vstack and hstack

2019-07-08 Thread Limin Wang
On Mon, Jul 08, 2019 at 05:44:06PM +0530, Gyan wrote:
> 
> 
> On 08-07-2019 04:18 PM, lance.lmw...@gmail.com wrote:
> >From: Limin Wang 
> >
> >It's useful to compare two 4K videos quality side by side on 4K TV.
> >
> >Signed-off-by: Limin Wang 
> >---
> >  doc/filters.texi   |  6 ++
> >  libavfilter/vf_stack.c | 31 ++-
> >  2 files changed, 32 insertions(+), 5 deletions(-)
> >
> >diff --git a/doc/filters.texi b/doc/filters.texi
> >index ee6a93ffbf..675b02fc34 100644
> >--- a/doc/filters.texi
> >+++ b/doc/filters.texi
> >@@ -11280,6 +11280,9 @@ The filter accept the following option:
> >  @item inputs
> >  Set number of input streams. Default is 2.
> >+@item keep_dar
> >+stack with 1/nb_inputs of each inputs screen to keep the same DAR, Default 
> >is 0.
> >+
> >  @item shortest
> >  If set to 1, force the output to terminate when the shortest input
> >  terminates. Default value is 0.
> >@@ -18333,6 +18336,9 @@ The filter accept the following option:
> >  @item inputs
> >  Set number of input streams. Default is 2.
> >+@item keep_dar
> >+stack with 1/nb_inputs of each inputs screen to keep the same DAR, Default 
> >is 0.
> >+
> >  @item shortest
> >  If set to 1, force the output to terminate when the shortest input
> >  terminates. Default value is 0.
> >diff --git a/libavfilter/vf_stack.c b/libavfilter/vf_stack.c
> >index 4d254e0013..9196b5b0b7 100644
> >--- a/libavfilter/vf_stack.c
> >+++ b/libavfilter/vf_stack.c
> >@@ -44,6 +44,7 @@ typedef struct StackContext {
> >  int is_vertical;
> >  int is_horizontal;
> >  int nb_planes;
> >+int keep_dar;
> >  StackItem *items;
> >  AVFrame **frames;
> >@@ -123,7 +124,7 @@ static int process_frame(FFFrameSync *fs)
> >  StackContext *s = fs->opaque;
> >  AVFrame **in = s->frames;
> >  AVFrame *out;
> >-int i, p, ret, offset[4] = { 0 };
> >+int i, p, ret, offset[4] = { 0 }, in_offset[4] = { 0 };
> >  for (i = 0; i < s->nb_inputs; i++) {
> >  if ((ret = ff_framesync_get_frame(>fs, i, [i], 0)) < 0)
> >@@ -153,16 +154,25 @@ static int process_frame(FFFrameSync *fs)
> >  for (p = 0; p < s->nb_planes; p++) {
> >  if (s->is_vertical) {
> >+if (s->keep_dar) {
> >+height[p] /= s->nb_inputs;
> >+in_offset[p] = i * height[p] * in[i]->linesize[p];
> >+}
> >+
> >  av_image_copy_plane(out->data[p] + offset[p] * 
> > out->linesize[p],
> >  out->linesize[p],
> >-in[i]->data[p],
> >+in[i]->data[p] + in_offset[p],
> >  in[i]->linesize[p],
> >  linesize[p], height[p]);
> >  offset[p] += height[p];
> >  } else if (s->is_horizontal) {
> >+if (s->keep_dar) {
> >+linesize[p] /= s->nb_inputs;
> >+in_offset[p] = i * in[i]->linesize[p] / s->nb_inputs;
> >+}
> >  av_image_copy_plane(out->data[p] + offset[p],
> >  out->linesize[p],
> >-in[i]->data[p],
> >+in[i]->data[p] + in_offset[p],
> >  in[i]->linesize[p],
> >  linesize[p], height[p]);
> >  offset[p] += linesize[p];
> >@@ -197,20 +207,30 @@ static int config_output(AVFilterLink *outlink)
> >  return AVERROR_BUG;
> >  if (s->is_vertical) {
> >+if (s->keep_dar)
> >+height /= s->nb_inputs;
> >  for (i = 1; i < s->nb_inputs; i++) {
> >  if (ctx->inputs[i]->w != width) {
> >  av_log(ctx, AV_LOG_ERROR, "Input %d width %d does not 
> > match input %d width %d.\n", i, ctx->inputs[i]->w, 0, width);
> >  return AVERROR(EINVAL);
> >  }
> >-height += ctx->inputs[i]->h;
> >+if (!s->keep_dar)
> >+height += ctx->inputs[i]->h;
> >+else
> >+height += ctx->inputs[i]->h / s->nb_inputs;
> >  }
> >  } else if (s->is_horizontal) {
> >+if (s->keep_dar)
> >+width /= s->nb_inputs;
> >  for (i = 1; i < s->nb_inputs; i++) {
> >  if (ctx->inputs[i]->h != height) {
> >  av_log(ctx, AV_LOG_ERROR, "Input %d height %d does not 
> > match input %d height %d.\n", i, ctx->inputs[i]->h, 0, height);
> >  return AVERROR(EINVAL);
> >  }
> >-width += ctx->inputs[i]->w;
> >+if (!s->keep_dar)
> >+width += ctx->inputs[i]->w;
> >+else
> >+width += ctx->inputs[i]->w / s->nb_inputs;
> >  }
> >  } else {
> >  char *arg, *p = s->layout, *saveptr = NULL;
> >@@ 

Re: [FFmpeg-devel] [PATCH] lavf/vf_stack: add keep_dar option for vstack and hstack

2019-07-08 Thread Paul B Mahol
Not acceptable patch.

Please do not merge.

On 7/8/19, lance.lmw...@gmail.com  wrote:
> From: Limin Wang 
>
> It's useful to compare two 4K videos quality side by side on 4K TV.
>
> Signed-off-by: Limin Wang 
> ---
>  doc/filters.texi   |  6 ++
>  libavfilter/vf_stack.c | 31 ++-
>  2 files changed, 32 insertions(+), 5 deletions(-)
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index ee6a93ffbf..675b02fc34 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -11280,6 +11280,9 @@ The filter accept the following option:
>  @item inputs
>  Set number of input streams. Default is 2.
>
> +@item keep_dar
> +stack with 1/nb_inputs of each inputs screen to keep the same DAR, Default
> is 0.
> +
>  @item shortest
>  If set to 1, force the output to terminate when the shortest input
>  terminates. Default value is 0.
> @@ -18333,6 +18336,9 @@ The filter accept the following option:
>  @item inputs
>  Set number of input streams. Default is 2.
>
> +@item keep_dar
> +stack with 1/nb_inputs of each inputs screen to keep the same DAR, Default
> is 0.
> +
>  @item shortest
>  If set to 1, force the output to terminate when the shortest input
>  terminates. Default value is 0.
> diff --git a/libavfilter/vf_stack.c b/libavfilter/vf_stack.c
> index 4d254e0013..9196b5b0b7 100644
> --- a/libavfilter/vf_stack.c
> +++ b/libavfilter/vf_stack.c
> @@ -44,6 +44,7 @@ typedef struct StackContext {
>  int is_vertical;
>  int is_horizontal;
>  int nb_planes;
> +int keep_dar;
>
>  StackItem *items;
>  AVFrame **frames;
> @@ -123,7 +124,7 @@ static int process_frame(FFFrameSync *fs)
>  StackContext *s = fs->opaque;
>  AVFrame **in = s->frames;
>  AVFrame *out;
> -int i, p, ret, offset[4] = { 0 };
> +int i, p, ret, offset[4] = { 0 }, in_offset[4] = { 0 };
>
>  for (i = 0; i < s->nb_inputs; i++) {
>  if ((ret = ff_framesync_get_frame(>fs, i, [i], 0)) < 0)
> @@ -153,16 +154,25 @@ static int process_frame(FFFrameSync *fs)
>
>  for (p = 0; p < s->nb_planes; p++) {
>  if (s->is_vertical) {
> +if (s->keep_dar) {
> +height[p] /= s->nb_inputs;
> +in_offset[p] = i * height[p] * in[i]->linesize[p];
> +}
> +
>  av_image_copy_plane(out->data[p] + offset[p] *
> out->linesize[p],
>  out->linesize[p],
> -in[i]->data[p],
> +in[i]->data[p] + in_offset[p],
>  in[i]->linesize[p],
>  linesize[p], height[p]);
>  offset[p] += height[p];
>  } else if (s->is_horizontal) {
> +if (s->keep_dar) {
> +linesize[p] /= s->nb_inputs;
> +in_offset[p] = i * in[i]->linesize[p] / s->nb_inputs;
> +}
>  av_image_copy_plane(out->data[p] + offset[p],
>  out->linesize[p],
> -in[i]->data[p],
> +in[i]->data[p] + in_offset[p],
>  in[i]->linesize[p],
>  linesize[p], height[p]);
>  offset[p] += linesize[p];
> @@ -197,20 +207,30 @@ static int config_output(AVFilterLink *outlink)
>  return AVERROR_BUG;
>
>  if (s->is_vertical) {
> +if (s->keep_dar)
> +height /= s->nb_inputs;
>  for (i = 1; i < s->nb_inputs; i++) {
>  if (ctx->inputs[i]->w != width) {
>  av_log(ctx, AV_LOG_ERROR, "Input %d width %d does not match
> input %d width %d.\n", i, ctx->inputs[i]->w, 0, width);
>  return AVERROR(EINVAL);
>  }
> -height += ctx->inputs[i]->h;
> +if (!s->keep_dar)
> +height += ctx->inputs[i]->h;
> +else
> +height += ctx->inputs[i]->h / s->nb_inputs;
>  }
>  } else if (s->is_horizontal) {
> +if (s->keep_dar)
> +width /= s->nb_inputs;
>  for (i = 1; i < s->nb_inputs; i++) {
>  if (ctx->inputs[i]->h != height) {
>  av_log(ctx, AV_LOG_ERROR, "Input %d height %d does not
> match input %d height %d.\n", i, ctx->inputs[i]->h, 0, height);
>  return AVERROR(EINVAL);
>  }
> -width += ctx->inputs[i]->w;
> +if (!s->keep_dar)
> +width += ctx->inputs[i]->w;
> +else
> +width += ctx->inputs[i]->w / s->nb_inputs;
>  }
>  } else {
>  char *arg, *p = s->layout, *saveptr = NULL;
> @@ -339,6 +359,7 @@ static int activate(AVFilterContext *ctx)
>  #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
>  static const AVOption stack_options[] = {
>  { "inputs", "set 

Re: [FFmpeg-devel] [PATCH] lavf/vf_stack: add keep_dar option for vstack and hstack

2019-07-08 Thread Gyan



On 08-07-2019 04:18 PM, lance.lmw...@gmail.com wrote:

From: Limin Wang 

It's useful to compare two 4K videos quality side by side on 4K TV.

Signed-off-by: Limin Wang 
---
  doc/filters.texi   |  6 ++
  libavfilter/vf_stack.c | 31 ++-
  2 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index ee6a93ffbf..675b02fc34 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -11280,6 +11280,9 @@ The filter accept the following option:
  @item inputs
  Set number of input streams. Default is 2.
  
+@item keep_dar

+stack with 1/nb_inputs of each inputs screen to keep the same DAR, Default is 
0.
+
  @item shortest
  If set to 1, force the output to terminate when the shortest input
  terminates. Default value is 0.
@@ -18333,6 +18336,9 @@ The filter accept the following option:
  @item inputs
  Set number of input streams. Default is 2.
  
+@item keep_dar

+stack with 1/nb_inputs of each inputs screen to keep the same DAR, Default is 
0.
+
  @item shortest
  If set to 1, force the output to terminate when the shortest input
  terminates. Default value is 0.
diff --git a/libavfilter/vf_stack.c b/libavfilter/vf_stack.c
index 4d254e0013..9196b5b0b7 100644
--- a/libavfilter/vf_stack.c
+++ b/libavfilter/vf_stack.c
@@ -44,6 +44,7 @@ typedef struct StackContext {
  int is_vertical;
  int is_horizontal;
  int nb_planes;
+int keep_dar;
  
  StackItem *items;

  AVFrame **frames;
@@ -123,7 +124,7 @@ static int process_frame(FFFrameSync *fs)
  StackContext *s = fs->opaque;
  AVFrame **in = s->frames;
  AVFrame *out;
-int i, p, ret, offset[4] = { 0 };
+int i, p, ret, offset[4] = { 0 }, in_offset[4] = { 0 };
  
  for (i = 0; i < s->nb_inputs; i++) {

  if ((ret = ff_framesync_get_frame(>fs, i, [i], 0)) < 0)
@@ -153,16 +154,25 @@ static int process_frame(FFFrameSync *fs)
  
  for (p = 0; p < s->nb_planes; p++) {

  if (s->is_vertical) {
+if (s->keep_dar) {
+height[p] /= s->nb_inputs;
+in_offset[p] = i * height[p] * in[i]->linesize[p];
+}
+
  av_image_copy_plane(out->data[p] + offset[p] * 
out->linesize[p],
  out->linesize[p],
-in[i]->data[p],
+in[i]->data[p] + in_offset[p],
  in[i]->linesize[p],
  linesize[p], height[p]);
  offset[p] += height[p];
  } else if (s->is_horizontal) {
+if (s->keep_dar) {
+linesize[p] /= s->nb_inputs;
+in_offset[p] = i * in[i]->linesize[p] / s->nb_inputs;
+}
  av_image_copy_plane(out->data[p] + offset[p],
  out->linesize[p],
-in[i]->data[p],
+in[i]->data[p] + in_offset[p],
  in[i]->linesize[p],
  linesize[p], height[p]);
  offset[p] += linesize[p];
@@ -197,20 +207,30 @@ static int config_output(AVFilterLink *outlink)
  return AVERROR_BUG;
  
  if (s->is_vertical) {

+if (s->keep_dar)
+height /= s->nb_inputs;
  for (i = 1; i < s->nb_inputs; i++) {
  if (ctx->inputs[i]->w != width) {
  av_log(ctx, AV_LOG_ERROR, "Input %d width %d does not match input %d 
width %d.\n", i, ctx->inputs[i]->w, 0, width);
  return AVERROR(EINVAL);
  }
-height += ctx->inputs[i]->h;
+if (!s->keep_dar)
+height += ctx->inputs[i]->h;
+else
+height += ctx->inputs[i]->h / s->nb_inputs;
  }
  } else if (s->is_horizontal) {
+if (s->keep_dar)
+width /= s->nb_inputs;
  for (i = 1; i < s->nb_inputs; i++) {
  if (ctx->inputs[i]->h != height) {
  av_log(ctx, AV_LOG_ERROR, "Input %d height %d does not match input %d 
height %d.\n", i, ctx->inputs[i]->h, 0, height);
  return AVERROR(EINVAL);
  }
-width += ctx->inputs[i]->w;
+if (!s->keep_dar)
+width += ctx->inputs[i]->w;
+else
+width += ctx->inputs[i]->w / s->nb_inputs;
  }
  } else {
  char *arg, *p = s->layout, *saveptr = NULL;
@@ -339,6 +359,7 @@ static int activate(AVFilterContext *ctx)
  #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
  static const AVOption stack_options[] = {
  { "inputs", "set number of inputs", OFFSET(nb_inputs), AV_OPT_TYPE_INT, 
{.i64=2}, 2, INT_MAX, .flags = FLAGS },
+{ "keep_dar", "stack with 1/nb_inputs of each inputs screen to keep the same 
DAR", 

Re: [FFmpeg-devel] [PATCH] avformat/mpegenc - reject unsupported audio streams

2019-07-08 Thread Gyan



On 25-04-2019 01:48 PM, Gyan wrote:



On 25-04-2019 01:23 PM, Ali KIZIL wrote:


There are also Dolby Codecs (ac3 & eac3). Will it also throw error for
these codecs ?


AC3   is  supported before and after this patch.
EAC3 is unsupported before and after this patch.

But it's sent to the same decoder, so support could be added. I'll check.


Attached patch allows muxing EAC3 in MPEG-PS.  Stock ffmpeg can demux 
and decode such streams fine.


Gyan
From 4558eab851efc252fc6cac4aff4f557b5768004a Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Mon, 8 Jul 2019 17:04:21 +0530
Subject: [PATCH] avformat/mpegenc: allow muxing eac3 streams

---
 libavformat/mpegenc.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index 43ebc46e0e..15b191bc9d 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -352,6 +352,7 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
 case AVMEDIA_TYPE_AUDIO:
 if (!s->is_mpeg2 &&
 (st->codecpar->codec_id == AV_CODEC_ID_AC3 ||
+ st->codecpar->codec_id == AV_CODEC_ID_EAC3 ||
  st->codecpar->codec_id == AV_CODEC_ID_DTS ||
  st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE ||
  st->codecpar->codec_id == AV_CODEC_ID_PCM_DVD))
@@ -360,7 +361,8 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
 "consider using the vob or the dvd muxer "
 "to force a MPEG-2 program stream.\n",
 avcodec_get_name(st->codecpar->codec_id));
-if (st->codecpar->codec_id == AV_CODEC_ID_AC3) {
+if (st->codecpar->codec_id == AV_CODEC_ID_AC3 ||
+st->codecpar->codec_id == AV_CODEC_ID_EAC3) {
 stream->id = ac3_id++;
 } else if (st->codecpar->codec_id == AV_CODEC_ID_DTS) {
 stream->id = dts_id++;
@@ -415,7 +417,7 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
 } else if (st->codecpar->codec_id != AV_CODEC_ID_MP1 &&
st->codecpar->codec_id != AV_CODEC_ID_MP2 &&
st->codecpar->codec_id != AV_CODEC_ID_MP3) {
-   av_log(ctx, AV_LOG_ERROR, "Unsupported audio codec. 
Must be one of mp1, mp2, mp3, 16-bit pcm_dvd, pcm_s16be, ac3 or dts.\n");
+   av_log(ctx, AV_LOG_ERROR, "Unsupported audio codec. 
Must be one of mp1, mp2, mp3, 16-bit pcm_dvd, pcm_s16be, ac3, eac3 or dts.\n");
goto fail;
 } else {
 stream->id = mpa_id++;
-- 
2.22.0___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v5] avfilter/avf_aphasemeter: Add out-of-phase and mono detection

2019-07-08 Thread Romane Lafon
This patch extends aphasemeter to detect out of phase or mono sequences in
stereo streams, with its associated documentation.
From 7e2846ac3b4b79a2e9beca845d0f2be7ae6abcdb Mon Sep 17 00:00:00 2001
From: Romane Lafon 
Date: Mon, 8 Jul 2019 13:51:05 +0200
Subject: [PATCH] avfilter/avf_aphasemeter: Add out of phase and mono detection

Signed-off-by: Romane Lafon 
---
 doc/filters.texi  |  33 +++
 libavfilter/avf_aphasemeter.c | 127 --
 2 files changed, 156 insertions(+), 4 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index ee6a93ffbf..46d19826d0 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -20672,6 +20672,39 @@ Set color which will be used for drawing median phase. If color is
 Enable video output. Default is enabled.
 @end table
 
+@subsection phasing detection
+
+The filter also detects out of phase and mono sequences in stereo streams.
+It logs the sequence start, end and duration when it lasts longer or as long as the minimum set.
+
+The filter accepts the following options for this detection:
+
+@table @option
+@item phasing
+Enable mono and out of phase detection. Default is disabled.
+
+@item tolerance
+Set phase tolerance for mono detection, in amplitude ratio. Default is @code{0}.
+Allowed range is @code{[0, 1]}.
+
+@item angle
+Set angle threshold for out of phase detection, in degree. Default is @code{170}.
+Allowed range is @code{[0, 180]}.
+
+@item duration
+Set mono or out of phase duration until notification, expressed in seconds. Default is @code{2}.
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Complete example with @command{ffmpeg} to detect 1 second of mono with 0.001 phase tolerance:
+@example
+ffmpeg -i stereo.wav -af aphasemeter=video=0:phasing=1:duration=1:tolerance=0.001 -f null -
+@end example
+@end itemize
+
 @section avectorscope
 
 Convert input audio to a video output, representing the audio vector
diff --git a/libavfilter/avf_aphasemeter.c b/libavfilter/avf_aphasemeter.c
index f497bc9969..77701e5cde 100644
--- a/libavfilter/avf_aphasemeter.c
+++ b/libavfilter/avf_aphasemeter.c
@@ -28,26 +28,41 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/opt.h"
 #include "libavutil/parseutils.h"
+#include "libavutil/timestamp.h"
 #include "avfilter.h"
 #include "formats.h"
 #include "audio.h"
 #include "video.h"
 #include "internal.h"
+#include "stdbool.h"
+#include "float.h"
 
 typedef struct AudioPhaseMeterContext {
 const AVClass *class;
 AVFrame *out;
 int do_video;
+int do_phasing_detection;
 int w, h;
 AVRational frame_rate;
 int contrast[4];
 uint8_t *mpc_str;
 uint8_t mpc[4];
 int draw_median_phase;
+int is_mono;
+int is_out_phase;
+int start_mono_presence;
+int start_out_phase_presence;
+float tolerance;
+float angle;
+float phase;
+float mono_idx[2];
+float out_phase_idx[2];
+double duration;
 } AudioPhaseMeterContext;
 
 #define OFFSET(x) offsetof(AudioPhaseMeterContext, x)
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
+#define get_duration(index) (index[1] - index[0])
 
 static const AVOption aphasemeter_options[] = {
 { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
@@ -59,6 +74,10 @@ static const AVOption aphasemeter_options[] = {
 { "bc", "set blue contrast",  OFFSET(contrast[2]), AV_OPT_TYPE_INT, {.i64=1}, 0, 255, FLAGS },
 { "mpc", "set median phase color", OFFSET(mpc_str), AV_OPT_TYPE_STRING, {.str = "none"}, 0, 0, FLAGS },
 { "video", "set video output", OFFSET(do_video), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FLAGS },
+{ "phasing", "set mono and out-of-phase detection output", OFFSET(do_phasing_detection), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS },
+{ "tolerance", "set phase tolerance for mono detection", OFFSET(tolerance), AV_OPT_TYPE_FLOAT, {.dbl = 0.}, 0, 1, FLAGS },
+{ "angle", "set angle threshold for out-of-phase detection", OFFSET(angle), AV_OPT_TYPE_FLOAT, {.dbl = 170.}, 90, 180, FLAGS },
+{ "duration", "set minimum mono or out-of-phase duration in seconds", OFFSET(duration), AV_OPT_TYPE_DOUBLE, {.dbl=2.}, 0, 24*60*60, FLAGS },
 { NULL }
 };
 
@@ -140,6 +159,22 @@ static inline int get_x(float phase, int w)
   return (phase + 1.) / 2. * (w - 1);
 }
 
+static inline float get_index(AVFilterLink *inlink, AVFrame *in)
+{
+char *index_str = av_ts2timestr(in->pts, >time_base);
+return atof(index_str);
+}
+
+static inline void add_metadata(AVFrame *insamples, const char *key, float value)
+{
+char buf[128];
+char str[128];
+
+snprintf(str, sizeof(str), "%f", value);
+snprintf(buf, sizeof(buf), "lavfi.aphasemeter.%s", key);
+av_dict_set(>metadata, buf, str, 0);
+}
+
 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
 AVFilterContext *ctx = inlink->dst;
@@ -154,6 +189,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 

Re: [FFmpeg-devel] [PATCH] lavf/vf_stack: add keep_dar option for vstack and hstack

2019-07-08 Thread Moritz Barsnick
On Mon, Jul 08, 2019 at 18:48:46 +0800, lance.lmw...@gmail.com wrote:
> +@item keep_dar
> +stack with 1/nb_inputs of each inputs screen to keep the same DAR, Default 
> is 0.
  ^
Probably "input's". Is screen the correct term here at all? (In three
places in the patch.)

> +{ "keep_dar", "stack with 1/nb_inputs of each inputs screen to keep the 
> same DAR", OFFSET(keep_dar), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, .flags = FLAGS 
> },

AV_OPT_TYPE_BOOL

Not sure about the actual implementation, can't judge.

Cheers,
Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4] avfilter/avf_aphasemeter: Add out-of-phase and mono detection

2019-07-08 Thread Romane Lafon
Ok, thanks

Le ven. 5 juil. 2019 à 16:54, Devin Heitmueller 
a écrit :

> On Wed, Jul 3, 2019 at 9:34 AM Romane Lafon  wrote:
> >
> > I've added documentation for the extension of aphasemeter filter.
> > Also, I'm not sure that "phasing" is the right word to describe the
> > detection.
>
> In some commercial analyzers I've also seen audio phase presented
> using the term "lissajous" (after the name of the actual curve), but
> personally I prefer to refer to it as audio phase.
>
> Devin
>
> --
> Devin J. Heitmueller - Kernel Labs
> http://www.kernellabs.com
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] lavc/videotoolboxenc: add hdr10, linear, hlg color transfer function for videotoolboxenc

2019-07-08 Thread Limin Wang

Richard Kern, please help to review the patch.

On Wed, Jun 26, 2019 at 06:57:59PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Below is the testing ffmpeg command for the setting:
> ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020 
> -colorspace bt2020_ncl -color_trc smpte2084 smpte2048.ts
> ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020 
> -colorspace bt2020_ncl -color_trc linear linear.ts
> ./ffmpeg -i input.ts -c:v hevc_videotoolbox -color_primaries bt2020 
> -colorspace bt2020_ncl -color_trc arib-std-b67 hlg.ts
> 
> Signed-off-by: Limin Wang 
> ---
>  configure|  6 ++
>  libavcodec/videotoolboxenc.c | 16 
>  2 files changed, 22 insertions(+)
> 
> diff --git a/configure b/configure
> index 7cea9d4d73..0a5e940c0c 100755
> --- a/configure
> +++ b/configure
> @@ -2260,6 +2260,9 @@ TOOLCHAIN_FEATURES="
>  TYPES_LIST="
>  kCMVideoCodecType_HEVC
>  kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange
> +kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ
> +kCVImageBufferTransferFunction_ITU_R_2100_HLG
> +kCVImageBufferTransferFunction_Linear
>  socklen_t
>  struct_addrinfo
>  struct_group_source_req
> @@ -6044,6 +6047,9 @@ enabled videotoolbox && {
>  check_lib coreservices CoreServices/CoreServices.h UTGetOSTypeFromString 
> "-framework CoreServices"
>  check_func_headers CoreMedia/CMFormatDescription.h 
> kCMVideoCodecType_HEVC "-framework CoreMedia"
>  check_func_headers CoreVideo/CVPixelBuffer.h 
> kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange "-framework CoreVideo"
> +check_func_headers CoreVideo/CVImageBuffer.h 
> kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ "-framework CoreVideo"
> +check_func_headers CoreVideo/CVImageBuffer.h 
> kCVImageBufferTransferFunction_ITU_R_2100_HLG "-framework CoreVideo"
> +check_func_headers CoreVideo/CVImageBuffer.h 
> kCVImageBufferTransferFunction_Linear "-framework CoreVideo"
>  }
>  
>  check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index f8ccdea52d..0dc6eb4cf4 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -915,6 +915,22 @@ static int get_cv_transfer_function(AVCodecContext 
> *avctx,
>  *transfer_fnc = kCVImageBufferTransferFunction_SMPTE_240M_1995;
>  break;
>  
> +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ
> +case AVCOL_TRC_SMPTE2084:
> +*transfer_fnc = kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
> +break;
> +#endif
> +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR
> +case AVCOL_TRC_LINEAR:
> +*transfer_fnc = kCVImageBufferTransferFunction_Linear;
> +break;
> +#endif
> +#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG
> +case AVCOL_TRC_ARIB_STD_B67:
> +*transfer_fnc = kCVImageBufferTransferFunction_ITU_R_2100_HLG;
> +break;
> +#endif
> +
>  case AVCOL_TRC_GAMMA22:
>  gamma = 2.2;
>  *transfer_fnc = kCVImageBufferTransferFunction_UseGamma;
> -- 
> 2.21.0
> 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] lavf/vf_stack: add keep_dar option for vstack and hstack

2019-07-08 Thread lance . lmwang
From: Limin Wang 

It's useful to compare two 4K videos quality side by side on 4K TV.

Signed-off-by: Limin Wang 
---
 doc/filters.texi   |  6 ++
 libavfilter/vf_stack.c | 31 ++-
 2 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index ee6a93ffbf..675b02fc34 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -11280,6 +11280,9 @@ The filter accept the following option:
 @item inputs
 Set number of input streams. Default is 2.
 
+@item keep_dar
+stack with 1/nb_inputs of each inputs screen to keep the same DAR, Default is 
0.
+
 @item shortest
 If set to 1, force the output to terminate when the shortest input
 terminates. Default value is 0.
@@ -18333,6 +18336,9 @@ The filter accept the following option:
 @item inputs
 Set number of input streams. Default is 2.
 
+@item keep_dar
+stack with 1/nb_inputs of each inputs screen to keep the same DAR, Default is 
0.
+
 @item shortest
 If set to 1, force the output to terminate when the shortest input
 terminates. Default value is 0.
diff --git a/libavfilter/vf_stack.c b/libavfilter/vf_stack.c
index 4d254e0013..9196b5b0b7 100644
--- a/libavfilter/vf_stack.c
+++ b/libavfilter/vf_stack.c
@@ -44,6 +44,7 @@ typedef struct StackContext {
 int is_vertical;
 int is_horizontal;
 int nb_planes;
+int keep_dar;
 
 StackItem *items;
 AVFrame **frames;
@@ -123,7 +124,7 @@ static int process_frame(FFFrameSync *fs)
 StackContext *s = fs->opaque;
 AVFrame **in = s->frames;
 AVFrame *out;
-int i, p, ret, offset[4] = { 0 };
+int i, p, ret, offset[4] = { 0 }, in_offset[4] = { 0 };
 
 for (i = 0; i < s->nb_inputs; i++) {
 if ((ret = ff_framesync_get_frame(>fs, i, [i], 0)) < 0)
@@ -153,16 +154,25 @@ static int process_frame(FFFrameSync *fs)
 
 for (p = 0; p < s->nb_planes; p++) {
 if (s->is_vertical) {
+if (s->keep_dar) {
+height[p] /= s->nb_inputs;
+in_offset[p] = i * height[p] * in[i]->linesize[p];
+}
+
 av_image_copy_plane(out->data[p] + offset[p] * 
out->linesize[p],
 out->linesize[p],
-in[i]->data[p],
+in[i]->data[p] + in_offset[p],
 in[i]->linesize[p],
 linesize[p], height[p]);
 offset[p] += height[p];
 } else if (s->is_horizontal) {
+if (s->keep_dar) {
+linesize[p] /= s->nb_inputs;
+in_offset[p] = i * in[i]->linesize[p] / s->nb_inputs;
+}
 av_image_copy_plane(out->data[p] + offset[p],
 out->linesize[p],
-in[i]->data[p],
+in[i]->data[p] + in_offset[p],
 in[i]->linesize[p],
 linesize[p], height[p]);
 offset[p] += linesize[p];
@@ -197,20 +207,30 @@ static int config_output(AVFilterLink *outlink)
 return AVERROR_BUG;
 
 if (s->is_vertical) {
+if (s->keep_dar)
+height /= s->nb_inputs;
 for (i = 1; i < s->nb_inputs; i++) {
 if (ctx->inputs[i]->w != width) {
 av_log(ctx, AV_LOG_ERROR, "Input %d width %d does not match 
input %d width %d.\n", i, ctx->inputs[i]->w, 0, width);
 return AVERROR(EINVAL);
 }
-height += ctx->inputs[i]->h;
+if (!s->keep_dar)
+height += ctx->inputs[i]->h;
+else
+height += ctx->inputs[i]->h / s->nb_inputs;
 }
 } else if (s->is_horizontal) {
+if (s->keep_dar)
+width /= s->nb_inputs;
 for (i = 1; i < s->nb_inputs; i++) {
 if (ctx->inputs[i]->h != height) {
 av_log(ctx, AV_LOG_ERROR, "Input %d height %d does not match 
input %d height %d.\n", i, ctx->inputs[i]->h, 0, height);
 return AVERROR(EINVAL);
 }
-width += ctx->inputs[i]->w;
+if (!s->keep_dar)
+width += ctx->inputs[i]->w;
+else
+width += ctx->inputs[i]->w / s->nb_inputs;
 }
 } else {
 char *arg, *p = s->layout, *saveptr = NULL;
@@ -339,6 +359,7 @@ static int activate(AVFilterContext *ctx)
 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
 static const AVOption stack_options[] = {
 { "inputs", "set number of inputs", OFFSET(nb_inputs), AV_OPT_TYPE_INT, 
{.i64=2}, 2, INT_MAX, .flags = FLAGS },
+{ "keep_dar", "stack with 1/nb_inputs of each inputs screen to keep the 
same DAR", OFFSET(keep_dar), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, .flags = FLAGS },
 { "shortest", "force termination when the shortest input 

[FFmpeg-devel] [PATCH] fftools/ffmpeg: fix video frame lost sync for the dual input ts files with audio

2019-07-08 Thread lance . lmwang
From: Limin Wang 

How to reproduce the problem(use two ts files with audio stream):
ffmpeg -i left_w_a.ts -i right_w_a.ts -filter_complex "hstack=inputs=2" -f null 
-

With above command, the audio stream of the second input will be discarded 
default, however the start_time is 
initalized from the audio stream, so the old code will try to correct the ts 
offset in the condition which will
cause the video frame out of sync and report some dts error like below:
[null @ 0x7fa78c000c00] Application provided invalid, non monotonically 
increasing dts to muxer in stream 0: 43 >= 43
[null @ 0x7fa78c000c00] Application provided invalid, non monotonically 
increasing dts to muxer in stream 0: 44 >= 44
[null @ 0x7fa78c000c00] Application provided invalid, non monotonically 
increasing dts to muxer in stream 0: 45 >= 45
[null @ 0x7fa78c000c00] Application provided invalid, non monotonically 
increasing dts to muxer in stream 0: 46 >= 46
[null @ 0x7fa78c000c00] Application provided invalid, non monotonically 
increasing dts to muxer in stream 0: 47 >= 47

Or you can try with below command to reproduce the issue:
ffmpeg -i input_w_a.ts -i input_w_a.ts -filter_complex "ssim=f=ssim.log" -f 
null -

You'll get below ssim result which isn't expected result for the two input is 
same, the SSIM should be 1.0
SSIM Y:0.777353 (6.523822) U:0.964087 (14.447539) V:0.966739 (14.780661) 
All:0.840039 (7.959872)

With the patch applied, the above testing command can get expected result.

other solution are: use the setpts=PTS-STARTPTS filter or skip all audio stream 
to avoid the timestamp adjustment.

Signed-off-by: Limin Wang 
---
 fftools/ffmpeg.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 01f04103cf..3fed92639a 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -4378,13 +4378,16 @@ static int process_input(int file_index)
 && ifile->ts_offset == -is->start_time
 && (is->iformat->flags & AVFMT_TS_DISCONT)) {
 int64_t new_start_time = INT64_MAX;
+int nb_used_streams = 0;
+
 for (i=0; inb_streams; i++) {
 AVStream *st = is->streams[i];
 if(st->discard == AVDISCARD_ALL || st->start_time == 
AV_NOPTS_VALUE)
 continue;
+nb_used_streams++;
 new_start_time = FFMIN(new_start_time, 
av_rescale_q(st->start_time, st->time_base, AV_TIME_BASE_Q));
 }
-if (new_start_time > is->start_time) {
+if (nb_used_streams > 1 && new_start_time > is->start_time) {
 av_log(is, AV_LOG_VERBOSE, "Correcting start time by 
%"PRId64"\n", new_start_time - is->start_time);
 ifile->ts_offset = -new_start_time;
 }
-- 
2.21.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 4/6] avcodec/flicvideo: Make line_packets int

2019-07-08 Thread Paul B Mahol
On 7/8/19, Michael Niedermayer  wrote:
> On Sat, Jun 22, 2019 at 04:58:37PM +0200, Paul B Mahol wrote:
>> On 6/22/19, Michael Niedermayer  wrote:
>> > Fixes: signed integer overflow: -32768 * 196032 cannot be represented
>> > in
>> > type 'int'
>> > Fixes:
>> > 15300/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLIC_fuzzer-5733319519502336
>> >
>> > Found-by: continuous fuzzing process
>> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
>> > Signed-off-by: Michael Niedermayer 
>> > ---
>> >  libavcodec/flicvideo.c | 14 +++---
>> >  1 file changed, 7 insertions(+), 7 deletions(-)
>> >
>> > diff --git a/libavcodec/flicvideo.c b/libavcodec/flicvideo.c
>> > index ba5bda48c4..cd9cd089af 100644
>> > --- a/libavcodec/flicvideo.c
>> > +++ b/libavcodec/flicvideo.c
>> > @@ -175,7 +175,7 @@ static int flic_decode_frame_8BPP(AVCodecContext
>> > *avctx,
>> >  int lines;
>> >  int compressed_lines;
>> >  int starting_line;
>> > -signed short line_packets;
>> > +int line_packets;
>> >  int y_ptr;
>> >  int byte_run;
>> >  int pixel_skip;
>> > @@ -274,7 +274,7 @@ static int flic_decode_frame_8BPP(AVCodecContext
>> > *avctx,
>> >  break;
>> >  if (y_ptr > pixel_limit)
>> >  return AVERROR_INVALIDDATA;
>> > -line_packets = bytestream2_get_le16();
>> > +line_packets = (int16_t)bytestream2_get_le16();
>> >  if ((line_packets & 0xC000) == 0xC000) {
>> >  // line skip opcode
>> >  line_packets = -line_packets;
>> > @@ -340,7 +340,7 @@ static int flic_decode_frame_8BPP(AVCodecContext
>> > *avctx,
>> >  pixel_countdown = s->avctx->width;
>> >  if (bytestream2_tell() + 1 >
>> > stream_ptr_after_chunk)
>> >  break;
>> > -line_packets = bytestream2_get_byte();
>> > +line_packets = (int16_t)bytestream2_get_byte();
>> >  if (line_packets > 0) {
>> >  for (i = 0; i < line_packets; i++) {
>> >  /* account for the skip bytes */
>> > @@ -508,7 +508,7 @@ static int
>> > flic_decode_frame_15_16BPP(AVCodecContext
>> > *avctx,
>> >
>> >  int lines;
>> >  int compressed_lines;
>> > -signed short line_packets;
>> > +int line_packets;
>> >  int y_ptr;
>> >  int byte_run;
>> >  int pixel_skip;
>> > @@ -572,7 +572,7 @@ static int
>> > flic_decode_frame_15_16BPP(AVCodecContext
>> > *avctx,
>> >  break;
>> >  if (y_ptr > pixel_limit)
>> >  return AVERROR_INVALIDDATA;
>> > -line_packets = bytestream2_get_le16();
>> > +line_packets = (int16_t)bytestream2_get_le16();
>> >  if (line_packets < 0) {
>> >  line_packets = -line_packets;
>> >  if (line_packets > s->avctx->height)
>> > @@ -806,7 +806,7 @@ static int flic_decode_frame_24BPP(AVCodecContext
>> > *avctx,
>> >
>> >  int lines;
>> >  int compressed_lines;
>> > -signed short line_packets;
>> > +int line_packets;
>> >  int y_ptr;
>> >  int byte_run;
>> >  int pixel_skip;
>> > @@ -870,7 +870,7 @@ static int flic_decode_frame_24BPP(AVCodecContext
>> > *avctx,
>> >  break;
>> >  if (y_ptr > pixel_limit)
>> >  return AVERROR_INVALIDDATA;
>> > -line_packets = bytestream2_get_le16();
>> > +line_packets = (int16_t)bytestream2_get_le16();
>> >  if (line_packets < 0) {
>> >  line_packets = -line_packets;
>> >  if (line_packets > s->avctx->height)
>> > --
>> > 2.22.0
>> >
>> > ___
>> > ffmpeg-devel mailing list
>> > ffmpeg-devel@ffmpeg.org
>> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> >
>> > To unsubscribe, visit link above, or email
>> > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>>
>> In some cases casting in not needed.
>
> unneeded one dropped
>
>
>> Also cant you use sign_extend ?
>
> certainly but that might be slower.
> Do you prefer if i use sign_extend ?

Not if it is slower.

>
> thanks
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Everything should be made as simple as possible, but not simpler.
> -- Albert Einstein
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/3] avcodec/qdm2: error out of qdm2_fft_decode_tones() before entering endless loop

2019-07-08 Thread Michael Niedermayer
On Mon, Jun 24, 2019 at 01:01:03AM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 2147483646 + 2 cannot be represented in type 
> 'int'
> Fixes: infinite loop
> Fixes: 
> 15396/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_QDM2_fuzzer-5116605501014016
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/qdm2.c | 4 
>  1 file changed, 4 insertions(+)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If a bugfix only changes things apparently unrelated to the bug with no
further explanation, that is a good sign that the bugfix is wrong.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] lavc/vaapi_decode: recreate hw_frames_ctx without destroy va_context

2019-07-08 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Yan Wang
> Sent: Monday, July 8, 2019 15:54
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 2/2] lavc/vaapi_decode: recreate
> hw_frames_ctx without destroy va_context
> 
> 
> On 7/8/2019 2:45 PM, Yan Wang wrote:
> >
> > On 7/7/2019 9:49 PM, Fu, Linjie wrote:
> >>> -Original Message-
> >>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> >>> Of Mark Thompson
> >>> Sent: Sunday, July 7, 2019 19:51
> >>> To: ffmpeg-devel@ffmpeg.org
> >>> Subject: Re: [FFmpeg-devel] [PATCH 2/2] lavc/vaapi_decode: recreate
> >>> hw_frames_ctx without destroy va_context
> >>>
> >>> On 07/07/2019 17:38, Linjie Fu wrote:
>  VP9 allows resolution changes per frame. Currently in VAAPI,
>  resolution
>  changes leads to va context destroy and reinit.
> >>> Which is correct - it needs to remake the context because the old
> >>> one is for
> >>> the wrong resolution.
> >> It seems that we don't need to remake context, remaking the surface
> >> is enough
> >> for resolution changing.
> >> Currently in libva, surface is able to be recreated separately
> >> without remaking context.
> >> And this way is used in libyami to cope with resolution changing cases.
> >>
>  This will cause
>  reference frame surface lost and produce garbage.
> >>> This isn't right - the reference frame surfaces aren't lost. See
> >>> VP9Context.s.refs[], which holds references to the frames (including
> >>> their
> >>> hardware frame contexts) until the stream indicates that they can be
> >>> discarded by overwriting their reference frame slots.
> >> I'm not quite sure about this, at least the result shows they are not
> >> used correctly
> >> in current way.
> >> Will look deeper into it.
> >
> > In vaapi_vp9_start_frame() of libavcodec/vaapi_vp9.c, it only passes
> > VASurfaceID into pic_param.reference_frames[i].
> >
> > But when destroy va_context, the surface/render target based on this
> > VASurfaceID has been destroyed.
> 
> Update: the surface isn't destroyed when destroy va_context. But every
> va_context maintains one independent map table: m_ddiDecodeCtx->RTtbl.
> 
> So the new context cannot find this surface in its map table.
> 
> My previous suggested solution should be available still.
>

Yes, tracing the code and could find that:

1.  surface is not destroyed until the decode finishes and calls avcodec_close;
2. refs[i] is passed to driver, however in DdiMediaBase::GetRenderTargetID, 
driver failed to
find the expected surface in the re-created m_ddiDecodeCtx->RTtbl, and returns 
invalid.
if(rtTbl->pRT[i] == surface) {
return i;
}
return DDI_CODEC_INVALID_FRAME_INDEX;

One possible way is to register the refs[] surfaces in the new created context 
->RTtbl and make it
findable.

Thanks for reviews and all comments.
linjie
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 4/4] avcodec/ilbcdec: Simplify use of unsigned and fix more undefined overflows

2019-07-08 Thread Michael Niedermayer
On Mon, Jul 01, 2019 at 12:16:51AM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 2147475672 + 8192 cannot be represented in 
> type 'int'
> Fixes: 
> 15415/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ILBC_fuzzer-5712074128228352
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/ilbcdec.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 3/4] avcodec/h264_refs: Also check reference in ff_h264_build_ref_list()

2019-07-08 Thread Michael Niedermayer
On Mon, Jul 01, 2019 at 12:16:50AM +0200, Michael Niedermayer wrote:
> Fixes: out of array read
> Fixes: 
> 15409/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5758846959616000
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/h264_refs.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/golomb: Correct the doxy about get_ue_golomb() and errors

2019-07-08 Thread Michael Niedermayer
On Sun, Jun 30, 2019 at 05:55:20PM +0200, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/golomb.h | 2 ++
>  1 file changed, 2 insertions(+)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/hq_hqa: Use ff_set_dimensions()

2019-07-08 Thread Michael Niedermayer
On Sun, Jun 30, 2019 at 12:30:15AM +0200, Michael Niedermayer wrote:
> Fixes: 
> 15530/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HQ_HQA_fuzzer-5637370344374272
> Fixes: signed integer overflow: 65312 * 65312 cannot be represented in type 
> 'int'
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/hq_hqa.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)

will apply patchset

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/4] avcodec/rv10: Fix integer overflow in aspect ratio compare

2019-07-08 Thread Michael Niedermayer
On Fri, Jun 28, 2019 at 10:53:42PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 2040 * 1187872 cannot be represented in type 
> 'int'
> Fixes: 
> 15368/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV20_fuzzer-5681657136283648
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/rv10.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/4] avcodec/tta: Limit decoder to 16 channels

2019-07-08 Thread Michael Niedermayer
On Fri, Jun 28, 2019 at 10:53:43PM +0200, Michael Niedermayer wrote:
> libtta 2.3 has a limit of 6 channels, so 16 is substantially above the 
> "official" already
> 
> Fixes: OOM
> Fixes: 
> 15249/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TTA_fuzzer-5643988125614080
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/tta.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship: All citizens are under surveillance, all their steps and
actions recorded, for the politicians to enforce control.
Democracy: All politicians are under surveillance, all their steps and
actions recorded, for the citizens to enforce control.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] lavc/vaapi_decode: recreate hw_frames_ctx without destroy va_context

2019-07-08 Thread Yan Wang


On 7/8/2019 2:45 PM, Yan Wang wrote:


On 7/7/2019 9:49 PM, Fu, Linjie wrote:

-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
Of Mark Thompson
Sent: Sunday, July 7, 2019 19:51
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 2/2] lavc/vaapi_decode: recreate
hw_frames_ctx without destroy va_context

On 07/07/2019 17:38, Linjie Fu wrote:
VP9 allows resolution changes per frame. Currently in VAAPI, 
resolution

changes leads to va context destroy and reinit.
Which is correct - it needs to remake the context because the old 
one is for

the wrong resolution.
It seems that we don't need to remake context, remaking the surface 
is enough

for resolution changing.
Currently in libva, surface is able to be recreated separately 
without remaking context.

And this way is used in libyami to cope with resolution changing cases.


This will cause
reference frame surface lost and produce garbage.

This isn't right - the reference frame surfaces aren't lost. See
VP9Context.s.refs[], which holds references to the frames (including 
their

hardware frame contexts) until the stream indicates that they can be
discarded by overwriting their reference frame slots.
I'm not quite sure about this, at least the result shows they are not 
used correctly

in current way.
Will look deeper into it.


In vaapi_vp9_start_frame() of libavcodec/vaapi_vp9.c, it only passes 
VASurfaceID into pic_param.reference_frames[i].


But when destroy va_context, the surface/render target based on this 
VASurfaceID has been destroyed.


Update: the surface isn't destroyed when destroy va_context. But every 
va_context maintains one independent map table: m_ddiDecodeCtx->RTtbl.


So the new context cannot find this surface in its map table.

My previous suggested solution should be available still.

Thanks.

Yan Wang



So the new va_context cannot find the corresponding surface based on 
this surface ID.


IMHO, one possible solution is to create one the VA surfaces including 
VP9Context.s.refs[] data which is AVFrame in fact and pass them into 
libva when re-creating new va_context.


Thanks.

Yan Wang




As libva allows re-create surface separately without changing the
context, this issue could be handled by only recreating hw_frames_ctx.

Could be verified by:
ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -i
./resolutions.ivf
-pix_fmt p010le -f rawvideo -vframes 20 -y vaapi.yuv

Signed-off-by: Linjie Fu 
---
  libavcodec/decode.c   |  8 
  libavcodec/vaapi_decode.c | 40 
++

--

  2 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 0863b82..a81b857 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1254,7 +1254,6 @@ int

ff_decode_get_hw_frames_ctx(AVCodecContext *avctx,

  frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;

-
  if (frames_ctx->initial_pool_size) {
  // We guarantee 4 base work surfaces. The function above 
guarantees

1

  // (the absolute minimum), so add the missing count.
@@ -1333,7 +1332,7 @@ static int hwaccel_init(AVCodecContext *avctx,
  return AVERROR_PATCHWELCOME;
  }

-    if (hwaccel->priv_data_size) {
+    if (hwaccel->priv_data_size && 
!avctx->internal->hwaccel_priv_data) {

  avctx->internal->hwaccel_priv_data =
  av_mallocz(hwaccel->priv_data_size);
  if (!avctx->internal->hwaccel_priv_data)
@@ -1397,8 +1396,9 @@ int ff_get_format(AVCodecContext *avctx, const

enum AVPixelFormat *fmt)

  for (;;) {
  // Remove the previous hwaccel, if there was one.
-    hwaccel_uninit(avctx);
-
+    // VAAPI allows reinit hw_frames_ctx only
+    if (choices[0] != AV_PIX_FMT_VAAPI_VLD)

Including codec-specific conditions in the generic code suggests that
something very shady is going on.

Yes, will try to avoid this.


+ hwaccel_uninit(avctx);>  user_choice = avctx-
get_format(avctx, choices);
  if (user_choice == AV_PIX_FMT_NONE) {
  // Explicitly chose nothing, give up.
diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index 69512e1..13f0cf0 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -613,8 +613,10 @@ int ff_vaapi_decode_init(AVCodecContext *avctx)
  VAStatus vas;
  int err;

-    ctx->va_config  = VA_INVALID_ID;
-    ctx->va_context = VA_INVALID_ID;
+    if (!ctx->va_config && !ctx->va_context){
+    ctx->va_config  = VA_INVALID_ID;
+    ctx->va_context = VA_INVALID_ID;
+    }

  #if FF_API_STRUCT_VAAPI_CONTEXT
  if (avctx->hwaccel_context) {
@@ -642,7 +644,6 @@ int ff_vaapi_decode_init(AVCodecContext *avctx)
  // present, so set it here to avoid the behaviour changing.
  ctx->hwctx->driver_quirks =
  AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS;
-
  }
  #endif

@@ -655,7 +656,8 @@ int 

Re: [FFmpeg-devel] [PATCH 3/4] avcodec/sanm: Optimize fill_frame() with av_memcpy_backptr()

2019-07-08 Thread Michael Niedermayer
On Fri, Jun 28, 2019 at 10:53:44PM +0200, Michael Niedermayer wrote:
> Fixes: Timeout (76 sec -> 24 sec)
> Fixes: 
> 15043/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SANM_fuzzer-5699856238116864
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/sanm.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/4] avformat/vividas: Check for input length in get_v()

2019-07-08 Thread Michael Niedermayer
On Thu, Jun 27, 2019 at 02:35:30AM +0200, Michael Niedermayer wrote:
> Fixes: out of array read
> Fixes: 
> 15286/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5658245101780992
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/vividas.c | 11 ++-
>  1 file changed, 6 insertions(+), 5 deletions(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/4] avcodec/4xm: Fix signed integer overflows in idct()

2019-07-08 Thread Michael Niedermayer
On Thu, Jun 27, 2019 at 02:35:31AM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 20242 * 121095 cannot be represented in type 
> 'int'
> Fixes: 
> 15310/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FOURXM_fuzzer-5737051745419264
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/4xm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 3/3] avcodec/qdm2: Check checksum_size for 0

2019-07-08 Thread Michael Niedermayer
On Mon, Jun 24, 2019 at 01:01:04AM +0200, Michael Niedermayer wrote:
> Fixes: Infinite loop
> Fixes: 
> 15337/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_QDM2_fuzzer-5757428949319680
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/qdm2.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Whats the most studid thing your enemy could do ? Blow himself up
Whats the most studid thing you could do ? Give up your rights and
freedom because your enemy blew himself up.



signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/3] avcodec/qdm2: Do not read out of array in fix_coding_method_array()

2019-07-08 Thread Michael Niedermayer
On Mon, Jun 24, 2019 at 02:09:57PM +0200, Moritz Barsnick wrote:
> On Mon, Jun 24, 2019 at 01:01:02 +0200, Michael Niedermayer wrote:
> > +if (sb + (j + k) / 64 > 29) {
> [...]
> >  if (coding_method[ch][sb + (j + k) / 64][(j + k) % 64] 
> > > coding_method[ch][sb][j]) {
> 
> You could do the "sb + (j + k) / 64]" calculation only once and reuse
> the result. OTOH, this code is full of magic numbers (notably 30, where
> your 29 derives from) which could nicely make use of macros, but don't,
> so it probably doesn't matter.

ill factor the value in a seperate variable and will apply

thanks


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/3] avcodec/svq3: Use ff_set_dimension()

2019-07-08 Thread Michael Niedermayer
On Wed, Jun 26, 2019 at 01:32:32AM +0200, Michael Niedermayer wrote:
> Fixes: OOM
> Fixes: 
> 15410/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SVQ3_fuzzer-5659464805384192
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/svq3.c | 36 
>  1 file changed, 20 insertions(+), 16 deletions(-)

will apply patchset

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety -- Benjamin Franklin


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/3] avcodec/iff: Check ham vs bpp

2019-07-08 Thread Michael Niedermayer
On Sun, Jun 23, 2019 at 10:45:56AM +0200, Michael Niedermayer wrote:
> On Sun, Jun 23, 2019 at 06:33:02PM +1000, Peter Ross wrote:
> > On Sun, Jun 23, 2019 at 12:30:54AM +0200, Michael Niedermayer wrote:
> > > This checks the ham value much stricter and avoids hitting cases which 
> > > cannot be reached
> > > with data from the libavformat demuxer.
> > > 
> > > Fixes: out of array access
> > > Fixes: 
> > > 15320/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5080476840099840
> > > Fixes: 
> > > 15423/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5630765833912320
> > > 
> > > Found-by: continuous fuzzing process 
> > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > > Signed-off-by: Michael Niedermayer 
> > > ---
> > >  libavcodec/iff.c | 15 ---
> > >  1 file changed, 12 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/libavcodec/iff.c b/libavcodec/iff.c
> > > index b43bd507b3..b065bbe598 100644
> > > --- a/libavcodec/iff.c
> > > +++ b/libavcodec/iff.c
> > > @@ -280,6 +280,18 @@ static int extract_header(AVCodecContext *const 
> > > avctx,
> > >  for (i = 0; i < 16; i++)
> > >  s->tvdc[i] = bytestream_get_be16();
> > >  
> > > +if (s->ham) {
> > > +if (s->bpp > 8) {
> > > +av_log(avctx, AV_LOG_ERROR, "Invalid number of hold bits 
> > > for HAM: %u\n", s->ham);
> > > +s->ham = 0;
> > > +return AVERROR_INVALIDDATA;
> > > +} if (s->ham != (s->bpp > 6 ? 6 : 4)) {
> > > +av_log(avctx, AV_LOG_ERROR, "Invalid number of hold bits 
> > > for HAM: %u, BPP: %u\n", s->ham, s->bpp);
> > > +s->ham = 0;
> > > +return AVERROR_INVALIDDATA;
> > > +}
> > > +}
> > 
> > i am curious why we need to reset ham = 0? otherwise patch okay.
> 
> That was just so as not to leave an invalid value in the context. It is
> very likely not needed, I will remove it.

will apply without the ham = 0


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 3/6] avcodec/ffwavesynth: use uint32_t to compute difference, it is enough

2019-07-08 Thread Michael Niedermayer
On Sat, Jun 22, 2019 at 01:29:33AM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 6494225984479297536 - -6043795377581187040 
> cannot be represented in type 'long'
> Fixes: 
> 15285/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFWAVESYNTH_fuzzer-5632780307791872
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/ffwavesynth.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/6] avcodec/ffwavesynth: Simplify lcg_seek(), avoid negative case

2019-07-08 Thread Michael Niedermayer
On Sat, Jun 22, 2019 at 01:29:32AM +0200, Michael Niedermayer wrote:
> Fixes: negation of -9223372036854775808 cannot be represented in type 
> 'int64_t' (aka 'long'); cast to an unsigned type to negate this value to 
> itself
> Fixes: 
> 15289/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFWAVESYNTH_fuzzer-5709034499342336
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/ffwavesynth.c | 12 +++-
>  1 file changed, 3 insertions(+), 9 deletions(-)


will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/6] avcodec/ffwavesynth: Fix backward lcg_seek()

2019-07-08 Thread Michael Niedermayer
On Sat, Jun 22, 2019 at 01:29:31AM +0200, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/ffwavesynth.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct answer.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 4/6] avcodec/flicvideo: Make line_packets int

2019-07-08 Thread Michael Niedermayer
On Sat, Jun 22, 2019 at 04:58:37PM +0200, Paul B Mahol wrote:
> On 6/22/19, Michael Niedermayer  wrote:
> > Fixes: signed integer overflow: -32768 * 196032 cannot be represented in
> > type 'int'
> > Fixes:
> > 15300/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLIC_fuzzer-5733319519502336
> >
> > Found-by: continuous fuzzing process
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/flicvideo.c | 14 +++---
> >  1 file changed, 7 insertions(+), 7 deletions(-)
> >
> > diff --git a/libavcodec/flicvideo.c b/libavcodec/flicvideo.c
> > index ba5bda48c4..cd9cd089af 100644
> > --- a/libavcodec/flicvideo.c
> > +++ b/libavcodec/flicvideo.c
> > @@ -175,7 +175,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
> >  int lines;
> >  int compressed_lines;
> >  int starting_line;
> > -signed short line_packets;
> > +int line_packets;
> >  int y_ptr;
> >  int byte_run;
> >  int pixel_skip;
> > @@ -274,7 +274,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
> >  break;
> >  if (y_ptr > pixel_limit)
> >  return AVERROR_INVALIDDATA;
> > -line_packets = bytestream2_get_le16();
> > +line_packets = (int16_t)bytestream2_get_le16();
> >  if ((line_packets & 0xC000) == 0xC000) {
> >  // line skip opcode
> >  line_packets = -line_packets;
> > @@ -340,7 +340,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
> >  pixel_countdown = s->avctx->width;
> >  if (bytestream2_tell() + 1 > stream_ptr_after_chunk)
> >  break;
> > -line_packets = bytestream2_get_byte();
> > +line_packets = (int16_t)bytestream2_get_byte();
> >  if (line_packets > 0) {
> >  for (i = 0; i < line_packets; i++) {
> >  /* account for the skip bytes */
> > @@ -508,7 +508,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext
> > *avctx,
> >
> >  int lines;
> >  int compressed_lines;
> > -signed short line_packets;
> > +int line_packets;
> >  int y_ptr;
> >  int byte_run;
> >  int pixel_skip;
> > @@ -572,7 +572,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext
> > *avctx,
> >  break;
> >  if (y_ptr > pixel_limit)
> >  return AVERROR_INVALIDDATA;
> > -line_packets = bytestream2_get_le16();
> > +line_packets = (int16_t)bytestream2_get_le16();
> >  if (line_packets < 0) {
> >  line_packets = -line_packets;
> >  if (line_packets > s->avctx->height)
> > @@ -806,7 +806,7 @@ static int flic_decode_frame_24BPP(AVCodecContext
> > *avctx,
> >
> >  int lines;
> >  int compressed_lines;
> > -signed short line_packets;
> > +int line_packets;
> >  int y_ptr;
> >  int byte_run;
> >  int pixel_skip;
> > @@ -870,7 +870,7 @@ static int flic_decode_frame_24BPP(AVCodecContext
> > *avctx,
> >  break;
> >  if (y_ptr > pixel_limit)
> >  return AVERROR_INVALIDDATA;
> > -line_packets = bytestream2_get_le16();
> > +line_packets = (int16_t)bytestream2_get_le16();
> >  if (line_packets < 0) {
> >  line_packets = -line_packets;
> >  if (line_packets > s->avctx->height)
> > --
> > 2.22.0
> >
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> 
> In some cases casting in not needed.

unneeded one dropped


> Also cant you use sign_extend ?

certainly but that might be slower.
Do you prefer if i use sign_extend ?

thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Everything should be made as simple as possible, but not simpler.
-- Albert Einstein


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] lavc/vaapi_decode: recreate hw_frames_ctx without destroy va_context

2019-07-08 Thread Yan Wang


On 7/7/2019 9:49 PM, Fu, Linjie wrote:

-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
Of Mark Thompson
Sent: Sunday, July 7, 2019 19:51
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 2/2] lavc/vaapi_decode: recreate
hw_frames_ctx without destroy va_context

On 07/07/2019 17:38, Linjie Fu wrote:

VP9 allows resolution changes per frame. Currently in VAAPI, resolution
changes leads to va context destroy and reinit.

Which is correct - it needs to remake the context because the old one is for
the wrong resolution.

It seems that we don't need to remake context, remaking the surface is enough
for resolution changing.
Currently in libva, surface is able to be recreated separately without remaking 
context.
And this way is used in libyami to cope with resolution changing cases.


 This will cause
reference frame surface lost and produce garbage.

This isn't right - the reference frame surfaces aren't lost.  See
VP9Context.s.refs[], which holds references to the frames (including their
hardware frame contexts) until the stream indicates that they can be
discarded by overwriting their reference frame slots.

I'm not quite sure about this, at least the result shows they are not used 
correctly
in current way.
Will look deeper into it.


In vaapi_vp9_start_frame() of libavcodec/vaapi_vp9.c, it only passes 
VASurfaceID into pic_param.reference_frames[i].


But when destroy va_context, the surface/render target based on this 
VASurfaceID has been destroyed.


So the new va_context cannot find the corresponding surface based on 
this surface ID.


IMHO, one possible solution is to create one the VA surfaces including 
VP9Context.s.refs[] data which is AVFrame in fact and pass them into 
libva when re-creating new va_context.


Thanks.

Yan Wang




As libva allows re-create surface separately without changing the
context, this issue could be handled by only recreating hw_frames_ctx.

Could be verified by:
ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -i
./resolutions.ivf
-pix_fmt p010le -f rawvideo -vframes 20 -y vaapi.yuv

Signed-off-by: Linjie Fu 
---
  libavcodec/decode.c   |  8 
  libavcodec/vaapi_decode.c | 40 ++

--

  2 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 0863b82..a81b857 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1254,7 +1254,6 @@ int

ff_decode_get_hw_frames_ctx(AVCodecContext *avctx,

  frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;

-
  if (frames_ctx->initial_pool_size) {
  // We guarantee 4 base work surfaces. The function above guarantees

1

  // (the absolute minimum), so add the missing count.
@@ -1333,7 +1332,7 @@ static int hwaccel_init(AVCodecContext *avctx,
  return AVERROR_PATCHWELCOME;
  }

-if (hwaccel->priv_data_size) {
+if (hwaccel->priv_data_size && !avctx->internal->hwaccel_priv_data) {
  avctx->internal->hwaccel_priv_data =
  av_mallocz(hwaccel->priv_data_size);
  if (!avctx->internal->hwaccel_priv_data)
@@ -1397,8 +1396,9 @@ int ff_get_format(AVCodecContext *avctx, const

enum AVPixelFormat *fmt)

  for (;;) {
  // Remove the previous hwaccel, if there was one.
-hwaccel_uninit(avctx);
-
+// VAAPI allows reinit hw_frames_ctx only
+if (choices[0] != AV_PIX_FMT_VAAPI_VLD)

Including codec-specific conditions in the generic code suggests that
something very shady is going on.

Yes, will try to avoid this.


+hwaccel_uninit(avctx);>  user_choice = avctx-
get_format(avctx, choices);
  if (user_choice == AV_PIX_FMT_NONE) {
  // Explicitly chose nothing, give up.
diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index 69512e1..13f0cf0 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -613,8 +613,10 @@ int ff_vaapi_decode_init(AVCodecContext *avctx)
  VAStatus vas;
  int err;

-ctx->va_config  = VA_INVALID_ID;
-ctx->va_context = VA_INVALID_ID;
+if (!ctx->va_config && !ctx->va_context){
+ctx->va_config  = VA_INVALID_ID;
+ctx->va_context = VA_INVALID_ID;
+}

  #if FF_API_STRUCT_VAAPI_CONTEXT
  if (avctx->hwaccel_context) {
@@ -642,7 +644,6 @@ int ff_vaapi_decode_init(AVCodecContext *avctx)
  // present, so set it here to avoid the behaviour changing.
  ctx->hwctx->driver_quirks =
  AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS;
-
  }
  #endif

@@ -655,7 +656,8 @@ int ff_vaapi_decode_init(AVCodecContext *avctx)
 "context: %#x/%#x.\n", ctx->va_config, ctx->va_context);
  } else {
  #endif
-
+// Get a new hw_frames_ctx even if there is already one
+// recreate surface without reconstuct va_context
  err = 

Re: [FFmpeg-devel] [PATCH] avcodec: Implement DM PAR Muxer/Demuxer

2019-07-08 Thread Tom Needham
Hi Paul

The only windows player I am aware of can be downloaded from here.

https://www.dedicatedmicros-support.com/software_release/download.php?file=5357

Also, there is a tool that directly converts these PAR files into H264
format which can be obtained from here.

https://www.dedicatedmicros-support.com/software_release/download.php?file=3344

And finally the library I used to create the wrapper can be downloaded from
here.

https://www.dedicatedmicros-support.com/software_release/download.php?file=3347

Thanks


Virus-free.
www.avg.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Sun, 7 Jul 2019 at 10:55, Paul B Mahol  wrote:

> On 7/5/19, Tom Needham <06needh...@gmail.com> wrote:
> > Samples are Available from
> >
> > https://transfernow.net/131xk9g4u0jt
> >
>
> Is there native Windows player for those files?
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 5/6] avcodec/flicvideo: Fix off by 1 error in flic_decode_frame_24BPP()

2019-07-08 Thread Michael Niedermayer
On Sat, Jun 22, 2019 at 01:29:35AM +0200, Michael Niedermayer wrote:
> Fixes: out of array access
> Fixes: 
> 15360/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLIC_fuzzer-5653837190266880
> Fixes: 
> 15412/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLIC_fuzzer-5740537648250880
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/flicvideo.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 5/5] avcodec/vc1_block: Check for vlc error in vc1_decode_ac_coeff()

2019-07-08 Thread Michael Niedermayer
On Sun, Jun 16, 2019 at 12:00:56AM +0200, Michael Niedermayer wrote:
> Fixes: index -1 out of bounds for type 'const uint8_t [185][2]'
> Fixes: 
> 15250/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3IMAGE_fuzzer-5648992869810176
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/vc1_block.c | 34 ++
>  1 file changed, 26 insertions(+), 8 deletions(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/vc1_block: Fix invalid shifts in vc1_decode_i_blocks()

2019-07-08 Thread Michael Niedermayer
On Sat, Jun 22, 2019 at 02:21:43PM +0200, Michael Niedermayer wrote:
> Fixes: left shift of negative value -9
> Fixes: 
> 15299/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSS2_fuzzer-5660922678345728
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/vc1_block.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Will apply these 2 in a few days unless there are further objections, 
benchmarks, 
disassemblies showing a slowdown
My tests indicate as already stated that the asm code generated is identical


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct answer.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 3/3] avcodec/alac: Check lpc_quant

2019-07-08 Thread Michael Niedermayer
On Wed, Jun 19, 2019 at 01:53:03AM +0200, Michael Niedermayer wrote:
> lpc_quant of 0 produces undefined behavior, thus disallow this.
> If valid samples use this then such a sample would be quite
> usefull to confirm the correct handling of this.
> 
> Fixes: libavcodec/alac.c:218:25: runtime error: shift exponent -1 is negative
> Fixes: 
> 15273/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALAC_fuzzer-5656388535058432
> Fixes: 
> 15276/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALAC_fuzzer-5761238417539072
> Fixes: 
> 15315/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALAC_fuzzer-5767260766994432
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/alac.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".