📄 umc_vc1_dec_seq.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, Sequence layer
//
*/
#include "umc_defs.h"
#if defined (UMC_ENABLE_VC1_VIDEO_DECODER)
#include "ipps.h"
#include "string.h"
#include "ippcore.h"
#include "umc_vc1_dec_seq.h"
#include "umc_vc1_common_dc_tbl.h"
#include "umc_vc1_common_cbpcy_tbl.h"
#include "umc_vc1_dec_run_level_tbl.h"
#include "umc_vc1_common_tables.h"
#include "umc_vc1_common_mvdiff_tbl.h"
#include "umc_vc1_common_ttmb_tbl.h"
#include "umc_vc1_common_interlace_mb_mode_tables.h"
#include "umc_vc1_common_interlace_mv_tables.h"
#include "umc_vc1_common_interlaced_cbpcy_tables.h"
#include "umc_vc1_common_mv_block_pattern_tables.h"
#include "umc_vc1_common_tables_adv.h"
#include "umc_vc1_common_defs.h"
#include "umc_vc1_dec_task.h"
#include "umc_vc1_dec_time_statistics.h"
#include "umc_vc1_common.h"
#include "umc_structures.h"
#include "assert.h"
#ifdef BSWAP
#undef BSWAP
#define BSWAP(x) (Ipp32u)(((x) << 24) + (((x)&0xff00) << 8) + (((x) >> 8)&0xff00) + ((x) >> 24))
#endif
using namespace UMC;
using namespace UMC::VC1Common;
static void reset_index(VC1Context* pContext)
{
pContext->m_frmBuff.m_iPrevIndex = -1;
pContext->m_frmBuff.m_iNextIndex = -1;
}
//3.1 Sequence-level Syntax and Semantics, figure 7
VC1Status SequenceLayer(VC1Context* pContext)
{
Ipp32u reserved;
Ipp32u i=0;
Ipp32u tempValue;
pContext->m_seqInit = 0;
VC1_GET_BITS(2, pContext->m_seqLayerHeader->PROFILE);
if(pContext->m_seqLayerHeader->PROFILE == VC1_PROFILE_ADVANCED)
{
VC1_GET_BITS(3, pContext->m_seqLayerHeader->LEVEL);
VC1_GET_BITS(2,tempValue); //CHROMAFORMAT
}
else
{
VC1_GET_BITS(2, pContext->m_seqLayerHeader->LEVEL);
}
VC1_GET_BITS(3, pContext->m_seqLayerHeader->FRMRTQ_POSTPROC);
VC1_GET_BITS(5, pContext->m_seqLayerHeader->BITRTQ_POSTPROC);
if(pContext->m_seqLayerHeader->PROFILE == VC1_PROFILE_ADVANCED)
{
VC1_GET_BITS(1, pContext->m_seqLayerHeader->POSTPROCFLAG);
VC1_GET_BITS(12, pContext->m_seqLayerHeader->MAX_CODED_WIDTH);
VC1_GET_BITS(12, pContext->m_seqLayerHeader->MAX_CODED_HEIGHT);
VC1_GET_BITS(1, pContext->m_seqLayerHeader->PULLDOWN);
VC1_GET_BITS(1, pContext->m_seqLayerHeader->INTERLACE);
VC1_GET_BITS(1, pContext->m_seqLayerHeader->TFCNTRFLAG);
}
else
{
VC1_GET_BITS(1, pContext->m_seqLayerHeader->LOOPFILTER);
VC1_GET_BITS(1, reserved);
VC1_GET_BITS(1, pContext->m_seqLayerHeader->MULTIRES);
VC1_GET_BITS(1, reserved);
VC1_GET_BITS(1, pContext->m_seqLayerHeader->FASTUVMC);
VC1_GET_BITS(1, pContext->m_seqLayerHeader->EXTENDED_MV);
VC1_GET_BITS(2, pContext->m_seqLayerHeader->DQUANT);
VC1_GET_BITS(1, pContext->m_seqLayerHeader->VSTRANSFORM);
VC1_GET_BITS(1, reserved);
VC1_GET_BITS(1, pContext->m_seqLayerHeader->OVERLAP);
VC1_GET_BITS(1, pContext->m_seqLayerHeader->SYNCMARKER);
VC1_GET_BITS(1, pContext->m_seqLayerHeader->RANGERED);
VC1_GET_BITS(3, pContext->m_seqLayerHeader->MAXBFRAMES);
VC1_GET_BITS(2, pContext->m_seqLayerHeader->QUANTIZER);
}
VC1_GET_BITS(1, pContext->m_seqLayerHeader->FINTERPFLAG);
if(pContext->m_seqLayerHeader->PROFILE == VC1_PROFILE_ADVANCED)
{
VC1_GET_BITS(2, reserved);
VC1_GET_BITS(1, tempValue);//DISPLAY_EXT
if(tempValue)//DISPLAY_EXT
{
VC1_GET_BITS(14,tempValue); //DISP_HORIZ_SIZE
VC1_GET_BITS(14,tempValue); //DISP_VERT_SIZE
VC1_GET_BITS(1,tempValue); //ASPECT_RATIO_FLAG
if(tempValue)
{
VC1_GET_BITS(4,tempValue); //ASPECT_RATIO
if(tempValue==15)
{
VC1_GET_BITS(8,tempValue); //ASPECT_HORIZ_SIZE
VC1_GET_BITS(8,tempValue); //ASPECT_VERT_SIZE
}
}
VC1_GET_BITS(1,tempValue); //FRAMERATE_FLAG
if(tempValue) //FRAMERATE_FLAG
{
VC1_GET_BITS(1,tempValue); //FRAMERATEIND
if(!tempValue) //FRAMERATEIND
{
VC1_GET_BITS(8,tempValue); //FRAMERATENR
VC1_GET_BITS(4,tempValue); //FRAMERATEDR
}
else
{
VC1_GET_BITS(16,tempValue); //FRAMERATEEXP
}
}
VC1_GET_BITS(1,tempValue); //COLOR_FORMAT_FLAG
if(tempValue) //COLOR_FORMAT_FLAG
{
VC1_GET_BITS(8,tempValue); //COLOR_PRIM
VC1_GET_BITS(8,tempValue); //TRANSFER_CHAR
VC1_GET_BITS(8,tempValue); //MATRIX_COEF
}
}
VC1_GET_BITS(1, pContext->m_seqLayerHeader->HRD_PARAM_FLAG);
if(pContext->m_seqLayerHeader->HRD_PARAM_FLAG)
{
VC1_GET_BITS(5,pContext->m_seqLayerHeader->HRD_NUM_LEAKY_BUCKETS);
VC1_GET_BITS(4,tempValue);//BIT_RATE_EXPONENT
VC1_GET_BITS(4,tempValue);//BUFFER_SIZE_EXPONENT
for(i=0; i<pContext->m_seqLayerHeader->HRD_NUM_LEAKY_BUCKETS; i++)
{
VC1_GET_BITS(16,tempValue);//HRD_RATE[i]
VC1_GET_BITS(16,tempValue);//HRD_BUFFER[i]
}
}
}
pContext->m_seqInit = 1;
return VC1_OK;
}
VC1Status EntryPointLayer(VC1Context* pContext)
{
Ipp32u i=0;
Ipp32u tempValue;
VC1_GET_BITS(1, pContext->m_seqLayerHeader->BROKEN_LINK);
VC1_GET_BITS(1, pContext->m_seqLayerHeader->CLOSED_ENTRY);
VC1_GET_BITS(1, pContext->m_seqLayerHeader->PANSCAN_FLAG);
VC1_GET_BITS(1, pContext->m_seqLayerHeader->REFDIST_FLAG);
VC1_GET_BITS(1, pContext->m_seqLayerHeader->LOOPFILTER);
VC1_GET_BITS(1, pContext->m_seqLayerHeader->FASTUVMC);
VC1_GET_BITS(1, pContext->m_seqLayerHeader->EXTENDED_MV);
VC1_GET_BITS(2, pContext->m_seqLayerHeader->DQUANT);
VC1_GET_BITS(1, pContext->m_seqLayerHeader->VSTRANSFORM);
VC1_GET_BITS(1, pContext->m_seqLayerHeader->OVERLAP);
VC1_GET_BITS(2, pContext->m_seqLayerHeader->QUANTIZER);
if (pContext->m_seqLayerHeader->CLOSED_ENTRY)
pContext->m_seqLayerHeader->BROKEN_LINK = 0;
if (pContext->m_seqLayerHeader->BROKEN_LINK && !pContext->m_seqLayerHeader->CLOSED_ENTRY)
reset_index(pContext);
if(pContext->m_seqLayerHeader->HRD_PARAM_FLAG == 1)
{
for(i=0; i<pContext->m_seqLayerHeader->HRD_NUM_LEAKY_BUCKETS;i++)
{
VC1_GET_BITS(8, tempValue); //m_hrd_buffer_fullness.HRD_FULLNESS[i]
}
}
VC1_GET_BITS(1, tempValue); //CODED_SIZE_FLAG
if (tempValue == 1)
{
VC1_GET_BITS(12, pContext->m_seqLayerHeader->CODED_WIDTH);
VC1_GET_BITS(12, pContext->m_seqLayerHeader->CODED_HEIGHT);
}
if (pContext->m_seqLayerHeader->EXTENDED_MV == 1)
{
VC1_GET_BITS(1, pContext->m_seqLayerHeader->EXTENDED_DMV);
}
VC1_GET_BITS(1, pContext->m_seqLayerHeader->RANGE_MAPY_FLAG); //RANGE_MAPY_FLAG
if (pContext->m_seqLayerHeader->RANGE_MAPY_FLAG == 1)
{
VC1_GET_BITS(3,pContext->m_seqLayerHeader->RANGE_MAPY);
}
else
pContext->m_seqLayerHeader->RANGE_MAPY = -1;
VC1_GET_BITS(1, pContext->m_seqLayerHeader->RANGE_MAPUV_FLAG); //RANGE_MAPUV_FLAG
if (pContext->m_seqLayerHeader->RANGE_MAPUV_FLAG == 1)
{
VC1_GET_BITS(3,pContext->m_seqLayerHeader->RANGE_MAPUV);
}
else
pContext->m_seqLayerHeader->RANGE_MAPUV = -1;
return VC1_OK;
}
Ipp32s InitCommonTables(VC1Context* pContext)
{
//MOTION DC DIFF
if (ippStsNoErr != ippiHuffmanTableInitAlloc_32s(
VC1_LowMotionLumaDCDiff, &pContext->m_vlcTbl->m_pLowMotionLumaDCDiff))
return 0;
if (ippStsNoErr != ippiHuffmanTableInitAlloc_32s(
VC1_HighMotionLumaDCDiff, &pContext->m_vlcTbl->m_pHighMotionLumaDCDiff))
return 0;
if (ippStsNoErr != ippiHuffmanTableInitAlloc_32s(
VC1_LowMotionChromaDCDiff, &pContext->m_vlcTbl->m_pLowMotionChromaDCDiff))
return 0;
if (ippStsNoErr != ippiHuffmanTableInitAlloc_32s(
VC1_HighMotionChromaDCDiff, &pContext->m_vlcTbl->m_pHighMotionChromaDCDiff))
return 0;
//CBPCY
if (ippStsNoErr != ippiHuffmanTableInitAlloc_32s(
VC1_CBPCY_Ipic, &pContext->m_vlcTbl->m_pCBPCY_Ipic))
return 0;
if (ippStsNoErr != ippiHuffmanTableInitAlloc_32s(
VC1_CBPCY_PBpic_tbl0,
&pContext->m_vlcTbl->CBPCY_PB_TABLES[0]))
return 0;
if (ippStsNoErr != ippiHuffmanTableInitAlloc_32s(
VC1_CBPCY_PBpic_tbl1,
&pContext->m_vlcTbl->CBPCY_PB_TABLES[1]))
return 0;
if (ippStsNoErr != ippiHuffmanTableInitAlloc_32s(
VC1_CBPCY_PBpic_tbl2,
&pContext->m_vlcTbl->CBPCY_PB_TABLES[2]))
return 0;
if (ippStsNoErr != ippiHuffmanTableInitAlloc_32s(
VC1_CBPCY_PBpic_tbl3,
&pContext->m_vlcTbl->CBPCY_PB_TABLES[3]))
return 0;
//DEDCODE INDEX TABLES
if (ippStsNoErr != ippiHuffmanTableInitAlloc_32s(
VC1_LowMotionIntraAC,
&LowMotionIntraACDecodeSet.pRLTable))
return 0;
if (ippStsNoErr != ippiHuffmanTableInitAlloc_32s(
VC1_HighMotionIntraAC,
&HighMotionIntraACDecodeSet.pRLTable))
return 0;
if (ippStsNoErr != ippiHuffmanTableInitAlloc_32s(
VC1_LowMotionInterAC,
&LowMotionInterACDecodeSet.pRLTable))
return 0;
if (ippStsNoErr != ippiHuffmanTableInitAlloc_32s(
VC1_HighMotionInterAC,
&HighMotionInterACDecodeSet.pRLTable))
return 0;
if (ippStsNoErr != ippiHuffmanTableInitAlloc_32s(
VC1_MidRateIntraAC,
&MidRateIntraACDecodeSet.pRLTable))
return 0;
if (ippStsNoErr != ippiHuffmanTableInitAlloc_32s(
VC1_MidRateInterAC,
&MidRateInterACDecodeSet.pRLTable))
return 0;
if (ippStsNoErr != ippiHuffmanTableInitAlloc_32s(
VC1_HighRateIntraAC,
&HighRateIntraACDecodeSet.pRLTable))
return 0;
if (ippStsNoErr != ippiHuffmanTableInitAlloc_32s(
VC1_HighRateInterAC,
&HighRateInterACDecodeSet.pRLTable))
return 0;
//BITPLANE
if (ippStsNoErr != ippiHuffmanTableInitAlloc_32s(
VC1_Bitplane_IMODE_tbl,
&pContext->m_vlcTbl->m_Bitplane_IMODE))
return 0;
if (ippStsNoErr != ippiHuffmanTableInitAlloc_32s(
VC1_BitplaneTaledbitsTbl,
&pContext->m_vlcTbl->m_BitplaneTaledbits))
return 0;
//BFRACTION
if (ippStsNoErr != ippiHuffmanRunLevelTableInitAlloc_32s(
VC1_BFraction_tbl,
&pContext->m_vlcTbl->BFRACTION))
return 0;
//MV DIFF PB TABLES
if (ippStsNoErr != ippiHuffmanTableInitAlloc_32s(
VC1_Progressive_MV_Diff_tbl0,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -