vp9_mcomp.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  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. #ifndef VP9_ENCODER_VP9_MCOMP_H_
  11. #define VP9_ENCODER_VP9_MCOMP_H_
  12. #include "vp9/encoder/vp9_block.h"
  13. #include "vp9/encoder/vp9_variance.h"
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. // The maximum number of steps in a step search given the largest
  18. // allowed initial step
  19. #define MAX_MVSEARCH_STEPS 11
  20. // Max full pel mv specified in the unit of full pixel
  21. // Enable the use of motion vector in range [-1023, 1023].
  22. #define MAX_FULL_PEL_VAL ((1 << (MAX_MVSEARCH_STEPS - 1)) - 1)
  23. // Maximum size of the first step in full pel units
  24. #define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS-1))
  25. // Allowed motion vector pixel distance outside image border
  26. // for Block_16x16
  27. #define BORDER_MV_PIXELS_B16 (16 + VP9_INTERP_EXTEND)
  28. // motion search site
  29. typedef struct search_site {
  30. MV mv;
  31. int offset;
  32. } search_site;
  33. typedef struct search_site_config {
  34. search_site ss[8 * MAX_MVSEARCH_STEPS + 1];
  35. int ss_count;
  36. int searches_per_step;
  37. } search_site_config;
  38. void vp9_init_dsmotion_compensation(search_site_config *cfg, int stride);
  39. void vp9_init3smotion_compensation(search_site_config *cfg, int stride);
  40. void vp9_set_mv_search_range(MACROBLOCK *x, const MV *mv);
  41. int vp9_mv_bit_cost(const MV *mv, const MV *ref,
  42. const int *mvjcost, int *mvcost[2], int weight);
  43. // Utility to compute variance + MV rate cost for a given MV
  44. int vp9_get_mvpred_var(const MACROBLOCK *x,
  45. const MV *best_mv, const MV *center_mv,
  46. const vp9_variance_fn_ptr_t *vfp,
  47. int use_mvcost);
  48. int vp9_get_mvpred_av_var(const MACROBLOCK *x,
  49. const MV *best_mv, const MV *center_mv,
  50. const uint8_t *second_pred,
  51. const vp9_variance_fn_ptr_t *vfp,
  52. int use_mvcost);
  53. struct VP9_COMP;
  54. struct SPEED_FEATURES;
  55. int vp9_init_search_range(int size);
  56. int vp9_refining_search_sad(const struct macroblock *x,
  57. struct mv *ref_mv,
  58. int sad_per_bit, int distance,
  59. const struct vp9_variance_vtable *fn_ptr,
  60. const struct mv *center_mv);
  61. // Runs sequence of diamond searches in smaller steps for RD.
  62. int vp9_full_pixel_diamond(const struct VP9_COMP *cpi, MACROBLOCK *x,
  63. MV *mvp_full, int step_param,
  64. int sadpb, int further_steps, int do_refine,
  65. int *cost_list,
  66. const vp9_variance_fn_ptr_t *fn_ptr,
  67. const MV *ref_mv, MV *dst_mv);
  68. // Perform integral projection based motion estimation.
  69. unsigned int vp9_int_pro_motion_estimation(const struct VP9_COMP *cpi,
  70. MACROBLOCK *x,
  71. BLOCK_SIZE bsize,
  72. int mi_row, int mi_col);
  73. typedef int (integer_mv_pattern_search_fn) (
  74. const MACROBLOCK *x,
  75. MV *ref_mv,
  76. int search_param,
  77. int error_per_bit,
  78. int do_init_search,
  79. int *cost_list,
  80. const vp9_variance_fn_ptr_t *vf,
  81. int use_mvcost,
  82. const MV *center_mv,
  83. MV *best_mv);
  84. integer_mv_pattern_search_fn vp9_hex_search;
  85. integer_mv_pattern_search_fn vp9_bigdia_search;
  86. integer_mv_pattern_search_fn vp9_square_search;
  87. integer_mv_pattern_search_fn vp9_fast_hex_search;
  88. integer_mv_pattern_search_fn vp9_fast_dia_search;
  89. typedef int (fractional_mv_step_fp) (
  90. const MACROBLOCK *x,
  91. MV *bestmv, const MV *ref_mv,
  92. int allow_hp,
  93. int error_per_bit,
  94. const vp9_variance_fn_ptr_t *vfp,
  95. int forced_stop, // 0 - full, 1 - qtr only, 2 - half only
  96. int iters_per_step,
  97. int *cost_list,
  98. int *mvjcost, int *mvcost[2],
  99. int *distortion, unsigned int *sse1,
  100. const uint8_t *second_pred,
  101. int w, int h);
  102. extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree;
  103. extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree_pruned;
  104. extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree_pruned_more;
  105. extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree_pruned_evenmore;
  106. typedef int (*vp9_full_search_fn_t)(const MACROBLOCK *x,
  107. const MV *ref_mv, int sad_per_bit,
  108. int distance,
  109. const vp9_variance_fn_ptr_t *fn_ptr,
  110. const MV *center_mv, MV *best_mv);
  111. typedef int (*vp9_refining_search_fn_t)(const MACROBLOCK *x,
  112. MV *ref_mv, int sad_per_bit,
  113. int distance,
  114. const vp9_variance_fn_ptr_t *fn_ptr,
  115. const MV *center_mv);
  116. typedef int (*vp9_diamond_search_fn_t)(const MACROBLOCK *x,
  117. const search_site_config *cfg,
  118. MV *ref_mv, MV *best_mv,
  119. int search_param, int sad_per_bit,
  120. int *num00,
  121. const vp9_variance_fn_ptr_t *fn_ptr,
  122. const MV *center_mv);
  123. int vp9_refining_search_8p_c(const MACROBLOCK *x,
  124. MV *ref_mv, int error_per_bit,
  125. int search_range,
  126. const vp9_variance_fn_ptr_t *fn_ptr,
  127. const MV *center_mv, const uint8_t *second_pred);
  128. struct VP9_COMP;
  129. int vp9_full_pixel_search(struct VP9_COMP *cpi, MACROBLOCK *x,
  130. BLOCK_SIZE bsize, MV *mvp_full,
  131. int step_param, int error_per_bit,
  132. int *cost_list,
  133. const MV *ref_mv, MV *tmp_mv,
  134. int var_max, int rd);
  135. #ifdef __cplusplus
  136. } // extern "C"
  137. #endif
  138. #endif // VP9_ENCODER_VP9_MCOMP_H_