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

📄 umc_avs_dec_decompressor_pred_inter.cpp

📁 audio-video-codecs.rar语音编解码器
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/*
//
//              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) 2007 Intel Corporation. All Rights Reserved.
//
//
*/

#include "umc_defs.h"
#if defined(UMC_ENABLE_AVS_VIDEO_DECODER)

#include "umc_avs_dec_decompressor.h"
#include "umc_avs_picture_header.h"
#include "umc_avs_dec_mb_info.h"

namespace UMC
{

void AVSDecompressor::ReconstructMotionVectorsPSlice(void)
{
    AVSMVector mvTemp;

    switch (m_pMbInfo->divType)
    {
    case Div_16x16:
        // get the motion vector prediction & reconstruct motion vector
        GetMotionVectorPredictor16x16(PredForward);
        mvTemp = mv_diff[0] + m_mvPred;
        m_pMbInfo->mv[0][0] = mvTemp;
        m_pMbInfo->mv[0][1] = mvTemp;
        m_pMbInfo->mv[0][2] = mvTemp;
        m_pMbInfo->mv[0][3] = mvTemp;
        break;

    case Div_16x8:
        // get the motion vector prediction & reconstruct motion vector
        m_neighbours.pNearest = m_pMbInfoTop;
        m_neighbours.pTop = m_pMbInfoTop;
        m_neighbours.pTopRight = m_pMbInfoTopRight;
        m_neighbours.pTopLeft = m_pMbInfoTopLeft;
        GetMotionVectorPredictor16x8(PredForward, 0);
        mvTemp = mv_diff[0] + m_mvPred;
        m_pMbInfo->mv[0][0] = mvTemp;
        m_pMbInfo->mv[0][1] = mvTemp;

        // get the motion vector prediction & reconstruct motion vector
        m_neighbours.pNearest = m_pMbInfoLeft;
        m_neighbours.pTop = m_pMbInfo;
        m_neighbours.pTopRight = NULL;
        m_neighbours.pTopLeft = m_pMbInfoLeft;
        GetMotionVectorPredictor16x8(PredForward, 2);
        mvTemp = mv_diff[1] + m_mvPred;
        m_pMbInfo->mv[0][2] = mvTemp;
        m_pMbInfo->mv[0][3] = mvTemp;
        break;

    case Div_8x16:
        // get the motion vector prediction & reconstruct motion vector
        m_neighbours.pNearest = m_pMbInfoLeft;
        m_neighbours.pLeft = m_pMbInfoLeft;
        m_neighbours.pTopRight = m_pMbInfoTop;
        m_neighbours.pTopLeft = NULL;
        GetMotionVectorPredictor8x16(PredForward, 0);
        mvTemp = mv_diff[0] + m_mvPred;
        m_pMbInfo->mv[0][0] = mvTemp;
        m_pMbInfo->mv[0][2] = mvTemp;

        // get the motion vector prediction & reconstruct motion vector
        m_neighbours.pNearest = (m_pMbInfoTopRight) ? (m_pMbInfoTopRight) : (m_pMbInfoTop);
        m_neighbours.pLeft = m_pMbInfo;
        m_neighbours.pTopRight = m_pMbInfoTopRight;
        m_neighbours.pTopLeft = m_pMbInfoTop;
        GetMotionVectorPredictor8x16(PredForward, 1);
        mvTemp = mv_diff[1] + m_mvPred;
        m_pMbInfo->mv[0][1] = mvTemp;
        m_pMbInfo->mv[0][3] = mvTemp;
        break;

    default:
        // get the motion vector prediction & reconstruct motion vector
        m_neighbours.pLeft = m_pMbInfoLeft;
        m_neighbours.pTop = m_pMbInfoTop;
        m_neighbours.pTopRight = m_pMbInfoTop;
        m_neighbours.pTopLeft = NULL;
        GetMotionVectorPredictor8x8(PredForward, 0);
        mvTemp = mv_diff[0] + m_mvPred;
        m_pMbInfo->mv[0][0] = mvTemp;

        // get the motion vector prediction & reconstruct motion vector
        m_neighbours.pLeft = m_pMbInfo;
        m_neighbours.pTopRight = m_pMbInfoTopRight;
        m_neighbours.pTopLeft = m_pMbInfoTop;
        GetMotionVectorPredictor8x8(PredForward, 1);
        mvTemp = mv_diff[1] + m_mvPred;
        m_pMbInfo->mv[0][1] = mvTemp;

        // get the motion vector prediction & reconstruct motion vector
        m_neighbours.pLeft = m_pMbInfoLeft;
        m_neighbours.pTop = m_pMbInfo;
        m_neighbours.pTopRight = m_pMbInfo;
        m_neighbours.pTopLeft = NULL;
        GetMotionVectorPredictor8x8(PredForward, 2);
        mvTemp = mv_diff[2] + m_mvPred;
        m_pMbInfo->mv[0][2] = mvTemp;

        // get the motion vector prediction & reconstruct motion vector
        m_neighbours.pLeft = m_pMbInfo;
        m_neighbours.pTopRight = NULL;
        m_neighbours.pTopLeft = m_pMbInfo;
        GetMotionVectorPredictor8x8(PredForward, 3);
        mvTemp = mv_diff[3] + m_mvPred;
        m_pMbInfo->mv[0][3] = mvTemp;
        break;
    }

} // void AVSDecompressor::ReconstructMotionVectorsPSlice(void)

void AVSDecompressor::ReconstructMotionVectorsBSlice(void)
{
    switch (m_pMbInfo->divType)
    {
    case Div_16x16:
        ReconstructMotionVectorsBSlice16x16();
        break;

    case Div_16x8:
        ReconstructMotionVectorsBSlice16x8();
        break;

    case Div_8x16:
        ReconstructMotionVectorsBSlice8x16();
        break;

    default:
        ReconstructMotionVectorsBSlice8x8();
        break;
    }

} // void AVSDecompressor::ReconstructMotionVectorsBSlice(void)

void AVSDecompressor::ReconstructMotionVectorsBSlice16x16(void)
{
    Ipp8u *pPredType = m_pMbInfo->predType;

    // get the forward motion vector prediction & reconstruct the motion vector
    if (pPredType[0] & PredForward)
    {
        AVSMVector mvTemp;

        GetMotionVectorPredictor16x16(PredForward);
        mvTemp = mv_diff[0] + m_mvPred;
        m_pMbInfo->mv[AVS_FORWARD][0] = mvTemp;
        m_pMbInfo->mv[AVS_FORWARD][1] = mvTemp;
        m_pMbInfo->mv[AVS_FORWARD][2] = mvTemp;
        m_pMbInfo->mv[AVS_FORWARD][3] = mvTemp;
    }

    if (PredForward != pPredType[0])
    {
        AVSMVector mvTemp;

        // reconstruct the backward motion vector
        if (PredBackward == pPredType[0])
        {
            GetMotionVectorPredictor16x16(PredBackward);
            mvTemp = mv_diff[0] + m_mvPred;
        }
        // create the symmetrical backward motion vector
        else
        {
            AVSMVector mvFrw;
            Ipp32s DistanceMul;

            mvFrw = m_pMbInfo->mv[AVS_FORWARD][0];
            DistanceMul = m_blockDist[AVS_BACKWARD][0] * (512 / m_blockDist[AVS_FORWARD][0]);
            mvTemp.vector.x = (Ipp16s) -((mvFrw.vector.x * DistanceMul + 256) >> 9);
            mvTemp.vector.y = (Ipp16s) -((mvFrw.vector.y * DistanceMul + 256) >> 9);

            // correct prediction type
            pPredType[0] = PredBiDir;
            pPredType[1] = PredBiDir;
            pPredType[2] = PredBiDir;
            pPredType[3] = PredBiDir;
        }

        m_pMbInfo->mv[AVS_BACKWARD][0] = mvTemp;
        m_pMbInfo->mv[AVS_BACKWARD][1] = mvTemp;
        m_pMbInfo->mv[AVS_BACKWARD][2] = mvTemp;
        m_pMbInfo->mv[AVS_BACKWARD][3] = mvTemp;
    }

} // void AVSDecompressor::ReconstructMotionVectorsBSlice16x16(void)

#define AVS_PREPARE_NEIGHBOURS_16x8_0 \
    m_neighbours.pNearest = m_pMbInfoTop; \
    m_neighbours.pTop = m_pMbInfoTop; \
    m_neighbours.pTopRight = m_pMbInfoTopRight; \
    m_neighbours.pTopLeft = m_pMbInfoTopLeft;

#define AVS_PREPARE_NEIGHBOURS_16x8_1 \
    m_neighbours.pNearest = m_pMbInfoLeft; \
    m_neighbours.pTop = m_pMbInfo; \
    m_neighbours.pTopRight = NULL; \
    m_neighbours.pTopLeft = m_pMbInfoLeft;

void AVSDecompressor::ReconstructMotionVectorsBSlice16x8(void)
{
    Ipp8u *pPredType = m_pMbInfo->predType;
    Ipp32s numMV;

    numMV = 0;
    // get the motion vector prediction & reconstruct motion vector
    if (pPredType[0] & PredForward)
    {
        AVSMVector mvTemp;

        AVS_PREPARE_NEIGHBOURS_16x8_0
        GetMotionVectorPredictor16x8(PredForward, 0);
        mvTemp = mv_diff[numMV++] + m_mvPred;
        m_pMbInfo->mv[AVS_FORWARD][0] = mvTemp;
        m_pMbInfo->mv[AVS_FORWARD][1] = mvTemp;
    }

    // get the motion vector prediction & reconstruct motion vector
    if (pPredType[2] & PredForward)
    {
        AVSMVector mvTemp;

        AVS_PREPARE_NEIGHBOURS_16x8_1
        GetMotionVectorPredictor16x8(PredForward, 2);
        mvTemp = mv_diff[numMV++] + m_mvPred;
        m_pMbInfo->mv[AVS_FORWARD][2] = mvTemp;
        m_pMbInfo->mv[AVS_FORWARD][3] = mvTemp;
    }

    if (PredForward != pPredType[0])
    {
        AVSMVector mvTemp;

        // reconstruct the backward motion vector
        if (PredBackward == pPredType[0])
        {
            AVS_PREPARE_NEIGHBOURS_16x8_0
            GetMotionVectorPredictor16x8(PredBackward, 0);
            mvTemp = mv_diff[numMV++] + m_mvPred;
        }
        // create the symmetrical backward motion vector
        else
        {
            AVSMVector mvFrw;
            Ipp32s DistanceMul;

            mvFrw = m_pMbInfo->mv[AVS_FORWARD][0];
            DistanceMul = m_blockDist[AVS_BACKWARD][0] * (512 / m_blockDist[AVS_FORWARD][0]);
            mvTemp.vector.x = (Ipp16s) -((mvFrw.vector.x * DistanceMul + 256) >> 9);
            mvTemp.vector.y = (Ipp16s) -((mvFrw.vector.y * DistanceMul + 256) >> 9);

            // correct prediction type
            pPredType[0] = PredBiDir;
            pPredType[1] = PredBiDir;
        }

        m_pMbInfo->mv[AVS_BACKWARD][0] = mvTemp;
        m_pMbInfo->mv[AVS_BACKWARD][1] = mvTemp;
    }

    if (PredForward != pPredType[2])
    {
        AVSMVector mvTemp;

        // reconstruct the backward motion vector
        if (PredBackward == pPredType[2])
        {
            AVS_PREPARE_NEIGHBOURS_16x8_1
            GetMotionVectorPredictor16x8(PredBackward, 2);
            mvTemp = mv_diff[numMV++] + m_mvPred;
        }
        // create the symmetrical backward motion vector
        else
        {
            AVSMVector mvFrw;
            Ipp32s DistanceMul;

            mvFrw = m_pMbInfo->mv[AVS_FORWARD][2];
            DistanceMul = m_blockDist[AVS_BACKWARD][0] * (512 / m_blockDist[AVS_FORWARD][0]);
            mvTemp.vector.x = (Ipp16s) -((mvFrw.vector.x * DistanceMul + 256) >> 9);
            mvTemp.vector.y = (Ipp16s) -((mvFrw.vector.y * DistanceMul + 256) >> 9);

            // correct prediction type
            pPredType[2] = PredBiDir;
            pPredType[3] = PredBiDir;
        }

        m_pMbInfo->mv[AVS_BACKWARD][2] = mvTemp;
        m_pMbInfo->mv[AVS_BACKWARD][3] = mvTemp;
    }

} // void AVSDecompressor::ReconstructMotionVectorsBSlice16x8(void)

#define AVS_PREPARE_NEIGHBOURS_8x16_0 \
    m_neighbours.pNearest = m_pMbInfoLeft; \
    m_neighbours.pLeft = m_pMbInfoLeft; \
    m_neighbours.pTopRight = m_pMbInfoTop; \
    m_neighbours.pTopLeft = NULL; \

#define AVS_PREPARE_NEIGHBOURS_8x16_1 \
    m_neighbours.pNearest = (m_pMbInfoTopRight) ? (m_pMbInfoTopRight) : (m_pMbInfoTop); \
    m_neighbours.pLeft = m_pMbInfo; \
    m_neighbours.pTopRight = m_pMbInfoTopRight; \
    m_neighbours.pTopLeft = m_pMbInfoTop;

void AVSDecompressor::ReconstructMotionVectorsBSlice8x16(void)
{
    Ipp8u *pPredType = m_pMbInfo->predType;
    Ipp32s numMV;

    numMV = 0;
    // get the motion vector prediction & reconstruct motion vector
    if (pPredType[0] & PredForward)
    {
        AVSMVector mvTemp;

        AVS_PREPARE_NEIGHBOURS_8x16_0
        GetMotionVectorPredictor8x16(PredForward, 0);
        mvTemp = mv_diff[numMV++] + m_mvPred;
        m_pMbInfo->mv[AVS_FORWARD][0] = mvTemp;

⌨️ 快捷键说明

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