From e33655fde58def098e743cbb605f1a3874686b11 Mon Sep 17 00:00:00 2001 From: Ari Koivula Date: Wed, 29 Jan 2014 16:15:13 +0200 Subject: [PATCH] Remove debug stuff and disable intra NxN in preparation for a merge. - Re-enable intra search based on reconstructed image. - This didn't have as much of an effect as I thought it would. - Re-enable SAO and deblocking. - Disable NxN searching. (4x4 luma coding is still broken) --- src/encmain.c | 4 ++-- src/encoder.c | 30 +++++++++++++++++------------- src/intra.c | 15 --------------- src/search.c | 6 ++---- 4 files changed, 21 insertions(+), 34 deletions(-) diff --git a/src/encmain.c b/src/encmain.c index ca4eb00e..8a12241a 100644 --- a/src/encmain.c +++ b/src/encmain.c @@ -146,11 +146,11 @@ int main(int argc, char *argv[]) encoder->QP = 32; encoder->in.video_format = FORMAT_420; // deblocking filter - encoder->deblock_enable = 0; + encoder->deblock_enable = 1; encoder->beta_offset_div2 = 0; encoder->tc_offset_div2 = 0; // SAO - encoder->sao_enable = 0; + encoder->sao_enable = 1; init_encoder_input(&encoder->in, input, cfg->width, cfg->height); diff --git a/src/encoder.c b/src/encoder.c index 81018936..a7a93e04 100644 --- a/src/encoder.c +++ b/src/encoder.c @@ -1582,14 +1582,13 @@ void encode_transform_tree(encoder_control *encoder, int32_t x_pu, int32_t y_pu, for (i = 0; i < width * width; i++) { if (coeff_y[i] != 0) { // Found one, we can break here + cur_cu->coeff_y = 1; + cbf_y = 1; if (depth <= MAX_DEPTH) { - cur_cu->coeff_y = 1; cur_cu->coeff_top_y[depth] = 1; - cbf_y = 1; } else { int pu_index = x_pu % 2 + 2 * (y_pu % 2); cur_cu->coeff_top_y[depth + pu_index] = 1; - cbf_y = 1; } break; } @@ -1644,8 +1643,8 @@ void encode_transform_tree(encoder_control *encoder, int32_t x_pu, int32_t y_pu, for (i = 0; i < chroma_size; i++) { if (coeff_u[i] != 0) { // Found one, we can break here - cur_cu->coeff_u = 1; - cur_cu->coeff_top_u[depth] = 1; + cur_cu->coeff_u = 1; + cur_cu->coeff_top_u[depth] = 1; break; } } @@ -1653,8 +1652,8 @@ void encode_transform_tree(encoder_control *encoder, int32_t x_pu, int32_t y_pu, for (i = 0; i < chroma_size; i++) { if (coeff_v[i] != 0) { // Found one, we can break here - cur_cu->coeff_v = 1; - cur_cu->coeff_top_v[depth] = 1; + cur_cu->coeff_v = 1; + cur_cu->coeff_top_v[depth] = 1; break; } } @@ -2244,7 +2243,7 @@ void encode_block_residual(encoder_control *encoder, if (cur_cu->type == CU_INTRA) { // INTRAPREDICTION VARIABLES - //pixel pred_y[LCU_WIDTH * LCU_WIDTH]; + pixel pred_y[LCU_WIDTH * LCU_WIDTH]; pixel *recbase_y = &encoder->in.cur_pic->y_recdata[x_ctb * (LCU_WIDTH >> (MAX_DEPTH)) + (y_ctb * (LCU_WIDTH >> (MAX_DEPTH))) * encoder->in.width]; pixel *recbase_u = &encoder->in.cur_pic->u_recdata[x_ctb * (LCU_WIDTH >> (MAX_DEPTH + 1)) + (y_ctb * (LCU_WIDTH >> (MAX_DEPTH + 1))) * (encoder->in.width >> 1)]; @@ -2268,10 +2267,13 @@ void encode_block_residual(encoder_control *encoder, cur_cu->intra[0].mode_chroma = 36; // TODO: Chroma intra prediction - // Disable for now because it doesn't implement NxN yet. - /*intra_build_reference_border(encoder->in.cur_pic, x_ctb, y_ctb, - (LCU_WIDTH >> (depth)) * 2 + 8, rec, - (LCU_WIDTH >> (depth)) * 2 + 8, 0); + // This does not support NxN yet. + // A quick test with 10 frames of PeopleOnStreet_3840x2160 showed that + // re-doing the search here with actual reconstructed reference lowered + // bitrate by 4% and improved luma PSNR by 0.03dB. Doing it here might + // not be worth it. + intra_build_reference_border(encoder->in.cur_pic, x_ctb * 8, y_ctb * 8, + width * 2 + 8, rec, width * 2 + 8, 0); cur_cu->intra[0].mode = (int8_t)intra_prediction(encoder->in.cur_pic->y_data, encoder->in.width, rec_shift, @@ -2281,7 +2283,9 @@ void encode_block_residual(encoder_control *encoder, width, pred_y, width, &cur_cu->intra[0].cost); intra_set_block_mode(encoder->in.cur_pic, x_ctb, y_ctb, depth, - cur_cu->intra[0].mode, cur_cu->part_size);*/ + cur_cu->intra[0].mode, cur_cu->part_size); + intra_set_block_mode(encoder->in.cur_pic, x_ctb, y_ctb, depth, + cur_cu->intra[0].mode, cur_cu->part_size); diff --git a/src/intra.c b/src/intra.c index 823c5fa9..d4140c7c 100644 --- a/src/intra.c +++ b/src/intra.c @@ -62,21 +62,6 @@ void intra_set_block_mode(picture *pic,uint32_t x_cu, uint32_t y_cu, uint8_t dep cur_cu->tr_depth = depth; } } - - // Loop through all the blocks in the area of cur_cu - /*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++) { - 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[0].mode = mode; - pic->cu_array[MAX_DEPTH][cu_pos + x].intra[1].mode = mode; - pic->cu_array[MAX_DEPTH][cu_pos + x].intra[2].mode = mode; - pic->cu_array[MAX_DEPTH][cu_pos + x].intra[3].mode = mode; - pic->cu_array[MAX_DEPTH][cu_pos + x].part_size = part_mode; - pic->cu_array[MAX_DEPTH][cu_pos + x].tr_depth = depth; - } - }*/ } /** diff --git a/src/search.c b/src/search.c index 6c8f1192..74ecf378 100644 --- a/src/search.c +++ b/src/search.c @@ -400,7 +400,8 @@ void search_intra(encoder_control *encoder, uint16_t x_ctb, uint16_t y_ctb, uint cur_cu->part_size = SIZE_2Nx2N; // Do search for NxN split. - if (1 && depth == MAX_DEPTH) { // Disabled because coding NxN doesn't work yet. + // This feature doesn't work yet so it is disabled. + if (0 && depth == MAX_DEPTH) { // Disabled because coding NxN doesn't work yet. // Save 2Nx2N information to compare with NxN. int nn_cost = cur_cu->intra[0].cost; int nn_mode = cur_cu->intra[0].mode; @@ -525,9 +526,6 @@ uint32_t search_best_mode(encoder_control *encoder, } else { intra_set_block_mode(encoder->in.cur_pic, x_ctb, y_ctb, depth, cur_cu->intra[0].mode, cur_cu->part_size); - if (cur_cu->part_size == SIZE_NxN) { - printf("coded NxN (%u, %u)\n", x_ctb, y_ctb); - } return best_intra_cost; } }