From 19b1642aa2dbdba2eebacf62f22381a3eefdc99a Mon Sep 17 00:00:00 2001 From: Laurent Fasnacht Date: Tue, 22 Apr 2014 11:46:53 +0200 Subject: [PATCH] Removed all cabac parameters (cabac is part of encoder_state) --- src/context.c | 3 +- src/context.h | 2 +- src/encoder.c | 99 ++++++++++++++++++++++++++------------------------- src/encoder.h | 10 +++--- src/intra.c | 10 +++--- src/intra.h | 6 ++-- src/rdo.c | 54 ++++++++++++++-------------- src/rdo.h | 12 +++---- src/search.c | 35 +++++++++--------- src/search.h | 2 +- 10 files changed, 119 insertions(+), 114 deletions(-) diff --git a/src/context.c b/src/context.c index a82a1828..3d962dc7 100644 --- a/src/context.c +++ b/src/context.c @@ -199,8 +199,9 @@ void ctx_init(cabac_ctx *ctx, uint32_t qp, uint32_t init_value) * \param slice type of slice we are coding (P/B/I) */ -void init_contexts(cabac_data *cabac, int8_t QP, int8_t slice) +void init_contexts(encoder_state *encoder_state, int8_t QP, int8_t slice) { + cabac_data * const cabac = &encoder_state->cabac; uint16_t i; // Initialize contexts diff --git a/src/context.h b/src/context.h index dae816d0..e12dce70 100644 --- a/src/context.h +++ b/src/context.h @@ -32,7 +32,7 @@ // Functions void ctx_init(cabac_ctx* ctx, uint32_t qp, uint32_t init_value); -void init_contexts(cabac_data *cabac, int8_t QP, int8_t slice); +void init_contexts(encoder_state *encoder_state, int8_t QP, int8_t slice); int32_t context_calc_pattern_sig_ctx( const uint32_t *sig_coeff_group_flag, uint32_t pos_x, uint32_t pos_y, int32_t width); uint32_t context_get_sig_coeff_group( uint32_t *sig_coeff_group_flag,uint32_t pos_x, uint32_t pos_y,int32_t width); diff --git a/src/encoder.c b/src/encoder.c index e81c79f7..bb23d9f6 100644 --- a/src/encoder.c +++ b/src/encoder.c @@ -47,7 +47,6 @@ static void add_checksum(encoder_state *encoder); static void encode_VUI(encoder_state *encoder); static void encode_sao(encoder_state *encoder, - cabac_data *cabac, unsigned x_lcu, uint16_t y_lcu, sao_info *sao_luma, sao_info *sao_chroma); @@ -312,7 +311,7 @@ void encode_one_frame(encoder_state * const encoder_state) } cabac_start(&encoder_state->cabac); - init_contexts(&encoder_state->cabac, encoder_state->QP, encoder_state->cur_pic->slicetype); + init_contexts(encoder_state, encoder_state->QP, encoder_state->cur_pic->slicetype); encode_slice_header(encoder_state); bitstream_align(stream); @@ -336,7 +335,7 @@ void encode_one_frame(encoder_state * const encoder_state) const int right = px.x + lcu_dim.x; const int bottom = px.y + lcu_dim.y; - search_lcu(encoder_state, &encoder_state->cabac, px.x, px.y, hor_buf, ver_buf); + search_lcu(encoder_state, px.x, px.y, hor_buf, ver_buf); // Take the bottom right pixel from the LCU above and put it as the // first pixel in this LCUs rightmost pixels. @@ -394,10 +393,10 @@ void encode_one_frame(encoder_state * const encoder_state) sao_luma->merge_left_flag = sao_luma->merge_left_flag & sao_chroma->merge_left_flag; sao_luma->merge_up_flag = sao_luma->merge_up_flag & sao_chroma->merge_up_flag; - encode_sao(encoder_state, &encoder_state->cabac, lcu.x, lcu.y, sao_luma, sao_chroma); + encode_sao(encoder_state, lcu.x, lcu.y, sao_luma, sao_chroma); } - encode_coding_tree(encoder_state, &encoder_state->cabac, lcu.x << MAX_DEPTH, lcu.y << MAX_DEPTH, 0); + encode_coding_tree(encoder_state, lcu.x << MAX_DEPTH, lcu.y << MAX_DEPTH, 0); { const int last_lcu = (lcu.x == size_lcu.x - 1 && lcu.y == size_lcu.y - 1); @@ -1062,9 +1061,10 @@ void encode_slice_header(encoder_state * const encoder_state) } -static void encode_sao_color(const encoder_state * const encoder_state, cabac_data *cabac, sao_info *sao, +static void encode_sao_color(encoder_state * const encoder_state, sao_info *sao, color_index color_i) { + cabac_data * const cabac = &encoder_state->cabac; const picture * const cur_pic = encoder_state->cur_pic; sao_eo_cat i; @@ -1112,9 +1112,9 @@ static void encode_sao_color(const encoder_state * const encoder_state, cabac_da } } -static void encode_sao_merge_flags(sao_info *sao, cabac_data *cabac, - unsigned x_ctb, unsigned y_ctb) +static void encode_sao_merge_flags(encoder_state * const encoder_state, sao_info *sao, unsigned x_ctb, unsigned y_ctb) { + cabac_data * const cabac = &encoder_state->cabac; // SAO merge flags are not present for the first row and column. if (x_ctb > 0) { cabac->ctx = &(cabac->ctx_sao_merge_flag_model); @@ -1130,25 +1130,25 @@ static void encode_sao_merge_flags(sao_info *sao, cabac_data *cabac, * \brief Encode SAO information. */ static void encode_sao(encoder_state * const encoder_state, - cabac_data *cabac, unsigned x_lcu, uint16_t y_lcu, sao_info *sao_luma, sao_info *sao_chroma) { // TODO: transmit merge flags outside sao_info - encode_sao_merge_flags(sao_luma, cabac, x_lcu, y_lcu); + encode_sao_merge_flags(encoder_state, sao_luma, x_lcu, y_lcu); // If SAO is merged, nothing else needs to be coded. if (!sao_luma->merge_left_flag && !sao_luma->merge_up_flag) { - encode_sao_color(encoder_state, cabac, sao_luma, COLOR_Y); - encode_sao_color(encoder_state, cabac, sao_chroma, COLOR_U); - encode_sao_color(encoder_state, cabac, sao_chroma, COLOR_V); + encode_sao_color(encoder_state, sao_luma, COLOR_Y); + encode_sao_color(encoder_state, sao_chroma, COLOR_U); + encode_sao_color(encoder_state, sao_chroma, COLOR_V); } } -void encode_coding_tree(encoder_state * const encoder_state, cabac_data *cabac, +void encode_coding_tree(encoder_state * const encoder_state, uint16_t x_ctb, uint16_t y_ctb, uint8_t depth) { + cabac_data * const cabac = &encoder_state->cabac; const picture * const cur_pic = encoder_state->cur_pic; cu_info *cur_cu = &cur_pic->cu_array[MAX_DEPTH][x_ctb + y_ctb * (cur_pic->width_in_lcu << MAX_DEPTH)]; uint8_t split_flag = GET_SPLITDATA(cur_cu, depth); @@ -1182,17 +1182,17 @@ void encode_coding_tree(encoder_state * const encoder_state, cabac_data *cabac, if (split_flag || border) { // Split blocks and remember to change x and y block positions uint8_t change = 1<<(MAX_DEPTH-1-depth); - encode_coding_tree(encoder_state, cabac, x_ctb, y_ctb, depth + 1); // x,y + encode_coding_tree(encoder_state, x_ctb, y_ctb, depth + 1); // x,y // TODO: fix when other half of the block would not be completely over the border if (!border_x || border_split_x) { - encode_coding_tree(encoder_state, cabac, x_ctb + change, y_ctb, depth + 1); + encode_coding_tree(encoder_state, x_ctb + change, y_ctb, depth + 1); } if (!border_y || border_split_y) { - encode_coding_tree(encoder_state, cabac, x_ctb, y_ctb + change, depth + 1); + encode_coding_tree(encoder_state, x_ctb, y_ctb + change, depth + 1); } if (!border || (border_split_x && border_split_y)) { - encode_coding_tree(encoder_state, cabac, x_ctb + change, y_ctb + change, depth + 1); + encode_coding_tree(encoder_state, x_ctb + change, y_ctb + change, depth + 1); } return; } @@ -1392,7 +1392,7 @@ void encode_coding_tree(encoder_state * const encoder_state, cabac_data *cabac, // Code (possible) coeffs to bitstream if(cur_cu->coeff_top_y[depth] | cur_cu->coeff_top_u[depth] | cur_cu->coeff_top_v[depth]) { - encode_transform_coeff(encoder_state, cabac, x_ctb * 2, y_ctb * 2, depth, 0, 0, 0); + encode_transform_coeff(encoder_state, x_ctb * 2, y_ctb * 2, depth, 0, 0, 0); } @@ -1514,7 +1514,7 @@ void encode_coding_tree(encoder_state * const encoder_state, cabac_data *cabac, } } // end intra chroma pred mode coding - encode_transform_coeff(encoder_state, cabac, x_ctb * 2, y_ctb * 2, depth, 0, 0, 0); + encode_transform_coeff(encoder_state, x_ctb * 2, y_ctb * 2, depth, 0, 0, 0); } #if ENABLE_PCM == 1 @@ -1565,7 +1565,7 @@ void encode_coding_tree(encoder_state * const encoder_state, cabac_data *cabac, /* end coding_unit */ } -static void transform_chroma(encoder_state * const encoder_state, cabac_data *cabac, cu_info *cur_cu, +static void transform_chroma(encoder_state * const encoder_state, cu_info *cur_cu, int depth, pixel *base_u, pixel *pred_u, coefficient *coeff_u, int8_t scan_idx_chroma, coefficient *pre_quant_coeff, coefficient *block) @@ -1591,7 +1591,7 @@ static void transform_chroma(encoder_state * const encoder_state, cabac_data *ca transform2d(encoder, block, pre_quant_coeff, width_c, 65535); if (encoder->rdoq_enable) { - rdoq(encoder_state, cabac, pre_quant_coeff, coeff_u, width_c, width_c, &ac_sum, 2, + rdoq(encoder_state, pre_quant_coeff, coeff_u, width_c, width_c, &ac_sum, 2, scan_idx_chroma, cur_cu->type, cur_cu->tr_depth-cur_cu->depth); } else { quant(encoder_state, pre_quant_coeff, coeff_u, width_c, width_c, &ac_sum, 2, @@ -1636,7 +1636,7 @@ static void reconstruct_chroma(const encoder_state * const encoder_state, cu_inf } } -void encode_transform_tree(encoder_state * const encoder_state, cabac_data* cabac, int32_t x, int32_t y, const uint8_t depth, lcu_t* lcu) +void encode_transform_tree(encoder_state * const encoder_state, int32_t x, int32_t y, const uint8_t depth, lcu_t* lcu) { const encoder_control * const encoder = encoder_state->encoder_control; // we have 64>>depth transform size @@ -1654,10 +1654,10 @@ void encode_transform_tree(encoder_state * const encoder_state, cabac_data* caba // Split transform and increase depth if (depth == 0 || cur_cu->tr_depth > depth) { int offset = width_c; - encode_transform_tree(encoder_state, cabac, x, y, depth+1, lcu); - encode_transform_tree(encoder_state, cabac, x + offset, y, depth+1, lcu); - encode_transform_tree(encoder_state, cabac, x, y + offset, depth+1, lcu); - encode_transform_tree(encoder_state, cabac, x + offset, y + offset, depth+1, lcu); + encode_transform_tree(encoder_state, x, y, depth+1, lcu); + encode_transform_tree(encoder_state, x + offset, y, depth+1, lcu); + encode_transform_tree(encoder_state, x, y + offset, depth+1, lcu); + encode_transform_tree(encoder_state, x + offset, y + offset, depth+1, lcu); // Derive coded coeff flags from the next depth if (depth == MAX_DEPTH) { @@ -1796,7 +1796,7 @@ void encode_transform_tree(encoder_state * const encoder_state, cabac_data* caba // Test for transform skip transformskip(encoder, block,pre_quant_coeff,width); if (encoder->rdoq_enable) { - rdoq(encoder_state, cabac, pre_quant_coeff, temp_coeff, 4, 4, &ac_sum, 0, scan_idx_luma, cur_cu->type,0); + rdoq(encoder_state, pre_quant_coeff, temp_coeff, 4, 4, &ac_sum, 0, scan_idx_luma, cur_cu->type,0); } else { quant(encoder_state, pre_quant_coeff, temp_coeff, 4, 4, &ac_sum, 0, scan_idx_luma, cur_cu->type); } @@ -1805,7 +1805,7 @@ void encode_transform_tree(encoder_state * const encoder_state, cabac_data* caba transform2d(encoder, block,pre_quant_coeff,width,0); if (encoder->rdoq_enable) { - rdoq(encoder_state, cabac, pre_quant_coeff, temp_coeff2, 4, 4, &ac_sum, 0, scan_idx_luma, cur_cu->type,0); + rdoq(encoder_state, pre_quant_coeff, temp_coeff2, 4, 4, &ac_sum, 0, scan_idx_luma, cur_cu->type,0); } else { quant(encoder_state, pre_quant_coeff, temp_coeff2, 4, 4, &ac_sum, 0, scan_idx_luma, cur_cu->type); } @@ -1832,8 +1832,8 @@ void encode_transform_tree(encoder_state * const encoder_state, cabac_data* caba cost2 += (coeffcost2 + (coeffcost2>>1))*((int)encoder_state->cur_lambda_cost+0.5); // Full RDO } else if(encoder->rdo == 2) { - coeffcost = get_coeff_cost(encoder, cabac, temp_coeff, 4, 0, scan_idx_luma); - coeffcost2 = get_coeff_cost(encoder, cabac, temp_coeff2, 4, 0, scan_idx_luma); + coeffcost = get_coeff_cost(encoder_state, temp_coeff, 4, 0, scan_idx_luma); + coeffcost2 = get_coeff_cost(encoder_state, temp_coeff2, 4, 0, scan_idx_luma); cost += coeffcost*((int)encoder_state->cur_lambda_cost+0.5); cost2 += coeffcost2*((int)encoder_state->cur_lambda_cost+0.5); @@ -1850,7 +1850,7 @@ void encode_transform_tree(encoder_state * const encoder_state, cabac_data* caba } if (encoder->rdoq_enable) { - rdoq(encoder_state, cabac, pre_quant_coeff, coeff_y, width, width, &ac_sum, 0, + rdoq(encoder_state, pre_quant_coeff, coeff_y, width, width, &ac_sum, 0, scan_idx_luma, cur_cu->type, cur_cu->tr_depth-cur_cu->depth); } else { quant(encoder_state, pre_quant_coeff, coeff_y, width, width, &ac_sum, 0, scan_idx_luma, cur_cu->type); @@ -1934,7 +1934,7 @@ void encode_transform_tree(encoder_state * const encoder_state, cabac_data* caba } } - transform_chroma(encoder_state, cabac, cur_cu, chroma_depth, base_u, pred_u, coeff_u, scan_idx_chroma, pre_quant_coeff, block); + transform_chroma(encoder_state, cur_cu, chroma_depth, base_u, pred_u, coeff_u, scan_idx_chroma, pre_quant_coeff, block); for (i = 0; i < chroma_size; i++) { if (coeff_u[i] != 0) { int d; @@ -1944,7 +1944,7 @@ void encode_transform_tree(encoder_state * const encoder_state, cabac_data* caba break; } } - transform_chroma(encoder_state, cabac, cur_cu, chroma_depth, base_v, pred_v, coeff_v, scan_idx_chroma, pre_quant_coeff, block); + transform_chroma(encoder_state, cur_cu, chroma_depth, base_v, pred_v, coeff_v, scan_idx_chroma, pre_quant_coeff, block); for (i = 0; i < chroma_size; i++) { if (coeff_v[i] != 0) { int d; @@ -1983,10 +1983,9 @@ void encode_transform_tree(encoder_state * const encoder_state, cabac_data* caba // end Residual Coding } -static void encode_transform_unit(encoder_state * const encoder_state, cabac_data *cabac, +static void encode_transform_unit(encoder_state * const encoder_state, int x_pu, int y_pu, int depth, int tr_depth) { - const encoder_control * const encoder = encoder_state->encoder_control; const picture * const cur_pic = encoder_state->cur_pic; uint8_t width = LCU_WIDTH >> depth; uint8_t width_c = (depth == MAX_PU_DEPTH ? width : width / 2); @@ -2061,7 +2060,7 @@ static void encode_transform_unit(encoder_state * const encoder_state, cabac_dat } } - encode_coeff_nxn(encoder, cabac, coeff_y, width, 0, scan_idx, cur_cu->intra[PU_INDEX(x_pu, y_pu)].tr_skip); + encode_coeff_nxn(encoder_state, coeff_y, width, 0, scan_idx, cur_cu->intra[PU_INDEX(x_pu, y_pu)].tr_skip); } if (depth == MAX_DEPTH + 1 && !(x_pu % 2 && y_pu % 2)) { @@ -2117,11 +2116,11 @@ static void encode_transform_unit(encoder_state * const encoder_state, cabac_dat } if (cur_cu->coeff_top_u[depth]) { - encode_coeff_nxn(encoder, cabac, coeff_u, width_c, 2, scan_idx, 0); + encode_coeff_nxn(encoder_state, coeff_u, width_c, 2, scan_idx, 0); } if (cur_cu->coeff_top_v[depth]) { - encode_coeff_nxn(encoder, cabac, coeff_v, width_c, 2, scan_idx, 0); + encode_coeff_nxn(encoder_state, coeff_v, width_c, 2, scan_idx, 0); } } } @@ -2135,9 +2134,10 @@ static void encode_transform_unit(encoder_state * const encoder_state, cabac_dat * \param parent_coeff_u What was signaled at previous level for cbf_cb. * \param parent_coeff_v What was signlaed at previous level for cbf_cr. */ -void encode_transform_coeff(encoder_state * const encoder_state, cabac_data *cabac, int32_t x_pu,int32_t y_pu, +void encode_transform_coeff(encoder_state * const encoder_state, int32_t x_pu,int32_t y_pu, int8_t depth, int8_t tr_depth, uint8_t parent_coeff_u, uint8_t parent_coeff_v) { + cabac_data * const cabac = &encoder_state->cabac; int32_t x_cu = x_pu / 2; int32_t y_cu = y_pu / 2; const picture * const cur_pic = encoder_state->cur_pic; @@ -2194,10 +2194,10 @@ void encode_transform_coeff(encoder_state * const encoder_state, cabac_data *cab if (split) { uint8_t pu_offset = 1 << (MAX_PU_DEPTH - (depth + 1)); - encode_transform_coeff(encoder_state, cabac, x_pu, y_pu, depth + 1, tr_depth + 1, cb_flag_u, cb_flag_v); - encode_transform_coeff(encoder_state, cabac, x_pu + pu_offset, y_pu, depth + 1, tr_depth + 1, cb_flag_u, cb_flag_v); - encode_transform_coeff(encoder_state, cabac, x_pu, y_pu + pu_offset, depth + 1, tr_depth + 1, cb_flag_u, cb_flag_v); - encode_transform_coeff(encoder_state, cabac, x_pu + pu_offset, y_pu + pu_offset, depth + 1, tr_depth + 1, cb_flag_u, cb_flag_v); + encode_transform_coeff(encoder_state, x_pu, y_pu, depth + 1, tr_depth + 1, cb_flag_u, cb_flag_v); + encode_transform_coeff(encoder_state, x_pu + pu_offset, y_pu, depth + 1, tr_depth + 1, cb_flag_u, cb_flag_v); + encode_transform_coeff(encoder_state, x_pu, y_pu + pu_offset, depth + 1, tr_depth + 1, cb_flag_u, cb_flag_v); + encode_transform_coeff(encoder_state, x_pu + pu_offset, y_pu + pu_offset, depth + 1, tr_depth + 1, cb_flag_u, cb_flag_v); return; } @@ -2212,13 +2212,15 @@ void encode_transform_coeff(encoder_state * const encoder_state, cabac_data *cab } if (cb_flag_y | cb_flag_u | cb_flag_v) { - encode_transform_unit(encoder_state, cabac, x_pu, y_pu, depth, tr_depth); + encode_transform_unit(encoder_state, x_pu, y_pu, depth, tr_depth); } } -void encode_coeff_nxn(const encoder_control * const encoder, cabac_data *cabac, coefficient *coeff, uint8_t width, +void encode_coeff_nxn(encoder_state * const encoder_state, coefficient *coeff, uint8_t width, uint8_t type, int8_t scan_mode, int8_t tr_skip) { + const encoder_control * const encoder = encoder_state->encoder_control; + cabac_data * const cabac = &encoder_state->cabac; int c1 = 1; uint8_t last_coeff_x = 0; uint8_t last_coeff_y = 0; @@ -2282,7 +2284,7 @@ void encode_coeff_nxn(const encoder_control * const encoder, cabac_data *cabac, last_coeff_y = (uint8_t)(pos_last >> log2_block_size); // Code last_coeff_x and last_coeff_y - encode_last_significant_xy(cabac, last_coeff_x, last_coeff_y, width, width, + encode_last_significant_xy(encoder_state, last_coeff_x, last_coeff_y, width, width, type, scan_mode); scan_pos_sig = scan_pos_last; @@ -2439,11 +2441,12 @@ void encode_coeff_nxn(const encoder_control * const encoder, cabac_data *cabac, This method encodes the X and Y component within a block of the last significant coefficient. */ -void encode_last_significant_xy(cabac_data *cabac, +void encode_last_significant_xy(encoder_state * const encoder_state, uint8_t lastpos_x, uint8_t lastpos_y, uint8_t width, uint8_t height, uint8_t type, uint8_t scan) { + cabac_data * const cabac = &encoder_state->cabac; uint8_t offset_x = type?0:((TOBITS(width)*3) + ((TOBITS(width)+1)>>2)),offset_y = offset_x; uint8_t shift_x = type?(TOBITS(width)):((TOBITS(width)+3)>>2), shift_y = shift_x; int group_idx_x; diff --git a/src/encoder.h b/src/encoder.h index f0b41634..c522cd9e 100644 --- a/src/encoder.h +++ b/src/encoder.h @@ -142,17 +142,17 @@ void encode_vid_parameter_set(encoder_state *encoder); void encode_slice_header(encoder_state * encoder); void encode_access_unit_delimiter(encoder_state *encoder); void encode_prefix_sei_version(encoder_state *encoder); -void encode_coding_tree(encoder_state *encoder, cabac_data *cabac, uint16_t x_ctb, +void encode_coding_tree(encoder_state *encoder, uint16_t x_ctb, uint16_t y_ctb, uint8_t depth); -void encode_last_significant_xy(cabac_data *cabac, +void encode_last_significant_xy(encoder_state *encoder, uint8_t lastpos_x, uint8_t lastpos_y, uint8_t width, uint8_t height, uint8_t type, uint8_t scan); -void encode_coeff_nxn(const encoder_control * const encoder, cabac_data *cabac, int16_t *coeff, uint8_t width, +void encode_coeff_nxn(encoder_state *encoder, int16_t *coeff, uint8_t width, uint8_t type, int8_t scan_mode, int8_t tr_skip); -void encode_transform_tree(encoder_state *encoder_state, cabac_data* cabac, int32_t x, int32_t y, uint8_t depth, lcu_t* lcu ); -void encode_transform_coeff(encoder_state *encoder_state, cabac_data *cabac, int32_t x_cu, int32_t y_cu, +void encode_transform_tree(encoder_state *encoder_state, int32_t x, int32_t y, uint8_t depth, lcu_t* lcu ); +void encode_transform_coeff(encoder_state *encoder_state, int32_t x_cu, int32_t y_cu, int8_t depth, int8_t tr_depth, uint8_t parent_coeff_u, uint8_t parent_coeff_v); void encode_block_residual(const encoder_control * const encoder, uint16_t x_ctb, uint16_t y_ctb, uint8_t depth); diff --git a/src/intra.c b/src/intra.c index 72ca69d9..443f9307 100644 --- a/src/intra.c +++ b/src/intra.c @@ -327,9 +327,9 @@ static void intra_get_pred(const encoder_control * const encoder, pixel *rec[2], * \param sad_out sad value of best mode * \returns best intra mode */ -int16_t intra_prediction(const encoder_state * const encoder_state, pixel *orig, int32_t origstride, pixel *rec, int16_t recstride, +int16_t intra_prediction(encoder_state * const encoder_state, pixel *orig, int32_t origstride, pixel *rec, int16_t recstride, uint8_t width, uint32_t *sad_out, - int8_t *intra_preds, uint32_t *bitcost_out, cabac_data *cabac) + int8_t *intra_preds, uint32_t *bitcost_out) { uint32_t best_sad = 0xffffffff; uint32_t sad = 0; @@ -415,7 +415,7 @@ int16_t intra_prediction(const encoder_state * const encoder_state, pixel *orig, int rdo_bitcost; // The reconstruction is calculated again here, it could be saved from before.. intra_recon(encoder_state->encoder_control, rec, recstride, width, pred, width, rdo_modes[rdo_mode], 0); - rdo_costs[rdo_mode] = rdo_cost_intra(encoder_state,pred,orig_block,width,cabac,rdo_modes[rdo_mode]); + rdo_costs[rdo_mode] = rdo_cost_intra(encoder_state,pred,orig_block,width,rdo_modes[rdo_mode]); // Bitcost also calculated again for this mode rdo_bitcost = intra_pred_ratecost(rdo_modes[rdo_mode],intra_preds); // Add bitcost * lambda @@ -833,7 +833,7 @@ void intra_get_planar_pred(pixel* src, int32_t srcstride, uint32_t width, pixel* } } -void intra_recon_lcu(encoder_state * const encoder_state, cabac_data *cabac, int x, int y, int depth, lcu_t *lcu, uint32_t pic_width, uint32_t pic_height) +void intra_recon_lcu(encoder_state * const encoder_state, int x, int y, int depth, lcu_t *lcu, uint32_t pic_width, uint32_t pic_height) { const encoder_control * const encoder = encoder_state->encoder_control; int x_local = (x&0x3f), y_local = (y&0x3f); @@ -892,5 +892,5 @@ void intra_recon_lcu(encoder_state * const encoder_state, cabac_data *cabac, int rec_stride, width, width); } - encode_transform_tree(encoder_state, cabac, x, y, depth, lcu); + encode_transform_tree(encoder_state, x, y, depth, lcu); } \ No newline at end of file diff --git a/src/intra.h b/src/intra.h index 43537c36..cdfa3935 100644 --- a/src/intra.h +++ b/src/intra.h @@ -39,9 +39,9 @@ void intra_build_reference_border(const encoder_control *encoder, int32_t x_luma void intra_filter(pixel* ref, int32_t stride, int32_t width, int8_t mode); /* Predictions */ -int16_t intra_prediction(const encoder_state *encoder_state, pixel *orig, int32_t origstride, pixel *rec, int16_t recstride, +int16_t intra_prediction(encoder_state *encoder_state, pixel *orig, int32_t origstride, pixel *rec, int16_t recstride, uint8_t width, uint32_t *sad_out, - int8_t *intra_preds, uint32_t *bitcost_out, cabac_data *cabac); + int8_t *intra_preds, uint32_t *bitcost_out); pixel intra_get_dc_pred(pixel* pic, uint16_t pic_width, uint8_t width); void intra_get_planar_pred(pixel* src,int32_t srcstride, uint32_t width, pixel* dst, int32_t dststride); @@ -49,6 +49,6 @@ void intra_get_angular_pred(const encoder_control *encoder, pixel* src, int32_t void intra_recon(const encoder_control *encoder, pixel* rec, int32_t rec_stride, uint32_t width, pixel* dst, int32_t dst_stride, int8_t mode, int8_t chroma); -void intra_recon_lcu(encoder_state *encoder_state, cabac_data *cabac, int x, int y, int depth, lcu_t *lcu, uint32_t pic_width, uint32_t pic_height); +void intra_recon_lcu(encoder_state *encoder_state, int x, int y, int depth, lcu_t *lcu, uint32_t pic_width, uint32_t pic_height); #endif diff --git a/src/rdo.c b/src/rdo.c index 4115f379..d9be91db 100644 --- a/src/rdo.c +++ b/src/rdo.c @@ -63,7 +63,7 @@ const uint32_t entropy_bits[128] = ** Only for luma */ -uint32_t rdo_cost_intra(const encoder_state * const encoder_state, pixel *pred, pixel *orig_block, int width, cabac_data *cabac, int8_t mode) +uint32_t rdo_cost_intra(encoder_state * const encoder_state, pixel *pred, pixel *orig_block, int width, int8_t mode) { const encoder_control * const encoder = encoder_state->encoder_control; coefficient pre_quant_coeff[LCU_WIDTH*LCU_WIDTH>>2]; @@ -93,7 +93,7 @@ uint32_t rdo_cost_intra(const encoder_state * const encoder_state, pixel *pred, } transform2d(encoder, block,pre_quant_coeff,width,0); if(encoder->rdoq_enable) { - rdoq(encoder_state, cabac, pre_quant_coeff, temp_coeff, width, width, &ac_sum, 0, luma_scan_mode, CU_INTRA,0); + rdoq(encoder_state, pre_quant_coeff, temp_coeff, width, width, &ac_sum, 0, luma_scan_mode, CU_INTRA,0); } else { quant(encoder_state, pre_quant_coeff, temp_coeff, width, width, &ac_sum, 0, luma_scan_mode, CU_INTRA); } @@ -115,7 +115,7 @@ uint32_t rdo_cost_intra(const encoder_state * const encoder_state, pixel *pred, cost += (1 + coeffcost + (coeffcost>>1))*((int)encoder_state->cur_lambda_cost+0.5); // Full RDO } else if(encoder->rdo == 2) { - coeffcost = get_coeff_cost(encoder, cabac, temp_coeff, width, 0, luma_scan_mode); + coeffcost = get_coeff_cost(encoder_state, temp_coeff, width, 0, luma_scan_mode); cost += coeffcost*((int)encoder_state->cur_lambda_cost+0.5); } @@ -128,12 +128,12 @@ uint32_t rdo_cost_intra(const encoder_state * const encoder_state, pixel *pred, * \param type data type (0 == luma) * \returns bits needed to code input coefficients */ -int32_t get_coeff_cost(const encoder_control * const encoder, cabac_data *cabac, coefficient *coeff, int32_t width, int32_t type, int8_t scan_mode) +int32_t get_coeff_cost(const encoder_state * const current_encoder_state, coefficient *coeff, int32_t width, int32_t type, int8_t scan_mode) { - cabac_data temp_cabac; int32_t cost = 0; int i; int found = 0; + encoder_state temp_encoder; // Make sure there are coeffs present for(i = 0; i < width*width; i++) { @@ -146,21 +146,18 @@ int32_t get_coeff_cost(const encoder_control * const encoder, cabac_data *cabac, if(!found) return 0; // Store cabac state and contexts - memcpy(&temp_cabac,cabac,sizeof(cabac_data)); + memcpy(&temp_encoder,current_encoder_state,sizeof(encoder_state)); // Clear bytes and bits and set mode to "count" - cabac->only_count = 1; - cabac->num_buffered_bytes = 0; - cabac->bits_left = 23; + temp_encoder.cabac.only_count = 1; + temp_encoder.cabac.num_buffered_bytes = 0; + temp_encoder.cabac.bits_left = 23; // Execute the coding function - encode_coeff_nxn(encoder, cabac, coeff, width, type, scan_mode, 0); + encode_coeff_nxn(&temp_encoder, coeff, width, type, scan_mode, 0); // Store bitcost before restoring cabac - cost = (23-cabac->bits_left) + (cabac->num_buffered_bytes << 3); - - // Restore cabac state and contexts - memcpy(cabac,&temp_cabac,sizeof(cabac_data)); + cost = (23-temp_encoder.cabac.bits_left) + (temp_encoder.cabac.num_buffered_bytes << 3); return cost; } @@ -176,7 +173,7 @@ int32_t get_coeff_cost(const encoder_control * const encoder, cabac_data *cabac, * \returns cost of given absolute transform level * From HM 12.0 */ -double get_ic_rate_cost (cabac_data *cabac, +double get_ic_rate_cost (encoder_state * const encoder_state, uint32_t abs_level, uint16_t ctx_num_one, uint16_t ctx_num_abs, @@ -186,6 +183,7 @@ double get_ic_rate_cost (cabac_data *cabac, int8_t type ) { + cabac_data * const cabac = &encoder_state->cabac; double rate = 32768.0; uint32_t base_level = (c1_idx < C1FLAG_NUMBER)? (2 + (c2_idx < C2FLAG_NUMBER)) : 1; cabac_ctx *base_one_ctx = (type == 0) ? &(cabac->ctx_cu_one_model_luma[0]) : &(cabac->ctx_cu_one_model_chroma[0]); @@ -224,9 +222,10 @@ double get_ic_rate_cost (cabac_data *cabac, } -int32_t get_ic_rate( cabac_data *cabac, uint32_t abs_level, uint16_t ctx_num_one,uint16_t ctx_num_abs, +int32_t get_ic_rate( encoder_state * const encoder_state, uint32_t abs_level, uint16_t ctx_num_one,uint16_t ctx_num_abs, uint16_t abs_go_rice, uint32_t c1_idx, uint32_t c2_idx, int8_t type) { + cabac_data * const cabac = &encoder_state->cabac; int32_t rate = 0; uint32_t base_level = (c1_idx < C1FLAG_NUMBER)? (2 + (c2_idx < C2FLAG_NUMBER)) : 1; cabac_ctx *base_one_ctx = (type == 0) ? &(cabac->ctx_cu_one_model_luma[0]) : &(cabac->ctx_cu_one_model_chroma[0]); @@ -285,13 +284,14 @@ int32_t get_ic_rate( cabac_data *cabac, uint32_t abs_level, uint16_t ctx_num_one * This method calculates the best quantized transform level for a given scan position. * From HM 12.0 */ -uint32_t get_coded_level ( const encoder_state * const encoder_state, cabac_data *cabac, double *coded_cost, double *coded_cost0, double *coded_cost_sig, +uint32_t get_coded_level ( encoder_state * const encoder_state, double *coded_cost, double *coded_cost0, double *coded_cost_sig, int32_t level_double, uint32_t max_abs_level, uint16_t ctx_num_sig, uint16_t ctx_num_one, uint16_t ctx_num_abs, uint16_t abs_go_rice, uint32_t c1_idx, uint32_t c2_idx, int32_t q_bits,double temp, int8_t last, int8_t type) { + cabac_data * const cabac = &encoder_state->cabac; double cur_cost_sig = 0; uint32_t best_abs_level = 0; int32_t abs_level; @@ -314,7 +314,7 @@ uint32_t get_coded_level ( const encoder_state * const encoder_state, cabac_data for (abs_level = max_abs_level; abs_level >= min_abs_level ; abs_level-- ) { double err = (double)(level_double - ( abs_level << q_bits ) ); double cur_cost = err * err * temp + encoder_state->cur_lambda_cost * - get_ic_rate_cost( cabac, abs_level, ctx_num_one, ctx_num_abs, + get_ic_rate_cost( encoder_state, abs_level, ctx_num_one, ctx_num_abs, abs_go_rice, c1_idx, c2_idx, type); cur_cost += cur_cost_sig; @@ -353,9 +353,10 @@ static double get_rate_last(const encoder_state * const encoder_state, return encoder_state->cur_lambda_cost*uiCost; } -static void calc_last_bits(cabac_data *cabac, int32_t width, int32_t height, int8_t type, +static void calc_last_bits(encoder_state * const encoder_state, int32_t width, int32_t height, int8_t type, int32_t* last_x_bits, int32_t* last_y_bits) { + cabac_data * const cabac = &encoder_state->cabac; int32_t bits_x = 0, bits_y = 0; int32_t blk_size_offset_x, blk_size_offset_y, shiftX, shiftY; int32_t ctx; @@ -389,10 +390,11 @@ static void calc_last_bits(cabac_data *cabac, int32_t width, int32_t height, int * coding engines using probability models like CABAC * From HM 12.0 */ -void rdoq(const encoder_state * const encoder_state, cabac_data *cabac, coefficient *coef, coefficient *dest_coeff, int32_t width, +void rdoq(encoder_state * const encoder_state, coefficient *coef, coefficient *dest_coeff, int32_t width, int32_t height, uint32_t *abs_sum, int8_t type, int8_t scan_mode, int8_t block_type, int8_t tr_depth) { const encoder_control * const encoder = encoder_state->encoder_control; + cabac_data * const cabac = &encoder_state->cabac; uint32_t log2_tr_size = g_convert_to_bit[ width ] + 2; int32_t transform_shift = MAX_TR_DYNAMIC_RANGE - encoder->bitdepth - log2_tr_size; // Represents scaling through forward transform uint16_t go_rice_param = 0; @@ -458,7 +460,7 @@ void rdoq(const encoder_state * const encoder_state, cabac_data *cabac, coeffic coeffgroup_rd_stats rd_stats; int32_t last_x_bits[32],last_y_bits[32]; - calc_last_bits(cabac, width, height, type,last_x_bits, last_y_bits); + calc_last_bits(encoder_state, width, height, type,last_x_bits, last_y_bits); memset( cost_coeff, 0, sizeof(double) * max_num_coeff ); memset( cost_sig, 0, sizeof(double) * max_num_coeff ); @@ -513,7 +515,7 @@ void rdoq(const encoder_state * const encoder_state, cabac_data *cabac, coeffic uint16_t abs_ctx = ctx_set + c2; if( scanpos == last_scanpos ) { - level = get_coded_level(encoder_state, cabac, &cost_coeff[ scanpos ], &cost_coeff0[ scanpos ], &cost_sig[ scanpos ], + level = get_coded_level(encoder_state, &cost_coeff[ scanpos ], &cost_coeff0[ scanpos ], &cost_sig[ scanpos ], level_double, max_abs_level, 0, one_ctx, abs_ctx, go_rice_param, c1_idx, c2_idx, q_bits, temp, 1, type ); } else { @@ -521,16 +523,16 @@ void rdoq(const encoder_state * const encoder_state, cabac_data *cabac, coeffic uint32_t pos_x = blkpos - ( pos_y << log2_block_size ); uint16_t ctx_sig = (uint16_t)context_get_sig_ctx_inc(pattern_sig_ctx, scan_mode, pos_x, pos_y, log2_block_size, type); - level = get_coded_level(encoder_state, cabac, &cost_coeff[ scanpos ], &cost_coeff0[ scanpos ], &cost_sig[ scanpos ], + level = get_coded_level(encoder_state, &cost_coeff[ scanpos ], &cost_coeff0[ scanpos ], &cost_sig[ scanpos ], level_double, max_abs_level, ctx_sig, one_ctx, abs_ctx, go_rice_param, c1_idx, c2_idx, q_bits, temp, 0, type ); sig_rate_delta[ blkpos ] = CTX_ENTROPY_BITS(&baseCtx[ctx_sig],1) - CTX_ENTROPY_BITS(&baseCtx[ctx_sig],0); } delta_u[ blkpos ] = (level_double - ((int32_t)level << q_bits)) >> (q_bits-8); if( level > 0 ) { - int32_t rate_now = get_ic_rate( cabac, level, one_ctx, abs_ctx, go_rice_param, c1_idx, c2_idx, type); - rate_inc_up [blkpos] = get_ic_rate( cabac, level+1, one_ctx, abs_ctx, go_rice_param, c1_idx, c2_idx, type) - rate_now; - rate_inc_down[blkpos] = get_ic_rate( cabac, level-1, one_ctx, abs_ctx, go_rice_param, c1_idx, c2_idx, type) - rate_now; + int32_t rate_now = get_ic_rate( encoder_state, level, one_ctx, abs_ctx, go_rice_param, c1_idx, c2_idx, type); + rate_inc_up [blkpos] = get_ic_rate( encoder_state, level+1, one_ctx, abs_ctx, go_rice_param, c1_idx, c2_idx, type) - rate_now; + rate_inc_down[blkpos] = get_ic_rate( encoder_state, level-1, one_ctx, abs_ctx, go_rice_param, c1_idx, c2_idx, type) - rate_now; } else { // level == 0 rate_inc_up[blkpos] = CTX_ENTROPY_BITS(&base_one_ctx[one_ctx],0); } diff --git a/src/rdo.h b/src/rdo.h index 1392a9d8..598018e8 100644 --- a/src/rdo.h +++ b/src/rdo.h @@ -42,18 +42,18 @@ extern const uint32_t g_go_rice_range[5]; extern const uint32_t g_go_rice_prefix_len[5]; -void rdoq(const encoder_state *encoder_state, cabac_data *cabac, coefficient *coef, coefficient *dest_coeff, int32_t width, +void rdoq(encoder_state *encoder_state, coefficient *coef, coefficient *dest_coeff, int32_t width, int32_t height, uint32_t *abs_sum, int8_t type, int8_t scan_mode, int8_t block_type, int8_t tr_depth); -uint32_t rdo_cost_intra(const encoder_state *encoder, pixel* pred, pixel* orig_block, int width, cabac_data* cabac, int8_t mode); +uint32_t rdo_cost_intra(encoder_state *encoder, pixel* pred, pixel* orig_block, int width, int8_t mode); -int32_t get_coeff_cost(const encoder_control * const encoder, cabac_data *cabac, coefficient *coeff, int32_t width, int32_t type, int8_t scan_mode); +int32_t get_coeff_cost(const encoder_state *encoder_state, coefficient *coeff, int32_t width, int32_t type, int8_t scan_mode); -int32_t get_ic_rate(cabac_data *cabac, uint32_t abs_level, uint16_t ctx_num_one,uint16_t ctx_num_abs, +int32_t get_ic_rate(encoder_state *encoder_state, uint32_t abs_level, uint16_t ctx_num_one,uint16_t ctx_num_abs, uint16_t abs_go_rice, uint32_t c1_idx, uint32_t c2_idx, int8_t type); -double get_ic_rate_cost (cabac_data *cabac, uint32_t abs_level, uint16_t ctx_num_one, uint16_t ctx_num_abs, +double get_ic_rate_cost (encoder_state *encoder_state, uint32_t abs_level, uint16_t ctx_num_one, uint16_t ctx_num_abs, uint16_t abs_go_rice, uint32_t c1_idx, uint32_t c2_idx, int8_t type); -uint32_t get_coded_level ( const encoder_state * encoder_state, cabac_data *cabac, double* coded_cost, double* coded_cost0, double* coded_cost_sig, +uint32_t get_coded_level ( encoder_state * encoder_state, double* coded_cost, double* coded_cost0, double* coded_cost_sig, int32_t level_double, uint32_t max_abs_level, uint16_t ctx_num_sig, uint16_t ctx_num_one, uint16_t ctx_num_abs, uint16_t abs_go_rice, diff --git a/src/search.c b/src/search.c index b0584dc0..910648ce 100644 --- a/src/search.c +++ b/src/search.c @@ -664,9 +664,9 @@ static void lcu_set_coeff(lcu_t *lcu, int x_px, int y_px, int depth, cu_info *cu * Update lcu to have best modes at this depth. * \return Cost of best mode. */ -static int search_cu_intra(const encoder_state * const encoder_state, +static int search_cu_intra(encoder_state * const encoder_state, const int x_px, const int y_px, - const int depth, lcu_t *lcu, cabac_data *cabac) + const int depth, lcu_t *lcu) { const picture * const cur_pic = encoder_state->cur_pic; const vector2d lcu_px = { x_px & 0x3f, y_px & 0x3f }; @@ -711,7 +711,7 @@ static int search_cu_intra(const encoder_state * const encoder_state, unsigned pu_index = PU_INDEX(x_px >> 2, y_px >> 2); mode = intra_prediction(encoder_state,ref_pixels, LCU_WIDTH, cu_in_rec_buffer, cu_width * 2 + 8, cu_width, - &cost, candidate_modes, &bitcost, cabac); + &cost, candidate_modes, &bitcost); cur_cu->intra[pu_index].mode = (int8_t)mode; cur_cu->intra[pu_index].cost = cost; cur_cu->intra[pu_index].bitcost = bitcost; @@ -729,7 +729,6 @@ static int search_cu_intra(const encoder_state * const encoder_state, * here as (coefficient_sum * 1.5) * lambda) */ static int lcu_get_final_cost(const encoder_state * const encoder_state, - cabac_data *cabac, const int x_px, const int y_px, const int depth, lcu_t *lcu) { @@ -818,7 +817,7 @@ static int lcu_get_final_cost(const encoder_state * const encoder_state, // Calculate luma coeff bit count picture_blit_coeffs(&lcu->coeff.y[(blk_y*LCU_WIDTH)+blk_x],coeff_temp,blockwidth,blockwidth,LCU_WIDTH,blockwidth); - coeff_cost += get_coeff_cost(encoder_state->encoder_control, cabac, coeff_temp, blockwidth, 0, luma_scan_mode); + coeff_cost += get_coeff_cost(encoder_state, coeff_temp, blockwidth, 0, luma_scan_mode); blk_y >>= 1; blk_x >>= 1; @@ -833,8 +832,8 @@ static int lcu_get_final_cost(const encoder_state * const encoder_state, picture_blit_coeffs(&lcu->coeff.u[(blk_y*(LCU_WIDTH>>1))+blk_x],coeff_temp_u,blockwidth,blockwidth,LCU_WIDTH>>1,blockwidth); picture_blit_coeffs(&lcu->coeff.v[(blk_y*(LCU_WIDTH>>1))+blk_x],coeff_temp_v,blockwidth,blockwidth,LCU_WIDTH>>1,blockwidth); - coeff_cost += get_coeff_cost(encoder_state->encoder_control, cabac, coeff_temp_u, blockwidth, 2, chroma_scan_mode); - coeff_cost += get_coeff_cost(encoder_state->encoder_control, cabac, coeff_temp_v, blockwidth, 2, chroma_scan_mode); + coeff_cost += get_coeff_cost(encoder_state, coeff_temp_u, blockwidth, 2, chroma_scan_mode); + coeff_cost += get_coeff_cost(encoder_state, coeff_temp_v, blockwidth, 2, chroma_scan_mode); } // Multiply bit count with lambda to get RD-cost cost += coeff_cost * (int32_t)(encoder_state->cur_lambda_cost+0.5); @@ -856,7 +855,7 @@ static int lcu_get_final_cost(const encoder_state * const encoder_state, * - All the final data for the LCU gets eventually copied to depth 0, which * will be the final output of the recursion. */ -static int search_cu(encoder_state * const encoder_state, cabac_data *cabac, int x, int y, int depth, lcu_t work_tree[MAX_PU_DEPTH]) +static int search_cu(encoder_state * const encoder_state, int x, int y, int depth, lcu_t work_tree[MAX_PU_DEPTH]) { const picture * const cur_pic = encoder_state->cur_pic; int cu_width = LCU_WIDTH >> depth; @@ -896,7 +895,7 @@ static int search_cu(encoder_state * const encoder_state, cabac_data *cabac, int if (depth >= MIN_INTRA_SEARCH_DEPTH && depth <= MAX_INTRA_SEARCH_DEPTH) { - int mode_cost = search_cu_intra(encoder_state, x, y, depth, &work_tree[depth], cabac); + int mode_cost = search_cu_intra(encoder_state, x, y, depth, &work_tree[depth]); if (mode_cost < cost) { cost = mode_cost; cur_cu->type = CU_INTRA; @@ -907,10 +906,10 @@ static int search_cu(encoder_state * const encoder_state, cabac_data *cabac, int // mode search of adjacent CUs. if (cur_cu->type == CU_INTRA) { lcu_set_intra_mode(&work_tree[depth], x, y, depth, cur_cu->intra[PU_INDEX(x >> 2, y >> 2)].mode, cur_cu->part_size); - intra_recon_lcu(encoder_state, cabac, x, y, depth,&work_tree[depth], cur_pic->width, cur_pic->height); + intra_recon_lcu(encoder_state, x, y, depth,&work_tree[depth], cur_pic->width, cur_pic->height); } else if (cur_cu->type == CU_INTER) { inter_recon_lcu(encoder_state->encoder_control, encoder_state->ref->pics[cur_cu->inter.mv_ref], x, y, LCU_WIDTH>>depth, cur_cu->inter.mv, &work_tree[depth]); - encode_transform_tree(encoder_state, cabac, x, y, depth, &work_tree[depth]); + encode_transform_tree(encoder_state, x, y, depth, &work_tree[depth]); if(cur_cu->merged && !cur_cu->coeff_top_y[depth] && !cur_cu->coeff_top_u[depth] && !cur_cu->coeff_top_v[depth]) { cur_cu->merged = 0; @@ -923,7 +922,7 @@ static int search_cu(encoder_state * const encoder_state, cabac_data *cabac, int } } if (cur_cu->type == CU_INTRA || cur_cu->type == CU_INTER) { - cost = lcu_get_final_cost(encoder_state, cabac, x, y, depth, &work_tree[depth]); + cost = lcu_get_final_cost(encoder_state, x, y, depth, &work_tree[depth]); } // Recursively split all the way to max search depth. @@ -936,10 +935,10 @@ static int search_cu(encoder_state * const encoder_state, cabac_data *cabac, int // might not give any better results but takes more time to do. if(cur_cu->type == CU_NOTSET || cur_cu->coeff_top_y[depth] || cur_cu->coeff_top_u[depth] || cur_cu->coeff_top_v[depth]) { - split_cost += search_cu(encoder_state, cabac, x, y, depth + 1, work_tree); - split_cost += search_cu(encoder_state, cabac, x + half_cu, y, depth + 1, work_tree); - split_cost += search_cu(encoder_state, cabac, x, y + half_cu, depth + 1, work_tree); - split_cost += search_cu(encoder_state, cabac, x + half_cu, y + half_cu, depth + 1, work_tree); + split_cost += search_cu(encoder_state, x, y, depth + 1, work_tree); + split_cost += search_cu(encoder_state, x + half_cu, y, depth + 1, work_tree); + split_cost += search_cu(encoder_state, x, y + half_cu, depth + 1, work_tree); + split_cost += search_cu(encoder_state, x + half_cu, y + half_cu, depth + 1, work_tree); } else { split_cost = INT_MAX; } @@ -1124,7 +1123,7 @@ static void copy_lcu_to_cu_data(const encoder_state * const encoder_state, int x * Search LCU for modes. * - Best mode gets copied to current picture. */ -void search_lcu(encoder_state * const encoder_state, cabac_data *cabac, int x, int y, yuv_t* hor_buf, yuv_t* ver_buf) +void search_lcu(encoder_state * const encoder_state, int x, int y, yuv_t* hor_buf, yuv_t* ver_buf) { lcu_t work_tree[MAX_PU_DEPTH + 1]; int depth; @@ -1135,7 +1134,7 @@ void search_lcu(encoder_state * const encoder_state, cabac_data *cabac, int x, i } // Start search from depth 0. - search_cu(encoder_state, cabac, x, y, 0, work_tree); + search_cu(encoder_state, x, y, 0, work_tree); copy_lcu_to_cu_data(encoder_state, x, y, &work_tree[0]); } diff --git a/src/search.h b/src/search.h index 68642b84..32d7b2b4 100644 --- a/src/search.h +++ b/src/search.h @@ -30,6 +30,6 @@ #include "picture.h" -void search_lcu(encoder_state *encoder_state, cabac_data *cabac, int x, int y, yuv_t *hor_buf, yuv_t *ver_buf); +void search_lcu(encoder_state *encoder_state, int x, int y, yuv_t *hor_buf, yuv_t *ver_buf); #endif