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 #ifndef IXHEAACD_MPS_RES_HUFFMAN_H
21 #define IXHEAACD_MPS_RES_HUFFMAN_H
22
23 #define _SWAP(a, b) \
24 (b = (((WORD32)a[0] << 24) | ((WORD32)a[1] << 16) | ((WORD32)a[2] << 8) | ((WORD32)a[3])))
25
26 extern UWORD32 ixheaacd_res_aac_showbits_32(UWORD8 *p_read_next);
27
ixheaacd_res_exts(UWORD32 a,WORD32 shift_left,WORD32 shift_right)28 static PLATFORM_INLINE WORD32 ixheaacd_res_exts(UWORD32 a, WORD32 shift_left,
29 WORD32 shift_right) {
30 WORD32 x;
31 x = (UWORD32)a << shift_left;
32 x = (WORD32)x >> shift_right;
33
34 return x;
35 }
36
ixheaacd_aac_read_2bytes(UWORD8 ** p_read_next,WORD32 * r_bit_pos,WORD32 * readword)37 static PLATFORM_INLINE UWORD32 ixheaacd_aac_read_2bytes(UWORD8 **p_read_next, WORD32 *r_bit_pos,
38 WORD32 *readword) {
39 UWORD8 *v = *p_read_next;
40 WORD32 bits_consumed = *r_bit_pos;
41
42 if ((bits_consumed - 16) >= 0) {
43 *readword = (*readword << 8) | *v;
44 v++;
45 *readword = (*readword << 8) | *v;
46 v++;
47 bits_consumed -= 16;
48 } else if ((bits_consumed - 8) >= 0) {
49 *readword = (*readword << 8) | *v;
50 v++;
51 bits_consumed -= 8;
52 }
53
54 *r_bit_pos = bits_consumed;
55 *p_read_next = v;
56 return 1;
57 }
58
59 #endif /* IXHEAACD_MPS_RES_HUFFMAN_H */
60