ref: 86212bc3c19f4d3dd131d7e57b2fbcfb84f03144
parent: 13ce6e6d00a6937d13d315700ea5ab8d228eee0d
parent: 6877acb67e74a837ee5f2539737e3f63002b0ea9
author: Marco Paniconi <[email protected]>
date: Fri Apr 8 13:51:25 EDT 2016
Merge "vp8-denoiser: Avoid doing the mcomp if we don't denoise."
--- a/vp8/encoder/denoising.c
+++ b/vp8/encoder/denoising.c
@@ -572,62 +572,69 @@
best_sse = zero_mv_sse;
}
- saved_pre = filter_xd->pre;
- saved_dst = filter_xd->dst;
+ mv_row = x->best_sse_mv.as_mv.row;
+ mv_col = x->best_sse_mv.as_mv.col;
+ motion_magnitude2 = mv_row * mv_row + mv_col * mv_col;
+ motion_threshold = denoiser->denoise_pars.scale_motion_thresh *
+ NOISE_MOTION_THRESHOLD;
- /* Compensate the running average. */
- filter_xd->pre.y_buffer = src->y_buffer + recon_yoffset;
- filter_xd->pre.u_buffer = src->u_buffer + recon_uvoffset;
- filter_xd->pre.v_buffer = src->v_buffer + recon_uvoffset;
- /* Write the compensated running average to the destination buffer. */
- filter_xd->dst.y_buffer = dst->y_buffer + recon_yoffset;
- filter_xd->dst.u_buffer = dst->u_buffer + recon_uvoffset;
- filter_xd->dst.v_buffer = dst->v_buffer + recon_uvoffset;
+ if (motion_magnitude2 <
+ denoiser->denoise_pars.scale_increase_filter * NOISE_MOTION_THRESHOLD)
+ x->increase_denoising = 1;
- if (!x->skip)
- {
- vp8_build_inter_predictors_mb(filter_xd);
- }
- else
- {
- vp8_build_inter16x16_predictors_mb(filter_xd,
- filter_xd->dst.y_buffer,
- filter_xd->dst.u_buffer,
- filter_xd->dst.v_buffer,
- filter_xd->dst.y_stride,
- filter_xd->dst.uv_stride);
- }
- filter_xd->pre = saved_pre;
- filter_xd->dst = saved_dst;
- *mbmi = saved_mbmi;
+ sse_thresh = denoiser->denoise_pars.scale_sse_thresh * SSE_THRESHOLD;
+ if (x->increase_denoising)
+ sse_thresh =
+ denoiser->denoise_pars.scale_sse_thresh * SSE_THRESHOLD_HIGH;
- }
+ if (best_sse > sse_thresh || motion_magnitude2 > motion_threshold)
+ decision = COPY_BLOCK;
- mv_row = x->best_sse_mv.as_mv.row;
- mv_col = x->best_sse_mv.as_mv.col;
- motion_magnitude2 = mv_row * mv_row + mv_col * mv_col;
- motion_threshold = denoiser->denoise_pars.scale_motion_thresh *
- NOISE_MOTION_THRESHOLD;
+ // If block is considered skin, don't denoise if the block
+ // (1) is selected as non-zero motion for current frame, or
+ // (2) has not been selected as ZERO_LAST mode at least x past frames
+ // in a row.
+ // TODO(marpan): Parameter "x" should be varied with framerate.
+ // In particualar, should be reduced for layers (base layer/LAST).
+ if (x->is_skin && (consec_zero_last < 2 || motion_magnitude2 > 0))
+ decision = COPY_BLOCK;
- if (motion_magnitude2 <
- denoiser->denoise_pars.scale_increase_filter * NOISE_MOTION_THRESHOLD)
- x->increase_denoising = 1;
+ if (decision == FILTER_BLOCK) {
+ saved_pre = filter_xd->pre;
+ saved_dst = filter_xd->dst;
- sse_thresh = denoiser->denoise_pars.scale_sse_thresh * SSE_THRESHOLD;
- if (x->increase_denoising)
- sse_thresh = denoiser->denoise_pars.scale_sse_thresh * SSE_THRESHOLD_HIGH;
+ /* Compensate the running average. */
+ filter_xd->pre.y_buffer = src->y_buffer + recon_yoffset;
+ filter_xd->pre.u_buffer = src->u_buffer + recon_uvoffset;
+ filter_xd->pre.v_buffer = src->v_buffer + recon_uvoffset;
+ /* Write the compensated running average to the destination buffer. */
+ filter_xd->dst.y_buffer = dst->y_buffer + recon_yoffset;
+ filter_xd->dst.u_buffer = dst->u_buffer + recon_uvoffset;
+ filter_xd->dst.v_buffer = dst->v_buffer + recon_uvoffset;
- if (best_sse > sse_thresh || motion_magnitude2 > motion_threshold)
+ if (!x->skip)
+ {
+ vp8_build_inter_predictors_mb(filter_xd);
+ }
+ else
+ {
+ vp8_build_inter16x16_predictors_mb(filter_xd,
+ filter_xd->dst.y_buffer,
+ filter_xd->dst.u_buffer,
+ filter_xd->dst.v_buffer,
+ filter_xd->dst.y_stride,
+ filter_xd->dst.uv_stride);
+ }
+ filter_xd->pre = saved_pre;
+ filter_xd->dst = saved_dst;
+ *mbmi = saved_mbmi;
+ }
+ } else {
+ // zero_frame should always be 1 for real-time mode, as the
+ // ZEROMV mode is always checked, so we should never go into this branch.
+ // If case ZEROMV is not checked, then we will force no denoise (COPY).
decision = COPY_BLOCK;
-
- // If block is considered skin, don't denoise if the block
- // (1) is selected as non-zero motion for current frame, or
- // (2) has not been selected as ZERO_LAST mode at least x past frames
- // in a row.
- // TODO(marpan): Parameter "x" should be varied with framerate.
- // In particualar, should be reduced for temporal layers (base layer/LAST).
- if (x->is_skin && (consec_zero_last < 2 || motion_magnitude2 > 0))
- decision = COPY_BLOCK;
+ }
if (decision == FILTER_BLOCK)
{