diff mbox series

[FFmpeg-devel,26/29] fftools/ffmpeg: use AVPacket.time_base to simplify do_streamcopy()

Message ID 20230409140853.28858-26-anton@khirnov.net
State Accepted
Commit d867f9ab8cf50b12b978c9cb72871c53fd606d75
Headers show
Series [FFmpeg-devel,01/29] fftools/ffmpeg: move OutputStream.vsync_frame_number to Encoder | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov April 9, 2023, 2:08 p.m. UTC
Besides making the code shorter, this also reduces the use of
InputStream in this function and will allow not accessing it at all in
the future.
---
 fftools/ffmpeg.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 95e4044dc6..f905836af6 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -964,7 +964,7 @@  static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
         if (!ost->copy_prior_start &&
             (pkt->pts == AV_NOPTS_VALUE ?
              ist->pts < ost->ts_copy_start :
-             pkt->pts < av_rescale_q(ost->ts_copy_start, AV_TIME_BASE_Q, ist->st->time_base)))
+             pkt->pts < av_rescale_q(ost->ts_copy_start, AV_TIME_BASE_Q, pkt->time_base)))
             return;
 
         if (of->start_time != AV_NOPTS_VALUE && ist->pts < of->start_time)
@@ -995,7 +995,7 @@  static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
     opkt->time_base = ost->mux_timebase;
 
     if (pkt->pts != AV_NOPTS_VALUE)
-        opkt->pts = av_rescale_q(pkt->pts, ist->st->time_base, opkt->time_base) - ost_tb_start_time;
+        opkt->pts = av_rescale_q(pkt->pts, pkt->time_base, opkt->time_base) - ost_tb_start_time;
 
     if (pkt->dts == AV_NOPTS_VALUE) {
         opkt->dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, opkt->time_base);
@@ -1003,16 +1003,16 @@  static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
         int duration = av_get_audio_frame_duration2(ist->par, pkt->size);
         if(!duration)
             duration = ist->par->frame_size;
-        opkt->dts = av_rescale_delta(ist->st->time_base, pkt->dts,
+        opkt->dts = av_rescale_delta(pkt->time_base, pkt->dts,
                                     (AVRational){1, ist->par->sample_rate}, duration,
                                     &ist->filter_in_rescale_delta_last, opkt->time_base);
         /* dts will be set immediately afterwards to what pts is now */
         opkt->pts = opkt->dts - ost_tb_start_time;
     } else
-        opkt->dts = av_rescale_q(pkt->dts, ist->st->time_base, opkt->time_base);
+        opkt->dts = av_rescale_q(pkt->dts, pkt->time_base, opkt->time_base);
     opkt->dts -= ost_tb_start_time;
 
-    opkt->duration = av_rescale_q(pkt->duration, ist->st->time_base, opkt->time_base);
+    opkt->duration = av_rescale_q(pkt->duration, pkt->time_base, opkt->time_base);
 
     {
         int ret = trigger_fix_sub_duration_heartbeat(ost, pkt);