This allows handling more than 26.5h of mpeg* input Fixes: Ticket 7876
Unified · Split
| @@ -4263,6 +4263,7 @@ static int process_input(int file_index) · 4262 unmodified lines | |||
| 4263 | int ret, thread_ret, i, j; | 4263 | int ret, thread_ret, i, j; |
| 4264 | int64_t duration; | 4264 | int64_t duration; |
| 4265 | int64_t pkt_dts; | 4265 | int64_t pkt_dts; |
| 4266 | int disable_discontinuity_correction = copy_ts; | ||
| 4266 | 4267 | ||
| 4267 | is = ifile->ctx; | 4268 | is = ifile->ctx; |
| 4268 | ret = get_input_packet(ifile, &pkt); | 4269 | ret = get_input_packet(ifile, &pkt); |
| @@ -4464,10 +4465,20 @@ static int process_input(int file_index) · 195 unmodified lines | |||
| 4464 | pkt.dts += duration; | 4465 | pkt.dts += duration; |
| 4465 | 4466 | ||
| 4466 | pkt_dts = av_rescale_q_rnd(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); | 4467 | pkt_dts = av_rescale_q_rnd(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); |
| 4468 | |||
| 4469 | if (copy_ts && pkt_dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE && | ||
| 4470 | (is->iformat->flags & AVFMT_TS_DISCONT) && ist->st->pts_wrap_bits < 60) { | ||
| 4471 | int64_t wrap_dts = av_rescale_q_rnd(pkt.dts + (1LL<<ist->st->pts_wrap_bits), | ||
| 4472 | ist->st->time_base, AV_TIME_BASE_Q, | ||
| 4473 | AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); | ||
| 4474 | if (FFABS(wrap_dts - ist->next_dts) < FFABS(pkt_dts - ist->next_dts)/10) | ||
| 4475 | disable_discontinuity_correction = 0; | ||
| 4476 | } | ||
| 4477 | |||
| 4467 | if ((ist->dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO || | 4478 | if ((ist->dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO || |
| 4468 | ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) && | 4479 | ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) && |
| 4469 | pkt_dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE && | 4480 | pkt_dts != AV_NOPTS_VALUE && ist->next_dts != AV_NOPTS_VALUE && |
| 4470 | !copy_ts) { | 4481 | !disable_discontinuity_correction) { |
| 4471 | int64_t delta = pkt_dts - ist->next_dts; | 4482 | int64_t delta = pkt_dts - ist->next_dts; |
| 4472 | if (is->iformat->flags & AVFMT_TS_DISCONT) { | 4483 | if (is->iformat->flags & AVFMT_TS_DISCONT) { |
| 4473 | if (delta < -1LL*dts_delta_threshold*AV_TIME_BASE || | 4484 | if (delta < -1LL*dts_delta_threshold*AV_TIME_BASE || |