Fix to denoiser with dynamic resize.
Temporary fix to denoiser when dynamic resizing is on. -Reallocate denoiser buffers on resized frame. -Force golden update on resized frame. -Don't denoise resized frame, and copy source into denoised buffers. Change-Id: Ife7638173b76a1c49eac7da4f2a30c9c1f4e2000
This commit is contained in:
@@ -375,8 +375,11 @@ void vp9_denoiser_update_frame_info(VP9_DENOISER *denoiser,
|
|||||||
FRAME_TYPE frame_type,
|
FRAME_TYPE frame_type,
|
||||||
int refresh_alt_ref_frame,
|
int refresh_alt_ref_frame,
|
||||||
int refresh_golden_frame,
|
int refresh_golden_frame,
|
||||||
int refresh_last_frame) {
|
int refresh_last_frame,
|
||||||
if (frame_type == KEY_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;
|
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)
|
||||||
@@ -462,7 +465,6 @@ int vp9_denoiser_alloc(VP9_DENOISER *denoiser, int width, int height,
|
|||||||
#endif
|
#endif
|
||||||
denoiser->increase_denoising = 0;
|
denoiser->increase_denoising = 0;
|
||||||
denoiser->frame_buffer_initialized = 1;
|
denoiser->frame_buffer_initialized = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ void vp9_denoiser_update_frame_info(VP9_DENOISER *denoiser,
|
|||||||
FRAME_TYPE frame_type,
|
FRAME_TYPE frame_type,
|
||||||
int refresh_alt_ref_frame,
|
int refresh_alt_ref_frame,
|
||||||
int refresh_golden_frame,
|
int refresh_golden_frame,
|
||||||
int refresh_last_frame);
|
int refresh_last_frame,
|
||||||
|
int resized);
|
||||||
|
|
||||||
void vp9_denoiser_denoise(VP9_DENOISER *denoiser, MACROBLOCK *mb,
|
void vp9_denoiser_denoise(VP9_DENOISER *denoiser, MACROBLOCK *mb,
|
||||||
int mi_row, int mi_col, BLOCK_SIZE bs,
|
int mi_row, int mi_col, BLOCK_SIZE bs,
|
||||||
|
|||||||
@@ -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);
|
update_state_rt(cpi, td, ctx, mi_row, mi_col, bsize);
|
||||||
|
|
||||||
#if CONFIG_VP9_TEMPORAL_DENOISING
|
#if CONFIG_VP9_TEMPORAL_DENOISING
|
||||||
if (cpi->oxcf.noise_sensitivity > 0 && output_enabled &&
|
if (cpi->oxcf.noise_sensitivity > 0 &&
|
||||||
cpi->common.frame_type != KEY_FRAME) {
|
output_enabled &&
|
||||||
|
cpi->common.frame_type != KEY_FRAME &&
|
||||||
|
cpi->resize_pending == 0) {
|
||||||
vp9_denoiser_denoise(&cpi->denoiser, x, mi_row, mi_col,
|
vp9_denoiser_denoise(&cpi->denoiser, x, mi_row, mi_col,
|
||||||
VPXMAX(BLOCK_8X8, bsize), ctx);
|
VPXMAX(BLOCK_8X8, bsize), ctx);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2756,7 +2756,8 @@ void vp9_update_reference_frames(VP9_COMP *cpi) {
|
|||||||
cpi->common.frame_type,
|
cpi->common.frame_type,
|
||||||
cpi->refresh_alt_ref_frame,
|
cpi->refresh_alt_ref_frame,
|
||||||
cpi->refresh_golden_frame,
|
cpi->refresh_golden_frame,
|
||||||
cpi->refresh_last_frame);
|
cpi->refresh_last_frame,
|
||||||
|
cpi->resize_pending);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -3099,6 +3100,21 @@ static void set_size_dependent_vars(VP9_COMP *cpi, int *q,
|
|||||||
#endif // CONFIG_VP9_POSTPROC
|
#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) {
|
static void init_motion_estimation(VP9_COMP *cpi) {
|
||||||
int y_stride = cpi->scaled_source.y_stride;
|
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.
|
// TODO(agrange) Scale cpi->max_mv_magnitude if frame-size has changed.
|
||||||
set_mv_search_params(cpi);
|
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) &&
|
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,
|
int vp9_receive_raw_frame(VP9_COMP *cpi, unsigned int frame_flags,
|
||||||
YV12_BUFFER_CONFIG *sd, int64_t time_stamp,
|
YV12_BUFFER_CONFIG *sd, int64_t time_stamp,
|
||||||
int64_t end_time) {
|
int64_t end_time) {
|
||||||
|
|||||||
Reference in New Issue
Block a user