1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker *
4*77c1e3ccSAndroid Build Coastguard Worker * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker */
11*77c1e3ccSAndroid Build Coastguard Worker
12*77c1e3ccSAndroid Build Coastguard Worker #include <assert.h>
13*77c1e3ccSAndroid Build Coastguard Worker #include <stdio.h>
14*77c1e3ccSAndroid Build Coastguard Worker #include <limits.h>
15*77c1e3ccSAndroid Build Coastguard Worker
16*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_config.h"
17*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_dsp_rtcd.h"
18*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_scale_rtcd.h"
19*77c1e3ccSAndroid Build Coastguard Worker
20*77c1e3ccSAndroid Build Coastguard Worker #include "aom/aom_integer.h"
21*77c1e3ccSAndroid Build Coastguard Worker #include "aom_dsp/blend.h"
22*77c1e3ccSAndroid Build Coastguard Worker #include "aom_ports/aom_once.h"
23*77c1e3ccSAndroid Build Coastguard Worker
24*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/av1_common_int.h"
25*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/blockd.h"
26*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/mvref_common.h"
27*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/obmc.h"
28*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/reconinter.h"
29*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/reconintra.h"
30*77c1e3ccSAndroid Build Coastguard Worker
31*77c1e3ccSAndroid Build Coastguard Worker // This function will determine whether or not to create a warped
32*77c1e3ccSAndroid Build Coastguard Worker // prediction.
allow_warp(const MB_MODE_INFO * const mbmi,const WarpTypesAllowed * const warp_types,const WarpedMotionParams * const gm_params,int build_for_obmc,const struct scale_factors * const sf,WarpedMotionParams * final_warp_params)33*77c1e3ccSAndroid Build Coastguard Worker static int allow_warp(const MB_MODE_INFO *const mbmi,
34*77c1e3ccSAndroid Build Coastguard Worker const WarpTypesAllowed *const warp_types,
35*77c1e3ccSAndroid Build Coastguard Worker const WarpedMotionParams *const gm_params,
36*77c1e3ccSAndroid Build Coastguard Worker int build_for_obmc, const struct scale_factors *const sf,
37*77c1e3ccSAndroid Build Coastguard Worker WarpedMotionParams *final_warp_params) {
38*77c1e3ccSAndroid Build Coastguard Worker // Note: As per the spec, we must test the fixed point scales here, which are
39*77c1e3ccSAndroid Build Coastguard Worker // at a higher precision (1 << 14) than the xs and ys in subpel_params (that
40*77c1e3ccSAndroid Build Coastguard Worker // have 1 << 10 precision).
41*77c1e3ccSAndroid Build Coastguard Worker if (av1_is_scaled(sf)) return 0;
42*77c1e3ccSAndroid Build Coastguard Worker
43*77c1e3ccSAndroid Build Coastguard Worker if (final_warp_params != NULL) *final_warp_params = default_warp_params;
44*77c1e3ccSAndroid Build Coastguard Worker
45*77c1e3ccSAndroid Build Coastguard Worker if (build_for_obmc) return 0;
46*77c1e3ccSAndroid Build Coastguard Worker
47*77c1e3ccSAndroid Build Coastguard Worker if (warp_types->local_warp_allowed && !mbmi->wm_params.invalid) {
48*77c1e3ccSAndroid Build Coastguard Worker if (final_warp_params != NULL)
49*77c1e3ccSAndroid Build Coastguard Worker memcpy(final_warp_params, &mbmi->wm_params, sizeof(*final_warp_params));
50*77c1e3ccSAndroid Build Coastguard Worker return 1;
51*77c1e3ccSAndroid Build Coastguard Worker } else if (warp_types->global_warp_allowed && !gm_params->invalid) {
52*77c1e3ccSAndroid Build Coastguard Worker if (final_warp_params != NULL)
53*77c1e3ccSAndroid Build Coastguard Worker memcpy(final_warp_params, gm_params, sizeof(*final_warp_params));
54*77c1e3ccSAndroid Build Coastguard Worker return 1;
55*77c1e3ccSAndroid Build Coastguard Worker }
56*77c1e3ccSAndroid Build Coastguard Worker
57*77c1e3ccSAndroid Build Coastguard Worker return 0;
58*77c1e3ccSAndroid Build Coastguard Worker }
59*77c1e3ccSAndroid Build Coastguard Worker
av1_init_warp_params(InterPredParams * inter_pred_params,const WarpTypesAllowed * warp_types,int ref,const MACROBLOCKD * xd,const MB_MODE_INFO * mi)60*77c1e3ccSAndroid Build Coastguard Worker void av1_init_warp_params(InterPredParams *inter_pred_params,
61*77c1e3ccSAndroid Build Coastguard Worker const WarpTypesAllowed *warp_types, int ref,
62*77c1e3ccSAndroid Build Coastguard Worker const MACROBLOCKD *xd, const MB_MODE_INFO *mi) {
63*77c1e3ccSAndroid Build Coastguard Worker if (inter_pred_params->block_height < 8 || inter_pred_params->block_width < 8)
64*77c1e3ccSAndroid Build Coastguard Worker return;
65*77c1e3ccSAndroid Build Coastguard Worker
66*77c1e3ccSAndroid Build Coastguard Worker if (xd->cur_frame_force_integer_mv) return;
67*77c1e3ccSAndroid Build Coastguard Worker
68*77c1e3ccSAndroid Build Coastguard Worker if (allow_warp(mi, warp_types, &xd->global_motion[mi->ref_frame[ref]], 0,
69*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->scale_factors,
70*77c1e3ccSAndroid Build Coastguard Worker &inter_pred_params->warp_params)) {
71*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_REALTIME_ONLY && !CONFIG_AV1_DECODER
72*77c1e3ccSAndroid Build Coastguard Worker aom_internal_error(xd->error_info, AOM_CODEC_UNSUP_FEATURE,
73*77c1e3ccSAndroid Build Coastguard Worker "Warped motion is disabled in realtime only build.");
74*77c1e3ccSAndroid Build Coastguard Worker #endif // CONFIG_REALTIME_ONLY && !CONFIG_AV1_DECODER
75*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->mode = WARP_PRED;
76*77c1e3ccSAndroid Build Coastguard Worker }
77*77c1e3ccSAndroid Build Coastguard Worker }
78*77c1e3ccSAndroid Build Coastguard Worker
av1_make_inter_predictor(const uint8_t * src,int src_stride,uint8_t * dst,int dst_stride,InterPredParams * inter_pred_params,const SubpelParams * subpel_params)79*77c1e3ccSAndroid Build Coastguard Worker void av1_make_inter_predictor(const uint8_t *src, int src_stride, uint8_t *dst,
80*77c1e3ccSAndroid Build Coastguard Worker int dst_stride,
81*77c1e3ccSAndroid Build Coastguard Worker InterPredParams *inter_pred_params,
82*77c1e3ccSAndroid Build Coastguard Worker const SubpelParams *subpel_params) {
83*77c1e3ccSAndroid Build Coastguard Worker assert(IMPLIES(inter_pred_params->conv_params.is_compound,
84*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->conv_params.dst != NULL));
85*77c1e3ccSAndroid Build Coastguard Worker
86*77c1e3ccSAndroid Build Coastguard Worker if (inter_pred_params->mode == TRANSLATION_PRED) {
87*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
88*77c1e3ccSAndroid Build Coastguard Worker if (inter_pred_params->use_hbd_buf) {
89*77c1e3ccSAndroid Build Coastguard Worker highbd_inter_predictor(src, src_stride, dst, dst_stride, subpel_params,
90*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->block_width,
91*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->block_height,
92*77c1e3ccSAndroid Build Coastguard Worker &inter_pred_params->conv_params,
93*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->interp_filter_params,
94*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->bit_depth);
95*77c1e3ccSAndroid Build Coastguard Worker } else {
96*77c1e3ccSAndroid Build Coastguard Worker inter_predictor(src, src_stride, dst, dst_stride, subpel_params,
97*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->block_width,
98*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->block_height,
99*77c1e3ccSAndroid Build Coastguard Worker &inter_pred_params->conv_params,
100*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->interp_filter_params);
101*77c1e3ccSAndroid Build Coastguard Worker }
102*77c1e3ccSAndroid Build Coastguard Worker #else
103*77c1e3ccSAndroid Build Coastguard Worker inter_predictor(src, src_stride, dst, dst_stride, subpel_params,
104*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->block_width,
105*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->block_height,
106*77c1e3ccSAndroid Build Coastguard Worker &inter_pred_params->conv_params,
107*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->interp_filter_params);
108*77c1e3ccSAndroid Build Coastguard Worker #endif
109*77c1e3ccSAndroid Build Coastguard Worker }
110*77c1e3ccSAndroid Build Coastguard Worker #if !CONFIG_REALTIME_ONLY || CONFIG_AV1_DECODER
111*77c1e3ccSAndroid Build Coastguard Worker // TODO(jingning): av1_warp_plane() can be further cleaned up.
112*77c1e3ccSAndroid Build Coastguard Worker else if (inter_pred_params->mode == WARP_PRED) {
113*77c1e3ccSAndroid Build Coastguard Worker av1_warp_plane(
114*77c1e3ccSAndroid Build Coastguard Worker &inter_pred_params->warp_params, inter_pred_params->use_hbd_buf,
115*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->bit_depth, inter_pred_params->ref_frame_buf.buf0,
116*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->ref_frame_buf.width,
117*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->ref_frame_buf.height,
118*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->ref_frame_buf.stride, dst,
119*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->pix_col, inter_pred_params->pix_row,
120*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->block_width, inter_pred_params->block_height,
121*77c1e3ccSAndroid Build Coastguard Worker dst_stride, inter_pred_params->subsampling_x,
122*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->subsampling_y, &inter_pred_params->conv_params);
123*77c1e3ccSAndroid Build Coastguard Worker }
124*77c1e3ccSAndroid Build Coastguard Worker #endif // !CONFIG_REALTIME_ONLY || CONFIG_AV1_DECODER
125*77c1e3ccSAndroid Build Coastguard Worker else {
126*77c1e3ccSAndroid Build Coastguard Worker assert(0 && "Unsupported inter_pred_params->mode");
127*77c1e3ccSAndroid Build Coastguard Worker }
128*77c1e3ccSAndroid Build Coastguard Worker }
129*77c1e3ccSAndroid Build Coastguard Worker
130*77c1e3ccSAndroid Build Coastguard Worker static const uint8_t wedge_master_oblique_odd[MASK_MASTER_SIZE] = {
131*77c1e3ccSAndroid Build Coastguard Worker 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
132*77c1e3ccSAndroid Build Coastguard Worker 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 6, 18,
133*77c1e3ccSAndroid Build Coastguard Worker 37, 53, 60, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
134*77c1e3ccSAndroid Build Coastguard Worker 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
135*77c1e3ccSAndroid Build Coastguard Worker };
136*77c1e3ccSAndroid Build Coastguard Worker static const uint8_t wedge_master_oblique_even[MASK_MASTER_SIZE] = {
137*77c1e3ccSAndroid Build Coastguard Worker 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
138*77c1e3ccSAndroid Build Coastguard Worker 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 11, 27,
139*77c1e3ccSAndroid Build Coastguard Worker 46, 58, 62, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
140*77c1e3ccSAndroid Build Coastguard Worker 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
141*77c1e3ccSAndroid Build Coastguard Worker };
142*77c1e3ccSAndroid Build Coastguard Worker static const uint8_t wedge_master_vertical[MASK_MASTER_SIZE] = {
143*77c1e3ccSAndroid Build Coastguard Worker 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
144*77c1e3ccSAndroid Build Coastguard Worker 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 7, 21,
145*77c1e3ccSAndroid Build Coastguard Worker 43, 57, 62, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
146*77c1e3ccSAndroid Build Coastguard Worker 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
147*77c1e3ccSAndroid Build Coastguard Worker };
148*77c1e3ccSAndroid Build Coastguard Worker
shift_copy(const uint8_t * src,uint8_t * dst,int shift,int width)149*77c1e3ccSAndroid Build Coastguard Worker static inline void shift_copy(const uint8_t *src, uint8_t *dst, int shift,
150*77c1e3ccSAndroid Build Coastguard Worker int width) {
151*77c1e3ccSAndroid Build Coastguard Worker if (shift >= 0) {
152*77c1e3ccSAndroid Build Coastguard Worker memcpy(dst + shift, src, width - shift);
153*77c1e3ccSAndroid Build Coastguard Worker memset(dst, src[0], shift);
154*77c1e3ccSAndroid Build Coastguard Worker } else {
155*77c1e3ccSAndroid Build Coastguard Worker shift = -shift;
156*77c1e3ccSAndroid Build Coastguard Worker memcpy(dst, src + shift, width - shift);
157*77c1e3ccSAndroid Build Coastguard Worker memset(dst + width - shift, src[width - 1], shift);
158*77c1e3ccSAndroid Build Coastguard Worker }
159*77c1e3ccSAndroid Build Coastguard Worker }
160*77c1e3ccSAndroid Build Coastguard Worker
161*77c1e3ccSAndroid Build Coastguard Worker /* clang-format off */
162*77c1e3ccSAndroid Build Coastguard Worker DECLARE_ALIGNED(16, static uint8_t,
163*77c1e3ccSAndroid Build Coastguard Worker wedge_signflip_lookup[BLOCK_SIZES_ALL][MAX_WEDGE_TYPES]) = {
164*77c1e3ccSAndroid Build Coastguard Worker { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, // not used
165*77c1e3ccSAndroid Build Coastguard Worker { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, // not used
166*77c1e3ccSAndroid Build Coastguard Worker { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, // not used
167*77c1e3ccSAndroid Build Coastguard Worker { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, },
168*77c1e3ccSAndroid Build Coastguard Worker { 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, },
169*77c1e3ccSAndroid Build Coastguard Worker { 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, },
170*77c1e3ccSAndroid Build Coastguard Worker { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, },
171*77c1e3ccSAndroid Build Coastguard Worker { 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, },
172*77c1e3ccSAndroid Build Coastguard Worker { 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, },
173*77c1e3ccSAndroid Build Coastguard Worker { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, },
174*77c1e3ccSAndroid Build Coastguard Worker { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, // not used
175*77c1e3ccSAndroid Build Coastguard Worker { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, // not used
176*77c1e3ccSAndroid Build Coastguard Worker { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, // not used
177*77c1e3ccSAndroid Build Coastguard Worker { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, // not used
178*77c1e3ccSAndroid Build Coastguard Worker { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, // not used
179*77c1e3ccSAndroid Build Coastguard Worker { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, // not used
180*77c1e3ccSAndroid Build Coastguard Worker { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, // not used
181*77c1e3ccSAndroid Build Coastguard Worker { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, // not used
182*77c1e3ccSAndroid Build Coastguard Worker { 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, },
183*77c1e3ccSAndroid Build Coastguard Worker { 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, },
184*77c1e3ccSAndroid Build Coastguard Worker { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, // not used
185*77c1e3ccSAndroid Build Coastguard Worker { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, // not used
186*77c1e3ccSAndroid Build Coastguard Worker };
187*77c1e3ccSAndroid Build Coastguard Worker /* clang-format on */
188*77c1e3ccSAndroid Build Coastguard Worker
189*77c1e3ccSAndroid Build Coastguard Worker // [negative][direction]
190*77c1e3ccSAndroid Build Coastguard Worker DECLARE_ALIGNED(
191*77c1e3ccSAndroid Build Coastguard Worker 16, static uint8_t,
192*77c1e3ccSAndroid Build Coastguard Worker wedge_mask_obl[2][WEDGE_DIRECTIONS][MASK_MASTER_SIZE * MASK_MASTER_SIZE]);
193*77c1e3ccSAndroid Build Coastguard Worker
194*77c1e3ccSAndroid Build Coastguard Worker // 4 * MAX_WEDGE_SQUARE is an easy to compute and fairly tight upper bound
195*77c1e3ccSAndroid Build Coastguard Worker // on the sum of all mask sizes up to an including MAX_WEDGE_SQUARE.
196*77c1e3ccSAndroid Build Coastguard Worker DECLARE_ALIGNED(16, static uint8_t,
197*77c1e3ccSAndroid Build Coastguard Worker wedge_mask_buf[2 * MAX_WEDGE_TYPES * 4 * MAX_WEDGE_SQUARE]);
198*77c1e3ccSAndroid Build Coastguard Worker
199*77c1e3ccSAndroid Build Coastguard Worker DECLARE_ALIGNED(16, static uint8_t,
200*77c1e3ccSAndroid Build Coastguard Worker smooth_interintra_mask_buf[INTERINTRA_MODES][BLOCK_SIZES_ALL]
201*77c1e3ccSAndroid Build Coastguard Worker [MAX_WEDGE_SQUARE]);
202*77c1e3ccSAndroid Build Coastguard Worker
203*77c1e3ccSAndroid Build Coastguard Worker static wedge_masks_type wedge_masks[BLOCK_SIZES_ALL][2];
204*77c1e3ccSAndroid Build Coastguard Worker
205*77c1e3ccSAndroid Build Coastguard Worker static const wedge_code_type wedge_codebook_16_hgtw[16] = {
206*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_OBLIQUE27, 4, 4 }, { WEDGE_OBLIQUE63, 4, 4 },
207*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_OBLIQUE117, 4, 4 }, { WEDGE_OBLIQUE153, 4, 4 },
208*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_HORIZONTAL, 4, 2 }, { WEDGE_HORIZONTAL, 4, 4 },
209*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_HORIZONTAL, 4, 6 }, { WEDGE_VERTICAL, 4, 4 },
210*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_OBLIQUE27, 4, 2 }, { WEDGE_OBLIQUE27, 4, 6 },
211*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_OBLIQUE153, 4, 2 }, { WEDGE_OBLIQUE153, 4, 6 },
212*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_OBLIQUE63, 2, 4 }, { WEDGE_OBLIQUE63, 6, 4 },
213*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_OBLIQUE117, 2, 4 }, { WEDGE_OBLIQUE117, 6, 4 },
214*77c1e3ccSAndroid Build Coastguard Worker };
215*77c1e3ccSAndroid Build Coastguard Worker
216*77c1e3ccSAndroid Build Coastguard Worker static const wedge_code_type wedge_codebook_16_hltw[16] = {
217*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_OBLIQUE27, 4, 4 }, { WEDGE_OBLIQUE63, 4, 4 },
218*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_OBLIQUE117, 4, 4 }, { WEDGE_OBLIQUE153, 4, 4 },
219*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_VERTICAL, 2, 4 }, { WEDGE_VERTICAL, 4, 4 },
220*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_VERTICAL, 6, 4 }, { WEDGE_HORIZONTAL, 4, 4 },
221*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_OBLIQUE27, 4, 2 }, { WEDGE_OBLIQUE27, 4, 6 },
222*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_OBLIQUE153, 4, 2 }, { WEDGE_OBLIQUE153, 4, 6 },
223*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_OBLIQUE63, 2, 4 }, { WEDGE_OBLIQUE63, 6, 4 },
224*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_OBLIQUE117, 2, 4 }, { WEDGE_OBLIQUE117, 6, 4 },
225*77c1e3ccSAndroid Build Coastguard Worker };
226*77c1e3ccSAndroid Build Coastguard Worker
227*77c1e3ccSAndroid Build Coastguard Worker static const wedge_code_type wedge_codebook_16_heqw[16] = {
228*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_OBLIQUE27, 4, 4 }, { WEDGE_OBLIQUE63, 4, 4 },
229*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_OBLIQUE117, 4, 4 }, { WEDGE_OBLIQUE153, 4, 4 },
230*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_HORIZONTAL, 4, 2 }, { WEDGE_HORIZONTAL, 4, 6 },
231*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_VERTICAL, 2, 4 }, { WEDGE_VERTICAL, 6, 4 },
232*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_OBLIQUE27, 4, 2 }, { WEDGE_OBLIQUE27, 4, 6 },
233*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_OBLIQUE153, 4, 2 }, { WEDGE_OBLIQUE153, 4, 6 },
234*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_OBLIQUE63, 2, 4 }, { WEDGE_OBLIQUE63, 6, 4 },
235*77c1e3ccSAndroid Build Coastguard Worker { WEDGE_OBLIQUE117, 2, 4 }, { WEDGE_OBLIQUE117, 6, 4 },
236*77c1e3ccSAndroid Build Coastguard Worker };
237*77c1e3ccSAndroid Build Coastguard Worker
238*77c1e3ccSAndroid Build Coastguard Worker const wedge_params_type av1_wedge_params_lookup[BLOCK_SIZES_ALL] = {
239*77c1e3ccSAndroid Build Coastguard Worker { 0, NULL, NULL, NULL },
240*77c1e3ccSAndroid Build Coastguard Worker { 0, NULL, NULL, NULL },
241*77c1e3ccSAndroid Build Coastguard Worker { 0, NULL, NULL, NULL },
242*77c1e3ccSAndroid Build Coastguard Worker { MAX_WEDGE_TYPES, wedge_codebook_16_heqw, wedge_signflip_lookup[BLOCK_8X8],
243*77c1e3ccSAndroid Build Coastguard Worker wedge_masks[BLOCK_8X8] },
244*77c1e3ccSAndroid Build Coastguard Worker { MAX_WEDGE_TYPES, wedge_codebook_16_hgtw, wedge_signflip_lookup[BLOCK_8X16],
245*77c1e3ccSAndroid Build Coastguard Worker wedge_masks[BLOCK_8X16] },
246*77c1e3ccSAndroid Build Coastguard Worker { MAX_WEDGE_TYPES, wedge_codebook_16_hltw, wedge_signflip_lookup[BLOCK_16X8],
247*77c1e3ccSAndroid Build Coastguard Worker wedge_masks[BLOCK_16X8] },
248*77c1e3ccSAndroid Build Coastguard Worker { MAX_WEDGE_TYPES, wedge_codebook_16_heqw, wedge_signflip_lookup[BLOCK_16X16],
249*77c1e3ccSAndroid Build Coastguard Worker wedge_masks[BLOCK_16X16] },
250*77c1e3ccSAndroid Build Coastguard Worker { MAX_WEDGE_TYPES, wedge_codebook_16_hgtw, wedge_signflip_lookup[BLOCK_16X32],
251*77c1e3ccSAndroid Build Coastguard Worker wedge_masks[BLOCK_16X32] },
252*77c1e3ccSAndroid Build Coastguard Worker { MAX_WEDGE_TYPES, wedge_codebook_16_hltw, wedge_signflip_lookup[BLOCK_32X16],
253*77c1e3ccSAndroid Build Coastguard Worker wedge_masks[BLOCK_32X16] },
254*77c1e3ccSAndroid Build Coastguard Worker { MAX_WEDGE_TYPES, wedge_codebook_16_heqw, wedge_signflip_lookup[BLOCK_32X32],
255*77c1e3ccSAndroid Build Coastguard Worker wedge_masks[BLOCK_32X32] },
256*77c1e3ccSAndroid Build Coastguard Worker { 0, NULL, NULL, NULL },
257*77c1e3ccSAndroid Build Coastguard Worker { 0, NULL, NULL, NULL },
258*77c1e3ccSAndroid Build Coastguard Worker { 0, NULL, NULL, NULL },
259*77c1e3ccSAndroid Build Coastguard Worker { 0, NULL, NULL, NULL },
260*77c1e3ccSAndroid Build Coastguard Worker { 0, NULL, NULL, NULL },
261*77c1e3ccSAndroid Build Coastguard Worker { 0, NULL, NULL, NULL },
262*77c1e3ccSAndroid Build Coastguard Worker { 0, NULL, NULL, NULL },
263*77c1e3ccSAndroid Build Coastguard Worker { 0, NULL, NULL, NULL },
264*77c1e3ccSAndroid Build Coastguard Worker { MAX_WEDGE_TYPES, wedge_codebook_16_hgtw, wedge_signflip_lookup[BLOCK_8X32],
265*77c1e3ccSAndroid Build Coastguard Worker wedge_masks[BLOCK_8X32] },
266*77c1e3ccSAndroid Build Coastguard Worker { MAX_WEDGE_TYPES, wedge_codebook_16_hltw, wedge_signflip_lookup[BLOCK_32X8],
267*77c1e3ccSAndroid Build Coastguard Worker wedge_masks[BLOCK_32X8] },
268*77c1e3ccSAndroid Build Coastguard Worker { 0, NULL, NULL, NULL },
269*77c1e3ccSAndroid Build Coastguard Worker { 0, NULL, NULL, NULL },
270*77c1e3ccSAndroid Build Coastguard Worker };
271*77c1e3ccSAndroid Build Coastguard Worker
get_wedge_mask_inplace(int wedge_index,int neg,BLOCK_SIZE sb_type)272*77c1e3ccSAndroid Build Coastguard Worker static const uint8_t *get_wedge_mask_inplace(int wedge_index, int neg,
273*77c1e3ccSAndroid Build Coastguard Worker BLOCK_SIZE sb_type) {
274*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *master;
275*77c1e3ccSAndroid Build Coastguard Worker const int bh = block_size_high[sb_type];
276*77c1e3ccSAndroid Build Coastguard Worker const int bw = block_size_wide[sb_type];
277*77c1e3ccSAndroid Build Coastguard Worker const wedge_code_type *a =
278*77c1e3ccSAndroid Build Coastguard Worker av1_wedge_params_lookup[sb_type].codebook + wedge_index;
279*77c1e3ccSAndroid Build Coastguard Worker int woff, hoff;
280*77c1e3ccSAndroid Build Coastguard Worker const uint8_t wsignflip =
281*77c1e3ccSAndroid Build Coastguard Worker av1_wedge_params_lookup[sb_type].signflip[wedge_index];
282*77c1e3ccSAndroid Build Coastguard Worker
283*77c1e3ccSAndroid Build Coastguard Worker assert(wedge_index >= 0 && wedge_index < get_wedge_types_lookup(sb_type));
284*77c1e3ccSAndroid Build Coastguard Worker woff = (a->x_offset * bw) >> 3;
285*77c1e3ccSAndroid Build Coastguard Worker hoff = (a->y_offset * bh) >> 3;
286*77c1e3ccSAndroid Build Coastguard Worker master = wedge_mask_obl[neg ^ wsignflip][a->direction] +
287*77c1e3ccSAndroid Build Coastguard Worker MASK_MASTER_STRIDE * (MASK_MASTER_SIZE / 2 - hoff) +
288*77c1e3ccSAndroid Build Coastguard Worker MASK_MASTER_SIZE / 2 - woff;
289*77c1e3ccSAndroid Build Coastguard Worker return master;
290*77c1e3ccSAndroid Build Coastguard Worker }
291*77c1e3ccSAndroid Build Coastguard Worker
av1_get_compound_type_mask(const INTERINTER_COMPOUND_DATA * const comp_data,BLOCK_SIZE sb_type)292*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *av1_get_compound_type_mask(
293*77c1e3ccSAndroid Build Coastguard Worker const INTERINTER_COMPOUND_DATA *const comp_data, BLOCK_SIZE sb_type) {
294*77c1e3ccSAndroid Build Coastguard Worker (void)sb_type;
295*77c1e3ccSAndroid Build Coastguard Worker switch (comp_data->type) {
296*77c1e3ccSAndroid Build Coastguard Worker case COMPOUND_WEDGE:
297*77c1e3ccSAndroid Build Coastguard Worker return av1_get_contiguous_soft_mask(comp_data->wedge_index,
298*77c1e3ccSAndroid Build Coastguard Worker comp_data->wedge_sign, sb_type);
299*77c1e3ccSAndroid Build Coastguard Worker default: return comp_data->seg_mask;
300*77c1e3ccSAndroid Build Coastguard Worker }
301*77c1e3ccSAndroid Build Coastguard Worker }
302*77c1e3ccSAndroid Build Coastguard Worker
diffwtd_mask_d16(uint8_t * mask,int which_inverse,int mask_base,const CONV_BUF_TYPE * src0,int src0_stride,const CONV_BUF_TYPE * src1,int src1_stride,int h,int w,ConvolveParams * conv_params,int bd)303*77c1e3ccSAndroid Build Coastguard Worker static inline void diffwtd_mask_d16(uint8_t *mask, int which_inverse,
304*77c1e3ccSAndroid Build Coastguard Worker int mask_base, const CONV_BUF_TYPE *src0,
305*77c1e3ccSAndroid Build Coastguard Worker int src0_stride, const CONV_BUF_TYPE *src1,
306*77c1e3ccSAndroid Build Coastguard Worker int src1_stride, int h, int w,
307*77c1e3ccSAndroid Build Coastguard Worker ConvolveParams *conv_params, int bd) {
308*77c1e3ccSAndroid Build Coastguard Worker int round =
309*77c1e3ccSAndroid Build Coastguard Worker 2 * FILTER_BITS - conv_params->round_0 - conv_params->round_1 + (bd - 8);
310*77c1e3ccSAndroid Build Coastguard Worker int i, j, m, diff;
311*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < h; ++i) {
312*77c1e3ccSAndroid Build Coastguard Worker for (j = 0; j < w; ++j) {
313*77c1e3ccSAndroid Build Coastguard Worker diff = abs(src0[i * src0_stride + j] - src1[i * src1_stride + j]);
314*77c1e3ccSAndroid Build Coastguard Worker diff = ROUND_POWER_OF_TWO(diff, round);
315*77c1e3ccSAndroid Build Coastguard Worker m = clamp(mask_base + (diff / DIFF_FACTOR), 0, AOM_BLEND_A64_MAX_ALPHA);
316*77c1e3ccSAndroid Build Coastguard Worker mask[i * w + j] = which_inverse ? AOM_BLEND_A64_MAX_ALPHA - m : m;
317*77c1e3ccSAndroid Build Coastguard Worker }
318*77c1e3ccSAndroid Build Coastguard Worker }
319*77c1e3ccSAndroid Build Coastguard Worker }
320*77c1e3ccSAndroid Build Coastguard Worker
av1_build_compound_diffwtd_mask_d16_c(uint8_t * mask,DIFFWTD_MASK_TYPE mask_type,const CONV_BUF_TYPE * src0,int src0_stride,const CONV_BUF_TYPE * src1,int src1_stride,int h,int w,ConvolveParams * conv_params,int bd)321*77c1e3ccSAndroid Build Coastguard Worker void av1_build_compound_diffwtd_mask_d16_c(
322*77c1e3ccSAndroid Build Coastguard Worker uint8_t *mask, DIFFWTD_MASK_TYPE mask_type, const CONV_BUF_TYPE *src0,
323*77c1e3ccSAndroid Build Coastguard Worker int src0_stride, const CONV_BUF_TYPE *src1, int src1_stride, int h, int w,
324*77c1e3ccSAndroid Build Coastguard Worker ConvolveParams *conv_params, int bd) {
325*77c1e3ccSAndroid Build Coastguard Worker switch (mask_type) {
326*77c1e3ccSAndroid Build Coastguard Worker case DIFFWTD_38:
327*77c1e3ccSAndroid Build Coastguard Worker diffwtd_mask_d16(mask, 0, 38, src0, src0_stride, src1, src1_stride, h, w,
328*77c1e3ccSAndroid Build Coastguard Worker conv_params, bd);
329*77c1e3ccSAndroid Build Coastguard Worker break;
330*77c1e3ccSAndroid Build Coastguard Worker case DIFFWTD_38_INV:
331*77c1e3ccSAndroid Build Coastguard Worker diffwtd_mask_d16(mask, 1, 38, src0, src0_stride, src1, src1_stride, h, w,
332*77c1e3ccSAndroid Build Coastguard Worker conv_params, bd);
333*77c1e3ccSAndroid Build Coastguard Worker break;
334*77c1e3ccSAndroid Build Coastguard Worker default: assert(0);
335*77c1e3ccSAndroid Build Coastguard Worker }
336*77c1e3ccSAndroid Build Coastguard Worker }
337*77c1e3ccSAndroid Build Coastguard Worker
diffwtd_mask(uint8_t * mask,int which_inverse,int mask_base,const uint8_t * src0,int src0_stride,const uint8_t * src1,int src1_stride,int h,int w)338*77c1e3ccSAndroid Build Coastguard Worker static inline void diffwtd_mask(uint8_t *mask, int which_inverse, int mask_base,
339*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *src0, int src0_stride,
340*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *src1, int src1_stride, int h,
341*77c1e3ccSAndroid Build Coastguard Worker int w) {
342*77c1e3ccSAndroid Build Coastguard Worker int i, j, m, diff;
343*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < h; ++i) {
344*77c1e3ccSAndroid Build Coastguard Worker for (j = 0; j < w; ++j) {
345*77c1e3ccSAndroid Build Coastguard Worker diff =
346*77c1e3ccSAndroid Build Coastguard Worker abs((int)src0[i * src0_stride + j] - (int)src1[i * src1_stride + j]);
347*77c1e3ccSAndroid Build Coastguard Worker m = clamp(mask_base + (diff / DIFF_FACTOR), 0, AOM_BLEND_A64_MAX_ALPHA);
348*77c1e3ccSAndroid Build Coastguard Worker mask[i * w + j] = which_inverse ? AOM_BLEND_A64_MAX_ALPHA - m : m;
349*77c1e3ccSAndroid Build Coastguard Worker }
350*77c1e3ccSAndroid Build Coastguard Worker }
351*77c1e3ccSAndroid Build Coastguard Worker }
352*77c1e3ccSAndroid Build Coastguard Worker
av1_build_compound_diffwtd_mask_c(uint8_t * mask,DIFFWTD_MASK_TYPE mask_type,const uint8_t * src0,int src0_stride,const uint8_t * src1,int src1_stride,int h,int w)353*77c1e3ccSAndroid Build Coastguard Worker void av1_build_compound_diffwtd_mask_c(uint8_t *mask,
354*77c1e3ccSAndroid Build Coastguard Worker DIFFWTD_MASK_TYPE mask_type,
355*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *src0, int src0_stride,
356*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *src1, int src1_stride,
357*77c1e3ccSAndroid Build Coastguard Worker int h, int w) {
358*77c1e3ccSAndroid Build Coastguard Worker switch (mask_type) {
359*77c1e3ccSAndroid Build Coastguard Worker case DIFFWTD_38:
360*77c1e3ccSAndroid Build Coastguard Worker diffwtd_mask(mask, 0, 38, src0, src0_stride, src1, src1_stride, h, w);
361*77c1e3ccSAndroid Build Coastguard Worker break;
362*77c1e3ccSAndroid Build Coastguard Worker case DIFFWTD_38_INV:
363*77c1e3ccSAndroid Build Coastguard Worker diffwtd_mask(mask, 1, 38, src0, src0_stride, src1, src1_stride, h, w);
364*77c1e3ccSAndroid Build Coastguard Worker break;
365*77c1e3ccSAndroid Build Coastguard Worker default: assert(0);
366*77c1e3ccSAndroid Build Coastguard Worker }
367*77c1e3ccSAndroid Build Coastguard Worker }
368*77c1e3ccSAndroid Build Coastguard Worker
369*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
diffwtd_mask_highbd(uint8_t * mask,int which_inverse,int mask_base,const uint16_t * src0,int src0_stride,const uint16_t * src1,int src1_stride,int h,int w,const unsigned int bd)370*77c1e3ccSAndroid Build Coastguard Worker static AOM_FORCE_INLINE void diffwtd_mask_highbd(
371*77c1e3ccSAndroid Build Coastguard Worker uint8_t *mask, int which_inverse, int mask_base, const uint16_t *src0,
372*77c1e3ccSAndroid Build Coastguard Worker int src0_stride, const uint16_t *src1, int src1_stride, int h, int w,
373*77c1e3ccSAndroid Build Coastguard Worker const unsigned int bd) {
374*77c1e3ccSAndroid Build Coastguard Worker assert(bd >= 8);
375*77c1e3ccSAndroid Build Coastguard Worker if (bd == 8) {
376*77c1e3ccSAndroid Build Coastguard Worker if (which_inverse) {
377*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < h; ++i) {
378*77c1e3ccSAndroid Build Coastguard Worker for (int j = 0; j < w; ++j) {
379*77c1e3ccSAndroid Build Coastguard Worker int diff = abs((int)src0[j] - (int)src1[j]) / DIFF_FACTOR;
380*77c1e3ccSAndroid Build Coastguard Worker unsigned int m = negative_to_zero(mask_base + diff);
381*77c1e3ccSAndroid Build Coastguard Worker m = AOMMIN(m, AOM_BLEND_A64_MAX_ALPHA);
382*77c1e3ccSAndroid Build Coastguard Worker mask[j] = AOM_BLEND_A64_MAX_ALPHA - m;
383*77c1e3ccSAndroid Build Coastguard Worker }
384*77c1e3ccSAndroid Build Coastguard Worker src0 += src0_stride;
385*77c1e3ccSAndroid Build Coastguard Worker src1 += src1_stride;
386*77c1e3ccSAndroid Build Coastguard Worker mask += w;
387*77c1e3ccSAndroid Build Coastguard Worker }
388*77c1e3ccSAndroid Build Coastguard Worker } else {
389*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < h; ++i) {
390*77c1e3ccSAndroid Build Coastguard Worker for (int j = 0; j < w; ++j) {
391*77c1e3ccSAndroid Build Coastguard Worker int diff = abs((int)src0[j] - (int)src1[j]) / DIFF_FACTOR;
392*77c1e3ccSAndroid Build Coastguard Worker unsigned int m = negative_to_zero(mask_base + diff);
393*77c1e3ccSAndroid Build Coastguard Worker m = AOMMIN(m, AOM_BLEND_A64_MAX_ALPHA);
394*77c1e3ccSAndroid Build Coastguard Worker mask[j] = m;
395*77c1e3ccSAndroid Build Coastguard Worker }
396*77c1e3ccSAndroid Build Coastguard Worker src0 += src0_stride;
397*77c1e3ccSAndroid Build Coastguard Worker src1 += src1_stride;
398*77c1e3ccSAndroid Build Coastguard Worker mask += w;
399*77c1e3ccSAndroid Build Coastguard Worker }
400*77c1e3ccSAndroid Build Coastguard Worker }
401*77c1e3ccSAndroid Build Coastguard Worker } else {
402*77c1e3ccSAndroid Build Coastguard Worker const unsigned int bd_shift = bd - 8;
403*77c1e3ccSAndroid Build Coastguard Worker if (which_inverse) {
404*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < h; ++i) {
405*77c1e3ccSAndroid Build Coastguard Worker for (int j = 0; j < w; ++j) {
406*77c1e3ccSAndroid Build Coastguard Worker int diff =
407*77c1e3ccSAndroid Build Coastguard Worker (abs((int)src0[j] - (int)src1[j]) >> bd_shift) / DIFF_FACTOR;
408*77c1e3ccSAndroid Build Coastguard Worker unsigned int m = negative_to_zero(mask_base + diff);
409*77c1e3ccSAndroid Build Coastguard Worker m = AOMMIN(m, AOM_BLEND_A64_MAX_ALPHA);
410*77c1e3ccSAndroid Build Coastguard Worker mask[j] = AOM_BLEND_A64_MAX_ALPHA - m;
411*77c1e3ccSAndroid Build Coastguard Worker }
412*77c1e3ccSAndroid Build Coastguard Worker src0 += src0_stride;
413*77c1e3ccSAndroid Build Coastguard Worker src1 += src1_stride;
414*77c1e3ccSAndroid Build Coastguard Worker mask += w;
415*77c1e3ccSAndroid Build Coastguard Worker }
416*77c1e3ccSAndroid Build Coastguard Worker } else {
417*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < h; ++i) {
418*77c1e3ccSAndroid Build Coastguard Worker for (int j = 0; j < w; ++j) {
419*77c1e3ccSAndroid Build Coastguard Worker int diff =
420*77c1e3ccSAndroid Build Coastguard Worker (abs((int)src0[j] - (int)src1[j]) >> bd_shift) / DIFF_FACTOR;
421*77c1e3ccSAndroid Build Coastguard Worker unsigned int m = negative_to_zero(mask_base + diff);
422*77c1e3ccSAndroid Build Coastguard Worker m = AOMMIN(m, AOM_BLEND_A64_MAX_ALPHA);
423*77c1e3ccSAndroid Build Coastguard Worker mask[j] = m;
424*77c1e3ccSAndroid Build Coastguard Worker }
425*77c1e3ccSAndroid Build Coastguard Worker src0 += src0_stride;
426*77c1e3ccSAndroid Build Coastguard Worker src1 += src1_stride;
427*77c1e3ccSAndroid Build Coastguard Worker mask += w;
428*77c1e3ccSAndroid Build Coastguard Worker }
429*77c1e3ccSAndroid Build Coastguard Worker }
430*77c1e3ccSAndroid Build Coastguard Worker }
431*77c1e3ccSAndroid Build Coastguard Worker }
432*77c1e3ccSAndroid Build Coastguard Worker
av1_build_compound_diffwtd_mask_highbd_c(uint8_t * mask,DIFFWTD_MASK_TYPE mask_type,const uint8_t * src0,int src0_stride,const uint8_t * src1,int src1_stride,int h,int w,int bd)433*77c1e3ccSAndroid Build Coastguard Worker void av1_build_compound_diffwtd_mask_highbd_c(
434*77c1e3ccSAndroid Build Coastguard Worker uint8_t *mask, DIFFWTD_MASK_TYPE mask_type, const uint8_t *src0,
435*77c1e3ccSAndroid Build Coastguard Worker int src0_stride, const uint8_t *src1, int src1_stride, int h, int w,
436*77c1e3ccSAndroid Build Coastguard Worker int bd) {
437*77c1e3ccSAndroid Build Coastguard Worker switch (mask_type) {
438*77c1e3ccSAndroid Build Coastguard Worker case DIFFWTD_38:
439*77c1e3ccSAndroid Build Coastguard Worker diffwtd_mask_highbd(mask, 0, 38, CONVERT_TO_SHORTPTR(src0), src0_stride,
440*77c1e3ccSAndroid Build Coastguard Worker CONVERT_TO_SHORTPTR(src1), src1_stride, h, w, bd);
441*77c1e3ccSAndroid Build Coastguard Worker break;
442*77c1e3ccSAndroid Build Coastguard Worker case DIFFWTD_38_INV:
443*77c1e3ccSAndroid Build Coastguard Worker diffwtd_mask_highbd(mask, 1, 38, CONVERT_TO_SHORTPTR(src0), src0_stride,
444*77c1e3ccSAndroid Build Coastguard Worker CONVERT_TO_SHORTPTR(src1), src1_stride, h, w, bd);
445*77c1e3ccSAndroid Build Coastguard Worker break;
446*77c1e3ccSAndroid Build Coastguard Worker default: assert(0);
447*77c1e3ccSAndroid Build Coastguard Worker }
448*77c1e3ccSAndroid Build Coastguard Worker }
449*77c1e3ccSAndroid Build Coastguard Worker #endif // CONFIG_AV1_HIGHBITDEPTH
450*77c1e3ccSAndroid Build Coastguard Worker
init_wedge_master_masks(void)451*77c1e3ccSAndroid Build Coastguard Worker static inline void init_wedge_master_masks(void) {
452*77c1e3ccSAndroid Build Coastguard Worker int i, j;
453*77c1e3ccSAndroid Build Coastguard Worker const int w = MASK_MASTER_SIZE;
454*77c1e3ccSAndroid Build Coastguard Worker const int h = MASK_MASTER_SIZE;
455*77c1e3ccSAndroid Build Coastguard Worker const int stride = MASK_MASTER_STRIDE;
456*77c1e3ccSAndroid Build Coastguard Worker // Note: index [0] stores the masters, and [1] its complement.
457*77c1e3ccSAndroid Build Coastguard Worker // Generate prototype by shifting the masters
458*77c1e3ccSAndroid Build Coastguard Worker int shift = h / 4;
459*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < h; i += 2) {
460*77c1e3ccSAndroid Build Coastguard Worker shift_copy(wedge_master_oblique_even,
461*77c1e3ccSAndroid Build Coastguard Worker &wedge_mask_obl[0][WEDGE_OBLIQUE63][i * stride], shift,
462*77c1e3ccSAndroid Build Coastguard Worker MASK_MASTER_SIZE);
463*77c1e3ccSAndroid Build Coastguard Worker shift--;
464*77c1e3ccSAndroid Build Coastguard Worker shift_copy(wedge_master_oblique_odd,
465*77c1e3ccSAndroid Build Coastguard Worker &wedge_mask_obl[0][WEDGE_OBLIQUE63][(i + 1) * stride], shift,
466*77c1e3ccSAndroid Build Coastguard Worker MASK_MASTER_SIZE);
467*77c1e3ccSAndroid Build Coastguard Worker memcpy(&wedge_mask_obl[0][WEDGE_VERTICAL][i * stride],
468*77c1e3ccSAndroid Build Coastguard Worker wedge_master_vertical,
469*77c1e3ccSAndroid Build Coastguard Worker MASK_MASTER_SIZE * sizeof(wedge_master_vertical[0]));
470*77c1e3ccSAndroid Build Coastguard Worker memcpy(&wedge_mask_obl[0][WEDGE_VERTICAL][(i + 1) * stride],
471*77c1e3ccSAndroid Build Coastguard Worker wedge_master_vertical,
472*77c1e3ccSAndroid Build Coastguard Worker MASK_MASTER_SIZE * sizeof(wedge_master_vertical[0]));
473*77c1e3ccSAndroid Build Coastguard Worker }
474*77c1e3ccSAndroid Build Coastguard Worker
475*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < h; ++i) {
476*77c1e3ccSAndroid Build Coastguard Worker for (j = 0; j < w; ++j) {
477*77c1e3ccSAndroid Build Coastguard Worker const int msk = wedge_mask_obl[0][WEDGE_OBLIQUE63][i * stride + j];
478*77c1e3ccSAndroid Build Coastguard Worker wedge_mask_obl[0][WEDGE_OBLIQUE27][j * stride + i] = msk;
479*77c1e3ccSAndroid Build Coastguard Worker wedge_mask_obl[0][WEDGE_OBLIQUE117][i * stride + w - 1 - j] =
480*77c1e3ccSAndroid Build Coastguard Worker wedge_mask_obl[0][WEDGE_OBLIQUE153][(w - 1 - j) * stride + i] =
481*77c1e3ccSAndroid Build Coastguard Worker (1 << WEDGE_WEIGHT_BITS) - msk;
482*77c1e3ccSAndroid Build Coastguard Worker wedge_mask_obl[1][WEDGE_OBLIQUE63][i * stride + j] =
483*77c1e3ccSAndroid Build Coastguard Worker wedge_mask_obl[1][WEDGE_OBLIQUE27][j * stride + i] =
484*77c1e3ccSAndroid Build Coastguard Worker (1 << WEDGE_WEIGHT_BITS) - msk;
485*77c1e3ccSAndroid Build Coastguard Worker wedge_mask_obl[1][WEDGE_OBLIQUE117][i * stride + w - 1 - j] =
486*77c1e3ccSAndroid Build Coastguard Worker wedge_mask_obl[1][WEDGE_OBLIQUE153][(w - 1 - j) * stride + i] = msk;
487*77c1e3ccSAndroid Build Coastguard Worker const int mskx = wedge_mask_obl[0][WEDGE_VERTICAL][i * stride + j];
488*77c1e3ccSAndroid Build Coastguard Worker wedge_mask_obl[0][WEDGE_HORIZONTAL][j * stride + i] = mskx;
489*77c1e3ccSAndroid Build Coastguard Worker wedge_mask_obl[1][WEDGE_VERTICAL][i * stride + j] =
490*77c1e3ccSAndroid Build Coastguard Worker wedge_mask_obl[1][WEDGE_HORIZONTAL][j * stride + i] =
491*77c1e3ccSAndroid Build Coastguard Worker (1 << WEDGE_WEIGHT_BITS) - mskx;
492*77c1e3ccSAndroid Build Coastguard Worker }
493*77c1e3ccSAndroid Build Coastguard Worker }
494*77c1e3ccSAndroid Build Coastguard Worker }
495*77c1e3ccSAndroid Build Coastguard Worker
init_wedge_masks(void)496*77c1e3ccSAndroid Build Coastguard Worker static inline void init_wedge_masks(void) {
497*77c1e3ccSAndroid Build Coastguard Worker uint8_t *dst = wedge_mask_buf;
498*77c1e3ccSAndroid Build Coastguard Worker BLOCK_SIZE bsize;
499*77c1e3ccSAndroid Build Coastguard Worker memset(wedge_masks, 0, sizeof(wedge_masks));
500*77c1e3ccSAndroid Build Coastguard Worker for (bsize = BLOCK_4X4; bsize < BLOCK_SIZES_ALL; ++bsize) {
501*77c1e3ccSAndroid Build Coastguard Worker const wedge_params_type *wedge_params = &av1_wedge_params_lookup[bsize];
502*77c1e3ccSAndroid Build Coastguard Worker const int wtypes = wedge_params->wedge_types;
503*77c1e3ccSAndroid Build Coastguard Worker if (wtypes == 0) continue;
504*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *mask;
505*77c1e3ccSAndroid Build Coastguard Worker const int bw = block_size_wide[bsize];
506*77c1e3ccSAndroid Build Coastguard Worker const int bh = block_size_high[bsize];
507*77c1e3ccSAndroid Build Coastguard Worker int w;
508*77c1e3ccSAndroid Build Coastguard Worker for (w = 0; w < wtypes; ++w) {
509*77c1e3ccSAndroid Build Coastguard Worker mask = get_wedge_mask_inplace(w, 0, bsize);
510*77c1e3ccSAndroid Build Coastguard Worker aom_convolve_copy(mask, MASK_MASTER_STRIDE, dst, bw /* dst_stride */, bw,
511*77c1e3ccSAndroid Build Coastguard Worker bh);
512*77c1e3ccSAndroid Build Coastguard Worker wedge_params->masks[0][w] = dst;
513*77c1e3ccSAndroid Build Coastguard Worker dst += bw * bh;
514*77c1e3ccSAndroid Build Coastguard Worker
515*77c1e3ccSAndroid Build Coastguard Worker mask = get_wedge_mask_inplace(w, 1, bsize);
516*77c1e3ccSAndroid Build Coastguard Worker aom_convolve_copy(mask, MASK_MASTER_STRIDE, dst, bw /* dst_stride */, bw,
517*77c1e3ccSAndroid Build Coastguard Worker bh);
518*77c1e3ccSAndroid Build Coastguard Worker wedge_params->masks[1][w] = dst;
519*77c1e3ccSAndroid Build Coastguard Worker dst += bw * bh;
520*77c1e3ccSAndroid Build Coastguard Worker }
521*77c1e3ccSAndroid Build Coastguard Worker assert(sizeof(wedge_mask_buf) >= (size_t)(dst - wedge_mask_buf));
522*77c1e3ccSAndroid Build Coastguard Worker }
523*77c1e3ccSAndroid Build Coastguard Worker }
524*77c1e3ccSAndroid Build Coastguard Worker
525*77c1e3ccSAndroid Build Coastguard Worker /* clang-format off */
526*77c1e3ccSAndroid Build Coastguard Worker static const uint8_t ii_weights1d[MAX_SB_SIZE] = {
527*77c1e3ccSAndroid Build Coastguard Worker 60, 58, 56, 54, 52, 50, 48, 47, 45, 44, 42, 41, 39, 38, 37, 35, 34, 33, 32,
528*77c1e3ccSAndroid Build Coastguard Worker 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 22, 21, 20, 19, 19, 18, 18, 17, 16,
529*77c1e3ccSAndroid Build Coastguard Worker 16, 15, 15, 14, 14, 13, 13, 12, 12, 12, 11, 11, 10, 10, 10, 9, 9, 9, 8,
530*77c1e3ccSAndroid Build Coastguard Worker 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4,
531*77c1e3ccSAndroid Build Coastguard Worker 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2,
532*77c1e3ccSAndroid Build Coastguard Worker 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
533*77c1e3ccSAndroid Build Coastguard Worker 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
534*77c1e3ccSAndroid Build Coastguard Worker };
535*77c1e3ccSAndroid Build Coastguard Worker static uint8_t ii_size_scales[BLOCK_SIZES_ALL] = {
536*77c1e3ccSAndroid Build Coastguard Worker 32, 16, 16, 16, 8, 8, 8, 4,
537*77c1e3ccSAndroid Build Coastguard Worker 4, 4, 2, 2, 2, 1, 1, 1,
538*77c1e3ccSAndroid Build Coastguard Worker 8, 8, 4, 4, 2, 2
539*77c1e3ccSAndroid Build Coastguard Worker };
540*77c1e3ccSAndroid Build Coastguard Worker /* clang-format on */
541*77c1e3ccSAndroid Build Coastguard Worker
build_smooth_interintra_mask(uint8_t * mask,int stride,BLOCK_SIZE plane_bsize,INTERINTRA_MODE mode)542*77c1e3ccSAndroid Build Coastguard Worker static inline void build_smooth_interintra_mask(uint8_t *mask, int stride,
543*77c1e3ccSAndroid Build Coastguard Worker BLOCK_SIZE plane_bsize,
544*77c1e3ccSAndroid Build Coastguard Worker INTERINTRA_MODE mode) {
545*77c1e3ccSAndroid Build Coastguard Worker int i, j;
546*77c1e3ccSAndroid Build Coastguard Worker const int bw = block_size_wide[plane_bsize];
547*77c1e3ccSAndroid Build Coastguard Worker const int bh = block_size_high[plane_bsize];
548*77c1e3ccSAndroid Build Coastguard Worker const int size_scale = ii_size_scales[plane_bsize];
549*77c1e3ccSAndroid Build Coastguard Worker
550*77c1e3ccSAndroid Build Coastguard Worker switch (mode) {
551*77c1e3ccSAndroid Build Coastguard Worker case II_V_PRED:
552*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < bh; ++i) {
553*77c1e3ccSAndroid Build Coastguard Worker memset(mask, ii_weights1d[i * size_scale], bw * sizeof(mask[0]));
554*77c1e3ccSAndroid Build Coastguard Worker mask += stride;
555*77c1e3ccSAndroid Build Coastguard Worker }
556*77c1e3ccSAndroid Build Coastguard Worker break;
557*77c1e3ccSAndroid Build Coastguard Worker
558*77c1e3ccSAndroid Build Coastguard Worker case II_H_PRED:
559*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < bh; ++i) {
560*77c1e3ccSAndroid Build Coastguard Worker for (j = 0; j < bw; ++j) mask[j] = ii_weights1d[j * size_scale];
561*77c1e3ccSAndroid Build Coastguard Worker mask += stride;
562*77c1e3ccSAndroid Build Coastguard Worker }
563*77c1e3ccSAndroid Build Coastguard Worker break;
564*77c1e3ccSAndroid Build Coastguard Worker
565*77c1e3ccSAndroid Build Coastguard Worker case II_SMOOTH_PRED:
566*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < bh; ++i) {
567*77c1e3ccSAndroid Build Coastguard Worker for (j = 0; j < bw; ++j)
568*77c1e3ccSAndroid Build Coastguard Worker mask[j] = ii_weights1d[(i < j ? i : j) * size_scale];
569*77c1e3ccSAndroid Build Coastguard Worker mask += stride;
570*77c1e3ccSAndroid Build Coastguard Worker }
571*77c1e3ccSAndroid Build Coastguard Worker break;
572*77c1e3ccSAndroid Build Coastguard Worker
573*77c1e3ccSAndroid Build Coastguard Worker case II_DC_PRED:
574*77c1e3ccSAndroid Build Coastguard Worker default:
575*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < bh; ++i) {
576*77c1e3ccSAndroid Build Coastguard Worker memset(mask, 32, bw * sizeof(mask[0]));
577*77c1e3ccSAndroid Build Coastguard Worker mask += stride;
578*77c1e3ccSAndroid Build Coastguard Worker }
579*77c1e3ccSAndroid Build Coastguard Worker break;
580*77c1e3ccSAndroid Build Coastguard Worker }
581*77c1e3ccSAndroid Build Coastguard Worker }
582*77c1e3ccSAndroid Build Coastguard Worker
init_smooth_interintra_masks(void)583*77c1e3ccSAndroid Build Coastguard Worker static inline void init_smooth_interintra_masks(void) {
584*77c1e3ccSAndroid Build Coastguard Worker for (int m = 0; m < INTERINTRA_MODES; ++m) {
585*77c1e3ccSAndroid Build Coastguard Worker for (int bs = 0; bs < BLOCK_SIZES_ALL; ++bs) {
586*77c1e3ccSAndroid Build Coastguard Worker const int bw = block_size_wide[bs];
587*77c1e3ccSAndroid Build Coastguard Worker const int bh = block_size_high[bs];
588*77c1e3ccSAndroid Build Coastguard Worker if (bw > MAX_WEDGE_SIZE || bh > MAX_WEDGE_SIZE) continue;
589*77c1e3ccSAndroid Build Coastguard Worker build_smooth_interintra_mask(smooth_interintra_mask_buf[m][bs], bw, bs,
590*77c1e3ccSAndroid Build Coastguard Worker m);
591*77c1e3ccSAndroid Build Coastguard Worker }
592*77c1e3ccSAndroid Build Coastguard Worker }
593*77c1e3ccSAndroid Build Coastguard Worker }
594*77c1e3ccSAndroid Build Coastguard Worker
595*77c1e3ccSAndroid Build Coastguard Worker // Equation of line: f(x, y) = a[0]*(x - a[2]*w/8) + a[1]*(y - a[3]*h/8) = 0
init_all_wedge_masks(void)596*77c1e3ccSAndroid Build Coastguard Worker static void init_all_wedge_masks(void) {
597*77c1e3ccSAndroid Build Coastguard Worker init_wedge_master_masks();
598*77c1e3ccSAndroid Build Coastguard Worker init_wedge_masks();
599*77c1e3ccSAndroid Build Coastguard Worker init_smooth_interintra_masks();
600*77c1e3ccSAndroid Build Coastguard Worker }
601*77c1e3ccSAndroid Build Coastguard Worker
av1_init_wedge_masks(void)602*77c1e3ccSAndroid Build Coastguard Worker void av1_init_wedge_masks(void) { aom_once(init_all_wedge_masks); }
603*77c1e3ccSAndroid Build Coastguard Worker
build_masked_compound_no_round(uint8_t * dst,int dst_stride,const CONV_BUF_TYPE * src0,int src0_stride,const CONV_BUF_TYPE * src1,int src1_stride,const INTERINTER_COMPOUND_DATA * const comp_data,BLOCK_SIZE sb_type,int h,int w,InterPredParams * inter_pred_params)604*77c1e3ccSAndroid Build Coastguard Worker static inline void build_masked_compound_no_round(
605*77c1e3ccSAndroid Build Coastguard Worker uint8_t *dst, int dst_stride, const CONV_BUF_TYPE *src0, int src0_stride,
606*77c1e3ccSAndroid Build Coastguard Worker const CONV_BUF_TYPE *src1, int src1_stride,
607*77c1e3ccSAndroid Build Coastguard Worker const INTERINTER_COMPOUND_DATA *const comp_data, BLOCK_SIZE sb_type, int h,
608*77c1e3ccSAndroid Build Coastguard Worker int w, InterPredParams *inter_pred_params) {
609*77c1e3ccSAndroid Build Coastguard Worker const int ssy = inter_pred_params->subsampling_y;
610*77c1e3ccSAndroid Build Coastguard Worker const int ssx = inter_pred_params->subsampling_x;
611*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *mask = av1_get_compound_type_mask(comp_data, sb_type);
612*77c1e3ccSAndroid Build Coastguard Worker const int mask_stride = block_size_wide[sb_type];
613*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
614*77c1e3ccSAndroid Build Coastguard Worker if (inter_pred_params->use_hbd_buf) {
615*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_blend_a64_d16_mask(dst, dst_stride, src0, src0_stride, src1,
616*77c1e3ccSAndroid Build Coastguard Worker src1_stride, mask, mask_stride, w, h, ssx,
617*77c1e3ccSAndroid Build Coastguard Worker ssy, &inter_pred_params->conv_params,
618*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->bit_depth);
619*77c1e3ccSAndroid Build Coastguard Worker } else {
620*77c1e3ccSAndroid Build Coastguard Worker aom_lowbd_blend_a64_d16_mask(dst, dst_stride, src0, src0_stride, src1,
621*77c1e3ccSAndroid Build Coastguard Worker src1_stride, mask, mask_stride, w, h, ssx, ssy,
622*77c1e3ccSAndroid Build Coastguard Worker &inter_pred_params->conv_params);
623*77c1e3ccSAndroid Build Coastguard Worker }
624*77c1e3ccSAndroid Build Coastguard Worker #else
625*77c1e3ccSAndroid Build Coastguard Worker aom_lowbd_blend_a64_d16_mask(dst, dst_stride, src0, src0_stride, src1,
626*77c1e3ccSAndroid Build Coastguard Worker src1_stride, mask, mask_stride, w, h, ssx, ssy,
627*77c1e3ccSAndroid Build Coastguard Worker &inter_pred_params->conv_params);
628*77c1e3ccSAndroid Build Coastguard Worker #endif
629*77c1e3ccSAndroid Build Coastguard Worker }
630*77c1e3ccSAndroid Build Coastguard Worker
av1_make_masked_inter_predictor(const uint8_t * pre,int pre_stride,uint8_t * dst,int dst_stride,InterPredParams * inter_pred_params,const SubpelParams * subpel_params)631*77c1e3ccSAndroid Build Coastguard Worker void av1_make_masked_inter_predictor(const uint8_t *pre, int pre_stride,
632*77c1e3ccSAndroid Build Coastguard Worker uint8_t *dst, int dst_stride,
633*77c1e3ccSAndroid Build Coastguard Worker InterPredParams *inter_pred_params,
634*77c1e3ccSAndroid Build Coastguard Worker const SubpelParams *subpel_params) {
635*77c1e3ccSAndroid Build Coastguard Worker const INTERINTER_COMPOUND_DATA *comp_data = &inter_pred_params->mask_comp;
636*77c1e3ccSAndroid Build Coastguard Worker BLOCK_SIZE sb_type = inter_pred_params->sb_type;
637*77c1e3ccSAndroid Build Coastguard Worker
638*77c1e3ccSAndroid Build Coastguard Worker // We're going to call av1_make_inter_predictor to generate a prediction into
639*77c1e3ccSAndroid Build Coastguard Worker // a temporary buffer, then will blend that temporary buffer with that from
640*77c1e3ccSAndroid Build Coastguard Worker // the other reference.
641*77c1e3ccSAndroid Build Coastguard Worker DECLARE_ALIGNED(32, uint8_t, tmp_buf[2 * MAX_SB_SQUARE]);
642*77c1e3ccSAndroid Build Coastguard Worker uint8_t *tmp_dst =
643*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->use_hbd_buf ? CONVERT_TO_BYTEPTR(tmp_buf) : tmp_buf;
644*77c1e3ccSAndroid Build Coastguard Worker
645*77c1e3ccSAndroid Build Coastguard Worker const int tmp_buf_stride = MAX_SB_SIZE;
646*77c1e3ccSAndroid Build Coastguard Worker CONV_BUF_TYPE *org_dst = inter_pred_params->conv_params.dst;
647*77c1e3ccSAndroid Build Coastguard Worker int org_dst_stride = inter_pred_params->conv_params.dst_stride;
648*77c1e3ccSAndroid Build Coastguard Worker CONV_BUF_TYPE *tmp_buf16 = (CONV_BUF_TYPE *)tmp_buf;
649*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->conv_params.dst = tmp_buf16;
650*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->conv_params.dst_stride = tmp_buf_stride;
651*77c1e3ccSAndroid Build Coastguard Worker assert(inter_pred_params->conv_params.do_average == 0);
652*77c1e3ccSAndroid Build Coastguard Worker
653*77c1e3ccSAndroid Build Coastguard Worker // This will generate a prediction in tmp_buf for the second reference
654*77c1e3ccSAndroid Build Coastguard Worker av1_make_inter_predictor(pre, pre_stride, tmp_dst, MAX_SB_SIZE,
655*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params, subpel_params);
656*77c1e3ccSAndroid Build Coastguard Worker
657*77c1e3ccSAndroid Build Coastguard Worker if (!inter_pred_params->conv_params.plane &&
658*77c1e3ccSAndroid Build Coastguard Worker comp_data->type == COMPOUND_DIFFWTD) {
659*77c1e3ccSAndroid Build Coastguard Worker av1_build_compound_diffwtd_mask_d16(
660*77c1e3ccSAndroid Build Coastguard Worker comp_data->seg_mask, comp_data->mask_type, org_dst, org_dst_stride,
661*77c1e3ccSAndroid Build Coastguard Worker tmp_buf16, tmp_buf_stride, inter_pred_params->block_height,
662*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->block_width, &inter_pred_params->conv_params,
663*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->bit_depth);
664*77c1e3ccSAndroid Build Coastguard Worker }
665*77c1e3ccSAndroid Build Coastguard Worker build_masked_compound_no_round(
666*77c1e3ccSAndroid Build Coastguard Worker dst, dst_stride, org_dst, org_dst_stride, tmp_buf16, tmp_buf_stride,
667*77c1e3ccSAndroid Build Coastguard Worker comp_data, sb_type, inter_pred_params->block_height,
668*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->block_width, inter_pred_params);
669*77c1e3ccSAndroid Build Coastguard Worker }
670*77c1e3ccSAndroid Build Coastguard Worker
av1_dist_wtd_comp_weight_assign(const AV1_COMMON * cm,const MB_MODE_INFO * mbmi,int * fwd_offset,int * bck_offset,int * use_dist_wtd_comp_avg,int is_compound)671*77c1e3ccSAndroid Build Coastguard Worker void av1_dist_wtd_comp_weight_assign(const AV1_COMMON *cm,
672*77c1e3ccSAndroid Build Coastguard Worker const MB_MODE_INFO *mbmi, int *fwd_offset,
673*77c1e3ccSAndroid Build Coastguard Worker int *bck_offset,
674*77c1e3ccSAndroid Build Coastguard Worker int *use_dist_wtd_comp_avg,
675*77c1e3ccSAndroid Build Coastguard Worker int is_compound) {
676*77c1e3ccSAndroid Build Coastguard Worker assert(fwd_offset != NULL && bck_offset != NULL);
677*77c1e3ccSAndroid Build Coastguard Worker if (!is_compound || mbmi->compound_idx) {
678*77c1e3ccSAndroid Build Coastguard Worker *fwd_offset = 8;
679*77c1e3ccSAndroid Build Coastguard Worker *bck_offset = 8;
680*77c1e3ccSAndroid Build Coastguard Worker *use_dist_wtd_comp_avg = 0;
681*77c1e3ccSAndroid Build Coastguard Worker return;
682*77c1e3ccSAndroid Build Coastguard Worker }
683*77c1e3ccSAndroid Build Coastguard Worker
684*77c1e3ccSAndroid Build Coastguard Worker *use_dist_wtd_comp_avg = 1;
685*77c1e3ccSAndroid Build Coastguard Worker const RefCntBuffer *const bck_buf = get_ref_frame_buf(cm, mbmi->ref_frame[0]);
686*77c1e3ccSAndroid Build Coastguard Worker const RefCntBuffer *const fwd_buf = get_ref_frame_buf(cm, mbmi->ref_frame[1]);
687*77c1e3ccSAndroid Build Coastguard Worker const int cur_frame_index = cm->cur_frame->order_hint;
688*77c1e3ccSAndroid Build Coastguard Worker int bck_frame_index = 0, fwd_frame_index = 0;
689*77c1e3ccSAndroid Build Coastguard Worker
690*77c1e3ccSAndroid Build Coastguard Worker if (bck_buf != NULL) bck_frame_index = bck_buf->order_hint;
691*77c1e3ccSAndroid Build Coastguard Worker if (fwd_buf != NULL) fwd_frame_index = fwd_buf->order_hint;
692*77c1e3ccSAndroid Build Coastguard Worker
693*77c1e3ccSAndroid Build Coastguard Worker int d0 = clamp(abs(get_relative_dist(&cm->seq_params->order_hint_info,
694*77c1e3ccSAndroid Build Coastguard Worker fwd_frame_index, cur_frame_index)),
695*77c1e3ccSAndroid Build Coastguard Worker 0, MAX_FRAME_DISTANCE);
696*77c1e3ccSAndroid Build Coastguard Worker int d1 = clamp(abs(get_relative_dist(&cm->seq_params->order_hint_info,
697*77c1e3ccSAndroid Build Coastguard Worker cur_frame_index, bck_frame_index)),
698*77c1e3ccSAndroid Build Coastguard Worker 0, MAX_FRAME_DISTANCE);
699*77c1e3ccSAndroid Build Coastguard Worker
700*77c1e3ccSAndroid Build Coastguard Worker const int order = d0 <= d1;
701*77c1e3ccSAndroid Build Coastguard Worker
702*77c1e3ccSAndroid Build Coastguard Worker if (d0 == 0 || d1 == 0) {
703*77c1e3ccSAndroid Build Coastguard Worker *fwd_offset = quant_dist_lookup_table[3][order];
704*77c1e3ccSAndroid Build Coastguard Worker *bck_offset = quant_dist_lookup_table[3][1 - order];
705*77c1e3ccSAndroid Build Coastguard Worker return;
706*77c1e3ccSAndroid Build Coastguard Worker }
707*77c1e3ccSAndroid Build Coastguard Worker
708*77c1e3ccSAndroid Build Coastguard Worker int i;
709*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < 3; ++i) {
710*77c1e3ccSAndroid Build Coastguard Worker int c0 = quant_dist_weight[i][order];
711*77c1e3ccSAndroid Build Coastguard Worker int c1 = quant_dist_weight[i][!order];
712*77c1e3ccSAndroid Build Coastguard Worker int d0_c0 = d0 * c0;
713*77c1e3ccSAndroid Build Coastguard Worker int d1_c1 = d1 * c1;
714*77c1e3ccSAndroid Build Coastguard Worker if ((d0 > d1 && d0_c0 < d1_c1) || (d0 <= d1 && d0_c0 > d1_c1)) break;
715*77c1e3ccSAndroid Build Coastguard Worker }
716*77c1e3ccSAndroid Build Coastguard Worker
717*77c1e3ccSAndroid Build Coastguard Worker *fwd_offset = quant_dist_lookup_table[i][order];
718*77c1e3ccSAndroid Build Coastguard Worker *bck_offset = quant_dist_lookup_table[i][1 - order];
719*77c1e3ccSAndroid Build Coastguard Worker }
720*77c1e3ccSAndroid Build Coastguard Worker
av1_setup_dst_planes(struct macroblockd_plane * planes,BLOCK_SIZE bsize,const YV12_BUFFER_CONFIG * src,int mi_row,int mi_col,const int plane_start,const int plane_end)721*77c1e3ccSAndroid Build Coastguard Worker void av1_setup_dst_planes(struct macroblockd_plane *planes, BLOCK_SIZE bsize,
722*77c1e3ccSAndroid Build Coastguard Worker const YV12_BUFFER_CONFIG *src, int mi_row, int mi_col,
723*77c1e3ccSAndroid Build Coastguard Worker const int plane_start, const int plane_end) {
724*77c1e3ccSAndroid Build Coastguard Worker // We use AOMMIN(num_planes, MAX_MB_PLANE) instead of num_planes to quiet
725*77c1e3ccSAndroid Build Coastguard Worker // the static analysis warnings.
726*77c1e3ccSAndroid Build Coastguard Worker for (int i = plane_start; i < AOMMIN(plane_end, MAX_MB_PLANE); ++i) {
727*77c1e3ccSAndroid Build Coastguard Worker struct macroblockd_plane *const pd = &planes[i];
728*77c1e3ccSAndroid Build Coastguard Worker const int is_uv = i > 0;
729*77c1e3ccSAndroid Build Coastguard Worker setup_pred_plane(&pd->dst, bsize, src->buffers[i], src->crop_widths[is_uv],
730*77c1e3ccSAndroid Build Coastguard Worker src->crop_heights[is_uv], src->strides[is_uv], mi_row,
731*77c1e3ccSAndroid Build Coastguard Worker mi_col, NULL, pd->subsampling_x, pd->subsampling_y);
732*77c1e3ccSAndroid Build Coastguard Worker }
733*77c1e3ccSAndroid Build Coastguard Worker }
734*77c1e3ccSAndroid Build Coastguard Worker
av1_setup_pre_planes(MACROBLOCKD * xd,int idx,const YV12_BUFFER_CONFIG * src,int mi_row,int mi_col,const struct scale_factors * sf,const int num_planes)735*77c1e3ccSAndroid Build Coastguard Worker void av1_setup_pre_planes(MACROBLOCKD *xd, int idx,
736*77c1e3ccSAndroid Build Coastguard Worker const YV12_BUFFER_CONFIG *src, int mi_row, int mi_col,
737*77c1e3ccSAndroid Build Coastguard Worker const struct scale_factors *sf,
738*77c1e3ccSAndroid Build Coastguard Worker const int num_planes) {
739*77c1e3ccSAndroid Build Coastguard Worker if (src != NULL) {
740*77c1e3ccSAndroid Build Coastguard Worker // We use AOMMIN(num_planes, MAX_MB_PLANE) instead of num_planes to quiet
741*77c1e3ccSAndroid Build Coastguard Worker // the static analysis warnings.
742*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < AOMMIN(num_planes, MAX_MB_PLANE); ++i) {
743*77c1e3ccSAndroid Build Coastguard Worker struct macroblockd_plane *const pd = &xd->plane[i];
744*77c1e3ccSAndroid Build Coastguard Worker const int is_uv = i > 0;
745*77c1e3ccSAndroid Build Coastguard Worker setup_pred_plane(&pd->pre[idx], xd->mi[0]->bsize, src->buffers[i],
746*77c1e3ccSAndroid Build Coastguard Worker src->crop_widths[is_uv], src->crop_heights[is_uv],
747*77c1e3ccSAndroid Build Coastguard Worker src->strides[is_uv], mi_row, mi_col, sf,
748*77c1e3ccSAndroid Build Coastguard Worker pd->subsampling_x, pd->subsampling_y);
749*77c1e3ccSAndroid Build Coastguard Worker }
750*77c1e3ccSAndroid Build Coastguard Worker }
751*77c1e3ccSAndroid Build Coastguard Worker }
752*77c1e3ccSAndroid Build Coastguard Worker
753*77c1e3ccSAndroid Build Coastguard Worker // obmc_mask_N[overlap_position]
754*77c1e3ccSAndroid Build Coastguard Worker static const uint8_t obmc_mask_1[1] = { 64 };
755*77c1e3ccSAndroid Build Coastguard Worker DECLARE_ALIGNED(2, static const uint8_t, obmc_mask_2[2]) = { 45, 64 };
756*77c1e3ccSAndroid Build Coastguard Worker
757*77c1e3ccSAndroid Build Coastguard Worker DECLARE_ALIGNED(4, static const uint8_t, obmc_mask_4[4]) = { 39, 50, 59, 64 };
758*77c1e3ccSAndroid Build Coastguard Worker
759*77c1e3ccSAndroid Build Coastguard Worker static const uint8_t obmc_mask_8[8] = { 36, 42, 48, 53, 57, 61, 64, 64 };
760*77c1e3ccSAndroid Build Coastguard Worker
761*77c1e3ccSAndroid Build Coastguard Worker static const uint8_t obmc_mask_16[16] = { 34, 37, 40, 43, 46, 49, 52, 54,
762*77c1e3ccSAndroid Build Coastguard Worker 56, 58, 60, 61, 64, 64, 64, 64 };
763*77c1e3ccSAndroid Build Coastguard Worker
764*77c1e3ccSAndroid Build Coastguard Worker static const uint8_t obmc_mask_32[32] = { 33, 35, 36, 38, 40, 41, 43, 44,
765*77c1e3ccSAndroid Build Coastguard Worker 45, 47, 48, 50, 51, 52, 53, 55,
766*77c1e3ccSAndroid Build Coastguard Worker 56, 57, 58, 59, 60, 60, 61, 62,
767*77c1e3ccSAndroid Build Coastguard Worker 64, 64, 64, 64, 64, 64, 64, 64 };
768*77c1e3ccSAndroid Build Coastguard Worker
769*77c1e3ccSAndroid Build Coastguard Worker static const uint8_t obmc_mask_64[64] = {
770*77c1e3ccSAndroid Build Coastguard Worker 33, 34, 35, 35, 36, 37, 38, 39, 40, 40, 41, 42, 43, 44, 44, 44,
771*77c1e3ccSAndroid Build Coastguard Worker 45, 46, 47, 47, 48, 49, 50, 51, 51, 51, 52, 52, 53, 54, 55, 56,
772*77c1e3ccSAndroid Build Coastguard Worker 56, 56, 57, 57, 58, 58, 59, 60, 60, 60, 60, 60, 61, 62, 62, 62,
773*77c1e3ccSAndroid Build Coastguard Worker 62, 62, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
774*77c1e3ccSAndroid Build Coastguard Worker };
775*77c1e3ccSAndroid Build Coastguard Worker
av1_get_obmc_mask(int length)776*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *av1_get_obmc_mask(int length) {
777*77c1e3ccSAndroid Build Coastguard Worker switch (length) {
778*77c1e3ccSAndroid Build Coastguard Worker case 1: return obmc_mask_1;
779*77c1e3ccSAndroid Build Coastguard Worker case 2: return obmc_mask_2;
780*77c1e3ccSAndroid Build Coastguard Worker case 4: return obmc_mask_4;
781*77c1e3ccSAndroid Build Coastguard Worker case 8: return obmc_mask_8;
782*77c1e3ccSAndroid Build Coastguard Worker case 16: return obmc_mask_16;
783*77c1e3ccSAndroid Build Coastguard Worker case 32: return obmc_mask_32;
784*77c1e3ccSAndroid Build Coastguard Worker case 64: return obmc_mask_64;
785*77c1e3ccSAndroid Build Coastguard Worker default: assert(0); return NULL;
786*77c1e3ccSAndroid Build Coastguard Worker }
787*77c1e3ccSAndroid Build Coastguard Worker }
788*77c1e3ccSAndroid Build Coastguard Worker
increment_int_ptr(MACROBLOCKD * xd,int rel_mi_row,int rel_mi_col,uint8_t op_mi_size,int dir,MB_MODE_INFO * mi,void * fun_ctxt,const int num_planes)789*77c1e3ccSAndroid Build Coastguard Worker static inline void increment_int_ptr(MACROBLOCKD *xd, int rel_mi_row,
790*77c1e3ccSAndroid Build Coastguard Worker int rel_mi_col, uint8_t op_mi_size,
791*77c1e3ccSAndroid Build Coastguard Worker int dir, MB_MODE_INFO *mi, void *fun_ctxt,
792*77c1e3ccSAndroid Build Coastguard Worker const int num_planes) {
793*77c1e3ccSAndroid Build Coastguard Worker (void)xd;
794*77c1e3ccSAndroid Build Coastguard Worker (void)rel_mi_row;
795*77c1e3ccSAndroid Build Coastguard Worker (void)rel_mi_col;
796*77c1e3ccSAndroid Build Coastguard Worker (void)op_mi_size;
797*77c1e3ccSAndroid Build Coastguard Worker (void)dir;
798*77c1e3ccSAndroid Build Coastguard Worker (void)mi;
799*77c1e3ccSAndroid Build Coastguard Worker ++*(uint8_t *)fun_ctxt;
800*77c1e3ccSAndroid Build Coastguard Worker (void)num_planes;
801*77c1e3ccSAndroid Build Coastguard Worker }
802*77c1e3ccSAndroid Build Coastguard Worker
av1_count_overlappable_neighbors(const AV1_COMMON * cm,MACROBLOCKD * xd)803*77c1e3ccSAndroid Build Coastguard Worker void av1_count_overlappable_neighbors(const AV1_COMMON *cm, MACROBLOCKD *xd) {
804*77c1e3ccSAndroid Build Coastguard Worker MB_MODE_INFO *mbmi = xd->mi[0];
805*77c1e3ccSAndroid Build Coastguard Worker
806*77c1e3ccSAndroid Build Coastguard Worker mbmi->overlappable_neighbors = 0;
807*77c1e3ccSAndroid Build Coastguard Worker
808*77c1e3ccSAndroid Build Coastguard Worker if (!is_motion_variation_allowed_bsize(mbmi->bsize)) return;
809*77c1e3ccSAndroid Build Coastguard Worker
810*77c1e3ccSAndroid Build Coastguard Worker foreach_overlappable_nb_above(cm, xd, INT_MAX, increment_int_ptr,
811*77c1e3ccSAndroid Build Coastguard Worker &mbmi->overlappable_neighbors);
812*77c1e3ccSAndroid Build Coastguard Worker if (mbmi->overlappable_neighbors) return;
813*77c1e3ccSAndroid Build Coastguard Worker foreach_overlappable_nb_left(cm, xd, INT_MAX, increment_int_ptr,
814*77c1e3ccSAndroid Build Coastguard Worker &mbmi->overlappable_neighbors);
815*77c1e3ccSAndroid Build Coastguard Worker }
816*77c1e3ccSAndroid Build Coastguard Worker
817*77c1e3ccSAndroid Build Coastguard Worker // HW does not support < 4x4 prediction. To limit the bandwidth requirement, if
818*77c1e3ccSAndroid Build Coastguard Worker // block-size of current plane is smaller than 8x8, always only blend with the
819*77c1e3ccSAndroid Build Coastguard Worker // left neighbor(s) (skip blending with the above side).
820*77c1e3ccSAndroid Build Coastguard Worker #define DISABLE_CHROMA_U8X8_OBMC 0 // 0: one-sided obmc; 1: disable
821*77c1e3ccSAndroid Build Coastguard Worker
av1_skip_u4x4_pred_in_obmc(BLOCK_SIZE bsize,const struct macroblockd_plane * pd,int dir)822*77c1e3ccSAndroid Build Coastguard Worker int av1_skip_u4x4_pred_in_obmc(BLOCK_SIZE bsize,
823*77c1e3ccSAndroid Build Coastguard Worker const struct macroblockd_plane *pd, int dir) {
824*77c1e3ccSAndroid Build Coastguard Worker assert(is_motion_variation_allowed_bsize(bsize));
825*77c1e3ccSAndroid Build Coastguard Worker
826*77c1e3ccSAndroid Build Coastguard Worker const BLOCK_SIZE bsize_plane =
827*77c1e3ccSAndroid Build Coastguard Worker get_plane_block_size(bsize, pd->subsampling_x, pd->subsampling_y);
828*77c1e3ccSAndroid Build Coastguard Worker switch (bsize_plane) {
829*77c1e3ccSAndroid Build Coastguard Worker #if DISABLE_CHROMA_U8X8_OBMC
830*77c1e3ccSAndroid Build Coastguard Worker case BLOCK_4X4:
831*77c1e3ccSAndroid Build Coastguard Worker case BLOCK_8X4:
832*77c1e3ccSAndroid Build Coastguard Worker case BLOCK_4X8: return 1;
833*77c1e3ccSAndroid Build Coastguard Worker #else
834*77c1e3ccSAndroid Build Coastguard Worker case BLOCK_4X4:
835*77c1e3ccSAndroid Build Coastguard Worker case BLOCK_8X4:
836*77c1e3ccSAndroid Build Coastguard Worker case BLOCK_4X8: return dir == 0;
837*77c1e3ccSAndroid Build Coastguard Worker #endif
838*77c1e3ccSAndroid Build Coastguard Worker default: return 0;
839*77c1e3ccSAndroid Build Coastguard Worker }
840*77c1e3ccSAndroid Build Coastguard Worker }
841*77c1e3ccSAndroid Build Coastguard Worker
842*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_DECODER
modify_neighbor_predictor_for_obmc(MB_MODE_INFO * mbmi)843*77c1e3ccSAndroid Build Coastguard Worker static void modify_neighbor_predictor_for_obmc(MB_MODE_INFO *mbmi) {
844*77c1e3ccSAndroid Build Coastguard Worker mbmi->ref_frame[1] = NONE_FRAME;
845*77c1e3ccSAndroid Build Coastguard Worker mbmi->interinter_comp.type = COMPOUND_AVERAGE;
846*77c1e3ccSAndroid Build Coastguard Worker }
847*77c1e3ccSAndroid Build Coastguard Worker #endif // CONFIG_AV1_DECODER
848*77c1e3ccSAndroid Build Coastguard Worker
849*77c1e3ccSAndroid Build Coastguard Worker struct obmc_inter_pred_ctxt {
850*77c1e3ccSAndroid Build Coastguard Worker uint8_t **adjacent;
851*77c1e3ccSAndroid Build Coastguard Worker int *adjacent_stride;
852*77c1e3ccSAndroid Build Coastguard Worker };
853*77c1e3ccSAndroid Build Coastguard Worker
build_obmc_inter_pred_above(MACROBLOCKD * xd,int rel_mi_row,int rel_mi_col,uint8_t op_mi_size,int dir,MB_MODE_INFO * above_mi,void * fun_ctxt,const int num_planes)854*77c1e3ccSAndroid Build Coastguard Worker static inline void build_obmc_inter_pred_above(
855*77c1e3ccSAndroid Build Coastguard Worker MACROBLOCKD *xd, int rel_mi_row, int rel_mi_col, uint8_t op_mi_size,
856*77c1e3ccSAndroid Build Coastguard Worker int dir, MB_MODE_INFO *above_mi, void *fun_ctxt, const int num_planes) {
857*77c1e3ccSAndroid Build Coastguard Worker (void)above_mi;
858*77c1e3ccSAndroid Build Coastguard Worker (void)rel_mi_row;
859*77c1e3ccSAndroid Build Coastguard Worker (void)dir;
860*77c1e3ccSAndroid Build Coastguard Worker struct obmc_inter_pred_ctxt *ctxt = (struct obmc_inter_pred_ctxt *)fun_ctxt;
861*77c1e3ccSAndroid Build Coastguard Worker const BLOCK_SIZE bsize = xd->mi[0]->bsize;
862*77c1e3ccSAndroid Build Coastguard Worker const int overlap =
863*77c1e3ccSAndroid Build Coastguard Worker AOMMIN(block_size_high[bsize], block_size_high[BLOCK_64X64]) >> 1;
864*77c1e3ccSAndroid Build Coastguard Worker
865*77c1e3ccSAndroid Build Coastguard Worker for (int plane = 0; plane < num_planes; ++plane) {
866*77c1e3ccSAndroid Build Coastguard Worker const struct macroblockd_plane *pd = &xd->plane[plane];
867*77c1e3ccSAndroid Build Coastguard Worker const int bw = (op_mi_size * MI_SIZE) >> pd->subsampling_x;
868*77c1e3ccSAndroid Build Coastguard Worker const int bh = overlap >> pd->subsampling_y;
869*77c1e3ccSAndroid Build Coastguard Worker const int plane_col = (rel_mi_col * MI_SIZE) >> pd->subsampling_x;
870*77c1e3ccSAndroid Build Coastguard Worker
871*77c1e3ccSAndroid Build Coastguard Worker if (av1_skip_u4x4_pred_in_obmc(bsize, pd, 0)) continue;
872*77c1e3ccSAndroid Build Coastguard Worker
873*77c1e3ccSAndroid Build Coastguard Worker const int dst_stride = pd->dst.stride;
874*77c1e3ccSAndroid Build Coastguard Worker uint8_t *const dst = &pd->dst.buf[plane_col];
875*77c1e3ccSAndroid Build Coastguard Worker const int tmp_stride = ctxt->adjacent_stride[plane];
876*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *const tmp = &ctxt->adjacent[plane][plane_col];
877*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *const mask = av1_get_obmc_mask(bh);
878*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
879*77c1e3ccSAndroid Build Coastguard Worker const int is_hbd = is_cur_buf_hbd(xd);
880*77c1e3ccSAndroid Build Coastguard Worker if (is_hbd)
881*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_blend_a64_vmask(dst, dst_stride, dst, dst_stride, tmp,
882*77c1e3ccSAndroid Build Coastguard Worker tmp_stride, mask, bw, bh, xd->bd);
883*77c1e3ccSAndroid Build Coastguard Worker else
884*77c1e3ccSAndroid Build Coastguard Worker aom_blend_a64_vmask(dst, dst_stride, dst, dst_stride, tmp, tmp_stride,
885*77c1e3ccSAndroid Build Coastguard Worker mask, bw, bh);
886*77c1e3ccSAndroid Build Coastguard Worker #else
887*77c1e3ccSAndroid Build Coastguard Worker aom_blend_a64_vmask(dst, dst_stride, dst, dst_stride, tmp, tmp_stride, mask,
888*77c1e3ccSAndroid Build Coastguard Worker bw, bh);
889*77c1e3ccSAndroid Build Coastguard Worker #endif
890*77c1e3ccSAndroid Build Coastguard Worker }
891*77c1e3ccSAndroid Build Coastguard Worker }
892*77c1e3ccSAndroid Build Coastguard Worker
build_obmc_inter_pred_left(MACROBLOCKD * xd,int rel_mi_row,int rel_mi_col,uint8_t op_mi_size,int dir,MB_MODE_INFO * left_mi,void * fun_ctxt,const int num_planes)893*77c1e3ccSAndroid Build Coastguard Worker static inline void build_obmc_inter_pred_left(
894*77c1e3ccSAndroid Build Coastguard Worker MACROBLOCKD *xd, int rel_mi_row, int rel_mi_col, uint8_t op_mi_size,
895*77c1e3ccSAndroid Build Coastguard Worker int dir, MB_MODE_INFO *left_mi, void *fun_ctxt, const int num_planes) {
896*77c1e3ccSAndroid Build Coastguard Worker (void)left_mi;
897*77c1e3ccSAndroid Build Coastguard Worker (void)rel_mi_col;
898*77c1e3ccSAndroid Build Coastguard Worker (void)dir;
899*77c1e3ccSAndroid Build Coastguard Worker struct obmc_inter_pred_ctxt *ctxt = (struct obmc_inter_pred_ctxt *)fun_ctxt;
900*77c1e3ccSAndroid Build Coastguard Worker const BLOCK_SIZE bsize = xd->mi[0]->bsize;
901*77c1e3ccSAndroid Build Coastguard Worker const int overlap =
902*77c1e3ccSAndroid Build Coastguard Worker AOMMIN(block_size_wide[bsize], block_size_wide[BLOCK_64X64]) >> 1;
903*77c1e3ccSAndroid Build Coastguard Worker
904*77c1e3ccSAndroid Build Coastguard Worker for (int plane = 0; plane < num_planes; ++plane) {
905*77c1e3ccSAndroid Build Coastguard Worker const struct macroblockd_plane *pd = &xd->plane[plane];
906*77c1e3ccSAndroid Build Coastguard Worker const int bw = overlap >> pd->subsampling_x;
907*77c1e3ccSAndroid Build Coastguard Worker const int bh = (op_mi_size * MI_SIZE) >> pd->subsampling_y;
908*77c1e3ccSAndroid Build Coastguard Worker const int plane_row = (rel_mi_row * MI_SIZE) >> pd->subsampling_y;
909*77c1e3ccSAndroid Build Coastguard Worker
910*77c1e3ccSAndroid Build Coastguard Worker if (av1_skip_u4x4_pred_in_obmc(bsize, pd, 1)) continue;
911*77c1e3ccSAndroid Build Coastguard Worker
912*77c1e3ccSAndroid Build Coastguard Worker const int dst_stride = pd->dst.stride;
913*77c1e3ccSAndroid Build Coastguard Worker uint8_t *const dst = &pd->dst.buf[plane_row * dst_stride];
914*77c1e3ccSAndroid Build Coastguard Worker const int tmp_stride = ctxt->adjacent_stride[plane];
915*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *const tmp = &ctxt->adjacent[plane][plane_row * tmp_stride];
916*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *const mask = av1_get_obmc_mask(bw);
917*77c1e3ccSAndroid Build Coastguard Worker
918*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
919*77c1e3ccSAndroid Build Coastguard Worker const int is_hbd = is_cur_buf_hbd(xd);
920*77c1e3ccSAndroid Build Coastguard Worker if (is_hbd)
921*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_blend_a64_hmask(dst, dst_stride, dst, dst_stride, tmp,
922*77c1e3ccSAndroid Build Coastguard Worker tmp_stride, mask, bw, bh, xd->bd);
923*77c1e3ccSAndroid Build Coastguard Worker else
924*77c1e3ccSAndroid Build Coastguard Worker aom_blend_a64_hmask(dst, dst_stride, dst, dst_stride, tmp, tmp_stride,
925*77c1e3ccSAndroid Build Coastguard Worker mask, bw, bh);
926*77c1e3ccSAndroid Build Coastguard Worker #else
927*77c1e3ccSAndroid Build Coastguard Worker aom_blend_a64_hmask(dst, dst_stride, dst, dst_stride, tmp, tmp_stride, mask,
928*77c1e3ccSAndroid Build Coastguard Worker bw, bh);
929*77c1e3ccSAndroid Build Coastguard Worker #endif
930*77c1e3ccSAndroid Build Coastguard Worker }
931*77c1e3ccSAndroid Build Coastguard Worker }
932*77c1e3ccSAndroid Build Coastguard Worker
933*77c1e3ccSAndroid Build Coastguard Worker // This function combines motion compensated predictions that are generated by
934*77c1e3ccSAndroid Build Coastguard Worker // top/left neighboring blocks' inter predictors with the regular inter
935*77c1e3ccSAndroid Build Coastguard Worker // prediction. We assume the original prediction (bmc) is stored in
936*77c1e3ccSAndroid Build Coastguard Worker // xd->plane[].dst.buf
av1_build_obmc_inter_prediction(const AV1_COMMON * cm,MACROBLOCKD * xd,uint8_t * above[MAX_MB_PLANE],int above_stride[MAX_MB_PLANE],uint8_t * left[MAX_MB_PLANE],int left_stride[MAX_MB_PLANE])937*77c1e3ccSAndroid Build Coastguard Worker void av1_build_obmc_inter_prediction(const AV1_COMMON *cm, MACROBLOCKD *xd,
938*77c1e3ccSAndroid Build Coastguard Worker uint8_t *above[MAX_MB_PLANE],
939*77c1e3ccSAndroid Build Coastguard Worker int above_stride[MAX_MB_PLANE],
940*77c1e3ccSAndroid Build Coastguard Worker uint8_t *left[MAX_MB_PLANE],
941*77c1e3ccSAndroid Build Coastguard Worker int left_stride[MAX_MB_PLANE]) {
942*77c1e3ccSAndroid Build Coastguard Worker const BLOCK_SIZE bsize = xd->mi[0]->bsize;
943*77c1e3ccSAndroid Build Coastguard Worker
944*77c1e3ccSAndroid Build Coastguard Worker // handle above row
945*77c1e3ccSAndroid Build Coastguard Worker struct obmc_inter_pred_ctxt ctxt_above = { above, above_stride };
946*77c1e3ccSAndroid Build Coastguard Worker foreach_overlappable_nb_above(cm, xd,
947*77c1e3ccSAndroid Build Coastguard Worker max_neighbor_obmc[mi_size_wide_log2[bsize]],
948*77c1e3ccSAndroid Build Coastguard Worker build_obmc_inter_pred_above, &ctxt_above);
949*77c1e3ccSAndroid Build Coastguard Worker
950*77c1e3ccSAndroid Build Coastguard Worker // handle left column
951*77c1e3ccSAndroid Build Coastguard Worker struct obmc_inter_pred_ctxt ctxt_left = { left, left_stride };
952*77c1e3ccSAndroid Build Coastguard Worker foreach_overlappable_nb_left(cm, xd,
953*77c1e3ccSAndroid Build Coastguard Worker max_neighbor_obmc[mi_size_high_log2[bsize]],
954*77c1e3ccSAndroid Build Coastguard Worker build_obmc_inter_pred_left, &ctxt_left);
955*77c1e3ccSAndroid Build Coastguard Worker }
956*77c1e3ccSAndroid Build Coastguard Worker
av1_setup_obmc_dst_bufs(MACROBLOCKD * xd,uint8_t ** dst_buf1,uint8_t ** dst_buf2)957*77c1e3ccSAndroid Build Coastguard Worker void av1_setup_obmc_dst_bufs(MACROBLOCKD *xd, uint8_t **dst_buf1,
958*77c1e3ccSAndroid Build Coastguard Worker uint8_t **dst_buf2) {
959*77c1e3ccSAndroid Build Coastguard Worker if (is_cur_buf_hbd(xd)) {
960*77c1e3ccSAndroid Build Coastguard Worker int len = sizeof(uint16_t);
961*77c1e3ccSAndroid Build Coastguard Worker dst_buf1[0] = CONVERT_TO_BYTEPTR(xd->tmp_obmc_bufs[0]);
962*77c1e3ccSAndroid Build Coastguard Worker dst_buf1[1] =
963*77c1e3ccSAndroid Build Coastguard Worker CONVERT_TO_BYTEPTR(xd->tmp_obmc_bufs[0] + MAX_SB_SQUARE * len);
964*77c1e3ccSAndroid Build Coastguard Worker dst_buf1[2] =
965*77c1e3ccSAndroid Build Coastguard Worker CONVERT_TO_BYTEPTR(xd->tmp_obmc_bufs[0] + MAX_SB_SQUARE * 2 * len);
966*77c1e3ccSAndroid Build Coastguard Worker dst_buf2[0] = CONVERT_TO_BYTEPTR(xd->tmp_obmc_bufs[1]);
967*77c1e3ccSAndroid Build Coastguard Worker dst_buf2[1] =
968*77c1e3ccSAndroid Build Coastguard Worker CONVERT_TO_BYTEPTR(xd->tmp_obmc_bufs[1] + MAX_SB_SQUARE * len);
969*77c1e3ccSAndroid Build Coastguard Worker dst_buf2[2] =
970*77c1e3ccSAndroid Build Coastguard Worker CONVERT_TO_BYTEPTR(xd->tmp_obmc_bufs[1] + MAX_SB_SQUARE * 2 * len);
971*77c1e3ccSAndroid Build Coastguard Worker } else {
972*77c1e3ccSAndroid Build Coastguard Worker dst_buf1[0] = xd->tmp_obmc_bufs[0];
973*77c1e3ccSAndroid Build Coastguard Worker dst_buf1[1] = xd->tmp_obmc_bufs[0] + MAX_SB_SQUARE;
974*77c1e3ccSAndroid Build Coastguard Worker dst_buf1[2] = xd->tmp_obmc_bufs[0] + MAX_SB_SQUARE * 2;
975*77c1e3ccSAndroid Build Coastguard Worker dst_buf2[0] = xd->tmp_obmc_bufs[1];
976*77c1e3ccSAndroid Build Coastguard Worker dst_buf2[1] = xd->tmp_obmc_bufs[1] + MAX_SB_SQUARE;
977*77c1e3ccSAndroid Build Coastguard Worker dst_buf2[2] = xd->tmp_obmc_bufs[1] + MAX_SB_SQUARE * 2;
978*77c1e3ccSAndroid Build Coastguard Worker }
979*77c1e3ccSAndroid Build Coastguard Worker }
980*77c1e3ccSAndroid Build Coastguard Worker
981*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_DECODER
av1_setup_build_prediction_by_above_pred(MACROBLOCKD * xd,int rel_mi_col,uint8_t above_mi_width,MB_MODE_INFO * above_mbmi,struct build_prediction_ctxt * ctxt,const int num_planes)982*77c1e3ccSAndroid Build Coastguard Worker void av1_setup_build_prediction_by_above_pred(
983*77c1e3ccSAndroid Build Coastguard Worker MACROBLOCKD *xd, int rel_mi_col, uint8_t above_mi_width,
984*77c1e3ccSAndroid Build Coastguard Worker MB_MODE_INFO *above_mbmi, struct build_prediction_ctxt *ctxt,
985*77c1e3ccSAndroid Build Coastguard Worker const int num_planes) {
986*77c1e3ccSAndroid Build Coastguard Worker const BLOCK_SIZE a_bsize = AOMMAX(BLOCK_8X8, above_mbmi->bsize);
987*77c1e3ccSAndroid Build Coastguard Worker const int above_mi_col = xd->mi_col + rel_mi_col;
988*77c1e3ccSAndroid Build Coastguard Worker
989*77c1e3ccSAndroid Build Coastguard Worker modify_neighbor_predictor_for_obmc(above_mbmi);
990*77c1e3ccSAndroid Build Coastguard Worker
991*77c1e3ccSAndroid Build Coastguard Worker for (int j = 0; j < num_planes; ++j) {
992*77c1e3ccSAndroid Build Coastguard Worker struct macroblockd_plane *const pd = &xd->plane[j];
993*77c1e3ccSAndroid Build Coastguard Worker setup_pred_plane(&pd->dst, a_bsize, ctxt->tmp_buf[j], ctxt->tmp_width[j],
994*77c1e3ccSAndroid Build Coastguard Worker ctxt->tmp_height[j], ctxt->tmp_stride[j], 0, rel_mi_col,
995*77c1e3ccSAndroid Build Coastguard Worker NULL, pd->subsampling_x, pd->subsampling_y);
996*77c1e3ccSAndroid Build Coastguard Worker }
997*77c1e3ccSAndroid Build Coastguard Worker
998*77c1e3ccSAndroid Build Coastguard Worker const int num_refs = 1 + has_second_ref(above_mbmi);
999*77c1e3ccSAndroid Build Coastguard Worker
1000*77c1e3ccSAndroid Build Coastguard Worker for (int ref = 0; ref < num_refs; ++ref) {
1001*77c1e3ccSAndroid Build Coastguard Worker const MV_REFERENCE_FRAME frame = above_mbmi->ref_frame[ref];
1002*77c1e3ccSAndroid Build Coastguard Worker
1003*77c1e3ccSAndroid Build Coastguard Worker const RefCntBuffer *const ref_buf = get_ref_frame_buf(ctxt->cm, frame);
1004*77c1e3ccSAndroid Build Coastguard Worker const struct scale_factors *const sf =
1005*77c1e3ccSAndroid Build Coastguard Worker get_ref_scale_factors_const(ctxt->cm, frame);
1006*77c1e3ccSAndroid Build Coastguard Worker xd->block_ref_scale_factors[ref] = sf;
1007*77c1e3ccSAndroid Build Coastguard Worker if ((!av1_is_valid_scale(sf)))
1008*77c1e3ccSAndroid Build Coastguard Worker aom_internal_error(xd->error_info, AOM_CODEC_UNSUP_BITSTREAM,
1009*77c1e3ccSAndroid Build Coastguard Worker "Reference frame has invalid dimensions");
1010*77c1e3ccSAndroid Build Coastguard Worker av1_setup_pre_planes(xd, ref, &ref_buf->buf, xd->mi_row, above_mi_col, sf,
1011*77c1e3ccSAndroid Build Coastguard Worker num_planes);
1012*77c1e3ccSAndroid Build Coastguard Worker }
1013*77c1e3ccSAndroid Build Coastguard Worker
1014*77c1e3ccSAndroid Build Coastguard Worker xd->mb_to_left_edge = 8 * MI_SIZE * (-above_mi_col);
1015*77c1e3ccSAndroid Build Coastguard Worker xd->mb_to_right_edge =
1016*77c1e3ccSAndroid Build Coastguard Worker ctxt->mb_to_far_edge +
1017*77c1e3ccSAndroid Build Coastguard Worker (xd->width - rel_mi_col - above_mi_width) * MI_SIZE * 8;
1018*77c1e3ccSAndroid Build Coastguard Worker }
1019*77c1e3ccSAndroid Build Coastguard Worker
av1_setup_build_prediction_by_left_pred(MACROBLOCKD * xd,int rel_mi_row,uint8_t left_mi_height,MB_MODE_INFO * left_mbmi,struct build_prediction_ctxt * ctxt,const int num_planes)1020*77c1e3ccSAndroid Build Coastguard Worker void av1_setup_build_prediction_by_left_pred(MACROBLOCKD *xd, int rel_mi_row,
1021*77c1e3ccSAndroid Build Coastguard Worker uint8_t left_mi_height,
1022*77c1e3ccSAndroid Build Coastguard Worker MB_MODE_INFO *left_mbmi,
1023*77c1e3ccSAndroid Build Coastguard Worker struct build_prediction_ctxt *ctxt,
1024*77c1e3ccSAndroid Build Coastguard Worker const int num_planes) {
1025*77c1e3ccSAndroid Build Coastguard Worker const BLOCK_SIZE l_bsize = AOMMAX(BLOCK_8X8, left_mbmi->bsize);
1026*77c1e3ccSAndroid Build Coastguard Worker const int left_mi_row = xd->mi_row + rel_mi_row;
1027*77c1e3ccSAndroid Build Coastguard Worker
1028*77c1e3ccSAndroid Build Coastguard Worker modify_neighbor_predictor_for_obmc(left_mbmi);
1029*77c1e3ccSAndroid Build Coastguard Worker
1030*77c1e3ccSAndroid Build Coastguard Worker for (int j = 0; j < num_planes; ++j) {
1031*77c1e3ccSAndroid Build Coastguard Worker struct macroblockd_plane *const pd = &xd->plane[j];
1032*77c1e3ccSAndroid Build Coastguard Worker setup_pred_plane(&pd->dst, l_bsize, ctxt->tmp_buf[j], ctxt->tmp_width[j],
1033*77c1e3ccSAndroid Build Coastguard Worker ctxt->tmp_height[j], ctxt->tmp_stride[j], rel_mi_row, 0,
1034*77c1e3ccSAndroid Build Coastguard Worker NULL, pd->subsampling_x, pd->subsampling_y);
1035*77c1e3ccSAndroid Build Coastguard Worker }
1036*77c1e3ccSAndroid Build Coastguard Worker
1037*77c1e3ccSAndroid Build Coastguard Worker const int num_refs = 1 + has_second_ref(left_mbmi);
1038*77c1e3ccSAndroid Build Coastguard Worker
1039*77c1e3ccSAndroid Build Coastguard Worker for (int ref = 0; ref < num_refs; ++ref) {
1040*77c1e3ccSAndroid Build Coastguard Worker const MV_REFERENCE_FRAME frame = left_mbmi->ref_frame[ref];
1041*77c1e3ccSAndroid Build Coastguard Worker
1042*77c1e3ccSAndroid Build Coastguard Worker const RefCntBuffer *const ref_buf = get_ref_frame_buf(ctxt->cm, frame);
1043*77c1e3ccSAndroid Build Coastguard Worker const struct scale_factors *const ref_scale_factors =
1044*77c1e3ccSAndroid Build Coastguard Worker get_ref_scale_factors_const(ctxt->cm, frame);
1045*77c1e3ccSAndroid Build Coastguard Worker
1046*77c1e3ccSAndroid Build Coastguard Worker xd->block_ref_scale_factors[ref] = ref_scale_factors;
1047*77c1e3ccSAndroid Build Coastguard Worker if ((!av1_is_valid_scale(ref_scale_factors)))
1048*77c1e3ccSAndroid Build Coastguard Worker aom_internal_error(xd->error_info, AOM_CODEC_UNSUP_BITSTREAM,
1049*77c1e3ccSAndroid Build Coastguard Worker "Reference frame has invalid dimensions");
1050*77c1e3ccSAndroid Build Coastguard Worker av1_setup_pre_planes(xd, ref, &ref_buf->buf, left_mi_row, xd->mi_col,
1051*77c1e3ccSAndroid Build Coastguard Worker ref_scale_factors, num_planes);
1052*77c1e3ccSAndroid Build Coastguard Worker }
1053*77c1e3ccSAndroid Build Coastguard Worker
1054*77c1e3ccSAndroid Build Coastguard Worker xd->mb_to_top_edge = GET_MV_SUBPEL(MI_SIZE * (-left_mi_row));
1055*77c1e3ccSAndroid Build Coastguard Worker xd->mb_to_bottom_edge =
1056*77c1e3ccSAndroid Build Coastguard Worker ctxt->mb_to_far_edge +
1057*77c1e3ccSAndroid Build Coastguard Worker GET_MV_SUBPEL((xd->height - rel_mi_row - left_mi_height) * MI_SIZE);
1058*77c1e3ccSAndroid Build Coastguard Worker }
1059*77c1e3ccSAndroid Build Coastguard Worker #endif // CONFIG_AV1_DECODER
1060*77c1e3ccSAndroid Build Coastguard Worker
combine_interintra(INTERINTRA_MODE mode,int8_t use_wedge_interintra,int8_t wedge_index,int8_t wedge_sign,BLOCK_SIZE bsize,BLOCK_SIZE plane_bsize,uint8_t * comppred,int compstride,const uint8_t * interpred,int interstride,const uint8_t * intrapred,int intrastride)1061*77c1e3ccSAndroid Build Coastguard Worker static inline void combine_interintra(
1062*77c1e3ccSAndroid Build Coastguard Worker INTERINTRA_MODE mode, int8_t use_wedge_interintra, int8_t wedge_index,
1063*77c1e3ccSAndroid Build Coastguard Worker int8_t wedge_sign, BLOCK_SIZE bsize, BLOCK_SIZE plane_bsize,
1064*77c1e3ccSAndroid Build Coastguard Worker uint8_t *comppred, int compstride, const uint8_t *interpred,
1065*77c1e3ccSAndroid Build Coastguard Worker int interstride, const uint8_t *intrapred, int intrastride) {
1066*77c1e3ccSAndroid Build Coastguard Worker const int bw = block_size_wide[plane_bsize];
1067*77c1e3ccSAndroid Build Coastguard Worker const int bh = block_size_high[plane_bsize];
1068*77c1e3ccSAndroid Build Coastguard Worker
1069*77c1e3ccSAndroid Build Coastguard Worker if (use_wedge_interintra) {
1070*77c1e3ccSAndroid Build Coastguard Worker if (av1_is_wedge_used(bsize)) {
1071*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *mask =
1072*77c1e3ccSAndroid Build Coastguard Worker av1_get_contiguous_soft_mask(wedge_index, wedge_sign, bsize);
1073*77c1e3ccSAndroid Build Coastguard Worker const int subw = 2 * mi_size_wide[bsize] == bw;
1074*77c1e3ccSAndroid Build Coastguard Worker const int subh = 2 * mi_size_high[bsize] == bh;
1075*77c1e3ccSAndroid Build Coastguard Worker aom_blend_a64_mask(comppred, compstride, intrapred, intrastride,
1076*77c1e3ccSAndroid Build Coastguard Worker interpred, interstride, mask, block_size_wide[bsize],
1077*77c1e3ccSAndroid Build Coastguard Worker bw, bh, subw, subh);
1078*77c1e3ccSAndroid Build Coastguard Worker }
1079*77c1e3ccSAndroid Build Coastguard Worker return;
1080*77c1e3ccSAndroid Build Coastguard Worker }
1081*77c1e3ccSAndroid Build Coastguard Worker
1082*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *mask = smooth_interintra_mask_buf[mode][plane_bsize];
1083*77c1e3ccSAndroid Build Coastguard Worker aom_blend_a64_mask(comppred, compstride, intrapred, intrastride, interpred,
1084*77c1e3ccSAndroid Build Coastguard Worker interstride, mask, bw, bw, bh, 0, 0);
1085*77c1e3ccSAndroid Build Coastguard Worker }
1086*77c1e3ccSAndroid Build Coastguard Worker
1087*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
combine_interintra_highbd(INTERINTRA_MODE mode,int8_t use_wedge_interintra,int8_t wedge_index,int8_t wedge_sign,BLOCK_SIZE bsize,BLOCK_SIZE plane_bsize,uint8_t * comppred8,int compstride,const uint8_t * interpred8,int interstride,const uint8_t * intrapred8,int intrastride,int bd)1088*77c1e3ccSAndroid Build Coastguard Worker static inline void combine_interintra_highbd(
1089*77c1e3ccSAndroid Build Coastguard Worker INTERINTRA_MODE mode, int8_t use_wedge_interintra, int8_t wedge_index,
1090*77c1e3ccSAndroid Build Coastguard Worker int8_t wedge_sign, BLOCK_SIZE bsize, BLOCK_SIZE plane_bsize,
1091*77c1e3ccSAndroid Build Coastguard Worker uint8_t *comppred8, int compstride, const uint8_t *interpred8,
1092*77c1e3ccSAndroid Build Coastguard Worker int interstride, const uint8_t *intrapred8, int intrastride, int bd) {
1093*77c1e3ccSAndroid Build Coastguard Worker const int bw = block_size_wide[plane_bsize];
1094*77c1e3ccSAndroid Build Coastguard Worker const int bh = block_size_high[plane_bsize];
1095*77c1e3ccSAndroid Build Coastguard Worker
1096*77c1e3ccSAndroid Build Coastguard Worker if (use_wedge_interintra) {
1097*77c1e3ccSAndroid Build Coastguard Worker if (av1_is_wedge_used(bsize)) {
1098*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *mask =
1099*77c1e3ccSAndroid Build Coastguard Worker av1_get_contiguous_soft_mask(wedge_index, wedge_sign, bsize);
1100*77c1e3ccSAndroid Build Coastguard Worker const int subh = 2 * mi_size_high[bsize] == bh;
1101*77c1e3ccSAndroid Build Coastguard Worker const int subw = 2 * mi_size_wide[bsize] == bw;
1102*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_blend_a64_mask(comppred8, compstride, intrapred8, intrastride,
1103*77c1e3ccSAndroid Build Coastguard Worker interpred8, interstride, mask,
1104*77c1e3ccSAndroid Build Coastguard Worker block_size_wide[bsize], bw, bh, subw, subh, bd);
1105*77c1e3ccSAndroid Build Coastguard Worker }
1106*77c1e3ccSAndroid Build Coastguard Worker return;
1107*77c1e3ccSAndroid Build Coastguard Worker }
1108*77c1e3ccSAndroid Build Coastguard Worker
1109*77c1e3ccSAndroid Build Coastguard Worker uint8_t mask[MAX_SB_SQUARE];
1110*77c1e3ccSAndroid Build Coastguard Worker build_smooth_interintra_mask(mask, bw, plane_bsize, mode);
1111*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_blend_a64_mask(comppred8, compstride, intrapred8, intrastride,
1112*77c1e3ccSAndroid Build Coastguard Worker interpred8, interstride, mask, bw, bw, bh, 0, 0,
1113*77c1e3ccSAndroid Build Coastguard Worker bd);
1114*77c1e3ccSAndroid Build Coastguard Worker }
1115*77c1e3ccSAndroid Build Coastguard Worker #endif
1116*77c1e3ccSAndroid Build Coastguard Worker
av1_build_intra_predictors_for_interintra(const AV1_COMMON * cm,MACROBLOCKD * xd,BLOCK_SIZE bsize,int plane,const BUFFER_SET * ctx,uint8_t * dst,int dst_stride)1117*77c1e3ccSAndroid Build Coastguard Worker void av1_build_intra_predictors_for_interintra(const AV1_COMMON *cm,
1118*77c1e3ccSAndroid Build Coastguard Worker MACROBLOCKD *xd,
1119*77c1e3ccSAndroid Build Coastguard Worker BLOCK_SIZE bsize, int plane,
1120*77c1e3ccSAndroid Build Coastguard Worker const BUFFER_SET *ctx,
1121*77c1e3ccSAndroid Build Coastguard Worker uint8_t *dst, int dst_stride) {
1122*77c1e3ccSAndroid Build Coastguard Worker struct macroblockd_plane *const pd = &xd->plane[plane];
1123*77c1e3ccSAndroid Build Coastguard Worker const int ssx = xd->plane[plane].subsampling_x;
1124*77c1e3ccSAndroid Build Coastguard Worker const int ssy = xd->plane[plane].subsampling_y;
1125*77c1e3ccSAndroid Build Coastguard Worker BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, ssx, ssy);
1126*77c1e3ccSAndroid Build Coastguard Worker PREDICTION_MODE mode = interintra_to_intra_mode[xd->mi[0]->interintra_mode];
1127*77c1e3ccSAndroid Build Coastguard Worker assert(xd->mi[0]->angle_delta[PLANE_TYPE_Y] == 0);
1128*77c1e3ccSAndroid Build Coastguard Worker assert(xd->mi[0]->angle_delta[PLANE_TYPE_UV] == 0);
1129*77c1e3ccSAndroid Build Coastguard Worker assert(xd->mi[0]->filter_intra_mode_info.use_filter_intra == 0);
1130*77c1e3ccSAndroid Build Coastguard Worker assert(xd->mi[0]->use_intrabc == 0);
1131*77c1e3ccSAndroid Build Coastguard Worker const SequenceHeader *seq_params = cm->seq_params;
1132*77c1e3ccSAndroid Build Coastguard Worker
1133*77c1e3ccSAndroid Build Coastguard Worker av1_predict_intra_block(xd, seq_params->sb_size,
1134*77c1e3ccSAndroid Build Coastguard Worker seq_params->enable_intra_edge_filter, pd->width,
1135*77c1e3ccSAndroid Build Coastguard Worker pd->height, max_txsize_rect_lookup[plane_bsize], mode,
1136*77c1e3ccSAndroid Build Coastguard Worker 0, 0, FILTER_INTRA_MODES, ctx->plane[plane],
1137*77c1e3ccSAndroid Build Coastguard Worker ctx->stride[plane], dst, dst_stride, 0, 0, plane);
1138*77c1e3ccSAndroid Build Coastguard Worker }
1139*77c1e3ccSAndroid Build Coastguard Worker
av1_combine_interintra(MACROBLOCKD * xd,BLOCK_SIZE bsize,int plane,const uint8_t * inter_pred,int inter_stride,const uint8_t * intra_pred,int intra_stride)1140*77c1e3ccSAndroid Build Coastguard Worker void av1_combine_interintra(MACROBLOCKD *xd, BLOCK_SIZE bsize, int plane,
1141*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *inter_pred, int inter_stride,
1142*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *intra_pred, int intra_stride) {
1143*77c1e3ccSAndroid Build Coastguard Worker const int ssx = xd->plane[plane].subsampling_x;
1144*77c1e3ccSAndroid Build Coastguard Worker const int ssy = xd->plane[plane].subsampling_y;
1145*77c1e3ccSAndroid Build Coastguard Worker const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, ssx, ssy);
1146*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
1147*77c1e3ccSAndroid Build Coastguard Worker if (is_cur_buf_hbd(xd)) {
1148*77c1e3ccSAndroid Build Coastguard Worker combine_interintra_highbd(
1149*77c1e3ccSAndroid Build Coastguard Worker xd->mi[0]->interintra_mode, xd->mi[0]->use_wedge_interintra,
1150*77c1e3ccSAndroid Build Coastguard Worker xd->mi[0]->interintra_wedge_index, INTERINTRA_WEDGE_SIGN, bsize,
1151*77c1e3ccSAndroid Build Coastguard Worker plane_bsize, xd->plane[plane].dst.buf, xd->plane[plane].dst.stride,
1152*77c1e3ccSAndroid Build Coastguard Worker inter_pred, inter_stride, intra_pred, intra_stride, xd->bd);
1153*77c1e3ccSAndroid Build Coastguard Worker return;
1154*77c1e3ccSAndroid Build Coastguard Worker }
1155*77c1e3ccSAndroid Build Coastguard Worker #endif
1156*77c1e3ccSAndroid Build Coastguard Worker combine_interintra(
1157*77c1e3ccSAndroid Build Coastguard Worker xd->mi[0]->interintra_mode, xd->mi[0]->use_wedge_interintra,
1158*77c1e3ccSAndroid Build Coastguard Worker xd->mi[0]->interintra_wedge_index, INTERINTRA_WEDGE_SIGN, bsize,
1159*77c1e3ccSAndroid Build Coastguard Worker plane_bsize, xd->plane[plane].dst.buf, xd->plane[plane].dst.stride,
1160*77c1e3ccSAndroid Build Coastguard Worker inter_pred, inter_stride, intra_pred, intra_stride);
1161*77c1e3ccSAndroid Build Coastguard Worker }
1162*77c1e3ccSAndroid Build Coastguard Worker
1163*77c1e3ccSAndroid Build Coastguard Worker // build interintra_predictors for one plane
av1_build_interintra_predictor(const AV1_COMMON * cm,MACROBLOCKD * xd,uint8_t * pred,int stride,const BUFFER_SET * ctx,int plane,BLOCK_SIZE bsize)1164*77c1e3ccSAndroid Build Coastguard Worker void av1_build_interintra_predictor(const AV1_COMMON *cm, MACROBLOCKD *xd,
1165*77c1e3ccSAndroid Build Coastguard Worker uint8_t *pred, int stride,
1166*77c1e3ccSAndroid Build Coastguard Worker const BUFFER_SET *ctx, int plane,
1167*77c1e3ccSAndroid Build Coastguard Worker BLOCK_SIZE bsize) {
1168*77c1e3ccSAndroid Build Coastguard Worker assert(bsize < BLOCK_SIZES_ALL);
1169*77c1e3ccSAndroid Build Coastguard Worker if (is_cur_buf_hbd(xd)) {
1170*77c1e3ccSAndroid Build Coastguard Worker DECLARE_ALIGNED(16, uint16_t, intrapredictor[MAX_SB_SQUARE]);
1171*77c1e3ccSAndroid Build Coastguard Worker av1_build_intra_predictors_for_interintra(
1172*77c1e3ccSAndroid Build Coastguard Worker cm, xd, bsize, plane, ctx, CONVERT_TO_BYTEPTR(intrapredictor),
1173*77c1e3ccSAndroid Build Coastguard Worker MAX_SB_SIZE);
1174*77c1e3ccSAndroid Build Coastguard Worker av1_combine_interintra(xd, bsize, plane, pred, stride,
1175*77c1e3ccSAndroid Build Coastguard Worker CONVERT_TO_BYTEPTR(intrapredictor), MAX_SB_SIZE);
1176*77c1e3ccSAndroid Build Coastguard Worker } else {
1177*77c1e3ccSAndroid Build Coastguard Worker DECLARE_ALIGNED(16, uint8_t, intrapredictor[MAX_SB_SQUARE]);
1178*77c1e3ccSAndroid Build Coastguard Worker av1_build_intra_predictors_for_interintra(cm, xd, bsize, plane, ctx,
1179*77c1e3ccSAndroid Build Coastguard Worker intrapredictor, MAX_SB_SIZE);
1180*77c1e3ccSAndroid Build Coastguard Worker av1_combine_interintra(xd, bsize, plane, pred, stride, intrapredictor,
1181*77c1e3ccSAndroid Build Coastguard Worker MAX_SB_SIZE);
1182*77c1e3ccSAndroid Build Coastguard Worker }
1183*77c1e3ccSAndroid Build Coastguard Worker }
1184