Commit 21042c71 authored by Marco Paniconi's avatar Marco Paniconi

vp8: Allow for on/off control of UV temporal denoiser.

Use noise_sensitivity level for enabling UV denoiser.

Change-Id: Ib208786a6fdf654981bcd96a3cf44e8e678025c1
parent 1f6aaedd
...@@ -32,6 +32,14 @@ void usage_exit() { ...@@ -32,6 +32,14 @@ void usage_exit() {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
// Denoiser states, for temporal denoising.
enum denoiserState {
kDenoiserOff,
kDenoiserOnYOnly,
kDenoiserOnYUV,
kDenoiserOnYUVAggressive // Aggressive mode not implemented currently.
};
static int mode_to_num_layers[12] = {1, 2, 2, 3, 3, 3, 3, 5, 2, 3, 3, 3}; static int mode_to_num_layers[12] = {1, 2, 2, 3, 3, 3, 3, 5, 2, 3, 3, 3};
// For rate control encoding stats. // For rate control encoding stats.
...@@ -571,7 +579,7 @@ int main(int argc, char **argv) { ...@@ -571,7 +579,7 @@ int main(int argc, char **argv) {
if (strncmp(encoder->name, "vp8", 3) == 0) { if (strncmp(encoder->name, "vp8", 3) == 0) {
vpx_codec_control(&codec, VP8E_SET_CPUUSED, -speed); vpx_codec_control(&codec, VP8E_SET_CPUUSED, -speed);
vpx_codec_control(&codec, VP8E_SET_NOISE_SENSITIVITY, 1); vpx_codec_control(&codec, VP8E_SET_NOISE_SENSITIVITY, kDenoiserOnYUV);
} else if (strncmp(encoder->name, "vp9", 3) == 0) { } else if (strncmp(encoder->name, "vp9", 3) == 0) {
vpx_codec_control(&codec, VP8E_SET_CPUUSED, speed); vpx_codec_control(&codec, VP8E_SET_CPUUSED, speed);
vpx_codec_control(&codec, VP9E_SET_AQ_MODE, 3); vpx_codec_control(&codec, VP9E_SET_AQ_MODE, 3);
......
...@@ -104,7 +104,17 @@ extern "C" ...@@ -104,7 +104,17 @@ extern "C"
struct vpx_rational timebase; struct vpx_rational timebase;
unsigned int target_bandwidth; /* kilobits per second */ unsigned int target_bandwidth; /* kilobits per second */
/* parameter used for applying pre processing blur: recommendation 0 */ /* Parameter used for applying denoiser.
* 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 will be used for aggressive mode in future.
* Temporal denoiser is enabled via the build option
* CONFIG_TEMPORAL_DENOISING.
* For spatial denoiser: noise_sensitivity controls the amount of
* pre-processing blur: noise_sensitivity = 0 means off.
* Spatial denoiser invoked under !CONFIG_TEMPORAL_DENOISING.
*/
int noise_sensitivity; int noise_sensitivity;
/* parameter used for sharpening output: recommendation 0: */ /* parameter used for sharpening output: recommendation 0: */
......
...@@ -396,15 +396,14 @@ void vp8_denoiser_denoise_mb(VP8_DENOISER *denoiser, ...@@ -396,15 +396,14 @@ void vp8_denoiser_denoise_mb(VP8_DENOISER *denoiser,
loop_filter_info_n *lfi_n, loop_filter_info_n *lfi_n,
int mb_row, int mb_row,
int mb_col, int mb_col,
int block_index) int block_index,
int uv_denoise)
{ {
int mv_row; int mv_row;
int mv_col; int mv_col;
unsigned int motion_magnitude2; unsigned int motion_magnitude2;
unsigned int sse_thresh; unsigned int sse_thresh;
int sse_diff_thresh = 0; int sse_diff_thresh = 0;
// Denoise the UV channel.
int apply_color_denoise = 0;
// Spatial loop filter: only applied selectively based on // Spatial loop filter: only applied selectively based on
// temporal filter state of block relative to top/left neighbors. // temporal filter state of block relative to top/left neighbors.
int apply_spatial_loop_filter = 1; int apply_spatial_loop_filter = 1;
...@@ -529,7 +528,7 @@ void vp8_denoiser_denoise_mb(VP8_DENOISER *denoiser, ...@@ -529,7 +528,7 @@ void vp8_denoiser_denoise_mb(VP8_DENOISER *denoiser,
denoiser->denoise_state[block_index] = motion_magnitude2 > 0 ? denoiser->denoise_state[block_index] = motion_magnitude2 > 0 ?
kFilterNonZeroMV : kFilterZeroMV; kFilterNonZeroMV : kFilterZeroMV;
// Only denoise UV for zero motion, and if y channel was denoised. // Only denoise UV for zero motion, and if y channel was denoised.
if (apply_color_denoise && if (uv_denoise &&
motion_magnitude2 == 0 && motion_magnitude2 == 0 &&
decision == FILTER_BLOCK) { decision == FILTER_BLOCK) {
unsigned char *mc_running_avg_u = unsigned char *mc_running_avg_u =
...@@ -566,7 +565,7 @@ void vp8_denoiser_denoise_mb(VP8_DENOISER *denoiser, ...@@ -566,7 +565,7 @@ void vp8_denoiser_denoise_mb(VP8_DENOISER *denoiser,
denoiser->yv12_running_avg[INTRA_FRAME].y_stride); denoiser->yv12_running_avg[INTRA_FRAME].y_stride);
denoiser->denoise_state[block_index] = kNoFilter; denoiser->denoise_state[block_index] = kNoFilter;
} }
if (apply_color_denoise) { if (uv_denoise) {
if (decision_u == COPY_BLOCK) { if (decision_u == COPY_BLOCK) {
vp8_copy_mem8x8( vp8_copy_mem8x8(
x->block[16].src + *x->block[16].base_src, x->block[16].src_stride, x->block[16].src + *x->block[16].base_src, x->block[16].src_stride,
......
...@@ -61,7 +61,8 @@ void vp8_denoiser_denoise_mb(VP8_DENOISER *denoiser, ...@@ -61,7 +61,8 @@ void vp8_denoiser_denoise_mb(VP8_DENOISER *denoiser,
loop_filter_info_n *lfi_n, loop_filter_info_n *lfi_n,
int mb_row, int mb_row,
int mb_col, int mb_col,
int block_index); int block_index,
int uv_denoise);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
......
...@@ -1168,6 +1168,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, ...@@ -1168,6 +1168,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
#if CONFIG_TEMPORAL_DENOISING #if CONFIG_TEMPORAL_DENOISING
if (cpi->oxcf.noise_sensitivity) 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; int block_index = mb_row * cpi->common.mb_cols + mb_col;
if (x->best_sse_inter_mode == DC_PRED) if (x->best_sse_inter_mode == DC_PRED)
{ {
...@@ -1182,7 +1183,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, ...@@ -1182,7 +1183,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
vp8_denoiser_denoise_mb(&cpi->denoiser, x, best_sse, zero_mv_sse, vp8_denoiser_denoise_mb(&cpi->denoiser, x, best_sse, zero_mv_sse,
recon_yoffset, recon_uvoffset, recon_yoffset, recon_uvoffset,
&cpi->common.lf_info, mb_row, mb_col, &cpi->common.lf_info, mb_row, mb_col,
block_index); block_index, uv_denoise);
/* Reevaluate ZEROMV after denoising. */ /* Reevaluate ZEROMV after denoising. */
......
...@@ -2511,6 +2511,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, ...@@ -2511,6 +2511,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
#if CONFIG_TEMPORAL_DENOISING #if CONFIG_TEMPORAL_DENOISING
if (cpi->oxcf.noise_sensitivity) 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; int block_index = mb_row * cpi->common.mb_cols + mb_col;
if (x->best_sse_inter_mode == DC_PRED) if (x->best_sse_inter_mode == DC_PRED)
{ {
...@@ -2524,7 +2525,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, ...@@ -2524,7 +2525,7 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
vp8_denoiser_denoise_mb(&cpi->denoiser, x, best_sse, zero_mv_sse, vp8_denoiser_denoise_mb(&cpi->denoiser, x, best_sse, zero_mv_sse,
recon_yoffset, recon_uvoffset, recon_yoffset, recon_uvoffset,
&cpi->common.lf_info, mb_row, mb_col, &cpi->common.lf_info, mb_row, mb_col,
block_index); block_index, uv_denoise);
/* Reevaluate ZEROMV after denoising. */ /* Reevaluate ZEROMV after denoising. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment