summaryrefslogtreecommitdiff
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-07-28 16:55:12 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-07-28 17:05:24 +0200
commit157f95697338dd79253fb4b278399a591bf6894e (patch)
treeb0a3456f6c6df7b33ad1427b4e834f7d63a38783 /ffmpeg.c
parent05a6c625f47500d8079eea8512670f9134b31328 (diff)
ffmpeg: add code to perform ts wrap correction
Fixes ticket1385 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 1ce377241c..3ffc9969b8 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -231,6 +231,7 @@ typedef struct InputStream {
int64_t next_pts; ///< synthetic pts for the next decode frame (in AV_TIME_BASE units)
int64_t pts; ///< current pts of the decoded frame (in AV_TIME_BASE units)
+ int wrap_correction_done;
double ts_scale;
int is_start; /* is 1 at the start and after a discontinuity */
int saw_first_ts;
@@ -3762,6 +3763,20 @@ static int transcode(void)
if (ist->discard)
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);
+ 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;
+ 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;
+ ist->wrap_correction_done = 0;
+ }
+ }
+
if (pkt.dts != AV_NOPTS_VALUE)
pkt.dts += av_rescale_q(input_files[ist->file_index]->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)