BILINEAR = 1,
EIGHTTAP = 2,
EIGHTTAP_SHARP = 3,
-#if CONFIG_SWITCHABLE_INTERP
SWITCHABLE /* should be the last one */
-#endif
} INTERPOLATIONFILTERTYPE;
typedef enum
// Flag to turn prediction signal filter on(1)/off(0 ) at the MB level
unsigned int pred_filter_enabled;
#endif
-#if CONFIG_SWITCHABLE_INTERP
INTERPOLATIONFILTERTYPE interp_filter;
-#endif
#if CONFIG_SUPERBLOCKS
// FIXME need a SB array of 4 MB_MODE_INFOs that
vpx_memcpy(x->fc.sub_mv_ref_prob, vp8_sub_mv_ref_prob2, sizeof(vp8_sub_mv_ref_prob2));
vpx_memcpy(x->fc.mbsplit_prob, vp8_mbsplit_probs, sizeof(vp8_mbsplit_probs));
-#if CONFIG_SWITCHABLE_INTERP
vpx_memcpy(x->fc.switchable_interp_prob, vp8_switchable_interp_prob,
sizeof(vp8_switchable_interp_prob));
-#endif
-
}
} while (++i < VP8_BINTRAMODES);
}
-#if CONFIG_SWITCHABLE_INTERP
#if VP8_SWITCHABLE_FILTERS == 3
const vp8_tree_index vp8_switchable_interp_tree[VP8_SWITCHABLE_FILTERS*2-2] = {
-0, 2,
{ 64},
{192},
};
-//#define SWITCHABLE_86
-#ifdef SWITCHABLE_86
-const INTERPOLATIONFILTERTYPE vp8_switchable_interp[VP8_SWITCHABLE_FILTERS] = {
- EIGHTTAP, SIXTAP};
-const int vp8_switchable_interp_map[SWITCHABLE+1] = {1, -1, 0, -1, -1}; //8, 6
-#else
const INTERPOLATIONFILTERTYPE vp8_switchable_interp[VP8_SWITCHABLE_FILTERS] = {
EIGHTTAP, EIGHTTAP_SHARP};
const int vp8_switchable_interp_map[SWITCHABLE+1] = {-1, -1, 0, 1, -1}; //8, 8s
#endif
-#endif
-#endif
-
void vp8_entropy_mode_init() {
vp8_tokens_from_tree(vp8_bmode_encodings, vp8_bmode_tree);
vp8_tokens_from_tree(vp8_uv_mode_encodings, vp8_uv_mode_tree);
vp8_tokens_from_tree(vp8_i8x8_mode_encodings, vp8_i8x8_mode_tree);
vp8_tokens_from_tree(vp8_mbsplit_encodings, vp8_mbsplit_tree);
-#if CONFIG_SWITCHABLE_INTERP
vp8_tokens_from_tree(vp8_switchable_interp_encodings,
vp8_switchable_interp_tree);
-#endif
vp8_tokens_from_tree_offset(vp8_mv_ref_encoding_array,
vp8_mv_ref_tree, NEARESTMV);
void vp8_adapt_mode_probs(struct VP8Common *);
-#if CONFIG_SWITCHABLE_INTERP
#define VP8_SWITCHABLE_FILTERS 2 /* number of switchable filters */
extern const INTERPOLATIONFILTERTYPE vp8_switchable_interp
[VP8_SWITCHABLE_FILTERS];
-extern const int vp8_switchable_interp_map[SWITCHABLE+1];
+extern const int vp8_switchable_interp_map[SWITCHABLE + 1];
extern const vp8_tree_index vp8_switchable_interp_tree
- [2*(VP8_SWITCHABLE_FILTERS-1)];
+ [2*(VP8_SWITCHABLE_FILTERS - 1)];
extern struct vp8_token_struct vp8_switchable_interp_encodings
[VP8_SWITCHABLE_FILTERS];
extern const vp8_prob vp8_switchable_interp_prob
- [VP8_SWITCHABLE_FILTERS+1][VP8_SWITCHABLE_FILTERS-1];
-#endif
+ [VP8_SWITCHABLE_FILTERS + 1][VP8_SWITCHABLE_FILTERS - 1];
#endif
[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
nmv_context_counts NMVcount;
-#if CONFIG_SWITCHABLE_INTERP
- vp8_prob switchable_interp_prob[VP8_SWITCHABLE_FILTERS+1]
- [VP8_SWITCHABLE_FILTERS-1];
-#endif
+ vp8_prob switchable_interp_prob[VP8_SWITCHABLE_FILTERS + 1]
+ [VP8_SWITCHABLE_FILTERS - 1];
int mode_context[6][4];
int mode_context_a[6][4];
(m - cm->mode_info_stride)->mbmi.mb_skip_coeff;
break;
-#if CONFIG_SWITCHABLE_INTERP
case PRED_SWITCHABLE_INTERP:
{
int left_in_image = (m - 1)->mbmi.mb_in_image;
pred_context = VP8_SWITCHABLE_FILTERS;
}
break;
-#endif
default:
// TODO *** add error trap code.
pred_probability = &cm->mbskip_pred_probs[pred_context];
break;
-#if CONFIG_SWITCHABLE_INTERP
case PRED_SWITCHABLE_INTERP:
pred_probability = &cm->fc.switchable_interp_prob[pred_context][0];
break;
-#endif
+
default:
// TODO *** add error trap code.
pred_probability = NULL;
PRED_REF = 1,
PRED_COMP = 2,
PRED_MBSKIP = 3,
-#if CONFIG_SWITCHABLE_INTERP
- PRED_SWITCHABLE_INTERP = 4,
-#endif
+ PRED_SWITCHABLE_INTERP = 4
} PRED_ID;
-
extern unsigned char get_pred_context(const VP8_COMMON *const cm,
const MACROBLOCKD *const xd,
PRED_ID pred_id);
&cm->rtcd.subpix, sixtap_avg8x8);
xd->subpixel_predict_avg16x16 = SUBPIX_INVOKE(
&cm->rtcd.subpix, sixtap_avg16x16);
- }
- else if (mcomp_filter_type == EIGHTTAP
-#if CONFIG_SWITCHABLE_INTERP
- ||
- mcomp_filter_type == SWITCHABLE
-#endif
- ) {
+ } else if (mcomp_filter_type == EIGHTTAP || mcomp_filter_type == SWITCHABLE) {
xd->subpixel_predict = SUBPIX_INVOKE(
&cm->rtcd.subpix, eighttap4x4);
xd->subpixel_predict8x4 = SUBPIX_INVOKE(
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
};
-#if CONFIG_SWITCHABLE_INTERP
static void read_switchable_interp_probs(VP8D_COMP* const pbi,
BOOL_DECODER* const bc) {
VP8_COMMON *const cm = &pbi->common;
int i, j;
for (j = 0; j <= VP8_SWITCHABLE_FILTERS; ++j) {
- //for (j = 0; j <= 0; ++j) {
for (i = 0; i < VP8_SWITCHABLE_FILTERS - 1; ++i) {
cm->fc.switchable_interp_prob[j][i] = vp8_read_literal(bc, 8);
}
//printf("DECODER: %d %d\n", cm->fc.switchable_interp_prob[0],
//cm->fc.switchable_interp_prob[1]);
}
-#endif
static void mb_mode_mv_init(VP8D_COMP *pbi, vp8_reader *bc) {
VP8_COMMON *const cm = &pbi->common;
if (cm->pred_filter_mode == 2)
cm->prob_pred_filter_off = (vp8_prob)vp8_read_literal(bc, 8);
#endif
-#if CONFIG_SWITCHABLE_INTERP
if (cm->mcomp_filter_type == SWITCHABLE)
read_switchable_interp_probs(pbi, bc);
-#endif
// Decode the baseline probabilities for decoding reference frame
cm->prob_intra_coded = (vp8_prob)vp8_read_literal(bc, 8);
cm->prob_last_coded = (vp8_prob)vp8_read_literal(bc, 8);
mbmi->pred_filter_enabled = cm->pred_filter_mode;
}
#endif
-#if CONFIG_SWITCHABLE_INTERP
if (mbmi->mode >= NEARESTMV && mbmi->mode <= SPLITMV)
{
if (cm->mcomp_filter_type == SWITCHABLE) {
mbmi->interp_filter = vp8_switchable_interp[
vp8_treed_read(bc, vp8_switchable_interp_tree,
get_pred_probs(cm, xd, PRED_SWITCHABLE_INTERP))];
- //printf("Reading: %d\n", mbmi->interp_filter);
} else {
mbmi->interp_filter = cm->mcomp_filter_type;
}
}
-#endif
if (cm->comp_pred_mode == COMP_PREDICTION_ONLY ||
(cm->comp_pred_mode == HYBRID_PREDICTION &&
}
//mode = xd->mode_info_context->mbmi.mode;
-#if CONFIG_SWITCHABLE_INTERP
if (pbi->common.frame_type != KEY_FRAME)
vp8_setup_interp_filters(xd, xd->mode_info_context->mbmi.interp_filter,
&pbi->common);
-#endif
if (eobtotal == 0 && mode != B_PRED && mode != SPLITMV
&& mode != I8X8_PRED
/* Is high precision mv allowed */
xd->allow_high_precision_mv = (unsigned char)vp8_read_bit(&header_bc);
// Read the type of subpel filter to use
-#if CONFIG_SWITCHABLE_INTERP
if (vp8_read_bit(&header_bc)) {
pc->mcomp_filter_type = SWITCHABLE;
- } else
-#endif
- {
+ } else {
pc->mcomp_filter_type = vp8_read_literal(&header_bc, 2);
}
/* To enable choice of different interploation filters */
}
}
-#if CONFIG_SWITCHABLE_INTERP
void update_switchable_interp_probs(VP8_COMP *cpi, vp8_writer* const bc) {
VP8_COMMON *const pc = &cpi->common;
unsigned int branch_ct[32][2];
int i, j;
for (j = 0; j <= VP8_SWITCHABLE_FILTERS; ++j) {
- //for (j = 0; j <= 0; ++j) {
-/*
- if (!cpi->dummy_packing)
-#if VP8_SWITCHABLE_FILTERS == 3
- printf("HELLO %d %d %d\n", cpi->switchable_interp_count[j][0],
- cpi->switchable_interp_count[j][1], cpi->switchable_interp_count[j][2]);
-#else
- printf("HELLO %d %d\n", cpi->switchable_interp_count[j][0],
- cpi->switchable_interp_count[j][1]);
-#endif
-*/
vp8_tree_probs_from_distribution(
VP8_SWITCHABLE_FILTERS,
vp8_switchable_interp_encodings, vp8_switchable_interp_tree,
- pc->fc.switchable_interp_prob[j], branch_ct, cpi->switchable_interp_count[j],
- 256, 1
- );
+ pc->fc.switchable_interp_prob[j], branch_ct,
+ cpi->switchable_interp_count[j], 256, 1);
for (i = 0; i < VP8_SWITCHABLE_FILTERS - 1; ++i) {
if (pc->fc.switchable_interp_prob[j][i] < 1)
pc->fc.switchable_interp_prob[j][i] = 1;
vp8_write_literal(bc, pc->fc.switchable_interp_prob[j][i], 8);
-/*
- if (!cpi->dummy_packing)
-#if VP8_SWITCHABLE_FILTERS == 3
- printf("Probs %d %d [%d]\n",
- pc->fc.switchable_interp_prob[j][0],
- pc->fc.switchable_interp_prob[j][1], pc->frame_type);
-#else
- printf("Probs %d [%d]\n", pc->fc.switchable_interp_prob[j][0],
- pc->frame_type);
-#endif
-*/
}
}
- /*
- if (!cpi->dummy_packing)
-#if VP8_SWITCHABLE_FILTERS == 3
- printf("Probs %d %d [%d]\n",
- pc->fc.switchable_interp_prob[0], pc->fc.switchable_interp_prob[1], pc->frame_type);
-#else
- printf("Probs %d [%d]\n", pc->fc.switchable_interp_prob[0], pc->frame_type);
-#endif
- */
}
-#endif
// This function updates the reference frame prediction stats
static void update_refpred_stats(VP8_COMP *cpi) {
cpi->common.pred_filter_mode);
}
#endif
-#if CONFIG_SWITCHABLE_INTERP
if (mode >= NEARESTMV && mode <= SPLITMV)
{
if (cpi->common.mcomp_filter_type == SWITCHABLE) {
vp8_write_token(bc, vp8_switchable_interp_tree,
- get_pred_probs(&cpi->common, xd, PRED_SWITCHABLE_INTERP),
+ get_pred_probs(&cpi->common, xd,
+ PRED_SWITCHABLE_INTERP),
vp8_switchable_interp_encodings +
vp8_switchable_interp_map[mi->interp_filter]);
- //if (!cpi->dummy_packing) printf("Reading: %d\n", mi->interp_filter);
} else {
assert (mi->interp_filter ==
cpi->common.mcomp_filter_type);
}
}
-#endif
if (mi->second_ref_frame &&
(mode == NEWMV || mode == SPLITMV)) {
int_mv n1, n2;
// Signal whether to allow high MV precision
vp8_write_bit(&header_bc, (xd->allow_high_precision_mv) ? 1 : 0);
-#if CONFIG_SWITCHABLE_INTERP
if (pc->mcomp_filter_type == SWITCHABLE) {
/* Check to see if only one of the filters is actually used */
int count[VP8_SWITCHABLE_FILTERS];
// Signal the type of subpel filter to use
vp8_write_bit(&header_bc, (pc->mcomp_filter_type == SWITCHABLE));
if (pc->mcomp_filter_type != SWITCHABLE)
-#endif /* CONFIG_SWITCHABLE_INTERP */
vp8_write_literal(&header_bc, (pc->mcomp_filter_type), 2);
}
vp8_write_literal(&header_bc, pc->prob_pred_filter_off, 8);
#endif
-#if CONFIG_SWITCHABLE_INTERP
if (pc->mcomp_filter_type == SWITCHABLE)
update_switchable_interp_probs(cpi, &header_bc);
-#endif
vp8_write_literal(&header_bc, pc->prob_intra_coded, 8);
vp8_write_literal(&header_bc, pc->prob_last_coded, 8);
int bmode_costs[VP8_BINTRAMODES][VP8_BINTRAMODES][VP8_BINTRAMODES];
int i8x8_mode_costs[MB_MODE_COUNT];
int inter_bmode_costs[B_MODE_COUNT];
-#if CONFIG_SWITCHABLE_INTERP
- int switchable_interp_costs[VP8_SWITCHABLE_FILTERS+1]
+ int switchable_interp_costs[VP8_SWITCHABLE_FILTERS + 1]
[VP8_SWITCHABLE_FILTERS];
-#endif
- // These define limits to motion vector components to prevent them from extending outside the UMV borders
+ // These define limits to motion vector components to prevent them
+ // from extending outside the UMV borders
int mv_col_min;
int mv_col_max;
int mv_row_min;
cpi->pred_filter_on_count = 0;
cpi->pred_filter_off_count = 0;
#endif
-#if CONFIG_SWITCHABLE_INTERP
vp8_zero(cpi->switchable_interp_count);
-#endif
-
-#if 0
- // Experimental code
- cpi->frame_distortion = 0;
- cpi->last_mb_distortion = 0;
-#endif
xd->mode_info_context = cm->mi;
xd->prev_mode_info_context = cm->prev_mi;
assert(!xd->mode_info_context->mbmi.encoded_as_sb);
#endif
-#if CONFIG_SWITCHABLE_INTERP
vp8_setup_interp_filters(xd, mbmi->interp_filter, cm);
-#endif
if (cpi->oxcf.tuning == VP8_TUNE_SSIM) {
// Adjust the zbin based on this MB rate.
adjust_act_zbin(cpi, x);
vp8_cost_tokens(c->mb.i8x8_mode_costs,
x->fc.i8x8_mode_prob, vp8_i8x8_mode_tree);
-#if CONFIG_SWITCHABLE_INTERP
{
int i;
for (i = 0; i <= VP8_SWITCHABLE_FILTERS; ++i)
- //for (i = 0; i <= 0; ++i)
vp8_cost_tokens((int *)c->mb.switchable_interp_costs[i],
x->fc.switchable_interp_prob[i],
vp8_switchable_interp_tree);
}
-#endif
}
extern const int vp8_gf_interval_table[101];
+#define DEFAULT_INTERP_FILTER EIGHTTAP /* SWITCHABLE for better performance */
#define SEARCH_BEST_FILTER 0 /* to search exhaustively for
best filter */
#define RESET_FOREACH_FILTER 0 /* whether to reset the encoder state
cpi->cq_target_quality = cpi->oxcf.cq_level;
if (!cm->use_bilinear_mc_filter)
- cm->mcomp_filter_type = EIGHTTAP;
+ cm->mcomp_filter_type = DEFAULT_INTERP_FILTER;
else
cm->mcomp_filter_type = BILINEAR;
/* list of filters to search over */
int mcomp_filters_to_search[] = {
-#if CONFIG_SWITCHABLE_INTERP
EIGHTTAP, EIGHTTAP_SHARP, SIXTAP, SWITCHABLE
-#else
- EIGHTTAP, EIGHTTAP_SHARP, SIXTAP,
-#endif
};
- int mcomp_filters = sizeof(mcomp_filters_to_search) / sizeof(*mcomp_filters_to_search);
+ int mcomp_filters = sizeof(mcomp_filters_to_search) /
+ sizeof(*mcomp_filters_to_search);
int mcomp_filter_index = 0;
INT64 mcomp_filter_cost[4];
cm->mcomp_filter_type = mcomp_filters_to_search[0];
mcomp_filter_index = 0;
} else {
-#if CONFIG_SWITCHABLE_INTERP
- cm->mcomp_filter_type = SWITCHABLE;
-#else
- cm->mcomp_filter_type =
- (Q < SHARP_FILTER_QTHRESH ? EIGHTTAP_SHARP : EIGHTTAP);
-#endif
+ cm->mcomp_filter_type = DEFAULT_INTERP_FILTER;
}
/* TODO: Decide this more intelligently */
xd->allow_high_precision_mv = (Q < HIGH_PRECISION_MV_QTHRESH);
if (cpi->is_src_frame_alt_ref)
Loop = FALSE;
-#if CONFIG_SWITCHABLE_INTERP
if (cm->frame_type != KEY_FRAME &&
!sf->search_best_filter &&
cm->mcomp_filter_type == SWITCHABLE) {
if (count[i]) {
cm->mcomp_filter_type = vp8_switchable_interp[i];
Loop = TRUE; /* Make sure to loop since the filter changed */
- //loop_count = -1;
break;
}
}
}
}
-#endif
if (Loop == FALSE && cm->frame_type != KEY_FRAME && sf->search_best_filter) {
if (mcomp_filter_index < mcomp_filters) {
vp8_prob sub_mv_ref_prob [SUBMVREF_COUNT][VP8_SUBMVREFS - 1];
vp8_prob mbsplit_prob [VP8_NUMMBSPLITS - 1];
-#if CONFIG_SWITCHABLE_INTERP
vp8_prob switchable_interp_prob[VP8_SWITCHABLE_FILTERS + 1]
[VP8_SWITCHABLE_FILTERS - 1];
-#endif
int mv_ref_ct[6][4][2];
int mode_context[6][4];
int pred_filter_on_count;
int pred_filter_off_count;
#endif
-#if CONFIG_SWITCHABLE_INTERP
- unsigned int switchable_interp_count[VP8_SWITCHABLE_FILTERS+1]
+ unsigned int switchable_interp_count[VP8_SWITCHABLE_FILTERS + 1]
[VP8_SWITCHABLE_FILTERS];
-#endif
#if CONFIG_NEW_MVREF
unsigned int best_ref_index_counts[MAX_MV_REFS];
vp8_copy(cc->hybrid_coef_probs_8x8, cm->fc.hybrid_coef_probs_8x8);
vp8_copy(cc->coef_probs_16x16, cm->fc.coef_probs_16x16);
vp8_copy(cc->hybrid_coef_probs_16x16, cm->fc.hybrid_coef_probs_16x16);
-#if CONFIG_SWITCHABLE_INTERP
vp8_copy(cc->switchable_interp_prob, cm->fc.switchable_interp_prob);
-#endif
}
void vp8_restore_coding_context(VP8_COMP *cpi) {
vp8_copy(cm->fc.hybrid_coef_probs_8x8, cc->hybrid_coef_probs_8x8);
vp8_copy(cm->fc.coef_probs_16x16, cc->coef_probs_16x16);
vp8_copy(cm->fc.hybrid_coef_probs_16x16, cc->hybrid_coef_probs_16x16);
-#if CONFIG_SWITCHABLE_INTERP
vp8_copy(cm->fc.switchable_interp_prob, cc->switchable_interp_prob);
-#endif
}
#define INVALID_MV 0x80008000
-#if CONFIG_SWITCHABLE_INTERP
/* Factor to weigh the rate for switchable interp filters */
#define SWITCHABLE_INTERP_RATE_FACTOR 1
-#endif
static const int auto_speed_thresh[17] = {
1000,
int_mv ref_mv[MAX_REF_FRAMES] = {{0}};
#endif
-#if CONFIG_SWITCHABLE_INTERP
int switchable_filter_index = 0;
-#endif
MB_PREDICTION_MODE uv_intra_mode;
MB_PREDICTION_MODE uv_intra_mode_8x8 = 0;
// that depend on the current prediction etc.
vp8_estimate_ref_frame_costs(cpi, segment_id, ref_costs);
-#if CONFIG_SWITCHABLE_INTERP
for (mode_index = 0; mode_index < MAX_MODES;
mode_index += (!switchable_filter_index)) {
-#else
- for (mode_index = 0; mode_index < MAX_MODES; ++mode_index) {
-#endif
int64_t this_rd = INT64_MAX;
int is_comp_pred;
int disable_skip = 0, skippable = 0;
#if CONFIG_PRED_FILTER
mbmi->pred_filter_enabled = 0;
#endif
-#if CONFIG_SWITCHABLE_INTERP
if (cpi->common.mcomp_filter_type == SWITCHABLE &&
this_mode >= NEARESTMV && this_mode <= SPLITMV) {
mbmi->interp_filter =
vp8_switchable_interp[switchable_filter_index++];
if (switchable_filter_index == VP8_SWITCHABLE_FILTERS)
switchable_filter_index = 0;
- //printf("Searching %d (%d)\n", this_mode, switchable_filter_index);
} else {
mbmi->interp_filter = cpi->common.mcomp_filter_type;
}
vp8_setup_interp_filters(xd, mbmi->interp_filter, &cpi->common);
-#endif
// Test best rd so far against threshold for trying this mode.
if (best_rd <= cpi->rd_threshes[mode_index])
rate2 += rate;
distortion2 += distortion;
-#if CONFIG_SWITCHABLE_INTERP
if (cpi->common.mcomp_filter_type == SWITCHABLE)
rate2 += SWITCHABLE_INTERP_RATE_FACTOR * x->switchable_interp_costs
[get_pred_context(&cpi->common, xd, PRED_SWITCHABLE_INTERP)]
[vp8_switchable_interp_map[mbmi->interp_filter]];
-#endif
// If even the 'Y' rd value of split is higher than best so far
// then dont bother looking at UV
if (tmp_rd < best_yrd) {
rate2 += vp8_cost_bit(cpi->common.prob_pred_filter_off,
xd->mode_info_context->mbmi.pred_filter_enabled);
#endif
-#if CONFIG_SWITCHABLE_INTERP
if (cpi->common.mcomp_filter_type == SWITCHABLE)
rate2 += SWITCHABLE_INTERP_RATE_FACTOR * x->switchable_interp_costs
[get_pred_context(&cpi->common, xd, PRED_SWITCHABLE_INTERP)]
[vp8_switchable_interp_map[
x->e_mbd.mode_info_context->mbmi.interp_filter]];
-#endif
/* We don't include the cost of the second reference here, because there are only
* three options: Last/Golden, ARF/Last or Golden/ARF, or in other words if you
else
++cpi->pred_filter_off_count;
#endif
-#if CONFIG_SWITCHABLE_INTERP
if (cpi->common.mcomp_filter_type == SWITCHABLE &&
best_mbmode.mode >= NEARESTMV &&
best_mbmode.mode <= SPLITMV) {
[get_pred_context(&cpi->common, xd, PRED_SWITCHABLE_INTERP)]
[vp8_switchable_interp_map[best_mbmode.interp_filter]];
}
-#endif
// Reduce the activation RD thresholds for the best choice mode
if ((cpi->rd_baseline_thresh[best_mode_index] > 0) &&