aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/utils.c
diff options
context:
space:
mode:
authorNicolas George <nicolas.george@normalesup.org>2012-07-15 16:24:59 +0200
committerNicolas George <nicolas.george@normalesup.org>2012-07-19 23:41:03 +0200
commitcd089003936030c506fb7a28e9a26e028b1aece0 (patch)
tree0bd1d5f48a31597cd675abcc90d215c48ecd2038 /libavcodec/utils.c
parentd853ed46b1732c80016e0dbae83810104a84ed32 (diff)
downloadffmpeg-cd089003936030c506fb7a28e9a26e028b1aece0.tar.gz
lavc: update pkt_duration for skipped samples.
Also: factor the the computation of the timestamp difference.
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index dd9c0d1675..63aa862716 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1664,10 +1664,15 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
av_samples_copy(frame->extended_data, frame->extended_data, 0, avctx->internal->skip_samples,
frame->nb_samples - avctx->internal->skip_samples, avctx->channels, frame->format);
if(avctx->pkt_timebase.num && avctx->sample_rate) {
+ int64_t diff_ts = av_rescale_q(avctx->internal->skip_samples,
+ (AVRational){1, avctx->sample_rate},
+ avctx->pkt_timebase);
if(frame->pkt_pts!=AV_NOPTS_VALUE)
- frame->pkt_pts += av_rescale_q(avctx->internal->skip_samples,(AVRational){1, avctx->sample_rate}, avctx->pkt_timebase);
+ frame->pkt_pts += diff_ts;
if(frame->pkt_dts!=AV_NOPTS_VALUE)
- frame->pkt_dts += av_rescale_q(avctx->internal->skip_samples,(AVRational){1, avctx->sample_rate}, avctx->pkt_timebase);
+ frame->pkt_dts += diff_ts;
+ if (frame->pkt_duration >= diff_ts)
+ frame->pkt_duration -= diff_ts;
} else {
av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for skipped samples.\n");
}