Line data Source code
1 : /*
2 : * Copyright(c) 2019 Intel Corporation
3 : * SPDX - License - Identifier: BSD - 2 - Clause - Patent
4 : */
5 :
6 : #ifndef EbInterPrediction_h
7 : #define EbInterPrediction_h
8 :
9 : #include "EbDefinitions.h"
10 : #include "EbPictureControlSet.h"
11 : #include "EbCodingUnit.h"
12 : #include "EbPredictionUnit.h"
13 : #include "EbModeDecision.h"
14 : #include "EbMcp.h"
15 : #include "EbMvMerge.h"
16 : #include "EbObject.h"
17 :
18 : #ifdef __cplusplus
19 : extern "C" {
20 : #endif
21 :
22 : #define REF_SCALE_SHIFT 14
23 : #define REF_NO_SCALE (1 << REF_SCALE_SHIFT)
24 : #define REF_INVALID_SCALE -1
25 :
26 : #define RS_SUBPEL_BITS 6
27 : #define RS_SUBPEL_MASK ((1 << RS_SUBPEL_BITS) - 1)
28 : #define RS_SCALE_SUBPEL_BITS 14
29 : #define RS_SCALE_SUBPEL_MASK ((1 << RS_SCALE_SUBPEL_BITS) - 1)
30 : #define RS_SCALE_EXTRA_BITS (RS_SCALE_SUBPEL_BITS - RS_SUBPEL_BITS)
31 : #define RS_SCALE_EXTRA_OFF (1 << (RS_SCALE_EXTRA_BITS - 1))
32 :
33 : extern DECLARE_ALIGNED(256, const InterpKernel, sub_pel_filters_8[SUBPEL_SHIFTS]);
34 : extern DECLARE_ALIGNED(256, const InterpKernel, sub_pel_filters_4[SUBPEL_SHIFTS]);
35 : extern DECLARE_ALIGNED(256, const InterpKernel, sub_pel_filters_8sharp[SUBPEL_SHIFTS]);
36 : extern DECLARE_ALIGNED(256, const InterpKernel, sub_pel_filters_8smooth[SUBPEL_SHIFTS]);
37 : extern DECLARE_ALIGNED(256, const InterpKernel, bilinear_filters[SUBPEL_SHIFTS]);
38 : extern DECLARE_ALIGNED(256, const InterpKernel, sub_pel_filters_4smooth[SUBPEL_SHIFTS]);
39 :
40 : typedef struct SubpelParams {
41 : int32_t xs;
42 : int32_t ys;
43 : int32_t subpel_x;
44 : int32_t subpel_y;
45 : } SubpelParams;
46 :
47 : struct ModeDecisionContext;
48 :
49 : typedef struct InterPredictionContext {
50 : EbDctor dctor;
51 : MotionCompensationPredictionContext *mcp_context;
52 : } InterPredictionContext;
53 :
54 : void svt_inter_predictor(const uint8_t *src, int32_t src_stride,
55 : uint8_t *dst, int32_t dst_stride, const SubpelParams *subpel_params,
56 : const ScaleFactors *sf, int32_t w, int32_t h, ConvolveParams *conv_params,
57 : InterpFilters interp_filters, int32_t is_intrabc);
58 :
59 : void svt_highbd_inter_predictor(const uint16_t *src, int32_t src_stride,
60 : uint16_t *dst, int32_t dst_stride, const SubpelParams *subpel_params,
61 : const ScaleFactors *sf, int32_t w, int32_t h, ConvolveParams *conv_params,
62 : InterpFilters interp_filters, int32_t is_intrabc, int32_t bd);
63 :
64 : typedef EbErrorType(*EB_AV1_INTER_PREDICTION_FUNC_PTR)(
65 : PictureControlSet *picture_control_set_ptr,
66 : uint32_t interp_filters,
67 : CodingUnit *cu_ptr,
68 : uint8_t ref_frame_type,
69 : MvUnit *mv_unit,
70 : uint8_t use_intrabc,
71 : #if OBMC_FLAG
72 : MotionMode motion_mode,
73 : uint8_t use_precomputed_obmc,
74 : struct ModeDecisionContext *md_context,
75 : #endif
76 : uint8_t compound_idx,
77 : InterInterCompoundData *interinter_comp,
78 : #if II_COMP_FLAG
79 : TileInfo * tile,
80 : NeighborArrayUnit *luma_recon_neighbor_array,
81 : NeighborArrayUnit *cb_recon_neighbor_array ,
82 : NeighborArrayUnit *cr_recon_neighbor_array ,
83 : uint8_t is_interintra_used ,
84 : INTERINTRA_MODE interintra_mode,
85 : uint8_t use_wedge_interintra,
86 : int32_t interintra_wedge_index,
87 : #endif
88 : uint16_t pu_origin_x,
89 : uint16_t pu_origin_y,
90 : uint8_t bwidth,
91 : uint8_t bheight,
92 : EbPictureBufferDesc *ref_pic_list0,
93 : EbPictureBufferDesc *ref_pic_list1,
94 : EbPictureBufferDesc *prediction_ptr,
95 : uint16_t dst_origin_x,
96 : uint16_t dst_origin_y,
97 : EbBool perform_chroma,
98 : uint8_t bit_depth);
99 :
100 :
101 :
102 : EbErrorType av1_inter_prediction(
103 : PictureControlSet *picture_control_set_ptr,
104 : uint32_t interp_filters,
105 : CodingUnit *cu_ptr,
106 : uint8_t ref_frame_type,
107 : MvUnit *mv_unit,
108 : uint8_t use_intrabc,
109 : #if OBMC_FLAG
110 : MotionMode motion_mode,
111 : uint8_t use_precomputed_obmc,
112 : struct ModeDecisionContext *md_context,
113 : #endif
114 : uint8_t compound_idx,
115 : InterInterCompoundData *interinter_comp,
116 : #if II_COMP_FLAG
117 : TileInfo * tile,
118 : NeighborArrayUnit *luma_recon_neighbor_array,
119 : NeighborArrayUnit *cb_recon_neighbor_array ,
120 : NeighborArrayUnit *cr_recon_neighbor_array ,
121 : uint8_t is_interintra_used ,
122 : INTERINTRA_MODE interintra_mode,
123 : uint8_t use_wedge_interintra,
124 : int32_t interintra_wedge_index,
125 : #endif
126 : uint16_t pu_origin_x,
127 : uint16_t pu_origin_y,
128 : uint8_t bwidth,
129 : uint8_t bheight,
130 : EbPictureBufferDesc *ref_pic_list0,
131 : EbPictureBufferDesc *ref_pic_list1,
132 : EbPictureBufferDesc *prediction_ptr,
133 : uint16_t dst_origin_x,
134 : uint16_t dst_origin_y,
135 : EbBool perform_chroma,
136 : uint8_t bit_depth);
137 :
138 :
139 : EbErrorType av1_inter_prediction_hbd(
140 : PictureControlSet *picture_control_set_ptr,
141 : uint32_t interp_filters,
142 : CodingUnit *cu_ptr,
143 : uint8_t ref_frame_type,
144 : MvUnit *mv_unit,
145 : uint8_t use_intrabc,
146 : #if OBMC_FLAG
147 : MotionMode motion_mode,
148 : uint8_t use_precomputed_obmc,
149 : struct ModeDecisionContext *md_context,
150 : #endif
151 : uint8_t compound_idx,
152 : InterInterCompoundData *interinter_comp,
153 : #if II_COMP_FLAG
154 : TileInfo * tile,
155 : NeighborArrayUnit *luma_recon_neighbor_array,
156 : NeighborArrayUnit *cb_recon_neighbor_array ,
157 : NeighborArrayUnit *cr_recon_neighbor_array ,
158 : uint8_t is_interintra_used ,
159 : INTERINTRA_MODE interintra_mode,
160 : uint8_t use_wedge_interintra,
161 : int32_t interintra_wedge_index,
162 : #endif
163 : uint16_t pu_origin_x,
164 : uint16_t pu_origin_y,
165 : uint8_t bwidth,
166 : uint8_t bheight,
167 : EbPictureBufferDesc *ref_pic_list0,
168 : EbPictureBufferDesc *ref_pic_list1,
169 : EbPictureBufferDesc *prediction_ptr,
170 : uint16_t dst_origin_x,
171 : uint16_t dst_origin_y,
172 : EbBool perform_chroma,
173 : uint8_t bit_depth);
174 :
175 : void search_compound_diff_wedge(
176 : PictureControlSet *picture_control_set_ptr,
177 : struct ModeDecisionContext *context_ptr,
178 : ModeDecisionCandidate *candidate_ptr);
179 : void search_compound_avg_dist(
180 : PictureControlSet *picture_control_set_ptr,
181 : struct ModeDecisionContext *context_ptr,
182 : ModeDecisionCandidate *candidate_ptr);
183 :
184 : void av1_dist_wtd_comp_weight_assign(
185 : SeqHeader *seq_header,
186 : int cur_frame_index,
187 : int bck_frame_index,
188 : int fwd_frame_index,
189 : int compound_idx,
190 : int order_idx,
191 : int *fwd_offset, int *bck_offset,
192 : int *use_dist_wtd_comp_avg,
193 : int is_compound);
194 :
195 : void build_masked_compound_no_round(uint8_t *dst, int dst_stride,
196 : const CONV_BUF_TYPE *src0, int src0_stride,
197 : const CONV_BUF_TYPE *src1, int src1_stride,
198 : const InterInterCompoundData *const comp_data, uint8_t *seg_mask,
199 : BlockSize sb_type, int h, int w, ConvolveParams *conv_params,
200 : uint8_t bd);
201 :
202 : void av1_get_convolve_filter_params(uint32_t interp_filters,
203 : InterpFilterParams *params_x, InterpFilterParams *params_y,
204 : int32_t w, int32_t h);
205 :
206 : #if COMP_INTERINTRA
207 : /* Mapping of interintra to intra mode for use in the intra component */
208 : static const PredictionMode interintra_to_intra_mode[INTERINTRA_MODES] = {
209 : DC_PRED, V_PRED, H_PRED, SMOOTH_PRED
210 : };
211 23375512 : static INLINE int is_interintra_wedge_used(BlockSize sb_type) {
212 23375512 : return wedge_params_lookup[sb_type].bits > 0;
213 : }
214 :
215 : void combine_interintra(INTERINTRA_MODE mode,
216 : int8_t use_wedge_interintra, int wedge_index,
217 : int wedge_sign, BlockSize bsize,
218 : BlockSize plane_bsize, uint8_t *comppred,
219 : int compstride, const uint8_t *interpred,
220 : int interstride, const uint8_t *intrapred,
221 : int intrastride);
222 :
223 : void combine_interintra_highbd(
224 : InterIntraMode mode, uint8_t use_wedge_interintra, uint8_t wedge_index,
225 : uint8_t wedge_sign, BlockSize bsize, BlockSize plane_bsize,
226 : uint8_t *comppred8, int compstride, const uint8_t *interpred8,
227 : int interstride, const uint8_t *intrapred8, int intrastride, int bd);
228 :
229 : #endif //comp_interintra
230 :
231 : void av1_setup_scale_factors_for_frame(ScaleFactors *sf, int other_w,
232 : int other_h, int this_w, int this_h);
233 :
234 0 : static INLINE int av1_is_valid_scale(const struct ScaleFactors *sf) {
235 0 : return sf->x_scale_fp != REF_INVALID_SCALE &&
236 0 : sf->y_scale_fp != REF_INVALID_SCALE;
237 : }
238 0 : static INLINE int av1_is_scaled(const struct ScaleFactors *sf) {
239 0 : return av1_is_valid_scale(sf) &&
240 0 : (sf->x_scale_fp != REF_NO_SCALE || sf->y_scale_fp != REF_NO_SCALE);
241 : }
242 0 : static INLINE int valid_ref_frame_size(int ref_width, int ref_height,
243 : int this_width, int this_height)
244 : {
245 0 : return 2 * this_width >= ref_width && 2 * this_height >= ref_height &&
246 0 : this_width <= 16 * ref_width && this_height <= 16 * ref_height;
247 : }
248 : MV32 av1_scale_mv(const MV *mvq4, int x, int y,
249 : const ScaleFactors *sf);
250 :
251 : EbErrorType inter_pu_prediction_av1(
252 : struct ModeDecisionContext *md_context_ptr,
253 : PictureControlSet *picture_control_set_ptr,
254 : ModeDecisionCandidateBuffer *candidate_buffer_ptr);
255 :
256 :
257 : EbErrorType choose_mvp_idx_v2(
258 : ModeDecisionCandidate *candidate_ptr,
259 : uint32_t cu_origin_x,
260 : uint32_t cu_origin_y,
261 : uint32_t pu_index,
262 : uint32_t tb_size,
263 : int16_t *ref0_amvp_cand_array_x,
264 : int16_t *ref0_amvp_cand_array_y,
265 : uint32_t ref0_num_available_amvp_cand,
266 : int16_t *ref1_amvp_cand_array_x,
267 : int16_t *ref1_amvp_cand_array_y,
268 : uint32_t ref1_num_available_amvp_cand,
269 : PictureControlSet *picture_control_set_ptr);
270 :
271 : EbErrorType warped_motion_prediction(
272 : PictureControlSet *picture_control_set_ptr,
273 : MvUnit *mv_unit,
274 : uint8_t ref_frame_type,
275 : uint8_t compound_idx,
276 : InterInterCompoundData *interinter_comp,
277 : uint16_t pu_origin_x,
278 : uint16_t pu_origin_y,
279 : CodingUnit *cu_ptr,
280 : const BlockGeom *blk_geom,
281 : EbPictureBufferDesc *ref_pic_list0,
282 : EbPictureBufferDesc *ref_pic_list1,
283 : EbPictureBufferDesc *prediction_ptr,
284 : uint16_t dst_origin_x,
285 : uint16_t dst_origin_y,
286 : EbWarpedMotionParams *wm_params_l0,
287 : EbWarpedMotionParams *wm_params_l1,
288 : uint8_t bit_depth,
289 : EbBool perform_chroma);
290 :
291 : extern aom_highbd_convolve_fn_t convolveHbd[/*subX*/2][/*subY*/2][/*bi*/2];
292 : extern aom_convolve_fn_t convolve[/*subX*/2][/*subY*/2][/*bi*/2];
293 :
294 : #ifdef __cplusplus
295 : }
296 : #endif
297 : #endif //EbInterPrediction_h
|