x264_param_t结构体是x264库中一个非常重要的结构体,用于存储x264编码器的大多数设置参数。以下是对x264_param_t结构体中每个成员变量的注释:
/**
* 颜色空间类型:
* X264_CSP_I420: planar 4 2 0 YUV
* X264_CSP_BGRA: packed 4 4 4 RGB
* X264_CSP_RGB: packed 8 8 8 RGB
* X264_CSP_YUYV: packed 4 2 2 YUV
* X264_CSP_NV12: semi-planar 4 2 0 YUV
*/
enum x264_csp i_csp;
/**
* 编码后输出帧的宽度和高度
* 最小值为16,所有值必须是2的倍数
*/
int i_width, i_height;
/**
* 关键帧间隔,单位为帧
* keyint是指此参数为0时的默认值
* i_scenecut_threshold是指如果当前帧的QP超过了上一帧的QP加上此值就认为需要一帧新的关键帧
*/
int i_keyint_max, i_keyint_min, i_keyint, keyint, i_scenecut_threshold;
/**
* QP的范围,QP的范围是[0,51],几乎所有的情况都不需要设置这个参数
*/
int i_qp_min, i_qp_max, i_qp;
/**
* Profile和level,codecId根据选定的Profile和level自动设置
* 如果i_profile参数为FF_PROFILE_UNKNOWN,x264会根据其他参数自动推导Profile
* 如果i_level参数为[0,51],则x264会根据其他参数自动推导level
* 如果是0,则表示使用默认值
*/
int i_profile, i_level, b_annexb, i_log_level, b_vfr_input;
/**
* GOP size (frame distance between intra frames)
* o deprecated, use i_keyint instead
* o minor issue: no long term reference check for >60/3 >30/2
*/
int i_gop_size;
/**
* force max QP for sub-8x8 blocks to this value
* note: this artificially inflates PSNR and is only useful for debugging
*/
int b_subme_zero;
/**
* b-adapt parameter, determines when b-frames are used
* b_adapt=0 只使用B帧作为参考
* b_adapt=1 根据场景自动选择使用多少B帧
* b_adapt=2 全部使用B帧
* 如果b_adapt=3,则B帧会随着帧数的增加而增加
*/
int i_bframe, b_bframe_adaptive, b_bframe_bidir, b_open_gop;
/**
* Rate control parameters
* i_rc_method = X264_RC_CQP(恒定码率控制,用于调试),X264_RC_CRF(常量失真控制),X264_RC_ABR(平均码率控制)
*
* 以下一些个参数选择对于rate control是非常重要的:
* i_bitrate 对于恒定(固定)码率控制时必须设置
* i_qp_min 是限制QP最小的值,剩下的最相关的参数就是:
* qp_step, qp_step_min来控制调整QP的逐渐精细
*/
int i_bitrate, i_rc_method;
/**
* qp for P-frames; value depends on i_rc_method
* o forced_qp = X264_QP_AUTO indicates rate control should set this automatically
*/
int i_qp_p, i_qp_b;
/**
* Constant rate factor
* same quantizer scale as x264_qscale when using CRF
* CRF is not recommended for streaming or selecting fixed-size output
* video quality scale: CRF values roughly 15-30 will likely generate "transparent"
* results with an adequate bitrate. Lower values will result in smaller files of
* lower quality while still taking more time to compress, while higher values
* will be larger, of lesser quality, and compress more quickly.
*/
float f_rf_constant, f_rf_constant_max, f_rf_constant_min;
/**
* 查找区域,即在该区域内对比度小于阈值的相邻两个宏块之间自动插入一个帧内预测的Coded Block Pattern (CBP)
* 值为0表示禁用自适应查找区域
*/
int i_lookahead_threads, i_lookahead_downsample, i_overscan, b_intra_refresh, i_lookahead;
/**
* 最大延时帧数,通过调用x264_encoder_delayed_frames() 返回当前缓冲区未编码帧的数量
* 如果max_delay==0,x264会自动设置值
*/
int i_frame_reference, i_dpb_size, i_slice_max_size, i_sps_id;
/**
* 分块的大小,最小为4,最大为16,不需要修改
*/
int i_mb_width, i_mb_height;
/**
* 分辨率调整参数
*/
int i_pad_x, i_pad_y, i_frame_total, i_vfr_duration;
/**
* 新增加的参数
*/
int b_repeat_headers, b_aud, b_unregistered, b_deterministic, b_sliced_threads;
/**
* uint16_t array of size chroma_format_idc, 8<=chroma_format_idc<=16 with number of subpixels per pixel
* initialized by calling x264_build_chroma_qp_table after
* x264_picture_alloc has been called
*/
uint16_t *i_chroma_qp_offset;
/**
* scalar quantization matrix arrays, for 8x8/4x4 intra prediction
* no quantization: NULL
* per-frame quantization: memset(i_quant_chroma, i_quant_luma, sizeof(i_quant_chroma))
* x264 default quantizers: defaults->i_quant_chroma and defaults->i_quant_luma
*/
uint16_t *i_quant_luma, *i_quant_chroma, *i_qpplus1_delta_depth;
/**
* 以下参数一般不需要修改
* */
int b_deblocking_filter, b_transform_8x8, b_cabac, i_sync_lookahead,
i_width_pad, i_height_pad, b_interlaced, b_constrained_intra, i_level_idc,
i_cqm_preset;
x264_custom_cqm_t custom_cqm[2];
char error_msg[80];
int internal_flags, b_frames;
/**
* 新增加的参数
*/
char *psz_o, *psz_preset, *psz_tune, *psz_filter, *psz_stat, *psz_log,
*psz_keyint, *psz_min_keyint, *psz_scenecut, *psz_bframes, *psz_bref_mode,
*psz_b_adapt, *psz_weightb_mode, *psz_8x8dct_mode, *psz_aq_mode, *psz_aq_strength,
*psz_dct_decimate, *psz_deadzone_inter, *psz_deadzone_intra, *psz_deblock_alpha,
*psz_deblock_beta, *psz_mixed_references, *psz_chroma_me, *psz_partitions,
*psz_direct_mv_pred, *psz_weighted_prediction, *psz_weighted_biprediction,
*psz_slices, *psz_slice_max_size, *psz_interlaced_mode, *psz_low_latency,
*psz_qp, *psz_qp_step, *psz_qpmin, *psz_qpmax, *psz_qp_init, *psz_qdiff,
*psz_qp_factor, *psz_ip_factor, *psz_pb_factor, *psz_keyint_min, *psz_align_opt,
*psz_h264_profile, *psz_h264_level, *psz_vui, *psz_nal_hrd, *psz_force_nal_hrd,
*psz_pic_struct, *psz_dbr_level, *psz_vbv_bufsize, *psz_vbv_maxrate,
*psz_quant_mat, *psz_me_method, *psz_subq, *psz_bframe_bias, *psz_movie,
*psz_pulldown, *psz_index;
/**
* convert 4:4:4 to 4:2:2 or 4:2:0 before encoding (Quantization must also be changed accordingly)
* i_ch