Pack InterpFilters into a single integer
Before this patch, if CONFIG_DUAL_FILTER was true then an MB_MODE_INFO
stored its filter choices as an array of four numbers, each of which
was between 0 and 10. It also seems that elements 2 and 3 of the array
were always the same as elements 0 and 1 when used.
This patch defines a new type(def) called InterpFilters together with
constructor and extractor functions. When CONFIG_DUAL_FILTER is zero,
InterpFilters is a synonym for InterpFilter and the constructor and
extractor functions should compile away to nothing. When it is
nonzero, InterpFilters is a uint32_t which stores the x filter in the
high part and the y filter in the low part (this looks strange, but
matches the old numbering).
Making this change allows us to get rid of lots of special case code
that was dependent on CONFIG_DUAL_FILTER. The uniform
extract/make/broadcast interface also actually shortens code in
general.
Change-Id: I6b24a61bac3e4b220d8d46d0b27cfe865dcfba81
diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c
index 53795b4..9503dc8 100644
--- a/av1/decoder/decodemv.c
+++ b/av1/decoder/decodemv.c
@@ -1161,11 +1161,7 @@
if (mbmi->use_intrabc) {
mbmi->tx_size = read_tx_size(cm, xd, 1, !mbmi->skip, r);
mbmi->mode = mbmi->uv_mode = UV_DC_PRED;
-#if CONFIG_DUAL_FILTER
- for (int idx = 0; idx < 4; ++idx) mbmi->interp_filter[idx] = BILINEAR;
-#else
- mbmi->interp_filter = BILINEAR;
-#endif
+ mbmi->interp_filters = av1_broadcast_interp_filter(BILINEAR);
int16_t inter_mode_ctx[MODE_CTX_REF_FRAMES];
int_mv ref_mvs[MAX_MV_REF_CANDIDATES];
@@ -1750,43 +1746,33 @@
return;
}
-#if CONFIG_DUAL_FILTER
if (cm->interp_filter != SWITCHABLE) {
- int dir;
-
- for (dir = 0; dir < 4; ++dir) mbmi->interp_filter[dir] = cm->interp_filter;
+ mbmi->interp_filters = av1_broadcast_interp_filter(cm->interp_filter);
} else {
- int dir;
-
- for (dir = 0; dir < 2; ++dir) {
- const int ctx = av1_get_pred_context_switchable_interp(xd, dir);
- mbmi->interp_filter[dir] = EIGHTTAP_REGULAR;
-
+#if CONFIG_DUAL_FILTER
+ InterpFilter ref0_filter[2] = { EIGHTTAP_REGULAR, EIGHTTAP_REGULAR };
+ for (int dir = 0; dir < 2; ++dir) {
if (has_subpel_mv_component(xd->mi[0], xd, dir) ||
(mbmi->ref_frame[1] > INTRA_FRAME &&
has_subpel_mv_component(xd->mi[0], xd, dir + 2))) {
- mbmi->interp_filter[dir] =
+ const int ctx = av1_get_pred_context_switchable_interp(xd, dir);
+ ref0_filter[dir] =
(InterpFilter)aom_read_symbol(r, ec_ctx->switchable_interp_cdf[ctx],
SWITCHABLE_FILTERS, ACCT_STR);
- if (counts) ++counts->switchable_interp[ctx][mbmi->interp_filter[dir]];
+ if (counts) ++counts->switchable_interp[ctx][ref0_filter[dir]];
}
}
- // The index system works as:
- // (0, 1) -> (vertical, horizontal) filter types for the first ref frame.
- // (2, 3) -> (vertical, horizontal) filter types for the second ref frame.
- mbmi->interp_filter[2] = mbmi->interp_filter[0];
- mbmi->interp_filter[3] = mbmi->interp_filter[1];
- }
+ // The index system works as: (0, 1) -> (vertical, horizontal) filter types
+ mbmi->interp_filters =
+ av1_make_interp_filters(ref0_filter[0], ref0_filter[1]);
#else // CONFIG_DUAL_FILTER
- if (cm->interp_filter != SWITCHABLE) {
- mbmi->interp_filter = cm->interp_filter;
- } else {
const int ctx = av1_get_pred_context_switchable_interp(xd);
- mbmi->interp_filter = (InterpFilter)aom_read_symbol(
+ InterpFilter filter = (InterpFilter)aom_read_symbol(
r, ec_ctx->switchable_interp_cdf[ctx], SWITCHABLE_FILTERS, ACCT_STR);
- if (counts) ++counts->switchable_interp[ctx][mbmi->interp_filter];
- }
+ mbmi->interp_filters = av1_broadcast_interp_filter(filter);
+ if (counts) ++counts->switchable_interp[ctx][filter];
#endif // CONFIG_DUAL_FILTER
+ }
}
static void read_intra_block_mode_info(AV1_COMMON *const cm, const int mi_row,
diff --git a/av1/decoder/inspection.c b/av1/decoder/inspection.c
index 1728333..98c51d4 100644
--- a/av1/decoder/inspection.c
+++ b/av1/decoder/inspection.c
@@ -91,10 +91,10 @@
// Skip Flag
mi->skip = mbmi->skip;
#if CONFIG_DUAL_FILTER
- mi->filter[0] = mbmi->interp_filter[0];
- mi->filter[1] = mbmi->interp_filter[1];
+ mi->filter[0] = av1_extract_interp_filter(mbmi->interp_filters, 0);
+ mi->filter[1] = av1_extract_interp_filter(mbmi->interp_filters, 1);
#else
- mi->filter = mbmi->interp_filter;
+ mi->filter = av1_extract_interp_filter(mbmi->interp_filters, 0);
#endif
// Transform
mi->tx_type = mbmi->tx_type;