Clean up ext_interp
1) Simplify macro branch
2) Improve the naming of interp_filter read/write functions
Change-Id: I0ae290b08a8b058359874d91da468062706ab2d5
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 91c2b3a..9de00fc 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -2643,7 +2643,7 @@
}
}
-static InterpFilter read_interp_filter(struct aom_read_bit_buffer *rb) {
+static InterpFilter read_frame_interp_filter(struct aom_read_bit_buffer *rb) {
return aom_rb_read_bit(rb) ? SWITCHABLE
: aom_rb_read_literal(rb, LOG_SWITCHABLE_FILTERS);
}
@@ -3938,7 +3938,7 @@
#endif
cm->allow_high_precision_mv = aom_rb_read_bit(rb);
- cm->interp_filter = read_interp_filter(rb);
+ cm->interp_filter = read_frame_interp_filter(rb);
for (i = 0; i < INTER_REFS_PER_FRAME; ++i) {
RefBuffer *const ref_buf = &cm->frame_refs[i];
diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c
index 2c2d98a..fc1c8e9 100644
--- a/av1/decoder/decodemv.c
+++ b/av1/decoder/decodemv.c
@@ -1034,12 +1034,12 @@
}
}
-static INLINE InterpFilter read_interp_filter(AV1_COMMON *const cm,
- MACROBLOCKD *const xd,
+static INLINE InterpFilter read_mb_interp_filter(AV1_COMMON *const cm,
+ MACROBLOCKD *const xd,
#if CONFIG_DUAL_FILTER
- int dir,
+ int dir,
#endif
- aom_reader *r) {
+ aom_reader *r) {
#if CONFIG_EXT_INTERP
if (!av1_is_interp_needed(xd)) return EIGHTTAP_REGULAR;
#endif
@@ -1563,7 +1563,7 @@
#endif
#if !CONFIG_EXT_INTERP && !CONFIG_DUAL_FILTER
- mbmi->interp_filter = read_interp_filter(cm, xd, r);
+ mbmi->interp_filter = read_mb_interp_filter(cm, xd, r);
#endif // !CONFIG_EXT_INTERP && !CONFIG_DUAL_FILTER
if (bsize < BLOCK_8X8) {
@@ -1787,7 +1787,7 @@
if (has_subpel_mv_component(xd->mi[0], xd, ref) ||
(mbmi->ref_frame[1] > INTRA_FRAME &&
has_subpel_mv_component(xd->mi[0], xd, ref + 2)))
- mbmi->interp_filter[ref] = read_interp_filter(cm, xd, ref, r);
+ mbmi->interp_filter[ref] = read_mb_interp_filter(cm, xd, ref, r);
}
// The index system worsk as:
// (0, 1) -> (vertical, horizontal) filter types for the first ref frame.
@@ -1796,7 +1796,7 @@
mbmi->interp_filter[3] = mbmi->interp_filter[1];
#else
#if CONFIG_EXT_INTERP
- mbmi->interp_filter = read_interp_filter(cm, xd, r);
+ mbmi->interp_filter = read_mb_interp_filter(cm, xd, r);
#endif // CONFIG_EXT_INTERP
#endif // CONFIG_DUAL_FILTER
}
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index c7ee55f..8b9d17d 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -1030,8 +1030,8 @@
}
#endif // CONFIG_EXT_INTRA
-static void write_switchable_interp_filter(AV1_COMP *cpi, const MACROBLOCKD *xd,
- aom_writer *w) {
+static void write_mb_interp_filter(AV1_COMP *cpi, const MACROBLOCKD *xd,
+ aom_writer *w) {
AV1_COMMON *const cm = &cpi->common;
const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
#if CONFIG_DUAL_FILTER
@@ -1395,7 +1395,7 @@
}
#if !CONFIG_EXT_INTERP && !CONFIG_DUAL_FILTER
- write_switchable_interp_filter(cpi, xd, w);
+ write_mb_interp_filter(cpi, xd, w);
#endif // !CONFIG_EXT_INTERP
if (bsize < BLOCK_8X8) {
@@ -1615,7 +1615,7 @@
#endif // CONFIG_EXT_INTER
#if CONFIG_EXT_INTERP || CONFIG_DUAL_FILTER
- write_switchable_interp_filter(cpi, xd, w);
+ write_mb_interp_filter(cpi, xd, w);
#endif // CONFIG_EXT_INTERP
}
@@ -3280,8 +3280,8 @@
}
}
-static void write_interp_filter(InterpFilter filter,
- struct aom_write_bit_buffer *wb) {
+static void write_frame_interp_filter(InterpFilter filter,
+ struct aom_write_bit_buffer *wb) {
aom_wb_write_bit(wb, filter == SWITCHABLE);
if (filter != SWITCHABLE)
aom_wb_write_literal(wb, filter, LOG_SWITCHABLE_FILTERS);
@@ -3983,7 +3983,7 @@
aom_wb_write_bit(wb, cm->allow_high_precision_mv);
fix_interp_filter(cm, cpi->td.counts);
- write_interp_filter(cm->interp_filter, wb);
+ write_frame_interp_filter(cm->interp_filter, wb);
}
}
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 2905864..c63f87a 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -53,20 +53,21 @@
#include "av1/encoder/pvq_encoder.h"
#endif
#if CONFIG_DUAL_FILTER
+#define DUAL_FILTER_SET_SIZE (SWITCHABLE_FILTERS * SWITCHABLE_FILTERS)
#if CONFIG_EXT_INTERP
-static const int filter_sets[25][2] = {
+static const int filter_sets[DUAL_FILTER_SET_SIZE][2] = {
{ 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, { 0, 4 }, { 1, 0 }, { 1, 1 },
{ 1, 2 }, { 1, 3 }, { 1, 4 }, { 2, 0 }, { 2, 1 }, { 2, 2 }, { 2, 3 },
{ 2, 4 }, { 3, 0 }, { 3, 1 }, { 3, 2 }, { 3, 3 }, { 3, 4 }, { 4, 0 },
{ 4, 1 }, { 4, 2 }, { 4, 3 }, { 4, 4 },
};
-#else
-static const int filter_sets[9][2] = {
+#else // CONFIG_EXT_INTERP
+static const int filter_sets[DUAL_FILTER_SET_SIZE][2] = {
{ 0, 0 }, { 0, 1 }, { 0, 2 }, { 1, 0 }, { 1, 1 },
{ 1, 2 }, { 2, 0 }, { 2, 1 }, { 2, 2 },
};
-#endif
-#endif
+#endif // CONFIG_EXT_INTERP
+#endif // CONFIG_DUAL_FILTER
#if CONFIG_EXT_REFS
@@ -7296,6 +7297,11 @@
if (assign_filter == SWITCHABLE) {
// do interp_filter search
if (av1_is_interp_needed(xd)) {
+#if CONFIG_DUAL_FILTER
+ const int filter_set_size = DUAL_FILTER_SET_SIZE;
+#else
+ const int filter_set_size = SWITCHABLE_FILTERS;
+#endif
int best_in_temp = 0;
#if CONFIG_DUAL_FILTER
InterpFilter best_filter[4];
@@ -7304,14 +7310,8 @@
InterpFilter best_filter = mbmi->interp_filter;
#endif
restore_dst_buf(xd, tmp_dst, tmp_dst_stride);
-#if CONFIG_DUAL_FILTER
// EIGHTTAP_REGULAR mode is calculated beforehand
- for (i = 1; i < SWITCHABLE_FILTERS * SWITCHABLE_FILTERS; ++i)
-#else
- // EIGHTTAP_REGULAR mode is calculated beforehand
- for (i = 1; i < SWITCHABLE_FILTERS; ++i)
-#endif
- {
+ for (i = 1; i < filter_set_size; ++i) {
int tmp_skip_sb = 0;
int64_t tmp_skip_sse = INT64_MAX;
int tmp_rs;
@@ -10485,11 +10485,7 @@
b_mode_info tmp_best_bmodes[16]; // Should this be 4 ?
MB_MODE_INFO tmp_best_mbmode;
#if CONFIG_DUAL_FILTER
-#if CONFIG_EXT_INTERP
- BEST_SEG_INFO bsi[25];
-#else
- BEST_SEG_INFO bsi[9];
-#endif
+ BEST_SEG_INFO bsi[DUAL_FILTER_SET_SIZE];
#else
BEST_SEG_INFO bsi[SWITCHABLE_FILTERS];
#endif
@@ -10559,18 +10555,13 @@
#endif
} else {
#if CONFIG_DUAL_FILTER
- for (switchable_filter_index = 0;
-#if CONFIG_EXT_INTERP
- switchable_filter_index < 25;
+ const int filter_set_size = DUAL_FILTER_SET_SIZE;
#else
- switchable_filter_index < 9;
+ const int filter_set_size = SWITCHABLE_FILTERS;
#endif
- ++switchable_filter_index) {
-#else
for (switchable_filter_index = 0;
- switchable_filter_index < SWITCHABLE_FILTERS;
+ switchable_filter_index < filter_set_size;
++switchable_filter_index) {
-#endif
int newbest, rs;
int64_t rs_rd;
MB_MODE_INFO_EXT *mbmi_ext = x->mbmi_ext;