aboutsummaryrefslogtreecommitdiff
path: root/encoder/ixheaace_bits_count.h
blob: ee20d36b6a405113553fb05b5c937e51ca115812 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/******************************************************************************
 *                                                                            *
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *****************************************************************************
 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
 */

#pragma once
#define INVALID_BITCOUNT_LC (SHRT_MAX)
#define INVALID_BITCOUNT_LD (SHRT_MAX / 4)

#define abs32(a) (a > 0 ? a : -a)
#define HI_LTAB(a) (a >> 8)
#define LO_LTAB(a) (a & 0xff)

#define HI_EXPLTAB(a) (a >> 16)
#define LO_EXPLTAB(a) (a & 0xffff)
#define EXPAND(a) ((((WORD32)(a & 0xff00)) << 8) | (WORD32)(a & 0xff))

/*  code book number table */
enum codeBookNo {
  CODE_BCK_ZERO_NO = 0,
  CODE_BCK_1_NO = 1,
  CODE_BCK_2_NO = 2,
  CODE_BCK_3_NO = 3,
  CODE_BCK_4_NO = 4,
  CODE_BCK_5_NO = 5,
  CODE_BCK_6_NO = 6,
  CODE_BCK_7_NO = 7,
  CODE_BCK_8_NO = 8,
  CODE_BCK_9_NO = 9,
  CODE_BCK_10_NO = 10,
  CODE_BCK_ESC_NO = 11,
  CODE_BCK_RES_NO = 12,
  CODE_BCK_PNS_NO = 13
};

/*  code book index table */
enum codeBookNdx {
  CODE_BCK_ZERO_NDX,
  CODE_BCK_1_NDX,
  CODE_BCK_2_NDX,
  CODE_BCK_3_NDX,
  CODE_BCK_4_NDX,
  CODE_BCK_5_NDX,
  CODE_BCK_6_NDX,
  CODE_BCK_7_NDX,
  CODE_BCK_8_NDX,
  CODE_BCK_9_NDX,
  CODE_BCK_10_NDX,
  CODE_BCK_ESC_NDX,
  CODE_BCK_RES_NDX,
  CODE_BCK_PNS_NDX,
  NUMBER_OF_CODE_BOOKS
};

/*  code book lav table */
enum codeBookLav {
  CODE_BCK_ZERO_LAV = 0,
  CODE_BCK_1_LAV = 1,
  CODE_BCK_2_LAV = 1,
  CODE_BCK_3_LAV = 2,
  CODE_BCK_4_LAV = 2,
  CODE_BCK_5_LAV = 4,
  CODE_BCK_6_LAV = 4,
  CODE_BCK_7_LAV = 7,
  CODE_BCK_8_LAV = 7,
  CODE_BCK_9_LAV = 12,
  CODE_BCK_10_LAV = 12,
  CODE_BCK_ESC_LAV = 16,
  CODE_BCK_SCF_LAV = 60,
  CODE_BCK_PNS_LAV = 60
};

VOID ia_enhaacplus_enc_bitcount(const WORD16 *ptr_values, const WORD32 width, WORD32 max_val,
                                WORD32 *bit_cnt, ixheaace_huffman_tables *pstr_huffman_tbl,
                                WORD32 aot);

VOID ia_enhaacplus_enc_code_values(WORD16 *ptr_values, WORD32 width, WORD32 code_book,
                                   ixheaace_bit_buf_handle pstr_bitstream,
                                   ixheaace_huffman_tables *pstr_huffman_tbl);

WORD32 ia_enhaacplus_enc_code_scale_factor_delta(WORD32 scalefactor,
                                                 ixheaace_bit_buf_handle h_bitstream,
                                                 ixheaace_huffman_tables *pstr_huffman_tbl);

VOID ia_enhaacplus_enc_count1_2_3_4_5_6_7_8_9_10_11(const WORD16 *values, const WORD32 width,
                                                    WORD32 *bitcnt,
                                                    ixheaace_huffman_tables *pstr_huffman_tbl,
                                                    WORD32 invalid_bitcnt);