ref: 392a958274f6456add66363ae2dfdfc060b94fe9
parent: c0ba42d3c0e8f28422c819e7b93413224a5cf2cb
author: John Koleszar <jkoleszar@google.com>
date: Mon Aug 9 09:27:26 EDT 2010
avoid negative array subscript warnings The mv_ref and sub_mv_ref token encodings are indexed from NEARESTMV and LEFT4X4, respectively, rather than being zero-based like the other token encodings. Change-Id: I3699c3f84111209ecfb91097c4b900773e9a3ad5
--- a/vp8/common/entropymode.c
+++ b/vp8/common/entropymode.c
@@ -264,8 +264,10 @@
vp8_tokens_from_tree(vp8_uv_mode_encodings, vp8_uv_mode_tree);
vp8_tokens_from_tree(vp8_mbsplit_encodings, vp8_mbsplit_tree);
- vp8_tokens_from_tree(VP8_MVREFENCODINGS, vp8_mv_ref_tree);
- vp8_tokens_from_tree(VP8_SUBMVREFENCODINGS, vp8_sub_mv_ref_tree);
+ vp8_tokens_from_tree_offset(vp8_mv_ref_encoding_array,
+ vp8_mv_ref_tree, NEARESTMV);
+ vp8_tokens_from_tree_offset(vp8_sub_mv_ref_encoding_array,
+ vp8_sub_mv_ref_tree, LEFT4X4);
vp8_tokens_from_tree(vp8_small_mvencodings, vp8_small_mvtree);
}
--- a/vp8/common/entropymode.h
+++ b/vp8/common/entropymode.h
@@ -54,10 +54,6 @@
extern struct vp8_token_struct vp8_mv_ref_encoding_array [VP8_MVREFS];
extern struct vp8_token_struct vp8_sub_mv_ref_encoding_array [VP8_SUBMVREFS];
-#define VP8_MVREFENCODINGS (vp8_mv_ref_encoding_array - NEARESTMV)
-#define VP8_SUBMVREFENCODINGS (vp8_sub_mv_ref_encoding_array - LEFT4X4)
-
-
extern const vp8_tree_index vp8_small_mvtree[];
extern struct vp8_token_struct vp8_small_mvencodings [8];
--- a/vp8/common/treecoder.c
+++ b/vp8/common/treecoder.c
@@ -47,6 +47,12 @@
tree2tok(p, t, 0, 0, 0);
}
+void vp8_tokens_from_tree_offset(struct vp8_token_struct *p, vp8_tree t,
+ int offset)
+{
+ tree2tok(p - offset, t, 0, 0, 0);
+}
+
static void branch_counts(
int n, /* n = size of alphabet */
vp8_token tok [ /* n */ ],
--- a/vp8/common/treecoder.h
+++ b/vp8/common/treecoder.h
@@ -54,6 +54,8 @@
/* Construct encoding array from tree. */
void vp8_tokens_from_tree(struct vp8_token_struct *, vp8_tree);
+void vp8_tokens_from_tree_offset(struct vp8_token_struct *, vp8_tree,
+ int offset);
/* Convert array of token occurrence counts into a table of probabilities
--- a/vp8/encoder/bitstream.c
+++ b/vp8/encoder/bitstream.c
@@ -792,7 +792,8 @@
assert(NEARESTMV <= m && m <= SPLITMV);
- vp8_write_token(w, vp8_mv_ref_tree, p, VP8_MVREFENCODINGS + m);
+ vp8_write_token(w, vp8_mv_ref_tree, p,
+ vp8_mv_ref_encoding_array - NEARESTMV + m);
}
static void write_sub_mv_ref
@@ -802,7 +803,8 @@
{
assert(LEFT4X4 <= m && m <= NEW4X4);
- vp8_write_token(w, vp8_sub_mv_ref_tree, p, VP8_SUBMVREFENCODINGS + m);
+ vp8_write_token(w, vp8_sub_mv_ref_tree, p,
+ vp8_sub_mv_ref_encoding_array - LEFT4X4 + m);
}
static void write_mv
--- a/vp8/encoder/rdopt.c
+++ b/vp8/encoder/rdopt.c
@@ -880,7 +880,8 @@
vp8_prob p [VP8_MVREFS-1];
assert(NEARESTMV <= m && m <= SPLITMV);
vp8_mv_ref_probs(p, near_mv_ref_ct);
- return vp8_cost_token(vp8_mv_ref_tree, p, VP8_MVREFENCODINGS + m);
+ return vp8_cost_token(vp8_mv_ref_tree, p,
+ vp8_mv_ref_encoding_array - NEARESTMV + m);
}
void vp8_set_mbmode_and_mvs(MACROBLOCK *x, MB_PREDICTION_MODE mb, MV *mv)