diff mbox series

[FFmpeg-devel,3/5] fftools/ffmpeg_demux: move InputStream.guess_layout_max to stack

Message ID 20230211074412.29495-3-anton@khirnov.net
State Accepted
Commit d9079f6700b022460e4492dc6f9e349741db0bdd
Headers show
Series [FFmpeg-devel,1/5] fftools/ffmpeg_demux: add an AVClass to Demuxer/InputFile | expand

Checks

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

Commit Message

Anton Khirnov Feb. 11, 2023, 7:44 a.m. UTC
It is only needed while processing the stream in add_input_streams(), no
reason to store it in the context.
---
 fftools/ffmpeg.h       |  1 -
 fftools/ffmpeg_demux.c | 13 +++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 2d48a147b8..66dda45f70 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -388,7 +388,6 @@  typedef struct InputStream {
     AVDictionary *decoder_opts;
     AVRational framerate;               /* framerate forced with -r */
     int top_field_first;
-    int guess_layout_max;
 
     int autorotate;
 
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index b6b6b21271..ac0431233e 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -552,14 +552,14 @@  static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s
     }
 }
 
-static int guess_input_channel_layout(InputStream *ist)
+static int guess_input_channel_layout(InputStream *ist, int guess_layout_max)
 {
     AVCodecContext *dec = ist->dec_ctx;
 
     if (dec->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) {
         char layout_name[256];
 
-        if (dec->ch_layout.nb_channels > ist->guess_layout_max)
+        if (dec->ch_layout.nb_channels > guess_layout_max)
             return 0;
         av_channel_layout_default(&dec->ch_layout, dec->ch_layout.nb_channels);
         if (dec->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)
@@ -800,11 +800,12 @@  static void add_input_streams(const OptionsContext *o, Demuxer *d)
             ist->framerate_guessed = av_guess_frame_rate(ic, st, NULL);
 
             break;
-        case AVMEDIA_TYPE_AUDIO:
-            ist->guess_layout_max = INT_MAX;
-            MATCH_PER_STREAM_OPT(guess_layout_max, i, ist->guess_layout_max, ic, st);
-            guess_input_channel_layout(ist);
+        case AVMEDIA_TYPE_AUDIO: {
+            int guess_layout_max = INT_MAX;
+            MATCH_PER_STREAM_OPT(guess_layout_max, i, guess_layout_max, ic, st);
+            guess_input_channel_layout(ist, guess_layout_max);
             break;
+        }
         case AVMEDIA_TYPE_DATA:
         case AVMEDIA_TYPE_SUBTITLE: {
             char *canvas_size = NULL;