vp9-denoiser: Avoid copy-block when denoising is at LowLow level.
Avoid copy-block when denoising is at LowLow level (i.e., no denoising is done). Instead, don't enter denoiser at all, and when level goes back up over kLowLow do a reset in denoiser. Change-Id: I0544adf58f4dd51ecc4a4607fcb0353bfbbb7a59
This commit is contained in:
@@ -450,11 +450,12 @@ void vp9_denoiser_update_frame_info(VP9_DENOISER *denoiser,
|
|||||||
int resized) {
|
int resized) {
|
||||||
// Copy source into denoised reference buffers on KEY_FRAME or
|
// Copy source into denoised reference buffers on KEY_FRAME or
|
||||||
// if the just encoded frame was resized.
|
// if the just encoded frame was resized.
|
||||||
if (frame_type == KEY_FRAME || resized != 0) {
|
if (frame_type == KEY_FRAME || resized != 0 || denoiser->reset) {
|
||||||
int i;
|
int i;
|
||||||
// Start at 1 so as not to overwrite the INTRA_FRAME
|
// Start at 1 so as not to overwrite the INTRA_FRAME
|
||||||
for (i = 1; i < MAX_REF_FRAMES; ++i)
|
for (i = 1; i < MAX_REF_FRAMES; ++i)
|
||||||
copy_frame(&denoiser->running_avg_y[i], &src);
|
copy_frame(&denoiser->running_avg_y[i], &src);
|
||||||
|
denoiser->reset = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -567,6 +568,8 @@ int vp9_denoiser_alloc(VP9_DENOISER *denoiser, int width, int height,
|
|||||||
denoiser->increase_denoising = 0;
|
denoiser->increase_denoising = 0;
|
||||||
denoiser->frame_buffer_initialized = 1;
|
denoiser->frame_buffer_initialized = 1;
|
||||||
denoiser->denoising_level = kDenLow;
|
denoiser->denoising_level = kDenLow;
|
||||||
|
denoiser->prev_denoising_level = kDenLow;
|
||||||
|
denoiser->reset = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -586,6 +589,12 @@ void vp9_denoiser_free(VP9_DENOISER *denoiser) {
|
|||||||
void vp9_denoiser_set_noise_level(VP9_DENOISER *denoiser,
|
void vp9_denoiser_set_noise_level(VP9_DENOISER *denoiser,
|
||||||
int noise_level) {
|
int noise_level) {
|
||||||
denoiser->denoising_level = noise_level;
|
denoiser->denoising_level = noise_level;
|
||||||
|
if (denoiser->denoising_level > kDenLowLow &&
|
||||||
|
denoiser->prev_denoising_level == kDenLowLow)
|
||||||
|
denoiser->reset = 1;
|
||||||
|
else
|
||||||
|
denoiser->reset = 0;
|
||||||
|
denoiser->prev_denoising_level = denoiser->denoising_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OUTPUT_YUV_DENOISED
|
#ifdef OUTPUT_YUV_DENOISED
|
||||||
|
|||||||
@@ -40,7 +40,9 @@ typedef struct vp9_denoiser {
|
|||||||
YV12_BUFFER_CONFIG last_source;
|
YV12_BUFFER_CONFIG last_source;
|
||||||
int increase_denoising;
|
int increase_denoising;
|
||||||
int frame_buffer_initialized;
|
int frame_buffer_initialized;
|
||||||
|
int reset;
|
||||||
VP9_DENOISER_LEVEL denoising_level;
|
VP9_DENOISER_LEVEL denoising_level;
|
||||||
|
VP9_DENOISER_LEVEL prev_denoising_level;
|
||||||
} VP9_DENOISER;
|
} VP9_DENOISER;
|
||||||
|
|
||||||
struct VP9_COMP;
|
struct VP9_COMP;
|
||||||
|
|||||||
@@ -2839,7 +2839,8 @@ void vp9_update_reference_frames(VP9_COMP *cpi) {
|
|||||||
sizeof(cpi->interp_filter_selected[0]));
|
sizeof(cpi->interp_filter_selected[0]));
|
||||||
}
|
}
|
||||||
#if CONFIG_VP9_TEMPORAL_DENOISING
|
#if CONFIG_VP9_TEMPORAL_DENOISING
|
||||||
if (cpi->oxcf.noise_sensitivity > 0) {
|
if (cpi->oxcf.noise_sensitivity > 0 &&
|
||||||
|
cpi->denoiser.denoising_level > kDenLowLow) {
|
||||||
vp9_denoiser_update_frame_info(&cpi->denoiser,
|
vp9_denoiser_update_frame_info(&cpi->denoiser,
|
||||||
*cpi->Source,
|
*cpi->Source,
|
||||||
cpi->common.frame_type,
|
cpi->common.frame_type,
|
||||||
|
|||||||
@@ -1270,7 +1270,10 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_VP9_TEMPORAL_DENOISING
|
#if CONFIG_VP9_TEMPORAL_DENOISING
|
||||||
|
if (cpi->oxcf.noise_sensitivity > 0 &&
|
||||||
|
cpi->denoiser.denoising_level > kDenLowLow) {
|
||||||
vp9_denoiser_reset_frame_stats(ctx);
|
vp9_denoiser_reset_frame_stats(ctx);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (cpi->rc.frames_since_golden == 0 && !cpi->use_svc) {
|
if (cpi->rc.frames_since_golden == 0 && !cpi->use_svc) {
|
||||||
@@ -1642,7 +1645,8 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_VP9_TEMPORAL_DENOISING
|
#if CONFIG_VP9_TEMPORAL_DENOISING
|
||||||
if (cpi->oxcf.noise_sensitivity > 0) {
|
if (cpi->oxcf.noise_sensitivity > 0 &&
|
||||||
|
cpi->denoiser.denoising_level > kDenLowLow) {
|
||||||
vp9_denoiser_update_frame_stats(mi, sse_y, this_mode, ctx);
|
vp9_denoiser_update_frame_stats(mi, sse_y, this_mode, ctx);
|
||||||
// Keep track of zero_last cost.
|
// Keep track of zero_last cost.
|
||||||
if (ref_frame == LAST_FRAME && frame_mv[this_mode][ref_frame].as_int == 0)
|
if (ref_frame == LAST_FRAME && frame_mv[this_mode][ref_frame].as_int == 0)
|
||||||
@@ -1823,7 +1827,9 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
|
|||||||
|
|
||||||
#if CONFIG_VP9_TEMPORAL_DENOISING
|
#if CONFIG_VP9_TEMPORAL_DENOISING
|
||||||
if (cpi->oxcf.noise_sensitivity > 0 &&
|
if (cpi->oxcf.noise_sensitivity > 0 &&
|
||||||
cpi->resize_pending == 0) {
|
cpi->resize_pending == 0 &&
|
||||||
|
cpi->denoiser.denoising_level > kDenLowLow &&
|
||||||
|
cpi->denoiser.reset == 0) {
|
||||||
VP9_DENOISER_DECISION decision = COPY_BLOCK;
|
VP9_DENOISER_DECISION decision = COPY_BLOCK;
|
||||||
vp9_denoiser_denoise(cpi, x, mi_row, mi_col, VPXMAX(BLOCK_8X8, bsize),
|
vp9_denoiser_denoise(cpi, x, mi_row, mi_col, VPXMAX(BLOCK_8X8, bsize),
|
||||||
ctx, &decision);
|
ctx, &decision);
|
||||||
|
|||||||
Reference in New Issue
Block a user