📄 slice.c
字号:
else if (bit_buf >= 0x02000000) { tab = DCT_B14_10 + (UBITS (bit_buf, 10) - 8); i += tab->run; if (i < 64) goto normal_code; } else if (bit_buf >= 0x00800000) { tab = DCT_13 + (UBITS (bit_buf, 13) - 16); i += tab->run; if (i < 64) goto normal_code; } else if (bit_buf >= 0x00200000) { tab = DCT_15 + (UBITS (bit_buf, 15) - 16); i += tab->run; if (i < 64) goto normal_code; } else { tab = DCT_16 + UBITS (bit_buf, 16); bit_buf <<= 16; GETWORD (bit_buf, bits + 16, bit_ptr); i += tab->run; if (i < 64) goto normal_code; } break; /* illegal, check needed to avoid buffer overflow */ }#ifdef NO_PERF // $PP dest[63] ^= mismatch & 16;#endif //#ifdef NO_PERF DUMPBITS (bit_buf, bits, 2); /* dump end of block code */ decoder->bitstream_buf = bit_buf; decoder->bitstream_bits = bits; decoder->bitstream_ptr = bit_ptr; return i;}// $PP// added one more param// used to create MB dataSTATIC_INLINE void slice_intra_DCT (mpeg2_decoder_t * const decoder, const int cc, uint8_t * const dest, const int stride, short int *pBlockData, unsigned int iBlockNum){#define bit_buf (decoder->bitstream_buf)#define bits (decoder->bitstream_bits)#define bit_ptr (decoder->bitstream_ptr)#ifdef NO_PERF INTERMEDITATE_BLOCK_CHECKERS BlockCheckersData; unsigned char szFileName[255]; int16_t IquantBlock[64] = {0}; int i;#endif //#ifdef NO_PERF#ifndef NO_PERF ZERO_128B(pBlockData);#endif NEEDBITS (bit_buf, bits, bit_ptr); /* Get the intra DC coefficient and inverse quantize it */ if (cc == 0) { decoder->DCTblock[0] = decoder->dc_dct_pred[0] += get_luma_dc_dct_diff (decoder); } else { decoder->DCTblock[0] = decoder->dc_dct_pred[cc] += get_chroma_dc_dct_diff (decoder); }#ifndef NO_PERF // $PP // write DC coeff val pBlockData[0 ^ 1] = decoder->DCTblock[0];#endif if (decoder->mpeg1) { if (decoder->coding_type != D_TYPE) get_mpeg1_intra_block (decoder, pBlockData); } else if (decoder->intra_vlc_format) {#ifdef NO_PERF get_intra_block_B15 (decoder, decoder->quantizer_matrix[cc ? 2 : 0], pBlockData);#else get_intra_block_B15 (decoder, NULL, pBlockData);#endif //#ifdef NO_PERF } else {#ifdef NO_PERF get_intra_block_B14 (decoder, decoder->quantizer_matrix[cc ? 2 : 0], pBlockData);#else get_intra_block_B14 (decoder, NULL, pBlockData);#endif //#ifdef NO_PERF }#ifdef NO_PERF // $PP // Dont perform IDCT here if we are in C Model mode /**************************************************/ if (decoder->bUseMAE) { // we need to accumulate data enough for one entire MacroBlock // before we do IQUANT and IDCT } else { if (decoder->bDumpFiles) { for (i = 0; i < 64; i++) { if (!decoder->scan_type) IquantBlock[my_mpeg2_scan_norm[i]] = decoder->DCTblock[mpeg2_scan_norm[i]]; else IquantBlock[my_mpeg2_scan_alt[i]] = decoder->DCTblock[mpeg2_scan_alt[i]]; } // $PP // write intermediate output after IQUANT memset (szFileName, 0, 255); sprintf(szFileName, "%s%d%s", FILE_AFTER_INTRA_IQUANT, decoder->iFrameCount, REF_FILE_EXTENSION); BlockCheckersData.nIntraWithinInter = 0; BlockCheckersData.nStepSize = 0; BlockCheckersData.bBlockCoded = BLOCK_CODED; BlockCheckersData.blk_after_iquant = (int*)IquantBlock; BlockCheckersData.nMB = decoder->iMBCount; BlockCheckersData.nOutputType = IQUANT_DONE; BlockCheckersData.nBlkType = iBlockNum; InterChecksOnBlock (&BlockCheckersData, szFileName); } mpeg2_idct_copy (decoder->DCTblock, dest, stride, decoder, iBlockNum); }#endif //#ifdef NO_PERF#undef bit_buf#undef bits#undef bit_ptr}// $PP// added one more param// used to create MB dataSTATIC_INLINE void slice_non_intra_DCT (mpeg2_decoder_t * const decoder, const int cc, uint8_t * const dest, const int stride, short int *pBlockData, unsigned int iBlockNum){ int last;#ifdef NO_PERF // $PP INTERMEDITATE_BLOCK_CHECKERS BlockCheckersData; unsigned char szFileName[255]; int16_t IquantBlock[64] = {0}; int i;#endif //#ifdef NO_PERF#ifndef NO_PERF ZERO_128B(pBlockData);#endif if (decoder->mpeg1) { last = get_mpeg1_non_intra_block (decoder, pBlockData); } else {#ifdef NO_PERF // $PP last = get_non_intra_block (decoder, decoder->quantizer_matrix[cc ? 3 : 1], pBlockData);#else get_non_intra_block (decoder, NULL, pBlockData);#endif //#ifdef NO_PERF }#ifdef NO_PERF if (decoder->bUseMAE) { // let C Model perform IQUANT and IDCT } else { if (decoder->bDumpFiles) { for (i = 0; i < 64; i++) { if (!decoder->scan_type) IquantBlock[my_mpeg2_scan_norm[i]] = decoder->DCTblock[mpeg2_scan_norm[i]]; else IquantBlock[my_mpeg2_scan_alt[i]] = decoder->DCTblock[mpeg2_scan_alt[i]]; } // $PP // write intermediate output after IQUANT memset (szFileName, 0, 255); switch (decoder->coding_type) { case P_TYPE: sprintf(szFileName, "%s%d%s", FILE_AFTER_INTER_P_IQUANT, decoder->iFrameCount, REF_FILE_EXTENSION); break; case B_TYPE: sprintf(szFileName, "%s%d%s", FILE_AFTER_INTER_B_IQUANT, decoder->iFrameCount, REF_FILE_EXTENSION); break; }; BlockCheckersData.nIntraWithinInter = 0; BlockCheckersData.bBlockCoded = BLOCK_CODED; BlockCheckersData.blk_after_iquant = (int*)IquantBlock; BlockCheckersData.nMB = decoder->iMBCount; BlockCheckersData.nOutputType = IQUANT_DONE; BlockCheckersData.nBlkType = iBlockNum; InterChecksOnBlock (&BlockCheckersData, szFileName); } mpeg2_idct_add (last, decoder->DCTblock, dest, stride, decoder, iBlockNum); }#endif //#ifdef NO_PERF}#define MOTION_CALL(routine,direction) \do { \ if ((direction) & MACROBLOCK_MOTION_FORWARD) \ routine (decoder, &(decoder->f_motion), mpeg2_mc.put); \ if ((direction) & MACROBLOCK_MOTION_BACKWARD) \ routine (decoder, &(decoder->b_motion), \ ((direction) & MACROBLOCK_MOTION_FORWARD ? \ mpeg2_mc.avg : mpeg2_mc.put)); \} while (0)#ifdef NO_PERF#define NEXT_MACROBLOCK \decoder->iMBCount++; /* $PP - increment MB count */ \do { \ decoder->offset += 16; \ if (decoder->offset == decoder->width) { \ do { /* just so we can use the break statement */ \ if (decoder->convert) { \ decoder->convert (decoder->convert_id, decoder->dest, \ decoder->v_offset); \ if (decoder->coding_type == B_TYPE) \ break; \ } \ decoder->dest[0] += decoder->slice_stride; \ decoder->dest[1] += decoder->slice_uv_stride; \ decoder->dest[2] += decoder->slice_uv_stride; \ } while (0); \ decoder->v_offset += 16; \ if (decoder->v_offset > decoder->limit_y) { \ goto SUBMIT; /*return;*/ \ } \ decoder->offset = 0; \ } \} while (0)#else#define NEXT_MACROBLOCK \decoder->iMBCount++; /* $PP - increment MB count */ \decoder->offset += 16; \if (decoder->offset == decoder->width) { \ decoder->v_offset += 16; \ if (decoder->v_offset > decoder->limit_y) { \ goto SUBMIT; /*return;*/ \ } \ decoder->offset = 0; \ }#endif //#ifdef NO_PERF#ifdef NEW_MAE_DRIVERvoid mpeg2_init_fbuf (mpeg2_decoder_t * decoder){ int offset, stride, height, bottom_field; stride = decoder->stride_frame; bottom_field = (decoder->picture_structure == BOTTOM_FIELD); offset = bottom_field ? stride : 0; height = decoder->height; if (decoder->picture_structure != FRAME_PICTURE) { decoder->dmv_offset = bottom_field ? 1 : -1; stride <<= 1; height >>= 1; } decoder->stride = stride; decoder->uv_stride = stride >> 1; decoder->slice_stride = 16 * stride; decoder->slice_uv_stride = decoder->slice_stride >> (2 - decoder->chroma_format); decoder->limit_x = 2 * decoder->width - 32; decoder->limit_y_16 = 2 * height - 32; decoder->limit_y_8 = 2 * height - 16; decoder->limit_y = height - 16; if (decoder->mpeg1) { decoder->motion_parser[0] = motion_zero_420; decoder->motion_parser[MC_FRAME] = motion_mp1; decoder->motion_parser[4] = motion_reuse_420; } else if (decoder->picture_structure == FRAME_PICTURE) { if (decoder->chroma_format == 0) { decoder->motion_parser[0] = motion_zero_420; decoder->motion_parser[MC_FIELD] = motion_fr_field_420; decoder->motion_parser[MC_FRAME] = motion_fr_frame_420; decoder->motion_parser[MC_DMV] = motion_fr_dmv_420; decoder->motion_parser[4] = motion_reuse_420; } else if (decoder->chroma_format == 1) { decoder->motion_parser[0] = motion_zero_422; decoder->motion_parser[MC_FIELD] = motion_fr_field_422; decoder->motion_parser[MC_FRAME] = motion_fr_frame_422; decoder->motion_parser[MC_DMV] = motion_fr_dmv_422; decoder->motion_parser[4] = motion_reuse_422; } else { decoder->motion_parser[0] = motion_zero_444; decoder->motion_parser[MC_FIELD] = motion_fr_field_444; decoder->motion_parser[MC_FRAME] = motion_fr_frame_444; decoder->motion_parser[MC_DMV] = motion_fr_dmv_444; decoder->motion_parser[4] = motion_reuse_444; } } else { if (decoder->chroma_format == 0) { decoder->motion_parser[0] = motion_zero_420; decoder->motion_parser[MC_FIELD] = motion_fi_field_420; decoder->motion_parser[MC_16X8] = motion_fi_16x8_420; decoder->motion_parser[MC_DMV] = motion_fi_dmv_420; decoder->motion_parser[4] = motion_reuse_420; } else if (decoder->chroma_format == 1) { decoder->motion_parser[0] = motion_zero_422; decoder->motion_parser[MC_FIELD] = motion_fi_field_422; decoder->motion_parser[MC_16X8] = motion_fi_16x8_422; decoder->motion_parser[MC_DMV] = motion_fi_dmv_422; decoder->motion_parser[4] = motion_reuse_422; } else { decoder->motion_parser[0] = motion_zero_444; decoder->motion_parser[MC_FIELD] = motion_fi_field_444; decoder->motion_parser[MC_16X8] = motion_fi_16x8_444; decoder->motion_parser[MC_DMV] = motion_fi_dmv_444; decoder->motion_parser[4] = motion_reuse_444; } }}#elsevoid mpeg2_init_fbuf (mpeg2_decoder_t * decoder, uint8_t * current_fbuf[3], uint8_t * forward_fbuf[3], uint8_t * backward_fbuf[3]){ int offset, stride, height, bottom_field; static unsigned long ulFrameNumber; stride = decoder->stride_frame; bottom_field = (decoder->picture_structure == BOTTOM_FIELD); offset = bottom_field ? stride : 0; height = decoder->height; decoder->picture_dest[0] = current_fbuf[0] + offset; decoder->picture_dest[1] = current_fbuf[1] + (offset >> 1); decoder->picture_dest[2] = current_fbuf[2] + (offset >> 1); // $PP // destination pointers for MAE must be FRAME pointers and NOT field pointer // hence store the frame pointers decoder->pict_dest[0] = decoder->picture_dest[0]; decoder->pict_dest[1] = decoder->picture_dest[1]; decoder->pict_dest[2] = decoder->picture_dest[2];#ifndef DRV_ENABLED if (decoder->coding_type == B_TYPE) { decoder->pict_dest[0] = decoder->pYOut + offset; decoder->pict_dest[1] = decoder->pCbOut + (offset >> 1); decoder->pict_dest[2] = decoder->pCrOut + (offset >> 1); }#else if(decoder->bUseMAE) { // Nothing to do } else { if (decoder->coding_type == B_TYPE) { decoder->pict_dest[0] = decoder->pYOut + offset; decoder->pict_dest[1] = decoder->pCbOut + (offset >> 1); decoder->pict_dest[2] = decoder->pCrOut + (offset >> 1); } }#endif#ifdef NO_PERF if (ucMarkFrameSet == 0) { WriteFrame (decoder, MARK_START, 0); ucMarkFrameSet = 1; ulFrameNumber = decoder->iFrameCount; } if ( (ucMarkFieldSet == 0) && (decoder->picture_structure != FRAME_PICTURE) && (decoder->iFrameCount == (ulFrameNumber + 1)) ) { WriteFrame (decoder, MARK_FIELD_START, 0); ucMarkFieldSet = 1; }#endif //#ifdef NO_PERF decoder->f_motion.ref[0][0] = forward_fbuf[0] + offset; decoder->f_motion.ref[0][1] = forward_fbuf[1] + (offset >> 1); decoder->f_motion.ref[0][2] = forward_fbuf[2] + (offset >> 1); decoder->b_motion.ref[0][0] = backward_fbuf[0] + offset; decoder->b_motion.ref[0][1] = backward_fbuf[1] + (offset >> 1); decoder->b_motion.ref[0][2] = backward_fbuf[2] + (offset >> 1); if (decoder->picture_structure != FRAME_PICTURE) { decoder->dmv_offset = bottom_field ? 1 : -1; decoder->f_motion.ref2[0] = decoder->f_motion.ref[bottom_field]; decoder->f_motion.ref2[1] = decoder->f_motion.ref[!bottom_field]; decoder->b_motion.ref2[0] = decoder->b_motion.ref[bottom_field]; decoder->b_motion.ref2[1] = decoder->b_motion.ref[!bottom_field]; offset = stride - offset; if (decoder->second_field && (decoder->coding_type != B_TYPE)) forward_fbuf = current_fbuf; decoder->f_motion.ref[1][0] = forward_fbuf[0] + offset; decoder->f_motion.ref[1][1] = forward_fbuf[1] + (offset >> 1); decoder->f_motion.ref[1][2] = forward_fbuf[2] + (offset >> 1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -