📄 umc_avs_dec_decompressor.cpp
字号:
/*
//
// 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_sequence_header.h"
#include "umc_avs_picture_header.h"
#include "umc_avs_dec_bit_stream.h"
#include "umc_avs_dec_mb_info.h"
#include "umc_avs_dec_pic.h"
#include "umc_avs_dec_slice.h"
namespace UMC
{
AVSDecompressor::AVSDecompressor(void)
{
} // AVSDecompressor::AVSDecompressor(void)
AVSDecompressor::~AVSDecompressor(void)
{
} // AVSDecompressor::AVSDecompressor(void)
void AVSDecompressor::PrepareNeighbours(AVS_BASE_CONTEXT *pCtx)
{
// set the current macroblock
m_pMbInfo = pCtx->m_pMBInfo;
// set the pointer to the left macroblock
m_pMbInfoLeft = NULL;
// set the pointer to the upper macroblocks
if (pCtx->MbIndex > pCtx->MbFirst)
{
m_pMbInfoTop = pCtx->m_pMBInfo - pCtx->MbWidth;
m_pMbInfoTopRight = (1 < pCtx->MbWidth) ? (m_pMbInfoTop + 1) : (NULL);
}
else
{
m_pMbInfoTop = NULL;
m_pMbInfoTopRight = NULL;
}
m_pMbInfoTopLeft = NULL;
} // void AVSDecompressor::PrepareNeighbours(AVS_BASE_CONTEXT *pCtx)
void AVSDecompressor::PrepareDecoding(void)
{
AVSPicture *pPic = m_decCtx.m_pSlice->m_pPic;
// move blockDist closer
memcpy(m_blockDist, pPic->m_blockDist, sizeof(m_blockDist));
} // void AVSDecompressor::PrepareDecoding(void)
void AVSDecompressor::PrepareReconstruction(void)
{
if (AVS_I_PICTURE != m_recCtx.m_pPicHeader->PictureType)
{
AVSPicture *pPic = m_recCtx.m_pSlice->m_pPic;
// move reference list close
memcpy(m_pRef, pPic->m_pRef, sizeof(m_pRef));
// prepare motion compensation structures
memset(&m_lumaMCParams, 0, sizeof(m_lumaMCParams));
m_lumaMCParams.sizeFrame = pPic->m_sizeLuma;
memset(&m_chromaMCParams, 0, sizeof(m_chromaMCParams));
m_chromaMCParams.sizeFrame = pPic->m_sizeChroma;
// move picture's plane pointers closer
memcpy(m_pPlanes8u, pPic->m_pPlanes8u, sizeof(m_pPlanes8u));
m_iPitch = pPic->m_iPitch;
}
} // void AVSDecompressor::PrepareReconstruction(void)
void AVSDecompressor::ResetMacroblock(void)
{
// reset macroblock info
memset(m_pMbInfo, 0, sizeof(AVS_MB_INFO));
} // void AVSDecompressor::ResetMacroblock(void)
void AVSDecompressor::AdvanceNeighbours(void)
{
// update pointer to the upper neighbours
if (m_pMbInfoTop)
{
m_pMbInfoTopLeft = m_pMbInfoTop;
m_pMbInfoTop += 1;
m_pMbInfoTopRight = (MbIndex + 1 < MbMax) ?
(m_pMbInfoTopRight + 1) :
(NULL);
}
// update pointer to the left neighbour
m_pMbInfoLeft = m_pMbInfo;
// update pointer to the current macroblock
m_pMbInfo += 1;
} // void AVSDecompressor::AdvanceNeighbours(void)
void AVSDecompressor::AdvanceDecoding(void)
{
} // void AVSDecompressor::AdvanceDecoding(void)
void AVSDecompressor::AdvanceReconstruction(void)
{
// update plane pointers
if (1 == m_recCtx.m_pSeqHeader->sample_precission)
{
// advance luminance pointer
m_recCtx.m_pPlanes8u[0] += 16;
// advance chrominance pointer
m_recCtx.m_pPlanes8u[1] += 8;
m_recCtx.m_pPlanes8u[2] += 8;
}
// update macroblock position
m_recCtx.MbX += 1;
} // void AVSDecompressor::AdvanceReconstruction(void)
void AVSDecompressor::DecompressIMacroBlocksRow(void)
{
MbMax = m_decCtx.MbIndex + m_decCtx.MbWidth;
// we can use MbIndex either from decoding and reconstructing contexts
MbIndex = m_decCtx.MbIndex;
PrepareNeighbours(&m_decCtx);
PrepareDecoding();
PrepareReconstruction();
do
{
ResetMacroblock();
// decode next macroblock
// set coeffs buffers
m_pWriteCoeffs = m_decCtx.m_pCoeffs;
m_pReadCoeffs = m_recCtx.m_pCoeffs;
DecodeIMacroBlockType();
DecodeIMacroBlock();
ReconstructIMacroBlock();
MbIndex += 1;
AdvanceNeighbours();
AdvanceDecoding();
AdvanceReconstruction();
} while (MbIndex < MbMax);
// update context
FinalizeDecoding();
FinalizeReconstruction();
} // void AVSDecompressor::DecompressIMacroBlocksRow(void)
void AVSDecompressor::DecompressPMacroBlocksRow(void)
{
MbMax = m_decCtx.MbIndex + m_decCtx.MbWidth;
// we can use MbIndex either from decoding and reconstructing contexts
MbIndex = m_decCtx.MbIndex;
PrepareNeighbours(&m_decCtx);
PrepareDecoding();
PrepareReconstruction();
do
{
ResetMacroblock();
// try to get number of skipped macroblocks
if (-1 == m_decCtx.SkipMbCount)
{
if (1 == m_decCtx.m_pPicHeader->skip_mode_flag)
{
m_decCtx.SkipMbCount = GetUE(&m_decCtx.m_stream);
}
}
// the previous macroblock was skipped or skip_mb_run is 0,
// so this one is decoded
if (0 == m_decCtx.SkipMbCount)
{
m_decCtx.SkipMbCount -= 1;
}
// decode next macroblock
if (0 >= m_decCtx.SkipMbCount)
{
// set coeffs buffers
m_pWriteCoeffs = m_decCtx.m_pCoeffs;
m_pReadCoeffs = m_recCtx.m_pCoeffs;
DecodePMacroBlockType();
// call appropriate routines
switch (m_pMbInfo->MbType)
{
case P_Skip:
DecodeSkipPMacroBlock();
ReconstructPMacroBlock();
break;
case I_8x8:
DecodeIMacroBlock();
ReconstructIMacroBlock();
break;
default:
DecodePMacroBlock();
ReconstructPMacroBlock();
break;
};
}
// next macroblock is skipped
else
{
DecodeSkipPMacroBlock();
ReconstructPMacroBlock();
m_decCtx.SkipMbCount -= 1;
}
MbIndex += 1;
AdvanceNeighbours();
AdvanceDecoding();
AdvanceReconstruction();
} while (MbIndex < MbMax);
// update context
FinalizeDecoding();
FinalizeReconstruction();
} // void AVSDecompressor::DecompressPMacroBlocksRow(void)
void AVSDecompressor::FinalizeDecoding(void)
{
// update variables
m_decCtx.MbIndex += m_decCtx.MbWidth;
m_decCtx.m_pMBInfo += m_decCtx.MbWidth;
m_decCtx.m_pCoeffs = m_pWriteCoeffs;
} // void AVSDecompressor::FinalizeDecoding(void)
void AVSDecompressor::FinalizeReconstruction(void)
{
// update variables
m_recCtx.MbIndex += m_recCtx.MbWidth;
m_recCtx.m_pMBInfo += m_recCtx.MbWidth;
m_recCtx.m_pCoeffs = m_pReadCoeffs;
m_recCtx.MbX = 0;
m_recCtx.MbY = m_recCtx.MbY + 1;
// update pointers to the video planes
if (1 == m_recCtx.m_pSeqHeader->sample_precission)
{
Ipp32s iPitch = m_recCtx.m_iPitch;
m_recCtx.m_pPlanes8u[0] = m_recCtx.m_pPlanes8u[0] -
m_recCtx.MbWidth * 16 +
iPitch * 16;
if (AVS_CHROMA_420_FORMAT == m_recCtx.m_pSeqHeader->chroma_format)
{
m_recCtx.m_pPlanes8u[1] = m_recCtx.m_pPlanes8u[1] -
m_recCtx.MbWidth * 8 +
iPitch * 8;
m_recCtx.m_pPlanes8u[2] = m_recCtx.m_pPlanes8u[2] -
m_recCtx.MbWidth * 8 +
iPitch * 8;
}
else
{
m_recCtx.m_pPlanes8u[1] = m_recCtx.m_pPlanes8u[1] -
m_recCtx.MbWidth * 8 +
iPitch * 16;
m_recCtx.m_pPlanes8u[2] = m_recCtx.m_pPlanes8u[2] -
m_recCtx.MbWidth * 8 +
iPitch * 16;
}
}
} // void AVSDecompressor::FinalizeReconstruction(void)
} // namespace UMC
#endif // #if defined(UMC_ENABLE_AVS_VIDEO_DECODER)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -