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 : /*====================================================================================
34 : EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
35 : ====================================================================================*/
36 :
37 : #include <stdint.h>
38 : #include "options.h"
39 : #include "cnst.h"
40 : #include "rom_com.h"
41 : #include "prot.h"
42 : #include "stat_com.h"
43 : #include "wmc_auto.h"
44 :
45 :
46 : /*---------------------------------------------------------------------*
47 : * ReadTnsData()
48 : *
49 : *
50 : *---------------------------------------------------------------------*/
51 :
52 2390448 : void ReadTnsData(
53 : STnsConfig const *pTnsConfig,
54 : Decoder_State *st,
55 : int16_t *pnBits,
56 : int16_t *stream,
57 : int16_t *pnSize )
58 : {
59 : int16_t start_bit_pos;
60 :
61 2390448 : start_bit_pos = st->next_bit_pos;
62 2390448 : if ( pTnsConfig->nMaxFilters > 1 )
63 : {
64 2085003 : if ( pTnsConfig->allowTnsOnWhite )
65 : {
66 1742646 : if ( pTnsConfig->iFilterBorders[0] < 512 )
67 : {
68 85608 : ReadFromBitstream( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, st, &stream, pnSize );
69 : }
70 : else
71 : {
72 1657038 : ReadFromBitstream( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, st, &stream, pnSize );
73 : }
74 : }
75 : else
76 : {
77 342357 : if ( pTnsConfig->iFilterBorders[0] < 512 )
78 : {
79 12222 : ReadFromBitstream( &tnsEnabledSWBTCX10BitMap, 1, st, &stream, pnSize );
80 : }
81 : else
82 : {
83 330135 : ReadFromBitstream( &tnsEnabledSWBTCX20BitMap, 1, st, &stream, pnSize );
84 : }
85 : }
86 : }
87 : else
88 : {
89 305445 : ReadFromBitstream( &tnsEnabledWBTCX20BitMap, 1, st, &stream, pnSize );
90 : }
91 :
92 2390448 : *pnBits = st->next_bit_pos - start_bit_pos;
93 :
94 2390448 : return;
95 : }
96 :
97 :
98 : /*---------------------------------------------------------------------*
99 : * DecodeTnsData()
100 : *
101 : *
102 : *---------------------------------------------------------------------*/
103 :
104 2398068 : int16_t DecodeTnsData(
105 : STnsConfig const *pTnsConfig,
106 : const int16_t *stream,
107 : int16_t *pnSize,
108 : STnsData *pTnsData )
109 : {
110 2398068 : ResetTnsData( pTnsData );
111 :
112 2398068 : if ( pTnsConfig->nMaxFilters > 1 )
113 : {
114 2092443 : if ( pTnsConfig->allowTnsOnWhite )
115 : {
116 1750086 : if ( pTnsConfig->iFilterBorders[0] < 512 )
117 : {
118 87018 : SetParameters( &tnsEnabledOnWhiteSWBTCX10BitMap, 1, pTnsData, &stream, pnSize );
119 : }
120 : else
121 : {
122 1663068 : SetParameters( &tnsEnabledOnWhiteSWBTCX20BitMap, 1, pTnsData, &stream, pnSize );
123 : }
124 : }
125 : else
126 : {
127 342357 : if ( pTnsConfig->iFilterBorders[0] < 512 )
128 : {
129 12222 : SetParameters( &tnsEnabledSWBTCX10BitMap, 1, pTnsData, &stream, pnSize );
130 : }
131 : else
132 : {
133 330135 : SetParameters( &tnsEnabledSWBTCX20BitMap, 1, pTnsData, &stream, pnSize );
134 : }
135 : }
136 : }
137 : else
138 : {
139 305625 : SetParameters( &tnsEnabledWBTCX20BitMap, 1, pTnsData, &stream, pnSize );
140 : }
141 :
142 2398068 : return ( pTnsData->nFilters > 0 ) ? TRUE : FALSE;
143 : }
|