]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/decode: set best_effort_timestamp on output frames for all decoders
authorJames Almer <jamrial@gmail.com>
Sun, 13 Dec 2020 00:37:53 +0000 (21:37 -0300)
committerJames Almer <jamrial@gmail.com>
Sun, 13 Dec 2020 15:14:57 +0000 (12:14 -0300)
Fixes a decoding regression introduced by e9a2a87773, and as a side effect also
fixes bogus values set to certain audio frames that had some samples discarded,
where the offsets added to pts, pkt_dts and pkt_duration were not reflected in
best_effort_timestamp.

Signed-off-by: James Almer <jamrial@gmail.com>
libavcodec/decode.c
tests/ref/fate/exif-image-embedded
tests/ref/fate/gaplessinfo-itunes1
tests/ref/fate/gaplessinfo-itunes2

index 5a1849f9448f4872390927e896fa4f530797e75a..d804b0bed0c6d21fb0dc2f7173cf2303bfd9efba 100644 (file)
@@ -372,10 +372,6 @@ static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame,
     if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
         if (frame->flags & AV_FRAME_FLAG_DISCARD)
             got_frame = 0;
-        if (got_frame)
-            frame->best_effort_timestamp = guess_correct_pts(avctx,
-                                                             frame->pts,
-                                                             frame->pkt_dts);
     } else if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
         uint8_t *side;
         int side_size;
@@ -384,9 +380,6 @@ static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame,
         uint8_t discard_reason = 0;
 
         if (ret >= 0 && got_frame) {
-            frame->best_effort_timestamp = guess_correct_pts(avctx,
-                                                             frame->pts,
-                                                             frame->pkt_dts);
             if (frame->format == AV_SAMPLE_FMT_NONE)
                 frame->format = avctx->sample_fmt;
             if (!frame->channel_layout)
@@ -579,6 +572,10 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
         avci->draining_done = 1;
 
     if (!ret) {
+        frame->best_effort_timestamp = guess_correct_pts(avctx,
+                                                         frame->pts,
+                                                         frame->pkt_dts);
+
         /* the only case where decode data is not set should be decoders
          * that do not call ff_get_buffer() */
         av_assert0((frame->private_ref && frame->private_ref->size == sizeof(FrameDecodeData)) ||
index 392c145efb9e75d26cec91cd792ea5a339804f1d..d9239b3c83ec25418fb00fb9eb57ece45456276a 100644 (file)
@@ -44,8 +44,8 @@ pkt_pts=353600
 pkt_pts_time=0.025057
 pkt_dts=353600
 pkt_dts_time=0.025057
-best_effort_timestamp=0
-best_effort_timestamp_time=0.000000
+best_effort_timestamp=353600
+best_effort_timestamp_time=0.025057
 pkt_duration=15040
 pkt_duration_time=0.001066
 pkt_pos=16292
index bb5c09ad349b0eb484fac7cae86a9fb1cdb6fba8..c10e4cccfd29a9c7fc8453eee104fef4c1402ecc 100644 (file)
@@ -24,7 +24,7 @@ packet|pts=1291264|dts=1291264|duration=1024|flags=K_
 packet|pts=1292288|dts=1292288|duration=1024|flags=K_
 packet|pts=1293312|dts=1293312|duration=1024|flags=K_
 stream|nb_read_packets=1264
-frame|pkt_pts=2112|pkt_dts=2112|best_effort_timestamp=2048|pkt_duration=960|nb_samples=960
+frame|pkt_pts=2112|pkt_dts=2112|best_effort_timestamp=2112|pkt_duration=960|nb_samples=960
 frame|pkt_pts=3072|pkt_dts=3072|best_effort_timestamp=3072|pkt_duration=1024|nb_samples=1024
 frame|pkt_pts=4096|pkt_dts=4096|best_effort_timestamp=4096|pkt_duration=1024|nb_samples=1024
 frame|pkt_pts=5120|pkt_dts=5120|best_effort_timestamp=5120|pkt_duration=1024|nb_samples=1024
index 0603ba8bf28ed06b8d22245e397d469c52d70f21..752b95319798bdfe378a4563181cd43312f0f4bf 100644 (file)
@@ -24,7 +24,7 @@ packet|pts=102400|dts=102400|duration=1024|flags=K_
 packet|pts=103424|dts=103424|duration=1024|flags=K_
 packet|pts=104448|dts=104448|duration=1024|flags=K_
 stream|nb_read_packets=103
-frame|pkt_pts=2112|pkt_dts=2112|best_effort_timestamp=2048|pkt_duration=960|nb_samples=960
+frame|pkt_pts=2112|pkt_dts=2112|best_effort_timestamp=2112|pkt_duration=960|nb_samples=960
 frame|pkt_pts=3072|pkt_dts=3072|best_effort_timestamp=3072|pkt_duration=1024|nb_samples=1024
 frame|pkt_pts=4096|pkt_dts=4096|best_effort_timestamp=4096|pkt_duration=1024|nb_samples=1024
 frame|pkt_pts=5120|pkt_dts=5120|best_effort_timestamp=5120|pkt_duration=1024|nb_samples=1024