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

📄 ippvideoencodermpeg4_vop.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    *pSum0 = sum0;    *pSum1 = sum1;}static void RestoreIntraAC(mp4_MacroBlock *MBcurr, Ipp16s *dcCurr, int *predDir){    int         i, k;    Ipp16s      *predAcA, *predAcC;    mp4_Block   *bCurr;    for (i = 0; i < 6; i ++) {        bCurr = &MBcurr->block[i];        predAcA = bCurr->predA ? (bCurr->predA->validPredIntra ? bCurr->predA->dct_acA : NULL) : NULL;        predAcC = bCurr->predC ? (bCurr->predC->validPredIntra ? bCurr->predC->dct_acC : NULL) : NULL;        if (predDir[i] == IPPVC_SCAN_HORIZONTAL && predAcC) {            if (predAcC[0] != 0) {                for (k = 1; k < 8; k ++)                    dcCurr[k] = bCurr->dct_acC[k];            }        } else if (predDir[i] == IPPVC_SCAN_VERTICAL && predAcA) {            if (predAcA[0] != 0) {                for (k = 1; k < 8; k ++)                    dcCurr[k*8] = bCurr->dct_acA[k];            }        }        dcCurr += 64;    }}int ippVideoEncoderMPEG4::TransMacroBlockIntra_H263(Ipp8u *pY, Ipp8u *pU, Ipp8u *pV, Ipp16s *coeffMB, Ipp32s *nzCount, int quant){    int   pattern;    ippiDCT8x8Fwd_8u16s_C1R(pY, mStepLuma, coeffMB+0*64);    ippiDCT8x8Fwd_8u16s_C1R(pY+8, mStepLuma, coeffMB+1*64);    ippiDCT8x8Fwd_8u16s_C1R(pY+8*mStepLuma, mStepLuma, coeffMB+2*64);    ippiDCT8x8Fwd_8u16s_C1R(pY+8*mStepLuma+8, mStepLuma, coeffMB+3*64);    ippiDCT8x8Fwd_8u16s_C1R(pU, mStepChroma, coeffMB+4*64);    ippiDCT8x8Fwd_8u16s_C1R(pV, mStepChroma, coeffMB+5*64);    ippiQuantIntra_H263_16s_C1I(coeffMB+0*64, quant, &nzCount[0], 0, 0);    ippiQuantIntra_H263_16s_C1I(coeffMB+1*64, quant, &nzCount[1], 0, 0);    ippiQuantIntra_H263_16s_C1I(coeffMB+2*64, quant, &nzCount[2], 0, 0);    ippiQuantIntra_H263_16s_C1I(coeffMB+3*64, quant, &nzCount[3], 0, 0);    ippiQuantIntra_H263_16s_C1I(coeffMB+4*64, quant, &nzCount[4], 0, 0);    ippiQuantIntra_H263_16s_C1I(coeffMB+5*64, quant, &nzCount[5], 0, 0);    mp4_SetPatternIntra(pattern, nzCount, coeffMB, 1);    return pattern;}int ippVideoEncoderMPEG4::TransMacroBlockInter_H263(Ipp8u *pYc, Ipp8u *pUc, Ipp8u *pVc, Ipp16s *coeffMB, Ipp32s *nzCount, int quant, Ipp8u *mcPred, int lumaErr){    int   pattern, sU, sV, sL0, sL1, sL2, sL3, lim;    lim = quant * 16;    if (lumaErr < quant * 20) {        nzCount[0] = nzCount[1] = nzCount[2] = nzCount[3] = 0;        coeffMB[0*64] = coeffMB[1*64] = coeffMB[2*64] = coeffMB[3*64] = 0;    } else {        ippiSubSAD8x8_8u16s_C1R(pYc, mStepLuma, mcPred, 16, coeffMB+0*64, 16, &sL0);        ippiSubSAD8x8_8u16s_C1R(pYc+8, mStepLuma, mcPred+8, 16, coeffMB+1*64, 16, &sL1);        ippiSubSAD8x8_8u16s_C1R(pYc+8*mStepLuma, mStepLuma, mcPred+128, 16, coeffMB+2*64, 16, &sL2);        ippiSubSAD8x8_8u16s_C1R(pYc+8*mStepLuma+8, mStepLuma, mcPred+136, 16, coeffMB+3*64, 16, &sL3);        if (sL0 < lim) {            nzCount[0] = 0;            coeffMB[0*64] = 0;        } else {            ippiDCT8x8Fwd_16s_C1I(coeffMB+0*64);            ippiQuantInter_H263_16s_C1I(coeffMB+0*64, quant, &nzCount[0], 0);        }        if (sL1 < lim) {            nzCount[1] = 0;            coeffMB[1*64] = 0;        } else {            ippiDCT8x8Fwd_16s_C1I(coeffMB+1*64);            ippiQuantInter_H263_16s_C1I(coeffMB+1*64, quant, &nzCount[1], 0);        }        if (sL2 < lim) {            nzCount[2] = 0;            coeffMB[2*64] = 0;        } else {            ippiDCT8x8Fwd_16s_C1I(coeffMB+2*64);            ippiQuantInter_H263_16s_C1I(coeffMB+2*64, quant, &nzCount[2], 0);        }        if (sL3 < lim) {            nzCount[3] = 0;            coeffMB[3*64] = 0;        } else {            ippiDCT8x8Fwd_16s_C1I(coeffMB+3*64);            ippiQuantInter_H263_16s_C1I(coeffMB+3*64, quant, &nzCount[3], 0);        }    }    ippiSubSAD8x8_8u16s_C1R(pUc, mStepChroma, mcPred+64*4, 8, coeffMB+4*64, 16, &sU);    ippiSubSAD8x8_8u16s_C1R(pVc, mStepChroma, mcPred+64*5, 8, coeffMB+5*64, 16, &sV);    if (sU < lim) {        nzCount[4] = 0;        coeffMB[4*64] = 0;    } else {        ippiDCT8x8Fwd_16s_C1I(coeffMB+4*64);        ippiQuantInter_H263_16s_C1I(coeffMB+4*64, quant, &nzCount[4], 0);    }    if (sV < lim) {        nzCount[5] = 0;        coeffMB[5*64] = 0;    } else {        ippiDCT8x8Fwd_16s_C1I(coeffMB+5*64);        ippiQuantInter_H263_16s_C1I(coeffMB+5*64, quant, &nzCount[5], 0);    }    mp4_SetPatternInter(pattern, nzCount);    return pattern;}int ippVideoEncoderMPEG4::TransMacroBlockIntra_MPEG4(Ipp8u *pY, Ipp8u *pU, Ipp8u *pV, Ipp16s *coeffMB, Ipp32s *nzCount, int quant, int row, int col, int *dct_type){    int   pattern, yOff23, yStep, dctt = 0;    if (VOL.interlaced) {        // boundary MBs should be frame-DCT coded        if (row != 0 && col != 0 && row != (mNumMacroBlockPerCol-1) && col != (mNumMacroBlockPerRow-1)) {            Ipp32s  sfr, sfi;            ippiFrameFieldSAD16x16_8u32s_C1R(pY, mStepLuma, &sfr, &sfi);            dctt = (sfi + 999) < sfr;        }    }    if (!dctt) {        yOff23 = mStepLuma * 8;        yStep = mStepLuma;    } else {        yOff23 = mStepLuma;        yStep = mStepLuma * 2;    }    *dct_type = dctt;    ippiDCT8x8Fwd_8u16s_C1R(pY, yStep, coeffMB+0*64);    ippiDCT8x8Fwd_8u16s_C1R(pY+8, yStep, coeffMB+1*64);    ippiDCT8x8Fwd_8u16s_C1R(pY+yOff23, yStep, coeffMB+2*64);    ippiDCT8x8Fwd_8u16s_C1R(pY+yOff23+8, yStep, coeffMB+3*64);    ippiDCT8x8Fwd_8u16s_C1R(pU, mStepChroma, coeffMB+4*64);    ippiDCT8x8Fwd_8u16s_C1R(pV, mStepChroma, coeffMB+5*64);    ippiQuantIntra_MPEG4_16s_C1I(coeffMB+0*64, mQuantIntraSpec, quant, &nzCount[0], IPPVC_BLOCK_LUMA);    ippiQuantIntra_MPEG4_16s_C1I(coeffMB+1*64, mQuantIntraSpec, quant, &nzCount[1], IPPVC_BLOCK_LUMA);    ippiQuantIntra_MPEG4_16s_C1I(coeffMB+2*64, mQuantIntraSpec, quant, &nzCount[2], IPPVC_BLOCK_LUMA);    ippiQuantIntra_MPEG4_16s_C1I(coeffMB+3*64, mQuantIntraSpec, quant, &nzCount[3], IPPVC_BLOCK_LUMA);    ippiQuantIntra_MPEG4_16s_C1I(coeffMB+4*64, mQuantIntraSpec, quant, &nzCount[4], IPPVC_BLOCK_CHROMA);    ippiQuantIntra_MPEG4_16s_C1I(coeffMB+5*64, mQuantIntraSpec, quant, &nzCount[5], IPPVC_BLOCK_CHROMA);    mp4_SetPatternIntra(pattern, nzCount, coeffMB, 1);    return pattern;}int ippVideoEncoderMPEG4::TransMacroBlockInter_MPEG4(Ipp8u *pYc, Ipp8u *pUc, Ipp8u *pVc, Ipp16s *coeffMB, Ipp32s *nzCount, int quant, Ipp8u *mcPred, int row, int col, int *dct_type){    int   pattern, sU, sV, sL0, sL1, sL2, sL3, lim, off23, s, dctt = 0;    lim = (VOL.quant_type == 0) ? quant * 16 : quant * 12;    ippiSub16x16_8u16s_C1R(pYc, mStepLuma, mcPred, 16, coeffMB+6*64, 32);    if (VOL.interlaced) {        // boundary MBs should be frame-DCT coded        if (row != 0 && col != 0 && row != (mNumMacroBlockPerCol-1) && col != (mNumMacroBlockPerRow-1)) {            Ipp32s  sfr, sfi;            ippiFrameFieldSAD16x16_16s32s_C1R(coeffMB+64*6, 32, &sfr, &sfi);            dctt = (sfi + 999) < sfr;        }    }    if (dctt) {        ippiSAD8x8_8u32s_C1R(pYc, 2*mStepLuma, mcPred, 32, &sL0, IPPVC_MC_APX_FF);        ippiSAD8x8_8u32s_C1R(pYc+8, 2*mStepLuma, mcPred+8, 32, &sL1, IPPVC_MC_APX_FF);        ippiSAD8x8_8u32s_C1R(pYc+mStepLuma, 2*mStepLuma, mcPred+16, 32, &sL2, IPPVC_MC_APX_FF);        ippiSAD8x8_8u32s_C1R(pYc+mStepLuma+8, 2*mStepLuma, mcPred+24, 32, &sL3, IPPVC_MC_APX_FF);        off23 = 6*64+16;        s = 64;    } else {        ippiSAD8x8_8u32s_C1R(pYc, mStepLuma, mcPred, 16, &sL0, IPPVC_MC_APX_FF);        ippiSAD8x8_8u32s_C1R(pYc+8, mStepLuma, mcPred+8, 16, &sL1, IPPVC_MC_APX_FF);        ippiSAD8x8_8u32s_C1R(pYc+8*mStepLuma, mStepLuma, mcPred+128, 16, &sL2, IPPVC_MC_APX_FF);        ippiSAD8x8_8u32s_C1R(pYc+8*mStepLuma+8, mStepLuma, mcPred+136, 16, &sL3, IPPVC_MC_APX_FF);        off23 = 8*64;        s = 32;    }    *dct_type = dctt;    if (sL0 < lim) {        nzCount[0] = 0;    } else {        ippiDCT8x8Fwd_16s_C1R(coeffMB+6*64, s, coeffMB+0*64);        ippiQuantInter_MPEG4_16s_C1I(coeffMB+0*64, mQuantInterSpec, quant, &nzCount[0]);    }    if (sL1 < lim) {        nzCount[1] = 0;    } else {        ippiDCT8x8Fwd_16s_C1R(coeffMB+6*64+8, s, coeffMB+1*64);        ippiQuantInter_MPEG4_16s_C1I(coeffMB+1*64, mQuantInterSpec, quant, &nzCount[1]);    }    if (sL2 < lim) {        nzCount[2] = 0;    } else {        ippiDCT8x8Fwd_16s_C1R(coeffMB+off23, s, coeffMB+2*64);        ippiQuantInter_MPEG4_16s_C1I(coeffMB+2*64, mQuantInterSpec, quant, &nzCount[2]);    }    if (sL3 < lim) {        nzCount[3] = 0;    } else {        ippiDCT8x8Fwd_16s_C1R(coeffMB+off23+8, s, coeffMB+3*64);        ippiQuantInter_MPEG4_16s_C1I(coeffMB+3*64, mQuantInterSpec, quant, &nzCount[3]);    }    ippiSAD8x8_8u32s_C1R(pUc, mStepChroma, mcPred+64*4, 8, &sU, IPPVC_MC_APX_FF);    ippiSAD8x8_8u32s_C1R(pVc, mStepChroma, mcPred+64*5, 8, &sV, IPPVC_MC_APX_FF);    if (sU < lim) {        nzCount[4] = 0;    } else {        ippiSub8x8_8u16s_C1R(pUc, mStepChroma, mcPred+64*4, 8, coeffMB+4*64, 16);        ippiDCT8x8Fwd_16s_C1I(coeffMB+4*64);        ippiQuantInter_MPEG4_16s_C1I(coeffMB+4*64, mQuantInterSpec, quant, &nzCount[4]);    }    if (sV < lim) {        nzCount[5] = 0;    } else {        ippiSub8x8_8u16s_C1R(pVc, mStepChroma, mcPred+64*5, 8, coeffMB+5*64, 16);        ippiDCT8x8Fwd_16s_C1I(coeffMB+5*64);        ippiQuantInter_MPEG4_16s_C1I(coeffMB+5*64, mQuantInterSpec, quant, &nzCount[5]);    }/*    lim = (VOL.quant_type == 0) ? quant * 16 : quant * 12;    if (!dct_type) {        ippiSubSAD8x8_8u16s_C1R(pYc, mStepLuma, mcPred, 16, coeffMB+0*64, 16, &sL0);        ippiSubSAD8x8_8u16s_C1R(pYc+8, mStepLuma, mcPred+8, 16, coeffMB+1*64, 16, &sL1);        ippiSubSAD8x8_8u16s_C1R(pYc+8*mStepLuma, mStepLuma, mcPred+128, 16, coeffMB+2*64, 16, &sL2);        ippiSubSAD8x8_8u16s_C1R(pYc+8*mStepLuma+8, mStepLuma, mcPred+136, 16, coeffMB+3*64, 16, &sL3);    } else {        ippiSubSAD8x8_8u16s_C1R(pYc, 2*mStepLuma, mcPred, 32, coeffMB+0*64, 16, &sL0);        ippiSubSAD8x8_8u16s_C1R(pYc+8, 2*mStepLuma, mcPred+8, 32, coeffMB+1*64, 16, &sL1);        ippiSubSAD8x8_8u16s_C1R(pYc+mStepLuma, 2*mStepLuma, mcPred+16, 32, coeffMB+2*64, 16, &sL2);        ippiSubSAD8x8_8u16s_C1R(pYc+mStepLuma+8, 2*mStepLuma, mcPred+24, 32, coeffMB+3*64, 16, &sL3);    }    if (sL0 < lim) {        nzCount[0] = 0;    } else {        ippiDCT8x8Fwd_16s_C1I(coeffMB+0*64);        ippiQuantInter_MPEG4_16s_C1I(coeffMB+0*64, mQuantInterSpec, quant, &nzCount[0]);    }    if (sL1 < lim) {        nzCount[1] = 0;    } else {        ippiDCT8x8Fwd_16s_C1I(coeffMB+1*64);        ippiQuantInter_MPEG4_16s_C1I(coeffMB+1*64, mQuantInterSpec, quant, &nzCount[1]);    }    if (sL2 < lim) {        nzCount[2] = 0;    } else {        ippiDCT8x8Fwd_16s_C1I(coeffMB+2*64);        ippiQuantInter_MPEG4_16s_C1I(coeffMB+2*64, mQuantInterSpec, quant, &nzCount[2]);    }    if (sL3 < lim) {        nzCount[3] = 0;    } else {        ippiDCT8x8Fwd_16s_C1I(coeffMB+3*64);        ippiQuantInter_MPEG4_16s_C1I(coeffMB+3*64, mQuantInterSpec, quant, &nzCount[3]);    }    ippiSubSAD8x8_8u16s_C1R(pUc, mStepChroma, mcPred+64*4, 8, coeffMB+4*64, 16, &sU);    ippiSubSAD8x8_8u16s_C1R(pVc, mStepChroma, mcPred+64*5, 8, coeffMB+5*64, 16, &sV);    if (sU < lim) {        nzCount[4] = 0;    } else {        ippiDCT8x8Fwd_16s_C1I(coeffMB+4*64);        ippiQuantInter_MPEG4_16s_C1I(coeffMB+4*64, mQuantInterSpec, quant, &nzCount[4]);    }    if (sV < lim) {        nzCount[5] = 0;    } else {        ippiDCT8x8Fwd_16s_C1I(coeffMB+5*64);        ippiQuantInter_MPEG4_16s_C1I(coeffMB+5*64, mQuantInterSpec, quant, &nzCount[5]);    }*/    mp4_SetPatternInter(pattern, nzCount);    return pattern;}inline void ippVideoEncoderMPEG4::EncodeMacroBlockIntra_H263(Ipp16s *coeffMB, int pattern, int *nzCount){    int  i, pm = 32;    for (i = 0; i < 6; i ++) {        ippiEncodeDCIntra_H263_16s1u(coeffMB[i*64], &cBS.mPtr, &cBS.mBitOff);        if (pattern & pm)            ippiEncodeCoeffsIntra_H263_16s1u(coeffMB+i*64, &cBS.mPtr, &cBS.mBitOff, nzCount[i] - 1, 0, 0, IPPVC_SCAN_ZIGZAG);        pm >>= 1;    }}inline void ippVideoEncoderMPEG4::EncodeMacroBlockInter_H263(Ipp16s *coeffMB, int pattern, int *nzCount){    int  i, pm = 32;    for (i = 0; i < 6; i ++) {        if (pattern & pm)            ippiEncodeCoeffsInter_H263_16s1u(coeffMB+i*64, &cBS.mPtr, &cBS.mBitOff, nzCount[i], 0, IPPVC_SCAN_ZIGZAG);        pm >>= 1;    }}inline void ippVideoEncoderMPEG4::EncodeMacroBlockIntra_MPEG4(Ipp16s *coeffMB, int pattern, int use_intra_dc_vlc, int *predDir, int *nzCount){    int  i, nzc, pm = 32;    for (i = 0; i < 6; i ++) {        if (use_intra_dc_vlc)            ippiEncodeDCIntra_MPEG4_16s1u(coeffMB[i*64], &cBS.mPtr, &cBS.mBitOff, (i < 4) ? IPPVC_BLOCK_LUMA : IPPVC_BLOCK_CHROMA);        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, 0, use_intra_dc_vlc, VOP.alternate_vertical_scan_flag ? IPPVC_SCAN_VERTICAL : predDir[i]);        }        pm >>= 1;    }}inline void ippVideoEncoderMPEG4::EncodeMacroBlockInter_MPEG4(Ipp16s *coeffMB, int pattern, int *nzCount){    int  i, pm = 32;    for (i = 0; i < 6; i ++) {        if (pattern & pm)            ippiEncodeCoeffsInter_MPEG4_16s1u(coeffMB+i*64, &cBS.mPtr, &cBS.mBitOff, nzCount[i], VOL.reversible_vlc, VOP.alternate_vertical_scan_flag ? IPPVC_SCAN_VERTICAL : IPPVC_SCAN_ZIGZAG);        pm >>= 1;    }}

⌨️ 快捷键说明

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