xref: /aosp_15_r20/external/libxaac/encoder/ixheaace_bitbuffer.h (revision 15dc779a375ca8b5125643b829a8aa4b70d7f451)
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 
21 #pragma once
22 
23 #undef ARIB_COMPLIANCE
24 #undef ADTS_CRC_ENABLE
25 
26 typedef struct {
27   UWORD8 *ptr_bit_buf_base; /* pointer points to first position in bitstream buffer */
28   UWORD8 *ptr_bit_buf_end;  /* pointer points to last position in bitstream buffer */
29   UWORD8 *ptr_read_next;  /* pointer points to next available word in bitstream buffer to read */
30   UWORD8 *ptr_write_next; /* pointer points to next available word in bitstream buffer to write */
31   WORD32 read_position;   /* 7 <= read_position <= 0 */
32   WORD32 write_position;  /* 7 <= write_position <= 0 */
33   WORD32 cnt_bits;        /* number of available bits in the bitstream buffer
34                          write bits to bitstream buffer  => increment cnt_bits
35                          read bits from bitstream buffer => decrement cnt_bits */
36   WORD32 size;            /* size of bitbuffer in bits */
37 } ixheaace_bit_buf;
38 
39 /* Define pointer to bit buffer structure */
40 typedef ixheaace_bit_buf *ixheaace_bit_buf_handle;
41 
42 ixheaace_bit_buf_handle ia_enhaacplus_enc_create_bitbuffer(ixheaace_bit_buf_handle pstr_bit_buf,
43                                                            UWORD8 *ptr_bit_buf_base,
44                                                            UWORD32 bitbuf_size);
45 
46 VOID ia_enhaacplus_enc_delete_bitbuffer(ixheaace_bit_buf_handle pstr_bit_buf);
47 
48 UWORD32 ixheaace_readbits(ixheaace_bit_buf_handle pstr_bit_buf, UWORD8 no_bits_to_read);
49 
50 UWORD8 ixheaace_write_bits(ixheaace_bit_buf_handle pstr_bit_buf, UWORD32 write_value,
51                            UWORD8 num_bits_to_write);
52 
53 VOID ixheaace_reset_bitbuf(ixheaace_bit_buf_handle pstr_bit_buf, UWORD8 *ptr_bit_buf_base,
54                            UWORD32 bitbuf_size);
55 
56 VOID ixheaace_copy_bitbuf_to_and_fro(ixheaace_bit_buf_handle h_bitbuf_src,
57                                      ixheaace_bit_buf_handle h_bitbuf_dst);
58 
59 VOID ia_enhaacplus_enc_copy_bitbuf(ixheaace_bit_buf_handle h_bitbuf_src,
60                                    ixheaace_bit_buf_handle h_bitbuf_dst);
61 
62 VOID ia_enhaacplus_enc_wind_bitbuffer_bidirectional(ixheaace_bit_buf_handle pstr_bit_buf,
63                                                     WORD32 offset);
64 
65 WORD32 ia_enhaacplus_enc_get_bits_available(ixheaace_bit_buf_handle pstr_bit_buf_handle);
66 
67 UWORD32 ixheaace_byte_align_buffer(ixheaace_bit_buf_handle pstr_it_bit_buff);
68