History

fftools/ffmpeg: replace stream timebase with packet one where appropriate

Anton Khirnov committed 3 years ago

Commit 03a465b1 parent 65b13501 file · +18 −18Browse files

Unified · Split

fftools/ffmpeg.c+18−18
@@ -1116,7 +1116,7 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output, · 1115 unmodified lines
11161116 decoded_frame_tb = ist->st->time_base;
11171117 } else if (pkt && pkt->pts != AV_NOPTS_VALUE) {
11181118 decoded_frame->pts = pkt->pts;
1119− decoded_frame_tb = ist->st->time_base;
1119+ decoded_frame_tb = pkt->time_base;
11201120 }else {
11211121 decoded_frame->pts = ist->dts;
11221122 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
15531553 ist->pts = 0;
15541554 if (pkt && pkt->pts != AV_NOPTS_VALUE && !ist->decoding_needed) {
15551555 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);
15571557 }
15581558 ist->saw_first_ts = 1;
15591559 }
@@ -1571,7 +1571,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo · 11 unmodified lines
15711571 }
15721572
15731573 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);
15751575 if (par->codec_type != AVMEDIA_TYPE_VIDEO)
15761576 ist->pts = ist->dts;
15771577 }
@@ -1597,7 +1597,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo · 19 unmodified lines
15971597 &decode_failed);
15981598 if (!repeating || !pkt || got_output) {
15991599 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);
16011601 } else if(ist->dec_ctx->framerate.num != 0 && ist->dec_ctx->framerate.den != 0) {
16021602 int ticks = ist->last_pkt_repeat_pict >= 0 ?
16031603 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
16921692 ist->next_dts += ((int64_t)AV_TIME_BASE * par->frame_size) /
16931693 par->sample_rate;
16941694 } 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);
16961696 }
16971697 break;
16981698 case AVMEDIA_TYPE_VIDEO:
@@ -1702,7 +1702,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo · 3 unmodified lines
17021702 int64_t next_dts = av_rescale_q(ist->next_dts, time_base_q, av_inv_q(ist->framerate));
17031703 ist->next_dts = av_rescale_q(next_dts + 1, av_inv_q(ist->framerate), time_base_q);
17041704 } 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);
17061706 } else if(ist->dec_ctx->framerate.num != 0) {
17071707 int ticks = ist->last_pkt_repeat_pict >= 0 ?
17081708 ist->last_pkt_repeat_pict + 1 :
@@ -2074,13 +2074,13 @@ static void ts_discontinuity_detect(InputFile *ifile, InputStream *ist, · 365 unmodified lines
20742074 {
20752075 const int fmt_is_discont = ifile->ctx->iformat->flags & AVFMT_TS_DISCONT;
20762076 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,
20782078 AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX);
20792079
20802080 if (copy_ts && ist->next_dts != AV_NOPTS_VALUE &&
20812081 fmt_is_discont && ist->st->pts_wrap_bits < 60) {
20822082 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,
20842084 AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
20852085 if (FFABS(wrap_dts - ist->next_dts) < FFABS(pkt_dts - ist->next_dts)/10)
20862086 disable_discontinuity_correction = 0;
@@ -2098,9 +2098,9 @@ static void ts_discontinuity_detect(InputFile *ifile, InputStream *ist, · 11 unmodified lines
20982098 ist->file_index, ist->st->index, ist->st->id,
20992099 av_get_media_type_string(ist->par->codec_type),
21002100 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);
21022102 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);
21042104 }
21052105 } else {
21062106 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
21082108 pkt->dts = AV_NOPTS_VALUE;
21092109 }
21102110 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);
21122112 delta = pkt_pts - ist->next_dts;
21132113 if (FFABS(delta) > 1LL * dts_error_threshold * AV_TIME_BASE) {
21142114 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
21242124 av_log(NULL, AV_LOG_DEBUG,
21252125 "Inter stream timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",
21262126 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);
21282128 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);
21302130 }
21312131 }
21322132
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);
21342134 }
21352135
21362136 static void ts_discontinuity_process(InputFile *ifile, InputStream *ist,
21372137 AVPacket *pkt)
21382138 {
21392139 int64_t offset = av_rescale_q(ifile->ts_offset_discont, AV_TIME_BASE_Q,
2140− ist->st->time_base);
2140+ pkt->time_base);
21412141
21422142 // apply previously-detected timestamp-discontinuity offset
21432143 // (to all streams, not just audio/video)
@@ -2245,9 +2245,9 @@ static int process_input(int file_index) · 101 unmodified lines
22452245 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",
22462246 ifile->index, pkt->stream_index,
22472247 av_get_media_type_string(ist->par->codec_type),
2248− av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ist->st->time_base),
2249− av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ist->st->time_base),
2250− av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &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, &pkt->time_base),
2250+ av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &pkt->time_base),
22512251 av_ts2str(input_files[ist->file_index]->ts_offset),
22522252 av_ts2timestr(input_files[ist->file_index]->ts_offset, &AV_TIME_BASE_Q));
22532253 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t