diff mbox series

[FFmpeg-devel,24/29] fftools/ffmpeg: inline check_output_constraints() into its only caller

Message ID 20230409140853.28858-24-anton@khirnov.net
State Accepted
Commit fdf29dcebb4f24c962221910546c3a15a87d11ee
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
Which is subtitle encoding. Also, check for AVSubtitle.pts rather than
InputStream.pts, since that is the more authoritative value and is
guaranteed to be valid.
---
 fftools/ffmpeg.c     | 19 +------------------
 fftools/ffmpeg_enc.c |  3 +++
 2 files changed, 4 insertions(+), 18 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 44ead4e3bc..95e4044dc6 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -941,22 +941,6 @@  int ifilter_parameters_from_codecpar(InputFilter *ifilter, AVCodecParameters *pa
     return 0;
 }
 
-/*
- * Check whether a packet from ist should be written into ost at this time
- */
-static int check_output_constraints(InputStream *ist, OutputStream *ost)
-{
-    OutputFile *of = output_files[ost->file_index];
-
-    if (ost->finished & MUXER_FINISHED)
-        return 0;
-
-    if (of->start_time != AV_NOPTS_VALUE && ist->pts < of->start_time)
-        return 0;
-
-    return 1;
-}
-
 static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *pkt)
 {
     OutputFile *of = output_files[ost->file_index];
@@ -1471,8 +1455,7 @@  static int process_subtitle(InputStream *ist, AVSubtitle *subtitle, int *got_out
 
     for (int oidx = 0; oidx < ist->nb_outputs; oidx++) {
         OutputStream *ost = ist->outputs[oidx];
-        if (!check_output_constraints(ist, ost) || !ost->enc_ctx
-            || ost->enc_ctx->codec_type != AVMEDIA_TYPE_SUBTITLE)
+        if (!ost->enc_ctx || ost->enc_ctx->codec_type != AVMEDIA_TYPE_SUBTITLE)
             continue;
 
         enc_subtitle(output_files[ost->file_index], ost, subtitle);
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index 2aaef806f6..a0779c45ae 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -440,6 +440,9 @@  void enc_subtitle(OutputFile *of, OutputStream *ost, AVSubtitle *sub)
             exit_program(1);
         return;
     }
+    if (ost->finished ||
+        (of->start_time != AV_NOPTS_VALUE && sub->pts < of->start_time))
+        return;
 
     enc = ost->enc_ctx;