Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 4 | * This source code is subject to the terms of the BSD 2 Clause License and |
| 5 | * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
| 6 | * was not distributed with this source code in the LICENSE file, you can |
| 7 | * obtain it at www.aomedia.org/license/software. If the Alliance for Open |
| 8 | * Media Patent License 1.0 was not distributed with this source code in the |
| 9 | * PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 12 | #ifndef AOM_AV1_ENCODER_MCOMP_H_ |
| 13 | #define AOM_AV1_ENCODER_MCOMP_H_ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 14 | |
chiyotsai | 2ad959b | 2020-02-12 14:29:32 -0800 | [diff] [blame] | 15 | #include "av1/common/mv.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 16 | #include "av1/encoder/block.h" |
chiyotsai | 19a58ee | 2019-03-18 18:01:05 -0700 | [diff] [blame] | 17 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 18 | #include "aom_dsp/variance.h" |
| 19 | |
| 20 | #ifdef __cplusplus |
| 21 | extern "C" { |
| 22 | #endif |
| 23 | |
| 24 | // The maximum number of steps in a step search given the largest |
| 25 | // allowed initial step |
Yunqing Wang | e25fdbb | 2018-03-16 16:36:32 -0700 | [diff] [blame] | 26 | #define MAX_MVSEARCH_STEPS 11 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 27 | // Max full pel mv specified in the unit of full pixel |
Yunqing Wang | e25fdbb | 2018-03-16 16:36:32 -0700 | [diff] [blame] | 28 | // Enable the use of motion vector in range [-1023, 1023]. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 29 | #define MAX_FULL_PEL_VAL ((1 << (MAX_MVSEARCH_STEPS - 1)) - 1) |
| 30 | // Maximum size of the first step in full pel units |
| 31 | #define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS - 1)) |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 32 | |
Deepa K G | d4febfb | 2018-08-14 11:33:51 +0530 | [diff] [blame] | 33 | #define SEARCH_RANGE_8P 3 |
| 34 | #define SEARCH_GRID_STRIDE_8P (2 * SEARCH_RANGE_8P + 1) |
| 35 | #define SEARCH_GRID_CENTER_8P \ |
| 36 | (SEARCH_RANGE_8P * SEARCH_GRID_STRIDE_8P + SEARCH_RANGE_8P) |
| 37 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 38 | // motion search site |
| 39 | typedef struct search_site { |
chiyotsai | e46cff7 | 2020-02-05 15:03:34 -0800 | [diff] [blame] | 40 | FULLPEL_MV mv; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 41 | int offset; |
| 42 | } search_site; |
| 43 | |
| 44 | typedef struct search_site_config { |
Jingning Han | 969a8d4 | 2019-12-16 19:40:14 -0800 | [diff] [blame] | 45 | search_site ss[MAX_MVSEARCH_STEPS * 2][16 + 1]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 46 | int ss_count; |
Jingning Han | 969a8d4 | 2019-12-16 19:40:14 -0800 | [diff] [blame] | 47 | int searches_per_step[MAX_MVSEARCH_STEPS * 2]; |
| 48 | int radius[MAX_MVSEARCH_STEPS * 2]; |
chiyotsai | 836b69b | 2019-04-09 13:41:24 -0700 | [diff] [blame] | 49 | int stride; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 50 | } search_site_config; |
| 51 | |
Deepa K G | d4febfb | 2018-08-14 11:33:51 +0530 | [diff] [blame] | 52 | typedef struct { |
chiyotsai | 9f664e3 | 2020-02-19 14:17:31 -0800 | [diff] [blame] | 53 | FULLPEL_MV coord; |
Deepa K G | d4febfb | 2018-08-14 11:33:51 +0530 | [diff] [blame] | 54 | int coord_offset; |
| 55 | } search_neighbors; |
| 56 | |
chiyotsai | 9f664e3 | 2020-02-19 14:17:31 -0800 | [diff] [blame] | 57 | struct AV1_COMP; |
| 58 | struct SPEED_FEATURES; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 59 | |
chiyotsai | 9f664e3 | 2020-02-19 14:17:31 -0800 | [diff] [blame] | 60 | // ============================================================================= |
| 61 | // Cost functions |
| 62 | // ============================================================================= |
| 63 | typedef struct { |
| 64 | const MV *ref_mv; |
chiyotsai | 2e42a66 | 2020-02-26 17:39:03 -0800 | [diff] [blame] | 65 | FULLPEL_MV full_ref_mv; |
chiyotsai | 9f664e3 | 2020-02-19 14:17:31 -0800 | [diff] [blame] | 66 | const int *mvjcost; |
| 67 | const int *mvcost[2]; |
| 68 | int error_per_bit; |
chiyotsai | 2e42a66 | 2020-02-26 17:39:03 -0800 | [diff] [blame] | 69 | int sad_per_bit; |
chiyotsai | 9f664e3 | 2020-02-19 14:17:31 -0800 | [diff] [blame] | 70 | MV_COST_TYPE mv_cost_type; |
| 71 | } MV_COST_PARAMS; |
Yunqing Wang | 8e17342 | 2017-04-21 09:27:55 -0700 | [diff] [blame] | 72 | |
chiyotsai | e46cff7 | 2020-02-05 15:03:34 -0800 | [diff] [blame] | 73 | int av1_mv_bit_cost(const MV *mv, const MV *ref_mv, const int *mvjcost, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 74 | int *mvcost[2], int weight); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 75 | |
chiyotsai | ff03e5b | 2020-02-10 15:47:14 -0800 | [diff] [blame] | 76 | int av1_get_mvpred_sse(const MACROBLOCK *x, const FULLPEL_MV *best_mv, |
| 77 | const MV *ref_mv, const aom_variance_fn_ptr_t *vfp); |
chiyotsai | e46cff7 | 2020-02-05 15:03:34 -0800 | [diff] [blame] | 78 | int av1_get_mvpred_var(const MACROBLOCK *x, const FULLPEL_MV *best_mv, |
chiyotsai | f1839b5 | 2020-02-10 16:10:36 -0800 | [diff] [blame] | 79 | const MV *ref_mv, const aom_variance_fn_ptr_t *vfp); |
chiyotsai | 30a5bdf | 2020-04-06 14:28:59 -0700 | [diff] [blame] | 80 | int av1_get_mvpred_compound_var(const MV_COST_PARAMS *ms_params, |
| 81 | const FULLPEL_MV best_mv, |
| 82 | const uint8_t *second_pred, const uint8_t *mask, |
| 83 | int mask_stride, int invert_mask, |
| 84 | const aom_variance_fn_ptr_t *vfp, |
| 85 | const struct buf_2d *src, |
| 86 | const struct buf_2d *pre); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 87 | |
chiyotsai | 9f664e3 | 2020-02-19 14:17:31 -0800 | [diff] [blame] | 88 | // ============================================================================= |
chiyotsai | 30a5bdf | 2020-04-06 14:28:59 -0700 | [diff] [blame] | 89 | // Motion Search |
chiyotsai | 9f664e3 | 2020-02-19 14:17:31 -0800 | [diff] [blame] | 90 | // ============================================================================= |
chiyotsai | 94f4aca | 2020-03-20 12:54:47 -0700 | [diff] [blame] | 91 | typedef struct { |
| 92 | // The reference buffer |
| 93 | const struct buf_2d *ref; |
| 94 | |
| 95 | // The source and predictors/mask used by translational search |
| 96 | const struct buf_2d *src; |
| 97 | const uint8_t *second_pred; |
| 98 | const uint8_t *mask; |
| 99 | int mask_stride; |
| 100 | int inv_mask; |
| 101 | |
| 102 | // The weighted source and mask used by OBMC |
| 103 | const int32_t *wsrc; |
| 104 | const int32_t *obmc_mask; |
| 105 | } MSBuffers; |
| 106 | |
chiyotsai | 4d1b7d9 | 2020-04-07 13:56:22 -0700 | [diff] [blame^] | 107 | static INLINE void av1_set_ms_compound_refs(MSBuffers *ms_buffers, |
| 108 | const uint8_t *second_pred, |
| 109 | const uint8_t *mask, |
| 110 | int mask_stride, int invert_mask) { |
chiyotsai | 30a5bdf | 2020-04-06 14:28:59 -0700 | [diff] [blame] | 111 | ms_buffers->second_pred = second_pred; |
| 112 | ms_buffers->mask = mask; |
| 113 | ms_buffers->mask_stride = mask_stride; |
| 114 | ms_buffers->inv_mask = invert_mask; |
| 115 | } |
| 116 | |
| 117 | // ============================================================================= |
| 118 | // Fullpixel Motion Search |
| 119 | // ============================================================================= |
| 120 | enum { |
| 121 | DIAMOND = 0, |
| 122 | NSTEP = 1, |
| 123 | HEX = 2, |
| 124 | BIGDIA = 3, |
| 125 | SQUARE = 4, |
| 126 | FAST_HEX = 5, |
| 127 | FAST_DIAMOND = 6 |
| 128 | } UENUM1BYTE(SEARCH_METHODS); |
| 129 | |
chiyotsai | 2e42a66 | 2020-02-26 17:39:03 -0800 | [diff] [blame] | 130 | // This struct holds fullpixel motion search parameters that should be constant |
| 131 | // during the search |
| 132 | typedef struct { |
| 133 | BLOCK_SIZE bsize; |
| 134 | const aom_variance_fn_ptr_t *vfp; |
| 135 | |
chiyotsai | 94f4aca | 2020-03-20 12:54:47 -0700 | [diff] [blame] | 136 | MSBuffers ms_buffers; |
| 137 | |
chiyotsai | 2e42a66 | 2020-02-26 17:39:03 -0800 | [diff] [blame] | 138 | SEARCH_METHODS search_method; |
| 139 | const search_site_config *search_sites; |
| 140 | FullMvLimits mv_limits; |
| 141 | |
| 142 | int run_mesh_search; // Sets mesh search unless it got pruned by |
| 143 | // prune_mesh_search. |
| 144 | int prune_mesh_search; // Disables mesh search if the best_mv after a normal |
| 145 | // search if close to the start_mv. |
| 146 | int force_mesh_thresh; // Forces mesh search if the residue variance is |
| 147 | // higher than the threshold. |
| 148 | const struct MESH_PATTERN *mesh_patterns[2]; |
| 149 | |
| 150 | int is_intra_mode; |
| 151 | |
chiyotsai | 2e42a66 | 2020-02-26 17:39:03 -0800 | [diff] [blame] | 152 | int fast_obmc_search; |
| 153 | |
| 154 | // For calculating mv cost |
| 155 | MV_COST_PARAMS mv_cost_params; |
| 156 | } FULLPEL_MOTION_SEARCH_PARAMS; |
| 157 | |
| 158 | void av1_make_default_fullpel_ms_params(FULLPEL_MOTION_SEARCH_PARAMS *ms_params, |
| 159 | const struct AV1_COMP *cpi, |
| 160 | const MACROBLOCK *x, BLOCK_SIZE bsize, |
| 161 | const MV *ref_mv, |
| 162 | const search_site_config *search_sites); |
| 163 | |
chiyotsai | 9f664e3 | 2020-02-19 14:17:31 -0800 | [diff] [blame] | 164 | // Sets up configs for fullpixel diamond search |
| 165 | void av1_init_dsmotion_compensation(search_site_config *cfg, int stride); |
| 166 | // Sets up configs for firstpass motion search |
| 167 | void av1_init_motion_fpf(search_site_config *cfg, int stride); |
| 168 | // Sets up configs for all other types of motion search |
| 169 | void av1_init3smotion_compensation(search_site_config *cfg, int stride); |
| 170 | |
Yunqing Wang | 9664005 | 2020-02-25 18:59:47 -0800 | [diff] [blame] | 171 | // Set up limit values for MV components. |
| 172 | // Mv beyond the range do not produce new/different prediction block. |
Urvang Joshi | 9dc909d | 2020-03-23 16:07:02 -0700 | [diff] [blame] | 173 | static INLINE void av1_set_mv_row_limits( |
| 174 | const CommonModeInfoParams *const mi_params, FullMvLimits *mv_limits, |
| 175 | int mi_row, int mi_height, int border) { |
Yunqing Wang | 6a35bf9 | 2020-02-28 13:44:21 -0800 | [diff] [blame] | 176 | const int min1 = -(mi_row * MI_SIZE + border - 2 * AOM_INTERP_EXTEND); |
| 177 | const int min2 = -(((mi_row + mi_height) * MI_SIZE) + 2 * AOM_INTERP_EXTEND); |
| 178 | mv_limits->row_min = AOMMAX(min1, min2); |
Urvang Joshi | 9dc909d | 2020-03-23 16:07:02 -0700 | [diff] [blame] | 179 | const int max1 = (mi_params->mi_rows - mi_row - mi_height) * MI_SIZE + |
| 180 | border - 2 * AOM_INTERP_EXTEND; |
| 181 | const int max2 = |
| 182 | (mi_params->mi_rows - mi_row) * MI_SIZE + 2 * AOM_INTERP_EXTEND; |
Yunqing Wang | 6a35bf9 | 2020-02-28 13:44:21 -0800 | [diff] [blame] | 183 | mv_limits->row_max = AOMMIN(max1, max2); |
| 184 | } |
| 185 | |
Urvang Joshi | 9dc909d | 2020-03-23 16:07:02 -0700 | [diff] [blame] | 186 | static INLINE void av1_set_mv_col_limits( |
| 187 | const CommonModeInfoParams *const mi_params, FullMvLimits *mv_limits, |
| 188 | int mi_col, int mi_width, int border) { |
Yunqing Wang | 6a35bf9 | 2020-02-28 13:44:21 -0800 | [diff] [blame] | 189 | const int min1 = -(mi_col * MI_SIZE + border - 2 * AOM_INTERP_EXTEND); |
| 190 | const int min2 = -(((mi_col + mi_width) * MI_SIZE) + 2 * AOM_INTERP_EXTEND); |
| 191 | mv_limits->col_min = AOMMAX(min1, min2); |
Urvang Joshi | 9dc909d | 2020-03-23 16:07:02 -0700 | [diff] [blame] | 192 | const int max1 = (mi_params->mi_cols - mi_col - mi_width) * MI_SIZE + border - |
Yunqing Wang | 6a35bf9 | 2020-02-28 13:44:21 -0800 | [diff] [blame] | 193 | 2 * AOM_INTERP_EXTEND; |
Urvang Joshi | 9dc909d | 2020-03-23 16:07:02 -0700 | [diff] [blame] | 194 | const int max2 = |
| 195 | (mi_params->mi_cols - mi_col) * MI_SIZE + 2 * AOM_INTERP_EXTEND; |
Yunqing Wang | 6a35bf9 | 2020-02-28 13:44:21 -0800 | [diff] [blame] | 196 | mv_limits->col_max = AOMMIN(max1, max2); |
| 197 | } |
| 198 | |
Urvang Joshi | 9dc909d | 2020-03-23 16:07:02 -0700 | [diff] [blame] | 199 | static INLINE void av1_set_mv_limits( |
| 200 | const CommonModeInfoParams *const mi_params, FullMvLimits *mv_limits, |
| 201 | int mi_row, int mi_col, int mi_height, int mi_width, int border) { |
| 202 | av1_set_mv_row_limits(mi_params, mv_limits, mi_row, mi_height, border); |
| 203 | av1_set_mv_col_limits(mi_params, mv_limits, mi_col, mi_width, border); |
Yunqing Wang | 9664005 | 2020-02-25 18:59:47 -0800 | [diff] [blame] | 204 | } |
| 205 | |
chiyotsai | 9f664e3 | 2020-02-19 14:17:31 -0800 | [diff] [blame] | 206 | void av1_set_mv_search_range(FullMvLimits *mv_limits, const MV *mv); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 207 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 208 | int av1_init_search_range(int size); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 209 | |
kyslov | 9de0d28 | 2019-02-27 16:14:08 -0800 | [diff] [blame] | 210 | unsigned int av1_int_pro_motion_estimation(const struct AV1_COMP *cpi, |
| 211 | MACROBLOCK *x, BLOCK_SIZE bsize, |
| 212 | int mi_row, int mi_col, |
| 213 | const MV *ref_mv); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 214 | |
chiyotsai | 30a5bdf | 2020-04-06 14:28:59 -0700 | [diff] [blame] | 215 | int av1_refining_search_8p_c(const FULLPEL_MOTION_SEARCH_PARAMS *ms_params, |
| 216 | const FULLPEL_MV start_mv, FULLPEL_MV *best_mv); |
chiyotsai | 9f664e3 | 2020-02-19 14:17:31 -0800 | [diff] [blame] | 217 | |
chiyotsai | 2e42a66 | 2020-02-26 17:39:03 -0800 | [diff] [blame] | 218 | int av1_full_pixel_search(const FULLPEL_MV start_mv, |
| 219 | const FULLPEL_MOTION_SEARCH_PARAMS *ms_params, |
| 220 | const int step_param, int *cost_list, |
chiyotsai | 8bbdd41 | 2020-03-03 14:57:23 -0800 | [diff] [blame] | 221 | FULLPEL_MV *best_mv, FULLPEL_MV *second_best_mv); |
chiyotsai | 9f664e3 | 2020-02-19 14:17:31 -0800 | [diff] [blame] | 222 | |
chiyotsai | 8bbdd41 | 2020-03-03 14:57:23 -0800 | [diff] [blame] | 223 | void av1_intrabc_hash_search(const struct AV1_COMP *cpi, MACROBLOCK *x, |
| 224 | BLOCK_SIZE bsize, const MV *ref_mv, int *bestsme, |
| 225 | FULLPEL_MV *best_mv); |
| 226 | |
chiyotsai | 94f4aca | 2020-03-20 12:54:47 -0700 | [diff] [blame] | 227 | int av1_obmc_full_pixel_search(const FULLPEL_MV start_mv, |
chiyotsai | 2e42a66 | 2020-02-26 17:39:03 -0800 | [diff] [blame] | 228 | const FULLPEL_MOTION_SEARCH_PARAMS *ms_params, |
| 229 | const int step_param, FULLPEL_MV *best_mv); |
chiyotsai | 9f664e3 | 2020-02-19 14:17:31 -0800 | [diff] [blame] | 230 | |
chiyotsai | 9f664e3 | 2020-02-19 14:17:31 -0800 | [diff] [blame] | 231 | static INLINE int av1_is_fullmv_in_range(const FullMvLimits *mv_limits, |
| 232 | FULLPEL_MV mv) { |
| 233 | return (mv.col >= mv_limits->col_min) && (mv.col <= mv_limits->col_max) && |
| 234 | (mv.row >= mv_limits->row_min) && (mv.row <= mv_limits->row_max); |
| 235 | } |
| 236 | // ============================================================================= |
| 237 | // Subpixel Motion Search |
| 238 | // ============================================================================= |
chiyotsai | 2aac300 | 2020-02-13 17:02:01 -0800 | [diff] [blame] | 239 | enum { |
| 240 | EIGHTH_PEL, |
| 241 | QUARTER_PEL, |
| 242 | HALF_PEL, |
| 243 | FULL_PEL |
| 244 | } UENUM1BYTE(SUBPEL_FORCE_STOP); |
| 245 | |
| 246 | typedef struct { |
chiyotsai | 2aac300 | 2020-02-13 17:02:01 -0800 | [diff] [blame] | 247 | const aom_variance_fn_ptr_t *vfp; |
| 248 | SUBPEL_SEARCH_TYPE subpel_search_type; |
chiyotsai | 5aa7075 | 2020-03-26 10:13:10 -0700 | [diff] [blame] | 249 | // Source and reference buffers |
| 250 | MSBuffers ms_buffers; |
chiyotsai | 2aac300 | 2020-02-13 17:02:01 -0800 | [diff] [blame] | 251 | int w, h; |
chiyotsai | a742e7d | 2020-02-14 17:27:58 -0800 | [diff] [blame] | 252 | } SUBPEL_SEARCH_VAR_PARAMS; |
chiyotsai | 2aac300 | 2020-02-13 17:02:01 -0800 | [diff] [blame] | 253 | |
| 254 | // This struct holds subpixel motion search parameters that should be constant |
| 255 | // during the search |
| 256 | typedef struct { |
| 257 | // High level motion search settings |
| 258 | int allow_hp; |
| 259 | const int *cost_list; |
| 260 | SUBPEL_FORCE_STOP forced_stop; |
| 261 | int iters_per_step; |
chiyotsai | 5aa7075 | 2020-03-26 10:13:10 -0700 | [diff] [blame] | 262 | SubpelMvLimits mv_limits; |
chiyotsai | 2aac300 | 2020-02-13 17:02:01 -0800 | [diff] [blame] | 263 | |
| 264 | // For calculating mv cost |
| 265 | MV_COST_PARAMS mv_cost_params; |
| 266 | |
| 267 | // Distortion calculation params |
chiyotsai | a742e7d | 2020-02-14 17:27:58 -0800 | [diff] [blame] | 268 | SUBPEL_SEARCH_VAR_PARAMS var_params; |
chiyotsai | 2aac300 | 2020-02-13 17:02:01 -0800 | [diff] [blame] | 269 | } SUBPEL_MOTION_SEARCH_PARAMS; |
| 270 | |
chiyotsai | 083db97 | 2020-03-30 11:43:52 -0700 | [diff] [blame] | 271 | void av1_make_default_subpel_ms_params(SUBPEL_MOTION_SEARCH_PARAMS *ms_params, |
| 272 | const struct AV1_COMP *cpi, |
| 273 | const MACROBLOCK *x, BLOCK_SIZE bsize, |
chiyotsai | 4d1b7d9 | 2020-04-07 13:56:22 -0700 | [diff] [blame^] | 274 | const MV *ref_mv, const int *cost_list); |
chiyotsai | 2aac300 | 2020-02-13 17:02:01 -0800 | [diff] [blame] | 275 | |
chiyotsai | 5aa7075 | 2020-03-26 10:13:10 -0700 | [diff] [blame] | 276 | typedef int(fractional_mv_step_fp)(MACROBLOCKD *xd, const AV1_COMMON *const cm, |
chiyotsai | 2aac300 | 2020-02-13 17:02:01 -0800 | [diff] [blame] | 277 | const SUBPEL_MOTION_SEARCH_PARAMS *ms_params, |
Yaowu Xu | f8b0e9b | 2020-03-31 13:14:38 -0700 | [diff] [blame] | 278 | MV start_mv, MV *bestmv, int *distortion, |
| 279 | unsigned int *sse1, |
chiyotsai | 5aa7075 | 2020-03-26 10:13:10 -0700 | [diff] [blame] | 280 | int_mv *last_mv_search_list); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 281 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 282 | extern fractional_mv_step_fp av1_find_best_sub_pixel_tree; |
| 283 | extern fractional_mv_step_fp av1_find_best_sub_pixel_tree_pruned; |
| 284 | extern fractional_mv_step_fp av1_find_best_sub_pixel_tree_pruned_more; |
| 285 | extern fractional_mv_step_fp av1_find_best_sub_pixel_tree_pruned_evenmore; |
Yunqing Wang | ff4fa06 | 2017-04-21 10:56:08 -0700 | [diff] [blame] | 286 | extern fractional_mv_step_fp av1_return_max_sub_pixel_mv; |
| 287 | extern fractional_mv_step_fp av1_return_min_sub_pixel_mv; |
chiyotsai | 2aac300 | 2020-02-13 17:02:01 -0800 | [diff] [blame] | 288 | extern fractional_mv_step_fp av1_find_best_obmc_sub_pixel_tree_up; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 289 | |
chiyotsai | 74da72b | 2020-04-07 13:45:40 -0700 | [diff] [blame] | 290 | unsigned int av1_refine_warped_mv(MACROBLOCKD *xd, const AV1_COMMON *const cm, |
| 291 | const SUBPEL_MOTION_SEARCH_PARAMS *ms_params, |
| 292 | BLOCK_SIZE bsize, const int *pts0, |
| 293 | const int *pts_inref0, int total_samples); |
chiyotsai | 30a5bdf | 2020-04-06 14:28:59 -0700 | [diff] [blame] | 294 | |
Venkat | e846e2b | 2018-09-21 07:31:14 +0530 | [diff] [blame] | 295 | static INLINE void av1_set_fractional_mv(int_mv *fractional_best_mv) { |
| 296 | for (int z = 0; z < 3; z++) { |
| 297 | fractional_best_mv[z].as_int = INVALID_MV; |
| 298 | } |
| 299 | } |
| 300 | |
chiyotsai | 2ad959b | 2020-02-12 14:29:32 -0800 | [diff] [blame] | 301 | static INLINE void av1_set_subpel_mv_search_range(SubpelMvLimits *subpel_limits, |
| 302 | const FullMvLimits *mv_limits, |
| 303 | const MV *ref_mv) { |
chiyotsai | 87bb805 | 2020-02-12 16:56:33 -0800 | [diff] [blame] | 304 | const int max_mv = GET_MV_SUBPEL(MAX_FULL_PEL_VAL); |
| 305 | const int minc = |
| 306 | AOMMAX(GET_MV_SUBPEL(mv_limits->col_min), ref_mv->col - max_mv); |
| 307 | const int maxc = |
| 308 | AOMMIN(GET_MV_SUBPEL(mv_limits->col_max), ref_mv->col + max_mv); |
| 309 | const int minr = |
| 310 | AOMMAX(GET_MV_SUBPEL(mv_limits->row_min), ref_mv->row - max_mv); |
| 311 | const int maxr = |
| 312 | AOMMIN(GET_MV_SUBPEL(mv_limits->row_max), ref_mv->row + max_mv); |
Yunqing Wang | da21361 | 2019-06-12 08:47:03 -0700 | [diff] [blame] | 313 | |
chiyotsai | 2ad959b | 2020-02-12 14:29:32 -0800 | [diff] [blame] | 314 | subpel_limits->col_min = AOMMAX(MV_LOW + 1, minc); |
| 315 | subpel_limits->col_max = AOMMIN(MV_UPP - 1, maxc); |
| 316 | subpel_limits->row_min = AOMMAX(MV_LOW + 1, minr); |
| 317 | subpel_limits->row_max = AOMMIN(MV_UPP - 1, maxr); |
| 318 | } |
| 319 | |
chiyotsai | 2ad959b | 2020-02-12 14:29:32 -0800 | [diff] [blame] | 320 | static INLINE int av1_is_subpelmv_in_range(const SubpelMvLimits *mv_limits, |
| 321 | MV mv) { |
| 322 | return (mv.col >= mv_limits->col_min) && (mv.col <= mv_limits->col_max) && |
| 323 | (mv.row >= mv_limits->row_min) && (mv.row <= mv_limits->row_max); |
Yunqing Wang | da21361 | 2019-06-12 08:47:03 -0700 | [diff] [blame] | 324 | } |
| 325 | |
Peng Bin | 6e2ced6 | 2018-05-08 11:34:36 +0800 | [diff] [blame] | 326 | #ifdef __cplusplus |
| 327 | } // extern "C" |
| 328 | #endif |
| 329 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 330 | #endif // AOM_AV1_ENCODER_MCOMP_H_ |