/src/libxaac/decoder/ixheaacd_rev_vlc.c
Line | Count | Source |
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 | | |
21 | | #include <string.h> |
22 | | #include "ixheaacd_sbr_common.h" |
23 | | #include "ixheaac_type_def.h" |
24 | | |
25 | | #include "ixheaac_constants.h" |
26 | | #include "ixheaac_basic_ops32.h" |
27 | | #include "ixheaac_basic_ops16.h" |
28 | | #include "ixheaac_basic_ops40.h" |
29 | | #include "ixheaac_basic_ops.h" |
30 | | |
31 | | #include "ixheaacd_bitbuffer.h" |
32 | | #include "ixheaacd_error_codes.h" |
33 | | #include "ixheaacd_defines.h" |
34 | | #include "ixheaacd_aac_rom.h" |
35 | | #include "ixheaacd_pulsedata.h" |
36 | | |
37 | | #include "ixheaacd_pns.h" |
38 | | #include "ixheaacd_drc_data_struct.h" |
39 | | |
40 | | #include "ixheaacd_lt_predict.h" |
41 | | #include "ixheaacd_cnst.h" |
42 | | #include "ixheaacd_ec_defines.h" |
43 | | #include "ixheaacd_ec_struct_def.h" |
44 | | #include "ixheaacd_channelinfo.h" |
45 | | |
46 | | #include "ixheaacd_drc_dec.h" |
47 | | |
48 | | #include "ixheaacd_sbrdecoder.h" |
49 | | |
50 | | #include "ixheaacd_block.h" |
51 | | #include "ixheaacd_channel.h" |
52 | | |
53 | | #include "ixheaacd_common_rom.h" |
54 | | #include "ixheaacd_basic_funcs.h" |
55 | | #include "ixheaac_basic_op.h" |
56 | | |
57 | | #include "ixheaacd_aacdec.h" |
58 | | |
59 | | #include "ixheaacd_sbrdecsettings.h" |
60 | | #include "ixheaacd_sbr_scale.h" |
61 | | #include "ixheaacd_env_extr_part.h" |
62 | | #include "ixheaacd_sbr_rom.h" |
63 | | #include "ixheaacd_audioobjtypes.h" |
64 | | #include "ixheaacd_sbrdecoder.h" |
65 | | #include "ixheaacd_memory_standards.h" |
66 | | #include "ixheaacd_latmdemux.h" |
67 | | #include "ixheaacd_mps_polyphase.h" |
68 | | #include "ixheaacd_config.h" |
69 | | #include "ixheaacd_hybrid.h" |
70 | | #include "ixheaacd_ps_dec.h" |
71 | | #include "ixheaacd_qmf_dec.h" |
72 | | #include "ixheaacd_mps_macro_def.h" |
73 | | #include "ixheaacd_mps_struct_def.h" |
74 | | #include "ixheaacd_mps_res_rom.h" |
75 | | #include "ixheaacd_mps_aac_struct.h" |
76 | | #include "ixheaacd_mps_dec.h" |
77 | | #include "ixheaacd_mps_interface.h" |
78 | | #include "ixheaacd_struct_def.h" |
79 | | #include "ixheaacd_cnst.h" |
80 | | #include "ixheaac_error_standards.h" |
81 | | |
82 | 2 | #define RVLC_ERROR_ALL_ESCAPE_WORDS_INVALID 0x80000000 |
83 | 72.9k | #define RVLC_ERROR_FORBIDDEN_CW_DETECTED_FWD 0x08000000 |
84 | 72.9k | #define RVLC_ERROR_FORBIDDEN_CW_DETECTED_BWD 0x04000000 |
85 | | |
86 | 4.57M | #define FWD 0 |
87 | | #define BWD 1 |
88 | | |
89 | 2.41M | #define MAX_LEN_RVLC_CODE_WORD 9 |
90 | 3.03M | #define MAX_LEN_RVLC_ESCAPE_WORD 20 |
91 | | |
92 | 394k | #define CONCEAL_MAX_INIT 1311 |
93 | 364k | #define CONCEAL_MIN_INIT -1311 |
94 | | |
95 | 9.42M | #define RVLC_MAX_SFB ((8) * (16)) |
96 | | |
97 | 0 | #define MASK_LEFT 0xFFF000 |
98 | 0 | #define MASK_RIGHT 0xFFF |
99 | 0 | #define CLR_BIT_10 0x3FF |
100 | 0 | #define LEFT_OFFSET 12 |
101 | | |
102 | | #define ixheaacd_bitbuf_checkpoint(it_bit_buf, saved_bit_buf) \ |
103 | 72.9k | (saved_bit_buf) = (it_bit_buf) |
104 | | #define ixheaacd_bitbuf_restore(it_bit_buf, saved_bit_buf) \ |
105 | 72.9k | (it_bit_buf) = (saved_bit_buf) |
106 | | |
107 | 3.23M | static WORD32 ixheaacd_rvlc_decode(WORD16 cw, WORD32 len, WORD32 *found) { |
108 | 3.23M | WORD16 indx = 0; |
109 | 3.23M | *found = 0; |
110 | 3.23M | switch (len) { |
111 | 1.22M | case 1: |
112 | 1.22M | if (cw == 0) |
113 | 687k | indx = 0; |
114 | 539k | else |
115 | 539k | return 3; |
116 | 687k | break; |
117 | 687k | case 3: |
118 | 539k | switch (cw) { |
119 | 97.7k | case 5: |
120 | 97.7k | indx = -1; |
121 | 97.7k | break; |
122 | 198k | case 7: |
123 | 198k | indx = 1; |
124 | 198k | break; |
125 | 243k | default: |
126 | 243k | return 4; |
127 | 539k | } |
128 | 296k | break; |
129 | 296k | case 4: |
130 | 243k | if (cw == 9) |
131 | 19.5k | indx = -2; |
132 | 223k | else |
133 | 223k | return 5; |
134 | 19.5k | break; |
135 | 223k | case 5: |
136 | 223k | switch (cw) { |
137 | 34.9k | case 17: |
138 | 34.9k | indx = -3; |
139 | 34.9k | break; |
140 | 17.8k | case 27: |
141 | 17.8k | indx = 2; |
142 | 17.8k | break; |
143 | 170k | default: |
144 | 170k | return 6; |
145 | 223k | } |
146 | 52.7k | break; |
147 | 170k | case 6: |
148 | 170k | switch (cw) { |
149 | 6.22k | case 33: |
150 | 6.22k | indx = -4; |
151 | 6.22k | break; |
152 | 5.73k | case 51: |
153 | 5.73k | indx = 3; |
154 | 5.73k | break; |
155 | 158k | default: |
156 | 158k | return 7; |
157 | 170k | } |
158 | 11.9k | break; |
159 | 158k | case 7: |
160 | 158k | switch (cw) { |
161 | 39.1k | case 65: |
162 | 39.1k | indx = -7; |
163 | 39.1k | break; |
164 | 23.5k | case 107: |
165 | 23.5k | indx = 4; |
166 | 23.5k | break; |
167 | 25.1k | case 99: |
168 | 25.1k | indx = 7; |
169 | 25.1k | break; |
170 | 71.0k | default: |
171 | 71.0k | return 8; |
172 | 158k | } |
173 | 87.8k | break; |
174 | 87.8k | case 8: |
175 | 71.0k | switch (cw) { |
176 | 1.36k | case 129: |
177 | 1.36k | indx = -5; |
178 | 1.36k | break; |
179 | 3.08k | case 195: |
180 | 3.08k | indx = 5; |
181 | 3.08k | break; |
182 | 66.5k | default: |
183 | 66.5k | return 9; |
184 | 71.0k | } |
185 | 4.45k | break; |
186 | 66.5k | case 9: |
187 | 66.5k | switch (cw) { |
188 | 10.6k | case 257: |
189 | 10.6k | indx = -6; |
190 | 10.6k | break; |
191 | 20.6k | case 427: |
192 | 20.6k | indx = 6; |
193 | 20.6k | break; |
194 | 35.2k | default: |
195 | 35.2k | return -1; |
196 | 66.5k | } |
197 | 31.2k | break; |
198 | 539k | default: |
199 | 539k | return -1; |
200 | 3.23M | } |
201 | 1.19M | *found = 1; |
202 | 1.19M | return indx; |
203 | 3.23M | } |
204 | | |
205 | 4.57M | static WORD32 ixheaacd_rvlc_decode_esc(WORD32 cw, WORD32 len, WORD32 *found) { |
206 | 4.57M | WORD16 indx = 0; |
207 | 4.57M | *found = 0; |
208 | 4.57M | switch (len) { |
209 | 1.51M | case 2: |
210 | 1.51M | switch (cw) { |
211 | 277k | case 2: |
212 | 277k | indx = 0; |
213 | 277k | break; |
214 | 609k | case 0: |
215 | 609k | indx = 1; |
216 | 609k | break; |
217 | 631k | default: |
218 | 631k | return 3; |
219 | 1.51M | } |
220 | 886k | break; |
221 | 886k | case 3: |
222 | 631k | switch (cw) { |
223 | 149k | case 6: |
224 | 149k | indx = 2; |
225 | 149k | break; |
226 | 91.9k | case 2: |
227 | 91.9k | indx = 3; |
228 | 91.9k | break; |
229 | 390k | default: |
230 | 390k | return 4; |
231 | 631k | } |
232 | 241k | break; |
233 | 390k | case 4: |
234 | 390k | if (cw == 14) |
235 | 60.8k | indx = 4; |
236 | 329k | else |
237 | 329k | return 5; |
238 | 60.8k | break; |
239 | 329k | case 5: |
240 | 329k | switch (cw) { |
241 | 188k | case 31: |
242 | 188k | indx = 5; |
243 | 188k | break; |
244 | 31.4k | case 15: |
245 | 31.4k | indx = 6; |
246 | 31.4k | break; |
247 | 16.0k | case 13: |
248 | 16.0k | indx = 7; |
249 | 16.0k | break; |
250 | 93.3k | default: |
251 | 93.3k | return 6; |
252 | 329k | } |
253 | 236k | break; |
254 | 236k | case 6: |
255 | 93.3k | switch (cw) { |
256 | 11.0k | case 61: |
257 | 11.0k | indx = 8; |
258 | 11.0k | break; |
259 | 12.0k | case 29: |
260 | 12.0k | indx = 9; |
261 | 12.0k | break; |
262 | 23.6k | case 25: |
263 | 23.6k | indx = 10; |
264 | 23.6k | break; |
265 | 8.89k | case 24: |
266 | 8.89k | indx = 11; |
267 | 8.89k | break; |
268 | 37.6k | default: |
269 | 37.6k | return 7; |
270 | 93.3k | } |
271 | 55.7k | break; |
272 | 55.7k | case 7: |
273 | 37.6k | switch (cw) { |
274 | 14.9k | case 120: |
275 | 14.9k | indx = 12; |
276 | 14.9k | break; |
277 | 8.41k | case 56: |
278 | 8.41k | indx = 13; |
279 | 8.41k | break; |
280 | 14.2k | default: |
281 | 14.2k | return 8; |
282 | 37.6k | } |
283 | 23.4k | break; |
284 | 23.4k | case 8: |
285 | 14.2k | switch (cw) { |
286 | 2.92k | case 242: |
287 | 2.92k | indx = 14; |
288 | 2.92k | break; |
289 | 1.64k | case 114: |
290 | 1.64k | indx = 15; |
291 | 1.64k | break; |
292 | 9.64k | default: |
293 | 9.64k | return 9; |
294 | 14.2k | } |
295 | 4.56k | break; |
296 | 9.64k | case 9: |
297 | 9.64k | switch (cw) { |
298 | 534 | case 486: |
299 | 534 | indx = 16; |
300 | 534 | break; |
301 | 1.71k | case 230: |
302 | 1.71k | indx = 17; |
303 | 1.71k | break; |
304 | 7.38k | default: |
305 | 7.38k | return 10; |
306 | 9.64k | } |
307 | 2.25k | break; |
308 | 7.38k | case 10: |
309 | 7.38k | switch (cw) { |
310 | 2.44k | case 974: |
311 | 2.44k | indx = 18; |
312 | 2.44k | break; |
313 | 94 | case 463: |
314 | 94 | indx = 19; |
315 | 94 | break; |
316 | 4.85k | default: |
317 | 4.85k | return 11; |
318 | 7.38k | } |
319 | 2.53k | break; |
320 | 4.85k | case 11: |
321 | 4.85k | switch (cw) { |
322 | 192 | case 1950: |
323 | 192 | indx = 20; |
324 | 192 | break; |
325 | 205 | case 1951: |
326 | 205 | indx = 21; |
327 | 205 | break; |
328 | 1.34k | case 925: |
329 | 1.34k | indx = 22; |
330 | 1.34k | break; |
331 | 3.10k | default: |
332 | 3.10k | return 12; |
333 | 4.85k | } |
334 | 1.74k | break; |
335 | 3.10k | case 12: |
336 | 3.10k | if (cw == 1848) |
337 | 142 | indx = 23; |
338 | 2.96k | else |
339 | 2.96k | return 13; |
340 | 142 | break; |
341 | 2.96k | case 13: |
342 | 2.96k | if (cw == 3698) |
343 | 322 | indx = 25; |
344 | 2.64k | else |
345 | 2.64k | return 14; |
346 | 322 | break; |
347 | 2.64k | case 14: |
348 | 2.64k | if (cw == 7399) |
349 | 17 | indx = 24; |
350 | 2.62k | else |
351 | 2.62k | return 15; |
352 | 17 | break; |
353 | 2.62k | case 15: |
354 | 2.62k | if (cw == 14797) |
355 | 574 | indx = 26; |
356 | 2.05k | else |
357 | 2.05k | return 19; |
358 | 574 | break; |
359 | 2.05k | case 19: |
360 | 2.05k | if ((cw >= 236736) && (cw <= 236740)) |
361 | 701 | indx = 53 - (236740 - cw); |
362 | 1.34k | else |
363 | 1.34k | return 20; |
364 | 701 | break; |
365 | 1.34k | case 20: |
366 | 1.34k | if ((cw >= 473482) && (cw <= 473503)) |
367 | 1.34k | indx = 48 - (473503 - cw); |
368 | 0 | else |
369 | 0 | return -1; |
370 | 1.34k | break; |
371 | 1.52M | default: |
372 | 1.52M | return -1; |
373 | 4.57M | } |
374 | 1.51M | *found = 1; |
375 | 1.51M | return indx; |
376 | 4.57M | } |
377 | | static VOID ixheaacd_rvlc_check_intensity_cb( |
378 | | ia_rvlc_info_struct *ptr_rvlc, |
379 | 72.9k | ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info) { |
380 | 72.9k | WORD32 group, band, bnds; |
381 | | |
382 | 72.9k | ptr_rvlc->intensity_used = 0; |
383 | | |
384 | 159k | for (group = 0; group < ptr_rvlc->num_wind_grps; group++) { |
385 | 609k | for (band = 0; band < ptr_rvlc->max_sfb_transmitted; band++) { |
386 | 544k | bnds = 16 * group + band; |
387 | 544k | if ((ptr_aac_dec_channel_info->ptr_code_book[bnds] == INTENSITY_HCB) || |
388 | 534k | (ptr_aac_dec_channel_info->ptr_code_book[bnds] == INTENSITY_HCB2)) { |
389 | 21.3k | ptr_rvlc->intensity_used = 1; |
390 | 21.3k | break; |
391 | 21.3k | } |
392 | 544k | } |
393 | 86.6k | } |
394 | 72.9k | } |
395 | | |
396 | | VOID ixheaacd_carry_bit_branch_val(UWORD8 carry_bit, UWORD32 tree_node, |
397 | 0 | UWORD32 *branch_val, UWORD32 *branch_node) { |
398 | 0 | if (carry_bit == 0) { |
399 | 0 | *branch_node = (tree_node & MASK_LEFT) >> LEFT_OFFSET; |
400 | 0 | } else { |
401 | 0 | *branch_node = tree_node & MASK_RIGHT; |
402 | 0 | } |
403 | |
|
404 | 0 | *branch_val = *branch_node & CLR_BIT_10; |
405 | 0 | } |
406 | | |
407 | | UWORD8 ixheaacd_rvlc_read_bits(ia_bit_buf_struct *it_bit_buff, |
408 | 7.81M | UWORD16 *ptr_position, UWORD8 read_direction) { |
409 | 7.81M | UWORD32 bit; |
410 | 7.81M | WORD32 read_bit_offset = |
411 | 7.81M | *ptr_position - (it_bit_buff->size - it_bit_buff->cnt_bits); |
412 | | |
413 | 7.81M | if (read_bit_offset) it_bit_buff->cnt_bits -= read_bit_offset; |
414 | | |
415 | 7.81M | it_bit_buff->ptr_read_next = |
416 | 7.81M | it_bit_buff->ptr_bit_buf_base + |
417 | 7.81M | ((it_bit_buff->size - it_bit_buff->cnt_bits) >> 3); |
418 | 7.81M | it_bit_buff->bit_pos = ((it_bit_buff->size - it_bit_buff->cnt_bits) & 7); |
419 | | |
420 | 7.81M | if (read_direction == 0) { |
421 | 6.24M | bit = ixheaacd_aac_read_bit_rev(it_bit_buff); |
422 | | |
423 | 6.24M | *ptr_position += 1; |
424 | 6.24M | } else { |
425 | 1.57M | bit = ixheaacd_aac_read_bit(it_bit_buff); |
426 | | |
427 | 1.57M | *ptr_position -= 1; |
428 | 1.57M | } |
429 | | |
430 | 7.81M | return (bit); |
431 | 7.81M | } |
432 | | |
433 | | static WORD8 ixheaacd_rvlc_decode_escape_word(ia_rvlc_info_struct *ptr_rvlc, |
434 | 1.51M | ia_bit_buf_struct *it_bit_buff) { |
435 | 1.51M | WORD32 i; |
436 | | |
437 | 1.51M | UWORD8 carry_bit; |
438 | | |
439 | 1.51M | UWORD16 *ptr_bitstream_index_esc; |
440 | | |
441 | 1.51M | int len = 0; |
442 | 1.51M | int codeword = 0; |
443 | 1.51M | int found = 0; |
444 | 1.51M | int indx; |
445 | | |
446 | 1.51M | ptr_bitstream_index_esc = &(ptr_rvlc->esc_bit_str_idx); |
447 | | |
448 | 4.57M | for (i = MAX_LEN_RVLC_ESCAPE_WORD - 1; i >= 0; i--) { |
449 | 4.57M | carry_bit = |
450 | 4.57M | ixheaacd_rvlc_read_bits(it_bit_buff, ptr_bitstream_index_esc, FWD); |
451 | | |
452 | 4.57M | len++; |
453 | 4.57M | codeword = codeword << 1 | carry_bit; |
454 | 4.57M | indx = ixheaacd_rvlc_decode_esc(codeword, len, &found); |
455 | | |
456 | 4.57M | if (found) { |
457 | 1.51M | ptr_rvlc->rvlc_esc_len -= (MAX_LEN_RVLC_ESCAPE_WORD - i); |
458 | 1.51M | return indx; |
459 | 1.51M | } |
460 | 4.57M | } |
461 | | |
462 | 1 | ptr_rvlc->rvlc_err_log |= RVLC_ERROR_ALL_ESCAPE_WORDS_INVALID; |
463 | | |
464 | 1 | return -1; |
465 | 1.51M | } |
466 | | |
467 | | static VOID ixheaacd_rvlc_decode_escape(ia_rvlc_info_struct *ptr_rvlc, |
468 | | WORD16 *ptr_escape, |
469 | 36.2k | ia_bit_buf_struct *it_bit_buff) { |
470 | 36.2k | WORD8 esc_word; |
471 | 36.2k | WORD8 esc_cnt = 0; |
472 | 36.2k | WORD16 *ptr_esc_bit_cnt_sum; |
473 | | |
474 | 36.2k | ptr_esc_bit_cnt_sum = &(ptr_rvlc->rvlc_esc_len); |
475 | | |
476 | 1.55M | while (*ptr_esc_bit_cnt_sum > 0) { |
477 | 1.51M | esc_word = ixheaacd_rvlc_decode_escape_word(ptr_rvlc, it_bit_buff); |
478 | | |
479 | 1.51M | if (esc_word >= 0) { |
480 | 1.51M | ptr_escape[esc_cnt] = esc_word; |
481 | 1.51M | esc_cnt++; |
482 | 1.51M | } else { |
483 | 1 | ptr_rvlc->rvlc_err_log |= RVLC_ERROR_ALL_ESCAPE_WORDS_INVALID; |
484 | 1 | ptr_rvlc->num_esc_words_decoded = esc_cnt; |
485 | | |
486 | 1 | return; |
487 | 1 | } |
488 | 1.51M | } |
489 | | |
490 | 36.2k | ptr_rvlc->num_esc_words_decoded = esc_cnt; |
491 | 36.2k | } |
492 | | |
493 | | WORD8 ixheaacd_decode_rvlc_code_word(ia_bit_buf_struct *it_bit_buff, |
494 | 1.22M | ia_rvlc_info_struct *ptr_rvlc) { |
495 | 1.22M | WORD32 i; |
496 | | |
497 | 1.22M | UWORD8 carry_bit; |
498 | | |
499 | 1.22M | UWORD8 direction = ptr_rvlc->direction; |
500 | 1.22M | UWORD16 *ptr_bit_str_idx_rvl = ptr_rvlc->ptr_rvl_bit_str_idx; |
501 | | |
502 | 1.22M | int len = 0; |
503 | 1.22M | short codeword = 0; |
504 | 1.22M | int found = 0; |
505 | 1.22M | int indx; |
506 | | |
507 | 3.27M | for (i = MAX_LEN_RVLC_CODE_WORD - 1; i >= 0; i--) { |
508 | 3.23M | carry_bit = |
509 | 3.23M | ixheaacd_rvlc_read_bits(it_bit_buff, ptr_bit_str_idx_rvl, direction); |
510 | | |
511 | 3.23M | len++; |
512 | 3.23M | codeword = codeword << 1 | carry_bit; |
513 | 3.23M | indx = ixheaacd_rvlc_decode(codeword, len, &found); |
514 | 3.23M | if (found) { |
515 | 1.19M | indx = indx + 7; |
516 | 1.19M | *ptr_rvlc->ptr_rvl_bit_cnt -= (MAX_LEN_RVLC_CODE_WORD - i); |
517 | 1.19M | return indx; |
518 | 1.19M | } |
519 | 3.23M | } |
520 | | |
521 | 35.3k | return -1; |
522 | 1.22M | } |
523 | | |
524 | | static VOID ixheaacd_rvlc_decode_forward( |
525 | | ia_rvlc_info_struct *ptr_rvlc, |
526 | | ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, |
527 | 72.9k | ia_bit_buf_struct *it_bit_buff) { |
528 | 72.9k | WORD32 band = 0; |
529 | 72.9k | WORD32 group = 0; |
530 | 72.9k | WORD32 bnds = 0; |
531 | | |
532 | 72.9k | WORD16 dpcm; |
533 | | |
534 | 72.9k | ia_bit_buf_struct temp_buf = {0}; |
535 | | |
536 | 72.9k | WORD16 factor = ptr_aac_dec_channel_info->global_gain; |
537 | 72.9k | WORD16 position = 0; |
538 | 72.9k | WORD16 noise_energy = ptr_aac_dec_channel_info->global_gain - 90 - 256; |
539 | | |
540 | 72.9k | WORD16 *ptr_scf_fwd = ptr_aac_dec_channel_info->rvlc_scf_fwd_arr; |
541 | 72.9k | WORD16 *ptr_scf_esc = ptr_aac_dec_channel_info->rvlc_scf_esc_arr; |
542 | 72.9k | UWORD8 *ptr_esc_fwd_cnt = &(ptr_rvlc->num_fwd_esc_words_decoded); |
543 | | |
544 | 72.9k | ptr_rvlc->ptr_rvl_bit_cnt = &(ptr_rvlc->rvlc_sf_fwd_len); |
545 | 72.9k | ptr_rvlc->ptr_rvl_bit_str_idx = &(ptr_rvlc->rvl_fwd_bit_str_idx); |
546 | | |
547 | 72.9k | *ptr_esc_fwd_cnt = 0; |
548 | 72.9k | ptr_rvlc->direction = 0; |
549 | 72.9k | ptr_rvlc->noise_used = 0; |
550 | 72.9k | ptr_rvlc->sf_used = 0; |
551 | 72.9k | ptr_rvlc->last_scale_fac = 0; |
552 | 72.9k | ptr_rvlc->last_nrg = 0; |
553 | 72.9k | ptr_rvlc->is_last = 0; |
554 | | |
555 | 72.9k | ixheaacd_rvlc_check_intensity_cb(ptr_rvlc, ptr_aac_dec_channel_info); |
556 | | |
557 | 138k | for (group = 0; group < ptr_rvlc->num_wind_grps; group++) { |
558 | 819k | for (band = 0; band < ptr_rvlc->max_sfb_transmitted; band++) { |
559 | 753k | bnds = 16 * group + band; |
560 | | |
561 | 753k | switch (ptr_aac_dec_channel_info->ptr_code_book[bnds]) { |
562 | 85.1k | case ZERO_HCB: |
563 | 85.1k | ptr_scf_fwd[bnds] = 0; |
564 | 85.1k | break; |
565 | | |
566 | 74.2k | case INTENSITY_HCB2: |
567 | 209k | case INTENSITY_HCB: |
568 | | |
569 | 209k | { |
570 | 209k | dpcm = ixheaacd_decode_rvlc_code_word(it_bit_buff, ptr_rvlc); |
571 | 209k | if (dpcm < 0) { |
572 | 5.54k | ptr_rvlc->conceal_max = bnds; |
573 | 5.54k | return; |
574 | 5.54k | } |
575 | 204k | dpcm -= 7; |
576 | 204k | } |
577 | 204k | if ((dpcm == -7) || (dpcm == 7)) { |
578 | 13.2k | if (ptr_rvlc->rvlc_esc_len) { |
579 | 2.02k | ptr_rvlc->conceal_max = bnds; |
580 | 2.02k | return; |
581 | 11.2k | } else { |
582 | 11.2k | if (dpcm == -7) { |
583 | 6.75k | dpcm -= *ptr_scf_esc++; |
584 | 6.75k | } else { |
585 | 4.49k | dpcm += *ptr_scf_esc++; |
586 | 4.49k | } |
587 | 11.2k | (*ptr_esc_fwd_cnt)++; |
588 | 11.2k | if (ptr_rvlc->conceal_max_esc == 1311) { |
589 | 1.72k | ptr_rvlc->conceal_max_esc = bnds; |
590 | 1.72k | } |
591 | 11.2k | } |
592 | 13.2k | } |
593 | 202k | position += dpcm; |
594 | 202k | ptr_scf_fwd[bnds] = position; |
595 | 202k | ptr_rvlc->is_last = position; |
596 | 202k | break; |
597 | | |
598 | 304k | case NOISE_HCB: |
599 | 304k | if (ptr_rvlc->noise_used == 0) { |
600 | 23.8k | ptr_rvlc->noise_used = 1; |
601 | 23.8k | ptr_rvlc->first_noise_band = bnds; |
602 | 23.8k | noise_energy += ptr_rvlc->dpcm_noise_nrg; |
603 | 23.8k | ptr_scf_fwd[bnds] = noise_energy; |
604 | 23.8k | ptr_rvlc->last_nrg = noise_energy; |
605 | 280k | } else { |
606 | 280k | dpcm = ixheaacd_decode_rvlc_code_word(it_bit_buff, ptr_rvlc); |
607 | 280k | if (dpcm < 0) { |
608 | 6.90k | ptr_rvlc->conceal_max = bnds; |
609 | 6.90k | return; |
610 | 6.90k | } |
611 | 273k | dpcm -= 7; |
612 | 273k | if ((dpcm == -7) || (dpcm == 7)) { |
613 | 12.3k | if (ptr_rvlc->rvlc_esc_len) { |
614 | 1.37k | ptr_rvlc->conceal_max = bnds; |
615 | 1.37k | return; |
616 | 10.9k | } else { |
617 | 10.9k | if (dpcm == -7) { |
618 | 7.85k | dpcm -= *ptr_scf_esc++; |
619 | 7.85k | } else { |
620 | 3.09k | dpcm += *ptr_scf_esc++; |
621 | 3.09k | } |
622 | 10.9k | (*ptr_esc_fwd_cnt)++; |
623 | 10.9k | if (ptr_rvlc->conceal_max_esc == 1311) { |
624 | 3.10k | ptr_rvlc->conceal_max_esc = bnds; |
625 | 3.10k | } |
626 | 10.9k | } |
627 | 12.3k | } |
628 | 272k | noise_energy += dpcm; |
629 | 272k | ptr_scf_fwd[bnds] = noise_energy; |
630 | 272k | ptr_rvlc->last_nrg = noise_energy; |
631 | 272k | } |
632 | 295k | ptr_aac_dec_channel_info->str_pns_info.pns_used[bnds] = 1; |
633 | 295k | break; |
634 | | |
635 | 154k | default: |
636 | 154k | ptr_rvlc->sf_used = 1; |
637 | 154k | { |
638 | 154k | memcpy(&temp_buf, it_bit_buff, sizeof(ia_bit_buf_struct)); |
639 | | |
640 | 154k | dpcm = ixheaacd_decode_rvlc_code_word(it_bit_buff, ptr_rvlc); |
641 | 154k | if (dpcm < 0) { |
642 | 3.02k | ptr_rvlc->conceal_max = bnds; |
643 | 3.02k | return; |
644 | 3.02k | } |
645 | 151k | dpcm -= 7; |
646 | 151k | } |
647 | 151k | if ((dpcm == -7) || (dpcm == 7)) { |
648 | 5.94k | if (ptr_rvlc->rvlc_esc_len) { |
649 | 2.56k | ptr_rvlc->conceal_max = bnds; |
650 | 2.56k | return; |
651 | 3.38k | } else { |
652 | 3.38k | if (dpcm == -7) { |
653 | 2.25k | dpcm -= *ptr_scf_esc++; |
654 | 2.25k | } else { |
655 | 1.13k | dpcm += *ptr_scf_esc++; |
656 | 1.13k | } |
657 | 3.38k | (*ptr_esc_fwd_cnt)++; |
658 | 3.38k | if (ptr_rvlc->conceal_max_esc == 1311) { |
659 | 2.87k | ptr_rvlc->conceal_max_esc = bnds; |
660 | 2.87k | } |
661 | 3.38k | } |
662 | 5.94k | } |
663 | 149k | factor += dpcm; |
664 | 149k | ptr_scf_fwd[bnds] = factor; |
665 | 149k | ptr_rvlc->last_scale_fac = factor; |
666 | 149k | break; |
667 | 753k | } |
668 | 753k | } |
669 | 86.6k | } |
670 | | |
671 | 51.5k | if (ptr_rvlc->intensity_used) { |
672 | 8.78k | dpcm = ixheaacd_decode_rvlc_code_word(it_bit_buff, ptr_rvlc); |
673 | 8.78k | if (dpcm < 0) { |
674 | 317 | ptr_rvlc->conceal_max = bnds; |
675 | 317 | return; |
676 | 317 | } |
677 | 8.46k | dpcm -= 7; |
678 | 8.46k | if ((dpcm == -7) || (dpcm == 7)) { |
679 | 1.20k | if (ptr_rvlc->rvlc_esc_len) { |
680 | 137 | ptr_rvlc->conceal_max = bnds; |
681 | 137 | return; |
682 | 1.06k | } else { |
683 | 1.06k | if (dpcm == -7) { |
684 | 449 | dpcm -= *ptr_scf_esc++; |
685 | 619 | } else { |
686 | 619 | dpcm += *ptr_scf_esc++; |
687 | 619 | } |
688 | 1.06k | (*ptr_esc_fwd_cnt)++; |
689 | 1.06k | if (ptr_rvlc->conceal_max_esc == 1311) { |
690 | 782 | ptr_rvlc->conceal_max_esc = bnds; |
691 | 782 | } |
692 | 1.06k | } |
693 | 1.20k | } |
694 | 8.33k | ptr_rvlc->dpcm_is_last_pos = dpcm; |
695 | 8.33k | } |
696 | 51.5k | } |
697 | | |
698 | | static VOID ixheaacd_rvlc_decode_backward( |
699 | | ia_rvlc_info_struct *ptr_rvlc, |
700 | | ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, |
701 | 72.9k | ia_bit_buf_struct *it_bit_buff) { |
702 | 72.9k | WORD16 band, group, dpcm; |
703 | 72.9k | WORD16 bnds = ptr_rvlc->max_sfb_transmitted - 1; |
704 | | |
705 | 72.9k | WORD16 factor = ptr_rvlc->rev_global_gain; |
706 | 72.9k | WORD16 position = ptr_rvlc->dpcm_is_last_pos; |
707 | 72.9k | WORD16 noise_energy = |
708 | 72.9k | ptr_rvlc->rev_global_gain + ptr_rvlc->dpcm_noise_last_pos - 90 - 256; |
709 | | |
710 | 72.9k | WORD16 *ptr_scf_bwd = ptr_aac_dec_channel_info->rvlc_scf_bwd_arr; |
711 | 72.9k | WORD16 *ptr_scf_esc = ptr_aac_dec_channel_info->rvlc_scf_esc_arr; |
712 | 72.9k | UWORD8 *ptr_esc_cnt = &(ptr_rvlc->num_esc_words_decoded); |
713 | 72.9k | UWORD8 *ptr_esc_bwd_cnt = &(ptr_rvlc->num_bwd_esc_words_decoded); |
714 | | |
715 | 72.9k | ptr_rvlc->ptr_rvl_bit_cnt = &(ptr_rvlc->rvlc_sf_bwd_len); |
716 | 72.9k | ptr_rvlc->ptr_rvl_bit_str_idx = &(ptr_rvlc->rvl_bwd_bit_str_idx); |
717 | | |
718 | 72.9k | *ptr_esc_bwd_cnt = 0; |
719 | 72.9k | ptr_rvlc->direction = 1; |
720 | 72.9k | ptr_scf_esc += *ptr_esc_cnt - 1; |
721 | 72.9k | ptr_rvlc->firt_scale_fac = 0; |
722 | 72.9k | ptr_rvlc->first_nrg = 0; |
723 | 72.9k | ptr_rvlc->is_first = 0; |
724 | | |
725 | 72.9k | if (ptr_rvlc->intensity_used) { |
726 | 21.3k | dpcm = ixheaacd_decode_rvlc_code_word(it_bit_buff, ptr_rvlc); |
727 | 21.3k | if (dpcm < 0) { |
728 | 2.75k | ptr_rvlc->dpcm_is_last_pos = 0; |
729 | 2.75k | ptr_rvlc->conceal_min = bnds; |
730 | 2.75k | return; |
731 | 2.75k | } |
732 | 18.5k | dpcm -= 7; |
733 | 18.5k | if ((dpcm == -7) || (dpcm == 7)) { |
734 | 2.06k | if (ptr_rvlc->rvlc_esc_len) { |
735 | 1.31k | ptr_rvlc->conceal_min = bnds; |
736 | 1.31k | return; |
737 | 1.31k | } else { |
738 | 744 | if (dpcm == -7) { |
739 | 500 | dpcm -= *ptr_scf_esc--; |
740 | 500 | } else { |
741 | 244 | dpcm += *ptr_scf_esc--; |
742 | 244 | } |
743 | 744 | (*ptr_esc_bwd_cnt)++; |
744 | 744 | if (ptr_rvlc->conceal_min_esc == -1311) { |
745 | 744 | ptr_rvlc->conceal_min_esc = bnds; |
746 | 744 | } |
747 | 744 | } |
748 | 2.06k | } |
749 | 17.2k | ptr_rvlc->dpcm_is_last_pos = dpcm; |
750 | 17.2k | } |
751 | | |
752 | 130k | for (group = ptr_rvlc->num_wind_grps - 1; group >= 0; group--) { |
753 | 683k | for (band = ptr_rvlc->max_sfb_transmitted - 1; band >= 0; band--) { |
754 | 621k | bnds = 16 * group + band; |
755 | | |
756 | 621k | switch (ptr_aac_dec_channel_info->ptr_code_book[bnds]) { |
757 | 55.1k | case ZERO_HCB: |
758 | 55.1k | ptr_scf_bwd[bnds] = 0; |
759 | 55.1k | break; |
760 | | |
761 | 72.4k | case INTENSITY_HCB2: |
762 | 170k | case INTENSITY_HCB: |
763 | | |
764 | 170k | dpcm = ixheaacd_decode_rvlc_code_word(it_bit_buff, ptr_rvlc); |
765 | 170k | if (dpcm < 0) { |
766 | 4.28k | ptr_scf_bwd[bnds] = position; |
767 | | |
768 | 4.28k | return; |
769 | 4.28k | } |
770 | 166k | dpcm -= 7; |
771 | 166k | if ((dpcm == -7) || (dpcm == 7)) { |
772 | 8.80k | if (ptr_rvlc->rvlc_esc_len) { |
773 | 1.56k | ptr_scf_bwd[bnds] = position; |
774 | | |
775 | 1.56k | return; |
776 | 7.23k | } else { |
777 | 7.23k | if (dpcm == -7) { |
778 | 2.65k | dpcm -= *ptr_scf_esc--; |
779 | 4.57k | } else { |
780 | 4.57k | dpcm += *ptr_scf_esc--; |
781 | 4.57k | } |
782 | 7.23k | (*ptr_esc_bwd_cnt)++; |
783 | 7.23k | if (ptr_rvlc->conceal_min_esc == -1311) { |
784 | 3.17k | } |
785 | 7.23k | } |
786 | 8.80k | } |
787 | 164k | ptr_scf_bwd[bnds] = position; |
788 | 164k | position -= dpcm; |
789 | 164k | ptr_rvlc->is_first = position; |
790 | 164k | break; |
791 | | |
792 | 283k | case NOISE_HCB: |
793 | 283k | if (bnds == ptr_rvlc->first_noise_band) { |
794 | 15.0k | ptr_scf_bwd[bnds] = ptr_rvlc->dpcm_noise_nrg + |
795 | 15.0k | ptr_aac_dec_channel_info->global_gain - 90 - |
796 | 15.0k | 256; |
797 | 15.0k | ptr_rvlc->first_nrg = ptr_scf_bwd[bnds]; |
798 | 268k | } else { |
799 | 268k | dpcm = ixheaacd_decode_rvlc_code_word(it_bit_buff, ptr_rvlc); |
800 | 268k | if (dpcm < 0) { |
801 | 9.39k | ptr_scf_bwd[bnds] = noise_energy; |
802 | 9.39k | return; |
803 | 9.39k | } |
804 | 259k | dpcm -= 7; |
805 | 259k | if ((dpcm == -7) || (dpcm == 7)) { |
806 | 15.2k | if (ptr_rvlc->rvlc_esc_len) { |
807 | 759 | ptr_scf_bwd[bnds] = noise_energy; |
808 | 759 | return; |
809 | 14.4k | } else { |
810 | 14.4k | if (dpcm == -7) { |
811 | 11.3k | dpcm -= *ptr_scf_esc--; |
812 | 11.3k | } else { |
813 | 3.10k | dpcm += *ptr_scf_esc--; |
814 | 3.10k | } |
815 | 14.4k | (*ptr_esc_bwd_cnt)++; |
816 | 14.4k | if (ptr_rvlc->conceal_min_esc == -1311) { |
817 | 10.4k | } |
818 | 14.4k | } |
819 | 15.2k | } |
820 | 258k | ptr_scf_bwd[bnds] = noise_energy; |
821 | 258k | noise_energy -= dpcm; |
822 | 258k | ptr_rvlc->first_nrg = noise_energy; |
823 | 258k | } |
824 | 273k | break; |
825 | | |
826 | 273k | default: |
827 | 112k | dpcm = ixheaacd_decode_rvlc_code_word(it_bit_buff, ptr_rvlc); |
828 | 112k | if (dpcm < 0) { |
829 | 3.07k | ptr_scf_bwd[bnds] = factor; |
830 | | |
831 | 3.07k | return; |
832 | 3.07k | } |
833 | 109k | dpcm -= 7; |
834 | 109k | if ((dpcm == -7) || (dpcm == 7)) { |
835 | 5.46k | if (ptr_rvlc->rvlc_esc_len) { |
836 | 2.21k | ptr_scf_bwd[bnds] = factor; |
837 | | |
838 | 2.21k | return; |
839 | 3.24k | } else { |
840 | 3.24k | if (dpcm == -7) { |
841 | 1.83k | dpcm -= *ptr_scf_esc--; |
842 | 1.83k | } else { |
843 | 1.40k | dpcm += *ptr_scf_esc--; |
844 | 1.40k | } |
845 | 3.24k | (*ptr_esc_bwd_cnt)++; |
846 | 3.24k | if (ptr_rvlc->conceal_min_esc == -1311) { |
847 | 2.83k | } |
848 | 3.24k | } |
849 | 5.46k | } |
850 | 106k | ptr_scf_bwd[bnds] = factor; |
851 | 106k | factor -= dpcm; |
852 | 106k | ptr_rvlc->firt_scale_fac = factor; |
853 | 106k | break; |
854 | 621k | } |
855 | 621k | } |
856 | 82.5k | } |
857 | 68.9k | } |
858 | | |
859 | | VOID ixheaacd_rvlc_read( |
860 | | ia_bit_buf_struct *it_bit_buff, |
861 | 73.1k | ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info) { |
862 | 73.1k | ia_rvlc_info_struct *ptr_rvlc = &ptr_aac_dec_channel_info->ptr_rvlc_info; |
863 | | |
864 | 73.1k | WORD32 group, band; |
865 | | |
866 | 73.1k | ptr_rvlc->num_wind_grps = |
867 | 73.1k | ptr_aac_dec_channel_info->str_ics_info.num_window_groups; |
868 | 73.1k | ptr_rvlc->max_sfb_transmitted = |
869 | 73.1k | ptr_aac_dec_channel_info->str_ics_info.max_sfb; |
870 | 73.1k | ptr_rvlc->noise_used = 0; |
871 | 73.1k | ptr_rvlc->dpcm_noise_nrg = 0; |
872 | 73.1k | ptr_rvlc->dpcm_noise_last_pos = 0; |
873 | 73.1k | ptr_rvlc->rvlc_esc_len = -1; |
874 | 73.1k | ptr_rvlc->dpcm_is_last_pos = 0; |
875 | | |
876 | 73.1k | ptr_rvlc->sf_concealment = ixheaacd_read_bits_buf(it_bit_buff, 1); |
877 | 73.1k | ptr_rvlc->rev_global_gain = ixheaacd_read_bits_buf(it_bit_buff, 8); |
878 | | |
879 | 73.1k | if (ptr_aac_dec_channel_info->str_ics_info.window_sequence == |
880 | 73.1k | EIGHT_SHORT_SEQUENCE) { |
881 | 4.56k | ptr_rvlc->rvlc_sf_len = ixheaacd_read_bits_buf(it_bit_buff, 11); |
882 | 68.6k | } else { |
883 | 68.6k | ptr_rvlc->rvlc_sf_len = ixheaacd_read_bits_buf(it_bit_buff, 9); |
884 | 68.6k | } |
885 | | |
886 | 160k | for (group = 0; group < ptr_rvlc->num_wind_grps; group++) { |
887 | 652k | for (band = 0; band < ptr_rvlc->max_sfb_transmitted; band++) { |
888 | 594k | if (ptr_aac_dec_channel_info->ptr_code_book[16 * group + band] == |
889 | 594k | NOISE_HCB) { |
890 | 29.0k | ptr_rvlc->noise_used = 1; |
891 | 29.0k | break; |
892 | 29.0k | } |
893 | 594k | } |
894 | 86.9k | } |
895 | | |
896 | 73.1k | if (ptr_rvlc->noise_used) |
897 | 29.0k | ptr_rvlc->dpcm_noise_nrg = ixheaacd_read_bits_buf(it_bit_buff, 9); |
898 | | |
899 | 73.1k | ptr_rvlc->sf_esc_present = ixheaacd_read_bits_buf(it_bit_buff, 1); |
900 | | |
901 | 73.1k | if (ptr_rvlc->sf_esc_present) { |
902 | 36.4k | ptr_rvlc->rvlc_esc_len = ixheaacd_read_bits_buf(it_bit_buff, 8); |
903 | 36.4k | } |
904 | | |
905 | 73.1k | if (ptr_rvlc->noise_used) { |
906 | 29.0k | ptr_rvlc->dpcm_noise_last_pos = ixheaacd_read_bits_buf(it_bit_buff, 9); |
907 | 29.0k | ptr_rvlc->rvlc_sf_len -= 9; |
908 | 29.0k | } |
909 | | |
910 | 73.1k | ptr_rvlc->rvlc_sf_fwd_len = ptr_rvlc->rvlc_sf_len; |
911 | 73.1k | ptr_rvlc->rvlc_sf_bwd_len = ptr_rvlc->rvlc_sf_len; |
912 | 73.1k | } |
913 | | |
914 | | VOID ixheaacd_hcr_read(ia_bit_buf_struct *it_bit_buff, |
915 | | ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, |
916 | 60.8k | WORD32 ele_type) { |
917 | 60.8k | WORD16 len_reordered_spec_data; |
918 | 60.8k | WORD8 len_longest_code_word; |
919 | | |
920 | 60.8k | ptr_aac_dec_channel_info->reorder_spect_data_len = 0; |
921 | 60.8k | ptr_aac_dec_channel_info->longest_cw_len = 0; |
922 | | |
923 | 60.8k | len_reordered_spec_data = ixheaacd_read_bits_buf(it_bit_buff, 14); |
924 | 60.8k | if (ele_type == ID_CPE) { |
925 | 533 | if ((len_reordered_spec_data >= 0) && (len_reordered_spec_data <= 12288)) { |
926 | 516 | ptr_aac_dec_channel_info->reorder_spect_data_len = |
927 | 516 | len_reordered_spec_data; |
928 | 516 | } else { |
929 | 17 | if (len_reordered_spec_data > 12288) { |
930 | 17 | ptr_aac_dec_channel_info->reorder_spect_data_len = 12288; |
931 | 17 | } |
932 | 17 | } |
933 | 60.3k | } else if (ele_type == ID_SCE || ele_type == ID_LFE || ele_type == ID_CCE) { |
934 | 60.3k | if ((len_reordered_spec_data >= 0) && (len_reordered_spec_data <= 6144)) { |
935 | 54.5k | ptr_aac_dec_channel_info->reorder_spect_data_len = |
936 | 54.5k | len_reordered_spec_data; |
937 | 54.5k | } else { |
938 | 5.80k | if (len_reordered_spec_data > 6144) { |
939 | 5.80k | ptr_aac_dec_channel_info->reorder_spect_data_len = 6144; |
940 | 5.80k | } |
941 | 5.80k | } |
942 | 60.3k | } |
943 | | |
944 | 60.8k | len_longest_code_word = ixheaacd_read_bits_buf(it_bit_buff, 6); |
945 | 60.8k | if ((len_longest_code_word >= 0) && (len_longest_code_word <= 49)) { |
946 | 50.2k | ptr_aac_dec_channel_info->longest_cw_len = len_longest_code_word; |
947 | 50.2k | } else { |
948 | 10.6k | if (len_longest_code_word > 49) { |
949 | 10.6k | ptr_aac_dec_channel_info->longest_cw_len = 49; |
950 | 10.6k | } |
951 | 10.6k | } |
952 | 60.8k | } |
953 | | |
954 | | static IA_ERRORCODE ixheaacd_rvlc_init( |
955 | | ia_rvlc_info_struct *ptr_rvlc, |
956 | | ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, |
957 | 73.0k | ia_bit_buf_struct *it_bit_buff) { |
958 | 73.0k | WORD16 *ptr_scf_esc = ptr_aac_dec_channel_info->rvlc_scf_esc_arr; |
959 | 73.0k | WORD16 *ptr_scf_fwd = ptr_aac_dec_channel_info->rvlc_scf_fwd_arr; |
960 | 73.0k | WORD16 *ptr_scf_bwd = ptr_aac_dec_channel_info->rvlc_scf_bwd_arr; |
961 | 73.0k | WORD16 *ptr_scale_factor = ptr_aac_dec_channel_info->ptr_scale_factor; |
962 | 73.0k | WORD32 bnds; |
963 | | |
964 | 73.0k | ptr_aac_dec_channel_info->rvlc_intensity_used = 0; |
965 | | |
966 | 73.0k | ptr_rvlc->num_esc_words_decoded = 0; |
967 | 73.0k | ptr_rvlc->num_fwd_esc_words_decoded = 0; |
968 | 73.0k | ptr_rvlc->num_bwd_esc_words_decoded = 0; |
969 | | |
970 | 73.0k | ptr_rvlc->intensity_used = 0; |
971 | 73.0k | ptr_rvlc->rvlc_err_log = 0; |
972 | | |
973 | 73.0k | ptr_rvlc->conceal_max = CONCEAL_MAX_INIT; |
974 | 73.0k | ptr_rvlc->conceal_min = CONCEAL_MIN_INIT; |
975 | | |
976 | 73.0k | ptr_rvlc->conceal_max_esc = CONCEAL_MAX_INIT; |
977 | 73.0k | ptr_rvlc->conceal_min_esc = CONCEAL_MIN_INIT; |
978 | | |
979 | 9.42M | for (bnds = 0; bnds < RVLC_MAX_SFB; bnds++) { |
980 | 9.35M | ptr_scf_fwd[bnds] = 0; |
981 | 9.35M | ptr_scf_bwd[bnds] = 0; |
982 | 9.35M | ptr_scf_esc[bnds] = 0; |
983 | 9.35M | ptr_scale_factor[bnds] = 0; |
984 | 9.35M | } |
985 | | |
986 | 73.0k | ptr_rvlc->rvl_fwd_bit_str_idx = it_bit_buff->size - it_bit_buff->cnt_bits; |
987 | 73.0k | ptr_rvlc->rvl_bwd_bit_str_idx = |
988 | 73.0k | it_bit_buff->size - it_bit_buff->cnt_bits + ptr_rvlc->rvlc_sf_len - 1; |
989 | | |
990 | 73.0k | it_bit_buff->cnt_bits -= ptr_rvlc->rvlc_sf_len; |
991 | 73.0k | it_bit_buff->ptr_read_next = |
992 | 73.0k | it_bit_buff->ptr_bit_buf_base + |
993 | 73.0k | ((it_bit_buff->size - it_bit_buff->cnt_bits) >> 3); |
994 | 73.0k | it_bit_buff->bit_pos = ((it_bit_buff->size - it_bit_buff->cnt_bits) & 7); |
995 | | |
996 | 73.0k | if (ptr_rvlc->sf_esc_present != 0) { |
997 | 36.3k | ptr_rvlc->esc_bit_str_idx = it_bit_buff->size - it_bit_buff->cnt_bits; |
998 | | |
999 | 36.3k | it_bit_buff->cnt_bits -= ptr_rvlc->rvlc_esc_len; |
1000 | 36.3k | it_bit_buff->ptr_read_next = |
1001 | 36.3k | it_bit_buff->ptr_bit_buf_base + |
1002 | 36.3k | ((it_bit_buff->size - it_bit_buff->cnt_bits) >> 3); |
1003 | 36.3k | it_bit_buff->bit_pos = ((it_bit_buff->size - it_bit_buff->cnt_bits) & 7); |
1004 | 36.3k | } |
1005 | 73.0k | if (it_bit_buff->cnt_bits < 0) { |
1006 | 103 | return IA_XHEAAC_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES; |
1007 | 103 | } else |
1008 | 72.9k | return IA_NO_ERROR; |
1009 | 73.0k | } |
1010 | | |
1011 | | VOID ixheaacd_bi_dir_est_scf_prev_frame_reference( |
1012 | | ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, |
1013 | 0 | ia_aac_dec_overlap_info *ptr_aac_dec_static_channel_info) { |
1014 | 0 | ia_rvlc_info_struct *ptr_rvlc = &ptr_aac_dec_channel_info->ptr_rvlc_info; |
1015 | 0 | WORD32 band, bnds, start_band, end_band, group; |
1016 | 0 | WORD32 conceal_min, conceal_max; |
1017 | 0 | WORD32 conceal_group_min, conceal_group_max; |
1018 | 0 | WORD32 max_scf_bands; |
1019 | 0 | WORD32 common_min; |
1020 | |
|
1021 | 0 | if (ptr_aac_dec_channel_info->str_ics_info.window_sequence == |
1022 | 0 | EIGHT_SHORT_SEQUENCE) { |
1023 | 0 | max_scf_bands = 16; |
1024 | 0 | } else { |
1025 | 0 | max_scf_bands = 64; |
1026 | 0 | } |
1027 | |
|
1028 | 0 | if (ptr_rvlc->conceal_min == CONCEAL_MIN_INIT) ptr_rvlc->conceal_min = 0; |
1029 | |
|
1030 | 0 | if (ptr_rvlc->conceal_max == CONCEAL_MAX_INIT) |
1031 | 0 | ptr_rvlc->conceal_max = |
1032 | 0 | (ptr_rvlc->num_wind_grps - 1) * 16 + ptr_rvlc->max_sfb_transmitted - 1; |
1033 | |
|
1034 | 0 | conceal_min = ptr_rvlc->conceal_min % max_scf_bands; |
1035 | 0 | conceal_group_min = ptr_rvlc->conceal_min / max_scf_bands; |
1036 | 0 | conceal_max = ptr_rvlc->conceal_max % max_scf_bands; |
1037 | 0 | conceal_group_max = ptr_rvlc->conceal_max / max_scf_bands; |
1038 | |
|
1039 | 0 | ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[ptr_rvlc->conceal_max] = |
1040 | 0 | ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[ptr_rvlc->conceal_max]; |
1041 | 0 | ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[ptr_rvlc->conceal_min] = |
1042 | 0 | ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[ptr_rvlc->conceal_min]; |
1043 | |
|
1044 | 0 | start_band = conceal_min; |
1045 | 0 | if (conceal_group_min == conceal_group_max) |
1046 | 0 | end_band = conceal_max; |
1047 | 0 | else |
1048 | 0 | end_band = ptr_rvlc->max_sfb_transmitted - 1; |
1049 | |
|
1050 | 0 | for (group = conceal_group_min; group <= conceal_group_max; group++) { |
1051 | 0 | for (band = start_band; band <= end_band; band++) { |
1052 | 0 | bnds = 16 * group + band; |
1053 | 0 | switch (ptr_aac_dec_channel_info->ptr_code_book[bnds]) { |
1054 | 0 | case ZERO_HCB: |
1055 | 0 | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = 0; |
1056 | 0 | break; |
1057 | | |
1058 | 0 | case INTENSITY_HCB: |
1059 | 0 | case INTENSITY_HCB2: |
1060 | 0 | if ((ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] == |
1061 | 0 | INTENSITY_HCB) || |
1062 | 0 | (ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] == |
1063 | 0 | INTENSITY_HCB2)) { |
1064 | 0 | common_min = ixheaac_min32( |
1065 | 0 | ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds], |
1066 | 0 | ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]); |
1067 | 0 | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ixheaac_min32( |
1068 | 0 | common_min, |
1069 | 0 | ptr_aac_dec_static_channel_info->rvlc_prev_sf[bnds]); |
1070 | 0 | } else { |
1071 | 0 | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ixheaac_min32( |
1072 | 0 | ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds], |
1073 | 0 | ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]); |
1074 | 0 | } |
1075 | 0 | break; |
1076 | | |
1077 | 0 | case NOISE_HCB: |
1078 | 0 | if (ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] == |
1079 | 0 | NOISE_HCB) { |
1080 | 0 | common_min = ixheaac_min32( |
1081 | 0 | ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds], |
1082 | 0 | ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]); |
1083 | 0 | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ixheaac_min32( |
1084 | 0 | common_min, |
1085 | 0 | ptr_aac_dec_static_channel_info->rvlc_prev_sf[bnds]); |
1086 | 0 | } else { |
1087 | 0 | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ixheaac_min32( |
1088 | 0 | ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds], |
1089 | 0 | ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]); |
1090 | 0 | } |
1091 | 0 | break; |
1092 | | |
1093 | 0 | default: |
1094 | 0 | if ((ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] != |
1095 | 0 | ZERO_HCB) && |
1096 | 0 | (ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] != |
1097 | 0 | NOISE_HCB) && |
1098 | 0 | (ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] != |
1099 | 0 | INTENSITY_HCB) && |
1100 | 0 | (ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] != |
1101 | 0 | INTENSITY_HCB2)) { |
1102 | 0 | common_min = ixheaac_min32( |
1103 | 0 | ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds], |
1104 | 0 | ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]); |
1105 | 0 | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ixheaac_min32( |
1106 | 0 | common_min, |
1107 | 0 | ptr_aac_dec_static_channel_info->rvlc_prev_sf[bnds]); |
1108 | 0 | } else { |
1109 | 0 | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ixheaac_min32( |
1110 | 0 | ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds], |
1111 | 0 | ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]); |
1112 | 0 | } |
1113 | 0 | break; |
1114 | 0 | } |
1115 | 0 | } |
1116 | 0 | start_band = 0; |
1117 | 0 | if ((group + 1) == conceal_group_max) end_band = conceal_max; |
1118 | 0 | } |
1119 | | |
1120 | 0 | if (conceal_group_min == 0) |
1121 | 0 | end_band = conceal_min; |
1122 | 0 | else |
1123 | 0 | end_band = ptr_rvlc->max_sfb_transmitted; |
1124 | 0 | for (group = 0; group <= conceal_group_min; group++) { |
1125 | 0 | for (band = 0; band < end_band; band++) { |
1126 | 0 | bnds = 16 * group + band; |
1127 | 0 | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = |
1128 | 0 | ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; |
1129 | 0 | } |
1130 | 0 | if ((group + 1) == conceal_group_min) end_band = conceal_min; |
1131 | 0 | } |
1132 | |
|
1133 | 0 | start_band = conceal_max + 1; |
1134 | 0 | for (group = conceal_group_max; group < ptr_rvlc->num_wind_grps; group++) { |
1135 | 0 | for (band = start_band; band < ptr_rvlc->max_sfb_transmitted; band++) { |
1136 | 0 | bnds = 16 * group + band; |
1137 | 0 | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = |
1138 | 0 | ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; |
1139 | 0 | } |
1140 | 0 | start_band = 0; |
1141 | 0 | } |
1142 | 0 | } |
1143 | | |
1144 | | static VOID ixheaacd_calc_ref_val_fwd( |
1145 | | ia_rvlc_info_struct *ptr_rvlc, |
1146 | | ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, WORD32 *ref_fwd, |
1147 | 7.96k | WORD32 *ref_nrg_fwd, WORD32 *ref_scf_fwd) { |
1148 | 7.96k | WORD32 band, bnds, group, start_band; |
1149 | 7.96k | WORD32 id_is, id_nrg, id_scf; |
1150 | 7.96k | WORD32 conceal_min, conceal_group_min; |
1151 | 7.96k | WORD32 max_scf_bands; |
1152 | | |
1153 | 7.96k | if (ptr_aac_dec_channel_info->str_ics_info.window_sequence == |
1154 | 7.96k | EIGHT_SHORT_SEQUENCE) |
1155 | 18 | max_scf_bands = 16; |
1156 | 7.94k | else |
1157 | 7.94k | max_scf_bands = 64; |
1158 | | |
1159 | 7.96k | conceal_min = ptr_rvlc->conceal_min % max_scf_bands; |
1160 | 7.96k | conceal_group_min = ptr_rvlc->conceal_min / max_scf_bands; |
1161 | | |
1162 | 7.96k | id_is = id_nrg = id_scf = 1; |
1163 | | |
1164 | 7.96k | *ref_nrg_fwd = ptr_aac_dec_channel_info->global_gain - 90 - 256; |
1165 | 7.96k | *ref_scf_fwd = ptr_aac_dec_channel_info->global_gain; |
1166 | | |
1167 | 7.96k | start_band = conceal_min - 1; |
1168 | 15.9k | for (group = conceal_group_min; group >= 0; group--) { |
1169 | 43.8k | for (band = start_band; band >= 0; band--) { |
1170 | 35.9k | bnds = 16 * group + band; |
1171 | 35.9k | switch (ptr_aac_dec_channel_info->ptr_code_book[bnds]) { |
1172 | 1.57k | case ZERO_HCB: |
1173 | 1.57k | break; |
1174 | 11.0k | case INTENSITY_HCB: |
1175 | 21.8k | case INTENSITY_HCB2: |
1176 | 21.8k | if (id_is) { |
1177 | 1.62k | *ref_fwd = ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; |
1178 | 1.62k | id_is = 0; |
1179 | 1.62k | } |
1180 | 21.8k | break; |
1181 | 10.2k | case NOISE_HCB: |
1182 | 10.2k | if (id_nrg) { |
1183 | 1.40k | *ref_nrg_fwd = ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; |
1184 | 1.40k | id_nrg = 0; |
1185 | 1.40k | } |
1186 | 10.2k | break; |
1187 | 2.31k | default: |
1188 | 2.31k | if (id_scf) { |
1189 | 773 | *ref_scf_fwd = ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; |
1190 | 773 | id_scf = 0; |
1191 | 773 | } |
1192 | 2.31k | break; |
1193 | 35.9k | } |
1194 | 35.9k | } |
1195 | 7.96k | start_band = ptr_rvlc->max_sfb_transmitted - 1; |
1196 | 7.96k | } |
1197 | 7.96k | } |
1198 | | |
1199 | | static VOID ixheaacd_calc_ref_val_bwd( |
1200 | | ia_rvlc_info_struct *ptr_rvlc, |
1201 | | ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, WORD32 *ref_bwd, |
1202 | 7.96k | WORD32 *ref_nrg_bwd, WORD32 *ref_scf_bwd) { |
1203 | 7.96k | WORD32 band, bnds, group, start_band; |
1204 | 7.96k | WORD32 id_is, id_nrg, id_scf; |
1205 | 7.96k | WORD32 conceal_max, conceal_group_max; |
1206 | 7.96k | WORD32 max_scf_bands; |
1207 | | |
1208 | 7.96k | if (ptr_aac_dec_channel_info->str_ics_info.window_sequence == |
1209 | 7.96k | EIGHT_SHORT_SEQUENCE) |
1210 | 18 | max_scf_bands = 16; |
1211 | 7.94k | else |
1212 | 7.94k | max_scf_bands = 64; |
1213 | | |
1214 | 7.96k | conceal_max = ptr_rvlc->conceal_max % max_scf_bands; |
1215 | 7.96k | conceal_group_max = ptr_rvlc->conceal_max / max_scf_bands; |
1216 | | |
1217 | 7.96k | id_is = id_nrg = id_scf = 1; |
1218 | | |
1219 | 7.96k | *ref_bwd = ptr_rvlc->dpcm_is_last_pos; |
1220 | 7.96k | *ref_nrg_bwd = ptr_rvlc->rev_global_gain + ptr_rvlc->dpcm_noise_last_pos - |
1221 | 7.96k | 90 - 256 + ptr_rvlc->dpcm_noise_nrg; |
1222 | 7.96k | *ref_scf_bwd = ptr_rvlc->rev_global_gain; |
1223 | | |
1224 | 7.96k | start_band = conceal_max + 1; |
1225 | | |
1226 | 15.9k | for (group = conceal_group_max; group < ptr_rvlc->num_wind_grps; group++) { |
1227 | 59.6k | for (band = start_band; band < ptr_rvlc->max_sfb_transmitted; band++) { |
1228 | 51.7k | bnds = 16 * group + band; |
1229 | 51.7k | switch (ptr_aac_dec_channel_info->ptr_code_book[bnds]) { |
1230 | 335 | case ZERO_HCB: |
1231 | 335 | break; |
1232 | 7.05k | case INTENSITY_HCB: |
1233 | 39.8k | case INTENSITY_HCB2: |
1234 | 39.8k | if (id_is) { |
1235 | 2.63k | *ref_bwd = ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; |
1236 | 2.63k | id_is = 0; |
1237 | 2.63k | } |
1238 | 39.8k | break; |
1239 | 10.3k | case NOISE_HCB: |
1240 | 10.3k | if (id_nrg) { |
1241 | 956 | *ref_nrg_bwd = ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; |
1242 | 956 | id_nrg = 0; |
1243 | 956 | } |
1244 | 10.3k | break; |
1245 | 1.14k | default: |
1246 | 1.14k | if (id_scf) { |
1247 | 346 | *ref_scf_bwd = ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; |
1248 | 346 | id_scf = 0; |
1249 | 346 | } |
1250 | 1.14k | break; |
1251 | 51.7k | } |
1252 | 51.7k | } |
1253 | 7.96k | start_band = 0; |
1254 | 7.96k | } |
1255 | 7.96k | } |
1256 | | |
1257 | | VOID ixheaacd_bi_dir_est_lower_scf_cur_frame( |
1258 | 16.1k | ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info) { |
1259 | 16.1k | ia_rvlc_info_struct *ptr_rvlc = &ptr_aac_dec_channel_info->ptr_rvlc_info; |
1260 | 16.1k | WORD32 band, bnds, start_band, end_band, group; |
1261 | 16.1k | WORD32 conceal_min, conceal_max; |
1262 | 16.1k | WORD32 conceal_group_min, conceal_group_max; |
1263 | 16.1k | WORD32 max_scf_bands; |
1264 | | |
1265 | 16.1k | if (ptr_aac_dec_channel_info->str_ics_info.window_sequence == |
1266 | 16.1k | EIGHT_SHORT_SEQUENCE) { |
1267 | 18 | max_scf_bands = 16; |
1268 | 16.1k | } else { |
1269 | 16.1k | max_scf_bands = 64; |
1270 | 16.1k | } |
1271 | | |
1272 | 16.1k | if (ptr_rvlc->conceal_min == CONCEAL_MIN_INIT) ptr_rvlc->conceal_min = 0; |
1273 | | |
1274 | 16.1k | if (ptr_rvlc->conceal_max == CONCEAL_MAX_INIT) |
1275 | 1.18k | ptr_rvlc->conceal_max = |
1276 | 1.18k | (ptr_rvlc->num_wind_grps - 1) * 16 + ptr_rvlc->max_sfb_transmitted - 1; |
1277 | | |
1278 | 16.1k | conceal_min = ptr_rvlc->conceal_min % max_scf_bands; |
1279 | 16.1k | conceal_group_min = ptr_rvlc->conceal_min / max_scf_bands; |
1280 | 16.1k | conceal_max = ptr_rvlc->conceal_max % max_scf_bands; |
1281 | 16.1k | conceal_group_max = ptr_rvlc->conceal_max / max_scf_bands; |
1282 | | |
1283 | 16.1k | if (ptr_rvlc->conceal_min == ptr_rvlc->conceal_max) { |
1284 | 7.96k | WORD32 ref_fwd = 0, ref_nrg_fwd = 0, ref_scf_fwd = 0; |
1285 | 7.96k | WORD32 ref_bwd = 0, ref_nrg_bwd = 0, ref_scf_bwd = 0; |
1286 | | |
1287 | 7.96k | bnds = ptr_rvlc->conceal_min; |
1288 | 7.96k | ixheaacd_calc_ref_val_fwd(ptr_rvlc, ptr_aac_dec_channel_info, &ref_fwd, |
1289 | 7.96k | &ref_nrg_fwd, &ref_scf_fwd); |
1290 | 7.96k | ixheaacd_calc_ref_val_bwd(ptr_rvlc, ptr_aac_dec_channel_info, &ref_bwd, |
1291 | 7.96k | &ref_nrg_bwd, &ref_scf_bwd); |
1292 | | |
1293 | 7.96k | switch (ptr_aac_dec_channel_info->ptr_code_book[bnds]) { |
1294 | 2.46k | case ZERO_HCB: |
1295 | 2.46k | break; |
1296 | 87 | case INTENSITY_HCB: |
1297 | 2.01k | case INTENSITY_HCB2: |
1298 | 2.01k | if (ref_fwd < ref_bwd) |
1299 | 742 | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ref_fwd; |
1300 | 1.26k | else |
1301 | 1.26k | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ref_bwd; |
1302 | 2.01k | break; |
1303 | 1.21k | case NOISE_HCB: |
1304 | 1.21k | if (ref_nrg_fwd < ref_nrg_bwd) |
1305 | 582 | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ref_nrg_fwd; |
1306 | 631 | else |
1307 | 631 | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ref_nrg_bwd; |
1308 | 1.21k | break; |
1309 | 2.27k | default: |
1310 | 2.27k | if (ref_scf_fwd < ref_scf_bwd) |
1311 | 1.21k | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ref_scf_fwd; |
1312 | 1.05k | else |
1313 | 1.05k | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ref_scf_bwd; |
1314 | 2.27k | break; |
1315 | 7.96k | } |
1316 | 8.17k | } else { |
1317 | 8.17k | ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[ptr_rvlc->conceal_max] = |
1318 | 8.17k | ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[ptr_rvlc->conceal_max]; |
1319 | 8.17k | ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[ptr_rvlc->conceal_min] = |
1320 | 8.17k | ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[ptr_rvlc->conceal_min]; |
1321 | | |
1322 | 8.17k | start_band = conceal_min; |
1323 | 8.17k | if (conceal_group_min == conceal_group_max) |
1324 | 8.17k | end_band = conceal_max; |
1325 | 0 | else |
1326 | 0 | end_band = ptr_rvlc->max_sfb_transmitted - 1; |
1327 | | |
1328 | 16.3k | for (group = conceal_group_min; group <= conceal_group_max; group++) { |
1329 | 135k | for (band = start_band; band <= end_band; band++) { |
1330 | 127k | bnds = 16 * group + band; |
1331 | 127k | if (ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds] < |
1332 | 127k | ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]) |
1333 | 29.5k | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = |
1334 | 29.5k | ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; |
1335 | 97.9k | else |
1336 | 97.9k | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = |
1337 | 97.9k | ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; |
1338 | 127k | } |
1339 | 8.17k | start_band = 0; |
1340 | 8.17k | if ((group + 1) == conceal_group_max) end_band = conceal_max; |
1341 | 8.17k | } |
1342 | 8.17k | } |
1343 | | |
1344 | 16.1k | if (conceal_group_min == 0) |
1345 | 16.1k | end_band = conceal_min; |
1346 | 0 | else |
1347 | 0 | end_band = ptr_rvlc->max_sfb_transmitted; |
1348 | 32.2k | for (group = 0; group <= conceal_group_min; group++) { |
1349 | 52.0k | for (band = 0; band < end_band; band++) { |
1350 | 35.9k | bnds = 16 * group + band; |
1351 | 35.9k | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = |
1352 | 35.9k | ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; |
1353 | 35.9k | } |
1354 | 16.1k | if ((group + 1) == conceal_group_min) end_band = conceal_min; |
1355 | 16.1k | } |
1356 | | |
1357 | 16.1k | start_band = conceal_max + 1; |
1358 | 32.2k | for (group = conceal_group_max; group < ptr_rvlc->num_wind_grps; group++) { |
1359 | 161k | for (band = start_band; band < ptr_rvlc->max_sfb_transmitted; band++) { |
1360 | 145k | bnds = 16 * group + band; |
1361 | 145k | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = |
1362 | 145k | ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; |
1363 | 145k | } |
1364 | 16.1k | start_band = 0; |
1365 | 16.1k | } |
1366 | 16.1k | } |
1367 | | |
1368 | | VOID ixheaacd_statistical_estimation( |
1369 | 5.16k | ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info) { |
1370 | 5.16k | ia_rvlc_info_struct *ptr_rvlc = &ptr_aac_dec_channel_info->ptr_rvlc_info; |
1371 | 5.16k | WORD32 band, bnds, group; |
1372 | 5.16k | WORD32 sum_fwd, sum_bwd; |
1373 | 5.16k | WORD32 sum_nrg_fwd, sum_nrg_bwd; |
1374 | 5.16k | WORD32 sum_scf_fwd, sum_scf_bwd; |
1375 | 5.16k | WORD32 use_fwd, use_nrg_fwd, use_scf_fwd; |
1376 | | |
1377 | 5.16k | sum_fwd = sum_bwd = sum_nrg_fwd = sum_nrg_bwd = sum_scf_fwd = sum_scf_bwd = 0; |
1378 | 5.16k | use_fwd = use_nrg_fwd = use_scf_fwd = 0; |
1379 | | |
1380 | 10.3k | for (group = 0; group < ptr_rvlc->num_wind_grps; group++) { |
1381 | 132k | for (band = 0; band < ptr_rvlc->max_sfb_transmitted; band++) { |
1382 | 127k | bnds = 16 * group + band; |
1383 | 127k | switch (ptr_aac_dec_channel_info->ptr_code_book[bnds]) { |
1384 | 17.6k | case ZERO_HCB: |
1385 | 17.6k | break; |
1386 | | |
1387 | 37.5k | case INTENSITY_HCB: |
1388 | 39.9k | case INTENSITY_HCB2: |
1389 | 39.9k | sum_fwd += ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; |
1390 | 39.9k | sum_bwd += ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; |
1391 | 39.9k | break; |
1392 | | |
1393 | 61.2k | case NOISE_HCB: |
1394 | 61.2k | sum_nrg_fwd += ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; |
1395 | 61.2k | sum_nrg_bwd += ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; |
1396 | 61.2k | break; |
1397 | | |
1398 | 8.69k | default: |
1399 | 8.69k | sum_scf_fwd += ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; |
1400 | 8.69k | sum_scf_bwd += ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; |
1401 | 8.69k | break; |
1402 | 127k | } |
1403 | 127k | } |
1404 | 5.16k | } |
1405 | | |
1406 | 5.16k | if (sum_fwd < sum_bwd) use_fwd = 1; |
1407 | | |
1408 | 5.16k | if (sum_nrg_fwd < sum_nrg_bwd) use_nrg_fwd = 1; |
1409 | | |
1410 | 5.16k | if (sum_scf_fwd < sum_scf_bwd) use_scf_fwd = 1; |
1411 | | |
1412 | 10.3k | for (group = 0; group < ptr_rvlc->num_wind_grps; group++) { |
1413 | 132k | for (band = 0; band < ptr_rvlc->max_sfb_transmitted; band++) { |
1414 | 127k | bnds = 16 * group + band; |
1415 | 127k | switch (ptr_aac_dec_channel_info->ptr_code_book[bnds]) { |
1416 | 17.6k | case ZERO_HCB: |
1417 | 17.6k | break; |
1418 | | |
1419 | 37.5k | case INTENSITY_HCB: |
1420 | 39.9k | case INTENSITY_HCB2: |
1421 | 39.9k | if (use_fwd) |
1422 | 17.8k | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = |
1423 | 17.8k | ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; |
1424 | 22.0k | else |
1425 | 22.0k | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = |
1426 | 22.0k | ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; |
1427 | 39.9k | break; |
1428 | | |
1429 | 61.2k | case NOISE_HCB: |
1430 | 61.2k | if (use_nrg_fwd) |
1431 | 22.9k | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = |
1432 | 22.9k | ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; |
1433 | 38.3k | else |
1434 | 38.3k | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = |
1435 | 38.3k | ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; |
1436 | 61.2k | break; |
1437 | | |
1438 | 8.69k | default: |
1439 | 8.69k | if (use_scf_fwd) |
1440 | 1.68k | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = |
1441 | 1.68k | ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; |
1442 | 7.01k | else |
1443 | 7.01k | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = |
1444 | 7.01k | ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]; |
1445 | 8.69k | break; |
1446 | 127k | } |
1447 | 127k | } |
1448 | 5.16k | } |
1449 | 5.16k | } |
1450 | | |
1451 | | VOID ixheaacd_predictive_interpolation( |
1452 | | ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, |
1453 | 0 | ia_aac_dec_overlap_info *ptr_aac_dec_static_channel_info) { |
1454 | 0 | ia_rvlc_info_struct *ptr_rvlc = &ptr_aac_dec_channel_info->ptr_rvlc_info; |
1455 | 0 | WORD32 band, bnds, group; |
1456 | 0 | WORD32 common_min; |
1457 | |
|
1458 | 0 | for (group = 0; group < ptr_rvlc->num_wind_grps; group++) { |
1459 | 0 | for (band = 0; band < ptr_rvlc->max_sfb_transmitted; band++) { |
1460 | 0 | bnds = 16 * group + band; |
1461 | 0 | switch (ptr_aac_dec_channel_info->ptr_code_book[bnds]) { |
1462 | 0 | case ZERO_HCB: |
1463 | 0 | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = 0; |
1464 | 0 | break; |
1465 | | |
1466 | 0 | case INTENSITY_HCB: |
1467 | 0 | case INTENSITY_HCB2: |
1468 | 0 | if ((ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] == |
1469 | 0 | INTENSITY_HCB) || |
1470 | 0 | (ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] == |
1471 | 0 | INTENSITY_HCB2)) { |
1472 | 0 | common_min = ixheaac_min32( |
1473 | 0 | ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds], |
1474 | 0 | ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]); |
1475 | 0 | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ixheaac_min32( |
1476 | 0 | common_min, |
1477 | 0 | ptr_aac_dec_static_channel_info->rvlc_prev_sf[bnds]); |
1478 | 0 | } else { |
1479 | 0 | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = -110; |
1480 | 0 | } |
1481 | 0 | break; |
1482 | | |
1483 | 0 | case NOISE_HCB: |
1484 | 0 | if (ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] == |
1485 | 0 | NOISE_HCB) { |
1486 | 0 | common_min = ixheaac_min32( |
1487 | 0 | ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds], |
1488 | 0 | ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]); |
1489 | 0 | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ixheaac_min32( |
1490 | 0 | common_min, |
1491 | 0 | ptr_aac_dec_static_channel_info->rvlc_prev_sf[bnds]); |
1492 | 0 | } else { |
1493 | 0 | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = -110; |
1494 | 0 | } |
1495 | 0 | break; |
1496 | | |
1497 | 0 | default: |
1498 | 0 | if ((ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] != |
1499 | 0 | ZERO_HCB) && |
1500 | 0 | (ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] != |
1501 | 0 | NOISE_HCB) && |
1502 | 0 | (ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] != |
1503 | 0 | INTENSITY_HCB) && |
1504 | 0 | (ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] != |
1505 | 0 | INTENSITY_HCB2)) { |
1506 | 0 | common_min = ixheaac_min32( |
1507 | 0 | ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds], |
1508 | 0 | ptr_aac_dec_channel_info->rvlc_scf_bwd_arr[bnds]); |
1509 | 0 | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = ixheaac_min32( |
1510 | 0 | common_min, |
1511 | 0 | ptr_aac_dec_static_channel_info->rvlc_prev_sf[bnds]); |
1512 | 0 | } else { |
1513 | 0 | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = 0; |
1514 | 0 | } |
1515 | 0 | break; |
1516 | 0 | } |
1517 | 0 | } |
1518 | 0 | } |
1519 | 0 | } |
1520 | | static VOID ixheaacd_rvlc_final_error_detection( |
1521 | | ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, |
1522 | 72.9k | ia_aac_dec_overlap_info *ptr_aac_dec_static_channel_info) { |
1523 | 72.9k | ia_rvlc_info_struct *ptr_rvlc = &ptr_aac_dec_channel_info->ptr_rvlc_info; |
1524 | 72.9k | UWORD8 err_status_complete = 0; |
1525 | 72.9k | UWORD8 err_status_length_fwd = 0; |
1526 | 72.9k | UWORD8 err_status_length_bwd = 0; |
1527 | 72.9k | UWORD8 err_status_length_escape = 0; |
1528 | 72.9k | UWORD8 err_status_first_scf = 0; |
1529 | 72.9k | UWORD8 err_status_last_scf = 0; |
1530 | 72.9k | UWORD8 err_status_first_nrg = 0; |
1531 | 72.9k | UWORD8 err_status_last_nrg = 0; |
1532 | 72.9k | UWORD8 err_status_first_is = 0; |
1533 | 72.9k | UWORD8 err_status_last_is = 0; |
1534 | 72.9k | UWORD8 err_status_forbidden_cw_fwd = 0; |
1535 | 72.9k | UWORD8 err_status_forbidden_cw_bwd = 0; |
1536 | 72.9k | UWORD8 err_status_num_escapes_fwd = 0; |
1537 | 72.9k | UWORD8 err_status_num_escapes_bwd = 0; |
1538 | 72.9k | UWORD8 conceal_status = 1; |
1539 | 72.9k | UWORD8 current_block_type; |
1540 | | |
1541 | 72.9k | ptr_aac_dec_channel_info->rvlc_curr_sf_flag = 1; |
1542 | | |
1543 | 72.9k | if (ptr_rvlc->rvlc_err_log & RVLC_ERROR_FORBIDDEN_CW_DETECTED_FWD) |
1544 | 0 | err_status_forbidden_cw_fwd = 1; |
1545 | | |
1546 | 72.9k | if (ptr_rvlc->rvlc_err_log & RVLC_ERROR_FORBIDDEN_CW_DETECTED_BWD) |
1547 | 0 | err_status_forbidden_cw_bwd = 1; |
1548 | | |
1549 | 72.9k | if (ptr_rvlc->rvlc_sf_fwd_len) err_status_length_fwd = 1; |
1550 | | |
1551 | 72.9k | if (ptr_rvlc->rvlc_sf_bwd_len) err_status_length_bwd = 1; |
1552 | | |
1553 | 72.9k | if (ptr_rvlc->sf_esc_present) |
1554 | 36.2k | if (ptr_rvlc->rvlc_esc_len) err_status_length_escape = 1; |
1555 | | |
1556 | 72.9k | if (ptr_rvlc->sf_used) { |
1557 | 24.6k | if (ptr_rvlc->firt_scale_fac != (ptr_aac_dec_channel_info->global_gain)) |
1558 | 24.5k | err_status_first_scf = 1; |
1559 | | |
1560 | 24.6k | if (ptr_rvlc->last_scale_fac != (ptr_rvlc->rev_global_gain)) |
1561 | 24.2k | err_status_last_scf = 1; |
1562 | 24.6k | } |
1563 | | |
1564 | 72.9k | if (ptr_rvlc->noise_used) { |
1565 | 23.8k | if (ptr_rvlc->first_nrg != (ptr_aac_dec_channel_info->global_gain + |
1566 | 23.8k | ptr_rvlc->dpcm_noise_nrg - 90 - 256)) |
1567 | 10.9k | err_status_first_nrg = 1; |
1568 | | |
1569 | 23.8k | if (ptr_rvlc->last_nrg != |
1570 | 23.8k | (ptr_rvlc->rev_global_gain + ptr_rvlc->dpcm_noise_last_pos - 90 - 256)) |
1571 | 23.3k | err_status_last_nrg = 1; |
1572 | 23.8k | } |
1573 | | |
1574 | 72.9k | if (ptr_rvlc->intensity_used) { |
1575 | 21.3k | if (ptr_rvlc->is_first != 0) err_status_first_is = 1; |
1576 | | |
1577 | 21.3k | if (ptr_rvlc->is_last != (ptr_rvlc->dpcm_is_last_pos)) |
1578 | 14.7k | err_status_last_is = 1; |
1579 | 21.3k | } |
1580 | | |
1581 | 72.9k | if ((ptr_rvlc->num_fwd_esc_words_decoded != |
1582 | 72.9k | ptr_rvlc->num_esc_words_decoded) && |
1583 | 35.0k | (ptr_rvlc->conceal_max == CONCEAL_MAX_INIT)) { |
1584 | 22.9k | err_status_num_escapes_fwd = 1; |
1585 | 22.9k | } |
1586 | | |
1587 | 72.9k | if ((ptr_rvlc->num_bwd_esc_words_decoded != |
1588 | 72.9k | ptr_rvlc->num_esc_words_decoded) && |
1589 | 33.8k | (ptr_rvlc->conceal_min == CONCEAL_MIN_INIT)) { |
1590 | 30.7k | err_status_num_escapes_bwd = 1; |
1591 | 30.7k | } |
1592 | | |
1593 | 72.9k | if (err_status_length_escape || |
1594 | 54.6k | (((ptr_rvlc->conceal_max == CONCEAL_MAX_INIT) && |
1595 | 41.4k | (ptr_rvlc->num_fwd_esc_words_decoded != |
1596 | 41.4k | ptr_rvlc->num_esc_words_decoded) && |
1597 | 13.3k | (err_status_last_scf || err_status_last_nrg || err_status_last_is)) |
1598 | | |
1599 | 9.58k | && |
1600 | | |
1601 | 9.58k | ((ptr_rvlc->conceal_min == CONCEAL_MIN_INIT) && |
1602 | 8.91k | (ptr_rvlc->num_bwd_esc_words_decoded != |
1603 | 8.91k | ptr_rvlc->num_esc_words_decoded) && |
1604 | 8.64k | (err_status_first_scf || err_status_first_nrg || |
1605 | 2.35k | err_status_first_is))) || |
1606 | 47.1k | ((ptr_rvlc->conceal_max == CONCEAL_MAX_INIT) && |
1607 | 33.9k | ((ptr_rvlc->rev_global_gain - ptr_rvlc->last_scale_fac) < -15)) || |
1608 | 45.9k | ((ptr_rvlc->conceal_min == CONCEAL_MIN_INIT) && |
1609 | 44.2k | ((ptr_aac_dec_channel_info->global_gain - ptr_rvlc->firt_scale_fac) < |
1610 | 44.2k | -15))) { |
1611 | 30.8k | if ((ptr_rvlc->conceal_max == CONCEAL_MAX_INIT) || |
1612 | 28.7k | (ptr_rvlc->conceal_min == CONCEAL_MIN_INIT)) { |
1613 | 28.7k | ptr_rvlc->conceal_max = 0; |
1614 | 28.7k | ptr_rvlc->conceal_min = |
1615 | 28.7k | ixheaac_max32(0, (ptr_rvlc->num_wind_grps - 1) * 16 + |
1616 | 28.7k | ptr_rvlc->max_sfb_transmitted - 1); |
1617 | 28.7k | } else { |
1618 | 2.10k | ptr_rvlc->conceal_max = |
1619 | 2.10k | ixheaac_min32(ptr_rvlc->conceal_max, ptr_rvlc->conceal_max_esc); |
1620 | 2.10k | ptr_rvlc->conceal_min = |
1621 | 2.10k | ixheaac_max32(ptr_rvlc->conceal_min, ptr_rvlc->conceal_min_esc); |
1622 | 2.10k | } |
1623 | 30.8k | } |
1624 | | |
1625 | 72.9k | err_status_complete = |
1626 | 72.9k | err_status_last_scf || err_status_first_scf || err_status_last_nrg || |
1627 | 35.9k | err_status_first_nrg || err_status_last_is || err_status_first_is || |
1628 | 28.4k | err_status_forbidden_cw_fwd || err_status_forbidden_cw_bwd || |
1629 | 28.4k | err_status_length_fwd || err_status_length_bwd || |
1630 | 8.46k | err_status_length_escape || err_status_num_escapes_fwd || |
1631 | 8.27k | err_status_num_escapes_bwd; |
1632 | | |
1633 | 72.9k | current_block_type = |
1634 | 72.9k | (ptr_aac_dec_channel_info->str_ics_info.window_sequence == |
1635 | 72.9k | EIGHT_SHORT_SEQUENCE) |
1636 | 72.9k | ? 0 |
1637 | 72.9k | : 1; |
1638 | | |
1639 | 72.9k | if (!err_status_complete) { |
1640 | 8.27k | WORD32 band; |
1641 | 8.27k | WORD32 group; |
1642 | 8.27k | WORD32 bnds; |
1643 | 8.27k | WORD32 last_sfb_idx; |
1644 | | |
1645 | 8.27k | last_sfb_idx = (ptr_rvlc->num_wind_grps > 1) ? 16 : 64; |
1646 | | |
1647 | 17.1k | for (group = 0; group < ptr_rvlc->num_wind_grps; group++) { |
1648 | 19.8k | for (band = 0; band < ptr_rvlc->max_sfb_transmitted; band++) { |
1649 | 11.0k | bnds = 16 * group + band; |
1650 | 11.0k | ptr_aac_dec_channel_info->ptr_scale_factor[bnds] = |
1651 | 11.0k | ptr_aac_dec_static_channel_info->rvlc_prev_sf[bnds] = |
1652 | 11.0k | ptr_aac_dec_channel_info->rvlc_scf_fwd_arr[bnds]; |
1653 | 11.0k | } |
1654 | 8.86k | } |
1655 | | |
1656 | 17.1k | for (group = 0; group < ptr_rvlc->num_wind_grps; group++) { |
1657 | 19.8k | for (band = 0; band < ptr_rvlc->max_sfb_transmitted; band++) { |
1658 | 11.0k | bnds = 16 * group + band; |
1659 | 11.0k | ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] = |
1660 | 11.0k | ptr_aac_dec_channel_info->ptr_code_book[bnds]; |
1661 | 11.0k | } |
1662 | 530k | for (; band < last_sfb_idx; band++) { |
1663 | 521k | bnds = 16 * group + band; |
1664 | 521k | ptr_aac_dec_static_channel_info->rvlc_prev_cb[bnds] = ZERO_HCB; |
1665 | 521k | } |
1666 | 8.86k | } |
1667 | 64.7k | } else { |
1668 | 64.7k | WORD32 band; |
1669 | 64.7k | WORD32 group; |
1670 | | |
1671 | 64.7k | if (((ptr_rvlc->conceal_min != CONCEAL_MIN_INIT) || |
1672 | 32.1k | (ptr_rvlc->conceal_max != CONCEAL_MAX_INIT)) && |
1673 | 43.4k | (ptr_rvlc->conceal_min <= ptr_rvlc->conceal_max) && |
1674 | 16.1k | (ptr_aac_dec_static_channel_info->rvlc_prev_blk_type == |
1675 | 16.1k | current_block_type) && |
1676 | 18 | ptr_aac_dec_static_channel_info->rvlc_prev_sf_ok && |
1677 | 0 | ptr_rvlc->sf_concealment && conceal_status) { |
1678 | 0 | ixheaacd_bi_dir_est_scf_prev_frame_reference( |
1679 | 0 | ptr_aac_dec_channel_info, ptr_aac_dec_static_channel_info); |
1680 | 0 | conceal_status = 0; |
1681 | 0 | } |
1682 | | |
1683 | 64.7k | if ((ptr_rvlc->conceal_min <= ptr_rvlc->conceal_max) && |
1684 | 37.3k | ((ptr_rvlc->conceal_min != CONCEAL_MIN_INIT) || |
1685 | 32.1k | (ptr_rvlc->conceal_max != CONCEAL_MAX_INIT)) && |
1686 | 16.1k | !(ptr_aac_dec_static_channel_info->rvlc_prev_sf_ok && |
1687 | 0 | ptr_rvlc->sf_concealment && |
1688 | 0 | (ptr_aac_dec_static_channel_info->rvlc_prev_blk_type == |
1689 | 0 | current_block_type)) && |
1690 | 16.1k | conceal_status) { |
1691 | 16.1k | ixheaacd_bi_dir_est_lower_scf_cur_frame(ptr_aac_dec_channel_info); |
1692 | 16.1k | conceal_status = 0; |
1693 | 16.1k | } |
1694 | | |
1695 | 64.7k | if ((ptr_rvlc->conceal_min <= ptr_rvlc->conceal_max) && |
1696 | 37.3k | ((err_status_last_scf && err_status_first_scf) || |
1697 | 29.9k | (err_status_last_nrg && err_status_first_nrg) || |
1698 | 26.7k | (err_status_last_is && err_status_first_is)) && |
1699 | 14.1k | !(err_status_forbidden_cw_fwd || err_status_forbidden_cw_bwd || |
1700 | 14.1k | err_status_length_escape) && |
1701 | 14.0k | conceal_status) { |
1702 | 5.16k | ixheaacd_statistical_estimation(ptr_aac_dec_channel_info); |
1703 | 5.16k | conceal_status = 0; |
1704 | 5.16k | } |
1705 | | |
1706 | 64.7k | if ((ptr_rvlc->conceal_min <= ptr_rvlc->conceal_max) && |
1707 | 37.3k | ptr_aac_dec_static_channel_info->rvlc_prev_sf_ok && |
1708 | 0 | ptr_rvlc->sf_concealment && |
1709 | 0 | (ptr_aac_dec_static_channel_info->rvlc_prev_blk_type == |
1710 | 0 | current_block_type) && |
1711 | 0 | conceal_status) { |
1712 | 0 | ixheaacd_predictive_interpolation(ptr_aac_dec_channel_info, |
1713 | 0 | ptr_aac_dec_static_channel_info); |
1714 | 0 | conceal_status = 0; |
1715 | 0 | } |
1716 | | |
1717 | 64.7k | if (conceal_status) { |
1718 | 99.9k | for (group = 0; group < ptr_rvlc->num_wind_grps; group++) { |
1719 | 619k | for (band = 0; band < ptr_rvlc->max_sfb_transmitted; band++) { |
1720 | 563k | ptr_aac_dec_channel_info->ptr_scale_factor[16 * group + band] = 0; |
1721 | 563k | } |
1722 | 56.5k | } |
1723 | 43.4k | ptr_aac_dec_channel_info->rvlc_curr_sf_flag = 0; |
1724 | 43.4k | } |
1725 | 64.7k | } |
1726 | 72.9k | } |
1727 | | |
1728 | | IA_ERRORCODE ixheaacd_rvlc_dec( |
1729 | | ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, |
1730 | | ia_aac_dec_overlap_info *ptr_aac_dec_static_channel_info, |
1731 | 73.0k | ia_bit_buf_struct *it_bit_buff) { |
1732 | 73.0k | ia_rvlc_info_struct *ptr_rvlc = &ptr_aac_dec_channel_info->ptr_rvlc_info; |
1733 | 73.0k | ia_bit_buf_struct saved_it_bit_buff; |
1734 | 73.0k | IA_ERRORCODE error_code = 0; |
1735 | 73.0k | error_code = |
1736 | 73.0k | ixheaacd_rvlc_init(ptr_rvlc, ptr_aac_dec_channel_info, it_bit_buff); |
1737 | 73.0k | if (error_code) return error_code; |
1738 | | |
1739 | 72.9k | ixheaacd_bitbuf_checkpoint(*it_bit_buff, saved_it_bit_buff); |
1740 | 72.9k | if (ptr_rvlc->sf_esc_present) |
1741 | 36.2k | ixheaacd_rvlc_decode_escape( |
1742 | 36.2k | ptr_rvlc, ptr_aac_dec_channel_info->rvlc_scf_esc_arr, it_bit_buff); |
1743 | | |
1744 | 72.9k | ixheaacd_rvlc_decode_forward(ptr_rvlc, ptr_aac_dec_channel_info, it_bit_buff); |
1745 | 72.9k | ixheaacd_rvlc_decode_backward(ptr_rvlc, ptr_aac_dec_channel_info, |
1746 | 72.9k | it_bit_buff); |
1747 | 72.9k | ixheaacd_rvlc_final_error_detection(ptr_aac_dec_channel_info, |
1748 | 72.9k | ptr_aac_dec_static_channel_info); |
1749 | | |
1750 | 72.9k | ptr_aac_dec_channel_info->rvlc_intensity_used = ptr_rvlc->intensity_used; |
1751 | 72.9k | ptr_aac_dec_channel_info->str_pns_info.pns_active = ptr_rvlc->noise_used; |
1752 | | |
1753 | 72.9k | ixheaacd_bitbuf_restore(*it_bit_buff, saved_it_bit_buff); |
1754 | 72.9k | return error_code; |
1755 | 73.0k | } |