[Ffmpeg-devel] low_delay and has_b_frames

Baptiste Coudurier baptiste.coudurier
Sun Nov 12 17:23:30 CET 2006


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 ?
Also, variable name is confusing and should be changed to has_delay.

>>> 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 ?

In libavformat/utils.c, compute_pkt_fields2, since has_b_frame is always 
true for MPEG1/2, you always have one frame delay, problem is maybe 
there though.

-- 
Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
checking for life_signs in -lkenny... no




More information about the ffmpeg-devel mailing list