📄 umc_mpeg2_dec_blk.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) 2003-2007 Intel Corporation. All Rights Reserved.
//
*/
#include "umc_defs.h"
#if defined (UMC_ENABLE_MPEG2_VIDEO_DECODER)
#include "umc_mpeg2_dec_defs.h"
static QUANT_MATRIX_TYPE Qmatrix[64] =
{
16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,
};
#define UHBITS(code, nbits) (((Ipp32u)(code)) >> (32 - (nbits)))
#define SHBITS(code, nbits) (((Ipp32s)(code)) >> (32 - (nbits)))
#define TAB1_OFFSET_10BIT 248
#define TAB1_OFFSET_15BIT 360
#define TAB1_OFFSET_16BIT 408
#define TAB1_OFFSET_8BIT_INTRA 432
#define TAB1_OFFSET_10BIT_INTRA 680
const Ipp16u MPEG2_VLC_TAB1[] =
{
0xae2, 0xae2,
0x6e9, 0x6e9,
0x12e0, 0x12e0,
0x6e8, 0x6e8,
0x6c7, 0x6c7, 0x6c7, 0x6c7,
0x6c6, 0x6c6, 0x6c6, 0x6c6,
0xac1, 0xac1, 0xac1, 0xac1,
0x6c5, 0x6c5, 0x6c5, 0x6c5,
0x70d,
0x1b00,
0x70c,
0x70b,
0xb03,
0xf01,
0x1700,
0x70a,
0xea0, 0xea0, 0xea0, 0xea0, 0xea0, 0xea0, 0xea0, 0xea0, // 0010 10xx
0x6a4, 0x6a4, 0x6a4, 0x6a4, 0x6a4, 0x6a4, 0x6a4, 0x6a4, // 0011 00xx
0x6a3, 0x6a3, 0x6a3, 0x6a3, 0x6a3, 0x6a3, 0x6a3, 0x6a3, // 0011 10xx
0xa80, 0xa80, 0xa80, 0xa80, 0xa80, 0xa80, 0xa80, 0xa80,
0xa80, 0xa80, 0xa80, 0xa80, 0xa80, 0xa80, 0xa80, 0xa80, // 0100 0xxx
0x682, 0x682, 0x682, 0x682, 0x682, 0x682, 0x682, 0x682,
0x682, 0x682, 0x682, 0x682, 0x682, 0x682, 0x682, 0x682, // 0101 0xxx
0x661, 0x661, 0x661, 0x661, 0x661, 0x661, 0x661, 0x661,
0x661, 0x661, 0x661, 0x661, 0x661, 0x661, 0x661, 0x661,
0x661, 0x661, 0x661, 0x661, 0x661, 0x661, 0x661, 0x661,
0x661, 0x661, 0x661, 0x661, 0x661, 0x661, 0x661, 0x661, // 0110 xxxx
0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640, 0x640, // 264
/* 13-bit code */
0xbaa, 0xba9, 0xfa5, 0x13a3,
0x17a2, 0x1fa1, 0x1ba1, 0x3fa0,
0x3ba0, 0x37a0, 0x33a0, 0x7ba,
0x7b9, 0x7b8, 0x7b7, 0x7b6,
0x2f80, 0x2f80, 0xb88, 0xb88,
0xf84, 0xf84, 0x2b80, 0x2b80,
0x1382, 0x1382, 0xb87, 0xb87,
0x795, 0x795, 0x794, 0x794,
0x2780, 0x2780, 0x793, 0x793,
0x792, 0x792, 0x1781, 0x1781,
0xf83, 0xf83, 0x2380, 0x2380,
0xb86, 0xb86, 0x791, 0x791, // 312
/* 10-bit code */
0x750, 0x750, 0x750, 0x750, 0x750, 0x750, 0x750, 0x750,
0xb45, 0xb45, 0xb45, 0xb45, 0xb45, 0xb45, 0xb45, 0xb45,
0x1f40, 0x1f40, 0x1f40, 0x1f40, 0x1f40, 0x1f40, 0x1f40, 0x1f40,
0xf42, 0xf42, 0xf42, 0xf42, 0xf42, 0xf42, 0xf42, 0xf42,
0x1341, 0x1341, 0x1341, 0x1341, 0x1341, 0x1341, 0x1341, 0x1341,
0x74f, 0x74f, 0x74f, 0x74f, 0x74f, 0x74f, 0x74f, 0x74f,
0x74e, 0x74e, 0x74e, 0x74e, 0x74e, 0x74e, 0x74e, 0x74e,
0xb44, 0xb44, 0xb44, 0xb44, 0xb44, 0xb44, 0xb44, 0xb44, // 376
/* 15-bit code */
0xa3e0, 0x9fe0, 0x9be0, 0x97e0,
0x93e0, 0x8fe0, 0x8be0, 0x87e0,
0x83e0, 0x3be1, 0x37e1, 0x33e1,
0x2fe1, 0x2be1, 0x27e1, 0x23e1,
0x7fc0, 0x7fc0, 0x7bc0, 0x7bc0,
0x77c0, 0x77c0, 0x73c0, 0x73c0,
0x6fc0, 0x6fc0, 0x6bc0, 0x6bc0,
0x67c0, 0x67c0, 0x63c0, 0x63c0,
0x5fc0, 0x5fc0, 0x5bc0, 0x5bc0,
0x57c0, 0x57c0, 0x53c0, 0x53c0,
0x4fc0, 0x4fc0, 0x4bc0, 0x4bc0,
0x47c0, 0x47c0, 0x43c0, 0x43c0, // 424
/* 16-bit code */
0x4a01, 0x4601, 0x4201, 0x3e01,
0xe06, 0xa10, 0xa0f, 0xa0e,
0xa0d, 0xa0c, 0xa0b, 0x61f,
0x61e, 0x61d, 0x61c, 0x61b, // 440
/* 8-bit code for B15 */
0x6e7, 0x6e7, 0x6e8, 0x6e8,
0x6e6, 0x6e6, 0xae2, 0xae2,
0x1ec0, 0x1ec0, 0x1ec0, 0x1ec0,
0x1ac0, 0x1ac0, 0x1ac0, 0x1ac0,
0x6c4, 0x6c4, 0x6c4, 0x6c4,
0x6c5, 0x6c5, 0x6c5, 0x6c5,
0x1701, 0x70b, 0x2f00, 0x2b00,
0x70d, 0x70c, 0xb03, 0x1301,
0x6a2, 0x6a2, 0x6a2, 0x6a2,
0x6a2, 0x6a2, 0x6a2, 0x6a2,
0xaa1, 0xaa1, 0xaa1, 0xaa1,
0xaa1, 0xaa1, 0xaa1, 0xaa1,
0x6a3, 0x6a3, 0x6a3, 0x6a3,
0x6a3, 0x6a3, 0x6a3, 0x6a3,
0x661, 0x661, 0x661, 0x661,
0x661, 0x661, 0x661, 0x661,
0x661, 0x661, 0x661, 0x661,
0x661, 0x661, 0x661, 0x661,
0x661, 0x661, 0x661, 0x661,
0x661, 0x661, 0x661, 0x661,
0x661, 0x661, 0x661, 0x661,
0x661, 0x661, 0x661, 0x661,
0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff,
0xe80, 0xe80, 0xe80, 0xe80,
0xe80, 0xe80, 0xe80, 0xe80,
0xe80, 0xe80, 0xe80, 0xe80,
0xe80, 0xe80, 0xe80, 0xe80,
0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640,
0x640, 0x640, 0x640, 0x640,
0xa60, 0xa60, 0xa60, 0xa60,
0xa60, 0xa60, 0xa60, 0xa60,
0xa60, 0xa60, 0xa60, 0xa60,
0xa60, 0xa60, 0xa60, 0xa60,
0xa60, 0xa60, 0xa60, 0xa60,
0xa60, 0xa60, 0xa60, 0xa60,
0xa60, 0xa60, 0xa60, 0xa60,
0xa60, 0xa60, 0xa60, 0xa60,
0x12a0, 0x12a0, 0x12a0, 0x12a0,
0x12a0, 0x12a0, 0x12a0, 0x12a0,
0x16a0, 0x16a0, 0x16a0, 0x16a0,
0x16a0, 0x16a0, 0x16a0, 0x16a0,
0x6e9, 0x6e9, 0xee1, 0xee1,
0x6ea, 0x6ea, 0x22e0, 0x22e0,
0x26e0, 0x26e0, 0x3300, 0x3700,
0xf02, 0xb04, 0x3b00, 0x3f00, // 688
/* 10-bit code for B15 */
0xb25, 0xb25, 0x72e, 0x72e,
0x1342, 0x750, 0x72f, 0x72f,
};
const Ipp8u MPEG2_DCSIZE_TAB[128] = {
0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21,
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
0x30, 0x30, 0x30, 0x30, 0x33, 0x33, 0x33, 0x33,
0x34, 0x34, 0x34, 0x34, 0x45, 0x45, 0x56, 0x00,
0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67,
0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67,
0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78,
0x89, 0x89, 0x89, 0x89, 0x9a, 0x9a, 0x9b, 0x9b,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21,
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
0x33, 0x33, 0x33, 0x33, 0x44, 0x44, 0x55, 0x00,
0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
0x88, 0x88, 0x88, 0x88, 0x99, 0x99, 0xaa, 0xbb
};
DECLALIGN(16)
static SCAN_MATRIX_TYPE scan_tbl[2][64] =
{
{
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, 8, 16,24,1, 9, 2, 10,
17,25,32,40,48,56,57,49,
41,33,26,18, 3,11,4, 12,
19,27,34,42,50,58,35,43,
51,59,20,28,5 ,13,6 ,14,
21,29,36,44,52,60,37,45,
53,61,22,30,7 ,15,23,31,
38,46,54,62,39,47,55,63
}
};
Ipp8u default_intra_quantizer_matrix[64] =
{
8, 16, 16, 19, 16, 19, 22, 22,
22, 22, 22, 22, 26, 24, 26, 27,
27, 27, 26, 26, 26, 26, 27, 27,
27, 29, 29, 29, 34, 34, 34, 29,
29, 29, 27, 27, 29, 29, 32, 32,
34, 34, 37, 38, 37, 35, 35, 34,
35, 38, 38, 40, 40, 40, 48, 48,
46, 46, 56, 56, 58, 69, 69, 83
};
/***************************************************************/
#define DEF_VARS() \
SCAN_MATRIX_TYPE *scanMatrix = pQuantSpec->scanMatrix; \
QUANT_MATRIX_TYPE *pQuantMatrix = pQuantSpec->quantMatrix; \
DEF_BLOCK(pDstBlock); \
DEF_BLOCK(idct); \
Ipp8u *BS_curr_ptr; \
Ipp32s BS_bit_offset; \
Ipp32s i, j, k; \
Ipp32s val, run, len, sign; \
Ipp32u tbl; \
Ipp32u code
/***************************************************************/
/* ///////////////////////////////////////////////////////////////////////////
// Name:
// ippiDecodeInter8x8IDCTAdd_MPEG2_1u8u
//
// Purpose:
// Performs VLC decoding of DCT coefficients for one inter 8x8 block,
// dequantization of coefficients, inverse DCT and addition of resulted
// 8x8 block to destination.
//
// Parameters:
// ppBitStream Pointer to the pointer to the current byte in
// the bitstream, it is updated after block decoding.
// pBitOffset Pointer to the bit position in the byte pointed by
// *ppBitStream, it is updated after block decoding.
// Must be in the range [0, 7].
// pQuantSpec Pointer to the structure IppiDecodeInterSpec_MPEG2
// QP Quantization parameter.
// pSrcDst Pointer to the 8x8 block in the destination image
// srcDstStep Step through the destination image
//
// Returns:
// ippStsNoErr No error.
// ippStsNullPtrErr One of the specified pointers is NULL.
// ippStsVLCErr An illegal code is detected through the
// stream processing.
*/
MP2_FUNC(IppStatus, ippiDecodeInter8x8IDCTAdd_MPEG2_1u8u, (
Ipp8u** BitStream_curr_ptr,
Ipp32s* BitStream_bit_offset,
IppiDecodeInterSpec_MPEG2* pQuantSpec,
Ipp32s quant,
Ipp8u* pSrcDst,
Ipp32s srcDstStep))
{
DEF_VARS();
Ipp32s mask;
Ipp32s q;
COPY_BITSTREAM(BS, *BitStream)
SHOW_HI9BITS(BS, code);
if (pQuantMatrix) {
if (code & 0x80000000) { /* first 2-bit code */
val = quant*pQuantMatrix[0];
val = (val + val + val) >> 5;
sign = SHBITS(code + code, 1);
APPLY_SIGN(val, sign);
if ((code & 0x30000000) == 0x20000000) { /* end */
SKIP_BITS(BS, 4);
COPY_BITSTREAM(*BitStream, BS)
IDCT_INTER1(val, idct, pSrcDst, srcDstStep);
return ippStsOk;
}
for (k = 0; k < 64; k++) {
pDstBlock[k] = 0;
}
pDstBlock[0] = val;
mask = 1 ^ val;
SKIP_BITS(BS, 2);
SHOW_HI9BITS(BS, code);
i = 0;
} else {
for (k = 0; k < 64; k++) {
pDstBlock[k] = 0;
}
i = -1;
mask = 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -