📄 umc_vc1_dec_blk_com.cpp
字号:
return sts;
}
IppStatus DecodeBlockInter4x4_VC1(IppiBitstream* pBitstream, Ipp16s* pDst,
const Ipp8u* pZigzagTbl, const IppiACDecodeSet_VC1 * pDecodeSet,
IppiEscInfo_VC1* pEscInfo, Ipp32s subBlockPattern)
{
Ipp32s last_flag = 0;
Ipp16s run = 0, level = 0;
Ipp32s curr_position = 0;
IppStatus sts = ippStsNoErr;
if((!pBitstream)||(!pDst) || (!pDecodeSet) || (!pZigzagTbl) || (!pEscInfo) || (!pBitstream->pBitstream))
//return ippStsNullPtrErr;
throw vc1_exception(internal_pipeline_error); // Global problem, no need to decode more
if((pBitstream->bitOffset < 0) || (pBitstream->bitOffset>31))
//return ippStsBitOffsetErr;
throw vc1_exception(internal_pipeline_error); // Global problem, no need to decode more
if(subBlockPattern & VC1_SBP_0)
do
{
last_flag = DecodeSymbol(pBitstream, &run, &level, pDecodeSet, pEscInfo);
#ifdef VC1_DEBUG_ON
VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_COEFFS,
VM_STRING("AC Run=%2d Level=%c%3d Last=%d\n"),
run,
(level < 0) ? '-' : '+',
(level < 0) ? -level : level,
last_flag);
#endif
if(curr_position > 64)
{
throw vc1_exception(vld);
}
curr_position = curr_position + run;
pDst[pZigzagTbl[curr_position]] = pDst[pZigzagTbl[curr_position]] + level;
curr_position++;
} while (last_flag == 0);
curr_position = 0;
if(subBlockPattern & VC1_SBP_1)
do
{
last_flag = DecodeSymbol(pBitstream, &run, &level, pDecodeSet, pEscInfo);
#ifdef VC1_DEBUG_ON
VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_COEFFS,
VM_STRING("AC Run=%2d Level=%c%3d Last=%d\n"),
run,
(level < 0) ? '-' : '+',
(level < 0) ? -level : level,
last_flag);
#endif
if(curr_position > 64)
throw vc1_exception(vld);
curr_position = curr_position + run;
pDst[pZigzagTbl[curr_position + 16]] = pDst[pZigzagTbl[curr_position + 16]] + level;
curr_position++;
} while (last_flag == 0);
curr_position = 0;
if(subBlockPattern & VC1_SBP_2)
do
{
last_flag = DecodeSymbol(pBitstream, &run, &level, pDecodeSet, pEscInfo);
#ifdef VC1_DEBUG_ON
VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_COEFFS,
VM_STRING("AC Run=%2d Level=%c%3d Last=%d\n"),
run,
(level < 0) ? '-' : '+',
(level < 0) ? -level : level,
last_flag);
#endif
if(curr_position > 64)
throw vc1_exception(vld);
curr_position = curr_position + run;
pDst[pZigzagTbl[curr_position + 32]] = pDst[pZigzagTbl[curr_position + 32]] + level;
curr_position++;
} while (last_flag == 0);
curr_position = 0;
if(subBlockPattern & VC1_SBP_3)
do
{
last_flag = DecodeSymbol(pBitstream, &run, &level, pDecodeSet, pEscInfo);
#ifdef VC1_DEBUG_ON
VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_COEFFS,
VM_STRING("AC Run=%2d Level=%c%3d Last=%d\n"),
run,
(level < 0) ? '-' : '+',
(level < 0) ? -level : level,
last_flag);
#endif
if(curr_position > 64)
throw vc1_exception(vld);
curr_position = curr_position + run;
pDst[pZigzagTbl[curr_position + 48]] = pDst[pZigzagTbl[curr_position + 48]] + level;
curr_position++;
} while (last_flag == 0);
return sts;
}
Ipp8u GetSubBlockPattern_8x4_4x8(VC1Context* pContext,Ipp32s blk_num)
{
Ipp32s Value;
//Table 67: 8x4 and 4x8 Transform sub-block pattern code-table for Progressive pictures
// 8x4 Sub-block pattern 4x8 Sub-block pattern
//SUBBLKPAT VLC Top Bottom Left Right
//10 X X
//0 X X X X
//11 X X
VC1_GET_BITS(1, Value);
if(0 != Value)
{
VC1_GET_BITS(1, Value);
Value++;
if(1 == Value)//for codeword "10b"
Value = VC1_SBP_1;
else //for codeword "11b"
Value = VC1_SBP_0;
}
else
{
Value = VC1_SBP_0|VC1_SBP_1;
}
#ifdef VC1_DEBUG_ON
VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_TT,
VM_STRING("Sub-block pattern 4x8|8x4: %d\n"), Value);
#endif
pContext->m_pSingleMB->m_pSingleBlock[blk_num].numCoef = (Ipp8u)Value;
return ((Ipp8u)Value);
}
Ipp8u GetSubBlockPattern_4x4(VC1Context* pContext,Ipp32s blk_num)
{
IppStatus ret;
Ipp32s Value;
ret = ippiDecodeHuffmanOne_1u32s( &pContext->m_bitstream.pBitstream,
&pContext->m_bitstream.bitOffset,
&Value,
pContext->m_picLayerHeader->m_pCurrSBPtbl);
//VM_ASSERT(ret == ippStsNoErr);
if (ret != ippStsNoErr)
throw vc1_exception(vld);
pContext->m_pSingleMB->m_pSingleBlock[blk_num].numCoef = (Ipp8u)Value;
#ifdef VC1_DEBUG_ON
VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_TT,
VM_STRING("Sub-block pattern 4x4: %d\n"),
pContext->m_pSingleMB->m_pSingleBlock[blk_num].numCoef);
#endif
return ((Ipp8u)Value);
}
Ipp8u GetTTBLK(VC1Context* pContext, Ipp32s blk_num)
{
IppStatus ret;
Ipp32s Value;
VC1MB *pMB = pContext->m_pCurrMB;
VC1Block *pBlock = &pMB->m_pBlocks[blk_num];
Ipp8u numCoef = 0;
ret = ippiDecodeHuffmanOne_1u32s( &pContext->m_bitstream.pBitstream,
&pContext->m_bitstream.bitOffset,
&Value,
pContext->m_picLayerHeader->m_pCurrTTBLKtbl);
//VM_ASSERT(ret == ippStsNoErr);
if (ret != ippStsNoErr)
throw vc1_exception(vld);
switch(Value)
{
case VC1_SBP_8X8_BLK:
numCoef = VC1_SBP_0;
pBlock->blkType = VC1_BLK_INTER8X8;
break;
case VC1_SBP_8X4_BOTTOM_BLK:
numCoef = VC1_SBP_1;
pBlock->blkType = VC1_BLK_INTER8X4;
break;
case VC1_SBP_8X4_TOP_BLK:
numCoef = VC1_SBP_0;
pBlock->blkType = VC1_BLK_INTER8X4;
break;
case VC1_SBP_8X4_BOTH_BLK:
numCoef = VC1_SBP_0|VC1_SBP_1;
pBlock->blkType = VC1_BLK_INTER8X4;
break;
case VC1_SBP_4X8_RIGHT_BLK:
numCoef = VC1_SBP_1;
pBlock->blkType = VC1_BLK_INTER4X8;
break;
case VC1_SBP_4X8_LEFT_BLK:
numCoef = VC1_SBP_0;
pBlock->blkType = VC1_BLK_INTER4X8;
break;
case VC1_SBP_4X8_BOTH_BLK:
numCoef = VC1_SBP_0|VC1_SBP_1;
pBlock->blkType = VC1_BLK_INTER4X8;
break;
case VC1_SBP_4X4_BLK:
numCoef = VC1_SBP_0|VC1_SBP_1|VC1_SBP_2|VC1_SBP_3;
pBlock->blkType = VC1_BLK_INTER4X4;
break;
default:
VM_ASSERT(0);
}
pContext->m_pSingleMB->m_pSingleBlock[blk_num].numCoef = numCoef;
return numCoef;
}
Ipp32u GetDCStepSize(Ipp32s MQUANT)
{
Ipp32u DCStepSize;
if(MQUANT < 4)
DCStepSize = 1 << MQUANT;
else
DCStepSize = MQUANT/2 + 6;
return DCStepSize;
}
#ifdef _OWN_FUNCTION
IppStatus _own_ippiQuantInvIntraUniform_VC1_16s_C1IR(Ipp16s* pSrcDst, Ipp32s srcDstStep,
Ipp32s doubleQuant, IppiSize* pDstSizeNZ)
{
Ipp32s i = 1;
Ipp32s j = 0;
Ipp32s X[8] = {0};
Ipp32s Y[8] = {0};
Ipp16s S;
Ipp16s* pSrc = pSrcDst;
for(j = 0; j < 8; j++)
{
for(i; i < 8; i++)
{
pSrc[i] = (Ipp16s)(pSrc[i]*doubleQuant);
S = !pSrc[i] ;
X[i] = X[i] + S;
Y[j] = Y[j] + S;
}
i = 0;
pSrc = (Ipp16s*)((Ipp8u*)pSrc + srcDstStep);
}
for(i=7; i>=0 && X[i]==8; i--);
pDstSizeNZ->width = i+1;
for(j=7; j>=0 && Y[j]==8; j--);
pDstSizeNZ->height = j+1;
return ippStsNoErr;
}
IppStatus _own_ippiQuantInvIntraNonuniform_VC1_16s_C1IR(Ipp16s* pSrcDst, Ipp32s srcDstStep,
Ipp32s doubleQuant, IppiSize* pDstSizeNZ)
{
Ipp32s i = 1;
Ipp32s j = 0;
Ipp16s* pSrc = pSrcDst;
Ipp32s X[8] = {0};
Ipp32s Y[8] = {0};
Ipp16s S;
for(j = 0; j < 8; j++)
{
for(i; i < 8; i++)
{
pSrc[i] = (Ipp16s)(pSrc[i]*doubleQuant) + (Ipp16s)(VC1_SIGN(pSrc[i])*(doubleQuant>>1));
S = !pSrc[i] ;
X[i] = X[i] + S;
Y[j] = Y[j] + S;
}
i = 0;
pSrc = (Ipp16s*)((Ipp8u*)pSrc + srcDstStep);
}
for(i=7; i>=0 && X[i]==8; i--);
pDstSizeNZ->width = i+1;
for(j=7; j>=0 && Y[j]==8; j--);
pDstSizeNZ->height = j+1;
return ippStsNoErr;
}
IppStatus _own_ippiQuantInvInterUniform_VC1_16s_C1IR(Ipp16s* pSrcDst, Ipp32s srcDstStep,
Ipp32s doubleQuant, IppiSize roiSize,
IppiSize* pDstSizeNZ)
{
Ipp32s i = 0;
Ipp32s j = 0;
Ipp32s X[8] = {0};
Ipp32s Y[8] = {0};
Ipp16s S;
Ipp16s* pSrc = pSrcDst;
for(j = 0; j < roiSize.height; j++)
{
for(i = 0; i < roiSize.width; i++)
{
pSrc[i] = (Ipp16s)(pSrc[i]*doubleQuant);
S = !pSrc[i] ;
X[i] = X[i] + S;
Y[j] = Y[j] + S;
}
pSrc = (Ipp16s*)((Ipp8u*)pSrc + srcDstStep);
}
for(i=7; i>=0 && X[i]==8; i--);
pDstSizeNZ->width = i+1;
for(j=7; j>=0 && Y[j]==8; j--);
pDstSizeNZ->height = j+1;
return ippStsNoErr;
}
IppStatus _own_ippiQuantInvInterNonuniform_VC1_16s_C1IR(Ipp16s* pSrcDst, Ipp32s srcDstStep,
Ipp32s doubleQuant, IppiSize roiSize,
IppiSize* pDstSizeNZ)
{
Ipp32s i = 0;
Ipp32s j = 0;
Ipp16s* pSrc = pSrcDst;
Ipp32s X[8] = {0};
Ipp32s Y[8] = {0};
Ipp16s S;
for(j = 0; j < roiSize.height; j++)
{
for(i; i < roiSize.width; i++)
{
pSrc[i] = (Ipp16s)(pSrc[i]*doubleQuant) + (Ipp16s)(VC1_SIGN(pSrc[i])*(doubleQuant>>1));
S = !pSrc[i] ;
X[i] = X[i] + S;
Y[j] = Y[j] + S;
}
i = 0;
pSrc = (Ipp16s*)((Ipp8u*)pSrc + srcDstStep);
}
for(i=7; i>=0 && X[i]==8; i--);
pDstSizeNZ->width = i+1;
for(j=7; j>=0 && Y[j]==8; j--);
pDstSizeNZ->height = j+1;
return ippStsNoErr;
}
#endif
#endif //UMC_ENABLE_VC1_VIDEO_DECODER
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -