⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ippvc_bs.h

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 H
字号:
/*////               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) 2001-2005 Intel Corporation. All Rights Reserved.////////              Bit Stream operations*/#ifndef __IPPVC_BS_H__#define __IPPVC_BS_H__#include <vm_debug.h>#ifndef __IPPDEFS_H__#include "ippdefs.h"#endif#define GET_BYTE_PTR(video) \  video##_curr_ptr + ((video##_bit_offset + 7) >> 3)#define GET_END_PTR(video) \  video##_end_ptr#define SET_PTR(video, PTR) {           \  video##_curr_ptr = (Ipp8u*)(PTR);      \  video##_bit_offset = 0;                \}#define GET_REMAINED_BYTES(video) \  (GET_END_PTR(video) - GET_BYTE_PTR(video))#define INIT_BITSTREAM(video, start_ptr, end_ptr) { \  video##_start_ptr = (Ipp8u*)(start_ptr); \  video##_end_ptr = (Ipp8u*)(end_ptr); \  SET_PTR(video, video##_start_ptr); \}#define SHOW_BITS_32(video, CODE) { \  Ipp32u _code = \  (video##_curr_ptr[0] << 24) | \  (video##_curr_ptr[1] << 16) | \  (video##_curr_ptr[2] << 8) | \  (video##_curr_ptr[3]); \  CODE = (_code << video##_bit_offset) | (video##_curr_ptr[4] >> (8 - video##_bit_offset)); \}#define SHOW_BITS_LONG(video, NUM_BITS, CODE) { \  Ipp32u _code2; \  SHOW_BITS_32(video, _code2); \  CODE = _code2 >> (32 - NUM_BITS); \}#define SHOW_HI9BITS(video, CODE) \  CODE = (((video##_curr_ptr[0] << 24) | (video##_curr_ptr[1] << 16)) << video##_bit_offset);#define EXPAND_17BITS(video, CODE) \  CODE |= video##_curr_ptr[2] << (8 + video##_bit_offset);#define SHOW_HI17BITS(video, CODE) \  CODE = (((video##_curr_ptr[0] << 24) | (video##_curr_ptr[1] << 16) | (video##_curr_ptr[3]<<8)) << video##_bit_offset);#define EXPAND_25BITS(video, CODE) \  CODE |= video##_curr_ptr[3] << video##_bit_offset;#define SHOW_BITS_SHORT(video, NUM_BITS, CODE) { \  Ipp32u _code; \  SHOW_HI9BITS(video, _code); \  CODE = _code >> (32 - NUM_BITS); \}#define SHOW_BITS(video, NUM_BITS, CODE) { \  Ipp32u _code = \  (video##_curr_ptr[0] << 24) | \  (video##_curr_ptr[1] << 16) | \  (video##_curr_ptr[2] << 8); \  CODE = (_code << video##_bit_offset) >> (32 - NUM_BITS); \}#define SHOW_1BIT(video, CODE) { \  CODE = (video##_curr_ptr[0] >> (7-video##_bit_offset)) & 1; \}#define SHOW_TO9BITS(video, NUM_BITS, CODE) { \  Ipp32u _code = \  (video##_curr_ptr[0] << 8) | (video##_curr_ptr[1] ); \  CODE = (_code >> (16 - NUM_BITS - video##_bit_offset)) & ((1<<NUM_BITS)-1); \}#define SKIP_BITS(video, NUM_BITS) \  video##_bit_offset += NUM_BITS; \  video##_curr_ptr += (video##_bit_offset >> 3); \  video##_bit_offset &= 7;#define GET_BITS(video, NUM_BITS, CODE) { \  SHOW_BITS(video, NUM_BITS, CODE); \  SKIP_BITS(video, NUM_BITS); \}#define GET_TO9BITS(video, NUM_BITS, CODE) { \  SHOW_TO9BITS(video, NUM_BITS, CODE); \  SKIP_BITS(video, NUM_BITS); \}#define GET_BITS_LONG(video, NUM_BITS, CODE) { \  SHOW_BITS_LONG(video, NUM_BITS, CODE); \  SKIP_BITS(video, NUM_BITS); \}#define SKIP_BITS_LONG(video, NUM_BITS) \  SKIP_BITS(video, NUM_BITS)#define SKIP_BITS_32(video) \  SKIP_BITS(video, 32);#define GET_BITS32(video, CODE) { \  SHOW_BITS_32(video, CODE) \  SKIP_BITS_32(video); \}#define GET_1BIT(video, CODE) {\  SHOW_1BIT(video, CODE) \  SKIP_BITS(video, 1) \}#define UNGET_BITS_32(video) \  video##_curr_ptr -= 4;#define COPY_BITSTREAM(DST_BS, SRC_BS) \  DST_BS##_curr_ptr = SRC_BS##_curr_ptr; \  DST_BS##_bit_offset = SRC_BS##_bit_offset;/***************************************************************/#define FIND_START_CODE(video, code) {                          \  Ipp8u *ptr = GET_BYTE_PTR(video);                             \  Ipp8u *end_ptr = GET_END_PTR(video) - 3;                      \  while (ptr < end_ptr && (ptr[0] || ptr[1] || (1 != ptr[2]))) {\    ptr++;                                                      \  }                                                             \  if (ptr < end_ptr) {                                          \    code = 256 + ptr[3];                                        \    SET_PTR(video, ptr);                                        \  } else {                                                      \    code = (Ipp32u)UMC_NOT_ENOUGH_DATA;                         \  }                                                             \}#define GET_START_CODE(video, code) { \  FIND_START_CODE(video, code)        \  if(code != (Ipp32u)UMC_NOT_ENOUGH_DATA) { \    SKIP_BITS_32(video);                    \  }                                         \}/***************************************************************/#define VLC_BAD        0x80#define VLC_NEXTTABLE  0x40#ifdef USE_VLC_THRESHOLD#define DECODE_VLC(value, bitstream, pVLC) \{ \  int max_bits = pVLC.max_bits; \  Ipp32u __code; \  Ipp32s tbl_value; \  \  SHOW_BITS_32(bitstream, __code); \  \  __code >>= (32 - max_bits); \  \  if (__code >= pVLC.threshold_table0 || isOneTable) { \    int bits_table0 = pVLC.bits_table0; \    tbl_value = pVLC.table0[__code >> (max_bits - bits_table0)]; \  } else { \    int bits_table1 = pVLC.bits_table1; \    tbl_value = pVLC.table1[__code & ((1 << bits_table1) - 1)]; \  } \  \  value = tbl_value >> 8; \  \  if (tbl_value & (VLC_BAD | VLC_NEXTTABLE)) return UMC_BAD_STREAM; \  \  tbl_value &= 0x3F; \  ippiSkipNBits(bitstream->bs_curr_ptr, bitstream->bs_bit_offset, tbl_value); \}#else#define DECODE_VLC(value, bitstream, pVLC) \{ \  Ipp32u __code; \  Ipp32s tbl_value; \  int bits_table0 = pVLC.bits_table0; \  \  SHOW_HI9BITS(bitstream, __code); \  \  tbl_value = pVLC.table0[__code >> (32 - bits_table0)]; \  \  if (tbl_value & (VLC_BAD | VLC_NEXTTABLE)) { \    int max_bits = pVLC.max_bits; \    int bits_table1 = pVLC.bits_table1; \  \    if (tbl_value & VLC_BAD) return UMC_BAD_STREAM; \    EXPAND_17BITS(bitstream, __code); \    tbl_value = pVLC.table1[(__code >> (32 - max_bits)) & ((1 << bits_table1) - 1)]; \  } \  \  value = tbl_value >> 8; \  \  tbl_value &= 0x3F; \  SKIP_BITS(bitstream, tbl_value); \}#endif#define DECODE_VLC_TEST1BIT(value, bitstream, pVLC) \  if (bitstream->bitstream_INP(current_data[0]) & (1 << bitstream->bs_bit_offset)) { \    value = 0; \    ippiSkipNBits(bitstream->bs_curr_ptr, bitstream->bs_bit_offset, 1); \  } else { \    DECODE_VLC(value, bitstream, pVLC); \  }/***************************************************************/#ifndef __MPEG2_FUNC__#define __MPEG2_FUNC__#include "ippdefs.h"#define MP2_API( type,name,arg )        extern type name arg;#define IPPVC_ZIGZAG_SCAN           0#define IPPVC_ALT_SCAN              1#define IPPVC_MPEG1_STREAM          2#define IPPVC_LEAVE_QUANT_UNCHANGED 4#define IPPVC_LEAVE_SCAN_UNCHANGED  8struct DecodeIntraSpec_MPEG2 {  Ipp16s _quantMatrix[64];  Ipp16s *quantMatrix;  Ipp32s *scanMatrix;  Ipp32s intraVLCFormat;  Ipp32s intraShiftDC;};struct DecodeInterSpec_MPEG2 {  Ipp16s _quantMatrix[64];  Ipp16s *quantMatrix;  Ipp32s *scanMatrix;  Ipp32s align[3];};typedef struct DecodeIntraSpec_MPEG2 IppiDecodeIntraSpec_MPEG2;typedef struct DecodeInterSpec_MPEG2 IppiDecodeInterSpec_MPEG2;/* /////////////////////////////////////////////////////////////////////////////  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_API(IppStatus, ippiDecodeInter8x8IDCTAdd_MPEG1_1u8u, (    Ipp8u**                            ppBitStream,    int*                               pBitOffset,    IppiDecodeInterSpec_MPEG2*         pQuantSpec,    int                                QP,    Ipp8u*                             pSrcDst,    int                                srcDstStep))MP2_API(IppStatus, ippiDecodeInter8x8IDCTAdd_MPEG2_1u8u, (    Ipp8u**                            ppBitStream,    int*                               pBitOffset,    IppiDecodeInterSpec_MPEG2*         pQuantSpec,    int                                QP,    Ipp8u*                             pSrcDst,    int                                srcDstStep))/* /////////////////////////////////////////////////////////////////////////////  Name://    ippiDecodeIntra8x8IDCT_MPEG2_1u8u////  Purpose://    Performs VLC decoding of DCT coefficients for one intra 8x8 block,//    dequantization of coefficients, inverse DCT and storing 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 IppiDecodeIntraSpec_MPEG2//    QP               Quantization parameter.//    blockType        Indicates the type of block, takes one of the following//                     values://                         IPPVC_BLOCK_LUMA - for luma blocks,//                         IPPVC_BLOCK_CHROMA - for chroma blocks//                     And in case of MPEG1 D-type block, IPPVC_BLOCK_MPEG1_DTYPE//                     have to be added to IPPVC_BLOCK_LUMA or IPPVC_BLOCK_CHROMA.//    pDCPred          Pointer to the value to be added to the DC coefficient//    pDst             Pointer to the 8x8 block in the destination image//    dstStep          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_API(IppStatus, ippiDecodeIntra8x8IDCT_MPEG1_1u8u, (    Ipp8u**                            ppBitStream,    int*                               pBitOffset,    IppiDecodeIntraSpec_MPEG2*         pQuantSpec,    int                                QP,    int                                blockType,    Ipp16s*                            pDCPred,    Ipp8u*                             pDst,    int                                dstStep))MP2_API(IppStatus, ippiDecodeIntra8x8IDCT_MPEG2_1u8u, (    Ipp8u**                            ppBitStream,    int*                               pBitOffset,    IppiDecodeIntraSpec_MPEG2*         pQuantSpec,    int                                QP,    int                                blockType,    Ipp16s*                            pDCPred,    Ipp8u*                             pDst,    int                                dstStep))/* /////////////////////////////////////////////////////////////////////////////  Name://    ippiDecodeIntraInit_MPEG2//    ippiDecodeInterInit_MPEG2////  Purpose://    Initialized IppiDecodeIntraSpec_16s(IppiDecodeInterSpec_MPEG2) structure.//    If pQuantMatrix is NULL this means default quantization matrix.////  Parameters://    pQuantMatrix   Pointer to the quantization matrix size of 64.//    scan           Type of the scan, takes one of the following values://                       IPPVC_SCAN_ZIGZAG, indicating the classical zigzag scan,//                       IPPVC_SCAN_VERTICAL - alternate-vertical scan//    intraVLCFormat 0 or 1, defines one of two VLC tables for decoding intra blocks//    intraShiftDC   Integer value for shifting intra DC coefficient after VLC decoding//    pSpec          Pointer to the structure IppiDecodeIntraSpec_16s or//                   IppiDecodeInterSpec_MPEG2 which will initialized.////  Returns://    ippStsNoErr        No error.//    ippStsNullPtrErr   Indicates an error when pointer pSpec is NULL.*/MP2_API(IppStatus, ippiDecodeIntraInit_MPEG2, (    const Ipp8u*                 pQuantMatrix,    int                          scan,    int                          intraVLCFormat,    int                          intraShiftDC,    IppiDecodeIntraSpec_MPEG2*   pSpec))MP2_API(IppStatus, ippiDecodeInterInit_MPEG2, (    const Ipp8u*                 pQuantMatrix,    int                          flag,    IppiDecodeInterSpec_MPEG2*   pSpec))#endif /* __MPEG2_FUNC__ *//***************************************************************/#endif /* __IPPVC_H__ *//* End of file */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -