Commit 64c59b62 authored by Michael Niedermayer's avatar Michael Niedermayer

fftools/ffmpeg: Disable copy_ts on timestamp wraparound

This allows handling more than 26.5h of mpeg* input

Fixes: Ticket 7876
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 88f95253
...@@ -4263,6 +4263,7 @@ static int process_input(int file_index) ...@@ -4263,6 +4263,7 @@ static int process_input(int file_index)
int ret, thread_ret, i, j; int ret, thread_ret, i, j;
int64_t duration; int64_t duration;
int64_t pkt_dts; int64_t pkt_dts;
int disable_discontinuity_correction = copy_ts;
is = ifile->ctx; is = ifile->ctx;
ret = get_input_packet(ifile, &pkt); ret = get_input_packet(ifile, &pkt);
...@@ -4464,10 +4465,20 @@ static int process_input(int file_index) ...@@ -4464,10 +4465,20 @@ static int process_input(int file_index)
pkt.dts += duration; pkt.dts += duration;
pkt_dts = av_rescale_q_rnd(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); pkt_dts = av_rescale_q_rnd(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
if (copy_ts && pkt_dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE &&
(is->iformat->flags & AVFMT_TS_DISCONT) && ist->st->pts_wrap_bits < 60) {
int64_t wrap_dts = av_rescale_q_rnd(pkt.dts + (1LL<<ist->st->pts_wrap_bits),
ist->st->time_base, AV_TIME_BASE_Q,
AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
if (FFABS(wrap_dts - ist->next_dts) < FFABS(pkt_dts - ist->next_dts)/10)
disable_discontinuity_correction = 0;
}
if ((ist->dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO || if ((ist->dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO ||
ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) && ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) &&
pkt_dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE && pkt_dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE &&
!copy_ts) { !disable_discontinuity_correction) {
int64_t delta = pkt_dts - ist->next_dts; int64_t delta = pkt_dts - ist->next_dts;
if (is->iformat->flags & AVFMT_TS_DISCONT) { if (is->iformat->flags & AVFMT_TS_DISCONT) {
if (delta < -1LL*dts_delta_threshold*AV_TIME_BASE || if (delta < -1LL*dts_delta_threshold*AV_TIME_BASE ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment