// Set to zero to make sure we do not use the previous encoded frame stats
mbmi->skip = 0;
- x->source_variance = get_sby_perpixel_variance(cpi, x, bsize);
+ x->source_variance = get_sby_perpixel_variance(cpi, &x->plane[0].src, bsize);
+ // Save rdmult before it might be changed, so it can be restored later.
+ orig_rdmult = x->rdmult;
+ if (cpi->oxcf.tuning == VP8_TUNE_SSIM)
+ activity_masking(cpi, x);
+
if (aq_mode == VARIANCE_AQ) {
const int energy = bsize <= BLOCK_16X16 ? x->mb_energy
: vp9_block_energy(cpi, x, bsize);