📄 vlc.cc
字号:
DUMPBITS(bit_buf,bits,size); return dc_diff; }#undef bit_buf#undef bits}#endif#if 0static DCtab DC_small [] = { {1, 2}, {1, 2}, {2, 2}, {2, 2}, {0, 3}, {3, 3}};static inline int get_luma_dc_dct_diff(FastBitBuf& bs){ bs.Fill16Bits();#define bit_buf bs.d_buffer#define bits bs.d_freebits DCtab * tab; int size; int dc_diff; int cnt; __asm__ ( "bsrl %1,%0\n\t" : "=r" (cnt) : "m" (~bit_buf) ); if (cnt>=30) { tab = DC_small + UBITS(bit_buf, 3); size = tab->size; if (size) { bits += tab->len + size; bit_buf <<= tab->len; dc_diff = UBITS (bit_buf, size) - UBITS (SBITS (~bit_buf, 1), size); bit_buf <<= size; return dc_diff; } else { DUMPBITS (bit_buf, bits, 3); return 0; } } else if (cnt>=25) { int len = 32-cnt; size = len+1; bits += len+size; bit_buf <<= len; dc_diff = UBITS (bit_buf, size) - UBITS (SBITS (~bit_buf, 1), size); bit_buf <<= size; return dc_diff; } else { int len = 32-cnt; size = len+1; DUMPBITS(bit_buf,bits,len); bs.Fill16Bits(); dc_diff = UBITS (bit_buf, size) - UBITS (SBITS (~bit_buf, 1), size); DUMPBITS(bit_buf,bits,size); return dc_diff; }#undef bit_buf#undef bits}#endif// -------------- chromastatic DCtab DC_chrom_5 [] = { {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {3, 3}, {3, 3}, {3, 3}, {3, 3}, {4, 4}, {4, 4}, {5, 5}};static inline int get_chroma_dc_dct_diff (FastBitBuf& bs){ bs.Fill16Bits();#define bit_buf bs.d_buffer#define bits bs.d_freebits DCtab * tab; int size; int dc_diff; if (bit_buf < 0xf8000000) { /* Max. codelength = 5 + max. size = 5 <= 16 , no refill needed. */ tab = DC_chrom_5 + UBITS (bit_buf, 5); size = tab->size; if (size) { bits += tab->len + size; bit_buf <<= tab->len; dc_diff = UBITS (bit_buf, size) - UBITS (SBITS (~bit_buf, 1), size); bit_buf <<= size; return dc_diff; } else { DUMPBITS (bit_buf, bits, 2); return 0; } } else { tab = DC_long - 0x3e0 + UBITS (bit_buf, 10); size = tab->size; int len = tab->len+1; if (size>=8) { DUMPBITS(bit_buf,bits,len); bs.Fill16Bits(); dc_diff = UBITS (bit_buf, size) - UBITS (SBITS (~bit_buf, 1), size); DUMPBITS(bit_buf,bits,size); } else { bits += len+size; bit_buf <<= len; dc_diff = UBITS (bit_buf, size) - UBITS (SBITS (~bit_buf, 1), size); bit_buf <<= size; } return dc_diff; }#undef bit_buf#undef bits}/************************************* Run/Level pairs ********************************/struct DCTtab { uint8 run, level, len;};/* Table B-14, DCT coefficients table zero, * codes 0100 ... 1xxx (used for first (DC) coefficient) */static DCTtab DCTtabfirst[12] ={ {0,2,4}, {2,1,4}, {1,1,3}, {1,1,3}, {0,1,1}, {0,1,1}, {0,1,1}, {0,1,1}, {0,1,1}, {0,1,1}, {0,1,1}, {0,1,1}};/* Table B-14, DCT coefficients table zero, * codes 0100 ... 1xxx (used for all other coefficients) */static DCTtab DCTtabnext[12] ={ {0,2,4}, {2,1,4}, {1,1,3}, {1,1,3}, {64,0,2}, {64,0,2}, {64,0,2}, {64,0,2}, /* EOB */ {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}};/* Table B-14, DCT coefficients table zero, * codes 000001xx ... 00111xxx */static DCTtab DCTtab0[60] ={ {65,0,6}, {65,0,6}, {65,0,6}, {65,0,6}, /* Escape */ {2,2,7}, {2,2,7}, {9,1,7}, {9,1,7}, {0,4,7}, {0,4,7}, {8,1,7}, {8,1,7}, {7,1,6}, {7,1,6}, {7,1,6}, {7,1,6}, {6,1,6}, {6,1,6}, {6,1,6}, {6,1,6}, {1,2,6}, {1,2,6}, {1,2,6}, {1,2,6}, {5,1,6}, {5,1,6}, {5,1,6}, {5,1,6}, {13,1,8}, {0,6,8}, {12,1,8}, {11,1,8}, {3,2,8}, {1,3,8}, {0,5,8}, {10,1,8}, {0,3,5}, {0,3,5}, {0,3,5}, {0,3,5}, {0,3,5}, {0,3,5}, {0,3,5}, {0,3,5}, {4,1,5}, {4,1,5}, {4,1,5}, {4,1,5}, {4,1,5}, {4,1,5}, {4,1,5}, {4,1,5}, {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5}};/* Table B-15, DCT coefficients table one, * codes 000001xx ... 11111111*/static DCTtab DCTtab0a[252] ={ {65,0,6}, {65,0,6}, {65,0,6}, {65,0,6}, /* Escape */ {7,1,7}, {7,1,7}, {8,1,7}, {8,1,7}, {6,1,7}, {6,1,7}, {2,2,7}, {2,2,7}, {0,7,6}, {0,7,6}, {0,7,6}, {0,7,6}, {0,6,6}, {0,6,6}, {0,6,6}, {0,6,6}, {4,1,6}, {4,1,6}, {4,1,6}, {4,1,6}, {5,1,6}, {5,1,6}, {5,1,6}, {5,1,6}, {1,5,8}, {11,1,8}, {0,11,8}, {0,10,8}, {13,1,8}, {12,1,8}, {3,2,8}, {1,4,8}, {2,1,5}, {2,1,5}, {2,1,5}, {2,1,5}, {2,1,5}, {2,1,5}, {2,1,5}, {2,1,5}, {1,2,5}, {1,2,5}, {1,2,5}, {1,2,5}, {1,2,5}, {1,2,5}, {1,2,5}, {1,2,5}, {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3}, {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4}, /* EOB */ {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4}, {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3}, {0,4,5}, {0,4,5}, {0,4,5}, {0,4,5}, {0,4,5}, {0,4,5}, {0,4,5}, {0,4,5}, {0,5,5}, {0,5,5}, {0,5,5}, {0,5,5}, {0,5,5}, {0,5,5}, {0,5,5}, {0,5,5}, {9,1,7}, {9,1,7}, {1,3,7}, {1,3,7}, {10,1,7}, {10,1,7}, {0,8,7}, {0,8,7}, {0,9,7}, {0,9,7}, {0,12,8}, {0,13,8}, {2,3,8}, {4,2,8}, {0,14,8}, {0,15,8}};/* Table B-14, DCT coefficients table zero, * codes 0000001000 ... 0000001111 */static DCTtab DCTtab1[8] ={ {16,1,10}, {5,2,10}, {0,7,10}, {2,3,10}, {1,4,10}, {15,1,10}, {14,1,10}, {4,2,10}};/* Table B-15, DCT coefficients table one, * codes 000000100x ... 000000111x */static DCTtab DCTtab1a[8] ={ {5,2,9}, {5,2,9}, {14,1,9}, {14,1,9}, {2,4,10}, {16,1,10}, {15,1,9}, {15,1,9}};/* Table B-14/15, DCT coefficients table zero / one, * codes 000000010000 ... 000000011111 */static DCTtab DCTtab2[16] ={ {0,11,12}, {8,2,12}, {4,3,12}, {0,10,12}, {2,4,12}, {7,2,12}, {21,1,12}, {20,1,12}, {0,9,12}, {19,1,12}, {18,1,12}, {1,5,12}, {3,3,12}, {0,8,12}, {6,2,12}, {17,1,12}};/* Table B-14/15, DCT coefficients table zero / one, * codes 0000000010000 ... 0000000011111 */static DCTtab DCTtab3[16] ={ {10,2,13}, {9,2,13}, {5,3,13}, {3,4,13}, {2,5,13}, {1,7,13}, {1,6,13}, {0,15,13}, {0,14,13}, {0,13,13}, {0,12,13}, {26,1,13}, {25,1,13}, {24,1,13}, {23,1,13}, {22,1,13}};/* Table B-14/15, DCT coefficients table zero / one, * codes 00000000010000 ... 00000000011111 */static DCTtab DCTtab4[16] ={ {0,31,14}, {0,30,14}, {0,29,14}, {0,28,14}, {0,27,14}, {0,26,14}, {0,25,14}, {0,24,14}, {0,23,14}, {0,22,14}, {0,21,14}, {0,20,14}, {0,19,14}, {0,18,14}, {0,17,14}, {0,16,14}};/* Table B-14/15, DCT coefficients table zero / one, * codes 000000000010000 ... 000000000011111 */static DCTtab DCTtab5[16] ={ {0,40,15}, {0,39,15}, {0,38,15}, {0,37,15}, {0,36,15}, {0,35,15}, {0,34,15}, {0,33,15}, {0,32,15}, {1,14,15}, {1,13,15}, {1,12,15}, {1,11,15}, {1,10,15}, {1,9,15}, {1,8,15}};/* Table B-14/15, DCT coefficients table zero / one, * codes 0000000000010000 ... 0000000000011111 */static DCTtab DCTtab6[16] ={ {1,18,16}, {1,17,16}, {1,16,16}, {1,15,16}, {6,3,16}, {16,2,16}, {15,2,16}, {14,2,16}, {13,2,16}, {12,2,16}, {11,2,16}, {31,1,16}, {30,1,16}, {29,1,16}, {28,1,16}, {27,1,16}};// r=0,l=0 -> EOB// r=1,l=0 -> ESCAPEstruct CoeffTab{ uint8 run; int16 level; uint8 nbits;};static CoeffTab coefftab_first[1<<17];static CoeffTab coefftab_nonfirst[1<<17];static CoeffTab coefftab_B15[1<<17];struct CoeffTabInit{ uint8 run; int16 level; uint8 nbits; uint32 bits;};struct CoeffTabInit2{ uint8 run; int16 level; char* bits;};CoeffTabInit coeff[] ={ { 0, 2, 5, 0x0008 }, { 0, 3, 6, 0x000A }, { 0, 4, 8, 0x000C }, { 0, 5, 9, 0x004C }, { 0, 6, 9, 0x0042 }, { 0, 7, 11, 0x0014 }, { 0, 8, 13, 0x003A }, { 0, 9, 13, 0x0030 }, { 0,10, 13, 0x0026 }, { 0,11, 13, 0x0020 }, { 0,12, 14, 0x0034 }, { 0,13, 14, 0x0032 }, { 0,14, 14, 0x00C0>>2 }, { 0,15, 14, 0x00B8>>2 }, { 0,16, 15, 0x007C>>1 }, { 0,17, 15, 0x0078>>1 }, { 0,18, 15, 0x0074>>1 }, { 0,19, 15, 0x0070>>1 }, { 0,20, 15, 0x006C>>1 }, { 0,21, 15, 0x0068>>1 }, { 0,22, 15, 0x0064>>1 }, { 0,23, 15, 0x0060>>1 }, { 0,24, 15, 0x005C>>1 }, { 0,25, 15, 0x0058>>1 }, { 0,26, 15, 0x0054>>1 }, { 0,27, 15, 0x0050>>1 }, { 0,28, 15, 0x004C>>1 }, { 0,29, 15, 0x0048>>1 }, { 0,30, 15, 0x0044>>1 }, { 0,31, 15, 0x0040>>1 }, { 0,32, 16, 0x0030 }, { 0,33, 16, 0x002E }, { 0,34, 16, 0x002C }, { 0,35, 16, 0x002A }, { 0,36, 16, 0x0028 }, { 0,37, 16, 0x0026 }, { 0,38, 16, 0x0024 }, { 0,39, 16, 0x0022 }, { 0,40, 16, 0x0020 }, { 1, 1, 4, 0x0006 }, { 1, 2, 7, 0x0018>>1 }, { 1, 3, 9, 0x0025<<1 }, { 1, 4, 11, 0x0030>>1 }, { 1, 5, 13, 0x001B<<1 }, { 1, 6, 14, 0x000B<<2 }, { 1, 7, 14, 0x00A8>>2 }, { 1, 8, 16, 0x003E }, { 1, 9, 16, 0x003C }, { 1,10, 16, 0x003A }, { 1,11, 16, 0x0038 }, { 1,12, 16, 0x0036 }, { 1,13, 16, 0x0034 }, { 1,14, 16, 0x0032 }, { 1,15, 17, 0x0013<<1 }, { 1,16, 17, 0x0012<<1 }, { 1,17, 17, 0x0011<<1 }, { 1,18, 17, 0x0010<<1 }, { 2, 1, 5, 0x0005<<1 }, { 2, 2, 8, 0x0008 }, { 2, 3, 11, 0x002C>>1 }, { 2, 4, 13, 0x0014<<1 }, { 2, 5, 14, 0x00A0>>2 }, { 3, 1, 6, 0x0038>>2 }, { 3, 2, 9, 0x0024<<1 }, { 3, 3, 13, 0x001C<<1 }, { 3, 4, 14, 0x0098>>2 }, { 4, 1, 6, 0x0030>>2 }, { 4, 2, 11, 0x003C>>1 }, { 4, 3, 13, 0x0012<<1 }, { 5, 1, 7, 0x001C>>1 }, { 5, 2, 11, 0x0024>>1 }, { 5, 3, 14, 0x0090>>2 }, { 6, 1, 7, 0x0014>>1 }, { 6, 2, 13, 0x001E<<1 }, { 6, 3, 17, 0x0014<<1 }, { 7, 1, 7, 0x0010>>1 }, { 7, 2, 13, 0x0015<<1 }, { 8, 1, 8, 0x000E }, { 8, 2, 13, 0x0011<<1 }, { 9, 1, 8, 0x000A }, { 9, 2, 14, 0x0088>>2 }, {10, 1, 9, 0x0027<<1 }, {10, 2, 14, 0x0080>>2 }, {11, 1, 9, 0x0023<<1 }, {11, 2, 17, 0x001A<<1 }, {12, 1, 9, 0x0022<<1 }, {12, 2, 17, 0x0019<<1 }, {13, 1, 9, 0x0020<<1 }, {13, 2, 17, 0x0018<<1 }, {14, 1, 11, 0x0038>>1 }, {14, 2, 17, 0x0017<<1 }, {15, 1, 11, 0x0034>>1 }, {15, 2, 17, 0x0016<<1 }, {16, 1, 11, 0x0020>>1 }, {16, 2, 17, 0x0015<<1 }, {17, 1, 13, 0x001F<<1 }, {18, 1, 13, 0x001A<<1 }, {19, 1, 13, 0x0019<<1 }, {20, 1, 13, 0x0017<<1 }, {21, 1, 13, 0x0016<<1 }, {22, 1, 14, 0x00F8>>2 }, {23, 1, 14, 0x00F0>>2 }, {24, 1, 14, 0x00E8>>2 }, {25, 1, 14, 0x00E0>>2 }, {26, 1, 14, 0x00D8>>2 }, {27, 1, 17, 0x001F<<1 }, {28, 1, 17, 0x001E<<1 }, {29, 1, 17, 0x001D<<1 }, {30, 1, 17, 0x001C<<1 }, {31, 1, 17, 0x001B<<1 }, { 0,0,0,0 }};CoeffTabInit2 coeff_B15[] ={ { 0, 1, "10s" }, { 1, 1, "010s" }, { 0, 2, "110s" }, { 2, 1, "00101s" }, { 0, 3, "0111s" }, { 3, 1, "00111s" }, { 4, 1, "000110s" }, { 1, 2, "00110s" }, { 5, 1, "000111s" }, { 6, 1, "0000110s" }, { 7, 1, "0000100s" }, { 0, 4, "11100s" }, { 2, 2, "0000111s" }, { 8, 1, "0000101s" }, { 9, 1, "1111000s" }, { 0, 5, "11101s" }, { 0, 6, "000101s" }, { 1, 3, "1111001s" }, { 3, 2, "00100110s" }, {10, 1, "1111010s" }, {11, 1, "00100001s" }, {12, 1, "00100101s" }, {13, 1, "00100100s" }, { 0, 7, "000100s" }, { 1, 4, "00100111s" }, { 2, 3, "11111100s" },
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -