summaryrefslogtreecommitdiffstats
path: root/third_party/aom/av1/encoder/mcomp.c
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/aom/av1/encoder/mcomp.c')
-rw-r--r--third_party/aom/av1/encoder/mcomp.c1235
1 files changed, 412 insertions, 823 deletions
diff --git a/third_party/aom/av1/encoder/mcomp.c b/third_party/aom/av1/encoder/mcomp.c
index 6c8503da0..c4572a341 100644
--- a/third_party/aom/av1/encoder/mcomp.c
+++ b/third_party/aom/av1/encoder/mcomp.c
@@ -13,8 +13,8 @@
#include <math.h>
#include <stdio.h>
-#include "./aom_config.h"
-#include "./aom_dsp_rtcd.h"
+#include "config/aom_config.h"
+#include "config/aom_dsp_rtcd.h"
#include "aom_dsp/aom_dsp_common.h"
#include "aom_mem/aom_mem.h"
@@ -22,9 +22,11 @@
#include "av1/common/common.h"
#include "av1/common/mvref_common.h"
+#include "av1/common/onyxc_int.h"
#include "av1/common/reconinter.h"
#include "av1/encoder/encoder.h"
+#include "av1/encoder/encodemv.h"
#include "av1/encoder/mcomp.h"
#include "av1/encoder/rdopt.h"
@@ -54,10 +56,9 @@ void av1_set_mv_search_range(MvLimits *mv_limits, const MV *mv) {
if (mv_limits->row_max > row_max) mv_limits->row_max = row_max;
}
-static void av1_set_subpel_mv_search_range(const MvLimits *mv_limits,
- int *col_min, int *col_max,
- int *row_min, int *row_max,
- const MV *ref_mv) {
+static void set_subpel_mv_search_range(const MvLimits *mv_limits, int *col_min,
+ int *col_max, int *row_min, int *row_max,
+ const MV *ref_mv) {
const int max_mv = MAX_FULL_PEL_VAL * 8;
const int minc = AOMMAX(mv_limits->col_min * 8, ref_mv->col - max_mv);
const int maxc = AOMMIN(mv_limits->col_max * 8, ref_mv->col + max_mv);
@@ -172,57 +173,64 @@ void av1_init3smotion_compensation(search_site_config *cfg, int stride) {
static INLINE int sp(int x) { return x & 7; }
static INLINE const uint8_t *pre(const uint8_t *buf, int stride, int r, int c) {
- return &buf[(r >> 3) * stride + (c >> 3)];
+ const int offset = (r >> 3) * stride + (c >> 3);
+ return buf + offset;
}
/* checks if (r, c) has better score than previous best */
-#define CHECK_BETTER(v, r, c) \
- if (c >= minc && c <= maxc && r >= minr && r <= maxr) { \
- MV this_mv = { r, c }; \
- v = mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit); \
- if (second_pred == NULL) \
- thismse = vfp->svf(pre(y, y_stride, r, c), y_stride, sp(c), sp(r), \
- src_address, src_stride, &sse); \
- else if (mask) \
- thismse = vfp->msvf(pre(y, y_stride, r, c), y_stride, sp(c), sp(r), \
- src_address, src_stride, second_pred, mask, \
- mask_stride, invert_mask, &sse); \
- else \
- thismse = vfp->svaf(pre(y, y_stride, r, c), y_stride, sp(c), sp(r), \
- src_address, src_stride, &sse, second_pred); \
- v += thismse; \
- if (v < besterr) { \
- besterr = v; \
- br = r; \
- bc = c; \
- *distortion = thismse; \
- *sse1 = sse; \
- } \
- } else { \
- v = INT_MAX; \
+#define CHECK_BETTER(v, r, c) \
+ if (c >= minc && c <= maxc && r >= minr && r <= maxr) { \
+ MV this_mv = { r, c }; \
+ v = mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit); \
+ if (second_pred == NULL) { \
+ thismse = vfp->svf(pre(y, y_stride, r, c), y_stride, sp(c), sp(r), \
+ src_address, src_stride, &sse); \
+ } else if (mask) { \
+ thismse = vfp->msvf(pre(y, y_stride, r, c), y_stride, sp(c), sp(r), \
+ src_address, src_stride, second_pred, mask, \
+ mask_stride, invert_mask, &sse); \
+ } else { \
+ if (xd->jcp_param.use_jnt_comp_avg) \
+ thismse = vfp->jsvaf(pre(y, y_stride, r, c), y_stride, sp(c), sp(r), \
+ src_address, src_stride, &sse, second_pred, \
+ &xd->jcp_param); \
+ else \
+ thismse = vfp->svaf(pre(y, y_stride, r, c), y_stride, sp(c), sp(r), \
+ src_address, src_stride, &sse, second_pred); \
+ } \
+ v += thismse; \
+ if (v < besterr) { \
+ besterr = v; \
+ br = r; \
+ bc = c; \
+ *distortion = thismse; \
+ *sse1 = sse; \
+ } \
+ } else { \
+ v = INT_MAX; \
}
#define CHECK_BETTER0(v, r, c) CHECK_BETTER(v, r, c)
/* checks if (r, c) has better score than previous best */
-#define CHECK_BETTER1(v, r, c) \
- if (c >= minc && c <= maxc && r >= minr && r <= maxr) { \
- MV this_mv = { r, c }; \
- thismse = upsampled_pref_error(xd, vfp, src_address, src_stride, \
- pre(y, y_stride, r, c), y_stride, sp(c), \
- sp(r), second_pred, mask, mask_stride, \
- invert_mask, w, h, &sse); \
- v = mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit); \
- v += thismse; \
- if (v < besterr) { \
- besterr = v; \
- br = r; \
- bc = c; \
- *distortion = thismse; \
- *sse1 = sse; \
- } \
- } else { \
- v = INT_MAX; \
+#define CHECK_BETTER1(v, r, c) \
+ if (c >= minc && c <= maxc && r >= minr && r <= maxr) { \
+ MV this_mv = { r, c }; \
+ thismse = upsampled_pref_error( \
+ xd, cm, mi_row, mi_col, &this_mv, vfp, src_address, src_stride, \
+ pre(y, y_stride, r, c), y_stride, sp(c), sp(r), second_pred, mask, \
+ mask_stride, invert_mask, w, h, &sse); \
+ v = mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit); \
+ v += thismse; \
+ if (v < besterr) { \
+ besterr = v; \
+ br = r; \
+ bc = c; \
+ *distortion = thismse; \
+ *sse1 = sse; \
+ } \
+ } else { \
+ v = INT_MAX; \
}
#define FIRST_LEVEL_CHECKS \
@@ -294,33 +302,33 @@ static INLINE const uint8_t *pre(const uint8_t *buf, int stride, int r, int c) {
} \
}
-#define SETUP_SUBPEL_SEARCH \
- const uint8_t *const src_address = x->plane[0].src.buf; \
- const int src_stride = x->plane[0].src.stride; \
- const MACROBLOCKD *xd = &x->e_mbd; \
- unsigned int besterr = INT_MAX; \
- unsigned int sse; \
- unsigned int whichdir; \
- int thismse; \
- MV *bestmv = &x->best_mv.as_mv; \
- const unsigned int halfiters = iters_per_step; \
- const unsigned int quarteriters = iters_per_step; \
- const unsigned int eighthiters = iters_per_step; \
- const int y_stride = xd->plane[0].pre[0].stride; \
- const int offset = bestmv->row * y_stride + bestmv->col; \
- const uint8_t *const y = xd->plane[0].pre[0].buf; \
- \
- int br = bestmv->row * 8; \
- int bc = bestmv->col * 8; \
- int hstep = 4; \
- int minc, maxc, minr, maxr; \
- int tr = br; \
- int tc = bc; \
- \
- av1_set_subpel_mv_search_range(&x->mv_limits, &minc, &maxc, &minr, &maxr, \
- ref_mv); \
- \
- bestmv->row *= 8; \
+#define SETUP_SUBPEL_SEARCH \
+ const uint8_t *const src_address = x->plane[0].src.buf; \
+ const int src_stride = x->plane[0].src.stride; \
+ const MACROBLOCKD *xd = &x->e_mbd; \
+ unsigned int besterr = INT_MAX; \
+ unsigned int sse; \
+ unsigned int whichdir; \
+ int thismse; \
+ MV *bestmv = &x->best_mv.as_mv; \
+ const unsigned int halfiters = iters_per_step; \
+ const unsigned int quarteriters = iters_per_step; \
+ const unsigned int eighthiters = iters_per_step; \
+ const int y_stride = xd->plane[0].pre[0].stride; \
+ const int offset = bestmv->row * y_stride + bestmv->col; \
+ const uint8_t *const y = xd->plane[0].pre[0].buf; \
+ \
+ int br = bestmv->row * 8; \
+ int bc = bestmv->col * 8; \
+ int hstep = 4; \
+ int minc, maxc, minr, maxr; \
+ int tr = br; \
+ int tc = bc; \
+ \
+ set_subpel_mv_search_range(&x->mv_limits, &minc, &maxc, &minr, &maxr, \
+ ref_mv); \
+ \
+ bestmv->row *= 8; \
bestmv->col *= 8;
static unsigned int setup_center_error(
@@ -331,25 +339,34 @@ static unsigned int setup_center_error(
int mask_stride, int invert_mask, int w, int h, int offset, int *mvjcost,
int *mvcost[2], unsigned int *sse1, int *distortion) {
unsigned int besterr;
-#if CONFIG_HIGHBITDEPTH
if (second_pred != NULL) {
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
DECLARE_ALIGNED(16, uint16_t, comp_pred16[MAX_SB_SQUARE]);
- if (mask)
+ if (mask) {
aom_highbd_comp_mask_pred(comp_pred16, second_pred, w, h, y + offset,
y_stride, mask, mask_stride, invert_mask);
- else
- aom_highbd_comp_avg_pred(comp_pred16, second_pred, w, h, y + offset,
- y_stride);
+ } else {
+ if (xd->jcp_param.use_jnt_comp_avg)
+ aom_highbd_jnt_comp_avg_pred(comp_pred16, second_pred, w, h,
+ y + offset, y_stride, &xd->jcp_param);
+ else
+ aom_highbd_comp_avg_pred(comp_pred16, second_pred, w, h, y + offset,
+ y_stride);
+ }
besterr =
vfp->vf(CONVERT_TO_BYTEPTR(comp_pred16), w, src, src_stride, sse1);
} else {
DECLARE_ALIGNED(16, uint8_t, comp_pred[MAX_SB_SQUARE]);
- if (mask)
+ if (mask) {
aom_comp_mask_pred(comp_pred, second_pred, w, h, y + offset, y_stride,
mask, mask_stride, invert_mask);
- else
- aom_comp_avg_pred(comp_pred, second_pred, w, h, y + offset, y_stride);
+ } else {
+ if (xd->jcp_param.use_jnt_comp_avg)
+ aom_jnt_comp_avg_pred(comp_pred, second_pred, w, h, y + offset,
+ y_stride, &xd->jcp_param);
+ else
+ aom_comp_avg_pred(comp_pred, second_pred, w, h, y + offset, y_stride);
+ }
besterr = vfp->vf(comp_pred, w, src, src_stride, sse1);
}
} else {
@@ -357,22 +374,6 @@ static unsigned int setup_center_error(
}
*distortion = besterr;
besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit);
-#else
- (void)xd;
- if (second_pred != NULL) {
- DECLARE_ALIGNED(16, uint8_t, comp_pred[MAX_SB_SQUARE]);
- if (mask)
- aom_comp_mask_pred(comp_pred, second_pred, w, h, y + offset, y_stride,
- mask, mask_stride, invert_mask);
- else
- aom_comp_avg_pred(comp_pred, second_pred, w, h, y + offset, y_stride);
- besterr = vfp->vf(comp_pred, w, src, src_stride, sse1);
- } else {
- besterr = vfp->vf(y + offset, y_stride, src, src_stride, sse1);
- }
- *distortion = besterr;
- besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit);
-#endif // CONFIG_HIGHBITDEPTH
return besterr;
}
@@ -401,11 +402,13 @@ static void get_cost_surf_min(int *cost_list, int *ir, int *ic, int bits) {
}
int av1_find_best_sub_pixel_tree_pruned_evenmore(
- MACROBLOCK *x, const MV *ref_mv, int allow_hp, int error_per_bit,
+ MACROBLOCK *x, const AV1_COMMON *const cm, int mi_row, int mi_col,
+ const MV *ref_mv, int allow_hp, int error_per_bit,
const aom_variance_fn_ptr_t *vfp, int forced_stop, int iters_per_step,
int *cost_list, int *mvjcost, int *mvcost[2], int *distortion,
unsigned int *sse1, const uint8_t *second_pred, const uint8_t *mask,
- int mask_stride, int invert_mask, int w, int h, int use_upsampled_ref) {
+ int mask_stride, int invert_mask, int w, int h,
+ int use_accurate_subpel_search) {
SETUP_SUBPEL_SEARCH;
besterr = setup_center_error(xd, bestmv, ref_mv, error_per_bit, vfp,
src_address, src_stride, y, y_stride,
@@ -418,7 +421,10 @@ int av1_find_best_sub_pixel_tree_pruned_evenmore(
(void)allow_hp;
(void)forced_stop;
(void)hstep;
- (void)use_upsampled_ref;
+ (void)use_accurate_subpel_search;
+ (void)cm;
+ (void)mi_row;
+ (void)mi_col;
if (cost_list && cost_list[0] != INT_MAX && cost_list[1] != INT_MAX &&
cost_list[2] != INT_MAX && cost_list[3] != INT_MAX &&
@@ -468,13 +474,18 @@ int av1_find_best_sub_pixel_tree_pruned_evenmore(
}
int av1_find_best_sub_pixel_tree_pruned_more(
- MACROBLOCK *x, const MV *ref_mv, int allow_hp, int error_per_bit,
+ MACROBLOCK *x, const AV1_COMMON *const cm, int mi_row, int mi_col,
+ const MV *ref_mv, int allow_hp, int error_per_bit,
const aom_variance_fn_ptr_t *vfp, int forced_stop, int iters_per_step,
int *cost_list, int *mvjcost, int *mvcost[2], int *distortion,
unsigned int *sse1, const uint8_t *second_pred, const uint8_t *mask,
- int mask_stride, int invert_mask, int w, int h, int use_upsampled_ref) {
+ int mask_stride, int invert_mask, int w, int h,
+ int use_accurate_subpel_search) {
SETUP_SUBPEL_SEARCH;
- (void)use_upsampled_ref;
+ (void)use_accurate_subpel_search;
+ (void)cm;
+ (void)mi_row;
+ (void)mi_col;
besterr = setup_center_error(xd, bestmv, ref_mv, error_per_bit, vfp,
src_address, src_stride, y, y_stride,
@@ -531,13 +542,18 @@ int av1_find_best_sub_pixel_tree_pruned_more(
}
int av1_find_best_sub_pixel_tree_pruned(
- MACROBLOCK *x, const MV *ref_mv, int allow_hp, int error_per_bit,
+ MACROBLOCK *x, const AV1_COMMON *const cm, int mi_row, int mi_col,
+ const MV *ref_mv, int allow_hp, int error_per_bit,
const aom_variance_fn_ptr_t *vfp, int forced_stop, int iters_per_step,
int *cost_list, int *mvjcost, int *mvcost[2], int *distortion,
unsigned int *sse1, const uint8_t *second_pred, const uint8_t *mask,
- int mask_stride, int invert_mask, int w, int h, int use_upsampled_ref) {
+ int mask_stride, int invert_mask, int w, int h,
+ int use_accurate_subpel_search) {
SETUP_SUBPEL_SEARCH;
- (void)use_upsampled_ref;
+ (void)use_accurate_subpel_search;
+ (void)cm;
+ (void)mi_row;
+ (void)mi_col;
besterr = setup_center_error(xd, bestmv, ref_mv, error_per_bit, vfp,
src_address, src_stride, y, y_stride,
@@ -624,7 +640,8 @@ static const MV search_step_table[12] = {
};
/* clang-format on */
-static int upsampled_pref_error(const MACROBLOCKD *xd,
+static int upsampled_pref_error(MACROBLOCKD *xd, const AV1_COMMON *const cm,
+ int mi_row, int mi_col, const MV *const mv,
const aom_variance_fn_ptr_t *vfp,
const uint8_t *const src, const int src_stride,
const uint8_t *const y, int y_stride,
@@ -633,73 +650,105 @@ static int upsampled_pref_error(const MACROBLOCKD *xd,
int mask_stride, int invert_mask, int w, int h,
unsigned int *sse) {
unsigned int besterr;
-#if CONFIG_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
DECLARE_ALIGNED(16, uint16_t, pred16[MAX_SB_SQUARE]);
if (second_pred != NULL) {
- if (mask)
+ if (mask) {
aom_highbd_comp_mask_upsampled_pred(
- pred16, second_pred, w, h, subpel_x_q3, subpel_y_q3, y, y_stride,
- mask, mask_stride, invert_mask, xd->bd);
- else
- aom_highbd_comp_avg_upsampled_pred(pred16, second_pred, w, h,
- subpel_x_q3, subpel_y_q3, y,
- y_stride, xd->bd);
+ xd, cm, mi_row, mi_col, mv, pred16, second_pred, w, h, subpel_x_q3,
+ subpel_y_q3, y, y_stride, mask, mask_stride, invert_mask, xd->bd);
+ } else {
+ if (xd->jcp_param.use_jnt_comp_avg)
+ aom_highbd_jnt_comp_avg_upsampled_pred(
+ xd, cm, mi_row, mi_col, mv, pred16, second_pred, w, h,
+ subpel_x_q3, subpel_y_q3, y, y_stride, xd->bd, &xd->jcp_param);
+ else
+ aom_highbd_comp_avg_upsampled_pred(xd, cm, mi_row, mi_col, mv, pred16,
+ second_pred, w, h, subpel_x_q3,
+ subpel_y_q3, y, y_stride, xd->bd);
+ }
} else {
- aom_highbd_upsampled_pred(pred16, w, h, subpel_x_q3, subpel_y_q3, y,
- y_stride, xd->bd);
+ aom_highbd_upsampled_pred(xd, cm, mi_row, mi_col, mv, pred16, w, h,
+ subpel_x_q3, subpel_y_q3, y, y_stride, xd->bd);
}
besterr = vfp->vf(CONVERT_TO_BYTEPTR(pred16), w, src, src_stride, sse);
} else {
DECLARE_ALIGNED(16, uint8_t, pred[MAX_SB_SQUARE]);
-#else
- DECLARE_ALIGNED(16, uint8_t, pred[MAX_SB_SQUARE]);
- (void)xd;
-#endif // CONFIG_HIGHBITDEPTH
if (second_pred != NULL) {
- if (mask)
- aom_comp_mask_upsampled_pred(pred, second_pred, w, h, subpel_x_q3,
- subpel_y_q3, y, y_stride, mask,
- mask_stride, invert_mask);
- else
- aom_comp_avg_upsampled_pred(pred, second_pred, w, h, subpel_x_q3,
- subpel_y_q3, y, y_stride);
+ if (mask) {
+ aom_comp_mask_upsampled_pred(
+ xd, cm, mi_row, mi_col, mv, pred, second_pred, w, h, subpel_x_q3,
+ subpel_y_q3, y, y_stride, mask, mask_stride, invert_mask);
+ } else {
+ if (xd->jcp_param.use_jnt_comp_avg)
+ aom_jnt_comp_avg_upsampled_pred(
+ xd, cm, mi_row, mi_col, mv, pred, second_pred, w, h, subpel_x_q3,
+ subpel_y_q3, y, y_stride, &xd->jcp_param);
+ else
+ aom_comp_avg_upsampled_pred(xd, cm, mi_row, mi_col, mv, pred,
+ second_pred, w, h, subpel_x_q3,
+ subpel_y_q3, y, y_stride);
+ }
} else {
- aom_upsampled_pred(pred, w, h, subpel_x_q3, subpel_y_q3, y, y_stride);
+ aom_upsampled_pred(xd, cm, mi_row, mi_col, mv, pred, w, h, subpel_x_q3,
+ subpel_y_q3, y, y_stride);
}
besterr = vfp->vf(pred, w, src, src_stride, sse);
-#if CONFIG_HIGHBITDEPTH
}
-#endif
return besterr;
}
static unsigned int upsampled_setup_center_error(
- const MACROBLOCKD *xd, const MV *bestmv, const MV *ref_mv,
- int error_per_bit, const aom_variance_fn_ptr_t *vfp,
- const uint8_t *const src, const int src_stride, const uint8_t *const y,
- int y_stride, const uint8_t *second_pred, const uint8_t *mask,
- int mask_stride, int invert_mask, int w, int h, int offset, int *mvjcost,
- int *mvcost[2], unsigned int *sse1, int *distortion) {
+ MACROBLOCKD *xd, const AV1_COMMON *const cm, int mi_row, int mi_col,
+ const MV *bestmv, const MV *ref_mv, int error_per_bit,
+ const aom_variance_fn_ptr_t *vfp, const uint8_t *const src,
+ const int src_stride, const uint8_t *const y, int y_stride,
+ const uint8_t *second_pred, const uint8_t *mask, int mask_stride,
+ int invert_mask, int w, int h, int offset, int *mvjcost, int *mvcost[2],
+ unsigned int *sse1, int *distortion) {
unsigned int besterr = upsampled_pref_error(
- xd, vfp, src, src_stride, y + offset, y_stride, 0, 0, second_pred, mask,
- mask_stride, invert_mask, w, h, sse1);
+ xd, cm, mi_row, mi_col, bestmv, vfp, src, src_stride, y + offset,
+ y_stride, 0, 0, second_pred, mask, mask_stride, invert_mask, w, h, sse1);
*distortion = besterr;
besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit);
return besterr;
}
+// when use_accurate_subpel_search == 0
+static INLINE unsigned int estimate_upsampled_pref_error(
+ MACROBLOCKD *xd, const aom_variance_fn_ptr_t *vfp, const uint8_t *const src,
+ const int src_stride, const uint8_t *const pre, int y_stride,
+ int subpel_x_q3, int subpel_y_q3, const uint8_t *second_pred,
+ const uint8_t *mask, int mask_stride, int invert_mask, unsigned int *sse) {
+ if (second_pred == NULL) {
+ return vfp->svf(pre, y_stride, subpel_x_q3, subpel_y_q3, src, src_stride,
+ sse);
+ } else if (mask) {
+ return vfp->msvf(pre, y_stride, subpel_x_q3, subpel_y_q3, src, src_stride,
+ second_pred, mask, mask_stride, invert_mask, sse);
+ } else {
+ if (xd->jcp_param.use_jnt_comp_avg)
+ return vfp->jsvaf(pre, y_stride, subpel_x_q3, subpel_y_q3, src,
+ src_stride, sse, second_pred, &xd->jcp_param);
+ else
+ return vfp->svaf(pre, y_stride, subpel_x_q3, subpel_y_q3, src, src_stride,
+ sse, second_pred);
+ }
+}
+
int av1_find_best_sub_pixel_tree(
- MACROBLOCK *x, const MV *ref_mv, int allow_hp, int error_per_bit,
+ MACROBLOCK *x, const AV1_COMMON *const cm, int mi_row, int mi_col,
+ const MV *ref_mv, int allow_hp, int error_per_bit,
const aom_variance_fn_ptr_t *vfp, int forced_stop, int iters_per_step,
int *cost_list, int *mvjcost, int *mvcost[2], int *distortion,
unsigned int *sse1, const uint8_t *second_pred, const uint8_t *mask,
- int mask_stride, int invert_mask, int w, int h, int use_upsampled_ref) {
+ int mask_stride, int invert_mask, int w, int h,
+ int use_accurate_subpel_search) {
const uint8_t *const src_address = x->plane[0].src.buf;
const int src_stride = x->plane[0].src.stride;
- const MACROBLOCKD *xd = &x->e_mbd;
+ MACROBLOCKD *xd = &x->e_mbd;
unsigned int besterr = INT_MAX;
unsigned int sse;
unsigned int thismse;
@@ -720,8 +769,7 @@ int av1_find_best_sub_pixel_tree(
int kr, kc;
int minc, maxc, minr, maxr;
- av1_set_subpel_mv_search_range(&x->mv_limits, &minc, &maxc, &minr, &maxr,
- ref_mv);
+ set_subpel_mv_search_range(&x->mv_limits, &minc, &maxc, &minr, &maxr, ref_mv);
if (!allow_hp)
if (round == 3) round = 2;
@@ -729,12 +777,11 @@ int av1_find_best_sub_pixel_tree(
bestmv->row *= 8;
bestmv->col *= 8;
- // use_upsampled_ref can be 0 or 1
- if (use_upsampled_ref)
+ if (use_accurate_subpel_search)
besterr = upsampled_setup_center_error(
- xd, bestmv, ref_mv, error_per_bit, vfp, src_address, src_stride, y,
- y_stride, second_pred, mask, mask_stride, invert_mask, w, h, offset,
- mvjcost, mvcost, sse1, distortion);
+ xd, cm, mi_row, mi_col, bestmv, ref_mv, error_per_bit, vfp, src_address,
+ src_stride, y, y_stride, second_pred, mask, mask_stride, invert_mask, w,
+ h, offset, mvjcost, mvcost, sse1, distortion);
else
besterr = setup_center_error(xd, bestmv, ref_mv, error_per_bit, vfp,
src_address, src_stride, y, y_stride,
@@ -751,23 +798,16 @@ int av1_find_best_sub_pixel_tree(
if (tc >= minc && tc <= maxc && tr >= minr && tr <= maxr) {
MV this_mv = { tr, tc };
- if (use_upsampled_ref) {
- thismse = upsampled_pref_error(xd, vfp, src_address, src_stride,
- pre(y, y_stride, tr, tc), y_stride,
- sp(tc), sp(tr), second_pred, mask,
- mask_stride, invert_mask, w, h, &sse);
+ if (use_accurate_subpel_search) {
+ thismse = upsampled_pref_error(
+ xd, cm, mi_row, mi_col, &this_mv, vfp, src_address, src_stride,
+ pre(y, y_stride, tr, tc), y_stride, sp(tc), sp(tr), second_pred,
+ mask, mask_stride, invert_mask, w, h, &sse);
} else {
- const uint8_t *const pre_address = pre(y, y_stride, tr, tc);
- if (second_pred == NULL)
- thismse = vfp->svf(pre_address, y_stride, sp(tc), sp(tr),
- src_address, src_stride, &sse);
- else if (mask)
- thismse = vfp->msvf(pre_address, y_stride, sp(tc), sp(tr),
- src_address, src_stride, second_pred, mask,
- mask_stride, invert_mask, &sse);
- else
- thismse = vfp->svaf(pre_address, y_stride, sp(tc), sp(tr),
- src_address, src_stride, &sse, second_pred);
+ thismse = estimate_upsampled_pref_error(
+ xd, vfp, src_address, src_stride, pre(y, y_stride, tr, tc),
+ y_stride, sp(tc), sp(tr), second_pred, mask, mask_stride,
+ invert_mask, &sse);
}
cost_array[idx] = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost,
@@ -793,24 +833,16 @@ int av1_find_best_sub_pixel_tree(
if (tc >= minc && tc <= maxc && tr >= minr && tr <= maxr) {
MV this_mv = { tr, tc };
- if (use_upsampled_ref) {
- thismse = upsampled_pref_error(xd, vfp, src_address, src_stride,
- pre(y, y_stride, tr, tc), y_stride,
- sp(tc), sp(tr), second_pred, mask,
- mask_stride, invert_mask, w, h, &sse);
+ if (use_accurate_subpel_search) {
+ thismse = upsampled_pref_error(
+ xd, cm, mi_row, mi_col, &this_mv, vfp, src_address, src_stride,
+ pre(y, y_stride, tr, tc), y_stride, sp(tc), sp(tr), second_pred,
+ mask, mask_stride, invert_mask, w, h, &sse);
} else {
- const uint8_t *const pre_address = pre(y, y_stride, tr, tc);
-
- if (second_pred == NULL)
- thismse = vfp->svf(pre_address, y_stride, sp(tc), sp(tr), src_address,
- src_stride, &sse);
- else if (mask)
- thismse = vfp->msvf(pre_address, y_stride, sp(tc), sp(tr),
- src_address, src_stride, second_pred, mask,
- mask_stride, invert_mask, &sse);
- else
- thismse = vfp->svaf(pre_address, y_stride, sp(tc), sp(tr),
- src_address, src_stride, &sse, second_pred);
+ thismse = estimate_upsampled_pref_error(
+ xd, vfp, src_address, src_stride, pre(y, y_stride, tr, tc),
+ y_stride, sp(tc), sp(tr), second_pred, mask, mask_stride,
+ invert_mask, &sse);
}
cost_array[4] = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost,
@@ -835,7 +867,7 @@ int av1_find_best_sub_pixel_tree(
}
if (iters_per_step > 1 && best_idx != -1) {
- if (use_upsampled_ref) {
+ if (use_accurate_subpel_search) {
SECOND_LEVEL_CHECKS_BEST(1);
} else {
SECOND_LEVEL_CHECKS_BEST(0);
@@ -861,63 +893,51 @@ int av1_find_best_sub_pixel_tree(
#undef PRE
#undef CHECK_BETTER
-#if CONFIG_WARPED_MOTION
unsigned int av1_compute_motion_cost(const AV1_COMP *cpi, MACROBLOCK *const x,
BLOCK_SIZE bsize, int mi_row, int mi_col,
const MV *this_mv) {
const AV1_COMMON *const cm = &cpi->common;
MACROBLOCKD *xd = &x->e_mbd;
- MODE_INFO *mi = xd->mi[0];
- MB_MODE_INFO *mbmi = &mi->mbmi;
const uint8_t *const src = x->plane[0].src.buf;
const int src_stride = x->plane[0].src.stride;
uint8_t *const dst = xd->plane[0].dst.buf;
const int dst_stride = xd->plane[0].dst.stride;
const aom_variance_fn_ptr_t *vfp = &cpi->fn_ptr[bsize];
- const MV ref_mv = x->mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0].as_mv;
+ const int_mv ref_mv = av1_get_ref_mv(x, 0);
unsigned int mse;
unsigned int sse;
av1_build_inter_predictors_sby(cm, xd, mi_row, mi_col, NULL, bsize);
mse = vfp->vf(dst, dst_stride, src, src_stride, &sse);
- mse +=
- mv_err_cost(this_mv, &ref_mv, x->nmvjointcost, x->mvcost, x->errorperbit);
+ mse += mv_err_cost(this_mv, &ref_mv.as_mv, x->nmvjointcost, x->mvcost,
+ x->errorperbit);
return mse;
}
// Refine MV in a small range
-#if WARPED_MOTION_SORT_SAMPLES
unsigned int av1_refine_warped_mv(const AV1_COMP *cpi, MACROBLOCK *const x,
BLOCK_SIZE bsize, int mi_row, int mi_col,
- int *pts0, int *pts_inref0, int *pts_mv0,
+ int *pts0, int *pts_inref0,
int total_samples) {
-#else
-unsigned int av1_refine_warped_mv(const AV1_COMP *cpi, MACROBLOCK *const x,
- BLOCK_SIZE bsize, int mi_row, int mi_col,
- int *pts, int *pts_inref) {
-#endif // WARPED_MOTION_SORT_SAMPLES
const AV1_COMMON *const cm = &cpi->common;
MACROBLOCKD *xd = &x->e_mbd;
- MODE_INFO *mi = xd->mi[0];
- MB_MODE_INFO *mbmi = &mi->mbmi;
+ MB_MODE_INFO *mbmi = xd->mi[0];
const MV neighbors[8] = { { 0, -1 }, { 1, 0 }, { 0, 1 }, { -1, 0 },
{ 0, -2 }, { 2, 0 }, { 0, 2 }, { -2, 0 } };
- const MV ref_mv = x->mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0].as_mv;
+ const int_mv ref_mv = av1_get_ref_mv(x, 0);
int16_t br = mbmi->mv[0].as_mv.row;
int16_t bc = mbmi->mv[0].as_mv.col;
int16_t *tr = &mbmi->mv[0].as_mv.row;
int16_t *tc = &mbmi->mv[0].as_mv.col;
WarpedMotionParams best_wm_params = mbmi->wm_params[0];
-#if WARPED_MOTION_SORT_SAMPLES
int best_num_proj_ref = mbmi->num_proj_ref[0];
-#endif // WARPED_MOTION_SORT_SAMPLES
unsigned int bestmse;
int minc, maxc, minr, maxr;
const int start = cm->allow_high_precision_mv ? 0 : 4;
int ite;
- av1_set_subpel_mv_search_range(&x->mv_limits, &minc, &maxc, &minr, &maxr,
- &ref_mv);
+ set_subpel_mv_search_range(&x->mv_limits, &minc, &maxc, &minr, &maxr,
+ &ref_mv.as_mv);
// Calculate the center position's error
assert(bc >= minc && bc <= maxc && br >= minr && br <= maxr);
@@ -937,15 +957,13 @@ unsigned int av1_refine_warped_mv(const AV1_COMP *cpi, MACROBLOCK *const x,
if (*tc >= minc && *tc <= maxc && *tr >= minr && *tr <= maxr) {
MV this_mv = { *tr, *tc };
-#if WARPED_MOTION_SORT_SAMPLES
int pts[SAMPLES_ARRAY_SIZE], pts_inref[SAMPLES_ARRAY_SIZE];
memcpy(pts, pts0, total_samples * 2 * sizeof(*pts0));
memcpy(pts_inref, pts_inref0, total_samples * 2 * sizeof(*pts_inref0));
if (total_samples > 1)
mbmi->num_proj_ref[0] =
- sortSamples(pts_mv0, &this_mv, pts, pts_inref, total_samples);
-#endif // WARPED_MOTION_SORT_SAMPLES
+ selectSamples(&this_mv, pts, pts_inref, total_samples, bsize);
if (!find_projection(mbmi->num_proj_ref[0], pts, pts_inref, bsize, *tr,
*tc, &mbmi->wm_params[0], mi_row, mi_col)) {
@@ -955,9 +973,7 @@ unsigned int av1_refine_warped_mv(const AV1_COMP *cpi, MACROBLOCK *const x,
if (thismse < bestmse) {
best_idx = idx;
best_wm_params = mbmi->wm_params[0];
-#if WARPED_MOTION_SORT_SAMPLES
best_num_proj_ref = mbmi->num_proj_ref[0];
-#endif // WARPED_MOTION_SORT_SAMPLES
bestmse = thismse;
}
}
@@ -975,12 +991,9 @@ unsigned int av1_refine_warped_mv(const AV1_COMP *cpi, MACROBLOCK *const x,
*tr = br;
*tc = bc;
mbmi->wm_params[0] = best_wm_params;
-#if WARPED_MOTION_SORT_SAMPLES
mbmi->num_proj_ref[0] = best_num_proj_ref;
-#endif // WARPED_MOTION_SORT_SAMPLES
return bestmse;
}
-#endif // CONFIG_WARPED_MOTION
static INLINE int check_bounds(const MvLimits *mv_limits, int row, int col,
int range) {
@@ -1386,11 +1399,19 @@ int av1_get_mvpred_av_var(const MACROBLOCK *x, const MV *best_mv,
const MV mv = { best_mv->row * 8, best_mv->col * 8 };
unsigned int unused;
- return vfp->svaf(get_buf_from_mv(in_what, best_mv), in_what->stride, 0, 0,
- what->buf, what->stride, &unused, second_pred) +
- (use_mvcost ? mv_err_cost(&mv, center_mv, x->nmvjointcost, x->mvcost,
- x->errorperbit)
- : 0);
+ if (xd->jcp_param.use_jnt_comp_avg)
+ return vfp->jsvaf(get_buf_from_mv(in_what, best_mv), in_what->stride, 0, 0,
+ what->buf, what->stride, &unused, second_pred,
+ &xd->jcp_param) +
+ (use_mvcost ? mv_err_cost(&mv, center_mv, x->nmvjointcost, x->mvcost,
+ x->errorperbit)
+ : 0);
+ else
+ return vfp->svaf(get_buf_from_mv(in_what, best_mv), in_what->stride, 0, 0,
+ what->buf, what->stride, &unused, second_pred) +
+ (use_mvcost ? mv_err_cost(&mv, center_mv, x->nmvjointcost, x->mvcost,
+ x->errorperbit)
+ : 0);
}
int av1_get_mvpred_mask_var(const MACROBLOCK *x, const MV *best_mv,
@@ -1785,205 +1806,6 @@ int av1_diamond_search_sad_c(MACROBLOCK *x, const search_site_config *cfg,
return bestsad;
}
-static int vector_match(int16_t *ref, int16_t *src, int bwl) {
- int best_sad = INT_MAX;
- int this_sad;
- int d;
- int center, offset = 0;
- int bw = 4 << bwl; // redundant variable, to be changed in the experiments.
- for (d = 0; d <= bw; d += 16) {
- this_sad = aom_vector_var(&ref[d], src, bwl);
- if (this_sad < best_sad) {
- best_sad = this_sad;
- offset = d;
- }
- }
- center = offset;
-
- for (d = -8; d <= 8; d += 16) {
- int this_pos = offset + d;
- // check limit
- if (this_pos < 0 || this_pos > bw) continue;
- this_sad = aom_vector_var(&ref[this_pos], src, bwl);
- if (this_sad < best_sad) {
- best_sad = this_sad;
- center = this_pos;
- }
- }
- offset = center;
-
- for (d = -4; d <= 4; d += 8) {
- int this_pos = offset + d;
- // check limit
- if (this_pos < 0 || this_pos > bw) continue;
- this_sad = aom_vector_var(&ref[this_pos], src, bwl);
- if (this_sad < best_sad) {
- best_sad = this_sad;
- center = this_pos;
- }
- }
- offset = center;
-
- for (d = -2; d <= 2; d += 4) {
- int this_pos = offset + d;
- // check limit
- if (this_pos < 0 || this_pos > bw) continue;
- this_sad = aom_vector_var(&ref[this_pos], src, bwl);
- if (this_sad < best_sad) {
- best_sad = this_sad;
- center = this_pos;
- }
- }
- offset = center;
-
- for (d = -1; d <= 1; d += 2) {
- int this_pos = offset + d;
- // check limit
- if (this_pos < 0 || this_pos > bw) continue;
- this_sad = aom_vector_var(&ref[this_pos], src, bwl);
- if (this_sad < best_sad) {
- best_sad = this_sad;
- center = this_pos;
- }
- }
-
- return (center - (bw >> 1));
-}
-
-static const MV search_pos[4] = {
- { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 },
-};
-
-unsigned int av1_int_pro_motion_estimation(const AV1_COMP *cpi, MACROBLOCK *x,
- BLOCK_SIZE bsize, int mi_row,
- int mi_col) {
- MACROBLOCKD *xd = &x->e_mbd;
- MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
- struct buf_2d backup_yv12[MAX_MB_PLANE] = { { 0, 0, 0, 0, 0 } };
- DECLARE_ALIGNED(16, int16_t, hbuf[2 * MAX_SB_SIZE]);
- DECLARE_ALIGNED(16, int16_t, vbuf[2 * MAX_SB_SIZE]);
- DECLARE_ALIGNED(16, int16_t, src_hbuf[MAX_SB_SQUARE]);
- DECLARE_ALIGNED(16, int16_t, src_vbuf[MAX_SB_SQUARE]);
- int idx;
- const int src_stride = x->plane[0].src.stride;
- const int ref_stride = xd->plane[0].pre[0].stride;
- uint8_t const *ref_buf, *src_buf;
- MV *tmp_mv = &xd->mi[0]->mbmi.mv[0].as_mv;
- unsigned int best_sad, tmp_sad, sad_arr[4];
- MV this_mv;
- const YV12_BUFFER_CONFIG *scaled_ref_frame =
- av1_get_scaled_ref_frame(cpi, mbmi->ref_frame[0]);
-
- if (scaled_ref_frame) {
- int i;
- // Swap out the reference frame for a version that's been scaled to
- // match the resolution of the current frame, allowing the existing
- // motion search code to be used without additional modifications.
- for (i = 0; i < MAX_MB_PLANE; i++) backup_yv12[i] = xd->plane[i].pre[0];
- av1_setup_pre_planes(xd, 0, scaled_ref_frame, mi_row, mi_col, NULL);
- }
-
-#if CONFIG_HIGHBITDEPTH
- {
- unsigned int this_sad;
- tmp_mv->row = 0;
- tmp_mv->col = 0;
- this_sad = cpi->fn_ptr[bsize].sdf(x->plane[0].src.buf, src_stride,
- xd->plane[0].pre[0].buf, ref_stride);
-
- if (scaled_ref_frame) {
- int i;
- for (i = 0; i < MAX_MB_PLANE; i++) xd->plane[i].pre[0] = backup_yv12[i];
- }
- return this_sad;
- }
-#endif
-
- const int bw = 4 << b_width_log2_lookup[bsize];
- const int bh = 4 << b_height_log2_lookup[bsize];
- const int search_width = bw << 1;
- const int search_height = bh << 1;
- const int norm_factor = 3 + (bw >> 5);
-
- // Set up prediction 1-D reference set
- ref_buf = xd->plane[0].pre[0].buf - (bw >> 1);
- for (idx = 0; idx < search_width; idx += 16) {
- aom_int_pro_row(&hbuf[idx], ref_buf, ref_stride, bh);
- ref_buf += 16;
- }
-
- ref_buf = xd->plane[0].pre[0].buf - (bh >> 1) * ref_stride;
- for (idx = 0; idx < search_height; ++idx) {
- vbuf[idx] = aom_int_pro_col(ref_buf, bw) >> norm_factor;
- ref_buf += ref_stride;
- }
-
- // Set up src 1-D reference set
- for (idx = 0; idx < bw; idx += 16) {
- src_buf = x->plane[0].src.buf + idx;
- aom_int_pro_row(&src_hbuf[idx], src_buf, src_stride, bh);
- }
-
- src_buf = x->plane[0].src.buf;
- for (idx = 0; idx < bh; ++idx) {
- src_vbuf[idx] = aom_int_pro_col(src_buf, bw) >> norm_factor;
- src_buf += src_stride;
- }
-
- // Find the best match per 1-D search
- tmp_mv->col = vector_match(hbuf, src_hbuf, b_width_log2_lookup[bsize]);
- tmp_mv->row = vector_match(vbuf, src_vbuf, b_height_log2_lookup[bsize]);
-
- this_mv = *tmp_mv;
- src_buf = x->plane[0].src.buf;
- ref_buf = xd->plane[0].pre[0].buf + this_mv.row * ref_stride + this_mv.col;
- best_sad = cpi->fn_ptr[bsize].sdf(src_buf, src_stride, ref_buf, ref_stride);
-
- {
- const uint8_t *const pos[4] = {
- ref_buf - ref_stride, ref_buf - 1, ref_buf + 1, ref_buf + ref_stride,
- };
-
- cpi->fn_ptr[bsize].sdx4df(src_buf, src_stride, pos, ref_stride, sad_arr);
- }
-
- for (idx = 0; idx < 4; ++idx) {
- if (sad_arr[idx] < best_sad) {
- best_sad = sad_arr[idx];
- tmp_mv->row = search_pos[idx].row + this_mv.row;
- tmp_mv->col = search_pos[idx].col + this_mv.col;
- }
- }
-
- if (sad_arr[0] < sad_arr[3])
- this_mv.row -= 1;
- else
- this_mv.row += 1;
-
- if (sad_arr[1] < sad_arr[2])
- this_mv.col -= 1;
- else
- this_mv.col += 1;
-
- ref_buf = xd->plane[0].pre[0].buf + this_mv.row * ref_stride + this_mv.col;
-
- tmp_sad = cpi->fn_ptr[bsize].sdf(src_buf, src_stride, ref_buf, ref_stride);
- if (best_sad > tmp_sad) {
- *tmp_mv = this_mv;
- best_sad = tmp_sad;
- }
-
- tmp_mv->row *= 8;
- tmp_mv->col *= 8;
-
- if (scaled_ref_frame) {
- int i;
- for (i = 0; i < MAX_MB_PLANE; i++) xd->plane[i].pre[0] = backup_yv12[i];
- }
-
- return best_sad;
-}
-
/* do_refine: If last step (1-away) of n-step search doesn't pick the center
point as the best match, we will do a final 1-away diamond
refining search */
@@ -2110,197 +1932,6 @@ static int full_pixel_exhaustive(const AV1_COMP *const cpi, MACROBLOCK *x,
return bestsme;
}
-int av1_full_search_sad_c(const MACROBLOCK *x, const MV *ref_mv,
- int sad_per_bit, int distance,
- const aom_variance_fn_ptr_t *fn_ptr,
- const MV *center_mv, MV *best_mv) {
- int r, c;
- const MACROBLOCKD *const xd = &x->e_mbd;
- const struct buf_2d *const what = &x->plane[0].src;
- const struct buf_2d *const in_what = &xd->plane[0].pre[0];
- const int row_min = AOMMAX(ref_mv->row - distance, x->mv_limits.row_min);
- const int row_max = AOMMIN(ref_mv->row + distance, x->mv_limits.row_max);
- const int col_min = AOMMAX(ref_mv->col - distance, x->mv_limits.col_min);
- const int col_max = AOMMIN(ref_mv->col + distance, x->mv_limits.col_max);
- const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 };
- int best_sad =
- fn_ptr->sdf(what->buf, what->stride, get_buf_from_mv(in_what, ref_mv),
- in_what->stride) +
- mvsad_err_cost(x, ref_mv, &fcenter_mv, sad_per_bit);
- *best_mv = *ref_mv;
-
- for (r = row_min; r < row_max; ++r) {
- for (c = col_min; c < col_max; ++c) {
- const MV mv = { r, c };
- const int sad =
- fn_ptr->sdf(what->buf, what->stride, get_buf_from_mv(in_what, &mv),
- in_what->stride) +
- mvsad_err_cost(x, &mv, &fcenter_mv, sad_per_bit);
- if (sad < best_sad) {
- best_sad = sad;
- *best_mv = mv;
- }
- }
- }
- return best_sad;
-}
-
-int av1_full_search_sadx3(const MACROBLOCK *x, const MV *ref_mv,
- int sad_per_bit, int distance,
- const aom_variance_fn_ptr_t *fn_ptr,
- const MV *center_mv, MV *best_mv) {
- int r;
- const MACROBLOCKD *const xd = &x->e_mbd;
- const struct buf_2d *const what = &x->plane[0].src;
- const struct buf_2d *const in_what = &xd->plane[0].pre[0];
- const int row_min = AOMMAX(ref_mv->row - distance, x->mv_limits.row_min);
- const int row_max = AOMMIN(ref_mv->row + distance, x->mv_limits.row_max);
- const int col_min = AOMMAX(ref_mv->col - distance, x->mv_limits.col_min);
- const int col_max = AOMMIN(ref_mv->col + distance, x->mv_limits.col_max);
- const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 };
- unsigned int best_sad =
- fn_ptr->sdf(what->buf, what->stride, get_buf_from_mv(in_what, ref_mv),
- in_what->stride) +
- mvsad_err_cost(x, ref_mv, &fcenter_mv, sad_per_bit);
- *best_mv = *ref_mv;
-
- for (r = row_min; r < row_max; ++r) {
- int c = col_min;
- const uint8_t *check_here = &in_what->buf[r * in_what->stride + c];
-
- if (fn_ptr->sdx3f != NULL) {
- while ((c + 2) < col_max) {
- int i;
- DECLARE_ALIGNED(16, uint32_t, sads[3]);
-
- fn_ptr->sdx3f(what->buf, what->stride, check_here, in_what->stride,
- sads);
-
- for (i = 0; i < 3; ++i) {
- unsigned int sad = sads[i];
- if (sad < best_sad) {
- const MV mv = { r, c };
- sad += mvsad_err_cost(x, &mv, &fcenter_mv, sad_per_bit);
- if (sad < best_sad) {
- best_sad = sad;
- *best_mv = mv;
- }
- }
- ++check_here;
- ++c;
- }
- }
- }
-
- while (c < col_max) {
- unsigned int sad =
- fn_ptr->sdf(what->buf, what->stride, check_here, in_what->stride);
- if (sad < best_sad) {
- const MV mv = { r, c };
- sad += mvsad_err_cost(x, &mv, &fcenter_mv, sad_per_bit);
- if (sad < best_sad) {
- best_sad = sad;
- *best_mv = mv;
- }
- }
- ++check_here;
- ++c;
- }
- }
-
- return best_sad;
-}
-
-int av1_full_search_sadx8(const MACROBLOCK *x, const MV *ref_mv,
- int sad_per_bit, int distance,
- const aom_variance_fn_ptr_t *fn_ptr,
- const MV *center_mv, MV *best_mv) {
- int r;
- const MACROBLOCKD *const xd = &x->e_mbd;
- const struct buf_2d *const what = &x->plane[0].src;
- const struct buf_2d *const in_what = &xd->plane[0].pre[0];
- const int row_min = AOMMAX(ref_mv->row - distance, x->mv_limits.row_min);
- const int row_max = AOMMIN(ref_mv->row + distance, x->mv_limits.row_max);
- const int col_min = AOMMAX(ref_mv->col - distance, x->mv_limits.col_min);
- const int col_max = AOMMIN(ref_mv->col + distance, x->mv_limits.col_max);
- const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 };
- unsigned int best_sad =
- fn_ptr->sdf(what->buf, what->stride, get_buf_from_mv(in_what, ref_mv),
- in_what->stride) +
- mvsad_err_cost(x, ref_mv, &fcenter_mv, sad_per_bit);
- *best_mv = *ref_mv;
-
- for (r = row_min; r < row_max; ++r) {
- int c = col_min;
- const uint8_t *check_here = &in_what->buf[r * in_what->stride + c];
-
- if (fn_ptr->sdx8f != NULL) {
- while ((c + 7) < col_max) {
- int i;
- DECLARE_ALIGNED(16, uint32_t, sads[8]);
-
- fn_ptr->sdx8f(what->buf, what->stride, check_here, in_what->stride,
- sads);
-
- for (i = 0; i < 8; ++i) {
- unsigned int sad = sads[i];
- if (sad < best_sad) {
- const MV mv = { r, c };
- sad += mvsad_err_cost(x, &mv, &fcenter_mv, sad_per_bit);
- if (sad < best_sad) {
- best_sad = sad;
- *best_mv = mv;
- }
- }
- ++check_here;
- ++c;
- }
- }
- }
-
- if (fn_ptr->sdx3f != NULL) {
- while ((c + 2) < col_max) {
- int i;
- DECLARE_ALIGNED(16, uint32_t, sads[3]);
-
- fn_ptr->sdx3f(what->buf, what->stride, check_here, in_what->stride,
- sads);
-
- for (i = 0; i < 3; ++i) {
- unsigned int sad = sads[i];
- if (sad < best_sad) {
- const MV mv = { r, c };
- sad += mvsad_err_cost(x, &mv, &fcenter_mv, sad_per_bit);
- if (sad < best_sad) {
- best_sad = sad;
- *best_mv = mv;
- }
- }
- ++check_here;
- ++c;
- }
- }
- }
-
- while (c < col_max) {
- unsigned int sad =
- fn_ptr->sdf(what->buf, what->stride, check_here, in_what->stride);
- if (sad < best_sad) {
- const MV mv = { r, c };
- sad += mvsad_err_cost(x, &mv, &fcenter_mv, sad_per_bit);
- if (sad < best_sad) {
- best_sad = sad;
- *best_mv = mv;
- }
- }
- ++check_here;
- ++c;
- }
- }
-
- return best_sad;
-}
-
int av1_refining_search_sad(MACROBLOCK *x, MV *ref_mv, int error_per_bit,
int search_range,
const aom_variance_fn_ptr_t *fn_ptr,
@@ -2394,16 +2025,23 @@ int av1_refining_search_8p_c(MACROBLOCK *x, int error_per_bit, int search_range,
clamp_mv(best_mv, x->mv_limits.col_min, x->mv_limits.col_max,
x->mv_limits.row_min, x->mv_limits.row_max);
- if (mask)
+ if (mask) {
best_sad = fn_ptr->msdf(what->buf, what->stride,
get_buf_from_mv(in_what, best_mv), in_what->stride,
second_pred, mask, mask_stride, invert_mask) +
mvsad_err_cost(x, best_mv, &fcenter_mv, error_per_bit);
- else
- best_sad =
- fn_ptr->sdaf(what->buf, what->stride, get_buf_from_mv(in_what, best_mv),
- in_what->stride, second_pred) +
- mvsad_err_cost(x, best_mv, &fcenter_mv, error_per_bit);
+ } else {
+ if (xd->jcp_param.use_jnt_comp_avg)
+ best_sad = fn_ptr->jsdaf(what->buf, what->stride,
+ get_buf_from_mv(in_what, best_mv),
+ in_what->stride, second_pred, &xd->jcp_param) +
+ mvsad_err_cost(x, best_mv, &fcenter_mv, error_per_bit);
+ else
+ best_sad = fn_ptr->sdaf(what->buf, what->stride,
+ get_buf_from_mv(in_what, best_mv),
+ in_what->stride, second_pred) +
+ mvsad_err_cost(x, best_mv, &fcenter_mv, error_per_bit);
+ }
for (i = 0; i < search_range; ++i) {
int best_site = -1;
@@ -2414,14 +2052,20 @@ int av1_refining_search_8p_c(MACROBLOCK *x, int error_per_bit, int search_range,
if (is_mv_in(&x->mv_limits, &mv)) {
unsigned int sad;
- if (mask)
+ if (mask) {
sad = fn_ptr->msdf(what->buf, what->stride,
get_buf_from_mv(in_what, &mv), in_what->stride,
second_pred, mask, mask_stride, invert_mask);
- else
- sad = fn_ptr->sdaf(what->buf, what->stride,
- get_buf_from_mv(in_what, &mv), in_what->stride,
- second_pred);
+ } else {
+ if (xd->jcp_param.use_jnt_comp_avg)
+ sad = fn_ptr->jsdaf(what->buf, what->stride,
+ get_buf_from_mv(in_what, &mv), in_what->stride,
+ second_pred, &xd->jcp_param);
+ else
+ sad = fn_ptr->sdaf(what->buf, what->stride,
+ get_buf_from_mv(in_what, &mv), in_what->stride,
+ second_pred);
+ }
if (sad < best_sad) {
sad += mvsad_err_cost(x, &mv, &fcenter_mv, error_per_bit);
if (sad < best_sad) {
@@ -2454,45 +2098,10 @@ static int is_exhaustive_allowed(const AV1_COMP *const cpi, MACROBLOCK *x) {
(*x->ex_search_count_ptr <= max_ex) && !cpi->rc.is_src_frame_alt_ref;
}
-#if CONFIG_HASH_ME
-#define MAX_HASH_MV_TABLE_SIZE 5
-static void add_to_sort_table(block_hash block_hashes[MAX_HASH_MV_TABLE_SIZE],
- int costs[MAX_HASH_MV_TABLE_SIZE], int *existing,
- int max_size, block_hash curr_block,
- int curr_cost) {
- if (*existing < max_size) {
- block_hashes[*existing] = curr_block;
- costs[*existing] = curr_cost;
- (*existing)++;
- } else {
- int max_cost = 0;
- int max_cost_idx = 0;
- for (int i = 0; i < max_size; i++) {
- if (costs[i] > max_cost) {
- max_cost = costs[i];
- max_cost_idx = i;
- }
- }
-
- if (curr_cost < max_cost) {
- block_hashes[max_cost_idx] = curr_block;
- costs[max_cost_idx] = curr_cost;
- }
- }
-}
-#endif
-
-#if CONFIG_HASH_ME
int av1_full_pixel_search(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
MV *mvp_full, int step_param, int error_per_bit,
int *cost_list, const MV *ref_mv, int var_max, int rd,
int x_pos, int y_pos, int intra) {
-#else
-int av1_full_pixel_search(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
- MV *mvp_full, int step_param, int error_per_bit,
- int *cost_list, const MV *ref_mv, int var_max,
- int rd) {
-#endif
const SPEED_FEATURES *const sf = &cpi->sf;
const SEARCH_METHODS method = sf->mv.search_method;
const aom_variance_fn_ptr_t *fn_ptr = &cpi->fn_ptr[bsize];
@@ -2539,7 +2148,7 @@ int av1_full_pixel_search(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
if (is_exhaustive_allowed(cpi, x)) {
int exhuastive_thr = sf->exhaustive_searches_thresh;
exhuastive_thr >>=
- 10 - (b_width_log2_lookup[bsize] + b_height_log2_lookup[bsize]);
+ 10 - (mi_size_wide_log2[bsize] + mi_size_high_log2[bsize]);
// Threshold variance for an exhaustive full search.
if (var > exhuastive_thr) {
@@ -2556,44 +2165,37 @@ int av1_full_pixel_search(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
}
}
break;
-
- break;
default: assert(0 && "Invalid search method.");
}
if (method != NSTEP && rd && var < var_max)
var = av1_get_mvpred_var(x, &x->best_mv.as_mv, ref_mv, fn_ptr, 1);
-#if CONFIG_HASH_ME
do {
- if (!cpi->common.allow_screen_content_tools) {
- break;
- }
+ if (!av1_use_hash_me(&cpi->common)) break;
+
// already single ME
// get block size and original buffer of current block
const int block_height = block_size_high[bsize];
const int block_width = block_size_wide[bsize];
if (block_height == block_width && x_pos >= 0 && y_pos >= 0) {
if (block_width == 4 || block_width == 8 || block_width == 16 ||
- block_width == 32 || block_width == 64) {
+ block_width == 32 || block_width == 64 || block_width == 128) {
uint8_t *what = x->plane[0].src.buf;
const int what_stride = x->plane[0].src.stride;
- block_hash block_hashes[MAX_HASH_MV_TABLE_SIZE];
- int costs[MAX_HASH_MV_TABLE_SIZE];
- int existing = 0;
- int i;
uint32_t hash_value1, hash_value2;
MV best_hash_mv;
int best_hash_cost = INT_MAX;
// for the hashMap
hash_table *ref_frame_hash =
- intra ? &cpi->common.cur_frame->hash_table
- : get_ref_frame_hash_map(cpi,
- x->e_mbd.mi[0]->mbmi.ref_frame[0]);
+ intra
+ ? &cpi->common.cur_frame->hash_table
+ : av1_get_ref_frame_hash_map(cpi, x->e_mbd.mi[0]->ref_frame[0]);
- av1_get_block_hash_value(what, what_stride, block_width, &hash_value1,
- &hash_value2);
+ av1_get_block_hash_value(
+ what, what_stride, block_width, &hash_value1, &hash_value2,
+ x->e_mbd.cur_buf->flags & YV12_FLAG_HIGHBITDEPTH);
const int count = av1_hash_table_count(ref_frame_hash, hash_value1);
// for intra, at lest one matching can be found, itself.
@@ -2603,44 +2205,31 @@ int av1_full_pixel_search(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
Iterator iterator =
av1_hash_get_first_iterator(ref_frame_hash, hash_value1);
- for (i = 0; i < count; i++, iterator_increment(&iterator)) {
+ for (int i = 0; i < count; i++, iterator_increment(&iterator)) {
block_hash ref_block_hash = *(block_hash *)(iterator_get(&iterator));
if (hash_value2 == ref_block_hash.hash_value2) {
- // for intra, make sure the prediction is from valid area
- // not predict from current block.
- // TODO(roger): check if the constrain is necessary
- if (intra &&
- ref_block_hash.y + block_height >
- ((y_pos >> MAX_SB_SIZE_LOG2) << MAX_SB_SIZE_LOG2) &&
- ref_block_hash.x + block_width >
- ((x_pos >> MAX_SB_SIZE_LOG2) << MAX_SB_SIZE_LOG2)) {
- continue;
+ // For intra, make sure the prediction is from valid area.
+ if (intra) {
+ const int mi_col = x_pos / MI_SIZE;
+ const int mi_row = y_pos / MI_SIZE;
+ const MV dv = { 8 * (ref_block_hash.y - y_pos),
+ 8 * (ref_block_hash.x - x_pos) };
+ if (!av1_is_dv_valid(dv, &cpi->common, &x->e_mbd, mi_row, mi_col,
+ bsize, cpi->common.seq_params.mib_size_log2))
+ continue;
+ }
+ MV hash_mv;
+ hash_mv.col = ref_block_hash.x - x_pos;
+ hash_mv.row = ref_block_hash.y - y_pos;
+ if (!is_mv_in(&x->mv_limits, &hash_mv)) continue;
+ const int refCost =
+ av1_get_mvpred_var(x, &hash_mv, ref_mv, fn_ptr, 1);
+ if (refCost < best_hash_cost) {
+ best_hash_cost = refCost;
+ best_hash_mv = hash_mv;
}
- int refCost =
- abs(ref_block_hash.x - x_pos) + abs(ref_block_hash.y - y_pos);
- add_to_sort_table(block_hashes, costs, &existing,
- MAX_HASH_MV_TABLE_SIZE, ref_block_hash, refCost);
- }
- }
-
- if (existing == 0) {
- break;
- }
-
- for (i = 0; i < existing; i++) {
- MV hash_mv;
- hash_mv.col = block_hashes[i].x - x_pos;
- hash_mv.row = block_hashes[i].y - y_pos;
- if (!is_mv_in(&x->mv_limits, &hash_mv)) {
- continue;
- }
- int currHashCost = av1_get_mvpred_var(x, &hash_mv, ref_mv, fn_ptr, 1);
- if (currHashCost < best_hash_cost) {
- best_hash_cost = currHashCost;
- best_hash_mv = hash_mv;
}
}
-
if (best_hash_cost < var) {
x->second_best_mv = x->best_mv;
x->best_mv.as_mv = best_hash_mv;
@@ -2649,12 +2238,10 @@ int av1_full_pixel_search(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
}
}
} while (0);
-#endif
return var;
}
-#if CONFIG_MOTION_VAR
/* returns subpixel variance error function */
#define DIST(r, c) \
vfp->osvf(pre(y, y_stride, r, c), y_stride, sp(c), sp(r), z, mask, &sse)
@@ -2687,20 +2274,21 @@ int av1_full_pixel_search(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
#define CHECK_BETTER0(v, r, c) CHECK_BETTER(v, r, c)
#undef CHECK_BETTER1
-#define CHECK_BETTER1(v, r, c) \
- if (c >= minc && c <= maxc && r >= minr && r <= maxr) { \
- thismse = \
- upsampled_obmc_pref_error(xd, mask, vfp, z, pre(y, y_stride, r, c), \
- y_stride, sp(c), sp(r), w, h, &sse); \
- if ((v = MVC(r, c) + thismse) < besterr) { \
- besterr = v; \
- br = r; \
- bc = c; \
- *distortion = thismse; \
- *sse1 = sse; \
- } \
- } else { \
- v = INT_MAX; \
+#define CHECK_BETTER1(v, r, c) \
+ if (c >= minc && c <= maxc && r >= minr && r <= maxr) { \
+ MV this_mv = { r, c }; \
+ thismse = upsampled_obmc_pref_error(xd, cm, mi_row, mi_col, &this_mv, \
+ mask, vfp, z, pre(y, y_stride, r, c), \
+ y_stride, sp(c), sp(r), w, h, &sse); \
+ if ((v = MVC(r, c) + thismse) < besterr) { \
+ besterr = v; \
+ br = r; \
+ bc = c; \
+ *distortion = thismse; \
+ *sse1 = sse; \
+ } \
+ } else { \
+ v = INT_MAX; \
}
static unsigned int setup_obmc_center_error(
@@ -2715,60 +2303,55 @@ static unsigned int setup_obmc_center_error(
return besterr;
}
-static int upsampled_obmc_pref_error(const MACROBLOCKD *xd, const int32_t *mask,
- const aom_variance_fn_ptr_t *vfp,
- const int32_t *const wsrc,
- const uint8_t *const y, int y_stride,
- int subpel_x_q3, int subpel_y_q3, int w,
- int h, unsigned int *sse) {
+static int upsampled_obmc_pref_error(
+ MACROBLOCKD *xd, const AV1_COMMON *const cm, int mi_row, int mi_col,
+ const MV *const mv, const int32_t *mask, const aom_variance_fn_ptr_t *vfp,
+ const int32_t *const wsrc, const uint8_t *const y, int y_stride,
+ int subpel_x_q3, int subpel_y_q3, int w, int h, unsigned int *sse) {
unsigned int besterr;
-#if CONFIG_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
DECLARE_ALIGNED(16, uint16_t, pred16[MAX_SB_SQUARE]);
- aom_highbd_upsampled_pred(pred16, w, h, subpel_x_q3, subpel_y_q3, y,
- y_stride, xd->bd);
+ aom_highbd_upsampled_pred(xd, cm, mi_row, mi_col, mv, pred16, w, h,
+ subpel_x_q3, subpel_y_q3, y, y_stride, xd->bd);
besterr = vfp->ovf(CONVERT_TO_BYTEPTR(pred16), w, wsrc, mask, sse);
} else {
DECLARE_ALIGNED(16, uint8_t, pred[MAX_SB_SQUARE]);
-#else
- DECLARE_ALIGNED(16, uint8_t, pred[MAX_SB_SQUARE]);
- (void)xd;
-#endif // CONFIG_HIGHBITDEPTH
- aom_upsampled_pred(pred, w, h, subpel_x_q3, subpel_y_q3, y, y_stride);
+ aom_upsampled_pred(xd, cm, mi_row, mi_col, mv, pred, w, h, subpel_x_q3,
+ subpel_y_q3, y, y_stride);
besterr = vfp->ovf(pred, w, wsrc, mask, sse);
-#if CONFIG_HIGHBITDEPTH
}
-#endif
return besterr;
}
static unsigned int upsampled_setup_obmc_center_error(
- const MACROBLOCKD *xd, const int32_t *mask, const MV *bestmv,
- const MV *ref_mv, int error_per_bit, const aom_variance_fn_ptr_t *vfp,
- const int32_t *const wsrc, const uint8_t *const y, int y_stride, int w,
- int h, int offset, int *mvjcost, int *mvcost[2], unsigned int *sse1,
- int *distortion) {
- unsigned int besterr = upsampled_obmc_pref_error(
- xd, mask, vfp, wsrc, y + offset, y_stride, 0, 0, w, h, sse1);
+ MACROBLOCKD *xd, const AV1_COMMON *const cm, int mi_row, int mi_col,
+ const int32_t *mask, const MV *bestmv, const MV *ref_mv, int error_per_bit,
+ const aom_variance_fn_ptr_t *vfp, const int32_t *const wsrc,
+ const uint8_t *const y, int y_stride, int w, int h, int offset,
+ int *mvjcost, int *mvcost[2], unsigned int *sse1, int *distortion) {
+ unsigned int besterr =
+ upsampled_obmc_pref_error(xd, cm, mi_row, mi_col, bestmv, mask, vfp, wsrc,
+ y + offset, y_stride, 0, 0, w, h, sse1);
*distortion = besterr;
besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit);
return besterr;
}
int av1_find_best_obmc_sub_pixel_tree_up(
- MACROBLOCK *x, MV *bestmv, const MV *ref_mv, int allow_hp,
- int error_per_bit, const aom_variance_fn_ptr_t *vfp, int forced_stop,
- int iters_per_step, int *mvjcost, int *mvcost[2], int *distortion,
- unsigned int *sse1, int is_second, int use_upsampled_ref) {
+ MACROBLOCK *x, const AV1_COMMON *const cm, int mi_row, int mi_col,
+ MV *bestmv, const MV *ref_mv, int allow_hp, int error_per_bit,
+ const aom_variance_fn_ptr_t *vfp, int forced_stop, int iters_per_step,
+ int *mvjcost, int *mvcost[2], int *distortion, unsigned int *sse1,
+ int is_second, int use_accurate_subpel_search) {
const int32_t *wsrc = x->wsrc_buf;
const int32_t *mask = x->mask_buf;
const int *const z = wsrc;
const int *const src_address = z;
MACROBLOCKD *xd = &x->e_mbd;
struct macroblockd_plane *const pd = &xd->plane[0];
- MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
+ MB_MODE_INFO *mbmi = xd->mi[0];
unsigned int besterr = INT_MAX;
unsigned int sse;
unsigned int thismse;
@@ -2794,8 +2377,7 @@ int av1_find_best_obmc_sub_pixel_tree_up(
int minc, maxc, minr, maxr;
- av1_set_subpel_mv_search_range(&x->mv_limits, &minc, &maxc, &minr, &maxr,
- ref_mv);
+ set_subpel_mv_search_range(&x->mv_limits, &minc, &maxc, &minr, &maxr, ref_mv);
y = pd->pre[is_second].buf;
y_stride = pd->pre[is_second].stride;
@@ -2806,11 +2388,11 @@ int av1_find_best_obmc_sub_pixel_tree_up(
bestmv->row *= 8;
bestmv->col *= 8;
- // use_upsampled_ref can be 0 or 1
- if (use_upsampled_ref)
+ // use_accurate_subpel_search can be 0 or 1
+ if (use_accurate_subpel_search)
besterr = upsampled_setup_obmc_center_error(
- xd, mask, bestmv, ref_mv, error_per_bit, vfp, z, y, y_stride, w, h,
- offset, mvjcost, mvcost, sse1, distortion);
+ xd, cm, mi_row, mi_col, mask, bestmv, ref_mv, error_per_bit, vfp, z, y,
+ y_stride, w, h, offset, mvjcost, mvcost, sse1, distortion);
else
besterr = setup_obmc_center_error(mask, bestmv, ref_mv, error_per_bit, vfp,
z, y, y_stride, offset, mvjcost, mvcost,
@@ -2823,15 +2405,13 @@ int av1_find_best_obmc_sub_pixel_tree_up(
tc = bc + search_step[idx].col;
if (tc >= minc && tc <= maxc && tr >= minr && tr <= maxr) {
MV this_mv = { tr, tc };
- const uint8_t *const pre_address = pre(y, y_stride, tr, tc);
-
- if (use_upsampled_ref) {
- thismse =
- upsampled_obmc_pref_error(xd, mask, vfp, src_address, pre_address,
- y_stride, sp(tc), sp(tr), w, h, &sse);
+ if (use_accurate_subpel_search) {
+ thismse = upsampled_obmc_pref_error(
+ xd, cm, mi_row, mi_col, &this_mv, mask, vfp, src_address,
+ pre(y, y_stride, tr, tc), y_stride, sp(tc), sp(tr), w, h, &sse);
} else {
- thismse = vfp->osvf(pre_address, y_stride, sp(tc), sp(tr),
- src_address, mask, &sse);
+ thismse = vfp->osvf(pre(y, y_stride, tr, tc), y_stride, sp(tc),
+ sp(tr), src_address, mask, &sse);
}
cost_array[idx] = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost,
@@ -2856,10 +2436,10 @@ int av1_find_best_obmc_sub_pixel_tree_up(
if (tc >= minc && tc <= maxc && tr >= minr && tr <= maxr) {
MV this_mv = { tr, tc };
- if (use_upsampled_ref) {
- thismse = upsampled_obmc_pref_error(xd, mask, vfp, src_address,
- pre(y, y_stride, tr, tc), y_stride,
- sp(tc), sp(tr), w, h, &sse);
+ if (use_accurate_subpel_search) {
+ thismse = upsampled_obmc_pref_error(
+ xd, cm, mi_row, mi_col, &this_mv, mask, vfp, src_address,
+ pre(y, y_stride, tr, tc), y_stride, sp(tc), sp(tr), w, h, &sse);
} else {
thismse = vfp->osvf(pre(y, y_stride, tr, tc), y_stride, sp(tc), sp(tr),
src_address, mask, &sse);
@@ -2887,7 +2467,7 @@ int av1_find_best_obmc_sub_pixel_tree_up(
}
if (iters_per_step > 1 && best_idx != -1) {
- if (use_upsampled_ref) {
+ if (use_accurate_subpel_search) {
SECOND_LEVEL_CHECKS_BEST(1);
} else {
SECOND_LEVEL_CHECKS_BEST(0);
@@ -3123,89 +2703,98 @@ int av1_obmc_full_pixel_diamond(const AV1_COMP *cpi, MACROBLOCK *x,
}
return bestsme;
}
-#endif // CONFIG_MOTION_VAR
// Note(yunqingwang): The following 2 functions are only used in the motion
// vector unit test, which return extreme motion vectors allowed by the MV
// limits.
-#define COMMON_MV_TEST \
- SETUP_SUBPEL_SEARCH; \
- \
- (void)error_per_bit; \
- (void)vfp; \
- (void)src_address; \
- (void)src_stride; \
- (void)y; \
- (void)y_stride; \
- (void)second_pred; \
- (void)w; \
- (void)h; \
- (void)use_upsampled_ref; \
- (void)offset; \
- (void)mvjcost; \
- (void)mvcost; \
- (void)sse1; \
- (void)distortion; \
- \
- (void)halfiters; \
- (void)quarteriters; \
- (void)eighthiters; \
- (void)whichdir; \
- (void)forced_stop; \
- (void)hstep; \
- \
- (void)tr; \
- (void)tc; \
- (void)sse; \
- (void)thismse; \
+#define COMMON_MV_TEST \
+ SETUP_SUBPEL_SEARCH; \
+ \
+ (void)error_per_bit; \
+ (void)vfp; \
+ (void)src_address; \
+ (void)src_stride; \
+ (void)y; \
+ (void)y_stride; \
+ (void)second_pred; \
+ (void)w; \
+ (void)h; \
+ (void)use_accurate_subpel_search; \
+ (void)offset; \
+ (void)mvjcost; \
+ (void)mvcost; \
+ (void)sse1; \
+ (void)distortion; \
+ \
+ (void)halfiters; \
+ (void)quarteriters; \
+ (void)eighthiters; \
+ (void)whichdir; \
+ (void)forced_stop; \
+ (void)hstep; \
+ \
+ (void)tr; \
+ (void)tc; \
+ (void)sse; \
+ (void)thismse; \
(void)cost_list;
// Return the maximum MV.
-int av1_return_max_sub_pixel_mv(
- MACROBLOCK *x, const MV *ref_mv, int allow_hp, int error_per_bit,
- const aom_variance_fn_ptr_t *vfp, int forced_stop, int iters_per_step,
- int *cost_list, int *mvjcost, int *mvcost[2], int *distortion,
- unsigned int *sse1, const uint8_t *second_pred, const uint8_t *mask,
- int mask_stride, int invert_mask, int w, int h, int use_upsampled_ref) {
+int av1_return_max_sub_pixel_mv(MACROBLOCK *x, const AV1_COMMON *const cm,
+ int mi_row, int mi_col, const MV *ref_mv,
+ int allow_hp, int error_per_bit,
+ const aom_variance_fn_ptr_t *vfp,
+ int forced_stop, int iters_per_step,
+ int *cost_list, int *mvjcost, int *mvcost[2],
+ int *distortion, unsigned int *sse1,
+ const uint8_t *second_pred, const uint8_t *mask,
+ int mask_stride, int invert_mask, int w, int h,
+ int use_accurate_subpel_search) {
COMMON_MV_TEST;
(void)mask;
(void)mask_stride;
(void)invert_mask;
(void)minr;
(void)minc;
+
+ (void)cm;
+ (void)mi_row;
+ (void)mi_col;
+
bestmv->row = maxr;
bestmv->col = maxc;
besterr = 0;
-// In the sub-pel motion search, if hp is not used, then the last bit of mv
-// has to be 0.
-#if CONFIG_AMVR
+ // In the sub-pel motion search, if hp is not used, then the last bit of mv
+ // has to be 0.
lower_mv_precision(bestmv, allow_hp, 0);
-#else
- lower_mv_precision(bestmv, allow_hp);
-#endif
return besterr;
}
// Return the minimum MV.
-int av1_return_min_sub_pixel_mv(
- MACROBLOCK *x, const MV *ref_mv, int allow_hp, int error_per_bit,
- const aom_variance_fn_ptr_t *vfp, int forced_stop, int iters_per_step,
- int *cost_list, int *mvjcost, int *mvcost[2], int *distortion,
- unsigned int *sse1, const uint8_t *second_pred, const uint8_t *mask,
- int mask_stride, int invert_mask, int w, int h, int use_upsampled_ref) {
+int av1_return_min_sub_pixel_mv(MACROBLOCK *x, const AV1_COMMON *const cm,
+ int mi_row, int mi_col, const MV *ref_mv,
+ int allow_hp, int error_per_bit,
+ const aom_variance_fn_ptr_t *vfp,
+ int forced_stop, int iters_per_step,
+ int *cost_list, int *mvjcost, int *mvcost[2],
+ int *distortion, unsigned int *sse1,
+ const uint8_t *second_pred, const uint8_t *mask,
+ int mask_stride, int invert_mask, int w, int h,
+ int use_accurate_subpel_search) {
COMMON_MV_TEST;
(void)maxr;
(void)maxc;
(void)mask;
(void)mask_stride;
(void)invert_mask;
+
+ (void)cm;
+ (void)mi_row;
+ (void)mi_col;
+
bestmv->row = minr;
bestmv->col = minc;
besterr = 0;
-// In the sub-pel motion search, if hp is not used, then the last bit of mv
-// has to be 0.
-#if CONFIG_AMVR
+ // In the sub-pel motion search, if hp is not used, then the last bit of mv
+ // has to be 0.
lower_mv_precision(bestmv, allow_hp, 0);
-#else
- lower_mv_precision(bestmv, allow_hp);
-#endif
return besterr;
}