📄 umc_h264_core_enc.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 - 2007 Intel Corporation. All Rights Reserved.
//
#ifndef UMC_H264_CORE_ENC_H__
#define UMC_H264_CORE_ENC_H__
#include "umc_memory_allocator.h"
#include "umc_h264_pub.h"
#include "umc_h264_bs.h"
#include "umc_h264_enc_cpb.h"
//f
#include "umc_h264_avbr.h"
#ifdef H264_NEW_ME
#include "umc_h264_me_new.h"
#endif
#define VM_DEBUG 7
#include "vm_debug.h"
namespace UMC_H264_ENCODER
{
template <class PixType> class CNoiseReductionFilter;
///////////////////////////////////////////////////////////////
// Data structures for Core_Encoder
///////////////////////////////////////////////////////////////
// Macroblock data
typedef struct {
Ipp32u uLumaOffset[2][2]; // from start of luma plane to upper left of MB (pixels)
Ipp32u uChromaOffset[2][2]; // from start of first chroma plane to upper left (pixels) of chroma MB
Ipp32s uMVLimits_L, uMVLimits_R, uMVLimits_U, uMVLimits_D;
} T_EncodeMBOffsets;
// Number of coded coefficients
typedef Ipp8s T_RefIdx;
Ipp32s SSD4x4( const Ipp8u* p1,
Ipp32s pitch1,
const Ipp8u* p2,
Ipp32s pitch2 );
Ipp32s SSD8x8( const Ipp8u* p1,
Ipp32s pitch1,
const Ipp8u* p2,
Ipp32s pitch2 );
Ipp32s SSD16x16( const Ipp8u* p1,
Ipp32s pitch1,
const Ipp8u* p2,
Ipp32s pitch2 );
#if defined BITDEPTH_9_12
Ipp32s SSD4x4( const Ipp16u* p1,
Ipp32s pitch1,
const Ipp16u* p2,
Ipp32s pitch2 );
Ipp32s SSD8x8( const Ipp16u* p1,
Ipp32s pitch1,
const Ipp16u* p2,
Ipp32s pitch2 );
Ipp32s SSD16x16( const Ipp16u* p1,
Ipp32s pitch1,
const Ipp16u* p2,
Ipp32s pitch2 );
#endif
// These are used to index into Block_RLE below.
#define U_DC_RLE 48 // Used in Intra Prediciton Modes
#define V_DC_RLE 49 // Used in Intra Prediciton Modes
#define Y_DC_RLE 50 // Used in Intra 16x16 Prediciton Mode
// Allocate 'size' bytes of memory, optionally clear it, and
// return a pointer to it. Returns NULL if allocation fails.
// The caller is repsonsible for recovering from a failed allocation.
// Allocating 0 bytes is supported, though it will result in
// some non-zero number of bytes actually being allocated.
void *H264_Allocate(Ipp32u size, bool zero_init);
// Free memory previously allocated by H264_Allocate.
void H264_Free(void*);
#ifdef H264_STAT
class H264FramesStat{
public:
int numIf, sizeI;
int numPf, sizeP;
int numBf, sizeB;
int numI[32][2];
int numP[32][2];
int numB[32][2];
int numIsize[32][2];
int numPsize[32][2];
int numBsize[32][2];
int numImb, numPmb, numBmb;
int numPnsb;
int numPsb[4];
H264FramesStat();
void addMB(Ipp32s sliceType, Ipp32s mbType, Ipp8u sbType[4], bool t8x8, Ipp32s mbBits);
void addFrame( Ipp32s frameType, Ipp32s size );
void printStat();
};
#endif
#define ANALYSE_I_4x4 1
#define ANALYSE_I_8x8 2
#define ANALYSE_P_4x4 4
#define ANALYSE_P_8x8 8
#define ANALYSE_B_4x4 16
#define ANALYSE_B_8x8 32
#define ANALYSE_SAD 64
#define ANALYSE_ME_EARLY_EXIT 128
#define ANALYSE_ME_ALL_REF 256
#define ANALYSE_ME_CHROMA 512
#define ANALYSE_ME_SUBPEL 1024
#define ANALYSE_CBP_EMPTY 2048
#define ANALYSE_RECODE_FRAME 4096
#define ANALYSE_ME_AUTO_DIRECT 8192
#define ANALYSE_ME_ADAPTIVE_B 16384
#define ANALYSE_SCENECUT 32768
#define ANALYSE_RD_MODE 65536
#define ANALYSE_RD_OPT 131072
template <class PixType, class CoeffsType> class H264EncoderThreadedDeblockingTools;
template <class PixType, class CoeffsType> class H264EncoderThreadPrivateSlice{
public:
H264EncoderThreadPrivateSlice();
Status Init(H264EncoderParams &info); // Must be called once as parameters are available.
~H264EncoderThreadPrivateSlice();
public:
EnumSliceType m_slice_type; // Type of the current slice.
Ipp32s m_slice_number; // Number of the current slice.
Ipp32s status; //Return value from Compress_Slice function
Ipp8s m_iLastXmittedQP;
Ipp8s m_iLastXmittedQPy; // For the current slice.
// Counters for per slice coded macroblocks
Ipp32u m_MB_Counter;
Ipp32u m_Intra_MB_Counter;
// For INTRA/INTER MB type decision
Ipp32u m_uMBIntraSAD;
MB_Type m_InterMBType;
Ipp32u m_uMBInterSAD;
Ipp32u m_uInterCBP4x4;
Ipp32s m_InterMB8x8PackFlag;
Ipp32u m_uIntraCBP4x4;
Ipp32u m_iNumCoeffs4x4[16];
Ipp32u m_iLastCoeff4x4[16];
Ipp32u m_uIntraCBP8x8;
Ipp32u m_iNumCoeffs8x8[16];
Ipp32u m_iLastCoeff8x8[16];
// For keeping track of skipped MBs to write mb_skip_run
Ipp32u m_uSkipRun;
Ipp32s m_is_cur_mb_field;
bool m_is_cur_mb_bottom_field;
Ipp32s m_first_mb_in_slice;
Ipp8s m_slice_qp_delta; // delta between slice QP and picture QP
Ipp8u m_cabac_init_idc; // CABAC initialization table index (0..2)
bool m_use_transform_for_intra_decision;
H264MBAddr m_CurMBAddr;
H264MBAddr m_PairMBAddr;
Ipp32s m_CurMB_X, m_CurMB_Y;
Ipp32s m_prev_dquant;
H264CurrentMacroblockDescriptor<PixType, CoeffsType> m_cur_mb;
Macroblock<PixType, CoeffsType> m_neighbours[MB_ALL_NEIGHBOURS];
CH264pBs<PixType,CoeffsType> *m_pbitstream; // Where this slice is encoded to.
CH264pBsFake<PixType, CoeffsType>* fakeBitstream;
Ipp8u m_disable_deblocking_filter_idc; // deblock filter control, 0=filter all edges
Ipp8s m_slice_alpha_c0_offset; // deblock filter c0, alpha table offset
Ipp8s m_slice_beta_offset; // deblock filter beta table offset
Ipp32s *m_InitialOffset;
Ipp32s m_NumRefsInL0List;
Ipp32s m_NumRefsInL1List;
Ipp32s m_NumRefsInLTList;
Ipp8u num_ref_idx_active_override_flag; // nonzero: use ref_idx_active from slice header
Ipp32s num_ref_idx_l0_active; // num of ref pics in list 0 used to decode the slice,
Ipp32s num_ref_idx_l1_active; // num of ref pics in list 1 used to decode the slice
// Temporal buffers.
// MB work buffer, allocated buffer pointer for freeing
Ipp8u* m_pAllocatedMBEncodeBuffer;
// m_pAllocatedMBEncodeBuffer is mapped onto the following 4 pointers.
PixType* m_pPred4DirectB; // the 16x16 MB prediction for direct B mode
PixType* m_pPred4BiPred; // the 16x16 MB prediction for BiPredicted B Mode
PixType* m_pTempBuff4DirectB; // 16x16 working buffer for direct B
PixType* m_pTempBuff4BiPred; // 16x16 working buffer for BiPred B
PixType* m_pTempChromaPred; // 16x16 working buffer for chroma pred B
PixType* m_pMBEncodeBuffer; // temp work buffer
Ipp8u* m_pMEMap;
// Buffers for CABAC.
T_RLE_Data<CoeffsType> Block_RLE[51]; // [0-15] Luma, [16-31] Chroma U/Luma1, [32-47] Chroma V/Luma2, [48] Chroma U DC/Luma1 DC, [49] Chroma V DC/Luma2 DC, [50] Luma DC
T_Block_CABAC_Data<CoeffsType> Block_CABAC[51]; // [0-15] Luma, [16-31] Chroma U/Luma1, [32-47] Chroma V/Luma2, [48] Chroma U DC/Luma1 DC, [49] Chroma V DC/Luma2 DC, [50] Luma DC
EncoderRefPicList<PixType> m_TempRefPicList[2][2];
Ipp32s DistScaleFactor[MAX_NUM_REF_FRAMES];
Ipp32s DistScaleFactorMV[MAX_NUM_REF_FRAMES];
Ipp32s DistScaleFactorAFF[2][2][2][MAX_NUM_REF_FRAMES]; // [curmb field],[ref1field],[ref0field]
Ipp32s DistScaleFactorMVAFF[2][2][2][MAX_NUM_REF_FRAMES]; // [curmb field],[ref1field],[ref0field]
};
template <class PixType> class DeblockingParameters;
template <class PixType> class DeblockingParametersMBAFF;
template <class PixType, class CoeffsType> class H264CoreEncoder {
public:
H264CoreEncoder(Status& status);
~H264CoreEncoder();
public:
// Initialize codec with specified parameter(s)
Status Init(BaseCodecParams *init, MemoryAllocator *pMemAlloc);
// Compress (decompress) next frame
Status GetFrame(MediaData *in, MediaData *out);
// Get codec working (initialization) parameter(s)
Status GetInfo(BaseCodecParams *info);
// Close all codec resources
Status Close();
Status SetParams (BaseCodecParams* params);
VideoData* GetReconstructedFrame();
protected:
//f
Ipp32s m_Analyse;
Ipp32s profile_frequency;
H264LocalMacroblockDescriptor m_mbinfo;
public: // public for deblocking tool
Ipp32s m_HeightInMBs;
Ipp32s m_WidthInMBs;
protected:
MemoryAllocator* memAlloc;
Ipp8u *m_pParsedDataNew;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -