zyl910

优化技巧、硬件体系、图像处理、图形学、游戏编程、国际化与文本信息处理。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

x264预设类参数详解

 

  x264版本——

x264 core:116 r2074 2641b9e

 

  加上“fullhelp”参数可以查看x264的完全版帮助——

x264 --fullhelp

 

  其中对预设类参数的说明是—— 

Presets:

--profile <string> Force the limits of an H.264 profile
Overrides all settings.
- baseline:
--no-8x8dct --bframes 0 --no-cabac
--cqm flat --weightp 0
No interlaced.
No lossless.
- main:
--no-8x8dct --cqm flat
No lossless.
- high:
No lossless.
- high10:
No lossless.
Support for bit depth 8-10.
--preset <string> Use a preset to select encoding settings [medium]
Overridden by user settings.
- ultrafast:
--no-8x8dct --aq-mode 0 --b-adapt 0
--bframes 0 --no-cabac --no-deblock
--no-mbtree --me dia --no-mixed-refs
--partitions none --rc-lookahead 0 --ref 1
--scenecut 0 --subme 0 --trellis 0
--no-weightb --weightp 0
- superfast:
--no-mbtree --me dia --no-mixed-refs
--partitions i8x8,i4x4 --rc-lookahead 0
--ref 1 --subme 1 --trellis 0 --weightp 1
- veryfast:
--no-mixed-refs --rc-lookahead 10
--ref 1 --subme 2 --trellis 0 --weightp 1
- faster:
--no-mixed-refs --rc-lookahead 20
--ref 2 --subme 4 --weightp 1
- fast:
--rc-lookahead 30 --ref 2 --subme 6
--weightp 1
- medium:
Default settings apply.
- slow:
--b-adapt 2 --direct auto --me umh
--rc-lookahead 50 --ref 5 --subme 8
- slower:
--b-adapt 2 --direct auto --me umh
--partitions all --rc-lookahead 60
--ref 8 --subme 9 --trellis 2
- veryslow:
--b-adapt 2 --bframes 8 --direct auto
--me umh --merange 24 --partitions all
--ref 16 --subme 10 --trellis 2
--rc-lookahead 60
- placebo:
--bframes 16 --b-adapt 2 --direct auto
--slow-firstpass --no-fast-pskip
--me tesa --merange 24 --partitions all
--rc-lookahead 60 --ref 16 --subme 11
--trellis 2
--tune <string> Tune the settings for a particular type of source
or situation
Overridden by user settings.
Multiple tunings are separated by commas.
Only one psy tuning can be used at a time.
- film (psy tuning):
--deblock -1:-1 --psy-rd <unset>:0.15
- animation (psy tuning):
--bframes {+2} --deblock 1:1
--psy-rd 0.4:<unset> --aq-strength 0.6
--ref {Double if >1 else 1}
- grain (psy tuning):
--aq-strength 0.5 --no-dct-decimate
--deadzone-inter 6 --deadzone-intra 6
--deblock -2:-2 --ipratio 1.1
--pbratio 1.1 --psy-rd <unset>:0.25
--qcomp 0.8
- stillimage (psy tuning):
--aq-strength 1.2 --deblock -3:-3
--psy-rd 2.0:0.7
- psnr (psy tuning):
--aq-mode 0 --no-psy
- ssim (psy tuning):
--aq-mode 2 --no-psy
- fastdecode:
--no-cabac --no-deblock --no-weightb
--weightp 0
- zerolatency:
--bframes 0 --force-cfr --no-mbtree
--sync-lookahead 0 --sliced-threads
--rc-lookahead 0

 

  文字太多看起来有点晕,于是我整理为表格。

  

1 profile(档次)

 

 

name 名称 8x8dct cqm bframes cabac weightp interlaced
1 baseline 基线 no flat 0 no 0 no
2 main 主要 no flat 不限 不限 不限 不限
3 high 不限 不限 不限 不限 不限 不限
4 high10 高10位 不限 不限 不限 不限 不限 不限

bframes:在I帧与P帧之间可插入B帧数量(Number of B-frames)的最大值,范围0-16。

cqm:自订量化矩阵(custom quantization matrices)。默认有flat和JVT。

weightp:使x264能够使用明确加权预测(explicit weighted prediction)来改善P帧的压缩。亦改善淡入/淡出的品质。模式越高越慢。

8x8dct:弹性8x8离散余弦转换(Adaptive 8x8 DCT)。

cabac:弹性内容的二进制算数编码(CABAC:Context Adaptive Binary Arithmetic Coder)。

interlaced:隔行扫描。 

 

 

2 preset(预设)

 

 

name 名称 b-adapt bframes direct me merange partitions rc-lookahead ref subme trellis weightp other
1 ultrafast 极快 0 0   dia   none 0 1 0 0 0 no-8x8dct aq-mode0 no-cabac no-deblock no-mbtree no-mixed-refs scenecut0   no-weightb
2 superfast 超快       dia   i8x8,i4x4 0 1 1 0 1 no-mixed-refsno-mbtree
3 veryfast 很快             10 1 2 0 1 no-mixed-refs
4 faster 较快             20 2 4   1 no-mixed-refs
5 fast             30 2 6   1  
6 medium                        
7 slow 2   auto umh     50 5 8      
8 slower 较慢 2   auto umh   all 60 8 9 2    
9 veryslow 很慢 2 8 auto umh 24 all 60 16 10 2    
10 placebo   2 16 auto tesa 24 all 60 16 11 2   slow-firstpass no-fast-pskip

b-adapt:设定弹性B帧位置决策算法。此设定控制x264如何决定要放置P帧或B帧。

bframes:在I帧与P帧之间可插入B帧数量(Number of B-frames)的最大值,范围0-16。

direct:"direct"动态向量(motion vectors)的预测模式。有两种模式可用:spatial和temporal。可以指定none来停用direct动态向量,和指定auto来允许x264在两者之间切换为适合的模式。

me:全像素(full-pixel)运动估计(motion estimation)的算法。

merange:控制运动估计的最大范围(单位是像素)。对于hex和dia,范围限制在4~16。对于umh和esa,它可以增加到超过默认值16来允许范围更广的动态搜寻,对于HD视讯和高动态镜头很有用。注意,对于umh、esa和tesa,增加merange会大幅减慢编码速度。

partitions:H.264视讯在压缩过程中划分为16x16的宏区块。这些区块可以进一步划分为更小的分割,这就是此选项要控制的部分。

rc-lookahead:设定mb-tree位元率控制和vbv-lookahead使用的帧数。最大允许值是250。对于mb-tree部分,增加帧数带来更好的效果但也会更慢。mb-tree使用的最大缓冲值是MIN(rc-lookahead, --keyint)。

ref:控制解码图片缓冲(DPB:Decoded Picture Buffer)的大小。范围是从0到16。总之,此值是每个P帧可以使用先前多少帧作为参照帧的数目(B帧可以使用的数目要少一或两个,取决于它们是否作为参照帧)。可以被参照的最小ref数是1。

subme:设定子像素(subpixel)估算复杂度。值越高越好。层级1~5只是控制子像素细分(refinement)强度。层级6为模式决策启用RDO,而层级8为动态向量和内部预测模式启用RDO。RDO层级明显慢于先前的层级。

trellis:执行Trellis quantization来提高效率。

weightp:使x264能够使用明确加权预测(explicit weighted prediction)来改善P帧的压缩。亦改善淡入/淡出的品质。模式越高越慢。

no-8x8dct:停用弹性8x8离散余弦转换(Adaptive 8x8 DCT)。

aq-mode:弹性量化模式。没有AQ时,x264很容易分配不足的位元数到细节较少的部分。AQ是用来更好地分配视讯里所有宏区块之间的可用位元数。

no-cabac:停用弹性内容的二进制算数编码(CABAC:Context Adaptive Binary Arithmetic Coder)资料流压缩,切换回效率较低的弹性内容的可变长度编码(CAVLC:Context Adaptive Variable Length Coder)系统。大幅降低压缩效率(通常10~20%)和解码的硬件需求。

no-deblock:停用循环筛选(loop filter。亦称为持续循环去区块(inloop deblocker))。

no-mbtree:停用宏区块树(macroblock tree)位元率控制。使用宏区块树位元率控制会改善整体压缩率,借由追踪跨帧的时间传播(temporal propagation)并相应地加权。

no-mixed-refs:混合参照会以每个8x8分割为基础来选取参照,而不是以每个宏区块为基础。当使用多个参照帧时这会改善品质,虽然要损失一些速度。设定此选项会停用该功能。

scenecut:设定I/IDR帧位置的阈值(场景变更侦测)。

no-weightb:停用“加权”B帧的参照。

slow-firstpass:慢速pass。

no-fast-pskip:停用P帧的早期略过侦测(early skip detection)。非常轻微地提高品质,但要损失很多速度。

 

 

3 tune(调校)

 

 

name 名称 ref bframes deblock psy-rd aq-strength other
1 film 电影     -1:-1 <unset>:0.15    
2 animation 动画 {Double if >1 else 1} {+2} 1:1 0.4:<unset> 0.6  
3 grain 颗粒     -2:-2 <unset>:0.25 0.5 no-dct-decimate deadzone-inter6 deadzone-intra6 ipratio1.1 pbratio1.1   qcomp0.8
4 stillimage 静态图像     -3:-3 2.0:0.7 1.2  
5 psnr PSNR测试       no   aq-mode0
6 ssim SSIM测试       no   aq-mode2
7 fastdecode 快速解码     no     no-cabac no-weightb weightp0
8 zerolatency 零延迟   0       force-cfr no-mbtree sync-lookahead0 sliced-threads rc-lookahead0

ref:控制解码图片缓冲(DPB:Decoded Picture Buffer)的大小。范围是从0到16。总之,此值是每个P帧可以使用先前多少帧作为参照帧的数目(B帧可以使用的数目要少一或两个,取决于它们是否作为参照帧)。可以被参照的最小ref数是1。

bframes:在I帧与P帧之间可插入B帧数量(Number of B-frames)的最大值,范围0-16。

deblock:控制循环筛选(亦称为持续循环去区块(inloop deblocker))。

psy-rd:第一个数是Psy-RDO的强度(需要subme>=6)。第二个数是Psy-Trellis的强度(需要trellis>=1)。

aq-strength:弹性量化强度。设定AQ偏向低细节(平面)的宏区块之强度。不允许为负数。0.0~2.0以外的值不建议。

no-dct-decimate:停用DCT Decimation。DCT Decimation会舍弃它认为“不必要的”DCT区块。这会改善编码效率,而降低的品质通常微不足道。

deadzone-inter/intra:设定inter/intra亮度量化反应区(deadzone)的大小。反应区的范围应该在0~32。此值设定x264会任意舍弃而不尝试保留细微细节的层级。非常细微的细节既难以看见又耗费位元数,舍弃这些细节可以不用浪费位元数在视讯的此类低收益画面上。反应区与--trellis不相容。

ipratio:修改I帧量化值相比P帧量化值的目标平均增量。越大的值会提高I帧的品质。

pbratio:修改B帧量化值相比P帧量化值的目标平均减量。越大的值会降低B帧的品质。当mbtree启用时(默认启用),此设定无作用,mbtree会自动计算最佳值。

qcomp:量化值曲线压缩系数。0.0是固定位元率,1.0则是固定量化值。当mbtree启用时,它会影响mbtree的强度(qcomp越大,mbtree越弱)。

aq-mode:弹性量化模式。没有AQ时,x264很容易分配不足的位元数到细节较少的部分。AQ是用来更好地分配视讯里所有宏区块之间的可用位元数。

no-cabac:停用弹性内容的二进制算数编码(CABAC:Context Adaptive Binary Arithmetic Coder)资料流压缩,切换回效率较低的弹性内容的可变长度编码(CAVLC:Context Adaptive Variable Length Coder)系统。大幅降低压缩效率(通常10~20%)和解码的硬件需求。

weightp:使x264能够使用明确加权预测(explicit weighted prediction)来改善P帧的压缩。亦改善淡入/淡出的品质。模式越高越慢。

force-cfr:如果使用 ffms2 或 lavf 分离器,且输出文件不是 raw 格式,则从输入文件复制时间码。此选项关闭这个功能,并强制 x264 自己产生。当使用此选项时估计你也会设置 --fps。

no-mbtree:停用宏区块树(macroblock tree)位元率控制。使用宏区块树位元率控制会改善整体压缩率,借由追踪跨帧的时间传播(temporal propagation)并相应地加权。

sync-lookahead:设置用于线程预测的帧缓存大小。最大值是250。在第二遍及更多遍编码或基于分片线程时自动关闭。设为0将关闭线程预测,将减小延迟,但是以降低性能为代价。

sliced-threads:开启基于分片的线程。比默认方式质量低、效率低,但是没有编码延迟。

rc-lookahead:设定mb-tree位元率控制和vbv-lookahead使用的帧数。最大允许值是250。对于mb-tree部分,增加帧数带来更好的效果但也会更慢。mb-tree使用的最大缓冲值是MIN(rc-lookahead, --keyint)。

 

posted on 2011-12-04 11:57  zyl910  阅读(18226)  评论(0编辑  收藏  举报