summaryrefslogtreecommitdiff
path: root/vp9/common
diff options
context:
space:
mode:
authorDeb Mukherjee <debargha@google.com>2013-07-10 16:51:07 -0700
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2013-07-12 10:22:56 -0700
commit94c481f9f17828db0d4b8b4f2549bc5ff1075cf8 (patch)
treeb78782202b3ee6832d40c56c64e1b7cf4235be6a /vp9/common
parent727631873d94e9526fa2e1f91b6a364957a89481 (diff)
downloadlibvpx-94c481f9f17828db0d4b8b4f2549bc5ff1075cf8.tar
libvpx-94c481f9f17828db0d4b8b4f2549bc5ff1075cf8.tar.gz
libvpx-94c481f9f17828db0d4b8b4f2549bc5ff1075cf8.tar.bz2
libvpx-94c481f9f17828db0d4b8b4f2549bc5ff1075cf8.zip
Some minor cleanups for efficiency
Implements some of the helper functions more efficiently with lookups rathers than branches. Modeling function is consolidated to reduce some computations. Also merged the two enums BLOCK_SIZE_TYPES and BlockSize into one because there is no need to keep them separate (even though the semantics are a little different). No bitstream or output change. About 0.5% speedup Change-Id: I7d71a66e8031ddb340744dc493f22976052b8f9f
Diffstat (limited to 'vp9/common')
-rw-r--r--vp9/common/vp9_blockd.h100
-rw-r--r--vp9/common/vp9_common_data.c56
-rw-r--r--vp9/common/vp9_common_data.h4
-rw-r--r--vp9/common/vp9_enums.h43
4 files changed, 105 insertions, 98 deletions
diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h
index e67250b0f..9ec6c187b 100644
--- a/vp9/common/vp9_blockd.h
+++ b/vp9/common/vp9_blockd.h
@@ -91,22 +91,6 @@ static INLINE int is_inter_mode(MB_PREDICTION_MODE mode) {
return mode >= NEARESTMV && mode <= NEWMV;
}
-// Segment level features.
-typedef enum {
- TX_4X4 = 0, // 4x4 dct transform
- TX_8X8 = 1, // 8x8 dct transform
- TX_16X16 = 2, // 16x16 dct transform
- TX_32X32 = 3, // 32x32 dct transform
- TX_SIZE_MAX_SB, // Number of transforms available to SBs
-} TX_SIZE;
-
-typedef enum {
- DCT_DCT = 0, // DCT in both horizontal and vertical
- ADST_DCT = 1, // ADST in vertical, DCT in horizontal
- DCT_ADST = 2, // DCT in vertical, ADST in horizontal
- ADST_ADST = 3 // ADST in both directions
-} TX_TYPE;
-
#define VP9_INTRA_MODES (TM_PRED + 1)
#define VP9_INTER_MODES (1 + NEWMV - NEARESTMV)
@@ -293,7 +277,7 @@ typedef struct macroblockd {
} MACROBLOCKD;
-static int *get_sb_index(MACROBLOCKD *xd, BLOCK_SIZE_TYPE subsize) {
+static INLINE int *get_sb_index(MACROBLOCKD *xd, BLOCK_SIZE_TYPE subsize) {
switch (subsize) {
case BLOCK_SIZE_SB64X64:
case BLOCK_SIZE_SB64X32:
@@ -361,49 +345,8 @@ static INLINE int partition_plane_context(MACROBLOCKD *xd,
static BLOCK_SIZE_TYPE get_subsize(BLOCK_SIZE_TYPE bsize,
PARTITION_TYPE partition) {
- BLOCK_SIZE_TYPE subsize = bsize;
- switch (partition) {
- case PARTITION_NONE:
- break;
- case PARTITION_HORZ:
- if (bsize == BLOCK_SIZE_SB64X64)
- subsize = BLOCK_SIZE_SB64X32;
- else if (bsize == BLOCK_SIZE_SB32X32)
- subsize = BLOCK_SIZE_SB32X16;
- else if (bsize == BLOCK_SIZE_MB16X16)
- subsize = BLOCK_SIZE_SB16X8;
- else if (bsize == BLOCK_SIZE_SB8X8)
- subsize = BLOCK_SIZE_SB8X4;
- else
- assert(0);
- break;
- case PARTITION_VERT:
- if (bsize == BLOCK_SIZE_SB64X64)
- subsize = BLOCK_SIZE_SB32X64;
- else if (bsize == BLOCK_SIZE_SB32X32)
- subsize = BLOCK_SIZE_SB16X32;
- else if (bsize == BLOCK_SIZE_MB16X16)
- subsize = BLOCK_SIZE_SB8X16;
- else if (bsize == BLOCK_SIZE_SB8X8)
- subsize = BLOCK_SIZE_SB4X8;
- else
- assert(0);
- break;
- case PARTITION_SPLIT:
- if (bsize == BLOCK_SIZE_SB64X64)
- subsize = BLOCK_SIZE_SB32X32;
- else if (bsize == BLOCK_SIZE_SB32X32)
- subsize = BLOCK_SIZE_MB16X16;
- else if (bsize == BLOCK_SIZE_MB16X16)
- subsize = BLOCK_SIZE_SB8X8;
- else if (bsize == BLOCK_SIZE_SB8X8)
- subsize = BLOCK_SIZE_AB4X4;
- else
- assert(0);
- break;
- default:
- assert(0);
- }
+ BLOCK_SIZE_TYPE subsize = subsize_lookup[partition][bsize];
+ assert(subsize != BLOCK_SIZE_TYPES);
return subsize;
}
@@ -444,31 +387,10 @@ static void setup_block_dptrs(MACROBLOCKD *xd, int ss_x, int ss_y) {
}
-static TX_SIZE get_uv_tx_size(const MB_MODE_INFO *mbmi) {
+static INLINE TX_SIZE get_uv_tx_size(const MB_MODE_INFO *mbmi) {
const TX_SIZE size = mbmi->txfm_size;
-
- switch (mbmi->sb_type) {
- case BLOCK_SIZE_SB64X64:
- return size;
- case BLOCK_SIZE_SB64X32:
- case BLOCK_SIZE_SB32X64:
- case BLOCK_SIZE_SB32X32:
- if (size == TX_32X32)
- return TX_16X16;
- else
- return size;
- case BLOCK_SIZE_SB32X16:
- case BLOCK_SIZE_SB16X32:
- case BLOCK_SIZE_MB16X16:
- if (size == TX_16X16)
- return TX_8X8;
- else
- return size;
- default:
- return TX_4X4;
- }
-
- return size;
+ const TX_SIZE max_size = max_uv_txsize_lookup[mbmi->sb_type];
+ return (size > max_size ? max_size : size);
}
struct plane_block_idx {
@@ -507,6 +429,16 @@ static INLINE int plane_block_height(BLOCK_SIZE_TYPE bsize,
return 4 << (b_height_log2(bsize) - plane->subsampling_y);
}
+static INLINE int plane_block_width_log2by4(
+ BLOCK_SIZE_TYPE bsize, const struct macroblockd_plane* plane) {
+ return (b_width_log2(bsize) - plane->subsampling_x);
+}
+
+static INLINE int plane_block_height_log2by4(
+ BLOCK_SIZE_TYPE bsize, const struct macroblockd_plane* plane) {
+ return (b_height_log2(bsize) - plane->subsampling_y);
+}
+
typedef void (*foreach_transformed_block_visitor)(int plane, int block,
BLOCK_SIZE_TYPE bsize,
int ss_txfrm_size,
diff --git a/vp9/common/vp9_common_data.c b/vp9/common/vp9_common_data.c
index 57e3d2f58..d5b51e89d 100644
--- a/vp9/common/vp9_common_data.c
+++ b/vp9/common/vp9_common_data.c
@@ -8,6 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+
+#include "vp9/common/vp9_blockd.h"
#include "vp9/common/vp9_common_data.h"
// Log 2 conversion lookup tables for block width and height
@@ -20,3 +22,57 @@ const int mi_width_log2_lookup[BLOCK_SIZE_TYPES] =
{0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3};
const int mi_height_log2_lookup[BLOCK_SIZE_TYPES] =
{0, 0, 0, 0, 1, 0, 1, 2, 1, 2, 3, 2, 3};
+
+const BLOCK_SIZE_TYPE subsize_lookup[PARTITION_TYPES][BLOCK_SIZE_TYPES] = {
+ { // PARTITION_NONE
+ BLOCK_SIZE_AB4X4, BLOCK_SIZE_SB4X8, BLOCK_SIZE_SB8X4,
+ BLOCK_SIZE_SB8X8, BLOCK_SIZE_SB8X16, BLOCK_SIZE_SB16X8,
+ BLOCK_SIZE_MB16X16, BLOCK_SIZE_SB16X32, BLOCK_SIZE_SB32X16,
+ BLOCK_SIZE_SB32X32, BLOCK_SIZE_SB32X64, BLOCK_SIZE_SB64X32,
+ BLOCK_SIZE_SB64X64,
+ }, { // PARTITION_HORZ
+ BLOCK_SIZE_TYPES, BLOCK_SIZE_TYPES, BLOCK_SIZE_TYPES,
+ BLOCK_SIZE_SB8X4, BLOCK_SIZE_TYPES, BLOCK_SIZE_TYPES,
+ BLOCK_SIZE_SB16X8, BLOCK_SIZE_TYPES, BLOCK_SIZE_TYPES,
+ BLOCK_SIZE_SB32X16, BLOCK_SIZE_TYPES, BLOCK_SIZE_TYPES,
+ BLOCK_SIZE_SB64X32,
+ }, { // PARTITION_VERT
+ BLOCK_SIZE_TYPES, BLOCK_SIZE_TYPES, BLOCK_SIZE_TYPES,
+ BLOCK_SIZE_SB4X8, BLOCK_SIZE_TYPES, BLOCK_SIZE_TYPES,
+ BLOCK_SIZE_SB8X16, BLOCK_SIZE_TYPES, BLOCK_SIZE_TYPES,
+ BLOCK_SIZE_SB16X32, BLOCK_SIZE_TYPES, BLOCK_SIZE_TYPES,
+ BLOCK_SIZE_SB32X64,
+ }, { // PARTITION_SPLIT
+ BLOCK_SIZE_TYPES, BLOCK_SIZE_TYPES, BLOCK_SIZE_TYPES,
+ BLOCK_SIZE_AB4X4, BLOCK_SIZE_TYPES, BLOCK_SIZE_TYPES,
+ BLOCK_SIZE_SB8X8, BLOCK_SIZE_TYPES, BLOCK_SIZE_TYPES,
+ BLOCK_SIZE_MB16X16, BLOCK_SIZE_TYPES, BLOCK_SIZE_TYPES,
+ BLOCK_SIZE_SB32X32,
+ }
+};
+
+const TX_SIZE max_txsize_lookup[BLOCK_SIZE_TYPES] = {
+ TX_4X4, TX_4X4, TX_4X4,
+ TX_8X8, TX_8X8, TX_8X8,
+ TX_16X16, TX_16X16, TX_16X16,
+ TX_32X32, TX_32X32, TX_32X32, TX_32X32
+};
+const TX_SIZE max_uv_txsize_lookup[BLOCK_SIZE_TYPES] = {
+ TX_4X4, TX_4X4, TX_4X4,
+ TX_4X4, TX_4X4, TX_4X4,
+ TX_8X8, TX_8X8, TX_8X8,
+ TX_16X16, TX_16X16, TX_16X16, TX_32X32
+};
+
+const BLOCK_SIZE_TYPE bsize_from_dim_lookup[5][5] = {
+ {BLOCK_SIZE_AB4X4, BLOCK_SIZE_SB4X8, BLOCK_SIZE_SB4X8,
+ BLOCK_SIZE_SB4X8, BLOCK_SIZE_SB4X8},
+ {BLOCK_SIZE_SB8X4, BLOCK_SIZE_SB8X8, BLOCK_SIZE_SB8X16,
+ BLOCK_SIZE_SB8X16, BLOCK_SIZE_SB8X16},
+ {BLOCK_SIZE_SB16X8, BLOCK_SIZE_SB16X8, BLOCK_SIZE_MB16X16,
+ BLOCK_SIZE_SB16X32, BLOCK_SIZE_SB16X32},
+ {BLOCK_SIZE_SB32X16, BLOCK_SIZE_SB32X16, BLOCK_SIZE_SB32X16,
+ BLOCK_SIZE_SB32X32, BLOCK_SIZE_SB32X64},
+ {BLOCK_SIZE_SB64X32, BLOCK_SIZE_SB64X32, BLOCK_SIZE_SB64X32,
+ BLOCK_SIZE_SB64X32, BLOCK_SIZE_SB64X64}
+};
diff --git a/vp9/common/vp9_common_data.h b/vp9/common/vp9_common_data.h
index 7f9f90433..52c314897 100644
--- a/vp9/common/vp9_common_data.h
+++ b/vp9/common/vp9_common_data.h
@@ -17,5 +17,9 @@ extern const int b_width_log2_lookup[BLOCK_SIZE_TYPES];
extern const int b_height_log2_lookup[BLOCK_SIZE_TYPES];
extern const int mi_width_log2_lookup[BLOCK_SIZE_TYPES];
extern const int mi_height_log2_lookup[BLOCK_SIZE_TYPES];
+extern const BLOCK_SIZE_TYPE subsize_lookup[PARTITION_TYPES][BLOCK_SIZE_TYPES];
+extern const TX_SIZE max_txsize_lookup[BLOCK_SIZE_TYPES];
+extern const TX_SIZE max_uv_txsize_lookup[BLOCK_SIZE_TYPES];
+extern const BLOCK_SIZE_TYPE bsize_from_dim_lookup[5][5];
#endif // VP9_COMMON_VP9_COMMON_DATA_H
diff --git a/vp9/common/vp9_enums.h b/vp9/common/vp9_enums.h
index dfd6a4a3f..bc739ffbd 100644
--- a/vp9/common/vp9_enums.h
+++ b/vp9/common/vp9_enums.h
@@ -22,20 +22,20 @@
#define MI_MASK (MI_BLOCK_SIZE - 1)
typedef enum BLOCK_SIZE_TYPE {
- BLOCK_SIZE_AB4X4,
- BLOCK_SIZE_SB4X8,
- BLOCK_SIZE_SB8X4,
- BLOCK_SIZE_SB8X8,
- BLOCK_SIZE_SB8X16,
- BLOCK_SIZE_SB16X8,
- BLOCK_SIZE_MB16X16,
- BLOCK_SIZE_SB16X32,
- BLOCK_SIZE_SB32X16,
- BLOCK_SIZE_SB32X32,
- BLOCK_SIZE_SB32X64,
- BLOCK_SIZE_SB64X32,
- BLOCK_SIZE_SB64X64,
- BLOCK_SIZE_TYPES
+ BLOCK_SIZE_AB4X4, BLOCK_4X4 = BLOCK_SIZE_AB4X4,
+ BLOCK_SIZE_SB4X8, BLOCK_4X8 = BLOCK_SIZE_SB4X8,
+ BLOCK_SIZE_SB8X4, BLOCK_8X4 = BLOCK_SIZE_SB8X4,
+ BLOCK_SIZE_SB8X8, BLOCK_8X8 = BLOCK_SIZE_SB8X8,
+ BLOCK_SIZE_SB8X16, BLOCK_8X16 = BLOCK_SIZE_SB8X16,
+ BLOCK_SIZE_SB16X8, BLOCK_16X8 = BLOCK_SIZE_SB16X8,
+ BLOCK_SIZE_MB16X16, BLOCK_16X16 = BLOCK_SIZE_MB16X16,
+ BLOCK_SIZE_SB16X32, BLOCK_16X32 = BLOCK_SIZE_SB16X32,
+ BLOCK_SIZE_SB32X16, BLOCK_32X16 = BLOCK_SIZE_SB32X16,
+ BLOCK_SIZE_SB32X32, BLOCK_32X32 = BLOCK_SIZE_SB32X32,
+ BLOCK_SIZE_SB32X64, BLOCK_32X64 = BLOCK_SIZE_SB32X64,
+ BLOCK_SIZE_SB64X32, BLOCK_64X32 = BLOCK_SIZE_SB64X32,
+ BLOCK_SIZE_SB64X64, BLOCK_64X64 = BLOCK_SIZE_SB64X64,
+ BLOCK_SIZE_TYPES, BLOCK_MAX_SB_SEGMENTS = BLOCK_SIZE_TYPES,
} BLOCK_SIZE_TYPE;
typedef enum PARTITION_TYPE {
@@ -49,4 +49,19 @@ typedef enum PARTITION_TYPE {
#define PARTITION_PLOFFSET 4 // number of probability models per block size
#define NUM_PARTITION_CONTEXTS (4 * PARTITION_PLOFFSET)
+typedef enum {
+ TX_4X4 = 0, // 4x4 dct transform
+ TX_8X8 = 1, // 8x8 dct transform
+ TX_16X16 = 2, // 16x16 dct transform
+ TX_32X32 = 3, // 32x32 dct transform
+ TX_SIZE_MAX_SB, // Number of transforms available to SBs
+} TX_SIZE;
+
+typedef enum {
+ DCT_DCT = 0, // DCT in both horizontal and vertical
+ ADST_DCT = 1, // ADST in vertical, DCT in horizontal
+ DCT_ADST = 2, // DCT in vertical, ADST in horizontal
+ ADST_ADST = 3 // ADST in both directions
+} TX_TYPE;
+
#endif // VP9_COMMON_VP9_ENUMS_H_