vp9: Compute skin only for blocks eligible for noise estimation.

Change-Id: Iddcb83a5968db57cfd312c5bc44b2a226a2a3264
This commit is contained in:
Jerome Jiang
2017-07-14 13:45:33 -07:00
parent 666e394d41
commit 682135fa60

View File

@@ -172,7 +172,6 @@ void vp9_update_noise_estimate(VP9_COMP *const cpi) {
int mi_row, mi_col; int mi_row, mi_col;
int num_low_motion = 0; int num_low_motion = 0;
int frame_low_motion = 1; int frame_low_motion = 1;
if (cpi->use_skin_detection) vp9_compute_skin_map(cpi, BLOCK_16X16);
for (mi_row = 0; mi_row < cm->mi_rows; mi_row++) { for (mi_row = 0; mi_row < cm->mi_rows; mi_row++) {
for (mi_col = 0; mi_col < cm->mi_cols; mi_col++) { for (mi_col = 0; mi_col < cm->mi_cols; mi_col++) {
int bl_index = mi_row * cm->mi_cols + mi_col; int bl_index = mi_row * cm->mi_cols + mi_col;
@@ -191,25 +190,31 @@ void vp9_update_noise_estimate(VP9_COMP *const cpi) {
int bl_index1 = bl_index + 1; int bl_index1 = bl_index + 1;
int bl_index2 = bl_index + cm->mi_cols; int bl_index2 = bl_index + cm->mi_cols;
int bl_index3 = bl_index2 + 1; int bl_index3 = bl_index2 + 1;
int is_skin = 0; int consec_zeromv =
if (cpi->use_skin_detection) is_skin = cpi->skin_map[bl_index]; VPXMIN(cpi->consec_zero_mv[bl_index],
VPXMIN(cpi->consec_zero_mv[bl_index1],
VPXMIN(cpi->consec_zero_mv[bl_index2],
cpi->consec_zero_mv[bl_index3])));
// Only consider blocks that are likely steady background. i.e, have // Only consider blocks that are likely steady background. i.e, have
// been encoded as zero/low motion x (= thresh_consec_zeromv) frames // been encoded as zero/low motion x (= thresh_consec_zeromv) frames
// in a row. consec_zero_mv[] defined for 8x8 blocks, so consider all // in a row. consec_zero_mv[] defined for 8x8 blocks, so consider all
// 4 sub-blocks for 16x16 block. Also, avoid skin blocks. // 4 sub-blocks for 16x16 block. Also, avoid skin blocks.
if (frame_low_motion && if (frame_low_motion && consec_zeromv > thresh_consec_zeromv) {
cpi->consec_zero_mv[bl_index] > thresh_consec_zeromv && int is_skin = 0;
cpi->consec_zero_mv[bl_index1] > thresh_consec_zeromv && if (cpi->use_skin_detection) {
cpi->consec_zero_mv[bl_index2] > thresh_consec_zeromv && is_skin =
cpi->consec_zero_mv[bl_index3] > thresh_consec_zeromv && vp9_compute_skin_block(src_y, src_u, src_v, src_ystride,
!is_skin) { src_uvstride, bsize, consec_zeromv, 0);
// Compute variance. }
if (!is_skin) {
unsigned int sse; unsigned int sse;
// Compute variance.
unsigned int variance = cpi->fn_ptr[bsize].vf( unsigned int variance = cpi->fn_ptr[bsize].vf(
src_y, src_ystride, last_src_y, last_src_ystride, &sse); src_y, src_ystride, last_src_y, last_src_ystride, &sse);
// Only consider this block as valid for noise measurement if the // Only consider this block as valid for noise measurement if the
// average term (sse - variance = N * avg^{2}, N = 16X16) of the // average term (sse - variance = N * avg^{2}, N = 16X16) of the
// temporal residual is small (avoid effects from lighting change). // temporal residual is small (avoid effects from lighting
// change).
if ((sse - variance) < thresh_sum_diff) { if ((sse - variance) < thresh_sum_diff) {
unsigned int sse2; unsigned int sse2;
const unsigned int spatial_variance = cpi->fn_ptr[bsize].vf( const unsigned int spatial_variance = cpi->fn_ptr[bsize].vf(
@@ -224,6 +229,7 @@ void vp9_update_noise_estimate(VP9_COMP *const cpi) {
} }
} }
} }
}
src_y += 8; src_y += 8;
last_src_y += 8; last_src_y += 8;
src_u += 4; src_u += 4;