Fix overwriting of motion vectors during search.

- Makes everything besides search to only use the bottom most layer of the
  picture.cu_array structure.
This commit is contained in:
Ari Koivula 2013-09-25 16:11:31 +03:00
parent 91ff438238
commit 04f1dde8a1
5 changed files with 32 additions and 36 deletions

View file

@ -817,8 +817,8 @@ 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_array[depth][xCtb+yCtb*(encoder->in.width_in_lcu<<MAX_DEPTH)];
uint8_t split_flag = cur_CU->split;
cu_info *cur_CU = &encoder->in.cur_pic->cu_array[MAX_DEPTH][xCtb+yCtb*(encoder->in.width_in_lcu<<MAX_DEPTH)];
uint8_t split_flag = GET_SPLITDATA(cur_CU, depth);
uint8_t split_model = 0;
/* Check for slice border */
@ -836,11 +836,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_array[depth][xCtb-1+yCtb*(encoder->in.width_in_lcu<<MAX_DEPTH)]),depth) == 1)
if(xCtb > 0 && GET_SPLITDATA(&(encoder->in.cur_pic->cu_array[MAX_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_array[depth][xCtb+(yCtb-1)*(encoder->in.width_in_lcu<<MAX_DEPTH)]),depth) == 1)
if(yCtb > 0 && GET_SPLITDATA(&(encoder->in.cur_pic->cu_array[MAX_DEPTH][xCtb+(yCtb-1)*(encoder->in.width_in_lcu<<MAX_DEPTH)]),depth) == 1)
{
split_model++;
}

View file

@ -294,7 +294,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_array[depth][x + y*(encoder->in.width_in_lcu << MAX_DEPTH)];
cu_info *cur_cu = &encoder->in.cur_pic->cu_array[MAX_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

@ -29,7 +29,7 @@
*/
void inter_set_block(picture* pic, uint32_t x_cu, uint32_t y_cu, uint8_t depth, cu_info* cur_cu)
{
uint32_t x,y,d;
uint32_t x, y;
// Width in smallest CU
int width_in_scu = pic->width_in_lcu<<MAX_DEPTH;
int block_scu_width = (LCU_WIDTH>>depth)/(LCU_WIDTH>>MAX_DEPTH);
@ -37,15 +37,13 @@ void inter_set_block(picture* pic, uint32_t x_cu, uint32_t y_cu, uint8_t depth,
for (y = y_cu; y < y_cu + block_scu_width; y++) {
int cu_pos = y * width_in_scu; //!< calculate y-position once, use with every x
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_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;
}
// Set all SCU's to this blocks values at the bottom most depth.
pic->cu_array[MAX_DEPTH][cu_pos + x].depth = depth;
pic->cu_array[MAX_DEPTH][cu_pos + x].type = CU_INTER;
pic->cu_array[MAX_DEPTH][cu_pos + x].inter.mode = cur_cu->inter.mode;
pic->cu_array[MAX_DEPTH][cu_pos + x].inter.mv[0] = cur_cu->inter.mv[0];
pic->cu_array[MAX_DEPTH][cu_pos + x].inter.mv[1] = cur_cu->inter.mv[1];
pic->cu_array[MAX_DEPTH][cu_pos + x].inter.mv_dir = cur_cu->inter.mv_dir;
}
}
}
@ -256,24 +254,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_array[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[MAX_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_array[depth][x_cu - 1 + (y_cu + cur_block_in_scu) * (encoder->in.width_in_lcu<<MAX_DEPTH)];
a0 = &encoder->in.cur_pic->cu_array[MAX_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_array[depth][x_cu + cur_block_in_scu + (y_cu - 1) * (encoder->in.width_in_lcu<<MAX_DEPTH)];
b0 = &encoder->in.cur_pic->cu_array[MAX_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_array[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[MAX_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_array[depth][x_cu - 1 + (y_cu - 1) * (encoder->in.width_in_lcu<<MAX_DEPTH)];
b2 = &encoder->in.cur_pic->cu_array[MAX_DEPTH][x_cu - 1 + (y_cu - 1) * (encoder->in.width_in_lcu<<MAX_DEPTH)];
if(!b2->coded) b2 = NULL;
}
}

View file

@ -35,7 +35,7 @@ const uint8_t intra_hor_ver_dist_thres[5] = {0,7,1,0,0};
*/
void intra_set_block_mode(picture *pic,uint32_t x_cu, uint32_t y_cu, uint8_t depth, uint8_t mode)
{
uint32_t x,y,d;
uint32_t x, y;
int width_in_scu = pic->width_in_lcu<<MAX_DEPTH; //!< Width in smallest CU
int block_scu_width = (LCU_WIDTH>>depth)/(LCU_WIDTH>>MAX_DEPTH);
@ -43,11 +43,9 @@ void intra_set_block_mode(picture *pic,uint32_t x_cu, uint32_t y_cu, uint8_t dep
for (y = y_cu; y < y_cu + block_scu_width; y++) {
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_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;
}
pic->cu_array[MAX_DEPTH][cu_pos + x].depth = depth;
pic->cu_array[MAX_DEPTH][cu_pos + x].type = CU_INTRA;
pic->cu_array[MAX_DEPTH][cu_pos + x].intra.mode = mode;
}
}
}
@ -64,8 +62,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_array[depth][cu_pos].type == CU_INTRA) {
return pic->cu_array[depth][cu_pos].intra.mode;
if (pic->cu_array[MAX_DEPTH][cu_pos].type == CU_INTRA) {
return pic->cu_array[MAX_DEPTH][cu_pos].intra.mode;
}
return -1;
}
@ -112,14 +110,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_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;
if(x_cu && pic->cu_array[MAX_DEPTH][cu_pos - 1].type == CU_INTRA && pic->cu_array[MAX_DEPTH][cu_pos - 1].coded) {
left_intra_dir = pic->cu_array[MAX_DEPTH][cu_pos - 1].intra.mode;
}
// Top PU predictor
if(y_cu && ((y_cu * (LCU_WIDTH>>MAX_DEPTH)) % LCU_WIDTH) != 0
&& 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;
&& pic->cu_array[MAX_DEPTH][cu_pos - width_in_scu].type == CU_INTRA && pic->cu_array[MAX_DEPTH][cu_pos - width_in_scu].coded) {
above_intra_dir = pic->cu_array[MAX_DEPTH][cu_pos - width_in_scu].intra.mode;
}
// If the predictions are the same, add new predictions
@ -387,7 +385,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_array[0][x_cu - 1 + (y_cu + left_column) * width_in_scu].coded) {
if ((y_cu + left_column) * scu_width >= src_height || !pic->cu_array[MAX_DEPTH][x_cu - 1 + (y_cu + left_column) * width_in_scu].coded) {
break;
}
}
@ -414,7 +412,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_array[0][x_cu + top_row+(y_cu - 1) * width_in_scu].coded) {
if ((x_cu + top_row) * scu_width >= src_width || !pic->cu_array[MAX_DEPTH][x_cu + top_row+(y_cu - 1) * width_in_scu].coded) {
break;
}
}

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_array[0][x_ctb - 1 + (y_ctb + left_col) * width_in_scu].type == CU_NOTSET) {
|| pic->cu_array[MAX_DEPTH][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_array[0][x_ctb + top_row + (y_ctb - 1) * width_in_scu].type
|| pic->cu_array[MAX_DEPTH][x_ctb + top_row + (y_ctb - 1) * width_in_scu].type
== CU_NOTSET) {
break;
}