📄 umc_vc1_dec_job.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) 2004-2007 Intel Corporation. All Rights Reserved.
//
//
// VC-1 (VC1) decoder, Jobs for thread model
//
*/
#include "umc_defs.h"
#if defined (UMC_ENABLE_VC1_VIDEO_DECODER)
#include "umc_vc1_dec_job.h"
#include "umc_vc1_dec_seq.h"
#include "umc_vc1_common_acintra.h"
#include "umc_vc1_common_acinter.h"
#include "umc_vc1_dec_frame_descr.h"
#include "umc_vc1_dec_time_statistics.h"
#include "umc_vc1_dec_task_store.h"
#include "umc_vc1_dec_debug.h"
#include "umc_vc1_common_blk_order_tbl.h"
#include "umc_vc1_common.h"
#include "umc_automatic_mutex.h"
using namespace UMC;
using namespace UMC::VC1Common;
using namespace UMC::VC1Exceptions;
extern MBLayerDecode MBLayerDecode_tbl_Adv[12] = {
//I pic
(MBLayer_ProgressiveIpicture_Adv),
(MBLayer_Frame_InterlaceIpicture),
(MBLayer_Field_InterlaceIpicture),
//P pic
(MBLayer_ProgressivePpicture_Adv),
(MBLayer_Frame_InterlacedPpicture),
(MBLayer_Field_InterlacedPpicture),
//B pic
(MBLayer_ProgressiveBpicture_Adv),
(MBLayer_Frame_InterlacedBpicture),
(MBLayer_Field_InterlacedBpicture),
//BI pic
(MBLayer_ProgressiveIpicture_Adv),
(MBLayer_Frame_InterlaceIpicture),
(MBLayer_Field_InterlaceIpicture)
};
extern MBLayerDecode MBLayerDecode_tbl[12] = {
//I pic
(MBLayer_ProgressiveIpicture),
(NULL),
(NULL),
//P pic
(MBLayer_ProgressivePpicture),
(NULL),
(NULL),
//B pic
(MBLayer_ProgressiveBpicture),
(NULL),
(NULL),
//BI pic
(MBLayer_ProgressiveIpicture),
(NULL),
(NULL),
};
extern Deblock Deblock_tbl_Adv[12] = {
//I pic
(Deblocking_ProgressiveIpicture_Adv),
(Deblocking_InterlaceFrameIpicture_Adv),
(Deblocking_ProgressiveIpicture_Adv),
//P pic
(Deblocking_ProgressivePpicture_Adv),
(Deblocking_InterlaceFramePpicture_Adv),
(Deblocking_ProgressivePpicture_Adv),
//B pic
(Deblocking_ProgressiveIpicture_Adv),
(Deblocking_InterlaceFramePpicture_Adv),
(Deblocking_InterlaceFieldBpicture_Adv),
//BI pic
(Deblocking_ProgressiveIpicture_Adv),
(Deblocking_InterlaceFramePpicture_Adv),
(Deblocking_ProgressiveIpicture_Adv)
};
extern Deblock Deblock_tbl[12] = {
//I pic
(Deblocking_ProgressiveIpicture),
(NULL),
(NULL),
//P pic
(Deblocking_ProgressivePpicture),
(NULL),
(NULL),
//B pic
(Deblocking_ProgressiveIpicture),
(NULL),
(NULL),
//BI pic
(Deblocking_ProgressiveIpicture),
(NULL),
(NULL),
};
extern ProcessDiff ProcessDiff_Adv[2] = {
(VC1ProcessDiffIntra),
(VC1ProcessDiffInter)
};
extern MotionComp MotionComp_Adv[6] = {
(PredictBlock_P),
(PredictBlock_B),
(PredictBlock_InterlacePPicture),
(PredictBlock_InterlaceBPicture),
(PredictBlock_InterlaceFieldPPicture),
(PredictBlock_InterlaceFieldBPicture)
};
typedef void (*SaveMV)(VC1Context* pContext);
SaveMV SaveMV_tbl[3] = {
(save_MV),
(save_MV_InterlaceFrame),
(save_MV_InterlaceField)
};
typedef VC1Status (*B_MB_DECODE)(VC1Context* pContext);
static B_MB_DECODE B_MB_Dispatch_table[] = {
(MBLayer_ProgressiveBpicture_NONDIRECT_Prediction),
(MBLayer_ProgressiveBpicture_DIRECT_Prediction),
(MBLayer_ProgressiveBpicture_SKIP_NONDIRECT_Prediction),
(MBLayer_ProgressiveBpicture_SKIP_DIRECT_Prediction)
};
static B_MB_DECODE B_MB_Dispatch_table_AdvProgr[] = {
(MBLayer_ProgressiveBpicture_NONDIRECT_AdvPrediction),
(MBLayer_ProgressiveBpicture_DIRECT_AdvPrediction),
(MBLayer_ProgressiveBpicture_SKIP_NONDIRECT_AdvPrediction),
(MBLayer_ProgressiveBpicture_SKIP_DIRECT_AdvPrediction)
};
static B_MB_DECODE B_MB_Dispatch_table_InterlaceFrame[] = {
(MBLayer_InterlaceFrameBpicture_NONDIRECT_Prediction),
(MBLayer_InterlaceFrameBpicture_DIRECT_Prediction),
(MBLayer_InterlaceFrameBpicture_SKIP_NONDIRECT_Prediction),
(MBLayer_InterlaceFrameBpicture_SKIP_DIRECT_Prediction)
};
static B_MB_DECODE B_MB_Dispatch_table_InterlaceFields[] = {
(MBLayer_InterlaceFieldBpicture_NONDIRECT_Predicition),
(MBLayer_InterlaceFieldBpicture_DIRECT_Prediction)
};
typedef IppStatus (*VC1DeqIntra)(Ipp16s* pSrcDst, Ipp32s srcDstStep,
Ipp32s doubleQuant, IppiSize* pDstSizeNZ);
VC1DeqIntra VC1DeqIntra_tbl[2] = {
(VC1DeqIntra) (_own_ippiQuantInvIntraUniform_VC1_16s_C1IR),
(VC1DeqIntra) (_own_ippiQuantInvIntraNonuniform_VC1_16s_C1IR)
};
typedef IppStatus (*VC1DeqInter)(Ipp16s* pSrcDst, Ipp32s srcDstStep,
Ipp32s doubleQuant, IppiSize roiSize,
IppiSize* pDstSizeNZ);
VC1DeqInter VC1DeqInter_tbl[2] = {
(VC1DeqInter) (_own_ippiQuantInvInterUniform_VC1_16s_C1IR),
(VC1DeqInter) (_own_ippiQuantInvInterNonuniform_VC1_16s_C1IR),
};
//typedef void (*MBSmooth)(VC1Context* pContext, Ipp32s Height);
extern MBSmooth MBSmooth_tbl[16] = {
//simple
(Smoothing_I),
(Smoothing_P),
(NULL),
(Smoothing_I),
//main
(Smoothing_I),
(Smoothing_P),
(NULL),
(Smoothing_I),
//reserved
(NULL),
(NULL),
(NULL),
(NULL),
//Advanced
(Smoothing_I_Adv),
(Smoothing_P_Adv),
(NULL),
(Smoothing_I_Adv)
};
VC1Status VC1TaskProcessor::VC1MVCalculation(VC1Context* pContext, VC1Task* pTask)
{
B_MB_DECODE* currMVtable = B_MB_Dispatch_table;
if (pContext->m_seqLayerHeader->PROFILE == VC1_PROFILE_ADVANCED)
{
switch (pContext->m_picLayerHeader->FCM)
{
case VC1_Progressive:
currMVtable = B_MB_Dispatch_table_AdvProgr;
break;
case VC1_FrameInterlace:
currMVtable = B_MB_Dispatch_table_InterlaceFrame;
break;
case VC1_FieldInterlace:
currMVtable = B_MB_Dispatch_table_InterlaceFields;
break;
default:
break;
}
}
else
{
currMVtable = B_MB_Dispatch_table;
}
for (Ipp32s i=0; i < pTask->m_pSlice->MBRowsToDecode;i++)
{
for (Ipp32s j = 0; j <pContext->m_seqLayerHeader->widthMB; j++)
{
STATISTICS_START_TIME(m_timeStatistics->motion_vector_decoding_StartTime);
if (pContext->m_pCurrMB->mbType != VC1_MB_INTRA)
currMVtable[pContext->m_pCurrMB->SkipAndDirectFlag](pContext);
STATISTICS_END_TIME(m_timeStatistics->motion_vector_decoding_StartTime,
m_timeStatistics->motion_vector_decoding_EndTime,
m_timeStatistics->motion_vector_decoding_TotalTime);
++pContext->m_pCurrMB;
++pContext->m_pSingleMB->m_currMBXpos;
}
pContext->m_pSingleMB->m_currMBXpos = 0;
++pContext->m_pSingleMB->m_currMBYpos;
}
return VC1_OK;
}
VC1Status VC1TaskProcessor::VC1Decoding (VC1Context* pContext, VC1Task* pTask)
{
volatile MBLayerDecode* pCurrMBTable = MBLayerDecode_tbl_Adv;
if (pContext->m_seqLayerHeader->PROFILE != VC1_PROFILE_ADVANCED)
pCurrMBTable = MBLayerDecode_tbl;
if (pTask->m_pSlice->is_NewInSlice)
{
pContext->m_pSingleMB->slice_currMBYpos = 0;
pContext->m_pSingleMB->EscInfo.levelSize = 0;
pContext->m_pSingleMB->EscInfo.runSize = 0;
if (pContext->m_picLayerHeader->m_PQuant_mode>0
|| pContext->m_picLayerHeader->PQUANT<=7)
{
pContext->m_pSingleMB->EscInfo.bEscapeMode3Tbl = VC1_ESCAPEMODE3_Conservative;
}
else
{
pContext->m_pSingleMB->EscInfo.bEscapeMode3Tbl = VC1_ESCAPEMODE3_Efficient;
}
}
for (Ipp32s i=0; i < pTask->m_pSlice->MBRowsToDecode;i++)
{
for (Ipp32s j = 0; j < pContext->m_pSingleMB->widthMB; j++)
{
try // check decoding on MB level
{
#ifdef UMC_STREAM_ANALYZER
//reset all variables for a new MB
memset(pContext->m_pCurrMB->pMbAnalyzInfo,0,sizeof(ExtraMBAnalyzer));
IppiBitstream Bitsream;
Bitsream.pBitstream = pContext->m_bitstream.pBitstream;
Bitsream.bitOffset = pContext->m_bitstream.bitOffset;
#endif
pCurrMBTable[pContext->m_picLayerHeader->PTYPE*3 + pContext->m_picLayerHeader->FCM](pContext);
#ifdef UMC_STREAM_ANALYZER
pContext->m_pCurrMB->pMbAnalyzInfo->dwNumBitsMB += CalculateUsedBits(Bitsream,pContext->m_bitstream);
#endif
}
catch (vc1_exception ex)
{
exception_type e_type = ex.get_exception_type();
if (e_type != vld)
throw ex;
else
{
robust_profile profile = vc1_except_profiler::GetEnvDescript().m_Profile;
switch (profile)
{
case fast_err_detect:
// we should signalize about error only
ex.set_exception_type(internal_pipeline_error);
throw ex;
break;
case max_decoding:
//continue decoding cycle
break;
case smart_recon:
if (vc1_except_profiler::GetEnvDescript().m_SmartLevel != FrameLevel)
{
ProcessSmartException(vc1_except_profiler::GetEnvDescript().m_SmartLevel,
pContext,
pTask,
pContext->m_pCurrMB);
// we already decode it
//if (mbGroupLevel == vc1_except_profiler::GetEnvDescript().m_SmartLevel)
//{
// i = pTask->m_pSlice->MBRowsToDecode;
// j = pContext->m_pSingleMB->widthMB;
//}
}
else
throw ex;
break;
default:
break;
}
}
}
// unexpected problems. The decoder works incorrect
catch(...)
{
}
++pContext->m_pSingleMB->m_currMBXpos;
pContext->m_pBlock += 8*8*6;
++pContext->m_pCurrMB;
++pContext->CurrDC;
}
pContext->m_pSingleMB->m_currMBXpos = 0;
++pContext->m_pSingleMB->m_currMBYpos;
++pContext->m_pSingleMB->slice_currMBYpos;
}
return VC1_OK;
}
VC1Status VC1TaskProcessor::VC1ProcessDiff (VC1Context* pContext, VC1Task* pTask)
{
IppiSize roiSize;
Ipp32u offset_table[] = {0,8,128,136};
Ipp32u plane_offset = 0;
Ipp32u IntraFlag;
if (m_pStore->IsNeedSimlifyReconstruct(pTask->m_pSlice->m_picLayerHeader->PTYPE))
AccelerReconstruct();
for (Ipp32s i=0; i < pTask->m_pSlice->MBRowsToDecode;i++)
{
for (Ipp32s j = 0; j < pContext->m_pSingleMB->widthMB; j++)
{
IntraFlag = pContext->m_pCurrMB->IntraFlag;
for (Ipp32s blk_num = 0; blk_num<6 ;blk_num++)
{
pReconstructTbl[IntraFlag & 1](pContext,blk_num);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -