diff mbox

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

Message ID 20161004163348.24786-1-nfxjfg@googlemail.com
State Accepted
Commit 40fbf3204208f89a0626f85ce6dd06ca0741583b
Headers show

Commit Message

wm4 Oct. 4, 2016, 4:33 p.m. UTC
Some API users (in particular ffmpeg.c) check the best effort timestamp
only.
---
Using guess_correct_pts() - not sure what I was thinking.
---
 libavcodec/utils.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Oct. 4, 2016, 6:26 p.m. UTC | #1
On Tue, Oct 04, 2016 at 06:33:48PM +0200, wm4 wrote:
> Some API users (in particular ffmpeg.c) check the best effort timestamp
> only.
> ---
> Using guess_correct_pts() - not sure what I was thinking.
> ---
>  libavcodec/utils.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)

LGTM

thx

[...]
wm4 Oct. 5, 2016, 9:36 a.m. UTC | #2
On Tue, 4 Oct 2016 20:26:49 +0200
Michael Niedermayer <michael@niedermayer.cc> wrote:

> On Tue, Oct 04, 2016 at 06:33:48PM +0200, wm4 wrote:
> > Some API users (in particular ffmpeg.c) check the best effort timestamp
> > only.
> > ---
> > Using guess_correct_pts() - not sure what I was thinking.
> > ---
> >  libavcodec/utils.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)  
> 
> LGTM
> 
> thx
> 
> [...]

Pushed.
diff mbox

Patch

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index ef3da65..9f8f9c7 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2867,7 +2867,14 @@  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,
+                    guess_correct_pts(avctx, frame->pkt_pts, frame->pkt_dts));
+            }
+        }
+        return ret;
     }
 
     // Emulation via old API.