fixed moments calculcation
[swftools.git] / lib / h.263 / h263tables.c
blob384ffb10d3c9c07983af1da3f54cbe8e867bea12
1 /* h263tables.c
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 */
33 {0,0,0},
36 struct mcbpc_intra_params
37 mcbpc_intra_params[] =
38 {{0, 3, 0}, //00
39 {1, 3, 1}, //01
40 {2, 3, 2}, //10
41 {3, 3, 3}, //11
42 {4, 4, 0}, //00
43 {5, 4, 1}, //01
44 {6, 4, 2}, //10
45 {7, 4, 3}, //11
46 {8 -1, -1}
49 struct huffcode mcbpc_inter[] = {
50 {"1", 1, 0},
51 {"0011", 4, 1},
52 {"0010", 4 ,2},
53 {"000101", 6, 3},
54 {"011", 3, 4},
55 {"0000111", 7, 5},
56 {"0000110", 7, 6},
57 {"000000101", 9, 7},
58 {"010", 3, 8},
59 {"0000101", 7, 9},
60 {"0000100", 7, 10},
61 {"00000101", 8, 11},
62 {"00011", 5, 12},
63 {"00000100", 8, 13},
64 {"00000011", 8, 14},
65 {"0000011", 7, 15},
66 {"000100", 6, 16},
67 {"000000100", 9, 17},
68 {"000000011", 9, 18},
69 {"000000010", 9, 19},
70 {"000000001", 9, 20}, /*stuffing*/
72 /* h.263+ only
73 {"00000000010", 11, 21},
74 {"0000000001100", 13, 22},
75 {"0000000001110", 13, 23},
76 {"0000000001111", 13, 24},
78 {0,0,0}
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[] = {
93 {"0011", 4, 0},
94 {"00101", 5, 1},
95 {"00100", 5, 2},
96 {"1001", 4, 3},
97 {"00011", 5, 4},
98 {"0111", 4, 5},
99 {"000010", 6, 6},
100 {"1011", 4, 7},
101 {"00010", 5, 8},
102 {"000011", 6, 9},
103 {"0101", 4, 10},
104 {"1010", 4, 11},
105 {"0100", 4, 12},
106 {"1000", 4, 13},
107 {"0110", 4, 14},
108 {"11", 2, 15},
109 {0,0,0}
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},
139 {"00000111", 8, 25},
140 {"00001001", 8, 26},
141 {"00001011", 8, 27},
142 {"0000111", 7, 28},
143 {"00011", 5, 29},
144 {"0011", 4, 30},
145 {"011", 3, 31},
146 {"1", 1, 32},
147 {"010", 3, 33},
148 {"0010", 4, 34},
149 {"00010", 5, 35},
150 {"0000110", 7, 36},
151 {"00001010", 8, 37},
152 {"00001000", 8, 38},
153 {"00000110", 8, 39},
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},
178 {0,0,0}};
180 struct huffcode rle[] =
182 {"10", 2, 0},
183 {"1111", 4, 1},
184 {"010101", 6, 2},
185 {"0010111", 7, 3},
186 {"00011111", 8, 4},
187 {"000100101", 9, 5},
188 {"000100100", 9, 6},
189 {"0000100001", 10, 7},
190 {"0000100000", 10, 8},
191 {"00000000111", 11, 9},
192 {"00000000110", 11, 10},
193 {"00000100000", 11, 11},
194 {"110", 3, 12},
195 {"010100", 6, 13},
196 {"00011110", 8, 14},
197 {"0000001111", 10, 15},
198 {"00000100001", 11, 16},
199 {"000001010000", 12, 17},
200 {"1110", 4, 18},
201 {"00011101", 8, 19},
202 {"0000001110", 10, 20},
203 {"000001010001", 12, 21},
204 {"01101", 5, 22},
205 {"000100011", 9, 23},
206 {"0000001101", 10, 24},
207 {"01100", 5, 25},
208 {"000100010", 9, 26},
209 {"000001010010", 12, 27},
210 {"01011", 5, 28},
211 {"0000001100", 10, 29},
212 {"000001010011", 12, 30},
213 {"010011", 6, 31},
214 {"0000001011", 10, 32},
215 {"000001010100", 12, 33},
216 {"010010", 6, 34},
217 {"0000001010", 10, 35},
218 {"010001", 6, 36},
219 {"0000001001", 10, 37},
220 {"010000", 6, 38},
221 {"0000001000", 10, 39},
222 {"0010110", 7, 40},
223 {"000001010101", 12, 41},
224 {"0010101", 7, 42},
225 {"0010100", 7, 43},
226 {"00011100", 8, 44},
227 {"00011011", 8, 45},
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},
240 {"0111", 4, 58},
241 {"000011001", 9, 59},
242 {"00000000101", 11, 60},
243 {"001111", 6, 61},
244 {"00000000100", 11, 62},
245 {"001110", 6, 63},
246 {"001101", 6, 64}, /* ?? */
247 {"001100", 6, 65},
248 {"0010011", 7, 66},
249 {"0010010", 7, 67},
250 {"0010001", 7, 68},
251 {"0010000", 7, 69},
252 {"00011010", 8, 70},
253 {"00011001", 8, 71},
254 {"00011000", 8, 72},
255 {"00010111", 8, 73},
256 {"00010110", 8, 74},
257 {"00010101", 8, 75},
258 {"00010100", 8, 76},
259 {"00010011", 8, 77},
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*/
285 {0,0,0}
288 struct rle_params
289 rle_params[] =
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},
306 {102,-1, -1, -1}