ref: bcd12de6c3a785473085fa9a9c2534e0ecb93062
parent: 3e7025022ef7732aa5aa41533715d7a249fd0ab4
author: Alex Converse <aconverse@google.com>
date: Fri Mar 3 10:02:56 EST 2017
Narrow cat6_high_cost tables to uint16_t Saves 2688 bytes of rodata. Change-Id: I46633b6e50c2845181c70fff6273a8e58fdd1e56
--- a/vp9/encoder/vp9_encodemb.c
+++ b/vp9/encoder/vp9_encodemb.c
@@ -113,9 +113,9 @@
mb->token_costs[tx_size][type][ref];
int best, band, pt, i, final_eob;
#if CONFIG_VP9_HIGHBITDEPTH
- const int *cat6_high_cost = vp9_get_high_cost_table(xd->bd);
+ const uint16_t *cat6_high_cost = vp9_get_high_cost_table(xd->bd);
#else
- const int *cat6_high_cost = vp9_get_high_cost_table(8);
+ const uint16_t *cat6_high_cost = vp9_get_high_cost_table(8);
#endif
assert((!type && !plane) || (type && plane));
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -360,9 +360,9 @@
uint8_t token_cache[32 * 32];
int cost;
#if CONFIG_VP9_HIGHBITDEPTH
- const int *cat6_high_cost = vp9_get_high_cost_table(xd->bd);
+ const uint16_t *cat6_high_cost = vp9_get_high_cost_table(xd->bd);
#else
- const int *cat6_high_cost = vp9_get_high_cost_table(8);
+ const uint16_t *cat6_high_cost = vp9_get_high_cost_table(8);
#endif
// Check for consistency of tx_size with mode info
--- a/vp9/encoder/vp9_tokenize.c
+++ b/vp9/encoder/vp9_tokenize.c
@@ -123,7 +123,7 @@
6620, 6632, 6654, 6666, 6677, 6689, 6751, 6763, 6774, 6786, 6808, 6820, 6831,
6843, 6890, 6902, 6913, 6925, 6947, 6959, 6970, 6982
};
-const int vp9_cat6_high_cost[64] = {
+const uint16_t vp9_cat6_high_cost[64] = {
88, 2251, 2727, 4890, 3148, 5311, 5787, 7950, 3666, 5829, 6305,
8468, 6726, 8889, 9365, 11528, 3666, 5829, 6305, 8468, 6726, 8889,
9365, 11528, 7244, 9407, 9883, 12046, 10304, 12467, 12943, 15106, 3666,
@@ -133,7 +133,7 @@
};
#if CONFIG_VP9_HIGHBITDEPTH
-const int vp9_cat6_high10_high_cost[256] = {
+const uint16_t vp9_cat6_high10_high_cost[256] = {
94, 2257, 2733, 4896, 3154, 5317, 5793, 7956, 3672, 5835, 6311,
8474, 6732, 8895, 9371, 11534, 3672, 5835, 6311, 8474, 6732, 8895,
9371, 11534, 7250, 9413, 9889, 12052, 10310, 12473, 12949, 15112, 3672,
@@ -159,7 +159,7 @@
18075, 20238, 18496, 20659, 21135, 23298, 19014, 21177, 21653, 23816, 22074,
24237, 24713, 26876
};
-const int vp9_cat6_high12_high_cost[1024] = {
+const uint16_t vp9_cat6_high12_high_cost[1024] = {
100, 2263, 2739, 4902, 3160, 5323, 5799, 7962, 3678, 5841, 6317,
8480, 6738, 8901, 9377, 11540, 3678, 5841, 6317, 8480, 6738, 8901,
9377, 11540, 7256, 9419, 9895, 12058, 10316, 12479, 12955, 15118, 3678,
--- a/vp9/encoder/vp9_tokenize.h
+++ b/vp9/encoder/vp9_tokenize.h
@@ -76,11 +76,11 @@
extern const TOKENVALUE *vp9_dct_cat_lt_10_value_tokens;
extern const int *vp9_dct_cat_lt_10_value_cost;
extern const int16_t vp9_cat6_low_cost[256];
-extern const int vp9_cat6_high_cost[64];
-extern const int vp9_cat6_high10_high_cost[256];
-extern const int vp9_cat6_high12_high_cost[1024];
+extern const uint16_t vp9_cat6_high_cost[64];
+extern const uint16_t vp9_cat6_high10_high_cost[256];
+extern const uint16_t vp9_cat6_high12_high_cost[1024];
static INLINE int vp9_get_cost(int16_t token, EXTRABIT extrabits,
- const int *cat6_high_table) {
+ const uint16_t *cat6_high_table) {
if (token != CATEGORY6_TOKEN)
return vp9_extra_bits[token].cost[extrabits >> 1];
return vp9_cat6_low_cost[(extrabits >> 1) & 0xff] +
@@ -88,13 +88,13 @@
}
#if CONFIG_VP9_HIGHBITDEPTH
-static INLINE const int *vp9_get_high_cost_table(int bit_depth) {
+static INLINE const uint16_t *vp9_get_high_cost_table(int bit_depth) {
return bit_depth == 8 ? vp9_cat6_high_cost
: (bit_depth == 10 ? vp9_cat6_high10_high_cost
: vp9_cat6_high12_high_cost);
}
#else
-static INLINE const int *vp9_get_high_cost_table(int bit_depth) {
+static INLINE const uint16_t *vp9_get_high_cost_table(int bit_depth) {
(void)bit_depth;
return vp9_cat6_high_cost;
}
@@ -118,7 +118,7 @@
}
static INLINE int vp9_get_token_cost(int v, int16_t *token,
- const int *cat6_high_table) {
+ const uint16_t *cat6_high_table) {
if (v >= CAT6_MIN_VAL || v <= -CAT6_MIN_VAL) {
EXTRABIT extrabits;
*token = CATEGORY6_TOKEN;