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/common/pred_common.c b/av1/common/pred_common.c
index b8dda61..b68bc34 100644
--- a/av1/common/pred_common.c
+++ b/av1/common/pred_common.c
@@ -22,19 +22,16 @@
static InterpFilter get_ref_filter_type(const MODE_INFO *mi,
const MACROBLOCKD *xd, int dir,
MV_REFERENCE_FRAME ref_frame) {
- InterpFilter ref_type = SWITCHABLE_FILTERS;
const MB_MODE_INFO *ref_mbmi = &mi->mbmi;
int use_subpel[2] = {
has_subpel_mv_component(mi, xd, dir),
has_subpel_mv_component(mi, xd, dir + 2),
};
- if (ref_mbmi->ref_frame[0] == ref_frame && use_subpel[0])
- ref_type = ref_mbmi->interp_filter[(dir & 0x01)];
- else if (ref_mbmi->ref_frame[1] == ref_frame && use_subpel[1])
- ref_type = ref_mbmi->interp_filter[(dir & 0x01) + 2];
-
- return ref_type;
+ return (((ref_mbmi->ref_frame[0] == ref_frame && use_subpel[0]) ||
+ (ref_mbmi->ref_frame[1] == ref_frame && use_subpel[1]))
+ ? av1_extract_interp_filter(ref_mbmi->interp_filters, dir & 0x01)
+ : SWITCHABLE_FILTERS);
}
int av1_get_pred_context_switchable_interp(const MACROBLOCKD *xd, int dir) {
@@ -79,13 +76,15 @@
// left of the entries corresponding to real macroblocks.
// The prediction flags in these dummy entries are initialized to 0.
const MB_MODE_INFO *const left_mbmi = xd->left_mbmi;
- const int left_type = xd->left_available && is_inter_block(left_mbmi)
- ? left_mbmi->interp_filter
- : SWITCHABLE_FILTERS;
+ const int left_type =
+ xd->left_available && is_inter_block(left_mbmi)
+ ? av1_extract_interp_filter(left_mbmi->interp_filters, 0)
+ : SWITCHABLE_FILTERS;
const MB_MODE_INFO *const above_mbmi = xd->above_mbmi;
- const int above_type = xd->up_available && is_inter_block(above_mbmi)
- ? above_mbmi->interp_filter
- : SWITCHABLE_FILTERS;
+ const int above_type =
+ xd->up_available && is_inter_block(above_mbmi)
+ ? av1_extract_interp_filter(above_mbmi->interp_filters, 0)
+ : SWITCHABLE_FILTERS;
if (left_type == above_type) {
return left_type;
@@ -110,11 +109,7 @@
if (ref_mbmi->sb_type >= BLOCK_8X8) {
const PREDICTION_MODE mode = ref_mbmi->mode;
if (is_inter_block(ref_mbmi)) {
-#if CONFIG_DUAL_FILTER
- switch (ref_mbmi->interp_filter[0]) {
-#else
- switch (ref_mbmi->interp_filter) {
-#endif
+ switch (av1_extract_interp_filter(ref_mbmi->interp_filters, 0)) {
case EIGHTTAP_REGULAR: ref_type = INTRA_FILTER_8TAP; break;
case EIGHTTAP_SMOOTH: ref_type = INTRA_FILTER_8TAP_SMOOTH; break;
case MULTITAP_SHARP: ref_type = INTRA_FILTER_8TAP_SHARP; break;