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

📄 umc_vc1_dec_mb_interpolate_adv.cpp

📁 audio-video-codecs.rar语音编解码器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    else
        DeriveSecondStageChromaMV(pContext, xMV, yMV);

    CropChroma_tbl[pContext->m_seqLayerHeader->PROFILE](pContext, xMV, yMV);

    *xMV = (Ipp16s)((X << 5) + *xMV);
    *yMV = (Ipp16s)((Y << 5) + *yMV);

}
static VC1Status InterpolateBlock_ProgressivePictureChroma4MV(VC1Context* pContext,
                                                           Ipp8u *pDst1, Ipp32s dstStep1,
                                                           Ipp8u *pDst2, Ipp32s dstStep2,
                                                           Ipp32s back)
{
    _IppVCInterpolate_8u*  interp_params = &pContext->interp_params_chroma;
    VC1MB *pCurrMB = pContext->m_pCurrMB;
    VC1SingletonMB* sMB = pContext->m_pSingleMB;

    Ipp32s index = (back)? pContext->m_frmBuff.m_iNextIndex:pContext->m_frmBuff.m_iPrevIndex;

    Ipp8u* pUPlaneRef = pContext->m_frmBuff.m_pFrames[index].m_pU;
    Ipp8u* pVPlaneRef = pContext->m_frmBuff.m_pFrames[index].m_pV;

    Ipp16s xMV, yMV;
    VM_ASSERT (index>-1);

#ifdef VC1_DEBUG_ON
//    VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_PRED,VM_STRING("Before Interpolation progressive chroma1%d, %d\n"),X,Y);
#endif

    interp_params->roiSize.width = 8;
    interp_params->roiSize.height = 8;

    //VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("%block number %d \n"),blk_num );

    //U channel
    xMV = pCurrMB->m_pBlocks[4].mv[back][0];
    yMV = pCurrMB->m_pBlocks[4].mv[back][1];

    Ipp32s count=0;
    sMB->MVcount =0;
    for (count = 0; count < 4; count++)
    {
        if (VC1_BLK_INTER & pCurrMB->m_pBlocks[count].blkType)
        {
            sMB->xLuMV[sMB->MVcount] = pCurrMB->m_pBlocks[count].mv[back][0];
            sMB->yLuMV[sMB->MVcount] = pCurrMB->m_pBlocks[count].mv[back][1];
            ++sMB->MVcount;
        }
    }

    CalcMVInterpolateProgChroma4MV(pContext, &xMV, &yMV);
    //VM_Debug::GetInstance().vm_debug_frame(-1,VC1_BFRAMES,VM_STRING("interpolation(%d block)MV(%d,%d) back=%d\n"),blk_num,xMV,yMV,back);

#ifdef VC1_DEBUG_ON
//    VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_PRED,VM_STRING("Before Interpolation progressive chroma%d, %d\n"),X,Y);
#endif

    interp_params->pSrc = pUPlaneRef + ((xMV>>2) + (yMV>>2) * interp_params->srcStep);
    interp_params->pDst = pDst1;
    interp_params->dstStep = dstStep1;
    interp_params->dx = xMV&3;
    interp_params->dy = yMV&3;

    _own_ippiInterpolateQPBilinearIC_VC1_8u_C1R(interp_params);

    //V channel
    xMV = pCurrMB->m_pBlocks[5].mv[back][0];
    yMV = pCurrMB->m_pBlocks[5].mv[back][1];

    CalcMVInterpolateProgChroma4MV(pContext, &xMV, &yMV);

#ifdef VC1_DEBUG_ON
//    VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_PRED,VM_STRING("Before Interpolation progressive chroma%d, %d\n"),X,Y);
#endif

    interp_params->pSrc = pVPlaneRef + ((xMV>>2) + (yMV>>2) * interp_params->srcStep);
    interp_params->pDst = pDst2;
    interp_params->dstStep = dstStep2;
    interp_params->dx = xMV&3;
    interp_params->dy = yMV&3;

    _own_ippiInterpolateQPBilinearIC_VC1_8u_C1R(interp_params);

    return VC1_OK;
}



static Ipp32s CalcMVInterpolateInterlacedLuma(VC1Context* pContext, Ipp16s* xMV, Ipp16s* yMV)
{
    Ipp32s f = 0;

    VC1SingletonMB* sMB = pContext->m_pSingleMB;
    Ipp32s X, Y;

    X = sMB->m_currMBXpos;
    Y = sMB->m_currMBYpos;

    CropLumaPullBack_Adv(pContext, xMV, yMV);

    X = (X << 6) + *xMV;
    Y = (Y << 6) + *yMV;

    f = (Y&4)>>2;

    Y>>=1;

    *xMV = (Ipp16s)X;
    *yMV = (Ipp16s)((Y & 0xFFFFFC) + (*yMV&3));

    return f;
}
static VC1Status InterpolateBlock_InterlacePictureLuma2MV(VC1Context* pContext, Ipp8u *pDst,
                                                       Ipp32s dstStep, Ipp32s back1,Ipp32s back2)
{
    _IppVCInterpolate_8u*  interp_params = &pContext->interp_params_luma;
    VC1MB *pMB = pContext->m_pCurrMB;
    Ipp32s index = (back1)? pContext->m_frmBuff.m_iNextIndex:pContext->m_frmBuff.m_iPrevIndex;
    Ipp16s xMV, yMV;
    Ipp32s f = 0;

    interp_params->pSrc = pContext->m_frmBuff.m_pFrames[index].m_pY;
    interp_params->roiSize.width = 16;
    interp_params->roiSize.height = 8;

    //VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("%block number %d \n"),blk_num );

    xMV = pMB->m_pBlocks[0].mv[back1][0];
    yMV = pMB->m_pBlocks[0].mv[back1][1];

    //VM_Debug::GetInstance().vm_debug_frame(-1,VC1_BFRAMES,VM_STRING("interpolation(%d block)MV(%d,%d) back=%d\n"),blk_num,xMV,yMV,back);

    f = CalcMVInterpolateInterlacedLuma(pContext, &xMV, &yMV);

    if (f)
        interp_params->pSrc += interp_params->srcStep;

    interp_params->srcStep = 2*interp_params->srcStep;
    interp_params->pSrc += ((xMV>>2) + (yMV>>2) * interp_params->srcStep);
    interp_params->pDst = pDst;
    interp_params->dstStep = dstStep;
    interp_params->dx = xMV&3;
    interp_params->dy = yMV&3;

#ifdef VC1_DEBUG_ON
    //VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_PRED,VM_STRING("Before Interpolation interlace luma%d, %d\n"),X,Y);
#endif

     _own_ippiInterpolateQPBicubicIC_VC1_8u_C1R(interp_params);


     //second field
     index = (back2)? pContext->m_frmBuff.m_iNextIndex:pContext->m_frmBuff.m_iPrevIndex;
     interp_params->pSrc = pContext->m_frmBuff.m_pFrames[index].m_pY;

     xMV = pMB->m_pBlocks[2].mv_bottom[back2][0];
     yMV = pMB->m_pBlocks[2].mv_bottom[back2][1];

     f = CalcMVInterpolateInterlacedLuma(pContext, &xMV, &yMV);

     if (f == 1)
        yMV = yMV + 4;
     else
        interp_params->pSrc += (interp_params->srcStep>>1);

    interp_params->pSrc += ((xMV>>2) + (yMV>>2) * interp_params->srcStep);
    interp_params->pDst = pDst + 8*dstStep;
    interp_params->dx = xMV&3;
    interp_params->dy = yMV&3;

    _own_ippiInterpolateQPBicubicIC_VC1_8u_C1R(interp_params);

     interp_params->srcStep = interp_params->srcStep/2;

    return VC1_OK;
}


static VC1Status InterpolateBlock_InterlacePictureLuma(VC1Context* pContext, Ipp8u *pDst,
                                                       Ipp32s dstStep, Ipp32s blk_num)
{
    _IppVCInterpolate_8u*  interp_params = &pContext->interp_params_luma;
    VC1MB *pMB = pContext->m_pCurrMB;
    Ipp32s index = pContext->m_frmBuff.m_iPrevIndex;

    interp_params->pSrc = pContext->m_frmBuff.m_pFrames[index].m_pY;

    Ipp16s xMV;
    Ipp16s yMV;

    Ipp32s f = 0;

    //VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("%block number %d \n"),blk_num );

    xMV = pMB->m_pBlocks[blk_num].mv[0][0];
    yMV = pMB->m_pBlocks[blk_num].mv[0][1];

    f = CalcMVInterpolateInterlacedLuma(pContext, &xMV, &yMV);

    if (f)
        interp_params->pSrc += interp_params->srcStep;

    if(blk_num & 1)
        xMV = xMV + 32;

    interp_params->roiSize.width = 8;
    interp_params->roiSize.height = 8;
    interp_params->srcStep = 2*interp_params->srcStep;
    interp_params->pSrc += ((xMV>>2) + (yMV>>2) * interp_params->srcStep);
    interp_params->pDst = pDst;
    interp_params->dstStep = dstStep;
    interp_params->dx = xMV&3;
    interp_params->dy = yMV&3;

#ifdef VC1_DEBUG_ON
    //VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_PRED,VM_STRING("Before Interpolation interlace luma%d, %d\n"),X,Y);
#endif
    //VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING(" vc1_MVMode1MV\n"));

    _own_ippiInterpolateQPBicubicIC_VC1_8u_C1R(interp_params);


    //second field
    xMV = pMB->m_pBlocks[blk_num + 2].mv_bottom[0][0];
    yMV = pMB->m_pBlocks[blk_num + 2].mv_bottom[0][1];

    interp_params->pSrc = pContext->m_frmBuff.m_pFrames[index].m_pY;

    f = CalcMVInterpolateInterlacedLuma(pContext, &xMV, &yMV);

     if (f == 1)
        yMV = yMV + 4;
     else
       interp_params->pSrc += (interp_params->srcStep>>1);

     if(blk_num&1)
        xMV = xMV + 32;

    interp_params->pSrc += ((xMV>>2) + (yMV>>2) * interp_params->srcStep);
    interp_params->pDst = pDst + 8*dstStep;
    interp_params->dx = xMV&3;
    interp_params->dy = yMV&3;

    _own_ippiInterpolateQPBicubicIC_VC1_8u_C1R(interp_params);

    interp_params->srcStep = interp_params->srcStep/2;

    return VC1_OK;
}


static Ipp32s CalcMVInterpolateInterlacedChroma2MV(VC1Context* pContext, Ipp16s* xMV, Ipp16s* yMV)
{
    Ipp32s f = 0;

    VC1SingletonMB* sMB = pContext->m_pSingleMB;
    Ipp32s X, Y;

    X = sMB->m_currMBXpos;
    Y = sMB->m_currMBYpos;

    DeriveSecondStageChromaMV_Interlace(pContext, xMV, yMV);
    CropChromaPullBack_Adv(pContext, xMV, yMV);

    X = (X << 5) + *xMV;
    Y = (Y << 5) + *yMV;

    f = (Y&4)>>2;

    Y>>=1;

    *xMV = (Ipp16s)X;
    *yMV = (Ipp16s)((Y & 0xFFFFFC) + (*yMV&3));

    return f;
}
static VC1Status InterpolateBlock_InterlacePictureChroma2MV_P(VC1Context* pContext,
                                                              Ipp8u *pDst1, Ipp32s dstStep1,
                                                              Ipp8u *pDst2, Ipp32s dstStep2)
{
    VC1MB *pMB = pContext->m_pCurrMB;
    Ipp32s index = pContext->m_frmBuff.m_iPrevIndex;
    _IppVCInterpolate_8u*  interp_params = &pContext->interp_params_chroma;

    Ipp8u* pUPlaneRef = pContext->m_frmBuff.m_pFrames[index].m_pU;
    Ipp8u* pVPlaneRef = pContext->m_frmBuff.m_pFrames[index].m_pV;

    Ipp8u* pRefData = NULL;
    Ipp8u* pCurrData = NULL;

    Ipp32s UPitch = pContext->m_frmBuff.m_pFrames[index].m_iUPitch;
    Ipp32s VPitch = pContext->m_frmBuff.m_pFrames[index].m_iVPitch;

    Ipp16s xMV=0;
    Ipp16s yMV=0;
    Ipp32s f;

    Ipp32s refPitch;

    interp_params->roiSize.width = 8;
    interp_params->roiSize.height = 4;

    //TOP FIELD
    xMV = pMB->m_pBlocks[0].mv[0][0];
    yMV = pMB->m_pBlocks[0].mv[0][1];
    //VM_Debug::GetInstance().vm_debug_frame(-1,VC1_BFRAMES,VM_STRING("interpolation(%d block)MV(%d,%d) back=%d\n"),blk_num,xMV,yMV,back);

    f = CalcMVInterpolateInterlacedChroma2MV(pContext, &xMV, &yMV);

    //4 BLOCK
    refPitch  = UPitch;
    pRefData  = pUPlaneRef;
    pCurrData = pDst1;

    if (f)
        pRefData += refPitch;
    refPitch  <<= 1;

    interp_params->pSrc = pRefData + ((xMV>>2) + (yMV>>2) * refPitch);
    interp_params->srcStep = 2*interp_params->srcStep;
    interp_params->pDst = pCurrData;
    interp_params->dstStep = dstStep1*2;
    interp_params->dx = xMV&3;
    interp_params->dy = yMV&3;

#ifdef VC1_DEBUG_ON
//    VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_PRED,VM_STRING("Before Interpolation interlace chroma%d, %d\n"),X,Y);
#endif
    ippiInterpolateQPBilinear_VC1_8u_C1R(interp_params);

    //5 BLOCK
    refPitch  = VPitch;
    pRefData  = pVPlaneRef;
    pCurrData = pDst2;

    if (f)
        pRefData += refPitch;
    refPitch  <<= 1;

    interp_params->pSrc = pRefData + ((xMV>>2) + (yMV>>2) * refPitch);
    interp_params->pDst = pCurrData;
    interp_params->dstStep = dstStep2*2;

    ippiInterpolateQPBilinear_VC1_8u_C1R(interp_params);

    //bottom field
    xMV = pMB->m_pBlocks[0].mv_bottom[0][0];
    yMV = pMB->m_pBlocks[0].mv_bottom[0][1];

    f = CalcMVInterpolateInterlacedChroma2MV(pContext, &xMV, &yMV);

    if (f == 1)
        yMV = yMV + 4;

    f ^= 1;

    //BLOCK 4
    refPitch  = UPitch;
    pRefData  = pUPlaneRef;
    pCurrData = pDst1 + dstStep1;

    if (f)
        pRefData += refPitch;
    refPitch  <<= 1;

    interp_params->pSrc = pRefData + ((xMV>>2) + (yMV>>2) * refPitch);
    interp_params->pDst = pCurrData;
    interp_params->dx = xMV&3;
    interp_params->dy = yMV&3;

    ippiInterpolateQPBilinear_VC1_8u_C1R(interp_params);

    //BLOCK 5
    refPitch  = VPitch;

⌨️ 快捷键说明

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