看来是俺理解错了“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 )函数
里面有几行代码
- int deadzone[4] = { 32 - h->param.analyse.i_luma_deadzone[1],
- 32 - h->param.analyse.i_luma_deadzone[0],
- 32 - 11, 32 - 21 };
- h->quant4_bias[i_list][q][i] = X264_MIN( DIV(deadzone[i_list]<<10, j), (1<<15)/j );
- 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里面有宏定义
- #define x264_macroblock_probe_pskip( h )\
- x264_macroblock_probe_skip( h, 0 )
- #define x264_macroblock_probe_bskip( h )\
- 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重新编辑 ]