Alway process filters in reverse order
The order of processing the filter will not change the result of
intepolation filter searching, no need to keep the old order.
Change-Id: I047f38face51a4e4cb8684bf1363e32a7389d0de
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 55f5e35..0d72d15 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -8286,77 +8286,6 @@
return 0;
}
-// Find the best rd filter in horizontal direction
-static INLINE int find_best_horiz_interp_filter_rd(
- MACROBLOCK *const x, const AV1_COMP *const cpi, BLOCK_SIZE bsize,
- int mi_row, int mi_col, BUFFER_SET *const orig_dst, int64_t *const rd,
- int *const switchable_rate, int *const skip_txfm_sb,
- int64_t *const skip_sse_sb, const BUFFER_SET *dst_bufs[2],
- const int switchable_ctx[2], const int skip_hor, int *rate, int64_t *dist,
- int best_dual_mode) {
- int i;
- const int bw = block_size_wide[bsize];
- assert(best_dual_mode == 0);
- if ((bw <= 4) && (skip_hor != cpi->default_interp_skip_flags)) {
- int skip_pred = cpi->default_interp_skip_flags;
- // Process the filters in reverse order to enable reusing rate and
- // distortion (calcuated during EIGHTTAP_REGULAR) for MULTITAP_SHARP
- for (i = (SWITCHABLE_FILTERS - 1); i >= 1; --i) {
- if (interpolation_filter_rd(x, cpi, bsize, mi_row, mi_col, orig_dst, rd,
- switchable_rate, skip_txfm_sb, skip_sse_sb,
- dst_bufs, i, switchable_ctx, skip_pred, rate,
- dist)) {
- best_dual_mode = i;
- }
- skip_pred = skip_hor;
- }
- } else {
- for (i = 1; i < SWITCHABLE_FILTERS; ++i) {
- if (interpolation_filter_rd(x, cpi, bsize, mi_row, mi_col, orig_dst, rd,
- switchable_rate, skip_txfm_sb, skip_sse_sb,
- dst_bufs, i, switchable_ctx, skip_hor, rate,
- dist)) {
- best_dual_mode = i;
- }
- }
- }
- return best_dual_mode;
-}
-
-// Find the best rd filter in vertical direction
-static INLINE void find_best_vert_interp_filter_rd(
- MACROBLOCK *const x, const AV1_COMP *const cpi, BLOCK_SIZE bsize,
- int mi_row, int mi_col, BUFFER_SET *const orig_dst, int64_t *const rd,
- int *const switchable_rate, int *const skip_txfm_sb,
- int64_t *const skip_sse_sb, const BUFFER_SET *dst_bufs[2],
- const int switchable_ctx[2], const int skip_ver, int *rate, int64_t *dist,
- int best_dual_mode, int filter_set_size) {
- int i;
- const int bh = block_size_high[bsize];
- if ((bh <= 4) && (skip_ver != cpi->default_interp_skip_flags)) {
- int skip_pred = cpi->default_interp_skip_flags;
- // Process the filters in reverse order to enable reusing rate and
- // distortion (calcuated during EIGHTTAP_REGULAR) for MULTITAP_SHARP
- assert(filter_set_size == DUAL_FILTER_SET_SIZE);
- for (i = (filter_set_size - SWITCHABLE_FILTERS + best_dual_mode);
- i >= (best_dual_mode + SWITCHABLE_FILTERS); i -= SWITCHABLE_FILTERS) {
- interpolation_filter_rd(x, cpi, bsize, mi_row, mi_col, orig_dst, rd,
- switchable_rate, skip_txfm_sb, skip_sse_sb,
- dst_bufs, i, switchable_ctx, skip_pred, rate,
- dist);
- skip_pred = skip_ver;
- }
- } else {
- for (i = best_dual_mode + SWITCHABLE_FILTERS; i < filter_set_size;
- i += SWITCHABLE_FILTERS) {
- interpolation_filter_rd(x, cpi, bsize, mi_row, mi_col, orig_dst, rd,
- switchable_rate, skip_txfm_sb, skip_sse_sb,
- dst_bufs, i, switchable_ctx, skip_ver, rate,
- dist);
- }
- }
-}
-
// Find the best interp filter if dual_interp_filter = 0
static INLINE void find_best_non_dual_interp_filter(
MACROBLOCK *const x, const AV1_COMP *const cpi, BLOCK_SIZE bsize,
@@ -8612,17 +8541,29 @@
// default to (R,R): EIGHTTAP_REGULARxEIGHTTAP_REGULAR
int best_dual_mode = 0;
// Find best of {R}x{R,Sm,Sh}
- // EIGHTTAP_REGULAR mode is calculated beforehand
- best_dual_mode = find_best_horiz_interp_filter_rd(
- x, cpi, bsize, mi_row, mi_col, orig_dst, rd, switchable_rate,
- best_skip_txfm_sb, best_skip_sse_sb, dst_bufs, switchable_ctx, skip_hor,
- tmp_rate, tmp_dist, best_dual_mode);
-
+ const int bw = block_size_wide[bsize];
+ int skip_pred = bw <= 4 ? cpi->default_interp_skip_flags : skip_hor;
+ for (i = (SWITCHABLE_FILTERS - 1); i >= 1; --i) {
+ if (interpolation_filter_rd(x, cpi, bsize, mi_row, mi_col, orig_dst, rd,
+ switchable_rate, best_skip_txfm_sb,
+ best_skip_sse_sb, dst_bufs, i, switchable_ctx,
+ skip_pred, tmp_rate, tmp_dist)) {
+ best_dual_mode = i;
+ }
+ skip_pred = skip_hor;
+ }
// From best of horizontal EIGHTTAP_REGULAR modes, check vertical modes
- find_best_vert_interp_filter_rd(
- x, cpi, bsize, mi_row, mi_col, orig_dst, rd, switchable_rate,
- best_skip_txfm_sb, best_skip_sse_sb, dst_bufs, switchable_ctx, skip_ver,
- tmp_rate, tmp_dist, best_dual_mode, filter_set_size);
+ const int bh = block_size_high[bsize];
+ skip_pred = bh <= 4 ? cpi->default_interp_skip_flags : skip_ver;
+ assert(filter_set_size == DUAL_FILTER_SET_SIZE);
+ for (i = (best_dual_mode + (SWITCHABLE_FILTERS * 2));
+ i >= (best_dual_mode + SWITCHABLE_FILTERS); i -= SWITCHABLE_FILTERS) {
+ interpolation_filter_rd(x, cpi, bsize, mi_row, mi_col, orig_dst, rd,
+ switchable_rate, best_skip_txfm_sb,
+ best_skip_sse_sb, dst_bufs, i, switchable_ctx,
+ skip_pred, tmp_rate, tmp_dist);
+ skip_pred = skip_ver;
+ }
} else if (cm->seq_params.enable_dual_filter == 0) {
find_best_non_dual_interp_filter(
x, cpi, bsize, mi_row, mi_col, orig_dst, rd, switchable_rate,