📄 ratecontrol.h
字号:
/***************************************************************************** * ratecontrol.h: h264 encoder library (Rate Control) ***************************************************************************** * Copyright (C) 2003 Laurent Aimar * $Id: ratecontrol.h,v 1.1 2004/06/03 19:27:08 fenrir Exp $ * * Authors: Laurent Aimar <fenrir@via.ecp.fr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. *****************************************************************************/#ifndef _RATECONTROL_H#define _RATECONTROL_H 1
#include "stdio.h"
typedef struct
{
int pict_type;
int kept_as_ref;
float qscale;
int mv_bits;
int i_tex_bits;
int p_tex_bits;
int misc_bits;
uint64_t expected_bits;
float new_qscale;
int new_qp;
int i_count;
int p_count;
int s_count;
float blurred_complexity;
char direct_mode;
} ratecontrol_entry_t;
typedef struct
{
double coeff;
double count;
double decay;
} predictor_t;
typedef struct
{
/* constants */
int b_abr;
int b_2pass;
int b_vbv;
double fps;
double bitrate;
double rate_tolerance;
int nmb; /* number of macroblocks in a frame */
int qp_constant[5];
/* current frame */
ratecontrol_entry_t *rce;
int qp; /* qp for current frame */
int qpm; /* qp for current macroblock */
float qpa; /* average of macroblocks' qp */
int slice_type;
int qp_force;
/* VBV stuff */
double buffer_size;
double buffer_fill;
double buffer_rate; /* # of bits added to buffer_fill after each frame */
predictor_t pred[5]; /* predict frame size from satd */
/* ABR stuff */
int last_satd;
double last_rceq;
double cplxr_sum; /* sum of bits*qscale/rceq */
double expected_bits_sum; /* sum of qscale2bits after rceq, ratefactor, and overflow */
double wanted_bits_window; /* target bitrate * window */
double cbr_decay;
double short_term_cplxsum;
double short_term_cplxcount;
double rate_factor_constant;
double ip_offset;
double pb_offset;
/* 2pass stuff */
FILE *p_stat_file_out;
char *psz_stat_file_tmpname;
int num_entries; /* number of ratecontrol_entry_ts */
ratecontrol_entry_t *entry; /* FIXME: copy needed data and free this once init is done */
double last_qscale;
double last_qscale_for[5]; /* last qscale for a specific pict type, used for max_diff & ipb factor stuff */
int last_non_b_pict_type;
double accum_p_qp; /* for determining I-frame quant */
double accum_p_norm;
double last_accum_p_norm;
double lmin[5]; /* min qscale by frame type */
double lmax[5];
double lstep; /* max change (multiply) in qscale per frame */
double i_cplx_sum[5]; /* estimated total texture bits in intra MBs at qscale=1 */
double p_cplx_sum[5];
double mv_bits_sum[5];
int frame_count[5]; /* number of frames of each type */
/* MBRC stuff */
double frame_size_planned;
int first_row, last_row; /* region of the frame to be encoded by this thread */
predictor_t *row_pred;
predictor_t row_preds[5];
predictor_t pred_b_from_p; /* predict B-frame size from P-frame satd */
int bframes; /* # consecutive B-frames before this P-frame */
int bframe_bits; /* total cost of those frames */
int i_zones;
x264_zone_t *zones;
}x264_ratecontrol_t;int x264_ratecontrol_new ( x264_t * );void x264_ratecontrol_delete( x264_t * );void x264_ratecontrol_start( x264_t *, int i_slice_type, int i_force_qp );void x264_ratecontrol_threads_start( x264_t * );int x264_ratecontrol_slice_type( x264_t *, int i_frame );void x264_ratecontrol_mb( x264_t *, int bits );int x264_ratecontrol_qp( x264_t * );void x264_ratecontrol_end( x264_t *, int bits );void x264_ratecontrol_summary( x264_t * );#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -