Merge "segmentation: Don't use uninitialized probability data." into nextgenv2
diff --git a/test/vp10_inv_txfm2d_test.cc b/test/vp10_inv_txfm2d_test.cc
index fef4629..c8976df 100644
--- a/test/vp10_inv_txfm2d_test.cc
+++ b/test/vp10_inv_txfm2d_test.cc
@@ -42,9 +42,6 @@
txfm1d_size_ = libvpx_test::get_txfm1d_size(tx_size_);
txfm2d_size_ = txfm1d_size_ * txfm1d_size_;
count_ = 500;
- input_ = new int16_t[txfm2d_size_];
- ref_input_ = new uint16_t[txfm2d_size_];
- output_ = new int32_t[txfm2d_size_];
input_ = reinterpret_cast<int16_t *>
(vpx_memalign(16, sizeof(int16_t) * txfm2d_size_));
diff --git a/vp10/decoder/decodemv.c b/vp10/decoder/decodemv.c
index c8f35c5..3d1a5da 100644
--- a/vp10/decoder/decodemv.c
+++ b/vp10/decoder/decodemv.c
@@ -780,7 +780,7 @@
ref_frame[!idx] = cm->comp_fwd_ref[bit];
{
const int ctx1 = vp10_get_pred_context_comp_bwdref_p(cm, xd);
- const int bit1 = vpx_read(r, fc->comp_bwdref_prob[ctx1][0]);
+ const int bit1 = vp10_read(r, fc->comp_bwdref_prob[ctx1][0]);
if (counts)
++counts->comp_bwdref[ctx1][0][bit1];
ref_frame[idx] = cm->comp_bwd_ref[bit1];
@@ -860,7 +860,7 @@
#if CONFIG_BIDIR_PRED
if (bit1) {
const int ctx2 = vp10_get_pred_context_single_ref_p3(xd);
- const int bit2 = vpx_read(r, fc->single_ref_prob[ctx2][2]);
+ const int bit2 = vp10_read(r, fc->single_ref_prob[ctx2][2]);
if (counts)
++counts->single_ref[ctx2][2][bit2];
ref_frame[0] = bit2 ? ALTREF_FRAME : BWDREF_FRAME;
diff --git a/vp10/encoder/bitstream.c b/vp10/encoder/bitstream.c
index 4ceb0ed..fb87767 100644
--- a/vp10/encoder/bitstream.c
+++ b/vp10/encoder/bitstream.c
@@ -857,7 +857,7 @@
}
#else // CONFIG_EXT_REFS
#if CONFIG_BIDIR_PRED
- vpx_write(w, bit_bwd, vp10_get_pred_prob_comp_bwdref_p(cm, xd));
+ vp10_write(w, bit_bwd, vp10_get_pred_prob_comp_bwdref_p(cm, xd));
#endif // CONFIG_BIDIR_PRED
#endif // CONFIG_EXT_REFS
} else {
diff --git a/vp10/encoder/block.h b/vp10/encoder/block.h
index 1ddc3d8..4b5831d 100644
--- a/vp10/encoder/block.h
+++ b/vp10/encoder/block.h
@@ -180,6 +180,11 @@
// Strong color activity detection. Used in RTC coding mode to enhance
// the visual quality at the boundary of moving color objects.
uint8_t color_sensitivity[2];
+
+ // use default transform and skip transform type search for intra modes
+ int use_default_intra_tx_type;
+ // use default transform and skip transform type search for inter modes
+ int use_default_inter_tx_type;
};
#ifdef __cplusplus
diff --git a/vp10/encoder/rdopt.c b/vp10/encoder/rdopt.c
index da3efe6..f38a213 100644
--- a/vp10/encoder/rdopt.c
+++ b/vp10/encoder/rdopt.c
@@ -780,7 +780,7 @@
const int tx_set_1D[TX_TYPES_1D] = {0};
#endif
- switch (cpi->sf.tx_type_search) {
+ switch (cpi->sf.tx_type_search.prune_mode) {
case NO_PRUNE:
return 0;
break;
@@ -1576,6 +1576,12 @@
for (n = start_tx; n >= end_tx; --n) {
if (FIXED_TX_TYPE && tx_type != get_default_tx_type(0, xd, 0, n))
continue;
+ if (!is_inter && x->use_default_intra_tx_type &&
+ tx_type != get_default_tx_type(0, xd, 0, n))
+ continue;
+ if (is_inter && x->use_default_inter_tx_type &&
+ tx_type != get_default_tx_type(0, xd, 0, n))
+ continue;
if (max_tx_size == TX_32X32 && n == TX_4X4)
continue;
#if CONFIG_EXT_TX
@@ -1583,7 +1589,7 @@
if (is_inter) {
if (!ext_tx_used_inter[ext_tx_set][tx_type])
continue;
- if (cpi->sf.tx_type_search > 0) {
+ if (cpi->sf.tx_type_search.prune_mode > NO_PRUNE) {
if (!do_tx_type_search(tx_type, prune))
continue;
}
@@ -1598,7 +1604,7 @@
#else // CONFIG_EXT_TX
if (n >= TX_32X32 && tx_type != DCT_DCT)
continue;
- if (is_inter && cpi->sf.tx_type_search > 0 &&
+ if (is_inter && cpi->sf.tx_type_search.prune_mode > NO_PRUNE &&
!do_tx_type_search(tx_type, prune))
continue;
#endif // CONFIG_EXT_TX
@@ -1674,7 +1680,7 @@
ext_tx_set = get_ext_tx_set(mbmi->tx_size, bs, is_inter);
#endif // CONFIG_EXT_TX
- if (is_inter && cpi->sf.tx_type_search > 0)
+ if (is_inter && cpi->sf.tx_type_search.prune_mode > NO_PRUNE)
#if CONFIG_EXT_TX
prune = prune_tx_types(cpi, bs, x, xd, ext_tx_set);
#else
@@ -1685,13 +1691,19 @@
!xd->lossless[mbmi->segment_id]) {
for (tx_type = 0; tx_type < TX_TYPES; ++tx_type) {
if (is_inter) {
+ if (x->use_default_inter_tx_type &&
+ tx_type != get_default_tx_type(0, xd, 0, mbmi->tx_size))
+ continue;
if (!ext_tx_used_inter[ext_tx_set][tx_type])
continue;
- if (cpi->sf.tx_type_search > 0) {
+ if (cpi->sf.tx_type_search.prune_mode > NO_PRUNE) {
if (!do_tx_type_search(tx_type, prune))
continue;
}
} else {
+ if (x->use_default_intra_tx_type &&
+ tx_type != get_default_tx_type(0, xd, 0, mbmi->tx_size))
+ continue;
if (!ALLOW_INTRA_EXT_TX && bs >= BLOCK_8X8) {
if (tx_type != intra_mode_to_tx_type_context[mbmi->mode])
continue;
@@ -1740,6 +1752,12 @@
if (mbmi->tx_size < TX_32X32 &&
!xd->lossless[mbmi->segment_id]) {
for (tx_type = 0; tx_type < TX_TYPES; ++tx_type) {
+ if (!is_inter && x->use_default_intra_tx_type &&
+ tx_type != get_default_tx_type(0, xd, 0, mbmi->tx_size))
+ continue;
+ if (is_inter && x->use_default_inter_tx_type &&
+ tx_type != get_default_tx_type(0, xd, 0, mbmi->tx_size))
+ continue;
mbmi->tx_type = tx_type;
txfm_rd_in_plane(x,
cpi,
@@ -1750,7 +1768,8 @@
continue;
if (is_inter) {
r += cpi->inter_tx_type_costs[mbmi->tx_size][mbmi->tx_type];
- if (cpi->sf.tx_type_search > 0 && !do_tx_type_search(tx_type, prune))
+ if (cpi->sf.tx_type_search.prune_mode > NO_PRUNE &&
+ !do_tx_type_search(tx_type, prune))
continue;
} else {
r += cpi->intra_tx_type_costs[mbmi->tx_size]
@@ -1817,7 +1836,7 @@
TX_TYPE tx_type, best_tx_type = DCT_DCT;
int prune = 0;
- if (is_inter && cpi->sf.tx_type_search > 0)
+ if (is_inter && cpi->sf.tx_type_search.prune_mode > NO_PRUNE)
// passing -1 in for tx_type indicates that all 1D
// transforms should be considered for pruning
prune = prune_tx_types(cpi, bs, x, xd, -1);
@@ -2459,7 +2478,7 @@
int *rate, int *rate_tokenonly,
int64_t *distortion, int *skippable,
BLOCK_SIZE bsize, int mode_cost,
- int64_t *best_rd) {
+ int64_t *best_rd, uint16_t skip_mask) {
MACROBLOCKD *const xd = &x->e_mbd;
MODE_INFO *const mic = xd->mi[0];
MB_MODE_INFO *mbmi = &mic->mbmi;
@@ -2477,6 +2496,8 @@
mbmi->palette_mode_info.palette_size[0] = 0;
for (mode = 0; mode < FILTER_INTRA_MODES; ++mode) {
+ if (skip_mask & (1 << mode))
+ continue;
mbmi->ext_intra_mode_info.ext_intra_mode[0] = mode;
super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion,
&s, NULL, bsize, *best_rd);
@@ -2835,7 +2856,7 @@
int64_t *distortion, int *skippable,
BLOCK_SIZE bsize,
int64_t best_rd) {
- PREDICTION_MODE mode;
+ uint8_t mode_idx;
PREDICTION_MODE mode_selected = DC_PRED;
MACROBLOCKD *const xd = &x->e_mbd;
MODE_INFO *const mic = xd->mi[0];
@@ -2848,6 +2869,7 @@
int is_directional_mode, rate_overhead, best_angle_delta = 0;
INTRA_FILTER best_filter = INTRA_FILTER_LINEAR;
uint8_t directional_mode_skip_mask[INTRA_MODES];
+ uint16_t filter_intra_mode_skip_mask = (1 << FILTER_INTRA_MODES) - 1;
const int src_stride = x->plane[0].src.stride;
const uint8_t *src = x->plane[0].src.buf;
#endif // CONFIG_EXT_INTRA
@@ -2864,6 +2886,7 @@
const MODE_INFO *left_mi = xd->left_mi;
const PREDICTION_MODE A = vp10_above_block_mode(mic, above_mi, 0);
const PREDICTION_MODE L = vp10_left_block_mode(mic, left_mi, 0);
+ const PREDICTION_MODE FINAL_MODE_SEARCH = TM_PRED + 1;
const TX_SIZE max_tx_size = max_txsize_lookup[bsize];
bmode_costs = cpi->y_mode_costs[A][L];
@@ -2889,15 +2912,28 @@
if (left_mi)
palette_ctx += (left_mi->mbmi.palette_mode_info.palette_size[0] > 0);
+ if (cpi->sf.tx_type_search.fast_intra_tx_type_search)
+ x->use_default_intra_tx_type = 1;
+ else
+ x->use_default_intra_tx_type = 0;
+
/* Y Search for intra prediction mode */
- for (mode = DC_PRED; mode <= TM_PRED; ++mode) {
- mic->mbmi.mode = mode;
+ for (mode_idx = DC_PRED; mode_idx <= FINAL_MODE_SEARCH; ++mode_idx) {
+ if (mode_idx == FINAL_MODE_SEARCH) {
+ if (x->use_default_intra_tx_type == 0)
+ break;
+ mic->mbmi.mode = mode_selected;
+ x->use_default_intra_tx_type = 0;
+ } else {
+ mic->mbmi.mode = mode_idx;
+ }
#if CONFIG_EXT_INTRA
- is_directional_mode = (mode != DC_PRED && mode != TM_PRED);
- if (is_directional_mode && directional_mode_skip_mask[mode])
+ is_directional_mode =
+ (mic->mbmi.mode != DC_PRED && mic->mbmi.mode != TM_PRED);
+ if (is_directional_mode && directional_mode_skip_mask[mic->mbmi.mode])
continue;
if (is_directional_mode) {
- rate_overhead = bmode_costs[mode] +
+ rate_overhead = bmode_costs[mic->mbmi.mode] +
write_uniform_cost(2 * MAX_ANGLE_DELTAS + 1, 0);
this_rate_tokenonly = INT_MAX;
this_rd =
@@ -2917,7 +2953,7 @@
if (this_rate_tokenonly == INT_MAX)
continue;
- this_rate = this_rate_tokenonly + bmode_costs[mode];
+ this_rate = this_rate_tokenonly + bmode_costs[mic->mbmi.mode];
if (!xd->lossless[xd->mi[0]->mbmi.segment_id]) {
// super_block_yrd above includes the cost of the tx_size in the
@@ -2928,12 +2964,12 @@
cpi->tx_size_cost[max_tx_size - TX_8X8][get_tx_size_context(xd)]
[mic->mbmi.tx_size];
}
- if (cpi->common.allow_screen_content_tools && mode == DC_PRED)
+ if (cpi->common.allow_screen_content_tools && mic->mbmi.mode == DC_PRED)
this_rate +=
vp10_cost_bit(vp10_default_palette_y_mode_prob[bsize - BLOCK_8X8]
[palette_ctx], 0);
#if CONFIG_EXT_INTRA
- if (mode == DC_PRED && ALLOW_FILTER_INTRA_MODES)
+ if (mic->mbmi.mode == DC_PRED && ALLOW_FILTER_INTRA_MODES)
this_rate += vp10_cost_bit(cpi->common.fc->ext_intra_probs[0], 0);
if (is_directional_mode) {
int p_angle;
@@ -2946,11 +2982,12 @@
this_rate +=
cpi->intra_filter_cost[intra_filter_ctx][mic->mbmi.intra_filter];
}
+ filter_intra_mode_skip_mask ^= (1 << mic->mbmi.mode);
#endif // CONFIG_EXT_INTRA
this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion);
if (this_rd < best_rd) {
- mode_selected = mode;
+ mode_selected = mic->mbmi.mode;
best_rd = this_rd;
best_tx = mic->mbmi.tx_size;
#if CONFIG_EXT_INTRA
@@ -2975,7 +3012,7 @@
if (ALLOW_FILTER_INTRA_MODES) {
if (rd_pick_ext_intra_sby(cpi, x, rate, rate_tokenonly, distortion,
skippable, bsize, bmode_costs[DC_PRED],
- &best_rd)) {
+ &best_rd, filter_intra_mode_skip_mask)) {
mode_selected = mic->mbmi.mode;
best_tx = mic->mbmi.tx_size;
ext_intra_mode_info = mic->mbmi.ext_intra_mode_info;
@@ -3444,7 +3481,7 @@
int ext_tx_set = get_ext_tx_set(max_tx_size, bsize, is_inter);
#endif // CONFIG_EXT_TX
- if (is_inter && cpi->sf.tx_type_search > 0)
+ if (is_inter && cpi->sf.tx_type_search.prune_mode > NO_PRUNE)
#if CONFIG_EXT_TX
prune = prune_tx_types(cpi, bsize, x, xd, ext_tx_set);
#else
@@ -3465,7 +3502,7 @@
if (is_inter) {
if (!ext_tx_used_inter[ext_tx_set][tx_type])
continue;
- if (cpi->sf.tx_type_search > 0) {
+ if (cpi->sf.tx_type_search.prune_mode > NO_PRUNE) {
if (!do_tx_type_search(tx_type, prune))
continue;
}
@@ -3480,7 +3517,7 @@
#else // CONFIG_EXT_TX
if (max_tx_size >= TX_32X32 && tx_type != DCT_DCT)
continue;
- if (is_inter && cpi->sf.tx_type_search > 0 &&
+ if (is_inter && cpi->sf.tx_type_search.prune_mode > NO_PRUNE &&
!do_tx_type_search(tx_type, prune))
continue;
#endif // CONFIG_EXT_TX
@@ -8308,6 +8345,7 @@
MB_MODE_INFO best_mbmode;
int best_mode_skippable = 0;
int midx, best_mode_index = -1;
+ const int FINAL_MODE_SEARCH = MAX_MODES;
unsigned int ref_costs_single[MAX_REF_FRAMES], ref_costs_comp[MAX_REF_FRAMES];
vpx_prob comp_mode_p;
int64_t best_intra_rd = INT64_MAX;
@@ -8597,8 +8635,18 @@
midx = end_pos;
}
- for (midx = 0; midx < MAX_MODES; ++midx) {
- int mode_index = mode_map[midx];
+
+ if (cpi->sf.tx_type_search.fast_intra_tx_type_search)
+ x->use_default_intra_tx_type = 1;
+ else
+ x->use_default_intra_tx_type = 0;
+ if (cpi->sf.tx_type_search.fast_inter_tx_type_search)
+ x->use_default_inter_tx_type = 1;
+ else
+ x->use_default_inter_tx_type = 0;
+
+ for (midx = 0; midx <= FINAL_MODE_SEARCH; ++midx) {
+ int mode_index;
int mode_excluded = 0;
int64_t this_rd = INT64_MAX;
int disable_skip = 0;
@@ -8617,6 +8665,22 @@
uint8_t ref_frame_type;
#endif
+ if (midx == FINAL_MODE_SEARCH) {
+ if (best_mode_index < 0)
+ break;
+ mode_index = best_mode_index;
+ if (!is_inter_mode(best_mbmode.mode) &&
+ x->use_default_intra_tx_type == 1) {
+ x->use_default_intra_tx_type = 0;
+ } else if (is_inter_mode(best_mbmode.mode) &&
+ x->use_default_inter_tx_type == 1) {
+ x->use_default_inter_tx_type = 0;
+ } else {
+ break;
+ }
+ } else {
+ mode_index = mode_map[midx];
+ }
this_mode = vp10_mode_order[mode_index].mode;
ref_frame = vp10_mode_order[mode_index].ref_frame[0];
second_ref_frame = vp10_mode_order[mode_index].ref_frame[1];
@@ -8902,7 +8966,7 @@
if (!rd_pick_ext_intra_sby(cpi, x, &rate_dummy, &rate_y, &distortion_y,
&skippable, bsize,
- intra_mode_cost[mbmi->mode], &this_rd))
+ intra_mode_cost[mbmi->mode], &this_rd, 0))
*mbmi = mbmi_copy;
}
#else
diff --git a/vp10/encoder/speed_features.c b/vp10/encoder/speed_features.c
index b766cae..92b071e 100644
--- a/vp10/encoder/speed_features.c
+++ b/vp10/encoder/speed_features.c
@@ -159,7 +159,9 @@
sf->tx_size_search_breakout = 1;
sf->partition_search_breakout_rate_thr = 80;
- sf->tx_type_search = PRUNE_ONE;
+ sf->tx_type_search.prune_mode = PRUNE_ONE;
+ sf->tx_type_search.fast_intra_tx_type_search = 1;
+ sf->tx_type_search.fast_inter_tx_type_search = 1;
// Use transform domain distortion.
// Note var-tx expt always uses pixel domain distortion.
sf->use_transform_domain_distortion = 1;
@@ -183,7 +185,7 @@
sf->allow_partition_search_skip = 1;
sf->use_upsampled_references = 0;
#if CONFIG_EXT_TX
- sf->tx_type_search = PRUNE_TWO;
+ sf->tx_type_search.prune_mode = PRUNE_TWO;
#endif
}
@@ -496,7 +498,9 @@
sf->alt_ref_search_fp = 0;
sf->use_quant_fp = 0;
sf->partition_search_type = SEARCH_PARTITION;
- sf->tx_type_search = NO_PRUNE;
+ sf->tx_type_search.prune_mode = NO_PRUNE;
+ sf->tx_type_search.fast_intra_tx_type_search = 0;
+ sf->tx_type_search.fast_inter_tx_type_search = 0;
sf->less_rectangular_check = 0;
sf->use_square_partition_only = 0;
sf->auto_min_max_partition_size = NOT_IN_USE;
diff --git a/vp10/encoder/speed_features.h b/vp10/encoder/speed_features.h
index ca6adbe..dc966e9 100644
--- a/vp10/encoder/speed_features.h
+++ b/vp10/encoder/speed_features.h
@@ -190,6 +190,12 @@
// eliminates two tx types in each direction
PRUNE_TWO = 2,
#endif
+} TX_TYPE_PRUNE_MODE;
+
+typedef struct {
+ TX_TYPE_PRUNE_MODE prune_mode;
+ int fast_intra_tx_type_search;
+ int fast_inter_tx_type_search;
} TX_TYPE_SEARCH;
typedef enum {
@@ -310,6 +316,7 @@
PARTITION_SEARCH_TYPE partition_search_type;
TX_TYPE_SEARCH tx_type_search;
+
// Used if partition_search_type = FIXED_SIZE_PARTITION
BLOCK_SIZE always_this_block_size;