Re: [FFmpeg-devel] [PATCH] ffprobe: use consistent string for unspecified color_range value

2017-07-31 Thread Tobias Rapp

On 24.07.2017 09:57, Tobias Rapp wrote:

Makes the handling of unspecified/unknown color_range values on stream
level consistent to the value used on frame level.

Signed-off-by: Tobias Rapp 
---
 ffprobe.c  | 2 +-
 tests/ref/fate/ffprobe_compact | 4 ++--
 tests/ref/fate/ffprobe_csv | 4 ++--
 tests/ref/fate/ffprobe_default | 4 ++--
 tests/ref/fate/ffprobe_flat| 4 ++--
 tests/ref/fate/ffprobe_ini | 4 ++--
 tests/ref/fate/mxf-probe-dnxhd | 2 +-
 tests/ref/fate/mxf-probe-dv25  | 2 +-
 8 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/ffprobe.c b/ffprobe.c
index 3d9f795..061f0a9 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -2499,7 +2499,7 @@ static int show_stream(WriterContext *w, AVFormatContext 
*fmt_ctx, int stream_id
 if (par->color_range != AVCOL_RANGE_UNSPECIFIED)
 print_str("color_range", 
av_color_range_name(par->color_range));
 else
-print_str_opt("color_range", "N/A");
+print_str_opt("color_range", 
av_color_range_name(par->color_range));

 if (par->color_space != AVCOL_SPC_UNSPECIFIED)
 print_str("color_space", av_color_space_name(par->color_space));
diff --git a/tests/ref/fate/ffprobe_compact b/tests/ref/fate/ffprobe_compact
index 910837d..4a0f4ee 100644
--- a/tests/ref/fate/ffprobe_compact
+++ b/tests/ref/fate/ffprobe_compact
@@ -27,6 +27,6 @@ 
frame|media_type=video|stream_index=1|key_frame=1|pkt_pts=6144|pkt_pts_time=0.12
 
packet|codec_type=video|stream_index=2|pts=6144|pts_time=0.12|dts=6144|dts_time=0.12|duration=2048|duration_time=0.04|convergence_duration=N/A|convergence_duration_time=N/A|size=3|pos=1023544|flags=K_
 
frame|media_type=video|stream_index=2|key_frame=1|pkt_pts=6144|pkt_pts_time=0.12|pkt_dts=6144|pkt_dts_time=0.12|best_effort_timestamp=6144|best_effort_timestamp_time=0.12|pkt_duration=2048|pkt_duration_time=0.04|pkt_pos=1023544|pkt_size=3|width=100|height=100|pix_fmt=rgb24|sample_aspect_ratio=1:1|pict_type=I|coded_picture_number=0|display_picture_number=0|interlaced_frame=0|top_field_first=0|repeat_pict=0|color_range=unknown|color_space=unknown|color_primaries=unknown|color_transfer=unknown|chroma_location=unspecified
 
stream|index=0|codec_name=pcm_s16le|profile=unknown|codec_type=audio|codec_time_base=1/44100|codec_tag_string=PSD[16]|codec_tag=0x10445350|sample_fmt=s16|sample_rate=44100|channels=1|channel_layout=unknown|bits_per_sample=16|id=N/A|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/44100|start_pts=0|start_time=0.00|duration_ts=N/A|duration=N/A|bit_rate=705600|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=6|nb_read_packets=6|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|tag:E=mc²|tag:encoder=Lavc
 pcm_s16le
-stream|index=1|codec_name=rawvideo|profile=unknown|codec_type=video|codec_time_base=1/25|codec_tag_string=RGB[24]|codec_tag=0x18424752|width=320|height=240|coded_width=320|coded_height=240|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=4:3|pix_fmt=rgb24|level=-99|color_range=N/A|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=unspecified|field_order=unknown|timecode=N/A|refs=1|id=N/A|r_frame_rate=25/1|avg_frame_rate=25/1|time_base=1/51200|start_pts=0|start_time=0.00|duration_ts=N/A|duration=N/A|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=4|nb_read_packets=4|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|tag:title=foobar|tag:duration_ts=field-and-tag
 s-conflict-attempt|tag:encoder=Lavc rawvideo
-stream|index=2|codec_name=rawvideo|profile=unknown|codec_type=video|codec_time_base=1/25|codec_tag_string=RGB[24]|codec_tag=0x18424752|width=100|height=100|coded_width=100|coded_height=100|has_b_frames=0|sample_aspect_ratio=1:1|display_aspect_ratio=1:1|pix_fmt=rgb24|level=-99|color_range=N/A|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=unspecified|field_order=unknown|timecode=N/A|refs=1|id=N/A|r_frame_rate=25/1|avg_frame_rate=25/1|time_base=1/51200|start_pts=0|start_time=0.00|duration_ts=N/A|duration=N/A|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=4|nb_read_packets=4|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|di

Re: [FFmpeg-devel] [PATCH] avfilter: add VIF filter

2017-07-31 Thread Ashish Pratap Singh
On Mon, Jul 31, 2017 at 3:24 AM, Ronald S. Bultje 
wrote:

> Hi,
>
> On Sun, Jul 30, 2017 at 1:46 PM, Ashish Pratap Singh 
> wrote:
>
> > On Sat, Jul 29, 2017 at 3:15 PM, Moritz Barsnick 
> wrote:
> > > On Sat, Jul 29, 2017 at 14:16:29 +0530, Ashish Pratap Singh wrote:
> > > > +av_log(ctx, AV_LOG_ERROR, "error: av_malloc failed for
> > > data_buf.\n");
> > >
> > > Are these messages of any help to anyone?
> > >
> > What would be an appropriate error message or should I don't write
> anything
> > at all?
>
>
> For -ENOMEM, you don't need to write an error message, the system error
> code is clear enough.
>
> Ok, thanks.

> Ronald
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libavcodec/mips: Improve avc idct8 msa function

2017-07-31 Thread Manojkumar Bhosale
LGTM

thx

-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of 
kaustubh.ra...@imgtec.com
Sent: Monday, July 31, 2017 12:07 PM
To: ffmpeg-devel@ffmpeg.org
Cc: Kaustubh Raste
Subject: [FFmpeg-devel] [PATCH] libavcodec/mips: Improve avc idct8 msa function

From: Kaustubh Raste 

Replace memset call with msa stores.

Signed-off-by: Kaustubh Raste 
---
 libavcodec/mips/h264idct_msa.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mips/h264idct_msa.c b/libavcodec/mips/h264idct_msa.c 
index 861befe..1e1a5c8 100644
--- a/libavcodec/mips/h264idct_msa.c
+++ b/libavcodec/mips/h264idct_msa.c
@@ -120,11 +120,12 @@ static void avc_idct8_addblk_msa(uint8_t *dst, int16_t 
*src, int32_t dst_stride)
 v4i32 res0_r, res1_r, res2_r, res3_r, res4_r, res5_r, res6_r, res7_r;
 v4i32 res0_l, res1_l, res2_l, res3_l, res4_l, res5_l, res6_l, res7_l;
 v16i8 dst0, dst1, dst2, dst3, dst4, dst5, dst6, dst7;
-v16i8 zeros = { 0 };
+v8i16 zeros = { 0 };
 
 src[0] += 32;
 
 LD_SH8(src, 8, src0, src1, src2, src3, src4, src5, src6, src7);
+ST_SH8(zeros, zeros, zeros, zeros, zeros, zeros, zeros, zeros, src, 
+ 8);
 
 vec0 = src0 + src4;
 vec1 = src0 - src4;
@@ -318,7 +319,6 @@ void ff_h264_idct8_addblk_msa(uint8_t *dst, int16_t *src,
   int32_t dst_stride)  {
 avc_idct8_addblk_msa(dst, src, dst_stride);
-memset(src, 0, 64 * sizeof(dctcoef));
 }
 
 void ff_h264_idct4x4_addblk_dc_msa(uint8_t *dst, int16_t *src,
--
1.7.9.5

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


[FFmpeg-devel] [PATCH] avfilter: add differencemax mode to the blend video filter

2017-07-31 Thread James Darnley
---
 Changelog  | 1 +
 doc/filters.texi   | 1 +
 libavfilter/blend.h| 1 +
 libavfilter/vf_blend.c | 4 
 4 files changed, 7 insertions(+)

diff --git a/Changelog b/Changelog
index 187ae7950a..894776d63a 100644
--- a/Changelog
+++ b/Changelog
@@ -29,6 +29,7 @@ version :
 - limiter video filter
 - libvmaf video filter
 - Dolby E decoder and SMPTE 337M demuxer
+- blend video filter gets differencemax mode
 
 version 3.3:
 - CrystalHD decoder moved to new decode API
diff --git a/doc/filters.texi b/doc/filters.texi
index 4c1ef0f485..149be70245 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -4859,6 +4859,7 @@ Available values for component modes are:
 @item darken
 @item difference
 @item difference128
+@item differencemax
 @item divide
 @item dodge
 @item freeze
diff --git a/libavfilter/blend.h b/libavfilter/blend.h
index 0f27b4d29d..97d2145eb7 100644
--- a/libavfilter/blend.h
+++ b/libavfilter/blend.h
@@ -34,6 +34,7 @@ enum BlendMode {
 BLEND_DARKEN,
 BLEND_DIFFERENCE,
 BLEND_DIFFERENCE128,
+BLEND_DIFFERENCEMAX,
 BLEND_DIVIDE,
 BLEND_DODGE,
 BLEND_EXCLUSION,
diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c
index 9bde3b22a1..efbb936961 100644
--- a/libavfilter/vf_blend.c
+++ b/libavfilter/vf_blend.c
@@ -73,6 +73,7 @@ typedef struct ThreadData {
 { "darken", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DARKEN}, 0, 0, 
FLAGS, "mode" },\
 { "difference", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DIFFERENCE}, 0, 0, 
FLAGS, "mode" },\
 { "difference128", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DIFFERENCE128}, 
0, 0, FLAGS, "mode" },\
+{ "differencemax", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DIFFERENCEMAX}, 
0, 0, FLAGS, "mode" },\
 { "divide", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DIVIDE}, 0, 0, 
FLAGS, "mode" },\
 { "dodge",  "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DODGE},  0, 0, 
FLAGS, "mode" },\
 { "exclusion",  "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_EXCLUSION},  0, 0, 
FLAGS, "mode" },\
@@ -245,6 +246,7 @@ DEFINE_BLEND8(negation,   255 - FFABS(255 - A - B))
 DEFINE_BLEND8(extremity,  FFABS(255 - A - B))
 DEFINE_BLEND8(difference, FFABS(A - B))
 DEFINE_BLEND8(difference128, av_clip_uint8(128 + A - B))
+DEFINE_BLEND8(differencemax, (A < B ? 0 : B > A ? 255 : 128))
 DEFINE_BLEND8(screen, SCREEN(1, A, B))
 DEFINE_BLEND8(overlay,(A < 128) ? MULTIPLY(2, A, B) : SCREEN(2, A, B))
 DEFINE_BLEND8(hardlight,  (B < 128) ? MULTIPLY(2, B, A) : SCREEN(2, B, A))
@@ -288,6 +290,7 @@ DEFINE_BLEND16(negation,   65535 - FFABS(65535 - A - B))
 DEFINE_BLEND16(extremity,  FFABS(65535 - A - B))
 DEFINE_BLEND16(difference, FFABS(A - B))
 DEFINE_BLEND16(difference128, av_clip_uint16(32768 + A - B))
+DEFINE_BLEND16(differencemax, (A < B ? 0 : B > A ? 65535 : 32768))
 DEFINE_BLEND16(screen, SCREEN(1, A, B))
 DEFINE_BLEND16(overlay,(A < 32768) ? MULTIPLY(2, A, B) : SCREEN(2, A, B))
 DEFINE_BLEND16(hardlight,  (B < 32768) ? MULTIPLY(2, B, A) : SCREEN(2, B, A))
@@ -457,6 +460,7 @@ void ff_blend_init(FilterParams *param, int is_16bit)
 case BLEND_DARKEN: param->blend = is_16bit ? blend_darken_16bit : 
blend_darken_8bit; break;
 case BLEND_DIFFERENCE: param->blend = is_16bit ? blend_difference_16bit : 
blend_difference_8bit; break;
 case BLEND_DIFFERENCE128: param->blend = is_16bit ? 
blend_difference128_16bit: blend_difference128_8bit; break;
+case BLEND_DIFFERENCEMAX: param->blend = is_16bit ? 
blend_differencemax_16bit: blend_differencemax_8bit; break;
 case BLEND_DIVIDE: param->blend = is_16bit ? blend_divide_16bit : 
blend_divide_8bit; break;
 case BLEND_DODGE:  param->blend = is_16bit ? blend_dodge_16bit  : 
blend_dodge_8bit;  break;
 case BLEND_EXCLUSION:  param->blend = is_16bit ? blend_exclusion_16bit  : 
blend_exclusion_8bit;  break;
-- 
2.13.3

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


Re: [FFmpeg-devel] [PATCH] avfilter: add differencemax mode to the blend video filter

2017-07-31 Thread Paul B Mahol
On 7/31/17, James Darnley  wrote:
> ---
>  Changelog  | 1 +
>  doc/filters.texi   | 1 +
>  libavfilter/blend.h| 1 +
>  libavfilter/vf_blend.c | 4 
>  4 files changed, 7 insertions(+)
>

How this compares with lut2 filter regarding speed?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/3] avcodec/vc2enc: assign some slice struct members init

2017-07-31 Thread James Darnley
---
 libavcodec/vc2enc.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c
index 7e0cb03eff..5dec88c81b 100644
--- a/libavcodec/vc2enc.c
+++ b/libavcodec/vc2enc.c
@@ -700,9 +700,6 @@ static int calc_slice_sizes(VC2EncContext *s)
 for (slice_y = 0; slice_y < s->num_y; slice_y++) {
 for (slice_x = 0; slice_x < s->num_x; slice_x++) {
 SliceArgs *args = &enc_args[s->num_x*slice_y + slice_x];
-args->ctx = s;
-args->x   = slice_x;
-args->y   = slice_y;
 args->bits_ceil  = s->slice_max_bytes << 3;
 args->bits_floor = s->slice_min_bytes << 3;
 memset(args->cache, 0, s->q_ceil*sizeof(*args->cache));
@@ -1201,6 +1198,17 @@ static av_cold int vc2_encode_init(AVCodecContext *avctx)
 s->slice_args = av_calloc(s->num_x*s->num_y, sizeof(SliceArgs));
 if (!s->slice_args)
 goto alloc_fail;
+else {
+int x, y;
+for (y = 0; y < s->num_y; y++) {
+for (x = 0; x < s->num_x; x++) {
+SliceArgs *args = &s->slice_args[s->num_x * y + x];
+args->ctx = s;
+args->x   = x;
+args->y   = y;
+}
+}
+}
 
 /* Lookup tables */
 s->coef_lut_len = 
av_malloc(COEF_LUT_TAB*(s->q_ceil+1)*sizeof(*s->coef_lut_len));
-- 
2.13.3

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


[FFmpeg-devel] [PATCH 3/3] avcodec/vc2enc: constant quantiser encoding

2017-07-31 Thread James Darnley
---
 libavcodec/vc2enc.c | 92 +++--
 1 file changed, 90 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c
index 5dec88c81b..ca8c8075fd 100644
--- a/libavcodec/vc2enc.c
+++ b/libavcodec/vc2enc.c
@@ -182,6 +182,8 @@ typedef struct VC2EncContext {
 /* Parse code state */
 uint32_t next_parse_offset;
 enum DiracParseCodes last_parse_code;
+
+int const_quant;
 } VC2EncContext;
 
 static av_always_inline void put_vc2_ue_uint(PutBitContext *pb, uint32_t val)
@@ -933,6 +935,71 @@ static int dwt_plane(AVCodecContext *avctx, void *arg)
 return 0;
 }
 
+static int constant_quantiser_slice_sizes(VC2EncContext *s, int quant_idx)
+{
+int bytes = 0;
+
+for (int i = 0; i < s->num_x * s->num_y; i++) {
+SliceArgs *slice = &s->slice_args[i];
+int x, y;
+uint8_t quants[MAX_DWT_LEVELS][4];
+int bits = 0, p, level, orientation;
+
+bits += 8*s->prefix_bytes;
+bits += 8; /* quant_idx */
+
+for (level = 0; level < s->wavelet_depth; level++)
+for (orientation = !!level; orientation < 4; orientation++)
+quants[level][orientation] = FFMAX(quant_idx - 
s->quant[level][orientation], 0);
+
+for (p = 0; p < 3; p++) {
+int bytes_start, bytes_len, pad_s, pad_c;
+bytes_start = bits >> 3;
+bits += 8;
+for (level = 0; level < s->wavelet_depth; level++) {
+for (orientation = !!level; orientation < 4; orientation++) {
+SubBand *b = &s->plane[p].band[level][orientation];
+
+const int q_idx = quants[level][orientation];
+const uint8_t *len_lut = 
&s->coef_lut_len[q_idx*COEF_LUT_TAB];
+const int qfactor = ff_dirac_qscale_tab[q_idx];
+
+const int left   = b->width  * slice->x/ s->num_x;
+const int right  = b->width  *(slice->x+1) / s->num_x;
+const int top= b->height * slice->y/ s->num_y;
+const int bottom = b->height *(slice->y+1) / s->num_y;
+
+dwtcoef *buf = b->buf + top * b->stride;
+
+for (y = top; y < bottom; y++) {
+for (x = left; x < right; x++) {
+uint32_t c_abs = FFABS(buf[x]);
+if (c_abs < COEF_LUT_TAB) {
+bits += len_lut[c_abs];
+} else {
+c_abs = QUANT(c_abs, qfactor);
+bits += count_vc2_ue_uint(c_abs);
+bits += !!c_abs;
+}
+}
+buf += b->stride;
+}
+}
+}
+bits += FFALIGN(bits, 8) - bits;
+bytes_len = (bits >> 3) - bytes_start - 1;
+pad_s = FFALIGN(bytes_len, s->size_scaler)/s->size_scaler;
+pad_c = (pad_s*s->size_scaler) - bytes_len;
+bits += pad_c*8;
+}
+
+slice->bytes = SSIZE_ROUND(bits >> 3);
+bytes += SSIZE_ROUND(bits >> 3);
+}
+
+return bytes;
+}
+
 static int encode_frame(VC2EncContext *s, AVPacket *avpkt, const AVFrame 
*frame,
 const char *aux_data, const int header_size, int field)
 {
@@ -951,7 +1018,13 @@ static int encode_frame(VC2EncContext *s, AVPacket 
*avpkt, const AVFrame *frame,
   sizeof(TransformArgs));
 
 /* Calculate per-slice quantizers and sizes */
-max_frame_bytes = header_size + calc_slice_sizes(s);
+max_frame_bytes = header_size;
+if(s->avctx->flags & AV_CODEC_FLAG_QSCALE) {
+max_frame_bytes += constant_quantiser_slice_sizes(s, s->const_quant);
+}
+else {
+max_frame_bytes += calc_slice_sizes(s);
+}
 
 if (field < 2) {
 ret = ff_alloc_packet2(s->avctx, avpkt,
@@ -1060,7 +1133,7 @@ static av_cold int vc2_encode_init(AVCodecContext *avctx)
 {
 Plane *p;
 SubBand *b;
-int i, j, level, o, shift;
+int i, j, level, o, shift, const_quant = 0;
 const AVPixFmtDescriptor *fmt = av_pix_fmt_desc_get(avctx->pix_fmt);
 const int depth = fmt->comp[0].depth;
 VC2EncContext *s = avctx->priv_data;
@@ -1108,6 +1181,20 @@ static av_cold int vc2_encode_init(AVCodecContext *avctx)
 if (s->interlaced)
 av_log(avctx, AV_LOG_WARNING, "Interlacing enabled!\n");
 
+if (avctx->flags & AV_CODEC_FLAG_QSCALE) {
+const int quant_max = FF_ARRAY_ELEMS(ff_dirac_qscale_tab);
+const_quant = avctx->global_quality / FF_QP2LAMBDA;
+
+if (const_quant < 0 || const_quant >= quant_max) {
+av_log(avctx, AV_LOG_ERROR, "constant quantiser (%d) outside valid 
range [%d..%d]\n",
+const_quant, 0, quant_max);
+return AVERROR(EINVAL);
+

[FFmpeg-devel] [PATCH 1/3] avcodec/vc2enc: correct the returned error code for invalid options

2017-07-31 Thread James Darnley
---
 libavcodec/vc2enc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c
index 96e27d93ed..7e0cb03eff 100644
--- a/libavcodec/vc2enc.c
+++ b/libavcodec/vc2enc.c
@@ -1114,13 +1114,13 @@ static av_cold int vc2_encode_init(AVCodecContext 
*avctx)
 if ((s->slice_width  & (s->slice_width  - 1)) ||
 (s->slice_height & (s->slice_height - 1))) {
 av_log(avctx, AV_LOG_ERROR, "Slice size is not a power of two!\n");
-return AVERROR_UNKNOWN;
+return AVERROR(EINVAL);
 }
 
 if ((s->slice_width > avctx->width) ||
 (s->slice_height > avctx->height)) {
 av_log(avctx, AV_LOG_ERROR, "Slice size is bigger than the image!\n");
-return AVERROR_UNKNOWN;
+return AVERROR(EINVAL);
 }
 
 if (s->base_vf <= 0) {
@@ -1130,7 +1130,7 @@ static av_cold int vc2_encode_init(AVCodecContext *avctx)
 } else {
 av_log(avctx, AV_LOG_WARNING, "Given format does not strictly 
comply with "
"the specifications, decrease strictness to use it.\n");
-return AVERROR_UNKNOWN;
+return AVERROR(EINVAL);
 }
 } else {
 av_log(avctx, AV_LOG_INFO, "Selected base video format = %i (%s)\n",
-- 
2.13.3

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


[FFmpeg-devel] [PATCH 02/14] lavfi/framesync2: add dualinput helper functions.

2017-07-31 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/framesync2.c | 84 
 libavfilter/framesync2.h | 20 
 2 files changed, 83 insertions(+), 21 deletions(-)


Nothing changed much.


diff --git a/libavfilter/framesync2.c b/libavfilter/framesync2.c
index 0e9f6f210c..b968679c42 100644
--- a/libavfilter/framesync2.c
+++ b/libavfilter/framesync2.c
@@ -46,6 +46,8 @@ enum {
 STATE_EOF,
 };
 
+static int consume_from_fifos(FFFrameSync *fs);
+
 int ff_framesync2_init(FFFrameSync *fs, AVFilterContext *parent, unsigned 
nb_in)
 {
 /* For filters with several outputs, we will not be able to assume which
@@ -127,30 +129,20 @@ int ff_framesync2_configure(FFFrameSync *fs)
 return 0;
 }
 
-static void framesync_advance(FFFrameSync *fs)
+static int framesync_advance(FFFrameSync *fs)
 {
-int latest;
 unsigned i;
 int64_t pts;
+int ret;
 
-if (fs->eof)
-return;
-while (!fs->frame_ready) {
-latest = -1;
-for (i = 0; i < fs->nb_in; i++) {
-if (!fs->in[i].have_next) {
-if (latest < 0 || fs->in[i].pts < fs->in[latest].pts)
-latest = i;
-}
-}
-if (latest >= 0) {
-fs->in_request = latest;
-break;
-}
+while (!(fs->frame_ready || fs->eof)) {
+ret = consume_from_fifos(fs);
+if (ret <= 0)
+return ret;
 
-pts = fs->in[0].pts_next;
-for (i = 1; i < fs->nb_in; i++)
-if (fs->in[i].pts_next < pts)
+pts = INT64_MAX;
+for (i = 0; i < fs->nb_in; i++)
+if (fs->in[i].have_next && fs->in[i].pts_next < pts)
 pts = fs->in[i].pts_next;
 if (pts == INT64_MAX) {
 framesync_eof(fs);
@@ -181,6 +173,7 @@ static void framesync_advance(FFFrameSync *fs)
 fs->frame_ready = 0;
 fs->pts = pts;
 }
+return 0;
 }
 
 static int64_t framesync_pts_extrapolate(FFFrameSync *fs, unsigned in,
@@ -264,7 +257,7 @@ void ff_framesync2_uninit(FFFrameSync *fs)
 av_freep(&fs->in);
 }
 
-int ff_framesync2_activate(FFFrameSync *fs)
+static int consume_from_fifos(FFFrameSync *fs)
 {
 AVFilterContext *ctx = fs->parent;
 AVFrame *frame = NULL;
@@ -300,8 +293,16 @@ int ff_framesync2_activate(FFFrameSync *fs)
 ff_inlink_request_frame(ctx->inputs[i]);
 return 0;
 }
+return 1;
+}
 
-framesync_advance(fs);
+int ff_framesync2_activate(FFFrameSync *fs)
+{
+int ret;
+
+ret = framesync_advance(fs);
+if (ret < 0)
+return ret;
 if (fs->eof || !fs->frame_ready)
 return 0;
 ret = fs->on_event(fs);
@@ -311,3 +312,44 @@ int ff_framesync2_activate(FFFrameSync *fs)
 
 return 0;
 }
+
+int ff_framesync2_init_dualinput(FFFrameSync *fs, AVFilterContext *parent)
+{
+int ret;
+
+ret = ff_framesync2_init(fs, parent, 2);
+if (ret < 0)
+return ret;
+fs->in[0].time_base = parent->inputs[0]->time_base;
+fs->in[1].time_base = parent->inputs[1]->time_base;
+fs->in[0].sync   = 2;
+fs->in[0].before = EXT_STOP;
+fs->in[0].after  = EXT_INFINITY;
+fs->in[1].sync   = 1;
+fs->in[1].before = EXT_NULL;
+fs->in[1].after  = EXT_INFINITY;
+return 0;
+}
+
+int ff_framesync2_dualinput_get(FFFrameSync *fs, AVFrame **f0, AVFrame **f1)
+{
+AVFilterContext *ctx = fs->parent;
+AVFrame *mainpic = NULL, *secondpic = NULL;
+int ret = 0;
+
+if ((ret = ff_framesync2_get_frame(fs, 0, &mainpic,   1)) < 0 ||
+(ret = ff_framesync2_get_frame(fs, 1, &secondpic, 0)) < 0) {
+av_frame_free(&mainpic);
+return ret;
+}
+ret = ff_inlink_make_frame_writable(ctx->inputs[0], &mainpic);
+if (ret < 0)
+return ret;
+av_assert0(mainpic);
+mainpic->pts = av_rescale_q(fs->pts, fs->time_base, 
ctx->outputs[0]->time_base);
+if (ctx->is_disabled)
+secondpic = NULL;
+*f0 = mainpic;
+*f1 = secondpic;
+return 0;
+}
diff --git a/libavfilter/framesync2.h b/libavfilter/framesync2.h
index 2b37636ebb..d24bd7abe8 100644
--- a/libavfilter/framesync2.h
+++ b/libavfilter/framesync2.h
@@ -245,4 +245,24 @@ int ff_framesync2_get_frame(FFFrameSync *fs, unsigned in, 
AVFrame **rframe,
  */
 int ff_framesync2_activate(FFFrameSync *fs);
 
+/**
+ * Initialize a frame sync structure for dualinput.
+ *
+ * Compared to generic framesync, dualinput assumes the first input is the
+ * main one and the filtering is performed on it. The first input will be
+ * the only one with sync set and generic timeline support will just pass it
+ * unchanged when disabled.
+ *
+ * Equivalent to ff_framesync2_init(fs, parent, 2) then setting the time
+ * base, sync and ext modes on the inputs.
+ */
+int ff_framesync2_init_dualinput(FFFrameSync *fs, AVFilterContext *parent);
+
+/**
+ * @param f0  used to return the main frame
+ * @param f1  used to return the second frame, or NULL if disabled

[FFmpeg-devel] [PATCH 03/14] lavfi/vf_overlay: move to framesync2.

2017-07-31 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/Makefile |  2 +-
 libavfilter/vf_overlay.c | 69 ++--
 2 files changed, 39 insertions(+), 32 deletions(-)

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index b4cdd303bd..2c7f715166 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -244,7 +244,7 @@ OBJS-$(CONFIG_OCR_FILTER)+= vf_ocr.o
 OBJS-$(CONFIG_OCV_FILTER)+= vf_libopencv.o
 OBJS-$(CONFIG_OPENCL)+= deshake_opencl.o 
unsharp_opencl.o
 OBJS-$(CONFIG_OSCILLOSCOPE_FILTER)   += vf_datascope.o
-OBJS-$(CONFIG_OVERLAY_FILTER)+= vf_overlay.o dualinput.o 
framesync.o
+OBJS-$(CONFIG_OVERLAY_FILTER)+= vf_overlay.o framesync2.o
 OBJS-$(CONFIG_OWDENOISE_FILTER)  += vf_owdenoise.o
 OBJS-$(CONFIG_PAD_FILTER)+= vf_pad.o
 OBJS-$(CONFIG_PALETTEGEN_FILTER) += vf_palettegen.o
diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index ad292a61c1..c1d2a21c05 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -36,8 +36,8 @@
 #include "libavutil/opt.h"
 #include "libavutil/timestamp.h"
 #include "internal.h"
-#include "dualinput.h"
 #include "drawutils.h"
+#include "framesync2.h"
 #include "video.h"
 
 static const char *const var_names[] = {
@@ -121,7 +121,7 @@ typedef struct OverlayContext {
 int format; ///< OverlayFormat
 int eval_mode;  ///< EvalMode
 
-FFDualInputContext dinput;
+FFFrameSync fs;
 
 int main_pix_step[4];   ///< steps per pixel for each plane of the 
main output
 int overlay_pix_step[4];///< steps per pixel for each plane of the 
overlay
@@ -132,6 +132,8 @@ typedef struct OverlayContext {
 char *x_expr, *y_expr;
 
 int eof_action; ///< action to take on EOF from source
+int opt_shortest;
+int opt_repeatlast;
 
 AVExpr *x_pexpr, *y_pexpr;
 
@@ -142,7 +144,7 @@ static av_cold void uninit(AVFilterContext *ctx)
 {
 OverlayContext *s = ctx->priv;
 
-ff_dualinput_uninit(&s->dinput);
+ff_framesync2_uninit(&s->fs);
 av_expr_free(s->x_pexpr); s->x_pexpr = NULL;
 av_expr_free(s->y_pexpr); s->y_pexpr = NULL;
 }
@@ -390,14 +392,20 @@ static int config_output(AVFilterLink *outlink)
 OverlayContext *s = ctx->priv;
 int ret;
 
-if ((ret = ff_dualinput_init(ctx, &s->dinput)) < 0)
+if ((ret = ff_framesync2_init_dualinput(&s->fs, ctx)) < 0)
 return ret;
+if (s->opt_shortest)
+s->fs.in[0].after = s->fs.in[1].after = EXT_STOP;
+if (!s->opt_repeatlast) {
+s->fs.in[1].after = EXT_NULL;
+s->fs.in[1].sync  = 0;
+}
 
 outlink->w = ctx->inputs[MAIN]->w;
 outlink->h = ctx->inputs[MAIN]->h;
 outlink->time_base = ctx->inputs[MAIN]->time_base;
 
-return 0;
+return ff_framesync2_configure(&s->fs);
 }
 
 // divide by 255 and round to nearest
@@ -766,11 +774,19 @@ static int config_input_main(AVFilterLink *inlink)
 return 0;
 }
 
-static AVFrame *do_blend(AVFilterContext *ctx, AVFrame *mainpic,
- const AVFrame *second)
+static int do_blend(FFFrameSync *fs)
 {
+AVFilterContext *ctx = fs->parent;
+AVFrame *mainpic, *second;
 OverlayContext *s = ctx->priv;
 AVFilterLink *inlink = ctx->inputs[0];
+int ret;
+
+ret = ff_framesync2_dualinput_get(fs, &mainpic, &second);
+if (ret < 0)
+return ret;
+if (!second)
+return ff_filter_frame(ctx->outputs[0], mainpic);
 
 if (s->eval_mode == EVAL_MODE_FRAME) {
 int64_t pos = mainpic->pkt_pos;
@@ -795,39 +811,32 @@ static AVFrame *do_blend(AVFilterContext *ctx, AVFrame 
*mainpic,
 if (s->x < mainpic->width  && s->x + second->width  >= 0 ||
 s->y < mainpic->height && s->y + second->height >= 0)
 s->blend_image(ctx, mainpic, second, s->x, s->y);
-return mainpic;
-}
-
-static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
-{
-OverlayContext *s = inlink->dst->priv;
-av_log(inlink->dst, AV_LOG_DEBUG, "Incoming frame (time:%s) from link 
#%d\n", av_ts2timestr(inpicref->pts, &inlink->time_base), 
FF_INLINK_IDX(inlink));
-return ff_dualinput_filter_frame(&s->dinput, inlink, inpicref);
-}
-
-static int request_frame(AVFilterLink *outlink)
-{
-OverlayContext *s = outlink->src->priv;
-return ff_dualinput_request_frame(&s->dinput, outlink);
+return ff_filter_frame(ctx->outputs[0], mainpic);
 }
 
 static av_cold int init(AVFilterContext *ctx)
 {
 OverlayContext *s = ctx->priv;
 
-if (!s->dinput.repeatlast || s->eof_action == EOF_ACTION_PASS) {
-s->dinput.repeatlast = 0;
+if (!s->opt_repeatlast || s->eof_action == EOF_ACTION_PASS) {
+s->opt_repeatlast = 0;
 s->eof_action = EOF_ACTION_PASS;
 }
-if (s->dinput.shortest || s->eof_action == EOF_ACTION_ENDALL) {
-s->dinput.shortest = 1;
+if (s

[FFmpeg-devel] [PATCH 01/14] lavfi: add f_streamsync dependency.

2017-07-31 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 4d61d7835e..b4cdd303bd 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -301,7 +301,7 @@ OBJS-$(CONFIG_SPLIT_FILTER)  += split.o
 OBJS-$(CONFIG_SPP_FILTER)+= vf_spp.o
 OBJS-$(CONFIG_SSIM_FILTER)   += vf_ssim.o dualinput.o 
framesync.o
 OBJS-$(CONFIG_STEREO3D_FILTER)   += vf_stereo3d.o
-OBJS-$(CONFIG_STREAMSELECT_FILTER)   += f_streamselect.o
+OBJS-$(CONFIG_STREAMSELECT_FILTER)   += f_streamselect.o framesync.o
 OBJS-$(CONFIG_SUBTITLES_FILTER)  += vf_subtitles.o
 OBJS-$(CONFIG_SUPER2XSAI_FILTER) += vf_super2xsai.o
 OBJS-$(CONFIG_SWAPRECT_FILTER)   += vf_swaprect.o
-- 
2.13.2

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


[FFmpeg-devel] [PATCH 14/14] lavfi: remove dualinput.

2017-07-31 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/dualinput.c | 90 -
 libavfilter/dualinput.h | 46 -
 2 files changed, 136 deletions(-)
 delete mode 100644 libavfilter/dualinput.c
 delete mode 100644 libavfilter/dualinput.h

diff --git a/libavfilter/dualinput.c b/libavfilter/dualinput.c
deleted file mode 100644
index 44750973a6..00
--- a/libavfilter/dualinput.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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
- */
-
-#include "dualinput.h"
-#include "libavutil/timestamp.h"
-
-static int process_frame(FFFrameSync *fs)
-{
-AVFilterContext *ctx = fs->parent;
-FFDualInputContext *s = fs->opaque;
-AVFrame *mainpic = NULL, *secondpic = NULL;
-int ret = 0;
-
-if ((ret = ff_framesync_get_frame(&s->fs, 0, &mainpic,   1)) < 0 ||
-(ret = ff_framesync_get_frame(&s->fs, 1, &secondpic, 0)) < 0) {
-av_frame_free(&mainpic);
-return ret;
-}
-av_assert0(mainpic);
-mainpic->pts = av_rescale_q(s->fs.pts, s->fs.time_base, 
ctx->outputs[0]->time_base);
-if (secondpic && !ctx->is_disabled)
-mainpic = s->process(ctx, mainpic, secondpic);
-ret = ff_filter_frame(ctx->outputs[0], mainpic);
-av_assert1(ret != AVERROR(EAGAIN));
-return ret;
-}
-
-int ff_dualinput_init(AVFilterContext *ctx, FFDualInputContext *s)
-{
-FFFrameSyncIn *in;
-int ret;
-
-if ((ret = ff_framesync_init(&s->fs, ctx, 2)) < 0)
-return ret;
-
-in = s->fs.in;
-s->fs.opaque = s;
-s->fs.on_event = process_frame;
-in[0].time_base = ctx->inputs[0]->time_base;
-in[1].time_base = ctx->inputs[1]->time_base;
-in[0].sync   = 2;
-in[0].before = EXT_STOP;
-in[0].after  = EXT_INFINITY;
-in[1].sync   = 1;
-in[1].before = EXT_NULL;
-in[1].after  = EXT_INFINITY;
-
-if (s->shortest)
-in[0].after = in[1].after = EXT_STOP;
-if (!s->repeatlast) {
-in[1].after = EXT_NULL;
-in[1].sync  = 0;
-}
-if (s->skip_initial_unpaired) {
-in[1].before = EXT_STOP;
-}
-
-return ff_framesync_configure(&s->fs);
-}
-
-int ff_dualinput_filter_frame(FFDualInputContext *s,
-   AVFilterLink *inlink, AVFrame *in)
-{
-return ff_framesync_filter_frame(&s->fs, inlink, in);
-}
-
-int ff_dualinput_request_frame(FFDualInputContext *s, AVFilterLink *outlink)
-{
-return ff_framesync_request_frame(&s->fs, outlink);
-}
-
-void ff_dualinput_uninit(FFDualInputContext *s)
-{
-ff_framesync_uninit(&s->fs);
-}
diff --git a/libavfilter/dualinput.h b/libavfilter/dualinput.h
deleted file mode 100644
index fcde0d6aa1..00
--- a/libavfilter/dualinput.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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
- */
-
-/**
- * @file
- * Double input streams helper for filters
- */
-
-#ifndef AVFILTER_DUALINPUT_H
-#define AVFILTER_DUALINPUT_H
-
-#include 
-#include "bufferqueue.h"
-#include "framesync.h"
-#include "internal.h"
-
-typedef struct FFDualInputContext {
-FFFrameSync fs;
-
-AVFrame *(*process)(AVFilterContext *ctx, AVFrame *main, const AVFrame 
*second);
-int shortest;   ///< terminate stream when the second input 
terminates
-int repeatlast; ///< repeat last second frame
-int skip_initial_unpaired;  ///< Skip initial frames that do not have a 
2nd input
-} FFDualInputContext;
-
-int ff_dualinput_init(AVFilterContext *ctx, FFDualInputContext *s);
-int ff_dualinput_filter_frame(FF

[FFmpeg-devel] [PATCH 04/14] lavfi: add a preinit callback to filters.

2017-07-31 Thread Nicolas George
It is necessary for filters with child objects, to set the class
and default options values.

Signed-off-by: Nicolas George 
---
 libavfilter/avfilter.c |  8 
 libavfilter/avfilter.h | 15 +++
 2 files changed, 23 insertions(+)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 185ba8df00..dcd975e104 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -692,6 +692,7 @@ static int default_execute(AVFilterContext *ctx, 
avfilter_action_func *func, voi
 AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name)
 {
 AVFilterContext *ret;
+int preinited = 0;
 
 if (!filter)
 return NULL;
@@ -708,6 +709,11 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, 
const char *inst_name)
 if (!ret->priv)
 goto err;
 }
+if (filter->preinit) {
+if (filter->preinit(ret) < 0)
+goto err;
+preinited = 1;
+}
 
 av_opt_set_defaults(ret);
 if (filter->priv_class) {
@@ -745,6 +751,8 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, 
const char *inst_name)
 return ret;
 
 err:
+if (preinited)
+filter->uninit(ret);
 av_freep(&ret->inputs);
 av_freep(&ret->input_pads);
 ret->nb_inputs = 0;
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 60662c19ac..73a723d583 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -195,6 +195,21 @@ typedef struct AVFilter {
  */
 
 /**
+ * Filter pre-initialization function
+ *
+ * This callback will be called immediately after the filter context is
+ * allocated, to allow allocating and initing sub-objects.
+ *
+ * If this callback is not NULL, the uninit callback will be called on
+ * allocation failure.
+ *
+ * @return 0 on success,
+ * AVERROR code on failure (but the code will be
+ *   dropped and treated as ENOMEM by the calling code)
+ */
+int (*preinit)(AVFilterContext *ctx);
+
+/**
  * Filter initialization function.
  *
  * This callback will be called only once during the filter lifetime, after
-- 
2.13.2

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


[FFmpeg-devel] [PATCH 06/14] lavfi/framesync2: add common options.

2017-07-31 Thread Nicolas George
Also add functions and macros to help filters chaining these
options to their own.

Signed-off-by: Nicolas George 
---
 libavfilter/framesync2.c | 55 ++--
 libavfilter/framesync2.h | 44 +-
 2 files changed, 96 insertions(+), 3 deletions(-)

diff --git a/libavfilter/framesync2.c b/libavfilter/framesync2.c
index b968679c42..59c753c072 100644
--- a/libavfilter/framesync2.c
+++ b/libavfilter/framesync2.c
@@ -19,24 +19,43 @@
  */
 
 #include "libavutil/avassert.h"
+#include "libavutil/opt.h"
 #include "avfilter.h"
 #include "filters.h"
 #include "framesync2.h"
 #include "internal.h"
 
 #define OFFSET(member) offsetof(FFFrameSync, member)
+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
+
+enum EOFAction {
+EOF_ACTION_REPEAT,
+EOF_ACTION_ENDALL,
+EOF_ACTION_PASS
+};
 
 static const char *framesync_name(void *ptr)
 {
 return "framesync";
 }
 
+static const AVOption framesync_options[] = {
+{ "eof_action", "Action to take when encountering EOF from secondary input 
",
+OFFSET(opt_eof_action), AV_OPT_TYPE_INT, { .i64 = EOF_ACTION_REPEAT },
+EOF_ACTION_REPEAT, EOF_ACTION_PASS, .flags = FLAGS, "eof_action" },
+{ "repeat", "Repeat the previous frame.",   0, AV_OPT_TYPE_CONST, { 
.i64 = EOF_ACTION_REPEAT }, .flags = FLAGS, "eof_action" },
+{ "endall", "End both streams.",0, AV_OPT_TYPE_CONST, { 
.i64 = EOF_ACTION_ENDALL }, .flags = FLAGS, "eof_action" },
+{ "pass",   "Pass through the main input.", 0, AV_OPT_TYPE_CONST, { 
.i64 = EOF_ACTION_PASS },   .flags = FLAGS, "eof_action" },
+{ "shortest", "force termination when the shortest input terminates", 
OFFSET(opt_shortest), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
+{ "repeatlast", "repeat overlay of the last overlay frame", 
OFFSET(opt_repeatlast), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },
+{ NULL }
+};
 static const AVClass framesync_class = {
 .version   = LIBAVUTIL_VERSION_INT,
 .class_name= "framesync",
 .item_name = framesync_name,
 .category  = AV_CLASS_CATEGORY_FILTER,
-.option= NULL,
+.option= framesync_options,
 .parent_log_context_offset = OFFSET(parent),
 };
 
@@ -48,6 +67,19 @@ enum {
 
 static int consume_from_fifos(FFFrameSync *fs);
 
+const AVClass *framesync2_get_class(void)
+{
+return &framesync_class;
+}
+
+void ff_framesync2_preinit(FFFrameSync *fs)
+{
+if (fs->class)
+return;
+fs->class  = &framesync_class;
+av_opt_set_defaults(fs);
+}
+
 int ff_framesync2_init(FFFrameSync *fs, AVFilterContext *parent, unsigned 
nb_in)
 {
 /* For filters with several outputs, we will not be able to assume which
@@ -55,7 +87,7 @@ int ff_framesync2_init(FFFrameSync *fs, AVFilterContext 
*parent, unsigned nb_in)
ff_outlink_set_status(). To be designed when needed. */
 av_assert0(parent->nb_outputs == 1);
 
-fs->class  = &framesync_class;
+ff_framesync2_preinit(fs);
 fs->parent = parent;
 fs->nb_in  = nb_in;
 
@@ -93,6 +125,25 @@ int ff_framesync2_configure(FFFrameSync *fs)
 unsigned i;
 int64_t gcd, lcm;
 
+if (!fs->opt_repeatlast || fs->opt_eof_action == EOF_ACTION_PASS) {
+fs->opt_repeatlast = 0;
+fs->opt_eof_action = EOF_ACTION_PASS;
+}
+if (fs->opt_shortest || fs->opt_eof_action == EOF_ACTION_ENDALL) {
+fs->opt_shortest = 1;
+fs->opt_eof_action = EOF_ACTION_ENDALL;
+}
+if (fs->opt_shortest) {
+for (i = 0; i < fs->nb_in; i++)
+fs->in[i].after = EXT_STOP;
+}
+if (!fs->opt_repeatlast) {
+for (i = 1; i < fs->nb_in; i++) {
+fs->in[i].after = EXT_NULL;
+fs->in[i].sync  = 0;
+}
+}
+
 if (!fs->time_base.num) {
 for (i = 0; i < fs->nb_in; i++) {
 if (fs->in[i].sync) {
diff --git a/libavfilter/framesync2.h b/libavfilter/framesync2.h
index d24bd7abe8..5a43e0c4bd 100644
--- a/libavfilter/framesync2.h
+++ b/libavfilter/framesync2.h
@@ -196,12 +196,30 @@ typedef struct FFFrameSync {
  */
 FFFrameSyncIn *in;
 
+int opt_repeatlast;
+int opt_shortest;
+int opt_eof_action;
+
 } FFFrameSync;
 
 /**
- * Initialize a frame sync structure.
+ * Get the class for the framesync2 object.
+ */
+const AVClass *framesync2_get_class(void);
+
+/**
+ * Pre-initialize a frame sync structure.
  *
+ * It sets the class pointer and inits the options to their default values.
  * The entire structure is expected to be already set to 0.
+ * This step is optional, but necessary to use the options.
+ */
+void ff_framesync2_preinit(FFFrameSync *fs);
+
+/**
+ * Initialize a frame sync structure.
+ *
+ * The entire structure is expected to be already set to 0 or preinited.
  *
  * @param  fs  frame sync structure to initialize
  * @param  parent  parent AV

[FFmpeg-devel] [PATCH 08/14] lavfi/vf_blend: convert to framesync2.

2017-07-31 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/Makefile   |  4 ++--
 libavfilter/vf_blend.c | 48 +++-
 2 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 2c7f715166..8cfbe10ea4 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -136,7 +136,7 @@ OBJS-$(CONFIG_BENCH_FILTER)  += f_bench.o
 OBJS-$(CONFIG_BITPLANENOISE_FILTER)  += vf_bitplanenoise.o
 OBJS-$(CONFIG_BLACKDETECT_FILTER)+= vf_blackdetect.o
 OBJS-$(CONFIG_BLACKFRAME_FILTER) += vf_blackframe.o
-OBJS-$(CONFIG_BLEND_FILTER)  += vf_blend.o dualinput.o 
framesync.o
+OBJS-$(CONFIG_BLEND_FILTER)  += vf_blend.o framesync2.o
 OBJS-$(CONFIG_BOXBLUR_FILTER)+= vf_boxblur.o
 OBJS-$(CONFIG_BWDIF_FILTER)  += vf_bwdif.o
 OBJS-$(CONFIG_CHROMAKEY_FILTER)  += vf_chromakey.o
@@ -306,7 +306,7 @@ OBJS-$(CONFIG_SUBTITLES_FILTER)  += 
vf_subtitles.o
 OBJS-$(CONFIG_SUPER2XSAI_FILTER) += vf_super2xsai.o
 OBJS-$(CONFIG_SWAPRECT_FILTER)   += vf_swaprect.o
 OBJS-$(CONFIG_SWAPUV_FILTER) += vf_swapuv.o
-OBJS-$(CONFIG_TBLEND_FILTER) += vf_blend.o dualinput.o 
framesync.o
+OBJS-$(CONFIG_TBLEND_FILTER) += vf_blend.o framesync2.o
 OBJS-$(CONFIG_TELECINE_FILTER)   += vf_telecine.o
 OBJS-$(CONFIG_THRESHOLD_FILTER)  += vf_threshold.o framesync2.o
 OBJS-$(CONFIG_THUMBNAIL_FILTER)  += vf_thumbnail.o
diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c
index 9bde3b22a1..24f8729892 100644
--- a/libavfilter/vf_blend.c
+++ b/libavfilter/vf_blend.c
@@ -25,8 +25,8 @@
 #include "avfilter.h"
 #include "bufferqueue.h"
 #include "formats.h"
+#include "framesync2.h"
 #include "internal.h"
-#include "dualinput.h"
 #include "video.h"
 #include "blend.h"
 
@@ -35,7 +35,7 @@
 
 typedef struct BlendContext {
 const AVClass *class;
-FFDualInputContext dinput;
+FFFrameSync fs;
 int hsub, vsub; ///< chroma subsampling values
 int nb_planes;
 char *all_expr;
@@ -114,12 +114,10 @@ typedef struct ThreadData {
 
 static const AVOption blend_options[] = {
 COMMON_OPTIONS,
-{ "shortest","force termination when the shortest input terminates", 
OFFSET(dinput.shortest), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
-{ "repeatlast",  "repeat last bottom frame", OFFSET(dinput.repeatlast), 
AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGS },
 { NULL }
 };
 
-AVFILTER_DEFINE_CLASS(blend);
+FRAMESYNC_DEFINE_CLASS(blend, BlendContext, fs);
 
 #define COPY(src)\
 static void blend_copy ## src(const uint8_t *top, ptrdiff_t top_linesize,\
@@ -405,13 +403,28 @@ static AVFrame *blend_frame(AVFilterContext *ctx, AVFrame 
*top_buf,
 return dst_buf;
 }
 
+static int blend_frame_for_dualinput(FFFrameSync *fs)
+{
+AVFilterContext *ctx = fs->parent;
+AVFrame *top_buf, *bottom_buf, *dst_buf;
+int ret;
+
+ret = ff_framesync2_dualinput_get(fs, &top_buf, &bottom_buf);
+if (ret < 0)
+return ret;
+if (!bottom_buf)
+return ff_filter_frame(ctx->outputs[0], top_buf);
+dst_buf = blend_frame(ctx, top_buf, bottom_buf);
+return ff_filter_frame(ctx->outputs[0], dst_buf);
+}
+
 static av_cold int init(AVFilterContext *ctx)
 {
 BlendContext *s = ctx->priv;
 
 s->tblend = !strcmp(ctx->filter->name, "tblend");
 
-s->dinput.process = blend_frame;
+s->fs.on_event = blend_frame_for_dualinput;
 return 0;
 }
 
@@ -439,7 +452,7 @@ static av_cold void uninit(AVFilterContext *ctx)
 BlendContext *s = ctx->priv;
 int i;
 
-ff_dualinput_uninit(&s->dinput);
+ff_framesync2_uninit(&s->fs);
 av_frame_free(&s->prev_frame);
 
 for (i = 0; i < FF_ARRAY_ELEMS(s->params); i++)
@@ -539,7 +552,7 @@ static int config_output(AVFilterLink *outlink)
 s->nb_planes = av_pix_fmt_count_planes(toplink->format);
 
 if (!s->tblend)
-if ((ret = ff_dualinput_init(ctx, &s->dinput)) < 0)
+if ((ret = ff_framesync2_init_dualinput(&s->fs, ctx)) < 0)
 return ret;
 
 for (plane = 0; plane < FF_ARRAY_ELEMS(s->params); plane++) {
@@ -566,32 +579,24 @@ static int config_output(AVFilterLink *outlink)
 }
 }
 
-return 0;
+return s->tblend ? 0 : ff_framesync2_configure(&s->fs);
 }
 
 #if CONFIG_BLEND_FILTER
 
-static int request_frame(AVFilterLink *outlink)
+static int activate(AVFilterContext *ctx)
 {
-BlendContext *s = outlink->src->priv;
-return ff_dualinput_request_frame(&s->dinput, outlink);
-}
-
-static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
-{
-BlendContext *s = inlink->dst->priv;
-return ff_dualinput_filter_frame(&s->dinput, inlink, buf);
+BlendContext *s = ctx->priv;
+return ff_framesync2_activate(&s->fs);
 }
 
 static const A

[FFmpeg-devel] [PATCH 05/14] lavfi: search options on child objects.

2017-07-31 Thread Nicolas George
The child objects must be allocated and inited in the
preinit() callback.

Signed-off-by: Nicolas George 
---
 libavfilter/avfilter.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index dcd975e104..6a97456054 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -897,7 +897,7 @@ static int process_options(AVFilterContext *ctx, 
AVDictionary **options,
 }
 } else {
 av_dict_set(options, key, value, 0);
-if ((ret = av_opt_set(ctx->priv, key, value, 0)) < 0) {
+if ((ret = av_opt_set(ctx->priv, key, value, AV_OPT_SEARCH_CHILDREN)) 
< 0) {
 if (!av_opt_find(ctx->priv, key, NULL, 0, AV_OPT_SEARCH_CHILDREN | 
AV_OPT_SEARCH_FAKE_OBJ)) {
 if (ret == AVERROR_OPTION_NOT_FOUND)
 av_log(ctx, AV_LOG_ERROR, "Option '%s' not found\n", key);
@@ -948,7 +948,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary 
**options)
 }
 
 if (ctx->filter->priv_class) {
-ret = av_opt_set_dict(ctx->priv, options);
+ret = av_opt_set_dict2(ctx->priv, options, AV_OPT_SEARCH_CHILDREN);
 if (ret < 0) {
 av_log(ctx, AV_LOG_ERROR, "Error applying options to the 
filter.\n");
 return ret;
-- 
2.13.2

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


[FFmpeg-devel] [PATCH 09/14] lavfi/vf_libvmaf: convert to framesync2.

2017-07-31 Thread Nicolas George
After this commit, the code compiles, but on my setup it
segfaults before and after. It also prints the very worrying
warning:

src/libavfilter/vf_libvmaf.c:161:66: warning: passing argument 4 of 
‘compute_vmaf’ from incompatible pointer type [-Wincompatible-pointer-types]
/tmp/i/include/libvmaf.h:26:8: note: expected ‘int (*)(float *, float *, float 
*, int,  void *)’ but argument is of type ‘int (*)(float *, float *, float *, 
int,  double *, void *)’

==12116== Thread 6:
==12116== Conditional jump or move depends on uninitialised value(s)
==12116==at 0x526D432: cons_ (ocval.h:1188)
==12116==by 0x526D432: GenericIT (ocval.h:1119)
==12116==by 0x526D432: OC::TranslateForNumPyClassesToArray(OC::Val&) 
(pickleloader.h:92)
==12116==by 0x5211F5D: loads (pickleloader.h:566)
==12116==by 0x5211F5D: LoadValFromArray (chooseser.h:290)
==12116==by 0x5211F5D: LoadValFromFile (chooseser.h:405)
==12116==by 0x5211F5D: _read_and_assert_model(char const*, OC::Val&, 
OC::Val&, OC::Val&, OC::Val&, OC::Val&, OC::Val&) (vmaf.cpp:77)
==12116==by 0x5212B0F: VmafRunner::run(Asset, int (*)(float*, float*, 
float*, int, void*), void*, bool, bool, bool, bool, bool) (vmaf.cpp:149)
==12116==by 0x52165B6: RunVmaf(char const*, int, int, int (*)(float*, 
float*, float*, int, void*), void*, char const*, char const*, char const*, 
bool, bool, bool, bool, bool, char const*) (vmaf.cpp:645)
==12116==by 0x518AFFF: compute_vmaf_score (vf_libvmaf.c:161)
==12116==by 0x518AFFF: call_vmaf (vf_libvmaf.c:170)
==12116==by 0x7967493: start_thread (pthread_create.c:333)
==12116==by 0x7F69A8E: clone (clone.S:97)
==12116==
==12116== Conditional jump or move depends on uninitialised value(s)
==12116==at 0x526D432: cons_ (ocval.h:1188)
==12116==by 0x526D432: GenericIT (ocval.h:1119)
==12116==by 0x526D432: OC::TranslateForNumPyClassesToArray(OC::Val&) 
(pickleloader.h:92)
==12116==by 0x526D50D: OC::TranslateForNumPyClassesToArray(OC::Val&) 
(pickleloader.h:94)
==12116==by 0x5211F5D: loads (pickleloader.h:566)
==12116==by 0x5211F5D: LoadValFromArray (chooseser.h:290)
==12116==by 0x5211F5D: LoadValFromFile (chooseser.h:405)
==12116==by 0x5211F5D: _read_and_assert_model(char const*, OC::Val&, 
OC::Val&, OC::Val&, OC::Val&, OC::Val&, OC::Val&) (vmaf.cpp:77)
==12116==by 0x5212B0F: VmafRunner::run(Asset, int (*)(float*, float*, 
float*, int, void*), void*, bool, bool, bool, bool, bool) (vmaf.cpp:149)
==12116==by 0x52165B6: RunVmaf(char const*, int, int, int (*)(float*, 
float*, float*, int, void*), void*, char const*, char const*, char const*, 
bool, bool, bool, bool, bool, char const*) (vmaf.cpp:645)
==12116==by 0x518AFFF: compute_vmaf_score (vf_libvmaf.c:161)
==12116==by 0x518AFFF: call_vmaf (vf_libvmaf.c:170)
==12116==by 0x7967493: start_thread (pthread_create.c:333)
==12116==by 0x7F69A8E: clone (clone.S:97)
==12116==
==12116== Conditional jump or move depends on uninitialised value(s)
==12116==at 0x526D432: cons_ (ocval.h:1188)
==12116==by 0x526D432: GenericIT (ocval.h:1119)
==12116==by 0x526D432: OC::TranslateForNumPyClassesToArray(OC::Val&) 
(pickleloader.h:92)
==12116==by 0x526D50D: OC::TranslateForNumPyClassesToArray(OC::Val&) 
(pickleloader.h:94)
==12116==by 0x526D50D: OC::TranslateForNumPyClassesToArray(OC::Val&) 
(pickleloader.h:94)
==12116==by 0x5211F5D: loads (pickleloader.h:566)
==12116==by 0x5211F5D: LoadValFromArray (chooseser.h:290)
==12116==by 0x5211F5D: LoadValFromFile (chooseser.h:405)
==12116==by 0x5211F5D: _read_and_assert_model(char const*, OC::Val&, 
OC::Val&, OC::Val&, OC::Val&, OC::Val&, OC::Val&) (vmaf.cpp:77)
==12116==by 0x5212B0F: VmafRunner::run(Asset, int (*)(float*, float*, 
float*, int, void*), void*, bool, bool, bool, bool, bool) (vmaf.cpp:149)
==12116==by 0x52165B6: RunVmaf(char const*, int, int, int (*)(float*, 
float*, float*, int, void*), void*, char const*, char const*, char const*, 
bool, bool, bool, bool, bool, char const*) (vmaf.cpp:645)
==12116==by 0x518AFFF: compute_vmaf_score (vf_libvmaf.c:161)
==12116==by 0x518AFFF: call_vmaf (vf_libvmaf.c:170)
==12116==by 0x7967493: start_thread (pthread_create.c:333)
==12116==by 0x7F69A8E: clone (clone.S:97)
==12116==
==12116== Use of uninitialised value of size 8
==12116==at 0x518AC79: read_frame_8bit (vf_libvmaf.c:147)
==12116==by 0x52AB5E8: combo (combo.c:149)
==12116==by 0x5212E95: VmafRunner::run(Asset, int (*)(float*, float*, 
float*, int, void*), void*, bool, bool, bool, bool, bool) (vmaf.cpp:278)
==12116==by 0x52165B6: RunVmaf(char const*, int, int, int (*)(float*, 
float*, float*, int, void*), void*, char const*, char const*, char const*, 
bool, bool, bool, bool, bool, char const*) (vmaf.cpp:645)
==12116==by 0x518AFFF: compute_vmaf_score (vf_libvmaf.c:161)
==12116==by 0x518AFFF: call_vmaf (vf_libvmaf.c:170)
==12116==by 0x7967493: start_thread (pthread_create.c:333)
==12116==by 

[FFmpeg-devel] [PATCH 10/14] lavfi/vf_lut3d: convert to framesync2.

2017-07-31 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/Makefile   |  2 +-
 libavfilter/vf_lut3d.c | 49 ++---
 2 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 4089d910ad..a62339992f 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -196,7 +196,7 @@ OBJS-$(CONFIG_FSPP_FILTER)   += vf_fspp.o
 OBJS-$(CONFIG_GBLUR_FILTER)  += vf_gblur.o
 OBJS-$(CONFIG_GEQ_FILTER)+= vf_geq.o
 OBJS-$(CONFIG_GRADFUN_FILTER)+= vf_gradfun.o
-OBJS-$(CONFIG_HALDCLUT_FILTER)   += vf_lut3d.o dualinput.o 
framesync.o
+OBJS-$(CONFIG_HALDCLUT_FILTER)   += vf_lut3d.o framesync2.o
 OBJS-$(CONFIG_HFLIP_FILTER)  += vf_hflip.o
 OBJS-$(CONFIG_HISTEQ_FILTER) += vf_histeq.o
 OBJS-$(CONFIG_HISTOGRAM_FILTER)  += vf_histogram.o
diff --git a/libavfilter/vf_lut3d.c b/libavfilter/vf_lut3d.c
index 7a294b0761..5ba91f7e47 100644
--- a/libavfilter/vf_lut3d.c
+++ b/libavfilter/vf_lut3d.c
@@ -31,8 +31,8 @@
 #include "libavutil/avstring.h"
 #include "avfilter.h"
 #include "drawutils.h"
-#include "dualinput.h"
 #include "formats.h"
+#include "framesync2.h"
 #include "internal.h"
 #include "video.h"
 
@@ -70,7 +70,7 @@ typedef struct LUT3DContext {
 int clut_step;
 int clut_is16bit;
 int clut_width;
-FFDualInputContext dinput;
+FFFrameSync fs;
 #endif
 } LUT3DContext;
 
@@ -681,24 +681,21 @@ static int config_output(AVFilterLink *outlink)
 LUT3DContext *lut3d = ctx->priv;
 int ret;
 
+ret = ff_framesync2_init_dualinput(&lut3d->fs, ctx);
+if (ret < 0)
+return ret;
 outlink->w = ctx->inputs[0]->w;
 outlink->h = ctx->inputs[0]->h;
 outlink->time_base = ctx->inputs[0]->time_base;
-if ((ret = ff_dualinput_init(ctx, &lut3d->dinput)) < 0)
+if ((ret = ff_framesync2_configure(&lut3d->fs)) < 0)
 return ret;
 return 0;
 }
 
-static int filter_frame_hald(AVFilterLink *inlink, AVFrame *inpicref)
-{
-LUT3DContext *s = inlink->dst->priv;
-return ff_dualinput_filter_frame(&s->dinput, inlink, inpicref);
-}
-
-static int request_frame(AVFilterLink *outlink)
+static int activate(AVFilterContext *ctx)
 {
-LUT3DContext *s = outlink->src->priv;
-return ff_dualinput_request_frame(&s->dinput, outlink);
+LUT3DContext *s = ctx->priv;
+return ff_framesync2_activate(&s->fs);
 }
 
 static int config_clut(AVFilterLink *inlink)
@@ -751,45 +748,50 @@ static int config_clut(AVFilterLink *inlink)
 return 0;
 }
 
-static AVFrame *update_apply_clut(AVFilterContext *ctx, AVFrame *main,
-  const AVFrame *second)
+static int update_apply_clut(FFFrameSync *fs)
 {
+AVFilterContext *ctx = fs->parent;
 AVFilterLink *inlink = ctx->inputs[0];
+AVFrame *main, *second, *out;
+int ret;
+
+ret = ff_framesync2_dualinput_get(fs, &main, &second);
+if (ret < 0)
+return ret;
+if (!second)
+return ff_filter_frame(ctx->outputs[0], main);
 update_clut(ctx->priv, second);
-return apply_lut(inlink, main);
+out = apply_lut(inlink, main);
+return ff_filter_frame(ctx->outputs[0], out);
 }
 
 static av_cold int haldclut_init(AVFilterContext *ctx)
 {
 LUT3DContext *lut3d = ctx->priv;
-lut3d->dinput.process = update_apply_clut;
+lut3d->fs.on_event = update_apply_clut;
 return 0;
 }
 
 static av_cold void haldclut_uninit(AVFilterContext *ctx)
 {
 LUT3DContext *lut3d = ctx->priv;
-ff_dualinput_uninit(&lut3d->dinput);
+ff_framesync2_uninit(&lut3d->fs);
 }
 
 static const AVOption haldclut_options[] = {
-{ "shortest",   "force termination when the shortest input terminates", 
OFFSET(dinput.shortest),   AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
-{ "repeatlast", "continue applying the last clut after eos",
OFFSET(dinput.repeatlast), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },
 COMMON_OPTIONS
 };
 
-AVFILTER_DEFINE_CLASS(haldclut);
+FRAMESYNC_DEFINE_CLASS(haldclut, LUT3DContext, fs);
 
 static const AVFilterPad haldclut_inputs[] = {
 {
 .name = "main",
 .type = AVMEDIA_TYPE_VIDEO,
-.filter_frame = filter_frame_hald,
 .config_props = config_input,
 },{
 .name = "clut",
 .type = AVMEDIA_TYPE_VIDEO,
-.filter_frame = filter_frame_hald,
 .config_props = config_clut,
 },
 { NULL }
@@ -799,7 +801,6 @@ static const AVFilterPad haldclut_outputs[] = {
 {
 .name  = "default",
 .type  = AVMEDIA_TYPE_VIDEO,
-.request_frame = request_frame,
 .config_props  = config_output,
 },
 { NULL }
@@ -809,9 +810,11 @@ AVFilter ff_vf_haldclut = {
 .name  = "haldclut",
 .description   = NULL_IF_CONFIG_SMALL("Adjust colors using a Hald CLUT."),
 .priv_size = sizeof(LU

[FFmpeg-devel] [PATCH 11/14] lavfi/vf_paletteuse: convert to framesync2.

2017-07-31 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/Makefile|  2 +-
 libavfilter/vf_paletteuse.c | 59 -
 2 files changed, 38 insertions(+), 23 deletions(-)

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index a62339992f..4e4201e2b6 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -248,7 +248,7 @@ OBJS-$(CONFIG_OVERLAY_FILTER)+= 
vf_overlay.o framesync2.o
 OBJS-$(CONFIG_OWDENOISE_FILTER)  += vf_owdenoise.o
 OBJS-$(CONFIG_PAD_FILTER)+= vf_pad.o
 OBJS-$(CONFIG_PALETTEGEN_FILTER) += vf_palettegen.o
-OBJS-$(CONFIG_PALETTEUSE_FILTER) += vf_paletteuse.o dualinput.o 
framesync.o
+OBJS-$(CONFIG_PALETTEUSE_FILTER) += vf_paletteuse.o framesync2.o
 OBJS-$(CONFIG_PERMS_FILTER)  += f_perms.o
 OBJS-$(CONFIG_PERSPECTIVE_FILTER)+= vf_perspective.o
 OBJS-$(CONFIG_PHASE_FILTER)  += vf_phase.o
diff --git a/libavfilter/vf_paletteuse.c b/libavfilter/vf_paletteuse.c
index b25c6a9eac..063873536b 100644
--- a/libavfilter/vf_paletteuse.c
+++ b/libavfilter/vf_paletteuse.c
@@ -27,8 +27,10 @@
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/qsort.h"
-#include "dualinput.h"
 #include "avfilter.h"
+#include "filters.h"
+#include "framesync2.h"
+#include "internal.h"
 
 enum dithering_mode {
 DITHERING_NONE,
@@ -80,7 +82,7 @@ typedef int (*set_frame_func)(struct PaletteUseContext *s, 
AVFrame *out, AVFrame
 
 typedef struct PaletteUseContext {
 const AVClass *class;
-FFDualInputContext dinput;
+FFFrameSync fs;
 struct cache_node cache[CACHE_SIZE];/* lookup cache */
 struct color_node map[AVPALETTE_COUNT]; /* 3D-Tree (KD-Tree with K=3) for 
reverse colormap */
 uint32_t palette[AVPALETTE_COUNT];
@@ -129,6 +131,8 @@ static const AVOption paletteuse_options[] = {
 
 AVFILTER_DEFINE_CLASS(paletteuse);
 
+static int load_apply_palette(FFFrameSync *fs);
+
 static int query_formats(AVFilterContext *ctx)
 {
 static const enum AVPixelFormat in_fmts[]= {AV_PIX_FMT_RGB32, 
AV_PIX_FMT_NONE};
@@ -900,11 +904,18 @@ static int config_output(AVFilterLink *outlink)
 AVFilterContext *ctx = outlink->src;
 PaletteUseContext *s = ctx->priv;
 
+ret = ff_framesync2_init_dualinput(&s->fs, ctx);
+if (ret < 0)
+return ret;
+s->fs.opt_repeatlast = 1; // only 1 frame in the palette
+s->fs.in[1].before = s->fs.in[1].after = EXT_INFINITY;
+s->fs.on_event = load_apply_palette;
+
 outlink->w = ctx->inputs[0]->w;
 outlink->h = ctx->inputs[0]->h;
 
 outlink->time_base = ctx->inputs[0]->time_base;
-if ((ret = ff_dualinput_init(ctx, &s->dinput)) < 0)
+if ((ret = ff_framesync2_configure(&s->fs)) < 0)
 return ret;
 return 0;
 }
@@ -951,21 +962,31 @@ static void load_palette(PaletteUseContext *s, const 
AVFrame *palette_frame)
 s->palette_loaded = 1;
 }
 
-static AVFrame *load_apply_palette(AVFilterContext *ctx, AVFrame *main,
-   const AVFrame *second)
+static int load_apply_palette(FFFrameSync *fs)
 {
+AVFilterContext *ctx = fs->parent;
 AVFilterLink *inlink = ctx->inputs[0];
 PaletteUseContext *s = ctx->priv;
+AVFrame *main, *second, *out;
+int ret;
+
+ret = ff_framesync2_dualinput_get(fs, &main, &second);
+if (ret < 0)
+return ret;
+if (!main || !second) {
+ret = AVERROR_BUG;
+goto error;
+}
 if (!s->palette_loaded) {
 load_palette(s, second);
 }
-return apply_palette(inlink, main);
-}
+out = apply_palette(inlink, main);
+return ff_filter_frame(ctx->outputs[0], out);
 
-static int filter_frame(AVFilterLink *inlink, AVFrame *in)
-{
-PaletteUseContext *s = inlink->dst->priv;
-return ff_dualinput_filter_frame(&s->dinput, inlink, in);
+error:
+av_frame_free(&main);
+av_frame_free(&second);
+return ret;
 }
 
 #define DEFINE_SET_FRAME(color_search, name, value)
 \
@@ -1013,9 +1034,6 @@ static int dither_value(int p)
 static av_cold int init(AVFilterContext *ctx)
 {
 PaletteUseContext *s = ctx->priv;
-s->dinput.repeatlast = 1; // only 1 frame in the palette
-s->dinput.skip_initial_unpaired = 1;
-s->dinput.process= load_apply_palette;
 
 s->set_frame = set_frame_lut[s->color_search_method][s->dither];
 
@@ -1030,10 +1048,10 @@ static av_cold int init(AVFilterContext *ctx)
 return 0;
 }
 
-static int request_frame(AVFilterLink *outlink)
+static int activate(AVFilterContext *ctx)
 {
-PaletteUseContext *s = outlink->src->priv;
-return ff_dualinput_request_frame(&s->dinput, outlink);
+PaletteUseContext *s = ctx->priv;
+return ff_framesync2_activate(&s->fs);
 }
 
 static av_cold void uninit(AVFilterContext *ctx)
@@ -1041,7 +1059,7 @@ static av_cold void uninit(AVFilterContext *ctx)
 int i;
 PaletteUseContext *s = ctx->priv;

[FFmpeg-devel] [PATCH 12/14] lavfi/vf_psnr: convert to framesync2.

2017-07-31 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/Makefile  |  2 +-
 libavfilter/vf_psnr.c | 50 +++---
 2 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 4e4201e2b6..3af35d2c47 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -258,7 +258,7 @@ OBJS-$(CONFIG_PP_FILTER) += vf_pp.o
 OBJS-$(CONFIG_PP7_FILTER)+= vf_pp7.o
 OBJS-$(CONFIG_PREMULTIPLY_FILTER)+= vf_premultiply.o framesync2.o
 OBJS-$(CONFIG_PREWITT_FILTER)+= vf_convolution.o
-OBJS-$(CONFIG_PSNR_FILTER)   += vf_psnr.o dualinput.o 
framesync.o
+OBJS-$(CONFIG_PSNR_FILTER)   += vf_psnr.o framesync2.o
 OBJS-$(CONFIG_PULLUP_FILTER) += vf_pullup.o
 OBJS-$(CONFIG_QP_FILTER) += vf_qp.o
 OBJS-$(CONFIG_RANDOM_FILTER) += vf_random.o
diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
index 20962c41f6..83f320c289 100644
--- a/libavfilter/vf_psnr.c
+++ b/libavfilter/vf_psnr.c
@@ -29,16 +29,16 @@
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
-#include "dualinput.h"
 #include "drawutils.h"
 #include "formats.h"
+#include "framesync2.h"
 #include "internal.h"
 #include "psnr.h"
 #include "video.h"
 
 typedef struct PSNRContext {
 const AVClass *class;
-FFDualInputContext dinput;
+FFFrameSync fs;
 double mse, min_mse, max_mse, mse_comp[4];
 uint64_t nb_frames;
 FILE *stats_file;
@@ -68,7 +68,7 @@ static const AVOption psnr_options[] = {
 { NULL }
 };
 
-AVFILTER_DEFINE_CLASS(psnr);
+FRAMESYNC_DEFINE_CLASS(psnr, PSNRContext, fs);
 
 static inline unsigned pow_2(unsigned base)
 {
@@ -142,13 +142,21 @@ static void set_meta(AVDictionary **metadata, const char 
*key, char comp, float
 }
 }
 
-static AVFrame *do_psnr(AVFilterContext *ctx, AVFrame *main,
-const AVFrame *ref)
+static int do_psnr(FFFrameSync *fs)
 {
+AVFilterContext *ctx = fs->parent;
 PSNRContext *s = ctx->priv;
+AVFrame *main, *ref;
 double comp_mse[4], mse = 0;
-int j, c;
-AVDictionary **metadata = &main->metadata;
+int ret, j, c;
+AVDictionary **metadata;
+
+ret = ff_framesync2_dualinput_get(fs, &main, &ref);
+if (ret < 0)
+return ret;
+if (!ref)
+return ff_filter_frame(ctx->outputs[0], main);
+metadata = &main->metadata;
 
 compute_images_mse(s, (const uint8_t **)main->data, main->linesize,
   (const uint8_t **)ref->data, ref->linesize,
@@ -214,7 +222,7 @@ static AVFrame *do_psnr(AVFilterContext *ctx, AVFrame *main,
 fprintf(s->stats_file, "\n");
 }
 
-return main;
+return ff_filter_frame(ctx->outputs[0], main);
 }
 
 static av_cold int init(AVFilterContext *ctx)
@@ -245,7 +253,7 @@ static av_cold int init(AVFilterContext *ctx)
 }
 }
 
-s->dinput.process = do_psnr;
+s->fs.on_event = do_psnr;
 return 0;
 }
 
@@ -331,27 +339,24 @@ static int config_output(AVFilterLink *outlink)
 AVFilterLink *mainlink = ctx->inputs[0];
 int ret;
 
+ret = ff_framesync2_init_dualinput(&s->fs, ctx);
+if (ret < 0)
+return ret;
 outlink->w = mainlink->w;
 outlink->h = mainlink->h;
 outlink->time_base = mainlink->time_base;
 outlink->sample_aspect_ratio = mainlink->sample_aspect_ratio;
 outlink->frame_rate = mainlink->frame_rate;
-if ((ret = ff_dualinput_init(ctx, &s->dinput)) < 0)
+if ((ret = ff_framesync2_configure(&s->fs)) < 0)
 return ret;
 
 return 0;
 }
 
-static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
+static int activate(AVFilterContext *ctx)
 {
-PSNRContext *s = inlink->dst->priv;
-return ff_dualinput_filter_frame(&s->dinput, inlink, inpicref);
-}
-
-static int request_frame(AVFilterLink *outlink)
-{
-PSNRContext *s = outlink->src->priv;
-return ff_dualinput_request_frame(&s->dinput, outlink);
+PSNRContext *s = ctx->priv;
+return ff_framesync2_activate(&s->fs);
 }
 
 static av_cold void uninit(AVFilterContext *ctx)
@@ -375,7 +380,7 @@ static av_cold void uninit(AVFilterContext *ctx)
get_psnr(s->min_mse, 1, s->average_max));
 }
 
-ff_dualinput_uninit(&s->dinput);
+ff_framesync2_uninit(&s->fs);
 
 if (s->stats_file && s->stats_file != stdout)
 fclose(s->stats_file);
@@ -385,11 +390,9 @@ static const AVFilterPad psnr_inputs[] = {
 {
 .name = "main",
 .type = AVMEDIA_TYPE_VIDEO,
-.filter_frame = filter_frame,
 },{
 .name = "reference",
 .type = AVMEDIA_TYPE_VIDEO,
-.filter_frame = filter_frame,
 .config_props = config_input_ref,
 },
 { NULL }
@@ -400,7 +403,6 @@ static const AVFilterPad psnr_outputs[] = {
 .name  = "default",
 .type  = AVMEDIA_TYPE_

[FFmpeg-devel] [PATCH 07/14] lavfi/vf_overlay: use framesync2 options.

2017-07-31 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/vf_overlay.c | 45 -
 1 file changed, 4 insertions(+), 41 deletions(-)

diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index c1d2a21c05..512df87630 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -70,16 +70,6 @@ enum var_name {
 VAR_VARS_NB
 };
 
-enum EOFAction {
-EOF_ACTION_REPEAT,
-EOF_ACTION_ENDALL,
-EOF_ACTION_PASS
-};
-
-static const char * const eof_action_str[] = {
-"repeat", "endall", "pass"
-};
-
 #define MAIN0
 #define OVERLAY 1
 
@@ -131,10 +121,6 @@ typedef struct OverlayContext {
 double var_values[VAR_VARS_NB];
 char *x_expr, *y_expr;
 
-int eof_action; ///< action to take on EOF from source
-int opt_shortest;
-int opt_repeatlast;
-
 AVExpr *x_pexpr, *y_pexpr;
 
 void (*blend_image)(AVFilterContext *ctx, AVFrame *dst, const AVFrame 
*src, int x, int y);
@@ -377,12 +363,11 @@ static int config_input_overlay(AVFilterLink *inlink)
 }
 
 av_log(ctx, AV_LOG_VERBOSE,
-   "main w:%d h:%d fmt:%s overlay w:%d h:%d fmt:%s eof_action:%s\n",
+   "main w:%d h:%d fmt:%s overlay w:%d h:%d fmt:%s\n",
ctx->inputs[MAIN]->w, ctx->inputs[MAIN]->h,
av_get_pix_fmt_name(ctx->inputs[MAIN]->format),
ctx->inputs[OVERLAY]->w, ctx->inputs[OVERLAY]->h,
-   av_get_pix_fmt_name(ctx->inputs[OVERLAY]->format),
-   eof_action_str[s->eof_action]);
+   av_get_pix_fmt_name(ctx->inputs[OVERLAY]->format));
 return 0;
 }
 
@@ -394,12 +379,6 @@ static int config_output(AVFilterLink *outlink)
 
 if ((ret = ff_framesync2_init_dualinput(&s->fs, ctx)) < 0)
 return ret;
-if (s->opt_shortest)
-s->fs.in[0].after = s->fs.in[1].after = EXT_STOP;
-if (!s->opt_repeatlast) {
-s->fs.in[1].after = EXT_NULL;
-s->fs.in[1].sync  = 0;
-}
 
 outlink->w = ctx->inputs[MAIN]->w;
 outlink->h = ctx->inputs[MAIN]->h;
@@ -818,15 +797,6 @@ static av_cold int init(AVFilterContext *ctx)
 {
 OverlayContext *s = ctx->priv;
 
-if (!s->opt_repeatlast || s->eof_action == EOF_ACTION_PASS) {
-s->opt_repeatlast = 0;
-s->eof_action = EOF_ACTION_PASS;
-}
-if (s->opt_shortest || s->eof_action == EOF_ACTION_ENDALL) {
-s->opt_shortest = 1;
-s->eof_action = EOF_ACTION_ENDALL;
-}
-
 s->fs.on_event = do_blend;
 return 0;
 }
@@ -843,16 +813,9 @@ static int activate(AVFilterContext *ctx)
 static const AVOption overlay_options[] = {
 { "x", "set the x expression", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str = 
"0"}, CHAR_MIN, CHAR_MAX, FLAGS },
 { "y", "set the y expression", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str = 
"0"}, CHAR_MIN, CHAR_MAX, FLAGS },
-{ "eof_action", "Action to take when encountering EOF from secondary input 
",
-OFFSET(eof_action), AV_OPT_TYPE_INT, { .i64 = EOF_ACTION_REPEAT },
-EOF_ACTION_REPEAT, EOF_ACTION_PASS, .flags = FLAGS, "eof_action" },
-{ "repeat", "Repeat the previous frame.",   0, AV_OPT_TYPE_CONST, { 
.i64 = EOF_ACTION_REPEAT }, .flags = FLAGS, "eof_action" },
-{ "endall", "End both streams.",0, AV_OPT_TYPE_CONST, { 
.i64 = EOF_ACTION_ENDALL }, .flags = FLAGS, "eof_action" },
-{ "pass",   "Pass through the main input.", 0, AV_OPT_TYPE_CONST, { 
.i64 = EOF_ACTION_PASS },   .flags = FLAGS, "eof_action" },
 { "eval", "specify when to evaluate expressions", OFFSET(eval_mode), 
AV_OPT_TYPE_INT, {.i64 = EVAL_MODE_FRAME}, 0, EVAL_MODE_NB-1, FLAGS, "eval" },
  { "init",  "eval expressions once during initialization", 0, 
AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_INIT},  .flags = FLAGS, .unit = "eval" },
  { "frame", "eval expressions per-frame",  0, 
AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_FRAME}, .flags = FLAGS, .unit = "eval" },
-{ "shortest", "force termination when the shortest input terminates", 
OFFSET(opt_shortest), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
 { "format", "set output format", OFFSET(format), AV_OPT_TYPE_INT, 
{.i64=OVERLAY_FORMAT_YUV420}, 0, OVERLAY_FORMAT_NB-1, FLAGS, "format" },
 { "yuv420", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_YUV420}, 
.flags = FLAGS, .unit = "format" },
 { "yuv422", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_YUV422}, 
.flags = FLAGS, .unit = "format" },
@@ -860,11 +823,10 @@ static const AVOption overlay_options[] = {
 { "rgb","", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_RGB},
.flags = FLAGS, .unit = "format" },
 { "gbrp",   "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_GBRP},   
.flags = FLAGS, .unit = "format" },
 { "auto",   "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_AUTO},   
.flags = FLAGS, .unit = "format" },
-{ "repeatlast", "repeat overlay of the last overlay frame", 
OFFSET(opt_repeatlast), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGS },
 

[FFmpeg-devel] [PATCH 13/14] vf_ssim: convert to framesync2.

2017-07-31 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/Makefile  |  2 +-
 libavfilter/vf_ssim.c | 52 ++-
 2 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 3af35d2c47..76cd906148 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -299,7 +299,7 @@ OBJS-$(CONFIG_SMARTBLUR_FILTER)  += 
vf_smartblur.o
 OBJS-$(CONFIG_SOBEL_FILTER)  += vf_convolution.o
 OBJS-$(CONFIG_SPLIT_FILTER)  += split.o
 OBJS-$(CONFIG_SPP_FILTER)+= vf_spp.o
-OBJS-$(CONFIG_SSIM_FILTER)   += vf_ssim.o dualinput.o 
framesync.o
+OBJS-$(CONFIG_SSIM_FILTER)   += vf_ssim.o framesync2.o
 OBJS-$(CONFIG_STEREO3D_FILTER)   += vf_stereo3d.o
 OBJS-$(CONFIG_STREAMSELECT_FILTER)   += f_streamselect.o framesync.o
 OBJS-$(CONFIG_SUBTITLES_FILTER)  += vf_subtitles.o
diff --git a/libavfilter/vf_ssim.c b/libavfilter/vf_ssim.c
index c3c204268f..ba6ce846ae 100644
--- a/libavfilter/vf_ssim.c
+++ b/libavfilter/vf_ssim.c
@@ -38,16 +38,16 @@
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
-#include "dualinput.h"
 #include "drawutils.h"
 #include "formats.h"
+#include "framesync2.h"
 #include "internal.h"
 #include "ssim.h"
 #include "video.h"
 
 typedef struct SSIMContext {
 const AVClass *class;
-FFDualInputContext dinput;
+FFFrameSync fs;
 FILE *stats_file;
 char *stats_file_str;
 int nb_components;
@@ -78,7 +78,7 @@ static const AVOption ssim_options[] = {
 { NULL }
 };
 
-AVFILTER_DEFINE_CLASS(ssim);
+FRAMESYNC_DEFINE_CLASS(ssim, SSIMContext, fs);
 
 static void set_meta(AVDictionary **metadata, const char *key, char comp, 
float d)
 {
@@ -280,13 +280,21 @@ static double ssim_db(double ssim, double weight)
 return 10 * log10(weight / (weight - ssim));
 }
 
-static AVFrame *do_ssim(AVFilterContext *ctx, AVFrame *main,
-const AVFrame *ref)
+static int do_ssim(FFFrameSync *fs)
 {
-AVDictionary **metadata = &main->metadata;
+AVFilterContext *ctx = fs->parent;
 SSIMContext *s = ctx->priv;
+AVFrame *main, *ref;
+AVDictionary **metadata;
 float c[4], ssimv = 0.0;
-int i;
+int ret, i;
+
+ret = ff_framesync2_dualinput_get(fs, &main, &ref);
+if (ret < 0)
+return ret;
+if (!ref)
+return ff_filter_frame(ctx->outputs[0], main);
+metadata = &main->metadata;
 
 s->nb_frames++;
 
@@ -318,7 +326,7 @@ static AVFrame *do_ssim(AVFilterContext *ctx, AVFrame *main,
 fprintf(s->stats_file, "All:%f (%f)\n", ssimv, ssim_db(ssimv, 1.0));
 }
 
-return main;
+return ff_filter_frame(ctx->outputs[0], main);
 }
 
 static av_cold int init(AVFilterContext *ctx)
@@ -341,9 +349,7 @@ static av_cold int init(AVFilterContext *ctx)
 }
 }
 
-s->dinput.process = do_ssim;
-s->dinput.shortest = 1;
-s->dinput.repeatlast = 0;
+s->fs.on_event = do_ssim;
 return 0;
 }
 
@@ -423,28 +429,25 @@ static int config_output(AVFilterLink *outlink)
 AVFilterLink *mainlink = ctx->inputs[0];
 int ret;
 
+ret = ff_framesync2_init_dualinput(&s->fs, ctx);
+if (ret < 0)
+return ret;
 outlink->w = mainlink->w;
 outlink->h = mainlink->h;
 outlink->time_base = mainlink->time_base;
 outlink->sample_aspect_ratio = mainlink->sample_aspect_ratio;
 outlink->frame_rate = mainlink->frame_rate;
 
-if ((ret = ff_dualinput_init(ctx, &s->dinput)) < 0)
+if ((ret = ff_framesync2_configure(&s->fs)) < 0)
 return ret;
 
 return 0;
 }
 
-static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
+static int activate(AVFilterContext *ctx)
 {
-SSIMContext *s = inlink->dst->priv;
-return ff_dualinput_filter_frame(&s->dinput, inlink, buf);
-}
-
-static int request_frame(AVFilterLink *outlink)
-{
-SSIMContext *s = outlink->src->priv;
-return ff_dualinput_request_frame(&s->dinput, outlink);
+SSIMContext *s = ctx->priv;
+return ff_framesync2_activate(&s->fs);
 }
 
 static av_cold void uninit(AVFilterContext *ctx)
@@ -464,7 +467,7 @@ static av_cold void uninit(AVFilterContext *ctx)
s->ssim_total / s->nb_frames, ssim_db(s->ssim_total, 
s->nb_frames));
 }
 
-ff_dualinput_uninit(&s->dinput);
+ff_framesync2_uninit(&s->fs);
 
 if (s->stats_file && s->stats_file != stdout)
 fclose(s->stats_file);
@@ -476,11 +479,9 @@ static const AVFilterPad ssim_inputs[] = {
 {
 .name = "main",
 .type = AVMEDIA_TYPE_VIDEO,
-.filter_frame = filter_frame,
 },{
 .name = "reference",
 .type = AVMEDIA_TYPE_VIDEO,
-.filter_frame = filter_frame,
 .config_props = config_input_ref,
 },
 { NULL }
@@ -491,7 +492,6 @@ static const AVFilterPad ssim_outputs[] = {
 .name  = "default",

Re: [FFmpeg-devel] [PATCH] examples/vaapi_enc: Add a VAAPI encoding example.

2017-07-31 Thread Mark Thompson
On 31/07/17 04:10, Jun Zhao wrote:
> On 2017/7/30 8:07, Mark Thompson wrote:
>> On 28/07/17 07:01, Jun Zhao wrote:
>>> From d5414b451012b3a0169740a26f452785eb44cce5 Mon Sep 17 00:00:00 2001
>>> From: Jun Zhao 
>>> Date: Fri, 28 Jul 2017 01:39:27 -0400
>>> Subject: [PATCH] examples/vaapi_enc: Add a VAAPI encoding example.
>>>
>>> Add a VAAPI encoding example.
>>>
>>> Use hwupload loading the raw date in HW surface, usage
>>> like this: ./vaapi_enc 1920 1080 input.yuv test.h264
>>>
>>> Signed-off-by: Liu, Kaixuan 
>>> Signed-off-by: Jun Zhao 
>>> ---
>>>  doc/examples/vaapi_enc.c | 291 
>>> +++
>>>  1 file changed, 291 insertions(+)
>>>  create mode 100644 doc/examples/vaapi_enc.c
>>
>> A general thought: do you actually want to use lavfi here?  All it's really 
>> doing is the hw frame creation and upload, which would be shorter to 
>> implement directly (av_hwframe_ctx_create(), av_hwframe_ctx_init(), 
>> av_hwframe_transfer_data()).  If the example might be extended with more 
>> stuff going on in filters then obviously the lavfi stuff is needed, but it 
>> seems overcomplicated if the intent is just to demonstrate encode.
> 
> As the API view, I don't want to use lavfi for VAAPI NEC example, I prefer 
> a simple API or simple step than use lavfi to load YUV from CPU to GPU 
> surface,
> 
> Can we give a simple API or step to load YUV to HW surface in this case ? 
> even use
> av_hwframe_xxx interface, it's not a easy task for the caller.

Well, what sort of API would you prefer?

Currently the actions to take here are:
* Allocate a new hardware frames context to contain the surfaces 
[av_hwframe_ctx_create()].
* Set the parameters for your surfaces - format and dimensions, pool size if 
needed, anything API-specific.
* Initialise the context with those parameters [av_hwframe_ctx_init()].
* Set the new context on the encoder for it to use 
[AVCodecContext.hw_frames_ctx].
* Then, for each frame:
** Allocate a new surface from the frames context [av_hwframe_get_buffer()].
** Copy the software frame data to the surface [av_hwframe_transfer_data()].
** Send the hardware frame to the encoder [avcodec_send_frame()].

It's not clear to me that any of those parts are sensibly mergable for the user 
without obscuring what is actually happening.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 01/14] lavfi: add f_streamsync dependency.

2017-07-31 Thread Nicolas George
Even better.
From 836cbf40eb95e16d48bb5a2d356c130ce9d53de1 Mon Sep 17 00:00:00 2001
From: Nicolas George 
Date: Mon, 31 Jul 2017 13:47:34 +0200
Subject: [PATCH] lavfi/f_streamselect: convert to framesync2.

Signed-off-by: Nicolas George 
---
 libavfilter/Makefile |  4 ++--
 libavfilter/f_streamselect.c | 33 +
 2 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 4d61d7835e..18d217bfe5 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -67,7 +67,7 @@ OBJS-$(CONFIG_ASHOWINFO_FILTER)  += af_ashowinfo.o
 OBJS-$(CONFIG_ASIDEDATA_FILTER)  += f_sidedata.o
 OBJS-$(CONFIG_ASPLIT_FILTER) += split.o
 OBJS-$(CONFIG_ASTATS_FILTER) += af_astats.o
-OBJS-$(CONFIG_ASTREAMSELECT_FILTER)  += f_streamselect.o
+OBJS-$(CONFIG_ASTREAMSELECT_FILTER)  += f_streamselect.o framesync2.o
 OBJS-$(CONFIG_ATEMPO_FILTER) += af_atempo.o
 OBJS-$(CONFIG_ATRIM_FILTER)  += trim.o
 OBJS-$(CONFIG_AZMQ_FILTER)   += f_zmq.o
@@ -301,7 +301,7 @@ OBJS-$(CONFIG_SPLIT_FILTER)  += split.o
 OBJS-$(CONFIG_SPP_FILTER)+= vf_spp.o
 OBJS-$(CONFIG_SSIM_FILTER)   += vf_ssim.o dualinput.o framesync.o
 OBJS-$(CONFIG_STEREO3D_FILTER)   += vf_stereo3d.o
-OBJS-$(CONFIG_STREAMSELECT_FILTER)   += f_streamselect.o
+OBJS-$(CONFIG_STREAMSELECT_FILTER)   += f_streamselect.o framesync2.o
 OBJS-$(CONFIG_SUBTITLES_FILTER)  += vf_subtitles.o
 OBJS-$(CONFIG_SUPER2XSAI_FILTER) += vf_super2xsai.o
 OBJS-$(CONFIG_SWAPRECT_FILTER)   += vf_swaprect.o
diff --git a/libavfilter/f_streamselect.c b/libavfilter/f_streamselect.c
index 1a517bfc95..10607de9b8 100644
--- a/libavfilter/f_streamselect.c
+++ b/libavfilter/f_streamselect.c
@@ -22,7 +22,7 @@
 #include "avfilter.h"
 #include "audio.h"
 #include "formats.h"
-#include "framesync.h"
+#include "framesync2.h"
 #include "internal.h"
 #include "video.h"
 
@@ -48,12 +48,6 @@ static const AVOption streamselect_options[] = {
 
 AVFILTER_DEFINE_CLASS(streamselect);
 
-static int filter_frame(AVFilterLink *inlink, AVFrame *in)
-{
-StreamSelectContext *s = inlink->dst->priv;
-return ff_framesync_filter_frame(&s->fs, inlink, in);
-}
-
 static int process_frame(FFFrameSync *fs)
 {
 AVFilterContext *ctx = fs->parent;
@@ -62,7 +56,7 @@ static int process_frame(FFFrameSync *fs)
 int i, j, ret = 0;
 
 for (i = 0; i < ctx->nb_inputs; i++) {
-if ((ret = ff_framesync_get_frame(&s->fs, i, &in[i], 0)) < 0)
+if ((ret = ff_framesync2_get_frame(&s->fs, i, &in[i], 0)) < 0)
 return ret;
 }
 
@@ -90,10 +84,10 @@ static int process_frame(FFFrameSync *fs)
 return ret;
 }
 
-static int request_frame(AVFilterLink *outlink)
+static int activate(AVFilterContext *ctx)
 {
-StreamSelectContext *s = outlink->src->priv;
-return ff_framesync_request_frame(&s->fs, outlink);
+StreamSelectContext *s = ctx->priv;
+return ff_framesync2_activate(&s->fs);
 }
 
 static int config_output(AVFilterLink *outlink)
@@ -130,7 +124,7 @@ static int config_output(AVFilterLink *outlink)
 if (s->fs.opaque == s)
 return 0;
 
-if ((ret = ff_framesync_init(&s->fs, ctx, ctx->nb_inputs)) < 0)
+if ((ret = ff_framesync2_init(&s->fs, ctx, ctx->nb_inputs)) < 0)
 return ret;
 
 in = s->fs.in;
@@ -148,12 +142,11 @@ static int config_output(AVFilterLink *outlink)
 if (!s->frames)
 return AVERROR(ENOMEM);
 
-return ff_framesync_configure(&s->fs);
+return ff_framesync2_configure(&s->fs);
 }
 
-static int parse_definition(AVFilterContext *ctx, int nb_pads, void *filter_frame, int is_audio)
+static int parse_definition(AVFilterContext *ctx, int nb_pads, int is_input, int is_audio)
 {
-const int is_input = !!filter_frame;
 const char *padtype = is_input ? "in" : "out";
 int i = 0, ret = 0;
 
@@ -169,11 +162,9 @@ static int parse_definition(AVFilterContext *ctx, int nb_pads, void *filter_fram
 av_log(ctx, AV_LOG_DEBUG, "Add %s pad %s\n", padtype, pad.name);
 
 if (is_input) {
-pad.filter_frame = filter_frame;
 ret = ff_insert_inpad(ctx, i, &pad);
 } else {
 pad.config_props  = config_output;
-pad.request_frame = request_frame;
 ret = ff_insert_outpad(ctx, i, &pad);
 }
 
@@ -281,8 +272,8 @@ static av_cold int init(AVFilterContext *ctx)
 if (!s->last_pts)
 return AVERROR(ENOMEM);
 
-if ((ret = parse_definition(ctx, s->nb_inputs, filter_frame, s->is_audio)) < 0 ||
-(ret = parse_definition(ctx, nb_outputs, NULL, s->is_audio)) < 0)
+if ((ret = parse_definition(ctx, s->nb_inputs, 1, s->is_audio)) < 0 ||
+(ret = parse_definition(ctx, nb_outputs, 0, s->is_audio)) < 0)
 return ret;
 
 av_log(ctx, AV_LOG_

Re: [FFmpeg-devel] [PATCH 14/14] lavfi: remove dualinput.

2017-07-31 Thread Nicolas George
Note: with this patch series, including the streamselect conversion, it
becomes possible to remove the old framesync code (and rename framesync2
into framesync).

A few filters using bufferqueue will still need to be converted to get
rid of that one.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] avfilter: add differencemax mode to the blend video filter

2017-07-31 Thread James Darnley
On 2017-07-31 13:45, Paul B Mahol wrote:
> On 7/31/17, James Darnley  wrote:
>> ---
>>  Changelog  | 1 +
>>  doc/filters.texi   | 1 +
>>  libavfilter/blend.h| 1 +
>>  libavfilter/vf_blend.c | 4 
>>  4 files changed, 7 insertions(+)
>>
> 
> How this compares with lut2 filter regarding speed?

Blending testsrc and testsrc2 at hd720 yuv420p I get ~81fps using my
addition.  Using lut2 I get ~80 fps.  Using no filters and rendering
just those 2 source I get 103 fps.

That is without SIMD though.  With SIMD I would expect blend to win.
I'm actually surprised that evaluating the expression isn't dead slow.

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


[FFmpeg-devel] [PATCH] avdevice/avfoundation: add scaleFactor attribute for avfoundation

2017-07-31 Thread sharpbai
From: sharpbai 

feature: add scaleFactor attribute for avfoundation
added by: siyuan.w...@duobei.com
added by: yiren...@duobei.com
---
 doc/indevs.texi| 6 ++
 libavdevice/avfoundation.m | 6 ++
 2 files changed, 12 insertions(+)

diff --git a/doc/indevs.texi b/doc/indevs.texi
index 09e3321..3d25930 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -139,6 +139,12 @@ Capture the mouse pointer. Default is 0.
 @item -capture_mouse_clicks
 Capture the screen mouse clicks. Default is 0.
 
+@item -scale_factor
+Scale factor for capture the screen. Set this property to scale the buffers
+by a given factor. For example a 320x240 capture area with a scale_factor of 
2.0
+produces video buffers at 640x480. Another example a 320x240 capture area with
+a scale_factor of 0.5 produces video buffers at 160x120. Default is 1.0 (no 
scaling).
+
 @end table
 
 @subsection Examples
diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index e2ddf47..1aec234 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -96,6 +96,7 @@ typedef struct
 
 int capture_cursor;
 int capture_mouse_clicks;
+float   scale_factor;
 
 int list_devices;
 int video_device_index;
@@ -735,6 +736,10 @@ static int avf_read_header(AVFormatContext *s)
 capture_screen_input.minFrameDuration = 
CMTimeMake(ctx->framerate.den, ctx->framerate.num);
 }
 
+if (ctx->scale_factor != 1 && ctx->scale_factor > 0) {
+capture_screen_input.scaleFactor = ctx->scale_factor;
+}
+
 #if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
 if (ctx->capture_cursor) {
 capture_screen_input.capturesCursor = YES;
@@ -1025,6 +1030,7 @@ static const AVOption options[] = {
 { "video_size", "set video size", offsetof(AVFContext, width), 
AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
 { "capture_cursor", "capture the screen cursor", offsetof(AVFContext, 
capture_cursor), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
 { "capture_mouse_clicks", "capture the screen mouse clicks", 
offsetof(AVFContext, capture_mouse_clicks), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, 
AV_OPT_FLAG_DECODING_PARAM },
+{ "scale_factor", "scale screen factor range", offsetof(AVFContext, 
scale_factor), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 2, AV_OPT_FLAG_DECODING_PARAM },
 
 { NULL },
 };
-- 
2.2.1

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


Re: [FFmpeg-devel] [PATCH] avdevice/avfoundation: add scaleFactor attribute for avfoundation

2017-07-31 Thread Steven Liu
2017-07-31 21:32 GMT+08:00 sharpbai :
> From: sharpbai 
>
> feature: add scaleFactor attribute for avfoundation
> added by: siyuan.w...@duobei.com
> added by: yiren...@duobei.com
> ---
>  doc/indevs.texi| 6 ++
>  libavdevice/avfoundation.m | 6 ++
>  2 files changed, 12 insertions(+)
>
> diff --git a/doc/indevs.texi b/doc/indevs.texi
> index 09e3321..3d25930 100644
> --- a/doc/indevs.texi
> +++ b/doc/indevs.texi
> @@ -139,6 +139,12 @@ Capture the mouse pointer. Default is 0.
>  @item -capture_mouse_clicks
>  Capture the screen mouse clicks. Default is 0.
>
> +@item -scale_factor
> +Scale factor for capture the screen. Set this property to scale the buffers
> +by a given factor. For example a 320x240 capture area with a scale_factor of 
> 2.0
> +produces video buffers at 640x480. Another example a 320x240 capture area 
> with
> +a scale_factor of 0.5 produces video buffers at 160x120. Default is 1.0 (no 
> scaling).
> +
>  @end table
>
>  @subsection Examples
> diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
> index e2ddf47..1aec234 100644
> --- a/libavdevice/avfoundation.m
> +++ b/libavdevice/avfoundation.m
> @@ -96,6 +96,7 @@ typedef struct
>
>  int capture_cursor;
>  int capture_mouse_clicks;
> +float   scale_factor;
>
>  int list_devices;
>  int video_device_index;
> @@ -735,6 +736,10 @@ static int avf_read_header(AVFormatContext *s)
>  capture_screen_input.minFrameDuration = 
> CMTimeMake(ctx->framerate.den, ctx->framerate.num);
>  }
>
> +if (ctx->scale_factor != 1 && ctx->scale_factor > 0) {
if the scale_factor is fload, this check maybe need attention, about
code secure

> +capture_screen_input.scaleFactor = ctx->scale_factor;
> +}
> +
>  #if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
>  if (ctx->capture_cursor) {
>  capture_screen_input.capturesCursor = YES;
> @@ -1025,6 +1030,7 @@ static const AVOption options[] = {
>  { "video_size", "set video size", offsetof(AVFContext, width), 
> AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
>  { "capture_cursor", "capture the screen cursor", offsetof(AVFContext, 
> capture_cursor), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM 
> },
>  { "capture_mouse_clicks", "capture the screen mouse clicks", 
> offsetof(AVFContext, capture_mouse_clicks), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, 
> AV_OPT_FLAG_DECODING_PARAM },
> +{ "scale_factor", "scale screen factor range", offsetof(AVFContext, 
> scale_factor), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 2, AV_OPT_FLAG_DECODING_PARAM 
> },
As Thilo's suggest, this default maybe 1.0 better.

>
>  { NULL },
>  };
> --
> 2.2.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avdevice/avfoundation: add scaleFactor attribute for avfoundation

2017-07-31 Thread sharpbai
From: sharpbai 

feature: add scaleFactor attribute for avfoundation
added by: siyuan.w...@duobei.com
added by: yiren...@duobei.com
---
 doc/indevs.texi| 6 ++
 libavdevice/avfoundation.m | 8 
 2 files changed, 14 insertions(+)

diff --git a/doc/indevs.texi b/doc/indevs.texi
index 09e3321..3d25930 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -139,6 +139,12 @@ Capture the mouse pointer. Default is 0.
 @item -capture_mouse_clicks
 Capture the screen mouse clicks. Default is 0.
 
+@item -scale_factor
+Scale factor for capture the screen. Set this property to scale the buffers
+by a given factor. For example a 320x240 capture area with a scale_factor of 
2.0
+produces video buffers at 640x480. Another example a 320x240 capture area with
+a scale_factor of 0.5 produces video buffers at 160x120. Default is 1.0 (no 
scaling).
+
 @end table
 
 @subsection Examples
diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index e2ddf47..3764de8 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -96,6 +96,7 @@ typedef struct
 
 int capture_cursor;
 int capture_mouse_clicks;
+float   scale_factor;
 
 int list_devices;
 int video_device_index;
@@ -735,6 +736,12 @@ static int avf_read_header(AVFormatContext *s)
 capture_screen_input.minFrameDuration = 
CMTimeMake(ctx->framerate.den, ctx->framerate.num);
 }
 
+if (ctx->scale_factor <= 2.0 && ctx->scale_factor > 0.0) {
+capture_screen_input.scaleFactor = ctx->scale_factor;
+} else {
+av_log(ctx, AV_LOG_ERROR, "The value of scale_factor must be 
more than 0.0 and less than or equal to 2.0");
+}
+
 #if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
 if (ctx->capture_cursor) {
 capture_screen_input.capturesCursor = YES;
@@ -1025,6 +1032,7 @@ static const AVOption options[] = {
 { "video_size", "set video size", offsetof(AVFContext, width), 
AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
 { "capture_cursor", "capture the screen cursor", offsetof(AVFContext, 
capture_cursor), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
 { "capture_mouse_clicks", "capture the screen mouse clicks", 
offsetof(AVFContext, capture_mouse_clicks), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, 
AV_OPT_FLAG_DECODING_PARAM },
+{ "scale_factor", "scale screen factor range", offsetof(AVFContext, 
scale_factor), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, 2.0, 
AV_OPT_FLAG_DECODING_PARAM },
 
 { NULL },
 };
-- 
2.2.1

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


Re: [FFmpeg-devel] [PATCH]v6 Opus Pyramid Vector Quantization Search in x86 SIMD asm

2017-07-31 Thread Henrik Gramner
On Wed, Jul 26, 2017 at 4:56 PM, Ivan Kalvachev  wrote:
> +++ b/libavcodec/x86/opus_pvq_search.asm

Generic minor stuff:

Use rN instead of rNq for numbered registers (q suffix is used for
named args only due to preprocessor limitations).

Use the same "standard" vertical alignment rules as most existing
code, e.g. instructions indented by 4 spaces and operands aligned on
the first comma.

Use xmN instead of xmmN (only really makes a difference when SWAP:s
are used, but might as well do it "correctly").

Use 32-bit operands, e.g. rNd, when 64-bit math isn't required.

Unless aligning every single loop entry helps a lot I'd avoid it since
it does waste a bit of icache.

Explicitly using the carry flag as a branch condition is a bit weird.
Generally using jg/jl/jge/jle tends to be clearer.

> +%ifdef __NASM_VER__
> +%use "smartalign"
> +ALIGNMODE p6
> +%endif

Assembler-specific ifdeffery should be avoided in individual files.
Something equivalent already exists in x86inc actually but I don't
remember if it was merged to FFmpeg from upstream (x264) yet.

> +const_int32_offsets:
> +%rep 8
> +dd $-const_int32_offsets
> +%endrep

Isn't this just an overly complicated way of expressing "dd 0*4, 1*4,
2*4, 3*4, 4*4, 5*4, 6*4, 7*4"?

> +SECTION .text
> +
> +
> +
> +

Reduce some of the excessive whitespace.

> +%macro HSUMPS 2 ; dst/src, tmp
> +%if cpuflag(avx)
> +  %if sizeof%1>=32  ; avx
> +   vperm2f128   %2,   %1,   %1,   (0)*16+(1)   ; %2=lo(%1)<<128+hi(%1)
> +   vaddps   %1,   %2
> +  %endif
> +   vshufps  %2,   %1,   %1,   q1032
> +   vaddps   %1,   %2
> +   vshufps  %2,   %1,   %1,   q0321
> +   vaddps   %1,   %2
> +
> +%else  ; this form is a bit faster than the short avx-like emulation.
> +movaps  %2,   %1;[d,   c,   b,   a   
> ]
> +shufps  %1,   %1,   q1032   ; %2=[b,   a,   d,   c   
> ]
> +addps   %1,   %2; %1=[b+d, a+c, d+b, c+a 
> ]
> +movaps  %2,   %1
> +shufps  %1,   %1,   q0321   ; %2=[c+a, b+d, a+c, d+b 
> ]
> +addps   %1,   %2; %1=[c+a+b+d, b+d+a+c, a+c+d+b, 
> d+b+c+a ]
> +; all %1 members should be equal for as long as float a+b==b+a
> +%endif
> +%endmacro

Is reordering moves for the non-AVX path worth the additional
complexity? Microoptimizations that only affect legacy hardware are
IMO a bit questionable.

> +%macro EMU_pblendvb 3 ; dst/src_a, src_b, mask
> +%if cpuflag(avx)
> +  %if cpuflag(avx) && notcpuflag(avx2) && sizeof%1 >= 32
> +%error AVX1 does not support integer 256 bit ymm operations
> +  %endif
> +
> +   vpblendvb%1,   %1,   %2,   %3
> +;-
> +%elif cpuflag(sse4)
> +%ifnidn %3,xmm0
> +  %error sse41 blendvps uses xmm0 as default 3 operand, you used %3
> +%endif
> +pblendvb%1,   %2,   %3
> +;-
> +%else
> +pxor%2,   %1
> +pand%2,   %3
> +pxor%1,   %2
> +%endif
> +%endmacro

The AVX1 integer warning is kind of silly and doesn't really serve any purpose.

> +%macro EMU_broadcastss 2 ; dst, src
> +%if cpuflag(avx2)
> +   vbroadcastss %1,   %2; ymm, xmm
> +;-
> +%elif cpuflag(avx)
> +  %ifnum sizeof%2   ; avx1 register
> +   vpermilpsxmm%1, xmm%2, q ; xmm, xmm, imm || ymm, ymm, imm
> +%if sizeof%1 >= 32  ; mmsize>=32
> +   vinsertf128  %1,   %1,xmm%1,   1 ; ymm, ymm, xmm, im
> +%endif
> +  %else ; avx1 memory
> +   vbroadcastss %1,   %2; ymm, mm32 || xmm, mm32
> +  %endif
> +;-
> +%else
> +  %ifnum sizeof%2   ; sse register
> +shufps  %1,   %2,   %2,   q
> +  %else ; sse memory
> +movss   %1,   %2; this zeroes the other 3 elements
> +shufps  %1,   %1,   0
> +  %endif
> +%endif
> +%endmacro

Use the existing x86util VBROADCASTSS macro. Modify it if it's lacking
something.

+%macro EMU_pbroadcastd 2 ; dst, src
+%if cpuflag(avx2)
+   vpbroadcastd %1,   %2
+%elif cpuflag(avx) && mmsize >= 32
+%error AVX1 does not support integer 256 bit ymm operations
+%else
+  %ifnum sizeof%2   ; sse2 register
+pshufd  %1,   %2,   q
+  %else ; sse memory
+movd%1,   %2; movd zero extends
+pshufd  %1,   %1,   0
+  %endif
+%endif
+%endmacro

Same as above, but using the SPLATD macro.

> +; Merge parallel maximums final round (1 vs 1)
> +movaps  xmm0, xmm3  ; m0 = m3[0] = p[0]
> +shufps  xmm3, xmm3, q   ; m3 = m3[1] = p[1]
> +cmpless xmm0, xmm3

Use 3-arg instead of reg-reg movaps.

Use the actual cmpss instruction instead of psuedo-instructions.

[FFmpeg-devel] [PATCH] avformat/utils: fix memory leak in avformat_free_context

2017-07-31 Thread Steven Siloti
The pointer to the packet queue is stored in the internal structure
so the queue needs to be flushed before internal is freed.

Signed-off-by: Steven Siloti 
---
 libavformat/utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 38d247c6cd..58283616dc 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4333,8 +4333,8 @@ void avformat_free_context(AVFormatContext *s)
 av_dict_free(&s->metadata);
 av_dict_free(&s->internal->id3v2_meta);
 av_freep(&s->streams);
-av_freep(&s->internal);
 flush_packet_queue(s);
+av_freep(&s->internal);
 av_free(s);
 }
 
-- 
2.13.0.windows.1

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


[FFmpeg-devel] Extarcting mor information in conversion s

2017-07-31 Thread Saeid Zangeneh
Im not familiar with the ffmpeg source code and I'm not so professional in
programming to can change or find out the code.
I just want to extract quantization matrix in jpeg conversion also the
residual error in mpeg conversion.
Thanks everyone for helping.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avdevice/avfoundation: add scaleFactor attribute for avfoundation

2017-07-31 Thread Thilo Borgmann
Am 31.07.17 um 17:34 schrieb sharpbai:
> From: sharpbai 
> 
> feature: add scaleFactor attribute for avfoundation
> added by: siyuan.w...@duobei.com
> added by: yiren...@duobei.com
> ---
>  doc/indevs.texi| 6 ++
>  libavdevice/avfoundation.m | 8 
>  2 files changed, 14 insertions(+)
> 
> diff --git a/doc/indevs.texi b/doc/indevs.texi
> index 09e3321..3d25930 100644
> --- a/doc/indevs.texi
> +++ b/doc/indevs.texi
> @@ -139,6 +139,12 @@ Capture the mouse pointer. Default is 0.
>  @item -capture_mouse_clicks
>  Capture the screen mouse clicks. Default is 0.
>  
> +@item -scale_factor
> +Scale factor for capture the screen. Set this property to scale the buffers
> +by a given factor. For example a 320x240 capture area with a scale_factor of 
> 2.0
> +produces video buffers at 640x480. Another example a 320x240 capture area 
> with
> +a scale_factor of 0.5 produces video buffers at 160x120. Default is 1.0 (no 
> scaling).
> +

Copy & Paste from the Apple's reference is hardly what is expected, please find 
your own wording.
Adding an example would be nice.
Maybe even renaming the option or state more implicitly that this option is for 
screen recording only.

How does it work? 

At least for me, this
"ffmpeg -f avfoundation -video_device_index 0 -scale_factor 1.5 -i "" out.avi" 
produces the same output resolution and viewport like that
"ffmpeg -f avfoundation -video_device_index 0 -scale_factor 1.0 -i "" out.avi".
What am I missing?
Some previous questions remain, about factor > 2.0 and factor < 1.0?


>  @end table
>  
>  @subsection Examples
> diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
> index e2ddf47..3764de8 100644
> --- a/libavdevice/avfoundation.m
> +++ b/libavdevice/avfoundation.m
> @@ -96,6 +96,7 @@ typedef struct
>  
>  int capture_cursor;
>  int capture_mouse_clicks;
> +float   scale_factor;
>  
>  int list_devices;
>  int video_device_index;
> @@ -735,6 +736,12 @@ static int avf_read_header(AVFormatContext *s)
>  capture_screen_input.minFrameDuration = 
> CMTimeMake(ctx->framerate.den, ctx->framerate.num);
>  }
>  
> +if (ctx->scale_factor <= 2.0 && ctx->scale_factor > 0.0) {
> +capture_screen_input.scaleFactor = ctx->scale_factor;
> +} else {
> +av_log(ctx, AV_LOG_ERROR, "The value of scale_factor must be 
> more than 0.0 and less than or equal to 2.0");
> +}
> +

I'm quite sure this is not what was meant to be checked.
Also, the range of this option is already guarded when reading it from the 
command line, you don't have to take care about out of limits here.



>  #if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
>  if (ctx->capture_cursor) {
>  capture_screen_input.capturesCursor = YES;
> @@ -1025,6 +1032,7 @@ static const AVOption options[] = {
>  { "video_size", "set video size", offsetof(AVFContext, width), 
> AV_OPT_TYPE_IMAGE_SIZE, {.str = > NULL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
>  { "capture_cursor", "capture the screen cursor", offsetof(AVFContext, 
> capture_cursor), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM 
> },
>  { "capture_mouse_clicks", "capture the screen mouse clicks", 
> offsetof(AVFContext, > capture_mouse_clicks), AV_OPT_TYPE_INT, {.i64=0}, 0, 
> 1, AV_OPT_FLAG_DECODING_PARAM },
> +{ "scale_factor", "scale screen factor range", offsetof(AVFContext, 
> scale_factor), 

It is not a range but the value (within a range) defining the scale factor of 
screen recording.
Also find something more precisely here, please.


> AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, 2.0, AV_OPT_FLAG_DECODING_PARAM },
>  
>  { NULL },
>  };
> 

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


[FFmpeg-devel] [PATCH] coverage: filter /usr/include*, not entire /usr*

2017-07-31 Thread foo86
/usr* filters all sources when building in /usr/src, which is probably
not intended.
---
 tests/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/Makefile b/tests/Makefile
index ab83ae855d..2c67095052 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -228,7 +228,7 @@ coverage.info: TAG = LCOV
 coverage.info:
$(M)lcov -q -d $(CURDIR) -b $(patsubst src%,./,$(SRC_LINK)) --capture | 
\
sed "s,$(CURDIR)/\./,$(CURDIR)/," > $@.in
-   $(M)lcov -q --remove $@.in "/usr*" > $@
+   $(M)lcov -q --remove $@.in "/usr/include*" > $@
$(Q)$(RM) $@.in
 
 lcov:  TAG = GENHTML
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 2/2] fate: add Dolby E test

2017-07-31 Thread foo86
---

Samples are here: https://0x0.st/ket.xz

 tests/fate/audio.mak | 5 +
 1 file changed, 5 insertions(+)

diff --git a/tests/fate/audio.mak b/tests/fate/audio.mak
index 40c4ca7b75..4fab472f90 100644
--- a/tests/fate/audio.mak
+++ b/tests/fate/audio.mak
@@ -19,6 +19,11 @@ fate-bmv-audio: CMD = framecrc -i 
$(TARGET_SAMPLES)/bmv/SURFING-partial.BMV -vn
 FATE_SAMPLES_AUDIO-$(call DEMDEC, DSICIN, DSICINAUDIO) += 
fate-delphine-cin-audio
 fate-delphine-cin-audio: CMD = framecrc -i 
$(TARGET_SAMPLES)/delphine-cin/LOGO-partial.CIN -vn
 
+FATE_SAMPLES_AUDIO-$(call DEMDEC, S337M, DOLBY_E) += fate-dolby-e
+fate-dolby-e: CMD = pcm -i $(TARGET_SAMPLES)/dolby_e/16-11
+fate-dolby-e: CMP = oneoff
+fate-dolby-e: REF = $(SAMPLES)/dolby_e/16-11.pcm
+
 FATE_SAMPLES_AUDIO-$(call DEMDEC, DSS, DSS_SP) += fate-dss-lp fate-dss-sp
 fate-dss-lp: CMD = framecrc -i $(TARGET_SAMPLES)/dss/lp.dss -frames 30
 fate-dss-sp: CMD = framecrc -i $(TARGET_SAMPLES)/dss/sp.dss -frames 30
-- 
2.11.0

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


Re: [FFmpeg-devel] [PATCH 1/2] fate: add more DCA tests

2017-07-31 Thread foo86
Oops, meant to include this comment in previous email:

Improves code coverage:
old%new%
dca_core76.581.3
dca_exss56.565.6
dca_lbr  2.280.5
dca_parser  86.298.6
dca_xll 81.287.2
dcadec  75.083.0
dcadsp  64.083.8

Samples are here: https://0x0.st/key.xz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avdevice/avfoundation: add scaleFactor attribute for avfoundation

2017-07-31 Thread Saeid Zangeneh
thanks
but i'm using linux ubuntu system.


On Tue, Aug 1, 2017 at 1:03 AM, Thilo Borgmann 
wrote:

> Am 31.07.17 um 17:34 schrieb sharpbai:
> > From: sharpbai 
> >
> > feature: add scaleFactor attribute for avfoundation
> > added by: siyuan.w...@duobei.com
> > added by: yiren...@duobei.com
> > ---
> >  doc/indevs.texi| 6 ++
> >  libavdevice/avfoundation.m | 8 
> >  2 files changed, 14 insertions(+)
> >
> > diff --git a/doc/indevs.texi b/doc/indevs.texi
> > index 09e3321..3d25930 100644
> > --- a/doc/indevs.texi
> > +++ b/doc/indevs.texi
> > @@ -139,6 +139,12 @@ Capture the mouse pointer. Default is 0.
> >  @item -capture_mouse_clicks
> >  Capture the screen mouse clicks. Default is 0.
> >
> > +@item -scale_factor
> > +Scale factor for capture the screen. Set this property to scale the
> buffers
> > +by a given factor. For example a 320x240 capture area with a
> scale_factor of 2.0
> > +produces video buffers at 640x480. Another example a 320x240 capture
> area with
> > +a scale_factor of 0.5 produces video buffers at 160x120. Default is 1.0
> (no scaling).
> > +
>
> Copy & Paste from the Apple's reference is hardly what is expected, please
> find your own wording.
> Adding an example would be nice.
> Maybe even renaming the option or state more implicitly that this option
> is for screen recording only.
>
> How does it work?
>
> At least for me, this
> "ffmpeg -f avfoundation -video_device_index 0 -scale_factor 1.5 -i ""
> out.avi"
> produces the same output resolution and viewport like that
> "ffmpeg -f avfoundation -video_device_index 0 -scale_factor 1.0 -i ""
> out.avi".
> What am I missing?
> Some previous questions remain, about factor > 2.0 and factor < 1.0?
>
>
> >  @end table
> >
> >  @subsection Examples
> > diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
> > index e2ddf47..3764de8 100644
> > --- a/libavdevice/avfoundation.m
> > +++ b/libavdevice/avfoundation.m
> > @@ -96,6 +96,7 @@ typedef struct
> >
> >  int capture_cursor;
> >  int capture_mouse_clicks;
> > +float   scale_factor;
> >
> >  int list_devices;
> >  int video_device_index;
> > @@ -735,6 +736,12 @@ static int avf_read_header(AVFormatContext *s)
> >  capture_screen_input.minFrameDuration =
> CMTimeMake(ctx->framerate.den, ctx->framerate.num);
> >  }
> >
> > +if (ctx->scale_factor <= 2.0 && ctx->scale_factor > 0.0) {
> > +capture_screen_input.scaleFactor = ctx->scale_factor;
> > +} else {
> > +av_log(ctx, AV_LOG_ERROR, "The value of scale_factor
> must be more than 0.0 and less than or equal to 2.0");
> > +}
> > +
>
> I'm quite sure this is not what was meant to be checked.
> Also, the range of this option is already guarded when reading it from the
> command line, you don't have to take care about out of limits here.
>
>
>
> >  #if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
> >  if (ctx->capture_cursor) {
> >  capture_screen_input.capturesCursor = YES;
> > @@ -1025,6 +1032,7 @@ static const AVOption options[] = {
> >  { "video_size", "set video size", offsetof(AVFContext, width),
> AV_OPT_TYPE_IMAGE_SIZE, {.str = > NULL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
> >  { "capture_cursor", "capture the screen cursor",
> offsetof(AVFContext, capture_cursor), AV_OPT_TYPE_INT, {.i64=0}, 0, 1,
> AV_OPT_FLAG_DECODING_PARAM },
> >  { "capture_mouse_clicks", "capture the screen mouse clicks",
> offsetof(AVFContext, > capture_mouse_clicks), AV_OPT_TYPE_INT, {.i64=0}, 0,
> 1, AV_OPT_FLAG_DECODING_PARAM },
> > +{ "scale_factor", "scale screen factor range", offsetof(AVFContext,
> scale_factor),
>
> It is not a range but the value (within a range) defining the scale factor
> of screen recording.
> Also find something more precisely here, please.
>
>
> > AV_OPT_TYPE_FLOAT, {.dbl=1.0}, 0.0, 2.0, AV_OPT_FLAG_DECODING_PARAM },
> >
> >  { NULL },
> >  };
> >
>
> -Thilo
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] fate: add more DCA tests

2017-07-31 Thread Saeid Zangeneh
Excuse me I'm confused! What is this?

On Aug 1, 2017 01:16, "foo86"  wrote:

> Oops, meant to include this comment in previous email:
>
> Improves code coverage:
> old%new%
> dca_core76.581.3
> dca_exss56.565.6
> dca_lbr  2.280.5
> dca_parser  86.298.6
> dca_xll 81.287.2
> dcadec  75.083.0
> dcadsp  64.083.8
>
> Samples are here: https://0x0.st/key.xz
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] coverage: filter /usr/include*, not entire /usr*

2017-07-31 Thread Nicolas George
Le tridi 13 thermidor, an CCXXV, foo86 a écrit :
> /usr* filters all sources when building in /usr/src, which is probably
> not intended.

This is leaving /usr/local/include, and many less known directories,
like compiler-specific includes.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH 1/2] fate: add more DCA tests

2017-07-31 Thread Ronald S. Bultje
Hi,

On Mon, Jul 31, 2017 at 4:46 PM, foo86  wrote:

> Oops, meant to include this comment in previous email:
>
> Improves code coverage:
> old%new%
> dca_core76.581.3
> dca_exss56.565.6
> dca_lbr  2.280.5
> dca_parser  86.298.6
> dca_xll 81.287.2
> dcadec  75.083.0
> dcadsp  64.083.8
>
> Samples are here: https://0x0.st/key.xz


Is the remainder error handling? Or is a subset of features untested? (If
so, do you know which?)

Nice work!

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


Re: [FFmpeg-devel] [mov] Fix trampling of ctts during seeks when sidx support is enabled.

2017-07-31 Thread Dale Curtis
Here's an updated patch with a fate test attached. You'll need to add
http://storage.googleapis.com/dalecurtis/buck480p30_na.mp4 to the
fate-suite/mov for this test. This is licensed under creative commons
attribution, so it should be fine for tests:
https://peach.blender.org/about/ I tried to use the existing samples, but
you need a clip long enough that the entire index isn't generated from the
start.

- dale

On Tue, Jul 25, 2017 at 1:03 PM, Michael Niedermayer  wrote:

> On Mon, Jul 24, 2017 at 02:32:41PM -0700, Dale Curtis wrote:
> > On Thu, Jul 20, 2017 at 5:00 AM, Michael Niedermayer
>  > > wrote:
> >
> > > Hi
> > >
> > > On Wed, Jul 19, 2017 at 07:30:01PM -0700, Dale Curtis wrote:
> > > > Thanks will take a look. Is this test not part of fate? make fate
> passed
> > >
> > > no, we should have tests for all (fixed) tickets in fate ideally
> > > but in reality most tickets lack a corresponding test
> > > I tried both in outreachy and as well in GSoC to improve this situation
> > > with student projects but both only moved this forward by a small
> > > step. Its a large amount of work to create robust, portable and
> > > practical tests for "all" tickets and everything else.
> > > The way out to get this actually done would be to pay a developer to
> > > create tests for "all" tickets in fate. I belive carl would be the
> > > ideal one to do this work as he has since a very long time always
> tested
> > > and kept track of all our tickets.
> > > I did suggest a while ago to someone at google that funding such
> > > project would make sense but IIRC i never heared back.
> > > if some company would fund something like this, i belive this would be
> > > very usefull in the long run for code quality
> > >
> >
> > I think it'd be pretty hard to get someone to go through and create tests
> > for every issue ever seen. Even Chromium has trouble with this, but
> making
>
> yes, unless theres someone who enjoys doing this kind of work.
>
>
> > it part of the culture helps. I.e. reviewers should ask for every change
> to
> > include a test.
>
> yes though theres already
> 1.8 patch submission checklist
> ...
> 26. Consider adding a regression test for your code.
> on http://ffmpeg.org/developer.html
>
>
> > I'm happy to add one to fate for this change. Or can do so
> > in a followup patch if you prefer.
>
> please do (any variant is fine)
>
> thx
>
> >
> > Does anyone have comments on this change specifically? We've already
> rolled
> > this into Chrome and it's working fine and passing all regression tests.
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> --
> 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
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
From 8c99024ff723853d8d8f83d9862b884e57fe2b83 Mon Sep 17 00:00:00 2001
From: Dale Curtis 
Date: Mon, 17 Jul 2017 17:38:09 -0700
Subject: [PATCH] Fix trampling of ctts during seeks when sidx support is
 enabled.

When sidx box support is enabled, the code will skip reading all
trun boxes (each containing ctts entries for samples inthat box).

If seeks are attempted before all ctts values are known, the old
code would dump ctts entries into the wrong location. These are
then used to compute pts values which leads to out of order and
incorrectly timestamped packets.

This patch fixes ctts processing by always using the index returned
by av_add_index_entry() as the ctts_data index. When the index gains
new entries old values are reshuffled as appropriate.

This approach makes sense since the mov demuxer is already relying
on the mapping of AVIndex entries to samples for correct demuxing.

Notes for future improvement:
Probably there are other boxes (stts, stsc, etc) that are impacted
by this issue... this patch only attempts to fix ctts since it
completely breaks packet timestamping.

This patch continues using an array for the ctts data, which is not
the most ideal given the rearrangement that needs to happen (via
memmove as new entries are read in). Ideally AVIndex and the ctts
data would be set-type structures so addition is always worst case
O(lg(n)) instead of the O(n^2) that exists now; this slowdown is
noticeable during seeks.

Additionally since ctts samples from trun boxes always have a count
of 1, there's probably an opportunity to avoid the post-seek fixup
that iterates O(n) over all samples with an O(1) when no non-1 count
samples are present.

Signed-off-by: Dale Curtis 
---
 libavformat/isom.h   |   1 +
 libavformat/mov.c|  58 
 tests/fate/seek.mak  

[FFmpeg-devel] [mov] Bail when invalid sample data is present.

2017-07-31 Thread Dale Curtis
[mov] Bail when invalid sample data is present.

ctts data in ffmpeg relies on the index entries array to be 1:1
with samples... yet sc->sample_count can be read directly from
the 'stsz' box and index entries are only generated if a chunk
count has been read from 'stco' box.

Ensure that if sc->sample_count > 0, sc->chunk_count is too.

This should be applied on top of the ctts fixes in my previous patch.
From e3b51516046255540c5a76b41e02cee7f0902541 Mon Sep 17 00:00:00 2001
From: Dale Curtis 
Date: Mon, 31 Jul 2017 13:44:22 -0700
Subject: [PATCH] [mov] Bail when invalid sample data is present.

ctts data in ffmpeg relies on the index entries array to be 1:1
with samples... yet sc->sample_count can be read directly from
the 'stsz' box and index entries are only generated if a chunk
count has been read from 'stco' box.

Ensure that if sc->sample_count > 0, sc->chunk_count is too.
---
 libavformat/mov.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index ab8e914581..5fe9bfac59 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3750,8 +3750,9 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 c->trak_index = -1;
 
 /* sanity checks */
-if (sc->chunk_count && (!sc->stts_count || !sc->stsc_count ||
-(!sc->sample_size && !sc->sample_count))) {
+if ((sc->chunk_count && (!sc->stts_count || !sc->stsc_count ||
+(!sc->sample_size && !sc->sample_count))) ||
+(!sc->chunk_count && sc->sample_count)) {
 av_log(c->fc, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n",
st->index);
 return 0;
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


Re: [FFmpeg-devel] [PATCH 1/2] fate: add more DCA tests

2017-07-31 Thread Michael Niedermayer
On Mon, Jul 31, 2017 at 11:46:33PM +0300, foo86 wrote:
> Oops, meant to include this comment in previous email:
> 
> Improves code coverage:
> old%new%
> dca_core76.581.3
> dca_exss56.565.6
> dca_lbr  2.280.5
> dca_parser  86.298.6
> dca_xll 81.287.2
> dcadec  75.083.0
> dcadsp  64.083.8
> 

great


> Samples are here: https://0x0.st/key.xz

am i correct in assuming that this cannot be made smaller easily ?

if so ill upload the files

thx


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu


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


Re: [FFmpeg-devel] [PATCH 1/2] fate: add more DCA tests

2017-07-31 Thread James Almer
On 7/31/2017 5:33 PM, foo86 wrote:
> ---
>  tests/fate/dca.mak   |  36 ++
>  tests/ref/fate/dca-core-14be |   1 +
>  tests/ref/fate/dca-core-14le |   1 +
>  tests/ref/fate/dca-core-16be |   1 +
>  tests/ref/fate/dca-core-16le |   1 +
>  tests/ref/fate/dca-core-dmix |   1 +
>  tests/ref/fate/dca-core-size |   1 +
>  tests/ref/fate/dca-core-x96  |   1 +
>  tests/ref/fate/dca-core-xch  |   1 +
>  tests/ref/fate/dca-core-xxch |   1 +
>  tests/ref/fate/dca-xll-ltrt  |   1 +
>  tests/ref/fate/dca-xll-pbr   | 836 
> +++
>  tests/ref/fate/dca-xll-read  | 510 ++
>  tests/ref/fate/dca-xll-sync  | 810 +
>  14 files changed, 2202 insertions(+)
>  create mode 100644 tests/ref/fate/dca-core-14be
>  create mode 100644 tests/ref/fate/dca-core-14le
>  create mode 100644 tests/ref/fate/dca-core-16be
>  create mode 100644 tests/ref/fate/dca-core-16le
>  create mode 100644 tests/ref/fate/dca-core-dmix
>  create mode 100644 tests/ref/fate/dca-core-size
>  create mode 100644 tests/ref/fate/dca-core-x96
>  create mode 100644 tests/ref/fate/dca-core-xch
>  create mode 100644 tests/ref/fate/dca-core-xxch
>  create mode 100644 tests/ref/fate/dca-xll-ltrt
>  create mode 100644 tests/ref/fate/dca-xll-pbr
>  create mode 100644 tests/ref/fate/dca-xll-read
>  create mode 100644 tests/ref/fate/dca-xll-sync
> 
> diff --git a/tests/fate/dca.mak b/tests/fate/dca.mak
> index b1681c6b59..563b83695f 100644
> --- a/tests/fate/dca.mak
> +++ b/tests/fate/dca.mak
> @@ -67,9 +67,45 @@ fate-dca-core: CMD = pcm -i $(TARGET_SAMPLES)/dts/dts.ts
>  fate-dca-core: CMP = oneoff
>  fate-dca-core: REF = $(SAMPLES)/dts/dts.pcm
>  
> +# lossy fixed point tests
> +DCA_FIXED_POINT = dca-core-14be dca-core-14le dca-core-16be dca-core-16le 
> dca-core-size dca-core-x96 dca-core-xch dca-core-xxch
> +
> +define FATE_DCA_FIXED_POINT
> +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-$(1)
> +fate-$(1): CMD = md5 -flags +bitexact -i $(TARGET_SAMPLES)/dts/$(1) -f s24le
> +endef
> +
> +$(foreach N,$(DCA_FIXED_POINT),$(eval $(call FATE_DCA_FIXED_POINT,$(N
> +
> +# lossy fixed point downmix test
> +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-core-dmix
> +fate-dca-core-dmix: CMD = md5 -flags +bitexact -request_channel_layout 0x3 
> -i $(TARGET_SAMPLES)/dts/dca-core-xxch -f s24le
> +
>  FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-xll
>  fate-dca-xll: CMD = md5 -i $(TARGET_SAMPLES)/dts/master_audio_7.1_24bit.dts 
> -f s24le
>  
> +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-xll-ltrt
> +fate-dca-xll-ltrt: CMD = md5 -err_detect crccheck -i 
> $(TARGET_SAMPLES)/dts/dca-xll-ltrt -f s16le

Any reason why these are using md5 instead of framemd5?

> +
> +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-xll-pbr
> +fate-dca-xll-pbr: CMD = framemd5 -err_detect crccheck -i 
> $(TARGET_SAMPLES)/dts/dca-xll-pbr -c:a pcm_s16le
> +
> +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-xll-read
> +fate-dca-xll-read: CMD = framemd5 -err_detect crccheck -i 
> $(TARGET_SAMPLES)/dts/dca-xll-read -c:a pcm_s24le
> +
> +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-xll-sync
> +fate-dca-xll-sync: CMD = framemd5 -err_detect crccheck -i 
> $(TARGET_SAMPLES)/dts/dca-xll-sync -c:a pcm_s24le

Can you limit these to only a bunch of audio frames, the minimum amount
necessary to get the intended code coverage, in order to avoid big
samples and ref files with hundreds of lines? Also because calculating
md5 is expensive.
Notice how the first tests added using your samples (dcadec-suite
folder) are all like six frames each.

Also, the naming scheme is different and you're placing them outside of
the dcadec-suite folder. But that's not as important as the above.

> +
> +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-lbr
> +fate-dca-lbr: CMD = pcm -err_detect crccheck -i $(TARGET_SAMPLES)/dts/dca-lbr
> +fate-dca-lbr: CMP = oneoff
> +fate-dca-lbr: REF = $(SAMPLES)/dts/dca-lbr.pcm
> +
> +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-lbr-256
> +fate-dca-lbr-256: CMD = pcm -err_detect crccheck -i 
> $(TARGET_SAMPLES)/dts/dca-lbr-256
> +fate-dca-lbr-256: CMP = oneoff
> +fate-dca-lbr-256: REF = $(SAMPLES)/dts/dca-lbr-256.pcm

Did you create the pcm files using your decoder, or created the lbr
samples from already existing pcm files? If the former, with what kind
of build and decoder settings?

I ask because, long ago when you first wrote the lbr decoder, you gave
me a bunch of samples i tried to use to write some tests. I used a
x86_32 build and forced no handwritten assembly (so it's all x87 floats)
to create pcm reference files, and the result was that x86_64 builds
(using sse floats, hand written assembly or otherwise) would
unexpectedly fail the tests by a huge error margin.

I narrowed the problem down to dcadsp's lbr_bank_c. That function
compiled with x87 floats and sse floats would give different results,
and i couldn't figure out why. Maybe it was the compiler i used back
then (mingw-w64 gcc 5 i think).

Re: [FFmpeg-devel] [mov] Fix trampling of ctts during seeks when sidx support is enabled.

2017-07-31 Thread Dale Curtis
Whoops, that patch accidentally reverted to an earlier version. Here's the
fixed one that works with the mpg sample mentioned above.

- dale

On Mon, Jul 31, 2017 at 2:29 PM, Dale Curtis 
wrote:

> Here's an updated patch with a fate test attached. You'll need to add
> http://storage.googleapis.com/dalecurtis/buck480p30_na.mp4 to the
> fate-suite/mov for this test. This is licensed under creative commons
> attribution, so it should be fine for tests: https://peach.blender.o
> rg/about/ I tried to use the existing samples, but you need a clip long
> enough that the entire index isn't generated from the start.
>
> - dale
>
> On Tue, Jul 25, 2017 at 1:03 PM, Michael Niedermayer <
> mich...@niedermayer.cc> wrote:
>
>> On Mon, Jul 24, 2017 at 02:32:41PM -0700, Dale Curtis wrote:
>> > On Thu, Jul 20, 2017 at 5:00 AM, Michael Niedermayer
>> > > > wrote:
>> >
>> > > Hi
>> > >
>> > > On Wed, Jul 19, 2017 at 07:30:01PM -0700, Dale Curtis wrote:
>> > > > Thanks will take a look. Is this test not part of fate? make fate
>> passed
>> > >
>> > > no, we should have tests for all (fixed) tickets in fate ideally
>> > > but in reality most tickets lack a corresponding test
>> > > I tried both in outreachy and as well in GSoC to improve this
>> situation
>> > > with student projects but both only moved this forward by a small
>> > > step. Its a large amount of work to create robust, portable and
>> > > practical tests for "all" tickets and everything else.
>> > > The way out to get this actually done would be to pay a developer to
>> > > create tests for "all" tickets in fate. I belive carl would be the
>> > > ideal one to do this work as he has since a very long time always
>> tested
>> > > and kept track of all our tickets.
>> > > I did suggest a while ago to someone at google that funding such
>> > > project would make sense but IIRC i never heared back.
>> > > if some company would fund something like this, i belive this would be
>> > > very usefull in the long run for code quality
>> > >
>> >
>> > I think it'd be pretty hard to get someone to go through and create
>> tests
>> > for every issue ever seen. Even Chromium has trouble with this, but
>> making
>>
>> yes, unless theres someone who enjoys doing this kind of work.
>>
>>
>> > it part of the culture helps. I.e. reviewers should ask for every
>> change to
>> > include a test.
>>
>> yes though theres already
>> 1.8 patch submission checklist
>> ...
>> 26. Consider adding a regression test for your code.
>> on http://ffmpeg.org/developer.html
>>
>>
>> > I'm happy to add one to fate for this change. Or can do so
>> > in a followup patch if you prefer.
>>
>> please do (any variant is fine)
>>
>> thx
>>
>> >
>> > Does anyone have comments on this change specifically? We've already
>> rolled
>> > this into Chrome and it's working fine and passing all regression tests.
>> > ___
>> > ffmpeg-devel mailing list
>> > ffmpeg-devel@ffmpeg.org
>> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> --
>> 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
>>
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>>
>
From 72f1211befcd169fbf343b902185995aece926df Mon Sep 17 00:00:00 2001
From: Dale Curtis 
Date: Mon, 17 Jul 2017 17:38:09 -0700
Subject: [PATCH] Fix trampling of ctts during seeks when sidx support is
 enabled.

When sidx box support is enabled, the code will skip reading all
trun boxes (each containing ctts entries for samples inthat box).

If seeks are attempted before all ctts values are known, the old
code would dump ctts entries into the wrong location. These are
then used to compute pts values which leads to out of order and
incorrectly timestamped packets.

This patch fixes ctts processing by always using the index returned
by av_add_index_entry() as the ctts_data index. When the index gains
new entries old values are reshuffled as appropriate.

This approach makes sense since the mov demuxer is already relying
on the mapping of AVIndex entries to samples for correct demuxing.

As a result of this all ctts entries are now 1-count. A followup
change will be submitted to remove support for > 1 count entries
which will simplify seeking.

Notes for future improvement:
Probably there are other boxes (stts, stsc, etc) that are impacted
by this issue... this patch only attempts to fix ctts since it
completely breaks packet timestamping.

This patch continues using an array for the ctts data, which is not
the most ideal given the rearrangement that needs to happen (via
memmove as new entries are read in). Ideally AVIndex and the ctts
data would be set-type structures so ad

Re: [FFmpeg-devel] [mov] Bail when invalid sample data is present.

2017-07-31 Thread Dale Curtis
I'm not convinced my original patch catches all cases. So here's an updated
one which explicitly verifies the contract.

- dale

On Mon, Jul 31, 2017 at 2:40 PM, Dale Curtis 
wrote:

> [mov] Bail when invalid sample data is present.
>
> ctts data in ffmpeg relies on the index entries array to be 1:1
> with samples... yet sc->sample_count can be read directly from
> the 'stsz' box and index entries are only generated if a chunk
> count has been read from 'stco' box.
>
> Ensure that if sc->sample_count > 0, sc->chunk_count is too.
>
> This should be applied on top of the ctts fixes in my previous patch.
>
>
From 51571dd294350f2ef367fd9391ed4c1e94387947 Mon Sep 17 00:00:00 2001
From: Dale Curtis 
Date: Mon, 31 Jul 2017 13:44:22 -0700
Subject: [PATCH] [mov] Bail when invalid sample data is present.

ctts data in ffmpeg relies on the index entries array to be 1:1
with samples... yet sc->sample_count can be read directly from
the 'stsz' box and index entries are only generated if a chunk
count has been read from 'stco' box.

Ensure that if sc->sample_count > 0, sc->chunk_count is too as
a basic sanity check. Additionally we need to check that after
the index is built we have the right number of entries, so we
also check in mov_read_trun() that sc->sample_count ==
st->nb_index_entries.
---
 libavformat/mov.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 13b5e454d8..6edb898b3e 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3752,8 +3752,9 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 c->trak_index = -1;
 
 /* sanity checks */
-if (sc->chunk_count && (!sc->stts_count || !sc->stsc_count ||
-(!sc->sample_size && !sc->sample_count))) {
+if ((sc->chunk_count && (!sc->stts_count || !sc->stsc_count ||
+(!sc->sample_size && !sc->sample_count))) ||
+(!sc->chunk_count && sc->sample_count)) {
 av_log(c->fc, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n",
st->index);
 return 0;
@@ -4288,6 +4289,9 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
  *  3) in the subsequent movie fragments, there are samples with composition time offset. */
 if (!sc->ctts_count && sc->sample_count)
 {
+/* ctts relies on being 1:1 with sample entries. */
+if (sc->sample_count != st->nb_index_entries)
+return AVERROR_INVALIDDATA;
 /* Complement ctts table if moov atom doesn't have ctts atom. */
 ctts_data = av_fast_realloc(NULL, &sc->ctts_allocated_size, sizeof(*sc->ctts_data) * sc->sample_count);
 if (!ctts_data)
-- 
2.14.0.rc0.400.g1c36432dff-goog

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


Re: [FFmpeg-devel] [PATCH 1/2] fate: add more DCA tests

2017-07-31 Thread foo86
On Mon, Jul 31, 2017 at 06:50:44PM -0300, James Almer wrote:
> On 7/31/2017 5:33 PM, foo86 wrote:
> > ---
> >  tests/fate/dca.mak   |  36 ++
> >  tests/ref/fate/dca-core-14be |   1 +
> >  tests/ref/fate/dca-core-14le |   1 +
> >  tests/ref/fate/dca-core-16be |   1 +
> >  tests/ref/fate/dca-core-16le |   1 +
> >  tests/ref/fate/dca-core-dmix |   1 +
> >  tests/ref/fate/dca-core-size |   1 +
> >  tests/ref/fate/dca-core-x96  |   1 +
> >  tests/ref/fate/dca-core-xch  |   1 +
> >  tests/ref/fate/dca-core-xxch |   1 +
> >  tests/ref/fate/dca-xll-ltrt  |   1 +
> >  tests/ref/fate/dca-xll-pbr   | 836 
> > +++
> >  tests/ref/fate/dca-xll-read  | 510 ++
> >  tests/ref/fate/dca-xll-sync  | 810 
> > +
> >  14 files changed, 2202 insertions(+)
> >  create mode 100644 tests/ref/fate/dca-core-14be
> >  create mode 100644 tests/ref/fate/dca-core-14le
> >  create mode 100644 tests/ref/fate/dca-core-16be
> >  create mode 100644 tests/ref/fate/dca-core-16le
> >  create mode 100644 tests/ref/fate/dca-core-dmix
> >  create mode 100644 tests/ref/fate/dca-core-size
> >  create mode 100644 tests/ref/fate/dca-core-x96
> >  create mode 100644 tests/ref/fate/dca-core-xch
> >  create mode 100644 tests/ref/fate/dca-core-xxch
> >  create mode 100644 tests/ref/fate/dca-xll-ltrt
> >  create mode 100644 tests/ref/fate/dca-xll-pbr
> >  create mode 100644 tests/ref/fate/dca-xll-read
> >  create mode 100644 tests/ref/fate/dca-xll-sync
> > 
> > diff --git a/tests/fate/dca.mak b/tests/fate/dca.mak
> > index b1681c6b59..563b83695f 100644
> > --- a/tests/fate/dca.mak
> > +++ b/tests/fate/dca.mak
> > @@ -67,9 +67,45 @@ fate-dca-core: CMD = pcm -i $(TARGET_SAMPLES)/dts/dts.ts
> >  fate-dca-core: CMP = oneoff
> >  fate-dca-core: REF = $(SAMPLES)/dts/dts.pcm
> >  
> > +# lossy fixed point tests
> > +DCA_FIXED_POINT = dca-core-14be dca-core-14le dca-core-16be dca-core-16le 
> > dca-core-size dca-core-x96 dca-core-xch dca-core-xxch
> > +
> > +define FATE_DCA_FIXED_POINT
> > +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-$(1)
> > +fate-$(1): CMD = md5 -flags +bitexact -i $(TARGET_SAMPLES)/dts/$(1) -f 
> > s24le
> > +endef
> > +
> > +$(foreach N,$(DCA_FIXED_POINT),$(eval $(call FATE_DCA_FIXED_POINT,$(N
> > +
> > +# lossy fixed point downmix test
> > +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-core-dmix
> > +fate-dca-core-dmix: CMD = md5 -flags +bitexact -request_channel_layout 0x3 
> > -i $(TARGET_SAMPLES)/dts/dca-core-xxch -f s24le
> > +
> >  FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-xll
> >  fate-dca-xll: CMD = md5 -i 
> > $(TARGET_SAMPLES)/dts/master_audio_7.1_24bit.dts -f s24le
> >  
> > +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-xll-ltrt
> > +fate-dca-xll-ltrt: CMD = md5 -err_detect crccheck -i 
> > $(TARGET_SAMPLES)/dts/dca-xll-ltrt -f s16le
> 
> Any reason why these are using md5 instead of framemd5?

To save space, because I didn't expect individual frame checksums to be
interesting in these tests.

> > +
> > +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-xll-pbr
> > +fate-dca-xll-pbr: CMD = framemd5 -err_detect crccheck -i 
> > $(TARGET_SAMPLES)/dts/dca-xll-pbr -c:a pcm_s16le
> > +
> > +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-xll-read
> > +fate-dca-xll-read: CMD = framemd5 -err_detect crccheck -i 
> > $(TARGET_SAMPLES)/dts/dca-xll-read -c:a pcm_s24le
> > +
> > +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-xll-sync
> > +fate-dca-xll-sync: CMD = framemd5 -err_detect crccheck -i 
> > $(TARGET_SAMPLES)/dts/dca-xll-sync -c:a pcm_s24le
> 
> Can you limit these to only a bunch of audio frames, the minimum amount
> necessary to get the intended code coverage, in order to avoid big
> samples and ref files with hundreds of lines? Also because calculating
> md5 is expensive.
> Notice how the first tests added using your samples (dcadec-suite
> folder) are all like six frames each.

fate-dca-xll-read test can be possibly reduced to a few frames, but -pbr
and -sync tests cannot (these need to encompass entire bitrate-managed
section of audio track, which can be quite lengthy). I can change those
to md5 if size of reference files is of concern.

> Also, the naming scheme is different and you're placing them outside of
> the dcadec-suite folder. But that's not as important as the above.

These files are not part of the original dcadec test suite, therefore
different naming scheme. How do you prefer them to be named?

> > +
> > +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-lbr
> > +fate-dca-lbr: CMD = pcm -err_detect crccheck -i 
> > $(TARGET_SAMPLES)/dts/dca-lbr
> > +fate-dca-lbr: CMP = oneoff
> > +fate-dca-lbr: REF = $(SAMPLES)/dts/dca-lbr.pcm
> > +
> > +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-lbr-256
> > +fate-dca-lbr-256: CMD = pcm -err_detect crccheck -i 
> > $(TARGET_SAMPLES)/dts/dca-lbr-256
> > +fate-dca-lbr-256: CMP = oneoff
> > +fate-dca-lbr-256: REF = $(SAMPLES)/dts/dca-lbr-256.pcm
> 
> Did you create the pcm files

Re: [FFmpeg-devel] [PATCH 1/2] fate: add more DCA tests

2017-07-31 Thread foo86
On Mon, Jul 31, 2017 at 11:48:09PM +0200, Michael Niedermayer wrote:
> On Mon, Jul 31, 2017 at 11:46:33PM +0300, foo86 wrote:
> > Oops, meant to include this comment in previous email:
> > 
> > Improves code coverage:
> > old%new%
> > dca_core76.581.3
> > dca_exss56.565.6
> > dca_lbr  2.280.5
> > dca_parser  86.298.6
> > dca_xll 81.287.2
> > dcadec  75.083.0
> > dcadsp  64.083.8
> > 
> 
> great
> 
> 
> > Samples are here: https://0x0.st/key.xz
> 
> am i correct in assuming that this cannot be made smaller easily ?
> 
> if so ill upload the files
> 
> thx

I think size of some files can be reduced, so if space is of concern,
please don't upload them yet.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] fate: add more DCA tests

2017-07-31 Thread foo86
On Mon, Jul 31, 2017 at 05:14:01PM -0400, Ronald S. Bultje wrote:
> Hi,
> 
> On Mon, Jul 31, 2017 at 4:46 PM, foo86  wrote:
> 
> > Oops, meant to include this comment in previous email:
> >
> > Improves code coverage:
> > old%new%
> > dca_core76.581.3
> > dca_exss56.565.6
> > dca_lbr  2.280.5
> > dca_parser  86.298.6
> > dca_xll 81.287.2
> > dcadec  75.083.0
> > dcadsp  64.083.8
> >
> > Samples are here: https://0x0.st/key.xz
> 
> 
> Is the remainder error handling? Or is a subset of features untested? (If
> so, do you know which?)

This is mostly error handling, but there are some untested features
which are either never used (mixing metadata in EXSS) or very rare (5.1
LBR).

> 
> Nice work!
> 
> Ronald
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] coverage: filter /usr/include*, not entire /usr*

2017-07-31 Thread foo86
On Mon, Jul 31, 2017 at 11:06:01PM +0200, Nicolas George wrote:
> Le tridi 13 thermidor, an CCXXV, foo86 a écrit :
> > /usr* filters all sources when building in /usr/src, which is probably
> > not intended.
> 
> This is leaving /usr/local/include, and many less known directories,
> like compiler-specific includes.

I see. Consider this patch withdrawn then.

> 
> Regards,
> 
> -- 
>   Nicolas George
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] fate: add more DCA tests

2017-07-31 Thread Michael Niedermayer
On Tue, Aug 01, 2017 at 03:01:38AM +0300, foo86 wrote:
> On Mon, Jul 31, 2017 at 11:48:09PM +0200, Michael Niedermayer wrote:
> > On Mon, Jul 31, 2017 at 11:46:33PM +0300, foo86 wrote:
> > > Oops, meant to include this comment in previous email:
> > > 
> > > Improves code coverage:
> > > old%new%
> > > dca_core76.581.3
> > > dca_exss56.565.6
> > > dca_lbr  2.280.5
> > > dca_parser  86.298.6
> > > dca_xll 81.287.2
> > > dcadec  75.083.0
> > > dcadsp  64.083.8
> > > 
> > 
> > great
> > 
> > 
> > > Samples are here: https://0x0.st/key.xz
> > 
> > am i correct in assuming that this cannot be made smaller easily ?
> > 
> > if so ill upload the files
> > 
> > thx
> 
> I think size of some files can be reduced, so if space is of concern,
> please don't upload them yet.

smaller files are better if its not much work.

thx

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

Never trust a computer, one day, it may think you are the virus. -- Compn


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


Re: [FFmpeg-devel] [PATCH 1/2] fate: add more DCA tests

2017-07-31 Thread James Almer
On 7/31/2017 8:58 PM, foo86 wrote:
> On Mon, Jul 31, 2017 at 06:50:44PM -0300, James Almer wrote:
>> On 7/31/2017 5:33 PM, foo86 wrote:
>>> ---
>>>  tests/fate/dca.mak   |  36 ++
>>>  tests/ref/fate/dca-core-14be |   1 +
>>>  tests/ref/fate/dca-core-14le |   1 +
>>>  tests/ref/fate/dca-core-16be |   1 +
>>>  tests/ref/fate/dca-core-16le |   1 +
>>>  tests/ref/fate/dca-core-dmix |   1 +
>>>  tests/ref/fate/dca-core-size |   1 +
>>>  tests/ref/fate/dca-core-x96  |   1 +
>>>  tests/ref/fate/dca-core-xch  |   1 +
>>>  tests/ref/fate/dca-core-xxch |   1 +
>>>  tests/ref/fate/dca-xll-ltrt  |   1 +
>>>  tests/ref/fate/dca-xll-pbr   | 836 
>>> +++
>>>  tests/ref/fate/dca-xll-read  | 510 ++
>>>  tests/ref/fate/dca-xll-sync  | 810 
>>> +
>>>  14 files changed, 2202 insertions(+)
>>>  create mode 100644 tests/ref/fate/dca-core-14be
>>>  create mode 100644 tests/ref/fate/dca-core-14le
>>>  create mode 100644 tests/ref/fate/dca-core-16be
>>>  create mode 100644 tests/ref/fate/dca-core-16le
>>>  create mode 100644 tests/ref/fate/dca-core-dmix
>>>  create mode 100644 tests/ref/fate/dca-core-size
>>>  create mode 100644 tests/ref/fate/dca-core-x96
>>>  create mode 100644 tests/ref/fate/dca-core-xch
>>>  create mode 100644 tests/ref/fate/dca-core-xxch
>>>  create mode 100644 tests/ref/fate/dca-xll-ltrt
>>>  create mode 100644 tests/ref/fate/dca-xll-pbr
>>>  create mode 100644 tests/ref/fate/dca-xll-read
>>>  create mode 100644 tests/ref/fate/dca-xll-sync
>>>
>>> diff --git a/tests/fate/dca.mak b/tests/fate/dca.mak
>>> index b1681c6b59..563b83695f 100644
>>> --- a/tests/fate/dca.mak
>>> +++ b/tests/fate/dca.mak
>>> @@ -67,9 +67,45 @@ fate-dca-core: CMD = pcm -i $(TARGET_SAMPLES)/dts/dts.ts
>>>  fate-dca-core: CMP = oneoff
>>>  fate-dca-core: REF = $(SAMPLES)/dts/dts.pcm
>>>  
>>> +# lossy fixed point tests
>>> +DCA_FIXED_POINT = dca-core-14be dca-core-14le dca-core-16be dca-core-16le 
>>> dca-core-size dca-core-x96 dca-core-xch dca-core-xxch
>>> +
>>> +define FATE_DCA_FIXED_POINT
>>> +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-$(1)
>>> +fate-$(1): CMD = md5 -flags +bitexact -i $(TARGET_SAMPLES)/dts/$(1) -f 
>>> s24le
>>> +endef
>>> +
>>> +$(foreach N,$(DCA_FIXED_POINT),$(eval $(call FATE_DCA_FIXED_POINT,$(N
>>> +
>>> +# lossy fixed point downmix test
>>> +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-core-dmix
>>> +fate-dca-core-dmix: CMD = md5 -flags +bitexact -request_channel_layout 0x3 
>>> -i $(TARGET_SAMPLES)/dts/dca-core-xxch -f s24le
>>> +
>>>  FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-xll
>>>  fate-dca-xll: CMD = md5 -i 
>>> $(TARGET_SAMPLES)/dts/master_audio_7.1_24bit.dts -f s24le
>>>  
>>> +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-xll-ltrt
>>> +fate-dca-xll-ltrt: CMD = md5 -err_detect crccheck -i 
>>> $(TARGET_SAMPLES)/dts/dca-xll-ltrt -f s16le
>>
>> Any reason why these are using md5 instead of framemd5?
> 
> To save space, because I didn't expect individual frame checksums to be
> interesting in these tests.

It's not so much about each frame's checksum in most cases as it's about
the extra printed info. It makes it easier to detect if something
changed in how the stream is detected that might not affect checksums
(time base, pts/dts, etc). But i guess that's already covered in every
other xll test.

For that matter, you can do something like

fate-dca-core-dmix: REF = 8e8f2e223787d2436853b5310dc6ec04

To avoid creating external ref files for md5 tests.

> 
>>> +
>>> +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-xll-pbr
>>> +fate-dca-xll-pbr: CMD = framemd5 -err_detect crccheck -i 
>>> $(TARGET_SAMPLES)/dts/dca-xll-pbr -c:a pcm_s16le
>>> +
>>> +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-xll-read
>>> +fate-dca-xll-read: CMD = framemd5 -err_detect crccheck -i 
>>> $(TARGET_SAMPLES)/dts/dca-xll-read -c:a pcm_s24le
>>> +
>>> +FATE_DCA-$(call DEMDEC, DTS, DCA) += fate-dca-xll-sync
>>> +fate-dca-xll-sync: CMD = framemd5 -err_detect crccheck -i 
>>> $(TARGET_SAMPLES)/dts/dca-xll-sync -c:a pcm_s24le
>>
>> Can you limit these to only a bunch of audio frames, the minimum amount
>> necessary to get the intended code coverage, in order to avoid big
>> samples and ref files with hundreds of lines? Also because calculating
>> md5 is expensive.
>> Notice how the first tests added using your samples (dcadec-suite
>> folder) are all like six frames each.
> 
> fate-dca-xll-read test can be possibly reduced to a few frames, but -pbr
> and -sync tests cannot (these need to encompass entire bitrate-managed
> section of audio track, which can be quite lengthy). I can change those
> to md5 if size of reference files is of concern.

Keep -pbr and -sync as they are and try to make the rest smaller, then.
Smallest size possible while making sure the test coverage is the
intended. It'll help save some bandwidth over time in our rsync server.

And you can keep them as framemd5. You chose it for those instead of md

[FFmpeg-devel] [DISCUSSION] Motion Estimation API/Library

2017-07-31 Thread Davinder Singh
Hello everyone,

As we've been planning since forever (
https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/snow.h#L182,
http://ffmpeg.org/pipermail/ffmpeg-devel/2016-July/197095.html) we need
Motion Estimation code that could be shared in codecs and motion filters.

The idea is to make the Motion Estimation idependent of Encoders more
specifically - AVCodecContext.
So, I’ve moved motion estimation and me_cmp code to a new location -
libmotion . I
think it’s a good idea to make a new lib instead moving it to
libavutil (as discussed
previously ).
That way we can make it independent of everything else in FFmpeg.
Everything will be accessed through single context AVMotionEstContext, and
also be initialized through it. This API could also be used by researchers
to test new codecs or FRUC. And additionally, we can implement best Optical
Flow methods: http://vision.middlebury.edu/flow/eval/results/results-i1.php in
the future which are not available in OpenCV.

GOALS:
1. Make me_cmp_func()

independent of MpegEncContext and AVCodecContext. To accomplish this, we
can move following from MpegEncContext to MotionEstContext or[*]
MECmpContext (as these are used in cmp fxn in me_cmp.c
):
int mb_intra;
PixblockDSPContext pdsp;
FDCTDSPContext fdsp;
IDCTDSPContext idsp;
int (*fast_dct_quantize)();
void (*dct_unquantize_inter)();
void (*dct_unquantize_intra)();
int block_last_index[12];
int qscale;
ScanTable intra_scantable;
int ac_esc_length;
uint8_t *intra_ac_vlc_length;
uint8_t *intra_ac_vlc_last_length;
uint8_t *inter_ac_vlc_length;
uint8_t *inter_ac_vlc_last_length;
uint8_t *luma_dc_vlc_length;
MECmpContext mecc; [*]

As pointed by michaelni earlier, these are mostly more used by Encoders
than ME. If libavcodec is more appropriate place for some of these (e.g.
pdsp, fdsp) and these are also used by few cmp functions, like
FF_CMP_BIT, FF_CMP_RD, FF_CMP_DCT, FF_CMP_PSNR,
we can move these to specific encoders and set function address in Context
before using them. Or we can register cmp functions via by calling API
while initializing FFmpeg/Options. Only generic functions will be part of
libmotion.

2. Initialization of MECmpContext at one place (like init pdsp and dct if
moved in MECmpContext).
3. Make motion_est.c

code independent of MpegEncContext. for this a lot of things need to be
moved from MpegEncContext to MotionEstContext. MpegEncContext is used at
lot of places. Please suggest your approach on this. Generic ME should
surely be seperated.

Please share your views on this.

Regards,
-- 
Davinder Singh
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/atrac3p: use float_dsp in ff_atrac3p_power_compensation

2017-07-31 Thread James Almer
On 7/29/2017 1:12 AM, James Almer wrote:
> On 7/20/2017 4:01 PM, James Almer wrote:
>> Signed-off-by: James Almer 
>> ---
>> Fate passes, so i guess the aligment requirements are met.
>>
>>  libavcodec/atrac3plus.h|  5 +++--
>>  libavcodec/atrac3plusdec.c | 36 ++--
>>  libavcodec/atrac3plusdsp.c |  8 
>>  3 files changed, 25 insertions(+), 24 deletions(-)
> 
> Will push soon unless someone objects.

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


Re: [FFmpeg-devel] [DISCUSSION] Motion Estimation API/Library

2017-07-31 Thread Nicolas George
Le quartidi 14 thermidor, an CCXXV, Davinder Singh a écrit :
> As we've been planning since forever (
> https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/snow.h#L182,
> http://ffmpeg.org/pipermail/ffmpeg-devel/2016-July/197095.html) we need
> Motion Estimation code that could be shared in codecs and motion filters.
> 
> The idea is to make the Motion Estimation idependent of Encoders more
> specifically - AVCodecContext.

This is a very good idea.

> So, I’ve moved motion estimation and me_cmp code to a new location -
> libmotion . I
> think it’s a good idea to make a new lib instead moving it to
> libavutil (as discussed
> previously ).
> That way we can make it independent of everything else in FFmpeg.

But this is not. Please no, not yet another library!

A separate library like that will at the beginning only be used by the
handful of hard-core developers. Unless it meets a wide success very
fast, with very useful tools available immediately, it will soon be
forgotten ("seems interesting, but not yet mature, I'll come back and
see in six months") and start bitrotting as soon as you have moved to
something else.

In particular, the main policy of FFmpeg is to not depend on external
libraries for core features. Therefore, if your project is a separate
library, it will definitely not be used by FFmpeg codecs like you wish
in your first paragraph.

If you want a fighting chance of a project that is not stillborn, I
think you need to make it part of FFmpeg, and make sure important
components of FFmpeg use it as soon as possible.

Regards,

-- 
  Nicolas George


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


[FFmpeg-devel] [PATCH 6/7] lavf/flacenc: avoid buffer overread with unexpected extradata sizes

2017-07-31 Thread Rodger Combs
---
 libavformat/flacenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index 9768b6a..1906aee 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -322,7 +322,7 @@ static int flac_write_trailer(struct AVFormatContext *s)
 if (!c->write_header || !streaminfo)
 return 0;
 
-if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
+if (pb->seekable & AVIO_SEEKABLE_NORMAL && (c->streaminfo || 
s->streams[0]->codecpar->extradata_size == FLAC_STREAMINFO_SIZE)) {
 /* rewrite the STREAMINFO header block data */
 file_size = avio_tell(pb);
 avio_seek(pb, 8, SEEK_SET);
-- 
2.6.4

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


[FFmpeg-devel] [PATCH 4/7] lavf/segment: write attached pictures to all segments by default

2017-07-31 Thread Rodger Combs
---
 doc/muxers.texi   |  4 
 libavformat/segment.c | 24 
 2 files changed, 28 insertions(+)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 23ef2e7..93147e1 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1576,6 +1576,10 @@ argument must be a time duration specification, and 
defaults to 0.
 If enabled, write an empty segment if there are no packets during the period a
 segment would usually span. Otherwise, the segment will be filled with the next
 packet written. Defaults to @code{0}.
+
+@item dup_attached_pics @var{1|0}
+If enabled, attached-picture packets will be written to all segments, rather
+than only the first. Defaults to @code{1}.
 @end table
 
 @subsection Examples
diff --git a/libavformat/segment.c b/libavformat/segment.c
index ef0a915..8e82030 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -119,6 +119,7 @@ typedef struct SegmentContext {
 int   reference_stream_index;
 int   break_non_keyframes;
 int   write_empty;
+int   dup_attached_pics;
 
 int use_rename;
 char temp_list_filename[1024];
@@ -126,6 +127,8 @@ typedef struct SegmentContext {
 SegmentListEntry cur_entry;
 SegmentListEntry *segment_list_entries;
 SegmentListEntry *segment_list_entries_end;
+
+AVPacket *attached_pics;
 } SegmentContext;
 
 static void print_csv_escaped_str(AVIOContext *ctx, const char *str)
@@ -301,6 +304,7 @@ static int segment_start(AVFormatContext *s, int 
write_header)
 av_opt_set(oc->priv_data, "mpegts_flags", "+resend_headers", 0);
 
 if (write_header) {
+int i;
 AVDictionary *options = NULL;
 av_dict_copy(&options, seg->format_options, 0);
 av_dict_set(&options, "fflags", "-autobsf", 0);
@@ -308,6 +312,13 @@ static int segment_start(AVFormatContext *s, int 
write_header)
 av_dict_free(&options);
 if (err < 0)
 return err;
+for (i = 0; i < s->nb_streams; i++) {
+if (seg->dup_attached_pics &&
+s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC &&
+seg->attached_pics[i].data) {
+av_write_frame(oc, &seg->attached_pics[i]);
+}
+}
 }
 
 seg->segment_frame_count = 0;
@@ -680,6 +691,12 @@ static void seg_free(AVFormatContext *s)
 ff_format_io_close(seg->avf, &seg->list_pb);
 avformat_free_context(seg->avf);
 seg->avf = NULL;
+if (seg->attached_pics) {
+int i;
+for (i = 0; i < s->nb_streams; i++)
+av_packet_unref(&seg->attached_pics[i]);
+av_freep(&seg->attached_pics);
+}
 }
 
 static int seg_init(AVFormatContext *s)
@@ -840,6 +857,9 @@ static int seg_init(AVFormatContext *s)
 avpriv_set_pts_info(outer_st, inner_st->pts_wrap_bits, 
inner_st->time_base.num, inner_st->time_base.den);
 }
 
+if (seg->dup_attached_pics && !(seg->attached_pics = 
av_calloc(s->nb_streams, sizeof(AVPacket
+return AVERROR(ENOMEM);
+
 if (oc->avoid_negative_ts > 0 && s->avoid_negative_ts < 0)
 s->avoid_negative_ts = 1;
 
@@ -905,6 +925,9 @@ static int seg_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 if (!seg->avf || !seg->avf->pb)
 return AVERROR(EINVAL);
 
+if (seg->dup_attached_pics && st->disposition & 
AV_DISPOSITION_ATTACHED_PIC)
+av_copy_packet(&seg->attached_pics[pkt->stream_index], pkt);
+
 calc_times:
 if (seg->times) {
 end_pts = seg->segment_count < seg->nb_times ?
@@ -,6 +1134,7 @@ static const AVOption options[] = {
 { "reset_timestamps", "reset timestamps at the begin of each segment", 
OFFSET(reset_timestamps), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, E },
 { "initial_offset", "set initial timestamp offset", 
OFFSET(initial_offset), AV_OPT_TYPE_DURATION, {.i64 = 0}, -INT64_MAX, 
INT64_MAX, E },
 { "write_empty_segments", "allow writing empty 'filler' segments", 
OFFSET(write_empty), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, E },
+{ "dup_attached_pics",  "write attached pictures to all segments", 
OFFSET(dup_attached_pics), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, E },
 { NULL },
 };
 
-- 
2.6.4

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


[FFmpeg-devel] [PATCH 7/7] lavf/flacenc: generate timestamps internally

2017-07-31 Thread Rodger Combs
---
 libavformat/flacenc.c | 88 +--
 1 file changed, 85 insertions(+), 3 deletions(-)

diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index 1906aee..f569c14 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -30,6 +30,7 @@
 #include "internal.h"
 #include "vorbiscomment.h"
 #include "libavcodec/bytestream.h"
+#include "libavutil/crc.h"
 
 
 typedef struct FlacMuxerContext {
@@ -46,6 +47,9 @@ typedef struct FlacMuxerContext {
 uint8_t *streaminfo;
 
 unsigned attached_types;
+
+uint64_t samples;
+unsigned last_bs;
 } FlacMuxerContext;
 
 static int flac_write_block_padding(AVIOContext *pb, unsigned int 
n_padding_bytes,
@@ -263,11 +267,17 @@ static int flac_write_header(struct AVFormatContext *s)
 return ret;
 }
 
+static const int32_t blocksize_table[16] = {
+ 0,192, 576<<0, 576<<1, 576<<2, 576<<3,  0,  0,
+256<<0, 256<<1, 256<<2, 256<<3, 256<<4, 256<<5, 256<<6, 256<<7
+};
+
 static int flac_write_audio_packet(struct AVFormatContext *s, AVPacket *pkt)
 {
 FlacMuxerContext *c = s->priv_data;
 uint8_t *streaminfo;
 int streaminfo_size;
+char header[16];
 
 /* check for updated streaminfo */
 streaminfo = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
@@ -281,8 +291,77 @@ static int flac_write_audio_packet(struct AVFormatContext 
*s, AVPacket *pkt)
 memcpy(c->streaminfo, streaminfo, FLAC_STREAMINFO_SIZE);
 }
 
-if (pkt->size)
-avio_write(s->pb, pkt->data, pkt->size);
+if (pkt->size) {
+uint8_t tmp;
+uint64_t pts = c->samples;
+int offset = 5;
+int headerlen = 4;
+int bscode, bs;
+int crc;
+if (pkt->size < FLAC_MIN_FRAME_SIZE)
+return AVERROR_INVALIDDATA;
+memcpy(header, pkt->data, 4);
+if (pkt->pts == AV_NOPTS_VALUE)
+pts = 0;
+if ((pkt->data[4] & 0xC0) == 0xC0)
+offset += ff_clz((unsigned char)~pkt->data[4]) - 25;
+else if (pkt->data[4] & 0x80)
+return AVERROR_INVALIDDATA;
+if (pkt->size <= offset + 1)
+return AVERROR_INVALIDDATA;
+
+bscode = (unsigned char)header[2] >> 4;
+bs = blocksize_table[bscode];
+if (bscode == 0)
+return AVERROR_INVALIDDATA;
+if (bscode == 6) {
+if (pkt->size <= offset + 1)
+return AVERROR_INVALIDDATA;
+bs = pkt->data[offset] + 1;
+} else if (bscode == 7) {
+if (pkt->size <= offset + 2)
+return AVERROR_INVALIDDATA;
+bs = AV_RB16(&pkt->data[offset]) + 1;
+}
+if ((header[1] & 1) == 0)
+pts /= c->last_bs ? c->last_bs : bs;
+
+c->last_bs = bs;
+
+c->samples += bs;
+
+PUT_UTF8(pts, tmp, header[headerlen++] = tmp;)
+if (headerlen > 11)
+return AVERROR_INVALIDDATA;
+if ((bscode & 0xE) == 0x6)
+header[headerlen++] = pkt->data[offset++];
+if (pkt->size <= offset + 1)
+return AVERROR_INVALIDDATA;
+if (bscode == 0x7)
+header[headerlen++] = pkt->data[offset++];
+if (pkt->size <= offset + 1)
+return AVERROR_INVALIDDATA;
+if ((header[2] & 0xC) == 0xC) {
+header[headerlen++] = pkt->data[offset++];
+if (pkt->size <= offset + 1)
+return AVERROR_INVALIDDATA;
+if ((header[2] & 0x3) == 0x3)
+return AVERROR_INVALIDDATA;
+else if (header[2] & 0x3) {
+header[headerlen++] = pkt->data[offset++];
+if (pkt->size <= offset + 1)
+return AVERROR_INVALIDDATA;
+}
+}
+header[headerlen] = av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, header, 
headerlen);
+headerlen++; offset++;
+crc = av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, header, headerlen);
+if (pkt->size < offset + 3)
+return AVERROR_INVALIDDATA;
+avio_write(s->pb, header, headerlen);
+avio_write(s->pb, pkt->data + offset, pkt->size - offset - 2);
+avio_wl16(s->pb, av_crc(av_crc_get_table(AV_CRC_16_ANSI), crc, 
pkt->data + offset, pkt->size - offset - 2));
+}
 return 0;
 }
 
@@ -326,7 +405,10 @@ static int flac_write_trailer(struct AVFormatContext *s)
 /* rewrite the STREAMINFO header block data */
 file_size = avio_tell(pb);
 avio_seek(pb, 8, SEEK_SET);
-avio_write(pb, streaminfo, FLAC_STREAMINFO_SIZE);
+avio_write(pb, streaminfo, 13);
+avio_w8(pb, (streaminfo[13] & 0xF0) | ((c->samples >> 32) & 0xF));
+avio_wb32(pb, c->samples);
+avio_write(pb, streaminfo + 18, FLAC_STREAMINFO_SIZE - 18);
 avio_seek(pb, file_size, SEEK_SET);
 avio_flush(pb);
 } else {
-- 
2.6.4

___
ffmpeg-devel mailing list
ffmpeg-devel

[FFmpeg-devel] [PATCH 3/7] lavf/segment: copy stream dispositions in output

2017-07-31 Thread Rodger Combs
---
 libavformat/segment.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index 590f62b..ef0a915 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -182,6 +182,7 @@ static int segment_mux_init(AVFormatContext *s)
 }
 st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
 st->time_base = s->streams[i]->time_base;
+st->disposition = s->streams[i]->disposition;
 av_dict_copy(&st->metadata, s->streams[i]->metadata, 0);
 }
 
-- 
2.6.4

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


[FFmpeg-devel] [PATCH 5/7] lavf/flacenc: support writing attached pictures

2017-07-31 Thread Rodger Combs
---
 libavformat/flacenc.c | 285 +++---
 1 file changed, 250 insertions(+), 35 deletions(-)

diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index b894f9e..9768b6a 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -21,10 +21,13 @@
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
 #include "libavcodec/flac.h"
 #include "avformat.h"
 #include "avio_internal.h"
 #include "flacenc.h"
+#include "id3v2.h"
+#include "internal.h"
 #include "vorbiscomment.h"
 #include "libavcodec/bytestream.h"
 
@@ -33,8 +36,16 @@ typedef struct FlacMuxerContext {
 const AVClass *class;
 int write_header;
 
+int audio_stream_idx;
+AVPacket *pics;
+int nb_pics, waiting_pics;
+/* audio packets are queued here until we get all the attached pictures */
+AVPacketList *queue, *queue_end;
+
 /* updated streaminfo sent by the encoder at the end */
 uint8_t *streaminfo;
+
+unsigned attached_types;
 } FlacMuxerContext;
 
 static int flac_write_block_padding(AVIOContext *pb, unsigned int 
n_padding_bytes,
@@ -74,31 +85,156 @@ static int flac_write_block_comment(AVIOContext *pb, 
AVDictionary **m,
 return 0;
 }
 
-static int flac_write_header(struct AVFormatContext *s)
+static int flac_write_picture(struct AVFormatContext *s, AVPacket *pkt)
 {
-int ret;
-int padding = s->metadata_header_padding;
-AVCodecParameters *par = s->streams[0]->codecpar;
-FlacMuxerContext *c   = s->priv_data;
-
-if (!c->write_header)
+FlacMuxerContext *c = s->priv_data;
+AVIOContext *pb = s->pb;
+const AVPixFmtDescriptor *pixdesc;
+const CodecMime *mime = ff_id3v2_mime_tags;
+AVDictionaryEntry *e;
+const char *mimetype = NULL, *desc = "";
+const AVStream *st = s->streams[pkt->stream_index];
+int i, mimelen, desclen, type = 0;
+
+if (!pkt->data)
 return 0;
 
-if (s->nb_streams > 1) {
-av_log(s, AV_LOG_ERROR, "only one stream is supported\n");
+while (mime->id != AV_CODEC_ID_NONE) {
+if (mime->id == st->codecpar->codec_id) {
+mimetype = mime->str;
+break;
+}
+mime++;
+}
+if (!mimetype) {
+av_log(s, AV_LOG_ERROR, "No mimetype is known for stream %d, cannot "
+   "write an attached picture.\n", st->index);
 return AVERROR(EINVAL);
 }
-if (par->codec_id != AV_CODEC_ID_FLAC) {
-av_log(s, AV_LOG_ERROR, "unsupported codec\n");
+mimelen = strlen(mimetype);
+
+/* get the picture type */
+e = av_dict_get(st->metadata, "comment", NULL, 0);
+for (i = 0; e && i < FF_ARRAY_ELEMS(ff_id3v2_picture_types); i++) {
+if (!av_strcasecmp(e->value, ff_id3v2_picture_types[i])) {
+type = i;
+break;
+}
+}
+
+if ((c->attached_types & (1 << type)) & 0x6) {
+av_log(s, AV_LOG_ERROR, "Duplicate attachment for type '%s'\n", 
ff_id3v2_picture_types[type]);
+return AVERROR(EINVAL);
+}
+
+if (type == 1 && (st->codecpar->codec_id != AV_CODEC_ID_PNG ||
+  st->codecpar->width != 32 ||
+  st->codecpar->height != 32)) {
+av_log(s, AV_LOG_ERROR, "File icon attachment must be a 32x32 PNG");
 return AVERROR(EINVAL);
 }
 
+c->attached_types |= (1 << type);
+
+/* get the description */
+if ((e = av_dict_get(st->metadata, "title", NULL, 0)))
+desc = e->value;
+desclen = strlen(desc);
+
+avio_w8(pb, 0x06);
+avio_wb24(pb, 4 + 4 + mimelen + 4 + desclen + 4 + 4 + 4 + 4 + 4 + 
pkt->size);
+
+avio_wb32(pb, type);
+
+avio_wb32(pb, mimelen);
+avio_write(pb, mimetype, mimelen);
+
+avio_wb32(pb, desclen);
+avio_write(pb, desc, desclen);
+
+avio_wb32(pb, st->codecpar->width);
+avio_wb32(pb, st->codecpar->height);
+if ((pixdesc = av_pix_fmt_desc_get(st->codecpar->format)))
+avio_wb32(pb, av_get_bits_per_pixel(pixdesc));
+else
+avio_wb32(pb, 0);
+avio_wb32(pb, 0);
+
+avio_wb32(pb, pkt->size);
+avio_write(pb, pkt->data, pkt->size);
+return 0;
+}
+
+static int flac_finish_header(struct AVFormatContext *s)
+{
+FlacMuxerContext *c = s->priv_data;
+int i, ret, padding = s->metadata_header_padding;
 if (padding < 0)
 padding = 8192;
 /* The FLAC specification states that 24 bits are used to represent the
  * size of a metadata block so we must clip this value to 2^24-1. */
 padding = av_clip_uintp2(padding, 24);
 
+for (i = 0; i < c->nb_pics; i++) {
+ret = flac_write_picture(s, &c->pics[i]);
+if (ret)
+return ret;
+}
+
+ret = flac_write_block_comment(s->pb, &s->metadata, !padding,
+   s->flags & AVFMT_FLAG_BITEXACT);
+if (ret)
+return ret;
+
+/* The command line flac encoder defaults to placing a seekpoint
+ * every 10s.  So one

[FFmpeg-devel] [PATCH 2/7] lavf/segment: add option to segment by chapter

2017-07-31 Thread Rodger Combs
---
 doc/muxers.texi   |  6 +
 libavformat/segment.c | 65 +++
 libavformat/version.h |  2 +-
 3 files changed, 67 insertions(+), 6 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 94472ce..23ef2e7 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1538,6 +1538,12 @@ This option specifies to start a new segment whenever a 
reference
 stream key frame is found and the sequential number (starting from 0)
 of the frame is greater or equal to the next value in the list.
 
+@item segment_chapters @var{1|0}
+Split each chapter into its own segment. Metadata from the chapters
+will be written to the corresponding segments. If this option is selected
+and the filename contains tokens in the format @code{$varname$}, they
+will be replaced by the corresponding metadata values.
+
 @item segment_wrap @var{limit}
 Wrap around segment index once it reaches @var{limit}.
 
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 0e8bcdd..590f62b 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -106,6 +106,8 @@ typedef struct SegmentContext {
 int frame_count;   ///< total number of reference frames
 int segment_frame_count; ///< number of reference frames in the segment
 
+int split_chapters;///< split on chapter markers
+
 int64_t time_delta;
 int  individual_header_trailer; /**< Set by a private option. */
 int  write_header_trailer; /**< Set by a private option. */
@@ -186,6 +188,43 @@ static int segment_mux_init(AVFormatContext *s)
 return 0;
 }
 
+static int replace_variables(AVFormatContext *oc)
+{
+char name[sizeof(oc->filename)];
+char *p = name;
+char *out = oc->filename;
+strncpy(name, oc->filename, sizeof(name));
+while (*p) {
+char c = *p++;
+if (c == '$') {
+if (*p == '$') {
+p++;
+goto append;
+} else {
+int len;
+const char *val;
+const AVDictionaryEntry *e;
+int end = strcspn(p, "$");
+if (p[end] == '\0')
+continue;
+p[end] = '\0';
+e = av_dict_get(oc->metadata, p, NULL, 0);
+val = e ? e->value : "(unknown)";
+len = strlen(val);
+strncpy(out, val, oc->filename + sizeof(oc->filename) - 1 - 
out);
+out = FFMIN(oc->filename + sizeof(oc->filename) - 1, out + 
len);
+p += end + 1;
+}
+} else {
+append:
+if (out - oc->filename < sizeof(oc->filename) - 1)
+*out++ = c;
+}
+}
+*out = '\0';
+return 0;
+}
+
 static int set_segment_filename(AVFormatContext *s)
 {
 SegmentContext *seg = s->priv_data;
@@ -210,6 +249,9 @@ static int set_segment_filename(AVFormatContext *s)
 return AVERROR(EINVAL);
 }
 
+if (seg->split_chapters)
+replace_variables(oc);
+
 /* copy modified name in list entry */
 size = strlen(av_basename(oc->filename)) + 1;
 if (seg->entry_prefix)
@@ -236,6 +278,8 @@ static int segment_start(AVFormatContext *s, int 
write_header)
 if ((err = segment_mux_init(s)) < 0)
 return err;
 oc = seg->avf;
+if (seg->split_chapters && seg->segment_count < s->nb_chapters && (err 
= av_dict_copy(&oc->metadata, s->chapters[seg->segment_count]->metadata, 0)) < 
0)
+return err;
 }
 
 seg->segment_idx++;
@@ -659,10 +703,14 @@ static int seg_init(AVFormatContext *s)
"you can use output_ts_offset instead of it\n");
 }
 
-if (!!seg->time_str + !!seg->times_str + !!seg->frames_str > 1) {
+if (seg->segment_idx < 0)
+seg->segment_idx = seg->split_chapters;
+
+if (!!seg->time_str + !!seg->times_str + !!seg->frames_str + 
!!seg->split_chapters > 1) {
 av_log(s, AV_LOG_ERROR,
-   "segment_time, segment_times, and segment_frames options "
-   "are mutually exclusive, select just one of them\n");
+   "segment_time, segment_times, segment_frames, and "
+   "segment_chapters options are mutually exclusive; "
+   "select just one of them\n");
 return AVERROR(EINVAL);
 }
 
@@ -672,7 +720,7 @@ static int seg_init(AVFormatContext *s)
 } else if (seg->frames_str) {
 if ((ret = parse_frames(s, &seg->frames, &seg->nb_frames, 
seg->frames_str)) < 0)
 return ret;
-} else {
+} else if (!seg->split_chapters) {
 /* set default value if not specified */
 if (!seg->time_str)
 seg->time_str = av_strdup("2");
@@ -739,6 +787,9 @@ static int seg_init(AVFormatContext *s)
 if ((ret = segment_mux_init(s)) < 0)
 return ret;
 
+if (seg->split_chapters && s->nb_chapters && (ret = 
av_dict_copy(&seg->avf->metadata, s->chapters[0]->metadata, 0)) < 0)
+return ret;
+
  

[FFmpeg-devel] [PATCH 1/7] lavf: add cue sheet demuxer

2017-07-31 Thread Rodger Combs
---
 Changelog|   2 +
 doc/demuxers.texi|   8 ++
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/cuedec.c | 215 +++
 libavformat/version.h|   2 +-
 6 files changed, 228 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/cuedec.c

diff --git a/Changelog b/Changelog
index 187ae79..6701d30 100644
--- a/Changelog
+++ b/Changelog
@@ -29,6 +29,8 @@ version :
 - limiter video filter
 - libvmaf video filter
 - Dolby E decoder and SMPTE 337M demuxer
+- Cue sheet demuxer
+
 
 version 3.3:
 - CrystalHD decoder moved to new decode API
diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 29a23d4..7ea4f27 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -244,6 +244,14 @@ file subdir/file-2.wav
 @end example
 @end itemize
 
+@section cue
+
+Cue sheet demuxer.
+
+This demuxer reads a cue sheet (text file) and exports its track listing in
+the form of AVChapters. Packet data is read from the file listed in the sheet.
+To override the path the packet data is read from, use the @code{url} option.
+
 @section flv, live_flv
 
 Adobe Flash Video Format demuxer.
diff --git a/libavformat/Makefile b/libavformat/Makefile
index b0ef82c..4381c42 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -130,6 +130,7 @@ OBJS-$(CONFIG_CDXL_DEMUXER)  += cdxl.o
 OBJS-$(CONFIG_CINE_DEMUXER)  += cinedec.o
 OBJS-$(CONFIG_CONCAT_DEMUXER)+= concatdec.o
 OBJS-$(CONFIG_CRC_MUXER) += crcenc.o
+OBJS-$(CONFIG_CUE_DEMUXER)   += cuedec.o
 OBJS-$(CONFIG_DATA_DEMUXER)  += rawdec.o
 OBJS-$(CONFIG_DATA_MUXER)+= rawenc.o
 OBJS-$(CONFIG_DASH_MUXER)+= dashenc.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 1ebc142..25afa8b 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -96,6 +96,7 @@ static void register_all(void)
 REGISTER_DEMUXER (CINE, cine);
 REGISTER_DEMUXER (CONCAT,   concat);
 REGISTER_MUXER   (CRC,  crc);
+REGISTER_DEMUXER (CUE,  cue);
 REGISTER_MUXER   (DASH, dash);
 REGISTER_MUXDEMUX(DATA, data);
 REGISTER_MUXDEMUX(DAUD, daud);
diff --git a/libavformat/cuedec.c b/libavformat/cuedec.c
new file mode 100644
index 000..d0dcac4
--- /dev/null
+++ b/libavformat/cuedec.c
@@ -0,0 +1,215 @@
+/*
+ * Cue sheet demuxer
+ * Copyright (c) 2016 The FFmpeg Project
+ *
+ * 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
+ */
+
+/**
+ * @file
+ * Cue sheet demuxer
+ * @author Rodger Combs 
+ */
+
+#include "avformat.h"
+#include "internal.h"
+#include "subtitles.h"
+#include "url.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/avstring.h"
+#include "libavutil/opt.h"
+
+typedef struct CueDemuxContext {
+AVClass *class;
+char *url;
+AVFormatContext *avf;
+} CueDemuxContext;
+
+static int cue_probe(AVProbeData *p)
+{
+const unsigned char *ptr = p->buf;
+
+if (AV_RB24(ptr) == 0xEFBBBF)
+ptr += 3;  /* skip UTF-8 BOM */
+while (*ptr && strncmp(ptr, "FILE ", 5))
+ptr += ff_subtitles_next_line(ptr);
+if (!strncmp(ptr, "FILE ", 5))
+return AVPROBE_SCORE_MAX - 5;
+return 0;
+}
+
+static char *get_token(char *in)
+{
+char *end;
+while (av_isspace(*in))
+in++;
+if (*in == '"') {
+in++;
+end = in + strcspn(in, "\"\n\t\r");
+} else {
+end = in + strcspn(in, " \n\t\r");
+}
+*end = '\0';
+return in;
+}
+
+static int cue_read_header(AVFormatContext *s)
+{
+int ret, i;
+CueDemuxContext *cue = s->priv_data;
+char line[4096], *ptr;
+AVDictionary **meta = &s->metadata;
+AVChapter *chap = NULL;
+while (ff_get_line(s->pb, line, sizeof(line))) {
+ptr = line;
+if (AV_RB24(ptr) == 0xEFBBBF)
+ptr += 3;  /* skip UTF-8 BOM */
+while (*ptr == ' ' || *ptr == '\t')
+ptr++;
+if (!strncmp(ptr, "REM ", 4)) {
+char *end = ptr + strcspn(ptr, "\r\n");
+*end = '\0';
+av_log(s, AV_LOG_INFO, "Comment: \"%s\"\n", ptr + 4);
+} else if (!strncmp(ptr, "TIT

Re: [FFmpeg-devel] [PATCH 4/7] lavf/segment: write attached pictures to all segments by default

2017-07-31 Thread Steven Liu
2017-08-01 14:33 GMT+08:00 Rodger Combs :
> ---
>  doc/muxers.texi   |  4 
>  libavformat/segment.c | 24 
>  2 files changed, 28 insertions(+)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 23ef2e7..93147e1 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -1576,6 +1576,10 @@ argument must be a time duration specification, and 
> defaults to 0.
>  If enabled, write an empty segment if there are no packets during the period 
> a
>  segment would usually span. Otherwise, the segment will be filled with the 
> next
>  packet written. Defaults to @code{0}.
> +
> +@item dup_attached_pics @var{1|0}
> +If enabled, attached-picture packets will be written to all segments, rather
> +than only the first. Defaults to @code{1}.
>  @end table
>
>  @subsection Examples
> diff --git a/libavformat/segment.c b/libavformat/segment.c
> index ef0a915..8e82030 100644
> --- a/libavformat/segment.c
> +++ b/libavformat/segment.c
> @@ -119,6 +119,7 @@ typedef struct SegmentContext {
>  int   reference_stream_index;
>  int   break_non_keyframes;
>  int   write_empty;
> +int   dup_attached_pics;
>
>  int use_rename;
>  char temp_list_filename[1024];
> @@ -126,6 +127,8 @@ typedef struct SegmentContext {
>  SegmentListEntry cur_entry;
>  SegmentListEntry *segment_list_entries;
>  SegmentListEntry *segment_list_entries_end;
> +
> +AVPacket *attached_pics;
>  } SegmentContext;
>
>  static void print_csv_escaped_str(AVIOContext *ctx, const char *str)
> @@ -301,6 +304,7 @@ static int segment_start(AVFormatContext *s, int 
> write_header)
>  av_opt_set(oc->priv_data, "mpegts_flags", "+resend_headers", 0);
>
>  if (write_header) {
> +int i;
move to the top of the function,
>  AVDictionary *options = NULL;
>  av_dict_copy(&options, seg->format_options, 0);
>  av_dict_set(&options, "fflags", "-autobsf", 0);
> @@ -308,6 +312,13 @@ static int segment_start(AVFormatContext *s, int 
> write_header)
>  av_dict_free(&options);
>  if (err < 0)
>  return err;
> +for (i = 0; i < s->nb_streams; i++) {
> +if (seg->dup_attached_pics &&
> +s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC &&
> +seg->attached_pics[i].data) {
> +av_write_frame(oc, &seg->attached_pics[i]);
> +}
> +}
>  }
>
>  seg->segment_frame_count = 0;
> @@ -680,6 +691,12 @@ static void seg_free(AVFormatContext *s)
>  ff_format_io_close(seg->avf, &seg->list_pb);
>  avformat_free_context(seg->avf);
>  seg->avf = NULL;
> +if (seg->attached_pics) {
> +int i;
move to the top of the function,
> +for (i = 0; i < s->nb_streams; i++)
> +av_packet_unref(&seg->attached_pics[i]);
> +av_freep(&seg->attached_pics);
> +}
>  }
>
>  static int seg_init(AVFormatContext *s)
> @@ -840,6 +857,9 @@ static int seg_init(AVFormatContext *s)
>  avpriv_set_pts_info(outer_st, inner_st->pts_wrap_bits, 
> inner_st->time_base.num, inner_st->time_base.den);
>  }
>
> +if (seg->dup_attached_pics && !(seg->attached_pics = 
> av_calloc(s->nb_streams, sizeof(AVPacket
> +return AVERROR(ENOMEM);
> +
>  if (oc->avoid_negative_ts > 0 && s->avoid_negative_ts < 0)
>  s->avoid_negative_ts = 1;
>
> @@ -905,6 +925,9 @@ static int seg_write_packet(AVFormatContext *s, AVPacket 
> *pkt)
>  if (!seg->avf || !seg->avf->pb)
>  return AVERROR(EINVAL);
>
> +if (seg->dup_attached_pics && st->disposition & 
> AV_DISPOSITION_ATTACHED_PIC)
> +av_copy_packet(&seg->attached_pics[pkt->stream_index], pkt);
> +
>  calc_times:
>  if (seg->times) {
>  end_pts = seg->segment_count < seg->nb_times ?
> @@ -,6 +1134,7 @@ static const AVOption options[] = {
>  { "reset_timestamps", "reset timestamps at the begin of each segment", 
> OFFSET(reset_timestamps), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, E },
>  { "initial_offset", "set initial timestamp offset", 
> OFFSET(initial_offset), AV_OPT_TYPE_DURATION, {.i64 = 0}, -INT64_MAX, 
> INT64_MAX, E },
>  { "write_empty_segments", "allow writing empty 'filler' segments", 
> OFFSET(write_empty), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, E },
> +{ "dup_attached_pics",  "write attached pictures to all segments", 
> OFFSET(dup_attached_pics), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, E },
>  { NULL },
>  };
>
> --
> 2.6.4
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/7] lavf/segment: copy stream dispositions in output

2017-07-31 Thread Steven Liu
2017-08-01 14:33 GMT+08:00 Rodger Combs :
> ---
>  libavformat/segment.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libavformat/segment.c b/libavformat/segment.c
> index 590f62b..ef0a915 100644
> --- a/libavformat/segment.c
> +++ b/libavformat/segment.c
> @@ -182,6 +182,7 @@ static int segment_mux_init(AVFormatContext *s)
>  }
>  st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
>  st->time_base = s->streams[i]->time_base;
> +st->disposition = s->streams[i]->disposition;
>  av_dict_copy(&st->metadata, s->streams[i]->metadata, 0);
>  }
>
> --
> 2.6.4
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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


Re: [FFmpeg-devel] [PATCH 2/7] lavf/segment: add option to segment by chapter

2017-07-31 Thread Steven Liu
2017-08-01 14:33 GMT+08:00 Rodger Combs :
> ---
>  doc/muxers.texi   |  6 +
>  libavformat/segment.c | 65 
> +++
>  libavformat/version.h |  2 +-
>  3 files changed, 67 insertions(+), 6 deletions(-)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 94472ce..23ef2e7 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -1538,6 +1538,12 @@ This option specifies to start a new segment whenever 
> a reference
>  stream key frame is found and the sequential number (starting from 0)
>  of the frame is greater or equal to the next value in the list.
>
> +@item segment_chapters @var{1|0}
> +Split each chapter into its own segment. Metadata from the chapters
> +will be written to the corresponding segments. If this option is selected
> +and the filename contains tokens in the format @code{$varname$}, they
> +will be replaced by the corresponding metadata values.
> +
>  @item segment_wrap @var{limit}
>  Wrap around segment index once it reaches @var{limit}.
>
> diff --git a/libavformat/segment.c b/libavformat/segment.c
> index 0e8bcdd..590f62b 100644
> --- a/libavformat/segment.c
> +++ b/libavformat/segment.c
> @@ -106,6 +106,8 @@ typedef struct SegmentContext {
>  int frame_count;   ///< total number of reference frames
>  int segment_frame_count; ///< number of reference frames in the segment
>
> +int split_chapters;///< split on chapter markers
> +
>  int64_t time_delta;
>  int  individual_header_trailer; /**< Set by a private option. */
>  int  write_header_trailer; /**< Set by a private option. */
> @@ -186,6 +188,43 @@ static int segment_mux_init(AVFormatContext *s)
>  return 0;
>  }
>
> +static int replace_variables(AVFormatContext *oc)
> +{
> +char name[sizeof(oc->filename)];
> +char *p = name;
> +char *out = oc->filename;
> +strncpy(name, oc->filename, sizeof(name));
> +while (*p) {
> +char c = *p++;
> +if (c == '$') {
> +if (*p == '$') {
> +p++;
> +goto append;
> +} else {
> +int len;
> +const char *val;
> +const AVDictionaryEntry *e;
> +int end = strcspn(p, "$");
> +if (p[end] == '\0')
> +continue;
> +p[end] = '\0';
> +e = av_dict_get(oc->metadata, p, NULL, 0);
> +val = e ? e->value : "(unknown)";
> +len = strlen(val);
> +strncpy(out, val, oc->filename + sizeof(oc->filename) - 1 - 
> out);
why not av_strlcpy?
> +out = FFMIN(oc->filename + sizeof(oc->filename) - 1, out + 
> len);
> +p += end + 1;
> +}
> +} else {
> +append:
> +if (out - oc->filename < sizeof(oc->filename) - 1)
> +*out++ = c;
> +}
> +}
> +*out = '\0';
> +return 0;
> +}
> +
>  static int set_segment_filename(AVFormatContext *s)
>  {
>  SegmentContext *seg = s->priv_data;
> @@ -210,6 +249,9 @@ static int set_segment_filename(AVFormatContext *s)
>  return AVERROR(EINVAL);
>  }
>
> +if (seg->split_chapters)
> +replace_variables(oc);
> +
>  /* copy modified name in list entry */
>  size = strlen(av_basename(oc->filename)) + 1;
>  if (seg->entry_prefix)
> @@ -236,6 +278,8 @@ static int segment_start(AVFormatContext *s, int 
> write_header)
>  if ((err = segment_mux_init(s)) < 0)
>  return err;
>  oc = seg->avf;
> +if (seg->split_chapters && seg->segment_count < s->nb_chapters && 
> (err = av_dict_copy(&oc->metadata, s->chapters[seg->segment_count]->metadata, 
> 0)) < 0)
> +return err;
>  }
>
>  seg->segment_idx++;
> @@ -659,10 +703,14 @@ static int seg_init(AVFormatContext *s)
> "you can use output_ts_offset instead of it\n");
>  }
>
> -if (!!seg->time_str + !!seg->times_str + !!seg->frames_str > 1) {
> +if (seg->segment_idx < 0)
> +seg->segment_idx = seg->split_chapters;
> +
> +if (!!seg->time_str + !!seg->times_str + !!seg->frames_str + 
> !!seg->split_chapters > 1) {
>  av_log(s, AV_LOG_ERROR,
> -   "segment_time, segment_times, and segment_frames options "
> -   "are mutually exclusive, select just one of them\n");
> +   "segment_time, segment_times, segment_frames, and "
> +   "segment_chapters options are mutually exclusive; "
> +   "select just one of them\n");
>  return AVERROR(EINVAL);
>  }
>
> @@ -672,7 +720,7 @@ static int seg_init(AVFormatContext *s)
>  } else if (seg->frames_str) {
>  if ((ret = parse_frames(s, &seg->frames, &seg->nb_frames, 
> seg->frames_str)) < 0)
>  return ret;
> -} else {
> +} else if (!seg->split_chapters) {
>  /* set default value if not specified */
>  if (!seg->time_str)
>   

Re: [FFmpeg-devel] [PATCH 1/7] lavf: add cue sheet demuxer

2017-07-31 Thread Hendrik Leppkes
On Tue, Aug 1, 2017 at 8:33 AM, Rodger Combs  wrote:
> ---
>  Changelog|   2 +
>  doc/demuxers.texi|   8 ++
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/cuedec.c | 215 
> +++
>  libavformat/version.h|   2 +-
>  6 files changed, 228 insertions(+), 1 deletion(-)
>  create mode 100644 libavformat/cuedec.c
>

Cue Sheets not only support a single data file, but can also contain
metadata for multiple files with one track per file already split (or
even a wild mix of multiple files with multiple tracks per file).
If you don't want to support this, you should probably document this
and perhaps also check in the Cue Sheet parsing if multiple FILE
directives are found, and error out.

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