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

📄 umc_vc1_dec_mc.cpp

📁 audio-video-codecs.rar语音编解码器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* /////////////////////////////////////////////////////////////////////////////
//
//                  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 motion compensation
//
*/

#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 "umc_vc1_dec_intens_comp_tbl.h"
#include "umc_vc1_dec_time_statistics.h"

typedef void (*ExpandIntens)(VC1Context* pContext, Frame* pFrame);

static const ExpandIntens ExpandIntens_table[] =
             {
               (ExpandIntens)(ExpandFrame_Adv),
               (ExpandIntens)(ExpandFrame_Interlace),
               (ExpandIntens)(ExpandFrame_Interlace)
             };

void VC1_copy_field(VC1Context*pContext,Ipp32u bottom)
{
    Ipp32s YPitch = pContext->m_frmBuff.m_pFrames[pContext->m_frmBuff.m_iCurrIndex].m_iYPitch;
    Ipp32s UPitch = pContext->m_frmBuff.m_pFrames[pContext->m_frmBuff.m_iCurrIndex].m_iUPitch;
    Ipp32s VPitch = pContext->m_frmBuff.m_pFrames[pContext->m_frmBuff.m_iCurrIndex].m_iVPitch;

    Ipp8u* pY_src = pContext->m_frmBuff.m_pFrames[pContext->m_frmBuff.m_iCurrIndex].m_pY;
    Ipp8u* pU_src = pContext->m_frmBuff.m_pFrames[pContext->m_frmBuff.m_iCurrIndex].m_pU;
    Ipp8u* pV_src = pContext->m_frmBuff.m_pFrames[pContext->m_frmBuff.m_iCurrIndex].m_pV;

    Ipp8u* pY_dst = pContext->m_frmBuff.m_pFrames[pContext->m_frmBuff.m_iICompFieldIndex].m_pY;
    Ipp8u* pU_dst = pContext->m_frmBuff.m_pFrames[pContext->m_frmBuff.m_iICompFieldIndex].m_pU;
    Ipp8u* pV_dst = pContext->m_frmBuff.m_pFrames[pContext->m_frmBuff.m_iICompFieldIndex].m_pV;
    IppiSize roiSize;

    roiSize.height = (pContext->m_seqLayerHeader->MAX_CODED_HEIGHT+1);
    roiSize.width = 2*(pContext->m_seqLayerHeader->MAX_CODED_WIDTH+1);

    if (bottom)
    {
        pY_src += YPitch;
        pU_src += UPitch;
        pV_src += VPitch;

        pY_dst += YPitch;
        pU_dst += UPitch;
        pV_dst += VPitch;
    }

    YPitch *= 2;
    UPitch *= 2;
    VPitch *= 2;

    ippiCopy_8u_C1R(pY_src,YPitch,pY_dst,YPitch, roiSize);

    roiSize.height = roiSize.height/2;
    roiSize.width = roiSize.width/2;

    ippiCopy_8u_C1R(pU_src,UPitch,pU_dst,UPitch, roiSize);
    ippiCopy_8u_C1R(pV_src,VPitch,pV_dst,VPitch, roiSize);
}


VC1Status FillTablesForIntensityCompensation(VC1Context* pContext,
                                             Ipp32u scale,
                                             Ipp32u shift)
{
    //Ipp32u index = pContext->m_frmBuff.m_iPrevIndex;
    /*scale, shift parameters are in [0,63]*/
    Ipp32s i;
    Ipp32s iscale = (scale)? scale+32 : -64;
    Ipp32s ishift = (scale)? shift*64 : (255-2*shift)*64;
    Ipp32s z      = (scale)? -1:2;
    Ipp32s j ;


    ishift += (shift>31)? z<<12: 0;
#ifdef VC1_DEBUG_ON
    VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_INTENS,
                                            VM_STRING("shift=%d, scale=%d, iscale=%d, ishift=%d\n"),
                                            shift, scale, iscale, ishift);
#endif

    for (i=0;i<256;i++)
    {
        j = (i*iscale+ishift+32)>>6;
        pContext->LumaTable[0][i] = (Ipp8u)VC1_CLIP(j);
        j = ((i-128)*iscale+128*64+32)>>6;
        pContext->ChromaTable[0][i] = (Ipp8u)VC1_CLIP(j);

#ifdef VC1_DEBUG_ON
        VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_INTENS,
            VM_STRING("LumaTable[i]=%d, ChromaTable[i]=%d\n"),
            pContext->LumaTable[0][i],pContext->ChromaTable[0][i]);
#endif
    }

    return VC1_OK;
}

VC1Status FillTablesForIntensityCompensation_Adv(VC1Context* pContext,
                                                 Ipp32u scale,
                                                 Ipp32u shift,
                                                 Ipp32u bottom_field,
                                                 Ipp32s index)
{
    /*scale, shift parameters are in [0,63]*/
    Ipp32s i;
    Ipp32s iscale = (scale)? scale+32 : -64;
    Ipp32s ishift = (scale)? shift*64 : (255-2*shift)*64;
    Ipp32s z      = (scale)? -1:2;
    Ipp32s j ;
    Ipp8u *pY, *pU, *pV;
    IppiSize roiSize;

    roiSize.width = 2*(pContext->m_seqLayerHeader->MAX_CODED_WIDTH+1);
    roiSize.height = 2*(pContext->m_seqLayerHeader->MAX_CODED_HEIGHT+1);

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

    pY = pContext->m_frmBuff.m_pFrames[index].m_pY;
    pU = pContext->m_frmBuff.m_pFrames[index].m_pU;
    pV = pContext->m_frmBuff.m_pFrames[index].m_pV;

    if (pContext->m_picLayerHeader->FCM == VC1_FieldInterlace)
    {
        if (bottom_field)
        {
            pY += YPitch;
            pU += UPitch;
            pV += VPitch;
        }
        YPitch *= 2;
        UPitch *= 2;
        VPitch *= 2;

        roiSize.height /= 2;
    }

    ishift += (shift>31)? z*64*64: 0;
#ifdef VC1_DEBUG_ON
    VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_INTENS,
                                            VM_STRING("shift=%d, scale=%d, iscale=%d, ishift=%d\n"),
                                            shift, scale, iscale, ishift);
#endif
    Ipp32u LUTindex = bottom_field + (pContext->m_picLayerHeader->CurrField << 1);

    for (i=0;i<256;i++)
    {
        j = (i*iscale+ishift+32)>>6;
        pContext->LumaTable[LUTindex][i] = (Ipp8u)VC1_CLIP(j);
        j = ((i-128)*iscale+128*64+32)>>6;
        pContext->ChromaTable[LUTindex][i] = (Ipp8u)VC1_CLIP(j);
#ifdef VC1_DEBUG_ON
        VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_INTENS,
                                VM_STRING("LumaTable[i]=%d, ChromaTable[i]=%d\n"),
                                pContext->LumaTable[LUTindex][i],pContext->ChromaTable[LUTindex][i]);
#endif
    }
    return VC1_OK;
}
//Advance Profile
void VC1CompensateFrame(VC1Context* pContext,VC1PictureLayerHeader* SecFieldPicLayerHeader)
{
    Ipp32s YPitch = pContext->m_frmBuff.m_pFrames[pContext->m_frmBuff.m_iPrevIndex].m_iYPitch;
    Ipp32s UPitch = pContext->m_frmBuff.m_pFrames[pContext->m_frmBuff.m_iPrevIndex].m_iUPitch;
    Ipp32s VPitch = pContext->m_frmBuff.m_pFrames[pContext->m_frmBuff.m_iPrevIndex].m_iVPitch;

    Ipp8u* pY = pContext->m_frmBuff.m_pFrames[pContext->m_frmBuff.m_iPrevIndex].m_pY;
    Ipp8u* pU = pContext->m_frmBuff.m_pFrames[pContext->m_frmBuff.m_iPrevIndex].m_pU;
    Ipp8u* pV = pContext->m_frmBuff.m_pFrames[pContext->m_frmBuff.m_iPrevIndex].m_pV;


    IppiSize roiSize;

    roiSize.height = 2*(pContext->m_seqLayerHeader->MAX_CODED_HEIGHT+1);
    roiSize.width = 2*(pContext->m_seqLayerHeader->MAX_CODED_WIDTH+1);

    if (pContext->m_picLayerHeader->FCM != VC1_FieldInterlace)
    {

        ippiLUT_8u_C1IR(pY, YPitch, roiSize, pContext->LumaTable[0], vc1_dec_ic_level_tbl, 257);
        roiSize.height /= 2;
        roiSize.width /= 2;
        ippiLUT_8u_C1IR(pU, UPitch, roiSize, pContext->ChromaTable[0], vc1_dec_ic_level_tbl, 257);
        ippiLUT_8u_C1IR(pV, VPitch, roiSize, pContext->ChromaTable[0], vc1_dec_ic_level_tbl, 257);
        pContext->m_frmBuff.m_pFrames[pContext->m_frmBuff.m_iPrevIndex].m_bIsExpanded = 0;
        if (pContext->typeOfPreviousFrame != VC1_FieldInterlace)
            ExpandIntens_table[pContext->typeOfPreviousFrame](pContext, &pContext->m_frmBuff.m_pFrames[pContext->m_frmBuff.m_iPrevIndex]);
        else
            ExpandFrame_Interlace(pContext, &pContext->m_frmBuff.m_pFrames[pContext->m_frmBuff.m_iPrevIndex]);
    }
    else
    {
        // first field
        Ipp32u is_bottom = 0;
        Ipp32u is_top    = 0;
        VC1PictureLayerHeader* picLayerHeader = pContext->m_InitPicLayer;

        if(VC1_IS_INT_TOP_FIELD(picLayerHeader->INTCOMFIELD))
        {

            YPitch *= 2;
            UPitch *= 2;
            VPitch *= 2;
            roiSize.height = (pContext->m_seqLayerHeader->MAX_CODED_HEIGHT+1);
            is_top    = 1;
            STATISTICS_START_TIME(m_timeStatistics->intensity_StartTime);

⌨️ 快捷键说明

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