Refactor mc reference block fetch in denoiser

This commit refactors the motion compensated reference block fetch
process in denoiser. It skips the stage that generates motion
compensated reference block if denoiser decides to use copy block
mode. For high motion clips, this could speed up the denoising
process by about 10%.

Change-Id: I8ef4fa5fe766a8c4529119b9ec01faefb3d4ef53
This commit is contained in:
Jingning Han 2015-01-08 12:15:30 -08:00
parent e3f0b19f3f
commit a0be730eae

View File

@ -190,7 +190,6 @@ static uint8_t *block_start(uint8_t *framebuf, int stride,
return framebuf + (stride * mi_row * 8) + (mi_col * 8);
}
static VP9_DENOISER_DECISION perform_motion_compensation(VP9_DENOISER *denoiser,
MACROBLOCK *mb,
BLOCK_SIZE bs,
@ -205,28 +204,18 @@ static VP9_DENOISER_DECISION perform_motion_compensation(VP9_DENOISER *denoiser,
MV_REFERENCE_FRAME frame;
MACROBLOCKD *filter_mbd = &mb->e_mbd;
MB_MODE_INFO *mbmi = &filter_mbd->mi[0].src_mi->mbmi;
MB_MODE_INFO saved_mbmi;
int i, j;
struct buf_2d saved_dst[MAX_MB_PLANE];
struct buf_2d saved_pre[MAX_MB_PLANE][2]; // 2 pre buffers
// We will restore these after motion compensation.
saved_mbmi = *mbmi;
for (i = 0; i < MAX_MB_PLANE; ++i) {
for (j = 0; j < 2; ++j) {
saved_pre[i][j] = filter_mbd->plane[i].pre[j];
}
saved_dst[i] = filter_mbd->plane[i].dst;
}
mv_col = ctx->best_sse_mv.as_mv.col;
mv_row = ctx->best_sse_mv.as_mv.row;
*motion_magnitude = mv_row * mv_row + mv_col * mv_col;
frame = ctx->best_reference_frame;
saved_mbmi = *mbmi;
// If the best reference frame uses inter-prediction and there is enough of a
// difference in sum-squared-error, use it.
if (frame != INTRA_FRAME &&
@ -247,6 +236,26 @@ static VP9_DENOISER_DECISION perform_motion_compensation(VP9_DENOISER *denoiser,
ctx->newmv_sse = ctx->zeromv_sse;
}
if (ctx->newmv_sse > sse_thresh(bs, increase_denoising)) {
// Restore everything to its original state
*mbmi = saved_mbmi;
return COPY_BLOCK;
}
if (mv_row * mv_row + mv_col * mv_col >
8 * noise_motion_thresh(bs, increase_denoising)) {
// Restore everything to its original state
*mbmi = saved_mbmi;
return COPY_BLOCK;
}
// We will restore these after motion compensation.
for (i = 0; i < MAX_MB_PLANE; ++i) {
for (j = 0; j < 2; ++j) {
saved_pre[i][j] = filter_mbd->plane[i].pre[j];
}
saved_dst[i] = filter_mbd->plane[i].dst;
}
// Set the pointers in the MACROBLOCKD to point to the buffers in the denoiser
// struct.
for (j = 0; j < 2; ++j) {
@ -299,13 +308,6 @@ static VP9_DENOISER_DECISION perform_motion_compensation(VP9_DENOISER *denoiser,
mv_row = ctx->best_sse_mv.as_mv.row;
mv_col = ctx->best_sse_mv.as_mv.col;
if (ctx->newmv_sse > sse_thresh(bs, increase_denoising)) {
return COPY_BLOCK;
}
if (mv_row * mv_row + mv_col * mv_col >
8 * noise_motion_thresh(bs, increase_denoising)) {
return COPY_BLOCK;
}
return FILTER_BLOCK;
}