2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
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.
12 #ifndef VP9_ENCODER_VP9_MCOMP_H_
13 #define VP9_ENCODER_VP9_MCOMP_H_
15 #include "vp9/encoder/vp9_block.h"
16 #include "vp9/encoder/vp9_variance.h"
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
32 #define BORDER_MV_PIXELS_B16 (16 + VP9_INTERP_EXTEND)
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);
42 int vp9_init_search_range(struct VP9_COMP *cpi, int size);
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);
51 int vp9_hex_search(const MACROBLOCK *x,
56 const vp9_variance_fn_ptr_t *vf,
60 int vp9_bigdia_search(const MACROBLOCK *x,
65 const vp9_variance_fn_ptr_t *vf,
69 int vp9_square_search(const MACROBLOCK *x,
74 const vp9_variance_fn_ptr_t *vf,
78 int vp9_fast_hex_search(const MACROBLOCK *x,
82 const vp9_variance_fn_ptr_t *vfp,
87 typedef int (fractional_mv_step_fp) (
89 MV *bestmv, const MV *ref_mv,
92 const vp9_variance_fn_ptr_t *vfp,
93 int forced_stop, // 0 - full, 1 - qtr only, 2 - half only
100 extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree;
102 typedef int (fractional_mv_step_comp_fp) (
104 MV *bestmv, const MV *ref_mv,
107 const vp9_variance_fn_ptr_t *vfp,
108 int forced_stop, // 0 - full, 1 - qtr only, 2 - half only
110 int *mvjcost, int *mvcost[2],
111 int *distortion, unsigned int *sse1,
112 const uint8_t *second_pred,
115 extern fractional_mv_step_comp_fp vp9_find_best_sub_pixel_comp_tree;
117 typedef int (*vp9_full_search_fn_t)(const MACROBLOCK *x,
118 const MV *ref_mv, int sad_per_bit,
120 const vp9_variance_fn_ptr_t *fn_ptr,
121 int *mvjcost, int *mvcost[2],
122 const MV *center_mv, MV *best_mv);
124 typedef int (*vp9_refining_search_fn_t)(const MACROBLOCK *x,
125 MV *ref_mv, int sad_per_bit,
127 const vp9_variance_fn_ptr_t *fn_ptr,
128 int *mvjcost, int *mvcost[2],
129 const MV *center_mv);
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,
135 const vp9_variance_fn_ptr_t *fn_ptr,
136 int *mvjcost, int *mvcost[2],
137 const MV *center_mv);
139 int vp9_refining_search_8p_c(const MACROBLOCK *x,
140 MV *ref_mv, int error_per_bit,
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,
150 #endif // VP9_ENCODER_VP9_MCOMP_H_