ref: 090574c0bee16d010741f34271137e926bf81e3d
parent: 6e5149b68d97ea0bd1f149645da83169bc447e39
parent: 354a2e612d2f54a96d57d32110f35b4fdc664945
author: Marco Paniconi <[email protected]>
date: Fri Aug 8 13:17:15 EDT 2014
Merge "vp8: Code cleanup for control of denoiser mode."
--- a/vp8/common/onyx.h
+++ b/vp8/common/onyx.h
@@ -108,7 +108,7 @@
* For temporal denoiser: noise_sensitivity = 0 means off,
* noise_sensitivity = 1 means temporal denoiser on for Y channel only,
* noise_sensitivity = 2 means temporal denoiser on for all channels.
- * noise_sensitivity = 3 means aggressive denoising mode.
+ * noise_sensitivity >= 3 means aggressive denoising mode.
* Temporal denoiser is enabled via the configuration option:
* CONFIG_TEMPORAL_DENOISING.
* For spatial denoiser: noise_sensitivity controls the amount of
--- a/vp8/encoder/denoising.c
+++ b/vp8/encoder/denoising.c
@@ -335,8 +335,16 @@
return FILTER_BLOCK;
}
-void vp8_denoiser_set_parameters(VP8_DENOISER *denoiser) {
- if (!denoiser->aggressive_mode) {
+void vp8_denoiser_set_parameters(VP8_DENOISER *denoiser, int mode) {
+ assert(mode > 0); // Denoiser is allocated only if mode > 0.
+ if (mode == 1) {
+ denoiser->denoiser_mode = kDenoiserOnYOnly;
+ } else if (mode == 2) {
+ denoiser->denoiser_mode = kDenoiserOnYUV;
+ } else {
+ denoiser->denoiser_mode = kDenoiserOnYUVAggressive;
+ }
+ if (denoiser->denoiser_mode != kDenoiserOnYUVAggressive) {
denoiser->denoise_pars.scale_sse_thresh = 1;
denoiser->denoise_pars.scale_motion_thresh = 8;
denoiser->denoise_pars.scale_increase_filter = 0;
@@ -361,7 +369,6 @@
int i;
assert(denoiser);
denoiser->num_mb_cols = num_mb_cols;
- denoiser->aggressive_mode = mode;
for (i = 0; i < MAX_REF_FRAMES; i++)
{
@@ -392,7 +399,7 @@
denoiser->denoise_state = vpx_calloc((num_mb_rows * num_mb_cols), 1);
vpx_memset(denoiser->denoise_state, 0, (num_mb_rows * num_mb_cols));
- vp8_denoiser_set_parameters(denoiser);
+ vp8_denoiser_set_parameters(denoiser, mode);
return 0;
}
@@ -420,8 +427,8 @@
loop_filter_info_n *lfi_n,
int mb_row,
int mb_col,
- int block_index,
- int uv_denoise)
+ int block_index)
+
{
int mv_row;
int mv_col;
@@ -558,7 +565,7 @@
denoiser->denoise_state[block_index] = motion_magnitude2 > 0 ?
kFilterNonZeroMV : kFilterZeroMV;
// Only denoise UV for zero motion, and if y channel was denoised.
- if (uv_denoise &&
+ if (denoiser->denoiser_mode != kDenoiserOnYOnly &&
motion_magnitude2 == 0 &&
decision == FILTER_BLOCK) {
unsigned char *mc_running_avg_u =
@@ -595,7 +602,7 @@
denoiser->yv12_running_avg[INTRA_FRAME].y_stride);
denoiser->denoise_state[block_index] = kNoFilter;
}
- if (uv_denoise) {
+ if (denoiser->denoiser_mode != kDenoiserOnYOnly) {
if (decision_u == COPY_BLOCK) {
vp8_copy_mem8x8(
x->block[16].src + *x->block[16].base_src, x->block[16].src_stride,
--- a/vp8/encoder/denoising.h
+++ b/vp8/encoder/denoising.h
@@ -39,6 +39,13 @@
kFilterNonZeroMV
};
+enum vp8_denoiser_mode {
+ kDenoiserOff,
+ kDenoiserOnYOnly,
+ kDenoiserOnYUV,
+ kDenoiserOnYUVAggressive
+};
+
typedef struct {
// Scale factor on sse threshold above which no denoising is done.
unsigned int scale_sse_thresh;
@@ -67,7 +74,7 @@
YV12_BUFFER_CONFIG yv12_mc_running_avg;
unsigned char* denoise_state;
int num_mb_cols;
- int aggressive_mode;
+ int denoiser_mode;
denoise_params denoise_pars;
} VP8_DENOISER;
@@ -85,8 +92,7 @@
loop_filter_info_n *lfi_n,
int mb_row,
int mb_col,
- int block_index,
- int uv_denoise);
+ int block_index);
#ifdef __cplusplus
} // extern "C"
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -615,7 +615,7 @@
cpi->cyclic_refresh_mode_index = i;
#if CONFIG_TEMPORAL_DENOISING
- if (cpi->denoiser.aggressive_mode != 0 &&
+ if (cpi->denoiser.denoiser_mode == kDenoiserOnYUVAggressive &&
Q < (int)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
@@ -1283,8 +1283,7 @@
vp8_denoiser_free(&cpi->denoiser);
vp8_denoiser_allocate(&cpi->denoiser, width, height,
cm->mb_rows, cm->mb_cols,
- ((cpi->oxcf.noise_sensitivity == 3) ?
- 1 : 0));
+ cpi->oxcf.noise_sensitivity);
}
#endif
}
@@ -1781,7 +1780,7 @@
int height = (cpi->oxcf.Height + 15) & ~15;
vp8_denoiser_allocate(&cpi->denoiser, width, height,
cm->mb_rows, cm->mb_cols,
- ((cpi->oxcf.noise_sensitivity == 3) ? 1 : 0));
+ cpi->oxcf.noise_sensitivity);
}
}
#endif
--- a/vp8/encoder/pickinter.c
+++ b/vp8/encoder/pickinter.c
@@ -1174,7 +1174,6 @@
#if CONFIG_TEMPORAL_DENOISING
if (cpi->oxcf.noise_sensitivity)
{
- int uv_denoise = (cpi->oxcf.noise_sensitivity >= 2) ? 1 : 0;
int block_index = mb_row * cpi->common.mb_cols + mb_col;
if (x->best_sse_inter_mode == DC_PRED)
{
@@ -1189,8 +1188,7 @@
vp8_denoiser_denoise_mb(&cpi->denoiser, x, best_sse, zero_mv_sse,
recon_yoffset, recon_uvoffset,
&cpi->common.lf_info, mb_row, mb_col,
- block_index, uv_denoise);
-
+ block_index);
/* Reevaluate ZEROMV after denoising. */
if (best_mbmode.ref_frame == INTRA_FRAME &&
--- a/vp8/encoder/rdopt.c
+++ b/vp8/encoder/rdopt.c
@@ -2511,7 +2511,6 @@
#if CONFIG_TEMPORAL_DENOISING
if (cpi->oxcf.noise_sensitivity)
{
- int uv_denoise = (cpi->oxcf.noise_sensitivity == 2) ? 1 : 0;
int block_index = mb_row * cpi->common.mb_cols + mb_col;
if (x->best_sse_inter_mode == DC_PRED)
{
@@ -2525,8 +2524,7 @@
vp8_denoiser_denoise_mb(&cpi->denoiser, x, best_sse, zero_mv_sse,
recon_yoffset, recon_uvoffset,
&cpi->common.lf_info, mb_row, mb_col,
- block_index, uv_denoise);
-
+ block_index);
/* Reevaluate ZEROMV after denoising. */
if (best_mode.mbmode.ref_frame == INTRA_FRAME &&