[FFmpeg-devel] [PATCH 2/2] Put the code for showing input and output streams and mapping in a separate function show_format_map().

Stefano Sabatini stefano.sabatini-lala
Sat Oct 16 16:59:53 CEST 2010


Improve readability and decrease the size of the still huge
transcode_init() function.
---
 ffmpeg.c |   53 ++++++++++++++++++++++++++++++-----------------------
 1 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 045e2d5..acd136d 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1935,6 +1935,35 @@ static AVInputStream **ist_table;
 static AVOutputStream **ost_table;
 static AVInputFile *file_table;
 
+static void show_format_map(void)
+{
+    int i;
+
+    /* dump the file output parameters - cannot be done before in case
+       of stream copy */
+    for(i=0;i<nb_output_files;i++) {
+        dump_format(output_files[i], i, output_files[i]->filename, 1);
+    }
+
+    /* dump the stream mapping */
+    if (verbose >= 0) {
+        fprintf(stderr, "Stream mapping:\n");
+        for(i=0;i<nb_ostreams;i++) {
+            AVOutputStream *ost = ost_table[i];
+            fprintf(stderr, "  Stream #%d.%d -> #%d.%d",
+                    ist_table[ost->source_index]->file_index,
+                    ist_table[ost->source_index]->index,
+                    ost->file_index,
+                    ost->index);
+            if (ost->sync_ist != ist_table[ost->source_index])
+                fprintf(stderr, " [sync #%d.%d]",
+                        ost->sync_ist->file_index,
+                        ost->sync_ist->index);
+            fprintf(stderr, "\n");
+        }
+    }
+}
+
 /*
  * The following code is the main loop of the file converter
  */
@@ -2420,29 +2449,7 @@ static int transcode_init(AVFormatContext **output_files,
     }
 
  dump_format:
-    /* dump the file output parameters - cannot be done before in case
-       of stream copy */
-    for(i=0;i<nb_output_files;i++) {
-        dump_format(output_files[i], i, output_files[i]->filename, 1);
-    }
-
-    /* dump the stream mapping */
-    if (verbose >= 0) {
-        fprintf(stderr, "Stream mapping:\n");
-        for(i=0;i<nb_ostreams;i++) {
-            ost = ost_table[i];
-            fprintf(stderr, "  Stream #%d.%d -> #%d.%d",
-                    ist_table[ost->source_index]->file_index,
-                    ist_table[ost->source_index]->index,
-                    ost->file_index,
-                    ost->index);
-            if (ost->sync_ist != ist_table[ost->source_index])
-                fprintf(stderr, " [sync #%d.%d]",
-                        ost->sync_ist->file_index,
-                        ost->sync_ist->index);
-            fprintf(stderr, "\n");
-        }
-    }
+    show_format_map();
 
     if (ret) {
         fprintf(stderr, "%s\n", error);
-- 
1.7.1




More information about the ffmpeg-devel mailing list