1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
FFmpeg/libavcodec/vc1data.c

985 lines
40 KiB
C
Raw Normal View History

/*
* VC-1 and WMV3 decoder
* copyright (c) 2011 Mashiat Sarker Shakkhar
* copyright (c) 2006 Konstantin Shishkov
* (c) 2005 anonymous, Alex Beregszaszi, Michael Niedermayer
*
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* VC-1 tables.
*/
#include "avcodec.h"
#include "vc1.h"
#include "vc1data.h"
/** Table for conversion between TTBLK and TTMB */
const int ff_vc1_ttblk_to_tt[3][8] = {
{ TT_8X4, TT_4X8, TT_8X8, TT_4X4, TT_8X4_TOP, TT_8X4_BOTTOM, TT_4X8_RIGHT, TT_4X8_LEFT },
{ TT_8X8, TT_4X8_RIGHT, TT_4X8_LEFT, TT_4X4, TT_8X4, TT_4X8, TT_8X4_BOTTOM, TT_8X4_TOP },
{ TT_8X8, TT_4X8, TT_4X4, TT_8X4_BOTTOM, TT_4X8_RIGHT, TT_4X8_LEFT, TT_8X4, TT_8X4_TOP }
};
const int ff_vc1_ttfrm_to_tt[4] = { TT_8X8, TT_8X4, TT_4X8, TT_4X4 };
/** MV P mode - the 5th element is only used for mode 1 */
const uint8_t ff_vc1_mv_pmode_table[2][5] = {
{ MV_PMODE_1MV_HPEL_BILIN, MV_PMODE_1MV, MV_PMODE_1MV_HPEL, MV_PMODE_INTENSITY_COMP, MV_PMODE_MIXED_MV },
{ MV_PMODE_1MV, MV_PMODE_MIXED_MV, MV_PMODE_1MV_HPEL, MV_PMODE_INTENSITY_COMP, MV_PMODE_1MV_HPEL_BILIN }
};
const uint8_t ff_vc1_mv_pmode_table2[2][4] = {
{ MV_PMODE_1MV_HPEL_BILIN, MV_PMODE_1MV, MV_PMODE_1MV_HPEL, MV_PMODE_MIXED_MV },
{ MV_PMODE_1MV, MV_PMODE_MIXED_MV, MV_PMODE_1MV_HPEL, MV_PMODE_1MV_HPEL_BILIN }
};
/* MBMODE table for interlaced frame P-picture */
const uint8_t ff_vc1_mbmode_intfrp[2][15][4] = {
{ /* 1: 4-MV, 0: non-4-MV */
/* Type, FIELDTX, 1-MV Differential present, Residuals (CBP) present */
/* Table 164 - Table 167 */
{ MV_PMODE_INTFR_1MV , 0, 1, 1},
{ MV_PMODE_INTFR_1MV , 1, 1, 1},
{ MV_PMODE_INTFR_1MV , 0, 1, 0},
{ MV_PMODE_INTFR_1MV , 0, 0, 1},
{ MV_PMODE_INTFR_1MV , 1, 0, 1},
{ MV_PMODE_INTFR_2MV_FIELD , 0, 0, 1},
{ MV_PMODE_INTFR_2MV_FIELD , 1, 0, 1},
{ MV_PMODE_INTFR_2MV_FIELD , 0, 0, 0},
{ MV_PMODE_INTFR_INTRA , 0, 0, 0} },
{
/* Table 160 - Table 163 */
{ MV_PMODE_INTFR_1MV , 0, 1, 1 },
{ MV_PMODE_INTFR_1MV , 1, 1, 1 },
{ MV_PMODE_INTFR_1MV , 0, 1, 0 },
{ MV_PMODE_INTFR_1MV , 0, 0, 1 },
{ MV_PMODE_INTFR_1MV , 1, 0, 1 },
{ MV_PMODE_INTFR_2MV_FIELD , 0, 0, 1 },
{ MV_PMODE_INTFR_2MV_FIELD , 1, 0, 1 },
{ MV_PMODE_INTFR_2MV_FIELD , 0, 0, 0 },
{ MV_PMODE_INTFR_4MV , 0, 0, 1 },
{ MV_PMODE_INTFR_4MV , 1, 0, 1 },
{ MV_PMODE_INTFR_4MV , 0, 0, 0 },
{ MV_PMODE_INTFR_4MV_FIELD , 0, 0, 1 },
{ MV_PMODE_INTFR_4MV_FIELD , 1, 0, 1 },
{ MV_PMODE_INTFR_4MV_FIELD , 0, 0, 0 },
{ MV_PMODE_INTFR_INTRA , 0, 0, 0 }
}
};
const int ff_vc1_fps_nr[5] = { 24, 25, 30, 50, 60 },
ff_vc1_fps_dr[2] = { 1000, 1001 };
const uint8_t ff_vc1_pquant_table[3][32] = {
{ /* Implicit quantizer */
0, 1, 2, 3, 4, 5, 6, 7, 8, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 29, 31
},
{ /* Explicit quantizer, pquantizer uniform */
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
},
{ /* Explicit quantizer, pquantizer non-uniform */
0, 1, 1, 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, 29, 31
}
};
/** @name VC-1 VLC tables and defines
* @todo TODO move this into the context
*/
//@{
#define VC1_BFRACTION_VLC_BITS 7
VLC ff_vc1_bfraction_vlc;
#define VC1_IMODE_VLC_BITS 4
VLC ff_vc1_imode_vlc;
#define VC1_NORM2_VLC_BITS 3
VLC ff_vc1_norm2_vlc;
#define VC1_NORM6_VLC_BITS 9
VLC ff_vc1_norm6_vlc;
/* Could be optimized, one table only needs 8 bits */
#define VC1_TTMB_VLC_BITS 9 //12
VLC ff_vc1_ttmb_vlc[3];
#define VC1_MV_DIFF_VLC_BITS 9 //15
VLC ff_vc1_mv_diff_vlc[4];
#define VC1_CBPCY_P_VLC_BITS 9 //14
VLC ff_vc1_cbpcy_p_vlc[4];
#define VC1_ICBPCY_VLC_BITS 9
VLC ff_vc1_icbpcy_vlc[8];
#define VC1_4MV_BLOCK_PATTERN_VLC_BITS 6
VLC ff_vc1_4mv_block_pattern_vlc[4];
#define VC1_2MV_BLOCK_PATTERN_VLC_BITS 3
VLC ff_vc1_2mv_block_pattern_vlc[4];
#define VC1_TTBLK_VLC_BITS 5
VLC ff_vc1_ttblk_vlc[3];
#define VC1_SUBBLKPAT_VLC_BITS 6
VLC ff_vc1_subblkpat_vlc[3];
#define VC1_INTFR_4MV_MBMODE_VLC_BITS 9
VLC ff_vc1_intfr_4mv_mbmode_vlc[4];
#define VC1_INTFR_NON4MV_MBMODE_VLC_BITS 6
VLC ff_vc1_intfr_non4mv_mbmode_vlc[4];
#define VC1_IF_MMV_MBMODE_VLC_BITS 5
VLC ff_vc1_if_mmv_mbmode_vlc[8];
#define VC1_IF_1MV_MBMODE_VLC_BITS 5
VLC ff_vc1_if_1mv_mbmode_vlc[8];
#define VC1_1REF_MVDATA_VLC_BITS 9
VLC ff_vc1_1ref_mvdata_vlc[4];
#define VC1_2REF_MVDATA_VLC_BITS 9
VLC ff_vc1_2ref_mvdata_vlc[8];
VLC ff_vc1_ac_coeff_table[8];
#define VC1_IF_MBMODE_VLC_BITS 5 // as a placeholder for VC1_IF_MMV_MBMODE_VLC_BITS
// or VC1_IF_1MV_MBMODE_VLC_BITS since they are the same
//@}
#if B_FRACTION_DEN==840 //original bfraction from vc9data.h, not conforming to standard
/* bfraction is fractional, we scale to the GCD 3*5*7*8 = 840 */
const int16_t ff_vc1_bfraction_lut[23] = {
420 /*1/2*/, 280 /*1/3*/, 560 /*2/3*/, 210 /*1/4*/,
630 /*3/4*/, 168 /*1/5*/, 336 /*2/5*/,
504 /*3/5*/, 672 /*4/5*/, 140 /*1/6*/, 700 /*5/6*/,
120 /*1/7*/, 240 /*2/7*/, 360 /*3/7*/, 480 /*4/7*/,
600 /*5/7*/, 720 /*6/7*/, 105 /*1/8*/, 315 /*3/8*/,
525 /*5/8*/, 735 /*7/8*/,
-1 /*inv.*/, 0 /*BI fm*/
};
#else
/* pre-computed scales for all bfractions and base=256 */
const int16_t ff_vc1_bfraction_lut[23] = {
128 /*1/2*/, 85 /*1/3*/, 170 /*2/3*/, 64 /*1/4*/,
192 /*3/4*/, 51 /*1/5*/, 102 /*2/5*/,
153 /*3/5*/, 204 /*4/5*/, 43 /*1/6*/, 215 /*5/6*/,
37 /*1/7*/, 74 /*2/7*/, 111 /*3/7*/, 148 /*4/7*/,
185 /*5/7*/, 222 /*6/7*/, 32 /*1/8*/, 96 /*3/8*/,
160 /*5/8*/, 224 /*7/8*/,
-1 /*inv.*/, 0 /*BI fm*/
};
#endif
const uint8_t ff_vc1_bfraction_bits[23] = {
3, 3, 3, 3,
3, 3, 3,
7, 7, 7, 7,
7, 7, 7, 7,
7, 7, 7, 7,
7, 7,
7, 7
};
const uint8_t ff_vc1_bfraction_codes[23] = {
0, 1, 2, 3,
4, 5, 6,
112, 113, 114, 115,
116, 117, 118, 119,
120, 121, 122, 123,
124, 125,
126, 127
};
//Same as H.264
const AVRational ff_vc1_pixel_aspect[16]={
{0, 1},
{1, 1},
{12, 11},
{10, 11},
{16, 11},
{40, 33},
{24, 11},
{20, 11},
{32, 11},
{80, 33},
{18, 11},
{15, 11},
{64, 33},
{160, 99},
{0, 1},
{0, 1}
};
/* BitPlane IMODE - such a small table... */
const uint8_t ff_vc1_imode_codes[7] = {
0, 2, 1, 3, 1, 2, 3
};
const uint8_t ff_vc1_imode_bits[7] = {
4, 2, 3, 2, 4, 3, 3
};
/* Normal-2 imode */
const uint8_t ff_vc1_norm2_codes[4] = {
0, 4, 5, 3
};
const uint8_t ff_vc1_norm2_bits[4] = {
1, 3, 3, 2
};
const uint16_t ff_vc1_norm6_codes[64] = {
0x001, 0x002, 0x003, 0x000, 0x004, 0x001, 0x002, 0x047, 0x005, 0x003, 0x004, 0x04B, 0x005, 0x04D, 0x04E, 0x30E,
0x006, 0x006, 0x007, 0x053, 0x008, 0x055, 0x056, 0x30D, 0x009, 0x059, 0x05A, 0x30C, 0x05C, 0x30B, 0x30A, 0x037,
0x007, 0x00A, 0x00B, 0x043, 0x00C, 0x045, 0x046, 0x309, 0x00D, 0x049, 0x04A, 0x308, 0x04C, 0x307, 0x306, 0x036,
0x00E, 0x051, 0x052, 0x305, 0x054, 0x304, 0x303, 0x035, 0x058, 0x302, 0x301, 0x034, 0x300, 0x033, 0x032, 0x007,
};
const uint8_t ff_vc1_norm6_bits[64] = {
1, 4, 4, 8, 4, 8, 8, 10, 4, 8, 8, 10, 8, 10, 10, 13,
4, 8, 8, 10, 8, 10, 10, 13, 8, 10, 10, 13, 10, 13, 13, 9,
4, 8, 8, 10, 8, 10, 10, 13, 8, 10, 10, 13, 10, 13, 13, 9,
8, 10, 10, 13, 10, 13, 13, 9, 10, 13, 13, 9, 13, 9, 9, 6,
};
/* 4MV Block pattern VLC tables */
const uint8_t ff_vc1_4mv_block_pattern_codes[4][16] = {
{ 14, 58, 59, 25, 12, 26, 15, 15, 13, 24, 27, 0, 28, 1, 2, 2},
{ 8, 18, 19, 4, 20, 5, 30, 11, 21, 31, 6, 12, 7, 13, 14, 0},
{ 15, 6, 7, 2, 8, 3, 28, 9, 10, 29, 4, 11, 5, 12, 13, 0},
{ 0, 11, 12, 4, 13, 5, 30, 16, 14, 31, 6, 17, 7, 18, 19, 10}
};
const uint8_t ff_vc1_4mv_block_pattern_bits[4][16] = {
{ 5, 6, 6, 5, 5, 5, 5, 4, 5, 5, 5, 3, 5, 3, 3, 2},
{ 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4, 4, 4, 4, 4, 2},
{ 4, 4, 4, 4, 4, 4, 5, 4, 4, 5, 4, 4, 4, 4, 4, 3},
{ 2, 4, 4, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4}
};
/* 2MV Block pattern VLC tables */
const uint8_t ff_vc1_2mv_block_pattern_codes[4][4] = {
{ 2, 1, 0, 3}, { 1, 0, 2, 3}, { 2, 0, 3, 1}, { 1, 3, 2, 0}
};
const uint8_t ff_vc1_2mv_block_pattern_bits[4][4] = {
{ 2, 2, 2, 2}, { 1, 2, 3, 3}, { 3, 2, 3, 1}, { 1, 3, 3, 2}
};
/* Interlaced frame picture 4MV MBMODE VLC tables (p. 246, p. 360) */
const uint16_t ff_vc1_intfr_4mv_mbmode_codes[4][15] = {
{ 22, 17, 0, 47, 32, 10, 1, 3, 67, 133, 132, 92, 19, 93, 18},
{ 3, 45, 0, 7, 23, 6, 1, 2, 10, 39, 44, 8, 18, 77, 76},
{ 15, 6, 28, 9, 41, 6, 2, 15, 14, 8, 40, 29, 0, 21, 11},
{ 7, 198, 1, 2, 193, 13, 25, 0, 97, 1599, 98, 398, 798, 192, 1598}
};
const uint8_t ff_vc1_intfr_4mv_mbmode_bits[4][15] = {
{ 5, 5, 2, 6, 6, 4, 2, 2, 7, 8, 8, 7, 5, 7, 5},
{ 3, 6, 3, 3, 5, 3, 3, 3, 4, 6, 6, 4, 5, 7, 7},
{ 4, 3, 5, 5, 7, 4, 2, 5, 5, 5, 7, 5, 2, 6, 5},
{ 4, 9, 1, 3, 9, 5, 6, 2, 8, 12, 8, 10, 11, 9, 12}
};
/* Interlaced frame picture NON-4MV MBMODE VLC tables (p. 363) */
const uint8_t ff_vc1_intfr_non4mv_mbmode_codes[4][9] = {
{ 9, 22, 0, 17, 16, 10, 1, 3, 23},
{ 7, 0, 5, 2, 1, 1, 6, 3, 4},
{ 1, 0, 10, 23, 44, 8, 3, 9, 45},
{ 7, 97, 1, 2, 49, 13, 25, 0, 96}
};
const uint8_t ff_vc1_intfr_non4mv_mbmode_bits[4][9] = {
{ 4, 5, 2, 5, 5, 4, 2, 2, 5},
{ 3, 4, 6, 2, 3, 2, 3, 5, 6},
{ 2, 2, 4, 5, 6, 4, 2, 4, 6},
{ 4, 8, 1, 3, 7, 5, 6, 2, 8}
};
/* Interlaced field picture MBMODE VLC tables (p. 356 - 11.4.1, 11.4.2) */
/* mixed-MV */
const uint8_t ff_vc1_if_mmv_mbmode_codes[8][8] = {
{ 16, 17, 3, 3, 0, 5, 9, 2 },
{ 8, 9, 3, 6, 7, 0, 5, 2 },
{ 16, 17, 5, 3, 0, 3, 9, 2 },
{ 56, 57, 15, 4, 5, 6, 29, 0 },
{ 52, 53, 27, 14, 15, 2, 12, 0 },
{ 56, 57, 29, 5, 6, 0, 15, 4 },
{ 16, 17, 6, 7, 0, 1, 9, 5 },
{ 56, 57, 0, 5, 6, 29, 4, 15 }
};
const uint8_t ff_vc1_if_mmv_mbmode_bits[8][8] = {
{ 6, 6, 2, 3, 2, 4, 5, 2 },
{ 5, 5, 3, 3, 3, 2, 4, 2 },
{ 6, 6, 4, 3, 2, 2, 5, 2 },
{ 6, 6, 4, 3, 3, 3, 5, 1 },
{ 6, 6, 5, 4, 4, 2, 4, 1 },
{ 6, 6, 5, 3, 3, 1, 4, 3 },
{ 5, 5, 3, 3, 2, 2, 4, 3 },
{ 6, 6, 1, 3, 3, 5, 3, 4 }
};
/* 1MV */
const uint8_t ff_vc1_if_1mv_mbmode_codes[8][6] = {
{ 0, 1, 1, 1, 1, 1 },
{ 0, 1, 1, 1, 1, 1 },
{ 16, 17, 3, 0, 9, 5 },
{ 20, 21, 3, 11, 0, 4 },
{ 4, 5, 2, 3, 3, 0 },
{ 4, 5, 3, 2, 0, 3 },
{ 0, 1, 1, 1, 1, 1 },
{ 16, 17, 9, 5, 3, 0 }
};
const uint8_t ff_vc1_if_1mv_mbmode_bits[8][6] = {
{ 5, 5, 1, 3, 2, 4 },
{ 5, 5, 1, 2, 3, 4 },
{ 5, 5, 2, 1, 4, 3 },
{ 5, 5, 2, 4, 1, 3 },
{ 4, 4, 2, 3, 2, 2 },
{ 4, 4, 3, 2, 2, 2 },
{ 5, 5, 3, 4, 1, 2 },
{ 5, 5, 4, 3, 2, 1 }
};
/* Interlaced frame/field picture MVDATA VLC tables */
/* 1-reference tables */
const uint32_t ff_vc1_1ref_mvdata_codes[4][72] = { /* uint32_t may be too big */
{5, 12, 30, 18, 12, 52, 117, 112, 0, 8, 27, 8, 29, 124, 214, 478, 431, 5, 27, 38, 30, 18, 118, 77,
502, 500, 57, 127, 39, 106, 113, 53, 113, 104, 476, 39, 115, 255, 232, 233, 126, 505, 501, 509, 62, 458, 1017, 76,
105, 506, 479, 503, 112, 477, 3661, 1831, 914, 456, 459, 1016, 430, 504, 507, 58574, 58575, 29280, 29281, 29282, 29283, 29284, 29285, 29286},
{7, 1, 7, 22, 1, 69, 24, 694, 6, 4, 23, 16, 41, 44, 346, 102, 414, 9, 40, 23, 0, 42, 4, 91,
181, 206, 6, 68, 15, 70, 14, 172, 50, 55, 4587, 10, 26, 287, 22, 20, 43, 360, 85, 9173, 87, 47, 54, 46,
361, 84, 1147, 415, 11133, 142, 2782, 1145, 1390, 2292, 5567, 1144, 9172, 44529, 22265, 712462, 712463, 356224, 356225, 356226, 356227, 356228, 356229, 356230},
{2, 6, 7, 13, 7, 48, 255, 496, 2, 0, 5, 25, 30, 7, 99, 253, 35, 14, 27, 26, 6, 9, 24, 197,
51, 497, 2, 1019, 499, 34, 508, 66, 1571, 131, 1568, 125, 64, 67, 996, 997, 401, 4073, 261, 520, 252, 1572, 1570, 400,
1574, 2037, 3147, 8144, 4173, 101, 3138, 201, 1575, 3139, 3146, 4174, 8145, 4175, 1042, 66766, 66767, 33376, 33377, 33378, 33379, 33380, 33381, 33382},
{13, 1, 4, 0, 23, 5, 127, 77, 3, 17, 62, 59, 23, 103, 74, 195, 242, 10, 44, 50, 61, 21, 40, 147,
204, 150, 3, 117, 32, 45, 33, 41, 144, 464, 507, 28, 76, 96, 9, 8, 45, 159, 506, 317, 49, 252, 88, 146,
240, 241, 205, 389, 357, 78, 145, 233, 388, 465, 486, 151, 487, 179, 316, 5710, 5711, 2848, 2849, 2850, 2851, 2852, 2853, 2854}
};
const uint8_t ff_vc1_1ref_mvdata_bits[4][72] = {
{3, 4, 5, 5, 5, 6, 7, 7, 2, 4, 5, 5, 6, 7, 8, 9, 9, 4, 6, 6, 6, 6, 7, 8,
9, 9, 6, 8, 7, 7, 7, 7, 8, 8, 9, 6, 8, 8, 8, 8, 8, 9, 9, 9, 7, 10, 10, 8,
8, 9, 9, 9, 8, 9, 13, 12, 11, 10, 10, 10, 9, 9, 9, 17, 17, 16, 16, 16, 16, 16, 16, 16},
{3, 3, 4, 5, 5, 7, 8, 10, 3, 4, 5, 5, 6, 7, 9, 10, 12, 4, 6, 6, 5, 6, 6, 8,
9, 11, 4, 7, 7, 7, 7, 8, 9, 9, 13, 5, 8, 9, 8, 8, 9, 10, 10, 14, 7, 9, 9, 9,
10, 10, 11, 12, 14, 8, 12, 11, 11, 12, 13, 11, 14, 16, 15, 20, 20, 19, 19, 19, 19, 19, 19, 19},
{3, 4, 4, 4, 5, 6, 8, 9, 2, 4, 5, 5, 5, 6, 7, 8, 8, 4, 7, 7, 6, 6, 7, 8,
8, 9, 5, 10, 9, 8, 9, 9, 11, 10, 11, 7, 9, 9, 10, 10, 11, 12, 11, 12, 8, 11, 11, 11,
11, 11, 12, 13, 15, 9, 12, 10, 11, 12, 12, 15, 13, 15, 13, 19, 19, 18, 18, 18, 18, 18, 18, 18},
{4, 4, 4, 4, 5, 5, 7, 7, 3, 5, 6, 6, 6, 7, 7, 8, 8, 4, 6, 6, 6, 6, 7, 8,
8, 8, 4, 7, 6, 6, 6, 7, 8, 9, 9, 5, 7, 7, 6, 6, 7, 8, 9, 9, 6, 8, 8, 8,
8, 8, 8, 9, 10, 7, 8, 8, 9, 9, 9, 8, 9, 9, 9, 14, 14, 13, 13, 13, 13, 13, 13, 13}
};
/* 2-reference tables */
const uint32_t ff_vc1_2ref_mvdata_codes[8][126] = { /* table 132 - table 139 */
{12, 28, 11, 0, 14, 42, 80, 872, 2, 26, 4, 58, 29, 108,
239, 444, 351, 15, 3, 28, 13, 11, 62, 167, 326, 409, 6, 31,
4, 60, 7, 446, 139, 44, 1971, 5, 219, 86, 236, 82, 445, 120,
207, 1395, 9, 35, 237, 24, 6, 68, 245, 121, 1746, 110, 43, 349,
23, 895, 324, 206, 40, 171, 16, 437, 247, 166, 123, 40, 493, 489,
1789, 4, 245, 41, 650, 651, 655, 3577, 821, 7813, 238, 701, 43, 984,
977, 408, 489, 1309, 180, 63, 1109, 555, 553, 1105, 1400, 1970, 1392, 341,
50, 976, 84, 1747, 1393, 1108, 820, 7153, 183, 41, 7812, 364, 411, 7152,
1401, 3907, 181, 2209, 42, 365, 2208, 1952, 977, 2789, 340, 2788, 2617, 2616},
{3, 9, 22, 16, 215, 821, 1396, 1365, 0, 29, 9, 23, 44, 173,
884, 1715, 1399, 15, 24, 10, 46, 34, 380, 3707, 7049, 5592, 8, 52,
109, 35, 450, 886, 723, 7242, 13066, 20, 106, 114, 108, 227, 411, 1855,
7408, 2881, 50, 230, 224, 207, 171, 412, 683, 3627, 5593, 111, 451, 175,
191, 172, 381, 1763, 3625, 6532, 84, 181, 378, 429, 409, 376, 856, 722,
7243, 91, 680, 817, 904, 907, 880, 1811, 3267, 7409, 441, 1519, 1848, 754,
827, 697, 1771, 1392, 3620, 925, 1442, 1443, 3709, 1518, 1849, 1364, 2725, 2724,
887, 7413, 3022, 3705, 1632, 1652, 1770, 3708, 3429, 758, 5594, 7048, 1441, 7412,
1510, 3624, 1397, 3428, 820, 13067, 5595, 2880, 3023, 3525, 3626, 1653, 1393, 1363},
{4, 2, 16, 3, 23, 69, 62, 126, 3, 2, 40, 30, 21, 71,
2, 333, 96, 11, 38, 36, 20, 50, 111, 195, 1329, 1765, 21, 63,
45, 1, 318, 221, 246, 773, 817, 14, 3, 52, 51, 26, 330, 197,
244, 1764, 1, 60, 125, 141, 157, 49, 110, 662, 205, 37, 329, 50,
137, 54, 136, 111, 3, 797, 14, 426, 638, 97, 334, 335, 103, 255,
387, 54, 855, 245, 198, 194, 665, 281, 561, 848, 44, 399, 1328, 663,
4, 440, 192, 634, 785, 156, 1569, 409, 796, 247, 995, 854, 393, 5,
107, 2242, 816, 1279, 1264, 849, 1266, 498, 883, 0, 3137, 2243, 2540, 994,
772, 1271, 1265, 496, 328, 3136, 2541, 2240, 2241, 1267, 1278, 254, 499, 425},
{0, 4, 47, 82, 16, 173, 1291, 400, 3, 22, 7, 13, 187, 371,
201, 1295, 5932, 3, 17, 5, 67, 35, 75, 814, 11867, 1154, 9, 42,
20, 42, 264, 1482, 1626, 8502, 8498, 11, 19, 65, 184, 372, 256, 5338,
16462, 5175, 43, 133, 167, 160, 332, 666, 812, 8499, 5162, 81, 644, 172,
258, 69, 68, 2075, 1630, 3255, 24, 1292, 530, 740, 515, 148, 290, 2074,
1621, 51, 698, 582, 578, 2670, 1036, 2056, 8500, 16463, 373, 1029, 583, 298,
2580, 699, 401, 2127, 5176, 175, 2967, 1155, 5179, 811, 579, 5163, 2392, 10687,
73, 2668, 5339, 1197, 5342, 2126, 5172, 599, 11866, 519, 5173, 5177, 3254, 5178,
404, 1620, 8501, 21372, 348, 576, 4114, 21373, 2393, 4248, 5174, 1631, 8230, 8503},
{5, 25, 22, 17, 62, 94, 239, 226, 0, 57, 43, 38, 40, 18,
194, 237, 285, 13, 49, 42, 37, 32, 92, 493, 589, 1904, 6, 122,
96, 79, 72, 57, 390, 531, 3782, 15, 38, 95, 117, 112, 39, 475,
966, 1935, 63, 166, 240, 58, 82, 78, 227, 473, 783, 16, 477, 167,
247, 34, 146, 964, 751, 1890, 121, 143, 474, 135, 232, 186, 374, 238,
944, 133, 281, 782, 264, 466, 268, 1907, 1060, 1076, 113, 1501, 449, 935,
295, 141, 539, 1970, 479, 984, 1892, 3812, 947, 1869, 472, 1500, 2122, 1177,
965, 7566, 1893, 1077, 1905, 450, 280, 956, 897, 903, 31539, 4247, 4246, 7885,
3737, 3868, 3869, 3813, 284, 31538, 15768, 7567, 3736, 3943, 957, 896, 1176, 902},
{13, 16, 46, 57, 13, 116, 237, 182, 1, 2, 0, 48, 41, 112,
243, 140, 358, 9, 51, 120, 6, 196, 11, 355, 204, 1470, 31, 47,
100, 24, 198, 10, 354, 704, 3827, 7, 15, 227, 202, 178, 399, 942,
1887, 3153, 21, 71, 238, 226, 234, 9, 362, 707, 1437, 61, 8, 473,
50, 14, 366, 812, 1627, 6507, 2, 15, 472, 141, 180, 484, 103, 791,
1940, 34, 958, 789, 52, 55, 734, 108, 3838, 1644, 40, 971, 940, 53,
363, 957, 705, 1580, 7678, 14, 1438, 1471, 218, 1577, 1412, 3767, 2826, 1645,
12, 1918, 1436, 1912, 1886, 1882, 1581, 823, 820, 407, 7767, 7652, 6506, 7766,
3152, 2879, 7764, 2827, 398, 438, 7765, 3252, 2878, 3766, 7653, 7679, 821, 439},
{1, 11, 25, 111, 42, 117, 2027, 355, 1, 14, 26, 62, 28, 45,
356, 2028, 357, 4, 6, 54, 127, 174, 344, 348, 1389, 1037584, 0, 4,
123, 243, 59, 2029, 691, 716, 1390, 24, 62, 23, 30, 175, 1015, 1391,
717, 1037585, 20, 173, 170, 20, 168, 339, 232, 510, 3535, 120, 440, 338,
254, 689, 349, 352, 1037586, 1037587, 122, 688, 485, 233, 252, 1766, 3528, 1412,
1037588, 171, 3550, 345, 1012, 3529, 3530, 506, 1037589, 1037590, 252, 511, 484, 175,
346, 359, 3531, 1413, 1037591, 1015, 16213, 1037592, 3548, 1414, 16214, 1037593, 16215, 1037594,
442, 1415, 1416, 3551, 690, 1037595, 3534, 1014, 1037596, 4052, 1037597, 1037598, 1037599, 518784,
518785, 1388, 518786, 518787, 886, 1417, 1418, 518788, 518789, 3549, 518790, 518791, 1419, 32425},
{3, 14, 15, 126, 98, 198, 3289, 1598, 2, 2, 0, 24, 12, 105,
57, 1799, 3198, 2, 13, 27, 15, 410, 1607, 6711, 214724, 13421, 1, 30,
127, 10, 225, 1633, 3300, 214725, 214726, 29, 48, 13, 203, 409, 800, 142,
25902, 214727, 62, 57, 53, 51, 415, 448, 3290, 214728, 214729, 11, 208, 414,
34, 56, 398, 798, 12948, 572, 50, 18, 19, 113, 413, 32, 3207, 3264,
214730, 824, 1619, 418, 810, 802, 3303, 132, 287, 214731, 805, 1609, 811, 119,
1608, 1602, 3206, 3212, 214732, 58, 6583, 67, 807, 140, 141, 3213, 214733, 214734,
823, 3301, 133, 806, 839, 3236, 3199, 3354, 214735, 808, 107360, 107361, 3288, 1676,
12949, 12950, 25903, 26328, 817, 1798, 573, 118, 3265, 898, 3302, 26329, 26330, 26331}
};
const uint8_t ff_vc1_2ref_mvdata_bits[8][126] = {
{4, 5, 5, 5, 6, 7, 8, 10, 2, 5, 5, 6, 6, 7,
8, 9, 10, 4, 5, 6, 6, 7, 8, 9, 10, 11, 4, 6,
6, 7, 7, 9, 9, 10, 12, 5, 8, 8, 8, 8, 9, 9,
10, 12, 5, 7, 8, 7, 7, 8, 9, 9, 11, 7, 9, 10,
9, 10, 10, 10, 10, 12, 6, 9, 9, 9, 9, 9, 10, 10,
11, 7, 10, 10, 11, 11, 11, 12, 12, 14, 8, 11, 10, 11,
11, 11, 11, 12, 12, 8, 12, 11, 11, 12, 12, 12, 12, 13,
8, 12, 11, 11, 12, 12, 12, 13, 12, 9, 14, 13, 11, 13,
12, 13, 12, 13, 9, 13, 13, 12, 12, 13, 13, 13, 13, 13},
{3, 4, 5, 6, 8, 10, 11, 11, 2, 5, 5, 6, 7, 8,
10, 11, 11, 4, 5, 5, 6, 7, 9, 12, 13, 13, 4, 6,
7, 7, 9, 10, 11, 13, 14, 5, 7, 7, 7, 8, 9, 11,
13, 13, 6, 8, 8, 8, 8, 9, 10, 12, 13, 7, 9, 8,
8, 8, 9, 11, 12, 13, 7, 9, 9, 9, 9, 9, 10, 11,
13, 8, 10, 10, 10, 10, 10, 11, 12, 13, 9, 11, 11, 10,
10, 10, 11, 11, 12, 10, 12, 12, 12, 11, 11, 11, 12, 12,
10, 13, 12, 12, 11, 11, 11, 12, 12, 10, 13, 13, 12, 13,
11, 12, 11, 12, 10, 14, 13, 13, 12, 12, 12, 11, 11, 11},
{4, 4, 5, 5, 6, 7, 8, 9, 2, 5, 6, 6, 6, 7,
7, 9, 9, 4, 6, 6, 6, 7, 8, 9, 11, 12, 5, 7,
7, 7, 9, 9, 10, 11, 12, 5, 7, 7, 7, 7, 9, 9,
10, 12, 5, 8, 8, 8, 8, 8, 9, 10, 10, 6, 9, 8,
8, 8, 8, 9, 9, 11, 6, 10, 10, 9, 9, 9, 9, 10,
10, 7, 11, 10, 9, 9, 10, 9, 10, 11, 7, 10, 11, 10,
10, 10, 9, 10, 11, 8, 12, 11, 11, 10, 11, 11, 10, 10,
8, 12, 12, 11, 11, 11, 11, 10, 11, 8, 13, 12, 12, 11,
11, 11, 11, 10, 9, 13, 12, 12, 12, 11, 11, 10, 10, 10},
{3, 4, 6, 7, 7, 9, 11, 11, 2, 5, 5, 6, 8, 9,
10, 11, 13, 3, 5, 5, 7, 8, 9, 12, 14, 13, 4, 6,
6, 7, 9, 11, 13, 14, 14, 5, 7, 7, 8, 9, 9, 13,
15, 13, 6, 8, 8, 8, 9, 10, 12, 14, 13, 7, 10, 9,
9, 9, 9, 12, 13, 14, 7, 11, 10, 10, 10, 10, 11, 12,
13, 8, 11, 12, 12, 12, 11, 12, 14, 15, 9, 11, 12, 11,
12, 11, 11, 12, 13, 9, 12, 13, 13, 12, 12, 13, 14, 14,
9, 12, 13, 13, 13, 12, 13, 12, 14, 10, 13, 13, 14, 13,
11, 13, 14, 15, 10, 12, 13, 15, 14, 13, 13, 13, 14, 14},
{4, 5, 5, 5, 6, 7, 8, 8, 2, 6, 6, 6, 6, 6,
8, 9, 10, 4, 6, 6, 6, 6, 7, 9, 10, 11, 4, 7,
7, 7, 7, 7, 9, 10, 12, 5, 7, 7, 7, 7, 7, 9,
10, 11, 6, 8, 8, 7, 7, 7, 8, 9, 10, 6, 9, 8,
8, 7, 8, 10, 10, 11, 7, 9, 9, 8, 8, 8, 9, 9,
10, 8, 10, 10, 9, 9, 9, 11, 11, 11, 8, 11, 10, 10,
9, 9, 10, 11, 10, 10, 12, 12, 11, 11, 10, 11, 12, 11,
10, 13, 12, 11, 11, 10, 10, 11, 11, 11, 15, 13, 13, 13,
12, 12, 12, 12, 10, 15, 14, 13, 12, 12, 11, 11, 11, 11},
{4, 5, 6, 6, 6, 7, 8, 8, 2, 4, 5, 6, 6, 7,
8, 8, 9, 4, 6, 7, 7, 8, 8, 9, 10, 11, 5, 6,
7, 7, 8, 8, 9, 10, 12, 5, 7, 8, 8, 8, 9, 10,
11, 12, 5, 7, 8, 8, 8, 8, 9, 10, 11, 6, 8, 9,
8, 8, 9, 10, 11, 13, 5, 8, 9, 8, 8, 9, 9, 10,
11, 6, 10, 10, 9, 9, 10, 10, 12, 13, 6, 10, 10, 9,
9, 10, 10, 11, 13, 7, 11, 11, 11, 11, 11, 12, 12, 13,
7, 11, 11, 11, 11, 11, 11, 12, 12, 9, 13, 13, 13, 13,
12, 12, 13, 12, 9, 12, 13, 12, 12, 12, 13, 13, 12, 12},
{3, 5, 6, 8, 9, 10, 12, 12, 1, 5, 6, 7, 8, 9,
12, 12, 12, 4, 6, 7, 8, 9, 12, 12, 14, 21, 4, 6,
8, 9, 9, 12, 13, 13, 14, 6, 9, 8, 8, 9, 13, 14,
13, 21, 6, 9, 9, 8, 9, 10, 11, 12, 13, 8, 10, 10,
11, 11, 12, 12, 21, 21, 8, 11, 10, 11, 11, 12, 13, 14,
21, 9, 13, 10, 11, 13, 13, 12, 21, 21, 9, 12, 10, 11,
12, 12, 13, 14, 21, 11, 15, 21, 13, 14, 15, 21, 15, 21,
10, 14, 14, 13, 13, 21, 13, 13, 21, 13, 21, 21, 21, 20,
20, 14, 20, 20, 11, 14, 14, 20, 20, 13, 20, 20, 14, 16},
{2, 5, 6, 8, 9, 10, 13, 13, 2, 4, 5, 6, 8, 9,
10, 13, 14, 3, 5, 7, 8, 10, 12, 15, 20, 16, 4, 6,
8, 8, 10, 12, 13, 20, 20, 7, 8, 8, 9, 10, 11, 12,
16, 20, 7, 8, 8, 8, 10, 11, 13, 20, 20, 8, 10, 10,
10, 10, 11, 12, 15, 14, 8, 9, 9, 9, 10, 10, 13, 13,
20, 11, 12, 11, 11, 11, 13, 12, 13, 20, 11, 12, 11, 11,
12, 12, 13, 13, 20, 10, 14, 11, 11, 12, 12, 13, 20, 20,
11, 13, 12, 11, 12, 13, 14, 14, 20, 11, 19, 19, 13, 13,
15, 15, 16, 16, 11, 13, 14, 11, 13, 12, 13, 16, 16, 16}
};
const uint8_t wmv3_dc_scale_table[32]={
0, 2, 4, 8, 8, 8, 9, 9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21
};
/* P-Picture CBPCY VLC tables */
2011-04-29 20:40:16 +03:00
// Looks like original tables are not conforming to standard at all. Are they used for old WMV?
const uint16_t ff_vc1_cbpcy_p_codes[4][64] = {
{
0, 6, 15, 13, 13, 11, 3, 13, 5, 8, 49, 10, 12, 114, 102, 119,
1, 54, 96, 8, 10, 111, 5, 15, 12, 10, 2, 12, 13, 115, 53, 63,
1, 7, 1, 7, 14, 12, 4, 14, 1, 9, 97, 11, 7, 58, 52, 62,
4, 103, 1, 9, 11, 56, 101, 118, 4, 110, 100, 30, 2, 5, 4, 3
},
{
0, 9, 1, 18, 5, 14, 237, 26, 3, 121, 3, 22, 13, 16, 6, 30,
2, 10, 1, 20, 12, 241, 5, 28, 16, 12, 3, 24, 28, 124, 239, 247,
1, 240, 1, 19, 18, 15, 4, 27, 1, 122, 2, 23, 1, 17, 7, 31,
1, 11, 2, 21, 19, 246, 238, 29, 17, 13, 236, 25, 58, 63, 8, 125
},
{
0, 201, 25, 231, 5, 221, 1, 3, 2, 414, 2, 241, 16, 225, 195, 492,
2, 412, 1, 240, 7, 224, 98, 245, 1, 220, 96, 5, 9, 230, 101, 247,
1, 102, 1, 415, 24, 3, 2, 244, 3, 54, 3, 484, 17, 114, 200, 493,
3, 413, 1, 4, 13, 113, 99, 485, 4, 111, 194, 243, 5, 29, 26, 31
},
{
0, 28, 12, 44, 3, 36, 20, 52, 2, 32, 16, 48, 8, 40, 24, 28,
1, 30, 14, 46, 6, 38, 22, 54, 3, 34, 18, 50, 10, 42, 26, 30,
1, 29, 13, 45, 5, 37, 21, 53, 2, 33, 17, 49, 9, 41, 25, 29,
1, 31, 15, 47, 7, 39, 23, 55, 4, 35, 19, 51, 11, 43, 27, 31
}
};
const uint8_t ff_vc1_cbpcy_p_bits[4][64] = {
{
13, 13, 7, 13, 7, 13, 13, 12, 6, 13, 7, 12, 6, 8, 8, 8,
5, 7, 8, 12, 6, 8, 13, 12, 7, 13, 13, 12, 6, 8, 7, 7,
6, 13, 8, 12, 7, 13, 13, 12, 7, 13, 8, 12, 5, 7, 7, 7,
6, 8, 13, 12, 6, 7, 8, 8, 5, 8, 8, 6, 3, 3, 3, 2
},
{
14, 13, 8, 13, 3, 13, 8, 13, 3, 7, 8, 13, 4, 13, 13, 13,
3, 13, 13, 13, 4, 8, 13, 13, 5, 13, 13, 13, 5, 7, 8, 8,
3, 8, 14, 13, 5, 13, 13, 13, 4, 7, 13, 13, 6, 13, 13, 13,
5, 13, 8, 13, 5, 8, 8, 13, 5, 13, 8, 13, 6, 6, 13, 7
},
{
13, 8, 6, 8, 4, 8, 13, 12, 4, 9, 8, 8, 5, 8, 8, 9,
5, 9, 10, 8, 4, 8, 7, 8, 6, 8, 7, 13, 4, 8, 7, 8,
5, 7, 8, 9, 6, 13, 13, 8, 4, 6, 8, 9, 5, 7, 8, 9,
5, 9, 9, 13, 5, 7, 7, 9, 4, 7, 8, 8, 3, 5, 5, 5
},
{
9, 9, 9, 9, 2, 9, 9, 9, 2, 9, 9, 9, 9, 9, 9, 8,
3, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8,
2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8
}
};
/* Interlaced CBPCY VLC tables (Table 124 - Table 131) */
const uint16_t ff_vc1_icbpcy_p_codes[8][63] = {
{
12058, 12059, 6028, 144, 680, 681, 3015, 145, 682, 683, 1504, 74, 150,
151, 189, 146, 684, 685, 1505, 152, 306, 307, 377, 308, 618, 619, 764,
78, 64, 65, 43, 147, 686, 687, 1506, 310, 622, 623, 765, 158, 318,
319, 383, 80, 66, 67, 44, 81, 164, 165, 190, 83, 68, 69, 45,
84, 70, 71, 46, 3, 0, 1, 1
}, {
65, 66, 256, 67, 136, 137, 257, 69, 140, 141, 258, 16, 34,
35, 36, 71, 16, 17, 259, 37, 88, 89, 90, 91, 90, 91, 92,
12, 48, 49, 25, 9, 20, 21, 44, 92, 93, 94, 95, 38, 93,
94, 95, 13, 52, 53, 27, 20, 39, 42, 43, 14, 56, 57, 29,
15, 60, 61, 31, 5, 9, 0, 3
}, {
50, 51, 26, 38, 228, 229, 486, 39, 230, 231, 487, 14, 99,
108, 119, 40, 232, 233, 488, 123, 218, 219, 236, 245, 440, 441, 474,
33, 75, 84, 43, 41, 234, 235, 489, 74, 442, 443, 475, 32, 222,
223, 242, 34, 85, 88, 45, 15, 112, 113, 120, 35, 89, 92, 47,
36, 93, 98, 48, 2, 31, 6, 0
}, {
40, 41, 157, 0, 490, 491, 492, 1, 493, 494, 495, 5, 240,
241, 59, 2, 496, 497, 498, 63, 348, 349, 153, 16, 976, 977, 304,
15, 158, 159, 251, 3, 499, 500, 501, 17, 978, 979, 305, 9, 350,
351, 156, 16, 168, 169, 56, 6, 242, 243, 77, 17, 170, 171, 57,
18, 172, 173, 58, 6, 22, 23, 14
}, {
60, 61, 31, 10, 97, 98, 2, 11, 99, 100, 3, 7, 3,
4, 11, 12, 101, 102, 4, 18, 10, 11, 20, 27, 24, 25, 52,
44, 103, 104, 53, 13, 105, 108, 5, 96, 26, 27, 53, 19, 14,
15, 21, 45, 109, 110, 56, 8, 8, 9, 12, 46, 111, 114, 58,
47, 115, 0, 59, 7, 20, 21, 4
}, {
56, 57, 157, 10, 145, 146, 147, 11, 148, 149, 150, 3, 238,
239, 54, 12, 151, 152, 153, 8, 484, 485, 106, 24, 972, 973, 214,
14, 158, 159, 245, 13, 154, 155, 156, 25, 974, 975, 215, 9, 488,
489, 144, 15, 232, 233, 246, 5, 240, 241, 55, 16, 234, 235, 247,
17, 236, 237, 52, 0, 62, 63, 2
}, {
60, 61, 463, 0, 191, 224, 508, 1, 225, 226, 509, 9, 497,
498, 499, 2, 227, 228, 510, 17, 1006, 1007, 1008, 33, 2018, 2019, 2020,
24, 1015, 1022, 1023, 3, 229, 230, 128, 46, 2021, 2022, 2023, 22, 1012,
1013, 1014, 25, 258, 259, 260, 10, 500, 501, 502, 26, 261, 262, 263,
27, 376, 377, 462, 29, 189, 190, 496
}, {
3, 4, 438, 4, 46, 47, 14, 5, 48, 49, 15, 3, 10,
11, 20, 6, 50, 51, 16, 5, 48, 49, 50, 9, 102, 103, 104,
29, 439, 440, 441, 7, 52, 53, 17, 22, 105, 106, 107, 10, 54,
55, 216, 30, 442, 443, 444, 4, 21, 22, 23, 31, 445, 446, 447,
0, 16, 17, 18, 28, 217, 218, 19
}
};
const uint8_t ff_vc1_icbpcy_p_bits[8][63] = {
{
15, 15, 14, 9, 11, 11, 13, 9, 11, 11, 12, 8, 9,
9, 9, 9, 11, 11, 12, 9, 10, 10, 10, 10, 11, 11, 11,
8, 8, 8, 7, 9, 11, 11, 12, 10, 11, 11, 11, 9, 10,
10, 10, 8, 8, 8, 7, 8, 9, 9, 9, 8, 8, 8, 7,
8, 8, 8, 7, 3, 3, 3, 1
}, {
7, 7, 9, 7, 8, 8, 9, 7, 8, 8, 9, 6, 7,
7, 7, 7, 7, 7, 9, 7, 8, 8, 8, 8, 9, 9, 9,
6, 7, 7, 6, 6, 7, 7, 8, 8, 9, 9, 9, 7, 8,
8, 8, 6, 7, 7, 6, 6, 7, 7, 7, 6, 7, 7, 6,
6, 7, 7, 6, 3, 4, 3, 2
}, {
6, 6, 5, 6, 8, 8, 9, 6, 8, 8, 9, 5, 7,
7, 7, 6, 8, 8, 9, 7, 8, 8, 8, 8, 9, 9, 9,
6, 7, 7, 6, 6, 8, 8, 9, 7, 9, 9, 9, 6, 8,
8, 8, 6, 7, 7, 6, 5, 7, 7, 7, 6, 7, 7, 6,
6, 7, 7, 6, 3, 5, 4, 2
}, {
6, 6, 8, 4, 9, 9, 9, 4, 9, 9, 9, 4, 8,
8, 7, 4, 9, 9, 9, 6, 9, 9, 8, 6, 10, 10, 9,
5, 8, 8, 8, 4, 9, 9, 9, 6, 10, 10, 9, 5, 9,
9, 8, 5, 8, 8, 7, 4, 8, 8, 7, 5, 8, 8, 7,
5, 8, 8, 7, 3, 5, 5, 4
}, {
6, 6, 5, 5, 7, 7, 7, 5, 7, 7, 7, 5, 6,
6, 6, 5, 7, 7, 7, 6, 7, 7, 7, 7, 8, 8, 8,
6, 7, 7, 6, 5, 7, 7, 7, 7, 8, 8, 8, 6, 7,
7, 7, 6, 7, 7, 6, 5, 6, 6, 6, 6, 7, 7, 6,
6, 7, 6, 6, 4, 5, 5, 3
}, {
6, 6, 8, 4, 8, 8, 8, 4, 8, 8, 8, 4, 8,
8, 7, 4, 8, 8, 8, 5, 9, 9, 8, 6, 10, 10, 9,
5, 8, 8, 8, 4, 8, 8, 8, 6, 10, 10, 9, 5, 9,
9, 8, 5, 8, 8, 8, 4, 8, 8, 7, 5, 8, 8, 8,
5, 8, 8, 7, 3, 6, 6, 4
}, {
6, 6, 9, 3, 8, 8, 9, 3, 8, 8, 9, 4, 9,
9, 9, 3, 8, 8, 9, 5, 10, 10, 10, 6, 11, 11, 11,
5, 10, 10, 10, 3, 8, 8, 8, 6, 11, 11, 11, 5, 10,
10, 10, 5, 9, 9, 9, 4, 9, 9, 9, 5, 9, 9, 9,
5, 9, 9, 9, 5, 8, 8, 9
}, {
6, 6, 10, 3, 7, 7, 7, 3, 7, 7, 7, 4, 8,
8, 8, 3, 7, 7, 7, 5, 9, 9, 9, 6, 10, 10, 10,
6, 10, 10, 10, 3, 7, 7, 7, 6, 10, 10, 10, 5, 9,
9, 9, 6, 10, 10, 10, 4, 8, 8, 8, 6, 10, 10, 10,
5, 9, 9, 9, 6, 9, 9, 9
}
};
/* MacroBlock Transform Type: 7.1.3.11, p89
* 8x8:B
* 8x4:B:btm 8x4:B:top 8x4:B:both,
* 4x8:B:right 4x8:B:left 4x8:B:both
* 4x4:B 8x8:MB
* 8x4:MB:btm 8x4:MB:top 8x4,MB,both
* 4x8,MB,right 4x8,MB,left
* 4x4,MB */
const uint16_t ff_vc1_ttmb_codes[3][16] = {
{
0x0003,
0x002E, 0x005F, 0x0000,
0x0016, 0x0015, 0x0001,
0x0004, 0x0014,
0x02F1, 0x0179, 0x017B,
0x0BC0, 0x0BC1, 0x05E1,
0x017A
},
{
0x0006,
0x0006, 0x0003, 0x0007,
0x000F, 0x000E, 0x0000,
0x0002, 0x0002,
0x0014, 0x0011, 0x000B,
0x0009, 0x0021, 0x0015,
0x0020
},
{
0x0006,
0x0000, 0x000E, 0x0005,
0x0002, 0x0003, 0x0003,
0x000F, 0x0002,
0x0081, 0x0021, 0x0009,
0x0101, 0x0041, 0x0011,
0x0100
}
};
const uint8_t ff_vc1_ttmb_bits[3][16] = {
{
2,
6, 7, 2,
5, 5, 2,
3, 5,
10, 9, 9,
12, 12, 11,
9
},
{
3,
4, 4, 4,
4, 4, 3,
3, 2,
7, 7, 6,
6, 8, 7,
8
},
{
3,
3, 4, 5,
3, 3, 4,
4, 2,
10, 8, 6,
11, 9, 7,
11
}
};
/* TTBLK (Transform Type per Block) tables */
const uint8_t ff_vc1_ttblk_codes[3][8] = {
{ 0, 1, 3, 5, 16, 17, 18, 19},
{ 3, 0, 1, 2, 3, 5, 8, 9},
{ 1, 0, 1, 4, 6, 7, 10, 11}
};
const uint8_t ff_vc1_ttblk_bits[3][8] = {
{ 2, 2, 2, 3, 5, 5, 5, 5},
{ 2, 3, 3, 3, 3, 3, 4, 4},
{ 2, 3, 3, 3, 3, 3, 4, 4}
};
/* SUBBLKPAT tables, p93-94, reordered */
const uint8_t ff_vc1_subblkpat_codes[3][15] = {
{ 14, 12, 7, 11, 9, 26, 2, 10, 27, 8, 0, 6, 1, 15, 1},
{ 14, 0, 8, 15, 10, 4, 23, 13, 5, 9, 25, 3, 24, 22, 1},
{ 5, 6, 2, 2, 8, 0, 28, 3, 1, 3, 29, 1, 19, 18, 15}
};
const uint8_t ff_vc1_subblkpat_bits[3][15] = {
{ 5, 5, 5, 5, 5, 6, 4, 5, 6, 5, 4, 5, 4, 5, 1},
{ 4, 3, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 2},
{ 3, 3, 4, 3, 4, 5, 5, 3, 5, 4, 5, 4, 5, 5, 4}
};
/* MV differential tables, p265 */
const uint16_t ff_vc1_mv_diff_codes[4][73] = {
{
0, 2, 3, 8, 576, 3, 2, 6,
5, 577, 578, 7, 8, 9, 40, 19,
37, 82, 21, 22, 23, 579, 580, 166,
96, 167, 49, 194, 195, 581, 582, 583,
292, 293, 294, 13, 2, 7, 24, 50,
102, 295, 13, 7, 8, 18, 50, 103,
38, 20, 21, 22, 39, 204, 103, 23,
24, 25, 104, 410, 105, 106, 107, 108,
109, 220, 411, 442, 222, 443, 446, 447,
7 /* 73 elements */
},
{
0, 4, 5, 3, 4, 3, 4, 5,
20, 6, 21, 44, 45, 46, 3008, 95,
112, 113, 57, 3009, 3010, 116, 117, 3011,
118, 3012, 3013, 3014, 3015, 3016, 3017, 3018,
3019, 3020, 3021, 3022, 1, 4, 15, 160,
161, 41, 6, 11, 42, 162, 43, 119,
56, 57, 58, 163, 236, 237, 3023, 119,
120, 242, 122, 486, 1512, 487, 246, 494,
1513, 495, 1514, 1515, 1516, 1517, 1518, 1519,
31 /* 73 elements */
},
{
0, 512, 513, 514, 515, 2, 3, 258,
259, 260, 261, 262, 263, 264, 265, 266,
267, 268, 269, 270, 271, 272, 273, 274,
275, 276, 277, 278, 279, 280, 281, 282,
283, 284, 285, 286, 1, 5, 287, 288,
289, 290, 6, 7, 291, 292, 293, 294,
295, 296, 297, 298, 299, 300, 301, 302,
303, 304, 305, 306, 307, 308, 309, 310,
311, 312, 313, 314, 315, 316, 317, 318,
319 /* 73 elements */
},
{
0, 1, 1, 2, 3, 4, 1, 5,
4, 3, 5, 8, 6, 9, 10, 11,
12, 7, 104, 14, 105, 4, 10, 15,
11, 6, 14, 8, 106, 107, 108, 15,
109, 9, 55, 10, 1, 2, 1, 2,
3, 12, 6, 2, 6, 7, 28, 7,
15, 8, 5, 18, 29, 152, 77, 24,
25, 26, 39, 108, 13, 109, 55, 56,
57, 116, 11, 153, 234, 235, 118, 119,
15 /* 73 elements */
}
};
const uint8_t ff_vc1_mv_diff_bits[4][73] = {
{
6, 7, 7, 8, 14, 6, 5, 6, 7, 14, 14, 6, 6, 6, 8, 9,
10, 9, 7, 7, 7, 14, 14, 10, 9, 10, 8, 10, 10, 14, 14, 14,
13, 13, 13, 6, 3, 5, 6, 8, 9, 13, 5, 4, 4, 5, 7, 9,
6, 5, 5, 5, 6, 9, 8, 5, 5, 5, 7, 10, 7, 7, 7, 7,
7, 8, 10, 9, 8, 9, 9, 9, 3 /* 73 elements */
},
{
5, 7, 7, 6, 6, 5, 5, 6, 7, 5, 7, 8, 8, 8, 14, 9,
9, 9, 8, 14, 14, 9, 9, 14, 9, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 2, 3, 6, 8, 8, 6, 3, 4, 6, 8, 6, 9,
6, 6, 6, 8, 8, 8, 14, 7, 7, 8, 7, 9, 13, 9, 8, 9,
13, 9, 13, 13, 13, 13, 13, 13, 5 /* 73 elements */
},
{
3, 12, 12, 12, 12, 3, 4, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 1, 5, 11, 11, 11, 11, 4, 4, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11 /* 73 elements */
},
{
15, 11, 15, 15, 15, 15, 12, 15, 12, 11, 12, 12, 15, 12, 12, 12,
12, 15, 15, 12, 15, 10, 11, 12, 11, 10, 11, 10, 15, 15, 15, 11,
15, 10, 14, 10, 4, 4, 5, 7, 8, 9, 5, 3, 4, 5, 6, 8,
5, 4, 3, 5, 6, 8, 7, 5, 5, 5, 6, 7, 9, 7, 6, 6,
6, 7, 10, 8, 8, 8, 7, 7, 4 /* 73 elements */
}
};
/* DC differentials low+hi-mo, p217 are the same as in msmpeg4data .h */
/* Table 232 */
const int8_t ff_vc1_simple_progressive_4x4_zz [16] =
{
0, 8, 16, 1,
9, 24, 17, 2,
10, 18, 25, 3,
11, 26, 19, 27
};
const int8_t ff_vc1_adv_progressive_8x4_zz [32] = /* Table 233 */
{
0, 8, 1, 16, 2, 9, 10, 3,
24, 17, 4, 11, 18, 12, 5, 19,
25, 13, 20, 26, 27, 6, 21, 28,
14, 22, 29, 7, 30, 15, 23, 31
};
const int8_t ff_vc1_adv_progressive_4x8_zz [32] = /* Table 234 */
{
0, 1, 8, 2,
9, 16, 17, 24,
10, 32, 25, 18,
40, 3, 33, 26,
48, 11, 56, 41,
34, 49, 57, 42,
19, 50, 27, 58,
35, 43, 51, 59
};
const int8_t ff_vc1_adv_interlaced_8x8_zz [64] = /* Table 235 */
{
0, 8, 1, 16, 24, 9, 2, 32,
40, 48, 56, 17, 10, 3, 25, 18,
11, 4, 33, 41, 49, 57, 26, 34,
42, 50, 58, 19, 12, 5, 27, 20,
13, 6, 35, 28, 21, 14, 7, 15,
22, 29, 36, 43, 51, 59, 60, 52,
44, 37, 30, 23, 31, 38, 45, 53,
61, 62, 54, 46, 39, 47, 55, 63
};
const int8_t ff_vc1_adv_interlaced_8x4_zz [32] = /* Table 236 */
{
0, 8, 16, 24, 1, 9, 2, 17,
25, 10, 3, 18, 26, 4, 11, 19,
12, 5, 13, 20, 27, 6, 21, 28,
14, 22, 29, 7, 30, 15, 23, 31
};
const int8_t ff_vc1_adv_interlaced_4x8_zz [32] = /* Table 237 */
{
0, 1, 2, 8,
16, 9, 24, 17,
10, 3, 32, 40,
48, 56, 25, 18,
33, 26, 41, 34,
49, 57, 11, 42,
19, 50, 27, 58,
35, 43, 51, 59
};
const int8_t ff_vc1_adv_interlaced_4x4_zz [16] = /* Table 238 */
{
0, 8, 16, 24,
1, 9, 17, 2,
25, 10, 18, 3,
26, 11, 19, 27
};
/* DQScale as specified in 8.1.3.9 - almost identical to 0x40000/i */
const int32_t ff_vc1_dqscale[63] = {
0x40000, 0x20000, 0x15555, 0x10000, 0xCCCD, 0xAAAB, 0x9249, 0x8000,
0x71C7, 0x6666, 0x5D17, 0x5555, 0x4EC5, 0x4925, 0x4444, 0x4000,
0x3C3C, 0x38E4, 0x35E5, 0x3333, 0x30C3, 0x2E8C, 0x2C86, 0x2AAB,
0x28F6, 0x2762, 0x25ED, 0x2492, 0x234F, 0x2222, 0x2108, 0x2000,
0x1F08, 0x1E1E, 0x1D42, 0x1C72, 0x1BAD, 0x1AF3, 0x1A42, 0x199A,
0x18FA, 0x1862, 0x17D0, 0x1746, 0x16C1, 0x1643, 0x15CA, 0x1555,
0x14E6, 0x147B, 0x1414, 0x13B1, 0x1352, 0x12F7, 0x129E, 0x1249,
0x11F7, 0x11A8, 0x115B, 0x1111, 0x10C9, 0x1084, 0x1000
};
/* P Interlaced field picture MV predictor scaling values (Table 114) */
const uint16_t vc1_field_mvpred_scales[2][7][4] = {
// Refdist 0 1 2 3 or greater
{ // current field is first
{ 128, 192, 213, 224}, // SCALEOPP
{ 512, 341, 307, 293}, // SCALESAME1
{ 219, 236, 242, 245}, // SCALESAME2
{ 32, 48, 53, 56}, // SCALEZONE1_X
{ 8, 12, 13, 14}, // SCALEZONE1_Y
{ 37, 20, 14, 11}, // ZONE1OFFSET_X
{ 10, 5, 4, 3} // ZONE1OFFSET_Y
},
{ // current field is second
{ 128, 64, 43, 32}, // SCALEOPP
{ 512, 1024, 1536, 2048}, // SCALESAME1
{ 219, 204, 200, 198}, // SCALESAME2
{ 32, 16, 11, 8}, // SCALEZONE1_X
{ 8, 4, 3, 2}, // SCALEZONE1_Y
{ 37, 52, 56, 58}, // ZONE1OFFSET_X
{ 10, 13, 14, 15} // ZONE1OFFSET_Y
}
};
/* B Interlaced field picture backward MV predictor scaling values for first field (Table 115) */
const uint16_t vc1_b_field_mvpred_scales[7][4] = {
// BRFD 0 1 2 3 or greater
{ 171, 205, 219, 228}, // SCALESAME
{ 384, 320, 299, 288}, // SCALEOPP1
{ 230, 239, 244, 246}, // SCALEOPP2
{ 43, 51, 55, 57}, // SCALEZONE1_X
{ 11, 13, 14, 14}, // SCALEZONE1_Y
{ 26, 17, 12, 10}, // ZONE1OFFSET_X
{ 7, 4, 3, 3} // ZONE1OFFSET_Y
};