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_COMMON_RECONINTER_H_ |
| 13 | #define AOM_AV1_COMMON_RECONINTER_H_ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 14 | |
| 15 | #include "av1/common/filter.h" |
| 16 | #include "av1/common/onyxc_int.h" |
Yaowu Xu | 6557ea9 | 2016-10-31 16:33:36 -0700 | [diff] [blame] | 17 | #include "av1/common/convolve.h" |
Sarah Parker | c2d3871 | 2017-01-24 15:15:41 -0800 | [diff] [blame] | 18 | #include "av1/common/warped_motion.h" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 19 | #include "aom/aom_integer.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 20 | |
David Barker | b3b5304 | 2017-11-23 13:13:30 +0000 | [diff] [blame] | 21 | // Work out how many pixels off the edge of a reference frame we're allowed |
| 22 | // to go when forming an inter prediction. |
| 23 | // The outermost row/col of each referernce frame is extended by |
| 24 | // (AOM_BORDER_IN_PIXELS >> subsampling) pixels, but we need to keep |
| 25 | // at least AOM_INTERP_EXTEND pixels within that to account for filtering. |
| 26 | // |
| 27 | // We have to break this up into two macros to keep both clang-format and |
| 28 | // tools/lint-hunks.py happy. |
| 29 | #define AOM_LEFT_TOP_MARGIN_PX(subsampling) \ |
| 30 | ((AOM_BORDER_IN_PIXELS >> subsampling) - AOM_INTERP_EXTEND) |
| 31 | #define AOM_LEFT_TOP_MARGIN_SCALED(subsampling) \ |
| 32 | (AOM_LEFT_TOP_MARGIN_PX(subsampling) << SCALE_SUBPEL_BITS) |
Debargha Mukherjee | 5433fa4 | 2017-10-10 09:55:51 -0700 | [diff] [blame] | 33 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 34 | #ifdef __cplusplus |
| 35 | extern "C" { |
| 36 | #endif |
| 37 | |
Debargha Mukherjee | c54594f | 2017-04-27 02:08:22 -0700 | [diff] [blame] | 38 | // Set to (1 << 5) if the 32-ary codebooks are used for any bock size |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 39 | #define MAX_WEDGE_TYPES (1 << 4) |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 40 | |
| 41 | #define MAX_WEDGE_SIZE_LOG2 5 // 32x32 |
| 42 | #define MAX_WEDGE_SIZE (1 << MAX_WEDGE_SIZE_LOG2) |
| 43 | #define MAX_WEDGE_SQUARE (MAX_WEDGE_SIZE * MAX_WEDGE_SIZE) |
| 44 | |
| 45 | #define WEDGE_WEIGHT_BITS 6 |
| 46 | |
| 47 | #define WEDGE_NONE -1 |
| 48 | |
| 49 | // Angles are with respect to horizontal anti-clockwise |
Satish Kumar Suman | 4667aa1 | 2018-12-14 18:28:19 +0530 | [diff] [blame] | 50 | enum { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 51 | WEDGE_HORIZONTAL = 0, |
| 52 | WEDGE_VERTICAL = 1, |
| 53 | WEDGE_OBLIQUE27 = 2, |
| 54 | WEDGE_OBLIQUE63 = 3, |
| 55 | WEDGE_OBLIQUE117 = 4, |
| 56 | WEDGE_OBLIQUE153 = 5, |
| 57 | WEDGE_DIRECTIONS |
Satish Kumar Suman | 4667aa1 | 2018-12-14 18:28:19 +0530 | [diff] [blame] | 58 | } UENUM1BYTE(WedgeDirectionType); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 59 | |
| 60 | // 3-tuple: {direction, x_offset, y_offset} |
| 61 | typedef struct { |
| 62 | WedgeDirectionType direction; |
| 63 | int x_offset; |
| 64 | int y_offset; |
| 65 | } wedge_code_type; |
| 66 | |
| 67 | typedef uint8_t *wedge_masks_type[MAX_WEDGE_TYPES]; |
| 68 | |
| 69 | typedef struct { |
| 70 | int bits; |
| 71 | const wedge_code_type *codebook; |
| 72 | uint8_t *signflip; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 73 | wedge_masks_type *masks; |
| 74 | } wedge_params_type; |
| 75 | |
Yaowu Xu | e51a494 | 2019-05-06 09:53:44 -0700 | [diff] [blame] | 76 | extern const wedge_params_type av1_wedge_params_lookup[BLOCK_SIZES_ALL]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 77 | |
Ravi Chaudhary | 6ac4b13 | 2018-05-08 16:34:44 +0530 | [diff] [blame] | 78 | typedef struct SubpelParams { |
| 79 | int xs; |
| 80 | int ys; |
| 81 | int subpel_x; |
| 82 | int subpel_y; |
| 83 | } SubpelParams; |
| 84 | |
| 85 | struct build_prediction_ctxt { |
| 86 | const AV1_COMMON *cm; |
| 87 | int mi_row; |
| 88 | int mi_col; |
| 89 | uint8_t **tmp_buf; |
| 90 | int *tmp_width; |
| 91 | int *tmp_height; |
| 92 | int *tmp_stride; |
| 93 | int mb_to_far_edge; |
| 94 | }; |
| 95 | |
Peng Bin | 088bfd0 | 2018-05-21 11:34:44 +0800 | [diff] [blame] | 96 | static INLINE int has_scale(int xs, int ys) { |
| 97 | return xs != SCALE_SUBPEL_SHIFTS || ys != SCALE_SUBPEL_SHIFTS; |
| 98 | } |
| 99 | |
| 100 | static INLINE void revert_scale_extra_bits(SubpelParams *sp) { |
| 101 | sp->subpel_x >>= SCALE_EXTRA_BITS; |
| 102 | sp->subpel_y >>= SCALE_EXTRA_BITS; |
| 103 | sp->xs >>= SCALE_EXTRA_BITS; |
| 104 | sp->ys >>= SCALE_EXTRA_BITS; |
| 105 | assert(sp->subpel_x < SUBPEL_SHIFTS); |
| 106 | assert(sp->subpel_y < SUBPEL_SHIFTS); |
| 107 | assert(sp->xs <= SUBPEL_SHIFTS); |
| 108 | assert(sp->ys <= SUBPEL_SHIFTS); |
| 109 | } |
| 110 | |
| 111 | static INLINE void inter_predictor(const uint8_t *src, int src_stride, |
| 112 | uint8_t *dst, int dst_stride, |
| 113 | const SubpelParams *subpel_params, |
| 114 | const struct scale_factors *sf, int w, int h, |
| 115 | ConvolveParams *conv_params, |
Hui Su | d547fa6 | 2018-09-06 16:13:58 -0700 | [diff] [blame] | 116 | InterpFilters interp_filters, |
| 117 | int is_intrabc) { |
Peng Bin | 088bfd0 | 2018-05-21 11:34:44 +0800 | [diff] [blame] | 118 | assert(conv_params->do_average == 0 || conv_params->do_average == 1); |
| 119 | assert(sf); |
Hui Su | d547fa6 | 2018-09-06 16:13:58 -0700 | [diff] [blame] | 120 | const int is_scaled = has_scale(subpel_params->xs, subpel_params->ys); |
| 121 | assert(IMPLIES(is_intrabc, !is_scaled)); |
| 122 | if (is_scaled) { |
Peng Bin | 088bfd0 | 2018-05-21 11:34:44 +0800 | [diff] [blame] | 123 | av1_convolve_2d_facade(src, src_stride, dst, dst_stride, w, h, |
| 124 | interp_filters, subpel_params->subpel_x, |
| 125 | subpel_params->xs, subpel_params->subpel_y, |
Hui Su | d547fa6 | 2018-09-06 16:13:58 -0700 | [diff] [blame] | 126 | subpel_params->ys, 1, conv_params, sf, is_intrabc); |
Peng Bin | 088bfd0 | 2018-05-21 11:34:44 +0800 | [diff] [blame] | 127 | } else { |
| 128 | SubpelParams sp = *subpel_params; |
| 129 | revert_scale_extra_bits(&sp); |
| 130 | av1_convolve_2d_facade(src, src_stride, dst, dst_stride, w, h, |
| 131 | interp_filters, sp.subpel_x, sp.xs, sp.subpel_y, |
Hui Su | d547fa6 | 2018-09-06 16:13:58 -0700 | [diff] [blame] | 132 | sp.ys, 0, conv_params, sf, is_intrabc); |
Peng Bin | 088bfd0 | 2018-05-21 11:34:44 +0800 | [diff] [blame] | 133 | } |
| 134 | } |
| 135 | |
Hui Su | d547fa6 | 2018-09-06 16:13:58 -0700 | [diff] [blame] | 136 | static INLINE void highbd_inter_predictor(const uint8_t *src, int src_stride, |
| 137 | uint8_t *dst, int dst_stride, |
| 138 | const SubpelParams *subpel_params, |
| 139 | const struct scale_factors *sf, int w, |
| 140 | int h, ConvolveParams *conv_params, |
| 141 | InterpFilters interp_filters, |
| 142 | int is_intrabc, int bd) { |
Peng Bin | 088bfd0 | 2018-05-21 11:34:44 +0800 | [diff] [blame] | 143 | assert(conv_params->do_average == 0 || conv_params->do_average == 1); |
| 144 | assert(sf); |
Hui Su | d547fa6 | 2018-09-06 16:13:58 -0700 | [diff] [blame] | 145 | const int is_scaled = has_scale(subpel_params->xs, subpel_params->ys); |
| 146 | assert(IMPLIES(is_intrabc, !is_scaled)); |
| 147 | if (is_scaled) { |
| 148 | av1_highbd_convolve_2d_facade( |
| 149 | src, src_stride, dst, dst_stride, w, h, interp_filters, |
| 150 | subpel_params->subpel_x, subpel_params->xs, subpel_params->subpel_y, |
| 151 | subpel_params->ys, 1, conv_params, sf, is_intrabc, bd); |
Peng Bin | 088bfd0 | 2018-05-21 11:34:44 +0800 | [diff] [blame] | 152 | } else { |
| 153 | SubpelParams sp = *subpel_params; |
| 154 | revert_scale_extra_bits(&sp); |
Hui Su | d547fa6 | 2018-09-06 16:13:58 -0700 | [diff] [blame] | 155 | av1_highbd_convolve_2d_facade( |
| 156 | src, src_stride, dst, dst_stride, w, h, interp_filters, sp.subpel_x, |
| 157 | sp.xs, sp.subpel_y, sp.ys, 0, conv_params, sf, is_intrabc, bd); |
Peng Bin | 088bfd0 | 2018-05-21 11:34:44 +0800 | [diff] [blame] | 158 | } |
| 159 | } |
| 160 | |
Ravi Chaudhary | 6ac4b13 | 2018-05-08 16:34:44 +0530 | [diff] [blame] | 161 | void av1_modify_neighbor_predictor_for_obmc(MB_MODE_INFO *mbmi); |
| 162 | int av1_skip_u4x4_pred_in_obmc(BLOCK_SIZE bsize, |
| 163 | const struct macroblockd_plane *pd, int dir); |
| 164 | |
Sarah Parker | 42d9610 | 2017-01-31 21:05:27 -0800 | [diff] [blame] | 165 | static INLINE int is_interinter_compound_used(COMPOUND_TYPE type, |
| 166 | BLOCK_SIZE sb_type) { |
Zoe Liu | 8efc827 | 2017-11-30 14:20:33 -0800 | [diff] [blame] | 167 | const int comp_allowed = is_comp_ref_allowed(sb_type); |
Sarah Parker | 42d9610 | 2017-01-31 21:05:27 -0800 | [diff] [blame] | 168 | switch (type) { |
Zoe Liu | 8efc827 | 2017-11-30 14:20:33 -0800 | [diff] [blame] | 169 | case COMPOUND_AVERAGE: |
Debargha Mukherjee | 54eabb5 | 2019-02-01 16:54:33 -0800 | [diff] [blame] | 170 | case COMPOUND_DISTWTD: |
Sarah Parker | 5b4df2b | 2018-04-02 14:48:25 -0700 | [diff] [blame] | 171 | case COMPOUND_DIFFWTD: return comp_allowed; |
Zoe Liu | 8efc827 | 2017-11-30 14:20:33 -0800 | [diff] [blame] | 172 | case COMPOUND_WEDGE: |
Yaowu Xu | e51a494 | 2019-05-06 09:53:44 -0700 | [diff] [blame] | 173 | return comp_allowed && av1_wedge_params_lookup[sb_type].bits > 0; |
Sarah Parker | 42d9610 | 2017-01-31 21:05:27 -0800 | [diff] [blame] | 174 | default: assert(0); return 0; |
| 175 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 176 | } |
| 177 | |
Sarah Parker | 42d9610 | 2017-01-31 21:05:27 -0800 | [diff] [blame] | 178 | static INLINE int is_any_masked_compound_used(BLOCK_SIZE sb_type) { |
| 179 | COMPOUND_TYPE comp_type; |
Peng Bin | 33ba1fe | 2018-01-24 11:48:08 +0800 | [diff] [blame] | 180 | int i; |
Zoe Liu | 8efc827 | 2017-11-30 14:20:33 -0800 | [diff] [blame] | 181 | if (!is_comp_ref_allowed(sb_type)) return 0; |
Peng Bin | 33ba1fe | 2018-01-24 11:48:08 +0800 | [diff] [blame] | 182 | for (i = 0; i < COMPOUND_TYPES; i++) { |
| 183 | comp_type = (COMPOUND_TYPE)i; |
Sarah Parker | 42d9610 | 2017-01-31 21:05:27 -0800 | [diff] [blame] | 184 | if (is_masked_compound_type(comp_type) && |
| 185 | is_interinter_compound_used(comp_type, sb_type)) |
| 186 | return 1; |
| 187 | } |
| 188 | return 0; |
| 189 | } |
| 190 | |
| 191 | static INLINE int get_wedge_bits_lookup(BLOCK_SIZE sb_type) { |
Yaowu Xu | e51a494 | 2019-05-06 09:53:44 -0700 | [diff] [blame] | 192 | return av1_wedge_params_lookup[sb_type].bits; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | static INLINE int get_interinter_wedge_bits(BLOCK_SIZE sb_type) { |
Yaowu Xu | e51a494 | 2019-05-06 09:53:44 -0700 | [diff] [blame] | 196 | const int wbits = av1_wedge_params_lookup[sb_type].bits; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 197 | return (wbits > 0) ? wbits + 1 : 0; |
| 198 | } |
| 199 | |
| 200 | static INLINE int is_interintra_wedge_used(BLOCK_SIZE sb_type) { |
Yaowu Xu | e51a494 | 2019-05-06 09:53:44 -0700 | [diff] [blame] | 201 | return av1_wedge_params_lookup[sb_type].bits > 0; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | static INLINE int get_interintra_wedge_bits(BLOCK_SIZE sb_type) { |
Yaowu Xu | e51a494 | 2019-05-06 09:53:44 -0700 | [diff] [blame] | 205 | return av1_wedge_params_lookup[sb_type].bits; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 206 | } |
Sarah Parker | 569edda | 2016-12-14 14:57:38 -0800 | [diff] [blame] | 207 | |
Peng Bin | 9295fca | 2018-05-18 13:46:12 +0800 | [diff] [blame] | 208 | void av1_make_inter_predictor(const uint8_t *src, int src_stride, uint8_t *dst, |
| 209 | int dst_stride, const SubpelParams *subpel_params, |
| 210 | const struct scale_factors *sf, int w, int h, |
| 211 | ConvolveParams *conv_params, |
| 212 | InterpFilters interp_filters, |
| 213 | const WarpTypesAllowed *warp_types, int p_col, |
| 214 | int p_row, int plane, int ref, |
| 215 | const MB_MODE_INFO *mi, int build_for_obmc, |
| 216 | const MACROBLOCKD *xd, int can_use_previous); |
Urvang Joshi | 52b6299 | 2018-02-02 14:43:07 -0800 | [diff] [blame] | 217 | |
Rupert Swarbrick | 27e9029 | 2017-09-28 17:46:50 +0100 | [diff] [blame] | 218 | void av1_make_masked_inter_predictor( |
| 219 | const uint8_t *pre, int pre_stride, uint8_t *dst, int dst_stride, |
Peng Bin | 9295fca | 2018-05-18 13:46:12 +0800 | [diff] [blame] | 220 | const SubpelParams *subpel_params, const struct scale_factors *sf, int w, |
| 221 | int h, ConvolveParams *conv_params, InterpFilters interp_filters, int plane, |
Peng Bin | 8c41e3a | 2018-05-18 13:10:28 +0800 | [diff] [blame] | 222 | const WarpTypesAllowed *warp_types, int p_col, int p_row, int ref, |
| 223 | MACROBLOCKD *xd, int can_use_previous); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 224 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 225 | // TODO(jkoleszar): yet another mv clamping function :-( |
Remy Foray | 9333b31 | 2018-11-28 09:17:05 +0000 | [diff] [blame] | 226 | static INLINE MV clamp_mv_to_umv_border_sb(const MACROBLOCKD *xd, |
| 227 | const MV *src_mv, int bw, int bh, |
| 228 | int ss_x, int ss_y) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 229 | // If the MV points so far into the UMV border that no visible pixels |
| 230 | // are used for reconstruction, the subpel part of the MV can be |
| 231 | // discarded and the MV limited to 16 pixels with equivalent results. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 232 | const int spel_left = (AOM_INTERP_EXTEND + bw) << SUBPEL_BITS; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 233 | const int spel_right = spel_left - SUBPEL_SHIFTS; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 234 | const int spel_top = (AOM_INTERP_EXTEND + bh) << SUBPEL_BITS; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 235 | const int spel_bottom = spel_top - SUBPEL_SHIFTS; |
Remy Foray | 9333b31 | 2018-11-28 09:17:05 +0000 | [diff] [blame] | 236 | MV clamped_mv = { (int16_t)(src_mv->row * (1 << (1 - ss_y))), |
| 237 | (int16_t)(src_mv->col * (1 << (1 - ss_x))) }; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 238 | assert(ss_x <= 1); |
| 239 | assert(ss_y <= 1); |
| 240 | |
Remy Foray | 9333b31 | 2018-11-28 09:17:05 +0000 | [diff] [blame] | 241 | clamp_mv(&clamped_mv, xd->mb_to_left_edge * (1 << (1 - ss_x)) - spel_left, |
| 242 | xd->mb_to_right_edge * (1 << (1 - ss_x)) + spel_right, |
| 243 | xd->mb_to_top_edge * (1 << (1 - ss_y)) - spel_top, |
| 244 | xd->mb_to_bottom_edge * (1 << (1 - ss_y)) + spel_bottom); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 245 | |
| 246 | return clamped_mv; |
| 247 | } |
| 248 | |
Jerome Jiang | d289a89 | 2019-03-12 15:28:02 -0700 | [diff] [blame] | 249 | static INLINE int64_t scaled_buffer_offset(int x_offset, int y_offset, |
| 250 | int stride, |
| 251 | const struct scale_factors *sf) { |
Debargha Mukherjee | 1583614 | 2017-06-27 07:07:31 -0700 | [diff] [blame] | 252 | const int x = |
| 253 | sf ? sf->scale_value_x(x_offset, sf) >> SCALE_EXTRA_BITS : x_offset; |
| 254 | const int y = |
| 255 | sf ? sf->scale_value_y(y_offset, sf) >> SCALE_EXTRA_BITS : y_offset; |
Jerome Jiang | d289a89 | 2019-03-12 15:28:02 -0700 | [diff] [blame] | 256 | return (int64_t)y * stride + x; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 257 | } |
| 258 | |
Jingning Han | 91d9a79 | 2017-04-18 12:01:52 -0700 | [diff] [blame] | 259 | static INLINE void setup_pred_plane(struct buf_2d *dst, BLOCK_SIZE bsize, |
| 260 | uint8_t *src, int width, int height, |
| 261 | int stride, int mi_row, int mi_col, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 262 | const struct scale_factors *scale, |
| 263 | int subsampling_x, int subsampling_y) { |
Rupert Swarbrick | 6a93b15 | 2017-08-09 10:18:21 +0100 | [diff] [blame] | 264 | // Offset the buffer pointer |
| 265 | if (subsampling_y && (mi_row & 0x01) && (mi_size_high[bsize] == 1)) |
| 266 | mi_row -= 1; |
| 267 | if (subsampling_x && (mi_col & 0x01) && (mi_size_wide[bsize] == 1)) |
| 268 | mi_col -= 1; |
Jingning Han | 91d9a79 | 2017-04-18 12:01:52 -0700 | [diff] [blame] | 269 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 270 | const int x = (MI_SIZE * mi_col) >> subsampling_x; |
| 271 | const int y = (MI_SIZE * mi_row) >> subsampling_y; |
| 272 | dst->buf = src + scaled_buffer_offset(x, y, stride, scale); |
| 273 | dst->buf0 = src; |
| 274 | dst->width = width; |
| 275 | dst->height = height; |
| 276 | dst->stride = stride; |
| 277 | } |
| 278 | |
Yaowu Xu | 989dd5b | 2017-10-11 21:59:46 -0700 | [diff] [blame] | 279 | void av1_setup_dst_planes(struct macroblockd_plane *planes, BLOCK_SIZE bsize, |
Imdad Sardharwalla | af8e264 | 2018-01-19 11:46:34 +0000 | [diff] [blame] | 280 | const YV12_BUFFER_CONFIG *src, int mi_row, int mi_col, |
Deepa K G | 7d4a0c1 | 2018-04-11 18:20:14 +0530 | [diff] [blame] | 281 | const int plane_start, const int plane_end); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 282 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 283 | void av1_setup_pre_planes(MACROBLOCKD *xd, int idx, |
| 284 | const YV12_BUFFER_CONFIG *src, int mi_row, int mi_col, |
Imdad Sardharwalla | af8e264 | 2018-01-19 11:46:34 +0000 | [diff] [blame] | 285 | const struct scale_factors *sf, const int num_planes); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 286 | |
Debargha Mukherjee | 0df711f | 2017-05-02 16:00:20 -0700 | [diff] [blame] | 287 | static INLINE void set_default_interp_filters( |
| 288 | MB_MODE_INFO *const mbmi, InterpFilter frame_interp_filter) { |
Rupert Swarbrick | 27e9029 | 2017-09-28 17:46:50 +0100 | [diff] [blame] | 289 | mbmi->interp_filters = |
| 290 | av1_broadcast_interp_filter(av1_unswitchable_filter(frame_interp_filter)); |
Debargha Mukherjee | 0df711f | 2017-05-02 16:00:20 -0700 | [diff] [blame] | 291 | } |
| 292 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 293 | static INLINE int av1_is_interp_needed(const MACROBLOCKD *const xd) { |
Yue Chen | 53b53f0 | 2018-03-29 14:31:23 -0700 | [diff] [blame] | 294 | const MB_MODE_INFO *const mbmi = xd->mi[0]; |
Zoe Liu | f704a1c | 2017-10-02 16:55:59 -0700 | [diff] [blame] | 295 | if (mbmi->skip_mode) return 0; |
Zoe Liu | f40a957 | 2017-10-13 12:37:19 -0700 | [diff] [blame] | 296 | if (mbmi->motion_mode == WARPED_CAUSAL) return 0; |
Debargha Mukherjee | 0565387 | 2018-04-26 15:31:27 -0700 | [diff] [blame] | 297 | if (is_nontrans_global_motion(xd, xd->mi[0])) return 0; |
Debargha Mukherjee | 0df711f | 2017-05-02 16:00:20 -0700 | [diff] [blame] | 298 | return 1; |
| 299 | } |
| 300 | |
Ravi Chaudhary | 6ac4b13 | 2018-05-08 16:34:44 +0530 | [diff] [blame] | 301 | void av1_setup_build_prediction_by_above_pred( |
| 302 | MACROBLOCKD *xd, int rel_mi_col, uint8_t above_mi_width, |
| 303 | MB_MODE_INFO *above_mbmi, struct build_prediction_ctxt *ctxt, |
| 304 | const int num_planes); |
| 305 | void av1_setup_build_prediction_by_left_pred(MACROBLOCKD *xd, int rel_mi_row, |
| 306 | uint8_t left_mi_height, |
| 307 | MB_MODE_INFO *left_mbmi, |
| 308 | struct build_prediction_ctxt *ctxt, |
| 309 | const int num_planes); |
Yue Chen | 19d7601 | 2018-02-16 15:13:40 -0800 | [diff] [blame] | 310 | void av1_build_obmc_inter_prediction(const AV1_COMMON *cm, MACROBLOCKD *xd, |
| 311 | int mi_row, int mi_col, |
| 312 | uint8_t *above[MAX_MB_PLANE], |
| 313 | int above_stride[MAX_MB_PLANE], |
| 314 | uint8_t *left[MAX_MB_PLANE], |
| 315 | int left_stride[MAX_MB_PLANE]); |
Yue Chen | 19d7601 | 2018-02-16 15:13:40 -0800 | [diff] [blame] | 316 | |
| 317 | const uint8_t *av1_get_obmc_mask(int length); |
| 318 | void av1_count_overlappable_neighbors(const AV1_COMMON *cm, MACROBLOCKD *xd, |
| 319 | int mi_row, int mi_col); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 320 | |
Debargha Mukherjee | c54594f | 2017-04-27 02:08:22 -0700 | [diff] [blame] | 321 | #define MASK_MASTER_SIZE ((MAX_WEDGE_SIZE) << 1) |
| 322 | #define MASK_MASTER_STRIDE (MASK_MASTER_SIZE) |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 323 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 324 | void av1_init_wedge_masks(); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 325 | |
Remya | f75b984 | 2019-06-13 15:54:17 +0530 | [diff] [blame] | 326 | static INLINE const uint8_t *av1_get_contiguous_soft_mask(int8_t wedge_index, |
| 327 | int8_t wedge_sign, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 328 | BLOCK_SIZE sb_type) { |
Yaowu Xu | e51a494 | 2019-05-06 09:53:44 -0700 | [diff] [blame] | 329 | return av1_wedge_params_lookup[sb_type].masks[wedge_sign][wedge_index]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 330 | } |
| 331 | |
Sarah Parker | b9f757c | 2017-01-06 17:12:24 -0800 | [diff] [blame] | 332 | const uint8_t *av1_get_compound_type_mask( |
| 333 | const INTERINTER_COMPOUND_DATA *const comp_data, BLOCK_SIZE sb_type); |
Yue Chen | 670b660 | 2017-10-30 16:57:42 -0700 | [diff] [blame] | 334 | |
Peng Bin | c4b0b0d | 2018-07-03 21:15:39 +0800 | [diff] [blame] | 335 | // build interintra_predictors for one plane |
| 336 | void av1_build_interintra_predictors_sbp(const AV1_COMMON *cm, MACROBLOCKD *xd, |
| 337 | uint8_t *pred, int stride, |
Hui Su | ee7a9c0 | 2019-01-24 15:10:31 -0800 | [diff] [blame] | 338 | const BUFFER_SET *ctx, int plane, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 339 | BLOCK_SIZE bsize); |
Yue Chen | 670b660 | 2017-10-30 16:57:42 -0700 | [diff] [blame] | 340 | |
David Barker | 761b1ac | 2017-09-25 11:23:03 +0100 | [diff] [blame] | 341 | void av1_build_interintra_predictors_sbuv(const AV1_COMMON *cm, MACROBLOCKD *xd, |
| 342 | uint8_t *upred, uint8_t *vpred, |
| 343 | int ustride, int vstride, |
Hui Su | ee7a9c0 | 2019-01-24 15:10:31 -0800 | [diff] [blame] | 344 | const BUFFER_SET *ctx, |
| 345 | BLOCK_SIZE bsize); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 346 | |
Yaowu Xu | dcf7217 | 2019-05-10 15:46:22 -0700 | [diff] [blame] | 347 | void av1_build_intra_predictors_for_interintra(const AV1_COMMON *cm, |
| 348 | MACROBLOCKD *xd, |
| 349 | BLOCK_SIZE bsize, int plane, |
| 350 | const BUFFER_SET *ctx, |
| 351 | uint8_t *dst, int dst_stride); |
Peng Bin | c4b0b0d | 2018-07-03 21:15:39 +0800 | [diff] [blame] | 352 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 353 | void av1_combine_interintra(MACROBLOCKD *xd, BLOCK_SIZE bsize, int plane, |
| 354 | const uint8_t *inter_pred, int inter_stride, |
| 355 | const uint8_t *intra_pred, int intra_stride); |
Yue Chen | 670b660 | 2017-10-30 16:57:42 -0700 | [diff] [blame] | 356 | |
Debargha Mukherjee | 7ac3eb1 | 2018-12-12 10:26:50 -0800 | [diff] [blame] | 357 | void av1_dist_wtd_comp_weight_assign(const AV1_COMMON *cm, |
| 358 | const MB_MODE_INFO *mbmi, int order_idx, |
| 359 | int *fwd_offset, int *bck_offset, |
| 360 | int *use_dist_wtd_comp_avg, |
| 361 | int is_compound); |
Ravi Chaudhary | 18c5f6f | 2018-06-06 13:43:07 +0530 | [diff] [blame] | 362 | int av1_allow_warp(const MB_MODE_INFO *const mbmi, |
| 363 | const WarpTypesAllowed *const warp_types, |
| 364 | const WarpedMotionParams *const gm_params, |
Urvang Joshi | e386338 | 2018-10-04 12:07:25 -0700 | [diff] [blame] | 365 | int build_for_obmc, const struct scale_factors *const sf, |
Ravi Chaudhary | 18c5f6f | 2018-06-06 13:43:07 +0530 | [diff] [blame] | 366 | WarpedMotionParams *final_warp_params); |
Cheng Chen | f78632e | 2017-10-20 15:30:51 -0700 | [diff] [blame] | 367 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 368 | #ifdef __cplusplus |
| 369 | } // extern "C" |
| 370 | #endif |
| 371 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 372 | #endif // AOM_AV1_COMMON_RECONINTER_H_ |