@@ -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)) ||
@@ -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
@@ -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
@@ -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
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 | 11 ++++------- tests/ref/fate/exif-image-embedded | 4 ++-- tests/ref/fate/gaplessinfo-itunes1 | 2 +- tests/ref/fate/gaplessinfo-itunes2 | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-)