[FFmpeg-devel] [PATCH] lavc: set best effort timestamp if unset when using new decode API

Timo Rothenpieler timo at rothenpieler.org
Tue Oct 4 08:14:46 EEST 2016


On 10/2/2016 6:56 PM, wm4 wrote:
> Some API users (in particular ffmpeg.c) check the best effort timestamp
> only.
> ---
> Still undecided if this is the right approach.
> ---
>  libavcodec/utils.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index ef3da65..1875a69 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -2867,7 +2867,12 @@ int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr
>      if (avctx->codec->receive_frame) {
>          if (avctx->internal->draining && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY))
>              return AVERROR_EOF;
> -        return avctx->codec->receive_frame(avctx, frame);
> +        ret = avctx->codec->receive_frame(avctx, frame);
> +        if (ret >= 0) {
> +            if (av_frame_get_best_effort_timestamp(frame) == AV_NOPTS_VALUE)
> +                av_frame_set_best_effort_timestamp(frame, frame->pkt_pts);
> +        }
> +        return ret;
>      }
>  
>      // Emulation via old API.
> 

+1 from me.
Not a single decoder sets this, and requiring it for the new API seems a
bit strange.


More information about the ffmpeg-devel mailing list