~ubuntu-branches/ubuntu/jaunty/xvidcap/jaunty-proposed

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/mpeg12data.h

  • Committer: Bazaar Package Importer
  • Author(s): John Dong
  • Date: 2008-02-25 15:47:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080225154712-qvr11ekcea4c9ry8
Tags: 1.1.6-0.1ubuntu1
* Merge from debian-multimedia (LP: #120003), Ubuntu Changes:
 - For ffmpeg-related build-deps, remove cvs from package names.
 - Standards-Version 3.7.3
 - Maintainer Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * MPEG1 codec / MPEG2 decoder
 
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
 
1
23
/**
2
24
 * @file mpeg12data.h
3
25
 * MPEG1/2 tables.
4
26
 */
5
27
 
6
 
const int16_t ff_mpeg1_default_intra_matrix[64] = {
7
 
        8, 16, 19, 22, 26, 27, 29, 34,
8
 
        16, 16, 22, 24, 27, 29, 34, 37,
9
 
        19, 22, 26, 27, 29, 34, 34, 38,
10
 
        22, 22, 26, 27, 29, 34, 37, 40,
11
 
        22, 26, 27, 29, 32, 35, 40, 48,
12
 
        26, 27, 29, 32, 35, 40, 48, 58,
13
 
        26, 27, 29, 34, 38, 46, 56, 69,
14
 
        27, 29, 35, 38, 46, 56, 69, 83
15
 
};
16
 
 
17
 
const int16_t ff_mpeg1_default_non_intra_matrix[64] = {
18
 
    16, 16, 16, 16, 16, 16, 16, 16,
19
 
    16, 16, 16, 16, 16, 16, 16, 16,
20
 
    16, 16, 16, 16, 16, 16, 16, 16,
21
 
    16, 16, 16, 16, 16, 16, 16, 16,
22
 
    16, 16, 16, 16, 16, 16, 16, 16,
23
 
    16, 16, 16, 16, 16, 16, 16, 16,
24
 
    16, 16, 16, 16, 16, 16, 16, 16,
25
 
    16, 16, 16, 16, 16, 16, 16, 16,
26
 
};
27
 
 
28
 
static const unsigned char vlc_dc_table[256] = {
29
 
    0, 1, 2, 2,
30
 
    3, 3, 3, 3,
31
 
    4, 4, 4, 4, 4, 4, 4, 4,
32
 
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
33
 
    6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
34
 
    6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
35
 
 
36
 
    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
37
 
    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
38
 
    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
39
 
    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
40
 
 
41
 
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
42
 
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
43
 
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
44
 
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
45
 
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
46
 
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
47
 
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
48
 
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
 
28
const uint16_t ff_mpeg1_default_intra_matrix[64] = {
 
29
        8, 16, 19, 22, 26, 27, 29, 34,
 
30
        16, 16, 22, 24, 27, 29, 34, 37,
 
31
        19, 22, 26, 27, 29, 34, 34, 38,
 
32
        22, 22, 26, 27, 29, 34, 37, 40,
 
33
        22, 26, 27, 29, 32, 35, 40, 48,
 
34
        26, 27, 29, 32, 35, 40, 48, 58,
 
35
        26, 27, 29, 34, 38, 46, 56, 69,
 
36
        27, 29, 35, 38, 46, 56, 69, 83
 
37
};
 
38
 
 
39
const uint16_t ff_mpeg1_default_non_intra_matrix[64] = {
 
40
    16, 16, 16, 16, 16, 16, 16, 16,
 
41
    16, 16, 16, 16, 16, 16, 16, 16,
 
42
    16, 16, 16, 16, 16, 16, 16, 16,
 
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,
49
48
};
50
49
 
51
50
static const uint16_t vlc_dc_lum_code[12] = {
55
54
    3, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 9,
56
55
};
57
56
 
58
 
const uint16_t vlc_dc_chroma_code[12] = {
 
57
static const uint16_t vlc_dc_chroma_code[12] = {
59
58
    0x0, 0x1, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe, 0x3fe, 0x3ff,
60
59
};
61
 
const unsigned char vlc_dc_chroma_bits[12] = {
 
60
static const unsigned char vlc_dc_chroma_bits[12] = {
62
61
    2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10,
63
62
};
64
63
 
110
109
  {0x20, 8}, {0x16,13}, {0x15,13}, {0x1f,15},
111
110
  {0x1e,15}, {0x1d,15}, {0x1c,15}, {0x1b,15},
112
111
  {0x1a,15}, {0x19,15}, {0x13,16}, {0x12,16},
113
 
  {0x11,16}, {0x10,16}, {0x05, 5}, {0x07, 7}, 
114
 
  {0xfc, 8}, {0x0c,10}, {0x14,13}, {0x07, 5}, 
115
 
  {0x26, 8}, {0x1c,12}, {0x13,13}, {0x06, 6}, 
116
 
  {0xfd, 8}, {0x12,12}, {0x07, 6}, {0x04, 9}, 
117
 
  {0x12,13}, {0x06, 7}, {0x1e,12}, {0x14,16}, 
118
 
  {0x04, 7}, {0x15,12}, {0x05, 7}, {0x11,12}, 
119
 
  {0x78, 7}, {0x11,13}, {0x7a, 7}, {0x10,13}, 
120
 
  {0x21, 8}, {0x1a,16}, {0x25, 8}, {0x19,16}, 
121
 
  {0x24, 8}, {0x18,16}, {0x05, 9}, {0x17,16}, 
122
 
  {0x07, 9}, {0x16,16}, {0x0d,10}, {0x15,16}, 
123
 
  {0x1f,12}, {0x1a,12}, {0x19,12}, {0x17,12}, 
124
 
  {0x16,12}, {0x1f,13}, {0x1e,13}, {0x1d,13}, 
125
 
  {0x1c,13}, {0x1b,13}, {0x1f,16}, {0x1e,16}, 
126
 
  {0x1d,16}, {0x1c,16}, {0x1b,16}, 
 
112
  {0x11,16}, {0x10,16}, {0x05, 5}, {0x07, 7},
 
113
  {0xfc, 8}, {0x0c,10}, {0x14,13}, {0x07, 5},
 
114
  {0x26, 8}, {0x1c,12}, {0x13,13}, {0x06, 6},
 
115
  {0xfd, 8}, {0x12,12}, {0x07, 6}, {0x04, 9},
 
116
  {0x12,13}, {0x06, 7}, {0x1e,12}, {0x14,16},
 
117
  {0x04, 7}, {0x15,12}, {0x05, 7}, {0x11,12},
 
118
  {0x78, 7}, {0x11,13}, {0x7a, 7}, {0x10,13},
 
119
  {0x21, 8}, {0x1a,16}, {0x25, 8}, {0x19,16},
 
120
  {0x24, 8}, {0x18,16}, {0x05, 9}, {0x17,16},
 
121
  {0x07, 9}, {0x16,16}, {0x0d,10}, {0x15,16},
 
122
  {0x1f,12}, {0x1a,12}, {0x19,12}, {0x17,12},
 
123
  {0x16,12}, {0x1f,13}, {0x1e,13}, {0x1d,13},
 
124
  {0x1c,13}, {0x1b,13}, {0x1f,16}, {0x1e,16},
 
125
  {0x1d,16}, {0x1c,16}, {0x1b,16},
127
126
  {0x01,6}, /* escape */
128
127
  {0x06,4}, /* EOB */
129
128
};
217
216
    {0x0, 8}, /* end (and 15 more 0 bits should follow) */
218
217
};
219
218
 
220
 
static const uint8_t mbPatTable[63][2] = {
 
219
static const uint8_t mbPatTable[64][2] = {
 
220
    {0x1, 9},
221
221
    {0xb, 5},
222
222
    {0x9, 5},
223
223
    {0xd, 6},
283
283
    {0xc, 6}
284
284
};
285
285
 
286
 
#define MB_TYPE_PAT       0x40000000
287
286
#define MB_TYPE_ZERO_MV   0x20000000
288
287
#define IS_ZERO_MV(a)   ((a)&MB_TYPE_ZERO_MV)
289
 
#define IS_PAT(a)       ((a)&MB_TYPE_PAT)
290
288
 
291
289
static const uint8_t table_mb_ptype[7][2] = {
292
290
    { 3, 5 }, // 0x01 MB_INTRA
300
298
 
301
299
static const uint32_t ptype2mb_type[7] = {
302
300
                    MB_TYPE_INTRA,
303
 
                    MB_TYPE_L0 | MB_TYPE_PAT | MB_TYPE_ZERO_MV | MB_TYPE_16x16,
 
301
                    MB_TYPE_L0 | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16,
304
302
                    MB_TYPE_L0,
305
 
                    MB_TYPE_L0 | MB_TYPE_PAT,
 
303
                    MB_TYPE_L0 | MB_TYPE_CBP,
306
304
    MB_TYPE_QUANT | MB_TYPE_INTRA,
307
 
    MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_PAT | MB_TYPE_ZERO_MV | MB_TYPE_16x16,
308
 
    MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_PAT,
 
305
    MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16,
 
306
    MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_CBP,
309
307
};
310
308
 
311
309
static const uint8_t table_mb_btype[11][2] = {
325
323
static const uint32_t btype2mb_type[11] = {
326
324
                    MB_TYPE_INTRA,
327
325
                    MB_TYPE_L1,
328
 
                    MB_TYPE_L1   | MB_TYPE_PAT,
 
326
                    MB_TYPE_L1   | MB_TYPE_CBP,
329
327
                    MB_TYPE_L0,
330
 
                    MB_TYPE_L0   | MB_TYPE_PAT,
 
328
                    MB_TYPE_L0   | MB_TYPE_CBP,
331
329
                    MB_TYPE_L0L1,
332
 
                    MB_TYPE_L0L1 | MB_TYPE_PAT,
 
330
                    MB_TYPE_L0L1 | MB_TYPE_CBP,
333
331
    MB_TYPE_QUANT | MB_TYPE_INTRA,
334
 
    MB_TYPE_QUANT | MB_TYPE_L1   | MB_TYPE_PAT,
335
 
    MB_TYPE_QUANT | MB_TYPE_L0   | MB_TYPE_PAT,
336
 
    MB_TYPE_QUANT | MB_TYPE_L0L1 | MB_TYPE_PAT,
 
332
    MB_TYPE_QUANT | MB_TYPE_L1   | MB_TYPE_CBP,
 
333
    MB_TYPE_QUANT | MB_TYPE_L0   | MB_TYPE_CBP,
 
334
    MB_TYPE_QUANT | MB_TYPE_L0L1 | MB_TYPE_CBP,
337
335
};
338
336
 
339
337
static const uint8_t mbMotionVectorTable[17][2] = {
356
354
{ 0xc, 10 },
357
355
};
358
356
 
359
 
#define MPEG1_FRAME_RATE_BASE 1001
360
 
 
361
 
static const int frame_rate_tab[16] = {
362
 
        0,        
363
 
    24000,
364
 
    24024,
365
 
    25025,
366
 
    30000,
367
 
    30030,
368
 
    50050,
369
 
    60000,
370
 
    60060,
 
357
const AVRational ff_frame_rate_tab[] = {
 
358
    {    0,    0},
 
359
    {24000, 1001},
 
360
    {   24,    1},
 
361
    {   25,    1},
 
362
    {30000, 1001},
 
363
    {   30,    1},
 
364
    {   50,    1},
 
365
    {60000, 1001},
 
366
    {   60,    1},
371
367
  // Xing's 15fps: (9)
372
 
    15015,
 
368
    {   15,    1},
373
369
  // libmpeg3's "Unofficial economy rates": (10-13)
374
 
     5005,
375
 
    10010,
376
 
    12012,
377
 
    15015,
378
 
  // random, just to avoid segfault !never encode these
379
 
    25025,
380
 
    25025,
 
370
    {    5,    1},
 
371
    {   10,    1},
 
372
    {   12,    1},
 
373
    {   15,    1},
 
374
    {    0,    0},
381
375
};
382
376
 
383
377
static const uint8_t non_linear_qscale[32] = {
387
381
    56,64,72,80,88,96,104,112,
388
382
};
389
383
 
390
 
uint8_t ff_mpeg1_dc_scale_table[128]={ // MN: mpeg2 really can have such large qscales?
391
 
//  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
392
 
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
393
 
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
394
 
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
395
 
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
 
384
const uint8_t ff_mpeg1_dc_scale_table[128]={
 
385
//  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
 
386
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
 
387
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
 
388
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
 
389
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
 
390
};
 
391
 
 
392
static const uint8_t mpeg2_dc_scale_table1[128]={
 
393
//  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
 
394
    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
 
395
    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
 
396
    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
 
397
    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
 
398
};
 
399
 
 
400
static const uint8_t mpeg2_dc_scale_table2[128]={
 
401
//  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
 
402
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
 
403
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
 
404
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
 
405
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
 
406
};
 
407
 
 
408
static const uint8_t mpeg2_dc_scale_table3[128]={
 
409
//  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
 
410
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
411
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
412
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
413
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
 
414
};
 
415
 
 
416
static const uint8_t *mpeg2_dc_scale_table[4]={
 
417
    ff_mpeg1_dc_scale_table,
 
418
    mpeg2_dc_scale_table1,
 
419
    mpeg2_dc_scale_table2,
 
420
    mpeg2_dc_scale_table3,
396
421
};
397
422
 
398
423
static const float mpeg1_aspect[16]={
400
425
    1.0000,
401
426
    0.6735,
402
427
    0.7031,
403
 
    
 
428
 
404
429
    0.7615,
405
430
    0.8055,
406
431
    0.8437,
416
441
    1.2015,
417
442
};
418
443
 
419
 
static const float mpeg2_aspect[16]={
420
 
    0,
421
 
    1.0,
422
 
    -3.0/4.0,
423
 
    -9.0/16.0,
424
 
    -1.0/2.21,
 
444
static const AVRational mpeg2_aspect[16]={
 
445
    {0,1},
 
446
    {1,1},
 
447
    {4,3},
 
448
    {16,9},
 
449
    {221,100},
 
450
    {0,1},
 
451
    {0,1},
 
452
    {0,1},
 
453
    {0,1},
 
454
    {0,1},
 
455
    {0,1},
 
456
    {0,1},
 
457
    {0,1},
 
458
    {0,1},
 
459
    {0,1},
 
460
    {0,1},
425
461
};
426
462
 
 
463
static const uint8_t svcd_scan_offset_placeholder[14]={
 
464
    0x10, 0x0E,
 
465
    0x00, 0x80, 0x81,
 
466
    0x00, 0x80, 0x81,
 
467
    0xff, 0xff, 0xff,
 
468
    0xff, 0xff, 0xff,
 
469
};