1 /*
2  * Copyright (c) 2020, Alliance for Open Media. All rights reserved
3  *
4  * This source code is subject to the terms of the BSD 2 Clause License and
5  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6  * was not distributed with this source code in the LICENSE file, you can
7  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8  * Media Patent License 1.0 was not distributed with this source code in the
9  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10  */
11 
12 #ifndef AOM_AV1_ENCODER_MOTION_SEARCH_H_
13 #define AOM_AV1_ENCODER_MOTION_SEARCH_H_
14 
15 #include "av1/encoder/encoder.h"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 typedef struct {
22   int64_t rd;
23   int drl_cost;
24 
25   int rate_mv;
26   int_mv mv;
27 
28   int_mv full_search_mv;
29   int full_mv_rate;
30 } inter_mode_info;
31 
32 void av1_single_motion_search(const AV1_COMP *const cpi, MACROBLOCK *x,
33                               BLOCK_SIZE bsize, int ref_idx, int *rate_mv,
34                               int search_range, inter_mode_info *mode_info);
35 
36 void av1_joint_motion_search(const AV1_COMP *cpi, MACROBLOCK *x,
37                              BLOCK_SIZE bsize, int_mv *cur_mv,
38                              const uint8_t *mask, int mask_stride,
39                              int *rate_mv);
40 
41 int av1_interinter_compound_motion_search(const AV1_COMP *const cpi,
42                                           MACROBLOCK *x,
43                                           const int_mv *const cur_mv,
44                                           const BLOCK_SIZE bsize,
45                                           const PREDICTION_MODE this_mode);
46 
47 void av1_compound_single_motion_search_interinter(
48     const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, int_mv *cur_mv,
49     const uint8_t *mask, int mask_stride, int *rate_mv, int ref_idx);
50 
51 void av1_compound_single_motion_search(const AV1_COMP *cpi, MACROBLOCK *x,
52                                        BLOCK_SIZE bsize, MV *this_mv,
53                                        const uint8_t *second_pred,
54                                        const uint8_t *mask, int mask_stride,
55                                        int *rate_mv, int ref_idx);
56 
57 // Performs a motion search in SIMPLE_TRANSLATION mode using reference frame
58 // ref. Note that this sets the offset of mbmi, so we will need to reset it
59 // after calling this function.
60 void av1_simple_motion_search(struct AV1_COMP *const cpi, MACROBLOCK *x,
61                               int mi_row, int mi_col, BLOCK_SIZE bsize, int ref,
62                               FULLPEL_MV start_mv, int num_planes,
63                               int use_subpixel);
64 
65 // Performs a simple motion search to calculate the sse and var of the residue
66 void av1_simple_motion_sse_var(struct AV1_COMP *cpi, MACROBLOCK *x, int mi_row,
67                                int mi_col, BLOCK_SIZE bsize,
68                                const FULLPEL_MV start_mv, int use_subpixel,
69                                unsigned int *sse, unsigned int *var);
70 
71 #ifdef __cplusplus
72 }  // extern "C"
73 #endif
74 
75 #endif  // AOM_AV1_ENCODER_MOTION_SEARCH_H_
76