Line data Source code
1 : /******************************************************************************************************
2 :
3 : (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
4 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
5 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
6 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
7 : contributors to this repository. All Rights Reserved.
8 :
9 : This software is protected by copyright law and by international treaties.
10 : The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
11 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
12 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
13 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
14 : contributors to this repository retain full ownership rights in their respective contributions in
15 : the software. This notice grants no license of any kind, including but not limited to patent
16 : license, nor is any license granted by implication, estoppel or otherwise.
17 :
18 : Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
19 : contributions.
20 :
21 : This software is provided "AS IS", without any express or implied warranties. The software is in the
22 : development stage. It is intended exclusively for experts who have experience with such software and
23 : solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
24 : and fitness for a particular purpose are hereby disclaimed and excluded.
25 :
26 : Any dispute, controversy or claim arising under or in relation to providing this software shall be
27 : submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
28 : accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
29 : the United Nations Convention on Contracts on the International Sales of Goods.
30 :
31 : *******************************************************************************************************/
32 :
33 : #include <assert.h>
34 : #include <stdint.h>
35 : #include "options.h"
36 : #include <math.h>
37 : #include "prot_fx.h"
38 : #include "wmc_auto.h"
39 : #include "ivas_prot_fx.h"
40 :
41 :
42 : /*---------------------------------------------------------------
43 : * ivas_mc_mode_select()
44 : *
45 : * selects the multichannel mode base on bitrate and LS setup
46 : * ---------------------------------------------------------------*/
47 :
48 : /*! r : MC format mode */
49 50598 : MC_MODE ivas_mc_mode_select_fx(
50 : const MC_LS_SETUP mc_ls_setup, /* i : MC loudspeaker setup */
51 : const Word32 total_brate /* i : IVAS total bitrate */
52 : )
53 : {
54 50598 : MC_MODE mc_mode = MC_MODE_MCT;
55 50598 : move32();
56 :
57 50598 : SWITCH( mc_ls_setup )
58 : {
59 44566 : case MC_LS_SETUP_5_1:
60 44566 : IF( LT_32( total_brate, IVAS_48k ) )
61 : {
62 10335 : mc_mode = MC_MODE_MCMASA;
63 10335 : move32();
64 : }
65 34231 : ELSE IF( LT_32( total_brate, IVAS_96k ) )
66 : {
67 10211 : mc_mode = MC_MODE_PARAMMC;
68 10211 : move32();
69 : }
70 44566 : BREAK;
71 677 : case MC_LS_SETUP_7_1:
72 677 : IF( LT_32( total_brate, IVAS_48k ) )
73 : {
74 164 : mc_mode = MC_MODE_MCMASA;
75 164 : move32();
76 : }
77 513 : ELSE IF( LT_32( total_brate, IVAS_128k ) )
78 : {
79 156 : mc_mode = MC_MODE_PARAMMC;
80 156 : move32();
81 : }
82 677 : BREAK;
83 948 : case MC_LS_SETUP_5_1_2:
84 948 : IF( LT_32( total_brate, IVAS_48k ) )
85 : {
86 252 : mc_mode = MC_MODE_MCMASA;
87 252 : move32();
88 : }
89 696 : ELSE IF( LT_32( total_brate, IVAS_128k ) )
90 : {
91 408 : mc_mode = MC_MODE_PARAMMC;
92 408 : move32();
93 : }
94 948 : BREAK;
95 926 : case MC_LS_SETUP_5_1_4:
96 926 : IF( LT_32( total_brate, IVAS_96k ) )
97 : {
98 258 : mc_mode = MC_MODE_MCMASA;
99 258 : move32();
100 : }
101 668 : ELSE IF( LT_32( total_brate, IVAS_160k ) )
102 : {
103 0 : mc_mode = MC_MODE_PARAMMC;
104 0 : move32();
105 : }
106 926 : BREAK;
107 3481 : case MC_LS_SETUP_7_1_4:
108 3481 : IF( LT_32( total_brate, IVAS_128k ) )
109 : {
110 1070 : mc_mode = MC_MODE_MCMASA;
111 1070 : move32();
112 : }
113 2411 : ELSE IF( LT_32( total_brate, IVAS_160k ) )
114 : {
115 107 : mc_mode = MC_MODE_PARAMMC;
116 107 : move32();
117 : }
118 2304 : ELSE IF( LT_32( total_brate, IVAS_192k ) )
119 : {
120 796 : mc_mode = MC_MODE_PARAMUPMIX;
121 796 : move32();
122 : }
123 3481 : BREAK;
124 0 : default:
125 0 : assert( 0 && "LS Setup not supported or defined for MC mode!\n" );
126 : }
127 :
128 50598 : return mc_mode;
129 : }
130 :
131 :
132 : /*---------------------------------------------------------------
133 : * ivas_mc_setup_get_num_channels()
134 : *
135 : * returns the number of channels (including the LFE) for a MC LS setup
136 : * ---------------------------------------------------------------*/
137 :
138 : /*! r : number of loudspeaker channels */
139 26432 : Word16 ivas_mc_ls_setup_get_num_channels_fx(
140 : const MC_LS_SETUP mc_ls_setup /* i : multi channel loudspeaker setup */
141 : )
142 : {
143 : Word16 nchan;
144 :
145 26432 : nchan = 0;
146 26432 : move16();
147 :
148 26432 : SWITCH( mc_ls_setup )
149 : {
150 23638 : case MC_LS_SETUP_5_1:
151 23638 : nchan = 6;
152 23638 : move16();
153 23638 : BREAK;
154 347 : case MC_LS_SETUP_7_1:
155 347 : nchan = 8;
156 347 : move16();
157 347 : break;
158 282 : case MC_LS_SETUP_5_1_2:
159 282 : nchan = 8;
160 282 : move16();
161 282 : BREAK;
162 669 : case MC_LS_SETUP_5_1_4:
163 669 : nchan = 10;
164 669 : move16();
165 669 : BREAK;
166 1496 : case MC_LS_SETUP_7_1_4:
167 1496 : nchan = 12;
168 1496 : move16();
169 1496 : BREAK;
170 0 : default:
171 0 : assert( 0 && "LS Setup not supported or defined for MC mode!\n" );
172 : }
173 :
174 26432 : return nchan;
175 : }
176 :
177 :
178 : /*---------------------------------------------------------------
179 : * ivas_mc_map_output_config_to_mc_ls_setup()
180 : *
181 : * maps output configuration multi channel loudspeaker setup
182 : * ---------------------------------------------------------------*/
183 :
184 : /*! r : multi channel loudspeaker setup */
185 99121 : MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup_fx(
186 : const AUDIO_CONFIG output_config /* i : output audio configuration */
187 : )
188 : {
189 : MC_LS_SETUP mc_ls_setup;
190 :
191 99121 : mc_ls_setup = MC_LS_SETUP_INVALID;
192 99121 : move32();
193 :
194 99121 : SWITCH( output_config )
195 : {
196 88102 : case IVAS_AUDIO_CONFIG_5_1:
197 88102 : mc_ls_setup = MC_LS_SETUP_5_1;
198 88102 : move32();
199 88102 : BREAK;
200 1305 : case IVAS_AUDIO_CONFIG_7_1:
201 1305 : mc_ls_setup = MC_LS_SETUP_7_1;
202 1305 : move32();
203 1305 : BREAK;
204 1865 : case IVAS_AUDIO_CONFIG_5_1_2:
205 1865 : mc_ls_setup = MC_LS_SETUP_5_1_2;
206 1865 : move32();
207 1865 : BREAK;
208 1835 : case IVAS_AUDIO_CONFIG_5_1_4:
209 1835 : mc_ls_setup = MC_LS_SETUP_5_1_4;
210 1835 : move32();
211 1835 : BREAK;
212 6014 : case IVAS_AUDIO_CONFIG_7_1_4:
213 6014 : mc_ls_setup = MC_LS_SETUP_7_1_4;
214 6014 : move32();
215 6014 : BREAK;
216 0 : default:
217 0 : assert( 0 && "Output config is not a valid MC loudspeaker setup!\n" );
218 : }
219 :
220 99121 : return mc_ls_setup;
221 : }
222 :
223 :
224 : /*---------------------------------------------------------------
225 : * ivas_mc_map_ls_setup_to_output_config
226 : *
227 : * maps multi channel loudspeaker setup to audio configuration
228 : * ---------------------------------------------------------------*/
229 :
230 : /*! r: audio configuration*/
231 48468 : AUDIO_CONFIG ivas_mc_map_ls_setup_to_output_config_fx(
232 : const MC_LS_SETUP mc_ls_setup /* i : multi channel loudspeaker setup*/
233 : )
234 : {
235 : AUDIO_CONFIG audio_config;
236 48468 : audio_config = IVAS_AUDIO_CONFIG_INVALID;
237 48468 : move32();
238 :
239 48468 : SWITCH( mc_ls_setup )
240 : {
241 42798 : case MC_LS_SETUP_5_1:
242 42798 : audio_config = IVAS_AUDIO_CONFIG_5_1;
243 42798 : move32();
244 42798 : BREAK;
245 597 : case MC_LS_SETUP_7_1:
246 597 : audio_config = IVAS_AUDIO_CONFIG_7_1;
247 597 : move32();
248 597 : BREAK;
249 894 : case MC_LS_SETUP_5_1_2:
250 894 : audio_config = IVAS_AUDIO_CONFIG_5_1_2;
251 894 : move32();
252 894 : BREAK;
253 900 : case MC_LS_SETUP_5_1_4:
254 900 : audio_config = IVAS_AUDIO_CONFIG_5_1_4;
255 900 : move32();
256 900 : BREAK;
257 3279 : case MC_LS_SETUP_7_1_4:
258 3279 : audio_config = IVAS_AUDIO_CONFIG_7_1_4;
259 3279 : move32();
260 3279 : BREAK;
261 0 : default:
262 0 : assert( 0 && "MC loudspeaker setup is not valid!\n" );
263 : }
264 :
265 48468 : return audio_config;
266 : }
|