Unified · Split
| @@ -1116,7 +1116,7 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output, · 1115 unmodified lines | |||
| 1116 | decoded_frame_tb = ist->st->time_base; | 1116 | decoded_frame_tb = ist->st->time_base; |
| 1117 | } else if (pkt && pkt->pts != AV_NOPTS_VALUE) { | 1117 | } else if (pkt && pkt->pts != AV_NOPTS_VALUE) { |
| 1118 | decoded_frame->pts = pkt->pts; | 1118 | decoded_frame->pts = pkt->pts; |
| 1119 | decoded_frame_tb = ist->st->time_base; | 1119 | decoded_frame_tb = pkt->time_base; |
| 1120 | }else { | 1120 | }else { |
| 1121 | decoded_frame->pts = ist->dts; | 1121 | decoded_frame->pts = ist->dts; |
| 1122 | decoded_frame_tb = AV_TIME_BASE_Q; | 1122 | decoded_frame_tb = AV_TIME_BASE_Q; |
| @@ -1553,7 +1553,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo · 430 unmodified lines | |||
| 1553 | ist->pts = 0; | 1553 | ist->pts = 0; |
| 1554 | if (pkt && pkt->pts != AV_NOPTS_VALUE && !ist->decoding_needed) { | 1554 | if (pkt && pkt->pts != AV_NOPTS_VALUE && !ist->decoding_needed) { |
| 1555 | ist->first_dts = | 1555 | ist->first_dts = |
| 1556 | ist->dts += av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q); | 1556 | ist->dts += av_rescale_q(pkt->pts, pkt->time_base, AV_TIME_BASE_Q); |
| 1557 | } | 1557 | } |
| 1558 | ist->saw_first_ts = 1; | 1558 | ist->saw_first_ts = 1; |
| 1559 | } | 1559 | } |
| @@ -1571,7 +1571,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo · 11 unmodified lines | |||
| 1571 | } | 1571 | } |
| 1572 | 1572 | ||
| 1573 | if (pkt && pkt->dts != AV_NOPTS_VALUE) { | 1573 | if (pkt && pkt->dts != AV_NOPTS_VALUE) { |
| 1574 | ist->next_dts = ist->dts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q); | 1574 | ist->next_dts = ist->dts = av_rescale_q(pkt->dts, pkt->time_base, AV_TIME_BASE_Q); |
| 1575 | if (par->codec_type != AVMEDIA_TYPE_VIDEO) | 1575 | if (par->codec_type != AVMEDIA_TYPE_VIDEO) |
| 1576 | ist->pts = ist->dts; | 1576 | ist->pts = ist->dts; |
| 1577 | } | 1577 | } |
| @@ -1597,7 +1597,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo · 19 unmodified lines | |||
| 1597 | &decode_failed); | 1597 | &decode_failed); |
| 1598 | if (!repeating || !pkt || got_output) { | 1598 | if (!repeating || !pkt || got_output) { |
| 1599 | if (pkt && pkt->duration) { | 1599 | if (pkt && pkt->duration) { |
| 1600 | duration_dts = av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q); | 1600 | duration_dts = av_rescale_q(pkt->duration, pkt->time_base, AV_TIME_BASE_Q); |
| 1601 | } else if(ist->dec_ctx->framerate.num != 0 && ist->dec_ctx->framerate.den != 0) { | 1601 | } else if(ist->dec_ctx->framerate.num != 0 && ist->dec_ctx->framerate.den != 0) { |
| 1602 | int ticks = ist->last_pkt_repeat_pict >= 0 ? | 1602 | int ticks = ist->last_pkt_repeat_pict >= 0 ? |
| 1603 | ist->last_pkt_repeat_pict + 1 : | 1603 | ist->last_pkt_repeat_pict + 1 : |
| @@ -1692,7 +1692,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo · 88 unmodified lines | |||
| 1692 | ist->next_dts += ((int64_t)AV_TIME_BASE * par->frame_size) / | 1692 | ist->next_dts += ((int64_t)AV_TIME_BASE * par->frame_size) / |
| 1693 | par->sample_rate; | 1693 | par->sample_rate; |
| 1694 | } else { | 1694 | } else { |
| 1695 | ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q); | 1695 | ist->next_dts += av_rescale_q(pkt->duration, pkt->time_base, AV_TIME_BASE_Q); |
| 1696 | } | 1696 | } |
| 1697 | break; | 1697 | break; |
| 1698 | case AVMEDIA_TYPE_VIDEO: | 1698 | case AVMEDIA_TYPE_VIDEO: |
| @@ -1702,7 +1702,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo · 3 unmodified lines | |||
| 1702 | int64_t next_dts = av_rescale_q(ist->next_dts, time_base_q, av_inv_q(ist->framerate)); | 1702 | int64_t next_dts = av_rescale_q(ist->next_dts, time_base_q, av_inv_q(ist->framerate)); |
| 1703 | ist->next_dts = av_rescale_q(next_dts + 1, av_inv_q(ist->framerate), time_base_q); | 1703 | ist->next_dts = av_rescale_q(next_dts + 1, av_inv_q(ist->framerate), time_base_q); |
| 1704 | } else if (pkt->duration) { | 1704 | } else if (pkt->duration) { |
| 1705 | ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q); | 1705 | ist->next_dts += av_rescale_q(pkt->duration, pkt->time_base, AV_TIME_BASE_Q); |
| 1706 | } else if(ist->dec_ctx->framerate.num != 0) { | 1706 | } else if(ist->dec_ctx->framerate.num != 0) { |
| 1707 | int ticks = ist->last_pkt_repeat_pict >= 0 ? | 1707 | int ticks = ist->last_pkt_repeat_pict >= 0 ? |
| 1708 | ist->last_pkt_repeat_pict + 1 : | 1708 | ist->last_pkt_repeat_pict + 1 : |
| @@ -2074,13 +2074,13 @@ static void ts_discontinuity_detect(InputFile *ifile, InputStream *ist, · 365 unmodified lines | |||
| 2074 | { | 2074 | { |
| 2075 | const int fmt_is_discont = ifile->ctx->iformat->flags & AVFMT_TS_DISCONT; | 2075 | const int fmt_is_discont = ifile->ctx->iformat->flags & AVFMT_TS_DISCONT; |
| 2076 | int disable_discontinuity_correction = copy_ts; | 2076 | int disable_discontinuity_correction = copy_ts; |
| 2077 | int64_t pkt_dts = av_rescale_q_rnd(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q, | 2077 | int64_t pkt_dts = av_rescale_q_rnd(pkt->dts, pkt->time_base, AV_TIME_BASE_Q, |
| 2078 | AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX); | 2078 | AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX); |
| 2079 | 2079 | ||
| 2080 | if (copy_ts && ist->next_dts != AV_NOPTS_VALUE && | 2080 | if (copy_ts && ist->next_dts != AV_NOPTS_VALUE && |
| 2081 | fmt_is_discont && ist->st->pts_wrap_bits < 60) { | 2081 | fmt_is_discont && ist->st->pts_wrap_bits < 60) { |
| 2082 | int64_t wrap_dts = av_rescale_q_rnd(pkt->dts + (1LL<<ist->st->pts_wrap_bits), | 2082 | int64_t wrap_dts = av_rescale_q_rnd(pkt->dts + (1LL<<ist->st->pts_wrap_bits), |
| 2083 | ist->st->time_base, AV_TIME_BASE_Q, | 2083 | pkt->time_base, AV_TIME_BASE_Q, |
| 2084 | AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); | 2084 | AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); |
| 2085 | if (FFABS(wrap_dts - ist->next_dts) < FFABS(pkt_dts - ist->next_dts)/10) | 2085 | if (FFABS(wrap_dts - ist->next_dts) < FFABS(pkt_dts - ist->next_dts)/10) |
| 2086 | disable_discontinuity_correction = 0; | 2086 | disable_discontinuity_correction = 0; |
| @@ -2098,9 +2098,9 @@ static void ts_discontinuity_detect(InputFile *ifile, InputStream *ist, · 11 unmodified lines | |||
| 2098 | ist->file_index, ist->st->index, ist->st->id, | 2098 | ist->file_index, ist->st->index, ist->st->id, |
| 2099 | av_get_media_type_string(ist->par->codec_type), | 2099 | av_get_media_type_string(ist->par->codec_type), |
| 2100 | delta, ifile->ts_offset_discont); | 2100 | delta, ifile->ts_offset_discont); |
| 2101 | pkt->dts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); | 2101 | pkt->dts -= av_rescale_q(delta, AV_TIME_BASE_Q, pkt->time_base); |
| 2102 | if (pkt->pts != AV_NOPTS_VALUE) | 2102 | if (pkt->pts != AV_NOPTS_VALUE) |
| 2103 | pkt->pts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); | 2103 | pkt->pts -= av_rescale_q(delta, AV_TIME_BASE_Q, pkt->time_base); |
| 2104 | } | 2104 | } |
| 2105 | } else { | 2105 | } else { |
| 2106 | if (FFABS(delta) > 1LL * dts_error_threshold * AV_TIME_BASE) { | 2106 | if (FFABS(delta) > 1LL * dts_error_threshold * AV_TIME_BASE) { |
| @@ -2108,7 +2108,7 @@ static void ts_discontinuity_detect(InputFile *ifile, InputStream *ist, · 1 unmodified line | |||
| 2108 | pkt->dts = AV_NOPTS_VALUE; | 2108 | pkt->dts = AV_NOPTS_VALUE; |
| 2109 | } | 2109 | } |
| 2110 | if (pkt->pts != AV_NOPTS_VALUE){ | 2110 | if (pkt->pts != AV_NOPTS_VALUE){ |
| 2111 | int64_t pkt_pts = av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q); | 2111 | int64_t pkt_pts = av_rescale_q(pkt->pts, pkt->time_base, AV_TIME_BASE_Q); |
| 2112 | delta = pkt_pts - ist->next_dts; | 2112 | delta = pkt_pts - ist->next_dts; |
| 2113 | if (FFABS(delta) > 1LL * dts_error_threshold * AV_TIME_BASE) { | 2113 | if (FFABS(delta) > 1LL * dts_error_threshold * AV_TIME_BASE) { |
| 2114 | av_log(NULL, AV_LOG_WARNING, "PTS %"PRId64", next:%"PRId64" invalid dropping st:%d\n", pkt->pts, ist->next_dts, pkt->stream_index); | 2114 | av_log(NULL, AV_LOG_WARNING, "PTS %"PRId64", next:%"PRId64" invalid dropping st:%d\n", pkt->pts, ist->next_dts, pkt->stream_index); |
| @@ -2124,20 +2124,20 @@ static void ts_discontinuity_detect(InputFile *ifile, InputStream *ist, · 9 unmodified lines | |||
| 2124 | av_log(NULL, AV_LOG_DEBUG, | 2124 | av_log(NULL, AV_LOG_DEBUG, |
| 2125 | "Inter stream timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", | 2125 | "Inter stream timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", |
| 2126 | delta, ifile->ts_offset_discont); | 2126 | delta, ifile->ts_offset_discont); |
| 2127 | pkt->dts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); | 2127 | pkt->dts -= av_rescale_q(delta, AV_TIME_BASE_Q, pkt->time_base); |
| 2128 | if (pkt->pts != AV_NOPTS_VALUE) | 2128 | if (pkt->pts != AV_NOPTS_VALUE) |
| 2129 | pkt->pts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base); | 2129 | pkt->pts -= av_rescale_q(delta, AV_TIME_BASE_Q, pkt->time_base); |
| 2130 | } | 2130 | } |
| 2131 | } | 2131 | } |
| 2132 | 2132 | ||
| 2133 | ifile->last_ts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q); | 2133 | ifile->last_ts = av_rescale_q(pkt->dts, pkt->time_base, AV_TIME_BASE_Q); |
| 2134 | } | 2134 | } |
| 2135 | 2135 | ||
| 2136 | static void ts_discontinuity_process(InputFile *ifile, InputStream *ist, | 2136 | static void ts_discontinuity_process(InputFile *ifile, InputStream *ist, |
| 2137 | AVPacket *pkt) | 2137 | AVPacket *pkt) |
| 2138 | { | 2138 | { |
| 2139 | int64_t offset = av_rescale_q(ifile->ts_offset_discont, AV_TIME_BASE_Q, | 2139 | int64_t offset = av_rescale_q(ifile->ts_offset_discont, AV_TIME_BASE_Q, |
| 2140 | ist->st->time_base); | 2140 | pkt->time_base); |
| 2141 | 2141 | ||
| 2142 | // apply previously-detected timestamp-discontinuity offset | 2142 | // apply previously-detected timestamp-discontinuity offset |
| 2143 | // (to all streams, not just audio/video) | 2143 | // (to all streams, not just audio/video) |
| @@ -2245,9 +2245,9 @@ static int process_input(int file_index) · 101 unmodified lines | |||
| 2245 | av_log(NULL, AV_LOG_INFO, "demuxer+ffmpeg -> ist_index:%d:%d type:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s duration:%s duration_time:%s off:%s off_time:%s\n", | 2245 | av_log(NULL, AV_LOG_INFO, "demuxer+ffmpeg -> ist_index:%d:%d type:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s duration:%s duration_time:%s off:%s off_time:%s\n", |
| 2246 | ifile->index, pkt->stream_index, | 2246 | ifile->index, pkt->stream_index, |
| 2247 | av_get_media_type_string(ist->par->codec_type), | 2247 | av_get_media_type_string(ist->par->codec_type), |
| 2248 | av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ist->st->time_base), | 2248 | av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &pkt->time_base), |
| 2249 | av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ist->st->time_base), | 2249 | av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &pkt->time_base), |
| 2250 | av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &ist->st->time_base), | 2250 | av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &pkt->time_base), |
| 2251 | av_ts2str(input_files[ist->file_index]->ts_offset), | 2251 | av_ts2str(input_files[ist->file_index]->ts_offset), |
| 2252 | av_ts2timestr(input_files[ist->file_index]->ts_offset, &AV_TIME_BASE_Q)); | 2252 | av_ts2timestr(input_files[ist->file_index]->ts_offset, &AV_TIME_BASE_Q)); |
| 2253 | } | 2253 | } |