介绍
- x265是符合 HEVC 编码标准的开源编码器;
- 可执行文件下–fullhelp 可查看全部编码参数及其解释:x265 --fullhelp。
- git仓库:https://bitbucket.org/multicoreware/x265_git.git
- x265_param_default(x265_param* param)函数内全部参数的赋值和使用;
参数详细解析
/* ----Applying default values to all elements in the param structure 将默认值应用于参数结构中的所有元素----*/
-
cpuid
x265_param_default() will auto-detect this cpu capability bitmap. it is recommended to not change this value unless you know the cpu detection is somehow flawed on your target hardware. The asm function tables are process global, the first encoder configures them for all encoders.//不推荐改变该值,可实现自动检测 cpu 能力位图param->cpuid = X265_NS::cpu_detect(false);
命令行:cpuid
-
bEnableWavefront
Enable wavefront parallel processing, greatly increases parallelism for less than 1% compression efficiency loss. Requires a thread pool, enabled by default.//wpp 技术,提高并行性,压缩效率损失小于 1%,需要线程池,默认开启波前并行技术,hevc 的并行处理技术之一;
param->bEnableWavefront = 1;
命令行:wpp
-
frameNumThreads
Number of concurrently encoded frames between 1 and X265_MAX_FRAME_THREADS or 0 for auto-detection. By default x265 will use a number of frame threads empirically determined to be optimal for your CPU core count, between 2 and 6. Using more than one frame thread causes motion search in the down direction to be clamped but otherwise encode behavior is unaffected. With CQP rate control the output bitstream is deterministic for all values of frameNumThreads greater than 1. All other forms of rate-control can be negatively impacted by increases to the number of frame threads because the extra concurrency adds uncertainty to the bitrate estimations. Frame parallelism is generally limited by the the is generally limited by the the number of CU rows When thread pools are used, each frame thread is assigned to a single pool and the frame thread itself is given the node affinity of its pool. But when no thread pools are used no node affinity is assigned.//在 1 和X265_MAX_FRAME_THREADS之间并行编码的帧数,自动检测时设置为0,一般选择 2-6 比较合适,CQP 时比特流不受帧线程数影响,其他码率控制受到一定的负面影响param->frameNumThreads = 0; //默认
tune:zerolatency模式下param->frameNumThreads = 1;
命令行:frame-threads
-
logLevel
The level of logging detail emitted by the encoder. X265_LOG_NONE to X265_LOG_FULL, default is X265_LOG_INFO//编码器发出的详细日志信息级别,默认 INFO 级别param->logLevel = X265_LOG_INFO;//默认
命令行:log-level/log
-
csvLogLevel
Level of csv logging. 0 is summary, 1 is frame level logging, 2 is frame level logging with performance statistics//cvs 日志级别,0 是摘要,1 是帧级别,2 是带有性能统计的帧级别param->csvLogLevel = 0;
命令行:csv-log-level
-
csvfn
filename of CSV log. If csvLogLevel is non-zero, the encoder will emit per-slice statistics to this log file in encode order. Otherwise the encoder will emit per-stream statistics into the log file when x265_encoder_log is called (presumably at the end of the encode)//cvs 日志文件名,依靠csvLogLevel的值或x265_encoder_log函数是否被调用param->csvfn = NULL;
命令行 :csv
-
lambdaFileName
specify a text file which contains MAX_MAX_QP + 1 floating point values to be copied into x265_lambda_tab and a second set of MAX_MAX_QP + 1 floating point values for x265_lambda2_tab. All values are separated by comma, space or newline. Text after a hash (#) is ignored. The lambda tables are process-global, so these new lambda values will affect all encoders in the same process.//指定文本文件,主要关于lambda的存储,属于码率控制模块的参数param->rc.lambdaFileName = NUL;
命令行:lambda-file
-
bLogCuStats(已弃用)
Enable analysis and logging distribution of CUs. Now deprecated.//CU 的分析和日志分发,已经弃用param->bLogCuStats = 0;
命令行:cu-stats
-
decodedPictureHashSEI
Enable the generation of SEI messages for each encoded frame containing the hashes of the three reconstructed picture planes. Most decoders will validate those hashes against the reconstructed images it generates and report any mismatches. This is essentially a debugging feature. Hash types are MD5(1), CRC(2), Checksum(3). Default is 0, none//产生包含哈希的SEI 信息,解码器会根据这些哈希验证重建图并报告错误,本质是 debug 特点,哈希类型有: MD5(1)、CRC(2)、Chechsum(3),默认是0,不产生哈希SEIparam->decodedPictureHashSEI = 0;
命令行:hash
/* ------------------Quality Measurement Metrics 质量评价度量------------------------*/
-
bEnablePsnr
Enable the measurement and reporting of PSNR. Default is enabled //计算并打印 PSNR,默认是关闭(代码备注写打开,写错了)param->bEnablePsnr = 0;
命令行:psnr
-
bEnableSsim
Enable the measurement and reporting of SSIM. Default is disabled //计算并打印 SSIM,默认关闭param->bEnableSsim = 0;
命令行:ssim
/* ------------Source specifications 源规范--------------------------*/
-
internalBitDepth
Internal encoder bit depth. If x265 was compiled to use 8bit pixels (HIGH_BIT_DEPTH=0), this field must be 8, else this field must be 10. Future builds may support 12bit pixels. //内部编码器位深度,如果 x265 被编译使用 8bit,该字段必须为 8,否则为 10,未来会支持 12bit 像素param->internalBitDepth = X265_DEPTH;
命令行:bitdepth
-
sourceBitDepth
Input sequence bit depth. It can be either 8bit, 10bit or 12bit.//输入序列位深度,可以是 8bit、10bit、12bitparam->sourceBitDepth = 8;
-
internalCsp
Color space of internal pictures, must match color space of input pictures. //内部图像的颜色空间,必须匹配输入图像的颜色空间param->internalCsp = X265_CSP_I420;
命令行:input-csp
-
levelIdc(水平 level)
Minimum decoder requirement level. Defaults to 0, which implies auto-detection by the encoder. If specified, the encoder will attempt to bring the encode specifications within that specified level. If the encoder is unable to reach the level it issues a warning and emits the actual decoder requirement. If the requested requirement level is higher than the actual level, the actual requirement level is signaled. The value is an specified as an integer with the level times 10, for example level “5.1” is specified as 51, and level “5.0” is specified as 50.//最小解码器要求级别,默认 0,表示由编码器自动检测;该值以整数形式指定水平(Level) 指出了一些对解码端负载和内存占用影响较大的关键参数的约束,这些参数主要包括有:采样频率、分辨率、码率的最大值,压缩率的最小值、解码图形缓冲区(DPB)的容量、编码图像缓冲区(CPB)的容量;水平中还约束了每帧中垂直和水平方向的tile的最大数量,以及每秒最大的tile数量。
HEVC共有13个水平:1, 2, 2.1, 3,3.1, 4, 4.1, 5, 5.1, 5.2, 6,6.1, 6.2。
param->levelIdc = 0; //Auto-detect level
命令行:level-idc