搜索 社区服务 统计排行 帮助
  • 1970阅读
  • 2回复

[请教]deadzone这个参数应该怎么用才好?

楼层直达
级别: 风云使者
注册时间:
2004-01-20
在线时间:
633小时
发帖:
549
之前因为看到deadzone在trellis=2下无用就没去研究deadzone了,不过在doom9上被别人指正后,实测发现deadzone还是能在trellis=2下有效的

引用
x264 [info]: cabac=1 ref=2 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=6 psy=0 mixed_ref=1 me_range=16 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 fgo=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 keyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=30 rc=2pass mbtree=1 bitrate=600 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 cplxblur=20.0 qblur=0.5 ip_ratio=1.40 aq=1:0.50
x264 [info]: started at Sat May 07 10:38:46 2011
x264 [info]: frame I:12    Avg QP:22.13  size: 14813  PSNR Mean Y:48.51 U:49.64 V:49.36 Avg:48.75 Global:46.90
x264 [info]: frame P:338   Avg QP:24.02  size:  5607  PSNR Mean Y:44.37 U:47.01 V:46.58 Avg:44.98 Global:44.49
x264 [info]: frame B:483   Avg QP:27.61  size:  1093  PSNR Mean Y:43.55 U:46.94 V:46.39 Avg:44.34 Global:44.22
x264 [info]: consecutive B-frames: 18.8% 10.6%  2.9% 67.7%
x264 [info]: mb I  I16..4: 42.9% 41.6% 15.5%
x264 [info]: mb P  I16..4: 12.9%  9.8%  2.0%  P16..4: 38.9% 11.9%  3.1%  0.0%  0.0%    skip:21.3%
x264 [info]: mb B  I16..4:  0.7%  1.1%  0.2%  B16..8: 23.7%  3.5%  0.3%  direct: 4.7%  skip:65.8%  L0:38.6% L1:50.2% BI:11.2%
x264 [info]: 8x8 transform intra:41.3% inter:63.2%
x264 [info]: coded y,uvDC,uvAC intra: 30.0% 54.5% 12.5% inter: 10.6% 16.6% 1.0%
x264 [info]: i16 v,h,dc,p: 42% 28% 13% 18%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 17% 29%  5%  6%  7%  5%  6%  6%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 20% 23%  5%  9%  7%  8%  6%  5%
x264 [info]: i8c dc,h,v,p: 46% 25% 21%  8%
x264 [info]: Weighted P-Frames: Y:17.8% UV:12.7%
x264 [info]: ref P L0: 70.8% 29.2%
x264 [info]: ref B L0: 82.1% 17.9%
x264 [info]: ref B L1: 96.3%  3.7%
x264 [info]: SSIM Mean Y:0.9897636 (19.899db)
x264 [info]: PSNR Mean Y:43.956 U:47.007 V:46.508 Avg:44.664 Global:44.361 kb/s:598.81
x264 [info]: encoded 833 frames, 22.23 fps, 598.81 kb/s


x264 [info]: cabac=1 ref=2 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=6 psy=0 mixed_ref=1 me_range=16 chroma_me=1 trellis=2 8x8dct=1 cqm=0 deadzone=6,4 fast_pskip=1 chroma_qp_offset=0 threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 fgo=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 keyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=30 rc=2pass mbtree=1 bitrate=600 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 cplxblur=20.0 qblur=0.5 ip_ratio=1.40 aq=1:0.50
x264 [info]: started at Sat May 07 10:39:38 2011
x264 [info]: frame I:12    Avg QP:22.18  size: 14734  PSNR Mean Y:48.49 U:49.62 V:49.31 Avg:48.72 Global:46.86
x264 [info]: frame P:338   Avg QP:24.08  size:  5591  PSNR Mean Y:44.38 U:47.00 V:46.57 Avg:44.98 Global:44.49
x264 [info]: frame B:483   Avg QP:27.73  size:  1112  PSNR Mean Y:43.67 U:46.93 V:46.37 Avg:44.43 Global:44.30
x264 [info]: consecutive B-frames: 18.8% 10.6%  2.9% 67.7%
x264 [info]: mb I  I16..4: 43.3% 41.5% 15.3%
x264 [info]: mb P  I16..4: 13.2%  9.7%  2.0%  P16..4: 40.8% 11.9%  3.3%  0.0%  0.0%    skip:19.2%
x264 [info]: mb B  I16..4:  0.6%  1.1%  0.2%  B16..8: 24.7%  3.6%  0.3%  direct: 5.1%  skip:64.4%  L0:38.4% L1:50.1% BI:11.6%
x264 [info]: 8x8 transform intra:40.8% inter:63.7%
x264 [info]: coded y,uvDC,uvAC intra: 29.9% 54.3% 12.4% inter: 10.8% 16.7% 1.0%
x264 [info]: i16 v,h,dc,p: 42% 28% 13% 17%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 17% 29%  5%  6%  7%  5%  7%  6%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 20% 23%  5%  9%  7%  8%  6%  5%
x264 [info]: i8c dc,h,v,p: 46% 25% 21%  8%
x264 [info]: Weighted P-Frames: Y:17.8% UV:12.7%
x264 [info]: ref P L0: 70.7% 29.3%
x264 [info]: ref B L0: 82.2% 17.8%
x264 [info]: ref B L1: 96.4%  3.6%
x264 [info]: SSIM Mean Y:0.9898141 (19.920db)
x264 [info]: PSNR Mean Y:44.027 U:46.995 V:46.490 Avg:44.715 Global:44.407 kb/s:599.55
x264 [info]: encoded 833 frames, 21.96 fps, 599.55 kb/s

所以也许只是 higher trellis <-> weaker deadzone 的关系
发这个帖子是想知道deadzone的意义,从而想知道在特定需求/特定类型视频应该如何设置更好。。
fullhelp和mewiki上的说明我看得不怎么清楚,觉得还是请教一下比较好

求资源,欢迎PM告知:
Xbox360 Clannad OP原版(WMV格式)
PS3 圣恩传说F / Tales of Graces F OP原版(BIK格式)


CLANNAD游戏OP/ED + TOMOYO after OP 无二次Credits内嵌字幕清晰版
BiliBili站点     AcFun站点

--- Direct264 自编译版 ---

碧之轨迹Nightmare VS风之剑圣 第1战(均无水印):6cn(六间房)   56(我乐)
BGM: Inevitable Struggle (Super Arrange Ver.)

Rockman 9 Rock Medley
级别: 圣骑士
注册时间:
2006-08-17
在线时间:
146小时
发帖:
215
只看该作者 1楼 发表于: 2011-05-07
看来是俺理解错了“deadzone and trellis are incompatible”这句话

查了下,doom9上有x264主力开发者之一Loren Merritt对这个问题的说明
http://forum.doom9.org/showthread.php?t=128669

引用
There are two different quantization algorithms: deadzone and trellis. Any given dct of a given block can only use one of them. Because, well, if you had two different values for each coefficient, what would you do with them?
--deadzone-inter and --deadzone-intra tweak a parameter of the deadzone algorithm. (The parameter in question is "deadzone", that's where the algorithm got its name.) --trellis determines when to use the trellis algorithm (0=never, 1=sometimes, 2=almost always); any dcts that don't use trellis must use deadzone instead.
So, the fact that --deadzone* still has some minor effect when you enable trellis does not contradict the fact that deadzone and trellis are incompatible.
Don't do that. If you enable trellis, then deadzone is only used as a fast estimate of trellis, so a reduced value of --deadzone does not provide any grain retention, it just reduces the precision of that estimate and thus of the mode decision process. Sure I could make x264 ignore --deadzone* if --trellis is enabled, but that would contradict my policy of "give the luser enough rope to hang himself".

That said, it might be possible to tweak trellis in a way that has similar results to --deadzone*. In which case --deadzone* could apply to trellis too, despite the name.

BTW, just because an option is printed in the userdata sei doesn't mean it had any effect on the encode. I remove some of the extraneous options (e.g. most of ratecontrol when using cqp), but still some options may be printed even if they're overridden by some other option.



在common/set.c里面有个int x264_cqm_init( x264_t *h )函数
里面有几行代码

  1.     int deadzone[4] = { 32 - h->param.analyse.i_luma_deadzone[1],
  2.                         32 - h->param.analyse.i_luma_deadzone[0],
  3.                         32 - 11, 32 - 21 };


  1.                 h->quant4_bias[i_list][q][i] = X264_MIN( DIV(deadzone[i_list]<<10, j), (1<<15)/j );


  1.                     h->quant8_bias[i_list][q][i] = X264_MIN( DIV(deadzone[i_list]<<10, j), (1<<15)/j );

似乎deadzone选项设定会影响到quant4_bias和quant8_bias这两个数组

在encoder/macroblock.c里面还有以下代码

引用
static ALWAYS_INLINE int x264_quant_4x4( x264_t *h, dctcoef dct[16], int i_qp, int ctx_block_cat, int b_intra, int idx )
{
    int i_quant_cat = b_intra ? CQM_4IY : CQM_4PY;
    if( h->mb.b_noise_reduction && ctx_block_cat != DCT_LUMA_AC )
        h->quantf.denoise_dct( dct, h->nr_residual_sum[0], h->nr_offset[0], 16 );
    if( h->mb.b_trellis )
        return x264_quant_4x4_trellis( h, dct, i_quant_cat, i_qp, ctx_block_cat, b_intra, 0, idx );
    else
        return h->quantf.quant_4x4( dct, h->quant4_mf[i_quant_cat][i_qp], h->quant4_bias[i_quant_cat][i_qp] );
}

static ALWAYS_INLINE int x264_quant_8x8( x264_t *h, dctcoef dct[64], int i_qp, int b_intra, int idx )
{
    int i_quant_cat = b_intra ? CQM_8IY : CQM_8PY;
    if( h->mb.b_noise_reduction )
        h->quantf.denoise_dct( dct, h->nr_residual_sum[1], h->nr_offset[1], 64 );
    if( h->mb.b_trellis )
        return x264_quant_8x8_trellis( h, dct, i_quant_cat, i_qp, b_intra, idx );
    else
        return h->quantf.quant_8x8( dct, h->quant8_mf[i_quant_cat][i_qp], h->quant8_bias[i_quant_cat][i_qp] );
}



macroblock.c里面还有个函数是
int x264_macroblock_probe_skip( x264_t *h, int b_bidir )
注释是Check if the current MB could be encoded as a [PB]_SKIP
里面会涉及到quant4_bias这个数组,而且与h->mb.b_trellis无关

macroblock.h里面有宏定义

  1. #define x264_macroblock_probe_pskip( h )\
  2.     x264_macroblock_probe_skip( h, 0 )
  3. #define x264_macroblock_probe_bskip( h )\
  4.     x264_macroblock_probe_skip( h, 1 )


encoder/analyse.c里面会调用到x264_macroblock_probe_skip这个函数
(搜索”x264_macroblock_probe_pskip“和”x264_macroblock_probe_bskip“)

所以个人猜测开trellis时,deadzone设置会影响到对mb的分析
[ 此帖被linuxyouxia在2011-05-07 22:50重新编辑 ]

Fansubbing is a waste of time.
级别: 风云使者
注册时间:
2004-01-20
在线时间:
633小时
发帖:
549
只看该作者 2楼 发表于: 2011-05-08
嗯,从x264 [info]来看确实是对MB影响相对更大

现在算是基本了解deadzone了……

求资源,欢迎PM告知:
Xbox360 Clannad OP原版(WMV格式)
PS3 圣恩传说F / Tales of Graces F OP原版(BIK格式)


CLANNAD游戏OP/ED + TOMOYO after OP 无二次Credits内嵌字幕清晰版
BiliBili站点     AcFun站点

--- Direct264 自编译版 ---

碧之轨迹Nightmare VS风之剑圣 第1战(均无水印):6cn(六间房)   56(我乐)
BGM: Inevitable Struggle (Super Arrange Ver.)

Rockman 9 Rock Medley
快速回复

限150 字节
上一个 下一个