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) { ...@@ -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 return aom_rb_read_bit(rb) ? SWITCHABLE
: aom_rb_read_literal(rb, LOG_SWITCHABLE_FILTERS); : aom_rb_read_literal(rb, LOG_SWITCHABLE_FILTERS);
} }
...@@ -3938,7 +3938,7 @@ static size_t read_uncompressed_header(AV1Decoder *pbi, ...@@ -3938,7 +3938,7 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
#endif #endif
cm->allow_high_precision_mv = aom_rb_read_bit(rb); 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) { for (i = 0; i < INTER_REFS_PER_FRAME; ++i) {
RefBuffer *const ref_buf = &cm->frame_refs[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, ...@@ -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, static INLINE InterpFilter read_mb_interp_filter(AV1_COMMON *const cm,
MACROBLOCKD *const xd, MACROBLOCKD *const xd,
#if CONFIG_DUAL_FILTER #if CONFIG_DUAL_FILTER
int dir, int dir,
#endif #endif
aom_reader *r) { aom_reader *r) {
#if CONFIG_EXT_INTERP #if CONFIG_EXT_INTERP
if (!av1_is_interp_needed(xd)) return EIGHTTAP_REGULAR; if (!av1_is_interp_needed(xd)) return EIGHTTAP_REGULAR;
#endif #endif
...@@ -1563,7 +1563,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi, ...@@ -1563,7 +1563,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
#endif #endif
#if !CONFIG_EXT_INTERP && !CONFIG_DUAL_FILTER #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 #endif // !CONFIG_EXT_INTERP && !CONFIG_DUAL_FILTER
if (bsize < BLOCK_8X8) { if (bsize < BLOCK_8X8) {
...@@ -1787,7 +1787,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi, ...@@ -1787,7 +1787,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
if (has_subpel_mv_component(xd->mi[0], xd, ref) || if (has_subpel_mv_component(xd->mi[0], xd, ref) ||
(mbmi->ref_frame[1] > INTRA_FRAME && (mbmi->ref_frame[1] > INTRA_FRAME &&
has_subpel_mv_component(xd->mi[0], xd, ref + 2))) 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: // The index system worsk as:
// (0, 1) -> (vertical, horizontal) filter types for the first ref frame. // (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, ...@@ -1796,7 +1796,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
mbmi->interp_filter[3] = mbmi->interp_filter[1]; mbmi->interp_filter[3] = mbmi->interp_filter[1];
#else #else
#if CONFIG_EXT_INTERP #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_EXT_INTERP
#endif // CONFIG_DUAL_FILTER #endif // CONFIG_DUAL_FILTER
} }
......
...@@ -1030,8 +1030,8 @@ static void write_intra_angle_info(const AV1_COMMON *cm, const MACROBLOCKD *xd, ...@@ -1030,8 +1030,8 @@ static void write_intra_angle_info(const AV1_COMMON *cm, const MACROBLOCKD *xd,
} }
#endif // CONFIG_EXT_INTRA #endif // CONFIG_EXT_INTRA
static void write_switchable_interp_filter(AV1_COMP *cpi, const MACROBLOCKD *xd, static void write_mb_interp_filter(AV1_COMP *cpi, const MACROBLOCKD *xd,
aom_writer *w) { aom_writer *w) {
AV1_COMMON *const cm = &cpi->common; AV1_COMMON *const cm = &cpi->common;
const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
#if CONFIG_DUAL_FILTER #if CONFIG_DUAL_FILTER
...@@ -1395,7 +1395,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi, ...@@ -1395,7 +1395,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
} }
#if !CONFIG_EXT_INTERP && !CONFIG_DUAL_FILTER #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 #endif // !CONFIG_EXT_INTERP
if (bsize < BLOCK_8X8) { if (bsize < BLOCK_8X8) {
...@@ -1615,7 +1615,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi, ...@@ -1615,7 +1615,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
#endif // CONFIG_EXT_INTER #endif // CONFIG_EXT_INTER
#if CONFIG_EXT_INTERP || CONFIG_DUAL_FILTER #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 #endif // CONFIG_EXT_INTERP
} }
...@@ -3280,8 +3280,8 @@ static void update_txfm_probs(AV1_COMMON *cm, aom_writer *w, ...@@ -3280,8 +3280,8 @@ static void update_txfm_probs(AV1_COMMON *cm, aom_writer *w,
} }
} }
static void write_interp_filter(InterpFilter filter, static void write_frame_interp_filter(InterpFilter filter,
struct aom_write_bit_buffer *wb) { struct aom_write_bit_buffer *wb) {
aom_wb_write_bit(wb, filter == SWITCHABLE); aom_wb_write_bit(wb, filter == SWITCHABLE);
if (filter != SWITCHABLE) if (filter != SWITCHABLE)
aom_wb_write_literal(wb, filter, LOG_SWITCHABLE_FILTERS); aom_wb_write_literal(wb, filter, LOG_SWITCHABLE_FILTERS);
...@@ -3983,7 +3983,7 @@ static void write_uncompressed_header(AV1_COMP *cpi, ...@@ -3983,7 +3983,7 @@ static void write_uncompressed_header(AV1_COMP *cpi,
aom_wb_write_bit(wb, cm->allow_high_precision_mv); aom_wb_write_bit(wb, cm->allow_high_precision_mv);
fix_interp_filter(cm, cpi->td.counts); 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 @@ ...@@ -53,20 +53,21 @@
#include "av1/encoder/pvq_encoder.h" #include "av1/encoder/pvq_encoder.h"
#endif #endif
#if CONFIG_DUAL_FILTER #if CONFIG_DUAL_FILTER
#define DUAL_FILTER_SET_SIZE (SWITCHABLE_FILTERS * SWITCHABLE_FILTERS)
#if CONFIG_EXT_INTERP #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 }, { 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 }, { 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 }, { 2, 4 }, { 3, 0 }, { 3, 1 }, { 3, 2 }, { 3, 3 }, { 3, 4 }, { 4, 0 },
{ 4, 1 }, { 4, 2 }, { 4, 3 }, { 4, 4 }, { 4, 1 }, { 4, 2 }, { 4, 3 }, { 4, 4 },
}; };
#else #else // CONFIG_EXT_INTERP
static const int filter_sets[9][2] = { static const int filter_sets[DUAL_FILTER_SET_SIZE][2] = {
{ 0, 0 }, { 0, 1 }, { 0, 2 }, { 1, 0 }, { 1, 1 }, { 0, 0 }, { 0, 1 }, { 0, 2 }, { 1, 0 }, { 1, 1 },
{ 1, 2 }, { 2, 0 }, { 2, 1 }, { 2, 2 }, { 1, 2 }, { 2, 0 }, { 2, 1 }, { 2, 2 },
}; };
#endif #endif // CONFIG_EXT_INTERP
#endif #endif // CONFIG_DUAL_FILTER
#if CONFIG_EXT_REFS #if CONFIG_EXT_REFS
...@@ -7296,6 +7297,11 @@ static int64_t handle_inter_mode( ...@@ -7296,6 +7297,11 @@ static int64_t handle_inter_mode(
if (assign_filter == SWITCHABLE) { if (assign_filter == SWITCHABLE) {
// do interp_filter search // do interp_filter search
if (av1_is_interp_needed(xd)) { 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; int best_in_temp = 0;
#if CONFIG_DUAL_FILTER #if CONFIG_DUAL_FILTER
InterpFilter best_filter[4]; InterpFilter best_filter[4];
...@@ -7304,14 +7310,8 @@ static int64_t handle_inter_mode( ...@@ -7304,14 +7310,8 @@ static int64_t handle_inter_mode(
InterpFilter best_filter = mbmi->interp_filter; InterpFilter best_filter = mbmi->interp_filter;
#endif #endif
restore_dst_buf(xd, tmp_dst, tmp_dst_stride); 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 // EIGHTTAP_REGULAR mode is calculated beforehand
for (i = 1; i < SWITCHABLE_FILTERS; ++i) for (i = 1; i < filter_set_size; ++i) {
#endif
{
int tmp_skip_sb = 0; int tmp_skip_sb = 0;
int64_t tmp_skip_sse = INT64_MAX; int64_t tmp_skip_sse = INT64_MAX;
int tmp_rs; int tmp_rs;
...@@ -10485,11 +10485,7 @@ void av1_rd_pick_inter_mode_sub8x8(const struct AV1_COMP *cpi, ...@@ -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 ? b_mode_info tmp_best_bmodes[16]; // Should this be 4 ?
MB_MODE_INFO tmp_best_mbmode; MB_MODE_INFO tmp_best_mbmode;
#if CONFIG_DUAL_FILTER #if CONFIG_DUAL_FILTER
#if CONFIG_EXT_INTERP BEST_SEG_INFO bsi[DUAL_FILTER_SET_SIZE];
BEST_SEG_INFO bsi[25];
#else
BEST_SEG_INFO bsi[9];
#endif
#else #else
BEST_SEG_INFO bsi[SWITCHABLE_FILTERS]; BEST_SEG_INFO bsi[SWITCHABLE_FILTERS];
#endif #endif
...@@ -10559,18 +10555,13 @@ void av1_rd_pick_inter_mode_sub8x8(const struct AV1_COMP *cpi, ...@@ -10559,18 +10555,13 @@ void av1_rd_pick_inter_mode_sub8x8(const struct AV1_COMP *cpi,
#endif #endif
} else { } else {
#if CONFIG_DUAL_FILTER #if CONFIG_DUAL_FILTER
for (switchable_filter_index = 0; const int filter_set_size = DUAL_FILTER_SET_SIZE;
#if CONFIG_EXT_INTERP
switchable_filter_index < 25;
#else #else
switchable_filter_index < 9; const int filter_set_size = SWITCHABLE_FILTERS;
#endif #endif
++switchable_filter_index) {
#else
for (switchable_filter_index = 0; for (switchable_filter_index = 0;
switchable_filter_index < SWITCHABLE_FILTERS; switchable_filter_index < filter_set_size;
++switchable_filter_index) { ++switchable_filter_index) {
#endif
int newbest, rs; int newbest, rs;
int64_t rs_rd; int64_t rs_rd;
MB_MODE_INFO_EXT *mbmi_ext = x->mbmi_ext; 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