xref: /aosp_15_r20/external/libxaac/encoder/ixheaace_dynamic_bits.h (revision 15dc779a375ca8b5125643b829a8aa4b70d7f451)
1*15dc779aSAndroid Build Coastguard Worker /******************************************************************************
2*15dc779aSAndroid Build Coastguard Worker  *                                                                            *
3*15dc779aSAndroid Build Coastguard Worker  * Copyright (C) 2023 The Android Open Source Project
4*15dc779aSAndroid Build Coastguard Worker  *
5*15dc779aSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
6*15dc779aSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
7*15dc779aSAndroid Build Coastguard Worker  * You may obtain a copy of the License at:
8*15dc779aSAndroid Build Coastguard Worker  *
9*15dc779aSAndroid Build Coastguard Worker  * http://www.apache.org/licenses/LICENSE-2.0
10*15dc779aSAndroid Build Coastguard Worker  *
11*15dc779aSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
12*15dc779aSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
13*15dc779aSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*15dc779aSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
15*15dc779aSAndroid Build Coastguard Worker  * limitations under the License.
16*15dc779aSAndroid Build Coastguard Worker  *
17*15dc779aSAndroid Build Coastguard Worker  *****************************************************************************
18*15dc779aSAndroid Build Coastguard Worker  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19*15dc779aSAndroid Build Coastguard Worker  */
20*15dc779aSAndroid Build Coastguard Worker 
21*15dc779aSAndroid Build Coastguard Worker #pragma once
22*15dc779aSAndroid Build Coastguard Worker #define MAXIMUM_SECTIONS MAXIMUM_GROUPED_SCALE_FACTOR_BAND
23*15dc779aSAndroid Build Coastguard Worker #define SECT_ESC_VAL_LONG 31
24*15dc779aSAndroid Build Coastguard Worker #define SECT_ESC_VAL_SHORT 7
25*15dc779aSAndroid Build Coastguard Worker #define CODE_BCK_BITS 4
26*15dc779aSAndroid Build Coastguard Worker #define SECT_BITS_LONG 5
27*15dc779aSAndroid Build Coastguard Worker #define SECT_BITS_SHORT 3
28*15dc779aSAndroid Build Coastguard Worker 
29*15dc779aSAndroid Build Coastguard Worker typedef enum {
30*15dc779aSAndroid Build Coastguard Worker   SI_ID_BITS = (3),
31*15dc779aSAndroid Build Coastguard Worker   SI_FILL_COUNT_BITS = (4),
32*15dc779aSAndroid Build Coastguard Worker   SI_FILL_ESC_COUNT_BITS = (8),
33*15dc779aSAndroid Build Coastguard Worker   SI_FILL_EXTENTION_BITS = (4),
34*15dc779aSAndroid Build Coastguard Worker   SI_FILL_NIBBLE_BITS = (4),
35*15dc779aSAndroid Build Coastguard Worker   SI_SCE_BITS = (4),
36*15dc779aSAndroid Build Coastguard Worker   SI_CPE_BITS = (5),
37*15dc779aSAndroid Build Coastguard Worker   SI_CPE_MS_MASK_BITS = (2),
38*15dc779aSAndroid Build Coastguard Worker   SI_ICS_INFO_BITS_LONG = (1 + 2 + 1 + 6 + 1),
39*15dc779aSAndroid Build Coastguard Worker   SI_ICS_INFO_BITS_SHORT = (1 + 2 + 1 + 4 + 7),
40*15dc779aSAndroid Build Coastguard Worker   SI_ICS_BITS = (8 + 1 + 1 + 1),
41*15dc779aSAndroid Build Coastguard Worker } SI_BITS;
42*15dc779aSAndroid Build Coastguard Worker typedef struct {
43*15dc779aSAndroid Build Coastguard Worker   WORD8 code_book;
44*15dc779aSAndroid Build Coastguard Worker   WORD8 sfb_start;
45*15dc779aSAndroid Build Coastguard Worker   WORD8 sfb_cnt;
46*15dc779aSAndroid Build Coastguard Worker   WORD16 section_bits;
47*15dc779aSAndroid Build Coastguard Worker } ixheaace_section_info;
48*15dc779aSAndroid Build Coastguard Worker 
49*15dc779aSAndroid Build Coastguard Worker typedef struct {
50*15dc779aSAndroid Build Coastguard Worker   WORD32 block_type;
51*15dc779aSAndroid Build Coastguard Worker   WORD32 total_groups_cnt;
52*15dc779aSAndroid Build Coastguard Worker   WORD32 sfb_cnt;
53*15dc779aSAndroid Build Coastguard Worker   WORD32 max_sfb_per_grp;
54*15dc779aSAndroid Build Coastguard Worker   WORD32 sfb_per_group;
55*15dc779aSAndroid Build Coastguard Worker   WORD32 num_of_sections;
56*15dc779aSAndroid Build Coastguard Worker   ixheaace_section_info section[MAXIMUM_SECTIONS];
57*15dc779aSAndroid Build Coastguard Worker   WORD32 side_info_bits; /* sectioning bits       */
58*15dc779aSAndroid Build Coastguard Worker   WORD32 huffman_bits;   /* huffman    coded bits */
59*15dc779aSAndroid Build Coastguard Worker   WORD32 scale_fac_bits; /* scalefac   coded bits */
60*15dc779aSAndroid Build Coastguard Worker   WORD32 first_scf;      /* first scf to be coded */
61*15dc779aSAndroid Build Coastguard Worker } ixheaace_section_data;
62*15dc779aSAndroid Build Coastguard Worker 
63*15dc779aSAndroid Build Coastguard Worker VOID ia_enhaacplus_enc_bitcount_init(WORD32 *side_info_tab_long, WORD32 *side_info_tab_short);
64*15dc779aSAndroid Build Coastguard Worker 
65*15dc779aSAndroid Build Coastguard Worker IA_ERRORCODE ia_enhaacplus_enc_dyn_bitcount(
66*15dc779aSAndroid Build Coastguard Worker     const WORD16 *ptr_quant_spec, const UWORD16 *ptr_max_val_in_sfb, const WORD16 *ptr_scale_fac,
67*15dc779aSAndroid Build Coastguard Worker     const WORD32 block_type, const WORD32 sfb_cnt, const WORD32 max_sfb_per_grp,
68*15dc779aSAndroid Build Coastguard Worker     const WORD32 sfb_per_grp, const WORD32 *ptr_sfb_offset,
69*15dc779aSAndroid Build Coastguard Worker     ixheaace_section_data *pstr_section_data, WORD32 *ptr_side_info_tab_long,
70*15dc779aSAndroid Build Coastguard Worker     WORD32 *ptr_side_info_tab_short, ixheaace_huffman_tables *ptr_huffman_tbl,
71*15dc779aSAndroid Build Coastguard Worker     WORD32 *ptr_scratch_buf, WORD32 aot, WORD32 *bit_cnt);
72