Merge "Fix to denoiser with dynamic resize."

This commit is contained in:
Marco Paniconi 2015-10-05 14:14:35 +00:00 committed by Gerrit Code Review
commit 7777e7a8d5
4 changed files with 39 additions and 22 deletions

View File

@ -375,8 +375,11 @@ void vp9_denoiser_update_frame_info(VP9_DENOISER *denoiser,
FRAME_TYPE frame_type,
int refresh_alt_ref_frame,
int refresh_golden_frame,
int refresh_last_frame) {
if (frame_type == KEY_FRAME) {
int refresh_last_frame,
int resized) {
// Copy source into denoised reference buffers on KEY_FRAME or
// if the just encoded frame was resized.
if (frame_type == KEY_FRAME || resized != 0) {
int i;
// Start at 1 so as not to overwrite the INTRA_FRAME
for (i = 1; i < MAX_REF_FRAMES; ++i)
@ -462,7 +465,6 @@ int vp9_denoiser_alloc(VP9_DENOISER *denoiser, int width, int height,
#endif
denoiser->increase_denoising = 0;
denoiser->frame_buffer_initialized = 1;
return 0;
}

View File

@ -37,7 +37,8 @@ void vp9_denoiser_update_frame_info(VP9_DENOISER *denoiser,
FRAME_TYPE frame_type,
int refresh_alt_ref_frame,
int refresh_golden_frame,
int refresh_last_frame);
int refresh_last_frame,
int resized);
void vp9_denoiser_denoise(VP9_DENOISER *denoiser, MACROBLOCK *mb,
int mi_row, int mi_col, BLOCK_SIZE bs,

View File

@ -1739,8 +1739,10 @@ static void encode_b_rt(VP9_COMP *cpi, ThreadData *td,
update_state_rt(cpi, td, ctx, mi_row, mi_col, bsize);
#if CONFIG_VP9_TEMPORAL_DENOISING
if (cpi->oxcf.noise_sensitivity > 0 && output_enabled &&
cpi->common.frame_type != KEY_FRAME) {
if (cpi->oxcf.noise_sensitivity > 0 &&
output_enabled &&
cpi->common.frame_type != KEY_FRAME &&
cpi->resize_pending == 0) {
vp9_denoiser_denoise(&cpi->denoiser, x, mi_row, mi_col,
VPXMAX(BLOCK_8X8, bsize), ctx);
}

View File

@ -2756,7 +2756,8 @@ void vp9_update_reference_frames(VP9_COMP *cpi) {
cpi->common.frame_type,
cpi->refresh_alt_ref_frame,
cpi->refresh_golden_frame,
cpi->refresh_last_frame);
cpi->refresh_last_frame,
cpi->resize_pending);
}
#endif
}
@ -3099,6 +3100,21 @@ static void set_size_dependent_vars(VP9_COMP *cpi, int *q,
#endif // CONFIG_VP9_POSTPROC
}
#if CONFIG_VP9_TEMPORAL_DENOISING
static void setup_denoiser_buffer(VP9_COMP *cpi) {
VP9_COMMON *const cm = &cpi->common;
if (cpi->oxcf.noise_sensitivity > 0 &&
!cpi->denoiser.frame_buffer_initialized) {
vp9_denoiser_alloc(&(cpi->denoiser), cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
#if CONFIG_VP9_HIGHBITDEPTH
cm->use_highbitdepth,
#endif
VP9_ENC_BORDER_IN_PIXELS);
}
}
#endif
static void init_motion_estimation(VP9_COMP *cpi) {
int y_stride = cpi->scaled_source.y_stride;
@ -3143,6 +3159,17 @@ static void set_frame_size(VP9_COMP *cpi) {
// TODO(agrange) Scale cpi->max_mv_magnitude if frame-size has changed.
set_mv_search_params(cpi);
#if CONFIG_VP9_TEMPORAL_DENOISING
// Reset the denoiser on the resized frame.
if (cpi->oxcf.noise_sensitivity > 0) {
vp9_denoiser_free(&(cpi->denoiser));
setup_denoiser_buffer(cpi);
// Dynamic resize is only triggered for non-SVC, so we can force
// golden frame update here as temporary fix to denoiser.
cpi->refresh_golden_frame = 1;
}
#endif
}
if ((oxcf->pass == 2) &&
@ -3983,21 +4010,6 @@ static void check_initial_width(VP9_COMP *cpi,
}
}
#if CONFIG_VP9_TEMPORAL_DENOISING
static void setup_denoiser_buffer(VP9_COMP *cpi) {
VP9_COMMON *const cm = &cpi->common;
if (cpi->oxcf.noise_sensitivity > 0 &&
!cpi->denoiser.frame_buffer_initialized) {
vp9_denoiser_alloc(&(cpi->denoiser), cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
#if CONFIG_VP9_HIGHBITDEPTH
cm->use_highbitdepth,
#endif
VP9_ENC_BORDER_IN_PIXELS);
}
}
#endif
int vp9_receive_raw_frame(VP9_COMP *cpi, unsigned int frame_flags,
YV12_BUFFER_CONFIG *sd, int64_t time_stamp,
int64_t end_time) {