Commit 5678ad98 authored by Angie Chiang's avatar Angie Chiang

Clean up ext_interp

1) Simplify macro branch
2) Improve the naming of interp_filter read/write functions

Change-Id: I0ae290b08a8b058359874d91da468062706ab2d5
parent dd28be8b
......@@ -2643,7 +2643,7 @@ static void setup_segmentation_dequant(AV1_COMMON *const cm) {
}
}
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 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
#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];
......
......@@ -1034,12 +1034,12 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
}
}
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 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
#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 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
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 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
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
}
......
......@@ -1030,8 +1030,8 @@ static void write_intra_angle_info(const AV1_COMMON *cm, const MACROBLOCKD *xd,
}
#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 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
}
#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 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
#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 update_txfm_probs(AV1_COMMON *cm, aom_writer *w,
}
}
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 @@ static void write_uncompressed_header(AV1_COMP *cpi,
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);
}
}
......
......@@ -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 @@ static int64_t handle_inter_mode(
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 @@ static int64_t handle_inter_mode(
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 @@ void av1_rd_pick_inter_mode_sub8x8(const struct AV1_COMP *cpi,
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 @@ void av1_rd_pick_inter_mode_sub8x8(const struct AV1_COMP *cpi,
#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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment