⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vc1data.c

📁 mediastreamer2是开源的网络传输媒体流的库
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * VC-1 and WMV3 decoder * copyright (c) 2006 Konstantin Shishkov * (c) 2005 anonymous, Alex Beregszaszi, Michael Niedermayer * * This file is part of FFmpeg. * * FFmpeg 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. * * FFmpeg 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 FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *//** * @file vc1data.c * 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 }};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 7VLC ff_vc1_bfraction_vlc;#define VC1_IMODE_VLC_BITS 4VLC ff_vc1_imode_vlc;#define VC1_NORM2_VLC_BITS 3VLC ff_vc1_norm2_vlc;#define VC1_NORM6_VLC_BITS 9VLC ff_vc1_norm6_vlc;/* Could be optimized, one table only needs 8 bits */#define VC1_TTMB_VLC_BITS 9 //12VLC ff_vc1_ttmb_vlc[3];#define VC1_MV_DIFF_VLC_BITS 9 //15VLC ff_vc1_mv_diff_vlc[4];#define VC1_CBPCY_P_VLC_BITS 9 //14VLC ff_vc1_cbpcy_p_vlc[4];#define VC1_4MV_BLOCK_PATTERN_VLC_BITS 6VLC ff_vc1_4mv_block_pattern_vlc[4];#define VC1_TTBLK_VLC_BITS 5VLC ff_vc1_ttblk_vlc[3];#define VC1_SUBBLKPAT_VLC_BITS 6VLC ff_vc1_subblkpat_vlc[3];VLC ff_vc1_ac_coeff_table[8];//@}#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*/};#endifconst 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.264const 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,};/* Normal-6 imode */const uint8_t ff_vc1_norm6_spec[64][5] = {{ 0,  1, 1        },{ 1,  2, 4        },{ 2,  3, 4        },{ 3,  0, 8        },{ 4,  4, 4        },{ 5,  1, 8        },{ 6,  2, 8        },{ 7,  2, 5,  7, 5 },{ 8,  5, 4        },{ 9,  3, 8        },{10,  4, 8        },{11,  2, 5, 11, 5 },{12,  5, 8        },{13,  2, 5, 13, 5 },{14,  2, 5, 14, 5 },{15,  3, 5, 14, 8 },{16,  6, 4        },{17,  6, 8        },{18,  7, 8        },{19,  2, 5, 19, 5 },{20,  8, 8        },{21,  2, 5, 21, 5 },{22,  2, 5, 22, 5 },{23,  3, 5, 13, 8 },{24,  9, 8        },{25,  2, 5, 25, 5 },{26,  2, 5, 26, 5 },{27,  3, 5, 12, 8 },{28,  2, 5, 28, 5 },{29,  3, 5, 11, 8 },{30,  3, 5, 10, 8 },{31,  3, 5,  7, 4 },{32,  7, 4        },{33, 10, 8        },{34, 11, 8        },{35,  2, 5,  3, 5 },{36, 12, 8        },{37,  2, 5,  5, 5 },{38,  2, 5,  6, 5 },{39,  3, 5,  9, 8 },{40, 13, 8        },{41,  2, 5,  9, 5 },{42,  2, 5, 10, 5 },{43,  3, 5,  8, 8 },{44,  2, 5, 12, 5 },{45,  3, 5,  7, 8 },{46,  3, 5,  6, 8 },{47,  3, 5,  6, 4 },{48, 14, 8        },{49,  2, 5, 17, 5 },{50,  2, 5, 18, 5 },{51,  3, 5,  5, 8 },{52,  2, 5, 20, 5 },{53,  3, 5,  4, 8 },{54,  3, 5,  3, 8 },{55,  3, 5,  5, 4 },{56,  2, 5, 24, 5 },{57,  3, 5,  2, 8 },{58,  3, 5,  1, 8 },{59,  3, 5,  4, 4 },{60,  3, 5,  0, 8 },{61,  3, 5,  3, 4 },{62,  3, 5,  2, 4 },{63,  3, 5,  1, 1 },};/* 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}};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 */#if 1 // 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  }};#elseconst uint16_t ff_vc1_cbpcy_p_codes[4][64] = {  {      0,   1,   1,   4,   5,   1,  12,   4,  13,  14,  10,  11,  12,   7,  13,   2,     15,   1,  96,   1,  49,  97,   2, 100,   3,   4,   5, 101, 102,  52,  53,   4,      6,   7,  54, 103,   8,   9,  10, 110,  11,  12, 111,  56, 114,  58, 115,   5,     13,   7,   8,   9,  10,  11,  12,  30,  13,  14,  15, 118, 119,  62,  63,   3  },  {      0,   1,   2,   1,   3,   1,  16,  17,   5,  18,  12,  19,  13,   1,  28,  58,      1,   1,   1,   2,   3,   2,   3, 236, 237,   4,   5, 238,   6,   7, 239,   8,      9, 240,  10,  11, 121, 122,  12,  13,  14,  15, 241, 246,  16,  17, 124,  63,     18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31, 247, 125  },  {      0,   1,   2,   3,   2,   3,   1,   4,   5,  24,   7,  13,  16,  17,   9,   5,     25,   1,   1,   1,   2,   3,  96, 194,   1,   2,  98,  99, 195, 200, 101,  26,    201, 102, 412, 413, 414,  54, 220, 111, 221,   3, 224, 113, 225, 114, 230,  29,    231, 415, 240,   4, 241, 484,   5, 243,   3, 244, 245, 485, 492, 493, 247,  31  },  {      0,   1,   1,   1,   2,   2,   3,   4,   3,   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,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,     44,  45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  28,  29,  30,  31   }};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -