aboutsummaryrefslogtreecommitdiffstats
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-08-24 01:39:32 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-08-24 01:39:32 +0200
commit91c18beb9d670a2f64f3ffbc1d60d443eb2ef858 (patch)
treed610d542d771ea4299905479638f158d69d7bdcd /ffmpeg.c
parent168ddcd33165e8e2f447116c05adf9a4fbeb112e (diff)
downloadandroid_external_ffmpeg-91c18beb9d670a2f64f3ffbc1d60d443eb2ef858.tar.gz
android_external_ffmpeg-91c18beb9d670a2f64f3ffbc1d60d443eb2ef858.tar.bz2
android_external_ffmpeg-91c18beb9d670a2f64f3ffbc1d60d443eb2ef858.zip
ffmpeg: fix wrap correction code.
The code failed with negative timestamps due to using unsigned numbers Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 4e8d32d91d..3a9c705675 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2739,15 +2739,16 @@ static int process_input(int file_index)
goto discard_packet;
if(!ist->wrap_correction_done && input_files[file_index]->ctx->start_time != AV_NOPTS_VALUE && ist->st->pts_wrap_bits < 64){
- uint64_t stime = av_rescale_q(input_files[file_index]->ctx->start_time, AV_TIME_BASE_Q, ist->st->time_base);
- uint64_t stime2= stime + (1LL<<ist->st->pts_wrap_bits);
+ int64_t stime = av_rescale_q(input_files[file_index]->ctx->start_time, AV_TIME_BASE_Q, ist->st->time_base);
+ int64_t stime2= stime + (1ULL<<ist->st->pts_wrap_bits);
ist->wrap_correction_done = 1;
- if(pkt.dts != AV_NOPTS_VALUE && pkt.dts > stime && pkt.dts - stime > stime2 - pkt.dts) {
- pkt.dts -= 1LL<<ist->st->pts_wrap_bits;
+
+ if(stime2 > stime && pkt.dts != AV_NOPTS_VALUE && pkt.dts > stime + (1LL<<(ist->st->pts_wrap_bits-1))) {
+ pkt.dts -= 1ULL<<ist->st->pts_wrap_bits;
ist->wrap_correction_done = 0;
}
- if(pkt.pts != AV_NOPTS_VALUE && pkt.pts > stime && pkt.pts - stime > stime2 - pkt.pts) {
- pkt.pts -= 1LL<<ist->st->pts_wrap_bits;
+ if(stime2 > stime && pkt.pts != AV_NOPTS_VALUE && pkt.pts > stime + (1LL<<(ist->st->pts_wrap_bits-1))) {
+ pkt.pts -= 1ULL<<ist->st->pts_wrap_bits;
ist->wrap_correction_done = 0;
}
}