diff --git a/src/encoder.c b/src/encoder.c index e781ae37..d3d7ec95 100644 --- a/src/encoder.c +++ b/src/encoder.c @@ -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) diff --git a/src/encoder.h b/src/encoder.h index aca455e7..83ab31a9 100644 --- a/src/encoder.h +++ b/src/encoder.h @@ -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. diff --git a/src/rdo.c b/src/rdo.c index a0e74453..0dfe81fc 100644 --- a/src/rdo.c +++ b/src/rdo.c @@ -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; diff --git a/src/transform.c b/src/transform.c index fefe9ab6..983f8f60 100644 --- a/src/transform.c +++ b/src/transform.c @@ -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;