📄 decoders.h
字号:
value = dct_coeff_tbl[index]; \ run = value >> RUN_SHIFT; \ if (run != END_OF_BLOCK) { \ /* num_bits = (value & NUM_MASK) + 1; */ \ /* flush_bits(num_bits); */ \ if (run != ESCAPE) { \ /* get_bits1(value); */ \ /* if (value) level = -level; */ \ flushed = (value & NUM_MASK) + 2; \ level = (value & LEVEL_MASK) >> LEVEL_SHIFT; \ value = next32bits >> (32-flushed); \ value &= 0x1; \ if (value) level = -level; \ /* next32bits &= ((~0) >> flushed); last op before update */ \ \ /* Update bitstream... */ \ flush_bits(flushed); \ assert (flushed <= 32); \ } \ else { /* run == ESCAPE */ \ /* Get the next six into run, and next 8 into temp */ \ /* get_bits14(temp); */ \ flushed = (value & NUM_MASK) + 1; \ temp = next32bits >> (18-flushed); \ /* Normally, we'd ad 14 to flushed, but I've saved a few \ * instr by moving the add below */ \ temp &= 0x3fff; \ run = temp >> 8; \ temp &= 0xff; \ if (temp == 0) { \ /* get_bits8(level); */ \ level = next32bits >> (10-flushed); \ level &= 0xff; \ flushed += 22; \ /* CG: 12jul2000 - assert(level >= 128); */ \ if (level >= 128) { \ /* Update bitstream... */ \ flush_bits(flushed); \ assert (flushed <= 32); \ } else { \ run = END_OF_BLOCK; \ level = END_OF_BLOCK; \ } \ } else if (temp != 128) { \ /* Grab sign bit */ \ flushed += 14; \ level = ((int) (temp << 24)) >> 24; \ /* Update bitstream... */ \ flush_bits(flushed); \ assert (flushed <= 32); \ } else { \ /* get_bits8(level); */ \ level = next32bits >> (10-flushed); \ level &= 0xff; \ flushed += 22; \ level = level - 256; \ /* CG: 12jul2000 - assert(level <= -128 && level >= -255); */ \ if ( level <= -128 && level >= -255) { \ /* Update bitstream... */ \ flush_bits(flushed); \ assert (flushed <= 32); \ } else { \ run = END_OF_BLOCK; \ level = END_OF_BLOCK; \ } \ } \ } \ } \ } \ else { \ switch (index) { \ case 2: { \ /* show_bits10(index); */ \ index = next32bits >> 22; \ value = dct_coeff_tbl_2[index & 3]; \ break; \ } \ case 3: { \ /* show_bits10(index); */ \ index = next32bits >> 22; \ value = dct_coeff_tbl_3[index & 3]; \ break; \ } \ case 1: { \ /* show_bits12(index); */ \ index = next32bits >> 20; \ value = dct_coeff_tbl_1[index & 15]; \ break; \ } \ default: { /* index == 0 */ \ /* show_bits16(index); */ \ index = next32bits >> 16; \ value = dct_coeff_tbl_0[index & 255]; \ }} \ run = value >> RUN_SHIFT; \ level = (value & LEVEL_MASK) >> LEVEL_SHIFT; \ \ /* \ * Fold these operations together to make it fast... \ */ \ /* num_bits = (value & NUM_MASK) + 1; */ \ /* flush_bits(num_bits); */ \ /* get_bits1(value); */ \ /* if (value) level = -level; */ \ \ flushed = (value & NUM_MASK) + 2; \ value = next32bits >> (32-flushed); \ value &= 0x1; \ if (value) level = -level; \ \ /* Update bitstream ... */ \ flush_bits(flushed); \ assert (flushed <= 32); \ } \}#endif /* NO_GRIFF_MODS */#define DecodeDCTCoeffFirst(runval, levelval) \{ \ DecodeDCTCoeff(dct_coeff_first, runval, levelval); \} #define DecodeDCTCoeffNext(runval, levelval) \{ \ DecodeDCTCoeff(dct_coeff_next, runval, levelval); \}/* *-------------------------------------------------------------- * * DecodeMBAddrInc -- * * Huffman Decoder for macro_block_address_increment; the location * in which the result will be placed is being passed as argument. * The decoded value is obtained by doing a table lookup on * mb_addr_inc. * * Results: * The decoded value for macro_block_address_increment or ERROR * for unbound values will be placed in the location specified. * * Side effects: * Bit stream is irreversibly parsed. * *-------------------------------------------------------------- */#define DecodeMBAddrInc(val) \{ \ unsigned int index; \ show_bits11(index); \ val = mb_addr_inc[index].value; \ flush_bits(mb_addr_inc[index].num_bits); \}/* *-------------------------------------------------------------- * * DecodeMotionVectors -- * * Huffman Decoder for the various motion vectors, including * motion_horizontal_forward_code, motion_vertical_forward_code, * motion_horizontal_backward_code, motion_vertical_backward_code. * Location where the decoded result will be placed is being passed * as argument. The decoded values are obtained by doing a table * lookup on motion_vectors. * * Results: * The decoded value for the motion vector or ERROR for unbound * values will be placed in the location specified. * * Side effects: * Bit stream is irreversibly parsed. * *-------------------------------------------------------------- */#define DecodeMotionVectors(value) \{ \ unsigned int index; \ show_bits11(index); \ value = motion_vectors[index].code; \ flush_bits(motion_vectors[index].num_bits); \}/* *-------------------------------------------------------------- * * DecodeMBTypeB -- * * Huffman Decoder for macro_block_type in bidirectionally-coded * pictures;locations in which the decoded results: macroblock_quant, * macroblock_motion_forward, macro_block_motion_backward, * macroblock_pattern, macro_block_intra, will be placed are * being passed as argument. The decoded values are obtained by * doing a table lookup on mb_type_B. * * Results: * The various decoded values for macro_block_type in * bidirectionally-coded pictures or ERROR for unbound values will * be placed in the locations specified. * * Side effects: * Bit stream is irreversibly parsed. * *-------------------------------------------------------------- */#define DecodeMBTypeB(quant, motion_fwd, motion_bwd, pat, intra) \{ \ unsigned int index; \ \ show_bits6(index); \ \ quant = mb_type_B[index].mb_quant; \ motion_fwd = mb_type_B[index].mb_motion_forward; \ motion_bwd = mb_type_B[index].mb_motion_backward; \ pat = mb_type_B[index].mb_pattern; \ intra = mb_type_B[index].mb_intra; \ flush_bits(mb_type_B[index].num_bits); \}/* *-------------------------------------------------------------- * * DecodeMBTypeI -- * * Huffman Decoder for macro_block_type in intra-coded pictures; * locations in which the decoded results: macroblock_quant, * macroblock_motion_forward, macro_block_motion_backward, * macroblock_pattern, macro_block_intra, will be placed are * being passed as argument. * * Results: * The various decoded values for macro_block_type in intra-coded * pictures or ERROR for unbound values will be placed in the * locations specified. * * Side effects: * Bit stream is irreversibly parsed. * *-------------------------------------------------------------- */#define DecodeMBTypeI(quant, motion_fwd, motion_bwd, pat, intra) \{ \ unsigned int index; \ static int quantTbl[4] = {ERROR, 1, 0, 0}; \ \ show_bits2(index); \ \ motion_fwd = 0; \ motion_bwd = 0; \ pat = 0; \ intra = 1; \ quant = quantTbl[index]; \ if (index) { \ flush_bits (1 + quant); \ } \}/* *-------------------------------------------------------------- * * DecodeMBTypeP -- * * Huffman Decoder for macro_block_type in predictive-coded pictures; * locations in which the decoded results: macroblock_quant, * macroblock_motion_forward, macro_block_motion_backward, * macroblock_pattern, macro_block_intra, will be placed are * being passed as argument. The decoded values are obtained by * doing a table lookup on mb_type_P. * * Results: * The various decoded values for macro_block_type in * predictive-coded pictures or ERROR for unbound values will be * placed in the locations specified. * * Side effects: * Bit stream is irreversibly parsed. * *-------------------------------------------------------------- */#define DecodeMBTypeP(quant, motion_fwd, motion_bwd, pat, intra) \{ \ unsigned int index; \ \ show_bits6(index); \ \ quant = mb_type_P[index].mb_quant; \ motion_fwd = mb_type_P[index].mb_motion_forward; \ motion_bwd = mb_type_P[index].mb_motion_backward; \ pat = mb_type_P[index].mb_pattern; \ intra = mb_type_P[index].mb_intra; \ \ flush_bits(mb_type_P[index].num_bits); \}/* *-------------------------------------------------------------- * * DecodeCBP -- * * Huffman Decoder for coded_block_pattern; location in which the * decoded result will be placed is being passed as argument. The * decoded values are obtained by doing a table lookup on * coded_block_pattern. * * Results: * The decoded value for coded_block_pattern or ERROR for unbound * values will be placed in the location specified. * * Side effects: * Bit stream is irreversibly parsed. * *-------------------------------------------------------------- */#define DecodeCBP(coded_bp) \{ \ unsigned int index; \ \ show_bits9(index); \ coded_bp = coded_block_pattern[index].cbp; \ flush_bits(coded_block_pattern[index].num_bits); \}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -