⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ippvideoencodermpeg4_vop.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
inline void ippVideoEncoderMPEG4::EncodeMacroBlockIntra_DC_MPEG4(Ipp16s *coeffMB){    int  i;    for (i = 0; i < 6; i ++) {        ippiEncodeDCIntra_MPEG4_16s1u(coeffMB[i*64], &cBS.mPtr, &cBS.mBitOff, (i < 4) ? IPPVC_BLOCK_LUMA : IPPVC_BLOCK_CHROMA);    }}inline void ippVideoEncoderMPEG4::EncodeMacroBlockIntra_AC_MPEG4(Ipp16s *coeffMB, int *predDir, int use_intra_dc_vlc, int pattern, int *nzCount){    int  i, nzc, pm = 32;    for (i = 0; i < 6; i ++) {        if (pattern & pm) {            nzc = nzCount[i];            if (use_intra_dc_vlc && (coeffMB[i*64] != 0))                nzc --;            ippiEncodeCoeffsIntra_MPEG4_16s1u(coeffMB+i*64, &cBS.mPtr, &cBS.mBitOff, nzc, VOL.reversible_vlc, use_intra_dc_vlc, predDir[i]);        }        pm >>= 1;    }}inline void ippVideoEncoderMPEG4::ReconMacroBlockNotCoded(Ipp8u *pYc, Ipp8u *pUc, Ipp8u *pVc, Ipp8u *mcPred){    if (mCalcPSNR) {        mPSNR_Y += mp4_CalcMSE_16x16(mcPred, 16, pYc, mStepLuma);        mPSNR_U += mp4_CalcMSE_8x8(mcPred+64*4, 8, pUc, mStepChroma);        mPSNR_V += mp4_CalcMSE_8x8(mcPred+64*5, 8, pVc, mStepChroma);    }    ippiCopy16x16_8u_C1R(mcPred, 16, pYc, mStepLuma);    ippiCopy8x8_8u_C1R(mcPred+64*4, 8, pUc, mStepChroma);    ippiCopy8x8_8u_C1R(mcPred+64*5, 8, pVc, mStepChroma);}void ippVideoEncoderMPEG4::ReconMacroBlockIntra_H263(Ipp8u *pY, Ipp8u *pU, Ipp8u *pV, Ipp16s *coeffMB, int quant, int pattern){    __ALIGN16(Ipp8u, pDec, 64*6);    if (mCalcPSNR) {        ippiCopy16x16_8u_C1R(pY, mStepLuma, pDec, 16);        ippiCopy8x8_8u_C1R(pU, mStepChroma, pDec+256, 8);        ippiCopy8x8_8u_C1R(pV, mStepChroma, pDec+320, 8);    }    if (pattern & 32) {        ippiQuantInvIntra_H263_16s_C1I(coeffMB+0*64, 63, quant, 0, 0);        ippiDCT8x8Inv_16s8u_C1R(coeffMB+0*64, pY, mStepLuma);    } else {        mp4_Set8x8_8u(pY, mStepLuma, (Ipp8u)coeffMB[0*64]);    }    if (pattern & 16) {        ippiQuantInvIntra_H263_16s_C1I(coeffMB+1*64, 63, quant, 0, 0);        ippiDCT8x8Inv_16s8u_C1R(coeffMB+1*64, pY+8, mStepLuma);    } else {        mp4_Set8x8_8u(pY+8, mStepLuma, (Ipp8u)coeffMB[1*64]);    }    if (pattern & 8) {        ippiQuantInvIntra_H263_16s_C1I(coeffMB+2*64, 63, quant, 0, 0);        ippiDCT8x8Inv_16s8u_C1R(coeffMB+2*64, pY+8*mStepLuma, mStepLuma);    } else {        mp4_Set8x8_8u(pY+8*mStepLuma, mStepLuma, (Ipp8u)coeffMB[2*64]);    }    if (pattern & 4) {        ippiQuantInvIntra_H263_16s_C1I(coeffMB+3*64, 63, quant, 0, 0);        ippiDCT8x8Inv_16s8u_C1R(coeffMB+3*64, pY+8*mStepLuma+8, mStepLuma);    } else {        mp4_Set8x8_8u(pY+8*mStepLuma+8, mStepLuma, (Ipp8u)coeffMB[3*64]);    }    if (pattern & 2) {        ippiQuantInvIntra_H263_16s_C1I(coeffMB+4*64, 63, quant, 0, 0);        ippiDCT8x8Inv_16s8u_C1R(coeffMB+4*64, pU, mStepChroma);    } else {        mp4_Set8x8_8u(pU, mStepChroma, (Ipp8u)coeffMB[4*64]);    }    if (pattern & 1) {        ippiQuantInvIntra_H263_16s_C1I(coeffMB+5*64, 63, quant, 0, 0);        ippiDCT8x8Inv_16s8u_C1R(coeffMB+5*64, pV, mStepChroma);    } else {        mp4_Set8x8_8u(pV, mStepChroma, (Ipp8u)coeffMB[5*64]);    }    if (mCalcPSNR) {        mPSNR_Y += mp4_CalcMSE_16x16(pY, mStepLuma, pDec, 16);        mPSNR_U += mp4_CalcMSE_8x8(pU, mStepChroma, pDec+256, 8);        mPSNR_V += mp4_CalcMSE_8x8(pV, mStepChroma, pDec+320, 8);    }}void ippVideoEncoderMPEG4::ReconMacroBlockInter_H263(Ipp8u *pYc, Ipp8u *pUc, Ipp8u *pVc, Ipp8u *mcPred, Ipp16s *coeffMB, int quant, int pattern){    if (pattern & 32) {        ippiQuantInvInter_H263_16s_C1I(coeffMB+0*64, 63, quant, 0);        ippiDCT8x8Inv_16s_C1I(coeffMB+0*64);        mp4_Add8x8_16s8u(mcPred, coeffMB+0*64, 16);    }    if (pattern & 16) {        ippiQuantInvInter_H263_16s_C1I(coeffMB+1*64, 63, quant, 0);        ippiDCT8x8Inv_16s_C1I(coeffMB+1*64);        mp4_Add8x8_16s8u(mcPred+8, coeffMB+1*64, 16);    }    if (pattern & 8) {        ippiQuantInvInter_H263_16s_C1I(coeffMB+2*64, 63, quant, 0);        ippiDCT8x8Inv_16s_C1I(coeffMB+2*64);        mp4_Add8x8_16s8u(mcPred+16*8, coeffMB+2*64, 16);    }    if (pattern & 4) {        ippiQuantInvInter_H263_16s_C1I(coeffMB+3*64, 63, quant, 0);        ippiDCT8x8Inv_16s_C1I(coeffMB+3*64);        mp4_Add8x8_16s8u(mcPred+16*8+8, coeffMB+3*64, 16);    }    if (pattern & 2) {        ippiQuantInvInter_H263_16s_C1I(coeffMB+4*64, 63, quant, 0);        ippiDCT8x8Inv_16s_C1I(coeffMB+4*64);        mp4_Add8x8_16s8u(mcPred+64*4, coeffMB+4*64, 8);    }    if (pattern & 1) {        ippiQuantInvInter_H263_16s_C1I(coeffMB+5*64, 63, quant, 0);        ippiDCT8x8Inv_16s_C1I(coeffMB+5*64);        mp4_Add8x8_16s8u(mcPred+64*5, coeffMB+5*64, 8);    }    if (mCalcPSNR) {        mPSNR_Y += mp4_CalcMSE_16x16(pYc, mStepLuma, mcPred, 16);        mPSNR_U += mp4_CalcMSE_8x8(pUc, mStepChroma, mcPred+64*4, 8);        mPSNR_V += mp4_CalcMSE_8x8(pVc, mStepChroma, mcPred+64*5, 8);    }    ippiCopy16x16_8u_C1R(mcPred, 16, pYc, mStepLuma);    ippiCopy8x8_8u_C1R(mcPred+64*4, 8, pUc, mStepChroma);    ippiCopy8x8_8u_C1R(mcPred+64*5, 8, pVc, mStepChroma);}void ippVideoEncoderMPEG4::ReconMacroBlockIntra_MPEG4(Ipp8u *pY, Ipp8u *pU, Ipp8u *pV, Ipp16s *coeffMB, int quant, mp4_MacroBlock *MBcurr, int pattern, int dct_type){    __ALIGN16(Ipp8u, pDec, 64*6);    int   yOff23, yStep, dc;    if (mCalcPSNR) {        ippiCopy16x16_8u_C1R(pY, mStepLuma, pDec, 16);        ippiCopy8x8_8u_C1R(pU, mStepChroma, pDec+256, 8);        ippiCopy8x8_8u_C1R(pV, mStepChroma, pDec+320, 8);    }    if (!dct_type) {        yOff23 = mStepLuma * 8;        yStep = mStepLuma;    } else {        yOff23 = mStepLuma;        yStep = mStepLuma * 2;    }    coeffMB[0*64] = MBcurr->block[0].dct_dcq;    coeffMB[1*64] = MBcurr->block[1].dct_dcq;    coeffMB[2*64] = MBcurr->block[2].dct_dcq;    coeffMB[3*64] = MBcurr->block[3].dct_dcq;    coeffMB[4*64] = MBcurr->block[4].dct_dcq;    coeffMB[5*64] = MBcurr->block[5].dct_dcq;    if (pattern & 32) {        ippiQuantInvIntra_MPEG4_16s_C1I(coeffMB+0*64, 63, mQuantInvIntraSpec, quant, IPPVC_BLOCK_LUMA);        ippiDCT8x8Inv_16s8u_C1R(coeffMB+0*64, pY, yStep);    } else {        dc = coeffMB[0*64] * mp4_DCScalerLuma_[quant];        mp4_Set8x8_8u(pY, yStep, (Ipp8u)((dc + 4) >> 3));    }    if (pattern & 16) {        ippiQuantInvIntra_MPEG4_16s_C1I(coeffMB+1*64, 63, mQuantInvIntraSpec, quant, IPPVC_BLOCK_LUMA);        ippiDCT8x8Inv_16s8u_C1R(coeffMB+1*64, pY+8, yStep);    } else {        dc = coeffMB[1*64] * mp4_DCScalerLuma_[quant];        mp4_Set8x8_8u(pY+8, yStep, (Ipp8u)((dc + 4) >> 3));    }    if (pattern & 8) {        ippiQuantInvIntra_MPEG4_16s_C1I(coeffMB+2*64, 63, mQuantInvIntraSpec, quant, IPPVC_BLOCK_LUMA);        ippiDCT8x8Inv_16s8u_C1R(coeffMB+2*64, pY+yOff23, yStep);    } else {        dc = coeffMB[2*64] * mp4_DCScalerLuma_[quant];        mp4_Set8x8_8u(pY+yOff23, yStep, (Ipp8u)((dc + 4) >> 3));    }    if (pattern & 4) {        ippiQuantInvIntra_MPEG4_16s_C1I(coeffMB+3*64, 63, mQuantInvIntraSpec, quant, IPPVC_BLOCK_LUMA);        ippiDCT8x8Inv_16s8u_C1R(coeffMB+3*64, pY+yOff23+8, yStep);    } else {        dc = coeffMB[3*64] * mp4_DCScalerLuma_[quant];        mp4_Set8x8_8u(pY+yOff23+8, yStep, (Ipp8u)((dc + 4) >> 3));    }    if (pattern & 2) {        ippiQuantInvIntra_MPEG4_16s_C1I(coeffMB+4*64, 63, mQuantInvIntraSpec, quant, IPPVC_BLOCK_CHROMA);        ippiDCT8x8Inv_16s8u_C1R(coeffMB+4*64, pU, mStepChroma);    } else {        dc = coeffMB[4*64] * mp4_DCScalerChroma_[quant];        mp4_Set8x8_8u(pU, mStepChroma, (Ipp8u)((dc + 4) >> 3));    }    if (pattern & 1) {        ippiQuantInvIntra_MPEG4_16s_C1I(coeffMB+5*64, 63, mQuantInvIntraSpec, quant, IPPVC_BLOCK_CHROMA);        ippiDCT8x8Inv_16s8u_C1R(coeffMB+5*64, pV, mStepChroma);    } else {        dc = coeffMB[5*64] * mp4_DCScalerChroma_[quant];        mp4_Set8x8_8u(pV, mStepChroma, (Ipp8u)((dc + 4) >> 3));    }    if (mCalcPSNR) {        mPSNR_Y += mp4_CalcMSE_16x16(pY, mStepLuma, pDec, 16);        mPSNR_U += mp4_CalcMSE_8x8(pU, mStepChroma, pDec+256, 8);        mPSNR_V += mp4_CalcMSE_8x8(pV, mStepChroma, pDec+320, 8);    }}void ippVideoEncoderMPEG4::ReconMacroBlockInter_MPEG4(Ipp8u *pYc, Ipp8u *pUc, Ipp8u *pVc, Ipp8u *mcPred, Ipp16s *coeffMB, int quant, int pattern, int dct_type){    int  yOff23, yStep;    if (!dct_type) {        yOff23 = 16 * 8;        yStep = 16;    } else {        yOff23 = 16;        yStep = 16 * 2;    }    if (pattern & 32) {        ippiQuantInvInter_MPEG4_16s_C1I(coeffMB+0*64, 63, mQuantInvInterSpec, quant);        ippiDCT8x8Inv_16s_C1I(coeffMB+0*64);        mp4_Add8x8_16s8u(mcPred, coeffMB+0*64, yStep);    }    if (pattern & 16) {        ippiQuantInvInter_MPEG4_16s_C1I(coeffMB+1*64, 63, mQuantInvInterSpec, quant);        ippiDCT8x8Inv_16s_C1I(coeffMB+1*64);        mp4_Add8x8_16s8u(mcPred+8, coeffMB+1*64, yStep);    }    if (pattern & 8) {        ippiQuantInvInter_MPEG4_16s_C1I(coeffMB+2*64, 63, mQuantInvInterSpec, quant);        ippiDCT8x8Inv_16s_C1I(coeffMB+2*64);        mp4_Add8x8_16s8u(mcPred+yOff23, coeffMB+2*64, yStep);    }    if (pattern & 4) {        ippiQuantInvInter_MPEG4_16s_C1I(coeffMB+3*64, 63, mQuantInvInterSpec, quant);        ippiDCT8x8Inv_16s_C1I(coeffMB+3*64);        mp4_Add8x8_16s8u(mcPred+yOff23+8, coeffMB+3*64, yStep);    }    if (pattern & 2) {        ippiQuantInvInter_MPEG4_16s_C1I(coeffMB+4*64, 63, mQuantInvInterSpec, quant);        ippiDCT8x8Inv_16s_C1I(coeffMB+4*64);        mp4_Add8x8_16s8u(mcPred+64*4, coeffMB+4*64, 8);    }    if (pattern & 1) {        ippiQuantInvInter_MPEG4_16s_C1I(coeffMB+5*64, 63, mQuantInvInterSpec, quant);        ippiDCT8x8Inv_16s_C1I(coeffMB+5*64);        mp4_Add8x8_16s8u(mcPred+64*5, coeffMB+5*64, 8);    }    if (mCalcPSNR) {        mPSNR_Y += mp4_CalcMSE_16x16(pYc, mStepLuma, mcPred, 16);        mPSNR_U += mp4_CalcMSE_8x8(pUc, mStepChroma, mcPred+64*4, 8);        mPSNR_V += mp4_CalcMSE_8x8(pVc, mStepChroma, mcPred+64*5, 8);    }    ippiCopy16x16_8u_C1R(mcPred, 16, pYc, mStepLuma);    ippiCopy8x8_8u_C1R(mcPred+64*4, 8, pUc, mStepChroma);    ippiCopy8x8_8u_C1R(mcPred+64*5, 8, pVc, mStepChroma);}void ippVideoEncoderMPEG4::EncodeIVOPSH(){    __ALIGN16(Ipp16s, coeffMB, 64*6);    Ipp8u  *pY, *pU, *pV;    int     i, j, quant, pattern;    Ipp32s  nzCount[6];    mp4_MacroBlock *MBcurr = MBinfo;    int  nmb = 0, nmbf = 0, dquant = 0;    if (mRateControl == 2)        InitMBRC();    VOP.gob_number = 1;    quant = VOP.vop_quant;    for (i = 0; i < mNumMacroBlockPerCol; i ++) {        pY = mFrameC->pY + i * 16 * mStepLuma;        pU = mFrameC->pU + i * 8 * mStepChroma;        pV = mFrameC->pV + i * 8 * mStepChroma;        for (j = 0; j < mNumMacroBlockPerRow; j ++) {            MBcurr->mv[0].dx = MBcurr->mv[0].dy = 0;            // for RTP support            mMBpos[nmbf] = 8 * (cBS.mPtr - cBS.mBuffer) + cBS.mBitOff;            mMBquant[nmbf] = (Ipp8u)quant;            quant += dquant;            mQuantSum += quant;            pattern = TransMacroBlockIntra_H263(pY, pU, pV, coeffMB, nzCount, quant);            EncodeMCBPC_I(dquant == 0 ? IPPVC_MBTYPE_INTRA : IPPVC_MBTYPE_INTRA_Q, pattern & 3);            EncodeCBPY_I(pattern >> 2);            if (dquant != 0)                EncodeDquant(dquant);            EncodeMacroBlockIntra_H263(coeffMB, pattern, nzCount);            if (mIVOPdist != 1 || mCalcPSNR)                ReconMacroBlockIntra_H263(pY, pU, pV, coeffMB, quant, pattern);            if (VOP.gob_resync) {                nmb ++;                if ((nmb == VOP.num_macroblocks_in_gob) && (VOP.gob_number < VOP.num_gobs_in_vop)) {                    // write gob_resync_marker                    EncodeZeroBitsAlign();                    cBS.PutBits(1, 17);                    cBS.PutBits(VOP.gob_number, 5);                    cBS.PutBits(VOP.gob_frame_id, 2);                    cBS.PutBits(VOP.vop_quant, 5);                    VOP.gob_number ++;                    nmb = 0;                }            }            if (mRateControl == 2)                UpdateMBRC(&dquant);            pY += 16; pU += 8; pV += 8;            MBcurr ++;            nmbf ++;        }    }    EncodeZeroBitsAlign();    if (mRateControl == 2)        CloseMBRC();}void ippVideoEncoderMPEG4::EncodeIVOP(){    __ALIGN16(Ipp16s, coeffMB, 64*6);    Ipp8u  *pY, *pU, *pV;    int     i, j, quant, pattern, acPredSum0, acPredSum1;    Ipp32s  nzCount[6];    mp4_MacroBlock *MBcurr = MBinfo;    int     predDir[6], ac_pred_flag, use_intra_dc_vlc, dct_type, pattern1, dquant;    int     nBits, nBits_1 = 0, nBits_2 = 0, sBitOff, mbn = 0, mbnvp = 0, tBitOff_1 = 0, tBitOff_2 = 0, smBitOff;    Ipp8u  *sPtr, *tPtr_1 = mBuffer_1, *tPtr_2 = mBuffer_2, *smPtr;    if (mRateControl == 2)        InitMBRC();    cBS.GetPos(&sPtr, &sBitOff);  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -