vp9_mcomp.h 4.85 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
#ifndef VP9_ENCODER_VP9_MCOMP_H_
#define VP9_ENCODER_VP9_MCOMP_H_
John Koleszar's avatar
John Koleszar committed
13

14
#include "vp9/encoder/vp9_block.h"
Johann's avatar
Johann committed
15
#include "vpx_dsp/variance.h"
John Koleszar's avatar
John Koleszar committed
16

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

21 22
// The maximum number of steps in a step search given the largest
// allowed initial step
23
#define MAX_MVSEARCH_STEPS 11
24 25 26
// 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)
27
// Maximum size of the first step in full pel units
clang-format's avatar
clang-format committed
28
#define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS - 1))
29 30 31 32
// Allowed motion vector pixel distance outside image border
// for Block_16x16
#define BORDER_MV_PIXELS_B16 (16 + VP9_INTERP_EXTEND)

33
typedef struct search_site_config {
34
  // motion search sites
clang-format's avatar
clang-format committed
35 36
  MV ss_mv[8 * MAX_MVSEARCH_STEPS];        // Motion vector
  intptr_t ss_os[8 * MAX_MVSEARCH_STEPS];  // Offset
37
  int searches_per_step;
38
  int total_steps;
39 40 41
} search_site_config;

void vp9_init_dsmotion_compensation(search_site_config *cfg, int stride);
clang-format's avatar
clang-format committed
42
void vp9_init3smotion_compensation(search_site_config *cfg, int stride);
John Koleszar's avatar
John Koleszar committed
43

Alex Converse's avatar
Alex Converse committed
44
void vp9_set_mv_search_range(MvLimits *mv_limits, const MV *mv);
clang-format's avatar
clang-format committed
45 46
int vp9_mv_bit_cost(const MV *mv, const MV *ref, const int *mvjcost,
                    int *mvcost[2], int weight);
Deb Mukherjee's avatar
Deb Mukherjee committed
47 48

// Utility to compute variance + MV rate cost for a given MV
clang-format's avatar
clang-format committed
49 50
int vp9_get_mvpred_var(const MACROBLOCK *x, const MV *best_mv,
                       const MV *center_mv, const vp9_variance_fn_ptr_t *vfp,
Deb Mukherjee's avatar
Deb Mukherjee committed
51
                       int use_mvcost);
clang-format's avatar
clang-format committed
52 53 54
int vp9_get_mvpred_av_var(const MACROBLOCK *x, const MV *best_mv,
                          const MV *center_mv, const uint8_t *second_pred,
                          const vp9_variance_fn_ptr_t *vfp, int use_mvcost);
Dmitry Kovalev's avatar
Dmitry Kovalev committed
55

56
struct VP9_COMP;
57 58
struct SPEED_FEATURES;

59
int vp9_init_search_range(int size);
60

clang-format's avatar
clang-format committed
61
int vp9_refining_search_sad(const struct macroblock *x, struct mv *ref_mv,
62 63 64 65
                            int sad_per_bit, int distance,
                            const struct vp9_variance_vtable *fn_ptr,
                            const struct mv *center_mv);

66 67
// Perform integral projection based motion estimation.
unsigned int vp9_int_pro_motion_estimation(const struct VP9_COMP *cpi,
clang-format's avatar
clang-format committed
68
                                           MACROBLOCK *x, BLOCK_SIZE bsize,
69
                                           int mi_row, int mi_col);
70

clang-format's avatar
clang-format committed
71 72 73
typedef uint32_t(fractional_mv_step_fp)(
    const MACROBLOCK *x, MV *bestmv, const MV *ref_mv, int allow_hp,
    int error_per_bit, const vp9_variance_fn_ptr_t *vfp,
74
    int forced_stop,  // 0 - full, 1 - qtr only, 2 - half only
clang-format's avatar
clang-format committed
75 76 77
    int iters_per_step, int *cost_list, int *mvjcost, int *mvcost[2],
    uint32_t *distortion, uint32_t *sse1, const uint8_t *second_pred, int w,
    int h);
78

79
extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree;
80
extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree_pruned;
81
extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree_pruned_more;
82
extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree_pruned_evenmore;
83
extern fractional_mv_step_fp vp9_skip_sub_pixel_tree;
John Koleszar's avatar
John Koleszar committed
84

clang-format's avatar
clang-format committed
85 86
typedef int (*vp9_full_search_fn_t)(const MACROBLOCK *x, const MV *ref_mv,
                                    int sad_per_bit, int distance,
87
                                    const vp9_variance_fn_ptr_t *fn_ptr,
88
                                    const MV *center_mv, MV *best_mv);
Jim Bankoski's avatar
Jim Bankoski committed
89

clang-format's avatar
clang-format committed
90 91
typedef int (*vp9_refining_search_fn_t)(const MACROBLOCK *x, MV *ref_mv,
                                        int sad_per_bit, int distance,
92
                                        const vp9_variance_fn_ptr_t *fn_ptr,
93
                                        const MV *center_mv);
Jim Bankoski's avatar
Jim Bankoski committed
94

clang-format's avatar
clang-format committed
95 96 97 98
typedef int (*vp9_diamond_search_fn_t)(
    const MACROBLOCK *x, const search_site_config *cfg, MV *ref_mv, MV *best_mv,
    int search_param, int sad_per_bit, int *num00,
    const vp9_variance_fn_ptr_t *fn_ptr, const MV *center_mv);
John Koleszar's avatar
John Koleszar committed
99

clang-format's avatar
clang-format committed
100
int vp9_refining_search_8p_c(const MACROBLOCK *x, MV *ref_mv, int error_per_bit,
101 102
                             int search_range,
                             const vp9_variance_fn_ptr_t *fn_ptr,
103
                             const MV *center_mv, const uint8_t *second_pred);
104 105 106

struct VP9_COMP;

clang-format's avatar
clang-format committed
107
int vp9_full_pixel_search(struct VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
108 109 110
                          MV *mvp_full, int step_param, int search_method,
                          int error_per_bit, int *cost_list, const MV *ref_mv,
                          MV *tmp_mv, int var_max, int rd);
111

112 113 114 115
#ifdef __cplusplus
}  // extern "C"
#endif

116
#endif  // VP9_ENCODER_VP9_MCOMP_H_