diff mbox series

[FFmpeg-devel,17/23] fftools/ffmpeg_enc: stop using OutputStream.initialized

Message ID 20230531145453.20994-17-anton@khirnov.net
State Accepted
Commit c803b36b8f5c8fa73ab2e77490d284d906d4c44b
Headers show
Series [FFmpeg-devel,01/23] fftools/ffmpeg_enc: move nb_frames{dup, drop} globals into OutputStream | expand

Checks

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

Commit Message

Anton Khirnov May 31, 2023, 2:54 p.m. UTC
It is set by the muxing code, which will not be synchronized with
encoding code after upcoming threading changes. Use an encoder-private
variable instead.
---
 fftools/ffmpeg_enc.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index cd2faccf4e..1515ca971f 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -62,6 +62,8 @@  struct Encoder {
 
     // number of packets received from the encoder
     uint64_t packets_encoded;
+
+    int opened;
 };
 
 static uint64_t dup_warning = 1000;
@@ -187,7 +189,7 @@  int enc_open(OutputStream *ost, AVFrame *frame)
     OutputFile      *of = output_files[ost->file_index];
     int ret;
 
-    if (ost->initialized)
+    if (e->opened)
         return 0;
 
     set_encoder_id(output_files[ost->file_index], ost);
@@ -362,6 +364,8 @@  int enc_open(OutputStream *ost, AVFrame *frame)
         return ret;
     }
 
+    e->opened = 1;
+
     if (ost->sq_idx_encode >= 0) {
         e->sq_frame = av_frame_alloc();
         if (!e->sq_frame)
@@ -1123,6 +1127,7 @@  void enc_flush(void)
     }
 
     for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) {
+        Encoder          *e = ost->enc;
         AVCodecContext *enc = ost->enc_ctx;
         OutputFile      *of = output_files[ost->file_index];
 
@@ -1131,7 +1136,7 @@  void enc_flush(void)
 
         // Try to enable encoding with no input frames.
         // Maybe we should just let encoding fail instead.
-        if (!ost->initialized) {
+        if (!e->opened) {
             FilterGraph *fg = ost->filter->graph;
 
             av_log(ost, AV_LOG_WARNING,