[FFmpeg-devel] [PATCH] lavc: add missing flags in codec context flags

Michael Niedermayer michaelni at gmx.at
Tue Sep 17 13:45:32 CEST 2013


On Tue, Sep 17, 2013 at 12:43:45PM +0200, Stefano Sabatini wrote:
> On date Tuesday 2013-09-17 00:40:29 +0200, Michael Niedermayer encoded:
> > On Mon, Sep 16, 2013 at 11:58:20PM +0200, Stefano Sabatini wrote:
> > > On date Monday 2013-09-16 23:56:13 +0200, Stefano Sabatini encoded:
> > > > In particular: allow to show the options when dumping help.
> > > > ---
> > > >  libavcodec/options_table.h | 8 ++++----
> > > >  1 file changed, 4 insertions(+), 4 deletions(-)
> > > > 
> > > > diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
> > > > index e9cdfc4..4cebd57 100644
> > > > --- a/libavcodec/options_table.h
> > > > +++ b/libavcodec/options_table.h
> > > > @@ -52,14 +52,14 @@ static const AVOption avcodec_options[] = {
> > > >  {"mv4", "use four motion vectors per macroblock (MPEG-4)", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_4MV }, INT_MIN, INT_MAX, V|E, "flags"},
> > > >  {"qpel", "use 1/4-pel motion compensation", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_QPEL }, INT_MIN, INT_MAX, V|E, "flags"},
> > > >  {"loop", "use loop filter", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_LOOP_FILTER }, INT_MIN, INT_MAX, V|E, "flags"},
> > 
> > > > -{"qscale", "use fixed qscale", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_QSCALE }, INT_MIN, INT_MAX, 0, "flags"},
> > > > +{"qscale", "use fixed qscale", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_QSCALE }, INT_MIN, INT_MAX, V|E, "flags"},
> > 
> > this is set when the user specifies a qscale to the user application
> > if the user does not specify a qscale and this flag is set behavior
> > is undefined
> > 
> > 
> > > >  {"gmc", "use gmc", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_GMC }, INT_MIN, INT_MAX, V|E, "flags"},
> > > >  {"mv0", "always try a mb with mv=<0,0>", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_MV0 }, INT_MIN, INT_MAX, V|E, "flags"},
> > > >  {"input_preserved", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_INPUT_PRESERVED }, INT_MIN, INT_MAX, 0, "flags"},
> > 
> > > > -{"pass1", "use internal 2-pass ratecontrol in first  pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_PASS1 }, INT_MIN, INT_MAX, 0, "flags"},
> > > > -{"pass2", "use internal 2-pass ratecontrol in second pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_PASS2 }, INT_MIN, INT_MAX, 0, "flags"},
> > > > +{"pass1", "use internal 2-pass ratecontrol in first  pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_PASS1 }, INT_MIN, INT_MAX, V|E, "flags"},
> > > > +{"pass2", "use internal 2-pass ratecontrol in second pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_PASS2 }, INT_MIN, INT_MAX, V|E, "flags"},
> > 
> > pass1 / pass2 are set by the user application when 2pass mode is used.
> > the user application in this case also has to make sure that the
> > 2pass statistics are brought from the first to the 2nd run.
> > Thus this flags cannot be set by the user without the user application
> > having specific code to handle 2pass mode
> 
> Not sure if you're suggesting to keep the constants flags non marked
> (so they are not shown in the output), or you suggest to extend the
> manual documentation for them after they are marked (I'm for this
> second option).

I was trying to say that they are flags only intended to be used
by user applications and not end users directly.
All the markings of 0 are intended.

It may be possible to change some of these to allow users to enable
specific things like edge emulation mode or the 1/2 pass. But
this may need changes in user applications because these are not
conventional user parameters like the bitrate is.
if 2 pass mode is enabled the user application has to read and
write statistics and set various fields in the context.
Will user applications do that if CODEC_FLAG_PASS* is set ?
Some surely will not because they dont support 2 pass mode. Some will
have their own -pass flags and will not recognize it as 2pass mode
if CODEC_FLAG_PASS* is set throgh AVOptions behind their back.
and users seeing the pass flags in their help output will then have
2 documented ways to enable 2pass mode only one of which working.

And of course for some user applications setting CODEC_FLAG_PASS*
might just work fine.

the preserve input flag OTOH will likely crash with most applications
if set, because applications dont magically preserve their input if
a new and unknown to them flag is set in AVCodecContext


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

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130917/28adf9f0/attachment.asc>


More information about the ffmpeg-devel mailing list