[FFmpeg-devel] [PATCH] lavc: add duration field to AVFrame
Michael Niedermayer
michaelni at gmx.at
Tue Oct 2 00:12:07 CEST 2012
On Thu, Sep 13, 2012 at 11:36:23AM +0200, Stefano Sabatini wrote:
> On date Tuesday 2012-09-11 22:45:33 +0200, Stefano Sabatini encoded:
> > On date Tuesday 2012-09-04 14:13:07 +0200, Stefano Sabatini encoded:
> > > On date Sunday 2012-08-26 05:22:39 +0200, Michael Niedermayer encoded:
> > > > On Thu, Aug 02, 2012 at 05:32:23PM +0200, Stefano Sabatini wrote:
> > > > > On date Thursday 2012-08-02 12:17:48 +0200, Stefano Sabatini encoded:
> > > > > avcodec.h | 12 ++++++++++++
> > > > > utils.c | 5 +++++
> > > > > 2 files changed, 17 insertions(+)
> > > > > 91ac00288f8063d65db98fed503f2c73850956a6 0006-lavc-add-duration-field-to-AVFrame.patch
> > > > > From dffa5ba28c9c9d9510bcfbe8bcb576e895e59c2e Mon Sep 17 00:00:00 2001
> > > > > From: Stefano Sabatini <stefasab at gmail.com>
> > > > > Date: Thu, 2 Aug 2012 13:12:28 +0200
> > > > > Subject: [PATCH] lavc: add duration field to AVFrame
> > > >
> > > > LGTM
> > >
> > > The main problem I see with this patch, is that the
> > > avcodec_decode_video2() can't set this value in a sane value (assuming
> > > pkt_duration if not specified and rescaling), since the pkt/stream
> > > time base is not known at the decoder level.
> > >
> > > With audio this is not a problem, since we can deduce the frame
> > > duration from the number of samples.
> > >
> > > As a consequence, if frame.duration is not set by the video decoder,
> > > the only possible way to set it, it is to do that at the application
> > > level, which I'd like to avoid.
> > >
> > > Other possible solutions:
> >
>
> > > - set the stream/packet timebase in the decoder context
>
> This is already implemented.
>
> Patch updated.
> --
> FFmpeg = Funny and Furious Mind-dumbing Pitiless Elastic Generator
> avcodec.h | 12 ++++++++++++
> utils.c | 8 ++++++++
> 2 files changed, 20 insertions(+)
> 42cb2b67000ca9131d16eaedf038e031fe16ab92 0001-lavc-add-duration-field-to-AVFrame.patch
> From 1d46af61ba85e5c7e1cf77e11975205ab42b5477 Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefasab at gmail.com>
> Date: Thu, 2 Aug 2012 13:12:28 +0200
> Subject: [PATCH] lavc: add duration field to AVFrame
>
> The new field must be set by the decoder, *or* will be set by the
> decoding framework based on the duration value stored in the packet (for
> video) or on the number of audio samples (for audio).
> ---
> libavcodec/avcodec.h | 12 ++++++++++++
> libavcodec/utils.c | 8 ++++++++
> 2 files changed, 20 insertions(+), 0 deletions(-)
>
> 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
[...]
> @@ -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
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway
-------------- 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/20121002/96096213/attachment.asc>
More information about the ffmpeg-devel
mailing list