[Ffmpeg-devel] low_delay and has_b_frames

Michael Niedermayer michaelni
Sun Nov 12 18:19:26 CET 2006


Hi

On Sun, Nov 12, 2006 at 05:23:30PM +0100, Baptiste Coudurier wrote:
> Hi
> 
> Michael Niedermayer a ?crit :
> >Hi
> >
> >On Sat, Nov 11, 2006 at 03:45:06PM +0100, Baptiste Coudurier wrote:
> >>Baptiste Coudurier a ?crit :
> >>>Hi
> >>>
> >>>I noticed that even when using -intra, encoder avctx has has_b_frames
> >>>set to 1.
> >>>
> >>>I checked mpegvideo.c and indeed:
> >>>
> >>>@@ -1169,12 +1169,12 @@
> >>>    switch(avctx->codec->id) {
> >>>    case CODEC_ID_MPEG1VIDEO:
> >>>        s->out_format = FMT_MPEG1;
> >>>-        s->low_delay= 0; //s->max_b_frames ? 0 : 1;
> >>>+        s->low_delay= s->max_b_frames ? 0 : 1;
> >>>        avctx->delay= s->low_delay ? 0 : (s->max_b_frames + 1);
> >>>        break;
> >>>    case CODEC_ID_MPEG2VIDEO:
> >>>        s->out_format = FMT_MPEG1;
> >>>-        s->low_delay= 0; //s->max_b_frames ? 0 : 1;
> >>>+        s->low_delay= s->max_b_frames ? 0 : 1;
> >>>        avctx->delay= s->low_delay ? 0 : (s->max_b_frames + 1);
> >>>        s->rtp_mode= 1;
> >>>        break;
> >>>
> >>>later:
> >>>   avctx->has_b_frames= !s->low_delay;
> >>>
> >>>What is the reason behind not using max_b_frames ?
> >
> >avcodec.h:
> >    /**
> >     * if 1 the stream has a 1 frame delay during decoding.
> >     * - encoding: set by lavc
> >     * - decoding: set by lavc
> >     */
> >    int has_b_frames;
> >
> 
> Ok. According to the code you are assuming that stream has always 1 
> frame delay during decoding. Is that true for I only and IP streams ?

the delay is stored i the header in mpeg1/2/4


> Also, variable name is confusing and should be changed to has_delay.

which would break compatibility


> 
> >>>Should I modify has_b_frames set by taking max_b_frames into account ?
> >>>
> >>Ping, any idea ?
> >
> >... about changing low delay
> >iam against changing the default unless you ensure that this is ok with
> >things like VCD/SVCD/DVD and so on
> >
> >adding optional low delay support via CODEC_FLAG_LOW_DELAY is fine though
> >
> 
> Humm basically I would like I only and IP streams not having 1 frame 
> delay, dts == pts for every frame. How can I achieve that ?

set has_b_frames= 0 ; low_delay= 1 before writing the header (that could
be done via CODEC_FLAG_LOW_DELAY

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

In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is




More information about the ffmpeg-devel mailing list