codec: avcodec: fix audio channel_layout conditionals
authorFrançois Cartegnie <fcvlcdev@free.fr>
Sat, 17 Aug 2024 04:22:33 +0000 (11:22 +0700)
committerSebastian Ramacher <sramacher@debian.org>
Tue, 21 Jan 2025 18:02:47 +0000 (19:02 +0100)
Gbp-Pq: Name 0071-codec-avcodec-fix-audio-channel_layout-conditionals.patch

modules/codec/avcodec/audio.c

index ad8a40ab4ed66ef465108fdf54701bae666136d0..c74757c76ae5f7050967782079032dcc80230cd5 100644 (file)
 #include <libavcodec/avcodec.h>
 #include <libavutil/mem.h>
 
-#include <libavutil/channel_layout.h>
+#define API_CHANNEL_LAYOUT (LIBAVUTIL_VERSION_CHECK( 52, 2, 6, 0, 100))
 
+#if API_CHANNEL_LAYOUT
+# include <libavutil/channel_layout.h>
+#endif
 
 /*****************************************************************************
  * decoder_sys_t : decoder descriptor
@@ -598,7 +601,7 @@ static void SetupOutputFormat( decoder_t *p_dec, bool b_trust )
         p_sys->i_previous_channels = p_sys->p_context->ch_layout.nb_channels;
         p_sys->i_previous_layout = p_sys->p_context->ch_layout.u.mask;
     }
-#else
+#elif API_CHANNEL_LAYOUT
     if( p_sys->i_previous_channels == p_sys->p_context->channels &&
         p_sys->i_previous_layout == p_sys->p_context->channel_layout )
         return;
@@ -612,15 +615,19 @@ static void SetupOutputFormat( decoder_t *p_dec, bool b_trust )
     const unsigned i_order_max = sizeof(pi_channels_map)/sizeof(*pi_channels_map);
     uint32_t pi_order_src[i_order_max];
 
-    int i_channels_src = 0;
+    int i_channels_src = 0, channel_count;
+    uint64_t channel_layout_mask;
 #if LIBAVCODEC_VERSION_CHECK(59, 999, 999, 24, 100)
-    uint64_t channel_layout_mask = p_sys->p_context->ch_layout.u.mask;
-    int channel_count = p_sys->p_context->ch_layout.nb_channels;
-#else
-    uint64_t channel_layout_mask =
+    channel_layout_mask = p_sys->p_context->ch_layout.u.mask;
+    channel_count = p_sys->p_context->ch_layout.nb_channels;
+#elif API_CHANNEL_LAYOUT
+    channel_layout_mask =
         p_sys->p_context->channel_layout ? p_sys->p_context->channel_layout :
         (uint64_t)av_get_default_channel_layout( p_sys->p_context->channels );
-    int channel_count = p_sys->p_context->channels;
+    channel_count = p_sys->p_context->channels;
+#else
+    channel_layout_mask = NULL;
+    channel_count = p_sys->p_context->channels;
 #endif
 
     if( channel_layout_mask )