Date Modified Tags hevc

Pre

最近在做关于HEVC的的东西,现在使用的是x265,一个开源的编码项目。 本文只介绍一些我用到的,会逐渐补充。 最好的方式是查询官方的手册。也不是很长。 在阅读x265代码的时候要注意,它的代码和HM的代码有比较大的区别,很多算法实验也有非常精巧的方法。让我大开眼界,建议一定先搞懂算法原理,然后看一下HM里面的实现,再看x265的代码,一定要花时间磨。磨代码的过程很重要。

移植到Arm

~~## 补丁 解压出来,将CMakeLists.txt覆盖/x265/source/下的同名文件,将cpu.cpp覆盖/x265/source/common/下的同名文件,然后make, 注意备份。~~ 由于这两个文件在新版本中也会有改变,所以原来的补丁失效,请对照这个补丁的内容修改对应的文件

配置参数

搜索算法

x265的默认配置很快,自动检测可用线程数,使用的ME(Mostion Estimation)搜索算法是Hex,它一共提供了5种搜索算法:

--me Motion search method. Generally, the higher the number the harder the ME method will try to find an optimal match. Diamond search is the simplest. Hexagon search is a little better. Uneven Multi-Hexegon is an adaption of the search method used by x264 for slower presets. Star is a three step search adapted from the HM encoder: a star-pattern search followed by an optional radix scan followed by an optional star-search refinement. Full is an exhaustive search; an order of magnitude slower than all other searches but not much better than umh or star. + dia 菱形 + hex (default) 六边形 + umh 可变半径六边形搜索(非对称十字六边形网络搜索) + star 星型 + full 全搜索

full是全搜索,找到的是最佳匹配块,但是速度非常非常慢。 前几个搜索算法跟x264的标准一样。

指定编码多少帧

--frames <integer>

在为了获得测试数据的时候,不必把所有的帧都编码,

指定参考帧的个数

--ref <integer>

指定输出日志的内容级别

--csv-log-level <integer>

详细输出什么请查阅官方文档

指定search window的大小

默认正方形

--merange <integer>

PU划分模式

--rect, --no-rect

2NxN Nx2N的划分方式默认不开启,要设置为默认开启

--amp, --no-amp

asymmetric motion partitioning (AMP) 四种非对称的划分模式。根据rd有不同的策略,默认不开启

以上一共六种划分模式,加上2Nx2N和NxN两种,一共八种PU的划分模式。但是x265为了速度,在rd0-4以内,amp模式只对CU大小是32x32及以下的开启。

--rd <0..6>
Level Description
0 sa8d mode and split decisions, intra w/ source pixels
1 recon generated (better intra), RDO merge/skip selection
2 RDO splits and merge/skip selection
3 RDO mode and split decisions, chroma residual used for sa8d
4 Currently same as 3
5 Adds RDO prediction decisions
6 Currently same as 5

Level of RDO in mode decision.The higher the value, the more exhaustive the analysis and the more rate distortion optimization is used. The lower the value the faster the encode, the higher the value the smaller the bitstream (in general). Default 3 默认是3级别。

B帧

--b-adapt <integer>
Set the level of effort in determining B frame placement.

With b-adapt 0, the GOP structure is fixed based on the values of --keyint and --bframes.

With b-adapt 1 a light lookahead is used to choose B frame placement.

With b-adapt 2 (trellis) a viterbi B path selection is performed

Values: 0:none; 1:fast; 2:full(trellis) default

--bframes, -b <0..16>
Maximum number of consecutive b-frames. Use --bframes 0 to force all P/I low-latency encodes. Default 4. This parameter has a quadratic effect on the amount of memory allocated and the amount of work performed by the full trellis version of --b-adapt lookahead.

出于各种方面的考虑,我的实验不准备使用B 帧,需要禁用,则此处都设置为0即可。

Tips

自己的测试

修改代码,添加printf,最后可以添加

> LogOutput.txt

来指定输出到文件,这是linux的用法,非x265特有。

注意!!!x265的报告是追加到原报告文件的后面的,不是覆盖。

我的运行命令

./x265 --fps 30 --input-res 832x480 /home/ubuntu/RaceHorses_832x480_30.yuv -o outvideotest   --ref 4 --merange 96 --b-adapt 0 --bframes 0 --csv stat_horse_832x480_30_4_test --csv-log-level 2 --me 0 --frames 10 >stat_horse_832x480_30_4_test.txt

文章版权归 FindHao 所有丨本站默认采用CC-BY-NC-SA 4.0协议进行授权|
转载必须包含本声明,并以超链接形式注明作者 FindHao 和本文原始地址:
https://findhao.net/easycoding/1428.html

Comments