Refactor: Change name of CU_info.CU to cu_array.

This commit is contained in:
Ari Koivula 2013-09-20 12:47:53 +03:00
parent 5233c417df
commit 8d5dd67f76
8 changed files with 41 additions and 41 deletions

View file

@ -36,7 +36,7 @@ void close_cu_file(FILE *fp) {
*/
unsigned render_cu_file(encoder_control *encoder, unsigned depth, uint16_t xCtb, uint16_t yCtb, FILE *fp)
{
CU_info *cu = &encoder->in.cur_pic->CU[depth][xCtb + yCtb * (encoder->in.width_in_lcu<<MAX_DEPTH)];
CU_info *cu = &encoder->in.cur_pic->cu_array[depth][xCtb + yCtb * (encoder->in.width_in_lcu<<MAX_DEPTH)];
unsigned lambda_cost = (4 * g_lambda_cost[encoder->QP]) << 4;
unsigned sum = 0;
unsigned best_cost = -1;

View file

@ -821,7 +821,7 @@ void encode_slice_data(encoder_control* encoder)
void encode_coding_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, uint8_t depth)
{
CU_info *cur_CU = &encoder->in.cur_pic->CU[depth][xCtb+yCtb*(encoder->in.width_in_lcu<<MAX_DEPTH)];
CU_info *cur_CU = &encoder->in.cur_pic->cu_array[depth][xCtb+yCtb*(encoder->in.width_in_lcu<<MAX_DEPTH)];
uint8_t split_flag = cur_CU->split;
uint8_t split_model = 0;
@ -840,11 +840,11 @@ void encode_coding_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, ui
if(!border)
{
/* Get left and top block split_flags and if they are present and true, increase model number */
if(xCtb > 0 && GET_SPLITDATA(&(encoder->in.cur_pic->CU[depth][xCtb-1+yCtb*(encoder->in.width_in_lcu<<MAX_DEPTH)]),depth) == 1)
if(xCtb > 0 && GET_SPLITDATA(&(encoder->in.cur_pic->cu_array[depth][xCtb-1+yCtb*(encoder->in.width_in_lcu<<MAX_DEPTH)]),depth) == 1)
{
split_model++;
}
if(yCtb > 0 && GET_SPLITDATA(&(encoder->in.cur_pic->CU[depth][xCtb+(yCtb-1)*(encoder->in.width_in_lcu<<MAX_DEPTH)]),depth) == 1)
if(yCtb > 0 && GET_SPLITDATA(&(encoder->in.cur_pic->cu_array[depth][xCtb+(yCtb-1)*(encoder->in.width_in_lcu<<MAX_DEPTH)]),depth) == 1)
{
split_model++;
}

View file

@ -274,7 +274,7 @@ void filter_deblock_edge_chroma(encoder_control *encoder,
*/
void filter_deblock_cu(encoder_control *encoder, int32_t x, int32_t y, int8_t depth, int32_t edge)
{
CU_info *cur_cu = &encoder->in.cur_pic->CU[depth][x + y*(encoder->in.width_in_lcu << MAX_DEPTH)];
CU_info *cur_cu = &encoder->in.cur_pic->cu_array[depth][x + y*(encoder->in.width_in_lcu << MAX_DEPTH)];
uint8_t split_flag = (cur_cu->depth > depth) ? 1 : 0;
uint8_t border_x = (encoder->in.width < x*(LCU_WIDTH >> MAX_DEPTH) + (LCU_WIDTH >> depth)) ? 1 : 0;
uint8_t border_y = (encoder->in.height < y*(LCU_WIDTH >> MAX_DEPTH) + (LCU_WIDTH >> depth)) ? 1 : 0;

View file

@ -39,12 +39,12 @@ void inter_set_block(picture* pic, uint32_t x_cu, uint32_t y_cu, uint8_t depth,
for (x = x_cu; x < x_cu + block_scu_width; x++) {
// reset all depths to the same MV/inter data
for(d = 0; d < MAX_DEPTH + 1; d++) {
pic->CU[d][cu_pos + x].depth = depth;
pic->CU[d][cu_pos + x].type = CU_INTER;
pic->CU[d][cu_pos + x].inter.mode = cur_cu->inter.mode;
pic->CU[d][cu_pos + x].inter.mv[0] = cur_cu->inter.mv[0];
pic->CU[d][cu_pos + x].inter.mv[1] = cur_cu->inter.mv[1];
pic->CU[d][cu_pos + x].inter.mv_dir = cur_cu->inter.mv_dir;
pic->cu_array[d][cu_pos + x].depth = depth;
pic->cu_array[d][cu_pos + x].type = CU_INTER;
pic->cu_array[d][cu_pos + x].inter.mode = cur_cu->inter.mode;
pic->cu_array[d][cu_pos + x].inter.mv[0] = cur_cu->inter.mv[0];
pic->cu_array[d][cu_pos + x].inter.mv[1] = cur_cu->inter.mv[1];
pic->cu_array[d][cu_pos + x].inter.mv_dir = cur_cu->inter.mv_dir;
}
}
}
@ -192,24 +192,24 @@ void inter_get_mv_cand(encoder_control *encoder, int32_t x_cu, int32_t y_cu, int
// A0 and A1 availability testing
if (x_cu != 0) {
a1 = &encoder->in.cur_pic->CU[depth][x_cu - 1 + (y_cu + cur_block_in_scu - 1) * (encoder->in.width_in_lcu<<MAX_DEPTH)];
a1 = &encoder->in.cur_pic->cu_array[depth][x_cu - 1 + (y_cu + cur_block_in_scu - 1) * (encoder->in.width_in_lcu<<MAX_DEPTH)];
if (!a1->coded) a1 = NULL;
if (y_cu + cur_block_in_scu < encoder->in.height_in_lcu<<MAX_DEPTH) {
a0 = &encoder->in.cur_pic->CU[depth][x_cu - 1 + (y_cu + cur_block_in_scu) * (encoder->in.width_in_lcu<<MAX_DEPTH)];
a0 = &encoder->in.cur_pic->cu_array[depth][x_cu - 1 + (y_cu + cur_block_in_scu) * (encoder->in.width_in_lcu<<MAX_DEPTH)];
if (!a0->coded) a0 = NULL;
}
}
// B0, B1 and B2 availability testing
if (y_cu != 0) {
b0 = &encoder->in.cur_pic->CU[depth][x_cu + cur_block_in_scu + (y_cu - 1) * (encoder->in.width_in_lcu<<MAX_DEPTH)];
b0 = &encoder->in.cur_pic->cu_array[depth][x_cu + cur_block_in_scu + (y_cu - 1) * (encoder->in.width_in_lcu<<MAX_DEPTH)];
if (!b0->coded) b0 = NULL;
b1 = &encoder->in.cur_pic->CU[depth][x_cu + cur_block_in_scu - 1 + (y_cu - 1) * (encoder->in.width_in_lcu<<MAX_DEPTH)];
b1 = &encoder->in.cur_pic->cu_array[depth][x_cu + cur_block_in_scu - 1 + (y_cu - 1) * (encoder->in.width_in_lcu<<MAX_DEPTH)];
if (!b1->coded) b1 = NULL;
if (x_cu != 0) {
b2 = &encoder->in.cur_pic->CU[depth][x_cu - 1 + (y_cu - 1) * (encoder->in.width_in_lcu<<MAX_DEPTH)];
b2 = &encoder->in.cur_pic->cu_array[depth][x_cu - 1 + (y_cu - 1) * (encoder->in.width_in_lcu<<MAX_DEPTH)];
if(!b2->coded) b2 = NULL;
}
}

View file

@ -44,9 +44,9 @@ void intra_set_block_mode(picture *pic,uint32_t x_cu, uint32_t y_cu, uint8_t dep
int cu_pos = y * width_in_scu;
for (x = x_cu; x < x_cu + block_scu_width; x++) {
for (d = 0; d < MAX_DEPTH + 1; d++) {
pic->CU[d][cu_pos + x].depth = depth;
pic->CU[d][cu_pos + x].type = CU_INTRA;
pic->CU[d][cu_pos + x].intra.mode = mode;
pic->cu_array[d][cu_pos + x].depth = depth;
pic->cu_array[d][cu_pos + x].type = CU_INTRA;
pic->cu_array[d][cu_pos + x].intra.mode = mode;
}
}
}
@ -64,8 +64,8 @@ int8_t intra_get_block_mode(picture *pic, uint32_t x_cu, uint32_t y_cu, uint8_t
{
int width_in_scu = pic->width_in_lcu<<MAX_DEPTH; //!< width in smallest CU
int cu_pos = y_cu * width_in_scu + x_cu;
if (pic->CU[depth][cu_pos].type == CU_INTRA) {
return pic->CU[depth][cu_pos].intra.mode;
if (pic->cu_array[depth][cu_pos].type == CU_INTRA) {
return pic->cu_array[depth][cu_pos].intra.mode;
}
return -1;
}
@ -112,14 +112,14 @@ int8_t intra_get_dir_luma_predictor(picture* pic, uint32_t x_cu, uint32_t y_cu,
int32_t cu_pos = y_cu * width_in_scu + x_cu;
// Left PU predictor
if(x_cu && pic->CU[depth][cu_pos - 1].type == CU_INTRA && pic->CU[depth][cu_pos - 1].coded) {
left_intra_dir = pic->CU[depth][cu_pos - 1].intra.mode;
if(x_cu && pic->cu_array[depth][cu_pos - 1].type == CU_INTRA && pic->cu_array[depth][cu_pos - 1].coded) {
left_intra_dir = pic->cu_array[depth][cu_pos - 1].intra.mode;
}
// Top PU predictor
if(y_cu && ((y_cu * (LCU_WIDTH>>MAX_DEPTH)) % LCU_WIDTH) != 0
&& pic->CU[depth][cu_pos - width_in_scu].type == CU_INTRA && pic->CU[depth][cu_pos - width_in_scu].coded) {
above_intra_dir = pic->CU[depth][cu_pos - width_in_scu].intra.mode;
&& pic->cu_array[depth][cu_pos - width_in_scu].type == CU_INTRA && pic->cu_array[depth][cu_pos - width_in_scu].coded) {
above_intra_dir = pic->cu_array[depth][cu_pos - width_in_scu].intra.mode;
}
// If the predictions are the same, add new predictions
@ -387,7 +387,7 @@ void intra_build_reference_border(picture *pic, int32_t x_cu, int32_t y_cu,int16
// loop SCU's
for (left_column = 1; left_column < outwidth / scu_width; left_column++) {
// If over the picture height or block not yet coded, stop
if ((y_cu + left_column) * scu_width >= src_height || !pic->CU[0][x_cu - 1 + (y_cu + left_column) * width_in_scu].coded) {
if ((y_cu + left_column) * scu_width >= src_height || !pic->cu_array[0][x_cu - 1 + (y_cu + left_column) * width_in_scu].coded) {
break;
}
}
@ -414,7 +414,7 @@ void intra_build_reference_border(picture *pic, int32_t x_cu, int32_t y_cu,int16
// Loop top SCU's
for(top_row = 1; top_row < outwidth / scu_width; top_row++) {
// If over the picture width or block not yet coded, stop
if ((x_cu + top_row) * scu_width >= src_width || !pic->CU[0][x_cu + top_row+(y_cu - 1) * width_in_scu].coded) {
if ((x_cu + top_row) * scu_width >= src_width || !pic->cu_array[0][x_cu + top_row+(y_cu - 1) * width_in_scu].coded) {
break;
}
}

View file

@ -38,7 +38,7 @@ void picture_set_block_split(picture *pic, uint32_t x_scu, uint32_t y_scu,
for (y = y_scu; y < y_scu + block_scu_width; ++y) {
int cu_row = y * width_in_scu;
for (x = x_scu; x < x_scu + block_scu_width; ++x) {
pic->CU[depth][cu_row + x].split = split;
pic->cu_array[depth][cu_row + x].split = split;
}
}
}
@ -62,7 +62,7 @@ void picture_set_block_coded(picture *pic, uint32_t x_scu, uint32_t y_scu,
int cu_row = y * width_in_scu;
for (x = x_scu; x < x_scu + block_scu_width; ++x) {
for (d = 0; d < MAX_DEPTH + 1; ++d) {
pic->CU[d][cu_row + x].coded = coded;
pic->cu_array[d][cu_row + x].coded = coded;
}
}
}
@ -234,14 +234,14 @@ picture *picture_init(int32_t width, int32_t height,
// Allocate memory for CU info 2D array
// TODO: we don't need this much space on LCU...MAX_DEPTH-1
pic->CU = (CU_info**)malloc(sizeof(CU_info*) * (MAX_DEPTH + 1));
pic->cu_array = (CU_info**)malloc(sizeof(CU_info*) * (MAX_DEPTH + 1));
for (i = 0; i <= MAX_DEPTH; ++i) {
// Allocate height_in_scu x width_in_scu x sizeof(CU_info)
unsigned height_in_scu = height_in_lcu << MAX_DEPTH;
unsigned width_in_scu = width_in_lcu << MAX_DEPTH;
unsigned cu_array_size = height_in_scu * width_in_scu;
pic->CU[i] = (CU_info*)malloc(sizeof(CU_info) * cu_array_size);
memset(pic->CU[i], 0, sizeof(CU_info) * cu_array_size);
pic->cu_array[i] = (CU_info*)malloc(sizeof(CU_info) * cu_array_size);
memset(pic->cu_array[i], 0, sizeof(CU_info) * cu_array_size);
}
return pic;
@ -268,12 +268,12 @@ int picture_destroy(picture *pic)
for (i = 0; i <= MAX_DEPTH; ++i)
{
free(pic->CU[i]);
pic->CU[i] = NULL;
free(pic->cu_array[i]);
pic->cu_array[i] = NULL;
}
free(pic->CU);
pic->CU = NULL;
free(pic->cu_array);
pic->cu_array = NULL;
return 1;
}

View file

@ -78,7 +78,7 @@ typedef struct
int32_t height_in_lcu; // \brief Picture width in number of LCU's.
int32_t width_in_lcu; // \brief Picture height in number of LCU's.
uint8_t referenced; // \brief Whether this picture is referenced.
CU_info** CU; // \brief Info for each CU at each depth.
CU_info** cu_array; // \brief Info for each CU at each depth.
uint8_t type;
uint8_t slicetype;
} picture;

View file

@ -97,7 +97,7 @@ void search_buildReferenceBorder(picture *pic, int32_t x_ctb, int32_t y_ctb,
for (left_col = 1; left_col < outwidth / scu_width; left_col++) {
// If over the picture height or block not yet searched, stop
if ((y_ctb + left_col) * scu_width >= src_height
|| pic->CU[0][x_ctb - 1 + (y_ctb + left_col) * width_in_scu].type == CU_NOTSET) {
|| pic->cu_array[0][x_ctb - 1 + (y_ctb + left_col) * width_in_scu].type == CU_NOTSET) {
break;
}
}
@ -125,7 +125,7 @@ void search_buildReferenceBorder(picture *pic, int32_t x_ctb, int32_t y_ctb,
// Loop top SCU's
for (top_row = 1; top_row < outwidth / scu_width; top_row++) {
if ((x_ctb + top_row) * scu_width >= src_width
|| pic->CU[0][x_ctb + top_row + (y_ctb - 1) * width_in_scu].type
|| pic->cu_array[0][x_ctb + top_row + (y_ctb - 1) * width_in_scu].type
== CU_NOTSET) {
break;
}
@ -163,7 +163,7 @@ void search_tree(encoder_control *encoder,
uint8_t border_split_x = ((encoder->in.width) < ((x_ctb + 1) * (LCU_WIDTH >> MAX_DEPTH) + (LCU_WIDTH >> (depth + 1)))) ? 0 : 1;
uint8_t border_split_y = ((encoder->in.height) < ((y_ctb + 1) * (LCU_WIDTH >> MAX_DEPTH) + (LCU_WIDTH >> (depth + 1)))) ? 0 : 1;
uint8_t border = border_x | border_y; // are we in any border CU
CU_info *cur_cu = &encoder->in.cur_pic->CU[depth][x_ctb + y_ctb * (encoder->in.width_in_lcu << MAX_DEPTH)];
CU_info *cur_cu = &encoder->in.cur_pic->cu_array[depth][x_ctb + y_ctb * (encoder->in.width_in_lcu << MAX_DEPTH)];
cur_cu->intra.cost = 0xffffffff;
cur_cu->inter.cost = 0xffffffff;
@ -258,7 +258,7 @@ void search_tree(encoder_control *encoder,
uint32_t search_best_mode(encoder_control *encoder,
uint16_t x_ctb, uint16_t y_ctb, uint8_t depth)
{
CU_info *cur_cu = &encoder->in.cur_pic->CU[depth][x_ctb
CU_info *cur_cu = &encoder->in.cur_pic->cu_array[depth][x_ctb
+ y_ctb * (encoder->in.width_in_lcu << MAX_DEPTH)];
uint32_t best_intra_cost = cur_cu->intra.cost;
uint32_t best_inter_cost = cur_cu->inter.cost;