[FFmpeg-devel,1/2] ffmpeg: Separated check_init_output_file() from init_output_stream()

Submitted by Aaron Levinson on May 12, 2017, 8:26 p.m.

Details

Message ID e411292f-d865-f8f6-0a14-3d134bf8ee99@aracnet.com
State New
Headers show

Commit Message

Aaron Levinson May 12, 2017, 8:26 p.m.
Purpose: Separated the call to check_init_output_file() from
init_output_stream(), and now check_init_output_file() is called by
the parent after calling init_output_stream().  Additionally, moved
some static function declarations to the beginning of the file.

Signed-off-by: Aaron Levinson <alevinsn@aracnet.com>
---
 ffmpeg.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

Patch hide | download patch | download mbox

diff --git a/ffmpeg.c b/ffmpeg.c
index e798d92277..3cd45ba665 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -141,6 +141,9 @@  AVIOContext *progress_avio = NULL;
 
 static uint8_t *subtitle_out;
 
+static int init_output_stream(OutputStream *ost, char *error, int error_len);
+static int check_init_output_file(OutputFile *of, int file_index);
+
 InputStream **input_streams = NULL;
 int        nb_input_streams = 0;
 InputFile   **input_files   = NULL;
@@ -1400,8 +1403,6 @@  static void do_video_stats(OutputStream *ost, int frame_size)
     }
 }
 
-static int init_output_stream(OutputStream *ost, char *error, int error_len);
-
 static void finish_output_stream(OutputStream *ost)
 {
     OutputFile *of = output_files[ost->file_index];
@@ -1446,6 +1447,10 @@  static int reap_filters(int flush)
                        ost->file_index, ost->index, error);
                 exit_program(1);
             }
+
+            ret = check_init_output_file(of, ost->file_index);
+            if (ret < 0)
+                exit_program(1);
         }
 
         if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc())) {
@@ -1894,6 +1899,10 @@  static void flush_encoders(void)
                        ost->file_index, ost->index, error);
                 exit_program(1);
             }
+
+            ret = check_init_output_file(of, ost->file_index);
+            if (ret < 0)
+                exit_program(1);
         }
 
         if (enc->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <= 1)
@@ -3564,10 +3573,6 @@  static int init_output_stream(OutputStream *ost, char *error, int error_len)
 
     ost->initialized = 1;
 
-    ret = check_init_output_file(output_files[ost->file_index], ost->file_index);
-    if (ret < 0)
-        return ret;
-
     return ret;
 }
 
@@ -3629,11 +3634,17 @@  static int transcode_init(void)
 
     /* open each encoder */
     for (i = 0; i < nb_output_streams; i++) {
+        ost = output_streams[i];
         // skip streams fed from filtergraphs until we have a frame for them
-        if (output_streams[i]->filter)
+        if (ost->filter)
             continue;
 
-        ret = init_output_stream(output_streams[i], error, sizeof(error));
+        ret = init_output_stream(ost, error, sizeof(error));
+        if (ret < 0)
+            goto dump_format;
+
+        ret = check_init_output_file(output_files[ost->file_index],
+                                     ost->file_index);
         if (ret < 0)
             goto dump_format;
     }