diff mbox series

[FFmpeg-devel,18/20] fftools/ffmpeg_mux_init: stop modifying OptionsContext.*_disable

Message ID 20221018123701.25002-18-anton@khirnov.net
State Accepted
Commit 0d821edb40d27848304a7354b1c64c2e30e00e7d
Headers show
Series [FFmpeg-devel,01/20] fftools/ffmpeg_opt: move opening input files to ffmpeg_demux.c | 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 Oct. 18, 2022, 12:36 p.m. UTC
The current code will override the *_disable fields (set by -vn/-an
options) when creating output streams for unlabeled complex filtergraph
outputs, in order to disable automatic mapping for the corresponding
media type.

However, this will apply not only to automatic mappings, but to manual
ones as well, which should not happen. Avoid this by adding local
variables that are used only for automatic mappings.
---
 fftools/ffmpeg_mux_init.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 6687ba872a..7c19cb7442 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1064,6 +1064,11 @@  loop_end:
 
 static void create_streams(Muxer *mux, OptionsContext *o)
 {
+    int auto_disable_v = o->video_disable;
+    int auto_disable_a = o->audio_disable;
+    int auto_disable_s = o->subtitle_disable;
+    int auto_disable_d = o->data_disable;
+
     /* create streams for all unlabeled output pads */
     for (int i = 0; i < nb_filtergraphs; i++) {
         FilterGraph *fg = filtergraphs[i];
@@ -1074,9 +1079,9 @@  static void create_streams(Muxer *mux, OptionsContext *o)
                 continue;
 
             switch (ofilter->type) {
-            case AVMEDIA_TYPE_VIDEO:    o->video_disable    = 1; break;
-            case AVMEDIA_TYPE_AUDIO:    o->audio_disable    = 1; break;
-            case AVMEDIA_TYPE_SUBTITLE: o->subtitle_disable = 1; break;
+            case AVMEDIA_TYPE_VIDEO:    auto_disable_v = 1; break;
+            case AVMEDIA_TYPE_AUDIO:    auto_disable_a = 1; break;
+            case AVMEDIA_TYPE_SUBTITLE: auto_disable_s = 1; break;
             }
             init_output_filter(ofilter, o, mux);
         }
@@ -1084,13 +1089,13 @@  static void create_streams(Muxer *mux, OptionsContext *o)
 
     if (!o->nb_stream_maps) {
         /* pick the "best" stream of each type */
-        if (!o->video_disable)
+        if (!auto_disable_v)
             map_auto_video(mux, o);
-        if (!o->audio_disable)
+        if (!auto_disable_a)
             map_auto_audio(mux, o);
-        if (!o->subtitle_disable)
+        if (!auto_disable_s)
             map_auto_subtitle(mux, o);
-        if (!o->data_disable)
+        if (!auto_disable_d)
             map_auto_data(mux, o);
     } else {
         for (int i = 0; i < o->nb_stream_maps; i++)