diff mbox

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

Message ID 20161002165648.24615-1-nfxjfg@googlemail.com
State Superseded
Headers show

Commit Message

wm4 Oct. 2, 2016, 4:56 p.m. UTC
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(-)

Comments

Timo Rothenpieler Oct. 4, 2016, 5:14 a.m. UTC | #1
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.
Michael Niedermayer Oct. 4, 2016, 4:21 p.m. UTC | #2
On Sun, Oct 02, 2016 at 06:56:48PM +0200, 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);

i think the pkt_dts should be considered as well if available
as in/with guess_correct_pts()

[...]
diff mbox

Patch

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.