From: Yaowu Xu Date: Mon, 9 Nov 2015 16:58:31 +0000 (-0800) Subject: Merge branch 'master' into nextgenv2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b49ac0b1601284397d72c2ca7a561c660ae6b18b;p=libvpx Merge branch 'master' into nextgenv2 Change-Id: I8811bfd8fc132b9f515707e795bb6308e4bf263b --- b49ac0b1601284397d72c2ca7a561c660ae6b18b diff --cc vp10/encoder/rdopt.c index 63b2a972e,8ba211017..adcd5473a --- a/vp10/encoder/rdopt.c +++ b/vp10/encoder/rdopt.c @@@ -2457,155 -1346,6 +2457,155 @@@ static int super_block_uvrd(const VP10_ return is_cost_valid; } +#if CONFIG_EXT_INTRA +// Return 1 if an ext intra mode is selected; return 0 otherwise. +static int rd_pick_ext_intra_sbuv(VP10_COMP *cpi, MACROBLOCK *x, + PICK_MODE_CONTEXT *ctx, + int *rate, int *rate_tokenonly, + int64_t *distortion, int *skippable, + BLOCK_SIZE bsize, int64_t *best_rd) { + MACROBLOCKD *const xd = &x->e_mbd; + MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; + int ext_intra_selected_flag = 0; + int this_rate_tokenonly, this_rate, s; + int64_t this_distortion, this_sse, this_rd, best_angle_rd = INT64_MAX; + EXT_INTRA_MODE mode; + int i, step, delta, angle, best_angle, best_angle_dir; + int deltas[3] = {25, 5, 1}; + int branches[3] = {2, 2, 2}; + EXT_INTRA_MODE_INFO ext_intra_mode_info; + + vp10_zero(ext_intra_mode_info); + mbmi->ext_intra_mode_info.use_ext_intra_mode[1] = 1; + mbmi->uv_mode = DC_PRED; + + if (!DR_ONLY) { + for (mode = 0; mode < FILTER_INTRA_MODES; ++mode) { + mbmi->ext_intra_mode_info.ext_intra_mode[1] = mode; + if (!super_block_uvrd(cpi, x, &this_rate_tokenonly, + &this_distortion, &s, &this_sse, bsize, *best_rd)) + continue; + + this_rate = this_rate_tokenonly + + vp10_cost_bit(cpi->common.fc->ext_intra_probs[1], 1) + + vp10_cost_bit(DR_EXT_INTRA_PROB, 0) + - cpi->intra_uv_mode_cost[mbmi->uv_mode] + ++ cpi->intra_uv_mode_cost[mbmi->mode][mbmi->uv_mode] + + write_uniform_cost(FILTER_INTRA_MODES, mode); + this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion); + if (this_rd < *best_rd) { + *best_rd = this_rd; + *rate = this_rate; + *rate_tokenonly = this_rate_tokenonly; + *distortion = this_distortion; + *skippable = s; + ext_intra_mode_info = mbmi->ext_intra_mode_info; + ext_intra_selected_flag = 1; + if (!x->select_tx_size) + swap_block_ptr(x, ctx, 2, 0, 1, MAX_MB_PLANE); + } + } + } + + mbmi->ext_intra_mode_info.ext_intra_mode[1] = EXT_DR_PRED; + if (ANGLE_FAST_SEARCH) { + best_angle = EXT_INTRA_ANGLES / 2; + for (step = 0; step < 3; ++step) { + delta = deltas[step]; + for (i = -branches[step]; i <= branches[step]; ++i) { + int64_t rd_thresh; + if (i == 0 && step != 0) + continue; + angle = best_angle + i * delta; + if (angle < 0) + angle = 0; + if (angle >= EXT_INTRA_ANGLES) + angle = EXT_INTRA_ANGLES - 1; + if (angle == best_angle && step != 0) + continue; + mbmi->ext_intra_mode_info.ext_intra_angle[1] = angle; + if (*best_rd == INT64_MAX) + rd_thresh = best_angle_rd; + else + rd_thresh = VPXMIN(best_angle_rd, *best_rd * RD_ADJUSTER); + if (!super_block_uvrd(cpi, x, &this_rate_tokenonly, &this_distortion, + &s, &this_sse, bsize, rd_thresh)) + continue; + this_rate = this_rate_tokenonly + + vp10_cost_bit(cpi->common.fc->ext_intra_probs[1], 1) + + (DR_ONLY ? 0: vp10_cost_bit(DR_EXT_INTRA_PROB, 1)) + - cpi->intra_uv_mode_cost[mbmi->uv_mode] + ++ cpi->intra_uv_mode_cost[mbmi->mode][mbmi->uv_mode] + + write_uniform_cost(EXT_INTRA_ANGLES, angle); + this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion); + if (this_rd < *best_rd) { + *best_rd = this_rd; + *rate = this_rate; + *rate_tokenonly = this_rate_tokenonly; + *distortion = this_distortion; + *skippable = s; + ext_intra_mode_info = mbmi->ext_intra_mode_info; + ext_intra_selected_flag = 1; + if (!x->select_tx_size) + swap_block_ptr(x, ctx, 2, 0, 1, MAX_MB_PLANE); + } + if (this_rd < best_angle_rd) { + best_angle_rd = this_rd; + best_angle_dir = i; + } + } + best_angle += best_angle_dir * delta; + if (best_angle < 0) + best_angle = 0; + if (best_angle >= EXT_INTRA_ANGLES) + best_angle = EXT_INTRA_ANGLES - 1; + if (*best_rd < best_angle_rd / RD_ADJUSTER) + break; + } + } else { + for (angle = 0; angle < EXT_INTRA_ANGLES; ++angle) { + mbmi->ext_intra_mode_info.ext_intra_angle[1] = angle; + if (prediction_angle_map(angle) == 90 || + prediction_angle_map(angle) == 180) + continue; + if (!super_block_uvrd(cpi, x, &this_rate_tokenonly, + &this_distortion, &s, &this_sse, bsize, *best_rd)) + continue; + + this_rate = this_rate_tokenonly + + vp10_cost_bit(cpi->common.fc->ext_intra_probs[1], 1) + + (DR_ONLY ? 0: vp10_cost_bit(DR_EXT_INTRA_PROB, 1)) + - cpi->intra_uv_mode_cost[mbmi->uv_mode] + ++ cpi->intra_uv_mode_cost[mbmi->mode][mbmi->uv_mode] + + write_uniform_cost(EXT_INTRA_ANGLES, angle); + this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion); + if (this_rd < *best_rd) { + *best_rd = this_rd; + *rate = this_rate; + *rate_tokenonly = this_rate_tokenonly; + *distortion = this_distortion; + *skippable = s; + ext_intra_mode_info = mbmi->ext_intra_mode_info; + ext_intra_selected_flag = 1; + if (!x->select_tx_size) + swap_block_ptr(x, ctx, 2, 0, 1, MAX_MB_PLANE); + } + } + } + + if (ext_intra_selected_flag) { + mbmi->uv_mode = DC_PRED; + mbmi->ext_intra_mode_info.use_ext_intra_mode[1] = + ext_intra_mode_info.use_ext_intra_mode[1]; + mbmi->ext_intra_mode_info.ext_intra_mode[1] = + ext_intra_mode_info.ext_intra_mode[1]; + mbmi->ext_intra_mode_info.ext_intra_angle[1] = + ext_intra_mode_info.ext_intra_angle[1]; + + return 1; + } else { + return 0; + } +} +#endif // CONFIG_EXT_INTRA + static int64_t rd_pick_intra_sbuv_mode(VP10_COMP *cpi, MACROBLOCK *x, PICK_MODE_CONTEXT *ctx, int *rate, int *rate_tokenonly, @@@ -2635,11 -1369,8 +2635,12 @@@ if (!super_block_uvrd(cpi, x, &this_rate_tokenonly, &this_distortion, &s, &this_sse, bsize, best_rd)) continue; - this_rate = this_rate_tokenonly + cpi->intra_uv_mode_cost[mode]; + this_rate = this_rate_tokenonly + + cpi->intra_uv_mode_cost[xd->mi[0]->mbmi.mode][mode]; +#if CONFIG_EXT_INTRA + if (mode == DC_PRED) + this_rate += vp10_cost_bit(cpi->common.fc->ext_intra_probs[1], 0); +#endif // CONFIG_EXT_INTRA this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion); if (this_rd < best_rd) {