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

📄 umc_h264_core_enc.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) 2004 - 2005 Intel Corporation. All Rights Reserved.//#ifndef ECORE_H__#define ECORE_H__#include "umc_h264_pub.h"#include "umc_h264_bs.h"#include "umc_h264_arc.h"#define VM_DEBUG 7#include "vm_debug.h"namespace UMC{void AIPredictBlock(    Ipp32u uMode,       // advanced intra mode of the block    Ipp32u uEdgeType,   // edge type for the block    Ipp32u uBlock,      // block number    Ipp8u* pBlock,      // pointer to upper left pel of block    Ipp32u uPitch,      // of reference plane    Ipp8u *pPredBuf);void AIPredictBlock2(    Ipp32u uMode,       // advanced intra mode of the block    Ipp8u *pPredBuf,    Ipp8u *tp,    Ipp8u *lp,    Ipp8u t0);Ipp32u SAD4x4Block4(        // 4 arguments    const Ipp8u *pBlock1,    Ipp32u uPitch1,    const Ipp8u *pBlock2,    Ipp32u uPitch2);void    PlanarPredictLuma(            Ipp32u uEdgeType,   // edge type for the macroblock            Ipp8u* pBlock,      // pointer to upper left pel of block            Ipp32u uPitch,      // of reference plane            Ipp8u *pPredBuf);void    PlanarPredictChroma(            Ipp32u uEdgeType,   // edge type for the macroblock            Ipp8u* pBlock,      // pointer to upper left pel of block            Ipp32u uPitch,      // of reference plane            Ipp8u *pPredBuf);// Moved a bunch of function prototypes to ecore.h to keep the fuction declarations close// to the function typedef.#define CLIP(arg, min, max) (CLIPtemp = (arg), (CLIPtemp) < (min) ? (min) : ((CLIPtemp) > (max) ? (max) : (CLIPtemp)))#define CHECK_PTR(ptr, status, goto_mark) \        if (!ptr)\        {\            status = H264_S_OUT_OF_MEMORY;\            goto goto_mark;\        }else if (H264_S_OK != status){\            delete ptr;\            ptr = 0;\            goto goto_mark;\        }\// Edge types are bitfields, where a bit (set) indicates that a//  particular macroblock is on a given edge.//  Macroblocks can be on more than one edge.typedef enum {    CENTER      = 0x00,    LEFT_EDGE   = 0x01,    RIGHT_EDGE  = 0x02,    TOP_EDGE    = 0x04,    BOTTOM_EDGE = 0x08} Edge_Type;// motion vector structtypedef struct {    Ipp32s mvx;    Ipp32s mvy;} Motion_Vector;///////////////////////////////////////////////////////////////// Class definition of the abstract base class Core_Encoder///////////////////////////////////////////////////////////////// Note:  Each layer of the H.263+ encoder will allocate a//          Core_Encoder to store motion vectors and frame//          info to support Annex O Scalabilityclass H264EncoderFrame;//inline functions for ME and MC: inline has to implement in header file// for both ecme.cpp and ecmc.cpp to use//////////////////////////////////////////////////////////////////////MVSub2FullPelsvoid inlineMVSub2FullPels(const Ipp32s mv, Ipp32s& mv_intg, Ipp32s& mv_frac){    mv_intg = mv / SubPelFactor;    mv_frac = mv - mv_intg * SubPelFactor;    if (mv_frac < 0)    {        mv_intg -= 1;        mv_frac += SubPelFactor;    }}// Constants used in the core encoder/* * MB Edge Types */// note the upper 4 bits of MBEdgeType are used for OBMC control// These codes are used to indicate frame (slice?) edges.const Ipp8u MBEdgeTypeIsLeftEdge   = 0xFE;const Ipp8u MBEdgeTypeIsRightEdge  = 0xFD;const Ipp8u MBEdgeTypeIsTopEdge    = 0xFB;const Ipp8u MBEdgeTypeIsUpperLeftCorner = 0xF7;// These codes are used to indicate which 4x4 blocks are NOT on// the edges of a 16x16 (or 8x8) macroblock.#define MBEdgeTypeIsNotLeftEdge   0x1#define MBEdgeTypeIsNotRightEdge  0x2#define MBEdgeTypeIsNotTopEdge    0x4#define MBEdgeTypeIsNotUpperLeftCorner 0x8#define NUM_AI_MODES 9// EOB flag for RLE stream#define RLE_EOB 0xffffffff#define TR_SHIFT 8// Intra MB_Type Offset by Slice Typeconst Ipp8u IntraMBTypeOffset[5] = {    5,  // PREDSLICE    23, // BPREDSLICE    0,  // INTRASLICE    5,  // S_PREDSLICE    1   // S_INTRASLICE};    // This macro calculates the Intra_16x16 mb_type from mode, nc and ac.    // These things are defined in the JVT-FCD.  Briefly:    // slice_type = As defined in EnumSliceType    // mode = 0..3 Luma 16x16 prediction mode 0=Vert, 1=Horiz, 2=DC, 3=Plane    //      VSI: NOTE: This is not what the FCD says: it says DC, Horiz, Vert, Plane...    // nc = coded chroma cbp (0=all coeffs are 0, 1=some nonzero DC, 2=some nonzero AC    // ac = flag that indicates where there are coded luma AC coefficients#define CALC_16x16_INTRA_MB_TYPE(slice, mode, nc, ac) (1+IntraMBTypeOffset[slice]+mode+4*nc+12*ac)#define CALC_4x4_INTRA_MB_TYPE(slice) (IntraMBTypeOffset[slice])#define CALC_PCM_MB_TYPE(slice) (IntraMBTypeOffset[slice]+25);// Minimum Max value that can be coded in any CAVLC escape code// ie. 16+2047#define MAX_CAVLC_LEVEL_VALUE   2063// Number of bits (header plus residual) that triggers a MB to// be recoded with a higher QP (up to twice) or in PCM mode.#define MB_RECODE_THRESH        2750///////////////////////////////////////////////////////////////// Data structures for Core_Encoder///////////////////////////////////////////////////////////////// Macroblock datatypedef struct {    Ipp32u  uLumaOffset;    // from start of luma plane to upper left of MB    Ipp32u uChromaOffset;   // from start of first chroma plane to upper left                        // of chroma MB    Ipp32u uFirstBlockIndex;    // index into luma block arrays, to the first block                            // for this MB    Ipp32u uFirstChromaBlockIndex;  // index into chroma block arrays, to the first block                                // for this MB    Ipp32u uMVLimits;       // max ME search range in each direction:                        //  bits 0..7   left                        //  bits 8..15  right                        //  bits 16..23 up                        //  bits 24..31 down} T_EncodeMBOffsets;// Number of coded coefficients// Advanced Intra modetypedef Ipp8s T_AIMode;typedef Ipp8s T_RefIdx;/////////////////////////////// Make sure all assembly-optimized function declarations are extern "C".// This suppresses C++ name mangling on the function names, allowing// MSVC .obj files to be translated to Linux .o files and referenced// appropriately./////////////////////////////#define IS_Left_Available(x) ((m_pCurrentFrame->pMBData[(x)].uEdgeType & MBEdgeTypeIsNotLeftEdge))#define IS_Top_Available(x) ((m_pCurrentFrame->pMBData[(x)].uEdgeType & MBEdgeTypeIsNotTopEdge))#define Get_Left_Value(x,value,missing_value) (IS_Left_Available((x)))?(value):(missing_value)#define Get_Top_Value(x,value,missing_value) (IS_Top_Available((x)))?(value):(missing_value)// SAD functionstypedef Ipp32u (T_SADFn)(    const Ipp8u *p1,    const Ipp8u *p2,    Ipp32u uPitch);// SAD functionstypedef Ipp32u (T_SADFn1)(    const Ipp8u *p1,    const Ipp8u *p2,    Ipp16u *p3,    Ipp32u uPitch);// Function declarations moved after typedefextern T_SADFn SAD4x4Block;extern T_SADFn SAD8x8Block;extern T_SADFn SAD16x16Block;extern T_SADFn1 SAD16x16Block_Sb4;extern T_SADFn1 SAD16x16Block_Sb16;// second source fixed pitch=16 functionsextern T_SADFn SAD4x4Block_P16;extern T_SADFn SAD8x8Block_P16;extern T_SADFn SAD16x16Block_P16;/*// subpel search functiontypedef void (T_SubpelSearchBlock)(    const Ipp8u *pTarget,       // block to match    const Ipp8u *pRef,          // reference block (includes pMV adjust)    Ipp32u uPitch,              // of both target and reference    Ipp32s *pBestSAD,           // SAD to beat; also return best SAD here    T_ECORE_MV *pMV,        // best MV, in subpel units; return best MV here    Ipp32s iSize,               //.of block, 4,8, or 16 for 4x4, 8x8, 16x16    T_SADFn *SADfunc        // pointer to SAD function to use);extern T_SubpelSearchBlock C_SubpelSearchBlock;*/// Direct B predictiontypedef void (T_DirectB_PredictOneMB)(    Ipp8u *const        pDirB,      // pointer to current direct mode MB buffer    const Ipp8u *const  pPrev,      // pointer to previous ref plane buffer    const Ipp8u *const  pFutr,      // pointer to future ref plane buffer    const Ipp32u        uRefPitch,  // reference buffers pitch    const Ipp32u        uInterpType,// 0 = Skip, 1 = Default, 2 = Implicit Weighted    const Ipp32s        uFwdRatio,    const Ipp32s        uBwdRatio,    const IppiSize &    roiSize);extern T_DirectB_PredictOneMB DirectB_PredictOneMB_Lu;extern T_DirectB_PredictOneMB DirectB_PredictOneMB_Cr;// struct to characterize the state of the arithmetic coding enginestruct T_CABAC_Data{  Ipp32u        low, range;  Ipp32u        buffer;  Ipp32u        bits_to_go;  Ipp32u        bits_to_follow;  Ipp8u         *codestrm;  Ipp32s        *codestrm_len;  Ipp32u        lowS, rangeS;  Ipp32u        bufferS;  Ipp32u        bits_to_goS;  Ipp32u        bits_to_followS;  Ipp8u         *codestrmS;  Ipp32s        *codestrm_lenS;  Ipp32s        C, CS;  Ipp32s        E, ES;  Ipp32s        B, BS;} ;typedef T_CABAC_Data *T_CABAC_DataPtr;// struct for context managementstruct T_CABAC_ContextType{  Ipp16u    state;         // index into state-table CP  Ipp8u     MPS;           // Most Probable Symbol 0/1 CP  Ipp32u      count;} ;typedef T_CABAC_ContextType *T_CABAC_ContextTypePtr;// These are used to index into Block_RLE below.#define U_DC_RLE 24     // Used in Intra Prediciton Modes#define V_DC_RLE 25     // Used in Intra Prediciton Modes#define Y_DC_RLE 26     // Used in Intra 16x16 Prediciton Mode// core function prototypes// function typedefs are used when multiple variants of a function are// being used, called through function pointers.// Motion estimate macroblock// Returns true if the MVs for uMB are predicted exactly// using the Skip MB MV prediction rules.// 4x4 intra block mode select function parameter structure// T_4x4IntraModeSelParams struct offsets for ASM functions#define IMSP_uEdgeType_Offset   0#define IMSP_uPitch_Offset      4#define IMSP_uWidthIn4x4Blocks_Offset   8#define IMSP_uUseURPred_Offset  12#define IMSP_iRDFactor_Offset   36// Slices with Intra MBs over this percentage may be recoded as Intra#define INTRA_PERCENTAGE_THRESHOLD 75// advanced intra mode select blocktypedef Ipp32u (T_AIModeSelectOneBlock)(    T_4x4IntraModeSelParams *pModeSelParams,    Ipp8u* pSrcBlock,           // pointer to upper left pel of source block    Ipp8u* pRefBlock,           // pointer to same block in reference picture    Ipp32u uBlock,              // which 4x4 of the MB (0..23)    T_AIMode *pMode,        // selected mode goes here    Ipp8u *pPred                // predictor pels for selected mode goes here                            // if not NULL);extern T_AIModeSelectOneBlock AIModeSelectOneBlock;// MB edge detectiontypedef bool (T_MBEdgeDetect)(Ipp8u* pMB, Ipp32u uPitch, Ipp32u uQP);extern T_MBEdgeDetect MBEdgeDetect;// 16x16 INTRA MB mode selection and predictiontypedef Ipp32u (T_AIModeSelectOneMB_16x16)(    Ipp8u* pSrc,                // pointer to upper left pel of source MB    Ipp8u* pRef,                // pointer to same MB in reference picture    Ipp32u uPitch,              // of source and ref data    Ipp32u uEdgeType,           // MB on picture edge?    Ipp32u available,       // Available pixels flags: 2 - top available, 1 left available, 3 both left and top are available.    T_AIMode *pMode,        // selected mode goes here    Ipp8u *pPredBuf         // predictor pels for selected mode goes here);extern T_AIModeSelectOneMB_16x16 AIModeSelectOneMB_16x16;// 8x8 INTRA MB mode selection and predictiontypedef Ipp32u (T_AIModeSelectChromaMBs_8x8)(    Ipp8u* pUSrc,               // pointer to upper left pel of U source MB    Ipp8u* pURef,               // pointer to same MB in U reference picture    Ipp8u* pVSrc,               // pointer to upper left pel of V source MB    Ipp8u* pVRef,               // pointer to same MB in V reference picture    Ipp32u uPitch,              // of source and ref data    Ipp32u uEdgeType,           // MB on picture edge?    Ipp32u available,           // Available pixels flags: 2 - top available, 1 left available, 3 both left and top are available.    Ipp8u *pMode,               // selected mode goes here    Ipp8u *pUPredBuf,           // U predictor pels for selected mode go here    Ipp8u *pVPredBuf            // V predictor pels for selected mode go here);extern T_AIModeSelectChromaMBs_8x8 AIModeSelectChromaMBs_8x8;//typedef T_NumCoeffs (T_RLE)(//  const Ipp16s*   pQbuf,      // quantized coeffs in scan order//  Ipp32u  NumCoeffs,          // number of coeffs in Block//  T_RLE_Data* pRLE_Data   // where to put RLE data//);//extern T_RLE RLE; // single scan with cost computations// Encoder tables// Table to obtain edge info for a 4x4 block of a MB. The table entry when// OR'd with the edge info for the MB, results in edge info for the block.extern const Ipp8u uEncNotEdge[24];// Threshold table, indexed by QP, which returns the pel count which// must be exceeded for the MB to be classified as having an edge.extern const Ipp32u uEdgePelCountTable [52];// 4x4 Intra prediction:// lookup table indexed by block number, return 0xff if lower left predictors// (MNOP) are valid for the block, based upon its position in the macroblock.extern const Ipp8u uBlockLLPredOK[24];} //namespace UMC#endif // ECORE_H__

⌨️ 快捷键说明

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