Line data Source code
1 :
2 : #include "ivas_prot_fx.h"
3 : #include "ivas_prot_rend_fx.h"
4 : #include <string.h>
5 :
6 2739205 : Word16 ivas_get_nchan_buffers_dec_ivas_fx(
7 : Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
8 : const Word16 sba_analysis_order, /* i : SBA order evaluated in SBA decoder */
9 : const Word32 ivas_total_brate /* i : total IVAS bitrate */
10 : )
11 : {
12 : Word16 nchan_out_buff;
13 : AUDIO_CONFIG output_config;
14 :
15 2739205 : output_config = st_ivas->hDecoderConfig->output_config;
16 2739205 : move16();
17 :
18 2739205 : nchan_out_buff = MAX_OUTPUT_CHANNELS;
19 2739205 : move16();
20 :
21 2739205 : IF( EQ_16( st_ivas->ivas_format, MONO_FORMAT ) )
22 : {
23 0 : nchan_out_buff = st_ivas->hDecoderConfig->nchan_out;
24 0 : move16();
25 : }
26 2739205 : ELSE IF( EQ_16( st_ivas->ivas_format, STEREO_FORMAT ) )
27 : {
28 207708 : nchan_out_buff = s_max( st_ivas->hDecoderConfig->nchan_out, CPE_CHANNELS );
29 : }
30 2531497 : ELSE IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) )
31 : {
32 550555 : nchan_out_buff = st_ivas->nchan_ism;
33 550555 : move16();
34 :
35 550555 : IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
36 : {
37 25500 : nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
38 : }
39 525055 : ELSE IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
40 : {
41 451117 : nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) );
42 451117 : nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
43 : }
44 : }
45 1980942 : ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) )
46 : {
47 : Word16 nchan_internal;
48 986328 : nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate );
49 986328 : nchan_out_buff = st_ivas->hDecoderConfig->nchan_out;
50 986328 : move16();
51 :
52 986328 : IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
53 : {
54 17000 : nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
55 : }
56 : ELSE
57 : {
58 969328 : nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) );
59 969328 : nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
60 : }
61 986328 : nchan_out_buff = s_max( nchan_out_buff, nchan_internal );
62 : }
63 994614 : ELSE IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) )
64 : {
65 147462 : nchan_out_buff = CPE_CHANNELS;
66 147462 : move16();
67 :
68 147462 : test();
69 147462 : test();
70 147462 : test();
71 147462 : IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
72 : {
73 0 : nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
74 : }
75 147462 : ELSE IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
76 : {
77 54736 : nchan_out_buff = shl( CPE_CHANNELS, 1 );
78 54736 : move16();
79 : }
80 92726 : ELSE IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
81 : {
82 81614 : nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) );
83 81614 : nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
84 : }
85 : }
86 847152 : ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
87 : {
88 43538 : nchan_out_buff = add( st_ivas->nchan_ism, CPE_CHANNELS );
89 :
90 43538 : IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
91 : {
92 0 : nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
93 : }
94 43538 : ELSE IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
95 : {
96 41288 : nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) );
97 41288 : nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
98 : }
99 : }
100 803614 : ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
101 : {
102 : Word16 nchan_internal;
103 413580 : nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate );
104 413580 : nchan_out_buff = add( st_ivas->nchan_ism, st_ivas->nchan_transport );
105 :
106 413580 : IF( st_ivas->hMCT != NULL )
107 : {
108 316620 : nchan_out_buff = shl( shr( add( nchan_out_buff, 1 ), 1 ), 1 ); /* ensure odd number of channels in MCT */
109 : }
110 :
111 413580 : IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
112 : {
113 0 : nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
114 : }
115 413580 : ELSE IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
116 : {
117 352580 : nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) );
118 352580 : nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
119 :
120 352580 : move16();
121 352580 : IF( EQ_16( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_16( st_ivas->renderer_type, RENDERER_OSBA_LS ) )
122 : {
123 30000 : nchan_out_buff = s_max( add( nchan_out_buff, st_ivas->nchan_ism ), audioCfg2channels( output_config ) ); /* needed for ivas_sba_upmixer_renderer() */
124 : }
125 : ELSE
126 : {
127 322580 : nchan_out_buff = s_max( add( nchan_out_buff, st_ivas->nchan_ism ), audioCfg2channels( output_config ) ); /* needed for ivas_spar_dec_upmixer_sf() which is based on 'nchan_out' */
128 : }
129 : }
130 61000 : ELSE IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
131 : {
132 61000 : nchan_out_buff = add( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_ism ); /*take into account sba_ch_idx' in ivas_dec() */
133 : }
134 :
135 413580 : test();
136 413580 : IF( !( EQ_16( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) )
137 : {
138 362050 : nchan_out_buff = s_max( nchan_out_buff, add( nchan_internal, st_ivas->nchan_ism ) );
139 : }
140 413580 : nchan_out_buff = s_min( nchan_out_buff, MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS );
141 : }
142 390034 : ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) )
143 : {
144 390034 : nchan_out_buff = st_ivas->hDecoderConfig->nchan_out;
145 390034 : move16();
146 :
147 390034 : IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
148 : {
149 17000 : nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
150 : }
151 : ELSE
152 : {
153 373034 : nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) );
154 373034 : nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
155 : }
156 : }
157 :
158 :
159 2739205 : return nchan_out_buff;
160 : }
161 :
162 : /*---------------------------------------------------------------------*
163 : * get_channel_config()
164 : *
165 : * Gets a str related to audio configuration
166 : *---------------------------------------------------------------------*/
167 :
168 1980 : ivas_error get_channel_config(
169 : const AUDIO_CONFIG config, /* i : audio configuration */
170 : Word8 *str /* o : string with the configuration name */
171 : )
172 : {
173 1980 : IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_MONO ) )
174 : {
175 114 : strcpy( (char *) str, "Mono" );
176 : }
177 1866 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_STEREO ) )
178 : {
179 171 : strcpy( (char *) str, "Stereo" );
180 : }
181 1695 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_ISM1 ) )
182 : {
183 37 : strcpy( (char *) str, "Object-based audio (1 object)" );
184 : }
185 1658 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_ISM2 ) )
186 : {
187 72 : strcpy( (char *) str, "Object-based audio (2 objects)" );
188 : }
189 1586 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_ISM3 ) )
190 : {
191 32 : strcpy( (char *) str, "Object-based audio (3 objects)" );
192 : }
193 1554 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_ISM4 ) )
194 : {
195 33 : strcpy( (char *) str, "Object-based audio (4 objects)" );
196 : }
197 1521 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_5_1 ) )
198 : {
199 97 : strcpy( (char *) str, "Multichannel 5.1 (CICP6)" );
200 : }
201 1424 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_7_1 ) )
202 : {
203 83 : strcpy( (char *) str, "Multichannel 7.1 (CICP12)" );
204 : }
205 1341 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_5_1_2 ) )
206 : {
207 81 : strcpy( (char *) str, "Multichannel 5.1+2 (CICP14)" );
208 : }
209 1260 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_5_1_4 ) )
210 : {
211 101 : strcpy( (char *) str, "Multichannel 5.1+4 (CICP16)" );
212 : }
213 1159 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_7_1_4 ) )
214 : {
215 92 : strcpy( (char *) str, "Multichannel 7.1+4 (CICP19)" );
216 : }
217 1067 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
218 : {
219 147 : strcpy( (char *) str, "Multichannel (custom loudspeaker layout)" );
220 : }
221 920 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_MASA1 ) )
222 : {
223 24 : strcpy( (char *) str, "Metadata-Assisted Spatial Audio mono (MASA1)" );
224 : }
225 896 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_MASA2 ) )
226 : {
227 26 : strcpy( (char *) str, "Metadata-Assisted Spatial Audio stereo (MASA2)" );
228 : }
229 870 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_FOA ) )
230 : {
231 261 : strcpy( (char *) str, "Ambisonics: First Order (FOA)" );
232 : }
233 609 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_HOA2 ) )
234 : {
235 84 : strcpy( (char *) str, "Ambisonics: Second Order (HOA2)" );
236 : }
237 525 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_HOA3 ) )
238 : {
239 94 : strcpy( (char *) str, "Ambisonics: Third Order (HOA3)" );
240 : }
241 431 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_BINAURAL ) )
242 : {
243 159 : strcpy( (char *) str, "Binaural: no room" );
244 : }
245 272 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) )
246 : {
247 115 : strcpy( (char *) str, "Binaural: room with impulse responses" );
248 : }
249 157 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
250 : {
251 107 : strcpy( (char *) str, "Binaural: room with reverb" );
252 : }
253 50 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) )
254 : {
255 0 : strcpy( (char *) str, "BINAURAL_SPLIT_CODED" );
256 : }
257 50 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
258 : {
259 0 : strcpy( (char *) str, "Binaural_Split_PCM" );
260 : }
261 50 : ELSE IF( EQ_16( (Word16) config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
262 : {
263 50 : strcpy( (char *) str, "External renderer" );
264 : }
265 : ELSE
266 : {
267 0 : return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Error: Incorrect Input/Output Configuration" );
268 : }
269 :
270 1980 : return IVAS_ERR_OK;
271 : }
|