📄 umc_h264_dec_decode_reconstruct.cpp
字号:
//bClearNC = false; } m_cur_mb.LocalMacroblockInfo->QP = QPFromCode(m_cur_mb.LocalMacroblockInfo->QP); quant_prev = m_cur_mb.LocalMacroblockInfo->QP; break; } // while 1 } // if MBSkipCount <= 0 // quit if error detected if (status != UMC_OK) break; // Note DecodeMacroBlockType above will change MBSkipCount value if (MBSkipCount) { if (mbaff) { if (pGetMBBottomFlag(m_cur_mb.GlobalMacroblockInfo)==0) { if (m_cur_mb.CurrentMacroblockNeighbours.mb_A>=0) { pSetMBFieldDecodingFlag(m_cur_mb.GlobalMacroblockInfo,GetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.mbs[m_cur_mb.CurrentMacroblockNeighbours.mb_A])); } else if (m_cur_mb.CurrentMacroblockNeighbours.mb_B>=0) { pSetMBFieldDecodingFlag(m_cur_mb.GlobalMacroblockInfo,GetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.mbs[m_cur_mb.CurrentMacroblockNeighbours.mb_B])); } else { pSetMBFieldDecodingFlag(m_cur_mb.GlobalMacroblockInfo,0); //probably doesn't needed } if (MBSkipCount==1) { Ipp32u bit = m_pBitStream->Get1Bit(); pSetPairMBFieldDecodingFlag(m_cur_mb.GlobalMacroblockInfo,m_cur_mb.GlobalMacroblockPairInfo,bit); PassFDFDecode = 1; } } else { pSetMBFieldDecodingFlag(m_cur_mb.GlobalMacroblockInfo,pGetMBFieldDecodingFlag(m_cur_mb.GlobalMacroblockPairInfo)); } } mbtype = m_cur_mb.GlobalMacroblockInfo->mbtype = MBTYPE_SKIPPED; UpdateNeighbouringBlocks();//new version // skip MB, set up MB vars for correct decoding. If not a B slice, // treat MB as 16x16 INTER with no coefficients, need to compute // motion vector. If B slice, treat MB as DIRECT with no coefficients. if (!bIsBSlice) { bClearMV = DecodeSkipMotionVectors(); } MBSkipCount--; if (MBSkipCount == 0) MBSkipCount = -1; // signal to DecodeMacroBlockType that skip run just completed } if (status != UMC_OK) break; if (bIsBSlice && (m_cur_mb.GlobalMacroblockInfo->mbtype == MBTYPE_SKIPPED || m_cur_mb.GlobalMacroblockInfo->mbtype == MBTYPE_DIRECT)) { // set DIRECT motion vectors for the MB if (!m_bUseSpatialDirectMode) { // temporal prediction Ipp32s yM=0; Ipp32s mb_col = GetColocatedLocation(pRefPicList1[0],0,yM); if (!bUseDirect8x8Inference && IS_INTER_MBTYPE(pRefPicList1[0]->m_mbinfo.mbs[mb_col].mbtype)) DecodeDirectMotionVectorsTemporal(/*pMB,*/0, pRefPicList0, pRefPicList1,&pFields_stub,&pFields_stub, false); else DecodeDirectMotionVectorsTemporal_8x8Inference(/*pMB,*/ pRefPicList0, pRefPicList1,&pFields_stub,&pFields_stub, -1); } else { // spatial prediction DecodeDirectMotionVectorsSpatial(/*pMB,*/ pRefPicList0, pRefPicList1,0, bUseDirect8x8Inference); } bClearMV = false; } if (bClearMV) { //++++++++++++++++++++++++++++++++++++++++++ // zero out stored motion vectors. 4 mvx,mvy pairs, 4 rows // also init ref index to -1 for all subblocks (4 bytes per row) // or to 0 when MB was P frame skipped. // pMV is 8-byte aligned for a MB H264DecoderMacroblockMVs *pMV = m_cur_mb.MVs[0]; H264DecoderMacroblockRefIdxs *pRefIndex = m_cur_mb.RefIdxs[0]; // zero out stored motion vectors. 4 mvx,mvy pairs, 4 rows // also init ref index to -1 for all subblocks (4 bytes per row) // or to 0 when MB was P frame skipped. // pMV is 8-byte aligned for a MB if ((m_cur_mb.GlobalMacroblockInfo->mbtype == MBTYPE_SKIPPED) && !bIsBSlice) memset((void *)pRefIndex,0,sizeof(H264DecoderMacroblockRefIdxs)); else memset((void *)pRefIndex,-1,sizeof(H264DecoderMacroblockRefIdxs)); memset((void *)pMV, 0, sizeof(H264DecoderMacroblockMVs));//clear all 16 vectors if (bIsBSlice) { // INTRA MB in B slice // zero MV in backward MV storage for all subblocks pMV = m_cur_mb.MVs[1]; memset((void *)pMV, 0, sizeof(H264DecoderMacroblockMVs));//clear all 16 vectors } }// reconstruct starts here // Perform motion compensation to reconstruct the YUV data // offsetY = mbXOffset + (mbYOffset * uPitch); offsetC = offsetY >> 1; intra = bool(IS_INTRA_MBTYPE(mbtype)); intra16x16 = bool(mbtype == MBTYPE_INTRA_16x16); QPChromaIndex = m_cur_mb.LocalMacroblockInfo->QP + ChromaQPOffset; QPChromaIndex = MIN(QPChromaIndex, (Ipp32s)QP_MAX); QPChromaIndex = MAX(0, QPChromaIndex); QPChroma = QPtoChromaQP[QPChromaIndex]; if (intra) { if (mbtype != MBTYPE_PCM) { Ipp8u edge_type = 0; Ipp8u edge_type_2t = 0; Ipp8u edge_type_2b = 0; Ipp32s nLeft, nTop, nTopLeft, nTopRight; Ipp32u rec_pitch = uPitch; Ipp8u special_MBAFF_case =0; nLeft = m_cur_mb.CurrentBlockNeighbours.mbs_left[0].mb_num; nTop = m_cur_mb.CurrentBlockNeighbours.mb_above.mb_num; nTopLeft = m_cur_mb.CurrentBlockNeighbours.mb_above_left.mb_num; nTopRight = m_cur_mb.CurrentBlockNeighbours.mb_above_right.mb_num; if (mbaff) { Ipp8u currmb_fdf = pGetMBFieldDecodingFlag(m_cur_mb.GlobalMacroblockInfo); Ipp8u currmb_bf = pGetMBBottomFlag(m_cur_mb.GlobalMacroblockInfo); if (bUseConstrainedIntra) { Ipp8u mbA_fdf=1; Ipp8u mbA_is_intra=0; Ipp8u mbpA_is_intra=0; if (nLeft>=0) { mbA_fdf = GetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.mbs[m_cur_mb.CurrentMacroblockNeighbours.mb_A]); mbA_is_intra = IS_INTRA_MBTYPE(m_pCurrentFrame->m_mbinfo.mbs[m_cur_mb.CurrentMacroblockNeighbours.mb_A].mbtype); mbpA_is_intra = IS_INTRA_MBTYPE(m_pCurrentFrame->m_mbinfo.mbs[m_cur_mb.CurrentMacroblockNeighbours.mb_A+mb_width].mbtype); } if (currmb_fdf) {//current mb coded as field MB if (!mbA_fdf) {//(special case is allowed only in this branch) if (mbA_is_intra && !mbpA_is_intra) special_MBAFF_case = 1;//only 2 top blocks can use left samples if (!mbA_is_intra && mbpA_is_intra) special_MBAFF_case = 2;//only 2 bottom blocks can use left samples } if (currmb_bf) { offsetY -= 15 * rec_pitch; offsetC -= 7 * rec_pitch; } rec_pitch *= 2; } switch (special_MBAFF_case) { case 1: if (0 > nTop) edge_type_2t |= IPPVC_TOP_EDGE; else if (!IS_INTRA_MBTYPE(m_pCurrentFrame->m_mbinfo.mbs[nTop].mbtype)) edge_type_2t |= IPPVC_TOP_EDGE; if (0 > nTopLeft) edge_type_2t |= IPPVC_TOP_LEFT_EDGE; else if (!IS_INTRA_MBTYPE(m_pCurrentFrame->m_mbinfo.mbs[nTopLeft].mbtype)) edge_type_2t |= IPPVC_TOP_LEFT_EDGE; if (0 > nTopRight) edge_type_2t |= IPPVC_TOP_RIGHT_EDGE; else if (!IS_INTRA_MBTYPE(m_pCurrentFrame->m_mbinfo.mbs[nTopRight].mbtype)) edge_type_2t |= IPPVC_TOP_RIGHT_EDGE; edge_type_2b = IPPVC_LEFT_EDGE | IPPVC_TOP_RIGHT_EDGE; break; case 2: edge_type_2t |= IPPVC_LEFT_EDGE; if (0 > nTop) edge_type_2t |= IPPVC_TOP_EDGE; else if (!IS_INTRA_MBTYPE(m_pCurrentFrame->m_mbinfo.mbs[nTop].mbtype)) edge_type_2t |= IPPVC_TOP_EDGE; if (0 > nTopLeft) edge_type_2t |= IPPVC_TOP_LEFT_EDGE; else if (!IS_INTRA_MBTYPE(m_pCurrentFrame->m_mbinfo.mbs[nTopLeft].mbtype)) edge_type_2t |= IPPVC_TOP_LEFT_EDGE; if (0 > nTopRight) edge_type_2t |= IPPVC_TOP_RIGHT_EDGE; else if (!IS_INTRA_MBTYPE(m_pCurrentFrame->m_mbinfo.mbs[nTopRight].mbtype)) edge_type_2t |= IPPVC_TOP_RIGHT_EDGE; edge_type_2b = IPPVC_TOP_LEFT_EDGE | IPPVC_TOP_RIGHT_EDGE; break; default: if (0 > nLeft) edge_type |= IPPVC_LEFT_EDGE; else { if (!IS_INTRA_MBTYPE(m_pCurrentFrame->m_mbinfo.mbs[nLeft].mbtype)) edge_type |= IPPVC_LEFT_EDGE; if (mbA_fdf && !currmb_fdf && (!mbpA_is_intra || !mbA_is_intra)) edge_type |= IPPVC_LEFT_EDGE; } if (0 > nTop) edge_type |= IPPVC_TOP_EDGE; else if (!IS_INTRA_MBTYPE(m_pCurrentFrame->m_mbinfo.mbs[nTop].mbtype)) edge_type |= IPPVC_TOP_EDGE; if (0 > nTopLeft) edge_type |= IPPVC_TOP_LEFT_EDGE; else if (!IS_INTRA_MBTYPE(m_pCurrentFrame->m_mbinfo.mbs[nTopLeft].mbtype)) edge_type |= IPPVC_TOP_LEFT_EDGE; if (0 > nTopRight) edge_type |= IPPVC_TOP_RIGHT_EDGE; else if (!IS_INTRA_MBTYPE(m_pCurrentFrame->m_mbinfo.mbs[nTopRight].mbtype)) edge_type |= IPPVC_TOP_RIGHT_EDGE; break; } } else { if (currmb_fdf) {//current mb coded as field MB if (currmb_bf) { offsetY -= 15 * rec_pitch; offsetC -= 7 * rec_pitch; } rec_pitch *= 2; } if (0 > nLeft) edge_type |= IPPVC_LEFT_EDGE; if (0 > nTop) edge_type |= IPPVC_TOP_EDGE; if (0 > nTopLeft) edge_type |= IPPVC_TOP_LEFT_EDGE; if (0 > nTopRight) edge_type |= IPPVC_TOP_RIGHT_EDGE; } } else { if (bUseConstrainedIntra) { if (0 > nLeft) edge_type |= IPPVC_LEFT_EDGE; else if (!IS_INTRA_MBTYPE(m_pCurrentFrame->m_mbinfo.mbs[nLeft].mbtype)) edge_type |= IPPVC_LEFT_EDGE; if (0 > nTop) edge_type |= IPPVC_TOP_EDGE; else if (!IS_INTRA_MBTYPE(m_pCurrentFrame->m_mbinfo.mbs[nTop].mbtype)) edge_type |= IPPVC_TOP_EDGE; if (0 > nTopLeft) edge_type |= IPPVC_TOP_LEFT_EDGE; else if (!IS_INTRA_MBTYPE(m_pCurrentFrame->m_mbinfo.mbs[nTopLeft].mbtype)) edge_type |= IPPVC_TOP_LEFT_EDGE; if (0 > nTopRight) edge_type |= IPPVC_TOP_RIGHT_EDGE; else if (!IS_INTRA_MBTYPE(m_pCurrentFrame->m_mbinfo.mbs[nTopRight].mbtype)) edge_type |= IPPVC_TOP_RIGHT_EDGE; } else { if (0 > nLeft) edge_type |= IPPVC_LEFT_EDGE; if (0 > nTop) edge_type |= IPPVC_TOP_EDGE; if (0 > nTopLeft) edge_type |= IPPVC_TOP_LEFT_EDGE; if (0 > nTopRight) edge_type |= IPPVC_TOP_RIGHT_EDGE; } } // reconstruct luma block(s) if (intra16x16) { sts = ippiReconstructLumaIntra16x16MB_H264_16s8u_C1R( &m_pCoeffBlocksRead, pYPlane + offsetY, rec_pitch, (IppIntra16x16PredMode_H264) pMBIntraTypes[0], m_cur_mb.LocalMacroblockInfo->cbp4x4, m_cur_mb.LocalMacroblockInfo->QP,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -