vp9_mcomp.h 5.78 KB
Newer Older
John Koleszar's avatar
John Koleszar committed
1
/*
2
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
John Koleszar's avatar
John Koleszar committed
3
 *
4
 *  Use of this source code is governed by a BSD-style license
5
6
 *  that can be found in the LICENSE file in the root of the source
 *  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.
John Koleszar's avatar
John Koleszar committed
9
10
11
 */


12
13
#ifndef VP9_ENCODER_VP9_MCOMP_H_
#define VP9_ENCODER_VP9_MCOMP_H_
John Koleszar's avatar
John Koleszar committed
14

15
16
#include "vp9/encoder/vp9_block.h"
#include "vp9/encoder/vp9_variance.h"
John Koleszar's avatar
John Koleszar committed
17

18
19
20
21
#ifdef __cplusplus
extern "C" {
#endif

22
23
// The maximum number of steps in a step search given the largest
// allowed initial step
24
#define MAX_MVSEARCH_STEPS 11
25
26
27
// Max full pel mv specified in the unit of full pixel
// Enable the use of motion vector in range [-1023, 1023].
#define MAX_FULL_PEL_VAL ((1 << (MAX_MVSEARCH_STEPS - 1)) - 1)
28
29
// Maximum size of the first step in full pel units
#define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS-1))
30
31
32
33
// Allowed motion vector pixel distance outside image border
// for Block_16x16
#define BORDER_MV_PIXELS_B16 (16 + VP9_INTERP_EXTEND)

John Koleszar's avatar
John Koleszar committed
34

Dmitry Kovalev's avatar
Dmitry Kovalev committed
35
void vp9_set_mv_search_range(MACROBLOCK *x, const MV *mv);
Dmitry Kovalev's avatar
Dmitry Kovalev committed
36
37
int vp9_mv_bit_cost(const MV *mv, const MV *ref,
                    const int *mvjcost, int *mvcost[2], int weight);
Dmitry Kovalev's avatar
Dmitry Kovalev committed
38
39
40
void vp9_init_dsmotion_compensation(MACROBLOCK *x, int stride);
void vp9_init3smotion_compensation(MACROBLOCK *x,  int stride);

41
struct VP9_COMP;
42
43
44
int vp9_init_search_range(struct VP9_COMP *cpi, int size);

// Runs sequence of diamond searches in smaller steps for RD
John Koleszar's avatar
John Koleszar committed
45
int vp9_full_pixel_diamond(struct VP9_COMP *cpi, MACROBLOCK *x,
Dmitry Kovalev's avatar
Dmitry Kovalev committed
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);
John Koleszar's avatar
John Koleszar committed
50

Dmitry Kovalev's avatar
Dmitry Kovalev committed
51
int vp9_hex_search(const MACROBLOCK *x,
52
                   MV *ref_mv,
53
54
55
                   int search_param,
                   int error_per_bit,
                   int do_init_search,
Dmitry Kovalev's avatar
Dmitry Kovalev committed
56
                   const vp9_variance_fn_ptr_t *vf,
57
                   int use_mvcost,
58
59
                   const MV *center_mv,
                   MV *best_mv);
Dmitry Kovalev's avatar
Dmitry Kovalev committed
60
int vp9_bigdia_search(const MACROBLOCK *x,
61
                      MV *ref_mv,
62
63
64
65
66
                      int search_param,
                      int error_per_bit,
                      int do_init_search,
                      const vp9_variance_fn_ptr_t *vf,
                      int use_mvcost,
67
68
                      const MV *center_mv,
                      MV *best_mv);
Dmitry Kovalev's avatar
Dmitry Kovalev committed
69
int vp9_square_search(const MACROBLOCK *x,
70
                      MV *ref_mv,
71
72
73
74
75
                      int search_param,
                      int error_per_bit,
                      int do_init_search,
                      const vp9_variance_fn_ptr_t *vf,
                      int use_mvcost,
76
77
                      const MV *center_mv,
                      MV *best_mv);
78
79
80
81
82
83
84
85
int vp9_fast_hex_search(const MACROBLOCK *x,
                        MV *ref_mv,
                        int search_param,
                        int sad_per_bit,
                        const vp9_variance_fn_ptr_t *vfp,
                        int use_mvcost,
                        const MV *center_mv,
                        MV *best_mv);
John Koleszar's avatar
John Koleszar committed
86

87
typedef int (fractional_mv_step_fp) (
Dmitry Kovalev's avatar
Dmitry Kovalev committed
88
    const MACROBLOCK *x,
89
    MV *bestmv, const MV *ref_mv,
90
    int allow_hp,
91
92
93
94
95
96
97
98
    int error_per_bit,
    const vp9_variance_fn_ptr_t *vfp,
    int forced_stop,  // 0 - full, 1 - qtr only, 2 - half only
    int iters_per_step,
    int *mvjcost,
    int *mvcost[2],
    int *distortion,
    unsigned int *sse);
99

100
101
102
extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree;

typedef int (fractional_mv_step_comp_fp) (
Dmitry Kovalev's avatar
Dmitry Kovalev committed
103
    const MACROBLOCK *x,
104
    MV *bestmv, const MV *ref_mv,
105
    int allow_hp,
106
107
108
109
110
111
112
113
    int error_per_bit,
    const vp9_variance_fn_ptr_t *vfp,
    int forced_stop,  // 0 - full, 1 - qtr only, 2 - half only
    int iters_per_step,
    int *mvjcost, int *mvcost[2],
    int *distortion, unsigned int *sse1,
    const uint8_t *second_pred,
    int w, int h);
114

115
extern fractional_mv_step_comp_fp vp9_find_best_sub_pixel_comp_tree;
John Koleszar's avatar
John Koleszar committed
116

117
typedef int (*vp9_full_search_fn_t)(const MACROBLOCK *x,
118
119
120
                                    const MV *ref_mv, int sad_per_bit,
                                    int distance,
                                    const vp9_variance_fn_ptr_t *fn_ptr,
121
                                    int *mvjcost, int *mvcost[2],
122
                                    const MV *center_mv, MV *best_mv);
Jim Bankoski's avatar
Jim Bankoski committed
123

124
typedef int (*vp9_refining_search_fn_t)(const MACROBLOCK *x,
125
                                        MV *ref_mv, int sad_per_bit,
Jim Bankoski's avatar
Jim Bankoski committed
126
                                        int distance,
127
                                        const vp9_variance_fn_ptr_t *fn_ptr,
128
                                        int *mvjcost, int *mvcost[2],
129
                                        const MV *center_mv);
Jim Bankoski's avatar
Jim Bankoski committed
130

131
typedef int (*vp9_diamond_search_fn_t)(const MACROBLOCK *x,
132
                                       MV *ref_mv, MV *best_mv,
Jim Bankoski's avatar
Jim Bankoski committed
133
134
                                       int search_param, int sad_per_bit,
                                       int *num00,
135
                                       const vp9_variance_fn_ptr_t *fn_ptr,
136
                                       int *mvjcost, int *mvcost[2],
137
                                       const MV *center_mv);
John Koleszar's avatar
John Koleszar committed
138

139
int vp9_refining_search_8p_c(const MACROBLOCK *x,
140
                             MV *ref_mv, int error_per_bit,
141
142
                             int search_range,
                             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
147
148
149
#ifdef __cplusplus
}  // extern "C"
#endif

150
#endif  // VP9_ENCODER_VP9_MCOMP_H_