blob: 4fca89a8a58f73bbb5a4ac18345746e9ffe25330
1 | /* |
2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
4 | ** |
5 | ** This program is free software; you can redistribute it and/or modify |
6 | ** it under the terms of the GNU General Public License as published by |
7 | ** the Free Software Foundation; either version 2 of the License, or |
8 | ** (at your option) any later version. |
9 | ** |
10 | ** This program is distributed in the hope that it will be useful, |
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | ** GNU General Public License for more details. |
14 | ** |
15 | ** You should have received a copy of the GNU General Public License |
16 | ** along with this program; if not, write to the Free Software |
17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | ** |
19 | ** Any non-GPL usage of this software or parts of this software is strictly |
20 | ** forbidden. |
21 | ** |
22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
24 | ** |
25 | ** Commercial non-GPL licensing of this software is possible. |
26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
27 | ** |
28 | ** $Id: hcb.h,v 1.8 2007/11/01 12:34:10 menno Exp $ |
29 | **/ |
30 | |
31 | #ifndef __HCB_H__ |
32 | #define __HCB_H__ |
33 | |
34 | #ifdef __cplusplus |
35 | extern "C" { |
36 | #endif |
37 | |
38 | /* |
39 | * Optimal huffman decoding for AAC taken from: |
40 | * "SELECTING AN OPTIMAL HUFFMAN DECODER FOR AAC" by |
41 | * VLADIMIR Z. MESAROVIC , RAGHUNATH RAO, MIROSLAV V. DOKIC, and SACHIN DEO |
42 | * AES paper 5436 |
43 | * |
44 | * 2 methods are used for huffman decoding: |
45 | * - binary search |
46 | * - 2-step table lookup |
47 | * |
48 | * The choice of the "optimal" method is based on the fact that if the |
49 | * memory size for the Two-step is exorbitantly high then the decision |
50 | * is Binary search for that codebook. However, for marginally more memory |
51 | * size, if Twostep outperforms even the best case of Binary then the |
52 | * decision is Two-step for that codebook. |
53 | * |
54 | * The following methods are used for the different tables. |
55 | * codebook "optimal" method |
56 | * HCB_1 2-Step |
57 | * HCB_2 2-Step |
58 | * HCB_3 Binary |
59 | * HCB_4 2-Step |
60 | * HCB_5 Binary |
61 | * HCB_6 2-Step |
62 | * HCB_7 Binary |
63 | * HCB_8 2-Step |
64 | * HCB_9 Binary |
65 | * HCB_10 2-Step |
66 | * HCB_11 2-Step |
67 | * HCB_SF Binary |
68 | * |
69 | */ |
70 | |
71 | |
72 | #define ZERO_HCB 0 |
73 | #define FIRST_PAIR_HCB 5 |
74 | #define ESC_HCB 11 |
75 | #define QUAD_LEN 4 |
76 | #define PAIR_LEN 2 |
77 | #define NOISE_HCB 13 |
78 | #define INTENSITY_HCB2 14 |
79 | #define INTENSITY_HCB 15 |
80 | |
81 | /* 1st step table */ |
82 | typedef struct { |
83 | uint8_t offset; |
84 | uint8_t extra_bits; |
85 | } hcb; |
86 | |
87 | /* 2nd step table with quadruple data */ |
88 | typedef struct { |
89 | uint8_t bits; |
90 | int8_t x; |
91 | int8_t y; |
92 | } hcb_2_pair; |
93 | |
94 | typedef struct { |
95 | uint8_t bits; |
96 | int8_t x; |
97 | int8_t y; |
98 | int8_t v; |
99 | int8_t w; |
100 | } hcb_2_quad; |
101 | |
102 | /* binary search table */ |
103 | typedef struct { |
104 | uint8_t is_leaf; |
105 | int8_t data[4]; |
106 | } hcb_bin_quad; |
107 | |
108 | typedef struct { |
109 | uint8_t is_leaf; |
110 | int8_t data[2]; |
111 | } hcb_bin_pair; |
112 | |
113 | hcb *hcb_table[]; |
114 | hcb_2_quad *hcb_2_quad_table[]; |
115 | hcb_2_pair *hcb_2_pair_table[]; |
116 | hcb_bin_pair *hcb_bin_table[]; |
117 | uint8_t hcbN[]; |
118 | uint8_t unsigned_cb[]; |
119 | int hcb_2_quad_table_size[]; |
120 | int hcb_2_pair_table_size[]; |
121 | int hcb_bin_table_size[]; |
122 | |
123 | #include "codebook/hcb_1.h" |
124 | #include "codebook/hcb_2.h" |
125 | #include "codebook/hcb_3.h" |
126 | #include "codebook/hcb_4.h" |
127 | #include "codebook/hcb_5.h" |
128 | #include "codebook/hcb_6.h" |
129 | #include "codebook/hcb_7.h" |
130 | #include "codebook/hcb_8.h" |
131 | #include "codebook/hcb_9.h" |
132 | #include "codebook/hcb_10.h" |
133 | #include "codebook/hcb_11.h" |
134 | #include "codebook/hcb_sf.h" |
135 | |
136 | |
137 | #ifdef __cplusplus |
138 | } |
139 | #endif |
140 | #endif |
141 |