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 93473 : 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 93473 : MC_MODE mc_mode = MC_MODE_MCT;
55 93473 : move32();
56 :
57 93473 : SWITCH( mc_ls_setup )
58 : {
59 82461 : case MC_LS_SETUP_5_1:
60 82461 : IF( LT_32( total_brate, IVAS_48k ) )
61 : {
62 18904 : mc_mode = MC_MODE_MCMASA;
63 18904 : move32();
64 : }
65 63557 : ELSE IF( LT_32( total_brate, IVAS_96k ) )
66 : {
67 18243 : mc_mode = MC_MODE_PARAMMC;
68 18243 : move32();
69 : }
70 82461 : BREAK;
71 931 : case MC_LS_SETUP_7_1:
72 931 : IF( LT_32( total_brate, IVAS_48k ) )
73 : {
74 216 : mc_mode = MC_MODE_MCMASA;
75 216 : move32();
76 : }
77 715 : ELSE IF( LT_32( total_brate, IVAS_128k ) )
78 : {
79 166 : mc_mode = MC_MODE_PARAMMC;
80 166 : move32();
81 : }
82 931 : BREAK;
83 1677 : case MC_LS_SETUP_5_1_2:
84 1677 : IF( LT_32( total_brate, IVAS_48k ) )
85 : {
86 460 : mc_mode = MC_MODE_MCMASA;
87 460 : move32();
88 : }
89 1217 : ELSE IF( LT_32( total_brate, IVAS_128k ) )
90 : {
91 728 : mc_mode = MC_MODE_PARAMMC;
92 728 : move32();
93 : }
94 1677 : BREAK;
95 1657 : case MC_LS_SETUP_5_1_4:
96 1657 : IF( LT_32( total_brate, IVAS_96k ) )
97 : {
98 393 : mc_mode = MC_MODE_MCMASA;
99 393 : move32();
100 : }
101 1264 : ELSE IF( LT_32( total_brate, IVAS_160k ) )
102 : {
103 0 : mc_mode = MC_MODE_PARAMMC;
104 0 : move32();
105 : }
106 1657 : BREAK;
107 6747 : case MC_LS_SETUP_7_1_4:
108 6747 : IF( LT_32( total_brate, IVAS_128k ) )
109 : {
110 2004 : mc_mode = MC_MODE_MCMASA;
111 2004 : move32();
112 : }
113 4743 : ELSE IF( LT_32( total_brate, IVAS_160k ) )
114 : {
115 159 : mc_mode = MC_MODE_PARAMMC;
116 159 : move32();
117 : }
118 4584 : ELSE IF( LT_32( total_brate, IVAS_192k ) )
119 : {
120 1579 : mc_mode = MC_MODE_PARAMUPMIX;
121 1579 : move32();
122 : }
123 6747 : BREAK;
124 0 : default:
125 0 : assert( 0 && "LS Setup not supported or defined for MC mode!\n" );
126 : }
127 :
128 93473 : 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 25154 : 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 25154 : nchan = 0;
146 25154 : move16();
147 :
148 25154 : SWITCH( mc_ls_setup )
149 : {
150 22544 : case MC_LS_SETUP_5_1:
151 22544 : nchan = 6;
152 22544 : move16();
153 22544 : BREAK;
154 238 : case MC_LS_SETUP_7_1:
155 238 : nchan = 8;
156 238 : move16();
157 238 : break;
158 234 : case MC_LS_SETUP_5_1_2:
159 234 : nchan = 8;
160 234 : move16();
161 234 : BREAK;
162 619 : case MC_LS_SETUP_5_1_4:
163 619 : nchan = 10;
164 619 : move16();
165 619 : BREAK;
166 1519 : case MC_LS_SETUP_7_1_4:
167 1519 : nchan = 12;
168 1519 : move16();
169 1519 : BREAK;
170 0 : default:
171 0 : assert( 0 && "LS Setup not supported or defined for MC mode!\n" );
172 : }
173 :
174 25154 : 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 89237 : 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 89237 : mc_ls_setup = MC_LS_SETUP_INVALID;
192 89237 : move32();
193 :
194 89237 : SWITCH( output_config )
195 : {
196 79913 : case IVAS_AUDIO_CONFIG_5_1:
197 79913 : mc_ls_setup = MC_LS_SETUP_5_1;
198 79913 : move32();
199 79913 : BREAK;
200 636 : case IVAS_AUDIO_CONFIG_7_1:
201 636 : mc_ls_setup = MC_LS_SETUP_7_1;
202 636 : move32();
203 636 : BREAK;
204 1526 : case IVAS_AUDIO_CONFIG_5_1_2:
205 1526 : mc_ls_setup = MC_LS_SETUP_5_1_2;
206 1526 : move32();
207 1526 : BREAK;
208 1505 : case IVAS_AUDIO_CONFIG_5_1_4:
209 1505 : mc_ls_setup = MC_LS_SETUP_5_1_4;
210 1505 : move32();
211 1505 : BREAK;
212 5657 : case IVAS_AUDIO_CONFIG_7_1_4:
213 5657 : mc_ls_setup = MC_LS_SETUP_7_1_4;
214 5657 : move32();
215 5657 : BREAK;
216 0 : default:
217 0 : assert( 0 && "Output config is not a valid MC loudspeaker setup!\n" );
218 : }
219 :
220 89237 : 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 43754 : 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 43754 : audio_config = IVAS_AUDIO_CONFIG_INVALID;
237 43754 : move32();
238 :
239 43754 : SWITCH( mc_ls_setup )
240 : {
241 38827 : case MC_LS_SETUP_5_1:
242 38827 : audio_config = IVAS_AUDIO_CONFIG_5_1;
243 38827 : move32();
244 38827 : BREAK;
245 301 : case MC_LS_SETUP_7_1:
246 301 : audio_config = IVAS_AUDIO_CONFIG_7_1;
247 301 : move32();
248 301 : BREAK;
249 745 : case MC_LS_SETUP_5_1_2:
250 745 : audio_config = IVAS_AUDIO_CONFIG_5_1_2;
251 745 : move32();
252 745 : BREAK;
253 751 : case MC_LS_SETUP_5_1_4:
254 751 : audio_config = IVAS_AUDIO_CONFIG_5_1_4;
255 751 : move32();
256 751 : BREAK;
257 3130 : case MC_LS_SETUP_7_1_4:
258 3130 : audio_config = IVAS_AUDIO_CONFIG_7_1_4;
259 3130 : move32();
260 3130 : BREAK;
261 0 : default:
262 0 : assert( 0 && "MC loudspeaker setup is not valid!\n" );
263 : }
264 :
265 43754 : return audio_config;
266 : }
|