diff mbox series

[FFmpeg-devel,15/24] fftools/ffmpeg: tweak sub2video_heartbeat() arguments

Message ID 20230528091416.17927-15-anton@khirnov.net
State Accepted
Commit ea5c39cef624c7bb636145052ea42ef789dae7ed
Headers show
Series [FFmpeg-devel,01/24] fftools/ffmpeg_mux_init: merge ost_add_from_filter() to ost_add() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov May 28, 2023, 9:14 a.m. UTC
This function should not take an InputStream, as it only uses it to get
the InputFile and the timebase. Pass those directly instead and avoid
confusion over dealing with multiple InputStreams.
---
 fftools/ffmpeg.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 9ee16ee8e0..4624960c17 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -252,9 +252,8 @@  void sub2video_update(InputStream *ist, int64_t heartbeat_pts,
     ist->sub2video.initialize = 0;
 }
 
-static void sub2video_heartbeat(InputStream *ist, int64_t pts)
+static void sub2video_heartbeat(InputFile *infile, int64_t pts, AVRational tb)
 {
-    InputFile *infile = input_files[ist->file_index];
     int i, j, nb_reqs;
     int64_t pts2;
 
@@ -268,7 +267,7 @@  static void sub2video_heartbeat(InputStream *ist, int64_t pts)
             continue;
         /* subtitles seem to be usually muxed ahead of other streams;
            if not, subtracting a larger time here is necessary */
-        pts2 = av_rescale_q(pts, ist->st->time_base, ist2->st->time_base) - 1;
+        pts2 = av_rescale_q(pts, tb, ist2->st->time_base) - 1;
         /* do not send the heartbeat frame if the subtitle is already ahead */
         if (pts2 <= ist2->sub2video.last_pts)
             continue;
@@ -1231,7 +1230,7 @@  static int process_input(int file_index)
 
     ist = ifile->streams[pkt->stream_index];
 
-    sub2video_heartbeat(ist, pkt->pts);
+    sub2video_heartbeat(ifile, pkt->pts, pkt->time_base);
 
     process_input_packet(ist, pkt, 0);