📄 umc_h264_video_encoder.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_VIDEO_ENCODER_H__
#define __UMC_H264_VIDEO_ENCODER_H__
#include "ippdefs.h"
#include "umc_video_data.h"
#include "umc_video_encoder.h"
#include "umc_h264_config.h"
namespace UMC_H264_ENCODER
{
enum EnumSliceType // Permitted MB Prediction Types
{ // ------------------------------------
PREDSLICE = 0, // I (Intra), P (Pred)
BPREDSLICE = 1, // I, P, B (BiPred)
INTRASLICE = 2, // I
S_PREDSLICE = 3, // SP (SPred), I
S_INTRASLICE = 4 // SI (SIntra), I
};
}
namespace UMC
{
typedef enum {
H264_BASE_PROFILE = 66,
H264_MAIN_PROFILE = 77,
H264_EXTENDED_PROFILE = 88,
H264_HIGH_PROFILE = 100,
H264_HIGH10_PROFILE = 110,
H264_HIGH422_PROFILE = 122,
H264_HIGH444_PROFILE = 144
} H264_PROFILE_IDC;
//
// Define formats for representing key frame control options.
//
// Key frames can be requested at regular intervals. Also, the target
// frame size for key frames can be specified, independently of the rate
// control for non-key frames.
//
typedef Ipp32s H264_Key_Frame_Control_Method;
// These methods control how often key frames are generated.
// Note that, regardless which of these methods is used, additional
// interfaces exist that allow a key frame to be requested on demand.
const H264_Key_Frame_Control_Method H264_KFCM_AUTO = 0;
// Let the encoder decide when to generate key frames.
// This method typically causes the least number of key frames to
// be generated.
const H264_Key_Frame_Control_Method H264_KFCM_INTERVAL = 1;
// Generate key frames at a regular interval
typedef enum {
H264_RCM_QUANT = 0,
H264_RCM_CBR = 1,
H264_RCM_VBR = 2,
H264_RCM_DEBUG = 3 // Fix quantizer values, no actual rate control.
} H264_Rate_Control_Method;
typedef struct {
H264_Rate_Control_Method method;
Ipp8s quantI;
Ipp8s quantP;
Ipp8s quantB;
} H264_Rate_Controls;
typedef struct {
H264_Key_Frame_Control_Method method;
Ipp32s interval;
Ipp32s idr_interval;
// 'interval' is meaningful only when method == H264_KFCM_INTERVAL.
// It specifies the frequency of key frames. A value of 1000,
// for example, means that a key frame should be generated
// approximately every 1000 frames. A value of 1 means that
// every frame should be a key frame.
// The interval must always be >= 1.
} H264_Key_Frame_Controls;
struct H264AdvRate_Options
{
Ipp32u max_qp;
Ipp32u min_qp;
Ipp32u max_dqp;
Ipp32u max_intra_qp;
Ipp32u queue_size;
Ipp64f min_fsize;
Ipp64f max_fsize;
Ipp64f i_frames_mult;
H264AdvRate_Options()
{
max_qp = 51;
min_qp = 0;
max_dqp = 2;
max_intra_qp = 37;
queue_size = 0;
max_fsize = 2.0;
i_frames_mult = 2.0;
min_fsize = 0.5;
}
H264AdvRate_Options& operator= (const H264AdvRate_Options& val)
{
max_qp=val.max_qp;
min_qp=val.min_qp;
max_dqp=val.max_dqp;
max_intra_qp=val.max_intra_qp;
queue_size=val.queue_size;
min_fsize=val.min_fsize;
max_fsize=val.max_fsize;
i_frames_mult=val.i_frames_mult;
return *this;
}
Ipp32s operator == (const H264AdvRate_Options &val) const
{
Ipp32s ret=0;
ret+=max_qp==val.max_qp;
ret+=min_qp==val.min_qp;
ret+=max_dqp==val.max_dqp;
ret+=max_intra_qp==val.max_intra_qp;
ret+=queue_size==val.queue_size;
ret+=min_fsize==val.min_fsize;
ret+=max_fsize==val.max_fsize;
ret+=i_frames_mult==val.i_frames_mult;
return !ret;
};
Ipp32s operator != (const H264AdvRate_Options &oprnd) const
{ return !(*this == oprnd); };
};
};
namespace UMC
{
class H264EncoderParams: public VideoEncoderParams
{
DYNAMIC_CAST_DECL(H264EncoderParams, VideoEncoderParams)
public:
H264EncoderParams();
virtual Status ReadParamFile(const vm_char *ParFileName);
Ipp32s chroma_format_idc;
H264AdvRate_Options arco;
Ipp32s coding_type; // 0 - only FRM, 1 - only FLD , 2 - only AFRM, 3 - pure PicAFF(no MBAFF) 4 PicAFF + MBAFF
Ipp32s B_frame_rate;
Ipp32s treat_B_as_reference;
Ipp32s num_ref_frames;
Ipp32s num_ref_to_start_code_B_slice;
Ipp8s level_idc;
H264_Rate_Controls rate_controls;
Ipp16s num_slices; // Number of slices
Ipp8s m_do_weak_forced_key_frames;
// This flag is set when an application "overrides" a
// B frame in the profile at the current TR for all layers.
// The following reserved members are place holders that allow us
// to add new options, without changing the size of this structure.
// They are intended to be used after a release, so that adding
// new options does not affect the size of our persistent data.
Ipp8s deblocking_filter_idc;
// This indicates that even though annex J may be
// on, the deblocking filter should not be called.
// This means that motion vectors off the edge
// are still on, as are 8x8 motion vectors.
// This is a non-standard option and only
// used in RealVideo. When this option is set
// to true the DFP bit in the RealVideo slice
// header is set to 1, otherwise, this bit will
// be set to 0. If Annex J is turned off, this
// option will be ignored. The decoder will also
// ignore the bit, if Annex J is off.
// These values control the deblocking filter strength
// the valid range for both is +\- 12, must be even numbers,
// since a value divided by 2 is coded into an output stream.
Ipp32s deblocking_filter_alpha;
Ipp32s deblocking_filter_beta;
Ipp32s mv_search_method;
Ipp32s me_split_mode; // 0 - 16x16 only; 1 - 16x16, 16x8, 8x16, 8x8; 2 - could split 8x8.
Ipp32s me_use_subpixel_search; // do not used now
Ipp32s me_search_x;
Ipp32s me_search_y;
Ipp32s use_weighted_pred;
Ipp32s use_weighted_bipred;
Ipp32s use_implicit_weighted_bipred;
// Determines whether weighted interpolation is used to form bi-predictions
Ipp8s direct_pred_mode; // 1 - spatial, 0 - temporal
Ipp32s use_direct_inference;
Ipp8s entropy_coding_mode; // 0 - CAVLC, 1 - CABAC
Ipp8s cabac_init_idc; // [0..2] used for CABAC
Ipp8s write_access_unit_delimiters; // 1 - write, 0 - do not
H264_Key_Frame_Controls key_frame_controls;
// Specifies key frame controls options for this layer.
// The following reserved members are place holders that allow us
// to add new options, without changing the size of this structure.
// They are intended to be used after a release, so that adding
// new options does not affect the size of our persistent data.
bool use_transform_for_intra_decision;
public:
H264_PROFILE_IDC profile_idc; // profile_idc
bool transform_8x8_mode_flag;
Ipp32s qpprime_y_zero_transform_bypass_flag;
Ipp32s use_default_scaling_matrix;
Ipp32s aux_format_idc;
bool alpha_incr_flag;
Ipp32s alpha_opaque_value;
Ipp32s alpha_transparent_value;
Ipp32s bit_depth_aux;
Ipp32s bit_depth_luma;
Ipp32s bit_depth_chroma;
Ipp32s numFramesToEncode;
Ipp32s m_QualitySpeed;
//Additional parameters
#if defined H264_LOG
bool m_log;
vm_char m_log_file[254];
#endif
};
} // namespace UMC
namespace UMC_H264_ENCODER {
template <class PixType, class CoeffsType> class H264CoreEncoder;
}
using namespace UMC_H264_ENCODER;
namespace UMC {
typedef enum {
H264_VIDEO_ENCODER_8U_16S = 0,
H264_VIDEO_ENCODER_16U_32S = 1,
H264_VIDEO_ENCODER_NONE = 2
} EncoderType;
class H264VideoEncoder : public VideoEncoder
{
public:
H264VideoEncoder();
~H264VideoEncoder();
public:
// Initialize codec with specified parameter(s)
virtual Status Init(BaseCodecParams *init);
// Compress (decompress) next frame
virtual Status GetFrame(MediaData *in, MediaData *out);
// Get codec working (initialization) parameter(s)
virtual Status GetInfo(BaseCodecParams *info);
// Close all codec resources
virtual Status Close();
virtual Status Reset() { return UMC_ERR_UNSUPPORTED; };
virtual Status SetParams(BaseCodecParams* params);
VideoData* GetReconstructedFrame();
protected:
EncoderType m_CurrEncoderType; // Type of the encoder applicable now.
H264CoreEncoder<Ipp8u, Ipp16s> *m_pEncoder_8u_16s; // For 8 bit video.
#if defined BITDEPTH_9_12
H264CoreEncoder<Ipp16u, Ipp32s> *m_pEncoder_16u_32s; // For 9-12 bit video.
#endif // BITDEPTH_9_12
};
} // namespace UMC
#endif // __UMC_H264_VIDEO_ENCODER_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -