From 66ef9d1c20a2aad48aa78605ded65b88a389a4fb Mon Sep 17 00:00:00 2001 From: Dmitry Kovalev Date: Thu, 19 Dec 2013 14:07:03 -0800 Subject: [PATCH] Adding get_block_variance_fn() function. Change-Id: I67d934b6af899ffd4bcad2d913a650685fa64abd --- vp9/encoder/vp9_firstpass.c | 44 ++++++++++++++----------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index 2d7ac7ce5..fee2d3bb5 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -364,6 +364,19 @@ void vp9_end_first_pass(VP9_COMP *cpi) { output_stats(cpi, cpi->output_pkt_list, &cpi->twopass.total_stats); } +static vp9_variance_fn_t get_block_variance_fn(BLOCK_SIZE bsize) { + switch (bsize) { + case BLOCK_8X8: + return vp9_mse8x8; + case BLOCK_16X8: + return vp9_mse16x8; + case BLOCK_8X16: + return vp9_mse8x16; + default: + return vp9_mse16x16; + } +} + static unsigned int zz_motion_search(VP9_COMP *cpi, MACROBLOCK *x, YV12_BUFFER_CONFIG *recon_buffer, int recon_yoffset) { @@ -375,20 +388,8 @@ static unsigned int zz_motion_search(VP9_COMP *cpi, MACROBLOCK *x, const int ref_stride = xd->plane[0].pre[0].stride; unsigned int sse; - switch (xd->mi_8x8[0]->mbmi.sb_type) { - case BLOCK_8X8: - vp9_mse8x8(src, src_stride, ref, ref_stride, &sse); - break; - case BLOCK_16X8: - vp9_mse16x8(src, src_stride, ref, ref_stride, &sse); - break; - case BLOCK_8X16: - vp9_mse8x16(src, src_stride, ref, ref_stride, &sse); - break; - default: - vp9_mse16x16(src, src_stride, ref, ref_stride, &sse); - break; - } + vp9_variance_fn_t fn = get_block_variance_fn(xd->mi_8x8[0]->mbmi.sb_type); + fn(src, src_stride, ref, ref_stride, &sse); return sse; } @@ -421,20 +422,7 @@ static void first_pass_motion_search(VP9_COMP *cpi, MACROBLOCK *x, further_steps -= sr; // override the default variance function to use MSE - switch (xd->mi_8x8[0]->mbmi.sb_type) { - case BLOCK_8X8: - v_fn_ptr.vf = vp9_mse8x8; - break; - case BLOCK_16X8: - v_fn_ptr.vf = vp9_mse16x8; - break; - case BLOCK_8X16: - v_fn_ptr.vf = vp9_mse8x16; - break; - default: - v_fn_ptr.vf = vp9_mse16x16; - break; - } + v_fn_ptr.vf = get_block_variance_fn(xd->mi_8x8[0]->mbmi.sb_type); // Set up pointers for this macro block recon buffer xd->plane[0].pre[0].buf = recon_buffer->y_buffer + recon_yoffset;