From 860e46764332ca90cf4b2b6eb21ab5a64ba9031e Mon Sep 17 00:00:00 2001 From: Dmitry Kovalev Date: Fri, 11 Oct 2013 16:25:50 -0700 Subject: [PATCH] Adding TREE_SIZE macro + cleanup. Using TREE_SIZE for the following trees: vp9_intra_mode_tree vp9_inter_mode_tree vp9_partition_tree vp9_switchable_interp_tree vp9_mv_joint_tree vp9_mv_class_tree vp9_mv_class0_tree vp9_mv_fp_tree Change-Id: I0212bb4c1ee6648249f68517e28a67a56591ee1b --- vp9/common/vp9_entropymode.c | 15 +++++++-------- vp9/common/vp9_entropymode.h | 12 +++++------- vp9/common/vp9_entropymv.c | 8 ++++---- vp9/common/vp9_entropymv.h | 16 ++++++++-------- vp9/common/vp9_treecoder.h | 2 ++ 5 files changed, 26 insertions(+), 27 deletions(-) diff --git a/vp9/common/vp9_entropymode.c b/vp9/common/vp9_entropymode.c index e17679616..56e644460 100644 --- a/vp9/common/vp9_entropymode.c +++ b/vp9/common/vp9_entropymode.c @@ -226,7 +226,7 @@ static const vp9_prob default_inter_mode_probs[INTER_MODE_CONTEXTS] }; /* Array indices are identical to previously-existing INTRAMODECONTEXTNODES. */ -const vp9_tree_index vp9_intra_mode_tree[INTRA_MODES * 2 - 2] = { +const vp9_tree_index vp9_intra_mode_tree[TREE_SIZE(INTRA_MODES)] = { -DC_PRED, 2, /* 0 = DC_NODE */ -TM_PRED, 4, /* 1 = TM_NODE */ -V_PRED, 6, /* 2 = V_NODE */ @@ -237,22 +237,20 @@ const vp9_tree_index vp9_intra_mode_tree[INTRA_MODES * 2 - 2] = { -D63_PRED, 16, /* 7 = D63_NODE */ -D153_PRED, -D207_PRED /* 8 = D153_NODE */ }; +struct vp9_token vp9_intra_mode_encodings[INTRA_MODES]; -const vp9_tree_index vp9_inter_mode_tree[6] = { +const vp9_tree_index vp9_inter_mode_tree[TREE_SIZE(INTER_MODES)] = { -ZEROMV, 2, -NEARESTMV, 4, -NEARMV, -NEWMV }; +struct vp9_token vp9_inter_mode_encodings[INTER_MODES]; -const vp9_tree_index vp9_partition_tree[6] = { +const vp9_tree_index vp9_partition_tree[TREE_SIZE(PARTITION_TYPES)] = { -PARTITION_NONE, 2, -PARTITION_HORZ, 4, -PARTITION_VERT, -PARTITION_SPLIT }; - -struct vp9_token vp9_intra_mode_encodings[INTRA_MODES]; -struct vp9_token vp9_inter_mode_encodings[INTER_MODES]; - struct vp9_token vp9_partition_encodings[PARTITION_TYPES]; static const vp9_prob default_intra_inter_p[INTRA_INTER_CONTEXTS] = { @@ -338,7 +336,8 @@ void vp9_init_mbmode_probs(VP9_COMMON *cm) { vp9_copy(cm->fc.mbskip_probs, default_mbskip_probs); } -const vp9_tree_index vp9_switchable_interp_tree[SWITCHABLE_FILTERS*2-2] = { +const vp9_tree_index vp9_switchable_interp_tree + [TREE_SIZE(SWITCHABLE_FILTERS)] = { -EIGHTTAP, 2, -EIGHTTAP_SMOOTH, -EIGHTTAP_SHARP }; diff --git a/vp9/common/vp9_entropymode.h b/vp9/common/vp9_entropymode.h index c73f79a03..ab37b75c6 100644 --- a/vp9/common/vp9_entropymode.h +++ b/vp9/common/vp9_entropymode.h @@ -37,19 +37,17 @@ extern const vp9_prob vp9_kf_uv_mode_prob[INTRA_MODES][INTRA_MODES - 1]; extern const vp9_prob vp9_kf_y_mode_prob[INTRA_MODES][INTRA_MODES] [INTRA_MODES - 1]; -extern const vp9_tree_index vp9_intra_mode_tree[]; -extern const vp9_tree_index vp9_inter_mode_tree[]; - +extern const vp9_tree_index vp9_intra_mode_tree[TREE_SIZE(INTRA_MODES)]; extern struct vp9_token vp9_intra_mode_encodings[INTRA_MODES]; + +extern const vp9_tree_index vp9_inter_mode_tree[TREE_SIZE(INTER_MODES)]; extern struct vp9_token vp9_inter_mode_encodings[INTER_MODES]; -// probability models for partition information -extern const vp9_tree_index vp9_partition_tree[]; +extern const vp9_tree_index vp9_partition_tree[TREE_SIZE(PARTITION_TYPES)]; extern struct vp9_token vp9_partition_encodings[PARTITION_TYPES]; extern const vp9_tree_index vp9_switchable_interp_tree - [2 * (SWITCHABLE_FILTERS - 1)]; - + [TREE_SIZE(SWITCHABLE_FILTERS)]; extern struct vp9_token vp9_switchable_interp_encodings[SWITCHABLE_FILTERS]; void vp9_entropy_mode_init(); diff --git a/vp9/common/vp9_entropymv.c b/vp9/common/vp9_entropymv.c index baff637e8..e85118118 100644 --- a/vp9/common/vp9_entropymv.c +++ b/vp9/common/vp9_entropymv.c @@ -18,14 +18,14 @@ /* Integer pel reference mv threshold for use of high-precision 1/8 mv */ #define COMPANDED_MVREF_THRESH 8 -const vp9_tree_index vp9_mv_joint_tree[2 * MV_JOINTS - 2] = { +const vp9_tree_index vp9_mv_joint_tree[TREE_SIZE(MV_JOINTS)] = { -MV_JOINT_ZERO, 2, -MV_JOINT_HNZVZ, 4, -MV_JOINT_HZVNZ, -MV_JOINT_HNZVNZ }; struct vp9_token vp9_mv_joint_encodings[MV_JOINTS]; -const vp9_tree_index vp9_mv_class_tree[2 * MV_CLASSES - 2] = { +const vp9_tree_index vp9_mv_class_tree[TREE_SIZE(MV_CLASSES)] = { -MV_CLASS_0, 2, -MV_CLASS_1, 4, 6, 8, @@ -39,12 +39,12 @@ const vp9_tree_index vp9_mv_class_tree[2 * MV_CLASSES - 2] = { }; struct vp9_token vp9_mv_class_encodings[MV_CLASSES]; -const vp9_tree_index vp9_mv_class0_tree[2 * CLASS0_SIZE - 2] = { +const vp9_tree_index vp9_mv_class0_tree[TREE_SIZE(CLASS0_SIZE)] = { -0, -1, }; struct vp9_token vp9_mv_class0_encodings[CLASS0_SIZE]; -const vp9_tree_index vp9_mv_fp_tree[2 * 4 - 2] = { +const vp9_tree_index vp9_mv_fp_tree[TREE_SIZE(4)] = { -0, 2, -1, 4, -2, -3 diff --git a/vp9/common/vp9_entropymv.h b/vp9/common/vp9_entropymv.h index 3b782ab0a..c42653d42 100644 --- a/vp9/common/vp9_entropymv.h +++ b/vp9/common/vp9_entropymv.h @@ -43,9 +43,6 @@ static INLINE int mv_joint_horizontal(MV_JOINT_TYPE type) { return type == MV_JOINT_HNZVZ || type == MV_JOINT_HNZVNZ; } -extern const vp9_tree_index vp9_mv_joint_tree[2 * MV_JOINTS - 2]; -extern struct vp9_token vp9_mv_joint_encodings[MV_JOINTS]; - /* Symbols for coding magnitude class of nonzero components */ #define MV_CLASSES 11 typedef enum { @@ -62,9 +59,6 @@ typedef enum { MV_CLASS_10 = 10, /* (1024,2048] integer pel */ } MV_CLASS_TYPE; -extern const vp9_tree_index vp9_mv_class_tree[2 * MV_CLASSES - 2]; -extern struct vp9_token vp9_mv_class_encodings[MV_CLASSES]; - #define CLASS0_BITS 1 /* bits at integer precision for class 0 */ #define CLASS0_SIZE (1 << CLASS0_BITS) #define MV_OFFSET_BITS (MV_CLASSES + CLASS0_BITS - 2) @@ -77,10 +71,16 @@ extern struct vp9_token vp9_mv_class_encodings[MV_CLASSES]; #define MV_UPP ((1 << MV_IN_USE_BITS) - 1) #define MV_LOW (-(1 << MV_IN_USE_BITS)) -extern const vp9_tree_index vp9_mv_class0_tree[2 * CLASS0_SIZE - 2]; +extern const vp9_tree_index vp9_mv_joint_tree[TREE_SIZE(MV_JOINTS)]; +extern struct vp9_token vp9_mv_joint_encodings[MV_JOINTS]; + +extern const vp9_tree_index vp9_mv_class_tree[TREE_SIZE(MV_CLASSES)]; +extern struct vp9_token vp9_mv_class_encodings[MV_CLASSES]; + +extern const vp9_tree_index vp9_mv_class0_tree[TREE_SIZE(CLASS0_SIZE)]; extern struct vp9_token vp9_mv_class0_encodings[CLASS0_SIZE]; -extern const vp9_tree_index vp9_mv_fp_tree[2 * 4 - 2]; +extern const vp9_tree_index vp9_mv_fp_tree[TREE_SIZE(4)]; extern struct vp9_token vp9_mv_fp_encodings[4]; typedef struct { diff --git a/vp9/common/vp9_treecoder.h b/vp9/common/vp9_treecoder.h index 24e6fa295..4ba171f46 100644 --- a/vp9/common/vp9_treecoder.h +++ b/vp9/common/vp9_treecoder.h @@ -21,6 +21,8 @@ typedef uint8_t vp9_prob; typedef int8_t vp9_tree_index; +#define TREE_SIZE(leaf_count) (2 * (leaf_count) - 2) + #define vp9_complement(x) (255 - x) /* We build coding trees compactly in arrays. -- 2.40.0