📄 umc_h264_segment_decoder_mt_reconstruct_mv.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) 2003-2007 Intel Corporation. All Rights Reserved.
//
//
*/
#include "umc_defs.h"
#if defined (UMC_ENABLE_H264_VIDEO_DECODER)
#include "umc_h264_segment_decoder_mt.h"
#include "vm_event.h"
#include "vm_semaphore.h"
#include "vm_thread.h"
#include "umc_h264_bitstream_inlines.h"
#include "umc_h264_segment_decoder_templates.h"
namespace UMC
{
void H264SegmentDecoderMultiThreaded::ResetMVs16x16(Ipp32s iListNum)
{
H264DecoderMotionVector *pMV = m_cur_mb.MVs[iListNum]->MotionVectors;
#ifdef __ICL
__assume_aligned(pMV, 16);
#endif // __ICL
memset(pMV, 0, 16 * sizeof(H264DecoderMotionVector));
} // void H264SegmentDecoderMultiThreaded::ResetMVs16x16(Ipp32s iListNum)
void H264SegmentDecoderMultiThreaded::ResetMVs16x8(Ipp32s iListNum,
Ipp32s iVectorOffset)
{
H264DecoderMotionVector *pMV = m_cur_mb.MVs[iListNum]->MotionVectors +
iVectorOffset;
#ifdef __ICL
__assume_aligned(pMV, 16);
#endif // __ICL
memset(pMV, 0, 8 * sizeof(H264DecoderMotionVector));
} // void H264SegmentDecoderMultiThreaded::ResetMVs16x8(Ipp32s iListNum,
void H264SegmentDecoderMultiThreaded::ResetMVs8x16(Ipp32s iListNum,
Ipp32s iVectorOffset)
{
H264DecoderMotionVector *pMV = m_cur_mb.MVs[iListNum]->MotionVectors +
iVectorOffset;
#ifdef __ICL
__assume_aligned(pMV, 16);
#endif // __ICL
memset(pMV, 0, 2 * sizeof(H264DecoderMotionVector));
} // void H264SegmentDecoderMultiThreaded::ResetMVs8x16(Ipp32s iListNum,
void H264SegmentDecoderMultiThreaded::ResetMVs8x8(Ipp32s iListNum,
Ipp32s iVectorOffset)
{
H264DecoderMotionVector *pMV = m_cur_mb.MVs[iListNum]->MotionVectors +
iVectorOffset;
#ifdef __ICL
__assume_aligned(pMV, 16);
#endif // __ICL
memset(pMV, 0, 2 * sizeof(H264DecoderMotionVector));
memset(pMV + 4, 0, 2 * sizeof(H264DecoderMotionVector));
} // void H264SegmentDecoderMultiThreaded::ResetMVs8x8(Ipp32s iListNum,
void H264SegmentDecoderMultiThreaded::CopyMVs8x16(Ipp32s iListNum)
{
H264DecoderMotionVector *pMV = m_cur_mb.MVs[iListNum]->MotionVectors;
#ifdef __ICL
__assume_aligned(pMV, 16);
#endif // __ICL
memcpy(pMV + 4, pMV + 0, 4 * sizeof(H264DecoderMotionVector));
memcpy(pMV + 8, pMV + 0, 4 * sizeof(H264DecoderMotionVector));
memcpy(pMV + 12, pMV + 0, 4 * sizeof(H264DecoderMotionVector));
} // void H264SegmentDecoderMultiThreaded::CopyMVs8x16(Ipp32s iListNum)
void H264SegmentDecoderMultiThreaded::ReconstructMVs16x16(Ipp32s iListNum)
{
H264DecoderMotionVector mvPred;
// get the prediction
ReconstructMVPredictor16x16(iListNum, &mvPred);
// do the reconstruction
{
H264DecoderMotionVector *pMV = m_cur_mb.MVs[iListNum]->MotionVectors;
H264DecoderMotionVector *pMVd = m_cur_mb.MVs[iListNum + 2]->MotionVectors;
#ifdef __ICL
__assume_aligned(pMV, 16);
__assume_aligned(pMVd, 16);
#endif // __ICL
{
Ipp32s i;
H264DecoderMotionVector mv;
// calculate new vector
mv.mvx = (Ipp16s) (mvPred.mvx + pMVd[0].mvx);
mv.mvy = (Ipp16s) (mvPred.mvy + pMVd[0].mvy);
if (mv.mvy > m_MVDistortion[iListNum])
m_MVDistortion[iListNum] = mv.mvy;
for (i = 0; i < 16; i += 1)
pMV[i] = mv;
}
}
} // void H264SegmentDecoderMultiThreaded::ReconstructMVs16x16(Ipp32s iListNum)
void H264SegmentDecoderMultiThreaded::ReconstructMVs16x8(Ipp32s iListNum,
Ipp32s iSubBlockNum)
{
H264DecoderMotionVector mvPred;
// get the prediction
ReconstructMVPredictor16x8(iListNum, iSubBlockNum, &mvPred);
// do the reconstruction
{
H264DecoderMotionVector *pMV = m_cur_mb.MVs[iListNum]->MotionVectors +
iSubBlockNum * 8;
H264DecoderMotionVector *pMVd = m_cur_mb.MVs[iListNum + 2]->MotionVectors +
iSubBlockNum * 8;
#ifdef __ICL
__assume_aligned(pMV, 16);
__assume_aligned(pMVd, 16);
#endif // __ICL
{
Ipp32s i;
H264DecoderMotionVector mv;
// calculate new vector
mv.mvx = (Ipp16s) (mvPred.mvx + pMVd[0].mvx);
mv.mvy = (Ipp16s) (mvPred.mvy + pMVd[0].mvy);
if (mv.mvy > m_MVDistortion[iListNum])
m_MVDistortion[iListNum] = mv.mvy;
for (i = 0; i < 8; i += 1)
pMV[i] = mv;
}
}
} // void H264SegmentDecoderMultiThreaded::ReconstructMVs16x8(Ipp32s iListNum,
void H264SegmentDecoderMultiThreaded::ReconstructMVs8x16(Ipp32s iListNum,
Ipp32s iSubBlockNum)
{
H264DecoderMotionVector mvPred;
// get the prediction
ReconstructMVPredictor8x16(iListNum, iSubBlockNum, &mvPred);
// do the reconstruction
{
H264DecoderMotionVector *pMV = m_cur_mb.MVs[iListNum]->MotionVectors +
iSubBlockNum * 2;
H264DecoderMotionVector *pMVd = m_cur_mb.MVs[iListNum + 2]->MotionVectors +
iSubBlockNum * 2;
#ifdef __ICL
__assume_aligned(pMV, 16);
__assume_aligned(pMVd, 16);
#endif // __ICL
{
H264DecoderMotionVector mv;
// calculate new vector
mv.mvx = (Ipp16s) (mvPred.mvx + pMVd[0].mvx);
mv.mvy = (Ipp16s) (mvPred.mvy + pMVd[0].mvy);
if (mv.mvy > m_MVDistortion[iListNum])
m_MVDistortion[iListNum] = mv.mvy;
pMV[0] = mv;
pMV[1] = mv;
}
}
} // void H264SegmentDecoderMultiThreaded::ReconstructMVs8x16(Ipp32s iListNum,
void H264SegmentDecoderMultiThreaded::ReconstructMVsExternal(Ipp32s iListNum)
{
Ipp8s *pSBType = m_cur_mb.GlobalMacroblockInfo->sbtype;
switch (pSBType[0])
{
case SBTYPE_8x8:
ReconstructMVs8x8External(iListNum);
break;
case SBTYPE_8x4:
// the first block
ReconstructMVs8x4External(iListNum);
// the second block
ReconstructMVs8x4Left(iListNum, 1);
break;
case SBTYPE_4x8:
// the first block
ReconstructMVs4x8External(iListNum);
// the second block
ReconstructMVs4x8Top(iListNum, 1);
break;
default:
// the first block
ReconstructMVs4x4External(iListNum);
// the second block
ReconstructMVs4x4Top(iListNum, 1);
// the third block
ReconstructMVs4x4Left(iListNum, 1);
// the fourth block
ReconstructMVs4x4InternalNoCheckRef(iListNum, 5);
break;
}
} // void H264SegmentDecoderMultiThreaded::ReconstructMVsExternal(Ipp32s iListNum)
void H264SegmentDecoderMultiThreaded::ReconstructMVsTop(Ipp32s iListNum)
{
Ipp8s *pSBType = m_cur_mb.GlobalMacroblockInfo->sbtype;
switch (pSBType[1])
{
case SBTYPE_8x8:
ReconstructMVs8x8Top(iListNum);
break;
case SBTYPE_8x4:
// the first block
ReconstructMVs8x4Top(iListNum);
// the second block
ReconstructMVs8x4Internal(iListNum, 6);
break;
case SBTYPE_4x8:
// the first block
ReconstructMVs4x8Top(iListNum, 2);
// the second block
ReconstructMVs4x8Top(iListNum, 3);
break;
default:
// the first block
ReconstructMVs4x4Top(iListNum, 2);
// the second block
ReconstructMVs4x4Top(iListNum, 3);
// the third block
ReconstructMVs4x4InternalFewCheckRef(iListNum, 6, 3);
// the fourth block
ReconstructMVs4x4InternalNoCheckRef(iListNum, 7);
break;
}
} // void H264SegmentDecoderMultiThreaded::ReconstructMVsTop(Ipp32s iListNum)
void H264SegmentDecoderMultiThreaded::ReconstructMVsLeft(Ipp32s iListNum)
{
Ipp8s *pSBType = m_cur_mb.GlobalMacroblockInfo->sbtype;
switch (pSBType[2])
{
case SBTYPE_8x8:
ReconstructMVs8x8Left(iListNum);
break;
case SBTYPE_8x4:
// the first block
ReconstructMVs8x4Left(iListNum, 2);
// the second block
ReconstructMVs8x4Left(iListNum, 3);
break;
case SBTYPE_4x8:
// the first block
ReconstructMVs4x8Left(iListNum);
// the second block
ReconstructMVs4x8Internal(iListNum, 9, 6);
break;
default:
// the first block
ReconstructMVs4x4Left(iListNum, 2);
// the second block
ReconstructMVs4x4Internal(iListNum, 9, 6);
// the third block
ReconstructMVs4x4Left(iListNum, 3);
// the fourth block
ReconstructMVs4x4InternalNoCheckRef(iListNum, 13);
break;
}
} // void H264SegmentDecoderMultiThreaded::ReconstructMVsLeft(Ipp32s iListNum)
void H264SegmentDecoderMultiThreaded::ReconstructMVsInternal(Ipp32s iListNum)
{
Ipp8s *pSBType = m_cur_mb.GlobalMacroblockInfo->sbtype;
switch (pSBType[3])
{
case SBTYPE_8x8:
ReconstructMVs8x8Internal(iListNum);
break;
case SBTYPE_8x4:
// the first block
ReconstructMVs8x4Internal(iListNum, 10);
// the second block
ReconstructMVs8x4Internal(iListNum, 14);
break;
case SBTYPE_4x8:
// the first block
ReconstructMVs4x8Internal(iListNum, 10, 7);
// the second block
ReconstructMVs4x8Internal(iListNum, 11, 6);
break;
default:
// the first block
ReconstructMVs4x4InternalFewCheckRef(iListNum, 10, 7);
// the second block
ReconstructMVs4x4InternalFewCheckRef(iListNum, 11, 6);
// the third block
ReconstructMVs4x4InternalFewCheckRef(iListNum, 14, 11);
// the fourth block
ReconstructMVs4x4InternalNoCheckRef(iListNum, 15);
break;
}
} // void H264SegmentDecoderMultiThreaded::ReconstructMVsInternal(Ipp32s iListNum)
void H264SegmentDecoderMultiThreaded::ReconstructMVs8x8External(Ipp32s iListNum)
{
H264DecoderMotionVector mvPred;
H264DecoderMotionVector *pMV = m_cur_mb.MVs[iListNum]->MotionVectors;
H264DecoderMotionVector *pMVd = m_cur_mb.MVs[iListNum + 2]->MotionVectors;
// get the prediction
{
H264DecoderBlockLocation mbAddrC;
mbAddrC = m_cur_mb.CurrentBlockNeighbours.mb_above;
mbAddrC.block_num += 2;
ReconstructMVPredictorExternalBlock(iListNum, mbAddrC, &mvPred);
}
#ifdef __ICL
__assume_aligned(pMV, 16);
__assume_aligned(pMVd, 16);
#endif // __ICL
{
H264DecoderMotionVector mv;
// calculate new vector
mv.mvx = (Ipp16s) (mvPred.mvx + pMVd[0].mvx);
mv.mvy = (Ipp16s) (mvPred.mvy + pMVd[0].mvy);
if (mv.mvy > m_MVDistortion[iListNum])
m_MVDistortion[iListNum] = mv.mvy;
pMV[0] = mv;
pMV[1] = mv;
pMV[4] = mv;
pMV[5] = mv;
}
} // void H264SegmentDecoderMultiThreaded::ReconstructMVs8x8External(Ipp32s iListNum)
void H264SegmentDecoderMultiThreaded::ReconstructMVs8x8Top(Ipp32s iListNum)
{
H264DecoderMotionVector mvPred;
H264DecoderMotionVector *pMV = m_cur_mb.MVs[iListNum]->MotionVectors;
H264DecoderMotionVector *pMVd = m_cur_mb.MVs[iListNum + 2]->MotionVectors;
// get the prediction
{
H264DecoderBlockLocation mbAddrC;
mbAddrC = m_cur_mb.CurrentBlockNeighbours.mb_above_right;
ReconstructMVPredictorTopBlock(iListNum, 2, mbAddrC, &mvPred);
}
#ifdef __ICL
__assume_aligned(pMV, 16);
__assume_aligned(pMVd, 16);
#endif // __ICL
{
H264DecoderMotionVector mv;
// calculate new vector
mv.mvx = (Ipp16s) (mvPred.mvx + pMVd[2].mvx);
mv.mvy = (Ipp16s) (mvPred.mvy + pMVd[2].mvy);
if (mv.mvy > m_MVDistortion[iListNum])
m_MVDistortion[iListNum] = mv.mvy;
pMV[2] = mv;
pMV[3] = mv;
pMV[6] = mv;
pMV[7] = mv;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -