/src/libxaac/decoder/ixheaacd_mps_res_pulsedata.c
Line | Count | Source |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Copyright (C) 2023 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 "ixheaac_type_def.h" |
21 | | #include "ixheaacd_bitbuffer.h" |
22 | | #include "ixheaacd_mps_aac_struct.h" |
23 | | #include "ixheaacd_mps_res_rom.h" |
24 | | #include "ixheaacd_error_codes.h" |
25 | | |
26 | | WORD32 ixheaacd_res_c_pulse_data_read(ia_bit_buf_struct *it_bit_buf, |
27 | | ia_mps_dec_residual_pulse_data_struct *pulse_data, |
28 | 861 | ia_mps_dec_residual_aac_tables_struct *aac_tables_ptr) { |
29 | 861 | WORD32 i, k; |
30 | 861 | WORD32 error = 0; |
31 | 861 | pulse_data->pulse_data_present = (FLAG)ixheaacd_read_bits_buf(it_bit_buf, 1); |
32 | 861 | if (pulse_data->pulse_data_present) { |
33 | 126 | WORD32 tmp = ixheaacd_read_bits_buf(it_bit_buf, 8); |
34 | 126 | pulse_data->number_pulse = tmp >> 6; |
35 | 126 | pulse_data->pulse_start_band = tmp & 0x3F; |
36 | | |
37 | 126 | if (pulse_data->pulse_start_band >= 52) { |
38 | 1 | return (WORD32)IA_XHEAAC_DEC_EXE_NONFATAL_PULSEDATA_ERROR; |
39 | 1 | } |
40 | | |
41 | 125 | k = aac_tables_ptr->sfb_index_long[pulse_data->pulse_start_band]; |
42 | | |
43 | 391 | for (i = 0; i <= pulse_data->number_pulse; i++) { |
44 | 266 | WORD32 tmp = ixheaacd_read_bits_buf(it_bit_buf, 9); |
45 | 266 | pulse_data->pulse_offset[i] = tmp >> 4; |
46 | 266 | pulse_data->pulse_amp[i] = tmp & 0xF; |
47 | | |
48 | 266 | k += pulse_data->pulse_offset[i]; |
49 | 266 | if (k >= 1024) error = (WORD32)IA_XHEAAC_DEC_EXE_NONFATAL_PULSEDATA_ERROR; |
50 | 266 | } |
51 | 125 | } |
52 | | |
53 | 860 | return error; |
54 | 861 | } |