3 Huffman Tables for h.263 encoding.
5 Copyright (c) 2003 Matthias Kramm <kramm@quiss.org>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
21 #include "h263tables.h"
23 struct huffcode mcbpc_intra[] = {
24 {"1",1, 0}, /*cbpc-00 mb type 3*/
25 {"001",3, 1}, /*cbpc-01 mb type 3*/
26 {"010",3, 2}, /*cbpc-10 mb type 3*/
27 {"011",3, 3}, /*cbpc-11 mb type 3*/
28 {"0001",4, 4}, /*cbpc-00 mb type 4*/
29 {"000001",6, 5}, /*cbpc-01 mb type 4*/
30 {"000010",6, 6}, /*cbpc-10 mb type 4*/
31 {"000011",6, 7}, /*cbpc-11 mb type 4*/
32 {"000000001",9, 8}, /* stuffing */
36 struct mcbpc_intra_params
37 mcbpc_intra_params[] =
49 struct huffcode mcbpc_inter[] = {
70 {"000000001", 9, 20}, /*stuffing*/
73 {"00000000010", 11, 21},
74 {"0000000001100", 13, 22},
75 {"0000000001110", 13, 23},
76 {"0000000001111", 13, 24},
81 struct mcbpc_inter_params
82 mcbpc_inter_params[] =
83 { {0, 0, 0}, {1, 0, 1}, {2, 0, 2}, {3, 0, 3},
84 {4, 1, 0}, {5, 1, 1}, {6, 1, 2}, {7, 1, 3},
85 {8, 2, 0}, {9, 2, 1}, {10, 2, 2}, {11, 2, 3},
86 {12, 3, 0}, {13, 3, 1}, {14, 3, 2}, {15, 3, 3},
87 {16, 4, 0}, {17, 4, 1}, {18, 4, 2}, {19, 4, 3},
88 {20, -1, -1}, //stuffing
89 //{21, 5, 0}, {22, 5, 1}, {23, 5, 2}, {24, 5, 3}, //h.263+ only
92 struct huffcode cbpy[] = {
112 struct huffcode mvd[] =
114 {"0000000000101", 13, 0},
115 {"0000000000111", 13, 1},
116 {"000000000101", 12, 2},
117 {"000000000111", 12, 3},
118 {"000000001001", 12, 4},
119 {"000000001011", 12, 5},
120 {"000000001101", 12, 6},
121 {"000000001111", 12, 7},
122 {"00000001001", 11, 8},
123 {"00000001011", 11, 9},
124 {"00000001101", 11, 10},
125 {"00000001111", 11, 11},
126 {"00000010001", 11, 12},
127 {"00000010011", 11, 13},
128 {"00000010101", 11, 14},
129 {"00000010111", 11, 15},
130 {"00000011001", 11, 16},
131 {"00000011011", 11, 17},
132 {"00000011101", 11, 18},
133 {"00000011111", 11, 19},
134 {"00000100001", 11, 20},
135 {"00000100011", 11, 21},
136 {"0000010011", 10, 22},
137 {"0000010101", 10, 23},
138 {"0000010111", 10, 24},
154 {"0000010110", 10, 40},
155 {"0000010100", 10, 41},
156 {"0000010010", 10, 42},
157 {"00000100010", 11, 43},
158 {"00000100000", 11, 44},
159 {"00000011110", 11, 45},
160 {"00000011100", 11, 46},
161 {"00000011010", 11, 47},
162 {"00000011000", 11, 48},
163 {"00000010110", 11, 49},
164 {"00000010100", 11, 50},
165 {"00000010010", 11, 51},
166 {"00000010000", 11, 52},
167 {"00000001110", 11, 53},
168 {"00000001100", 11, 54},
169 {"00000001010", 11, 55},
170 {"00000001000", 11, 56},
171 {"000000001110", 12, 57},
172 {"000000001100", 12, 58},
173 {"000000001010", 12, 59},
174 {"000000001000", 12, 60},
175 {"000000000110", 12, 61},
176 {"000000000100", 12, 62},
177 {"0000000000110", 13, 63},
180 struct huffcode rle[] =
189 {"0000100001", 10, 7},
190 {"0000100000", 10, 8},
191 {"00000000111", 11, 9},
192 {"00000000110", 11, 10},
193 {"00000100000", 11, 11},
197 {"0000001111", 10, 15},
198 {"00000100001", 11, 16},
199 {"000001010000", 12, 17},
202 {"0000001110", 10, 20},
203 {"000001010001", 12, 21},
205 {"000100011", 9, 23},
206 {"0000001101", 10, 24},
208 {"000100010", 9, 26},
209 {"000001010010", 12, 27},
211 {"0000001100", 10, 29},
212 {"000001010011", 12, 30},
214 {"0000001011", 10, 32},
215 {"000001010100", 12, 33},
217 {"0000001010", 10, 35},
219 {"0000001001", 10, 37},
221 {"0000001000", 10, 39},
223 {"000001010101", 12, 41},
228 {"000100001", 9, 46},
229 {"000100000", 9, 47},
230 {"000011111", 9, 48},
231 {"000011110", 9, 49},
232 {"000011101", 9, 50},
233 {"000011100", 9, 51},
234 {"000011011", 9, 52},
235 {"000011010", 9, 53},
236 {"00000100010", 11, 54},
237 {"00000100011", 11, 55},
238 {"000001010110", 12, 56},
239 {"000001010111", 12, 57},
241 {"000011001", 9, 59},
242 {"00000000101", 11, 60},
244 {"00000000100", 11, 62},
260 {"000011000", 9, 78},
261 {"000010111", 9, 79},
262 {"000010110", 9, 80},
263 {"000010101", 9, 81},
264 {"000010100", 9, 82},
265 {"000010011", 9, 83},
266 {"000010010", 9, 84},
267 {"000010001", 9, 85},
268 {"0000000111", 10, 86},
269 {"0000000110", 10, 87},
270 {"0000000101", 10, 88},
271 {"0000000100", 10, 89},
272 {"00000100100", 11, 90},
273 {"00000100101", 11, 91},
274 {"00000100110", 11, 92},
275 {"00000100111", 11, 93},
276 {"000001011000", 12, 94},
277 {"000001011001", 12, 95},
278 {"000001011010", 12, 96},
279 {"000001011011", 12, 97},
280 {"000001011100", 12, 98},
281 {"000001011101", 12, 99},
282 {"000001011110", 12, 100},
283 {"000001011111", 12, 101},
284 {"0000011", 7, 102}, /*ESCAPE*/
290 {{0,0,0,1}, {1,0,0,2}, {2,0,0,3}, {3,0,0,4}, {4,0,0,5}, {5,0,0,6}, {6,0,0,7},
291 {7,0,0,8}, {8,0,0,9}, {9,0,0,10}, {10,0,0,11}, {11,0,0,12}, {12,0,1,1}, {13,0,1,2},
292 {14,0,1,3}, {15,0,1,4}, {16,0,1,5}, {17,0,1,6}, {18,0,2,1}, {19,0,2,2}, {20,0,2,3}, {21,0,2,4},
293 {22,0,3,1}, {23,0,3,2}, {24,0,3,3}, {25,0,4,1}, {26,0,4,2}, {27,0,4,3}, {28,0,5,1},
294 {29,0,5,2}, {30,0,5,3}, {31,0,6,1}, {32,0,6,2}, {33,0,6,3},
295 {34,0,7,1}, {35,0,7,2}, {36,0,8,1}, {37,0,8,2}, {38,0,9,1}, {39,0,9,2}, {40,0,10,1},
296 {41,0,10,2}, {42,0,11,1}, {43,0,12,1}, {44,0,13,1}, {45,0,14,1}, {46,0,15,1},
297 {47,0,16,1}, {48,0,17,1}, {49,0,18,1}, {50,0,19,1}, {51,0,20,1}, {52,0,21,1},
298 {53,0,22,1}, {54,0,23,1}, {55,0,24,1}, {56,0,25,1}, {57,0,26,1},
299 {58,1,0,1}, {59,1,0,2}, {60,1,0,3}, {61,1,1,1}, {62,1,1,2}, {63,1,2,1}, {64,1,3,1}, {65, 1,4,1},
300 {66,1,5,1}, {67,1,6,1}, {68,1,7,1}, {69,1,8,1}, {70,1,9,1}, {71,1,10,1},
301 {72,1,11,1}, {73,1,12,1}, {74,1,13,1}, {75,1,14,1}, {76,1,15,1}, {77,1,16,1},
302 {78,1,17,1}, {79,1,18,1}, {80,1,19,1}, {81,1,20,1}, {82,1,21,1}, {83,1,22,1},
303 {84,1,23,1}, {85,1,24,1}, {86,1,25,1}, {87,1,26,1}, {88,1,27,1}, {89,1,28,1},
304 {90,1,29,1}, {91,1,30,1}, {92,1,31,1}, {93,1,32,1}, {94,1,33,1}, {95,1,34,1},
305 {96,1,35,1}, {97,1,36,1}, {98,1,37,1}, {99,1,38,1}, {100,1,39,1}, {101,1,40,1},