From 6c8170af52b8d29f52e3e155300de1f4e8e27624 Mon Sep 17 00:00:00 2001 From: Jim Bankoski <jimbankoski@google.com> Date: Wed, 10 Jul 2013 07:19:09 -0700 Subject: [PATCH] b_width_log2 and b_height_log2 lookups Replace case statement with lookup. Small speed gain at low speed settings but at speed 2+ where the number of motion searches etc. falls the impact rises to ~3-4%. Change-Id: Idff639b7b302ee65e042b7bf836943ac0a06fad8 Change-Id: I5940719a4a161f8c26ac9a6753f1678494cec644 --- vp9/common/vp9_blockd.h | 38 +++--------------------------------- vp9/common/vp9_common_data.c | 17 ++++++++++++++++ vp9/common/vp9_common_data.h | 19 ++++++++++++++++++ vp9/vp9_common.mk | 2 ++ 4 files changed, 41 insertions(+), 35 deletions(-) create mode 100644 vp9/common/vp9_common_data.c create mode 100644 vp9/common/vp9_common_data.h diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h index 5507942180..8c5827663d 100644 --- a/vp9/common/vp9_blockd.h +++ b/vp9/common/vp9_blockd.h @@ -20,6 +20,7 @@ #include "vpx_ports/mem.h" #include "vp9/common/vp9_common.h" #include "vp9/common/vp9_enums.h" +#include "vp9/common/vp9_common_data.h" #define BLOCK_SIZE_GROUPS 4 #define MAX_MB_SEGMENTS 8 @@ -141,43 +142,10 @@ typedef enum { } MV_REFERENCE_FRAME; static INLINE int b_width_log2(BLOCK_SIZE_TYPE sb_type) { - switch (sb_type) { - case BLOCK_SIZE_SB4X8: - case BLOCK_SIZE_AB4X4: return 0; - case BLOCK_SIZE_SB8X4: - case BLOCK_SIZE_SB8X8: - case BLOCK_SIZE_SB8X16: return 1; - case BLOCK_SIZE_SB16X8: - case BLOCK_SIZE_MB16X16: - case BLOCK_SIZE_SB16X32: return 2; - case BLOCK_SIZE_SB32X16: - case BLOCK_SIZE_SB32X32: - case BLOCK_SIZE_SB32X64: return 3; - case BLOCK_SIZE_SB64X32: - case BLOCK_SIZE_SB64X64: return 4; - default: assert(0); - return -1; - } + return b_width_log2_lookup[sb_type]; } - static INLINE int b_height_log2(BLOCK_SIZE_TYPE sb_type) { - switch (sb_type) { - case BLOCK_SIZE_SB8X4: - case BLOCK_SIZE_AB4X4: return 0; - case BLOCK_SIZE_SB4X8: - case BLOCK_SIZE_SB8X8: - case BLOCK_SIZE_SB16X8: return 1; - case BLOCK_SIZE_SB8X16: - case BLOCK_SIZE_MB16X16: - case BLOCK_SIZE_SB32X16: return 2; - case BLOCK_SIZE_SB16X32: - case BLOCK_SIZE_SB32X32: - case BLOCK_SIZE_SB64X32: return 3; - case BLOCK_SIZE_SB32X64: - case BLOCK_SIZE_SB64X64: return 4; - default: assert(0); - return -1; - } + return b_height_log2_lookup[sb_type]; } static INLINE int mi_width_log2(BLOCK_SIZE_TYPE sb_type) { diff --git a/vp9/common/vp9_common_data.c b/vp9/common/vp9_common_data.c new file mode 100644 index 0000000000..feb107e137 --- /dev/null +++ b/vp9/common/vp9_common_data.c @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2010 The WebM project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "vp9/common/vp9_common_data.h" + +// Log 2 conversion lookup tables for block width and height +const int b_width_log2_lookup[BLOCK_SIZE_TYPES] = + {0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4}; +const int b_height_log2_lookup[BLOCK_SIZE_TYPES] = + {0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4}; diff --git a/vp9/common/vp9_common_data.h b/vp9/common/vp9_common_data.h new file mode 100644 index 0000000000..f080fddc77 --- /dev/null +++ b/vp9/common/vp9_common_data.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2010 The WebM project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef VP9_COMMON_VP9_COMMON_DATA_H_ +#define VP9_COMMON_VP9_COMMON_DATA_H_ + +#include "vp9/common/vp9_enums.h" + +extern const int b_width_log2_lookup[BLOCK_SIZE_TYPES]; +extern const int b_height_log2_lookup[BLOCK_SIZE_TYPES]; + +#endif // VP9_COMMON_VP9_COMMON_DATA_H diff --git a/vp9/vp9_common.mk b/vp9/vp9_common.mk index 55d139d057..9d0472d106 100644 --- a/vp9/vp9_common.mk +++ b/vp9/vp9_common.mk @@ -66,6 +66,8 @@ VP9_COMMON_SRCS-yes += common/vp9_reconinter.c VP9_COMMON_SRCS-yes += common/vp9_reconintra.c VP9_COMMON_SRCS-$(CONFIG_POSTPROC_VISUALIZER) += common/vp9_textblit.c VP9_COMMON_SRCS-yes += common/vp9_treecoder.c +VP9_COMMON_SRCS-yes += common/vp9_common_data.c +VP9_COMMON_SRCS-yes += common/vp9_common_data.h VP9_COMMON_SRCS-$(ARCH_X86)$(ARCH_X86_64) += common/x86/vp9_loopfilter_x86.h VP9_COMMON_SRCS-$(ARCH_X86)$(ARCH_X86_64) += common/x86/vp9_postproc_x86.h -- GitLab