Merge "Always include the cost of tx size in rate for Y." into nextgenv2
diff --git a/vp10/encoder/encodeframe.c b/vp10/encoder/encodeframe.c
index 78d7067..b1cfa14 100644
--- a/vp10/encoder/encodeframe.c
+++ b/vp10/encoder/encodeframe.c
@@ -3362,6 +3362,8 @@
PICK_MODE_CONTEXT *ctx = &pc_tree->none;
int i;
const int pl = partition_plane_context(xd, mi_row, mi_col, bsize);
+ int *partition_cost = cpi->partition_cost[pl];
+ int tmp_partition_cost[PARTITION_TYPES];
BLOCK_SIZE subsize;
RD_COST this_rdc, sum_rdc, best_rdc;
#if CONFIG_SUPERTX
@@ -3399,6 +3401,30 @@
bsize >= BLOCK_8X8;
(void) *tp_orig;
+ if (force_horz_split || force_vert_split) {
+ tmp_partition_cost[PARTITION_NONE] = INT_MAX;
+
+ if (!force_vert_split) { // force_horz_split only
+ tmp_partition_cost[PARTITION_VERT] = INT_MAX;
+ tmp_partition_cost[PARTITION_HORZ] =
+ vp10_cost_bit(cm->fc->partition_prob[pl][PARTITION_HORZ], 0);
+ tmp_partition_cost[PARTITION_SPLIT] =
+ vp10_cost_bit(cm->fc->partition_prob[pl][PARTITION_HORZ], 1);
+ } else if (!force_horz_split) { // force_vert_split only
+ tmp_partition_cost[PARTITION_HORZ] = INT_MAX;
+ tmp_partition_cost[PARTITION_VERT] =
+ vp10_cost_bit(cm->fc->partition_prob[pl][PARTITION_VERT], 0);
+ tmp_partition_cost[PARTITION_SPLIT] =
+ vp10_cost_bit(cm->fc->partition_prob[pl][PARTITION_VERT], 1);
+ } else { // force_ horz_split && force_vert_split horz_split
+ tmp_partition_cost[PARTITION_HORZ] = INT_MAX;
+ tmp_partition_cost[PARTITION_VERT] = INT_MAX;
+ tmp_partition_cost[PARTITION_SPLIT] = 0;
+ }
+
+ partition_cost = tmp_partition_cost;
+ }
+
#if CONFIG_VAR_TX
#ifndef NDEBUG
// Nothing should rely on the default value of this array (which is just
@@ -3523,11 +3549,11 @@
bsize, ctx, best_rdc.rdcost);
if (this_rdc.rate != INT_MAX) {
if (bsize >= BLOCK_8X8) {
- this_rdc.rate += cpi->partition_cost[pl][PARTITION_NONE];
+ this_rdc.rate += partition_cost[PARTITION_NONE];
this_rdc.rdcost = RDCOST(x->rdmult, x->rddiv,
this_rdc.rate, this_rdc.dist);
#if CONFIG_SUPERTX
- this_rate_nocoef += cpi->partition_cost[pl][PARTITION_NONE];
+ this_rate_nocoef += partition_cost[PARTITION_NONE];
#endif
}
@@ -3782,11 +3808,11 @@
}
if (sum_rdc.rdcost < best_rdc.rdcost && i == 4) {
- sum_rdc.rate += cpi->partition_cost[pl][PARTITION_SPLIT];
+ sum_rdc.rate += partition_cost[PARTITION_SPLIT];
sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv,
sum_rdc.rate, sum_rdc.dist);
#if CONFIG_SUPERTX
- sum_rate_nocoef += cpi->partition_cost[pl][PARTITION_SPLIT];
+ sum_rate_nocoef += partition_cost[PARTITION_SPLIT];
#endif // CONFIG_SUPERTX
if (sum_rdc.rdcost < best_rdc.rdcost) {
@@ -3934,10 +3960,10 @@
#endif // CONFIG_SUPERTX
if (sum_rdc.rdcost < best_rdc.rdcost) {
- sum_rdc.rate += cpi->partition_cost[pl][PARTITION_HORZ];
+ sum_rdc.rate += partition_cost[PARTITION_HORZ];
sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
#if CONFIG_SUPERTX
- sum_rate_nocoef += cpi->partition_cost[pl][PARTITION_HORZ];
+ sum_rate_nocoef += partition_cost[PARTITION_HORZ];
#endif // CONFIG_SUPERTX
if (sum_rdc.rdcost < best_rdc.rdcost) {
best_rdc = sum_rdc;
@@ -4079,11 +4105,11 @@
#endif // CONFIG_SUPERTX
if (sum_rdc.rdcost < best_rdc.rdcost) {
- sum_rdc.rate += cpi->partition_cost[pl][PARTITION_VERT];
+ sum_rdc.rate += partition_cost[PARTITION_VERT];
sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv,
sum_rdc.rate, sum_rdc.dist);
#if CONFIG_SUPERTX
- sum_rate_nocoef += cpi->partition_cost[pl][PARTITION_VERT];
+ sum_rate_nocoef += partition_cost[PARTITION_VERT];
#endif // CONFIG_SUPERTX
if (sum_rdc.rdcost < best_rdc.rdcost) {
best_rdc = sum_rdc;
diff --git a/vp10/encoder/rdopt.c b/vp10/encoder/rdopt.c
index 78477ad..f2d4a12 100644
--- a/vp10/encoder/rdopt.c
+++ b/vp10/encoder/rdopt.c
@@ -5598,6 +5598,8 @@
ref_bsi->rdstat[i][mode_idx].mvs[ref].as_int;
}
+ have_ref &= ref_bsi->rdstat[i][mode_idx].brate > 0;
+
if (filter_idx > 1 && !subpelmv && !have_ref) {
ref_bsi = bsi_buf + 1;
have_ref = 1;
@@ -5613,6 +5615,8 @@
#endif // CONFIG_EXT_INTER
have_ref &= mode_mv[this_mode][ref].as_int ==
ref_bsi->rdstat[i][mode_idx].mvs[ref].as_int;
+
+ have_ref &= ref_bsi->rdstat[i][mode_idx].brate > 0;
}
if (!subpelmv && have_ref &&
@@ -9024,7 +9028,8 @@
}
#endif // CONFIG_EXT_INTRA
- rate2 = rate_y + intra_mode_cost[mbmi->mode] + rate_uv_intra[uv_tx];
+ rate2 = rate_y + intra_mode_cost[mbmi->mode] +
+ rate_uv + cpi->intra_uv_mode_cost[mbmi->mode][mbmi->uv_mode];
if (cpi->common.allow_screen_content_tools && mbmi->mode == DC_PRED)
rate2 +=
vp10_cost_bit(vp10_default_palette_y_mode_prob[bsize - BLOCK_8X8]