FFmpeg
mpeg12data.c
Go to the documentation of this file.
1 /*
2  * MPEG-1/2 tables
3  * copyright (c) 2000,2001 Fabrice Bellard
4  * copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 /**
24  * @file
25  * MPEG-1/2 tables.
26  */
27 
28 #include "mpeg12data.h"
29 #include "mpeg12vlc.h"
30 
31 const uint16_t ff_mpeg1_default_intra_matrix[256] = {
32  8, 16, 19, 22, 26, 27, 29, 34,
33  16, 16, 22, 24, 27, 29, 34, 37,
34  19, 22, 26, 27, 29, 34, 34, 38,
35  22, 22, 26, 27, 29, 34, 37, 40,
36  22, 26, 27, 29, 32, 35, 40, 48,
37  26, 27, 29, 32, 35, 40, 48, 58,
38  26, 27, 29, 34, 38, 46, 56, 69,
39  27, 29, 35, 38, 46, 56, 69, 83
40 };
41 
42 const uint16_t ff_mpeg1_default_non_intra_matrix[64] = {
43  16, 16, 16, 16, 16, 16, 16, 16,
44  16, 16, 16, 16, 16, 16, 16, 16,
45  16, 16, 16, 16, 16, 16, 16, 16,
46  16, 16, 16, 16, 16, 16, 16, 16,
47  16, 16, 16, 16, 16, 16, 16, 16,
48  16, 16, 16, 16, 16, 16, 16, 16,
49  16, 16, 16, 16, 16, 16, 16, 16,
50  16, 16, 16, 16, 16, 16, 16, 16,
51 };
52 
53 const uint16_t ff_mpeg12_vlc_dc_lum_code[12] = {
54  0x4, 0x0, 0x1, 0x5, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe, 0x1ff,
55 };
56 const unsigned char ff_mpeg12_vlc_dc_lum_bits[12] = {
57  3, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 9,
58 };
59 
60 const uint16_t ff_mpeg12_vlc_dc_chroma_code[12] = {
61  0x0, 0x1, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe, 0x3fe, 0x3ff,
62 };
63 const unsigned char ff_mpeg12_vlc_dc_chroma_bits[12] = {
64  2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10,
65 };
66 
67 const uint16_t ff_mpeg1_vlc_table[MPEG12_RL_NB_ELEMS + 2][2] = {
68  { 0x3, 2 }, { 0x4, 4 }, { 0x5, 5 }, { 0x6, 7 },
69  { 0x26, 8 }, { 0x21, 8 }, { 0xa, 10 }, { 0x1d, 12 },
70  { 0x18, 12 }, { 0x13, 12 }, { 0x10, 12 }, { 0x1a, 13 },
71  { 0x19, 13 }, { 0x18, 13 }, { 0x17, 13 }, { 0x1f, 14 },
72  { 0x1e, 14 }, { 0x1d, 14 }, { 0x1c, 14 }, { 0x1b, 14 },
73  { 0x1a, 14 }, { 0x19, 14 }, { 0x18, 14 }, { 0x17, 14 },
74  { 0x16, 14 }, { 0x15, 14 }, { 0x14, 14 }, { 0x13, 14 },
75  { 0x12, 14 }, { 0x11, 14 }, { 0x10, 14 }, { 0x18, 15 },
76  { 0x17, 15 }, { 0x16, 15 }, { 0x15, 15 }, { 0x14, 15 },
77  { 0x13, 15 }, { 0x12, 15 }, { 0x11, 15 }, { 0x10, 15 },
78  { 0x3, 3 }, { 0x6, 6 }, { 0x25, 8 }, { 0xc, 10 },
79  { 0x1b, 12 }, { 0x16, 13 }, { 0x15, 13 }, { 0x1f, 15 },
80  { 0x1e, 15 }, { 0x1d, 15 }, { 0x1c, 15 }, { 0x1b, 15 },
81  { 0x1a, 15 }, { 0x19, 15 }, { 0x13, 16 }, { 0x12, 16 },
82  { 0x11, 16 }, { 0x10, 16 }, { 0x5, 4 }, { 0x4, 7 },
83  { 0xb, 10 }, { 0x14, 12 }, { 0x14, 13 }, { 0x7, 5 },
84  { 0x24, 8 }, { 0x1c, 12 }, { 0x13, 13 }, { 0x6, 5 },
85  { 0xf, 10 }, { 0x12, 12 }, { 0x7, 6 }, { 0x9, 10 },
86  { 0x12, 13 }, { 0x5, 6 }, { 0x1e, 12 }, { 0x14, 16 },
87  { 0x4, 6 }, { 0x15, 12 }, { 0x7, 7 }, { 0x11, 12 },
88  { 0x5, 7 }, { 0x11, 13 }, { 0x27, 8 }, { 0x10, 13 },
89  { 0x23, 8 }, { 0x1a, 16 }, { 0x22, 8 }, { 0x19, 16 },
90  { 0x20, 8 }, { 0x18, 16 }, { 0xe, 10 }, { 0x17, 16 },
91  { 0xd, 10 }, { 0x16, 16 }, { 0x8, 10 }, { 0x15, 16 },
92  { 0x1f, 12 }, { 0x1a, 12 }, { 0x19, 12 }, { 0x17, 12 },
93  { 0x16, 12 }, { 0x1f, 13 }, { 0x1e, 13 }, { 0x1d, 13 },
94  { 0x1c, 13 }, { 0x1b, 13 }, { 0x1f, 16 }, { 0x1e, 16 },
95  { 0x1d, 16 }, { 0x1c, 16 }, { 0x1b, 16 },
96  { 0x1, 6 }, /* escape */
97  { 0x2, 2 }, /* EOB */
98 };
99 
100 const uint16_t ff_mpeg2_vlc_table[MPEG12_RL_NB_ELEMS + 2][2] = {
101  {0x02, 2}, {0x06, 3}, {0x07, 4}, {0x1c, 5},
102  {0x1d, 5}, {0x05, 6}, {0x04, 6}, {0x7b, 7},
103  {0x7c, 7}, {0x23, 8}, {0x22, 8}, {0xfa, 8},
104  {0xfb, 8}, {0xfe, 8}, {0xff, 8}, {0x1f,14},
105  {0x1e,14}, {0x1d,14}, {0x1c,14}, {0x1b,14},
106  {0x1a,14}, {0x19,14}, {0x18,14}, {0x17,14},
107  {0x16,14}, {0x15,14}, {0x14,14}, {0x13,14},
108  {0x12,14}, {0x11,14}, {0x10,14}, {0x18,15},
109  {0x17,15}, {0x16,15}, {0x15,15}, {0x14,15},
110  {0x13,15}, {0x12,15}, {0x11,15}, {0x10,15},
111  {0x02, 3}, {0x06, 5}, {0x79, 7}, {0x27, 8},
112  {0x20, 8}, {0x16,13}, {0x15,13}, {0x1f,15},
113  {0x1e,15}, {0x1d,15}, {0x1c,15}, {0x1b,15},
114  {0x1a,15}, {0x19,15}, {0x13,16}, {0x12,16},
115  {0x11,16}, {0x10,16}, {0x05, 5}, {0x07, 7},
116  {0xfc, 8}, {0x0c,10}, {0x14,13}, {0x07, 5},
117  {0x26, 8}, {0x1c,12}, {0x13,13}, {0x06, 6},
118  {0xfd, 8}, {0x12,12}, {0x07, 6}, {0x04, 9},
119  {0x12,13}, {0x06, 7}, {0x1e,12}, {0x14,16},
120  {0x04, 7}, {0x15,12}, {0x05, 7}, {0x11,12},
121  {0x78, 7}, {0x11,13}, {0x7a, 7}, {0x10,13},
122  {0x21, 8}, {0x1a,16}, {0x25, 8}, {0x19,16},
123  {0x24, 8}, {0x18,16}, {0x05, 9}, {0x17,16},
124  {0x07, 9}, {0x16,16}, {0x0d,10}, {0x15,16},
125  {0x1f,12}, {0x1a,12}, {0x19,12}, {0x17,12},
126  {0x16,12}, {0x1f,13}, {0x1e,13}, {0x1d,13},
127  {0x1c,13}, {0x1b,13}, {0x1f,16}, {0x1e,16},
128  {0x1d,16}, {0x1c,16}, {0x1b,16},
129  {0x01,6}, /* escape */
130  {0x06,4}, /* EOB */
131 };
132 
134  1, 2, 3, 4, 5, 6, 7, 8,
135  9, 10, 11, 12, 13, 14, 15, 16,
136  17, 18, 19, 20, 21, 22, 23, 24,
137  25, 26, 27, 28, 29, 30, 31, 32,
138  33, 34, 35, 36, 37, 38, 39, 40,
139  1, 2, 3, 4, 5, 6, 7, 8,
140  9, 10, 11, 12, 13, 14, 15, 16,
141  17, 18, 1, 2, 3, 4, 5, 1,
142  2, 3, 4, 1, 2, 3, 1, 2,
143  3, 1, 2, 3, 1, 2, 1, 2,
144  1, 2, 1, 2, 1, 2, 1, 2,
145  1, 2, 1, 2, 1, 2, 1, 2,
146  1, 1, 1, 1, 1, 1, 1, 1,
147  1, 1, 1, 1, 1, 1, 1,
148 };
149 
151  0, 0, 0, 0, 0, 0, 0, 0,
152  0, 0, 0, 0, 0, 0, 0, 0,
153  0, 0, 0, 0, 0, 0, 0, 0,
154  0, 0, 0, 0, 0, 0, 0, 0,
155  0, 0, 0, 0, 0, 0, 0, 0,
156  1, 1, 1, 1, 1, 1, 1, 1,
157  1, 1, 1, 1, 1, 1, 1, 1,
158  1, 1, 2, 2, 2, 2, 2, 3,
159  3, 3, 3, 4, 4, 4, 5, 5,
160  5, 6, 6, 6, 7, 7, 8, 8,
161  9, 9, 10, 10, 11, 11, 12, 12,
162  13, 13, 14, 14, 15, 15, 16, 16,
163  17, 18, 19, 20, 21, 22, 23, 24,
164  25, 26, 27, 28, 29, 30, 31,
165 };
166 
167 const uint8_t ff_mpeg12_mbAddrIncrTable[36][2] = {
168  {0x1, 1},
169  {0x3, 3},
170  {0x2, 3},
171  {0x3, 4},
172  {0x2, 4},
173  {0x3, 5},
174  {0x2, 5},
175  {0x7, 7},
176  {0x6, 7},
177  {0xb, 8},
178  {0xa, 8},
179  {0x9, 8},
180  {0x8, 8},
181  {0x7, 8},
182  {0x6, 8},
183  {0x17, 10},
184  {0x16, 10},
185  {0x15, 10},
186  {0x14, 10},
187  {0x13, 10},
188  {0x12, 10},
189  {0x23, 11},
190  {0x22, 11},
191  {0x21, 11},
192  {0x20, 11},
193  {0x1f, 11},
194  {0x1e, 11},
195  {0x1d, 11},
196  {0x1c, 11},
197  {0x1b, 11},
198  {0x1a, 11},
199  {0x19, 11},
200  {0x18, 11},
201  {0x8, 11}, /* escape */
202  {0xf, 11}, /* stuffing */
203  {0x0, 8}, /* end (and 15 more 0 bits should follow) */
204 };
205 
206 const uint8_t ff_mpeg12_mbPatTable[64][2] = {
207  {0x1, 9},
208  {0xb, 5},
209  {0x9, 5},
210  {0xd, 6},
211  {0xd, 4},
212  {0x17, 7},
213  {0x13, 7},
214  {0x1f, 8},
215  {0xc, 4},
216  {0x16, 7},
217  {0x12, 7},
218  {0x1e, 8},
219  {0x13, 5},
220  {0x1b, 8},
221  {0x17, 8},
222  {0x13, 8},
223  {0xb, 4},
224  {0x15, 7},
225  {0x11, 7},
226  {0x1d, 8},
227  {0x11, 5},
228  {0x19, 8},
229  {0x15, 8},
230  {0x11, 8},
231  {0xf, 6},
232  {0xf, 8},
233  {0xd, 8},
234  {0x3, 9},
235  {0xf, 5},
236  {0xb, 8},
237  {0x7, 8},
238  {0x7, 9},
239  {0xa, 4},
240  {0x14, 7},
241  {0x10, 7},
242  {0x1c, 8},
243  {0xe, 6},
244  {0xe, 8},
245  {0xc, 8},
246  {0x2, 9},
247  {0x10, 5},
248  {0x18, 8},
249  {0x14, 8},
250  {0x10, 8},
251  {0xe, 5},
252  {0xa, 8},
253  {0x6, 8},
254  {0x6, 9},
255  {0x12, 5},
256  {0x1a, 8},
257  {0x16, 8},
258  {0x12, 8},
259  {0xd, 5},
260  {0x9, 8},
261  {0x5, 8},
262  {0x5, 9},
263  {0xc, 5},
264  {0x8, 8},
265  {0x4, 8},
266  {0x4, 9},
267  {0x7, 3},
268  {0xa, 5},
269  {0x8, 5},
270  {0xc, 6}
271 };
272 
273 const uint8_t ff_mpeg12_mbMotionVectorTable[17][2] = {
274 { 0x1, 1 },
275 { 0x1, 2 },
276 { 0x1, 3 },
277 { 0x1, 4 },
278 { 0x3, 6 },
279 { 0x5, 7 },
280 { 0x4, 7 },
281 { 0x3, 7 },
282 { 0xb, 9 },
283 { 0xa, 9 },
284 { 0x9, 9 },
285 { 0x11, 10 },
286 { 0x10, 10 },
287 { 0xf, 10 },
288 { 0xe, 10 },
289 { 0xd, 10 },
290 { 0xc, 10 },
291 };
292 
294  { 1, 1},
295  { 2, 1},
296  { 3, 1},
297  { 4, 1},
298  { 5, 1},
299  { 6, 1},
300  { 8, 1},
301  { 9, 1},
302  { 10, 1},
303  { 12, 1},
304  { 15, 1},
305  { 16, 1},
306  { 18, 1},
307  { 20, 1},
308  { 24, 1},
309  { 25, 1},
310  { 30, 1},
311  { 32, 1},
312  { 36, 1},
313  { 40, 1},
314  { 45, 1},
315  { 48, 1},
316  { 50, 1},
317  { 60, 1},
318  { 72, 1},
319  { 75, 1},
320  { 80, 1},
321  { 90, 1},
322  { 96, 1},
323  { 100, 1},
324  { 120, 1},
325  { 150, 1},
326  { 180, 1},
327  { 200, 1},
328  { 240, 1},
329  { 750, 1001},
330  { 800, 1001},
331  { 960, 1001},
332  { 1000, 1001},
333  { 1200, 1001},
334  { 1250, 1001},
335  { 1500, 1001},
336  { 1600, 1001},
337  { 1875, 1001},
338  { 2000, 1001},
339  { 2400, 1001},
340  { 2500, 1001},
341  { 3000, 1001},
342  { 3750, 1001},
343  { 4000, 1001},
344  { 4800, 1001},
345  { 5000, 1001},
346  { 6000, 1001},
347  { 7500, 1001},
348  { 8000, 1001},
349  { 10000, 1001},
350  { 12000, 1001},
351  { 15000, 1001},
352  { 20000, 1001},
353  { 24000, 1001},
354  { 30000, 1001},
355  { 60000, 1001},
356  { 0, 0},
357 };
358 
359 const float ff_mpeg1_aspect[16]={
360  0.0000,
361  1.0000,
362  0.6735,
363  0.7031,
364 
365  0.7615,
366  0.8055,
367  0.8437,
368  0.8935,
369 
370  0.9157,
371  0.9815,
372  1.0255,
373  1.0695,
374 
375  1.0950,
376  1.1575,
377  1.2015,
378 };
379 
381  {0,1},
382  {1,1},
383  {4,3},
384  {16,9},
385  {221,100},
386  {0,1},
387  {0,1},
388  {0,1},
389  {0,1},
390  {0,1},
391  {0,1},
392  {0,1},
393  {0,1},
394  {0,1},
395  {0,1},
396  {0,1},
397 };
ff_mpeg2_aspect
const AVRational ff_mpeg2_aspect[16]
Definition: mpeg12data.c:380
MPEG12_RL_NB_ELEMS
#define MPEG12_RL_NB_ELEMS
Definition: mpeg12vlc.h:52
ff_mpeg12_vlc_dc_chroma_bits
const unsigned char ff_mpeg12_vlc_dc_chroma_bits[12]
Definition: mpeg12data.c:63
ff_mpeg12_vlc_dc_lum_bits
const unsigned char ff_mpeg12_vlc_dc_lum_bits[12]
Definition: mpeg12data.c:56
ff_mpeg12_mbAddrIncrTable
const uint8_t ff_mpeg12_mbAddrIncrTable[36][2]
Definition: mpeg12data.c:167
ff_mpeg2_frame_rate_tab
const AVRational ff_mpeg2_frame_rate_tab[]
Definition: mpeg12data.c:293
ff_mpeg12_mbMotionVectorTable
const uint8_t ff_mpeg12_mbMotionVectorTable[17][2]
Definition: mpeg12data.c:273
mpeg12vlc.h
ff_mpeg1_aspect
const float ff_mpeg1_aspect[16]
Definition: mpeg12data.c:359
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
ff_mpeg12_run
const int8_t ff_mpeg12_run[MPEG12_RL_NB_ELEMS]
Definition: mpeg12data.c:150
ff_mpeg12_level
const int8_t ff_mpeg12_level[MPEG12_RL_NB_ELEMS]
Definition: mpeg12data.c:133
ff_mpeg1_default_intra_matrix
const uint16_t ff_mpeg1_default_intra_matrix[256]
Definition: mpeg12data.c:31
ff_mpeg12_mbPatTable
const uint8_t ff_mpeg12_mbPatTable[64][2]
Definition: mpeg12data.c:206
ff_mpeg12_vlc_dc_chroma_code
const uint16_t ff_mpeg12_vlc_dc_chroma_code[12]
Definition: mpeg12data.c:60
ff_mpeg1_default_non_intra_matrix
const uint16_t ff_mpeg1_default_non_intra_matrix[64]
Definition: mpeg12data.c:42
ff_mpeg1_vlc_table
const uint16_t ff_mpeg1_vlc_table[MPEG12_RL_NB_ELEMS+2][2]
Definition: mpeg12data.c:67
mpeg12data.h
ff_mpeg2_vlc_table
const uint16_t ff_mpeg2_vlc_table[MPEG12_RL_NB_ELEMS+2][2]
Definition: mpeg12data.c:100
ff_mpeg12_vlc_dc_lum_code
const uint16_t ff_mpeg12_vlc_dc_lum_code[12]
Definition: mpeg12data.c:53