From 72fd127f8c03333e0b6d1cc5f1e579a7b8af38fb Mon Sep 17 00:00:00 2001 From: Dmitry Kovalev Date: Wed, 18 Sep 2013 13:11:38 +0400 Subject: [PATCH] Removing redundant code from vp9_mcomp.c. Replacing ((1 << MV_MAX_BITS) - 1) with MV_MAX, adding const qualifiers, reusing computed values. Change-Id: I7b46d47f6c644b079d9c3478116a9de465a9baec --- vp9/encoder/vp9_mcomp.c | 103 +++++++++++++--------------------------- 1 file changed, 34 insertions(+), 69 deletions(-) diff --git a/vp9/encoder/vp9_mcomp.c b/vp9/encoder/vp9_mcomp.c index 136008847..8f340d2af 100644 --- a/vp9/encoder/vp9_mcomp.c +++ b/vp9/encoder/vp9_mcomp.c @@ -333,11 +333,9 @@ int vp9_find_best_sub_pixel_iterative(MACROBLOCK *x, unsigned int eighthiters = iters_per_step; int thismse; - uint8_t *y = xd->plane[0].pre[0].buf + - (bestmv->as_mv.row) * xd->plane[0].pre[0].stride + - bestmv->as_mv.col; - const int y_stride = xd->plane[0].pre[0].stride; + const int offset = (bestmv->as_mv.row) * y_stride + bestmv->as_mv.col; + uint8_t *y = xd->plane[0].pre[0].buf + offset; int rr = ref_mv->as_mv.row; int rc = ref_mv->as_mv.col; @@ -352,8 +350,6 @@ int vp9_find_best_sub_pixel_iterative(MACROBLOCK *x, int tr = br; int tc = bc; - const int offset = (bestmv->as_mv.row) * y_stride + bestmv->as_mv.col; - // central mv bestmv->as_mv.row <<= 3; bestmv->as_mv.col <<= 3; @@ -424,45 +420,32 @@ int vp9_find_best_sub_pixel_tree(MACROBLOCK *x, int *distortion, unsigned int *sse1) { uint8_t *z = x->plane[0].src.buf; - int src_stride = x->plane[0].src.stride; + const int src_stride = x->plane[0].src.stride; MACROBLOCKD *xd = &x->e_mbd; - int rr, rc, br, bc, hstep; - int tr, tc; unsigned int besterr = INT_MAX; unsigned int sse; unsigned int whichdir; int thismse; - int maxc, minc, maxr, minr; - int y_stride; - int offset; unsigned int halfiters = iters_per_step; unsigned int quarteriters = iters_per_step; unsigned int eighthiters = iters_per_step; - uint8_t *y = xd->plane[0].pre[0].buf + - (bestmv->as_mv.row) * xd->plane[0].pre[0].stride + - bestmv->as_mv.col; - - y_stride = xd->plane[0].pre[0].stride; - - rr = ref_mv->as_mv.row; - rc = ref_mv->as_mv.col; - br = bestmv->as_mv.row << 3; - bc = bestmv->as_mv.col << 3; - hstep = 4; - minc = MAX(x->mv_col_min << 3, - (ref_mv->as_mv.col) - ((1 << MV_MAX_BITS) - 1)); - maxc = MIN(x->mv_col_max << 3, - (ref_mv->as_mv.col) + ((1 << MV_MAX_BITS) - 1)); - minr = MAX(x->mv_row_min << 3, - (ref_mv->as_mv.row) - ((1 << MV_MAX_BITS) - 1)); - maxr = MIN(x->mv_row_max << 3, - (ref_mv->as_mv.row) + ((1 << MV_MAX_BITS) - 1)); + const int y_stride = xd->plane[0].pre[0].stride; + const int offset = bestmv->as_mv.row * y_stride + bestmv->as_mv.col; + uint8_t *y = xd->plane[0].pre[0].buf + offset; - tr = br; - tc = bc; + int rr = ref_mv->as_mv.row; + int rc = ref_mv->as_mv.col; + int br = bestmv->as_mv.row << 3; + int bc = bestmv->as_mv.col << 3; + int hstep = 4; + const int minc = MAX(x->mv_col_min << 3, ref_mv->as_mv.col - MV_MAX); + const int maxc = MIN(x->mv_col_max << 3, ref_mv->as_mv.col + MV_MAX); + const int minr = MAX(x->mv_row_min << 3, ref_mv->as_mv.row - MV_MAX); + const int maxr = MIN(x->mv_row_max << 3, ref_mv->as_mv.row + MV_MAX); - offset = (bestmv->as_mv.row) * y_stride + bestmv->as_mv.col; + int tr = br; + int tc = bc; // central mv bestmv->as_mv.row <<= 3; @@ -543,11 +526,9 @@ int vp9_find_best_sub_pixel_comp_iterative(MACROBLOCK *x, int thismse; DECLARE_ALIGNED_ARRAY(16, uint8_t, comp_pred, 64 * 64); - uint8_t *const y = xd->plane[0].pre[0].buf + - (bestmv->as_mv.row) * xd->plane[0].pre[0].stride + - bestmv->as_mv.col; - const int y_stride = xd->plane[0].pre[0].stride; + const int offset = bestmv->as_mv.row * y_stride + bestmv->as_mv.col; + uint8_t *const y = xd->plane[0].pre[0].buf + offset; int rr = ref_mv->as_mv.row; int rc = ref_mv->as_mv.col; @@ -562,8 +543,6 @@ int vp9_find_best_sub_pixel_comp_iterative(MACROBLOCK *x, int tr = br; int tc = bc; - const int offset = (bestmv->as_mv.row) * y_stride + bestmv->as_mv.col; - // central mv bestmv->as_mv.row <<= 3; bestmv->as_mv.col <<= 3; @@ -638,47 +617,33 @@ int vp9_find_best_sub_pixel_comp_tree(MACROBLOCK *x, const uint8_t *second_pred, int w, int h) { uint8_t *z = x->plane[0].src.buf; - int src_stride = x->plane[0].src.stride; + const int src_stride = x->plane[0].src.stride; MACROBLOCKD *xd = &x->e_mbd; - int rr, rc, br, bc, hstep; - int tr, tc; unsigned int besterr = INT_MAX; unsigned int sse; unsigned int whichdir; int thismse; - int maxc, minc, maxr, minr; - int y_stride; - int offset; unsigned int halfiters = iters_per_step; unsigned int quarteriters = iters_per_step; unsigned int eighthiters = iters_per_step; DECLARE_ALIGNED_ARRAY(16, uint8_t, comp_pred, 64 * 64); - uint8_t *y = xd->plane[0].pre[0].buf + - (bestmv->as_mv.row) * xd->plane[0].pre[0].stride + - bestmv->as_mv.col; - - y_stride = xd->plane[0].pre[0].stride; - - rr = ref_mv->as_mv.row; - rc = ref_mv->as_mv.col; - br = bestmv->as_mv.row << 3; - bc = bestmv->as_mv.col << 3; - hstep = 4; - minc = MAX(x->mv_col_min << 3, (ref_mv->as_mv.col) - - ((1 << MV_MAX_BITS) - 1)); - maxc = MIN(x->mv_col_max << 3, (ref_mv->as_mv.col) + - ((1 << MV_MAX_BITS) - 1)); - minr = MAX(x->mv_row_min << 3, (ref_mv->as_mv.row) - - ((1 << MV_MAX_BITS) - 1)); - maxr = MIN(x->mv_row_max << 3, (ref_mv->as_mv.row) + - ((1 << MV_MAX_BITS) - 1)); - - tr = br; - tc = bc; + const int y_stride = xd->plane[0].pre[0].stride; + const int offset = (bestmv->as_mv.row) * y_stride + bestmv->as_mv.col; + uint8_t *y = xd->plane[0].pre[0].buf + offset; + int rr = ref_mv->as_mv.row; + int rc = ref_mv->as_mv.col; + int br = bestmv->as_mv.row << 3; + int bc = bestmv->as_mv.col << 3; + int hstep = 4; + const int minc = MAX(x->mv_col_min << 3, ref_mv->as_mv.col - MV_MAX); + const int maxc = MIN(x->mv_col_max << 3, ref_mv->as_mv.col + MV_MAX); + const int minr = MAX(x->mv_row_min << 3, ref_mv->as_mv.row - MV_MAX); + const int maxr = MIN(x->mv_row_max << 3, ref_mv->as_mv.row + MV_MAX); - offset = (bestmv->as_mv.row) * y_stride + bestmv->as_mv.col; + int tr = br; + int tc = bc; // central mv bestmv->as_mv.row <<= 3; -- 2.40.0