[FFmpeg-devel] [RFC] scenechange_score in AVCodecContext?

Stefano Sabatini stefano.sabatini-lala
Thu Nov 15 15:07:47 CET 2007


On date Thursday 2007-11-15 03:11:54 +0100, Michael Niedermayer encoded:
> Hi
> 
> On Wed, Nov 14, 2007 at 03:00:55PM +0100, Stefano Sabatini wrote:
[...]
> > But this is also going astray from the original issue of the thread,
> > so please could you comment about the attached patch?
> 
> 
> [...]
> > Index: libavcodec/avcodec.h
> > ===================================================================
> > --- libavcodec/avcodec.h	(revision 11020)
> > +++ libavcodec/avcodec.h	(working copy)
> > @@ -33,8 +33,8 @@
> >  #define AV_STRINGIFY(s)         AV_TOSTRING(s)
> >  #define AV_TOSTRING(s) #s
> >  
> > -#define LIBAVCODEC_VERSION_INT  ((51<<16)+(48<<8)+0)
> > -#define LIBAVCODEC_VERSION      51.48.0
> > +#define LIBAVCODEC_VERSION_INT  ((51<<16)+(49<<8)+0)
> > +#define LIBAVCODEC_VERSION      51.49.0
> >  #define LIBAVCODEC_BUILD        LIBAVCODEC_VERSION_INT
> >  
> >  #define LIBAVCODEC_IDENT        "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
> > @@ -1671,6 +1671,15 @@
> >      unsigned int stream_codec_tag;
> >  
> >      /**
> > +     * scene change score.
> > +     * Measures the degree of change between the current and the
> > +     * previous encoded frame.
> > +     * - encoding: Set by libavcodec.
> > +     * - decoding: unused
> > +     */
> > +    int scenechange_score;
> > +
> > +    /**
> >       * scene change detection threshold
> >       * 0 is default, larger means fewer detected scene changes.
> >       * - encoding: Set by user.
> 
> you cannot add anything in the middle it breaks the ABI
> also id like to see some examples where this is usefull/needed
> iam not in favor of exporting stuff just because it can be exportet
> there should be some sense in it

Consider this scenario: real-time streaming of impredictable
application dependant video content. It would be useful to change the
encoding parameters (rate control, frame rate, etc.) in function of
the *features* of the video streamed (I'm not sure if is possible to
change the parameteres of the avcodec context on the fly at all).

The scenechange_score field provides a very nice way (and cheap, since
it's already computed by the encoder) to dynamically measure the type
of video streamed (e.g. static images versus a rapidly changing
video), so if exported a callback function (for example defined in
get_buffer) monitoring this field could change accordingly the
encoding parameters.

For example a slowly changing video containing text streamed in a
noisy environment may benefit of a shorter gop size, since in this
case an I-frame corruption is propagated to all the following P-frames
of the gop, while this problem doesn't exist for a rapidly changing
video.

The alternative is to implement the scenechange detection computation
in the application, or maybe in a libavfilter, but in this case we
should pay for it (both in term of programming and computation
resources) while libavcodec already provides this feature for free
(well, with a very little overhead).

Best regards.
-- 
Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: define-scenechange-score-in-avctx-03.patch
Type: text/x-diff
Size: 2114 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20071115/cf7318cc/attachment.patch>



More information about the ffmpeg-devel mailing list