📄 umc_vc1_dec_bitplane.cpp
字号:
for(j = 0; j < height; j++)
{
Ipp32s Value = 0;
VC1_GET_BITS(1, Value);
pBitplane->m_databits[i + width * j] = (Ipp8u)Value;
}
}
else
{
for(j = 0; j < height; j++)
{
pBitplane->m_databits[i + width * j] = 0;
}
}
}
//ResidualY 0 or 1
for(j = 0; j < ResidualY; j++)
{
Ipp32s RowSkip;
VC1_GET_BITS(1, RowSkip);
if(1 == RowSkip)
{
for(i = ResidualX; i < width; i++)
{
Ipp32s Value = 0;
VC1_GET_BITS(1, Value);
pBitplane->m_databits[i] = (Ipp8u)Value;
}
}
else
{
for(i = ResidualX; i < width; i++)
{
pBitplane->m_databits[i] = 0;
}
}
}
}
void DecodeBitplane(VC1Context* pContext, VC1Bitplane* pBitplane, Ipp32s width, Ipp32s height,Ipp32s offset)
{
Ipp32s tmp;
Ipp32s i, j;
static Ipp32s round_count = -1;
IppStatus ret;
Ipp32s tmp_invert = 0;
Ipp32s tmp_databits = 0;
memset(pBitplane, 0, sizeof(VC1Bitplane));
if (offset == 0)
++round_count;
if (VC1_MAX_BITPANE_CHUNCKS == round_count)
round_count = 0;
pBitplane->m_databits = pContext->m_pBitplane.m_databits +
pContext->m_seqLayerHeader->heightMB*
pContext->m_seqLayerHeader->widthMB*round_count + offset;
//4.10.1
//The INVERT field shown in the syntax diagram of Figure 30 is a one bit
//code, which if set indicates that the bitplane has more set bits than
//zero bits. Depending on INVERT and the mode, the decoder must invert
//the interpreted bitplane to recreate the original.
VC1_GET_BITS(1, tmp_invert);
pBitplane->m_invert = (Ipp8u)tmp_invert;
//VC-1 Table 68: IMODE Codetable
//CODING MODE CODEWORD
//Raw 0000
//Norm-2 10
//Diff-2 001
//Norm-6 11
//Diff-6 0001
//Rowskip 010
//Colskip 011
ret = ippiDecodeHuffmanOne_1u32s (
&pContext->m_bitstream.pBitstream,
&pContext->m_bitstream.bitOffset,
&pBitplane->m_imode,
pContext->m_vlcTbl->m_Bitplane_IMODE
);
VM_ASSERT(ret == ippStsNoErr);
#ifdef VC1_DEBUG_ON
VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_BITBLANES,
VM_STRING("Bitplane bits: "));
#endif
//The DATABITS field shown in the syntax diagram of Figure 28 is an entropy
//coded stream of symbols that is based on the coding mode. The seven coding
//modes are described in the following sections.
switch(pBitplane->m_imode)
{
case VC1_BITPLANE_RAW_MODE:
#ifdef VC1_DEBUG_ON
VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_BITBLANES,
VM_STRING("Raw mode\n"));
#endif
//nothing to do
break;
case VC1_BITPLANE_NORM2_MODE:
#ifdef VC1_DEBUG_ON
VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_BITBLANES,
VM_STRING("Norm2 mode\n"));
#endif
//4.10.3.3 Normal-2 mode
//If rowMB x colMB is odd, the first symbol is encoded raw. Subsequent
//symbols are encoded pairwise, in natural scan order. The binary VLC
//table in Table 57 is used to encode symbol pairs.
//Table 57: Norm-2/Diff-2 Code Table
//SYMBOL 2N SYMBOL 2N + 1 CODEWORD
// 0 0 0
// 1 0 100
// 0 1 101
// 1 1 11
Norm2ModeDecode(pContext, pBitplane, width, height);
if(pBitplane->m_invert)
{
InverseBitplane(pBitplane, width*height);
}
break;
case VC1_BITPLANE_DIFF2_MODE:
#ifdef VC1_DEBUG_ON
VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_BITBLANES,
VM_STRING("Diff2 mode\n"));
#endif
//decode differentional bits
Norm2ModeDecode(pContext, pBitplane, width, height);
//restore original
InverseDiff(pBitplane, width, height);
break;
case VC1_BITPLANE_NORM6_MODE:
#ifdef VC1_DEBUG_ON
VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_BITBLANES,
VM_STRING("Norm6 mode\n"));
#endif
//In the Norm-6 and Diff-6 modes, the bitplane is encoded in groups of
//six pixels. These pixels are grouped into either 2x3 or 3x2 tiles.
//The bitplane is tiled maximally using a set of rules, and the remaining
//pixels are encoded using a variant of row-skip and column-skip modes.
//3x2 "vertical" tiles are used if and only if rowMB is a multiple of 3
//and colMB is not. Else, 2x3 "horizontal" tiles are used
Norm6ModeDecode(pContext, pBitplane, width, height);
if(pBitplane->m_invert)
{
InverseBitplane(pBitplane, width*height);
}
break;
case VC1_BITPLANE_DIFF6_MODE:
#ifdef VC1_DEBUG_ON
VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_BITBLANES,
VM_STRING("Diff6 mode\n"));
#endif
//decode differentional bits
Norm6ModeDecode(pContext, pBitplane, width, height);
//restore original
InverseDiff(pBitplane, width, height);
break;
case VC1_BITPLANE_ROWSKIP_MODE:
#ifdef VC1_DEBUG_ON
VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_BITBLANES,
VM_STRING("Rowskip mode\n"));
#endif
//In the row-skip coding mode, all-zero rows are skipped with one bit overhead.
//The syntax is as shown in Figure 79.
//If the entire row is zero, a zero bit is sent as the ROWSKIP symbol,
//and ROWBITS is skipped. If there is a set bit in the row, ROWSKIP
//is set to 1, and the entire row is sent raw (ROWBITS). Rows are
//scanned from the top to the bottom of the frame.
for(i = 0; i < height; i++)
{
VC1_GET_BITS(1, tmp);
if(tmp == 0)
{
for(j = 0; j < width; j++)
pBitplane->m_databits[width*i + j] = 0;
}
else
{
for(j = 0; j < width; j++)
{
VC1_GET_BITS(1, tmp_databits);
pBitplane->m_databits[width*i + j] = (Ipp8u)tmp_databits;
}
}
}
if(pBitplane->m_invert)
{
InverseBitplane(pBitplane, width*height);
}
break;
case VC1_BITPLANE_COLSKIP_MODE:
#ifdef VC1_DEBUG_ON
VM_Debug::GetInstance(VC1DebugRoutine).vm_debug_frame(-1,VC1_BITBLANES,
VM_STRING("Collskip mode\n"));
#endif
//Column-skip is the transpose of row-skip. Columns are scanned from the
//left to the right of the frame.
for(i = 0; i < width; i++)
{
VC1_GET_BITS(1, tmp);
if(tmp == 0)
{
for(j = 0; j < height; j++)
pBitplane->m_databits[i + j*width] = 0;
}
else
{
for(j = 0; j < height; j++)
{
VC1_GET_BITS(1, tmp_databits);
pBitplane->m_databits[i + j*width] = (Ipp8u)tmp_databits;
}
}
}
if(pBitplane->m_invert)
{
InverseBitplane(pBitplane, width*height);
}
break;
}
#ifdef VC1_DEBUG_ON
if (VC1_DEBUG&VC1_BITBLANES)
VM_Debug::GetInstance(VC1DebugRoutine).print_bitplane(pBitplane, width, height);
#endif
}
#endif //UMC_ENABLE_VC1_VIDEO_DECODER
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -