Upstream version 6.35.121.0
[platform/framework/web/crosswalk.git] / src / third_party / libvpx / source / libvpx / vp9 / encoder / vp9_mcomp.h
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
12 #ifndef VP9_ENCODER_VP9_MCOMP_H_
13 #define VP9_ENCODER_VP9_MCOMP_H_
14
15 #include "vp9/encoder/vp9_block.h"
16 #include "vp9/encoder/vp9_variance.h"
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 // The maximum number of steps in a step search given the largest
23 // allowed initial step
24 #define MAX_MVSEARCH_STEPS 11
25 // Max full pel mv specified in the unit of full pixel
26 // Enable the use of motion vector in range [-1023, 1023].
27 #define MAX_FULL_PEL_VAL ((1 << (MAX_MVSEARCH_STEPS - 1)) - 1)
28 // Maximum size of the first step in full pel units
29 #define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS-1))
30 // Allowed motion vector pixel distance outside image border
31 // for Block_16x16
32 #define BORDER_MV_PIXELS_B16 (16 + VP9_INTERP_EXTEND)
33
34
35 void vp9_set_mv_search_range(MACROBLOCK *x, const MV *mv);
36 int vp9_mv_bit_cost(const MV *mv, const MV *ref,
37                     const int *mvjcost, int *mvcost[2], int weight);
38 void vp9_init_dsmotion_compensation(MACROBLOCK *x, int stride);
39 void vp9_init3smotion_compensation(MACROBLOCK *x,  int stride);
40
41 struct VP9_COMP;
42 int vp9_init_search_range(struct VP9_COMP *cpi, int size);
43
44 // Runs sequence of diamond searches in smaller steps for RD
45 int vp9_full_pixel_diamond(struct VP9_COMP *cpi, MACROBLOCK *x,
46                            MV *mvp_full, int step_param,
47                            int sadpb, int further_steps, int do_refine,
48                            const vp9_variance_fn_ptr_t *fn_ptr,
49                            const MV *ref_mv, MV *dst_mv);
50
51 int vp9_hex_search(const MACROBLOCK *x,
52                    MV *ref_mv,
53                    int search_param,
54                    int error_per_bit,
55                    int do_init_search,
56                    const vp9_variance_fn_ptr_t *vf,
57                    int use_mvcost,
58                    const MV *center_mv,
59                    MV *best_mv);
60 int vp9_bigdia_search(const MACROBLOCK *x,
61                       MV *ref_mv,
62                       int search_param,
63                       int error_per_bit,
64                       int do_init_search,
65                       const vp9_variance_fn_ptr_t *vf,
66                       int use_mvcost,
67                       const MV *center_mv,
68                       MV *best_mv);
69 int vp9_square_search(const MACROBLOCK *x,
70                       MV *ref_mv,
71                       int search_param,
72                       int error_per_bit,
73                       int do_init_search,
74                       const vp9_variance_fn_ptr_t *vf,
75                       int use_mvcost,
76                       const MV *center_mv,
77                       MV *best_mv);
78 int vp9_fast_hex_search(const MACROBLOCK *x,
79                         MV *ref_mv,
80                         int search_param,
81                         int sad_per_bit,
82                         const vp9_variance_fn_ptr_t *vfp,
83                         int use_mvcost,
84                         const MV *center_mv,
85                         MV *best_mv);
86
87 typedef int (fractional_mv_step_fp) (
88     const MACROBLOCK *x,
89     MV *bestmv, const MV *ref_mv,
90     int allow_hp,
91     int error_per_bit,
92     const vp9_variance_fn_ptr_t *vfp,
93     int forced_stop,  // 0 - full, 1 - qtr only, 2 - half only
94     int iters_per_step,
95     int *mvjcost,
96     int *mvcost[2],
97     int *distortion,
98     unsigned int *sse);
99
100 extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree;
101
102 typedef int (fractional_mv_step_comp_fp) (
103     const MACROBLOCK *x,
104     MV *bestmv, const MV *ref_mv,
105     int allow_hp,
106     int error_per_bit,
107     const vp9_variance_fn_ptr_t *vfp,
108     int forced_stop,  // 0 - full, 1 - qtr only, 2 - half only
109     int iters_per_step,
110     int *mvjcost, int *mvcost[2],
111     int *distortion, unsigned int *sse1,
112     const uint8_t *second_pred,
113     int w, int h);
114
115 extern fractional_mv_step_comp_fp vp9_find_best_sub_pixel_comp_tree;
116
117 typedef int (*vp9_full_search_fn_t)(const MACROBLOCK *x,
118                                     const MV *ref_mv, int sad_per_bit,
119                                     int distance,
120                                     const vp9_variance_fn_ptr_t *fn_ptr,
121                                     int *mvjcost, int *mvcost[2],
122                                     const MV *center_mv, MV *best_mv);
123
124 typedef int (*vp9_refining_search_fn_t)(const MACROBLOCK *x,
125                                         MV *ref_mv, int sad_per_bit,
126                                         int distance,
127                                         const vp9_variance_fn_ptr_t *fn_ptr,
128                                         int *mvjcost, int *mvcost[2],
129                                         const MV *center_mv);
130
131 typedef int (*vp9_diamond_search_fn_t)(const MACROBLOCK *x,
132                                        MV *ref_mv, MV *best_mv,
133                                        int search_param, int sad_per_bit,
134                                        int *num00,
135                                        const vp9_variance_fn_ptr_t *fn_ptr,
136                                        int *mvjcost, int *mvcost[2],
137                                        const MV *center_mv);
138
139 int vp9_refining_search_8p_c(const MACROBLOCK *x,
140                              MV *ref_mv, int error_per_bit,
141                              int search_range,
142                              const vp9_variance_fn_ptr_t *fn_ptr,
143                              int *mvjcost, int *mvcost[2],
144                              const MV *center_mv, const uint8_t *second_pred,
145                              int w, int h);
146 #ifdef __cplusplus
147 }  // extern "C"
148 #endif
149
150 #endif  // VP9_ENCODER_VP9_MCOMP_H_