Re: [FFmpeg-devel] [PATCH] avcodec/mjpegenc: disable unused code with AMV

2017-08-10 Thread Michael Niedermayer
On Thu, Aug 10, 2017 at 01:43:42AM +, Davinder Singh wrote:
> On Thu, Aug 10, 2017 at 6:59 AM Michael Niedermayer 
> wrote:
> 
> > On Wed, Aug 09, 2017 at 07:46:30AM +, Davinder Singh wrote:
> > > hi,
> > >
> > > this disables unused function amv_encode_picture() when AMV encoder is
> > > disabled (and mjpeg enabled).
> > > silences this warning:
> > > CC libavcodec/mjpegenc.o
> > > libavcodec/mjpegenc.c:351:12: warning: unused function
> > 'amv_encode_picture'
> > > [-Wunused-function]
> > > static int amv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
> > >^
> > >
> > > Patch attached.
> > >
> > > Regards.
> > > --
> > > Davinder Singh
> >
> > >  mjpegenc.c |   10 +-
> > >  1 file changed, 5 insertions(+), 5 deletions(-)
> > > 0fe583bfdb304ce3d8881e9836cc1983c65e3a90
> > 0001-avcodec-mjpegenc-disable-unused-code-with-AMV.patch
> > > From cadf679bb0ad6d09d451512238e790645262f2f8 Mon Sep 17 00:00:00 2001
> > > From: Davinder Singh 
> > > Date: Wed, 9 Aug 2017 13:01:07 +0530
> > > Subject: [PATCH] avcodec/mjpegenc: disable unused code with AMV
> > >
> > > disable unused amv_encode_picture() when AMV encoder is not configured.
> > > minor formatting improvement.
> > > ---
> > >  libavcodec/mjpegenc.c | 10 +-
> > >  1 file changed, 5 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
> > > index ee77cde8cb..e6cdaf6376 100644
> > > --- a/libavcodec/mjpegenc.c
> > > +++ b/libavcodec/mjpegenc.c
> > > @@ -39,7 +39,6 @@
> > >  #include "mjpeg.h"
> > >  #include "mjpegenc.h"
> > >
> > > -
> > >  static int alloc_huffman(MpegEncContext *s)
> > >  {
> > >  MJpegContext *m = s->mjpeg_ctx;
> >
> > please move  unrelated cosmetic chages into a seperate patch
> >
> > Patches attached.

applied

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Take away the freedom of one citizen and you will be jailed, take away
the freedom of all citizens and you will be congratulated by your peers
in Parliament.


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


Re: [FFmpeg-devel] [PATCH] encoders.texi: Replace x264 --full-help suggestion with --fullhelp

2017-08-10 Thread Steven Liu
2017-08-11 0:40 GMT+08:00 Leo Izen :
> ---
>  doc/encoders.texi | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index 690cca83dc..f20be54ce8 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -1793,7 +1793,7 @@ the documentation of the undocumented generic options, 
> see
>  @ref{codec-options,,the Codec Options chapter}.
>
>  To get a more accurate and extensive documentation of the libx264
> -options, invoke the command @command{x264 --full-help} or consult
> +options, invoke the command @command{x264 --fullhelp} or consult
>  the libx264 documentation.
>
>  @table @option
> --
> 2.14.0
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Ah, fix typo,  LGTM
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 01/16] doc/filters: document the unstability of the shorthand options notation.

2017-08-10 Thread Michael Niedermayer
On Thu, Aug 10, 2017 at 04:15:55PM +0200, Nicolas George wrote:
> Le tridi 23 thermidor, an CCXXV, Michael Niedermayer a écrit :
> > Please limit the notes in filters.texi and Changelog to the filters and
> > options you intend to change.
> 
> That would defeat the purpose. Doubly so:
> 
> - Being free to change the options as need requires. That means any
>   filter and any option. Not all, not many, but any.
> 
> - Having a rule that is simple to remember instead of a long list.
> 
> Please bring new arguments to the discussion if you want to continue it.

well
First, I dont think a single developer should declare a whole class of
interfaces spaning the areas other developers work on unstable against
one or more objections from them. Or if one has that right then everyone
else should as well.

I maintain several filters and clearly stated that this doc-text does not
apply to them. None of them would benefit from breaking the
order or inserting options in the middle.
In fact with a unstable order there is no benefit from adding options
in the middle, noone could reliably use the new order.

as in if you link to libavfilter 99.123 you can write a:b:c , if you
link to libavfilter 99.124 you can write a:c:b. Update your distro
package and it could change in otherwise unchanged applications.

and none of this in the example above is neccesarily a syntax error
and gives an error message. the different order could just give
different results. thats bad design

I like to re iterate, i do not agree to declaring the option order
of the filters i maintain as unstable.

Even if we could reorder them without disadvantages,
there is no benefit in doing so.

Its trivial to change your docs/changeog patch to avoid my concern, and
its trivial to change MAINTAINERs as well if people value declaring the
interfaces as unstable more than a maintainer who fanatically insist on
maintaining a stable interface in the filters he maintains.

Also there is no long list, just a entry in the changelog and in the
documentation of the specific filter which was changed.
I think we both agree that this is a rare event. And i would argue
it is NOT a event specific to the shorthand interface. Am i not
correct that you would similarly change the named interface if a
cleanup you do benefits from it ?

Thanks
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 1
"Used only once"- "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."


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


Re: [FFmpeg-devel] [PATCH] ffmpeg: fix setting field_order during muxing

2017-08-10 Thread Dave Rice

> On Aug 10, 2017, at 5:18 PM, Jerome Martinez  wrote:
> 
> Le 10/08/2017 à 04:43, James Almer a écrit :
>> AVFrame.top_field_first doxy states
>> 
>> "If the content is interlaced, is top field displayed first."
>> 
>> And AVFieldOrder doxy defines:
>> AV_FIELD_TB,  //< Top coded first, bottom displayed first
>> AV_FIELD_BT,  //< Bottom coded first, top displayed first
>> 
>> Fixes ticket #6577
> 
> IMHO the subject is complex, and everyone should be in sync with the purpose 
> of each mux_par->field_order value and understand impact on other players 
> (sometimes the MOV metadata is the only one available as the codec has no 
> info e.g. uncompressed or jp2k) before changing current behavior in a so 
> general manner.
> What I understood is that it is based on QuickTime specs (the mapping is 1 to 
> 1 from fiel atom) and TN2162 and that they are not easy to understand and 
> maybe misleading : the feedback I got in the last years about the meaning of 
> this atom are not really in sync with specs having stored vs displayed, and 
> such change may have an impact on how other players handle fiel atom or other 
> metadata in the way it is currently implemented by FFmpeg.

I filed ticket #6577 but not feel cautious about this patch and consider that 
my initial report may have been based on some misunderstanding. As Jerome notes 
the MKV field order flag is derived from mov's fiel atom and there are two 
definitions for that:

https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html
 (Table 4-2)

https://developer.apple.com/library/content/technotes/tn2162/_index.html#//apple_ref/doc/uid/DTS40013070-CH1-TNTAG10-THE__FIEL__IMAGEDESCRIPTION_EXTENSION__FIELD_FRAME_INFORMATION
 (Figure 4)

From testing we have found that ffmpeg's behavior here is matching some Apple 
mov muxers in the assignment of a field order value, so the patch may be 
unneeded or the reason may need more testing.

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


Re: [FFmpeg-devel] [PATCH] ffmpeg: fix setting field_order during muxing

2017-08-10 Thread Jerome Martinez

Le 10/08/2017 à 04:43, James Almer a écrit :

AVFrame.top_field_first doxy states

"If the content is interlaced, is top field displayed first."

And AVFieldOrder doxy defines:
 AV_FIELD_TB,  //< Top coded first, bottom displayed first
 AV_FIELD_BT,  //< Bottom coded first, top displayed first

Fixes ticket #6577


IMHO the subject is complex, and everyone should be in sync with the 
purpose of each mux_par->field_order value and understand impact on 
other players (sometimes the MOV metadata is the only one available as 
the codec has no info e.g. uncompressed or jp2k) before changing current 
behavior in a so general manner.
What I understood is that it is based on QuickTime specs (the mapping is 
1 to 1 from fiel atom) and TN2162 and that they are not easy to 
understand and maybe misleading : the feedback I got in the last years 
about the meaning of this atom are not really in sync with specs having 
stored vs displayed, and such change may have an impact on how other 
players handle fiel atom or other metadata in the way it is currently 
implemented by FFmpeg.


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


Re: [FFmpeg-devel] [PATCH] avfilter/vf_overlay: fix alpha blending for planar formats with a transparent background

2017-08-10 Thread Marton Balint



On Mon, 7 Aug 2017, Marton Balint wrote:



On Sat, 5 Aug 2017, Michael Niedermayer wrote:


On Fri, Aug 04, 2017 at 10:23:55AM +0200, Marton Balint wrote:

When the background had an alpha channel, the old code in blend_plane
calculated premultiplied alpha from the destination plane colors instead 

of the

destination alpha.

Also the calculation of the output alpha should only happen after the 

color

planes are already finished.

Fixes output of:
ffplay -f lavfi "testsrc2=alpha=32[a];color=black[b];[b][a]overlay[out0]"


if it is easy, please add a fate test when / after you push this



Ok, will do as a second step. I am going to apply this soon.


Applied.

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


Re: [FFmpeg-devel] [PATCH 1/3] ffplay: add support for rendering yuv images with negative line size

2017-08-10 Thread Marton Balint


On Sun, 6 Aug 2017, Marton Balint wrote:


Signed-off-by: Marton Balint 
---
ffplay.c | 15 ++-
1 file changed, 10 insertions(+), 5 deletions(-)



Pushed the series.

Regards,
Marton
___
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-08-10 Thread Dale Curtis
On Tue, Aug 8, 2017 at 6:48 PM, Michael Niedermayer 
wrote:

>
> the fate test seems to fail:
>
> did i do something silly ?
>

Ah no, I did when I remuxed the test file. Updated expectations and test
clip at http://storage.googleapis.com/dalecurtis/buck480p30_na.mp4

- dale
From 6e77ff3deaa6e0ac04fb4e51dba1d4a0e69e9d5d 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 addition is always worst case
O(lg(n)) instead of the O(n^2) that exists now; this slowdown is
noticeable during seeks.

Signed-off-by: Dale Curtis 
---
 libavformat/isom.h   |   1 +
 libavformat/mov.c|  79 ++--
 tests/fate/seek.mak  |   3 ++
 tests/ref/seek/extra-mp4 | 134 +++
 4 files changed, 189 insertions(+), 28 deletions(-)
 create mode 100644 tests/ref/seek/extra-mp4

diff --git a/libavformat/isom.h b/libavformat/isom.h
index ff009b0896..fdd98c28f5 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -137,6 +137,7 @@ typedef struct MOVStreamContext {
 unsigned int stts_count;
 MOVStts *stts_data;
 unsigned int ctts_count;
+unsigned int ctts_allocated_size;
 MOVStts *ctts_data;
 unsigned int stsc_count;
 MOVStsc *stsc_data;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 63f84be782..85377f39a9 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -74,6 +74,8 @@ typedef struct MOVParseTableEntry {
 
 static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom);
 static int mov_read_mfra(MOVContext *c, AVIOContext *f);
+static int64_t add_ctts_entry(MOVStts** ctts_data, unsigned int* ctts_count, unsigned int* allocated_size,
+  int count, int duration);
 
 static int mov_metadata_track_or_disc_number(MOVContext *c, AVIOContext *pb,
  unsigned len, const char *key)
@@ -2708,7 +2710,7 @@ static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
 AVStream *st;
 MOVStreamContext *sc;
-unsigned int i, entries, ctts_count = 0;
+unsigned int i, j, entries, ctts_count = 0;
 
 if (c->fc->nb_streams < 1)
 return 0;
@@ -2726,7 +2728,7 @@ static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 if (entries >= UINT_MAX / sizeof(*sc->ctts_data))
 return AVERROR_INVALIDDATA;
 av_freep(>ctts_data);
-sc->ctts_data = av_realloc(NULL, entries * sizeof(*sc->ctts_data));
+sc->ctts_data = av_fast_realloc(NULL, >ctts_allocated_size, entries * sizeof(*sc->ctts_data));
 if (!sc->ctts_data)
 return AVERROR(ENOMEM);
 
@@ -2741,9 +2743,9 @@ static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 continue;
 }
 
-sc->ctts_data[ctts_count].count= count;
-sc->ctts_data[ctts_count].duration = duration;
-ctts_count++;
+/* Expand entries such that we have a 1-1 mapping with samples. */
+for (j = 0; j < count; j++)
+add_ctts_entry(>ctts_data, _count, >ctts_allocated_size, 1, duration);
 
 av_log(c->fc, AV_LOG_TRACE, "count=%d, duration=%d\n",
 count, duration);
@@ -3046,7 +3048,6 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
 int64_t index;
 int64_t index_ctts_count;
 int flags;
-unsigned int ctts_allocated_size = 0;
 int64_t start_dts = 0;
 int64_t edit_list_media_time_dts = 0;
 int64_t edit_list_start_encountered = 0;
@@ -3081,6 +3082,7 @@ static void 

Re: [FFmpeg-devel] [PATCH] JPEG2000: SSE optimisation of DWT decoding

2017-08-10 Thread maxime taisant


> From: Clément Bœsch 
> 
> On Tue, Aug 08, 2017 at 09:09:44AM +, maxime taisant wrote:
> > From: Maxime Taisant 
> >
> > Hi,
> >
> > Here is some SSE optimisations for the dwt function used to decode
> JPEG2000.
> > I tested this code by using the time command while reading a
> JPEG2000 encoded video with ffmpeg and, on average, I observed a
> 4.05% general improvement, and a 12.67% improvement on the dwt
> decoding part alone.
> > In the nasm code, you can notice that the SR1DFLOAT macro appear
> twice. One version is called in the nasm code by the HORSD macro
> and the other is called in the C code of the dwt function, I couldn't
> figure out a way to make only one macro.
> > I also couldn't figure out a good way to optimize the VER_SD part, so
> that is why I left it unchanged, with just a SSE-optimized version of
> the SR_1D_FLOAT function.
> >
> > Regards.
> >
> > ---
> >  libavcodec/jpeg2000dwt.c  |  21 +-
> >  libavcodec/jpeg2000dwt.h  |   6 +
> >  libavcodec/x86/jpeg2000dsp.asm| 794
> ++
> >  libavcodec/x86/jpeg2000dsp_init.c |  55 +++
> >  4 files changed, 863 insertions(+), 13 deletions(-)
> >
> > diff --git a/libavcodec/jpeg2000dwt.c b/libavcodec/jpeg2000dwt.c
> index
> > 55dd5e89b5..69c935980d 100644
> > --- a/libavcodec/jpeg2000dwt.c
> > +++ b/libavcodec/jpeg2000dwt.c
> > @@ -558,16 +558,19 @@ int ff_jpeg2000_dwt_init(DWTContext *s,
> int border[2][2],
> >  }
> >  switch (type) {
> >  case FF_DWT97:
> > +dwt_decode = dwt_decode97_float;
> >  s->f_linebuf = av_malloc_array((maxlen + 12), sizeof(*s-
> >f_linebuf));
> >  if (!s->f_linebuf)
> >  return AVERROR(ENOMEM);
> >  break;
> >   case FF_DWT97_INT:
> > +dwt_decode = dwt_decode97_int;
> >  s->i_linebuf = av_malloc_array((maxlen + 12), sizeof(*s-
> >i_linebuf));
> >  if (!s->i_linebuf)
> >  return AVERROR(ENOMEM);
> >  break;
> >  case FF_DWT53:
> > +dwt_decode = dwt_decode53;
> >  s->i_linebuf = av_malloc_array((maxlen +  6), sizeof(*s-
> >i_linebuf));
> >  if (!s->i_linebuf)
> >  return AVERROR(ENOMEM);
> 
> Using globals is not acceptable, you need to fix that.
> 

Yeah, I can't even remember why I did that... I will fix it.
Thank you.

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


Re: [FFmpeg-devel] [PATCH] JPEG2000: SSE optimisation of DWT decoding

2017-08-10 Thread maxime taisant

> From: Ivan Kalvachev 
> 
> On 8/8/17, maxime taisant  wrote:
> > From: Maxime Taisant 
> >
> > Hi,
> >
> > Here is some SSE optimisations for the dwt function used to decode
> JPEG2000.
> > I tested this code by using the time command while reading a
> JPEG2000
> > encoded video with ffmpeg and, on average, I observed a 4.05%
> general
> > improvement, and a 12.67% improvement on the dwt decoding part
> alone.
> > In the nasm code, you can notice that the SR1DFLOAT macro appear
> > twice. One version is called in the nasm code by the HORSD macro
> and
> > the other is called in the C code of the dwt function, I couldn't
> > figure out a way to make only one macro.
> 
> You want to use the same macro at two locations or you want to have
> 1 function and "call" it from 2 places?
> 
> For the former, I'd guess that you might have been getting errors
> about duplicated labels, since you use the local to the file form instead
> local to the macro form. aka: ".loop" vs "%%loop".

Currently I have one function declared with "cglobal" and called in the C code, 
and one macro with exactly the same behavior used in the nasm code.
So I guess I would like to keep only one of the two and call it from both 
places. (Sorry if it's still not clear, English is not my native language).

> > I also couldn't figure out a good way to optimize the VER_SD part, so
> > that is why I left it unchanged, with just a SSE-optimized version of
> > the SR_1D_FLOAT function.
> 
> [...]
> > +.extend:
> > +shl i0d, 2
> > +shl i1d, 2
> > +mov j0q, i0q
> > +mov j1q, i1q
> > +movups m0, [lineq+j0q+4]
> > +shufps m0, m0, 0x1B
> 
> The x86inc provides with readable method for the shuffle constant.
> q where X is index in the source reg.
> Using q3210 would generate constant that leaves all elements at their
> original places.
> The 0x1B is q0123 , that is swap, isn't it?.
> 
> Also, minor cosmetic nitpick.
>  usually the first parameters are placed so their commas are vertically
> aligned.
> This applies only when the parameter is register (so no jmp labels or []
> addresses ).
> 

Ok, I will change all that.

> [...]
> > +;line{2*i,2*(i+1),2*(i+2),2*(i+3)} -=
> > F_LFTG_DELTA*(line{2*i-1,2*(i+1)-1,2*(i+2)-1,2*(i+3)-
> 1}+line{2*i+1,2*(
> > i+1)+1,2*(i+2)+1,2*(i+3)+1})
> > +movups m0, [lineq+2*j0q-28]
> > +movups m4, [lineq+2*j0q-12]
> > +movups m1, m0
> > +shufps m0, m4, 0xDD
> > +shufps m1, m4, 0x88
> 
> The x86inc provides with a way to emulate 3 operand avx.
> This means it hides one of the movaps (use 'a' for reg reg).
> shufps m1, m0, m4, 0x88
> shufps m0, m4, 0xDD

I know, but I figured that I would do a sse version first and add avx support 
afterwards.

> 
> [...]
> > +movups m2, [lineq+2*j0q-24]
> > +movups m5, [lineq+2*j0q-8]
> > +shufps m2, m5, 0xDD
> > +addps m2, m1
> > +mulps m2, m3
> > +subps m0, m2
> > +movups m4, m1
> > +shufps m1, m0, 0x44 ; 0100'0100 q1010
> Is that movlhps m1, m0 ?

No, this command place the first two values of m1 in the last two doublewords 
of m1, and the first two values of m0 in the first two doublewords of m1.
Movhlps would simply replace the first two values of m1 by the ones of m0.

Thank you for all of your comments.

Best regards.



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


Re: [FFmpeg-devel] [PATCH 01/16] doc/filters: document the unstability of the shorthand options notation.

2017-08-10 Thread Marton Balint


On Thu, 10 Aug 2017, Nicolas George wrote:


Le tridi 23 thermidor, an CCXXV, Michael Niedermayer a écrit :

Please limit the notes in filters.texi and Changelog to the filters and
options you intend to change.


That would defeat the purpose. Doubly so:

- Being free to change the options as need requires. That means any
 filter and any option. Not all, not many, but any.

- Having a rule that is simple to remember instead of a long list.

Please bring new arguments to the discussion if you want to continue it.


I suggest you push the patch series without this patch, Michael can fix 
the overlay and blend/tblend parameter order. If later the needed 
additional compatibility code becomes too much of a burden, we can discuss 
this further.


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


[FFmpeg-devel] [PATCH] encoders.texi: Replace x264 --full-help suggestion with --fullhelp

2017-08-10 Thread Leo Izen
---
 doc/encoders.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 690cca83dc..f20be54ce8 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1793,7 +1793,7 @@ the documentation of the undocumented generic options, see
 @ref{codec-options,,the Codec Options chapter}.
 
 To get a more accurate and extensive documentation of the libx264
-options, invoke the command @command{x264 --full-help} or consult
+options, invoke the command @command{x264 --fullhelp} or consult
 the libx264 documentation.
 
 @table @option
-- 
2.14.0

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


Re: [FFmpeg-devel] [PATCH] ffmpeg: fix setting field_order during muxing

2017-08-10 Thread James Almer
On 8/10/2017 5:21 AM, Hendrik Leppkes wrote:
> On Thu, Aug 10, 2017 at 4:43 AM, James Almer  wrote:
>> AVFrame.top_field_first doxy states
>>
>> "If the content is interlaced, is top field displayed first."
>>
>> And AVFieldOrder doxy defines:
>> AV_FIELD_TB,  //< Top coded first, bottom displayed first
>> AV_FIELD_BT,  //< Bottom coded first, top displayed first
>>
>> Fixes ticket #6577
>>
> 
> Isn't top coded first in most codecs? So maybe it should use TT (top
> coded and displayed first), and TB (top coded first, bottom displayed
> first)?

I can make it TT/TB if that's preferred, but it would be as much of a
guess as it currently is.

> I suppose that difference between coding order might be highly codec
> dependent, though.

I don't know. ffmpeg.c right now is using TT/BB for mjpeg only, so it
has at least one codec specific case.

A quick grep shows codecs like h264, vc1 and canopus using TT/BB, and
ffv1 using TT/TB, so someone more familiar with this might want to take
a look at it and add some other cases as required, at least for codecs
supported in containers that care about the contents of
AVFormatContext.field_order (matroska, mov, etc).

> 
> - Hendrik
> ___
> 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 01/16] doc/filters: document the unstability of the shorthand options notation.

2017-08-10 Thread Nicolas George
Le tridi 23 thermidor, an CCXXV, Michael Niedermayer a écrit :
> Please limit the notes in filters.texi and Changelog to the filters and
> options you intend to change.

That would defeat the purpose. Doubly so:

- Being free to change the options as need requires. That means any
  filter and any option. Not all, not many, but any.

- Having a rule that is simple to remember instead of a long list.

Please bring new arguments to the discussion if you want to continue it.

Regards,

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


Re: [FFmpeg-devel] [PATCH 01/16] doc/filters: document the unstability of the shorthand options notation.

2017-08-10 Thread Michael Niedermayer
On Thu, Aug 10, 2017 at 01:46:27PM +0200, Nicolas George wrote:
> It does not mean that we intend to break the order of options
> at a whim, but it gives us more freedom to make necessary
> changes without extra unnecessary burden while giving stability
> to users that require it.
> 
> Signed-off-by: Nicolas George 
> ---
>  Changelog| 3 +++
>  doc/filters.texi | 5 +
>  2 files changed, 8 insertions(+)
> 
> 
> Another argument that I did not think to bring up earlier: with this change,
> it becomse similar to GNU long options or Vim commands: users can shorten
> the commands or options, as long as it is not ambiguous; but new options or
> commands can make it ambiguous, requiring a longer prefix, so long-term
> scripts must be written with the full name. Users are perfectly aware about
> it and do not fuss over it because they understand this small price is
> necessary for evolution.
> 
> 
> diff --git a/Changelog b/Changelog
> index c797d68a36..78286e3606 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -32,6 +32,9 @@ version :
>  - unpremultiply video filter
>  - tlut2 video filter
>  - floodfill video filter
> +- The order of options in filters is no longer considered stable. If
> +  long-term stability is necessary (i.e. for scripts), use named options
> +  (e.g. overlay=50:100 -> overlay=x=50:y=100).
>  
>  version 3.3:
>  - CrystalHD decoder moved to new decode API
> diff --git a/doc/filters.texi b/doc/filters.texi
> index eedc7b5896..470ffa60a1 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -161,6 +161,11 @@ follow the same constraints order of the previous point. 
> The following
>  
>  @end itemize
>  
> +Future evolutions of filters may require inserting new options or changing
> +their order, especially for the non-essential options, and that would break
> +options given without their name. For that reason, uses that require
> +stability should favor the @var{key=value} notation.

Please limit the notes in filters.texi and Changelog to the filters and
options you intend to change.

thanks

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

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


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


[FFmpeg-devel] [PATCH 16/16] doc/filters: document framesync options.

2017-08-10 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 Changelog|  2 ++
 doc/filters.texi | 76 +---
 2 files changed, 47 insertions(+), 31 deletions(-)

diff --git a/Changelog b/Changelog
index 78286e3606..d5ffa0a1f2 100644
--- a/Changelog
+++ b/Changelog
@@ -35,6 +35,8 @@ version :
 - The order of options in filters is no longer considered stable. If
   long-term stability is necessary (i.e. for scripts), use named options
   (e.g. overlay=50:100 -> overlay=x=50:y=100).
+- Some video filters with several inputs now use a common set of options:
+  blend, libvmaf, lut3d, overlay, psnr, ssim.
 
 version 3.3:
 - CrystalHD decoder moved to new decode API
diff --git a/doc/filters.texi b/doc/filters.texi
index 470ffa60a1..5c7d48738f 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -316,6 +316,39 @@ See @code{ffmpeg -filters} to view which filters have 
timeline support.
 
 @c man end FILTERGRAPH DESCRIPTION
 
+@anchor{framesync}
+@chapter Options for filters with several inputs (framesync)
+@c man begin OPTIONS FOR FILTERS WITH SEVERAL INPUTS
+
+Some filters with several inputs support a common set of options.
+These options can only be set by name, not with the short notation.
+
+@table @option
+@item eof_action
+The action to take when EOF is encountered on the secondary input; it accepts
+one of the following values:
+
+@table @option
+@item repeat
+Repeat the last frame (the default).
+@item endall
+End both streams.
+@item pass
+Pass the main input through.
+@end table
+
+@item shortest
+If set to 1, force the output to terminate when the shortest input
+terminates. Default value is 0.
+
+@item repeatlast
+If set to 1, force the filter to draw the last overlay frame over the
+main input until the end of the stream. A value of 0 disables this
+behavior. Default value is 1.
+@end table
+
+@c man end OPTIONS FOR FILTERS WITH SEVERAL INPUTS
+
 @chapter Audio Filters
 @c man begin AUDIO FILTERS
 
@@ -4937,17 +4970,10 @@ Value of pixel component at current location for first 
video frame (top layer).
 @item BOTTOM, B
 Value of pixel component at current location for second video frame (bottom 
layer).
 @end table
-
-@item shortest
-Force termination when the shortest input terminates. Default is
-@code{0}. This option is only defined for the @code{blend} filter.
-
-@item repeatlast
-Continue applying the last bottom frame after the end of the stream. A value of
-@code{0} disable the filter after the last frame of the bottom layer is 
reached.
-Default is @code{1}. This option is only defined for the @code{blend} filter.
 @end table
 
+The @code{blend} filter also supports the @ref{framesync} options.
+
 @subsection Examples
 
 @itemize
@@ -9745,6 +9771,8 @@ Enables computing ms_ssim along with vmaf.
 Set the pool method to be used for computing vmaf.
 @end table
 
+This filter also supports the @ref{framesync} options.
+
 For example:
 @example
 ffmpeg -i main.mpg -i ref.mpg -lavfi libvmaf -f null -
@@ -9826,6 +9854,8 @@ Interpolate values using a tetrahedron.
 @end table
 @end table
 
+This filter also supports the @ref{framesync} options.
+
 @section lumakey
 
 Turn certain luma values into transparency.
@@ -10854,19 +10884,6 @@ on the main video. Default value is "0" for both 
expressions. In case
 the expression is invalid, it is set to a huge value (meaning that the
 overlay will not be displayed within the output visible area).
 
-@item eof_action
-The action to take when EOF is encountered on the secondary input; it accepts
-one of the following values:
-
-@table @option
-@item repeat
-Repeat the last frame (the default).
-@item endall
-End both streams.
-@item pass
-Pass the main input through.
-@end table
-
 @item eval
 Set when the expressions for @option{x}, and @option{y} are evaluated.
 
@@ -10882,10 +10899,6 @@ evaluate expressions for each incoming frame
 
 Default value is @samp{frame}.
 
-@item shortest
-If set to 1, force the output to terminate when the shortest input
-terminates. Default value is 0.
-
 @item format
 Set the format for the output video.
 
@@ -10911,11 +10924,6 @@ automatically pick format
 @end table
 
 Default value is @samp{yuv420}.
-
-@item repeatlast
-If set to 1, force the filter to draw the last overlay frame over the
-main input until the end of the stream. A value of 0 disables this
-behavior. Default value is 1.
 @end table
 
 The @option{x}, and @option{y} expressions can contain the following
@@ -10952,6 +10960,8 @@ The timestamp, expressed in seconds. It's NAN if the 
input timestamp is unknown.
 
 @end table
 
+This filter also supports the @ref{framesync} options.
+
 Note that the @var{n}, @var{pos}, @var{t} variables are available only
 when evaluation is done @emph{per frame}, and will evaluate to NAN
 when @option{eval} is set to @samp{init}.
@@ -11829,6 +11839,8 @@ Requires stats_version >= 2. If this is set and 
stats_version < 2,
 the filter will return an error.
 @end table
 
+This filter 

[FFmpeg-devel] [PATCH 08/16] lavfi/vf_overlay: use framesync2 options.

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


Unchanged.


diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index 80365ce8df..5a76fa2ee9 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(>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, 

[FFmpeg-devel] [PATCH 07/16] lavfi/framesync2: add common options.

2017-08-10 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(-)


Unchanged.


diff --git a/libavfilter/framesync2.c b/libavfilter/framesync2.c
index 0f78a1733b..fae06aa1f5 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 _class;
+}
+
+void ff_framesync2_preinit(FFFrameSync *fs)
+{
+if (fs->class)
+return;
+fs->class  = _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  = _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 9a54b2b701..745e896bc8 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 

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

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


Unchanged.


diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 605df917a3..b988cdcd4f 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -300,7 +300,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 framesync2.o
 OBJS-$(CONFIG_SUBTITLES_FILTER)  += vf_subtitles.o
diff --git a/libavfilter/vf_ssim.c b/libavfilter/vf_ssim.c
index 371f6dba70..5f5bed7a0e 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)
 {
@@ -282,13 +282,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 = >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, , );
+if (ret < 0)
+return ret;
+if (!ref)
+return ff_filter_frame(ctx->outputs[0], main);
+metadata = >metadata;
 
 s->nb_frames++;
 
@@ -320,7 +328,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)
@@ -343,9 +351,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;
 }
 
@@ -425,28 +431,25 @@ static int config_output(AVFilterLink *outlink)
 AVFilterLink *mainlink = ctx->inputs[0];
 int ret;
 
+ret = ff_framesync2_init_dualinput(>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, >dinput)) < 0)
+if ((ret = ff_framesync2_configure(>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(>dinput, inlink, buf);
-}
-
-static int request_frame(AVFilterLink *outlink)
-{
-SSIMContext *s = outlink->src->priv;
-return ff_dualinput_request_frame(>dinput, outlink);
+SSIMContext *s = ctx->priv;
+return ff_framesync2_activate(>fs);
 }
 
 static av_cold void uninit(AVFilterContext *ctx)
@@ -466,7 +469,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(>dinput);
+ff_framesync2_uninit(>fs);
 
 if (s->stats_file && s->stats_file != stdout)
 fclose(s->stats_file);
@@ -478,11 +481,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 }
@@ -493,7 +494,6 @@ static const AVFilterPad ssim_outputs[] = {
 .name  = "default",
 .type   

[FFmpeg-devel] [PATCH 09/16] lavfi/vf_blend: convert to framesync2.

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


Unchanged.


diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 75a73c4cc0..13c0c2dbd2 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
@@ -307,7 +307,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, _buf, _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(>dinput);
+ff_framesync2_uninit(>fs);
 av_frame_free(>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, >dinput)) < 0)
+if ((ret = ff_framesync2_init_dualinput(>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(>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(>dinput, outlink);
-}
-
-static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
-{
-BlendContext *s = inlink->dst->priv;
-return ff_dualinput_filter_frame(>dinput, inlink, buf);
+BlendContext *s = ctx->priv;
+return ff_framesync2_activate(>fs);
 }
 
 static const 

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

2017-08-10 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


Unchanged.


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(>fs, 0, ,   1)) < 0 ||
-(ret = ff_framesync_get_frame(>fs, 1, , 0)) < 0) {
-av_frame_free();
-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(>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(>fs);
-}
-
-int ff_dualinput_filter_frame(FFDualInputContext *s,
-   AVFilterLink *inlink, AVFrame *in)
-{
-return ff_framesync_filter_frame(>fs, inlink, in);
-}
-
-int ff_dualinput_request_frame(FFDualInputContext *s, AVFilterLink *outlink)
-{
-return ff_framesync_request_frame(>fs, outlink);
-}
-
-void ff_dualinput_uninit(FFDualInputContext *s)
-{
-ff_framesync_uninit(>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 

[FFmpeg-devel] [PATCH 12/16] lavfi/vf_paletteuse: convert to framesync2.

2017-08-10 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/Makefile|  2 +-
 libavfilter/vf_paletteuse.c | 60 -
 2 files changed, 39 insertions(+), 23 deletions(-)


Now uses ff_framesync2_dualinput_get_writable().


diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 21a88954bb..f6cc8e9e95 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -249,7 +249,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..3d16c2dd84 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(>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, >dinput)) < 0)
+if ((ret = ff_framesync2_configure(>fs)) < 0)
 return ret;
 return 0;
 }
@@ -951,21 +962,32 @@ 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;
+
+// writable for error diffusal dithering
+ret = ff_framesync2_dualinput_get_writable(fs, , );
+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(>dinput, inlink, in);
+error:
+av_frame_free();
+av_frame_free();
+return ret;
 }
 
 #define DEFINE_SET_FRAME(color_search, name, value)
 \
@@ -1013,9 +1035,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 +1049,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(>dinput, outlink);
+PaletteUseContext *s = ctx->priv;
+return ff_framesync2_activate(>fs);
 }
 
 static av_cold void uninit(AVFilterContext *ctx)
@@ -1041,7 +1060,7 @@ static av_cold 

[FFmpeg-devel] [PATCH 13/16] lavfi/vf_psnr: convert to framesync2.

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


Unchanged.


diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index f6cc8e9e95..605df917a3 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -259,7 +259,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 6ab21d8e22..a8eb315445 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 = >metadata;
+int ret, j, c;
+AVDictionary **metadata;
+
+ret = ff_framesync2_dualinput_get(fs, , );
+if (ret < 0)
+return ret;
+if (!ref)
+return ff_filter_frame(ctx->outputs[0], main);
+metadata = >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(>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, >dinput)) < 0)
+if ((ret = ff_framesync2_configure(>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(>dinput, inlink, inpicref);
-}
-
-static int request_frame(AVFilterLink *outlink)
-{
-PSNRContext *s = outlink->src->priv;
-return ff_dualinput_request_frame(>dinput, outlink);
+PSNRContext *s = ctx->priv;
+return ff_framesync2_activate(>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(>dinput);
+ff_framesync2_uninit(>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_VIDEO,
   

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

2017-08-10 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(+)


Unchanged.


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(>inputs);
 av_freep(>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 11/16] lavfi/vf_lut3d: convert to framesync2.

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


Unchanged.


diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 47e649cdc4..21a88954bb 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -197,7 +197,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(>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, >dinput)) < 0)
+if ((ret = ff_framesync2_configure(>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(>dinput, inlink, inpicref);
-}
-
-static int request_frame(AVFilterLink *outlink)
+static int activate(AVFilterContext *ctx)
 {
-LUT3DContext *s = outlink->src->priv;
-return ff_dualinput_request_frame(>dinput, outlink);
+LUT3DContext *s = ctx->priv;
+return ff_framesync2_activate(>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, , );
+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(>dinput);
+ff_framesync2_uninit(>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(LUT3DContext),
+

[FFmpeg-devel] [PATCH 06/16] lavfi: search options on child objects.

2017-08-10 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(-)


Unchanged.


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 03/16] lavfi/framesync2: add dualinput helper functions.

2017-08-10 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/framesync2.c | 99 ++--
 libavfilter/framesync2.h | 25 
 2 files changed, 103 insertions(+), 21 deletions(-)


Added ff_framesync2_dualinput_get_writable().


diff --git a/libavfilter/framesync2.c b/libavfilter/framesync2.c
index 0e9f6f210c..0f78a1733b 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(>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,59 @@ 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, ,   1)) < 0 ||
+(ret = ff_framesync2_get_frame(fs, 1, , 0)) < 0) {
+av_frame_free();
+return ret;
+}
+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;
+}
+
+int ff_framesync2_dualinput_get_writable(FFFrameSync *fs, AVFrame **f0, 
AVFrame **f1)
+{
+int ret;
+
+ret = ff_framesync2_dualinput_get(fs, f0, f1);
+if (ret < 0)
+return ret;
+ret = ff_inlink_make_frame_writable(fs->parent->inputs[0], f0);
+if (ret < 0) {
+av_frame_free(f0);
+av_frame_free(f1);
+return ret;
+}
+return 0;
+}
diff --git a/libavfilter/framesync2.h b/libavfilter/framesync2.h
index 2b37636ebb..9a54b2b701 100644
--- a/libavfilter/framesync2.h
+++ b/libavfilter/framesync2.h
@@ -245,4 +245,29 @@ 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 

[FFmpeg-devel] [PATCH 10/16] lavfi/vf_libvmaf: convert to framesync2.

2017-08-10 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 04/16] lavfi/vf_overlay: move to framesync2.

2017-08-10 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/Makefile |  2 +-
 libavfilter/vf_overlay.c | 70 ++--
 2 files changed, 39 insertions(+), 33 deletions(-)


Now uses ff_framesync2_dualinput_get_writable().


diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 2079ccb557..75a73c4cc0 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -245,7 +245,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..80365ce8df 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(>dinput);
+ff_framesync2_uninit(>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, >dinput)) < 0)
+if ((ret = ff_framesync2_init_dualinput(>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(>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_writable(fs, , );
+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, >time_base), 
FF_INLINK_IDX(inlink));
-return ff_dualinput_filter_frame(>dinput, inlink, inpicref);
-}
-
-static int request_frame(AVFilterLink *outlink)
-{
-OverlayContext *s = outlink->src->priv;
-return ff_dualinput_request_frame(>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) {
-

[FFmpeg-devel] [PATCH 01/16] doc/filters: document the unstability of the shorthand options notation.

2017-08-10 Thread Nicolas George
It does not mean that we intend to break the order of options
at a whim, but it gives us more freedom to make necessary
changes without extra unnecessary burden while giving stability
to users that require it.

Signed-off-by: Nicolas George 
---
 Changelog| 3 +++
 doc/filters.texi | 5 +
 2 files changed, 8 insertions(+)


Another argument that I did not think to bring up earlier: with this change,
it becomse similar to GNU long options or Vim commands: users can shorten
the commands or options, as long as it is not ambiguous; but new options or
commands can make it ambiguous, requiring a longer prefix, so long-term
scripts must be written with the full name. Users are perfectly aware about
it and do not fuss over it because they understand this small price is
necessary for evolution.


diff --git a/Changelog b/Changelog
index c797d68a36..78286e3606 100644
--- a/Changelog
+++ b/Changelog
@@ -32,6 +32,9 @@ version :
 - unpremultiply video filter
 - tlut2 video filter
 - floodfill video filter
+- The order of options in filters is no longer considered stable. If
+  long-term stability is necessary (i.e. for scripts), use named options
+  (e.g. overlay=50:100 -> overlay=x=50:y=100).
 
 version 3.3:
 - CrystalHD decoder moved to new decode API
diff --git a/doc/filters.texi b/doc/filters.texi
index eedc7b5896..470ffa60a1 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -161,6 +161,11 @@ follow the same constraints order of the previous point. 
The following
 
 @end itemize
 
+Future evolutions of filters may require inserting new options or changing
+their order, especially for the non-essential options, and that would break
+options given without their name. For that reason, uses that require
+stability should favor the @var{key=value} notation.
+
 If the option value itself is a list of items (e.g. the @code{format} filter
 takes a list of pixel formats), the items in the list are usually separated by
 @samp{|}.
-- 
2.13.2

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


[FFmpeg-devel] [PATCH 02/16] lavfi/f_streamselect: convert to framesync2.

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


Unchanged.


diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 06b915fc91..2079ccb557 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
@@ -302,7 +302,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(>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(>fs, i, [i], 0)) < 0)
+if ((ret = ff_framesync2_get_frame(>fs, i, [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(>fs, outlink);
+StreamSelectContext *s = ctx->priv;
+return ff_framesync2_activate(>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(>fs, ctx, ctx->nb_inputs)) < 0)
+if ((ret = ff_framesync2_init(>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(>fs);
+return ff_framesync2_configure(>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, );
 } else {
 pad.config_props  = config_output;
-pad.request_frame = request_frame;
 ret = ff_insert_outpad(ctx, i, );
 }
 
@@ -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_DEBUG, "Configured with %d inpad and %d outpad\n",
@@ -298,7 +289,7 @@ static av_cold void uninit(AVFilterContext *ctx)
 av_freep(>last_pts);
 av_freep(>map);
 av_freep(>frames);
-

Re: [FFmpeg-devel] Mov/mp4 demuxer failing on mp4 file (Sample size is too large)

2017-08-10 Thread Paul B Mahol
On 8/10/17, Robert Krüger  wrote:
> On Thu, Aug 10, 2017 at 10:21 AM, Paul B Mahol  wrote:
>
>> On 8/9/17, Robert Krüger  wrote:
>> > Hi,
>> >
>> > can someone tell me what this hints at? Is this more likely a broken
>> > file
>> > or a missing feature of the demuxer? Unfortunately I cannot make the
>> > file
>> > available due to legal issues but if I know where to look, I could try
>> > to
>> > find a sample with similar characteristics.
>> >
>> > [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb4b7002200] Sample size 2147484020 is too
>> > large
>> >
>> > [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb4b7002200] Invalid
>> sample_count=-2147483519
>> >
>> > [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb4b7002200] error reading header
>>
>> Does it play in QuickTime?
>
>
> Yes it plays in Quicktime X on OSX but not in the old Quicktime 7.

Than it should be reported as ffmpeg bug.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2017-08-10 Thread Clément Bœsch
On Thu, Aug 10, 2017 at 11:33:31AM +0200, Nicolas George wrote:
> Le tridi 23 thermidor, an CCXXV, Clement Boesch a écrit :
> > But unless it's API documented, that's implementation specific. I'd prefer
> > if you keep that as a safe guard. It also has a documentation purpose.
> 
> I will do it if you insist, but before that, let me correct a little
> detail:
> 
> > If the frame is already writable it will be a noop.
> 
> Before it is used for its contents, frames are used for their timestamp.
> The frame could be read-only at the time it is dequeued by
> framesync but have become writable by the time it is ready for
> processing by the filter. And I think it is not that unlikely: a graph
> with split sending to overlay and scale would have that effect.
> 
> Instead of .needs_writable (I am not sure this flag should be relevant
> with the activate callback), I can propose the following solution that
> make the need for a writable explicit:
> 
>   /**
>* Like ff_framesync2_dualinput_get, but make sure f0 is
>* writable.
>*/
>   ff_framesync2_dualinput_get_writable(fs, , );
> 
> or:
> 
>   ff_framesync2_dualinput_get(fs, , ,
>   FRAMESYNC_MAIN_WRITABLE);
> 
> (whichever people prefer), and probably the same options for the
> individual ff_inlink_consume_frame().
> 

I like ff_framesync2_dualinput_get_writable() better, but both are fine
with me.

Note: if you follow that path, please keep the comment about dithering
above the writable call to that framesync function.

Thanks

-- 
Clément B.


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


Re: [FFmpeg-devel] Mov/mp4 demuxer failing on mp4 file (Sample size is too large)

2017-08-10 Thread Robert Krüger
On Thu, Aug 10, 2017 at 10:21 AM, Paul B Mahol  wrote:

> On 8/9/17, Robert Krüger  wrote:
> > Hi,
> >
> > can someone tell me what this hints at? Is this more likely a broken file
> > or a missing feature of the demuxer? Unfortunately I cannot make the file
> > available due to legal issues but if I know where to look, I could try to
> > find a sample with similar characteristics.
> >
> > [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb4b7002200] Sample size 2147484020 is too
> > large
> >
> > [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb4b7002200] Invalid
> sample_count=-2147483519
> >
> > [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb4b7002200] error reading header
>
> Does it play in QuickTime?


Yes it plays in Quicktime X on OSX but not in the old Quicktime 7.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2017-08-10 Thread Nicolas George
Le tridi 23 thermidor, an CCXXV, Clement Boesch a écrit :
> But unless it's API documented, that's implementation specific. I'd prefer
> if you keep that as a safe guard. It also has a documentation purpose.

I will do it if you insist, but before that, let me correct a little
detail:

> If the frame is already writable it will be a noop.

Before it is used for its contents, frames are used for their timestamp.
The frame could be read-only at the time it is dequeued by
framesync but have become writable by the time it is ready for
processing by the filter. And I think it is not that unlikely: a graph
with split sending to overlay and scale would have that effect.

Instead of .needs_writable (I am not sure this flag should be relevant
with the activate callback), I can propose the following solution that
make the need for a writable explicit:

/**
 * Like ff_framesync2_dualinput_get, but make sure f0 is
 * writable.
 */
ff_framesync2_dualinput_get_writable(fs, , );

or:

ff_framesync2_dualinput_get(fs, , ,
FRAMESYNC_MAIN_WRITABLE);

(whichever people prefer), and probably the same options for the
individual ff_inlink_consume_frame().

Regards,

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


Re: [FFmpeg-devel] Mov/mp4 demuxer failing on mp4 file (Sample size is too large)

2017-08-10 Thread Paul B Mahol
On 8/9/17, Robert Krüger  wrote:
> Hi,
>
> can someone tell me what this hints at? Is this more likely a broken file
> or a missing feature of the demuxer? Unfortunately I cannot make the file
> available due to legal issues but if I know where to look, I could try to
> find a sample with similar characteristics.
>
> [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb4b7002200] Sample size 2147484020 is too
> large
>
> [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb4b7002200] Invalid sample_count=-2147483519
>
> [mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb4b7002200] error reading header

Does it play in QuickTime?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg: fix setting field_order during muxing

2017-08-10 Thread Hendrik Leppkes
On Thu, Aug 10, 2017 at 4:43 AM, James Almer  wrote:
> AVFrame.top_field_first doxy states
>
> "If the content is interlaced, is top field displayed first."
>
> And AVFieldOrder doxy defines:
> AV_FIELD_TB,  //< Top coded first, bottom displayed first
> AV_FIELD_BT,  //< Bottom coded first, top displayed first
>
> Fixes ticket #6577
>

Isn't top coded first in most codecs? So maybe it should use TT (top
coded and displayed first), and TB (top coded first, bottom displayed
first)?
I suppose that difference between coding order might be highly codec
dependent, though.

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


Re: [FFmpeg-devel] [WIP] libcodec2 wrapper + de/muxer in FFmpeg

2017-08-10 Thread Paul B Mahol
On 8/9/17, Michael Niedermayer  wrote:
> On Tue, Aug 08, 2017 at 11:49:45PM +0200, Tomas Härdin wrote:
>  [...]
>
>>  ffmpeg.c |3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>> 5bd20883fdc12aefa609fc803fe5709069b3e9a0
>> 0003-Don-t-complain-about-codec2-s-700-bit-s-modes-in-ffm.patch
>> From b693b6175289e6ad0c643462d8f69f6830086099 Mon Sep 17 00:00:00 2001
>> From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= 
>> Date: Thu, 3 Aug 2017 17:33:04 +0200
>> Subject: [PATCH 3/3] Don't complain about codec2's 700 bit/s modes in
>> ffmpeg.c
>>
>> ---
>>  ffmpeg.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/ffmpeg.c b/ffmpeg.c
>> index 888d19a647..09a5b541c0 100644
>> --- a/ffmpeg.c
>> +++ b/ffmpeg.c
>> @@ -3480,7 +3480,8 @@ static int init_output_stream(OutputStream *ost,
>> char *error, int error_len)
>>  av_buffersink_set_frame_size(ost->filter->filter,
>>  ost->enc_ctx->frame_size);
>>  assert_avoptions(ost->encoder_opts);
>> -if (ost->enc_ctx->bit_rate && ost->enc_ctx->bit_rate < 1000)
>> +if (ost->enc_ctx->bit_rate && ost->enc_ctx->bit_rate < 1000 &&
>> +ost->enc_ctx->codec_id != AV_CODEC_ID_CODEC2 /* don't
>> complain about 700 bit/s modes */)
>>  av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set
>> too low."
>>   " It takes bits/s as argument,
>> not kbits/s\n");
>>
>
> LGTM
>
> alternatively you could add a minimum bitrate parameter to AVCodec
> or AVCodecDescriptor

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


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

2017-08-10 Thread Clément Bœsch
On Mon, Jul 31, 2017 at 02:02:23PM +0200, Nicolas George wrote:
[...]
>  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);
>  

So where do these options end up? I'm guessing at the end of the list; if
so, please update the documentation: typically, move/remove/factor/rework
the shortest/repeatlast part of the options table in the haldclut section
(currently there is the option table followed by a sentence about sharing
the options with lut3d).

Please also document the affected filters in the Changelog. I doubt
someone is relying on short-hands for this specific filter and these
options given the current unexpected order, but that might not be true for
all other filters.

Thanks

-- 
Clément B.


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


Re: [FFmpeg-devel] lavc/vaapi_encode_h264: respect "slices" option in h264 vaapi encoder

2017-08-10 Thread Jun Zhao


On 2017/8/10 6:05, Mark Thompson wrote:
> On 02/08/17 06:56, Jun Zhao wrote:
>> From f9b42385faedd64dacf613785c393c7b025237c9 Mon Sep 17 00:00:00 2001
>> From: Jun Zhao 
>> Date: Tue, 1 Aug 2017 23:05:44 -0400
>> Subject: [PATCH V2 3/4] lavc/vaapi_encode_h264: respect "slices" option in
>>  h264 vaapi encoder
>>
>> Enable multi-slice support in AVC/H.264 vaapi encoder.
>>
>> Signed-off-by: Wang, Yi A 
>> Signed-off-by: Jun Zhao 
>> ---
>>  libavcodec/vaapi_encode_h264.c | 38 +-
>>  1 file changed, 33 insertions(+), 5 deletions(-)
>>
>> diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
>> index f9fcd805a4..5dad6d10a5 100644
>> --- a/libavcodec/vaapi_encode_h264.c
>> +++ b/libavcodec/vaapi_encode_h264.c
>> @@ -141,6 +141,10 @@ typedef struct VAAPIEncodeH264Context {
>>  int mb_width;
>>  int mb_height;
>>  
>> +int slice_of_mbs;
>> +int slice_mod_mbs;
>> +int last_mb_index;
>> +
>>  int fixed_qp_idr;
>>  int fixed_qp_p;
>>  int fixed_qp_b;
>> @@ -957,6 +961,7 @@ static int 
>> vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
>>  VAEncPictureParameterBufferH264  *vpic = pic->codec_picture_params;
>>  VAAPIEncodeH264Context   *priv = ctx->priv_data;
>>  int i;
>> +int max_slices;
>>  
>>  if (pic->type == PICTURE_TYPE_IDR) {
>>  av_assert0(pic->display_order == pic->encode_order);
>> @@ -1002,7 +1007,22 @@ static int 
>> vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
>>  vpic->pic_fields.bits.idr_pic_flag = (pic->type == PICTURE_TYPE_IDR);
>>  vpic->pic_fields.bits.reference_pic_flag = (pic->type != 
>> PICTURE_TYPE_B);
>>  
>> -pic->nb_slices = 1;
>> +max_slices = 1;
>> +if (ctx->max_slices) {
>> +max_slices = FFMIN(priv->mb_height, ctx->max_slices);
> 
> Where is this coming from?  You don't enforce anything about rows below.

I use mb_height as the upper limit about MAX(slices) , but maybe I am wrong,
in va.h, I find the flag VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS with 
comment
"Driver supports an arbitrary number of rows(I guess rows is wrong 
comment in this, I think the right word is microblocks) per slice".

So I will drop this check in V3 patch. Tks.

> 
>> +if (avctx->slices > max_slices) {
>> +av_log(avctx, AV_LOG_WARNING, "The max slices number per frame "
>> +   "cannot more than %d.\n", max_slices);
> 
> So if you pass a value which is too high, you get some lower number instead?  
> It should probably hard fail here - I'm not sure what your use case is for 
> this option, but I imagine it being for conforming to the some specific 
> stream requirements (like bluray or whatever), so just ignoring the option in 
> that case is probably bad.

Agree.

> 
>> +} else {
>> +max_slices = avctx->slices;
>> +}
>> +}
>> +
>> +pic->nb_slices = max_slices;
>> +
>> +priv->slice_of_mbs  = (priv->mb_width * priv->mb_height) / 
>> pic->nb_slices;
>> +priv->slice_mod_mbs = (priv->mb_width * priv->mb_height) % 
>> pic->nb_slices;
>> +priv->last_mb_index = 0;
>>  
>>  return 0;
>>  }
>> @@ -1052,14 +1072,18 @@ static int 
>> vaapi_encode_h264_init_slice_params(AVCodecContext *avctx,
>>  av_assert0(0 && "invalid picture type");
>>  }
>>  
>> -// Only one slice per frame.
>> -vslice->macroblock_address = 0;
>> -vslice->num_macroblocks = priv->mb_width * priv->mb_height;
>> +vslice->macroblock_address = priv->last_mb_index;
>> +vslice->num_macroblocks = priv->slice_of_mbs + (priv->slice_mod_mbs > 0 
>> ? 1 : 0);
>> +if (priv->slice_mod_mbs > 0)
>> +priv->slice_mod_mbs--;
>> +priv->last_mb_index += vslice->num_macroblocks;
> 
> I'm still unconfortable about this method of distributing the macroblocks 
> equally to slices with rounding error at the top - slice boundaries are not 
> invisible at low bitrates.  I don't have anything better to suggest, though.

I don't have any idea to distribute MBs to slice, maybe we can follow x264 
style to forces rectangular slices ? I don't know.

> 
>>  
>>  vslice->macroblock_info = VA_INVALID_ID;
>>  
>>  vslice->pic_parameter_set_id = vpic->pic_parameter_set_id;
>> -vslice->idr_pic_id = priv->idr_pic_count++;
>> +vslice->idr_pic_id = priv->idr_pic_count;
>> +if (priv->last_mb_index == priv->mb_width * priv->mb_height)
>> +priv->idr_pic_count++;
>>  
>>  vslice->pic_order_cnt_lsb = (pic->display_order - priv->last_idr_frame) 
>> &
>>  ((1 << (4 + 
>> vseq->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4)) - 1);
>> @@ -1157,6 +1181,10 @@ static av_cold int 
>> vaapi_encode_h264_configure(AVCodecContext *avctx)
>>  #endif
>>  }
>>  
>> +if (!ctx->max_slices && avctx->slices > 0)
>> +av_log(avctx, AV_LOG_WARNING, "The encode slice option is not 

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

2017-08-10 Thread Clément Bœsch
On Thu, Aug 10, 2017 at 09:13:13AM +0200, Nicolas George wrote:
> Le tridi 23 thermidor, an CCXXV, Clement Boesch a écrit :
> > > -.needs_writable = 1, // for error diffusal dithering
> > why?
> 
> It was not needed in the first place: IIRC, dualinput always returns a
> writable main frame. And the new implementation does, I am sure of it.
> 

But unless it's API documented, that's implementation specific. I'd prefer
if you keep that as a safe guard. It also has a documentation purpose. If
the frame is already writable it will be a noop.

-- 
Clément B.


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


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

2017-08-10 Thread Nicolas George
Le tridi 23 thermidor, an CCXXV, Clement Boesch a écrit :
> > -.needs_writable = 1, // for error diffusal dithering
> why?

It was not needed in the first place: IIRC, dualinput always returns a
writable main frame. And the new implementation does, I am sure of it.

Regards,

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