blob: 9d1ab2aabe574c35a3f0d58271197c162e61356f [file] [log] [blame]
Jingning Han3ee6db62015-08-05 19:00:31 -07001/*
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
Yaowu Xu2dcefd92015-08-13 09:25:39 -070012#ifndef VP10_ENCODER_MCOMP_H_
13#define VP10_ENCODER_MCOMP_H_
Jingning Han3ee6db62015-08-05 19:00:31 -070014
Jingning Han54d66ef2015-08-06 21:14:07 -070015#include "vp10/encoder/block.h"
Jingning Han3ee6db62015-08-05 19:00:31 -070016#include "vpx_dsp/variance.h"
17
18#ifdef __cplusplus
19extern "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// motion search site
35typedef struct search_site {
36 MV mv;
37 int offset;
38} search_site;
39
40typedef struct search_site_config {
41 search_site ss[8 * MAX_MVSEARCH_STEPS + 1];
42 int ss_count;
43 int searches_per_step;
44} search_site_config;
45
46void vp10_init_dsmotion_compensation(search_site_config *cfg, int stride);
47void vp10_init3smotion_compensation(search_site_config *cfg, int stride);
48
49void vp10_set_mv_search_range(MACROBLOCK *x, const MV *mv);
50int vp10_mv_bit_cost(const MV *mv, const MV *ref,
51 const int *mvjcost, int *mvcost[2], int weight);
52
53// Utility to compute variance + MV rate cost for a given MV
54int vp10_get_mvpred_var(const MACROBLOCK *x,
55 const MV *best_mv, const MV *center_mv,
56 const vp9_variance_fn_ptr_t *vfp,
57 int use_mvcost);
58int vp10_get_mvpred_av_var(const MACROBLOCK *x,
59 const MV *best_mv, const MV *center_mv,
60 const uint8_t *second_pred,
61 const vp9_variance_fn_ptr_t *vfp,
62 int use_mvcost);
63
Yaowu Xu26a9afc2015-08-13 09:42:27 -070064struct VP10_COMP;
Jingning Han3ee6db62015-08-05 19:00:31 -070065struct SPEED_FEATURES;
66
67int vp10_init_search_range(int size);
68
69int vp10_refining_search_sad(const struct macroblock *x,
70 struct mv *ref_mv,
71 int sad_per_bit, int distance,
72 const struct vp9_variance_vtable *fn_ptr,
73 const struct mv *center_mv);
74
75// Runs sequence of diamond searches in smaller steps for RD.
Yaowu Xu26a9afc2015-08-13 09:42:27 -070076int vp10_full_pixel_diamond(const struct VP10_COMP *cpi, MACROBLOCK *x,
Jingning Han3ee6db62015-08-05 19:00:31 -070077 MV *mvp_full, int step_param,
78 int sadpb, int further_steps, int do_refine,
79 int *cost_list,
80 const vp9_variance_fn_ptr_t *fn_ptr,
81 const MV *ref_mv, MV *dst_mv);
82
83// Perform integral projection based motion estimation.
Yaowu Xu26a9afc2015-08-13 09:42:27 -070084unsigned int vp10_int_pro_motion_estimation(const struct VP10_COMP *cpi,
Jingning Han3ee6db62015-08-05 19:00:31 -070085 MACROBLOCK *x,
86 BLOCK_SIZE bsize,
87 int mi_row, int mi_col);
88
89typedef int (integer_mv_pattern_search_fn) (
90 const MACROBLOCK *x,
91 MV *ref_mv,
92 int search_param,
93 int error_per_bit,
94 int do_init_search,
95 int *cost_list,
96 const vp9_variance_fn_ptr_t *vf,
97 int use_mvcost,
98 const MV *center_mv,
99 MV *best_mv);
100
101integer_mv_pattern_search_fn vp10_hex_search;
102integer_mv_pattern_search_fn vp10_bigdia_search;
103integer_mv_pattern_search_fn vp10_square_search;
104integer_mv_pattern_search_fn vp10_fast_hex_search;
105integer_mv_pattern_search_fn vp10_fast_dia_search;
106
107typedef int (fractional_mv_step_fp) (
108 const MACROBLOCK *x,
109 MV *bestmv, const MV *ref_mv,
110 int allow_hp,
111 int error_per_bit,
112 const vp9_variance_fn_ptr_t *vfp,
113 int forced_stop, // 0 - full, 1 - qtr only, 2 - half only
114 int iters_per_step,
115 int *cost_list,
116 int *mvjcost, int *mvcost[2],
117 int *distortion, unsigned int *sse1,
118 const uint8_t *second_pred,
119 int w, int h);
120
121extern fractional_mv_step_fp vp10_find_best_sub_pixel_tree;
122extern fractional_mv_step_fp vp10_find_best_sub_pixel_tree_pruned;
123extern fractional_mv_step_fp vp10_find_best_sub_pixel_tree_pruned_more;
124extern fractional_mv_step_fp vp10_find_best_sub_pixel_tree_pruned_evenmore;
125
126typedef int (*vp10_full_search_fn_t)(const MACROBLOCK *x,
127 const MV *ref_mv, int sad_per_bit,
128 int distance,
129 const vp9_variance_fn_ptr_t *fn_ptr,
130 const MV *center_mv, MV *best_mv);
131
132typedef int (*vp10_refining_search_fn_t)(const MACROBLOCK *x,
133 MV *ref_mv, int sad_per_bit,
134 int distance,
135 const vp9_variance_fn_ptr_t *fn_ptr,
136 const MV *center_mv);
137
138typedef int (*vp10_diamond_search_fn_t)(const MACROBLOCK *x,
139 const search_site_config *cfg,
140 MV *ref_mv, MV *best_mv,
141 int search_param, int sad_per_bit,
142 int *num00,
143 const vp9_variance_fn_ptr_t *fn_ptr,
144 const MV *center_mv);
145
146int vp10_refining_search_8p_c(const MACROBLOCK *x,
147 MV *ref_mv, int error_per_bit,
148 int search_range,
149 const vp9_variance_fn_ptr_t *fn_ptr,
150 const MV *center_mv, const uint8_t *second_pred);
151
Yaowu Xu26a9afc2015-08-13 09:42:27 -0700152struct VP10_COMP;
Jingning Han3ee6db62015-08-05 19:00:31 -0700153
Yaowu Xu26a9afc2015-08-13 09:42:27 -0700154int vp10_full_pixel_search(struct VP10_COMP *cpi, MACROBLOCK *x,
Jingning Han3ee6db62015-08-05 19:00:31 -0700155 BLOCK_SIZE bsize, MV *mvp_full,
156 int step_param, int error_per_bit,
157 int *cost_list,
158 const MV *ref_mv, MV *tmp_mv,
159 int var_max, int rd);
160
161#ifdef __cplusplus
162} // extern "C"
163#endif
164
Yaowu Xu2dcefd92015-08-13 09:25:39 -0700165#endif // VP10_ENCODER_MCOMP_H_