Makes all global data in entropy.c const
Removes all runtime initialization of global data in entropy.c. Precalculated values are used for initializing all entropy related tabels. First patch in a series to make sure code is reentrant. Change-Id: I9aac91a2a26f96d73c6470d772a343df63bfe633
This commit is contained in:
Родитель
b5b61c179d
Коммит
a91b42f022
|
@ -208,7 +208,7 @@ void vp8_create_common(VP8_COMMON *oci)
|
|||
oci->clr_type = REG_YUV;
|
||||
oci->clamp_type = RECON_CLAMP_REQUIRED;
|
||||
|
||||
/* Initialise reference frame sign bias structure to defaults */
|
||||
/* Initialize reference frame sign bias structure to defaults */
|
||||
vpx_memset(oci->ref_frame_sign_bias, 0, sizeof(oci->ref_frame_sign_bias));
|
||||
|
||||
/* Default disable buffer to buffer copying */
|
||||
|
@ -223,10 +223,5 @@ void vp8_remove_common(VP8_COMMON *oci)
|
|||
|
||||
void vp8_initialize_common()
|
||||
{
|
||||
vp8_coef_tree_initialize();
|
||||
|
||||
vp8_entropy_mode_init();
|
||||
|
||||
vp8_init_scan_order_mask();
|
||||
|
||||
}
|
||||
|
|
|
@ -8,23 +8,11 @@
|
|||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "entropy.h"
|
||||
#include "string.h"
|
||||
#include "blockd.h"
|
||||
#include "onyxc_int.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
|
||||
#define uchar unsigned char /* typedefs can clash */
|
||||
#define uint unsigned int
|
||||
|
||||
typedef const uchar cuchar;
|
||||
typedef const uint cuint;
|
||||
|
||||
typedef vp8_prob Prob;
|
||||
|
||||
#include "coefupdateprobs.h"
|
||||
|
||||
DECLARE_ALIGNED(16, const unsigned char, vp8_norm[256]) =
|
||||
|
@ -47,10 +35,11 @@ DECLARE_ALIGNED(16, const unsigned char, vp8_norm[256]) =
|
|||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
DECLARE_ALIGNED(16, cuchar, vp8_coef_bands[16]) =
|
||||
DECLARE_ALIGNED(16, const unsigned char, vp8_coef_bands[16]) =
|
||||
{ 0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7};
|
||||
|
||||
DECLARE_ALIGNED(16, cuchar, vp8_prev_token_class[MAX_ENTROPY_TOKENS]) =
|
||||
DECLARE_ALIGNED(16, const unsigned char,
|
||||
vp8_prev_token_class[MAX_ENTROPY_TOKENS]) =
|
||||
{ 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0};
|
||||
|
||||
DECLARE_ALIGNED(16, const int, vp8_default_zig_zag1d[16]) =
|
||||
|
@ -69,7 +58,26 @@ DECLARE_ALIGNED(16, const short, vp8_default_inv_zig_zag[16]) =
|
|||
10, 11, 15, 16
|
||||
};
|
||||
|
||||
DECLARE_ALIGNED(16, short, vp8_default_zig_zag_mask[16]);
|
||||
/* vp8_default_zig_zag_mask generated with:
|
||||
|
||||
void vp8_init_scan_order_mask()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
vp8_default_zig_zag_mask[vp8_default_zig_zag1d[i]] = 1 << i;
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
DECLARE_ALIGNED(16, const short, vp8_default_zig_zag_mask[16]) =
|
||||
{
|
||||
1, 2, 32, 64,
|
||||
4, 16, 128, 4096,
|
||||
8, 256, 2048, 8192,
|
||||
512, 1024, 16384, -32768
|
||||
};
|
||||
|
||||
const int vp8_mb_feature_data_bits[MB_LVL_MAX] = {7, 6};
|
||||
|
||||
|
@ -90,56 +98,72 @@ const vp8_tree_index vp8_coef_tree[ 22] = /* corresponding _CONTEXT_NODEs */
|
|||
-DCT_VAL_CATEGORY5, -DCT_VAL_CATEGORY6 /* 10 = CAT_FIVE */
|
||||
};
|
||||
|
||||
struct vp8_token_struct vp8_coef_encodings[MAX_ENTROPY_TOKENS];
|
||||
/* vp8_coef_encodings generated with:
|
||||
vp8_tokens_from_tree(vp8_coef_encodings, vp8_coef_tree);
|
||||
*/
|
||||
const vp8_token vp8_coef_encodings[MAX_ENTROPY_TOKENS] =
|
||||
{
|
||||
{2, 2},
|
||||
{6, 3},
|
||||
{28, 5},
|
||||
{58, 6},
|
||||
{59, 6},
|
||||
{60, 6},
|
||||
{61, 6},
|
||||
{124, 7},
|
||||
{125, 7},
|
||||
{126, 7},
|
||||
{127, 7},
|
||||
{0, 1}
|
||||
};
|
||||
|
||||
/* Trees for extra bits. Probabilities are constant and
|
||||
do not depend on previously encoded bits */
|
||||
|
||||
static const Prob Pcat1[] = { 159};
|
||||
static const Prob Pcat2[] = { 165, 145};
|
||||
static const Prob Pcat3[] = { 173, 148, 140};
|
||||
static const Prob Pcat4[] = { 176, 155, 140, 135};
|
||||
static const Prob Pcat5[] = { 180, 157, 141, 134, 130};
|
||||
static const Prob Pcat6[] =
|
||||
static const vp8_prob Pcat1[] = { 159};
|
||||
static const vp8_prob Pcat2[] = { 165, 145};
|
||||
static const vp8_prob Pcat3[] = { 173, 148, 140};
|
||||
static const vp8_prob Pcat4[] = { 176, 155, 140, 135};
|
||||
static const vp8_prob Pcat5[] = { 180, 157, 141, 134, 130};
|
||||
static const vp8_prob Pcat6[] =
|
||||
{ 254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129};
|
||||
|
||||
static vp8_tree_index cat1[2], cat2[4], cat3[6], cat4[8], cat5[10], cat6[22];
|
||||
|
||||
void vp8_init_scan_order_mask()
|
||||
{
|
||||
int i;
|
||||
/* tree index tables generated with:
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
void init_bit_tree(vp8_tree_index *p, int n)
|
||||
{
|
||||
vp8_default_zig_zag_mask[vp8_default_zig_zag1d[i]] = 1 << i;
|
||||
int i = 0;
|
||||
|
||||
while (++i < n)
|
||||
{
|
||||
p[0] = p[1] = i << 1;
|
||||
p += 2;
|
||||
}
|
||||
|
||||
p[0] = p[1] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void init_bit_tree(vp8_tree_index *p, int n)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while (++i < n)
|
||||
void init_bit_trees()
|
||||
{
|
||||
p[0] = p[1] = i << 1;
|
||||
p += 2;
|
||||
init_bit_tree(cat1, 1);
|
||||
init_bit_tree(cat2, 2);
|
||||
init_bit_tree(cat3, 3);
|
||||
init_bit_tree(cat4, 4);
|
||||
init_bit_tree(cat5, 5);
|
||||
init_bit_tree(cat6, 11);
|
||||
}
|
||||
*/
|
||||
|
||||
p[0] = p[1] = 0;
|
||||
}
|
||||
static const vp8_tree_index cat1[2] = { 0, 0 };
|
||||
static const vp8_tree_index cat2[4] = { 2, 2, 0, 0 };
|
||||
static const vp8_tree_index cat3[6] = { 2, 2, 4, 4, 0, 0 };
|
||||
static const vp8_tree_index cat4[8] = { 2, 2, 4, 4, 6, 6, 0, 0 };
|
||||
static const vp8_tree_index cat5[10] = { 2, 2, 4, 4, 6, 6, 8, 8, 0, 0 };
|
||||
static const vp8_tree_index cat6[22] = { 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12,
|
||||
14, 14, 16, 16, 18, 18, 20, 20, 0, 0 };
|
||||
|
||||
static void init_bit_trees()
|
||||
{
|
||||
init_bit_tree(cat1, 1);
|
||||
init_bit_tree(cat2, 2);
|
||||
init_bit_tree(cat3, 3);
|
||||
init_bit_tree(cat4, 4);
|
||||
init_bit_tree(cat5, 5);
|
||||
init_bit_tree(cat6, 11);
|
||||
}
|
||||
|
||||
vp8_extra_bit_struct vp8_extra_bits[12] =
|
||||
const vp8_extra_bit_struct vp8_extra_bits[12] =
|
||||
{
|
||||
{ 0, 0, 0, 0},
|
||||
{ 0, 0, 0, 1},
|
||||
|
@ -163,8 +187,3 @@ void vp8_default_coef_probs(VP8_COMMON *pc)
|
|||
sizeof(default_coef_probs));
|
||||
}
|
||||
|
||||
void vp8_coef_tree_initialize()
|
||||
{
|
||||
init_bit_trees();
|
||||
vp8_tokens_from_tree(vp8_coef_encodings, vp8_coef_tree);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
extern const vp8_tree_index vp8_coef_tree[];
|
||||
|
||||
extern struct vp8_token_struct vp8_coef_encodings[MAX_ENTROPY_TOKENS];
|
||||
extern const struct vp8_token_struct vp8_coef_encodings[MAX_ENTROPY_TOKENS];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ typedef struct
|
|||
int base_val;
|
||||
} vp8_extra_bit_struct;
|
||||
|
||||
extern vp8_extra_bit_struct vp8_extra_bits[12]; /* indexed by token value */
|
||||
extern const vp8_extra_bit_struct vp8_extra_bits[12]; /* indexed by token value */
|
||||
|
||||
#define PROB_UPDATE_BASELINE_COST 7
|
||||
|
||||
|
@ -94,7 +94,7 @@ void vp8_default_coef_probs(struct VP8Common *);
|
|||
|
||||
extern DECLARE_ALIGNED(16, const int, vp8_default_zig_zag1d[16]);
|
||||
extern DECLARE_ALIGNED(16, const short, vp8_default_inv_zig_zag[16]);
|
||||
extern short vp8_default_zig_zag_mask[16];
|
||||
extern DECLARE_ALIGNED(16, const short, vp8_default_zig_zag_mask[16]);
|
||||
extern const int vp8_mb_feature_data_bits[MB_LVL_MAX];
|
||||
|
||||
void vp8_coef_tree_initialize(void);
|
||||
|
|
|
@ -162,7 +162,7 @@ static void write_split(vp8_writer *bc, int x)
|
|||
|
||||
void vp8_pack_tokens_c(vp8_writer *w, const TOKENEXTRA *p, int xcount)
|
||||
{
|
||||
const TOKENEXTRA *const stop = p + xcount;
|
||||
const TOKENEXTRA *stop = p + xcount;
|
||||
unsigned int split;
|
||||
unsigned int shift;
|
||||
int count = w->count;
|
||||
|
@ -172,8 +172,8 @@ void vp8_pack_tokens_c(vp8_writer *w, const TOKENEXTRA *p, int xcount)
|
|||
while (p < stop)
|
||||
{
|
||||
const int t = p->Token;
|
||||
vp8_token *const a = vp8_coef_encodings + t;
|
||||
const vp8_extra_bit_struct *const b = vp8_extra_bits + t;
|
||||
const vp8_token *a = vp8_coef_encodings + t;
|
||||
const vp8_extra_bit_struct *b = vp8_extra_bits + t;
|
||||
int i = 0;
|
||||
const unsigned char *pp = p->context_tree;
|
||||
int v = a->value;
|
||||
|
|
|
@ -14,19 +14,19 @@
|
|||
|
||||
#if HAVE_EDSP
|
||||
void vp8cx_pack_tokens_armv5(vp8_writer *w, const TOKENEXTRA *p, int xcount,
|
||||
vp8_token *,
|
||||
vp8_extra_bit_struct *,
|
||||
const vp8_token *,
|
||||
const vp8_extra_bit_struct *,
|
||||
const vp8_tree_index *);
|
||||
void vp8cx_pack_tokens_into_partitions_armv5(VP8_COMP *,
|
||||
unsigned char * cx_data,
|
||||
const unsigned char *cx_data_end,
|
||||
int num_parts,
|
||||
vp8_token *,
|
||||
vp8_extra_bit_struct *,
|
||||
const vp8_token *,
|
||||
const vp8_extra_bit_struct *,
|
||||
const vp8_tree_index *);
|
||||
void vp8cx_pack_mb_row_tokens_armv5(VP8_COMP *cpi, vp8_writer *w,
|
||||
vp8_token *,
|
||||
vp8_extra_bit_struct *,
|
||||
const vp8_token *,
|
||||
const vp8_extra_bit_struct *,
|
||||
const vp8_tree_index *);
|
||||
# define pack_tokens(a,b,c) \
|
||||
vp8cx_pack_tokens_armv5(a,b,c,vp8_coef_encodings,vp8_extra_bits,vp8_coef_tree)
|
||||
|
|
|
@ -37,8 +37,8 @@ int skip_false_count = 0;
|
|||
static void fill_value_tokens()
|
||||
{
|
||||
|
||||
TOKENVALUE *const t = dct_value_tokens + DCT_MAX_VALUE;
|
||||
vp8_extra_bit_struct *const e = vp8_extra_bits;
|
||||
TOKENVALUE *t = dct_value_tokens + DCT_MAX_VALUE;
|
||||
const vp8_extra_bit_struct *e = vp8_extra_bits;
|
||||
|
||||
int i = -DCT_MAX_VALUE;
|
||||
int sign = 1;
|
||||
|
@ -70,7 +70,7 @@ static void fill_value_tokens()
|
|||
// initialize the cost for extra bits for all possible coefficient value.
|
||||
{
|
||||
int cost = 0;
|
||||
vp8_extra_bit_struct *p = vp8_extra_bits + t[i].Token;
|
||||
const vp8_extra_bit_struct *p = vp8_extra_bits + t[i].Token;
|
||||
|
||||
if (p->base_val)
|
||||
{
|
||||
|
|
|
@ -23,11 +23,11 @@ void vp8_short_fdct8x4_mmx(short *input, short *output, int pitch)
|
|||
|
||||
int vp8_fast_quantize_b_impl_mmx(short *coeff_ptr, short *zbin_ptr,
|
||||
short *qcoeff_ptr, short *dequant_ptr,
|
||||
short *scan_mask, short *round_ptr,
|
||||
const short *scan_mask, short *round_ptr,
|
||||
short *quant_ptr, short *dqcoeff_ptr);
|
||||
void vp8_fast_quantize_b_mmx(BLOCK *b, BLOCKD *d)
|
||||
{
|
||||
short *scan_mask = vp8_default_zig_zag_mask;//d->scan_order_mask_ptr;
|
||||
const short *scan_mask = vp8_default_zig_zag_mask;
|
||||
short *coeff_ptr = b->coeff;
|
||||
short *zbin_ptr = b->zbin;
|
||||
short *round_ptr = b->round;
|
||||
|
|
Загрузка…
Ссылка в новой задаче