1 /*
2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef VPX_VP8_ENCODER_MCOMP_H_
12 #define VPX_VP8_ENCODER_MCOMP_H_
13 
14 #include "block.h"
15 #include "vpx_dsp/variance.h"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 /* The maximum number of steps in a step search given the largest allowed
22  * initial step
23  */
24 #define MAX_MVSEARCH_STEPS 8
25 
26 /* Max full pel mv specified in 1 pel units */
27 #define MAX_FULL_PEL_VAL ((1 << (MAX_MVSEARCH_STEPS)) - 1)
28 
29 /* Maximum size of the first step in full pel units */
30 #define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS - 1))
31 
32 int vp8_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvcost[2], int Weight);
33 void vp8_init_dsmotion_compensation(MACROBLOCK *x, int stride);
34 void vp8_init3smotion_compensation(MACROBLOCK *x, int stride);
35 
36 int vp8_hex_search(MACROBLOCK *x, BLOCK *b, BLOCKD *d, int_mv *ref_mv,
37                    int_mv *best_mv, int search_param, int sad_per_bit,
38                    const vp8_variance_fn_ptr_t *vfp, int *mvsadcost[2],
39                    int_mv *center_mv);
40 
41 typedef int(fractional_mv_step_fp)(MACROBLOCK *x, BLOCK *b, BLOCKD *d,
42                                    int_mv *bestmv, int_mv *ref_mv,
43                                    int error_per_bit,
44                                    const vp8_variance_fn_ptr_t *vfp,
45                                    int *mvcost[2], int *distortion,
46                                    unsigned int *sse);
47 
48 fractional_mv_step_fp vp8_find_best_sub_pixel_step_iteratively;
49 fractional_mv_step_fp vp8_find_best_sub_pixel_step;
50 fractional_mv_step_fp vp8_find_best_half_pixel_step;
51 fractional_mv_step_fp vp8_skip_fractional_mv_step;
52 
53 typedef int (*vp8_full_search_fn_t)(MACROBLOCK *x, BLOCK *b, BLOCKD *d,
54                                     int_mv *ref_mv, int sad_per_bit,
55                                     int distance, vp8_variance_fn_ptr_t *fn_ptr,
56                                     int *mvcost[2], int_mv *center_mv);
57 
58 typedef int (*vp8_refining_search_fn_t)(MACROBLOCK *x, BLOCK *b, BLOCKD *d,
59                                         int_mv *ref_mv, int sad_per_bit,
60                                         int distance,
61                                         vp8_variance_fn_ptr_t *fn_ptr,
62                                         int *mvcost[2], int_mv *center_mv);
63 
64 typedef int (*vp8_diamond_search_fn_t)(MACROBLOCK *x, BLOCK *b, BLOCKD *d,
65                                        int_mv *ref_mv, int_mv *best_mv,
66                                        int search_param, int sad_per_bit,
67                                        int *num00,
68                                        vp8_variance_fn_ptr_t *fn_ptr,
69                                        int *mvcost[2], int_mv *center_mv);
70 
71 #ifdef __cplusplus
72 }  // extern "C"
73 #endif
74 
75 #endif  // VPX_VP8_ENCODER_MCOMP_H_
76