#include "vp9/common/vp9_pred_common.h"
#include "vp9/common/vp9_seg_common.h"
-// Returns a context number for the given MB prediction signal
-int vp9_get_pred_context_switchable_interp(const MACROBLOCKD *xd) {
- // Note:
- // The mode info data structure has a one element border above and to the
- // left of the entries corresponding to real macroblocks.
- // The prediction flags in these dummy entries are initialized to 0.
- const MODE_INFO *const left_mi = xd->left_mi;
- const int left_type = left_mi && is_inter_block(left_mi) ?
- left_mi->interp_filter : SWITCHABLE_FILTERS;
- const MODE_INFO *const above_mi = xd->above_mi;
- const int above_type = above_mi && is_inter_block(above_mi) ?
- above_mi->interp_filter : SWITCHABLE_FILTERS;
-
- if (left_type == above_type)
- return left_type;
- else if (left_type == SWITCHABLE_FILTERS)
- return above_type;
- else if (above_type == SWITCHABLE_FILTERS)
- return left_type;
- else
- return SWITCHABLE_FILTERS;
-}
-
int vp9_get_reference_mode_context(const VP9_COMMON *cm,
const MACROBLOCKD *xd) {
int ctx;
return cm->fc->skip_probs[vp9_get_skip_context(xd)];
}
-int vp9_get_pred_context_switchable_interp(const MACROBLOCKD *xd);
+// Returns a context number for the given MB prediction signal
+static INLINE int get_pred_context_switchable_interp(const MACROBLOCKD *xd) {
+ // Note:
+ // The mode info data structure has a one element border above and to the
+ // left of the entries corresponding to real macroblocks.
+ // The prediction flags in these dummy entries are initialized to 0.
+ const MODE_INFO *const left_mi = xd->left_mi;
+ const int left_type = left_mi ? left_mi->interp_filter : SWITCHABLE_FILTERS;
+ const MODE_INFO *const above_mi = xd->above_mi;
+ const int above_type = above_mi ? above_mi->interp_filter
+ : SWITCHABLE_FILTERS;
+
+ if (left_type == above_type)
+ return left_type;
+ else if (left_type == SWITCHABLE_FILTERS)
+ return above_type;
+ else if (above_type == SWITCHABLE_FILTERS)
+ return left_type;
+ else
+ return SWITCHABLE_FILTERS;
+}
// The mode info data structure has a one element border above and to the
// left of the entries corresponding to real macroblocks.
}
}
-// TODO(slavarnway): Move this decoder version of
-// vp9_get_pred_context_switchable_interp() to vp9_pred_common.h and update the
-// encoder.
-//
-// Returns a context number for the given MB prediction signal
-static int dec_get_pred_context_switchable_interp(const MACROBLOCKD *xd) {
- // Note:
- // The mode info data structure has a one element border above and to the
- // left of the entries corresponding to real macroblocks.
- // The prediction flags in these dummy entries are initialized to 0.
- const MODE_INFO *const left_mi = xd->left_mi;
- const int left_type = left_mi ? left_mi->interp_filter : SWITCHABLE_FILTERS;
- const MODE_INFO *const above_mi = xd->above_mi;
- const int above_type = above_mi ? above_mi->interp_filter
- : SWITCHABLE_FILTERS;
-
- if (left_type == above_type)
- return left_type;
- else if (left_type == SWITCHABLE_FILTERS)
- return above_type;
- else if (above_type == SWITCHABLE_FILTERS)
- return left_type;
- else
- return SWITCHABLE_FILTERS;
-}
-
static INLINE INTERP_FILTER read_switchable_interp_filter(
VP9_COMMON *const cm, MACROBLOCKD *const xd,
vpx_reader *r) {
- const int ctx = dec_get_pred_context_switchable_interp(xd);
+ const int ctx = get_pred_context_switchable_interp(xd);
const INTERP_FILTER type =
(INTERP_FILTER)vpx_read_tree(r, vp9_switchable_interp_tree,
cm->fc->switchable_interp_prob[ctx]);
mi->uv_mode = read_intra_mode_uv(cm, xd, r, mi->mode);
// Initialize interp_filter here so we do not have to check for inter block
- // modes in dec_get_pred_context_switchable_interp()
+ // modes in get_pred_context_switchable_interp()
mi->interp_filter = SWITCHABLE_FILTERS;
mi->ref_frame[0] = INTRA_FRAME;
}
if (cm->interp_filter == SWITCHABLE) {
- const int ctx = vp9_get_pred_context_switchable_interp(xd);
+ const int ctx = get_pred_context_switchable_interp(xd);
vp9_write_token(w, vp9_switchable_interp_tree,
cm->fc->switchable_interp_prob[ctx],
&switchable_interp_encodings[mi->interp_filter]);
const int mi_stride = xd->mi_stride;
MODE_INFO *const src_mi = xd->mi[0];
int i, j;
+
for (j = 0; j < block_height; ++j)
for (i = 0; i < block_width; ++i)
xd->mi[j * mi_stride + i] = src_mi;
vp9_update_mv_count(td);
if (cm->interp_filter == SWITCHABLE) {
- const int ctx = vp9_get_pred_context_switchable_interp(xd);
+ const int ctx = get_pred_context_switchable_interp(xd);
++td->counts->switchable_interp[ctx][xdmi->interp_filter];
}
}
MODE_INFO *const mi = xd->mi[0];
INTERP_FILTER filter_ref;
- filter_ref = vp9_get_pred_context_switchable_interp(xd);
+ filter_ref = get_pred_context_switchable_interp(xd);
if (filter_ref == SWITCHABLE_FILTERS)
filter_ref = EIGHTTAP;
if (is_inter_block(mi)) {
vp9_update_mv_count(td);
if (cm->interp_filter == SWITCHABLE) {
- const int pred_ctx = vp9_get_pred_context_switchable_interp(xd);
+ const int pred_ctx = get_pred_context_switchable_interp(xd);
++td->counts->switchable_interp[pred_ctx][mi->interp_filter];
}
RD_COST this_rdc, sum_rdc, best_rdc;
int do_split = bsize >= BLOCK_8X8;
int do_rect = 1;
+ INTERP_FILTER pred_interp_filter;
// Override skipping rectangular partition operations for edge blocks
const int force_horz_split = (mi_row + mi_step >= cm->mi_rows);
// If the interp_filter is marked as SWITCHABLE_FILTERS, it was for an
// intra block and used for context purposes.
if (ctx->mic.interp_filter == SWITCHABLE_FILTERS) {
- ctx->mic.interp_filter = EIGHTTAP;
+ pred_interp_filter = EIGHTTAP;
+ } else {
+ pred_interp_filter = ctx->mic.interp_filter;
}
// PARTITION_SPLIT
if (bsize == BLOCK_8X8) {
i = 4;
if (cpi->sf.adaptive_pred_interp_filter && partition_none_allowed)
- pc_tree->leaf_split[0]->pred_interp_filter =
- ctx->mic.interp_filter;
+ pc_tree->leaf_split[0]->pred_interp_filter = pred_interp_filter;
rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &sum_rdc, subsize,
pc_tree->leaf_split[0], best_rdc.rdcost);
load_pred_mv(x, ctx);
if (cpi->sf.adaptive_pred_interp_filter && bsize == BLOCK_8X8 &&
partition_none_allowed)
- pc_tree->horizontal[0].pred_interp_filter =
- ctx->mic.interp_filter;
+ pc_tree->horizontal[0].pred_interp_filter = pred_interp_filter;
rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &sum_rdc, subsize,
&pc_tree->horizontal[0], best_rdc.rdcost);
load_pred_mv(x, ctx);
if (cpi->sf.adaptive_pred_interp_filter && bsize == BLOCK_8X8 &&
partition_none_allowed)
- pc_tree->horizontal[1].pred_interp_filter =
- ctx->mic.interp_filter;
+ pc_tree->horizontal[1].pred_interp_filter = pred_interp_filter;
rd_pick_sb_modes(cpi, tile_data, x, mi_row + mi_step, mi_col,
&this_rdc, subsize, &pc_tree->horizontal[1],
best_rdc.rdcost - sum_rdc.rdcost);
load_pred_mv(x, ctx);
if (cpi->sf.adaptive_pred_interp_filter && bsize == BLOCK_8X8 &&
partition_none_allowed)
- pc_tree->vertical[0].pred_interp_filter =
- ctx->mic.interp_filter;
+ pc_tree->vertical[0].pred_interp_filter = pred_interp_filter;
rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &sum_rdc, subsize,
&pc_tree->vertical[0], best_rdc.rdcost);
if (sum_rdc.rdcost < best_rdc.rdcost && mi_col + mi_step < cm->mi_cols &&
load_pred_mv(x, ctx);
if (cpi->sf.adaptive_pred_interp_filter && bsize == BLOCK_8X8 &&
partition_none_allowed)
- pc_tree->vertical[1].pred_interp_filter =
- ctx->mic.interp_filter;
+ pc_tree->vertical[1].pred_interp_filter = pred_interp_filter;
rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col + mi_step,
&this_rdc, subsize,
&pc_tree->vertical[1], best_rdc.rdcost - sum_rdc.rdcost);
vp9_rd_cost_reset(&this_rdc);
mi->ref_frame[0] = INTRA_FRAME;
+ // Initialize interp_filter here so we do not have to check for inter block
+ // modes in get_pred_context_switchable_interp()
+ mi->interp_filter = SWITCHABLE_FILTERS;
+
mi->mv[0].as_int = INVALID_MV;
mi->uv_mode = DC_PRED;
memset(x->skip_txfm, 0, sizeof(x->skip_txfm));
mi->sb_type = bsize;
mi->ref_frame[0] = NONE;
mi->ref_frame[1] = NONE;
+
mi->tx_size = VPXMIN(max_txsize_lookup[bsize],
tx_mode_to_biggest_tx_size[cm->tx_mode]);
int vp9_get_switchable_rate(const VP9_COMP *cpi, const MACROBLOCKD *const xd) {
const MODE_INFO *const mi = xd->mi[0];
- const int ctx = vp9_get_pred_context_switchable_interp(xd);
+ const int ctx = get_pred_context_switchable_interp(xd);
return SWITCHABLE_INTERP_RATE_FACTOR *
cpi->switchable_interp_costs[ctx][mi->interp_filter];
}
/* required for left and above block mv */
mi->mv[0].as_int = 0;
max_plane = 1;
+ // Initialize interp_filter here so we do not have to check for
+ // inter block modes in get_pred_context_switchable_interp()
+ mi->interp_filter = SWITCHABLE_FILTERS;
} else {
best_pred_sse = x->pred_sse[ref_frame];
}
/* required for left and above block mv */
mi->mv[0].as_int = 0;
max_plane = 1;
+ // Initialize interp_filter here so we do not have to check for
+ // inter block modes in get_pred_context_switchable_interp()
+ mi->interp_filter = SWITCHABLE_FILTERS;
}
rd_cost->rate = rate2;