📄 vpar_blocks.c
字号:
i_level -= 256; if (i_level<0) i_level = -i_level; break; case DCT_EOB:#ifdef HAVE_MMX /* The MMX IDCT has a precision problem with non-intra * blocks. */ p_mb->ppi_blocks[i_b][0] += 4;#endif if( i_nc <= 1 ) { p_mb->pf_idct[i_b] = vdec_SparseIDCT; p_mb->pi_sparse_pos[i_b] = i_coef; } else { p_mb->pf_idct[i_b] = vdec_IDCT; } return; break; default: b_sign = GetBits( &p_vpar->bit_stream, 1 ); } i_coef = i_parse; i_parse += i_run; i_nc ++; if( i_parse >= 64 ) { break; } i_pos = pi_scan[p_vpar->picture.b_alternate_scan][i_parse]; i_level = ( ((i_level << 1) + 1) * p_vpar->mb.i_quantizer_scale * p_vpar->sequence.nonintra_quant.pi_matrix[i_pos] ) >> 4; p_mb->ppi_blocks[i_b][i_pos] = b_sign ? -i_level : i_level; } intf_ErrMsg("vpar error: DCT coeff (non-intra) is out of bounds\n"); p_vpar->picture.b_error = 1;}/***************************************************************************** * DecodeMPEG1Intra : decode MPEG-1 intra blocks *****************************************************************************/static void DecodeMPEG1Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb, int i_b , int i_chroma_format ){ int i_parse; int i_nc; int i_cc; int i_coef; int i_code; int i_length; int i_pos; int i_dct_dc_size; int i_dct_dc_diff; int i_run; int i_level; boolean_t b_sign; boolean_t b_chroma; /* Give the chromatic component (0, 1, 2) */ i_cc = pi_cc_index[i_b]; /* Determine whether it is luminance or not (chrominance) */ b_chroma = ( i_cc + 1 ) >> 1; /* decode length */ i_code = ShowBits(&p_vpar->bit_stream, 5); if (i_code<31) { i_dct_dc_size = ppl_dct_dc_init_table_1[b_chroma][i_code].i_value; i_length = ppl_dct_dc_init_table_1[b_chroma][i_code].i_length; RemoveBits( &p_vpar->bit_stream, i_length); } else { i_code = ShowBits(&p_vpar->bit_stream, (9+b_chroma)) - (0x1f0 * (b_chroma + 1)); i_dct_dc_size = ppl_dct_dc_init_table_2[b_chroma][i_code].i_value; i_length = ppl_dct_dc_init_table_2[b_chroma][i_code].i_length; RemoveBits( &p_vpar->bit_stream, i_length); } if (i_dct_dc_size == 0) i_dct_dc_diff = 0; else { i_dct_dc_diff = GetBits( &p_vpar->bit_stream, i_dct_dc_size); if ((i_dct_dc_diff & (1<<(i_dct_dc_size-1))) == 0) i_dct_dc_diff -= (1<<i_dct_dc_size) - 1; } /* Read the actual code with the good length */ p_vpar->mb.pi_dc_dct_pred[i_cc] += i_dct_dc_diff; p_mb->ppi_blocks[i_b][0] = p_vpar->mb.pi_dc_dct_pred[i_cc]; i_nc = ( p_vpar->mb.pi_dc_dct_pred[i_cc] != 0 ); if( p_vpar->picture.i_coding_type == D_CODING_TYPE ) { /* Remove end_of_macroblock (always 1, prevents startcode emulation) * ISO/IEC 11172-2 section 2.4.2.7 and 2.4.3.6 */ RemoveBits( &p_vpar->bit_stream, 1 ); /* D pictures do not have AC coefficients */ return; } /* Decoding of the AC coefficients */ i_coef = 0; i_nc = 0; b_sign = 0; for( i_parse = 1; !p_vpar->b_die/*i_parse < 64*/; i_parse++ ) { i_code = ShowBits( &p_vpar->bit_stream, 16 ); /* We use 2 main tables for the coefficients */ if( i_code >= 16384 ) { i_run = ppl_dct_tab1[0][(i_code>>12)-4].i_run; i_level = ppl_dct_tab1[0][(i_code>>12)-4].i_level; i_length = ppl_dct_tab1[0][(i_code>>12)-4].i_length; } else { i_run = p_vpar->ppl_dct_coef[0][i_code].i_run; i_length = p_vpar->ppl_dct_coef[0][i_code].i_length; i_level = p_vpar->ppl_dct_coef[0][i_code].i_level; } RemoveBits( &p_vpar->bit_stream, i_length ); switch( i_run ) { case DCT_ESCAPE: i_run = GetBits( &p_vpar->bit_stream, 6 ); i_level = GetBits( &p_vpar->bit_stream, 8 ); if (i_level == 0) i_level = GetBits( &p_vpar->bit_stream, 8 ); else if (i_level == 128) i_level = GetBits( &p_vpar->bit_stream, 8 ) - 256; else if (i_level > 128) i_level -= 256; break; case DCT_EOB: if( i_nc <= 1 ) { p_mb->pf_idct[i_b] = vdec_SparseIDCT; p_mb->pi_sparse_pos[i_b] = i_coef; } else { p_mb->pf_idct[i_b] = vdec_IDCT; } return; break; default: b_sign = GetBits( &p_vpar->bit_stream, 1 ); } /* Prepare the next block */ i_coef = i_parse; i_parse += i_run; i_nc ++; if( i_parse >= 64 ) { /* We have an error in the stream */ break; } /* Determine the position of the block in the frame */ i_pos = pi_scan[p_vpar->picture.b_alternate_scan][i_parse]; i_level = ( i_level * p_vpar->mb.i_quantizer_scale * p_vpar->sequence.intra_quant.pi_matrix[i_pos] ) >> 3; p_mb->ppi_blocks[i_b][i_pos] = b_sign ? -i_level : i_level; } intf_ErrMsg("vpar error: DCT coeff (intra) is out of bounds\n"); p_vpar->picture.b_error = 1;}/***************************************************************************** * DecodeMPEG2NonIntra : decode MPEG-2 non-intra blocks *****************************************************************************/static void DecodeMPEG2NonIntra( vpar_thread_t * p_vpar, macroblock_t * p_mb, int i_b, int i_chroma_format ){ int i_parse; int i_nc; int i_cc; int i_coef; int i_code; int i_length; int i_pos; int i_run; int i_level; boolean_t b_dc; boolean_t b_sign; boolean_t b_chroma; int * pi_quant; /* Give the chromatic component (0, 1, 2) */ i_cc = pi_cc_index[i_b]; /* Determine whether it is luminance or not (chrominance) */ b_chroma = ( i_cc + 1 ) >> 1; /* Give a pointer to the quantization matrices for intra blocks */ if( (i_chroma_format == CHROMA_420) || (!b_chroma) ) { pi_quant = p_vpar->sequence.nonintra_quant.pi_matrix; } else { pi_quant = p_vpar->sequence.chroma_nonintra_quant.pi_matrix; } /* Decoding of the AC coefficients */ i_nc = 0; i_coef = 0; for( i_parse = 0; !p_vpar->b_die; i_parse++ ) { i_code = ShowBits( &p_vpar->bit_stream, 16 ); if( i_code >= 16384 ) { b_dc = (i_parse == 0); i_run = ppl_dct_tab2[b_dc][(i_code>>12)-4].i_run; i_level = ppl_dct_tab2[b_dc][(i_code>>12)-4].i_level; i_length = ppl_dct_tab2[b_dc][(i_code>>12)-4].i_length; } else { i_run = p_vpar->ppl_dct_coef[0][i_code].i_run; i_length = p_vpar->ppl_dct_coef[0][i_code].i_length; i_level = p_vpar->ppl_dct_coef[0][i_code].i_level; } RemoveBits( &p_vpar->bit_stream, i_length ); switch( i_run ) { case DCT_ESCAPE: i_run = GetBits( &p_vpar->bit_stream, 6 ); i_level = GetBits( &p_vpar->bit_stream, 12 ); i_level = (b_sign = ( i_level > 2047 )) ? 4096 - i_level : i_level; break; case DCT_EOB:#ifdef HAVE_MMX /* The MMX IDCT has a precision problem with non-intra * blocks. */ p_mb->ppi_blocks[i_b][0] += 4;#endif if( i_nc <= 1 ) { p_mb->pf_idct[i_b] = vdec_SparseIDCT; p_mb->pi_sparse_pos[i_b] = i_coef; } else { p_mb->pf_idct[i_b] = vdec_IDCT; } return; break; default: b_sign = GetBits( &p_vpar->bit_stream, 1 ); } i_coef = i_parse; i_parse += i_run; i_nc ++; if( i_parse >= 64 ) { break; } i_pos = pi_scan[p_vpar->picture.b_alternate_scan][i_parse]; i_level = ( ((i_level << 1) + 1) * p_vpar->mb.i_quantizer_scale * pi_quant[i_pos] ) >> 5; p_mb->ppi_blocks[i_b][i_pos] = b_sign ? -i_level : i_level; } intf_ErrMsg("vpar error: DCT coeff (non-intra) is out of bounds\n"); p_vpar->picture.b_error = 1;}/***************************************************************************** * DecodeMPEG2Intra : decode MPEG-2 intra blocks *****************************************************************************/static void DecodeMPEG2Intra( vpar_thread_t * p_vpar, macroblock_t * p_mb, int i_b, int i_chroma_format ){ int i_parse; int i_nc; int i_cc; int i_coef; int i_code; int i_length; int i_pos; int i_dct_dc_size; int i_dct_dc_diff; int i_run; int i_level; boolean_t b_vlc_intra; boolean_t b_sign; boolean_t b_chroma; int * pi_quant; /* Give the chromatic component (0, 1, 2) */ i_cc = pi_cc_index[i_b]; /* Determine whether it is luminance or not (chrominance) */ b_chroma = ( i_cc + 1 ) >> 1; /* Give a pointer to the quantization matrices for intra blocks */ if( (i_chroma_format == CHROMA_420) || (!b_chroma) ) { pi_quant = p_vpar->sequence.intra_quant.pi_matrix; } else { pi_quant = p_vpar->sequence.chroma_intra_quant.pi_matrix; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -