Decodes and rearranges segment block, multiplies first block element by 128.
IppStatus ippiHuffmanDecodeSegment_DV_8u16s(const Ipp8u* pStream, const Ipp32u* pZigzagTables, const Ipp32u* pHuffTable, Ipp16s* pBlock, Ipp32u* pBlockParam);
pStream |
Pointer to bitstream (compressed segment). |
pZigzagTables |
Pointer to the array of two scanning matrices. |
pHuffTable |
Pointer to the decoding Huffman table. |
pBlock |
Pointer to decoded elements. |
pBlockParam |
Pointer to output parameters array [30]. |
This function is declared in the ippvc.h header file. The function ippiHuffmanDecodeSegment_DV_8u16s decodes and rearranges segment, multiplies the first block element by 128.
The figure below depicts the DV frame decoding process.
At the first step, ippiHuffmanDecodeSegment_DV_8u16s function decodes the compressed frame. The output of the function is 6 decompressed macro blocks, which are then de-quantized, de-weighted, processed by inverse DCT, and stored to the appropriate places of the destination image.
AC coefficients are decoded using Variable Length Codes with the help of the destination decoding table created by InitAllocHuffmanTable_DV. The pointer to this table is passed to the ippiHuffmanDecodeSegment_DV function through the pHuffTable pointer. The table contains level values multiplied by 64, and the ippiHuffmanDecodeSegment_DV function also multiplies output values of AC coefficients by 64.
DC coefficients are obtained from the first 2 bytes of the compressed blocks (see "Arrangement of Y compressed blocks cbY0, cbY1, cbY2, cbY3" and "Arrangement of Cr compressed blocks cbU, cbV") with zeroing of the last 7 bits. The output values of DC coefficients are multiplied by 128 (shift left by 7).
The pointer pStream points to a compressed segment, which is a sequence of 5 compressed macroblocks. Each compressed macroblock occupies 80 bytes of data, hence the total length of the compressed video segment is 400 bytes.
The pZigzagTables pointer refers to two scanning matrices which are used to de-zigzag AC coefficients.
Scanning_matrix = pZigzagTables, if the block is of type 1(m0 = 0). Scanning_matrix = pZigzagTables + 64, if the block is of type 2 (m0 = 1).
The argument *pBlockParam ("BlockParam Structure") stores values m0 (block type), cl (class number), index (index of the last decoded element), and eob (end of block indicator) for every block.
Value qn0 (quantization number) is obtained from the first block of the macroblock. The same value qn0 is used for all blocks of the macroblock.
With 64 elements in an 8x8 block, if only the DC coefficient (that is, the first block element) is decoded, index=0. If all the elements are decoded, index=63.
eob=1 (“true”), if the symbol of the block end EOB is present in the block, otherwise eob=0 (“false”).
See Example “HuffmanDecodeSegment_DV Usage” and Example “HuffmanDecodeSegment_DV Usage with index and eob values .
Ipp32u DeZigzagTables[] = { 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63, 0, 32, 1, 33, 8, 40, 2, 34, 9, 41, 16, 48, 24, 56, 17, 49, 10, 42, 3, 35, 4, 36, 11, 43, 18, 50, 25, 57, 26, 58, 19, 51, 12, 44, 5, 37, 6, 38, 13, 45, 20, 52, 27, 59, 28, 60, 21, 53, 14, 46, 7, 39, 15, 47, 22, 54, 29, 61, 30, 62, 23, 55, 31, 63 }; { /* Create Huffman Decoding table*/ ippiInitAllocHuffmanTable_DV_32u( ..., ..., &pHuffTable); ... /* Huffman Decode video segment pEncodedVideoSegment - (Ipp8u*) pointer to compresses video segment DeZigzagTables - (Ipp32u*) pointer to array of two de-zigzag tables pHuffTable - (Ipp32u*) pointer to Huffman decoding table created by the ippiInitAllocHuffmanTable_DV_32u function lpsDecodedBlocks - (Ipp16s*) pointer to 30 decoded DCT blocks (5 macro blocks of 6 DCT blocks) BlockParamBuffer - (Ipp32u*) pointer to array of 30 unsigned double words, containing DC, m0 and cl values for DCT blocks */ ippiHuffmanDecodeSegment_DV_8u16s(pEncodedVideoSegment, DeZigzagTables, pHuffTable, lpsDecodedBlocks, BlockParamBuffer); }
void test_huff2(void) { /* Create Huffman Decoding table*/ ippiInitAllocHuffmanTable_DV_32u( ..., ..., &pHuffTable); ... /* Huffman Decode video segment pEncodedVideoSegment - (Ipp8u*) pointer to compresses video segment DeZigzagTables - (Ipp32u*) pointer to array of two de-zigzag tables pHuffTable - (Ipp32u*) pointer to Huffman decoding table created by the ippiInitAllocHuffmanTable_DV_32u function lpsDecodedBlocks - (Ipp16s*) pointer to 30 decoded DCT blocks (5 macro blocks of 6 DCT blocks) BlockParamBuffer - (Ipp32u*) pointer to array of 30 unsigned double words, containing DC, m0 and cl values for DCT blocks */ ippiHuffmanDecodeSegment_DV_8u16s(pEncodedVideoSegment, DeZigzagTables, pHuffTable, lpsDecodedBlocks, BlockParamBuffer); for (mb_num = 0;mb_num < 5;mb_num++) { // get quantization number qno = (BlParamBuffer[mb_num * 6] >> 16) & 0x0F; // decompress each block for (b_num = 0;b_num < 6;b_num++) { block_type = (BlParamBuffer[mb_num * 6 + b_num] >> 6) & 0x01; bl_index = (BlParamBuffer[mb_num * 6 + b_num] >> 8) & 0xff; eob = BlParamBuffer[mb_num * 6 + b_num] & 0x01; // do inverse and adaptive dequantization ippiQuantInv_DV_16s_C1I(lpsDecodedBlocks,...); // do iDCT if (0 == block_type) { if ((eob == 0)||( 10 > bl_index)) ippiDCT8x8Inv_4x4_16s_C1I((Ipp16s *) (lpsDecodedBlocks)); else ippiDCT8x8Inv_16s_C1I((Ipp16s *) (lpsDecodedBlocks)); } else { ippiDCT2x4x8Inv_16s_C1I((Ipp16s *) (lpsDecodedBlocks)); } } } }
This function is used in the DV decoder included into Intel IPP Samples. See introduction to DV.
ippStsNoErr |
Indicates no error. |
ippStsNullPtrErr |
Indicates an error when at least one input pointer is NULL. |
Copyright © 2000 - 2011, Intel Corporation. All rights reserved.