[FFmpeg-devel] [PATCH] lavc: add duration field to AVFrame

Stefano Sabatini stefasab at gmail.com
Tue Oct 2 00:43:41 CEST 2012


On date Tuesday 2012-10-02 00:12:07 +0200, Michael Niedermayer encoded:
> On Thu, Sep 13, 2012 at 11:36:23AM +0200, Stefano Sabatini wrote:
[...]
> > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > index ddf785e..7da05b8 100644
> > --- a/libavcodec/avcodec.h
> > +++ b/libavcodec/avcodec.h
> > @@ -1404,6 +1404,16 @@ typedef struct AVFrame {
> >       * - decoding: Read by user.
> >       */
> >      int64_t channels;
> > +
> > +    /**
> > +     * duration of the frame, expressed in
> > +     * AVCodecContext->time_base units, AV_NOPTS_VALUE if unknown.
> > +     * Code outside libavcodec should access this field using:
> > +     * av_frame_get_duration(frame)
> > +     * - encoding: unused
> > +     * - decoding: Read by user.
> > +     */
> > +    int64_t duration;
> >  } AVFrame;
> 
> the relation to repeat_pict should be clarified ideally

And really I'm not the best person for doing that (repeat_pict seems
only used by MPEG code).

> [...]
> > @@ -1527,6 +1530,9 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi
> >                  picture->height = avctx->height;
> >              if (picture->format == PIX_FMT_NONE)
> >                  picture->format = avctx->pix_fmt;
> > +            if (picture->duration == AV_NOPTS_VALUE && avpkt->duration)
> > +                picture->duration = av_rescale_q(avpkt->duration, avctx->pkt_timebase,
> > +                                                 avctx->time_base);
> >          }
> >  
> >          emms_c(); //needed to avoid an emms_c() call before every return;
> 
> this looks wrong in case of B frames / frame reordering

I believed that pkt_duration was related to the encoded packet even in
that case. So how should be fixed? Hints?
-- 
FFmpeg = Frenzy & Fabulous Marvellous Programmable Extended Goblin


More information about the ffmpeg-devel mailing list