7aee9899bfcc4138f24b84c2482501c32ddad017
[libav.git] / libavcodec / mpeg12decdata.h
1 /*
2 * MPEG1/2 decoder 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 mpeg12decdata.h
25 * MPEG1/2 decoder tables.
26 */
27
28 #ifndef AVCODEC_MPEG12DECDATA_H
29 #define AVCODEC_MPEG12DECDATA_H
30
31 #include <stdint.h>
32 #include "mpegvideo.h"
33
34
35 #define MB_TYPE_ZERO_MV 0x20000000
36 #define IS_ZERO_MV(a) ((a)&MB_TYPE_ZERO_MV)
37
38 static const uint8_t table_mb_ptype[7][2] = {
39 { 3, 5 }, // 0x01 MB_INTRA
40 { 1, 2 }, // 0x02 MB_PAT
41 { 1, 3 }, // 0x08 MB_FOR
42 { 1, 1 }, // 0x0A MB_FOR|MB_PAT
43 { 1, 6 }, // 0x11 MB_QUANT|MB_INTRA
44 { 1, 5 }, // 0x12 MB_QUANT|MB_PAT
45 { 2, 5 }, // 0x1A MB_QUANT|MB_FOR|MB_PAT
46 };
47
48 static const uint32_t ptype2mb_type[7] = {
49 MB_TYPE_INTRA,
50 MB_TYPE_L0 | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16,
51 MB_TYPE_L0,
52 MB_TYPE_L0 | MB_TYPE_CBP,
53 MB_TYPE_QUANT | MB_TYPE_INTRA,
54 MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16,
55 MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_CBP,
56 };
57
58 static const uint8_t table_mb_btype[11][2] = {
59 { 3, 5 }, // 0x01 MB_INTRA
60 { 2, 3 }, // 0x04 MB_BACK
61 { 3, 3 }, // 0x06 MB_BACK|MB_PAT
62 { 2, 4 }, // 0x08 MB_FOR
63 { 3, 4 }, // 0x0A MB_FOR|MB_PAT
64 { 2, 2 }, // 0x0C MB_FOR|MB_BACK
65 { 3, 2 }, // 0x0E MB_FOR|MB_BACK|MB_PAT
66 { 1, 6 }, // 0x11 MB_QUANT|MB_INTRA
67 { 2, 6 }, // 0x16 MB_QUANT|MB_BACK|MB_PAT
68 { 3, 6 }, // 0x1A MB_QUANT|MB_FOR|MB_PAT
69 { 2, 5 }, // 0x1E MB_QUANT|MB_FOR|MB_BACK|MB_PAT
70 };
71
72 static const uint32_t btype2mb_type[11] = {
73 MB_TYPE_INTRA,
74 MB_TYPE_L1,
75 MB_TYPE_L1 | MB_TYPE_CBP,
76 MB_TYPE_L0,
77 MB_TYPE_L0 | MB_TYPE_CBP,
78 MB_TYPE_L0L1,
79 MB_TYPE_L0L1 | MB_TYPE_CBP,
80 MB_TYPE_QUANT | MB_TYPE_INTRA,
81 MB_TYPE_QUANT | MB_TYPE_L1 | MB_TYPE_CBP,
82 MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_CBP,
83 MB_TYPE_QUANT | MB_TYPE_L0L1 | MB_TYPE_CBP,
84 };
85
86 static const uint8_t non_linear_qscale[32] = {
87 0, 1, 2, 3, 4, 5, 6, 7,
88 8,10,12,14,16,18,20,22,
89 24,28,32,36,40,44,48,52,
90 56,64,72,80,88,96,104,112,
91 };
92
93 static const uint8_t mpeg2_dc_scale_table1[128]={
94 // 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
95 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,
96 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,
97 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,
98 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,
99 };
100
101 static const uint8_t mpeg2_dc_scale_table2[128]={
102 // 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
103 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,
104 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,
105 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,
106 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,
107 };
108
109 static const uint8_t mpeg2_dc_scale_table3[128]={
110 // 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
111 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,
112 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,
113 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,
114 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,
115 };
116
117 static const uint8_t *mpeg2_dc_scale_table[4]={
118 ff_mpeg1_dc_scale_table,
119 mpeg2_dc_scale_table1,
120 mpeg2_dc_scale_table2,
121 mpeg2_dc_scale_table3,
122 };
123
124 #endif // AVCODEC_MPEG12DECDATA_H