vp8-denoiser: Avoid doing the mcomp if we don't denoise.
Avoid doing the mcomp in denoiser if we don't denoise the block (because of motion/SSE/skin threshold, etc). This can reduce encoding time (with denoiser enabled) by ~1.5-2%. Change-Id: Ia699b68dfd37b89cdf3a82b8aa40e8c8f98a3d4f
This commit is contained in:
Родитель
71cf9fac83
Коммит
6877acb67e
|
@ -572,63 +572,70 @@ void vp8_denoiser_denoise_mb(VP8_DENOISER *denoiser,
|
|||
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);
|
||||
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;
|
||||
|
||||
// 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 (decision == FILTER_BLOCK) {
|
||||
saved_pre = filter_xd->pre;
|
||||
saved_dst = filter_xd->dst;
|
||||
|
||||
/* 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 (!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
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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 (motion_magnitude2 <
|
||||
denoiser->denoise_pars.scale_increase_filter * NOISE_MOTION_THRESHOLD)
|
||||
x->increase_denoising = 1;
|
||||
|
||||
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;
|
||||
|
||||
// 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)
|
||||
{
|
||||
unsigned char *mc_running_avg_y =
|
||||
|
|
Загрузка…
Ссылка в новой задаче