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
23*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/av1_common_int.h"
24*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/blockd.h"
25*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/mvref_common.h"
26*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/obmc.h"
27*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/reconinter.h"
28*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/reconintra.h"
29*77c1e3ccSAndroid Build Coastguard Worker #include "av1/encoder/reconinter_enc.h"
30*77c1e3ccSAndroid Build Coastguard Worker
enc_calc_subpel_params(const MV * const src_mv,InterPredParams * const inter_pred_params,uint8_t ** pre,SubpelParams * subpel_params,int * src_stride)31*77c1e3ccSAndroid Build Coastguard Worker static inline void enc_calc_subpel_params(
32*77c1e3ccSAndroid Build Coastguard Worker const MV *const src_mv, InterPredParams *const inter_pred_params,
33*77c1e3ccSAndroid Build Coastguard Worker uint8_t **pre, SubpelParams *subpel_params, int *src_stride) {
34*77c1e3ccSAndroid Build Coastguard Worker struct buf_2d *pre_buf = &inter_pred_params->ref_frame_buf;
35*77c1e3ccSAndroid Build Coastguard Worker init_subpel_params(src_mv, inter_pred_params, subpel_params, pre_buf->width,
36*77c1e3ccSAndroid Build Coastguard Worker pre_buf->height);
37*77c1e3ccSAndroid Build Coastguard Worker *pre = pre_buf->buf0 +
38*77c1e3ccSAndroid Build Coastguard Worker (subpel_params->pos_y >> SCALE_SUBPEL_BITS) * pre_buf->stride +
39*77c1e3ccSAndroid Build Coastguard Worker (subpel_params->pos_x >> SCALE_SUBPEL_BITS);
40*77c1e3ccSAndroid Build Coastguard Worker *src_stride = pre_buf->stride;
41*77c1e3ccSAndroid Build Coastguard Worker }
42*77c1e3ccSAndroid Build Coastguard Worker
43*77c1e3ccSAndroid Build Coastguard Worker #define IS_DEC 0
44*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/reconinter_template.inc"
45*77c1e3ccSAndroid Build Coastguard Worker #undef IS_DEC
46*77c1e3ccSAndroid Build Coastguard Worker
av1_enc_build_one_inter_predictor(uint8_t * dst,int dst_stride,const MV * src_mv,InterPredParams * inter_pred_params)47*77c1e3ccSAndroid Build Coastguard Worker void av1_enc_build_one_inter_predictor(uint8_t *dst, int dst_stride,
48*77c1e3ccSAndroid Build Coastguard Worker const MV *src_mv,
49*77c1e3ccSAndroid Build Coastguard Worker InterPredParams *inter_pred_params) {
50*77c1e3ccSAndroid Build Coastguard Worker build_one_inter_predictor(dst, dst_stride, src_mv, inter_pred_params);
51*77c1e3ccSAndroid Build Coastguard Worker }
52*77c1e3ccSAndroid Build Coastguard Worker
enc_build_inter_predictors(const AV1_COMMON * cm,MACROBLOCKD * xd,int plane,const MB_MODE_INFO * mi,int bw,int bh,int mi_x,int mi_y)53*77c1e3ccSAndroid Build Coastguard Worker static void enc_build_inter_predictors(const AV1_COMMON *cm, MACROBLOCKD *xd,
54*77c1e3ccSAndroid Build Coastguard Worker int plane, const MB_MODE_INFO *mi,
55*77c1e3ccSAndroid Build Coastguard Worker int bw, int bh, int mi_x, int mi_y) {
56*77c1e3ccSAndroid Build Coastguard Worker build_inter_predictors(cm, xd, plane, mi, /*build_for_obmc=*/0, bw, bh, mi_x,
57*77c1e3ccSAndroid Build Coastguard Worker mi_y);
58*77c1e3ccSAndroid Build Coastguard Worker }
59*77c1e3ccSAndroid Build Coastguard Worker
av1_enc_build_inter_predictor_y(MACROBLOCKD * xd,int mi_row,int mi_col)60*77c1e3ccSAndroid Build Coastguard Worker void av1_enc_build_inter_predictor_y(MACROBLOCKD *xd, int mi_row, int mi_col) {
61*77c1e3ccSAndroid Build Coastguard Worker const int mi_x = mi_col * MI_SIZE;
62*77c1e3ccSAndroid Build Coastguard Worker const int mi_y = mi_row * MI_SIZE;
63*77c1e3ccSAndroid Build Coastguard Worker struct macroblockd_plane *const pd = &xd->plane[AOM_PLANE_Y];
64*77c1e3ccSAndroid Build Coastguard Worker InterPredParams inter_pred_params;
65*77c1e3ccSAndroid Build Coastguard Worker
66*77c1e3ccSAndroid Build Coastguard Worker struct buf_2d *const dst_buf = &pd->dst;
67*77c1e3ccSAndroid Build Coastguard Worker uint8_t *const dst = dst_buf->buf;
68*77c1e3ccSAndroid Build Coastguard Worker const MV mv = xd->mi[0]->mv[0].as_mv;
69*77c1e3ccSAndroid Build Coastguard Worker const struct scale_factors *const sf = xd->block_ref_scale_factors[0];
70*77c1e3ccSAndroid Build Coastguard Worker
71*77c1e3ccSAndroid Build Coastguard Worker av1_init_inter_params(&inter_pred_params, pd->width, pd->height, mi_y, mi_x,
72*77c1e3ccSAndroid Build Coastguard Worker pd->subsampling_x, pd->subsampling_y, xd->bd,
73*77c1e3ccSAndroid Build Coastguard Worker is_cur_buf_hbd(xd), false, sf, pd->pre,
74*77c1e3ccSAndroid Build Coastguard Worker xd->mi[0]->interp_filters);
75*77c1e3ccSAndroid Build Coastguard Worker
76*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params.conv_params = get_conv_params_no_round(
77*77c1e3ccSAndroid Build Coastguard Worker 0, AOM_PLANE_Y, xd->tmp_conv_dst, MAX_SB_SIZE, false, xd->bd);
78*77c1e3ccSAndroid Build Coastguard Worker
79*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params.conv_params.use_dist_wtd_comp_avg = 0;
80*77c1e3ccSAndroid Build Coastguard Worker av1_enc_build_one_inter_predictor(dst, dst_buf->stride, &mv,
81*77c1e3ccSAndroid Build Coastguard Worker &inter_pred_params);
82*77c1e3ccSAndroid Build Coastguard Worker }
83*77c1e3ccSAndroid Build Coastguard Worker
av1_enc_build_inter_predictor_y_nonrd(MACROBLOCKD * xd,InterPredParams * inter_pred_params,const SubpelParams * subpel_params)84*77c1e3ccSAndroid Build Coastguard Worker void av1_enc_build_inter_predictor_y_nonrd(MACROBLOCKD *xd,
85*77c1e3ccSAndroid Build Coastguard Worker InterPredParams *inter_pred_params,
86*77c1e3ccSAndroid Build Coastguard Worker const SubpelParams *subpel_params) {
87*77c1e3ccSAndroid Build Coastguard Worker struct macroblockd_plane *const pd = &xd->plane[AOM_PLANE_Y];
88*77c1e3ccSAndroid Build Coastguard Worker
89*77c1e3ccSAndroid Build Coastguard Worker const MB_MODE_INFO *mbmi = xd->mi[0];
90*77c1e3ccSAndroid Build Coastguard Worker struct buf_2d *const dst_buf = &pd->dst;
91*77c1e3ccSAndroid Build Coastguard Worker const struct buf_2d *pre_buf = &pd->pre[0];
92*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *src =
93*77c1e3ccSAndroid Build Coastguard Worker pre_buf->buf0 +
94*77c1e3ccSAndroid Build Coastguard Worker (subpel_params->pos_y >> SCALE_SUBPEL_BITS) * pre_buf->stride +
95*77c1e3ccSAndroid Build Coastguard Worker (subpel_params->pos_x >> SCALE_SUBPEL_BITS);
96*77c1e3ccSAndroid Build Coastguard Worker uint8_t *const dst = dst_buf->buf;
97*77c1e3ccSAndroid Build Coastguard Worker int src_stride = pre_buf->stride;
98*77c1e3ccSAndroid Build Coastguard Worker int dst_stride = dst_buf->stride;
99*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params->ref_frame_buf = *pre_buf;
100*77c1e3ccSAndroid Build Coastguard Worker
101*77c1e3ccSAndroid Build Coastguard Worker // Initialize interp filter for single reference mode.
102*77c1e3ccSAndroid Build Coastguard Worker init_interp_filter_params(inter_pred_params->interp_filter_params,
103*77c1e3ccSAndroid Build Coastguard Worker &mbmi->interp_filters.as_filters, pd->width,
104*77c1e3ccSAndroid Build Coastguard Worker pd->height, /*is_intrabc=*/0);
105*77c1e3ccSAndroid Build Coastguard Worker
106*77c1e3ccSAndroid Build Coastguard Worker av1_make_inter_predictor(src, src_stride, dst, dst_stride, inter_pred_params,
107*77c1e3ccSAndroid Build Coastguard Worker subpel_params);
108*77c1e3ccSAndroid Build Coastguard Worker }
109*77c1e3ccSAndroid Build Coastguard Worker
av1_enc_build_inter_predictor(const AV1_COMMON * cm,MACROBLOCKD * xd,int mi_row,int mi_col,const BUFFER_SET * ctx,BLOCK_SIZE bsize,int plane_from,int plane_to)110*77c1e3ccSAndroid Build Coastguard Worker void av1_enc_build_inter_predictor(const AV1_COMMON *cm, MACROBLOCKD *xd,
111*77c1e3ccSAndroid Build Coastguard Worker int mi_row, int mi_col,
112*77c1e3ccSAndroid Build Coastguard Worker const BUFFER_SET *ctx, BLOCK_SIZE bsize,
113*77c1e3ccSAndroid Build Coastguard Worker int plane_from, int plane_to) {
114*77c1e3ccSAndroid Build Coastguard Worker for (int plane = plane_from; plane <= plane_to; ++plane) {
115*77c1e3ccSAndroid Build Coastguard Worker if (plane && !xd->is_chroma_ref) break;
116*77c1e3ccSAndroid Build Coastguard Worker const int mi_x = mi_col * MI_SIZE;
117*77c1e3ccSAndroid Build Coastguard Worker const int mi_y = mi_row * MI_SIZE;
118*77c1e3ccSAndroid Build Coastguard Worker enc_build_inter_predictors(cm, xd, plane, xd->mi[0], xd->plane[plane].width,
119*77c1e3ccSAndroid Build Coastguard Worker xd->plane[plane].height, mi_x, mi_y);
120*77c1e3ccSAndroid Build Coastguard Worker
121*77c1e3ccSAndroid Build Coastguard Worker if (is_interintra_pred(xd->mi[0])) {
122*77c1e3ccSAndroid Build Coastguard Worker BUFFER_SET default_ctx = {
123*77c1e3ccSAndroid Build Coastguard Worker { xd->plane[0].dst.buf, xd->plane[1].dst.buf, xd->plane[2].dst.buf },
124*77c1e3ccSAndroid Build Coastguard Worker { xd->plane[0].dst.stride, xd->plane[1].dst.stride,
125*77c1e3ccSAndroid Build Coastguard Worker xd->plane[2].dst.stride }
126*77c1e3ccSAndroid Build Coastguard Worker };
127*77c1e3ccSAndroid Build Coastguard Worker if (!ctx) {
128*77c1e3ccSAndroid Build Coastguard Worker ctx = &default_ctx;
129*77c1e3ccSAndroid Build Coastguard Worker }
130*77c1e3ccSAndroid Build Coastguard Worker av1_build_interintra_predictor(cm, xd, xd->plane[plane].dst.buf,
131*77c1e3ccSAndroid Build Coastguard Worker xd->plane[plane].dst.stride, ctx, plane,
132*77c1e3ccSAndroid Build Coastguard Worker bsize);
133*77c1e3ccSAndroid Build Coastguard Worker }
134*77c1e3ccSAndroid Build Coastguard Worker }
135*77c1e3ccSAndroid Build Coastguard Worker }
136*77c1e3ccSAndroid Build Coastguard Worker
setup_address_for_obmc(MACROBLOCKD * xd,int mi_row_offset,int mi_col_offset,MB_MODE_INFO * ref_mbmi,struct build_prediction_ctxt * ctxt,const int num_planes)137*77c1e3ccSAndroid Build Coastguard Worker static void setup_address_for_obmc(MACROBLOCKD *xd, int mi_row_offset,
138*77c1e3ccSAndroid Build Coastguard Worker int mi_col_offset, MB_MODE_INFO *ref_mbmi,
139*77c1e3ccSAndroid Build Coastguard Worker struct build_prediction_ctxt *ctxt,
140*77c1e3ccSAndroid Build Coastguard Worker const int num_planes) {
141*77c1e3ccSAndroid Build Coastguard Worker const BLOCK_SIZE ref_bsize = AOMMAX(BLOCK_8X8, ref_mbmi->bsize);
142*77c1e3ccSAndroid Build Coastguard Worker const int ref_mi_row = xd->mi_row + mi_row_offset;
143*77c1e3ccSAndroid Build Coastguard Worker const int ref_mi_col = xd->mi_col + mi_col_offset;
144*77c1e3ccSAndroid Build Coastguard Worker
145*77c1e3ccSAndroid Build Coastguard Worker for (int plane = 0; plane < num_planes; ++plane) {
146*77c1e3ccSAndroid Build Coastguard Worker struct macroblockd_plane *const pd = &xd->plane[plane];
147*77c1e3ccSAndroid Build Coastguard Worker setup_pred_plane(&pd->dst, ref_bsize, ctxt->tmp_buf[plane],
148*77c1e3ccSAndroid Build Coastguard Worker ctxt->tmp_width[plane], ctxt->tmp_height[plane],
149*77c1e3ccSAndroid Build Coastguard Worker ctxt->tmp_stride[plane], mi_row_offset, mi_col_offset,
150*77c1e3ccSAndroid Build Coastguard Worker NULL, pd->subsampling_x, pd->subsampling_y);
151*77c1e3ccSAndroid Build Coastguard Worker }
152*77c1e3ccSAndroid Build Coastguard Worker
153*77c1e3ccSAndroid Build Coastguard Worker const MV_REFERENCE_FRAME frame = ref_mbmi->ref_frame[0];
154*77c1e3ccSAndroid Build Coastguard Worker
155*77c1e3ccSAndroid Build Coastguard Worker const RefCntBuffer *const ref_buf = get_ref_frame_buf(ctxt->cm, frame);
156*77c1e3ccSAndroid Build Coastguard Worker const struct scale_factors *const sf =
157*77c1e3ccSAndroid Build Coastguard Worker get_ref_scale_factors_const(ctxt->cm, frame);
158*77c1e3ccSAndroid Build Coastguard Worker
159*77c1e3ccSAndroid Build Coastguard Worker xd->block_ref_scale_factors[0] = sf;
160*77c1e3ccSAndroid Build Coastguard Worker if (!av1_is_valid_scale(sf))
161*77c1e3ccSAndroid Build Coastguard Worker aom_internal_error(xd->error_info, AOM_CODEC_UNSUP_BITSTREAM,
162*77c1e3ccSAndroid Build Coastguard Worker "Reference frame has invalid dimensions");
163*77c1e3ccSAndroid Build Coastguard Worker
164*77c1e3ccSAndroid Build Coastguard Worker av1_setup_pre_planes(xd, 0, &ref_buf->buf, ref_mi_row, ref_mi_col, sf,
165*77c1e3ccSAndroid Build Coastguard Worker num_planes);
166*77c1e3ccSAndroid Build Coastguard Worker }
167*77c1e3ccSAndroid Build Coastguard Worker
build_obmc_prediction(MACROBLOCKD * xd,int rel_mi_row,int rel_mi_col,uint8_t op_mi_size,int dir,MB_MODE_INFO * above_mbmi,void * fun_ctxt,const int num_planes)168*77c1e3ccSAndroid Build Coastguard Worker static inline void build_obmc_prediction(MACROBLOCKD *xd, int rel_mi_row,
169*77c1e3ccSAndroid Build Coastguard Worker int rel_mi_col, uint8_t op_mi_size,
170*77c1e3ccSAndroid Build Coastguard Worker int dir, MB_MODE_INFO *above_mbmi,
171*77c1e3ccSAndroid Build Coastguard Worker void *fun_ctxt, const int num_planes) {
172*77c1e3ccSAndroid Build Coastguard Worker struct build_prediction_ctxt *ctxt = (struct build_prediction_ctxt *)fun_ctxt;
173*77c1e3ccSAndroid Build Coastguard Worker setup_address_for_obmc(xd, rel_mi_row, rel_mi_col, above_mbmi, ctxt,
174*77c1e3ccSAndroid Build Coastguard Worker num_planes);
175*77c1e3ccSAndroid Build Coastguard Worker
176*77c1e3ccSAndroid Build Coastguard Worker const int mi_x = (xd->mi_col + rel_mi_col) << MI_SIZE_LOG2;
177*77c1e3ccSAndroid Build Coastguard Worker const int mi_y = (xd->mi_row + rel_mi_row) << MI_SIZE_LOG2;
178*77c1e3ccSAndroid Build Coastguard Worker
179*77c1e3ccSAndroid Build Coastguard Worker const BLOCK_SIZE bsize = xd->mi[0]->bsize;
180*77c1e3ccSAndroid Build Coastguard Worker
181*77c1e3ccSAndroid Build Coastguard Worker InterPredParams inter_pred_params;
182*77c1e3ccSAndroid Build Coastguard Worker
183*77c1e3ccSAndroid Build Coastguard Worker for (int j = 0; j < num_planes; ++j) {
184*77c1e3ccSAndroid Build Coastguard Worker const struct macroblockd_plane *pd = &xd->plane[j];
185*77c1e3ccSAndroid Build Coastguard Worker int bw = 0, bh = 0;
186*77c1e3ccSAndroid Build Coastguard Worker
187*77c1e3ccSAndroid Build Coastguard Worker if (dir) {
188*77c1e3ccSAndroid Build Coastguard Worker // prepare left reference block size
189*77c1e3ccSAndroid Build Coastguard Worker bw = clamp(block_size_wide[bsize] >> (pd->subsampling_x + 1), 4,
190*77c1e3ccSAndroid Build Coastguard Worker block_size_wide[BLOCK_64X64] >> (pd->subsampling_x + 1));
191*77c1e3ccSAndroid Build Coastguard Worker bh = (op_mi_size << MI_SIZE_LOG2) >> pd->subsampling_y;
192*77c1e3ccSAndroid Build Coastguard Worker } else {
193*77c1e3ccSAndroid Build Coastguard Worker // prepare above reference block size
194*77c1e3ccSAndroid Build Coastguard Worker bw = (op_mi_size * MI_SIZE) >> pd->subsampling_x;
195*77c1e3ccSAndroid Build Coastguard Worker bh = clamp(block_size_high[bsize] >> (pd->subsampling_y + 1), 4,
196*77c1e3ccSAndroid Build Coastguard Worker block_size_high[BLOCK_64X64] >> (pd->subsampling_y + 1));
197*77c1e3ccSAndroid Build Coastguard Worker }
198*77c1e3ccSAndroid Build Coastguard Worker
199*77c1e3ccSAndroid Build Coastguard Worker if (av1_skip_u4x4_pred_in_obmc(bsize, pd, dir)) continue;
200*77c1e3ccSAndroid Build Coastguard Worker
201*77c1e3ccSAndroid Build Coastguard Worker const struct buf_2d *const pre_buf = &pd->pre[0];
202*77c1e3ccSAndroid Build Coastguard Worker const MV mv = above_mbmi->mv[0].as_mv;
203*77c1e3ccSAndroid Build Coastguard Worker
204*77c1e3ccSAndroid Build Coastguard Worker av1_init_inter_params(&inter_pred_params, bw, bh, mi_y >> pd->subsampling_y,
205*77c1e3ccSAndroid Build Coastguard Worker mi_x >> pd->subsampling_x, pd->subsampling_x,
206*77c1e3ccSAndroid Build Coastguard Worker pd->subsampling_y, xd->bd, is_cur_buf_hbd(xd), 0,
207*77c1e3ccSAndroid Build Coastguard Worker xd->block_ref_scale_factors[0], pre_buf,
208*77c1e3ccSAndroid Build Coastguard Worker above_mbmi->interp_filters);
209*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params.conv_params = get_conv_params(0, j, xd->bd);
210*77c1e3ccSAndroid Build Coastguard Worker
211*77c1e3ccSAndroid Build Coastguard Worker av1_enc_build_one_inter_predictor(pd->dst.buf, pd->dst.stride, &mv,
212*77c1e3ccSAndroid Build Coastguard Worker &inter_pred_params);
213*77c1e3ccSAndroid Build Coastguard Worker }
214*77c1e3ccSAndroid Build Coastguard Worker }
215*77c1e3ccSAndroid Build Coastguard Worker
av1_build_prediction_by_above_preds(const AV1_COMMON * cm,MACROBLOCKD * xd,uint8_t * tmp_buf[MAX_MB_PLANE],int tmp_width[MAX_MB_PLANE],int tmp_height[MAX_MB_PLANE],int tmp_stride[MAX_MB_PLANE])216*77c1e3ccSAndroid Build Coastguard Worker void av1_build_prediction_by_above_preds(const AV1_COMMON *cm, MACROBLOCKD *xd,
217*77c1e3ccSAndroid Build Coastguard Worker uint8_t *tmp_buf[MAX_MB_PLANE],
218*77c1e3ccSAndroid Build Coastguard Worker int tmp_width[MAX_MB_PLANE],
219*77c1e3ccSAndroid Build Coastguard Worker int tmp_height[MAX_MB_PLANE],
220*77c1e3ccSAndroid Build Coastguard Worker int tmp_stride[MAX_MB_PLANE]) {
221*77c1e3ccSAndroid Build Coastguard Worker if (!xd->up_available) return;
222*77c1e3ccSAndroid Build Coastguard Worker struct build_prediction_ctxt ctxt = {
223*77c1e3ccSAndroid Build Coastguard Worker cm, tmp_buf, tmp_width, tmp_height, tmp_stride, xd->mb_to_right_edge, NULL
224*77c1e3ccSAndroid Build Coastguard Worker };
225*77c1e3ccSAndroid Build Coastguard Worker BLOCK_SIZE bsize = xd->mi[0]->bsize;
226*77c1e3ccSAndroid Build Coastguard Worker foreach_overlappable_nb_above(cm, xd,
227*77c1e3ccSAndroid Build Coastguard Worker max_neighbor_obmc[mi_size_wide_log2[bsize]],
228*77c1e3ccSAndroid Build Coastguard Worker build_obmc_prediction, &ctxt);
229*77c1e3ccSAndroid Build Coastguard Worker }
230*77c1e3ccSAndroid Build Coastguard Worker
av1_build_prediction_by_left_preds(const AV1_COMMON * cm,MACROBLOCKD * xd,uint8_t * tmp_buf[MAX_MB_PLANE],int tmp_width[MAX_MB_PLANE],int tmp_height[MAX_MB_PLANE],int tmp_stride[MAX_MB_PLANE])231*77c1e3ccSAndroid Build Coastguard Worker void av1_build_prediction_by_left_preds(const AV1_COMMON *cm, MACROBLOCKD *xd,
232*77c1e3ccSAndroid Build Coastguard Worker uint8_t *tmp_buf[MAX_MB_PLANE],
233*77c1e3ccSAndroid Build Coastguard Worker int tmp_width[MAX_MB_PLANE],
234*77c1e3ccSAndroid Build Coastguard Worker int tmp_height[MAX_MB_PLANE],
235*77c1e3ccSAndroid Build Coastguard Worker int tmp_stride[MAX_MB_PLANE]) {
236*77c1e3ccSAndroid Build Coastguard Worker if (!xd->left_available) return;
237*77c1e3ccSAndroid Build Coastguard Worker struct build_prediction_ctxt ctxt = {
238*77c1e3ccSAndroid Build Coastguard Worker cm, tmp_buf, tmp_width, tmp_height, tmp_stride, xd->mb_to_bottom_edge, NULL
239*77c1e3ccSAndroid Build Coastguard Worker };
240*77c1e3ccSAndroid Build Coastguard Worker BLOCK_SIZE bsize = xd->mi[0]->bsize;
241*77c1e3ccSAndroid Build Coastguard Worker foreach_overlappable_nb_left(cm, xd,
242*77c1e3ccSAndroid Build Coastguard Worker max_neighbor_obmc[mi_size_high_log2[bsize]],
243*77c1e3ccSAndroid Build Coastguard Worker build_obmc_prediction, &ctxt);
244*77c1e3ccSAndroid Build Coastguard Worker }
245*77c1e3ccSAndroid Build Coastguard Worker
av1_build_obmc_inter_predictors_sb(const AV1_COMMON * cm,MACROBLOCKD * xd)246*77c1e3ccSAndroid Build Coastguard Worker void av1_build_obmc_inter_predictors_sb(const AV1_COMMON *cm, MACROBLOCKD *xd) {
247*77c1e3ccSAndroid Build Coastguard Worker const int num_planes = av1_num_planes(cm);
248*77c1e3ccSAndroid Build Coastguard Worker uint8_t *dst_buf1[MAX_MB_PLANE], *dst_buf2[MAX_MB_PLANE];
249*77c1e3ccSAndroid Build Coastguard Worker int dst_stride1[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE };
250*77c1e3ccSAndroid Build Coastguard Worker int dst_stride2[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE };
251*77c1e3ccSAndroid Build Coastguard Worker int dst_width1[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE };
252*77c1e3ccSAndroid Build Coastguard Worker int dst_width2[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE };
253*77c1e3ccSAndroid Build Coastguard Worker int dst_height1[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE };
254*77c1e3ccSAndroid Build Coastguard Worker int dst_height2[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE };
255*77c1e3ccSAndroid Build Coastguard Worker
256*77c1e3ccSAndroid Build Coastguard Worker av1_setup_obmc_dst_bufs(xd, dst_buf1, dst_buf2);
257*77c1e3ccSAndroid Build Coastguard Worker
258*77c1e3ccSAndroid Build Coastguard Worker const int mi_row = xd->mi_row;
259*77c1e3ccSAndroid Build Coastguard Worker const int mi_col = xd->mi_col;
260*77c1e3ccSAndroid Build Coastguard Worker av1_build_prediction_by_above_preds(cm, xd, dst_buf1, dst_width1, dst_height1,
261*77c1e3ccSAndroid Build Coastguard Worker dst_stride1);
262*77c1e3ccSAndroid Build Coastguard Worker av1_build_prediction_by_left_preds(cm, xd, dst_buf2, dst_width2, dst_height2,
263*77c1e3ccSAndroid Build Coastguard Worker dst_stride2);
264*77c1e3ccSAndroid Build Coastguard Worker av1_setup_dst_planes(xd->plane, xd->mi[0]->bsize, &cm->cur_frame->buf, mi_row,
265*77c1e3ccSAndroid Build Coastguard Worker mi_col, 0, num_planes);
266*77c1e3ccSAndroid Build Coastguard Worker av1_build_obmc_inter_prediction(cm, xd, dst_buf1, dst_stride1, dst_buf2,
267*77c1e3ccSAndroid Build Coastguard Worker dst_stride2);
268*77c1e3ccSAndroid Build Coastguard Worker }
269*77c1e3ccSAndroid Build Coastguard Worker
av1_build_inter_predictors_for_planes_single_buf(MACROBLOCKD * xd,BLOCK_SIZE bsize,int plane_from,int plane_to,int ref,uint8_t * ext_dst[],int ext_dst_stride[])270*77c1e3ccSAndroid Build Coastguard Worker void av1_build_inter_predictors_for_planes_single_buf(
271*77c1e3ccSAndroid Build Coastguard Worker MACROBLOCKD *xd, BLOCK_SIZE bsize, int plane_from, int plane_to, int ref,
272*77c1e3ccSAndroid Build Coastguard Worker uint8_t *ext_dst[], int ext_dst_stride[]) {
273*77c1e3ccSAndroid Build Coastguard Worker assert(bsize < BLOCK_SIZES_ALL);
274*77c1e3ccSAndroid Build Coastguard Worker const MB_MODE_INFO *mi = xd->mi[0];
275*77c1e3ccSAndroid Build Coastguard Worker const int mi_row = xd->mi_row;
276*77c1e3ccSAndroid Build Coastguard Worker const int mi_col = xd->mi_col;
277*77c1e3ccSAndroid Build Coastguard Worker const int mi_x = mi_col * MI_SIZE;
278*77c1e3ccSAndroid Build Coastguard Worker const int mi_y = mi_row * MI_SIZE;
279*77c1e3ccSAndroid Build Coastguard Worker WarpTypesAllowed warp_types;
280*77c1e3ccSAndroid Build Coastguard Worker const WarpedMotionParams *const wm = &xd->global_motion[mi->ref_frame[ref]];
281*77c1e3ccSAndroid Build Coastguard Worker warp_types.global_warp_allowed = is_global_mv_block(mi, wm->wmtype);
282*77c1e3ccSAndroid Build Coastguard Worker warp_types.local_warp_allowed = mi->motion_mode == WARPED_CAUSAL;
283*77c1e3ccSAndroid Build Coastguard Worker
284*77c1e3ccSAndroid Build Coastguard Worker for (int plane = plane_from; plane <= plane_to; ++plane) {
285*77c1e3ccSAndroid Build Coastguard Worker const struct macroblockd_plane *pd = &xd->plane[plane];
286*77c1e3ccSAndroid Build Coastguard Worker const BLOCK_SIZE plane_bsize =
287*77c1e3ccSAndroid Build Coastguard Worker get_plane_block_size(bsize, pd->subsampling_x, pd->subsampling_y);
288*77c1e3ccSAndroid Build Coastguard Worker const int bw = block_size_wide[plane_bsize];
289*77c1e3ccSAndroid Build Coastguard Worker const int bh = block_size_high[plane_bsize];
290*77c1e3ccSAndroid Build Coastguard Worker
291*77c1e3ccSAndroid Build Coastguard Worker InterPredParams inter_pred_params;
292*77c1e3ccSAndroid Build Coastguard Worker
293*77c1e3ccSAndroid Build Coastguard Worker av1_init_inter_params(&inter_pred_params, bw, bh, mi_y >> pd->subsampling_y,
294*77c1e3ccSAndroid Build Coastguard Worker mi_x >> pd->subsampling_x, pd->subsampling_x,
295*77c1e3ccSAndroid Build Coastguard Worker pd->subsampling_y, xd->bd, is_cur_buf_hbd(xd), 0,
296*77c1e3ccSAndroid Build Coastguard Worker xd->block_ref_scale_factors[ref], &pd->pre[ref],
297*77c1e3ccSAndroid Build Coastguard Worker mi->interp_filters);
298*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params.conv_params = get_conv_params(0, plane, xd->bd);
299*77c1e3ccSAndroid Build Coastguard Worker av1_init_warp_params(&inter_pred_params, &warp_types, ref, xd, mi);
300*77c1e3ccSAndroid Build Coastguard Worker
301*77c1e3ccSAndroid Build Coastguard Worker uint8_t *const dst = get_buf_by_bd(xd, ext_dst[plane]);
302*77c1e3ccSAndroid Build Coastguard Worker const MV mv = mi->mv[ref].as_mv;
303*77c1e3ccSAndroid Build Coastguard Worker
304*77c1e3ccSAndroid Build Coastguard Worker av1_enc_build_one_inter_predictor(dst, ext_dst_stride[plane], &mv,
305*77c1e3ccSAndroid Build Coastguard Worker &inter_pred_params);
306*77c1e3ccSAndroid Build Coastguard Worker }
307*77c1e3ccSAndroid Build Coastguard Worker }
308*77c1e3ccSAndroid Build Coastguard Worker
build_masked_compound(uint8_t * dst,int dst_stride,const uint8_t * src0,int src0_stride,const uint8_t * src1,int src1_stride,const INTERINTER_COMPOUND_DATA * const comp_data,BLOCK_SIZE sb_type,int h,int w)309*77c1e3ccSAndroid Build Coastguard Worker static void build_masked_compound(
310*77c1e3ccSAndroid Build Coastguard Worker uint8_t *dst, int dst_stride, const uint8_t *src0, int src0_stride,
311*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *src1, int src1_stride,
312*77c1e3ccSAndroid Build Coastguard Worker const INTERINTER_COMPOUND_DATA *const comp_data, BLOCK_SIZE sb_type, int h,
313*77c1e3ccSAndroid Build Coastguard Worker int w) {
314*77c1e3ccSAndroid Build Coastguard Worker // Derive subsampling from h and w passed in. May be refactored to
315*77c1e3ccSAndroid Build Coastguard Worker // pass in subsampling factors directly.
316*77c1e3ccSAndroid Build Coastguard Worker const int subh = (2 << mi_size_high_log2[sb_type]) == h;
317*77c1e3ccSAndroid Build Coastguard Worker const int subw = (2 << mi_size_wide_log2[sb_type]) == w;
318*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *mask = av1_get_compound_type_mask(comp_data, sb_type);
319*77c1e3ccSAndroid Build Coastguard Worker aom_blend_a64_mask(dst, dst_stride, src0, src0_stride, src1, src1_stride,
320*77c1e3ccSAndroid Build Coastguard Worker mask, block_size_wide[sb_type], w, h, subw, subh);
321*77c1e3ccSAndroid Build Coastguard Worker }
322*77c1e3ccSAndroid Build Coastguard Worker
323*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
build_masked_compound_highbd(uint8_t * dst_8,int dst_stride,const uint8_t * src0_8,int src0_stride,const uint8_t * src1_8,int src1_stride,const INTERINTER_COMPOUND_DATA * const comp_data,BLOCK_SIZE sb_type,int h,int w,int bd)324*77c1e3ccSAndroid Build Coastguard Worker static void build_masked_compound_highbd(
325*77c1e3ccSAndroid Build Coastguard Worker uint8_t *dst_8, int dst_stride, const uint8_t *src0_8, int src0_stride,
326*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *src1_8, int src1_stride,
327*77c1e3ccSAndroid Build Coastguard Worker const INTERINTER_COMPOUND_DATA *const comp_data, BLOCK_SIZE sb_type, int h,
328*77c1e3ccSAndroid Build Coastguard Worker int w, int bd) {
329*77c1e3ccSAndroid Build Coastguard Worker // Derive subsampling from h and w passed in. May be refactored to
330*77c1e3ccSAndroid Build Coastguard Worker // pass in subsampling factors directly.
331*77c1e3ccSAndroid Build Coastguard Worker const int subh = (2 << mi_size_high_log2[sb_type]) == h;
332*77c1e3ccSAndroid Build Coastguard Worker const int subw = (2 << mi_size_wide_log2[sb_type]) == w;
333*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *mask = av1_get_compound_type_mask(comp_data, sb_type);
334*77c1e3ccSAndroid Build Coastguard Worker // const uint8_t *mask =
335*77c1e3ccSAndroid Build Coastguard Worker // av1_get_contiguous_soft_mask(wedge_index, wedge_sign, sb_type);
336*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_blend_a64_mask(dst_8, dst_stride, src0_8, src0_stride, src1_8,
337*77c1e3ccSAndroid Build Coastguard Worker src1_stride, mask, block_size_wide[sb_type], w, h,
338*77c1e3ccSAndroid Build Coastguard Worker subw, subh, bd);
339*77c1e3ccSAndroid Build Coastguard Worker }
340*77c1e3ccSAndroid Build Coastguard Worker #endif
341*77c1e3ccSAndroid Build Coastguard Worker
build_wedge_inter_predictor_from_buf(MACROBLOCKD * xd,int plane,int x,int y,int w,int h,uint8_t * ext_dst0,int ext_dst_stride0,uint8_t * ext_dst1,int ext_dst_stride1)342*77c1e3ccSAndroid Build Coastguard Worker static void build_wedge_inter_predictor_from_buf(
343*77c1e3ccSAndroid Build Coastguard Worker MACROBLOCKD *xd, int plane, int x, int y, int w, int h, uint8_t *ext_dst0,
344*77c1e3ccSAndroid Build Coastguard Worker int ext_dst_stride0, uint8_t *ext_dst1, int ext_dst_stride1) {
345*77c1e3ccSAndroid Build Coastguard Worker MB_MODE_INFO *const mbmi = xd->mi[0];
346*77c1e3ccSAndroid Build Coastguard Worker const int is_compound = has_second_ref(mbmi);
347*77c1e3ccSAndroid Build Coastguard Worker MACROBLOCKD_PLANE *const pd = &xd->plane[plane];
348*77c1e3ccSAndroid Build Coastguard Worker struct buf_2d *const dst_buf = &pd->dst;
349*77c1e3ccSAndroid Build Coastguard Worker uint8_t *const dst = dst_buf->buf + dst_buf->stride * y + x;
350*77c1e3ccSAndroid Build Coastguard Worker mbmi->interinter_comp.seg_mask = xd->seg_mask;
351*77c1e3ccSAndroid Build Coastguard Worker const INTERINTER_COMPOUND_DATA *comp_data = &mbmi->interinter_comp;
352*77c1e3ccSAndroid Build Coastguard Worker const int is_hbd = is_cur_buf_hbd(xd);
353*77c1e3ccSAndroid Build Coastguard Worker
354*77c1e3ccSAndroid Build Coastguard Worker if (is_compound && is_masked_compound_type(comp_data->type)) {
355*77c1e3ccSAndroid Build Coastguard Worker if (!plane && comp_data->type == COMPOUND_DIFFWTD) {
356*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
357*77c1e3ccSAndroid Build Coastguard Worker if (is_hbd) {
358*77c1e3ccSAndroid Build Coastguard Worker av1_build_compound_diffwtd_mask_highbd(
359*77c1e3ccSAndroid Build Coastguard Worker comp_data->seg_mask, comp_data->mask_type,
360*77c1e3ccSAndroid Build Coastguard Worker CONVERT_TO_BYTEPTR(ext_dst0), ext_dst_stride0,
361*77c1e3ccSAndroid Build Coastguard Worker CONVERT_TO_BYTEPTR(ext_dst1), ext_dst_stride1, h, w, xd->bd);
362*77c1e3ccSAndroid Build Coastguard Worker } else {
363*77c1e3ccSAndroid Build Coastguard Worker av1_build_compound_diffwtd_mask(
364*77c1e3ccSAndroid Build Coastguard Worker comp_data->seg_mask, comp_data->mask_type, ext_dst0,
365*77c1e3ccSAndroid Build Coastguard Worker ext_dst_stride0, ext_dst1, ext_dst_stride1, h, w);
366*77c1e3ccSAndroid Build Coastguard Worker }
367*77c1e3ccSAndroid Build Coastguard Worker #else
368*77c1e3ccSAndroid Build Coastguard Worker (void)is_hbd;
369*77c1e3ccSAndroid Build Coastguard Worker av1_build_compound_diffwtd_mask(comp_data->seg_mask, comp_data->mask_type,
370*77c1e3ccSAndroid Build Coastguard Worker ext_dst0, ext_dst_stride0, ext_dst1,
371*77c1e3ccSAndroid Build Coastguard Worker ext_dst_stride1, h, w);
372*77c1e3ccSAndroid Build Coastguard Worker #endif // CONFIG_AV1_HIGHBITDEPTH
373*77c1e3ccSAndroid Build Coastguard Worker }
374*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
375*77c1e3ccSAndroid Build Coastguard Worker if (is_hbd) {
376*77c1e3ccSAndroid Build Coastguard Worker build_masked_compound_highbd(
377*77c1e3ccSAndroid Build Coastguard Worker dst, dst_buf->stride, CONVERT_TO_BYTEPTR(ext_dst0), ext_dst_stride0,
378*77c1e3ccSAndroid Build Coastguard Worker CONVERT_TO_BYTEPTR(ext_dst1), ext_dst_stride1, comp_data, mbmi->bsize,
379*77c1e3ccSAndroid Build Coastguard Worker h, w, xd->bd);
380*77c1e3ccSAndroid Build Coastguard Worker } else {
381*77c1e3ccSAndroid Build Coastguard Worker build_masked_compound(dst, dst_buf->stride, ext_dst0, ext_dst_stride0,
382*77c1e3ccSAndroid Build Coastguard Worker ext_dst1, ext_dst_stride1, comp_data, mbmi->bsize,
383*77c1e3ccSAndroid Build Coastguard Worker h, w);
384*77c1e3ccSAndroid Build Coastguard Worker }
385*77c1e3ccSAndroid Build Coastguard Worker #else
386*77c1e3ccSAndroid Build Coastguard Worker build_masked_compound(dst, dst_buf->stride, ext_dst0, ext_dst_stride0,
387*77c1e3ccSAndroid Build Coastguard Worker ext_dst1, ext_dst_stride1, comp_data, mbmi->bsize, h,
388*77c1e3ccSAndroid Build Coastguard Worker w);
389*77c1e3ccSAndroid Build Coastguard Worker #endif
390*77c1e3ccSAndroid Build Coastguard Worker } else {
391*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
392*77c1e3ccSAndroid Build Coastguard Worker if (is_hbd) {
393*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_convolve_copy(CONVERT_TO_SHORTPTR(ext_dst0), ext_dst_stride0,
394*77c1e3ccSAndroid Build Coastguard Worker CONVERT_TO_SHORTPTR(dst), dst_buf->stride, w, h);
395*77c1e3ccSAndroid Build Coastguard Worker } else {
396*77c1e3ccSAndroid Build Coastguard Worker aom_convolve_copy(ext_dst0, ext_dst_stride0, dst, dst_buf->stride, w, h);
397*77c1e3ccSAndroid Build Coastguard Worker }
398*77c1e3ccSAndroid Build Coastguard Worker #else
399*77c1e3ccSAndroid Build Coastguard Worker aom_convolve_copy(ext_dst0, ext_dst_stride0, dst, dst_buf->stride, w, h);
400*77c1e3ccSAndroid Build Coastguard Worker #endif
401*77c1e3ccSAndroid Build Coastguard Worker }
402*77c1e3ccSAndroid Build Coastguard Worker }
403*77c1e3ccSAndroid Build Coastguard Worker
av1_build_wedge_inter_predictor_from_buf(MACROBLOCKD * xd,BLOCK_SIZE bsize,int plane_from,int plane_to,uint8_t * ext_dst0[],int ext_dst_stride0[],uint8_t * ext_dst1[],int ext_dst_stride1[])404*77c1e3ccSAndroid Build Coastguard Worker void av1_build_wedge_inter_predictor_from_buf(MACROBLOCKD *xd, BLOCK_SIZE bsize,
405*77c1e3ccSAndroid Build Coastguard Worker int plane_from, int plane_to,
406*77c1e3ccSAndroid Build Coastguard Worker uint8_t *ext_dst0[],
407*77c1e3ccSAndroid Build Coastguard Worker int ext_dst_stride0[],
408*77c1e3ccSAndroid Build Coastguard Worker uint8_t *ext_dst1[],
409*77c1e3ccSAndroid Build Coastguard Worker int ext_dst_stride1[]) {
410*77c1e3ccSAndroid Build Coastguard Worker int plane;
411*77c1e3ccSAndroid Build Coastguard Worker assert(bsize < BLOCK_SIZES_ALL);
412*77c1e3ccSAndroid Build Coastguard Worker for (plane = plane_from; plane <= plane_to; ++plane) {
413*77c1e3ccSAndroid Build Coastguard Worker const BLOCK_SIZE plane_bsize = get_plane_block_size(
414*77c1e3ccSAndroid Build Coastguard Worker bsize, xd->plane[plane].subsampling_x, xd->plane[plane].subsampling_y);
415*77c1e3ccSAndroid Build Coastguard Worker const int bw = block_size_wide[plane_bsize];
416*77c1e3ccSAndroid Build Coastguard Worker const int bh = block_size_high[plane_bsize];
417*77c1e3ccSAndroid Build Coastguard Worker build_wedge_inter_predictor_from_buf(
418*77c1e3ccSAndroid Build Coastguard Worker xd, plane, 0, 0, bw, bh, ext_dst0[plane], ext_dst_stride0[plane],
419*77c1e3ccSAndroid Build Coastguard Worker ext_dst1[plane], ext_dst_stride1[plane]);
420*77c1e3ccSAndroid Build Coastguard Worker }
421*77c1e3ccSAndroid Build Coastguard Worker }
422*77c1e3ccSAndroid Build Coastguard Worker
423*77c1e3ccSAndroid Build Coastguard Worker // Get pred block from up-sampled reference.
aom_upsampled_pred_c(MACROBLOCKD * xd,const AV1_COMMON * const cm,int mi_row,int mi_col,const MV * const mv,uint8_t * comp_pred,int width,int height,int subpel_x_q3,int subpel_y_q3,const uint8_t * ref,int ref_stride,int subpel_search)424*77c1e3ccSAndroid Build Coastguard Worker void aom_upsampled_pred_c(MACROBLOCKD *xd, const AV1_COMMON *const cm,
425*77c1e3ccSAndroid Build Coastguard Worker int mi_row, int mi_col, const MV *const mv,
426*77c1e3ccSAndroid Build Coastguard Worker uint8_t *comp_pred, int width, int height,
427*77c1e3ccSAndroid Build Coastguard Worker int subpel_x_q3, int subpel_y_q3, const uint8_t *ref,
428*77c1e3ccSAndroid Build Coastguard Worker int ref_stride, int subpel_search) {
429*77c1e3ccSAndroid Build Coastguard Worker // expect xd == NULL only in tests
430*77c1e3ccSAndroid Build Coastguard Worker if (xd != NULL) {
431*77c1e3ccSAndroid Build Coastguard Worker const MB_MODE_INFO *mi = xd->mi[0];
432*77c1e3ccSAndroid Build Coastguard Worker const int ref_num = 0;
433*77c1e3ccSAndroid Build Coastguard Worker const int is_intrabc = is_intrabc_block(mi);
434*77c1e3ccSAndroid Build Coastguard Worker const struct scale_factors *const sf =
435*77c1e3ccSAndroid Build Coastguard Worker is_intrabc ? &cm->sf_identity : xd->block_ref_scale_factors[ref_num];
436*77c1e3ccSAndroid Build Coastguard Worker const int is_scaled = av1_is_scaled(sf);
437*77c1e3ccSAndroid Build Coastguard Worker
438*77c1e3ccSAndroid Build Coastguard Worker if (is_scaled) {
439*77c1e3ccSAndroid Build Coastguard Worker int plane = 0;
440*77c1e3ccSAndroid Build Coastguard Worker const int mi_x = mi_col * MI_SIZE;
441*77c1e3ccSAndroid Build Coastguard Worker const int mi_y = mi_row * MI_SIZE;
442*77c1e3ccSAndroid Build Coastguard Worker const struct macroblockd_plane *const pd = &xd->plane[plane];
443*77c1e3ccSAndroid Build Coastguard Worker const struct buf_2d *const dst_buf = &pd->dst;
444*77c1e3ccSAndroid Build Coastguard Worker const struct buf_2d *const pre_buf =
445*77c1e3ccSAndroid Build Coastguard Worker is_intrabc ? dst_buf : &pd->pre[ref_num];
446*77c1e3ccSAndroid Build Coastguard Worker
447*77c1e3ccSAndroid Build Coastguard Worker InterPredParams inter_pred_params;
448*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params.conv_params = get_conv_params(0, plane, xd->bd);
449*77c1e3ccSAndroid Build Coastguard Worker const int_interpfilters filters =
450*77c1e3ccSAndroid Build Coastguard Worker av1_broadcast_interp_filter(EIGHTTAP_REGULAR);
451*77c1e3ccSAndroid Build Coastguard Worker av1_init_inter_params(
452*77c1e3ccSAndroid Build Coastguard Worker &inter_pred_params, width, height, mi_y >> pd->subsampling_y,
453*77c1e3ccSAndroid Build Coastguard Worker mi_x >> pd->subsampling_x, pd->subsampling_x, pd->subsampling_y,
454*77c1e3ccSAndroid Build Coastguard Worker xd->bd, is_cur_buf_hbd(xd), is_intrabc, sf, pre_buf, filters);
455*77c1e3ccSAndroid Build Coastguard Worker av1_enc_build_one_inter_predictor(comp_pred, width, mv,
456*77c1e3ccSAndroid Build Coastguard Worker &inter_pred_params);
457*77c1e3ccSAndroid Build Coastguard Worker return;
458*77c1e3ccSAndroid Build Coastguard Worker }
459*77c1e3ccSAndroid Build Coastguard Worker }
460*77c1e3ccSAndroid Build Coastguard Worker
461*77c1e3ccSAndroid Build Coastguard Worker const InterpFilterParams *filter = av1_get_filter(subpel_search);
462*77c1e3ccSAndroid Build Coastguard Worker
463*77c1e3ccSAndroid Build Coastguard Worker if (!subpel_x_q3 && !subpel_y_q3) {
464*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < height; i++) {
465*77c1e3ccSAndroid Build Coastguard Worker memcpy(comp_pred, ref, width * sizeof(*comp_pred));
466*77c1e3ccSAndroid Build Coastguard Worker comp_pred += width;
467*77c1e3ccSAndroid Build Coastguard Worker ref += ref_stride;
468*77c1e3ccSAndroid Build Coastguard Worker }
469*77c1e3ccSAndroid Build Coastguard Worker } else if (!subpel_y_q3) {
470*77c1e3ccSAndroid Build Coastguard Worker const int16_t *const kernel =
471*77c1e3ccSAndroid Build Coastguard Worker av1_get_interp_filter_subpel_kernel(filter, subpel_x_q3 << 1);
472*77c1e3ccSAndroid Build Coastguard Worker aom_convolve8_horiz_c(ref, ref_stride, comp_pred, width, kernel, 16, NULL,
473*77c1e3ccSAndroid Build Coastguard Worker -1, width, height);
474*77c1e3ccSAndroid Build Coastguard Worker } else if (!subpel_x_q3) {
475*77c1e3ccSAndroid Build Coastguard Worker const int16_t *const kernel =
476*77c1e3ccSAndroid Build Coastguard Worker av1_get_interp_filter_subpel_kernel(filter, subpel_y_q3 << 1);
477*77c1e3ccSAndroid Build Coastguard Worker aom_convolve8_vert_c(ref, ref_stride, comp_pred, width, NULL, -1, kernel,
478*77c1e3ccSAndroid Build Coastguard Worker 16, width, height);
479*77c1e3ccSAndroid Build Coastguard Worker } else {
480*77c1e3ccSAndroid Build Coastguard Worker DECLARE_ALIGNED(16, uint8_t,
481*77c1e3ccSAndroid Build Coastguard Worker temp[((MAX_SB_SIZE * 2 + 16) + 16) * MAX_SB_SIZE]);
482*77c1e3ccSAndroid Build Coastguard Worker const int16_t *const kernel_x =
483*77c1e3ccSAndroid Build Coastguard Worker av1_get_interp_filter_subpel_kernel(filter, subpel_x_q3 << 1);
484*77c1e3ccSAndroid Build Coastguard Worker const int16_t *const kernel_y =
485*77c1e3ccSAndroid Build Coastguard Worker av1_get_interp_filter_subpel_kernel(filter, subpel_y_q3 << 1);
486*77c1e3ccSAndroid Build Coastguard Worker const int intermediate_height =
487*77c1e3ccSAndroid Build Coastguard Worker (((height - 1) * 8 + subpel_y_q3) >> 3) + filter->taps;
488*77c1e3ccSAndroid Build Coastguard Worker assert(intermediate_height <= (MAX_SB_SIZE * 2 + 16) + 16);
489*77c1e3ccSAndroid Build Coastguard Worker aom_convolve8_horiz_c(ref - ref_stride * ((filter->taps >> 1) - 1),
490*77c1e3ccSAndroid Build Coastguard Worker ref_stride, temp, MAX_SB_SIZE, kernel_x, 16, NULL, -1,
491*77c1e3ccSAndroid Build Coastguard Worker width, intermediate_height);
492*77c1e3ccSAndroid Build Coastguard Worker aom_convolve8_vert_c(temp + MAX_SB_SIZE * ((filter->taps >> 1) - 1),
493*77c1e3ccSAndroid Build Coastguard Worker MAX_SB_SIZE, comp_pred, width, NULL, -1, kernel_y, 16,
494*77c1e3ccSAndroid Build Coastguard Worker width, height);
495*77c1e3ccSAndroid Build Coastguard Worker }
496*77c1e3ccSAndroid Build Coastguard Worker }
497*77c1e3ccSAndroid Build Coastguard Worker
aom_comp_avg_upsampled_pred_c(MACROBLOCKD * xd,const AV1_COMMON * const cm,int mi_row,int mi_col,const MV * const mv,uint8_t * comp_pred,const uint8_t * pred,int width,int height,int subpel_x_q3,int subpel_y_q3,const uint8_t * ref,int ref_stride,int subpel_search)498*77c1e3ccSAndroid Build Coastguard Worker void aom_comp_avg_upsampled_pred_c(MACROBLOCKD *xd, const AV1_COMMON *const cm,
499*77c1e3ccSAndroid Build Coastguard Worker int mi_row, int mi_col, const MV *const mv,
500*77c1e3ccSAndroid Build Coastguard Worker uint8_t *comp_pred, const uint8_t *pred,
501*77c1e3ccSAndroid Build Coastguard Worker int width, int height, int subpel_x_q3,
502*77c1e3ccSAndroid Build Coastguard Worker int subpel_y_q3, const uint8_t *ref,
503*77c1e3ccSAndroid Build Coastguard Worker int ref_stride, int subpel_search) {
504*77c1e3ccSAndroid Build Coastguard Worker int i, j;
505*77c1e3ccSAndroid Build Coastguard Worker
506*77c1e3ccSAndroid Build Coastguard Worker aom_upsampled_pred_c(xd, cm, mi_row, mi_col, mv, comp_pred, width, height,
507*77c1e3ccSAndroid Build Coastguard Worker subpel_x_q3, subpel_y_q3, ref, ref_stride,
508*77c1e3ccSAndroid Build Coastguard Worker subpel_search);
509*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < height; i++) {
510*77c1e3ccSAndroid Build Coastguard Worker for (j = 0; j < width; j++) {
511*77c1e3ccSAndroid Build Coastguard Worker comp_pred[j] = ROUND_POWER_OF_TWO(comp_pred[j] + pred[j], 1);
512*77c1e3ccSAndroid Build Coastguard Worker }
513*77c1e3ccSAndroid Build Coastguard Worker comp_pred += width;
514*77c1e3ccSAndroid Build Coastguard Worker pred += width;
515*77c1e3ccSAndroid Build Coastguard Worker }
516*77c1e3ccSAndroid Build Coastguard Worker }
517*77c1e3ccSAndroid Build Coastguard Worker
aom_comp_mask_upsampled_pred(MACROBLOCKD * xd,const AV1_COMMON * const cm,int mi_row,int mi_col,const MV * const mv,uint8_t * comp_pred,const uint8_t * pred,int width,int height,int subpel_x_q3,int subpel_y_q3,const uint8_t * ref,int ref_stride,const uint8_t * mask,int mask_stride,int invert_mask,int subpel_search)518*77c1e3ccSAndroid Build Coastguard Worker void aom_comp_mask_upsampled_pred(MACROBLOCKD *xd, const AV1_COMMON *const cm,
519*77c1e3ccSAndroid Build Coastguard Worker int mi_row, int mi_col, const MV *const mv,
520*77c1e3ccSAndroid Build Coastguard Worker uint8_t *comp_pred, const uint8_t *pred,
521*77c1e3ccSAndroid Build Coastguard Worker int width, int height, int subpel_x_q3,
522*77c1e3ccSAndroid Build Coastguard Worker int subpel_y_q3, const uint8_t *ref,
523*77c1e3ccSAndroid Build Coastguard Worker int ref_stride, const uint8_t *mask,
524*77c1e3ccSAndroid Build Coastguard Worker int mask_stride, int invert_mask,
525*77c1e3ccSAndroid Build Coastguard Worker int subpel_search) {
526*77c1e3ccSAndroid Build Coastguard Worker if (subpel_x_q3 | subpel_y_q3) {
527*77c1e3ccSAndroid Build Coastguard Worker aom_upsampled_pred(xd, cm, mi_row, mi_col, mv, comp_pred, width, height,
528*77c1e3ccSAndroid Build Coastguard Worker subpel_x_q3, subpel_y_q3, ref, ref_stride,
529*77c1e3ccSAndroid Build Coastguard Worker subpel_search);
530*77c1e3ccSAndroid Build Coastguard Worker ref = comp_pred;
531*77c1e3ccSAndroid Build Coastguard Worker ref_stride = width;
532*77c1e3ccSAndroid Build Coastguard Worker }
533*77c1e3ccSAndroid Build Coastguard Worker aom_comp_mask_pred(comp_pred, pred, width, height, ref, ref_stride, mask,
534*77c1e3ccSAndroid Build Coastguard Worker mask_stride, invert_mask);
535*77c1e3ccSAndroid Build Coastguard Worker }
536*77c1e3ccSAndroid Build Coastguard Worker
537*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
aom_highbd_upsampled_pred_c(MACROBLOCKD * xd,const struct AV1Common * const cm,int mi_row,int mi_col,const MV * const mv,uint8_t * comp_pred8,int width,int height,int subpel_x_q3,int subpel_y_q3,const uint8_t * ref8,int ref_stride,int bd,int subpel_search)538*77c1e3ccSAndroid Build Coastguard Worker void aom_highbd_upsampled_pred_c(MACROBLOCKD *xd,
539*77c1e3ccSAndroid Build Coastguard Worker const struct AV1Common *const cm, int mi_row,
540*77c1e3ccSAndroid Build Coastguard Worker int mi_col, const MV *const mv,
541*77c1e3ccSAndroid Build Coastguard Worker uint8_t *comp_pred8, int width, int height,
542*77c1e3ccSAndroid Build Coastguard Worker int subpel_x_q3, int subpel_y_q3,
543*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *ref8, int ref_stride, int bd,
544*77c1e3ccSAndroid Build Coastguard Worker int subpel_search) {
545*77c1e3ccSAndroid Build Coastguard Worker // expect xd == NULL only in tests
546*77c1e3ccSAndroid Build Coastguard Worker if (xd != NULL) {
547*77c1e3ccSAndroid Build Coastguard Worker const MB_MODE_INFO *mi = xd->mi[0];
548*77c1e3ccSAndroid Build Coastguard Worker const int ref_num = 0;
549*77c1e3ccSAndroid Build Coastguard Worker const int is_intrabc = is_intrabc_block(mi);
550*77c1e3ccSAndroid Build Coastguard Worker const struct scale_factors *const sf =
551*77c1e3ccSAndroid Build Coastguard Worker is_intrabc ? &cm->sf_identity : xd->block_ref_scale_factors[ref_num];
552*77c1e3ccSAndroid Build Coastguard Worker const int is_scaled = av1_is_scaled(sf);
553*77c1e3ccSAndroid Build Coastguard Worker
554*77c1e3ccSAndroid Build Coastguard Worker if (is_scaled) {
555*77c1e3ccSAndroid Build Coastguard Worker int plane = 0;
556*77c1e3ccSAndroid Build Coastguard Worker const int mi_x = mi_col * MI_SIZE;
557*77c1e3ccSAndroid Build Coastguard Worker const int mi_y = mi_row * MI_SIZE;
558*77c1e3ccSAndroid Build Coastguard Worker const struct macroblockd_plane *const pd = &xd->plane[plane];
559*77c1e3ccSAndroid Build Coastguard Worker const struct buf_2d *const dst_buf = &pd->dst;
560*77c1e3ccSAndroid Build Coastguard Worker const struct buf_2d *const pre_buf =
561*77c1e3ccSAndroid Build Coastguard Worker is_intrabc ? dst_buf : &pd->pre[ref_num];
562*77c1e3ccSAndroid Build Coastguard Worker
563*77c1e3ccSAndroid Build Coastguard Worker InterPredParams inter_pred_params;
564*77c1e3ccSAndroid Build Coastguard Worker inter_pred_params.conv_params = get_conv_params(0, plane, xd->bd);
565*77c1e3ccSAndroid Build Coastguard Worker const int_interpfilters filters =
566*77c1e3ccSAndroid Build Coastguard Worker av1_broadcast_interp_filter(EIGHTTAP_REGULAR);
567*77c1e3ccSAndroid Build Coastguard Worker av1_init_inter_params(
568*77c1e3ccSAndroid Build Coastguard Worker &inter_pred_params, width, height, mi_y >> pd->subsampling_y,
569*77c1e3ccSAndroid Build Coastguard Worker mi_x >> pd->subsampling_x, pd->subsampling_x, pd->subsampling_y,
570*77c1e3ccSAndroid Build Coastguard Worker xd->bd, is_cur_buf_hbd(xd), is_intrabc, sf, pre_buf, filters);
571*77c1e3ccSAndroid Build Coastguard Worker av1_enc_build_one_inter_predictor(comp_pred8, width, mv,
572*77c1e3ccSAndroid Build Coastguard Worker &inter_pred_params);
573*77c1e3ccSAndroid Build Coastguard Worker return;
574*77c1e3ccSAndroid Build Coastguard Worker }
575*77c1e3ccSAndroid Build Coastguard Worker }
576*77c1e3ccSAndroid Build Coastguard Worker
577*77c1e3ccSAndroid Build Coastguard Worker const InterpFilterParams *filter = av1_get_filter(subpel_search);
578*77c1e3ccSAndroid Build Coastguard Worker
579*77c1e3ccSAndroid Build Coastguard Worker if (!subpel_x_q3 && !subpel_y_q3) {
580*77c1e3ccSAndroid Build Coastguard Worker const uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
581*77c1e3ccSAndroid Build Coastguard Worker uint16_t *comp_pred = CONVERT_TO_SHORTPTR(comp_pred8);
582*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < height; i++) {
583*77c1e3ccSAndroid Build Coastguard Worker memcpy(comp_pred, ref, width * sizeof(*comp_pred));
584*77c1e3ccSAndroid Build Coastguard Worker comp_pred += width;
585*77c1e3ccSAndroid Build Coastguard Worker ref += ref_stride;
586*77c1e3ccSAndroid Build Coastguard Worker }
587*77c1e3ccSAndroid Build Coastguard Worker } else if (!subpel_y_q3) {
588*77c1e3ccSAndroid Build Coastguard Worker const int16_t *const kernel =
589*77c1e3ccSAndroid Build Coastguard Worker av1_get_interp_filter_subpel_kernel(filter, subpel_x_q3 << 1);
590*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_convolve8_horiz_c(ref8, ref_stride, comp_pred8, width, kernel,
591*77c1e3ccSAndroid Build Coastguard Worker 16, NULL, -1, width, height, bd);
592*77c1e3ccSAndroid Build Coastguard Worker } else if (!subpel_x_q3) {
593*77c1e3ccSAndroid Build Coastguard Worker const int16_t *const kernel =
594*77c1e3ccSAndroid Build Coastguard Worker av1_get_interp_filter_subpel_kernel(filter, subpel_y_q3 << 1);
595*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_convolve8_vert_c(ref8, ref_stride, comp_pred8, width, NULL, -1,
596*77c1e3ccSAndroid Build Coastguard Worker kernel, 16, width, height, bd);
597*77c1e3ccSAndroid Build Coastguard Worker } else {
598*77c1e3ccSAndroid Build Coastguard Worker DECLARE_ALIGNED(16, uint16_t,
599*77c1e3ccSAndroid Build Coastguard Worker temp[((MAX_SB_SIZE + 16) + 16) * MAX_SB_SIZE]);
600*77c1e3ccSAndroid Build Coastguard Worker const int16_t *const kernel_x =
601*77c1e3ccSAndroid Build Coastguard Worker av1_get_interp_filter_subpel_kernel(filter, subpel_x_q3 << 1);
602*77c1e3ccSAndroid Build Coastguard Worker const int16_t *const kernel_y =
603*77c1e3ccSAndroid Build Coastguard Worker av1_get_interp_filter_subpel_kernel(filter, subpel_y_q3 << 1);
604*77c1e3ccSAndroid Build Coastguard Worker const int intermediate_height =
605*77c1e3ccSAndroid Build Coastguard Worker (((height - 1) * 8 + subpel_y_q3) >> 3) + filter->taps;
606*77c1e3ccSAndroid Build Coastguard Worker assert(intermediate_height <= (MAX_SB_SIZE * 2 + 16) + 16);
607*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_convolve8_horiz_c(ref8 - ref_stride * ((filter->taps >> 1) - 1),
608*77c1e3ccSAndroid Build Coastguard Worker ref_stride, CONVERT_TO_BYTEPTR(temp),
609*77c1e3ccSAndroid Build Coastguard Worker MAX_SB_SIZE, kernel_x, 16, NULL, -1, width,
610*77c1e3ccSAndroid Build Coastguard Worker intermediate_height, bd);
611*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_convolve8_vert_c(
612*77c1e3ccSAndroid Build Coastguard Worker CONVERT_TO_BYTEPTR(temp + MAX_SB_SIZE * ((filter->taps >> 1) - 1)),
613*77c1e3ccSAndroid Build Coastguard Worker MAX_SB_SIZE, comp_pred8, width, NULL, -1, kernel_y, 16, width, height,
614*77c1e3ccSAndroid Build Coastguard Worker bd);
615*77c1e3ccSAndroid Build Coastguard Worker }
616*77c1e3ccSAndroid Build Coastguard Worker }
617*77c1e3ccSAndroid Build Coastguard Worker
aom_highbd_comp_avg_upsampled_pred_c(MACROBLOCKD * xd,const struct AV1Common * const cm,int mi_row,int mi_col,const MV * const mv,uint8_t * comp_pred8,const uint8_t * pred8,int width,int height,int subpel_x_q3,int subpel_y_q3,const uint8_t * ref8,int ref_stride,int bd,int subpel_search)618*77c1e3ccSAndroid Build Coastguard Worker void aom_highbd_comp_avg_upsampled_pred_c(
619*77c1e3ccSAndroid Build Coastguard Worker MACROBLOCKD *xd, const struct AV1Common *const cm, int mi_row, int mi_col,
620*77c1e3ccSAndroid Build Coastguard Worker const MV *const mv, uint8_t *comp_pred8, const uint8_t *pred8, int width,
621*77c1e3ccSAndroid Build Coastguard Worker int height, int subpel_x_q3, int subpel_y_q3, const uint8_t *ref8,
622*77c1e3ccSAndroid Build Coastguard Worker int ref_stride, int bd, int subpel_search) {
623*77c1e3ccSAndroid Build Coastguard Worker int i, j;
624*77c1e3ccSAndroid Build Coastguard Worker
625*77c1e3ccSAndroid Build Coastguard Worker const uint16_t *pred = CONVERT_TO_SHORTPTR(pred8);
626*77c1e3ccSAndroid Build Coastguard Worker uint16_t *comp_pred = CONVERT_TO_SHORTPTR(comp_pred8);
627*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_upsampled_pred(xd, cm, mi_row, mi_col, mv, comp_pred8, width,
628*77c1e3ccSAndroid Build Coastguard Worker height, subpel_x_q3, subpel_y_q3, ref8, ref_stride,
629*77c1e3ccSAndroid Build Coastguard Worker bd, subpel_search);
630*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < height; ++i) {
631*77c1e3ccSAndroid Build Coastguard Worker for (j = 0; j < width; ++j) {
632*77c1e3ccSAndroid Build Coastguard Worker comp_pred[j] = ROUND_POWER_OF_TWO(pred[j] + comp_pred[j], 1);
633*77c1e3ccSAndroid Build Coastguard Worker }
634*77c1e3ccSAndroid Build Coastguard Worker comp_pred += width;
635*77c1e3ccSAndroid Build Coastguard Worker pred += width;
636*77c1e3ccSAndroid Build Coastguard Worker }
637*77c1e3ccSAndroid Build Coastguard Worker }
638*77c1e3ccSAndroid Build Coastguard Worker
aom_highbd_dist_wtd_comp_avg_upsampled_pred_c(MACROBLOCKD * xd,const struct AV1Common * const cm,int mi_row,int mi_col,const MV * const mv,uint8_t * comp_pred8,const uint8_t * pred8,int width,int height,int subpel_x_q3,int subpel_y_q3,const uint8_t * ref8,int ref_stride,int bd,const DIST_WTD_COMP_PARAMS * jcp_param,int subpel_search)639*77c1e3ccSAndroid Build Coastguard Worker void aom_highbd_dist_wtd_comp_avg_upsampled_pred_c(
640*77c1e3ccSAndroid Build Coastguard Worker MACROBLOCKD *xd, const struct AV1Common *const cm, int mi_row, int mi_col,
641*77c1e3ccSAndroid Build Coastguard Worker const MV *const mv, uint8_t *comp_pred8, const uint8_t *pred8, int width,
642*77c1e3ccSAndroid Build Coastguard Worker int height, int subpel_x_q3, int subpel_y_q3, const uint8_t *ref8,
643*77c1e3ccSAndroid Build Coastguard Worker int ref_stride, int bd, const DIST_WTD_COMP_PARAMS *jcp_param,
644*77c1e3ccSAndroid Build Coastguard Worker int subpel_search) {
645*77c1e3ccSAndroid Build Coastguard Worker int i, j;
646*77c1e3ccSAndroid Build Coastguard Worker const int fwd_offset = jcp_param->fwd_offset;
647*77c1e3ccSAndroid Build Coastguard Worker const int bck_offset = jcp_param->bck_offset;
648*77c1e3ccSAndroid Build Coastguard Worker const uint16_t *pred = CONVERT_TO_SHORTPTR(pred8);
649*77c1e3ccSAndroid Build Coastguard Worker uint16_t *comp_pred = CONVERT_TO_SHORTPTR(comp_pred8);
650*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_upsampled_pred_c(xd, cm, mi_row, mi_col, mv, comp_pred8, width,
651*77c1e3ccSAndroid Build Coastguard Worker height, subpel_x_q3, subpel_y_q3, ref8,
652*77c1e3ccSAndroid Build Coastguard Worker ref_stride, bd, subpel_search);
653*77c1e3ccSAndroid Build Coastguard Worker
654*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < height; i++) {
655*77c1e3ccSAndroid Build Coastguard Worker for (j = 0; j < width; j++) {
656*77c1e3ccSAndroid Build Coastguard Worker int tmp = pred[j] * bck_offset + comp_pred[j] * fwd_offset;
657*77c1e3ccSAndroid Build Coastguard Worker tmp = ROUND_POWER_OF_TWO(tmp, DIST_PRECISION_BITS);
658*77c1e3ccSAndroid Build Coastguard Worker comp_pred[j] = (uint16_t)tmp;
659*77c1e3ccSAndroid Build Coastguard Worker }
660*77c1e3ccSAndroid Build Coastguard Worker comp_pred += width;
661*77c1e3ccSAndroid Build Coastguard Worker pred += width;
662*77c1e3ccSAndroid Build Coastguard Worker }
663*77c1e3ccSAndroid Build Coastguard Worker }
664*77c1e3ccSAndroid Build Coastguard Worker
aom_highbd_comp_mask_upsampled_pred(MACROBLOCKD * xd,const struct AV1Common * const cm,int mi_row,int mi_col,const MV * const mv,uint8_t * comp_pred8,const uint8_t * pred8,int width,int height,int subpel_x_q3,int subpel_y_q3,const uint8_t * ref8,int ref_stride,const uint8_t * mask,int mask_stride,int invert_mask,int bd,int subpel_search)665*77c1e3ccSAndroid Build Coastguard Worker void aom_highbd_comp_mask_upsampled_pred(
666*77c1e3ccSAndroid Build Coastguard Worker MACROBLOCKD *xd, const struct AV1Common *const cm, int mi_row, int mi_col,
667*77c1e3ccSAndroid Build Coastguard Worker const MV *const mv, uint8_t *comp_pred8, const uint8_t *pred8, int width,
668*77c1e3ccSAndroid Build Coastguard Worker int height, int subpel_x_q3, int subpel_y_q3, const uint8_t *ref8,
669*77c1e3ccSAndroid Build Coastguard Worker int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask,
670*77c1e3ccSAndroid Build Coastguard Worker int bd, int subpel_search) {
671*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_upsampled_pred(xd, cm, mi_row, mi_col, mv, comp_pred8, width,
672*77c1e3ccSAndroid Build Coastguard Worker height, subpel_x_q3, subpel_y_q3, ref8, ref_stride,
673*77c1e3ccSAndroid Build Coastguard Worker bd, subpel_search);
674*77c1e3ccSAndroid Build Coastguard Worker aom_highbd_comp_mask_pred(comp_pred8, pred8, width, height, comp_pred8, width,
675*77c1e3ccSAndroid Build Coastguard Worker mask, mask_stride, invert_mask);
676*77c1e3ccSAndroid Build Coastguard Worker }
677*77c1e3ccSAndroid Build Coastguard Worker #endif // CONFIG_AV1_HIGHBITDEPTH
678