Merge remote-tracking branch 'remotes/lfasnacht/const'

This commit is contained in:
Ari Koivula 2014-04-16 10:28:31 +03:00
commit a982800e1b
6 changed files with 30 additions and 22 deletions

View file

@ -63,7 +63,7 @@ void printf_bitstream(char *msg, ...)
}
#endif
bit_table *g_exp_table;
const bit_table *g_exp_table;
//From wikipedia
//http://en.wikipedia.org/wiki/Binary_logarithm#Algorithm
@ -89,16 +89,19 @@ int init_exp_golomb(uint32_t len)
uint32_t code_num;
uint8_t M;
uint32_t info;
g_exp_table = (bit_table*)malloc(len*sizeof(bit_table));
if(!g_exp_table)
bit_table* exp_table;
exp_table = (bit_table*)malloc(len*sizeof(bit_table));
if(!exp_table)
return 0;
for (code_num = 0; code_num < len; code_num++) {
M = (uint8_t)floor_log2(code_num + 1);
info = code_num + 1 - (uint32_t)pow(2, M);
g_exp_table[code_num].len = M * 2 + 1;
g_exp_table[code_num].value = (1<<M) | info;
exp_table[code_num].len = M * 2 + 1;
exp_table[code_num].value = (1<<M) | info;
}
g_exp_table = exp_table;
return 1;
}

View file

@ -58,7 +58,7 @@ typedef struct
uint32_t value;
} bit_table;
extern bit_table *g_exp_table;
extern const bit_table *g_exp_table;
int floor_log2(unsigned int n);

View file

@ -44,7 +44,7 @@
double g_lambda_cost[55];
double g_cur_lambda_cost;
uint32_t* g_sig_last_scan[3][5];
const uint32_t* g_sig_last_scan[3][5];
int8_t g_convert_to_bit[LCU_WIDTH + 1];
int8_t g_bitdepth = 8;
@ -198,12 +198,17 @@ void init_tables(void)
c = 2;
for (i = 0; i < 5; i++) {
g_sig_last_scan[0][i] = (uint32_t*)malloc(c*c*sizeof(uint32_t));
g_sig_last_scan[1][i] = (uint32_t*)malloc(c*c*sizeof(uint32_t));
g_sig_last_scan[2][i] = (uint32_t*)malloc(c*c*sizeof(uint32_t));
uint32_t *sls0, *sls1, *sls2;
sls0 = (uint32_t*)malloc(c*c*sizeof(uint32_t));
sls1 = (uint32_t*)malloc(c*c*sizeof(uint32_t));
sls2 = (uint32_t*)malloc(c*c*sizeof(uint32_t));
init_sig_last_scan(g_sig_last_scan[0][i], g_sig_last_scan[1][i],
g_sig_last_scan[2][i], c, c);
init_sig_last_scan(sls0, sls1, sls2, c, c);
g_sig_last_scan[0][i] = sls0;
g_sig_last_scan[1][i] = sls1;
g_sig_last_scan[2][i] = sls2;
c <<= 1;
}
}
@ -242,9 +247,9 @@ void free_tables(void)
{
int i;
for (i = 0; i < 5; i++) {
free(g_sig_last_scan[0][i]);
free(g_sig_last_scan[1][i]);
free(g_sig_last_scan[2][i]);
FREE_POINTER(g_sig_last_scan[0][i]);
FREE_POINTER(g_sig_last_scan[1][i]);
FREE_POINTER(g_sig_last_scan[2][i]);
}
}
encoder_control *init_encoder_control(config *cfg)
@ -708,7 +713,7 @@ void encode_prefix_sei_version(const encoder_control * const encoder)
int i, length;
char buf[STR_BUF_LEN] = { 0 };
char *s = buf + 16;
config *cfg = encoder->cfg;
const config *cfg = encoder->cfg;
// random uuid_iso_iec_11578 generated with www.famkruithof.net/uuid/uuidgen
static const uint8_t uuid[16] = {

View file

@ -71,7 +71,7 @@ typedef struct
{
int32_t frame;
int32_t poc; /*!< \brief picture order count */
config *cfg;
const config *cfg;
encoder_input in;
encoder_me me;
bitstream *stream;
@ -161,7 +161,7 @@ static const uint8_t g_min_in_group[10] = {
* First index: scan pattern 0 = diagonal, 1 = horizontal, 2 = vertical
* Second index: (log2 - 1) size of transform block. 2x2 .. 32x32
*/
extern uint32_t* g_sig_last_scan[3][5];
extern const uint32_t* g_sig_last_scan[3][5];
/***
* List of indices for 4x4 coefficient groups within 8x8 transform block.

View file

@ -438,7 +438,7 @@ void rdoq(const encoder_control * const encoder, cabac_data *cabac, coefficient
uint32_t c2_idx = 0;
int32_t base_level;
uint32_t *scan = g_sig_last_scan[ scan_mode ][ log2_block_size - 1 ];
const uint32_t *scan = g_sig_last_scan[ scan_mode ][ log2_block_size - 1 ];
uint32_t cg_num = width * height >> 4;

View file

@ -857,8 +857,8 @@ void itransform2d(int16_t *block,int16_t *coeff, int8_t block_size, int32_t mode
void quant(const encoder_control * const encoder, int16_t *coef, int16_t *q_coef, int32_t width,
int32_t height, uint32_t *ac_sum, int8_t type, int8_t scan_idx, int8_t block_type )
{
uint32_t log2_block_size = g_convert_to_bit[ width ] + 2;
uint32_t *scan = g_sig_last_scan[ scan_idx ][ log2_block_size - 1 ];
const uint32_t log2_block_size = g_convert_to_bit[ width ] + 2;
const uint32_t * const scan = g_sig_last_scan[ scan_idx ][ log2_block_size - 1 ];
#if ENABLE_SIGN_HIDING == 1
int32_t delta_u[LCU_WIDTH*LCU_WIDTH>>2];
@ -1103,7 +1103,7 @@ int scalinglist_parse(encoder_control * const encoder, FILE *fp)
for (size_id = 0; size_id < SCALING_LIST_SIZE_NUM; size_id++) {
uint32_t list_id;
uint32_t size = MIN(MAX_MATRIX_COEF_NUM, (int32_t)g_scaling_list_size[size_id]);
//uint32_t *scan = (size_id == 0) ? g_sig_last_scan[SCAN_DIAG][1] : g_sig_last_scan_32x32;
//const uint32_t * const scan = (size_id == 0) ? g_sig_last_scan[SCAN_DIAG][1] : g_sig_last_scan_32x32;
for (list_id = 0; list_id < g_scaling_list_num[size_id]; list_id++) {
int found;