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 #define INVALID_BITCOUNT_LC (SHRT_MAX) 23 #define INVALID_BITCOUNT_LD (SHRT_MAX / 4) 24 25 #define abs32(a) (a > 0 ? a : -a) 26 #define HI_LTAB(a) (a >> 8) 27 #define LO_LTAB(a) (a & 0xff) 28 29 #define HI_EXPLTAB(a) (a >> 16) 30 #define LO_EXPLTAB(a) (a & 0xffff) 31 #define EXPAND(a) ((((WORD32)(a & 0xff00)) << 8) | (WORD32)(a & 0xff)) 32 33 /* code book number table */ 34 enum codeBookNo { 35 CODE_BCK_ZERO_NO = 0, 36 CODE_BCK_1_NO = 1, 37 CODE_BCK_2_NO = 2, 38 CODE_BCK_3_NO = 3, 39 CODE_BCK_4_NO = 4, 40 CODE_BCK_5_NO = 5, 41 CODE_BCK_6_NO = 6, 42 CODE_BCK_7_NO = 7, 43 CODE_BCK_8_NO = 8, 44 CODE_BCK_9_NO = 9, 45 CODE_BCK_10_NO = 10, 46 CODE_BCK_ESC_NO = 11, 47 CODE_BCK_RES_NO = 12, 48 CODE_BCK_PNS_NO = 13 49 }; 50 51 /* code book index table */ 52 enum codeBookNdx { 53 CODE_BCK_ZERO_NDX, 54 CODE_BCK_1_NDX, 55 CODE_BCK_2_NDX, 56 CODE_BCK_3_NDX, 57 CODE_BCK_4_NDX, 58 CODE_BCK_5_NDX, 59 CODE_BCK_6_NDX, 60 CODE_BCK_7_NDX, 61 CODE_BCK_8_NDX, 62 CODE_BCK_9_NDX, 63 CODE_BCK_10_NDX, 64 CODE_BCK_ESC_NDX, 65 CODE_BCK_RES_NDX, 66 CODE_BCK_PNS_NDX, 67 NUMBER_OF_CODE_BOOKS 68 }; 69 70 /* code book lav table */ 71 enum codeBookLav { 72 CODE_BCK_ZERO_LAV = 0, 73 CODE_BCK_1_LAV = 1, 74 CODE_BCK_2_LAV = 1, 75 CODE_BCK_3_LAV = 2, 76 CODE_BCK_4_LAV = 2, 77 CODE_BCK_5_LAV = 4, 78 CODE_BCK_6_LAV = 4, 79 CODE_BCK_7_LAV = 7, 80 CODE_BCK_8_LAV = 7, 81 CODE_BCK_9_LAV = 12, 82 CODE_BCK_10_LAV = 12, 83 CODE_BCK_ESC_LAV = 16, 84 CODE_BCK_SCF_LAV = 60, 85 CODE_BCK_PNS_LAV = 60 86 }; 87 88 VOID ia_enhaacplus_enc_bitcount(const WORD16 *ptr_values, const WORD32 width, WORD32 max_val, 89 WORD32 *bit_cnt, ixheaace_huffman_tables *pstr_huffman_tbl, 90 WORD32 aot); 91 92 VOID ia_enhaacplus_enc_code_values(WORD16 *ptr_values, WORD32 width, WORD32 code_book, 93 ixheaace_bit_buf_handle pstr_bitstream, 94 ixheaace_huffman_tables *pstr_huffman_tbl); 95 96 VOID ia_enhaacplus_enc_code_scale_factor_delta(WORD32 scalefactor, 97 ixheaace_bit_buf_handle h_bitstream, 98 ixheaace_huffman_tables *pstr_huffman_tbl); 99 100 VOID ia_enhaacplus_enc_count1_2_3_4_5_6_7_8_9_10_11(const WORD16 *values, const WORD32 width, 101 WORD32 *bitcnt, 102 ixheaace_huffman_tables *pstr_huffman_tbl, 103 WORD32 invalid_bitcnt); 104