📄 umc_h264_ermb.cpp
字号:
//pDQBuf = (Ipp16s*) (pQBuf + 16); pDCBuf = (Ipp16s*) (pQBuf + 16); // Used for both luma and chroma DC blocks pMassDiffBuf= (Ipp16s*) (pDCBuf+ 16); if (uTotalCoeffs != 0) { // Force block empty if this is a recoding based uTotalCoeffs = 0; // on insufficient total coeffs uCBP4x4 = 0; } //-------------------------------------------------------------------------- // encode Y plane blocks (0-15) //-------------------------------------------------------------------------- // initialize pointers and offset pSrcPlane = m_pCurrentFrame->m_pYPlane; pRecPlane = m_pReconstructFrame->m_pYPlane; // get AI/MV array index for first block of the MB uIndex = m_pCurrentFrame->pMBOffsets[uMB].uFirstBlockIndex; uOffset = m_pCurrentFrame->pMBOffsets[uMB].uLumaOffset + m_pCurrentFrame->y_line_shift; // Motion Compensate this MB MCOneMBLuma(uMB, uPitch, &m_pCurrentFrame->pMVL0[uIndex], &m_pCurrentFrame->pMVL1[uIndex], pPredBuf, &m_pCurrentFrame->pMBData[uMB]); // loop over all 4x4 blocks in Y plane for the MB for (uBlock = 0; uBlock < 16; ) { pPredBuf = m_pCurrentFrame->pMBEncodeBuffer + xoff[uBlock] + yoff[uBlock]*16; m_pCurrentFrame->pYNumCoeffs[uIndex] = 0; // These will be updated if the block is coded if (m_PicParamSet.entropy_coding_mode) { m_pCurrentFrame->Block_CABAC[uBlock].uNumSigCoeffs = 0; } else { m_pCurrentFrame->Block_RLE[uBlock].uNumCoeffs = 0; m_pCurrentFrame->Block_RLE[uBlock].uTrailing_Ones = 0; m_pCurrentFrame->Block_RLE[uBlock].uTrailing_One_Signs = 0; m_pCurrentFrame->Block_RLE[uBlock].uTotalZeros = 16; } // check if block is coded bCoded = ((uCBP4x4 & CBP4x4Mask[uBlock])?(1):(0)); if (!bCoded) { // update reconstruct frame for the empty block Copy4x4( pPredBuf, // predictor block uPitch, pRecPlane + uOffset); // reconstruct frame } else { // block not declared empty, encode // compute difference of predictor and source pels // note: asm version does not use pDiffBuf // output is being passed in the mmx registers Diff4x4( pPredBuf, // predictor pels pSrcPlane + uOffset, // source pels uPitch, // source pitch pDiffBuf); // result buffer // forward transform, in place in iDiffBuf // note: asm version does not use pDiffBuf // input and output are being passed in the mmx reg.s //Transform4x4(pDiffBuf); // quantization and dequantization // note: asm version does not use pDiffBuf and pDQBuf // these values are being passed in the mmx registers ippiTransformQuantResidual_H264_16s_C1I(pDiffBuf,uMBQP,&iNumCoeffs,0, enc_single_scan[m_PicParamSet.picture_structure != FRAME_PICTURE],&uLastCoeff); // if everything quantized to zero, skip RLE if (!iNumCoeffs) { // the block is empty so it is not coded bCoded = 0; } else { // Preserve the absolute number of coeffs. m_pCurrentFrame->pYNumCoeffs[uIndex] = (T_NumCoeffs)ABS(iNumCoeffs); uTotalCoeffs += ((iNumCoeffs < 0) ? -(iNumCoeffs*2) : iNumCoeffs); // record RLE info if (m_PicParamSet.entropy_coding_mode) { int ctxIdxBlockCat = BLOCK_LUMA_LEVELS; ScanSignificant_CABAC(pDiffBuf,ctxIdxBlockCat,16, dec_single_scan[m_PicParamSet.picture_structure != FRAME_PICTURE], &m_pCurrentFrame->Block_CABAC[uBlock]); bCoded = m_pCurrentFrame->Block_CABAC[uBlock].uNumSigCoeffs; } else { ippiEncodeCoeffsCAVLC_H264_16s ( pDiffBuf, 0, dec_single_scan[m_PicParamSet.picture_structure != FRAME_PICTURE], uLastCoeff, &m_pCurrentFrame->Block_RLE[uBlock].uTrailing_Ones, &m_pCurrentFrame->Block_RLE[uBlock].uTrailing_One_Signs, &m_pCurrentFrame->Block_RLE[uBlock].uNumCoeffs, &m_pCurrentFrame->Block_RLE[uBlock].uTotalZeros, m_pCurrentFrame->Block_RLE[uBlock].iLevels, m_pCurrentFrame->Block_RLE[uBlock].uRuns); m_pCurrentFrame->pYNumCoeffs[uIndex] = bCoded = m_pCurrentFrame->Block_RLE[uBlock].uNumCoeffs;// } //bCoded = RLE( // pDiffBuf, // quantized coeffs in scan order // 16, // number of coeffs // &m_pCurrentFrame->Block_RLE[uBlock] // where to put RLE data // ); } // update flags if block quantized to empty if (!bCoded) { uCBP4x4 &= ~CBP4x4Mask[uBlock]; // update reconstruct frame for the empty block Copy4x4( pPredBuf, // predictor block uPitch, pRecPlane + uOffset); // reconstruct frame } else { // inverse transform for reconstruct AND... // add inverse transformed coefficients to original predictor // to obtain reconstructed block, store in reconstruct frame // buffer ippiDequantTransformResidualAndAdd_H264_16s_C1I ( pPredBuf, pDiffBuf, NULL, pRecPlane + uOffset, 16, uPitch, uMBQP, ((iNumCoeffs < -1) || (iNumCoeffs > 0)));/* m_pITransformAndAdd( pPredBuf, // predictor pels pDQBuf, // error pels pRecPlane + uOffset,// reconstruction pels 16, // predictor pitch uPitch, // reconstruction pitch ((iNumCoeffs < -1) || (iNumCoeffs > 0)) );*/ } } // block not declared empty // proceed to the next block uIndex += m_EncBlockIndexInc[uBlock]; uOffset += m_EncBlockOffsetInc[uBlock]; uBlock ++; } // for uBlock in luma plane //-------------------------------------------------------------------------- // encode U plane blocks (16-19) then V plane blocks (20-23) //-------------------------------------------------------------------------- if ((uCBP4x4 & 0xffff) == 0) uCBP4x4 = 0; m_pCurrentFrame->pMBData[uMB].uChromaNC = 0; uOffset = m_pCurrentFrame->pMBOffsets[uMB].uChromaOffset + m_pCurrentFrame->uv_line_shift; // initialize pointers for the U plane blocks Ipp32u uLastBlock = 20; pSrcPlane = m_pCurrentFrame->m_pUPlane; pRecPlane = m_pReconstructFrame->m_pUPlane; bool is_v_plane = false; // encode first chroma U plane then V plane do { T_NumCoeffs *pNumCoeffs; // This holds pointer to appropriate array uOffset = m_pCurrentFrame->pMBOffsets[uMB].uChromaOffset + m_pCurrentFrame->uv_line_shift; uIndex = m_pCurrentFrame->pMBOffsets[uMB].uFirstChromaBlockIndex; // Adjust the pPredBuf to point at the V plane predictor when appropriate: // (blocks 20-23 and an INTRA Y plane mode...) if (uBlock == 20) { pPredBuf = m_pCurrentFrame->pMBEncodeBuffer+(8*16); RLE_Offset = V_DC_RLE; pNumCoeffs = m_pCurrentFrame->pVNumCoeffs; } else { pPredBuf = m_pCurrentFrame->pMBEncodeBuffer; RLE_Offset = U_DC_RLE; pNumCoeffs = m_pCurrentFrame->pUNumCoeffs; } // Motion Compensate one chroma MB MCOneMBChroma(uMB, uPitch, &m_pCurrentFrame->pMVL0[m_pCurrentFrame->pMBOffsets[uMB].uFirstBlockIndex], &m_pCurrentFrame->pMVL1[m_pCurrentFrame->pMBOffsets[uMB].uFirstBlockIndex], pPredBuf, &m_pCurrentFrame->pMBData[uMB], is_v_plane); // Process the 2x2 block of DC coeffs // "pre-Calc" DC coeffs ippiSumsDiff8x8Blocks4x4_8u16s_C1( pSrcPlane + uOffset, // source pels uPitch, // source pitch pPredBuf, // predictor pels 16, pDCBuf,pMassDiffBuf); // result buffer // 2x2 forward transform ippiTransformQuantChromaDC_H264_16s_C1I(pDCBuf, pQBuf, QPtoChromaQP[uMBQP],&iNumCoeffs,(m_SliceHeader.slice_type == INTRASLICE),1); // DC values in this block if iNonEmpty is 1. m_pCurrentFrame->pMBData[uMB].uChromaNC |= (iNumCoeffs != 0); // record RLE info if (m_PicParamSet.entropy_coding_mode) { int ctxIdxBlockCat = BLOCK_CHROMA_DC_LEVELS; ScanSignificant_CABAC(pDCBuf,ctxIdxBlockCat,4,dec_single_scan_p,&m_pCurrentFrame->Block_CABAC[RLE_Offset]); bCoded = m_pCurrentFrame->Block_CABAC[RLE_Offset].uNumSigCoeffs; } else { ippiEncodeChromaDcCoeffsCAVLC_H264_16s ( pDCBuf, &m_pCurrentFrame->Block_RLE[RLE_Offset].uTrailing_Ones, &m_pCurrentFrame->Block_RLE[RLE_Offset].uTrailing_One_Signs, &m_pCurrentFrame->Block_RLE[RLE_Offset].uNumCoeffs, &m_pCurrentFrame->Block_RLE[RLE_Offset].uTotalZeros, m_pCurrentFrame->Block_RLE[RLE_Offset].iLevels, m_pCurrentFrame->Block_RLE[RLE_Offset].uRuns); bCoded = m_pCurrentFrame->Block_RLE[RLE_Offset].uNumCoeffs; } //bCoded = RLE( // pDCBuf, // quantized coeffs in scan order // 4, // number of coeffs // &m_pCurrentFrame->Block_RLE[RLE_Offset] // where to put RLE data // ); ippiTransformDequantChromaDC_H264_16s_C1I (pDCBuf, QPtoChromaQP[uMBQP]); // loop over all 4x4 blocks in one chroma plane for the MB for (; uBlock < uLastBlock; uBlock ++) { pNumCoeffs[uIndex] = 0; // This will be updated if the block is coded if (m_PicParamSet.entropy_coding_mode) { m_pCurrentFrame->Block_CABAC[uBlock].uNumSigCoeffs = 0; } else { m_pCurrentFrame->Block_RLE[uBlock].uNumCoeffs = 0; m_pCurrentFrame->Block_RLE[uBlock].uTrailing_Ones = 0; m_pCurrentFrame->Block_RLE[uBlock].uTrailing_One_Signs = 0; m_pCurrentFrame->Block_RLE[uBlock].uTotalZeros = 15; } // check if block is coded bCoded = ((uCBP4x4 & CBP4x4Mask[uBlock])?(1):(0)); if (!uCBP4x4) // If the whole block is empty { // update reconstruct frame for the empty block Copy4x4( pPredBuf, // predictor block uPitch, pRecPlane + uOffset); // reconstruct frame } else { // block not declared empty, encode // compute difference of predictor and source pels // note: asm version does not used pDiffBuf // output is being passed in the mmx registers //Diff4x4( // pPredBuf, // predictor pels //
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -