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

📄 umc_vc1_dec_mb_interpolate_adv.cpp

📁 audio-video-codecs.rar语音编解码器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        interp_params->dstStep = dstStep2;
        interp_params->pSrc = pRefData + ((xMV>>2) + (yMV>>2) * refPitch);

        ippiInterpolateQPBilinear_VC1_8u_C1R(interp_params);
    }

    return VC1_OK;
}


static Ipp32s CalcMVInterpolateInterlacedChroma4MV(VC1Context* pContext, Ipp16s* xMV, Ipp16s* yMV,
                                                   Ipp32s field, Ipp32s sblk_num)
{
    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;

    if (field)
    {
        f  = (Y & 4) >> 2;
        Y = Y >> 1;
    }

    if (sblk_num & 1)
        X += 16;

    if (sblk_num & 2)
    {
        if (field)
        {
            if (f==1)
                Y = Y + 4;
            f ^= 1;
        }
        else
            Y +=16;
    }

    *xMV = (Ipp16s) X;
    *yMV = (Ipp16s)((Y & 0xFFFFFC) + (*yMV & 3));
    return f;
}
static VC1Status InterpolateBlock_InterlaceChroma4MV (VC1Context* pContext,
                                                      Ipp8u* pDst1, Ipp32u dstStep1,
                                                      Ipp8u* pDst2, Ipp32u dstStep2,
                                                      Ipp32s field)
{
    VC1MB *pMB = pContext->m_pCurrMB;
    Ipp32s index = pContext->m_frmBuff.m_iPrevIndex;
    _IppVCInterpolate_8u*  interp_params = &pContext->interp_params_chroma;

    Ipp8u* pRefUData = NULL;
    Ipp32s refUPitch;

    Ipp8u* pRefVData = NULL;
    Ipp32s refVPitch;

    Ipp16s xMV[4] = {0};
    Ipp16s yMV[4] = {0};

    Ipp32s refCurUPitch = 0;
    Ipp32s refCurVPitch = 0;
    Ipp8u* pRefCurUData = NULL;
    Ipp8u* pRefCurVData = NULL;

    Ipp32s f = 0;
    Ipp32s sblk_num = 0;
    Ipp32u offset_tableU[4] ={0};
    Ipp32u offset_tableV[4] ={0};


    //BLOCK 4
    refUPitch  = pContext->m_frmBuff.m_pFrames[index].m_iUPitch;
    pRefUData  = pContext->m_frmBuff.m_pFrames[index].m_pU;

    //BLOCK 5
    refVPitch  = pContext->m_frmBuff.m_pFrames[index].m_iVPitch;
    pRefVData  = pContext->m_frmBuff.m_pFrames[index].m_pV;


    if (field)
    {
        xMV[0] = pMB->m_pBlocks[0].mv[0][0];
        xMV[1] = pMB->m_pBlocks[1].mv[0][0];
        xMV[2] = pMB->m_pBlocks[0].mv_bottom[0][0];
        xMV[3] = pMB->m_pBlocks[1].mv_bottom[0][0];
        yMV[0] = pMB->m_pBlocks[0].mv[0][1];
        yMV[1] = pMB->m_pBlocks[1].mv[0][1];
        yMV[2] = pMB->m_pBlocks[0].mv_bottom[0][1];
        yMV[3] = pMB->m_pBlocks[1].mv_bottom[0][1];

        //BLOCK 4
        refCurUPitch = 2*refUPitch;
        offset_tableU[0] = 0;
        offset_tableU[1] = 4;
        offset_tableU[2] = dstStep1;
        offset_tableU[3] = dstStep1 + 4;
        dstStep1 <<=1;

        //BLOCK 5
        refCurVPitch = 2*refVPitch;
        offset_tableV[0] = 0;
        offset_tableV[1] = 4;
        offset_tableV[2] = dstStep2;
        offset_tableV[3] = dstStep2 + 4;
        dstStep2 <<=1;
    }
    else
    {
        xMV[0] = pMB->m_pBlocks[0].mv[0][0];
        xMV[1] = pMB->m_pBlocks[1].mv[0][0];
        xMV[2] = pMB->m_pBlocks[2].mv[0][0];
        xMV[3] = pMB->m_pBlocks[3].mv[0][0];

        yMV[0] = pMB->m_pBlocks[0].mv[0][1];
        yMV[1] = pMB->m_pBlocks[1].mv[0][1];
        yMV[2] = pMB->m_pBlocks[2].mv[0][1];
        yMV[3] = pMB->m_pBlocks[3].mv[0][1];

        //BLOCK 4
        refCurUPitch = refUPitch;
        offset_tableU[0] = 0;
        offset_tableU[1] = 4;
        offset_tableU[2] = dstStep1*4;
        offset_tableU[3] = dstStep1*4 + 4;

        //BLOCK 5
        refCurVPitch = refVPitch;
        offset_tableV[0] = 0;
        offset_tableV[1] = 4;
        offset_tableV[2] = dstStep2*4;
        offset_tableV[3] = dstStep2*4 + 4;
    }

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

    for(sblk_num = 0; sblk_num < 4; sblk_num++)
    {
        pRefCurUData = pRefUData;
        pRefCurVData = pRefVData;

        f = CalcMVInterpolateInterlacedChroma4MV(pContext, &xMV[sblk_num], &yMV[sblk_num], field, sblk_num);

        if (f && field)
        {
            pRefCurUData = pRefCurUData + refUPitch;
            pRefCurVData = pRefCurVData + refVPitch;
        }

        interp_params->dx = xMV[sblk_num]&3;
        interp_params->dy = yMV[sblk_num]&3;

        //BLOCK 4
        interp_params->pSrc = pRefCurUData  + ((xMV[sblk_num]>>2) + (yMV[sblk_num]>>2) * refCurUPitch);
        interp_params->srcStep = refCurUPitch;
        interp_params->pDst = pDst1 + offset_tableU[sblk_num];
        interp_params->dstStep = dstStep1;

        ippiInterpolateQPBilinear_VC1_8u_C1R(interp_params);

        //BLOCK 5
        interp_params->pSrc = pRefCurVData  + ((xMV[sblk_num]>>2) + (yMV[sblk_num]>>2) * refCurVPitch);
        interp_params->srcStep = refCurVPitch;
        interp_params->pDst = pDst2 + offset_tableV[sblk_num];
        interp_params->dstStep = dstStep2;

        ippiInterpolateQPBilinear_VC1_8u_C1R(interp_params);
    }

    interp_params->dstStep = 8;
    interp_params->srcStep = refUPitch;

    return VC1_OK;
}

VC1Status PredictBlock_P(VC1Context* pContext)
{
    VC1MB* pCurrMB = pContext->m_pCurrMB;
    Ipp32u count = 0;
    Ipp8u IntraFlag = pCurrMB->IntraFlag;
    Ipp32s plane_offset;

    pCurrMB->pInterpolLumaSrc[0] = pCurrMB->currYPlane;
    pCurrMB->InterpolsrcLumaStep[0] = pCurrMB->currYPitch;

    pCurrMB->pInterpolChromaUSrc[0] = pCurrMB->currUPlane;
    pCurrMB->InterpolsrcChromaUStep[0] = pCurrMB->currUPitch;

    pCurrMB->pInterpolChromaVSrc[0] = pCurrMB->currVPlane;
    pCurrMB->InterpolsrcChromaVStep[0] = pCurrMB->currVPitch;

    if ( (pCurrMB->mbType&0x03) == VC1_MB_1MV_INTER)
    {
        //1 MV
        //luma
        InterpolateBlock_ProgressivePictureLuma1MV_P(pContext, pCurrMB->currYPlane,
                                                               pCurrMB->currYPitch);

        //chroma
        InterpolateBlock_ProgressivePictureChroma1MV(pContext, pCurrMB->currUPlane,
                                                               pCurrMB->currUPitch,
                                                               pCurrMB->currVPlane,
                                                               pCurrMB->currVPitch, 0);
    }
    else
    {
        //4 MV
        for (count = 0; count < VC1_NUM_OF_LUMA; count++)
        {
            if(IntraFlag & 1)
            {
                IntraFlag >>= 1;
                continue;
            }

            plane_offset = (count&1)*8 + (count&2)*4*pCurrMB->currYPitch;
            InterpolateBlock_ProgressivePictureLuma4MV(pContext, pCurrMB->currYPlane + plane_offset,
                                                                 pCurrMB->currYPitch, count);

            IntraFlag >>= 1;
        }

        if(!(IntraFlag & 1))
        {
            InterpolateBlock_ProgressivePictureChroma4MV(pContext, pCurrMB->currUPlane,
                                                                   pCurrMB->currUPitch,
                                                                   pCurrMB->currVPlane,
                                                                   pCurrMB->currVPitch, 0);
        }
    }
    return VC1_OK;
}

VC1Status PredictBlock_B(VC1Context* pContext)
{
    VC1MB* pCurrMB = pContext->m_pCurrMB;
    Ipp32u _predict_type = pCurrMB->mbType;
    Ipp32u predict_type = _predict_type >> 4;


    //1 MV
    if ( (VC1_GET_PREDICT(_predict_type) != VC1_MB_INTERP) && (VC1_GET_PREDICT(_predict_type) != VC1_MB_DIRECT) )
    {
        pCurrMB->pInterpolLumaSrc[predict_type] = pCurrMB->currYPlane;
        pCurrMB->InterpolsrcLumaStep[predict_type] = pCurrMB->currYPitch;

        pCurrMB->pInterpolChromaUSrc[predict_type] = pCurrMB->currUPlane;
        pCurrMB->InterpolsrcChromaUStep[predict_type] = pCurrMB->currUPitch;

        pCurrMB->pInterpolChromaVSrc[predict_type] = pCurrMB->currVPlane;
        pCurrMB->InterpolsrcChromaVStep[predict_type] = pCurrMB->currVPitch;

        //luma
        InterpolateBlock_ProgressivePictureLuma1MV_B(pContext, pCurrMB->currYPlane,
                                                   pCurrMB->currYPitch, predict_type);

        //chroma
        InterpolateBlock_ProgressivePictureChroma1MV(pContext, pCurrMB->currUPlane,
                                                               pCurrMB->currUPitch,
                                                               pCurrMB->currVPlane,
                                                               pCurrMB->currVPitch,
                                                               predict_type);

        pCurrMB->pInterpolLumaSrc[1 - predict_type] = NULL;
        pCurrMB->InterpolsrcLumaStep[1 - predict_type] = 0;
        pCurrMB->pInterpolChromaUSrc[1 - predict_type] =NULL;
        pCurrMB->InterpolsrcChromaUStep[1 - predict_type] = 0;
        pCurrMB->pInterpolChromaVSrc[1 - predict_type] = NULL;
        pCurrMB->InterpolsrcChromaVStep[1 - predict_type] = 0;
    }
    else
    {
        Ipp8u* pPredBlock = pContext->m_pPredBlock;

        assert(pPredBlock != NULL);

        pCurrMB->pInterpolLumaSrc[1] = pCurrMB->currYPlane;
        pCurrMB->InterpolsrcLumaStep[1] = pCurrMB->currYPitch;

        pCurrMB->pInterpolLumaSrc[0] = pPredBlock;
        pCurrMB->InterpolsrcLumaStep[0] = VC1_PIXEL_IN_LUMA;

        pCurrMB->pInterpolChromaUSrc[0] = pPredBlock + 64*4;
        pCurrMB->InterpolsrcChromaUStep[0] = VC1_PIXEL_IN_CHROMA;

        pCurrMB->pInterpolChromaVSrc[0] = pPredBlock + 64*5;
        pCurrMB->InterpolsrcChromaVStep[0] = VC1_PIXEL_IN_CHROMA;

        pCurrMB->pInterpolChromaUSrc[1] = pCurrMB->currUPlane;
        pCurrMB->InterpolsrcChromaUStep[1] = pCurrMB->currUPitch;

        pCurrMB->pInterpolChromaVSrc[1] = pCurrMB->currVPlane;
        pCurrMB->InterpolsrcChromaVStep[1] = pCurrMB->currVPitch;


        //luma
        //forward
        InterpolateBlock_ProgressivePictureLuma1MV_B(pContext, pPredBlock, VC1_PIXEL_IN_LUMA, 0);

        //backward
        InterpolateBlock_ProgressivePictureLuma1MV_B(pContext, pCurrMB->currYPlane,
                                                             pCurrMB->currYPitch, 1);
         //chroma U, V
        InterpolateBlock_ProgressivePictureChroma1MV(pContext, pPredBlock + 64*4,
                                                     VC1_PIXEL_IN_CHROMA,
                                                     pPredBlock + 64*5,
                                                     VC1_PIXEL_IN_CHROMA, 0);

        InterpolateBlock_ProgressivePictureChroma1MV(pContext, pCurrMB->currUPlane,
                                                               pCurrMB->currUPitch,
                                                               pCurrMB->currVPlane,
                                                               pCurrMB->currVPitch, 1);
    }

    return VC1_OK;
}

VC1Status PredictBlock_InterlacePPicture(VC1Context* pContext)
{
    VC1MB* pCurrMB = pContext->m_pCurrMB;
    Ipp8u* pPredBlock = pContext->m_pPredBlock;
    Ipp32s plane_offset;
    Ipp32u count= 0;
    pCurrMB->pInterpolLumaSrc[0] = pPredBlock;
    pCurrMB->InterpolsrcLumaStep[0] = VC1_PIXEL_IN_LUMA;
    pCurrMB->pInterpolChromaUSrc[0] = pCurrMB->currUPlane;
    pCurrMB->InterpolsrcChromaUStep[0] = pCurrMB->currUPitch;

    pCurrMB->pInterpolChromaVSrc[0] = pCurrMB->currVPlane;
    pCurrMB->InterpolsrcChromaVStep[0] = pCurrMB->currVPitch;

    assert(pPredBlock != NULL);

    //prediction phase: Derive MV and interpolation blocks
    switch(VC1_GET_MBTYPE(pCurrMB->mbType))
    {
    case  VC1_MB_4MV_INTER:
#ifdef VC1_DEBUG_ON
        VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_RESPEL,VM_STRING("4MV inter\n"));
#endif
        for (count = 0; count < VC1_NUM_OF_LUMA; count++)
        {
           plane_offset = (count&1)*8 + (count&2)*4*VC1_PIXEL_IN_LUMA;
           InterpolateBlock_ProgressivePictureLuma4MV(pContext, pPredBlock + plane_offset,
                                                             VC1_PIXEL_IN_LUMA,count);
        }

        InterpolateBlock_InterlaceChroma4MV(pContext, pCurrMB->currUPlane,       pCurrMB->currUPitch,
                                                      pCurrMB->currVPlane,       pCurrMB->currVPitch, 0);
         break;

    case VC1_MB_4MV_FIELD_INTER:
#ifdef VC1_DEBUG_ON
        VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_RESPEL,VM_STRING("4 MV field\n"));
#endif
        InterpolateBlock_InterlacePictureLuma(pContext, pPredBlock,
                                                        VC1_PIXEL_IN_LUMA, 0);

        InterpolateBlock_InterlacePictureLuma(pContext, pPredBlock + 8,
                                                        VC1_PIXEL_IN_LUMA, 1);

        InterpolateBlock_InterlaceChroma4MV(pContext, pCurrMB->currUPlane,       pCurrMB->currUPitch,
                                                      pCurrMB->currVPlane,       pCurrMB->currVPitch, 1);
  

⌨️ 快捷键说明

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