File: 0090-avcodec-audio-make-channel-mapping-array-0-terminate.patch

package info (click to toggle)
vlc 3.0.21-10
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 212,728 kB
  • sloc: ansic: 441,379; cpp: 110,628; objc: 36,394; sh: 6,947; makefile: 6,592; javascript: 4,902; xml: 1,611; asm: 1,355; yacc: 640; python: 555; lex: 88; perl: 77; sed: 16
file content (45 lines) | stat: -rw-r--r-- 1,604 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From: Ilkka Ollakka <ileoo@videolan.org>
Date: Wed, 5 Jul 2023 15:09:57 +0300
Subject: avcodec/audio: make channel mapping array 0 terminated

Also change pi_channels_src to be only AOUT_CHAN_MAX instead of same
size as mapping array.

(cherry picked from commit 0ff86bf8a28a080340f600cb8561815fc43e3b4a) (rebased)
rebased:
- the code around is slightly different
---
 modules/codec/avcodec/audio.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index 2074401..04c5401 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -585,6 +585,7 @@ static const uint64_t pi_channels_map[][2] =
     { AV_CH_TOP_BACK_RIGHT,    0 },
     { AV_CH_STEREO_LEFT,       0 },
     { AV_CH_STEREO_RIGHT,      0 },
+    { 0, 0 },
 };
 
 static void SetupOutputFormat( decoder_t *p_dec, bool b_trust )
@@ -617,8 +618,7 @@ static void SetupOutputFormat( decoder_t *p_dec, bool b_trust )
     }
 #endif
 
-    const unsigned i_order_max = sizeof(pi_channels_map)/sizeof(*pi_channels_map);
-    uint32_t pi_order_src[i_order_max];
+    uint32_t pi_order_src[AOUT_CHAN_MAX] = { 0 };
 
     int i_channels_src = 0, channel_count;
     uint64_t channel_layout_mask;
@@ -637,7 +637,7 @@ static void SetupOutputFormat( decoder_t *p_dec, bool b_trust )
 
     if( channel_layout_mask )
     {
-        for( unsigned i = 0; i < i_order_max
+        for( unsigned i = 0; pi_channels_map[i][0]
          && i_channels_src < channel_count; i++ )
         {
             if( channel_layout_mask & pi_channels_map[i][0] )