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 #ifndef IXHEAACD_BITBUFFER_H 21 #define IXHEAACD_BITBUFFER_H 22 23 #define CRC_ADTS_HEADER_LEN 56 24 #define CRC_ADTS_RAW_DATA_BLK_LEN 192 25 #define CRC_ADTS_RAW_IIND_ICS 128 26 #define CRC_ADTS_LEN_ALL -1 27 28 #define MAX_REG_SIZE 192 29 #define MAX_CRC_REGS 7 30 31 struct ia_crc_bit_buf_struct { 32 UWORD8 *ptr_bit_buf_base; 33 UWORD8 *ptr_bit_buf_end; 34 35 UWORD8 *ptr_read_next; 36 WORD16 bit_pos; 37 WORD32 cnt_bits; 38 39 WORD32 size; 40 }; 41 42 typedef struct { 43 UWORD8 active; 44 WORD32 buf_size; 45 WORD32 max_bits; 46 UWORD32 bit_cnt; 47 WORD32 bit_buf_cnt; 48 struct ia_crc_bit_buf_struct str_bit_buf; 49 } ia_crc_reg_data_struct; 50 51 typedef struct { 52 UWORD8 crc_active; 53 UWORD16 no_reg; 54 UWORD16 file_value; 55 UWORD16 crc_lookup[256]; 56 ia_crc_reg_data_struct str_crc_reg_data[MAX_CRC_REGS]; 57 } ia_adts_crc_info_struct; 58 59 typedef struct ia_bit_buf_struct { 60 UWORD8 *ptr_bit_buf_base; 61 UWORD8 *ptr_bit_buf_end; 62 63 UWORD8 *ptr_read_next; 64 65 WORD32 bit_pos; 66 WORD32 cnt_bits; 67 68 WORD32 size; 69 70 WORD32 adts_header_present; 71 WORD32 crc_check; 72 WORD8 protection_absent; 73 WORD8 no_raw_data_blocks; 74 ia_adts_crc_info_struct str_adts_crc_info; 75 ia_adts_crc_info_struct *pstr_adts_crc_info; 76 77 WORD32 initial_cnt_bits; 78 WORD32 audio_mux_align; 79 WORD32 bit_count; 80 WORD32 valid_bits; 81 UWORD8 byte; 82 UWORD8 *byte_ptr; 83 UWORD8 *ptr_start; 84 WORD32 write_bit_count; 85 WORD32 max_size; 86 87 } ia_bit_buf_struct; 88 89 typedef struct ia_bit_buf_struct *ia_handle_bit_buf_struct; 90 91 typedef struct ia_crc_bit_buf_struct *ia_crc_bit_buf_struct_handle; 92 93 VOID ixheaacd_byte_align(ia_bit_buf_struct *it_bit_buff, 94 WORD32 *ptr_byte_align_bits); 95 96 ia_bit_buf_struct *ixheaacd_create_bit_buf(ia_bit_buf_struct *it_bit_buff, 97 UWORD8 *ptr_bit_buf_base, 98 WORD32 bit_buf_size); 99 100 ia_bit_buf_struct *ixheaacd_create_init_bit_buf(ia_bit_buf_struct *it_bit_buff, 101 UWORD8 *ptr_bit_buf_base, 102 WORD32 bit_buf_size); 103 104 WORD32 ixheaacd_read_bits_buf(ia_bit_buf_struct *it_bit_buff, WORD no_of_bits); 105 106 WORD32 ixheaacd_show_bits_buf(ia_bit_buf_struct *it_bit_buff, WORD no_of_bits); 107 108 VOID ixheaacd_read_bidirection(ia_bit_buf_struct *it_bit_buff, 109 WORD32 ixheaacd_drc_offset); 110 111 UWORD32 ixheaacd_aac_showbits_32(UWORD8 *ptr_read_next); 112 113 UWORD32 ixheaacd_aac_read_byte(UWORD8 **ptr_read_next, WORD32 *bit_pos, 114 WORD32 *readword); 115 116 UWORD32 ixheaacd_aac_read_2bytes(UWORD8 **ptr_read_next, WORD32 *bit_pos, 117 WORD32 *readword); 118 119 UWORD32 ixheaacd_aac_read_byte_corr(UWORD8 **ptr_read_next, WORD32 *ptr_bit_pos, 120 WORD32 *readword, UWORD8 *p_bit_buf_end); 121 122 UWORD32 ixheaacd_aac_read_byte_corr1(UWORD8 **ptr_read_next, 123 WORD16 *ptr_bit_pos, WORD32 *readword); 124 125 #define get_no_bits_available(it_bit_buff) ((it_bit_buff)->cnt_bits) 126 #define ixheaacd_no_bits_read(it_bit_buff) \ 127 ((it_bit_buff)->size - (it_bit_buff)->cnt_bits) 128 129 WORD32 ixheaacd_aac_read_bit_rev(ia_bit_buf_struct *it_bit_buff); 130 WORD32 ixheaacd_aac_read_bit(ia_bit_buf_struct *it_bit_buff); 131 132 VOID ixheaacd_write_bit(ia_bit_buf_struct *it_bit_buff, WORD32 value, 133 WORD32 no_of_bits); 134 135 WORD32 ixheaacd_read_bit(ia_bit_buf_struct *data, WORD32 no_of_bits); 136 137 #endif /* IXHEAACD_BITBUFFER_H */ 138