Commit b35a0db0 authored by Attila Nagy's avatar Attila Nagy

Makes all global data in tokenize.c const

Removes all runtime initialization of global data in tokenize.c.
DCT token and cost tabels are pre-generated.

Second patch in a series to make sure code is reentrant.

Change-Id: Iab48b5fe290129823947b669413101f22a1bcac0
parent b5b61c17
This diff is collapsed.
This diff is collapsed.
...@@ -219,7 +219,6 @@ void vp8_initialize() ...@@ -219,7 +219,6 @@ void vp8_initialize()
{ {
vp8_scale_machine_specific_config(); vp8_scale_machine_specific_config();
vp8_initialize_common(); vp8_initialize_common();
vp8_tokenize_initialize();
init_done = 1; init_done = 1;
} }
......
...@@ -26,14 +26,20 @@ _int64 context_counters[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTR ...@@ -26,14 +26,20 @@ _int64 context_counters[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTR
void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t) ; void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t) ;
void vp8_fix_contexts(MACROBLOCKD *x); void vp8_fix_contexts(MACROBLOCKD *x);
static TOKENVALUE dct_value_tokens[DCT_MAX_VALUE*2]; #include "dct_value_tokens.h"
const TOKENVALUE *vp8_dct_value_tokens_ptr; #include "dct_value_cost.h"
static int dct_value_cost[DCT_MAX_VALUE*2];
const int *vp8_dct_value_cost_ptr; const TOKENVALUE *const vp8_dct_value_tokens_ptr = dct_value_tokens +
DCT_MAX_VALUE;
const short *const vp8_dct_value_cost_ptr = dct_value_cost + DCT_MAX_VALUE;
#if 0 #if 0
int skip_true_count = 0; int skip_true_count = 0;
int skip_false_count = 0; int skip_false_count = 0;
#endif #endif
/* function used to generate dct_value_tokens and dct_value_cost tables */
/*
static void fill_value_tokens() static void fill_value_tokens()
{ {
...@@ -80,7 +86,7 @@ static void fill_value_tokens() ...@@ -80,7 +86,7 @@ static void fill_value_tokens()
if (Length) if (Length)
cost += vp8_treed_cost(p->tree, p->prob, extra >> 1, Length); cost += vp8_treed_cost(p->tree, p->prob, extra >> 1, Length);
cost += vp8_cost_bit(vp8_prob_half, extra & 1); /* sign */ cost += vp8_cost_bit(vp8_prob_half, extra & 1); // sign
dct_value_cost[i + DCT_MAX_VALUE] = cost; dct_value_cost[i + DCT_MAX_VALUE] = cost;
} }
...@@ -92,6 +98,7 @@ static void fill_value_tokens() ...@@ -92,6 +98,7 @@ static void fill_value_tokens()
vp8_dct_value_tokens_ptr = dct_value_tokens + DCT_MAX_VALUE; vp8_dct_value_tokens_ptr = dct_value_tokens + DCT_MAX_VALUE;
vp8_dct_value_cost_ptr = dct_value_cost + DCT_MAX_VALUE; vp8_dct_value_cost_ptr = dct_value_cost + DCT_MAX_VALUE;
} }
*/
static void tokenize2nd_order_b static void tokenize2nd_order_b
( (
...@@ -476,12 +483,6 @@ void print_context_counters() ...@@ -476,12 +483,6 @@ void print_context_counters()
#endif #endif
void vp8_tokenize_initialize()
{
fill_value_tokens();
}
static void stuff2nd_order_b static void stuff2nd_order_b
( (
TOKENEXTRA **tp, TOKENEXTRA **tp,
......
...@@ -40,11 +40,11 @@ void print_context_counters(); ...@@ -40,11 +40,11 @@ void print_context_counters();
extern _int64 context_counters[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; extern _int64 context_counters[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
#endif #endif
extern const int *vp8_dct_value_cost_ptr; extern const short *const vp8_dct_value_cost_ptr;
/* TODO: The Token field should be broken out into a separate char array to /* TODO: The Token field should be broken out into a separate char array to
* improve cache locality, since it's needed for costing when the rest of the * improve cache locality, since it's needed for costing when the rest of the
* fields are not. * fields are not.
*/ */
extern const TOKENVALUE *vp8_dct_value_tokens_ptr; extern const TOKENVALUE *const vp8_dct_value_tokens_ptr;
#endif /* tokenize_h */ #endif /* tokenize_h */
...@@ -78,6 +78,8 @@ VP8_CX_SRCS-yes += encoder/segmentation.c ...@@ -78,6 +78,8 @@ VP8_CX_SRCS-yes += encoder/segmentation.c
VP8_CX_SRCS-yes += encoder/segmentation.h VP8_CX_SRCS-yes += encoder/segmentation.h
VP8_CX_SRCS-$(CONFIG_INTERNAL_STATS) += encoder/ssim.c VP8_CX_SRCS-$(CONFIG_INTERNAL_STATS) += encoder/ssim.c
VP8_CX_SRCS-yes += encoder/tokenize.c VP8_CX_SRCS-yes += encoder/tokenize.c
VP8_CX_SRCS-yes += encoder/dct_value_cost.h
VP8_CX_SRCS-yes += encoder/dct_value_tokens.h
VP8_CX_SRCS-yes += encoder/treewriter.c VP8_CX_SRCS-yes += encoder/treewriter.c
VP8_CX_SRCS-$(CONFIG_INTERNAL_STATS) += common/postproc.h VP8_CX_SRCS-$(CONFIG_INTERNAL_STATS) += common/postproc.h
VP8_CX_SRCS-$(CONFIG_INTERNAL_STATS) += common/postproc.c VP8_CX_SRCS-$(CONFIG_INTERNAL_STATS) += common/postproc.c
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment