summaryrefslogtreecommitdiff
path: root/vp8/encoder/onyx_if.c
diff options
context:
space:
mode:
Diffstat (limited to 'vp8/encoder/onyx_if.c')
-rw-r--r--vp8/encoder/onyx_if.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c
index 469d0d6e9..e81c05e6f 100644
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -613,6 +613,24 @@ static void cyclic_background_refresh(VP8_COMP *cpi, int Q, int lf_adjustment)
while(block_count && i != cpi->cyclic_refresh_mode_index);
cpi->cyclic_refresh_mode_index = i;
+
+#if CONFIG_TEMPORAL_DENOISING
+ if (cpi->denoiser.aggressive_mode != 0 &&
+ Q < cpi->denoiser.denoise_pars.qp_thresh) {
+ // Under aggressive denoising mode, use segmentation to turn off loop
+ // filter below some qp thresh. The loop filter is turned off for all
+ // blocks that have been encoded as ZEROMV LAST x frames in a row,
+ // where x is set by cpi->denoiser.denoise_pars.consec_zerolast.
+ // This is to avoid "dot" artifacts that can occur from repeated
+ // loop filtering on noisy input source.
+ cpi->cyclic_refresh_q = Q;
+ lf_adjustment = -MAX_LOOP_FILTER;
+ for (i = 0; i < mbs_in_frame; ++i) {
+ seg_map[i] = (cpi->consec_zero_last[i] >
+ cpi->denoiser.denoise_pars.consec_zerolast) ? 1 : 0;
+ }
+ }
+#endif
}
/* Activate segmentation. */
@@ -1752,7 +1770,8 @@ void vp8_change_config(VP8_COMP *cpi, VP8_CONFIG *oxcf)
int width = (cpi->oxcf.Width + 15) & ~15;
int height = (cpi->oxcf.Height + 15) & ~15;
vp8_denoiser_allocate(&cpi->denoiser, width, height,
- cpi->common.mb_rows, cpi->common.mb_cols);
+ cm->mb_rows, cm->mb_cols,
+ ((cpi->oxcf.noise_sensitivity == 3) ? 1 : 0));
}
}
#endif
@@ -1896,6 +1915,9 @@ struct VP8_COMP* vp8_create_compressor(VP8_CONFIG *oxcf)
else
cpi->cyclic_refresh_map = (signed char *) NULL;
+ CHECK_MEM_ERROR(cpi->consec_zero_last,
+ vpx_calloc(cpi->common.mb_rows * cpi->common.mb_cols, 1));
+
#ifdef VP8_ENTROPY_STATS
init_context_counters();
#endif
@@ -2416,6 +2438,7 @@ void vp8_remove_compressor(VP8_COMP **ptr)
vpx_free(cpi->mb.ss);
vpx_free(cpi->tok);
vpx_free(cpi->cyclic_refresh_map);
+ vpx_free(cpi->consec_zero_last);
vp8_remove_common(&cpi->common);
vpx_free(cpi);
@@ -3478,6 +3501,9 @@ static void encode_frame_to_data_rate
{
cpi->mb.rd_thresh_mult[i] = 128;
}
+
+ // Reset the zero_last counter to 0 on key frame.
+ vpx_memset(cpi->consec_zero_last, 0, cm->mb_rows * cm->mb_cols);
}
#if 0
@@ -3899,6 +3925,7 @@ static void encode_frame_to_data_rate
#endif
+
#ifdef OUTPUT_YUV_SRC
vp8_write_yuv_frame(yuv_file, cpi->Source);
#endif
@@ -3994,6 +4021,8 @@ static void encode_frame_to_data_rate
else
disable_segmentation(cpi);
}
+ // Reset the consec_zero_last counter on key frame.
+ vpx_memset(cpi->consec_zero_last, 0, cm->mb_rows * cm->mb_cols);
vp8_set_quantizer(cpi, Q);
}