Skip to content

Commit

Permalink
Fix selection of bitcost for NxN mode intra CUs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ari-koivula committed Mar 12, 2014
1 parent 17b9c9d commit 34d4e74
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,6 @@ static int search_cu_intra(encoder_control *encoder,

cu_info *left_cu = 0;
cu_info *above_cu = 0;
uint32_t bitcost = 0, bitcost_nxn;

if ((x_px >> 3) > 0) {
left_cu = &lcu->cu[cu_index - 1];
Expand All @@ -703,6 +702,7 @@ static int search_cu_intra(encoder_control *encoder,
{
uint32_t cost = -1;
int16_t mode = -1;
uint32_t bitcost = -1;
pixel *ref_pixels = &lcu->ref.y[lcu_px.x + lcu_px.y * LCU_WIDTH];
unsigned pu_index = PU_INDEX(x_px >> 2, y_px >> 2);
mode = intra_prediction(ref_pixels, LCU_WIDTH,
Expand All @@ -711,11 +711,10 @@ static int search_cu_intra(encoder_control *encoder,
&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;
}

cur_cu->intra[PU_INDEX(x_px >> 2, y_px >> 2)].bitcost = bitcost;
return cur_cu->intra[PU_INDEX(x_px >> 2, y_px >> 2)].cost;

}

/**
Expand Down Expand Up @@ -757,7 +756,7 @@ static int lcu_get_final_cost(encoder_control *encoder,
}

// Bitcost
cost += (cur_cu->type == CU_INTER ? cur_cu->inter.bitcost : cur_cu->intra[0].bitcost)*(int32_t)(g_cur_lambda_cost+0.5);
cost += (cur_cu->type == CU_INTER ? cur_cu->inter.bitcost : cur_cu->intra[PU_INDEX(x_px >> 2, y_px >> 2)].bitcost)*(int32_t)(g_cur_lambda_cost+0.5);

// Coefficient costs (TODO: more tuning of the cost)
cost += (coeff_cost + (coeff_cost>>1)) * (int32_t)(g_cur_lambda_cost+0.5);
Expand Down

0 comments on commit 34d4e74

Please sign in to comment.