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 <stdint.h>
34 : #include "options.h"
35 : #include "ivas_cnst.h"
36 : #include "ivas_rom_com.h"
37 : #include "ivas_stat_dec.h"
38 : #include "wmc_auto.h"
39 : #include "prot_fx.h"
40 : #include "ivas_rom_com_fx.h"
41 : #include "ivas_prot_fx.h"
42 :
43 :
44 : /*-------------------------------------------------------------------*
45 : * deindex_elevation()
46 : *
47 : * Decode elevation index
48 : *----------------------------------------------------------------------*/
49 :
50 : /*! r: decoded elevation value */
51 :
52 1621497 : Word32 deindex_elevation_fx(
53 : UWord16 *id_th, /* i : input index Q0*/
54 : const Word16 no_bits, /* i : number of bits for the spherical grid Q0*/
55 : const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */
56 : )
57 : {
58 : Word32 theta_hat_fx;
59 1621497 : Word16 q_id_th = sub( norm_l( *id_th ), 1 );
60 1621497 : Word32 id_th_fx = L_shl( *id_th, q_id_th ); /*q_id_th*/
61 :
62 1621497 : IF( EQ_32( *id_th, MASA_NO_INDEX ) )
63 : {
64 0 : theta_hat_fx = 0;
65 0 : move32();
66 : }
67 : ELSE
68 : {
69 1621497 : IF( NE_32( mc_format, MC_LS_SETUP_INVALID ) )
70 : {
71 42668 : theta_hat_fx = L_shl( Mpy_32_32( id_th_fx, delta_theta_masa_fx[( no_bits - 3 )] ), sub( 31, q_id_th ) ); /*Q22*/
72 42668 : IF( GT_32( theta_hat_fx, L_shl( 90, Q22 ) ) )
73 : {
74 63 : theta_hat_fx = 90 * ONE_IN_Q22;
75 63 : move32();
76 : }
77 : }
78 : ELSE
79 : {
80 1578829 : IF( L_and( *id_th, 1 ) == 0 )
81 : {
82 : /* theta is negative */
83 1308711 : *id_th = (UWord16) L_shr( *id_th, 1 ); /* *id_th / 2 */ /*Q0*/
84 1308711 : move16();
85 1308711 : id_th_fx = L_shr( id_th_fx, 1 ); /*q_id_th*/
86 1308711 : theta_hat_fx = L_negate( L_shl( Mpy_32_32( id_th_fx, delta_theta_masa_fx[( no_bits - 3 )] ), sub( 31, q_id_th ) ) ); /*Q22*/
87 1308711 : IF( LT_32( theta_hat_fx, -90 * ONE_IN_Q22 ) )
88 : {
89 251 : theta_hat_fx = -90 * ONE_IN_Q22;
90 251 : move32();
91 : }
92 : }
93 : ELSE
94 : {
95 270118 : *id_th = (UWord16) L_shr( L_add( *id_th, 1 ), 1 ); /* ( *id_th + 1 ) / 2 */ /*Q0*/
96 270118 : move16();
97 270118 : id_th_fx = L_shr( L_add( id_th_fx, L_shl( 1, q_id_th ) ), 1 ); /*q_id_th*/
98 270118 : theta_hat_fx = L_shl( Mpy_32_32( id_th_fx, delta_theta_masa_fx[( no_bits - 3 )] ), sub( 31, q_id_th ) ); /*Q22*/
99 270118 : IF( GT_32( theta_hat_fx, 90 * ONE_IN_Q22 ) )
100 : {
101 74 : theta_hat_fx = 90 * ONE_IN_Q22;
102 74 : move32();
103 : }
104 : }
105 : }
106 : }
107 :
108 1621497 : return theta_hat_fx; /*Q22*/
109 : }
|