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"
18 // The maximum number of steps in a step search given the largest
19 // allowed initial step
20 #define MAX_MVSEARCH_STEPS 11
21 // Max full pel mv specified in 1 pel units
22 #define MAX_FULL_PEL_VAL ((1 << (MAX_MVSEARCH_STEPS)) - 1)
23 // Maximum size of the first step in full pel units
24 #define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS-1))
26 void vp9_clamp_mv_min_max(MACROBLOCK *x, int_mv *ref_mv);
27 int vp9_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvjcost,
28 int *mvcost[2], int weight, int ishp);
29 void vp9_init_dsmotion_compensation(MACROBLOCK *x, int stride);
30 void vp9_init3smotion_compensation(MACROBLOCK *x, int stride);
33 int vp9_init_search_range(struct VP9_COMP *cpi, int size);
35 // Runs sequence of diamond searches in smaller steps for RD
36 int vp9_full_pixel_diamond(struct VP9_COMP *cpi, MACROBLOCK *x,
37 int_mv *mvp_full, int step_param,
38 int sadpb, int further_steps, int do_refine,
39 vp9_variance_fn_ptr_t *fn_ptr,
40 int_mv *ref_mv, int_mv *dst_mv);
42 int vp9_hex_search(MACROBLOCK *x,
43 int_mv *ref_mv, int_mv *best_mv,
44 int search_param, int error_per_bit,
45 const vp9_variance_fn_ptr_t *vf,
46 int *mvjsadcost, int *mvsadcost[2],
47 int *mvjcost, int *mvcost[2],
50 typedef int (fractional_mv_step_fp) (MACROBLOCK *x, int_mv
51 *bestmv, int_mv *ref_mv, int error_per_bit, const vp9_variance_fn_ptr_t *vfp,
52 int *mvjcost, int *mvcost[2], int *distortion, unsigned int *sse);
53 extern fractional_mv_step_fp vp9_find_best_sub_pixel_step_iteratively;
54 extern fractional_mv_step_fp vp9_find_best_sub_pixel_step;
55 extern fractional_mv_step_fp vp9_find_best_half_pixel_step;
57 typedef int (*vp9_full_search_fn_t)(MACROBLOCK *x,
58 int_mv *ref_mv, int sad_per_bit,
59 int distance, vp9_variance_fn_ptr_t *fn_ptr,
60 int *mvjcost, int *mvcost[2],
61 int_mv *center_mv, int n);
63 typedef int (*vp9_refining_search_fn_t)(MACROBLOCK *x,
64 int_mv *ref_mv, int sad_per_bit,
66 vp9_variance_fn_ptr_t *fn_ptr,
67 int *mvjcost, int *mvcost[2],
70 typedef int (*vp9_diamond_search_fn_t)(MACROBLOCK *x,
71 int_mv *ref_mv, int_mv *best_mv,
72 int search_param, int sad_per_bit,
74 vp9_variance_fn_ptr_t *fn_ptr,
75 int *mvjcost, int *mvcost[2],
78 int vp9_find_best_sub_pixel_comp(MACROBLOCK *x,
79 int_mv *bestmv, int_mv *ref_mv,
81 const vp9_variance_fn_ptr_t *vfp,
82 int *mvjcost, int *mvcost[2],
83 int *distortion, unsigned int *sse1,
84 const uint8_t *second_pred,
87 int vp9_refining_search_8p_c(MACROBLOCK *x,
88 int_mv *ref_mv, int error_per_bit,
89 int search_range, vp9_variance_fn_ptr_t *fn_ptr,
90 int *mvjcost, int *mvcost[2],
91 int_mv *center_mv, const uint8_t *second_pred,
93 #endif // VP9_ENCODER_VP9_MCOMP_H_