-/*
- * MPEG1/2 tables
+/**
+ * @file mpeg12data.h
+ * MPEG1/2 tables.
*/
const int16_t ff_mpeg1_default_intra_matrix[64] = {
16, 16, 16, 16, 16, 16, 16, 16,
};
-const unsigned char vlc_dc_table[256] = {
- 0, 1, 2, 2,
- 3, 3, 3, 3,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
-
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
-
- 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,
- 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,
- 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,
- 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,
-};
-
-const uint16_t vlc_dc_lum_code[12] = {
+static const uint16_t vlc_dc_lum_code[12] = {
0x4, 0x0, 0x1, 0x5, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe, 0x1ff,
};
-const unsigned char vlc_dc_lum_bits[12] = {
+static const unsigned char vlc_dc_lum_bits[12] = {
3, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 9,
};
2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10,
};
-/* simple include everything table for dc, first byte is bits number next 3 are code*/
-static uint32_t mpeg1_lum_dc_uni[512];
-static uint32_t mpeg1_chr_dc_uni[512];
-
static const uint16_t mpeg1_vlc[113][2] = {
{ 0x3, 2 }, { 0x4, 4 }, { 0x5, 5 }, { 0x6, 7 },
{ 0x26, 8 }, { 0x21, 8 }, { 0xa, 10 }, { 0x1d, 12 },
25, 26, 27, 28, 29, 30, 31,
};
-static uint8_t mpeg1_index_run[2][64];
-static int8_t mpeg1_max_level[2][64];
-
static RLTable rl_mpeg1 = {
111,
111,
mpeg1_level,
};
-static const uint8_t mbAddrIncrTable[35][2] = {
+static const uint8_t mbAddrIncrTable[36][2] = {
{0x1, 1},
{0x3, 3},
{0x2, 3},
{0x18, 11},
{0x8, 11}, /* escape */
{0xf, 11}, /* stuffing */
+ {0x0, 8}, /* end (and 15 more 0 bits should follow) */
};
-static const uint8_t mbPatTable[63][2] = {
+static const uint8_t mbPatTable[64][2] = {
+ {0x1, 9},
{0xb, 5},
{0x9, 5},
{0xd, 6},
{0xc, 6}
};
-#define MB_INTRA 0x01
-#define MB_PAT 0x02
-#define MB_BACK 0x04
-#define MB_FOR 0x08
-#define MB_QUANT 0x10
+#define MB_TYPE_ZERO_MV 0x20000000
+#define IS_ZERO_MV(a) ((a)&MB_TYPE_ZERO_MV)
-static const uint8_t table_mb_ptype[32][2] = {
- { 0, 0 }, // 0x00
+static const uint8_t table_mb_ptype[7][2] = {
{ 3, 5 }, // 0x01 MB_INTRA
{ 1, 2 }, // 0x02 MB_PAT
- { 0, 0 }, // 0x03
- { 0, 0 }, // 0x04
- { 0, 0 }, // 0x05
- { 0, 0 }, // 0x06
- { 0, 0 }, // 0x07
{ 1, 3 }, // 0x08 MB_FOR
- { 0, 0 }, // 0x09
{ 1, 1 }, // 0x0A MB_FOR|MB_PAT
- { 0, 0 }, // 0x0B
- { 0, 0 }, // 0x0C
- { 0, 0 }, // 0x0D
- { 0, 0 }, // 0x0E
- { 0, 0 }, // 0x0F
- { 0, 0 }, // 0x10
{ 1, 6 }, // 0x11 MB_QUANT|MB_INTRA
{ 1, 5 }, // 0x12 MB_QUANT|MB_PAT
- { 0, 0 }, // 0x13
- { 0, 0 }, // 0x14
- { 0, 0 }, // 0x15
- { 0, 0 }, // 0x16
- { 0, 0 }, // 0x17
- { 0, 0 }, // 0x18
- { 0, 0 }, // 0x19
{ 2, 5 }, // 0x1A MB_QUANT|MB_FOR|MB_PAT
- { 0, 0 }, // 0x1B
- { 0, 0 }, // 0x1C
- { 0, 0 }, // 0x1D
- { 0, 0 }, // 0x1E
- { 0, 0 }, // 0x1F
};
-static const uint8_t table_mb_btype[32][2] = {
- { 0, 0 }, // 0x00
+static const uint32_t ptype2mb_type[7] = {
+ MB_TYPE_INTRA,
+ MB_TYPE_L0 | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16,
+ MB_TYPE_L0,
+ MB_TYPE_L0 | MB_TYPE_CBP,
+ MB_TYPE_QUANT | MB_TYPE_INTRA,
+ MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16,
+ MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_CBP,
+};
+
+static const uint8_t table_mb_btype[11][2] = {
{ 3, 5 }, // 0x01 MB_INTRA
- { 0, 0 }, // 0x02
- { 0, 0 }, // 0x03
{ 2, 3 }, // 0x04 MB_BACK
- { 0, 0 }, // 0x05
{ 3, 3 }, // 0x06 MB_BACK|MB_PAT
- { 0, 0 }, // 0x07
{ 2, 4 }, // 0x08 MB_FOR
- { 0, 0 }, // 0x09
{ 3, 4 }, // 0x0A MB_FOR|MB_PAT
- { 0, 0 }, // 0x0B
{ 2, 2 }, // 0x0C MB_FOR|MB_BACK
- { 0, 0 }, // 0x0D
{ 3, 2 }, // 0x0E MB_FOR|MB_BACK|MB_PAT
- { 0, 0 }, // 0x0F
- { 0, 0 }, // 0x10
{ 1, 6 }, // 0x11 MB_QUANT|MB_INTRA
- { 0, 0 }, // 0x12
- { 0, 0 }, // 0x13
- { 0, 0 }, // 0x14
- { 0, 0 }, // 0x15
{ 2, 6 }, // 0x16 MB_QUANT|MB_BACK|MB_PAT
- { 0, 0 }, // 0x17
- { 0, 0 }, // 0x18
- { 0, 0 }, // 0x19
{ 3, 6 }, // 0x1A MB_QUANT|MB_FOR|MB_PAT
- { 0, 0 }, // 0x1B
- { 0, 0 }, // 0x1C
- { 0, 0 }, // 0x1D
{ 2, 5 }, // 0x1E MB_QUANT|MB_FOR|MB_BACK|MB_PAT
- { 0, 0 }, // 0x1F
+};
+
+static const uint32_t btype2mb_type[11] = {
+ MB_TYPE_INTRA,
+ MB_TYPE_L1,
+ MB_TYPE_L1 | MB_TYPE_CBP,
+ MB_TYPE_L0,
+ MB_TYPE_L0 | MB_TYPE_CBP,
+ MB_TYPE_L0L1,
+ MB_TYPE_L0L1 | MB_TYPE_CBP,
+ MB_TYPE_QUANT | MB_TYPE_INTRA,
+ MB_TYPE_QUANT | MB_TYPE_L1 | MB_TYPE_CBP,
+ MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_CBP,
+ MB_TYPE_QUANT | MB_TYPE_L0L1 | MB_TYPE_CBP,
};
static const uint8_t mbMotionVectorTable[17][2] = {
{ 0xc, 10 },
};
-static const int frame_rate_tab[9] = {
- 0,
- 24000 * FRAME_RATE_BASE / 1001,
- 24000 * FRAME_RATE_BASE / 1000,
- 25000 * FRAME_RATE_BASE / 1000,
- 30000 * FRAME_RATE_BASE / 1001,
- 30000 * FRAME_RATE_BASE / 1000,
- 50000 * FRAME_RATE_BASE / 1000,
- 60000 * FRAME_RATE_BASE / 1001,
- 60000 * FRAME_RATE_BASE / 1000,
+static const AVRational frame_rate_tab[] = {
+ { 0, 0},
+ {24000, 1001},
+ { 24, 1},
+ { 25, 1},
+ {30000, 1001},
+ { 30, 1},
+ { 50, 1},
+ {60000, 1001},
+ { 60, 1},
+ // Xing's 15fps: (9)
+ { 15, 1},
+ // libmpeg3's "Unofficial economy rates": (10-13)
+ { 5, 1},
+ { 10, 1},
+ { 12, 1},
+ { 15, 1},
+ { 0, 0},
};
static const uint8_t non_linear_qscale[32] = {
56,64,72,80,88,96,104,112,
};
-uint8_t ff_mpeg1_dc_scale_table[128]={ // MN: mpeg2 really can have such large qscales?
+const uint8_t ff_mpeg1_dc_scale_table[128]={
// 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
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,
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,
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,
};
+const static uint8_t mpeg2_dc_scale_table1[128]={
+// 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
+ 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,
+ 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,
+ 4, 4, 4, 4, 4, 4, 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+};
+
+static const uint8_t *mpeg2_dc_scale_table[4]={
+ ff_mpeg1_dc_scale_table,
+ mpeg2_dc_scale_table1,
+ mpeg2_dc_scale_table2,
+ mpeg2_dc_scale_table3,
+};
+
static const float mpeg1_aspect[16]={
0.0000,
1.0000,
1.2015,
};
-static const float mpeg2_aspect[16]={
- 0,
- 1.0,
- -3.0/4.0,
- -9.0/16.0,
- -1.0/2.21,
+static const AVRational mpeg2_aspect[16]={
+ {0,1},
+ {1,1},
+ {4,3},
+ {16,9},
+ {221,100},
+ {0,1},
+ {0,1},
+ {0,1},
+ {0,1},
+ {0,1},
+ {0,1},
+ {0,1},
+ {0,1},
+ {0,1},
+ {0,1},
+ {0,1},
};
+static const uint8_t svcd_scan_offset_placeholder[14]={
+ 0x10, 0x0E,
+ 0x00, 0x80, 0x81,
+ 0x00, 0x80, 0x81,
+ 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff,
+};