/src/libxaac/decoder/ixheaacd_mps_res_channel_info.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_cnst.h" |
23 | | #include "ixheaacd_mps_aac_struct.h" |
24 | | #include "ixheaacd_mps_res_rom.h" |
25 | | #include "ixheaac_basic_op.h" |
26 | | #include "ixheaacd_mps_res.h" |
27 | | |
28 | | const WORD16 *ixheaacd_res_get_sfb_offsets( |
29 | | ia_mps_dec_residual_ics_info_struct *p_ics_info, |
30 | 1.66k | ia_mps_dec_residual_aac_tables_struct *aac_tables_ptr) { |
31 | 1.66k | if (p_ics_info->window_sequence != EIGHT_SHORT_SEQUENCE) { |
32 | 1.09k | return aac_tables_ptr->sfb_index_long; |
33 | 1.09k | } else { |
34 | 565 | return aac_tables_ptr->sfb_index_short; |
35 | 565 | } |
36 | 1.66k | } |
37 | | |
38 | | const WORD8 *ixheaacd_res_get_sfb_width(ia_mps_dec_residual_ics_info_struct *p_ics_info, |
39 | 1.36k | ia_mps_dec_residual_aac_tables_struct *aac_tables_ptr) { |
40 | 1.36k | if (p_ics_info->window_sequence != EIGHT_SHORT_SEQUENCE) { |
41 | 974 | return aac_tables_ptr->sfb_index_long_width; |
42 | 974 | } else { |
43 | 390 | return aac_tables_ptr->sfb_index_short_width; |
44 | 390 | } |
45 | 1.36k | } |
46 | | |
47 | | WORD16 ixheaacd_res_ics_read(ia_bit_buf_struct *it_bif_buf, |
48 | | ia_mps_dec_residual_ics_info_struct *p_ics_info, |
49 | 1.50k | WORD8 tot_sf_bands_ls[2]) { |
50 | 1.50k | WORD i; |
51 | 1.50k | WORD mask; |
52 | 1.50k | WORD tmp = 0; |
53 | | |
54 | 1.50k | tmp = ixheaacd_read_bits_buf(it_bif_buf, 4); |
55 | 1.50k | p_ics_info->window_sequence = (WORD16)((tmp & 0x6) >> 1); |
56 | | |
57 | 1.50k | if (p_ics_info->window_sequence != EIGHT_SHORT_SEQUENCE) { |
58 | 1.06k | p_ics_info->total_sf_bands = tot_sf_bands_ls[0]; |
59 | | |
60 | 1.06k | p_ics_info->window_groups = 1; |
61 | 1.06k | p_ics_info->window_group_length[0] = 1; |
62 | | |
63 | 1.06k | tmp = ixheaacd_read_bits_buf(it_bif_buf, 7); |
64 | 1.06k | p_ics_info->max_sf_bands = (tmp & 0x7E) >> 1; |
65 | | |
66 | 1.06k | if (tmp & 1) { |
67 | 32 | return (WORD16)((WORD32)AAC_DEC_PREDICTION_NOT_SUPPORTED_IN_LC_AAC); |
68 | 32 | } |
69 | 1.06k | } else { |
70 | 447 | WORD32 win_grp = 0, tmp2; |
71 | 447 | p_ics_info->total_sf_bands = tot_sf_bands_ls[1]; |
72 | | |
73 | 447 | tmp = ixheaacd_read_bits_buf(it_bif_buf, 11); |
74 | 447 | p_ics_info->max_sf_bands = (tmp & 0x780) >> 7; |
75 | | |
76 | 447 | tmp2 = (tmp & 0x7F); |
77 | | |
78 | 3.54k | for (i = 0; i < 7; i++) { |
79 | 3.10k | mask = (1 << sub_d(6, i)); |
80 | 3.10k | p_ics_info->window_group_length[i] = 1; |
81 | 3.10k | if (tmp2 & mask) { |
82 | 2.47k | p_ics_info->window_group_length[win_grp] = |
83 | 2.47k | add_d(p_ics_info->window_group_length[win_grp], 1); |
84 | 2.47k | } else { |
85 | 622 | win_grp = add_d(win_grp, 1); |
86 | 622 | } |
87 | 3.10k | } |
88 | | |
89 | 447 | p_ics_info->window_group_length[7] = 1; |
90 | 447 | p_ics_info->window_groups = add_d(win_grp, 1); |
91 | 447 | } |
92 | | |
93 | 1.47k | if (p_ics_info->max_sf_bands > p_ics_info->total_sf_bands) |
94 | 5 | return (WORD16)IA_XHEAAC_DEC_EXE_NONFATAL_EXCEEDS_SFB_TRANSMITTED; |
95 | | |
96 | 1.47k | return AAC_DEC_OK; |
97 | 1.47k | } |