• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *                                                                            *
3  * Copyright (C) 2018 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *****************************************************************************
18  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19 */
20 #include <math.h>
21 #include <string.h>
22 #include <ixheaacd_type_def.h>
23 #include "ixheaacd_constants.h"
24 #include <ixheaacd_basic_ops32.h>
25 #include <ixheaacd_basic_ops16.h>
26 #include <ixheaacd_basic_ops40.h>
27 #include "ixheaacd_bitbuffer.h"
28 #include "ixheaacd_interface.h"
29 
30 #include "ixheaacd_tns_usac.h"
31 #include "ixheaacd_cnst.h"
32 
33 #include "ixheaacd_acelp_info.h"
34 
35 #include "ixheaacd_sbrdecsettings.h"
36 #include "ixheaacd_info.h"
37 #include "ixheaacd_sbr_common.h"
38 #include "ixheaacd_drc_data_struct.h"
39 #include "ixheaacd_drc_dec.h"
40 #include "ixheaacd_sbrdecoder.h"
41 #include "ixheaacd_mps_polyphase.h"
42 #include "ixheaacd_sbr_const.h"
43 #include "ixheaacd_main.h"
44 #include "ixheaacd_arith_dec.h"
45 
46 #include "ixheaacd_bit_extract.h"
47 
48 #include "ixheaacd_error_codes.h"
49 
50 #define ARITH_ESCAPE 16
51 
52 UWORD16 ixheaacd_ari_cf_r[3][4] = {
53     {12571, 10569, 3696, 0}, {12661, 5700, 3751, 0}, {10827, 6884, 2929, 0}};
54 
55 static UWORD16 ixheaacd_ari_lookup_m[742] = {
56     0x01, 0x34, 0x0D, 0x13, 0x12, 0x25, 0x00, 0x3A, 0x05, 0x00, 0x21, 0x13,
57     0x1F, 0x1A, 0x1D, 0x36, 0x24, 0x2B, 0x1B, 0x33, 0x37, 0x29, 0x1D, 0x33,
58     0x37, 0x33, 0x37, 0x33, 0x37, 0x33, 0x2C, 0x00, 0x21, 0x13, 0x25, 0x2A,
59     0x00, 0x21, 0x24, 0x12, 0x2C, 0x1E, 0x37, 0x24, 0x1F, 0x35, 0x37, 0x24,
60     0x35, 0x37, 0x35, 0x37, 0x38, 0x2D, 0x21, 0x29, 0x1E, 0x21, 0x13, 0x2D,
61     0x36, 0x38, 0x29, 0x36, 0x37, 0x24, 0x36, 0x38, 0x37, 0x38, 0x00, 0x20,
62     0x23, 0x20, 0x23, 0x36, 0x38, 0x24, 0x3B, 0x24, 0x26, 0x29, 0x1F, 0x30,
63     0x2D, 0x0D, 0x12, 0x3F, 0x2D, 0x21, 0x1C, 0x2A, 0x00, 0x21, 0x12, 0x1E,
64     0x36, 0x38, 0x36, 0x37, 0x3F, 0x1E, 0x0D, 0x1F, 0x2A, 0x1E, 0x21, 0x24,
65     0x12, 0x2A, 0x3C, 0x21, 0x24, 0x1F, 0x3C, 0x21, 0x29, 0x36, 0x38, 0x36,
66     0x37, 0x38, 0x21, 0x1E, 0x00, 0x3B, 0x25, 0x1E, 0x20, 0x10, 0x1F, 0x3C,
67     0x20, 0x23, 0x29, 0x08, 0x23, 0x12, 0x08, 0x23, 0x21, 0x38, 0x00, 0x20,
68     0x13, 0x20, 0x3B, 0x1C, 0x20, 0x3B, 0x29, 0x20, 0x23, 0x24, 0x21, 0x24,
69     0x21, 0x24, 0x3B, 0x13, 0x23, 0x26, 0x23, 0x13, 0x21, 0x24, 0x26, 0x29,
70     0x12, 0x22, 0x2B, 0x02, 0x1E, 0x0D, 0x1F, 0x2D, 0x00, 0x0D, 0x12, 0x00,
71     0x3C, 0x21, 0x29, 0x3C, 0x21, 0x2A, 0x3C, 0x3B, 0x22, 0x1E, 0x20, 0x10,
72     0x1F, 0x3C, 0x0D, 0x29, 0x3C, 0x21, 0x24, 0x08, 0x23, 0x20, 0x38, 0x39,
73     0x3C, 0x20, 0x13, 0x3C, 0x00, 0x0D, 0x13, 0x1F, 0x3C, 0x09, 0x26, 0x1F,
74     0x08, 0x09, 0x26, 0x12, 0x08, 0x23, 0x29, 0x20, 0x23, 0x21, 0x24, 0x20,
75     0x13, 0x20, 0x3B, 0x16, 0x20, 0x3B, 0x29, 0x20, 0x3B, 0x29, 0x20, 0x3B,
76     0x13, 0x21, 0x24, 0x29, 0x0B, 0x13, 0x09, 0x3B, 0x13, 0x09, 0x3B, 0x13,
77     0x21, 0x3B, 0x13, 0x0D, 0x26, 0x29, 0x26, 0x29, 0x3D, 0x12, 0x22, 0x28,
78     0x2E, 0x04, 0x08, 0x13, 0x3C, 0x3B, 0x3C, 0x20, 0x10, 0x3C, 0x21, 0x07,
79     0x08, 0x10, 0x00, 0x08, 0x0D, 0x29, 0x08, 0x0D, 0x29, 0x08, 0x09, 0x13,
80     0x20, 0x23, 0x39, 0x08, 0x09, 0x13, 0x08, 0x09, 0x16, 0x08, 0x09, 0x10,
81     0x12, 0x20, 0x3B, 0x3D, 0x09, 0x26, 0x20, 0x3B, 0x24, 0x39, 0x09, 0x26,
82     0x20, 0x0D, 0x13, 0x00, 0x09, 0x13, 0x20, 0x0D, 0x26, 0x12, 0x20, 0x3B,
83     0x13, 0x21, 0x26, 0x0B, 0x12, 0x09, 0x3B, 0x16, 0x09, 0x3B, 0x3D, 0x09,
84     0x26, 0x0D, 0x13, 0x26, 0x3D, 0x1C, 0x12, 0x1F, 0x28, 0x2E, 0x07, 0x0B,
85     0x08, 0x09, 0x00, 0x39, 0x0B, 0x08, 0x26, 0x08, 0x09, 0x13, 0x20, 0x0B,
86     0x39, 0x10, 0x39, 0x0D, 0x13, 0x20, 0x10, 0x12, 0x09, 0x13, 0x20, 0x3B,
87     0x13, 0x09, 0x26, 0x0B, 0x09, 0x3B, 0x1C, 0x09, 0x3B, 0x13, 0x20, 0x3B,
88     0x13, 0x09, 0x26, 0x0B, 0x16, 0x0D, 0x13, 0x09, 0x13, 0x09, 0x13, 0x26,
89     0x3D, 0x1C, 0x1F, 0x28, 0x2E, 0x07, 0x10, 0x39, 0x0B, 0x39, 0x39, 0x13,
90     0x39, 0x0B, 0x39, 0x0B, 0x39, 0x26, 0x39, 0x10, 0x20, 0x3B, 0x16, 0x20,
91     0x10, 0x09, 0x26, 0x0B, 0x13, 0x09, 0x13, 0x26, 0x1C, 0x0B, 0x3D, 0x1C,
92     0x1F, 0x28, 0x2B, 0x07, 0x0C, 0x39, 0x0B, 0x39, 0x0B, 0x0C, 0x0B, 0x26,
93     0x0B, 0x26, 0x3D, 0x0D, 0x1C, 0x14, 0x28, 0x2B, 0x39, 0x0B, 0x0C, 0x0E,
94     0x3D, 0x1C, 0x0D, 0x12, 0x22, 0x2B, 0x07, 0x0C, 0x0E, 0x3D, 0x1C, 0x10,
95     0x1F, 0x2B, 0x0C, 0x0E, 0x19, 0x14, 0x10, 0x1F, 0x28, 0x0C, 0x0E, 0x19,
96     0x14, 0x26, 0x22, 0x2B, 0x0C, 0x0E, 0x19, 0x14, 0x26, 0x28, 0x0E, 0x19,
97     0x14, 0x26, 0x28, 0x0E, 0x19, 0x14, 0x28, 0x0E, 0x19, 0x14, 0x22, 0x28,
98     0x2B, 0x0E, 0x14, 0x2B, 0x31, 0x00, 0x3A, 0x3A, 0x05, 0x05, 0x1B, 0x1D,
99     0x33, 0x06, 0x35, 0x35, 0x20, 0x21, 0x37, 0x21, 0x24, 0x05, 0x1B, 0x2C,
100     0x2C, 0x2C, 0x06, 0x34, 0x1E, 0x34, 0x00, 0x08, 0x36, 0x09, 0x21, 0x26,
101     0x1C, 0x2C, 0x00, 0x02, 0x02, 0x02, 0x3F, 0x04, 0x04, 0x04, 0x34, 0x39,
102     0x20, 0x0A, 0x0C, 0x39, 0x0B, 0x0F, 0x07, 0x07, 0x07, 0x07, 0x34, 0x39,
103     0x39, 0x0A, 0x0C, 0x39, 0x0C, 0x0F, 0x07, 0x07, 0x07, 0x00, 0x39, 0x39,
104     0x0C, 0x0F, 0x07, 0x07, 0x39, 0x0C, 0x0F, 0x07, 0x39, 0x0C, 0x0F, 0x39,
105     0x39, 0x0C, 0x0F, 0x39, 0x0C, 0x39, 0x0C, 0x0F, 0x00, 0x11, 0x27, 0x17,
106     0x2F, 0x27, 0x00, 0x27, 0x17, 0x00, 0x11, 0x17, 0x00, 0x11, 0x17, 0x11,
107     0x00, 0x27, 0x15, 0x11, 0x17, 0x01, 0x15, 0x11, 0x15, 0x11, 0x15, 0x15,
108     0x17, 0x00, 0x27, 0x01, 0x27, 0x27, 0x15, 0x00, 0x27, 0x11, 0x27, 0x15,
109     0x15, 0x15, 0x27, 0x15, 0x15, 0x15, 0x15, 0x17, 0x2F, 0x11, 0x17, 0x27,
110     0x27, 0x27, 0x11, 0x27, 0x15, 0x27, 0x27, 0x15, 0x15, 0x27, 0x17, 0x2F,
111     0x27, 0x17, 0x2F, 0x27, 0x17, 0x2F, 0x27, 0x17, 0x2F, 0x27, 0x17, 0x2F,
112     0x27, 0x17, 0x2F, 0x27, 0x17, 0x2F, 0x27, 0x17, 0x2F, 0x27, 0x17, 0x2F,
113     0x27, 0x17, 0x2F, 0x27, 0x17, 0x2F, 0x27, 0x17, 0x2F, 0x27, 0x17, 0x2F,
114     0x17, 0x2F, 0x2B, 0x00, 0x27, 0x00, 0x00, 0x11, 0x15, 0x00, 0x11, 0x11,
115     0x27, 0x27, 0x15, 0x17, 0x15, 0x17, 0x15, 0x17, 0x27, 0x17, 0x27, 0x17,
116     0x27, 0x17, 0x27, 0x17, 0x27, 0x17, 0x27, 0x17, 0x27, 0x17, 0x27, 0x17,
117     0x27, 0x17, 0x27, 0x17, 0x27, 0x15, 0x27, 0x27, 0x15, 0x27};
118 
119 static UWORD32 ixheaacd_ari_hash_m[742] = {
120     0x00000104UL >> 8, 0x0000030AUL >> 8, 0x00000510UL >> 8, 0x00000716UL >> 8,
121     0x00000A1FUL >> 8, 0x00000F2EUL >> 8, 0x00011100UL >> 8, 0x00111103UL >> 8,
122     0x00111306UL >> 8, 0x00111436UL >> 8, 0x00111623UL >> 8, 0x00111929UL >> 8,
123     0x00111F2EUL >> 8, 0x0011221BUL >> 8, 0x00112435UL >> 8, 0x00112621UL >> 8,
124     0x00112D12UL >> 8, 0x00113130UL >> 8, 0x0011331DUL >> 8, 0x00113535UL >> 8,
125     0x00113938UL >> 8, 0x0011411BUL >> 8, 0x00114433UL >> 8, 0x00114635UL >> 8,
126     0x00114F29UL >> 8, 0x00116635UL >> 8, 0x00116F24UL >> 8, 0x00117433UL >> 8,
127     0x0011FF0FUL >> 8, 0x00121102UL >> 8, 0x0012132DUL >> 8, 0x00121436UL >> 8,
128     0x00121623UL >> 8, 0x00121912UL >> 8, 0x0012213FUL >> 8, 0x0012232DUL >> 8,
129     0x00122436UL >> 8, 0x00122638UL >> 8, 0x00122A29UL >> 8, 0x00122F2BUL >> 8,
130     0x0012322DUL >> 8, 0x00123436UL >> 8, 0x00123738UL >> 8, 0x00123B29UL >> 8,
131     0x0012411DUL >> 8, 0x00124536UL >> 8, 0x00124938UL >> 8, 0x00124F12UL >> 8,
132     0x00125535UL >> 8, 0x00125F29UL >> 8, 0x00126535UL >> 8, 0x0012B837UL >> 8,
133     0x0013112AUL >> 8, 0x0013131EUL >> 8, 0x0013163BUL >> 8, 0x0013212DUL >> 8,
134     0x0013233CUL >> 8, 0x00132623UL >> 8, 0x00132F2EUL >> 8, 0x0013321EUL >> 8,
135     0x00133521UL >> 8, 0x00133824UL >> 8, 0x0013411EUL >> 8, 0x00134336UL >> 8,
136     0x00134838UL >> 8, 0x00135135UL >> 8, 0x00135537UL >> 8, 0x00135F12UL >> 8,
137     0x00137637UL >> 8, 0x0013FF29UL >> 8, 0x00140024UL >> 8, 0x00142321UL >> 8,
138     0x00143136UL >> 8, 0x00143321UL >> 8, 0x00143F25UL >> 8, 0x00144321UL >> 8,
139     0x00148638UL >> 8, 0x0014FF29UL >> 8, 0x00154323UL >> 8, 0x0015FF12UL >> 8,
140     0x0016F20CUL >> 8, 0x0018A529UL >> 8, 0x00210031UL >> 8, 0x0021122CUL >> 8,
141     0x00211408UL >> 8, 0x00211713UL >> 8, 0x00211F2EUL >> 8, 0x0021222AUL >> 8,
142     0x00212408UL >> 8, 0x00212710UL >> 8, 0x00212F2EUL >> 8, 0x0021331EUL >> 8,
143     0x00213436UL >> 8, 0x00213824UL >> 8, 0x0021412DUL >> 8, 0x0021431EUL >> 8,
144     0x00214536UL >> 8, 0x00214F1FUL >> 8, 0x00216637UL >> 8, 0x00220004UL >> 8,
145     0x0022122AUL >> 8, 0x00221420UL >> 8, 0x00221829UL >> 8, 0x00221F2EUL >> 8,
146     0x0022222DUL >> 8, 0x00222408UL >> 8, 0x00222623UL >> 8, 0x00222929UL >> 8,
147     0x00222F2BUL >> 8, 0x0022321EUL >> 8, 0x00223408UL >> 8, 0x00223724UL >> 8,
148     0x00223A29UL >> 8, 0x0022411EUL >> 8, 0x00224436UL >> 8, 0x00224823UL >> 8,
149     0x00225134UL >> 8, 0x00225621UL >> 8, 0x00225F12UL >> 8, 0x00226336UL >> 8,
150     0x00227637UL >> 8, 0x0022FF29UL >> 8, 0x0023112DUL >> 8, 0x0023133CUL >> 8,
151     0x00231420UL >> 8, 0x00231916UL >> 8, 0x0023212DUL >> 8, 0x0023233CUL >> 8,
152     0x00232509UL >> 8, 0x00232929UL >> 8, 0x0023312DUL >> 8, 0x00233308UL >> 8,
153     0x00233509UL >> 8, 0x00233724UL >> 8, 0x0023413CUL >> 8, 0x00234421UL >> 8,
154     0x00234A13UL >> 8, 0x0023513CUL >> 8, 0x00235421UL >> 8, 0x00235F1FUL >> 8,
155     0x00236421UL >> 8, 0x0023FF29UL >> 8, 0x00240024UL >> 8, 0x0024153BUL >> 8,
156     0x00242108UL >> 8, 0x00242409UL >> 8, 0x00242726UL >> 8, 0x00243108UL >> 8,
157     0x00243409UL >> 8, 0x00243610UL >> 8, 0x00244136UL >> 8, 0x00244321UL >> 8,
158     0x00244523UL >> 8, 0x00244F1FUL >> 8, 0x00245423UL >> 8, 0x0024610AUL >> 8,
159     0x00246423UL >> 8, 0x0024FF29UL >> 8, 0x00252510UL >> 8, 0x00253121UL >> 8,
160     0x0025343BUL >> 8, 0x00254121UL >> 8, 0x00254510UL >> 8, 0x00254F25UL >> 8,
161     0x00255221UL >> 8, 0x0025FF12UL >> 8, 0x00266513UL >> 8, 0x0027F529UL >> 8,
162     0x0029F101UL >> 8, 0x002CF224UL >> 8, 0x00310030UL >> 8, 0x0031122AUL >> 8,
163     0x00311420UL >> 8, 0x00311816UL >> 8, 0x0031212CUL >> 8, 0x0031231EUL >> 8,
164     0x00312408UL >> 8, 0x00312710UL >> 8, 0x0031312AUL >> 8, 0x0031321EUL >> 8,
165     0x00313408UL >> 8, 0x00313623UL >> 8, 0x0031411EUL >> 8, 0x0031433CUL >> 8,
166     0x00320007UL >> 8, 0x0032122DUL >> 8, 0x00321420UL >> 8, 0x00321816UL >> 8,
167     0x0032212DUL >> 8, 0x0032233CUL >> 8, 0x00322509UL >> 8, 0x00322916UL >> 8,
168     0x0032312DUL >> 8, 0x00323420UL >> 8, 0x00323710UL >> 8, 0x00323F2BUL >> 8,
169     0x00324308UL >> 8, 0x00324623UL >> 8, 0x00324F25UL >> 8, 0x00325421UL >> 8,
170     0x00325F1FUL >> 8, 0x00326421UL >> 8, 0x0032FF29UL >> 8, 0x00331107UL >> 8,
171     0x00331308UL >> 8, 0x0033150DUL >> 8, 0x0033211EUL >> 8, 0x00332308UL >> 8,
172     0x00332420UL >> 8, 0x00332610UL >> 8, 0x00332929UL >> 8, 0x0033311EUL >> 8,
173     0x00333308UL >> 8, 0x0033363BUL >> 8, 0x00333A29UL >> 8, 0x0033413CUL >> 8,
174     0x00334320UL >> 8, 0x0033463BUL >> 8, 0x00334A29UL >> 8, 0x0033510AUL >> 8,
175     0x00335320UL >> 8, 0x00335824UL >> 8, 0x0033610AUL >> 8, 0x00336321UL >> 8,
176     0x00336F12UL >> 8, 0x00337623UL >> 8, 0x00341139UL >> 8, 0x0034153BUL >> 8,
177     0x00342108UL >> 8, 0x00342409UL >> 8, 0x00342610UL >> 8, 0x00343108UL >> 8,
178     0x00343409UL >> 8, 0x00343610UL >> 8, 0x00344108UL >> 8, 0x0034440DUL >> 8,
179     0x00344610UL >> 8, 0x0034510AUL >> 8, 0x00345309UL >> 8, 0x0034553BUL >> 8,
180     0x0034610AUL >> 8, 0x00346309UL >> 8, 0x0034F824UL >> 8, 0x00350029UL >> 8,
181     0x00352510UL >> 8, 0x00353120UL >> 8, 0x0035330DUL >> 8, 0x00353510UL >> 8,
182     0x00354120UL >> 8, 0x0035430DUL >> 8, 0x00354510UL >> 8, 0x00354F28UL >> 8,
183     0x0035530DUL >> 8, 0x00355510UL >> 8, 0x00355F1FUL >> 8, 0x00356410UL >> 8,
184     0x00359626UL >> 8, 0x0035FF12UL >> 8, 0x00366426UL >> 8, 0x0036FF12UL >> 8,
185     0x0037F426UL >> 8, 0x0039D712UL >> 8, 0x003BF612UL >> 8, 0x003DF81FUL >> 8,
186     0x00410004UL >> 8, 0x00411207UL >> 8, 0x0041150DUL >> 8, 0x0041212AUL >> 8,
187     0x00412420UL >> 8, 0x0041311EUL >> 8, 0x00413308UL >> 8, 0x00413509UL >> 8,
188     0x00413F2BUL >> 8, 0x00414208UL >> 8, 0x00420007UL >> 8, 0x0042123CUL >> 8,
189     0x00421409UL >> 8, 0x00422107UL >> 8, 0x0042223CUL >> 8, 0x00422409UL >> 8,
190     0x00422610UL >> 8, 0x0042313CUL >> 8, 0x00423409UL >> 8, 0x0042363BUL >> 8,
191     0x0042413CUL >> 8, 0x00424320UL >> 8, 0x0042463BUL >> 8, 0x00425108UL >> 8,
192     0x00425409UL >> 8, 0x0042FF29UL >> 8, 0x00431107UL >> 8, 0x00431320UL >> 8,
193     0x0043153BUL >> 8, 0x0043213CUL >> 8, 0x00432320UL >> 8, 0x00432610UL >> 8,
194     0x0043313CUL >> 8, 0x00433320UL >> 8, 0x0043353BUL >> 8, 0x00433813UL >> 8,
195     0x00434108UL >> 8, 0x00434409UL >> 8, 0x00434610UL >> 8, 0x00435108UL >> 8,
196     0x0043553BUL >> 8, 0x00435F25UL >> 8, 0x00436309UL >> 8, 0x0043753BUL >> 8,
197     0x0043FF29UL >> 8, 0x00441239UL >> 8, 0x0044143BUL >> 8, 0x00442139UL >> 8,
198     0x00442309UL >> 8, 0x0044253BUL >> 8, 0x00443108UL >> 8, 0x00443220UL >> 8,
199     0x0044353BUL >> 8, 0x0044410AUL >> 8, 0x00444309UL >> 8, 0x0044453BUL >> 8,
200     0x00444813UL >> 8, 0x0044510AUL >> 8, 0x00445309UL >> 8, 0x00445510UL >> 8,
201     0x00445F25UL >> 8, 0x0044630DUL >> 8, 0x00450026UL >> 8, 0x00452713UL >> 8,
202     0x00453120UL >> 8, 0x0045330DUL >> 8, 0x00453510UL >> 8, 0x00454120UL >> 8,
203     0x0045430DUL >> 8, 0x00454510UL >> 8, 0x00455120UL >> 8, 0x0045530DUL >> 8,
204     0x00456209UL >> 8, 0x00456410UL >> 8, 0x0045FF12UL >> 8, 0x00466513UL >> 8,
205     0x0047FF22UL >> 8, 0x0048FF25UL >> 8, 0x0049F43DUL >> 8, 0x004BFB25UL >> 8,
206     0x004EF825UL >> 8, 0x004FFF18UL >> 8, 0x00511339UL >> 8, 0x00512107UL >> 8,
207     0x00513409UL >> 8, 0x00520007UL >> 8, 0x00521107UL >> 8, 0x00521320UL >> 8,
208     0x00522107UL >> 8, 0x00522409UL >> 8, 0x0052313CUL >> 8, 0x00523320UL >> 8,
209     0x0052353BUL >> 8, 0x00524108UL >> 8, 0x00524320UL >> 8, 0x00531139UL >> 8,
210     0x00531309UL >> 8, 0x00532139UL >> 8, 0x00532309UL >> 8, 0x0053253BUL >> 8,
211     0x00533108UL >> 8, 0x0053340DUL >> 8, 0x00533713UL >> 8, 0x00534108UL >> 8,
212     0x0053453BUL >> 8, 0x00534F2BUL >> 8, 0x00535309UL >> 8, 0x00535610UL >> 8,
213     0x00535F25UL >> 8, 0x0053643BUL >> 8, 0x00541139UL >> 8, 0x00542139UL >> 8,
214     0x00542309UL >> 8, 0x00542613UL >> 8, 0x00543139UL >> 8, 0x00543309UL >> 8,
215     0x00543510UL >> 8, 0x00543F2BUL >> 8, 0x00544309UL >> 8, 0x00544510UL >> 8,
216     0x00544F28UL >> 8, 0x0054530DUL >> 8, 0x0054FF12UL >> 8, 0x00553613UL >> 8,
217     0x00553F2BUL >> 8, 0x00554410UL >> 8, 0x0055510AUL >> 8, 0x0055543BUL >> 8,
218     0x00555F25UL >> 8, 0x0055633BUL >> 8, 0x0055FF12UL >> 8, 0x00566513UL >> 8,
219     0x00577413UL >> 8, 0x0059FF28UL >> 8, 0x005CC33DUL >> 8, 0x005EFB28UL >> 8,
220     0x005FFF18UL >> 8, 0x00611339UL >> 8, 0x00612107UL >> 8, 0x00613320UL >> 8,
221     0x0061A724UL >> 8, 0x00621107UL >> 8, 0x0062140BUL >> 8, 0x00622107UL >> 8,
222     0x00622320UL >> 8, 0x00623139UL >> 8, 0x00623320UL >> 8, 0x00631139UL >> 8,
223     0x0063130CUL >> 8, 0x00632139UL >> 8, 0x00632309UL >> 8, 0x00633139UL >> 8,
224     0x00633309UL >> 8, 0x00633626UL >> 8, 0x00633F2BUL >> 8, 0x00634309UL >> 8,
225     0x00634F2BUL >> 8, 0x0063543BUL >> 8, 0x0063FF12UL >> 8, 0x0064343BUL >> 8,
226     0x00643F2BUL >> 8, 0x0064443BUL >> 8, 0x00645209UL >> 8, 0x00665513UL >> 8,
227     0x0066610AUL >> 8, 0x00666526UL >> 8, 0x0067A616UL >> 8, 0x0069843DUL >> 8,
228     0x006CF612UL >> 8, 0x006EF326UL >> 8, 0x006FFF18UL >> 8, 0x0071130CUL >> 8,
229     0x00721107UL >> 8, 0x00722239UL >> 8, 0x0072291CUL >> 8, 0x0072340BUL >> 8,
230     0x00731139UL >> 8, 0x00732239UL >> 8, 0x0073630BUL >> 8, 0x0073FF12UL >> 8,
231     0x0074430BUL >> 8, 0x00755426UL >> 8, 0x00776F28UL >> 8, 0x00777410UL >> 8,
232     0x0078843DUL >> 8, 0x007CF416UL >> 8, 0x007EF326UL >> 8, 0x007FFF18UL >> 8,
233     0x00822239UL >> 8, 0x00831139UL >> 8, 0x0083430BUL >> 8, 0x0084530BUL >> 8,
234     0x0087561CUL >> 8, 0x00887F25UL >> 8, 0x00888426UL >> 8, 0x008AF61CUL >> 8,
235     0x008F0018UL >> 8, 0x008FFF18UL >> 8, 0x00911107UL >> 8, 0x0093230BUL >> 8,
236     0x0094530BUL >> 8, 0x0097743DUL >> 8, 0x00998C25UL >> 8, 0x00999616UL >> 8,
237     0x009EF825UL >> 8, 0x009FFF18UL >> 8, 0x00A3430BUL >> 8, 0x00A4530BUL >> 8,
238     0x00A7743DUL >> 8, 0x00AA9F2BUL >> 8, 0x00AAA616UL >> 8, 0x00ABD61FUL >> 8,
239     0x00AFFF18UL >> 8, 0x00B3330BUL >> 8, 0x00B44426UL >> 8, 0x00B7643DUL >> 8,
240     0x00BB971FUL >> 8, 0x00BBB53DUL >> 8, 0x00BEF512UL >> 8, 0x00BFFF18UL >> 8,
241     0x00C22139UL >> 8, 0x00C5330EUL >> 8, 0x00C7633DUL >> 8, 0x00CCAF2EUL >> 8,
242     0x00CCC616UL >> 8, 0x00CFFF18UL >> 8, 0x00D4440EUL >> 8, 0x00D6420EUL >> 8,
243     0x00DDCF2EUL >> 8, 0x00DDD516UL >> 8, 0x00DFFF18UL >> 8, 0x00E4330EUL >> 8,
244     0x00E6841CUL >> 8, 0x00EEE61CUL >> 8, 0x00EFFF18UL >> 8, 0x00F3320EUL >> 8,
245     0x00F55319UL >> 8, 0x00F8F41CUL >> 8, 0x00FAFF2EUL >> 8, 0x00FF002EUL >> 8,
246     0x00FFF10CUL >> 8, 0x00FFF33DUL >> 8, 0x00FFF722UL >> 8, 0x00FFFF18UL >> 8,
247     0x01000232UL >> 8, 0x0111113EUL >> 8, 0x01112103UL >> 8, 0x0111311AUL >> 8,
248     0x0112111AUL >> 8, 0x01122130UL >> 8, 0x01123130UL >> 8, 0x0112411DUL >> 8,
249     0x01131102UL >> 8, 0x01132102UL >> 8, 0x01133102UL >> 8, 0x01141108UL >> 8,
250     0x01142136UL >> 8, 0x01143136UL >> 8, 0x01144135UL >> 8, 0x0115223BUL >> 8,
251     0x01211103UL >> 8, 0x0121211AUL >> 8, 0x01213130UL >> 8, 0x01221130UL >> 8,
252     0x01222130UL >> 8, 0x01223102UL >> 8, 0x01231104UL >> 8, 0x01232104UL >> 8,
253     0x01233104UL >> 8, 0x01241139UL >> 8, 0x01241220UL >> 8, 0x01242220UL >> 8,
254     0x01251109UL >> 8, 0x0125223BUL >> 8, 0x0125810AUL >> 8, 0x01283212UL >> 8,
255     0x0131111AUL >> 8, 0x01312130UL >> 8, 0x0131222CUL >> 8, 0x0131322AUL >> 8,
256     0x0132122AUL >> 8, 0x0132222DUL >> 8, 0x0132322DUL >> 8, 0x01331207UL >> 8,
257     0x01332234UL >> 8, 0x01333234UL >> 8, 0x01341139UL >> 8, 0x01343134UL >> 8,
258     0x01344134UL >> 8, 0x01348134UL >> 8, 0x0135220BUL >> 8, 0x0136110BUL >> 8,
259     0x01365224UL >> 8, 0x01411102UL >> 8, 0x01412104UL >> 8, 0x01431239UL >> 8,
260     0x01432239UL >> 8, 0x0143320AUL >> 8, 0x01435134UL >> 8, 0x01443107UL >> 8,
261     0x01444134UL >> 8, 0x01446134UL >> 8, 0x0145220EUL >> 8, 0x01455134UL >> 8,
262     0x0147110EUL >> 8, 0x01511102UL >> 8, 0x01521239UL >> 8, 0x01531239UL >> 8,
263     0x01532239UL >> 8, 0x01533107UL >> 8, 0x0155220EUL >> 8, 0x01555134UL >> 8,
264     0x0157110EUL >> 8, 0x01611107UL >> 8, 0x01621239UL >> 8, 0x01631239UL >> 8,
265     0x01661139UL >> 8, 0x01666134UL >> 8, 0x01711107UL >> 8, 0x01721239UL >> 8,
266     0x01745107UL >> 8, 0x0177110CUL >> 8, 0x01811107UL >> 8, 0x01821107UL >> 8,
267     0x0185110CUL >> 8, 0x0188210CUL >> 8, 0x01911107UL >> 8, 0x01933139UL >> 8,
268     0x01A11107UL >> 8, 0x01A31139UL >> 8, 0x01F5220EUL >> 8, 0x02000001UL >> 8,
269     0x02000127UL >> 8, 0x02000427UL >> 8, 0x02000727UL >> 8, 0x02000E2FUL >> 8,
270     0x02110000UL >> 8, 0x02111200UL >> 8, 0x02111411UL >> 8, 0x02111827UL >> 8,
271     0x02111F2FUL >> 8, 0x02112411UL >> 8, 0x02112715UL >> 8, 0x02113200UL >> 8,
272     0x02113411UL >> 8, 0x02113715UL >> 8, 0x02114200UL >> 8, 0x02121200UL >> 8,
273     0x02121301UL >> 8, 0x02121F2FUL >> 8, 0x02122200UL >> 8, 0x02122615UL >> 8,
274     0x02122F2FUL >> 8, 0x02123311UL >> 8, 0x02123F2FUL >> 8, 0x02124411UL >> 8,
275     0x02131211UL >> 8, 0x02132311UL >> 8, 0x02133211UL >> 8, 0x02184415UL >> 8,
276     0x02211200UL >> 8, 0x02211311UL >> 8, 0x02211F2FUL >> 8, 0x02212311UL >> 8,
277     0x02212F2FUL >> 8, 0x02213211UL >> 8, 0x02221201UL >> 8, 0x02221311UL >> 8,
278     0x02221F2FUL >> 8, 0x02222311UL >> 8, 0x02222F2FUL >> 8, 0x02223211UL >> 8,
279     0x02223F2FUL >> 8, 0x02231211UL >> 8, 0x02232211UL >> 8, 0x02232F2FUL >> 8,
280     0x02233211UL >> 8, 0x02233F2FUL >> 8, 0x02287515UL >> 8, 0x022DAB17UL >> 8,
281     0x02311211UL >> 8, 0x02311527UL >> 8, 0x02312211UL >> 8, 0x02321211UL >> 8,
282     0x02322211UL >> 8, 0x02322F2FUL >> 8, 0x02323311UL >> 8, 0x02323F2FUL >> 8,
283     0x02331211UL >> 8, 0x02332211UL >> 8, 0x02332F2FUL >> 8, 0x02333F2FUL >> 8,
284     0x0237FF17UL >> 8, 0x02385615UL >> 8, 0x023D9517UL >> 8, 0x02410027UL >> 8,
285     0x02487827UL >> 8, 0x024E3117UL >> 8, 0x024FFF2FUL >> 8, 0x02598627UL >> 8,
286     0x025DFF2FUL >> 8, 0x025FFF2FUL >> 8, 0x02687827UL >> 8, 0x026DFA17UL >> 8,
287     0x026FFF2FUL >> 8, 0x02796427UL >> 8, 0x027E4217UL >> 8, 0x027FFF2FUL >> 8,
288     0x02888727UL >> 8, 0x028EFF2FUL >> 8, 0x028FFF2FUL >> 8, 0x02984327UL >> 8,
289     0x029F112FUL >> 8, 0x029FFF2FUL >> 8, 0x02A76527UL >> 8, 0x02AEF717UL >> 8,
290     0x02AFFF2FUL >> 8, 0x02B7C827UL >> 8, 0x02BEF917UL >> 8, 0x02BFFF2FUL >> 8,
291     0x02C66527UL >> 8, 0x02CD5517UL >> 8, 0x02CFFF2FUL >> 8, 0x02D63227UL >> 8,
292     0x02DDD527UL >> 8, 0x02DFFF2BUL >> 8, 0x02E84717UL >> 8, 0x02EEE327UL >> 8,
293     0x02EFFF2FUL >> 8, 0x02F54527UL >> 8, 0x02FCF817UL >> 8, 0x02FFEF2BUL >> 8,
294     0x02FFFA2FUL >> 8, 0x02FFFE2FUL >> 8, 0x03000127UL >> 8, 0x03000201UL >> 8,
295     0x03111200UL >> 8, 0x03122115UL >> 8, 0x03123200UL >> 8, 0x03133211UL >> 8,
296     0x03211200UL >> 8, 0x03213127UL >> 8, 0x03221200UL >> 8, 0x03345215UL >> 8,
297     0x04000F17UL >> 8, 0x04122F17UL >> 8, 0x043F6515UL >> 8, 0x043FFF17UL >> 8,
298     0x044F5527UL >> 8, 0x044FFF17UL >> 8, 0x045F0017UL >> 8, 0x045FFF17UL >> 8,
299     0x046F6517UL >> 8, 0x04710027UL >> 8, 0x047F4427UL >> 8, 0x04810027UL >> 8,
300     0x048EFA15UL >> 8, 0x048FFF2FUL >> 8, 0x049F4427UL >> 8, 0x049FFF2FUL >> 8,
301     0x04AEA727UL >> 8, 0x04AFFF2FUL >> 8, 0x04BE9C15UL >> 8, 0x04BFFF2FUL >> 8,
302     0x04CE5427UL >> 8, 0x04CFFF2FUL >> 8, 0x04DE3527UL >> 8, 0x04DFFF17UL >> 8,
303     0x04EE4627UL >> 8, 0x04EFFF17UL >> 8, 0x04FEF327UL >> 8, 0x04FFFF2FUL >> 8,
304     0x06000F27UL >> 8, 0x069FFF17UL >> 8, 0x06FFFF17UL >> 8, 0x08110017UL >> 8,
305     0x08EFFF15UL >> 8, 0xFFFFFF00UL >> 8};
306 
307 static UWORD8 ixheaacd_ari_hash_m_1[742] = {
308     (UWORD8)0x04, (UWORD8)0x0A, (UWORD8)0x10, (UWORD8)0x16, (UWORD8)0x1F,
309     (UWORD8)0x2E, (UWORD8)0x00, (UWORD8)0x03, (UWORD8)0x06, (UWORD8)0x36,
310     (UWORD8)0x23, (UWORD8)0x29, (UWORD8)0x2E, (UWORD8)0x1B, (UWORD8)0x35,
311     (UWORD8)0x21, (UWORD8)0x12, (UWORD8)0x30, (UWORD8)0x1D, (UWORD8)0x35,
312     (UWORD8)0x38, (UWORD8)0x1B, (UWORD8)0x33, (UWORD8)0x35, (UWORD8)0x29,
313     (UWORD8)0x35, (UWORD8)0x24, (UWORD8)0x33, (UWORD8)0x0F, (UWORD8)0x02,
314     (UWORD8)0x2D, (UWORD8)0x36, (UWORD8)0x23, (UWORD8)0x12, (UWORD8)0x3F,
315     (UWORD8)0x2D, (UWORD8)0x36, (UWORD8)0x38, (UWORD8)0x29, (UWORD8)0x2B,
316     (UWORD8)0x2D, (UWORD8)0x36, (UWORD8)0x38, (UWORD8)0x29, (UWORD8)0x1D,
317     (UWORD8)0x36, (UWORD8)0x38, (UWORD8)0x12, (UWORD8)0x35, (UWORD8)0x29,
318     (UWORD8)0x35, (UWORD8)0x37, (UWORD8)0x2A, (UWORD8)0x1E, (UWORD8)0x3B,
319     (UWORD8)0x2D, (UWORD8)0x3C, (UWORD8)0x23, (UWORD8)0x2E, (UWORD8)0x1E,
320     (UWORD8)0x21, (UWORD8)0x24, (UWORD8)0x1E, (UWORD8)0x36, (UWORD8)0x38,
321     (UWORD8)0x35, (UWORD8)0x37, (UWORD8)0x12, (UWORD8)0x37, (UWORD8)0x29,
322     (UWORD8)0x24, (UWORD8)0x21, (UWORD8)0x36, (UWORD8)0x21, (UWORD8)0x25,
323     (UWORD8)0x21, (UWORD8)0x38, (UWORD8)0x29, (UWORD8)0x23, (UWORD8)0x12,
324     (UWORD8)0x0C, (UWORD8)0x29, (UWORD8)0x31, (UWORD8)0x2C, (UWORD8)0x08,
325     (UWORD8)0x13, (UWORD8)0x2E, (UWORD8)0x2A, (UWORD8)0x08, (UWORD8)0x10,
326     (UWORD8)0x2E, (UWORD8)0x1E, (UWORD8)0x36, (UWORD8)0x24, (UWORD8)0x2D,
327     (UWORD8)0x1E, (UWORD8)0x36, (UWORD8)0x1F, (UWORD8)0x37, (UWORD8)0x04,
328     (UWORD8)0x2A, (UWORD8)0x20, (UWORD8)0x29, (UWORD8)0x2E, (UWORD8)0x2D,
329     (UWORD8)0x08, (UWORD8)0x23, (UWORD8)0x29, (UWORD8)0x2B, (UWORD8)0x1E,
330     (UWORD8)0x08, (UWORD8)0x24, (UWORD8)0x29, (UWORD8)0x1E, (UWORD8)0x36,
331     (UWORD8)0x23, (UWORD8)0x34, (UWORD8)0x21, (UWORD8)0x12, (UWORD8)0x36,
332     (UWORD8)0x37, (UWORD8)0x29, (UWORD8)0x2D, (UWORD8)0x3C, (UWORD8)0x20,
333     (UWORD8)0x16, (UWORD8)0x2D, (UWORD8)0x3C, (UWORD8)0x09, (UWORD8)0x29,
334     (UWORD8)0x2D, (UWORD8)0x08, (UWORD8)0x09, (UWORD8)0x24, (UWORD8)0x3C,
335     (UWORD8)0x21, (UWORD8)0x13, (UWORD8)0x3C, (UWORD8)0x21, (UWORD8)0x1F,
336     (UWORD8)0x21, (UWORD8)0x29, (UWORD8)0x24, (UWORD8)0x3B, (UWORD8)0x08,
337     (UWORD8)0x09, (UWORD8)0x26, (UWORD8)0x08, (UWORD8)0x09, (UWORD8)0x10,
338     (UWORD8)0x36, (UWORD8)0x21, (UWORD8)0x23, (UWORD8)0x1F, (UWORD8)0x23,
339     (UWORD8)0x0A, (UWORD8)0x23, (UWORD8)0x29, (UWORD8)0x10, (UWORD8)0x21,
340     (UWORD8)0x3B, (UWORD8)0x21, (UWORD8)0x10, (UWORD8)0x25, (UWORD8)0x21,
341     (UWORD8)0x12, (UWORD8)0x13, (UWORD8)0x29, (UWORD8)0x01, (UWORD8)0x24,
342     (UWORD8)0x30, (UWORD8)0x2A, (UWORD8)0x20, (UWORD8)0x16, (UWORD8)0x2C,
343     (UWORD8)0x1E, (UWORD8)0x08, (UWORD8)0x10, (UWORD8)0x2A, (UWORD8)0x1E,
344     (UWORD8)0x08, (UWORD8)0x23, (UWORD8)0x1E, (UWORD8)0x3C, (UWORD8)0x07,
345     (UWORD8)0x2D, (UWORD8)0x20, (UWORD8)0x16, (UWORD8)0x2D, (UWORD8)0x3C,
346     (UWORD8)0x09, (UWORD8)0x16, (UWORD8)0x2D, (UWORD8)0x20, (UWORD8)0x10,
347     (UWORD8)0x2B, (UWORD8)0x08, (UWORD8)0x23, (UWORD8)0x25, (UWORD8)0x21,
348     (UWORD8)0x1F, (UWORD8)0x21, (UWORD8)0x29, (UWORD8)0x07, (UWORD8)0x08,
349     (UWORD8)0x0D, (UWORD8)0x1E, (UWORD8)0x08, (UWORD8)0x20, (UWORD8)0x10,
350     (UWORD8)0x29, (UWORD8)0x1E, (UWORD8)0x08, (UWORD8)0x3B, (UWORD8)0x29,
351     (UWORD8)0x3C, (UWORD8)0x20, (UWORD8)0x3B, (UWORD8)0x29, (UWORD8)0x0A,
352     (UWORD8)0x20, (UWORD8)0x24, (UWORD8)0x0A, (UWORD8)0x21, (UWORD8)0x12,
353     (UWORD8)0x23, (UWORD8)0x39, (UWORD8)0x3B, (UWORD8)0x08, (UWORD8)0x09,
354     (UWORD8)0x10, (UWORD8)0x08, (UWORD8)0x09, (UWORD8)0x10, (UWORD8)0x08,
355     (UWORD8)0x0D, (UWORD8)0x10, (UWORD8)0x0A, (UWORD8)0x09, (UWORD8)0x3B,
356     (UWORD8)0x0A, (UWORD8)0x09, (UWORD8)0x24, (UWORD8)0x29, (UWORD8)0x10,
357     (UWORD8)0x20, (UWORD8)0x0D, (UWORD8)0x10, (UWORD8)0x20, (UWORD8)0x0D,
358     (UWORD8)0x10, (UWORD8)0x28, (UWORD8)0x0D, (UWORD8)0x10, (UWORD8)0x1F,
359     (UWORD8)0x10, (UWORD8)0x26, (UWORD8)0x12, (UWORD8)0x26, (UWORD8)0x12,
360     (UWORD8)0x26, (UWORD8)0x12, (UWORD8)0x12, (UWORD8)0x1F, (UWORD8)0x04,
361     (UWORD8)0x07, (UWORD8)0x0D, (UWORD8)0x2A, (UWORD8)0x20, (UWORD8)0x1E,
362     (UWORD8)0x08, (UWORD8)0x09, (UWORD8)0x2B, (UWORD8)0x08, (UWORD8)0x07,
363     (UWORD8)0x3C, (UWORD8)0x09, (UWORD8)0x07, (UWORD8)0x3C, (UWORD8)0x09,
364     (UWORD8)0x10, (UWORD8)0x3C, (UWORD8)0x09, (UWORD8)0x3B, (UWORD8)0x3C,
365     (UWORD8)0x20, (UWORD8)0x3B, (UWORD8)0x08, (UWORD8)0x09, (UWORD8)0x29,
366     (UWORD8)0x07, (UWORD8)0x20, (UWORD8)0x3B, (UWORD8)0x3C, (UWORD8)0x20,
367     (UWORD8)0x10, (UWORD8)0x3C, (UWORD8)0x20, (UWORD8)0x3B, (UWORD8)0x13,
368     (UWORD8)0x08, (UWORD8)0x09, (UWORD8)0x10, (UWORD8)0x08, (UWORD8)0x3B,
369     (UWORD8)0x25, (UWORD8)0x09, (UWORD8)0x3B, (UWORD8)0x29, (UWORD8)0x39,
370     (UWORD8)0x3B, (UWORD8)0x39, (UWORD8)0x09, (UWORD8)0x3B, (UWORD8)0x08,
371     (UWORD8)0x20, (UWORD8)0x3B, (UWORD8)0x0A, (UWORD8)0x09, (UWORD8)0x3B,
372     (UWORD8)0x13, (UWORD8)0x0A, (UWORD8)0x09, (UWORD8)0x10, (UWORD8)0x25,
373     (UWORD8)0x0D, (UWORD8)0x26, (UWORD8)0x13, (UWORD8)0x20, (UWORD8)0x0D,
374     (UWORD8)0x10, (UWORD8)0x20, (UWORD8)0x0D, (UWORD8)0x10, (UWORD8)0x20,
375     (UWORD8)0x0D, (UWORD8)0x09, (UWORD8)0x10, (UWORD8)0x12, (UWORD8)0x13,
376     (UWORD8)0x22, (UWORD8)0x25, (UWORD8)0x3D, (UWORD8)0x25, (UWORD8)0x25,
377     (UWORD8)0x18, (UWORD8)0x39, (UWORD8)0x07, (UWORD8)0x09, (UWORD8)0x07,
378     (UWORD8)0x07, (UWORD8)0x20, (UWORD8)0x07, (UWORD8)0x09, (UWORD8)0x3C,
379     (UWORD8)0x20, (UWORD8)0x3B, (UWORD8)0x08, (UWORD8)0x20, (UWORD8)0x39,
380     (UWORD8)0x09, (UWORD8)0x39, (UWORD8)0x09, (UWORD8)0x3B, (UWORD8)0x08,
381     (UWORD8)0x0D, (UWORD8)0x13, (UWORD8)0x08, (UWORD8)0x3B, (UWORD8)0x2B,
382     (UWORD8)0x09, (UWORD8)0x10, (UWORD8)0x25, (UWORD8)0x3B, (UWORD8)0x39,
383     (UWORD8)0x39, (UWORD8)0x09, (UWORD8)0x13, (UWORD8)0x39, (UWORD8)0x09,
384     (UWORD8)0x10, (UWORD8)0x2B, (UWORD8)0x09, (UWORD8)0x10, (UWORD8)0x28,
385     (UWORD8)0x0D, (UWORD8)0x12, (UWORD8)0x13, (UWORD8)0x2B, (UWORD8)0x10,
386     (UWORD8)0x0A, (UWORD8)0x3B, (UWORD8)0x25, (UWORD8)0x3B, (UWORD8)0x12,
387     (UWORD8)0x13, (UWORD8)0x13, (UWORD8)0x28, (UWORD8)0x3D, (UWORD8)0x28,
388     (UWORD8)0x18, (UWORD8)0x39, (UWORD8)0x07, (UWORD8)0x20, (UWORD8)0x24,
389     (UWORD8)0x07, (UWORD8)0x0B, (UWORD8)0x07, (UWORD8)0x20, (UWORD8)0x39,
390     (UWORD8)0x20, (UWORD8)0x39, (UWORD8)0x0C, (UWORD8)0x39, (UWORD8)0x09,
391     (UWORD8)0x39, (UWORD8)0x09, (UWORD8)0x26, (UWORD8)0x2B, (UWORD8)0x09,
392     (UWORD8)0x2B, (UWORD8)0x3B, (UWORD8)0x12, (UWORD8)0x3B, (UWORD8)0x2B,
393     (UWORD8)0x3B, (UWORD8)0x09, (UWORD8)0x13, (UWORD8)0x0A, (UWORD8)0x26,
394     (UWORD8)0x16, (UWORD8)0x3D, (UWORD8)0x12, (UWORD8)0x26, (UWORD8)0x18,
395     (UWORD8)0x0C, (UWORD8)0x07, (UWORD8)0x39, (UWORD8)0x1C, (UWORD8)0x0B,
396     (UWORD8)0x39, (UWORD8)0x39, (UWORD8)0x0B, (UWORD8)0x12, (UWORD8)0x0B,
397     (UWORD8)0x26, (UWORD8)0x28, (UWORD8)0x10, (UWORD8)0x3D, (UWORD8)0x16,
398     (UWORD8)0x26, (UWORD8)0x18, (UWORD8)0x39, (UWORD8)0x39, (UWORD8)0x0B,
399     (UWORD8)0x0B, (UWORD8)0x1C, (UWORD8)0x25, (UWORD8)0x26, (UWORD8)0x1C,
400     (UWORD8)0x18, (UWORD8)0x18, (UWORD8)0x07, (UWORD8)0x0B, (UWORD8)0x0B,
401     (UWORD8)0x3D, (UWORD8)0x25, (UWORD8)0x16, (UWORD8)0x25, (UWORD8)0x18,
402     (UWORD8)0x0B, (UWORD8)0x0B, (UWORD8)0x3D, (UWORD8)0x2B, (UWORD8)0x16,
403     (UWORD8)0x1F, (UWORD8)0x18, (UWORD8)0x0B, (UWORD8)0x26, (UWORD8)0x3D,
404     (UWORD8)0x1F, (UWORD8)0x3D, (UWORD8)0x12, (UWORD8)0x18, (UWORD8)0x39,
405     (UWORD8)0x0E, (UWORD8)0x3D, (UWORD8)0x2E, (UWORD8)0x16, (UWORD8)0x18,
406     (UWORD8)0x0E, (UWORD8)0x0E, (UWORD8)0x2E, (UWORD8)0x16, (UWORD8)0x18,
407     (UWORD8)0x0E, (UWORD8)0x1C, (UWORD8)0x1C, (UWORD8)0x18, (UWORD8)0x0E,
408     (UWORD8)0x19, (UWORD8)0x1C, (UWORD8)0x2E, (UWORD8)0x2E, (UWORD8)0x0C,
409     (UWORD8)0x3D, (UWORD8)0x22, (UWORD8)0x18, (UWORD8)0x32, (UWORD8)0x3E,
410     (UWORD8)0x03, (UWORD8)0x1A, (UWORD8)0x1A, (UWORD8)0x30, (UWORD8)0x30,
411     (UWORD8)0x1D, (UWORD8)0x02, (UWORD8)0x02, (UWORD8)0x02, (UWORD8)0x08,
412     (UWORD8)0x36, (UWORD8)0x36, (UWORD8)0x35, (UWORD8)0x3B, (UWORD8)0x03,
413     (UWORD8)0x1A, (UWORD8)0x30, (UWORD8)0x30, (UWORD8)0x30, (UWORD8)0x02,
414     (UWORD8)0x04, (UWORD8)0x04, (UWORD8)0x04, (UWORD8)0x39, (UWORD8)0x20,
415     (UWORD8)0x20, (UWORD8)0x09, (UWORD8)0x3B, (UWORD8)0x0A, (UWORD8)0x12,
416     (UWORD8)0x1A, (UWORD8)0x30, (UWORD8)0x2C, (UWORD8)0x2A, (UWORD8)0x2A,
417     (UWORD8)0x2D, (UWORD8)0x2D, (UWORD8)0x07, (UWORD8)0x34, (UWORD8)0x34,
418     (UWORD8)0x39, (UWORD8)0x34, (UWORD8)0x34, (UWORD8)0x34, (UWORD8)0x0B,
419     (UWORD8)0x0B, (UWORD8)0x24, (UWORD8)0x02, (UWORD8)0x04, (UWORD8)0x39,
420     (UWORD8)0x39, (UWORD8)0x0A, (UWORD8)0x34, (UWORD8)0x07, (UWORD8)0x34,
421     (UWORD8)0x34, (UWORD8)0x0E, (UWORD8)0x34, (UWORD8)0x0E, (UWORD8)0x02,
422     (UWORD8)0x39, (UWORD8)0x39, (UWORD8)0x39, (UWORD8)0x07, (UWORD8)0x0E,
423     (UWORD8)0x34, (UWORD8)0x0E, (UWORD8)0x07, (UWORD8)0x39, (UWORD8)0x39,
424     (UWORD8)0x39, (UWORD8)0x34, (UWORD8)0x07, (UWORD8)0x39, (UWORD8)0x07,
425     (UWORD8)0x0C, (UWORD8)0x07, (UWORD8)0x07, (UWORD8)0x0C, (UWORD8)0x0C,
426     (UWORD8)0x07, (UWORD8)0x39, (UWORD8)0x07, (UWORD8)0x39, (UWORD8)0x0E,
427     (UWORD8)0x01, (UWORD8)0x27, (UWORD8)0x27, (UWORD8)0x27, (UWORD8)0x2F,
428     (UWORD8)0x00, (UWORD8)0x00, (UWORD8)0x11, (UWORD8)0x27, (UWORD8)0x2F,
429     (UWORD8)0x11, (UWORD8)0x15, (UWORD8)0x00, (UWORD8)0x11, (UWORD8)0x15,
430     (UWORD8)0x00, (UWORD8)0x00, (UWORD8)0x01, (UWORD8)0x2F, (UWORD8)0x00,
431     (UWORD8)0x15, (UWORD8)0x2F, (UWORD8)0x11, (UWORD8)0x2F, (UWORD8)0x11,
432     (UWORD8)0x11, (UWORD8)0x11, (UWORD8)0x11, (UWORD8)0x15, (UWORD8)0x00,
433     (UWORD8)0x11, (UWORD8)0x2F, (UWORD8)0x11, (UWORD8)0x2F, (UWORD8)0x11,
434     (UWORD8)0x01, (UWORD8)0x11, (UWORD8)0x2F, (UWORD8)0x11, (UWORD8)0x2F,
435     (UWORD8)0x11, (UWORD8)0x2F, (UWORD8)0x11, (UWORD8)0x11, (UWORD8)0x2F,
436     (UWORD8)0x11, (UWORD8)0x2F, (UWORD8)0x15, (UWORD8)0x17, (UWORD8)0x11,
437     (UWORD8)0x27, (UWORD8)0x11, (UWORD8)0x11, (UWORD8)0x11, (UWORD8)0x2F,
438     (UWORD8)0x11, (UWORD8)0x2F, (UWORD8)0x11, (UWORD8)0x11, (UWORD8)0x2F,
439     (UWORD8)0x2F, (UWORD8)0x17, (UWORD8)0x15, (UWORD8)0x17, (UWORD8)0x27,
440     (UWORD8)0x27, (UWORD8)0x17, (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x2F,
441     (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x17, (UWORD8)0x2F, (UWORD8)0x27,
442     (UWORD8)0x17, (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x2F, (UWORD8)0x2F,
443     (UWORD8)0x27, (UWORD8)0x2F, (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x17,
444     (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x17, (UWORD8)0x2F, (UWORD8)0x27,
445     (UWORD8)0x17, (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x27, (UWORD8)0x2B,
446     (UWORD8)0x17, (UWORD8)0x27, (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x17,
447     (UWORD8)0x2B, (UWORD8)0x2F, (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x01,
448     (UWORD8)0x00, (UWORD8)0x15, (UWORD8)0x00, (UWORD8)0x11, (UWORD8)0x00,
449     (UWORD8)0x27, (UWORD8)0x00, (UWORD8)0x15, (UWORD8)0x17, (UWORD8)0x17,
450     (UWORD8)0x15, (UWORD8)0x17, (UWORD8)0x27, (UWORD8)0x17, (UWORD8)0x17,
451     (UWORD8)0x17, (UWORD8)0x17, (UWORD8)0x27, (UWORD8)0x27, (UWORD8)0x27,
452     (UWORD8)0x15, (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x2F, (UWORD8)0x27,
453     (UWORD8)0x2F, (UWORD8)0x15, (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x2F,
454     (UWORD8)0x27, (UWORD8)0x17, (UWORD8)0x27, (UWORD8)0x17, (UWORD8)0x27,
455     (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x17, (UWORD8)0x17, (UWORD8)0x17,
456     (UWORD8)0x15, (UWORD8)0x00};
457 
458 UWORD16 ixheaacd_ari_cf_m[64][17] = {
459     {708, 706, 579, 569, 568, 567, 479, 469, 297, 138, 97, 91, 72, 52, 38, 34,
460      0},
461     {7619, 6917, 6519, 6412, 5514, 5003, 4683, 4563, 3907, 3297, 3125, 3060,
462      2904, 2718, 2631, 2590, 0},
463     {7263, 4888, 4810, 4803, 1889, 415, 335, 327, 195, 72, 52, 49, 36, 20, 15,
464      14, 0},
465     {3626, 2197, 2188, 2187, 582, 57, 47, 46, 30, 12, 9, 8, 6, 4, 3, 2, 0},
466     {7806, 5541, 5451, 5441, 2720, 834, 691, 674, 487, 243, 179, 167, 139, 98,
467      77, 70, 0},
468     {6684, 4101, 4058, 4055, 1748, 426, 368, 364, 322, 257, 235, 232, 228, 222,
469      217, 215, 0},
470     {9162, 5964, 5831, 5819, 3269, 866, 658, 638, 535, 348, 258, 244, 234, 214,
471      195, 186, 0},
472     {10638, 8491, 8365, 8351, 4418, 2067, 1859, 1834, 1190, 601, 495, 478, 356,
473      217, 174, 164, 0},
474     {13389, 10514, 10032, 9961, 7166, 3488, 2655, 2524, 2015, 1140, 760, 672,
475      585, 426, 325, 283, 0},
476     {14861, 12788, 12115, 11952, 9987, 6657, 5323, 4984, 4324, 3001, 2205, 1943,
477      1764, 1394, 1115, 978, 0},
478     {12876, 10004, 9661, 9610, 7107, 3435, 2711, 2595, 2257, 1508, 1059, 952,
479      893, 753, 609, 538, 0},
480     {15125, 13591, 13049, 12874, 11192, 8543, 7406, 7023, 6291, 4922, 4104,
481      3769, 3465, 2890, 2486, 2275, 0},
482     {14574, 13106, 12731, 12638, 10453, 7947, 7233, 7037, 6031, 4618, 4081,
483      3906, 3465, 2802, 2476, 2349, 0},
484     {15070, 13179, 12517, 12351, 10742, 7657, 6200, 5825, 5264, 3998, 3014,
485      2662, 2510, 2153, 1799, 1564, 0},
486     {15542, 14466, 14007, 13844, 12489, 10409, 9481, 9132, 8305, 6940, 6193,
487      5867, 5458, 4743, 4291, 4047, 0},
488     {15165, 14384, 14084, 13934, 12911, 11485, 10844, 10513, 10002, 8993, 8380,
489      8051, 7711, 7036, 6514, 6233, 0},
490     {15642, 14279, 13625, 13393, 12348, 9971, 8405, 7858, 7335, 6119, 4918,
491      4376, 4185, 3719, 3231, 2860, 0},
492     {13408, 13407, 11471, 11218, 11217, 11216, 9473, 9216, 6480, 3689, 2857,
493      2690, 2256, 1732, 1405, 1302, 0},
494     {16098, 15584, 15191, 14931, 14514, 13578, 12703, 12103, 11830, 11172,
495      10475, 9867, 9695, 9281, 8825, 8389, 0},
496     {15844, 14873, 14277, 13996, 13230, 11535, 10205, 9543, 9107, 8086, 7085,
497      6419, 6214, 5713, 5195, 4731, 0},
498     {16131, 15720, 15443, 15276, 14848, 13971, 13314, 12910, 12591, 11874,
499      11225, 10788, 10573, 10077, 9585, 9209, 0},
500     {16331, 16330, 12283, 11435, 11434, 11433, 8725, 8049, 6065, 4138, 3187,
501      2842, 2529, 2171, 1907, 1745, 0},
502     {16011, 15292, 14782, 14528, 14008, 12767, 11556, 10921, 10591, 9759, 8813,
503      8043, 7855, 7383, 6863, 6282, 0},
504     {16380, 16379, 15159, 14610, 14609, 14608, 12859, 12111, 11046, 9536, 8348,
505      7713, 7216, 6533, 5964, 5546, 0},
506     {16367, 16333, 16294, 16253, 16222, 16143, 16048, 15947, 15915, 15832,
507      15731, 15619, 15589, 15512, 15416, 15310, 0},
508     {15967, 15319, 14937, 14753, 14010, 12638, 11787, 11360, 10805, 9706, 8934,
509      8515, 8166, 7456, 6911, 6575, 0},
510     {4906, 3005, 2985, 2984, 875, 102, 83, 81, 47, 17, 12, 11, 8, 5, 4, 3, 0},
511     {7217, 4346, 4269, 4264, 1924, 428, 340, 332, 280, 203, 179, 175, 171, 164,
512      159, 157, 0},
513     {16010, 15415, 15032, 14805, 14228, 13043, 12168, 11634, 11265, 10419, 9645,
514      9110, 8892, 8378, 7850, 7437, 0},
515     {8573, 5218, 5046, 5032, 2787, 771, 555, 533, 443, 286, 218, 205, 197, 181,
516      168, 162, 0},
517     {11474, 8095, 7822, 7796, 4632, 1443, 1046, 1004, 748, 351, 218, 194, 167,
518      121, 93, 83, 0},
519     {16152, 15764, 15463, 15264, 14925, 14189, 13536, 13070, 12846, 12314,
520      11763, 11277, 11131, 10777, 10383, 10011, 0},
521     {14187, 11654, 11043, 10919, 8498, 4885, 3778, 3552, 2947, 1835, 1283, 1134,
522      998, 749, 585, 514, 0},
523     {14162, 11527, 10759, 10557, 8601, 5417, 4105, 3753, 3286, 2353, 1708, 1473,
524      1370, 1148, 959, 840, 0},
525     {16205, 15902, 15669, 15498, 15213, 14601, 14068, 13674, 13463, 12970,
526      12471, 12061, 11916, 11564, 11183, 10841, 0},
527     {15043, 12972, 12092, 11792, 10265, 7446, 5934, 5379, 4883, 3825, 3036,
528      2647, 2507, 2185, 1901, 1699, 0},
529     {15320, 13694, 12782, 12352, 11191, 8936, 7433, 6671, 6255, 5366, 4622,
530      4158, 4020, 3712, 3420, 3198, 0},
531     {16255, 16020, 15768, 15600, 15416, 14963, 14440, 14006, 13875, 13534,
532      13137, 12697, 12602, 12364, 12084, 11781, 0},
533     {15627, 14503, 13906, 13622, 12557, 10527, 9269, 8661, 8117, 6933, 5994,
534      5474, 5222, 4664, 4166, 3841, 0},
535     {16366, 16365, 14547, 14160, 14159, 14158, 11969, 11473, 8735, 6147, 4911,
536      4530, 3865, 3180, 2710, 2473, 0},
537     {16257, 16038, 15871, 15754, 15536, 15071, 14673, 14390, 14230, 13842,
538      13452, 13136, 13021, 12745, 12434, 12154, 0},
539     {15855, 14971, 14338, 13939, 13239, 11782, 10585, 9805, 9444, 8623, 7846,
540      7254, 7079, 6673, 6262, 5923, 0},
541     {9492, 6318, 6197, 6189, 3004, 652, 489, 477, 333, 143, 96, 90, 78, 60, 50,
542      47, 0},
543     {16313, 16191, 16063, 15968, 15851, 15590, 15303, 15082, 14968, 14704,
544      14427, 14177, 14095, 13899, 13674, 13457, 0},
545     {8485, 5473, 5389, 5383, 2411, 494, 386, 377, 278, 150, 117, 112, 103, 89,
546      81, 78, 0},
547     {10497, 7154, 6959, 6943, 3788, 1004, 734, 709, 517, 238, 152, 138, 120, 90,
548      72, 66, 0},
549     {16317, 16226, 16127, 16040, 15955, 15762, 15547, 15345, 15277, 15111,
550      14922, 14723, 14671, 14546, 14396, 14239, 0},
551     {16382, 16381, 15858, 15540, 15539, 15538, 14704, 14168, 13768, 13092,
552      12452, 11925, 11683, 11268, 10841, 10460, 0},
553     {5974, 3798, 3758, 3755, 1275, 205, 166, 162, 95, 35, 26, 24, 18, 11, 8, 7,
554      0},
555     {3532, 2258, 2246, 2244, 731, 135, 118, 115, 87, 45, 36, 34, 29, 21, 17, 16,
556      0},
557     {7466, 4882, 4821, 4811, 2476, 886, 788, 771, 688, 531, 469, 457, 437, 400,
558      369, 361, 0},
559     {9580, 5772, 5291, 5216, 3444, 1496, 1025, 928, 806, 578, 433, 384, 366,
560      331, 296, 273, 0},
561     {10692, 7730, 7543, 7521, 4679, 1746, 1391, 1346, 1128, 692, 495, 458, 424,
562      353, 291, 268, 0},
563     {11040, 7132, 6549, 6452, 4377, 1875, 1253, 1130, 958, 631, 431, 370, 346,
564      296, 253, 227, 0},
565     {12687, 9332, 8701, 8585, 6266, 3093, 2182, 2004, 1683, 1072, 712, 608, 559,
566      458, 373, 323, 0},
567     {13429, 9853, 8860, 8584, 6806, 4039, 2862, 2478, 2239, 1764, 1409, 1224,
568      1178, 1077, 979, 903, 0},
569     {14685, 12163, 11061, 10668, 9101, 6345, 4871, 4263, 3908, 3200, 2668, 2368,
570      2285, 2106, 1942, 1819, 0},
571     {13295, 11302, 10999, 10945, 7947, 5036, 4490, 4385, 3391, 2185, 1836, 1757,
572      1424, 998, 833, 785, 0},
573     {4992, 2993, 2972, 2970, 1269, 575, 552, 549, 530, 505, 497, 495, 493, 489,
574      486, 485, 0},
575     {15419, 13862, 13104, 12819, 11429, 8753, 7220, 6651, 6020, 4667, 3663,
576      3220, 2995, 2511, 2107, 1871, 0},
577     {12468, 9263, 8912, 8873, 5758, 2193, 1625, 1556, 1187, 589, 371, 330, 283,
578      200, 149, 131, 0},
579     {15870, 15076, 14615, 14369, 13586, 12034, 10990, 10423, 9953, 8908, 8031,
580      7488, 7233, 6648, 6101, 5712, 0},
581     {1693, 978, 976, 975, 194, 18, 16, 15, 11, 7, 6, 5, 4, 3, 2, 1, 0},
582     {7992, 5218, 5147, 5143, 2152, 366, 282, 276, 173, 59, 38, 35, 27, 16, 11,
583      10, 0}};
584 
585 typedef struct { WORD32 low, high, value; } state_arith;
586 
587 const WORD32 ixheaacd_table_frac[7] = {
588     638450709,  759250126,  902905651,  1073741824,
589     1276901417, 1518500250, 1805811302,
590 };
591 
592 const WORD64 ixheaacd_table_exp[32] = {
593     1,         2,         4,          8,         16,       32,       64,
594     128,       256,       512,        1024,      2048,     4096,     8192,
595     16384,     32768,     65536,      131072,    262144,   524288,   1048576,
596     2097152,   4194304,   8388608,    16777216,  33554432, 67108864, 134217728,
597     268435456, 536870912, 1073741824, 2147483648};
598 
599 static const WORD32 ixheaacd_pow_14_3[8] = {0,    3251, 4096,  5161,
600                                             6502, 8192, 10321, 13004};
601 
602 const WORD32 ixheaacd_pow_table_Q13[1025] = {0,
603                                              131072 >> 4,
604                                              330281 >> 4,
605                                              567116 >> 4,
606                                              832256 >> 4,
607                                              1120650 >> 4,
608                                              1429042 >> 4,
609                                              1755122 >> 4,
610                                              2097152 >> 4,
611                                              2453767 >> 4,
612                                              2823861 >> 4,
613                                              3206517 >> 4,
614                                              3600960 >> 4,
615                                              4006524 >> 4,
616                                              4422631 >> 4,
617                                              4848770 >> 4,
618                                              5284492 >> 4,
619                                              5729392 >> 4,
620                                              6183105 >> 4,
621                                              6645302 >> 4,
622                                              7115683 >> 4,
623                                              7593972 >> 4,
624                                              8079916 >> 4,
625                                              8573281 >> 4,
626                                              9073850 >> 4,
627                                              9581422 >> 4,
628                                              10095808 >> 4,
629                                              10616832 >> 4,
630                                              11144330 >> 4,
631                                              11678147 >> 4,
632                                              12218136 >> 4,
633                                              12764159 >> 4,
634                                              13316085 >> 4,
635                                              13873792 >> 4,
636                                              14437162 >> 4,
637                                              15006082 >> 4,
638                                              15580448 >> 4,
639                                              16160157 >> 4,
640                                              16745112 >> 4,
641                                              17335222 >> 4,
642                                              17930398 >> 4,
643                                              18530554 >> 4,
644                                              19135610 >> 4,
645                                              19745488 >> 4,
646                                              20360112 >> 4,
647                                              20979411 >> 4,
648                                              21603314 >> 4,
649                                              22231755 >> 4,
650                                              22864669 >> 4,
651                                              23501994 >> 4,
652                                              24143669 >> 4,
653                                              24789637 >> 4,
654                                              25439841 >> 4,
655                                              26094226 >> 4,
656                                              26752740 >> 4,
657                                              27415332 >> 4,
658                                              28081952 >> 4,
659                                              28752552 >> 4,
660                                              29427086 >> 4,
661                                              30105507 >> 4,
662                                              30787772 >> 4,
663                                              31473838 >> 4,
664                                              32163664 >> 4,
665                                              32857208 >> 4,
666                                              33554432 >> 4,
667                                              34255297 >> 4,
668                                              34959765 >> 4,
669                                              35667801 >> 4,
670                                              36379368 >> 4,
671                                              37094431 >> 4,
672                                              37812958 >> 4,
673                                              38534914 >> 4,
674                                              39260268 >> 4,
675                                              39988988 >> 4,
676                                              40721043 >> 4,
677                                              41456403 >> 4,
678                                              42195038 >> 4,
679                                              42936921 >> 4,
680                                              43682022 >> 4,
681                                              44430314 >> 4,
682                                              45181770 >> 4,
683                                              45936364 >> 4,
684                                              46694070 >> 4,
685                                              47454862 >> 4,
686                                              48218716 >> 4,
687                                              48985607 >> 4,
688                                              49755512 >> 4,
689                                              50528406 >> 4,
690                                              51304267 >> 4,
691                                              52083073 >> 4,
692                                              52864802 >> 4,
693                                              53649431 >> 4,
694                                              54436939 >> 4,
695                                              55227306 >> 4,
696                                              56020511 >> 4,
697                                              56816534 >> 4,
698                                              57615355 >> 4,
699                                              58416954 >> 4,
700                                              59221313 >> 4,
701                                              60028412 >> 4,
702                                              60838233 >> 4,
703                                              61650759 >> 4,
704                                              62465970 >> 4,
705                                              63283850 >> 4,
706                                              64104381 >> 4,
707                                              64927547 >> 4,
708                                              65753329 >> 4,
709                                              66581713 >> 4,
710                                              67412681 >> 4,
711                                              68246218 >> 4,
712                                              69082308 >> 4,
713                                              69920936 >> 4,
714                                              70762086 >> 4,
715                                              71605743 >> 4,
716                                              72451892 >> 4,
717                                              73300519 >> 4,
718                                              74151609 >> 4,
719                                              75005149 >> 4,
720                                              75861124 >> 4,
721                                              76719520 >> 4,
722                                              77580324 >> 4,
723                                              78443523 >> 4,
724                                              79309103 >> 4,
725                                              80177051 >> 4,
726                                              81047354 >> 4,
727                                              81920000 >> 4,
728                                              82794977 >> 4,
729                                              83672271 >> 4,
730                                              84551871 >> 4,
731                                              5339610,
732                                              5394871,
733                                              5450274,
734                                              5505818,
735                                              5561502,
736                                              5617327,
737                                              5673290,
738                                              5729391,
739                                              5785631,
740                                              5842007,
741                                              5898519,
742                                              5955168,
743                                              6011951,
744                                              6068869,
745                                              6125920,
746                                              6183105,
747                                              6240422,
748                                              6297871,
749                                              6355451,
750                                              6413162,
751                                              6471004,
752                                              6528974,
753                                              6587074,
754                                              6645302,
755                                              6703658,
756                                              6762141,
757                                              6820751,
758                                              6879487,
759                                              6938349,
760                                              6997336,
761                                              7056447,
762                                              7115683,
763                                              7175042,
764                                              7234524,
765                                              7294129,
766                                              7353855,
767                                              7413703,
768                                              7473672,
769                                              7533762,
770                                              7593972,
771                                              7654301,
772                                              7714750,
773                                              7775317,
774                                              7836002,
775                                              7896805,
776                                              7957725,
777                                              8018762,
778                                              8079916,
779                                              8141185,
780                                              8202570,
781                                              8264070,
782                                              8325685,
783                                              8387413,
784                                              8449256,
785                                              8511212,
786                                              8573281,
787                                              8635462,
788                                              8697756,
789                                              8760161,
790                                              8822678,
791                                              8885305,
792                                              8948043,
793                                              9010892,
794                                              9073850,
795                                              9136917,
796                                              9200094,
797                                              9263379,
798                                              9326772,
799                                              9390274,
800                                              9453882,
801                                              9517598,
802                                              9581421,
803                                              9645351,
804                                              9709386,
805                                              9773527,
806                                              9837774,
807                                              9902125,
808                                              9966582,
809                                              10031143,
810                                              10095807,
811                                              10160576,
812                                              10225448,
813                                              10290423,
814                                              10355500,
815                                              10420681,
816                                              10485963,
817                                              10551347,
818                                              10616832,
819                                              10682419,
820                                              10748106,
821                                              10813894,
822                                              10879782,
823                                              10945770,
824                                              11011857,
825                                              11078044,
826                                              11144330,
827                                              11210715,
828                                              11277198,
829                                              11343779,
830                                              11410458,
831                                              11477234,
832                                              11544108,
833                                              11611079,
834                                              11678147,
835                                              11745311,
836                                              11812571,
837                                              11879927,
838                                              11947378,
839                                              12014925,
840                                              12082567,
841                                              12150304,
842                                              12218135,
843                                              12286061,
844                                              12354081,
845                                              12422194,
846                                              12490401,
847                                              12558701,
848                                              12627094,
849                                              12695580,
850                                              12764158,
851                                              12832829,
852                                              12901592,
853                                              12970446,
854                                              13039392,
855                                              13108429,
856                                              13177557,
857                                              13246776,
858                                              13316085,
859                                              13385485,
860                                              13454975,
861                                              13524554,
862                                              13594224,
863                                              13663982,
864                                              13733830,
865                                              13803767,
866                                              13873792,
867                                              13943906,
868                                              14014108,
869                                              14084398,
870                                              14154776,
871                                              14225242,
872                                              14295794,
873                                              14366435,
874                                              14437162,
875                                              14507975,
876                                              14578876,
877                                              14649862,
878                                              14720935,
879                                              14792093,
880                                              14863337,
881                                              14934667,
882                                              15006082,
883                                              15077582,
884                                              15149167,
885                                              15220837,
886                                              15292591,
887                                              15364429,
888                                              15436351,
889                                              15508358,
890                                              15580448,
891                                              15652621,
892                                              15724878,
893                                              15797217,
894                                              15869640,
895                                              15942146,
896                                              16014734,
897                                              16087404,
898                                              16160156,
899                                              16232991,
900                                              16305907,
901                                              16378905,
902                                              16451984,
903                                              16525145,
904                                              16598386,
905                                              16671709,
906                                              16745112,
907                                              16818596,
908                                              16892160,
909                                              16965804,
910                                              17039528,
911                                              17113332,
912                                              17187216,
913                                              17261179,
914                                              17335222,
915                                              17409343,
916                                              17483544,
917                                              17557824,
918                                              17632182,
919                                              17706618,
920                                              17781133,
921                                              17855726,
922                                              17930397,
923                                              18005146,
924                                              18079973,
925                                              18154877,
926                                              18229858,
927                                              18304917,
928                                              18380052,
929                                              18455265,
930                                              18530554,
931                                              18605920,
932                                              18681362,
933                                              18756880,
934                                              18832475,
935                                              18908145,
936                                              18983891,
937                                              19059713,
938                                              19135610,
939                                              19211583,
940                                              19287630,
941                                              19363753,
942                                              19439951,
943                                              19516223,
944                                              19592571,
945                                              19668992,
946                                              19745488,
947                                              19822058,
948                                              19898702,
949                                              19975420,
950                                              20052211,
951                                              20129076,
952                                              20206015,
953                                              20283027,
954                                              20360112,
955                                              20437270,
956                                              20514501,
957                                              20591805,
958                                              20669181,
959                                              20746630,
960                                              20824151,
961                                              20901745,
962                                              20979410,
963                                              21057148,
964                                              21134957,
965                                              21212838,
966                                              21290791,
967                                              21368815,
968                                              21446910,
969                                              21525076,
970                                              21603314,
971                                              21681622,
972                                              21760001,
973                                              21838451,
974                                              21916971,
975                                              21995561,
976                                              22074222,
977                                              22152953,
978                                              22231754,
979                                              22310625,
980                                              22389566,
981                                              22468576,
982                                              22547656,
983                                              22626806,
984                                              22706024,
985                                              22785312,
986                                              22864669,
987                                              22944094,
988                                              23023589,
989                                              23103152,
990                                              23182783,
991                                              23262484,
992                                              23342252,
993                                              23422089,
994                                              23501993,
995                                              23581966,
996                                              23662007,
997                                              23742115,
998                                              23822291,
999                                              23902534,
1000                                              23982845,
1001                                              24063223,
1002                                              24143669,
1003                                              24224181,
1004                                              24304761,
1005                                              24385407,
1006                                              24466120,
1007                                              24546899,
1008                                              24627745,
1009                                              24708658,
1010                                              24789637,
1011                                              24870682,
1012                                              24951793,
1013                                              25032970,
1014                                              25114213,
1015                                              25195521,
1016                                              25276895,
1017                                              25358335,
1018                                              25439841,
1019                                              25521411,
1020                                              25603047,
1021                                              25684748,
1022                                              25766514,
1023                                              25848345,
1024                                              25930241,
1025                                              26012201,
1026                                              26094226,
1027                                              26176316,
1028                                              26258469,
1029                                              26340688,
1030                                              26422970,
1031                                              26505317,
1032                                              26587727,
1033                                              26670202,
1034                                              26752740,
1035                                              26835342,
1036                                              26918008,
1037                                              27000737,
1038                                              27083530,
1039                                              27166386,
1040                                              27249305,
1041                                              27332287,
1042                                              27415332,
1043                                              27498440,
1044                                              27581611,
1045                                              27664845,
1046                                              27748142,
1047                                              27831501,
1048                                              27914922,
1049                                              27998406,
1050                                              28081952,
1051                                              28165561,
1052                                              28249231,
1053                                              28332963,
1054                                              28416758,
1055                                              28500614,
1056                                              28584532,
1057                                              28668511,
1058                                              28752552,
1059                                              28836655,
1060                                              28920819,
1061                                              29005044,
1062                                              29089330,
1063                                              29173677,
1064                                              29258086,
1065                                              29342555,
1066                                              29427086,
1067                                              29511676,
1068                                              29596328,
1069                                              29681040,
1070                                              29765813,
1071                                              29850646,
1072                                              29935539,
1073                                              30020493,
1074                                              30105507,
1075                                              30190581,
1076                                              30275714,
1077                                              30360908,
1078                                              30446162,
1079                                              30531475,
1080                                              30616848,
1081                                              30702280,
1082                                              30787772,
1083                                              30873323,
1084                                              30958934,
1085                                              31044604,
1086                                              31130332,
1087                                              31216120,
1088                                              31301967,
1089                                              31387873,
1090                                              31473838,
1091                                              31559862,
1092                                              31645944,
1093                                              31732084,
1094                                              31818284,
1095                                              31904541,
1096                                              31990857,
1097                                              32077231,
1098                                              32163664,
1099                                              32250154,
1100                                              32336703,
1101                                              32423309,
1102                                              32509974,
1103                                              32596696,
1104                                              32683476,
1105                                              32770313,
1106                                              32857208,
1107                                              32944161,
1108                                              33031171,
1109                                              33118238,
1110                                              33205363,
1111                                              33292544,
1112                                              33379783,
1113                                              33467079,
1114                                              33554432,
1115                                              33641842,
1116                                              33729308,
1117                                              33816832,
1118                                              33904412,
1119                                              33992048,
1120                                              34079741,
1121                                              34167491,
1122                                              34255297,
1123                                              34343159,
1124                                              34431078,
1125                                              34519052,
1126                                              34607083,
1127                                              34695170,
1128                                              34783312,
1129                                              34871511,
1130                                              34959765,
1131                                              35048075,
1132                                              35136441,
1133                                              35224862,
1134                                              35313339,
1135                                              35401872,
1136                                              35490459,
1137                                              35579102,
1138                                              35667801,
1139                                              35756554,
1140                                              35845363,
1141                                              35934226,
1142                                              36023145,
1143                                              36112118,
1144                                              36201147,
1145                                              36290230,
1146                                              36379367,
1147                                              36468560,
1148                                              36557807,
1149                                              36647108,
1150                                              36736464,
1151                                              36825875,
1152                                              36915339,
1153                                              37004858,
1154                                              37094431,
1155                                              37184058,
1156                                              37273739,
1157                                              37363474,
1158                                              37453263,
1159                                              37543106,
1160                                              37633003,
1161                                              37722953,
1162                                              37812957,
1163                                              37903015,
1164                                              37993126,
1165                                              38083291,
1166                                              38173509,
1167                                              38263780,
1168                                              38354105,
1169                                              38444483,
1170                                              38534914,
1171                                              38625398,
1172                                              38715935,
1173                                              38806525,
1174                                              38897168,
1175                                              38987864,
1176                                              39078612,
1177                                              39169414,
1178                                              39260268,
1179                                              39351174,
1180                                              39442133,
1181                                              39533145,
1182                                              39624209,
1183                                              39715325,
1184                                              39806494,
1185                                              39897714,
1186                                              39988987,
1187                                              40080312,
1188                                              40171690,
1189                                              40263119,
1190                                              40354600,
1191                                              40446133,
1192                                              40537718,
1193                                              40629354,
1194                                              40721042,
1195                                              40812782,
1196                                              40904574,
1197                                              40996417,
1198                                              41088311,
1199                                              41180257,
1200                                              41272254,
1201                                              41364303,
1202                                              41456402,
1203                                              41548553,
1204                                              41640755,
1205                                              41733008,
1206                                              41825313,
1207                                              41917668,
1208                                              42010074,
1209                                              42102530,
1210                                              42195038,
1211                                              42287596,
1212                                              42380205,
1213                                              42472865,
1214                                              42565575,
1215                                              42658336,
1216                                              42751147,
1217                                              42844009,
1218                                              42936921,
1219                                              43029883,
1220                                              43122895,
1221                                              43215958,
1222                                              43309071,
1223                                              43402233,
1224                                              43495446,
1225                                              43588709,
1226                                              43682022,
1227                                              43775384,
1228                                              43868797,
1229                                              43962259,
1230                                              44055771,
1231                                              44149332,
1232                                              44242943,
1233                                              44336604,
1234                                              44430314,
1235                                              44524073,
1236                                              44617882,
1237                                              44711741,
1238                                              44805648,
1239                                              44899605,
1240                                              44993611,
1241                                              45087666,
1242                                              45181770,
1243                                              45275923,
1244                                              45370126,
1245                                              45464377,
1246                                              45558677,
1247                                              45653025,
1248                                              45747423,
1249                                              45841869,
1250                                              45936364,
1251                                              46030908,
1252                                              46125500,
1253                                              46220141,
1254                                              46314830,
1255                                              46409567,
1256                                              46504353,
1257                                              46599187,
1258                                              46694070,
1259                                              46789001,
1260                                              46883980,
1261                                              46979007,
1262                                              47074082,
1263                                              47169205,
1264                                              47264376,
1265                                              47359595,
1266                                              47454862,
1267                                              47550177,
1268                                              47645540,
1269                                              47740950,
1270                                              47836408,
1271                                              47931914,
1272                                              48027467,
1273                                              48123068,
1274                                              48218716,
1275                                              48314412,
1276                                              48410155,
1277                                              48505945,
1278                                              48601783,
1279                                              48697668,
1280                                              48793601,
1281                                              48889580,
1282                                              48985607,
1283                                              49081681,
1284                                              49177802,
1285                                              49273969,
1286                                              49370184,
1287                                              49466446,
1288                                              49562754,
1289                                              49659109,
1290                                              49755511,
1291                                              49851960,
1292                                              49948456,
1293                                              50044998,
1294                                              50141586,
1295                                              50238222,
1296                                              50334903,
1297                                              50431631,
1298                                              50528406,
1299                                              50625227,
1300                                              50722094,
1301                                              50819007,
1302                                              50915967,
1303                                              51012973,
1304                                              51110025,
1305                                              51207123,
1306                                              51304267,
1307                                              51401457,
1308                                              51498694,
1309                                              51595976,
1310                                              51693304,
1311                                              51790677,
1312                                              51888097,
1313                                              51985562,
1314                                              52083073,
1315                                              52180630,
1316                                              52278232,
1317                                              52375880,
1318                                              52473573,
1319                                              52571312,
1320                                              52669097,
1321                                              52766926,
1322                                              52864801,
1323                                              52962722,
1324                                              53060688,
1325                                              53158699,
1326                                              53256755,
1327                                              53354856,
1328                                              53453002,
1329                                              53551194,
1330                                              53649430,
1331                                              53747712,
1332                                              53846038,
1333                                              53944410,
1334                                              54042826,
1335                                              54141287,
1336                                              54239793,
1337                                              54338344,
1338                                              54436939,
1339                                              54535579,
1340                                              54634263,
1341                                              54732993,
1342                                              54831766,
1343                                              54930585,
1344                                              55029447,
1345                                              55128354,
1346                                              55227306,
1347                                              55326302,
1348                                              55425342,
1349                                              55524426,
1350                                              55623555,
1351                                              55722728,
1352                                              55821945,
1353                                              55921206,
1354                                              56020511,
1355                                              56119860,
1356                                              56219253,
1357                                              56318690,
1358                                              56418171,
1359                                              56517696,
1360                                              56617265,
1361                                              56716877,
1362                                              56816534,
1363                                              56916234,
1364                                              57015977,
1365                                              57115765,
1366                                              57215595,
1367                                              57315470,
1368                                              57415388,
1369                                              57515349,
1370                                              57615354,
1371                                              57715403,
1372                                              57815494,
1373                                              57915629,
1374                                              58015808,
1375                                              58116030,
1376                                              58216294,
1377                                              58316602,
1378                                              58416954,
1379                                              58517348,
1380                                              58617785,
1381                                              58718266,
1382                                              58818789,
1383                                              58919356,
1384                                              59019965,
1385                                              59120617,
1386                                              59221312,
1387                                              59322050,
1388                                              59422831,
1389                                              59523654,
1390                                              59624521,
1391                                              59725429,
1392                                              59826381,
1393                                              59927375,
1394                                              60028412,
1395                                              60129491,
1396                                              60230613,
1397                                              60331777,
1398                                              60432983,
1399                                              60534232,
1400                                              60635524,
1401                                              60736857,
1402                                              60838233,
1403                                              60939651,
1404                                              61041112,
1405                                              61142614,
1406                                              61244159,
1407                                              61345746,
1408                                              61447375,
1409                                              61549046,
1410                                              61650759,
1411                                              61752513,
1412                                              61854310,
1413                                              61956149,
1414                                              62058030,
1415                                              62159952,
1416                                              62261916,
1417                                              62363922,
1418                                              62465970,
1419                                              62568059,
1420                                              62670191,
1421                                              62772363,
1422                                              62874578,
1423                                              62976833,
1424                                              63079131,
1425                                              63181470,
1426                                              63283850,
1427                                              63386272,
1428                                              63488735,
1429                                              63591239,
1430                                              63693785,
1431                                              63796372,
1432                                              63899001,
1433                                              64001670,
1434                                              64104381,
1435                                              64207133,
1436                                              64309926,
1437                                              64412760,
1438                                              64515636,
1439                                              64618552,
1440                                              64721509,
1441                                              64824507,
1442                                              64927546,
1443                                              65030627,
1444                                              65133747,
1445                                              65236909,
1446                                              65340112,
1447                                              65443355,
1448                                              65546639,
1449                                              65649964,
1450                                              65753329,
1451                                              65856735,
1452                                              65960182,
1453                                              66063669,
1454                                              66167197,
1455                                              66270765,
1456                                              66374374,
1457                                              66478023,
1458                                              66581713,
1459                                              66685443,
1460                                              66789213,
1461                                              66893024,
1462                                              66996875,
1463                                              67100766,
1464                                              67204698,
1465                                              67308669,
1466                                              67412681,
1467                                              67516733,
1468                                              67620825,
1469                                              67724957,
1470                                              67829130,
1471                                              67933342,
1472                                              68037594,
1473                                              68141886,
1474                                              68246218,
1475                                              68350590,
1476                                              68455002,
1477                                              68559454,
1478                                              68663945,
1479                                              68768476,
1480                                              68873047,
1481                                              68977658,
1482                                              69082308,
1483                                              69186998,
1484                                              69291728,
1485                                              69396497,
1486                                              69501306,
1487                                              69606154,
1488                                              69711042,
1489                                              69815969,
1490                                              69920936,
1491                                              70025942,
1492                                              70130987,
1493                                              70236072,
1494                                              70341196,
1495                                              70446360,
1496                                              70551562,
1497                                              70656804,
1498                                              70762085,
1499                                              70867406,
1500                                              70972765,
1501                                              71078164,
1502                                              71183601,
1503                                              71289078,
1504                                              71394594,
1505                                              71500149,
1506                                              71605742,
1507                                              71711375,
1508                                              71817046,
1509                                              71922757,
1510                                              72028506,
1511                                              72134294,
1512                                              72240121,
1513                                              72345987,
1514                                              72451892,
1515                                              72557835,
1516                                              72663817,
1517                                              72769837,
1518                                              72875896,
1519                                              72981994,
1520                                              73088130,
1521                                              73194305,
1522                                              73300519,
1523                                              73406770,
1524                                              73513061,
1525                                              73619390,
1526                                              73725757,
1527                                              73832162,
1528                                              73938606,
1529                                              74045088,
1530                                              74151609,
1531                                              74258168,
1532                                              74364765,
1533                                              74471400,
1534                                              74578073,
1535                                              74684785,
1536                                              74791535,
1537                                              74898323,
1538                                              75005149,
1539                                              75112012,
1540                                              75218914,
1541                                              75325854,
1542                                              75432832,
1543                                              75539848,
1544                                              75646902,
1545                                              75753994,
1546                                              75861123,
1547                                              75968291,
1548                                              76075496,
1549                                              76182739,
1550                                              76290020,
1551                                              76397338,
1552                                              76504694,
1553                                              76612088,
1554                                              76719520,
1555                                              76826989,
1556                                              76934495,
1557                                              77042040,
1558                                              77149622,
1559                                              77257241,
1560                                              77364898,
1561                                              77472592,
1562                                              77580324,
1563                                              77688093,
1564                                              77795899,
1565                                              77903743,
1566                                              78011625,
1567                                              78119543,
1568                                              78227499,
1569                                              78335492,
1570                                              78443522,
1571                                              78551590,
1572                                              78659695,
1573                                              78767836,
1574                                              78876015,
1575                                              78984232,
1576                                              79092485,
1577                                              79200775,
1578                                              79309102,
1579                                              79417467,
1580                                              79525868,
1581                                              79634306,
1582                                              79742781,
1583                                              79851293,
1584                                              79959842,
1585                                              80068428,
1586                                              80177050,
1587                                              80285710,
1588                                              80394406,
1589                                              80503139,
1590                                              80611908,
1591                                              80720715,
1592                                              80829558,
1593                                              80938438,
1594                                              81047354,
1595                                              81156307,
1596                                              81265296,
1597                                              81374322,
1598                                              81483385,
1599                                              81592484,
1600                                              81701620,
1601                                              81810792,
1602                                              81920000,
1603                                              82029245,
1604                                              82138526,
1605                                              82247844,
1606                                              82357198,
1607                                              82466588,
1608                                              82576014,
1609                                              82685477,
1610                                              82794976,
1611                                              82904512,
1612                                              83014083,
1613                                              83123691,
1614                                              83233334,
1615                                              83343014,
1616                                              83452730,
1617                                              83562482,
1618                                              83672271,
1619                                              83782095,
1620                                              83891955,
1621                                              84001851,
1622                                              84111783,
1623                                              84221751,
1624                                              84331755,
1625                                              84441795,
1626                                              84551870};
1627 
1628 static WORD32 ixheaacd_esc_nb_offset[8] = {0,      131072, 262144, 393216,
1629                                            524288, 655360, 786432, 917504};
1630 
ixheaacd_arith_map_context(WORD32 pres_n,WORD32 prev_n,WORD8 * c_prev,WORD8 * c,WORD32 arith_reset_flag,WORD8 * ptr_scratch)1631 static void ixheaacd_arith_map_context(WORD32 pres_n, WORD32 prev_n,
1632                                        WORD8 *c_prev, WORD8 *c,
1633                                        WORD32 arith_reset_flag,
1634                                        WORD8 *ptr_scratch) {
1635   WORD32 i, k;
1636   FLOAT32 ratio;
1637   WORD8 *c_prev_tmp = ptr_scratch;
1638   WORD8 *c_tmp = ptr_scratch + 516;
1639 
1640   if (arith_reset_flag) {
1641     for (i = 0; i < (1024 / 2) + 4; i++) {
1642       c_prev[i] = 0;
1643       c[i] = 0;
1644     }
1645 
1646   } else {
1647     for (i = 2; i < (prev_n / 2 + 4); i++) {
1648       c_prev_tmp[i] = c_prev[i];
1649       c_tmp[i] = c[i];
1650     }
1651 
1652     ratio = (FLOAT32)(prev_n) / (FLOAT32)(pres_n);
1653     for (i = 0; i < (pres_n / 2); i++) {
1654       k = (WORD32)((FLOAT32)(i)*ratio);
1655       c_prev[2 + i] = c_prev_tmp[2 + k];
1656       c[2 + i] = c_tmp[2 + k];
1657     }
1658     c_prev[(pres_n / 2) + 2] = c_prev_tmp[(prev_n / 2) + 2];
1659     c[(pres_n / 2) + 3] = c_tmp[(prev_n / 2) + 3];
1660   }
1661 }
1662 
ixheaacd_copy_to_bitbuff(ia_bit_buf_struct * it_bit_buff_src,ia_bit_buf_struct * it_bit_buff_dst)1663 VOID ixheaacd_copy_to_bitbuff(ia_bit_buf_struct *it_bit_buff_src,
1664                               ia_bit_buf_struct *it_bit_buff_dst) {
1665   *it_bit_buff_dst = *it_bit_buff_src;
1666 }
1667 
ixheaacd_arith_get_context(WORD8 * c_prev,WORD8 * c_pres,WORD32 * c,WORD32 i)1668 static WORD32 ixheaacd_arith_get_context(WORD8 *c_prev, WORD8 *c_pres,
1669                                          WORD32 *c, WORD32 i) {
1670   WORD32 tmp = (WORD32)c_prev[1] << 12;
1671 
1672   *c = *c >> 4;
1673   *c = *c + tmp;
1674   *c = (*c & 0xFFF0) + c_pres[-1];
1675 
1676   if (i > 3) {
1677     if ((c_pres[-1] + c_pres[-2] + c_pres[-3]) < 5) {
1678       return (*c + 0x10000);
1679     }
1680   }
1681 
1682   return (*c);
1683 }
1684 
ixheaacd_arith_first_symbol(ia_bit_buf_struct * it_bit_buff,state_arith * s)1685 static WORD32 ixheaacd_arith_first_symbol(ia_bit_buf_struct *it_bit_buff,
1686                                           state_arith *s) {
1687   register WORD32 val;
1688 
1689   WORD32 bit_count = 16;
1690 
1691   val = 0;
1692   if (it_bit_buff->cnt_bits < 16) {
1693     WORD32 shift_value = 16 - it_bit_buff->cnt_bits;
1694     val = ixheaacd_read_bits_buf(it_bit_buff, it_bit_buff->cnt_bits);
1695     val <<= shift_value;
1696   } else {
1697     val = ixheaacd_read_bits_buf(it_bit_buff, 16);
1698   }
1699 
1700   s->low = 0;
1701   s->high = 65535;
1702   s->value = val;
1703 
1704   return bit_count;
1705 }
1706 
ixheaacd_arith_get_pk(UWORD32 c)1707 static UWORD32 ixheaacd_arith_get_pk(UWORD32 c) {
1708   UWORD32 j;
1709   WORD32 i, i_min, i_max;
1710 
1711   i_min = -1;
1712   i = i_min;
1713   i_max = 742 - 1;
1714   while ((i_max - i_min) > 1) {
1715     i = i_min + ((i_max - i_min) >> 1);
1716     j = ixheaacd_ari_hash_m[i];
1717     if (c < j)
1718       i_max = i;
1719     else if (c > j)
1720       i_min = i;
1721     else
1722       return (UWORD32)ixheaacd_ari_hash_m_1[i];
1723   }
1724 
1725   return (ixheaacd_ari_lookup_m[i_max]);
1726 }
1727 
ixheaacd_arith_decode(ia_bit_buf_struct * it_bit_buff,WORD32 bit_count,WORD32 * m,state_arith * s,UWORD16 const * cum_freq,WORD32 cfl)1728 static WORD32 ixheaacd_arith_decode(ia_bit_buf_struct *it_bit_buff,
1729                                     WORD32 bit_count, WORD32 *m, state_arith *s,
1730                                     UWORD16 const *cum_freq, WORD32 cfl) {
1731   register WORD32 symbol;
1732   register WORD32 low, high, range, value;
1733   register WORD32 cum;
1734   register UWORD16 const *p;
1735   register UWORD16 const *q;
1736 
1737   WORD32 short_value, i = 16;
1738   int shift_value;
1739   if (it_bit_buff->cnt_bits < 16) {
1740     shift_value = 16 - it_bit_buff->cnt_bits;
1741     short_value = ixheaacd_read_bits_buf(it_bit_buff, it_bit_buff->cnt_bits);
1742     short_value <<= shift_value;
1743   } else {
1744     shift_value = 0;
1745     short_value = ixheaacd_read_bits_buf(it_bit_buff, 16);
1746   }
1747 
1748   low = s->low;
1749   high = s->high;
1750   value = s->value;
1751 
1752   range = high - low + 1;
1753   cum = ((((WORD32)(value - low + 1)) << 14) - ((WORD32)1)) / ((WORD32)range);
1754 
1755   p = cum_freq - 1;
1756 
1757   do {
1758     q = p + (cfl >> 1);
1759 
1760     if (*q > cum) {
1761       p = q;
1762       cfl++;
1763     }
1764     cfl >>= 1;
1765   } while (cfl > 1);
1766 
1767   symbol = p - cum_freq + 1;
1768 
1769   if (symbol) high = low + ((range * cum_freq[symbol - 1]) >> 14) - 1;
1770 
1771   low += ((range * cum_freq[symbol]) >> 14);
1772 
1773   for (;;) {
1774     if (high < 32768) {
1775     } else if (low >= 32768) {
1776       value -= 32768;
1777       low -= 32768;
1778       high -= 32768;
1779     } else if (low >= 16384 && high < 49152) {
1780       value -= 16384;
1781       low -= 16384;
1782       high -= 16384;
1783     } else
1784       break;
1785 
1786     low += low;
1787     high += high + 1;
1788 
1789     i--;
1790     value = (value << 1) | ((short_value >> i) & 1);
1791     bit_count++;
1792   }
1793 
1794   ixheaacd_read_bidirection(it_bit_buff, -(i - shift_value));
1795   s->low = low;
1796   s->high = high;
1797   s->value = value;
1798 
1799   *m = symbol;
1800 
1801   return bit_count;
1802 }
1803 
ixheaacd_arth_decoding_level2(ia_bit_buf_struct * it_bit_buff,WORD8 * c_prev,WORD8 * c_pres,WORD32 n,WORD32 pres_n,WORD32 * quant)1804 WORD32 ixheaacd_arth_decoding_level2(ia_bit_buf_struct *it_bit_buff,
1805                                      WORD8 *c_prev, WORD8 *c_pres, WORD32 n,
1806                                      WORD32 pres_n, WORD32 *quant) {
1807   state_arith as;
1808   WORD32 a, b;
1809   WORD32 i, j, lev, pki, esc_nb;
1810   WORD32 m;
1811   WORD32 c = 0;
1812   struct ia_bit_buf_struct it_bit_buff_temp = {0};
1813   WORD32 bit_count = 0;
1814   WORD32 s1;
1815   WORD32 temp;
1816   WORD32 bit_count_5;
1817   ixheaacd_copy_to_bitbuff(it_bit_buff, &it_bit_buff_temp);
1818 
1819   for (i = 0; i < pres_n; i++) {
1820     c_prev[i] = c_pres[i];
1821     c_pres[i] = 1;
1822   }
1823 
1824   bit_count = ixheaacd_arith_first_symbol(&it_bit_buff_temp, &as);
1825 
1826   c = (WORD32)c_prev[0] << 12;
1827   lev = 0;
1828 
1829   for (i = 0; i < n; i++) {
1830     s1 = ixheaacd_arith_get_context(c_prev + i, c_pres + i, &c, i);
1831 
1832     for (lev = esc_nb = 0;;) {
1833       pki = ixheaacd_arith_get_pk(s1 + ixheaacd_esc_nb_offset[esc_nb]);
1834       bit_count = ixheaacd_arith_decode(&it_bit_buff_temp, bit_count, &m, &as,
1835                                         ixheaacd_ari_cf_m[pki], 17);
1836       if (bit_count == -1) {
1837         return -1;
1838       }
1839 
1840       if (m < ARITH_ESCAPE) {
1841         break;
1842       }
1843 
1844       lev += 1;
1845       esc_nb = lev;
1846 
1847       if (esc_nb > 7) {
1848         esc_nb = 7;
1849       }
1850       if (esc_nb < 0) {
1851         esc_nb = 0;
1852         return -1;
1853       }
1854     }
1855 
1856     if (m == 0) {
1857       if (esc_nb > 0) break;
1858 
1859       quant[2 * i + 0] = 0;
1860       quant[2 * i + 1] = 0;
1861       c_pres[i] = 1;
1862     } else {
1863       b = m >> 2;
1864       a = m & 0x3;
1865 
1866       for (j = 0; j < lev; j++) {
1867         WORD32 lsbidx = (a == 0) ? 1 : ((b == 0) ? 0 : 2);
1868         bit_count = ixheaacd_arith_decode(&it_bit_buff_temp, bit_count, &m, &as,
1869                                           ixheaacd_ari_cf_r[lsbidx], 4);
1870         if (bit_count == -1) {
1871           return -1;
1872         }
1873         a = (a << 1) | (m & 1);
1874         b = (b << 1) | ((m >> 1) & 1);
1875       }
1876       if ((a > (8183)) || (b > (8183))) return -1;
1877       if ((a < (-8183)) || (b < (-8183))) return -1;
1878       quant[2 * i + 0] = a;
1879       quant[2 * i + 1] = b;
1880       temp = a + b + 1;
1881       c_pres[i] = (WORD8)temp;
1882       if (temp > 0xF) {
1883         c_pres[i] = 0xF;
1884       }
1885     }
1886   }
1887 
1888   bit_count -= 16 - 2;
1889   if (bit_count > it_bit_buff->cnt_bits)
1890     return IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES;
1891 
1892   if (bit_count > 0) {
1893     bit_count_5 = bit_count >> 5;
1894     for (i = 0; i < bit_count_5; i++) ixheaacd_read_bits_buf(it_bit_buff, 32);
1895     ixheaacd_read_bits_buf(it_bit_buff, bit_count & 31);
1896   }
1897 
1898   for (i = 0; i < pres_n; i++) {
1899     WORD32 temp0 = quant[0];
1900     WORD32 temp1 = quant[1];
1901     if (temp0) {
1902       m = ixheaacd_read_bits_buf(it_bit_buff, 1);
1903       bit_count++;
1904 
1905       m = (m << 1) * temp0;
1906       temp0 = m - (temp0);
1907     }
1908 
1909     if (temp1) {
1910       m = ixheaacd_read_bits_buf(it_bit_buff, 1);
1911       bit_count++;
1912 
1913       m = (m << 1) * temp1;
1914       temp1 = m - (temp1);
1915     }
1916     if ((temp0 > (8183)) || (temp1 > (8183))) return -1;
1917     if ((temp0 < (-8183)) || (temp1 < (-8183))) return -1;
1918     *quant++ = temp0;
1919     *quant++ = temp1;
1920   }
1921   return 0;
1922 }
1923 
ixheaacd_randomsign_fix(UWORD32 * seed)1924 static WORD32 ixheaacd_randomsign_fix(UWORD32 *seed) {
1925   WORD32 sign = 0;
1926   *seed = (UWORD32)(((UWORD64)(*seed) * (UWORD64)69069) + 5);
1927   if (((*seed) & 0x10000) > 0) {
1928     sign = -1;
1929   } else {
1930     sign = +1;
1931   }
1932   return sign;
1933 }
1934 
ixheaacd_esc_iquant(WORD32 * q,WORD32 * coef,WORD32 noise_level,WORD32 with_noise,UWORD32 * seed_value,WORD32 length,WORD64 fac_fix)1935 static VOID ixheaacd_esc_iquant(WORD32 *q, WORD32 *coef, WORD32 noise_level,
1936                                 WORD32 with_noise, UWORD32 *seed_value,
1937                                 WORD32 length, WORD64 fac_fix) {
1938   WORD32 q1 = 0;
1939   WORD64 temp;
1940   WORD16 interp;
1941   WORD32 i;
1942   WORD16 flag;
1943 
1944   for (i = 0; i < length; i++) {
1945     flag = 1;
1946 
1947     if (with_noise) {
1948       if (q[i] == 0) {
1949         coef[i] = (ixheaacd_randomsign_fix(seed_value) * noise_level);
1950         temp = (fac_fix * coef[i]);
1951         coef[i] = (WORD32)(temp >> 25);
1952         continue;
1953       }
1954     }
1955 
1956     if (q[i] < 0) {
1957       flag = -1;
1958       q[i] = -q[i];
1959     }
1960 
1961     if (q[i] >= 8192) {
1962       q[i] = 8191;
1963     }
1964 
1965     if (q[i] < 1024) {
1966       coef[i] = flag * ixheaacd_pow_table_Q13[q[i]];
1967     } else {
1968       q1 = (q[i]) >> 3;
1969 
1970       interp = q[i] - (q1 << 3);
1971 
1972       coef[i] = ixheaacd_pow_table_Q13[q1 + 1] - ixheaacd_pow_table_Q13[q1];
1973 
1974       coef[i] = (WORD32)(coef[i] * (WORD32)interp);
1975 
1976       coef[i] = coef[i] + (ixheaacd_pow_table_Q13[q1] << 3);
1977 
1978       coef[i] = flag * (coef[i] << 1);
1979     }
1980     temp = ixheaacd_mult64_sat(fac_fix, (WORD64)coef[i]);
1981 
1982     coef[i] = (WORD32)(temp >> 22);
1983   }
1984 
1985   return;
1986 }
1987 
ixheaacd_apply_scfs_and_nf(WORD32 noise_filling,ia_usac_data_struct * usac_data,WORD32 * quant,WORD32 noise_level,WORD32 noise_offset,UWORD8 max_sfb,WORD32 ch)1988 static void ixheaacd_apply_scfs_and_nf(WORD32 noise_filling,
1989                                        ia_usac_data_struct *usac_data,
1990                                        WORD32 *quant, WORD32 noise_level,
1991                                        WORD32 noise_offset, UWORD8 max_sfb,
1992                                        WORD32 ch) {
1993   WORD32 grp = 0, win_tot = 0, sfb = 0;
1994   WORD32 noise_filling_start_offset = 0;
1995   WORD32 fac = 0, length = 0;
1996   WORD64 fac_fix;
1997   WORD32 noise_level_fix = 0;
1998   ia_sfb_info_struct *pstr_sfb_info = usac_data->pstr_sfb_info[ch];
1999   WORD32 *coef = &usac_data->coef_fix[ch][0];
2000   WORD16 *factors = usac_data->factors[ch];
2001   UWORD32 *seed_value = &usac_data->seed_value[ch];
2002 
2003   if (noise_filling) {
2004     noise_level_fix = ixheaacd_pow_14_3[noise_level];
2005     noise_filling_start_offset = (usac_data->ccfl == 768)
2006                                      ? (pstr_sfb_info->islong ? 120 : 15)
2007                                      : (pstr_sfb_info->islong ? 160 : 20);
2008   }
2009 
2010   for (grp = 0; grp < pstr_sfb_info->num_groups; grp++) {
2011     WORD32 grp_win = 0;
2012     for (sfb = 0; sfb < (WORD32)max_sfb; sfb++) {
2013       WORD32 noise_filling_present = 0;
2014       WORD32 band_quantized_to_zero = 1;
2015 
2016       WORD32 sfb_offset = win_tot * pstr_sfb_info->sfb_per_sbk;
2017       fac = (WORD32)(factors[sfb_offset + sfb] - SF_OFFSET);
2018 
2019       if (noise_filling) {
2020         for (grp_win = 0; grp_win < pstr_sfb_info->group_len[grp]; grp_win++) {
2021           WORD32 win = grp_win + win_tot;
2022           WORD32 ixheaacd_drc_offset = win * pstr_sfb_info->bins_per_sbk;
2023           WORD32 start = (sfb == 0) ? 0 : pstr_sfb_info->ptr_sfb_tbl[sfb - 1];
2024           WORD32 idx = 0;
2025           for (idx = start; idx < pstr_sfb_info->ptr_sfb_tbl[sfb]; idx++) {
2026             if (quant[ixheaacd_drc_offset + idx] != 0) {
2027               band_quantized_to_zero = 0;
2028               break;
2029             }
2030             if (!band_quantized_to_zero) break;
2031           }
2032         }
2033       }
2034 
2035       if (band_quantized_to_zero && noise_filling) fac += (noise_offset - 16);
2036       {
2037         WORD16 exp, frac;
2038 
2039         exp = fac >> 2;
2040         frac = fac & 3;
2041 
2042         if (exp > 31) exp = 31;
2043 
2044         if (fac < 0)
2045           fac_fix = 0;
2046         else {
2047           fac_fix = (WORD64)((WORD64)ixheaacd_table_frac[3 + frac] *
2048                              (WORD64)ixheaacd_table_exp[exp]);
2049           fac_fix >>= 15;
2050         }
2051       }
2052 
2053       for (grp_win = 0; grp_win < pstr_sfb_info->group_len[grp]; grp_win++) {
2054         WORD32 win = win_tot + grp_win;
2055         WORD32 start = (sfb == 0) ? 0 : pstr_sfb_info->ptr_sfb_tbl[sfb - 1];
2056         WORD32 ixheaacd_drc_offset = win * pstr_sfb_info->bins_per_sbk;
2057 
2058         if (noise_filling) {
2059           noise_filling_present =
2060               (start >= noise_filling_start_offset) & noise_filling;
2061         }
2062 
2063         length = pstr_sfb_info->ptr_sfb_tbl[sfb] - start;
2064 
2065         ixheaacd_esc_iquant(&quant[ixheaacd_drc_offset + start],
2066                             &coef[ixheaacd_drc_offset + start], noise_level_fix,
2067                             noise_filling_present, seed_value, length, fac_fix);
2068       }
2069     }
2070 
2071     win_tot += pstr_sfb_info->group_len[grp];
2072   }
2073 
2074   return;
2075 }
2076 
ixheaacd_ac_spectral_data(ia_usac_data_struct * usac_data,WORD32 max_spec_coefficients,WORD32 noise_level,WORD32 noise_offset,WORD32 arith_pres_n,ia_bit_buf_struct * it_bit_buff,UWORD8 max_sfb,WORD32 arith_reset_flag,WORD32 noise_filling,WORD32 ch)2077 WORD32 ixheaacd_ac_spectral_data(ia_usac_data_struct *usac_data,
2078                                  WORD32 max_spec_coefficients,
2079                                  WORD32 noise_level, WORD32 noise_offset,
2080                                  WORD32 arith_pres_n,
2081                                  ia_bit_buf_struct *it_bit_buff, UWORD8 max_sfb,
2082                                  WORD32 arith_reset_flag, WORD32 noise_filling,
2083                                  WORD32 ch) {
2084   WORD32 i;
2085 
2086   WORD32 *x_ac_dec = usac_data->x_ac_dec;
2087   WORD32 sbk;
2088   WORD32 err_code = 0;
2089 
2090   const WORD32 max_win_len = usac_data->pstr_sfb_info[ch]->max_win_len;
2091   WORD8 *c_prev = &usac_data->c_prev[ch][0];
2092   WORD8 *c_pres = &usac_data->c[ch][0];
2093 
2094   WORD8 *ptr_scratch_buf = (WORD8 *)&usac_data->scratch_buffer[0];
2095 
2096   memset(x_ac_dec, 0, 1024 * sizeof(WORD32));
2097 
2098   ixheaacd_arith_map_context(arith_pres_n, usac_data->arith_prev_n[ch], c_prev,
2099                              c_pres, arith_reset_flag, ptr_scratch_buf);
2100 
2101   usac_data->arith_prev_n[ch] = arith_pres_n;
2102 
2103   if (max_spec_coefficients > 0) {
2104     for (sbk = 0; sbk < max_win_len; sbk++) {
2105       err_code = ixheaacd_arth_decoding_level2(
2106           it_bit_buff, c_prev + 2, c_pres + 2, max_spec_coefficients / 2,
2107           arith_pres_n / 2, &x_ac_dec[sbk * arith_pres_n]);
2108       if (err_code != 0) {
2109         return err_code;
2110       }
2111 
2112       for (i = max_spec_coefficients / 2; i < arith_pres_n / 2; i++) {
2113         x_ac_dec[sbk * arith_pres_n + 2 * i + 0] = 0;
2114         x_ac_dec[sbk * arith_pres_n + 2 * i + 1] = 0;
2115       }
2116     }
2117   } else {
2118     for (i = 0; i < (arith_pres_n / 2); i++) {
2119       c_pres[i + 2] = 1;
2120     }
2121   }
2122 
2123   ixheaacd_apply_scfs_and_nf(noise_filling, usac_data, x_ac_dec, noise_level,
2124                              noise_offset, max_sfb, ch);
2125 
2126   return 0;
2127 }
2128 
ixheaacd_arith_data(ia_td_frame_data_struct * pstr_td_frame_data,WORD32 * x_ac_dec,ia_usac_data_struct * usac_data,ia_bit_buf_struct * it_bit_buff,WORD32 first_tcx_flag,WORD32 k)2129 WORD32 ixheaacd_arith_data(ia_td_frame_data_struct *pstr_td_frame_data,
2130                            WORD32 *x_ac_dec, ia_usac_data_struct *usac_data,
2131                            ia_bit_buf_struct *it_bit_buff,
2132                            WORD32 first_tcx_flag, WORD32 k) {
2133   WORD32 *arith_prev_n = &usac_data->arith_prev_n[usac_data->present_chan];
2134   WORD32 arith_reset_flag =
2135       first_tcx_flag && pstr_td_frame_data->arith_reset_flag;
2136   WORD32 err_code = 0;
2137   WORD32 tcx_size = pstr_td_frame_data->tcx_lg[k];
2138   WORD8 *c_prev = usac_data->c_prev[usac_data->present_chan];
2139   WORD8 *c_pres = usac_data->c[usac_data->present_chan];
2140 
2141   WORD8 *ptr_scratch_buf = (WORD8 *)&usac_data->scratch_buffer[0];
2142 
2143   memset(x_ac_dec, 0, tcx_size * sizeof(WORD32));
2144 
2145   ixheaacd_arith_map_context(tcx_size, *arith_prev_n, c_prev, c_pres,
2146                              arith_reset_flag, ptr_scratch_buf);
2147 
2148   *arith_prev_n = tcx_size;
2149 
2150   err_code =
2151       ixheaacd_arth_decoding_level2(it_bit_buff, c_prev + 2, c_pres + 2,
2152                                     tcx_size / 2, tcx_size / 2, x_ac_dec);
2153 
2154   return err_code;
2155 }
2156