Also includes a bug fix.
Change-Id: Ia49ed00f8ffd1531c10bcf89b1f497310ee7cb82
fp_mb_stats
emulate_hardware
misc_fixes
- ext_tx
"
CONFIG_LIST="
dependency_tracking
// Only for INTER blocks
INTERP_FILTER interp_filter;
MV_REFERENCE_FRAME ref_frame[2];
-#if CONFIG_EXT_TX
TX_TYPE tx_type;
-#endif // CONFIG_EXT_TX
// TODO(slavarnway): Delete and use bmi[3].as_mv[] instead.
int_mv mv[2];
const MODE_INFO *const mi = xd->mi[0];
const MB_MODE_INFO *const mbmi = &mi->mbmi;
-#if CONFIG_EXT_TX
(void) block_idx;
if (plane_type != PLANE_TYPE_Y || xd->lossless[mbmi->segment_id] ||
mbmi->tx_size >= TX_32X32)
return DCT_DCT;
return mbmi->tx_type;
-#else
- if (plane_type != PLANE_TYPE_Y || xd->lossless[mbmi->segment_id] ||
- is_inter_block(mbmi) || mbmi->tx_size >= TX_32X32)
- return DCT_DCT;
-
- return intra_mode_to_tx_type_context[get_y_mode(mi, block_idx)];
-#endif // CONFIG_EXT_TX
}
void vp10_setup_block_planes(MACROBLOCKD *xd, int ss_x, int ss_y);
};
#endif
-#if CONFIG_EXT_TX
const vpx_tree_index vp10_ext_tx_tree[TREE_SIZE(TX_TYPES)] = {
-DCT_DCT, 2,
-ADST_ADST, 4,
{176, 85, 128},
{192, 85, 128},
};
-#endif // CONFIG_EXT_TX
static void init_mode_probs(FRAME_CONTEXT *fc) {
vp10_copy(fc->uv_mode_prob, default_uv_probs);
vp10_copy(fc->seg.tree_probs, default_seg_probs.tree_probs);
vp10_copy(fc->seg.pred_probs, default_seg_probs.pred_probs);
#endif
-#if CONFIG_EXT_TX
vp10_copy(fc->intra_ext_tx_prob, default_intra_ext_tx_prob);
vp10_copy(fc->inter_ext_tx_prob, default_inter_ext_tx_prob);
-#endif // CONFIG_EXT_TX
}
const vpx_tree_index vp10_switchable_interp_tree
fc->skip_probs[i] = mode_mv_merge_probs(
pre_fc->skip_probs[i], counts->skip[i]);
-#if CONFIG_EXT_TX
for (i = TX_4X4; i < EXT_TX_SIZES; ++i) {
int j;
for (j = 0; j < TX_TYPES; ++j)
counts->inter_ext_tx[i],
fc->inter_ext_tx_prob[i]);
}
-#endif // CONFIG_EXT_TX
#if CONFIG_MISC_FIXES
if (cm->seg.temporal_update) {
#if CONFIG_MISC_FIXES
struct segmentation_probs seg;
#endif
-#if CONFIG_EXT_TX
vpx_prob intra_ext_tx_prob[EXT_TX_SIZES][TX_TYPES][TX_TYPES - 1];
vpx_prob inter_ext_tx_prob[EXT_TX_SIZES][TX_TYPES - 1];
-#endif // CONFIG_EXT_TX
int initialized;
} FRAME_CONTEXT;
#if CONFIG_MISC_FIXES
struct seg_counts seg;
#endif
-#if CONFIG_EXT_TX
unsigned int intra_ext_tx[EXT_TX_SIZES][TX_TYPES][TX_TYPES];
unsigned int inter_ext_tx[EXT_TX_SIZES][TX_TYPES];
-#endif // CONFIG_EXT_TX
} FRAME_COUNTS;
extern const vpx_prob vp10_kf_y_mode_prob[INTRA_MODES][INTRA_MODES]
void vp10_tx_counts_to_branch_counts_8x8(const unsigned int *tx_count_8x8p,
unsigned int (*ct_8x8p)[2]);
-#if CONFIG_EXT_TX
extern const vpx_tree_index
vp10_ext_tx_tree[TREE_SIZE(TX_TYPES)];
-#endif // CONFIG_EXT_TX
static INLINE int vp10_ceil_log2(int n) {
int i = 1, p = 2;
TX_TYPES = 4
} TX_TYPE;
-#if CONFIG_EXT_TX
#define EXT_TX_SIZES 3 // number of sizes that use extended transforms
-#endif // CONFIG_EXT_TX
typedef enum {
VP9_LAST_FLAG = 1 << 0,
comps->fp[i] += comps_t->fp[i];
}
-#if CONFIG_EXT_TX
for (i = 0; i < EXT_TX_SIZES; i++) {
int j;
for (j = 0; j < TX_TYPES; ++j)
for (k = 0; k < TX_TYPES; k++)
cm->counts.inter_ext_tx[i][k] += counts->inter_ext_tx[i][k];
}
-#endif // CONFIG_EXT_TX
#if CONFIG_MISC_FIXES
for (i = 0; i < PREDICTION_PROBS; i++)
if (eob == 1) {
dqcoeff[0] = 0;
} else {
-#if CONFIG_EXT_TX
if (tx_type == DCT_DCT && tx_size <= TX_16X16 && eob <= 10)
-#else
- if (tx_size <= TX_16X16 && eob <= 10)
-#endif // CONFIG_EXT_TX
memset(dqcoeff, 0, 4 * (4 << tx_size) * sizeof(dqcoeff[0]));
else if (tx_size == TX_32X32 && eob <= 34)
memset(dqcoeff, 0, 256 * sizeof(dqcoeff[0]));
return sz;
}
-#if CONFIG_EXT_TX
static void read_ext_tx_probs(FRAME_CONTEXT *fc, vpx_reader *r) {
int i, j, k;
if (vpx_read(r, GROUP_DIFF_UPDATE_PROB)) {
}
}
}
-#endif // CONFIG_EXT_TX
static int read_compressed_header(VP10Decoder *pbi, const uint8_t *data,
size_t partition_size) {
#endif
read_mv_probs(nmvc, cm->allow_high_precision_mv, &r);
-#if CONFIG_EXT_TX
read_ext_tx_probs(fc, &r);
-#endif
}
return vpx_reader_has_error(&r);
assert(!memcmp(&cm->counts.tx, &zero_counts.tx, sizeof(cm->counts.tx)));
assert(!memcmp(cm->counts.skip, zero_counts.skip, sizeof(cm->counts.skip)));
assert(!memcmp(&cm->counts.mv, &zero_counts.mv, sizeof(cm->counts.mv)));
-#if CONFIG_EXT_TX
assert(!memcmp(cm->counts.intra_ext_tx, zero_counts.intra_ext_tx,
sizeof(cm->counts.intra_ext_tx)));
assert(!memcmp(cm->counts.inter_ext_tx, zero_counts.inter_ext_tx,
sizeof(cm->counts.inter_ext_tx)));
-#endif // CONFIG_EXT_TX
}
#endif // NDEBUG
mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode);
-#if CONFIG_EXT_TX
- if (mbmi->tx_size < TX_32X32 &&
- cm->base_qindex > 0 && !mbmi->skip &&
- !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
- FRAME_COUNTS *counts = xd->counts;
- TX_TYPE tx_type_nom = intra_mode_to_tx_type_context[mbmi->mode];
- mbmi->tx_type = vpx_read_tree(
- r, vp10_ext_tx_tree,
- cm->fc->intra_ext_tx_prob[mbmi->tx_size][tx_type_nom]);
- if (counts)
- ++counts->intra_ext_tx[mbmi->tx_size][tx_type_nom][mbmi->tx_type];
- } else {
- mbmi->tx_type = DCT_DCT;
- }
-#endif // CONFIG_EXT_TX
+ if (mbmi->tx_size < TX_32X32 &&
+ cm->base_qindex > 0 && !mbmi->skip &&
+ !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
+ FRAME_COUNTS *counts = xd->counts;
+ TX_TYPE tx_type_nom = intra_mode_to_tx_type_context[mbmi->mode];
+ mbmi->tx_type = vpx_read_tree(
+ r, vp10_ext_tx_tree,
+ cm->fc->intra_ext_tx_prob[mbmi->tx_size][tx_type_nom]);
+ if (counts)
+ ++counts->intra_ext_tx[mbmi->tx_size][tx_type_nom][mbmi->tx_type];
+ } else {
+ mbmi->tx_type = DCT_DCT;
+ }
}
static int read_mv_component(vpx_reader *r,
else
read_intra_block_mode_info(cm, xd, mi, r);
-#if CONFIG_EXT_TX
if (mbmi->tx_size < TX_32X32 &&
cm->base_qindex > 0 && !mbmi->skip &&
!segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
} else {
mbmi->tx_type = DCT_DCT;
}
-#endif // CONFIG_EXT_TX
}
void vp10_read_mode_info(VP10Decoder *const pbi, MACROBLOCKD *xd,
}
}
-#if CONFIG_EXT_TX
static struct vp10_token ext_tx_encodings[TX_TYPES];
-#endif // CONFIG_EXT_TX
void vp10_encode_token_init() {
-#if CONFIG_EXT_TX
vp10_tokens_from_tree(ext_tx_encodings, vp10_ext_tx_tree);
-#endif // CONFIG_EXT_TX
}
static void write_intra_mode(vpx_writer *w, PREDICTION_MODE mode,
counts->switchable_interp[j], SWITCHABLE_FILTERS, w);
}
-#if CONFIG_EXT_TX
static void update_ext_tx_probs(VP10_COMMON *cm, vpx_writer *w) {
const int savings_thresh = vp10_cost_one(GROUP_DIFF_UPDATE_PROB) -
vp10_cost_zero(GROUP_DIFF_UPDATE_PROB);
}
}
}
-#endif // CONFIG_EXT_TX
static void pack_mb_tokens(vpx_writer *w,
TOKENEXTRA **tp, const TOKENEXTRA *const stop,
}
}
}
-#if CONFIG_EXT_TX
if (mbmi->tx_size < TX_32X32 &&
cm->base_qindex > 0 && !mbmi->skip &&
!segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
if (!mbmi->skip)
assert(mbmi->tx_type == DCT_DCT);
}
-#endif // CONFIG_EXT_TX
}
static void write_mb_modes_kf(const VP10_COMMON *cm, const MACROBLOCKD *xd,
write_intra_mode(w, mbmi->uv_mode, cm->fc->uv_mode_prob[mbmi->mode]);
-#if CONFIG_EXT_TX
if (mbmi->tx_size < TX_32X32 &&
cm->base_qindex > 0 && !mbmi->skip &&
!segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
[intra_mode_to_tx_type_context[mbmi->mode]],
&ext_tx_encodings[mbmi->tx_type]);
}
-#endif // CONFIG_EXT_TX
}
static void write_modes_b(VP10_COMP *cpi, const TileInfo *const tile,
vp10_write_nmv_probs(cm, cm->allow_high_precision_mv, &header_bc,
&counts->mv);
-#if CONFIG_EXT_TX
update_ext_tx_probs(cm, &header_bc);
-#endif // CONFIG_EXT_TX
}
vpx_stop_encode(&header_bc);
}
++td->counts->tx.tx_totals[mbmi->tx_size];
++td->counts->tx.tx_totals[get_uv_tx_size(mbmi, &xd->plane[1])];
-#if CONFIG_EXT_TX
if (mbmi->tx_size < TX_32X32 &&
cm->base_qindex > 0 && !mbmi->skip &&
!segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
[mbmi->tx_type];
}
}
-#endif // CONFIG_EXT_TX
}
}
int multi_arf_enabled;
int multi_arf_last_grp_enabled;
-#if CONFIG_EXT_TX
int intra_tx_type_costs[EXT_TX_SIZES][TX_TYPES][TX_TYPES];
int inter_tx_type_costs[EXT_TX_SIZES][TX_TYPES];
-#endif // CONFIG_EXT_TX
#if CONFIG_VP9_TEMPORAL_DENOISING
VP9_DENOISER denoiser;
#endif
vp10_cost_tokens(cpi->switchable_interp_costs[i],
fc->switchable_interp_prob[i], vp10_switchable_interp_tree);
-#if CONFIG_EXT_TX
for (i = TX_4X4; i < EXT_TX_SIZES; ++i) {
for (j = 0; j < TX_TYPES; ++j)
vp10_cost_tokens(cpi->intra_tx_type_costs[i][j],
fc->inter_ext_tx_prob[i],
vp10_ext_tx_tree);
}
-#endif // CONFIG_EXT_TX
}
static void fill_token_costs(vp10_coeff_cost *c,
#define MIN_EARLY_TERM_INDEX 3
#define NEW_MV_DISCOUNT_FACTOR 8
-#if CONFIG_EXT_TX
const double ext_tx_th = 0.99;
-#endif // CONFIG_EXT_TX
typedef struct {
PREDICTION_MODE mode;
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
-#if CONFIG_EXT_TX
TX_TYPE tx_type, best_tx_type = DCT_DCT;
int r, s;
int64_t d, psse, this_rd, best_rd = INT64_MAX;
txfm_rd_in_plane(x, rate, distortion, skip,
sse, ref_best_rd, 0, bs,
mbmi->tx_size, cpi->sf.use_fast_coef_costing);
- if (mbmi->tx_size < TX_32X32 && !xd->lossless[mbmi->segment_id]) {
+ if (mbmi->tx_size < TX_32X32 && !xd->lossless[mbmi->segment_id] &&
+ *rate != INT_MAX) {
if (is_inter)
*rate += cpi->inter_tx_type_costs[mbmi->tx_size][mbmi->tx_type];
else
[intra_mode_to_tx_type_context[mbmi->mode]]
[mbmi->tx_type];
}
-#else
- mbmi->tx_size = VPXMIN(max_tx_size, largest_tx_size);
-
- txfm_rd_in_plane(x, rate, distortion, skip,
- sse, ref_best_rd, 0, bs,
- mbmi->tx_size, cpi->sf.use_fast_coef_costing);
-#endif // CONFIG_EXT_TX
}
static void choose_smallest_tx_size(VP10_COMP *cpi, MACROBLOCK *x,
TX_SIZE best_tx = max_tx_size;
int start_tx, end_tx;
const int tx_select = cm->tx_mode == TX_MODE_SELECT;
-#if CONFIG_EXT_TX
TX_TYPE tx_type, best_tx_type = DCT_DCT;
-#endif // CONFIG_EXT_TX
const int is_inter = is_inter_block(mbmi);
const vpx_prob *tx_probs = get_tx_probs2(max_tx_size, xd, &cm->fc->tx_probs);
*skip = 0;
*psse = INT64_MAX;
-#if CONFIG_EXT_TX
for (tx_type = DCT_DCT; tx_type < TX_TYPES; ++tx_type) {
-#endif // CONFIG_EXT_TX
last_rd = INT64_MAX;
for (n = start_tx; n >= end_tx; --n) {
int r_tx_size = 0;
r_tx_size += vp10_cost_one(tx_probs[m]);
}
-#if CONFIG_EXT_TX
if (n >= TX_32X32 && tx_type != DCT_DCT) {
continue;
}
[intra_mode_to_tx_type_context[mbmi->mode]]
[mbmi->tx_type];
}
-#else // CONFIG_EXT_TX
- txfm_rd_in_plane(x, &r, &d, &s,
- &sse, ref_best_rd, 0, bs, n,
- cpi->sf.use_fast_coef_costing);
-#endif // CONFIG_EXT_TX
if (r == INT_MAX)
continue;
// Early termination in transform size search.
if (cpi->sf.tx_size_search_breakout &&
(rd == INT64_MAX ||
-#if CONFIG_EXT_TX
(s == 1 && tx_type != DCT_DCT && n < start_tx) ||
-#else
- (s == 1 && n < start_tx) ||
-#endif
(n < (int) max_tx_size && rd > last_rd)))
break;
last_rd = rd;
if (rd <
-#if CONFIG_EXT_TX
(is_inter && best_tx_type == DCT_DCT ? ext_tx_th : 1) *
-#endif // CONFIG_EXT_TX
best_rd) {
best_tx = n;
best_rd = rd;
*rate = r;
*skip = s;
*psse = sse;
-#if CONFIG_EXT_TX
best_tx_type = mbmi->tx_type;
-#endif // CONFIG_EXT_TX
}
}
-#if CONFIG_EXT_TX
}
-#endif // CONFIG_EXT_TX
mbmi->tx_size = best_tx;
-#if CONFIG_EXT_TX
mbmi->tx_type = best_tx_type;
if (mbmi->tx_size >= TX_32X32)
assert(mbmi->tx_type == DCT_DCT);
txfm_rd_in_plane(x, &r, &d, &s,
&sse, ref_best_rd, 0, bs, best_tx,
cpi->sf.use_fast_coef_costing);
-#endif // CONFIG_EXT_TX
}
static void super_block_yrd(VP10_COMP *cpi, MACROBLOCK *x, int *rate,
int this_rate, this_rate_tokenonly, s;
int64_t this_distortion, this_rd;
TX_SIZE best_tx = TX_4X4;
-#if CONFIG_EXT_TX
TX_TYPE best_tx_type = DCT_DCT;
-#endif // CONFIG_EXT_TX
int *bmode_costs;
const MODE_INFO *above_mi = xd->above_mi;
const MODE_INFO *left_mi = xd->left_mi;
mode_selected = mode;
best_rd = this_rd;
best_tx = mic->mbmi.tx_size;
-#if CONFIG_EXT_TX
best_tx_type = mic->mbmi.tx_type;
-#endif // CONFIG_EXT_TX
*rate = this_rate;
*rate_tokenonly = this_rate_tokenonly;
*distortion = this_distortion;
mic->mbmi.mode = mode_selected;
mic->mbmi.tx_size = best_tx;
-#if CONFIG_EXT_TX
mic->mbmi.tx_type = best_tx_type;
-#endif // CONFIG_EXT_TX
return best_rd;
}