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

📄 umc_h264_me.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
            // derived the backward MV from the reference MV: MVb = MVf-MV = -(1-r1)*MV            MVPred[uMVnum].iMVx = (Ipp8s) (MVPred[uMVnum].iMVx - pMVRef->iMVx);            MVPred[uMVnum].iMVy = (Ipp8s) (MVPred[uMVnum].iMVy - pMVRef->iMVy);        }    }    // Scale to Integer Pel    MVPred[uMVnum].iMVx /= SubPelFactor;    MVPred[uMVnum].iMVy /= SubPelFactor;    for (i = 0; i < uMVnum; i ++)    {        if (MVPred[uMVnum].iMVx == MVPred[i].iMVx &&            MVPred[uMVnum].iMVy == MVPred[i].iMVy)            break;        if (i == uMVnum - 1 &&            MVPred[uMVnum].iMVx >= xMin && MVPred[uMVnum].iMVx <= xMax &&            MVPred[uMVnum].iMVy >= yMin && MVPred[uMVnum].iMVy <= yMax)        {            uMVnum ++;            break;        }    }#ifndef NO_LEFT_DEP    // left predictor    if (bMBIsNotOnLeftEdge) {        pMVLeft = pMV - 1;        MVPred[uMVnum].iMVx = pMVLeft->iMVx / SubPelFactor;        MVPred[uMVnum].iMVy = pMVLeft->iMVy / SubPelFactor;        for (i = 0; i < uMVnum; i ++)        {            if (MVPred[uMVnum].iMVx == MVPred[i].iMVx &&                MVPred[uMVnum].iMVy == MVPred[i].iMVy)                break;            if (i == uMVnum - 1 &&                MVPred[uMVnum].iMVx >= xMin && MVPred[uMVnum].iMVx <= xMax &&                MVPred[uMVnum].iMVy >= yMin && MVPred[uMVnum].iMVy <= yMax)            {                uMVnum ++;                break;            }        }    }#endif // NO_LEFT_DEP    do {    // This is not a real loop.  Allows 'break' to be used to jump to end...        // Begin tests to determine which of the 5 MVs is the best starting point...        // start with zero vector        BestMV16x16 = NullMV;        uBestSAD16x16NoRD = SAD16(pCurrent, pPrev, uPitch);        uBestSAD16x16e = uBestSAD16x16NoRD                            + MVConstraint(0 - PredictedMV.iMVx, 0 - PredictedMV.iMVy, pRDQM);        //  If the zero vector is the predicted vector, then give it preference        //  to encourage skip blocks in P slices.        if ((PredictedMV.iMVx == 0) && (PredictedMV.iMVy == 0) && !bBSlice)            uBestSAD16x16e -= ((rd_quant[uQP] * 6)>>3);#if defined _DEBUG && defined BFRAME_PRINT_MVS        if (bBSlice) {            printf("Null: %3d,%3d; %4d\n", NullMV.iMVx, NullMV.iMVy,                SAD16(pCurrent, MVADJUST(pPrev, uPitch, NullMV.iMVx, NullMV.iMVy), uPitch)                    + MVConstraint(SubPelFactor*NullMV.iMVx - xPred,                                   SubPelFactor*NullMV.iMVy - yPred, pRDQM));        }#endif  // BFRAME_PRINT_MVS#if defined BESTOF5_EARLY_EXIT        // Consider the best of five mv is good enough if the effective        // SAD is less than the given threshold.        if (uBestSAD16x16e <= BestOf5EarlyExitThres[uQP])        {            if (uBestSAD16x16e < 0)                uBestSAD16x16e = 0;            // end integer search            break;        }#else        // Skip if sad < 0        if (uBestSAD16x16e < 0)        {            uBestSAD16x16e = 0;            // end integer search            break;        }#endif        for (i = 1; i < uMVnum; i ++)        {            uSAD16x16e = MVConstraint(                    MVPred[i].iMVx * SubPelFactor - PredictedMV.iMVx,                    MVPred[i].iMVy * SubPelFactor - PredictedMV.iMVy,                    pRDQM);            // This accounts for the factor that perfectly predicted MBs            // can lead to Skip Blocks in P Slices            if (((MVPred[i].iMVx * SubPelFactor - PredictedMV.iMVx) == 0) &&                ((MVPred[i].iMVy * SubPelFactor - PredictedMV.iMVy) == 0) &&                  !bBSlice)                uSAD16x16e -= ((rd_quant[uQP] * 5)>>3);            if (uSAD16x16e < uBestSAD16x16e)            {                uSAD16x16NoRD = SAD16(pCurrent,                                      MVADJUST(pPrev, uPitch,                                               MVPred[i].iMVx,                                               MVPred[i].iMVy),                                      uPitch);                uSAD16x16e += uSAD16x16NoRD;                if (uSAD16x16e < uBestSAD16x16e)                {                    uBestSAD16x16e = uSAD16x16e;                    uBestSAD16x16NoRD = uSAD16x16NoRD;                    BestMV16x16 = MVPred[i];#if defined BESTOF5_EARLY_EXIT                    // Consider the best of five mv is good enough if the                    // effective SAD is less than the given threshold.                    if (uSAD16x16e <= BestOf5EarlyExitThres[uQP])                    {                        // end integer search                        break;                    }#endif                }            }        }   // for i        bDone = false;  // No "Early exit" breaks taken    } while (0);    // End of Bogus loop    return bDone;}   // FindBestInitialMV()typedef struct {    Ipp8s d, u, r, l;} durl_T;// 8x8 block size datastatic const durl_T durl8x8[] = {    {8, 0, 8, 0},    {8, 0, 0, 8},    {0, 8, 8, 0},    {0, 8, 0, 8}};// 4x4 block size datastatic const durl_T durl4x4[] = {    {12,  0, 12,  0},    {12,  0,  8,  4},    {12,  0,  4,  8},    {12,  0,  0, 12},    { 8,  4, 12,  0},    { 8,  4,  8,  4},    { 8,  4,  4,  8},    { 8,  4,  0, 12},    { 4,  8, 12,  0},    { 4,  8,  8,  4},    { 4,  8,  4,  8},    { 4,  8,  0, 12},    { 0, 12, 12,  0},    { 0, 12,  8,  4},    { 0, 12,  4,  8},    { 0, 12,  0, 12},};  // durl4x4[]// Sub-pel search structure//  spInterpFnx: horiz index to interpolation function pointer table//  spInterpFny: vert index to interpolation function pointer table//  spInterpFnx,spInterpFny://   1,1  2,1  3,1  0,1  1,1  2,1  3,1//   1,2  2,2  3,2  0,2  1,2  2,2  3,2//   1,3  2,3  3,3  0,3  1,3  2,3  3,3//   1,0  2,0  3,0   X   1,0  2,0  3,0      X is the integer pel location//   1,1  2,1  3,1  0,1  1,1  2,1  3,1//   1,2  2,2  3,2  0,2  1,2  2,2  3,2//   1,3  2,3  3,3  0,3  1,3  2,3  3,3//  MVx: x-component of sub-pel vector relative to integer position//  MVy: y-component of sub-pel vector relative to integer position//  MVxoff: x-component offset relative to sub-pel plane with origin in the lower-right corner//  MVyoff: y-component offset relative to sub-pel plane with origin in the lower-right cornertypedef struct {    Ipp8s spMVx, spMVy, spMVxoff, spMVyoff;    Ipp32u spInterpFnx;    Ipp32u spInterpFny;} subpel_T;static const subpel_T spList[48] = {    {-2,  0, -1,  0, 2, 0}, {+2,  0,  0,  0, 2, 0},    { 0, -2,  0, -1, 0, 2}, { 0, +2,  0,  0, 0, 2},    {-2, -2, -1, -1, 2, 2}, {-2, +2, -1,  0, 2, 2},    {+2, -2,  0, -1, 2, 2}, {+2, +2,  0,  0, 2, 2},    {-3,  0, -1,  0, 1, 0}, {+1,  0,  0,  0, 1, 0},    {-1,  0, -1,  0, 3, 0}, {+3,  0,  0,  0, 3, 0},    {-3, -2, -1, -1, 1, 2}, {+1, -2,  0, -1, 1, 2}, {-3, +2, -1,  0, 1, 2}, {+1, +2,  0,  0, 1, 2},    {-1, -2, -1, -1, 3, 2}, {+3, -2,  0, -1, 3, 2}, {-1, +2, -1,  0, 3, 2}, {+3, +2,  0,  0, 3, 2},    {-3, -3  -1, -1, 1, 1}, {+1, -3,  0, -1, 1, 1}, {-3, +1, -1,  0, 1, 1}, {+1, +1,  0,  0, 1, 1},    {-2, -3, -1, -1, 2, 1}, {+2, -3,  0, -1, 2, 1}, {-2, +1, -1,  0, 2, 1}, {+2, +1,  0,  0, 2, 1},    {-1, -3, -1, -1, 3, 1}, {+3, -3,  0, -1, 3, 1}, {-1, +1, -1,  0, 3, 1}, {+3, +1,  0,  0, 3, 1},    {-3, -1, -1, -1, 1, 3}, {+1, -1,  0, -1, 1, 3}, {-3, +3, -1,  0, 1, 3}, {+1, +3,  0,  0, 1, 3},    {-2, -1, -1, -1, 2, 3}, {+2, -1,  0, -1, 2, 3}, {-2, +3, -1,  0, 2, 3}, {+2, +3,  0,  0, 2, 3},    {-1, -1, -1, -1, 3, 3}, {+3, -1,  0, -1, 3, 3}, {-1, +3, -1,  0, 3, 3}, {+3, +3,  0,  0, 3, 3},    { 0, -3,  0, -1, 0, 1}, { 0, +1,  0,  0, 0, 1},    { 0, -1,  0, -1, 0, 3}, { 0, +3,  0,  0, 0, 3},};static const subpel_T spConjList[80] = {    {-2,  0, -1,  0, 2, 0}, // Step 1 L  // 0    {+2,  0,  0,  0, 2, 0}, // Step 1 R  // 1// ----    { 0, -2,  0, -1, 0, 2}, // Step 2 CU  // 2 = 0*2 + 2    { 0, +2,  0,  0, 0, 2}, // Step 2 CD  // 3 = 0*2 + 2 + 1    {-2, -2, -1, -1, 2, 2}, // Step 2 LU  // 4 = 1*2 + 2    {-2, +2, -1,  0, 2, 2}, // Step 2 LD  // 5 = 1*2 + 2 + 1    {+2, -2,  0, -1, 2, 2}, // Step 2 RU  // 6 = 2*2 + 2    {+2, +2,  0,  0, 2, 2}, // Step 2 RD  // 7 = 2*2 + 2 + 1// ----    {-1,  0, -1,  0, 3, 0}, // Step 3 CCL // 8 = (0*6) + (0*2) + 8    {+1,  0,  0,  0, 1, 0}, // Step 3 CCR // 9 = (0*6) + (0*2) + 8 + 1    {-1, -2, -1, -1, 3, 2}, // Step 3 CUL // 10 = (0*6) + (1*2) + 8    {+1, -2,  0, -1, 1, 2}, // Step 3 CUR // 11 = (0*6) + (1*2) + 8 + 1    {-1, +2, -1,  0, 3, 2}, // Step 3 CDL // 12 = (0*6) + (2*2) + 8    {+1, +2,  0,  0, 1, 2}, // Step 3 CDR // 13 = (0*6) + (2*2) + 8 + 1    {-3,  0, -1,  0, 1, 0}, // Step 3 LCL // 14 = (1*6) + (0*2) + 8    {-1,  0, -1,  0, 3, 0}, // Step 3 LCR // 15 = (1*6) + (0*2) + 8 + 1    {-3, -2, -1, -1, 1, 2}, // Step 3 LUL // 16 = (1*6) + (1*2) + 8    {-1, -2, -1, -1, 3, 2}, // Step 3 LUR // 17 = (1*6) + (1*2) + 8 + 1    {-3, +2, -1,  0, 1, 2}, // Step 3 LDL // 18 = (1*6) + (2*2) + 8    {-1, +2, -1,  0, 3, 2}, // Step 3 LDR // 19 = (1*6) + (2*2) + 8 + 1    {+1,  0,  0,  0, 1, 0}, // Step 3 RCL // 20 = (2*6) + (0*2) + 8    {+3,  0,  0,  0, 3, 0}, // Step 3 RCR // 21 = (2*6) + (0*2) + 8 + 1    {+1, -2,  0, -1, 1, 2}, // Step 3 RUL // 22 = (2*6) + (1*2) + 8    {+3, -2,  0, -1, 3, 2}, // Step 3 RUR // 23 = (2*6) + (1*2) + 8 + 1    {+1, +2,  0,  0, 1, 2}, // Step 3 RDL // 24 = (2*6) + (2*2) + 8    {+3, +2,  0,  0, 3, 2}, // Step 3 RDR // 25 = (2*6) + (2*2) + 8 + 1// ----    { 0, -1,  0, -1, 0, 3}, // Step 4 CCCU // 26 = (0*18) + (0*6) + (0*2) + 26    { 0, +1,  0,  0, 0, 1}, // Step 4 CCCD // 27 = (0*18) + (0*6) + (0*2) + 26 + 1    {-1, -1, -1, -1, 3, 3}, // Step 4 CCLU // 28 = (0*18) + (0*6) + (1*2) + 26    {-1, +1, -1,  0, 3, 1}, // Step 4 CCLD // 29 = (0*18) + (0*6) + (1*2) + 26 + 1    {+1, -1,  0, -1, 1, 3}, // Step 4 CCRU // 30 = (0*18) + (0*6) + (2*2) + 26    {+1, +1,  0,  0, 1, 1}, // Step 4 CCRD // 31 = (0*18) + (0*6) + (2*2) + 26 + 1    { 0, -3,  0, -1, 0, 1}, // Step 4 CUCU // 32 = (0*18) + (1*6) + (0*2) + 26    { 0, -1,  0, -1, 0, 3}, // Step 4 CUCD // 33 = (0*18) + (1*6) + (0*2) + 26 + 1    {-1, -3, -1, -1, 3, 1}, // Step 4 CULU // 34 = (0*18) + (1*6) + (1*2) + 26    {-1, -1, -1, -1, 3, 3}, // Step 4 CULD // 35 = (0*18) + (1*6) + (1*2) + 26 + 1    {+1, -3,  0, -1, 1, 1}, // Step 4 CURU // 36 = (0*18) + (1*6) + (2*2) + 26    {+1, -1,  0, -1, 1, 3}, // Step 4 CURD // 37 = (0*18) + (1*6) + (2*2) + 26 + 1    { 0, +1,  0,  0, 0, 1}, // Step 4 CDCU // 38 = (0*18) + (2*6) + (0*2) + 26    { 0, +3,  0,  0, 0, 3}, // Step 4 CDCD // 39 = (0*18) + (2*6) + (0*2) + 26 + 1    {-1, +1, -1,  0, 3, 1}, // Step 4 CDLU // 40 = (0*18) + (2*6) + (1*2) + 26    {-1, +3, -1,  0, 3, 3}, // Step 4 CDLD // 41 = (0*18) + (2*6) + (1*2) + 26 + 1    {+1, +1,  0,  0, 1, 1}, // Step 4 CDRU // 42 = (0*18) + (2*6) + (2*2) + 26    {+1, +3,  0,  0, 1, 3}, // Step 4 CDRD // 43 = (0*18) + (2*6) + (2*2) + 26 + 1    {-2, -1, -1, -1, 2, 3}, // Step 4 LCCU // 44 = (1*18) + (0*6) + (0*2) + 26    {-2, +1, -1,  0, 2, 1}, // Step 4 LCCD // 45 = (1*18) + (0*6) + (0*2) + 26 + 1    {-3, -1, -1, -1, 1, 3}, // Step 4 LCLU // 46 = (1*18) + (0*6) + (1*2) + 26    {-3, +1, -1,  0, 1, 1}, // Step 4 LCLD // 47 = (1*18) + (0*6) + (1*2) + 26 + 1    {-1, -1, -1, -1, 3, 3}, // Step 4 LCRU // 48 = (1*18) + (0*6) + (2*2) + 26    {-1, +1, -1,  0, 3, 1}, // Step 4 LCRD // 49 = (1*18) + (0*6) + (2*2) + 26 + 1    {-2, -3, -1, -1, 2, 1}, // Step 4 LUCU // 50 = (1*18) + (1*6) + (0*2) + 26    {-2, -1, -1, -1, 2, 3}, // Step 4 LUCD // 51 = (1*18) + (1*6) + (0*2) + 26 + 1

⌨️ 快捷键说明

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