add multiple inclusion guards to headers
[libav.git] / libavcodec / cavsdata.h
CommitLineData
0abc2e73
MN
1/*
2 * Chinese AVS video (AVS1-P2, JiZhun profile) decoder.
3 * Copyright (c) 2006 Stefan Gehrer <stefan.gehrer@gmx.de>
4 *
b78e7197
DB
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
0abc2e73
MN
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
b78e7197 10 * version 2.1 of the License, or (at your option) any later version.
0abc2e73 11 *
b78e7197 12 * FFmpeg is distributed in the hope that it will be useful,
0abc2e73
MN
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
b78e7197 18 * License along with FFmpeg; if not, write to the Free Software
0abc2e73
MN
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
699b3f99
MR
22#ifndef AVCODEC_CAVSDATA_H
23#define AVCODEC_CAVSDATA_H
24
b88e2114 25#include "cavs.h"
0abc2e73 26
69f34e5b 27static const uint8_t partition_flags[30] = {
c90c3919
SG
28 0, //I_8X8
29 0, //P_SKIP
30 0, //P_16X16
31 SPLITH, //P_16X8
32 SPLITV, //P_8X16
33 SPLITH|SPLITV, //P_8X8
34 SPLITH|SPLITV, //B_SKIP
35 SPLITH|SPLITV, //B_DIRECT
36 0, //B_FWD_16X16
37 0, //B_BWD_16X16
38 0, //B_SYM_16X16
39 FWD0|FWD1 |SPLITH,
40 FWD0|FWD1 |SPLITV,
41 BWD0|BWD1 |SPLITH,
42 BWD0|BWD1 |SPLITV,
43 FWD0|BWD1 |SPLITH,
44 FWD0|BWD1 |SPLITV,
45 BWD0|FWD1 |SPLITH,
46 BWD0|FWD1 |SPLITV,
47 FWD0|FWD1 |SYM1|SPLITH,
48 FWD0|FWD1 |SYM1 |SPLITV,
49 BWD0|FWD1 |SYM1|SPLITH,
50 BWD0|FWD1 |SYM1 |SPLITV,
51 FWD0|FWD1|SYM0 |SPLITH,
52 FWD0|FWD1|SYM0 |SPLITV,
53 FWD0|BWD1|SYM0 |SPLITH,
54 FWD0|BWD1|SYM0 |SPLITV,
55 FWD0|FWD1|SYM0|SYM1|SPLITH,
56 FWD0|FWD1|SYM0|SYM1 |SPLITV,
57 SPLITH|SPLITV, //B_8X8 = 29
0abc2e73
MN
58};
59
60static const uint8_t scan3x3[4] = {4,5,7,8};
61
62static const uint8_t mv_scan[4] = {
63 MV_FWD_X0,MV_FWD_X1,
64 MV_FWD_X2,MV_FWD_X3
65};
66
67static const uint8_t cbp_tab[64][2] = {
68 {63, 0},{15,15},{31,63},{47,31},{ 0,16},{14,32},{13,47},{11,13},
69 { 7,14},{ 5,11},{10,12},{ 8, 5},{12,10},{61, 7},{ 4,48},{55, 3},
70 { 1, 2},{ 2, 8},{59, 4},{ 3, 1},{62,61},{ 9,55},{ 6,59},{29,62},
71 {45,29},{51,27},{23,23},{39,19},{27,30},{46,28},{53, 9},{30, 6},
72 {43,60},{37,21},{60,44},{16,26},{21,51},{28,35},{19,18},{35,20},
73 {42,24},{26,53},{44,17},{32,37},{58,39},{24,45},{20,58},{17,43},
74 {18,42},{48,46},{22,36},{33,33},{25,34},{49,40},{40,52},{36,49},
75 {34,50},{50,56},{52,25},{54,22},{41,54},{56,57},{38,41},{57,38}
76};
77
78static const uint8_t chroma_qp[64] = {
79 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,
80 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
81 32,33,34,35,36,37,38,39,40,41,42,42,43,43,44,44,
82 45,45,46,46,47,47,48,48,48,49,49,49,50,50,50,51
83};
84
85static const uint8_t dequant_shift[64] = {
86 14,14,14,14,14,14,14,14,
87 13,13,13,13,13,13,13,13,
88 13,12,12,12,12,12,12,12,
89 11,11,11,11,11,11,11,11,
90 11,10,10,10,10,10,10,10,
91 10, 9, 9, 9, 9, 9, 9, 9,
92 9, 8, 8, 8, 8, 8, 8, 8,
93 7, 7, 7, 7, 7, 7, 7, 7
94};
95
96static const uint16_t dequant_mul[64] = {
97 32768,36061,38968,42495,46341,50535,55437,60424,
98 32932,35734,38968,42495,46177,50535,55109,59933,
99 65535,35734,38968,42577,46341,50617,55027,60097,
100 32809,35734,38968,42454,46382,50576,55109,60056,
101 65535,35734,38968,42495,46320,50515,55109,60076,
102 65535,35744,38968,42495,46341,50535,55099,60087,
103 65535,35734,38973,42500,46341,50535,55109,60097,
104 32771,35734,38965,42497,46341,50535,55109,60099
105};
106
f503b195
SG
107/** marks block as unavailable, i.e. out of picture
108 or not yet decoded */
0abc2e73
MN
109static const vector_t un_mv = {0,0,1,NOT_AVAIL};
110
f503b195
SG
111/** marks block as "no prediction from this direction"
112 e.g. forward motion vector in BWD partition */
0abc2e73
MN
113static const vector_t dir_mv = {0,0,1,REF_DIR};
114
f503b195 115/** marks block as using intra prediction */
0abc2e73
MN
116static const vector_t intra_mv = {0,0,1,REF_INTRA};
117
50879935
SG
118#define EOB 0,0,0
119
0abc2e73
MN
120static const residual_vlc_t intra_2dvlc[7] = {
121 {
122 { //level / run / table_inc
50879935
SG
123 { 1, 1, 1},{ -1, 1, 1},{ 1, 2, 1},{ -1, 2, 1},{ 1, 3, 1},{ -1, 3, 1},
124 { 1, 4, 1},{ -1, 4, 1},{ 1, 5, 1},{ -1, 5, 1},{ 1, 6, 1},{ -1, 6, 1},
125 { 1, 7, 1},{ -1, 7, 1},{ 1, 8, 1},{ -1, 8, 1},{ 1, 9, 1},{ -1, 9, 1},
126 { 1,10, 1},{ -1,10, 1},{ 1,11, 1},{ -1,11, 1},{ 2, 1, 2},{ -2, 1, 2},
127 { 1,12, 1},{ -1,12, 1},{ 1,13, 1},{ -1,13, 1},{ 1,14, 1},{ -1,14, 1},
128 { 1,15, 1},{ -1,15, 1},{ 2, 2, 2},{ -2, 2, 2},{ 1,16, 1},{ -1,16, 1},
129 { 1,17, 1},{ -1,17, 1},{ 3, 1, 3},{ -3, 1, 3},{ 1,18, 1},{ -1,18, 1},
130 { 1,19, 1},{ -1,19, 1},{ 2, 3, 2},{ -2, 3, 2},{ 1,20, 1},{ -1,20, 1},
131 { 1,21, 1},{ -1,21, 1},{ 2, 4, 2},{ -2, 4, 2},{ 1,22, 1},{ -1,22, 1},
132 { 2, 5, 2},{ -2, 5, 2},{ 1,23, 1},{ -1,23, 1},{ EOB }
0abc2e73
MN
133 },
134 //level_add
50879935 135 { 0, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
0abc2e73
MN
136 2, 2, 2, 2, 2, 2, 2,-1,-1,-1},
137 2, //golomb_order
138 0, //inc_limit
50879935 139 23, //max_run
0abc2e73
MN
140 },{
141 { //level / run
50879935
SG
142 { 1, 1, 0},{ -1, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 2, 1, 1},{ -2, 1, 1},
143 { 1, 3, 0},{ -1, 3, 0},{ EOB },{ 1, 4, 0},{ -1, 4, 0},{ 1, 5, 0},
144 { -1, 5, 0},{ 1, 6, 0},{ -1, 6, 0},{ 3, 1, 2},{ -3, 1, 2},{ 2, 2, 1},
145 { -2, 2, 1},{ 1, 7, 0},{ -1, 7, 0},{ 1, 8, 0},{ -1, 8, 0},{ 1, 9, 0},
146 { -1, 9, 0},{ 2, 3, 1},{ -2, 3, 1},{ 4, 1, 2},{ -4, 1, 2},{ 1,10, 0},
147 { -1,10, 0},{ 1,11, 0},{ -1,11, 0},{ 2, 4, 1},{ -2, 4, 1},{ 3, 2, 2},
148 { -3, 2, 2},{ 1,12, 0},{ -1,12, 0},{ 2, 5, 1},{ -2, 5, 1},{ 5, 1, 3},
149 { -5, 1, 3},{ 1,13, 0},{ -1,13, 0},{ 2, 6, 1},{ -2, 6, 1},{ 1,14, 0},
150 { -1,14, 0},{ 2, 7, 1},{ -2, 7, 1},{ 2, 8, 1},{ -2, 8, 1},{ 3, 3, 2},
151 { -3, 3, 2},{ 6, 1, 3},{ -6, 1, 3},{ 1,15, 0},{ -1,15, 0}
0abc2e73
MN
152 },
153 //level_add
50879935 154 { 0, 7, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2,-1,
0abc2e73
MN
155 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
156 2, //golomb_order
157 1, //inc_limit
50879935 158 15, //max_run
0abc2e73
MN
159 },{
160 { //level / run
50879935
SG
161 { 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 1, 2, 0},{ -1, 2, 0},
162 { 3, 1, 1},{ -3, 1, 1},{ EOB },{ 1, 3, 0},{ -1, 3, 0},{ 2, 2, 0},
163 { -2, 2, 0},{ 4, 1, 1},{ -4, 1, 1},{ 1, 4, 0},{ -1, 4, 0},{ 5, 1, 2},
164 { -5, 1, 2},{ 1, 5, 0},{ -1, 5, 0},{ 3, 2, 1},{ -3, 2, 1},{ 2, 3, 0},
165 { -2, 3, 0},{ 1, 6, 0},{ -1, 6, 0},{ 6, 1, 2},{ -6, 1, 2},{ 2, 4, 0},
166 { -2, 4, 0},{ 1, 7, 0},{ -1, 7, 0},{ 4, 2, 1},{ -4, 2, 1},{ 7, 1, 2},
167 { -7, 1, 2},{ 3, 3, 1},{ -3, 3, 1},{ 2, 5, 0},{ -2, 5, 0},{ 1, 8, 0},
168 { -1, 8, 0},{ 2, 6, 0},{ -2, 6, 0},{ 8, 1, 3},{ -8, 1, 3},{ 1, 9, 0},
169 { -1, 9, 0},{ 5, 2, 2},{ -5, 2, 2},{ 3, 4, 1},{ -3, 4, 1},{ 2, 7, 0},
170 { -2, 7, 0},{ 9, 1, 3},{ -9, 1, 3},{ 1,10, 0},{ -1,10, 0}
0abc2e73
MN
171 },
172 //level_add
50879935 173 { 0,10, 6, 4, 4, 3, 3, 3, 2, 2, 2,-1,-1,-1,-1,-1,-1,
0abc2e73
MN
174 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
175 2, //golomb_order
176 2, //inc_limit
50879935 177 10, //max_run
0abc2e73
MN
178 },{
179 { //level / run
50879935
SG
180 { 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},{ -3, 1, 0},
181 { 1, 2, 0},{ -1, 2, 0},{ EOB },{ 4, 1, 0},{ -4, 1, 0},{ 5, 1, 1},
182 { -5, 1, 1},{ 2, 2, 0},{ -2, 2, 0},{ 1, 3, 0},{ -1, 3, 0},{ 6, 1, 1},
183 { -6, 1, 1},{ 3, 2, 0},{ -3, 2, 0},{ 7, 1, 1},{ -7, 1, 1},{ 1, 4, 0},
184 { -1, 4, 0},{ 8, 1, 2},{ -8, 1, 2},{ 2, 3, 0},{ -2, 3, 0},{ 4, 2, 0},
185 { -4, 2, 0},{ 1, 5, 0},{ -1, 5, 0},{ 9, 1, 2},{ -9, 1, 2},{ 5, 2, 1},
186 { -5, 2, 1},{ 2, 4, 0},{ -2, 4, 0},{ 10, 1, 2},{-10, 1, 2},{ 3, 3, 0},
187 { -3, 3, 0},{ 1, 6, 0},{ -1, 6, 0},{ 11, 1, 3},{-11, 1, 3},{ 6, 2, 1},
188 { -6, 2, 1},{ 1, 7, 0},{ -1, 7, 0},{ 2, 5, 0},{ -2, 5, 0},{ 3, 4, 0},
189 { -3, 4, 0},{ 12, 1, 3},{-12, 1, 3},{ 4, 3, 0},{ -4, 3, 0}
0abc2e73
MN
190 },
191 //level_add
50879935 192 { 0,13, 7, 5, 4, 3, 2, 2,-1,-1,-1 -1,-1,-1,-1,-1,-1,
0abc2e73
MN
193 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
194 2, //golomb_order
195 4, //inc_limit
50879935 196 7, //max_run
0abc2e73
MN
197 },{
198 { //level / run
50879935
SG
199 { 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},{ -3, 1, 0},
200 { EOB },{ 4, 1, 0},{ -4, 1, 0},{ 5, 1, 0},{ -5, 1, 0},{ 6, 1, 0},
201 { -6, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 7, 1, 0},{ -7, 1, 0},{ 8, 1, 1},
202 { -8, 1, 1},{ 2, 2, 0},{ -2, 2, 0},{ 9, 1, 1},{ -9, 1, 1},{ 10, 1, 1},
203 {-10, 1, 1},{ 1, 3, 0},{ -1, 3, 0},{ 3, 2, 0},{ -3, 2, 0},{ 11, 1, 2},
204 {-11, 1, 2},{ 4, 2, 0},{ -4, 2, 0},{ 12, 1, 2},{-12, 1, 2},{ 13, 1, 2},
205 {-13, 1, 2},{ 5, 2, 0},{ -5, 2, 0},{ 1, 4, 0},{ -1, 4, 0},{ 2, 3, 0},
206 { -2, 3, 0},{ 14, 1, 2},{-14, 1, 2},{ 6, 2, 0},{ -6, 2, 0},{ 15, 1, 2},
207 {-15, 1, 2},{ 16, 1, 2},{-16, 1, 2},{ 3, 3, 0},{ -3, 3, 0},{ 1, 5, 0},
208 { -1, 5, 0},{ 7, 2, 0},{ -7, 2, 0},{ 17, 1, 2},{-17, 1, 2}
0abc2e73
MN
209 },
210 //level_add
50879935 211 { 0,18, 8, 4, 2, 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
0abc2e73
MN
212 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
213 2, //golomb_order
214 7, //inc_limit
50879935 215 5, //max_run
0abc2e73
MN
216 },{
217 { //level / run
50879935
SG
218 { EOB },{ 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},
219 { -3, 1, 0},{ 4, 1, 0},{ -4, 1, 0},{ 5, 1, 0},{ -5, 1, 0},{ 6, 1, 0},
220 { -6, 1, 0},{ 7, 1, 0},{ -7, 1, 0},{ 8, 1, 0},{ -8, 1, 0},{ 9, 1, 0},
221 { -9, 1, 0},{ 10, 1, 0},{-10, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 11, 1, 1},
222 {-11, 1, 1},{ 12, 1, 1},{-12, 1, 1},{ 13, 1, 1},{-13, 1, 1},{ 2, 2, 0},
223 { -2, 2, 0},{ 14, 1, 1},{-14, 1, 1},{ 15, 1, 1},{-15, 1, 1},{ 3, 2, 0},
224 { -3, 2, 0},{ 16, 1, 1},{-16, 1, 1},{ 1, 3, 0},{ -1, 3, 0},{ 17, 1, 1},
225 {-17, 1, 1},{ 4, 2, 0},{ -4, 2, 0},{ 18, 1, 1},{-18, 1, 1},{ 5, 2, 0},
226 { -5, 2, 0},{ 19, 1, 1},{-19, 1, 1},{ 20, 1, 1},{-20, 1, 1},{ 6, 2, 0},
227 { -6, 2, 0},{ 21, 1, 1},{-21, 1, 1},{ 2, 3, 0},{ -2, 3, 0}
0abc2e73
MN
228 },
229 //level_add
50879935 230 { 0,22, 7, 3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
0abc2e73
MN
231 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
232 2, //golomb_order
233 10, //inc_limit
50879935 234 3, //max_run
0abc2e73
MN
235 },{
236 { //level / run
50879935
SG
237 { EOB },{ 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},
238 { -3, 1, 0},{ 4, 1, 0},{ -4, 1, 0},{ 5, 1, 0},{ -5, 1, 0},{ 6, 1, 0},
239 { -6, 1, 0},{ 7, 1, 0},{ -7, 1, 0},{ 8, 1, 0},{ -8, 1, 0},{ 9, 1, 0},
240 { -9, 1, 0},{ 10, 1, 0},{-10, 1, 0},{ 11, 1, 0},{-11, 1, 0},{ 12, 1, 0},
241 {-12, 1, 0},{ 13, 1, 0},{-13, 1, 0},{ 14, 1, 0},{-14, 1, 0},{ 15, 1, 0},
242 {-15, 1, 0},{ 16, 1, 0},{-16, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 17, 1, 0},
243 {-17, 1, 0},{ 18, 1, 0},{-18, 1, 0},{ 19, 1, 0},{-19, 1, 0},{ 20, 1, 0},
244 {-20, 1, 0},{ 21, 1, 0},{-21, 1, 0},{ 2, 2, 0},{ -2, 2, 0},{ 22, 1, 0},
245 {-22, 1, 0},{ 23, 1, 0},{-23, 1, 0},{ 24, 1, 0},{-24, 1, 0},{ 25, 1, 0},
246 {-25, 1, 0},{ 3, 2, 0},{ -3, 2, 0},{ 26, 1, 0},{-26, 1, 0}
0abc2e73
MN
247 },
248 //level_add
50879935 249 { 0,27, 4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
0abc2e73
MN
250 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
251 2, //golomb_order
252 INT_MAX, //inc_limit
50879935 253 2, //max_run
0abc2e73
MN
254 }
255};
256
257static const residual_vlc_t inter_2dvlc[7] = {
258 {
259 { //level / run
50879935
SG
260 { 1, 1, 1},{ -1, 1, 1},{ 1, 2, 1},{ -1, 2, 1},{ 1, 3, 1},{ -1, 3, 1},
261 { 1, 4, 1},{ -1, 4, 1},{ 1, 5, 1},{ -1, 5, 1},{ 1, 6, 1},{ -1, 6, 1},
262 { 1, 7, 1},{ -1, 7, 1},{ 1, 8, 1},{ -1, 8, 1},{ 1, 9, 1},{ -1, 9, 1},
263 { 1,10, 1},{ -1,10, 1},{ 1,11, 1},{ -1,11, 1},{ 1,12, 1},{ -1,12, 1},
264 { 1,13, 1},{ -1,13, 1},{ 2, 1, 2},{ -2, 1, 2},{ 1,14, 1},{ -1,14, 1},
265 { 1,15, 1},{ -1,15, 1},{ 1,16, 1},{ -1,16, 1},{ 1,17, 1},{ -1,17, 1},
266 { 1,18, 1},{ -1,18, 1},{ 1,19, 1},{ -1,19, 1},{ 3, 1, 3},{ -3, 1, 3},
267 { 1,20, 1},{ -1,20, 1},{ 1,21, 1},{ -1,21, 1},{ 2, 2, 2},{ -2, 2, 2},
268 { 1,22, 1},{ -1,22, 1},{ 1,23, 1},{ -1,23, 1},{ 1,24, 1},{ -1,24, 1},
269 { 1,25, 1},{ -1,25, 1},{ 1,26, 1},{ -1,26, 1},{ EOB }
0abc2e73
MN
270 },
271 //level_add
50879935 272 { 0, 4, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
0abc2e73
MN
273 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
274 3, //golomb_order
275 0, //inc_limit
50879935 276 26 //max_run
0abc2e73
MN
277 },{
278 { //level / run
50879935
SG
279 { 1, 1, 0},{ -1, 1, 0},{ EOB },{ 1, 2, 0},{ -1, 2, 0},{ 1, 3, 0},
280 { -1, 3, 0},{ 1, 4, 0},{ -1, 4, 0},{ 1, 5, 0},{ -1, 5, 0},{ 1, 6, 0},
281 { -1, 6, 0},{ 2, 1, 1},{ -2, 1, 1},{ 1, 7, 0},{ -1, 7, 0},{ 1, 8, 0},
282 { -1, 8, 0},{ 1, 9, 0},{ -1, 9, 0},{ 1,10, 0},{ -1,10, 0},{ 2, 2, 1},
283 { -2, 2, 1},{ 1,11, 0},{ -1,11, 0},{ 1,12, 0},{ -1,12, 0},{ 3, 1, 2},
284 { -3, 1, 2},{ 1,13, 0},{ -1,13, 0},{ 1,14, 0},{ -1,14, 0},{ 2, 3, 1},
285 { -2, 3, 1},{ 1,15, 0},{ -1,15, 0},{ 2, 4, 1},{ -2, 4, 1},{ 1,16, 0},
286 { -1,16, 0},{ 2, 5, 1},{ -2, 5, 1},{ 1,17, 0},{ -1,17, 0},{ 4, 1, 3},
287 { -4, 1, 3},{ 2, 6, 1},{ -2, 6, 1},{ 1,18, 0},{ -1,18, 0},{ 1,19, 0},
288 { -1,19, 0},{ 2, 7, 1},{ -2, 7, 1},{ 3, 2, 2},{ -3, 2, 2}
0abc2e73
MN
289 },
290 //level_add
50879935 291 { 0, 5, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2,
0abc2e73
MN
292 2, 2, 2,-1,-1,-1,-1,-1,-1,-1},
293 2, //golomb_order
294 1, //inc_limit
50879935 295 19 //max_run
0abc2e73
MN
296 },{
297 { //level / run
50879935
SG
298 { 1, 1, 0},{ -1, 1, 0},{ EOB },{ 1, 2, 0},{ -1, 2, 0},{ 2, 1, 0},
299 { -2, 1, 0},{ 1, 3, 0},{ -1, 3, 0},{ 1, 4, 0},{ -1, 4, 0},{ 3, 1, 1},
300 { -3, 1, 1},{ 2, 2, 0},{ -2, 2, 0},{ 1, 5, 0},{ -1, 5, 0},{ 1, 6, 0},
301 { -1, 6, 0},{ 1, 7, 0},{ -1, 7, 0},{ 2, 3, 0},{ -2, 3, 0},{ 4, 1, 2},
302 { -4, 1, 2},{ 1, 8, 0},{ -1, 8, 0},{ 3, 2, 1},{ -3, 2, 1},{ 2, 4, 0},
303 { -2, 4, 0},{ 1, 9, 0},{ -1, 9, 0},{ 1,10, 0},{ -1,10, 0},{ 5, 1, 2},
304 { -5, 1, 2},{ 2, 5, 0},{ -2, 5, 0},{ 1,11, 0},{ -1,11, 0},{ 2, 6, 0},
305 { -2, 6, 0},{ 1,12, 0},{ -1,12, 0},{ 3, 3, 1},{ -3, 3, 1},{ 6, 1, 2},
306 { -6, 1, 2},{ 4, 2, 2},{ -4, 2, 2},{ 1,13, 0},{ -1,13, 0},{ 2, 7, 0},
307 { -2, 7, 0},{ 3, 4, 1},{ -3, 4, 1},{ 1,14, 0},{ -1,14, 0}
0abc2e73
MN
308 },
309 //level_add
50879935 310 { 0, 7, 5, 4, 4, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2,-1,-1,
0abc2e73
MN
311 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
312 2, //golomb_order
313 2, //inc_limit
50879935 314 14 //max_run
0abc2e73
MN
315 },{
316 { //level / run
50879935
SG
317 { 1, 1, 0},{ -1, 1, 0},{ EOB },{ 2, 1, 0},{ -2, 1, 0},{ 1, 2, 0},
318 { -1, 2, 0},{ 3, 1, 0},{ -3, 1, 0},{ 1, 3, 0},{ -1, 3, 0},{ 2, 2, 0},
319 { -2, 2, 0},{ 4, 1, 1},{ -4, 1, 1},{ 1, 4, 0},{ -1, 4, 0},{ 5, 1, 1},
320 { -5, 1, 1},{ 1, 5, 0},{ -1, 5, 0},{ 3, 2, 0},{ -3, 2, 0},{ 2, 3, 0},
321 { -2, 3, 0},{ 1, 6, 0},{ -1, 6, 0},{ 6, 1, 1},{ -6, 1, 1},{ 2, 4, 0},
322 { -2, 4, 0},{ 1, 7, 0},{ -1, 7, 0},{ 4, 2, 1},{ -4, 2, 1},{ 7, 1, 2},
323 { -7, 1, 2},{ 3, 3, 0},{ -3, 3, 0},{ 1, 8, 0},{ -1, 8, 0},{ 2, 5, 0},
324 { -2, 5, 0},{ 8, 1, 2},{ -8, 1, 2},{ 1, 9, 0},{ -1, 9, 0},{ 3, 4, 0},
325 { -3, 4, 0},{ 2, 6, 0},{ -2, 6, 0},{ 5, 2, 1},{ -5, 2, 1},{ 1,10, 0},
326 { -1,10, 0},{ 9, 1, 2},{ -9, 1, 2},{ 4, 3, 1},{ -4, 3, 1}
0abc2e73
MN
327 },
328 //level_add
50879935 329 { 0,10, 6, 5, 4, 3, 3, 2, 2, 2, 2,-1,-1,-1,-1,-1,-1,
0abc2e73
MN
330 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
331 2, //golomb_order
332 3, //inc_limit
50879935 333 10 //max_run
0abc2e73
MN
334 },{
335 { //level / run
50879935
SG
336 { 1, 1, 0},{ -1, 1, 0},{ EOB },{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},
337 { -3, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 4, 1, 0},{ -4, 1, 0},{ 5, 1, 0},
338 { -5, 1, 0},{ 2, 2, 0},{ -2, 2, 0},{ 1, 3, 0},{ -1, 3, 0},{ 6, 1, 0},
339 { -6, 1, 0},{ 3, 2, 0},{ -3, 2, 0},{ 7, 1, 1},{ -7, 1, 1},{ 1, 4, 0},
340 { -1, 4, 0},{ 8, 1, 1},{ -8, 1, 1},{ 2, 3, 0},{ -2, 3, 0},{ 4, 2, 0},
341 { -4, 2, 0},{ 1, 5, 0},{ -1, 5, 0},{ 9, 1, 1},{ -9, 1, 1},{ 5, 2, 0},
342 { -5, 2, 0},{ 2, 4, 0},{ -2, 4, 0},{ 1, 6, 0},{ -1, 6, 0},{ 10, 1, 2},
343 {-10, 1, 2},{ 3, 3, 0},{ -3, 3, 0},{ 11, 1, 2},{-11, 1, 2},{ 1, 7, 0},
344 { -1, 7, 0},{ 6, 2, 0},{ -6, 2, 0},{ 3, 4, 0},{ -3, 4, 0},{ 2, 5, 0},
345 { -2, 5, 0},{ 12, 1, 2},{-12, 1, 2},{ 4, 3, 0},{ -4, 3, 0}
0abc2e73
MN
346 },
347 //level_add
50879935 348 { 0,13, 7, 5, 4, 3, 2, 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,
0abc2e73
MN
349 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
350 2, //golomb_order
351 6, //inc_limit
50879935 352 7 //max_run
0abc2e73
MN
353 },{
354 { //level / run
50879935
SG
355 { EOB },{ 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},
356 { -3, 1, 0},{ 4, 1, 0},{ -4, 1, 0},{ 5, 1, 0},{ -5, 1, 0},{ 1, 2, 0},
357 { -1, 2, 0},{ 6, 1, 0},{ -6, 1, 0},{ 7, 1, 0},{ -7, 1, 0},{ 8, 1, 0},
358 { -8, 1, 0},{ 2, 2, 0},{ -2, 2, 0},{ 9, 1, 0},{ -9, 1, 0},{ 1, 3, 0},
359 { -1, 3, 0},{ 10, 1, 1},{-10, 1, 1},{ 3, 2, 0},{ -3, 2, 0},{ 11, 1, 1},
360 {-11, 1, 1},{ 4, 2, 0},{ -4, 2, 0},{ 12, 1, 1},{-12, 1, 1},{ 1, 4, 0},
361 { -1, 4, 0},{ 2, 3, 0},{ -2, 3, 0},{ 13, 1, 1},{-13, 1, 1},{ 5, 2, 0},
362 { -5, 2, 0},{ 14, 1, 1},{-14, 1, 1},{ 6, 2, 0},{ -6, 2, 0},{ 1, 5, 0},
363 { -1, 5, 0},{ 15, 1, 1},{-15, 1, 1},{ 3, 3, 0},{ -3, 3, 0},{ 16, 1, 1},
364 {-16, 1, 1},{ 2, 4, 0},{ -2, 4, 0},{ 7, 2, 0},{ -7, 2, 0}
0abc2e73
MN
365 },
366 //level_add
50879935 367 { 0,17, 8, 4, 3, 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
0abc2e73
MN
368 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
369 2, //golomb_order
370 9, //inc_limit
50879935 371 5 //max_run
0abc2e73
MN
372 },{
373 { //level / run
50879935
SG
374 { EOB },{ 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},
375 { -3, 1, 0},{ 4, 1, 0},{ -4, 1, 0},{ 5, 1, 0},{ -5, 1, 0},{ 6, 1, 0},
376 { -6, 1, 0},{ 7, 1, 0},{ -7, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 8, 1, 0},
377 { -8, 1, 0},{ 9, 1, 0},{ -9, 1, 0},{ 10, 1, 0},{-10, 1, 0},{ 11, 1, 0},
378 {-11, 1, 0},{ 12, 1, 0},{-12, 1, 0},{ 2, 2, 0},{ -2, 2, 0},{ 13, 1, 0},
379 {-13, 1, 0},{ 1, 3, 0},{ -1, 3, 0},{ 14, 1, 0},{-14, 1, 0},{ 15, 1, 0},
380 {-15, 1, 0},{ 3, 2, 0},{ -3, 2, 0},{ 16, 1, 0},{-16, 1, 0},{ 17, 1, 0},
381 {-17, 1, 0},{ 18, 1, 0},{-18, 1, 0},{ 4, 2, 0},{ -4, 2, 0},{ 19, 1, 0},
382 {-19, 1, 0},{ 20, 1, 0},{-20, 1, 0},{ 2, 3, 0},{ -2, 3, 0},{ 1, 4, 0},
383 { -1, 4, 0},{ 5, 2, 0},{ -5, 2, 0},{ 21, 1, 0},{-21, 1, 0}
0abc2e73
MN
384 },
385 //level_add
50879935 386 { 0,22, 6, 3, 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
0abc2e73
MN
387 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
388 2, //golomb_order
389 INT_MAX, //inc_limit
50879935 390 4 //max_run
0abc2e73
MN
391 }
392};
393
394static const residual_vlc_t chroma_2dvlc[5] = {
395 {
396 { //level / run
50879935
SG
397 { 1, 1, 1},{ -1, 1, 1},{ 1, 2, 1},{ -1, 2, 1},{ 1, 3, 1},{ -1, 3, 1},
398 { 1, 4, 1},{ -1, 4, 1},{ 1, 5, 1},{ -1, 5, 1},{ 1, 6, 1},{ -1, 6, 1},
399 { 1, 7, 1},{ -1, 7, 1},{ 2, 1, 2},{ -2, 1, 2},{ 1, 8, 1},{ -1, 8, 1},
400 { 1, 9, 1},{ -1, 9, 1},{ 1,10, 1},{ -1,10, 1},{ 1,11, 1},{ -1,11, 1},
401 { 1,12, 1},{ -1,12, 1},{ 1,13, 1},{ -1,13, 1},{ 1,14, 1},{ -1,14, 1},
402 { 1,15, 1},{ -1,15, 1},{ 3, 1, 3},{ -3, 1, 3},{ 1,16, 1},{ -1,16, 1},
403 { 1,17, 1},{ -1,17, 1},{ 1,18, 1},{ -1,18, 1},{ 1,19, 1},{ -1,19, 1},
404 { 1,20, 1},{ -1,20, 1},{ 1,21, 1},{ -1,21, 1},{ 1,22, 1},{ -1,22, 1},
405 { 2, 2, 2},{ -2, 2, 2},{ 1,23, 1},{ -1,23, 1},{ 1,24, 1},{ -1,24, 1},
406 { 1,25, 1},{ -1,25, 1},{ 4, 1, 3},{ -4, 1, 3},{ EOB }
0abc2e73
MN
407 },
408 //level_add
50879935 409 { 0, 5, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
0abc2e73
MN
410 2, 2, 2, 2, 2, 2, 2, 2, 2,-1},
411 2, //golomb_order
412 0, //inc_limit
50879935 413 25 //max_run
0abc2e73
MN
414 },{
415 { //level / run
50879935
SG
416 { EOB },{ 1, 1, 0},{ -1, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 2, 1, 1},
417 { -2, 1, 1},{ 1, 3, 0},{ -1, 3, 0},{ 1, 4, 0},{ -1, 4, 0},{ 1, 5, 0},
418 { -1, 5, 0},{ 1, 6, 0},{ -1, 6, 0},{ 3, 1, 2},{ -3, 1, 2},{ 1, 7, 0},
419 { -1, 7, 0},{ 1, 8, 0},{ -1, 8, 0},{ 2, 2, 1},{ -2, 2, 1},{ 1, 9, 0},
420 { -1, 9, 0},{ 1,10, 0},{ -1,10, 0},{ 1,11, 0},{ -1,11, 0},{ 4, 1, 2},
421 { -4, 1, 2},{ 1,12, 0},{ -1,12, 0},{ 1,13, 0},{ -1,13, 0},{ 1,14, 0},
422 { -1,14, 0},{ 2, 3, 1},{ -2, 3, 1},{ 1,15, 0},{ -1,15, 0},{ 2, 4, 1},
423 { -2, 4, 1},{ 5, 1, 3},{ -5, 1, 3},{ 3, 2, 2},{ -3, 2, 2},{ 1,16, 0},
424 { -1,16, 0},{ 1,17, 0},{ -1,17, 0},{ 1,18, 0},{ -1,18, 0},{ 2, 5, 1},
425 { -2, 5, 1},{ 1,19, 0},{ -1,19, 0},{ 1,20, 0},{ -1,20, 0}
0abc2e73
MN
426 },
427 //level_add
50879935 428 { 0, 6, 4, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
0abc2e73
MN
429 2, 2, 2, 2,-1,-1,-1,-1,-1,-1},
430 0, //golomb_order
431 1, //inc_limit
50879935 432 20 //max_run
0abc2e73
MN
433 },{
434 { //level / run
50879935
SG
435 { 1, 1, 0},{ -1, 1, 0},{ EOB },{ 2, 1, 0},{ -2, 1, 0},{ 1, 2, 0},
436 { -1, 2, 0},{ 3, 1, 1},{ -3, 1, 1},{ 1, 3, 0},{ -1, 3, 0},{ 4, 1, 1},
437 { -4, 1, 1},{ 2, 2, 0},{ -2, 2, 0},{ 1, 4, 0},{ -1, 4, 0},{ 5, 1, 2},
438 { -5, 1, 2},{ 1, 5, 0},{ -1, 5, 0},{ 3, 2, 1},{ -3, 2, 1},{ 2, 3, 0},
439 { -2, 3, 0},{ 1, 6, 0},{ -1, 6, 0},{ 6, 1, 2},{ -6, 1, 2},{ 1, 7, 0},
440 { -1, 7, 0},{ 2, 4, 0},{ -2, 4, 0},{ 7, 1, 2},{ -7, 1, 2},{ 1, 8, 0},
441 { -1, 8, 0},{ 4, 2, 1},{ -4, 2, 1},{ 1, 9, 0},{ -1, 9, 0},{ 3, 3, 1},
442 { -3, 3, 1},{ 2, 5, 0},{ -2, 5, 0},{ 2, 6, 0},{ -2, 6, 0},{ 8, 1, 2},
443 { -8, 1, 2},{ 1,10, 0},{ -1,10, 0},{ 1,11, 0},{ -1,11, 0},{ 9, 1, 2},
444 { -9, 1, 2},{ 5, 2, 2},{ -5, 2, 2},{ 3, 4, 1},{ -3, 4, 1},
0abc2e73
MN
445 },
446 //level_add
50879935 447 { 0,10, 6, 4, 4, 3, 3, 2, 2, 2, 2, 2,-1,-1,-1,-1,-1,
0abc2e73
MN
448 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
449 1, //golomb_order
450 2, //inc_limit
50879935 451 11 //max_run
0abc2e73
MN
452 },{
453 { //level / run
50879935
SG
454 { EOB },{ 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},
455 { -3, 1, 0},{ 4, 1, 0},{ -4, 1, 0},{ 1, 2, 0},{ -1, 2, 0},{ 5, 1, 1},
456 { -5, 1, 1},{ 2, 2, 0},{ -2, 2, 0},{ 6, 1, 1},{ -6, 1, 1},{ 1, 3, 0},
457 { -1, 3, 0},{ 7, 1, 1},{ -7, 1, 1},{ 3, 2, 0},{ -3, 2, 0},{ 8, 1, 1},
458 { -8, 1, 1},{ 1, 4, 0},{ -1, 4, 0},{ 2, 3, 0},{ -2, 3, 0},{ 9, 1, 1},
459 { -9, 1, 1},{ 4, 2, 0},{ -4, 2, 0},{ 1, 5, 0},{ -1, 5, 0},{ 10, 1, 1},
460 {-10, 1, 1},{ 3, 3, 0},{ -3, 3, 0},{ 5, 2, 1},{ -5, 2, 1},{ 2, 4, 0},
461 { -2, 4, 0},{ 11, 1, 1},{-11, 1, 1},{ 1, 6, 0},{ -1, 6, 0},{ 12, 1, 1},
462 {-12, 1, 1},{ 1, 7, 0},{ -1, 7, 0},{ 6, 2, 1},{ -6, 2, 1},{ 13, 1, 1},
463 {-13, 1, 1},{ 2, 5, 0},{ -2, 5, 0},{ 1, 8, 0},{ -1, 8, 0},
0abc2e73
MN
464 },
465 //level_add
50879935 466 { 0,14, 7, 4, 3, 3, 2, 2, 2,-1,-1,-1,-1,-1,-1,-1,-1,
0abc2e73
MN
467 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
468 1, //golomb_order
469 4, //inc_limit
50879935 470 8 //max_run
0abc2e73
MN
471 },{
472 { //level / run
50879935
SG
473 { EOB },{ 1, 1, 0},{ -1, 1, 0},{ 2, 1, 0},{ -2, 1, 0},{ 3, 1, 0},
474 { -3, 1, 0},{ 4, 1, 0},{ -4, 1, 0},{ 5, 1, 0},{ -5, 1, 0},{ 6, 1, 0},
475 { -6, 1, 0},{ 7, 1, 0},{ -7, 1, 0},{ 8, 1, 0},{ -8, 1, 0},{ 1, 2, 0},
476 { -1, 2, 0},{ 9, 1, 0},{ -9, 1, 0},{ 10, 1, 0},{-10, 1, 0},{ 11, 1, 0},
477 {-11, 1, 0},{ 2, 2, 0},{ -2, 2, 0},{ 12, 1, 0},{-12, 1, 0},{ 13, 1, 0},
478 {-13, 1, 0},{ 3, 2, 0},{ -3, 2, 0},{ 14, 1, 0},{-14, 1, 0},{ 1, 3, 0},
479 { -1, 3, 0},{ 15, 1, 0},{-15, 1, 0},{ 4, 2, 0},{ -4, 2, 0},{ 16, 1, 0},
480 {-16, 1, 0},{ 17, 1, 0},{-17, 1, 0},{ 5, 2, 0},{ -5, 2, 0},{ 1, 4, 0},
481 { -1, 4, 0},{ 2, 3, 0},{ -2, 3, 0},{ 18, 1, 0},{-18, 1, 0},{ 6, 2, 0},
482 { -6, 2, 0},{ 19, 1, 0},{-19, 1, 0},{ 1, 5, 0},{ -1, 5, 0},
0abc2e73
MN
483 },
484 //level_add
50879935 485 { 0,20, 7, 3, 2, 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
0abc2e73
MN
486 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
487 0, //golomb_order
488 INT_MAX, //inc_limit
50879935 489 5, //max_run
0abc2e73
MN
490 }
491};
492
50879935
SG
493#undef EOB
494
0abc2e73
MN
495static const uint8_t alpha_tab[64] = {
496 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3,
497 4, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 18, 20,
498 22, 24, 26, 28, 30, 33, 33, 35, 35, 36, 37, 37, 39, 39, 42, 44,
499 46, 48, 50, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64
500};
501
502static const uint8_t beta_tab[64] = {
503 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
504 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6,
505 6, 7, 7, 7, 8, 8, 8, 9, 9, 10, 10, 11, 11, 12, 13, 14,
506 15, 16, 17, 18, 19, 20, 21, 22, 23, 23, 24, 24, 25, 25, 26, 27
507};
508
509static const uint8_t tc_tab[64] = {
510 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
511 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
512 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
513 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9
514};
515
516static const int_fast8_t left_modifier_l[8] = { 0,-1, 6,-1,-1, 7, 6, 7};
517static const int_fast8_t top_modifier_l[8] = {-1, 1, 5,-1,-1, 5, 7, 7};
518static const int_fast8_t left_modifier_c[7] = { 5,-1, 2,-1, 6, 5, 6};
519static const int_fast8_t top_modifier_c[7] = { 4, 1,-1,-1, 4, 6, 6};
699b3f99
MR
520
521#endif