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

📄 umc_vc1_dec_mb_interpolate_adv.cpp

📁 audio-video-codecs.rar语音编解码器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/* /////////////////////////////////////////////////////////////////////////////
//
//                  INTEL CORPORATION PROPRIETARY INFORMATION
//     This software is supplied under the terms of a license agreement or
//     nondisclosure agreement with Intel Corporation and may not be copied
//     or disclosed except in accordance with the terms of that agreement.
//          Copyright(c) 2004-2007 Intel Corporation. All Rights Reserved.
//
//
//          VC-1 (VC1) decoder, MB Layer common for simple\main profiles
//
*/
#include "umc_defs.h"

#if defined (UMC_ENABLE_VC1_VIDEO_DECODER)

#include "umc_vc1_dec_seq.h"
#include "umc_vc1_dec_debug.h"
#include "umc_vc1_common_defs.h"
#include "assert.h"
#include "ippvc.h"


static const Ipp32s blk_table[] = {0,0,0,0,1,1};

typedef void (*CropMV) (VC1Context* pContext, Ipp16s* xMV, Ipp16s* yMV);

static const CropMV CropLuma_tbl[] = {
    (CropMV)(CropLumaPullBack),
    (CropMV)(CropLumaPullBack),
    (CropMV)(NULL),
    (CropMV)(CropLumaPullBack_Adv)
};

static const CropMV CropChroma_tbl[] = {
    (CropMV)(CropChromaPullBack),
    (CropMV)(CropChromaPullBack),
    (CropMV)(NULL),
    (CropMV)(CropChromaPullBack_Adv)
};


static const Ipp16s offset_table_x[] = {0,32,0, 32};
static const Ipp16s offset_table_y[] = {0,0, 32,32};

static void CalcMVInterpolateProgLuma(VC1Context* pContext, Ipp16s* xMV, Ipp16s* yMV)
{
    VC1SingletonMB* sMB = pContext->m_pSingleMB;
    Ipp32s X, Y;

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

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

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

}

static VC1Status InterpolateBlock_ProgressivePictureLuma1MV_P(VC1Context* pContext, Ipp8u *pDst,
                                                           Ipp32u dstStep)
{
    _IppVCInterpolate_8u*  interp_params = &pContext->interp_params_luma;

    VC1MB *pMB = pContext->m_pCurrMB;
    Ipp32s index = pContext->m_frmBuff.m_iPrevIndex;
    VM_ASSERT (index>-1);

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

    CalcMVInterpolateProgLuma(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);

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

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


//#ifdef VC1_DEBUG_ON
//    VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_PRED,VM_STRING("Before Interpolation Progressive luma %d, %d\n"),X,Y);
//#endif
    if((interp_params->dx + interp_params->dy == 0))
    {
        pMB->pInterpolLumaSrc[0] = interp_params->pSrc;
        pMB->InterpolsrcLumaStep[0] = interp_params->srcStep;
    }
    else
        switch(pContext->m_picLayerHeader->MVMODE)
        {
        case VC1_MVMODE_1MV:
        case VC1_MVMODE_MIXED_MV:
            //VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING(" vc1_MVMode1MV\n"));

            //if(interp_params->dx + interp_params->dy == 0)
            //{
            //    pMB->pInterpolSrc[0] = interp_params->pSrc;
            //    pMB->InterpolsrcStep[0] = interp_params->srcStep;
            //}
            //else
                _own_ippiInterpolateQPBicubicIC_VC1_8u_C1R(interp_params);

            break;
        case VC1_MVMODE_HPEL_1MV:
    //#ifdef VC1_DEBUG_ON
    //        VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_PRED,VM_STRING(" MVMode1MVHalfPel\n"));
    //#endif
            //interp_params->dx = xMV&2;
            //interp_params->dy = yMV&2;

            //interp_params->pSrc += ( (xMV>>2) + (yMV>>2) * interp_params->srcStep);

            //if((interp_params->dx + interp_params->dy == 0))
            //{
            //    pMB->pInterpolSrc[0] = interp_params->pSrc;
            //    pMB->InterpolsrcStep[0] = interp_params->srcStep;
            //}
            //else
                _own_ippiInterpolateQPBicubicIC_VC1_8u_C1R(interp_params);
            break;
        case VC1_MVMODE_HPELBI_1MV:
    //#ifdef VC1_DEBUG_ON
    //        VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_PRED,VM_STRING(" MVMode1MVHalfPelBilinear\n"));
    //#endif
            //interp_params->dx = xMV&2;
            //interp_params->dy = yMV&2;

            //interp_params->pSrc += ( (xMV>>2) + (yMV>>2) * interp_params->srcStep);

            //if((interp_params->dx + interp_params->dy == 0))
            //{
            //    pMB->pInterpolSrc[0] = interp_params->pSrc;
            //    pMB->InterpolsrcStep[0] = interp_params->srcStep;
            //}
            //else
                _own_ippiInterpolateQPBilinearIC_VC1_8u_C1R(interp_params);

            break;
        default:
            VM_ASSERT(0);
        }

    return VC1_OK;
}
static VC1Status InterpolateBlock_ProgressivePictureLuma1MV_B(VC1Context* pContext, Ipp8u *pDst,
                                                           Ipp32u dstStep, Ipp32s back)
{
    _IppVCInterpolate_8u*  interp_params = &pContext->interp_params_luma;

    VC1MB *pMB = pContext->m_pCurrMB;
    Ipp32s index = (back)? pContext->m_frmBuff.m_iNextIndex:pContext->m_frmBuff.m_iPrevIndex;
    VM_ASSERT (index>-1);

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

    CalcMVInterpolateProgLuma(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);

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

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

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

//#ifdef VC1_DEBUG_ON
//    VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_PRED,VM_STRING("Before Interpolation Progressive luma %d, %d\n"),X,Y);
//#endif
    if((interp_params->dx + interp_params->dy == 0))
    {
        pMB->pInterpolLumaSrc[back] = interp_params->pSrc;
        pMB->InterpolsrcLumaStep[back] = interp_params->srcStep;
    }
    else
        switch(pContext->m_picLayerHeader->MVMODE)
        {
        case VC1_MVMODE_1MV:
        case VC1_MVMODE_MIXED_MV:
            //VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING(" vc1_MVMode1MV\n"));

            //if((interp_params->dx + interp_params->dy == 0))
            //{
            //    pMB->pInterpolSrc[back] = interp_params->pSrc;
            //    pMB->InterpolsrcStep[back] = interp_params->srcStep;
            //}
            //else
                _own_ippiInterpolateQPBicubicIC_VC1_8u_C1R(interp_params);

            break;
        case VC1_MVMODE_HPEL_1MV:
    //#ifdef VC1_DEBUG_ON
    //        VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_PRED,VM_STRING(" MVMode1MVHalfPel\n"));
    //#endif
            //interp_params->dx = xMV&2;
            //interp_params->dy = yMV&2;

            //interp_params->pSrc += ( (xMV>>2) + (yMV>>2) * interp_params->srcStep);
            //if((interp_params->dx + interp_params->dy == 0))
            //{
            //    pMB->pInterpolSrc[back] = interp_params->pSrc;
            //    pMB->InterpolsrcStep[back] = interp_params->srcStep;
            //}
            //else
                _own_ippiInterpolateQPBicubicIC_VC1_8u_C1R(interp_params);
            break;
        case VC1_MVMODE_HPELBI_1MV:
    //#ifdef VC1_DEBUG_ON
    //        VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_PRED,VM_STRING(" MVMode1MVHalfPelBilinear\n"));
    //#endif
            //interp_params->dx = xMV&2;
            //interp_params->dy = yMV&2;

            //interp_params->pSrc += ( (xMV>>2) + (yMV>>2) * interp_params->srcStep);
            //if((interp_params->dx + interp_params->dy == 0))
            //{
            //    pMB->pInterpolSrc[back] = interp_params->pSrc;
            //    pMB->InterpolsrcStep[back] = interp_params->srcStep;
            //}
            //else
                _own_ippiInterpolateQPBilinearIC_VC1_8u_C1R(interp_params);

            break;
        default:
            VM_ASSERT(0);
        }

    return VC1_OK;
}


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

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

    VM_ASSERT (index>-1);

    CalcMVInterpolateProgLuma(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);

    xMV = xMV + offset_table_x[blk_num];
    yMV = yMV + offset_table_y[blk_num];

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

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


    _own_ippiInterpolateQPBicubicIC_VC1_8u_C1R(interp_params);

    return VC1_OK;
}

static void CalcMVInterpolateProgChroma1MV(VC1Context* pContext, Ipp16s* xMV, Ipp16s* yMV)
{
    VC1SingletonMB* sMB = pContext->m_pSingleMB;
    Ipp32s X, Y;

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

    if (pContext->m_picLayerHeader->FCM == VC1_FrameInterlace)
        DeriveSecondStageChromaMV_Interlace(pContext, xMV, yMV);
    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_ProgressivePictureChroma1MV(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;

    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 = pCurrMB->m_pBlocks[0].mv[back][0];
    Ipp16s yMV = pCurrMB->m_pBlocks[0].mv[back][1];
    Ipp32s PlaneOffset = 0;

    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

    CalcMVInterpolateProgChroma1MV(pContext, &xMV, &yMV);

    //VM_Debug::GetInstance().vm_debug_frame(-1,VC1_PRED,VM_STRING("%block number %d \n"),blk_num );
    //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);

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


    if((interp_params->dx + interp_params->dy == 0))
    {
        //U channel
        interp_params->pSrc    = pUPlaneRef + PlaneOffset;
        pCurrMB->pInterpolChromaUSrc[back] = interp_params->pSrc;
        pCurrMB->InterpolsrcChromaUStep[back] = interp_params->srcStep;

        //V channel
        interp_params->pSrc    = pVPlaneRef + PlaneOffset;
        pCurrMB->pInterpolChromaVSrc[back] = interp_params->pSrc;
        pCurrMB->InterpolsrcChromaVStep[back] = interp_params->srcStep;
    }
    else
    {
        //U channel
        interp_params->pSrc    = pUPlaneRef + PlaneOffset;
        interp_params->pDst    = pDst1;
        interp_params->dstStep = dstStep1;
        _own_ippiInterpolateQPBilinearIC_VC1_8u_C1R(interp_params);

        //V channel
        interp_params->pSrc    = pVPlaneRef + PlaneOffset;
        interp_params->pDst    = pDst2;
        interp_params->dstStep = dstStep2;

        _own_ippiInterpolateQPBilinearIC_VC1_8u_C1R(interp_params);
    }

    return VC1_OK;
}

static void CalcMVInterpolateProgChroma4MV(VC1Context* pContext, Ipp16s* xMV, Ipp16s* yMV)
{
    VC1SingletonMB* sMB = pContext->m_pSingleMB;
    Ipp32s X, Y;

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

    Derive4MV(sMB, xMV,yMV);

    if (pContext->m_picLayerHeader->FCM == VC1_FrameInterlace)
        DeriveSecondStageChromaMV_Interlace(pContext, xMV, yMV);

⌨️ 快捷键说明

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