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