?? ratecontrol.h
字號:
#ifndef _RATECONTROL_H_
#define _RATECONTROL_H_
/*#include "../encoder.h" */
#include "../portab.h"
/*#include "stdio.h"*/
#include "rc_data.h"
#define MAX_SLIDING_WINDOW 20
/*
typedef struct
{
int64_t size;
int32_t count;
}
QuantInfo;
*/
typedef struct
{
int32_t rtn_quant;
int64_t frames;
int64_t total_size;
double framerate;
int32_t target_rate;
int16_t max_quant;
int16_t min_quant;
int64_t last_change;
int64_t quant_sum;
double quant_error[32];
double avg_framesize;
double target_framesize;
double sequence_quality;
int32_t averaging_period;
int32_t reaction_delay_factor;
int32_t buffer;
}
RateControl;
/*
Rs: bit rate for the sequence (or segment). e.g., 24000 bits/sec */
/* Rf: bits used for the first frame. e.g., 10000 bits */
/* Rc: bits used for the current frame. It is the bit count obtained after encoding.
Rp: bits to be removed from the buffer per picture.
Ts: number of seconds for the sequence (or segment). e.g., 10 sec */
/* Ec: mean absolute difference for the current frame after motion compensation.
If the macroblock is intra coded, the original spatial pixel values are summed.
Qc: quantisation level used for the current frame.
Nr: number of P frames remaining for encoding.
Ns: distance between encoded frames. e.g., 4 for 7.5 fps */
/* Rr: number of bits remaining for encoding this sequence (or segment).
T: target bit to be used for the current frame.
S: number of bits used for encoding the previous frame.
Hc: header and motion vector bits used in the current frame. It includes all the information except to the residual information.
Hp: header and motion vector bits used in the previous frame. It includes all the information except to the residual information.
Ql: quantisation level used in the previous frame
Bs; buffer size e.g., R/2
B; current buffer level e.g., R/4 - start from the middle of the buffer*/
typedef struct
{
BOOL IsFirst;/*是否為I,P,B的第一幀 */
int Rc; /*: bits used for the current frame. It is the bit count obtained after encoding. */
int Ec; /*: mean absolute difference for the current frame after motion compensation.
If the macroblock is intra coded, the original spatial pixel values are summed.*/
int Ep;/* 前一幀的平均絕對差,whq */
int S; /*: number of bits used for encoding the previous frame. */
int Hc; /*: header and motion vector bits used in the current frame. It includes all the information except to the residual information. */
int Hp; /*: header and motion vector bits used in the previous frame. It includes all the information except to the residual information. */
int Ql; /*: quantisation level used in the previous frame */
int QpArray[MAX_SLIDING_WINDOW];/*數組中存放以前的量化值,用滑動窗口控制值的個數*/
int Qc; /*: quantisation level used for the current frame. */
double X1; /*二階模型的一次項系數*/
double X2; /*二階模型的二次項系數*/
double X11; /*一階模型的系數*/
double RpArray[MAX_SLIDING_WINDOW];/*過去幀的復雜度度量 */
}RCQ2_DATA;
typedef struct{
int Rp; /*: bits to be removed from the buffer per picture. */
int Ts; /*: number of seconds for the sequence (or segment). e.g., 10 sec */
int Bs; /*; buffer size e.g., R/2 */
int B; /*; current buffer level e.g., R/4 - start from the middle of the buffer */
int Nr; /*: number of frames remaining for encoding. */
int N_Total;/* total number of coded frame in a gop */
int Ns; /*: distance between encoded frames. e.g., 4 for 7.5 fps */
int Rr; /*: number of bits remaining for encoding this sequence (or segment). */
int T; /*: target bit to be used for the current frame. */
int Rs; /*: bit rate for the sequence (or segment). e.g., 24000 bits/sec */
int Rf; /*: bits used for the first frame. e.g., 10000 bits */
int max_key_interval;/*最大關鍵幀間隔 */
double array_x[MAX_SLIDING_WINDOW][2];
double array_y[MAX_SLIDING_WINDOW];
double rc_error[MAX_SLIDING_WINDOW];
RCQ2_DATA data[2];
RCQ2_SAVE_QUEUE rc_queue[2];
}RCQ2;
/* new rate control */
int Get_Initial_Quant(RCQ2* rc,int frametype);/*得到初始量化值 */
int RC_GetQ(FILE *pfile,RCQ2* rc,int frametype,int mad);/*得到量化值 */
void RCInitialization(RCQ2* rc,int bitrate,int framerate,int sequence_time);/*初始化位率控制 */
void Target_Bit_Calculation(RCQ2* rc,int frametype);/*目標位率計算 */
void Quantisation_Calculation(FILE *pfile,RCQ2* rc,int frametype);/*計算量化值 */
void UpdateRDModel (RCQ2* rc,int frametype);/*更新二階率失真模型 */
void After_encoding_current( FILE *pfile,RCQ2* rc,int frametype,int length,int head_vector,int mad);/*編碼一幀后調用 */
void Estimator(RCQ2* rc,int frametype,int * w); /*int Qp, uint32_t Rp,int w,uint32_t b 再估計用于去掉壞點 */
void RemoveOutlier(RCQ2* rc,int frametype,double X1,double X2,int Qp[],double Rp[],double Ec,int * w);/*去掉壞點 */
BOOL IsSkipFrame(RCQ2* rc); /*判斷是否丟幀,new add */
/* old rate control */
void RateControlInit(RateControl * rate_control,
uint32_t target_rate,
uint32_t reaction_delay_factor,
uint32_t averaging_period,
uint32_t buffer,
int framerate,
int max_quant,
int min_quant);
int RateControlGetQ(RateControl * rate_control,
int keyframe);
void RateControlUpdate(RateControl * rate_control,
uint32_t quant,
int frame_size,
int keyframe);
static int get_initial_quant(int bpp);
#endif /* _RATECONTROL_H_ */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -