typedef struct x264_param_t
{
/* CPU flags */
unsigned int cpu;
int i_threads; /* encode multiple frames in parallel //并行编码多帧 */
int b_deterministic; /* whether to allow non-deterministic optimizations when threaded //是否允许非确定性时线程优化*/
int i_sync_lookahead; /* threaded lookahead buffer //线程超前缓冲*/
/* Video Properties */
int i_width;
int i_height;
int i_csp; /* CSP of encoded bitstream, only i420 supported //csp比特流编码,只支持i420(即YUV标准格式4:2:0)*/
int i_level_idc;//编码复杂度
int i_frame_total; /* number of frames to encode if known, else 0 //如果已知则为需要编码的帧数,否则为0*/
struct /*Vui参数集视频可用性信息视频标准化选项 */
{
/* they will be reduced to be 0 < x <= 65535 and prime */
int i_sar_height;
int i_sar_width;/* 设置长宽比 */
int i_overscan; /* 0=undef, 1=no overscan, 2=overscan *//*过扫描线,默认"undef"(不设置),可选项:show(观看)/crop(去除)*/
/* see h264 annex E for the values of the following */
int i_vidformat;/* 视频格式,默认"undef",component/pal/ntsc/secam/mac/undef*/
int b_fullrange;//表示黑电平和亮度与色度信号的范围由E’Y, E’PB, 和E’PR 或 E’R, E’G, 和 E’B模拟信号分量得到。
int i_colorprim;//表示最初的原色的色度坐标
int i_transfer;//表示源图像的光电转换特性
int i_colmatrix;//描述用于根据红、绿、蓝三原色得到亮度和色度信号的矩阵系数
int i_chroma_loc; /* both top & bottom 等于1 表示hroma_sample_loc_type_top_field 和chroma_sample_loc_type_bottom_field 存在。
chroma_loc_info_present_flag 等于0 表示hroma_sample_loc_type_top_field 和chroma_sample_loc_type_bottom_field不存在。*/
} vui;
int i_fps_num;
int i_fps_den;/*这两个参数是由fps帧率确定的,赋值的过程见下:
{
float fps;
if( sscanf( value, "%d/%d", &p->i_fps_num, &p->i_fps_den ) == 2 )
;
else if( sscanf( value, "%f", &fps ) )
{
p->i_fps_num = (int)(fps * 1000 + .5);
p->i_fps_den = 1000;
}
else
b_error = 1;
}
Value的值就是fps。*/
/* Bitstream parameters */
int i_frame_reference; /* Maximum number of reference frames 参考帧最大数目*/
int i_keyint_max; /* Force an IDR keyframe at this interval 最大IDR关键帧间隔*/
int i_keyint_min; /* Scenecuts closer together than this are coded as I, not IDR. 场景切换少于次值编码位I,而不是IDR*/
int i_scenecut_threshold; /* how aggressively to insert extra I frames 如何积极的插入额外的I帧*/
int i_bframe; /* how many b-frame between 2 references pictures 两个相关图像间b帧数量*/
int i_bframe_adaptive;//自适应b帧判定
int i_bframe_bias;//控制插入b帧判定,范围-100~100,越高越容易插入b帧,默认为0
int b_bframe_pyramid; /* Keep some B-frames as references 允许部分b帧作为参考帧*/
//下面是去块滤波需要的参数
int b_deblocking_filter;
int i_deblocking_filter_alphac0; /* [-6, 6] -6 light filter, 6 strong */
int i_deblocking_filter_beta; /* [-6, 6] idem */
//熵编码
int b_cabac;
int i_cabac_init_idc;
int b_interlaced;//隔行扫描
int i_cqm_preset;
//自定义量化矩阵(CQM),初始化量化模式为flat
char *psz_cqm_file; /* JM format 读取jm格式的外部量化矩阵文件,自动忽略其他--cqm选项*/
uint8_t cqm_4iy[16]; /* used only if i_cqm_preset == X264_CQM_CUSTOM */
uint8_t cqm_4ic[16];
uint8_t cqm_4py[16];
uint8_t cqm_4pc[16];
uint8_t cqm_8iy[64];
uint8_t cqm_8py[64];
/* Log */
void (*pf_log)( void *, int i_level, const char *psz, va_list );
void *p_log_private;
int i_log_level;
int b_visualize;
char *psz_dump_yuv; /* filename for reconstructed frames */
/* Encoder analyser parameters 编码分析参数*/
struct
{
unsigned int intra; /* intra partitions 帧内分区*/
unsigned int inter; /* inter partitions 帧间分区*/
int b_transform_8x8;
int b_weighted_bipred; /* implicit weighting for B-frames 为B帧隐式加权*/
int i_direct_mv_pred; /* spatial vs temporal mv prediction 时间空间队列运动预测*/
int i_chroma_qp_offset;//色度量化步长偏移量
int i_me_method; /* motion estimation algorithm to use (X264_ME_*) 运动估计算法(X264_ME_*)*/
int i_me_range; /* integer pixel motion estimation search range (from predicted mv) 整像素运动估计范围*/
int i_mv_range; /* maximum length of a mv (in pixels). -1 = auto, based on level 运动矢量最大长度,-1为自动设置*/
int i_mv_range_thread; /* minimum space between threads. -1 = auto, based on number of threads. 线程之间最小空间*/
int i_subpel_refine; /* subpixel motion estimation quality 亚像素运动估计质量*/
int b_chroma_me; /* chroma ME for subpel and mode decision in P-frames 亚像素色度运动估计和P帧的模式选择*/
int b_mixed_references; /* allow each mb partition in P-frames to have it's own reference number 允许每个宏块的分区在P帧有它自己的参考号*/
int i_trellis; /* trellis RD quantization-- Trellis量化,对每个8x8的块寻找合适的量化值,需要CABAC,默认0 0:关闭1:只在最后编码时使用2:一直使用*/
int b_fast_pskip; /* early SKIP detection on P-frames 快速P帧跳过检测*/
int b_dct_decimate; /* transform coefficient thresholding on P-frames 在P帧转换参数域*/
int i_noise_reduction; /* adaptive pseudo-deadzone 自适应伪盲区*/
float f_psy_rd; /* Psy RD strength */
float f_psy_trellis; /* Psy trellis strength */
int b_psy; /* Toggle all psy optimizations */
/* the deadzone size that will be used in luma quantization */
/*,亮度量化中使用的无效区大小*/
int i_luma_deadzone[2]; /* {inter, intra} {帧间,帧内}*/
int b_psnr; /* compute and print PSNR stats 计算打印PSNR信息*/
int b_ssim; /* compute and print SSIM stats 计算打印SSIM信息*/
} analyse;
/* Rate control parameters 码率控制参数*/
struct
{
int i_rc_method; /* X264_RC_* */
int i_qp_constant; /* 0-51 */
int i_qp_min; /* min allowed QP value 允许最小量化值*/
int i_qp_max; /* max allowed QP value 允许最大量化值*/
int i_qp_step; /* max QP step between frames 帧间最大量化步长*/
int i_bitrate;
//平均码率
float f_rf_constant; /* 1pass VBR, nominal QP */
float f_rate_tolerance;
int i_vbv_max_bitrate;//平均码率模式下,最大瞬间码率,默认0(与-B设置相同)
int i_vbv_buffer_size;//码率控制缓冲区的大小,单位kbit,默认0
float f_vbv_buffer_init; /* <=1: fraction of buffer_size. >1: kbit 码率控制缓冲区数据保留的最大数据量与缓冲区大小之比,范围0~1.0,默认0.9*/
float f_ip_factor;
float f_pb_factor;
int i_aq_mode; /* psy adaptive QP. (X264_AQ_*) */
float f_aq_strength;
int b_mb_tree; /* Macroblock-tree ratecontrol. */
int i_lookahead;
/* 2pass */
int b_stat_write; /* Enable stat writing in psz_stat_out */
char *psz_stat_out;
int b_stat_read; /* Read stat from psz_stat_in and use it */
char *psz_stat_in;
/* 2pass params (same as ffmpeg ones) */
float f_qcompress; /* 0.0 => cbr, 1.0 => constant qp */
float f_qblur; /* temporally blur quants 时间上模糊量化*/
float f_complexity_blur; /* temporally blur complexity 时间上模糊复杂性*/
x264_zone_t *zones; /* ratecontrol overrides 码率控制覆盖*/
int i_zones; /* number of zone_t's --zones数量*/
char *psz_zones; /* alternate method of specifying zones 指定区的另一种方法*/
} rc;
/* Muxing parameters */
int b_aud; /* generate access unit delimiters 生成访问单元分隔符*/
int b_repeat_headers; /* put SPS/PPS before each keyframe 在每个关键帧前放置SPS/PPS*/
int b_annexb; /* if set, place start codes (4 bytes) before NAL units,
* otherwise place size (4 bytes) before NAL units. 如果设置了该项,则在每个NAL单元前加一个四字节的前缀符*/
int i_sps_id; /* SPS and PPS id number */
/* Slicing parameters */
int i_slice_max_size; /* Max size per slice in bytes; includes estimated NAL overhead. 每片字节最大数,包括预计的nal开销*/
int i_slice_max_mbs; /* Max number of MBs per slice; overrides i_slice_count. 每片宏块的最大数,重写i_slice_count*/
int i_slice_count; /* Number of slices per frame: forces rectangular slices. 每帧的像条数目:设置矩形像条*/
/* Optional callback for freeing this x264_param_t when it is done being used.
* Only used when the x264_param_t sits in memory for an indefinite period of time,
* i.e. when an x264_param_t is passed to x264_t in an x264_picture_t or in zones.
* Not used when x264_encoder_reconfig is called directly. */
void (*param_free)( void* );
} x264_param_t;