vp9_mcomp.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 "vpx_dsp/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. typedef struct search_site_config {
  29. // motion search sites
  30. MV ss_mv[8 * MAX_MVSEARCH_STEPS]; // Motion vector
  31. intptr_t ss_os[8 * MAX_MVSEARCH_STEPS]; // Offset
  32. int searches_per_step;
  33. int total_steps;
  34. } search_site_config;
  35. void vp9_init_dsmotion_compensation(search_site_config *cfg, int stride);
  36. void vp9_init3smotion_compensation(search_site_config *cfg, int stride);
  37. void vp9_set_mv_search_range(MvLimits *mv_limits, const MV *mv);
  38. int vp9_mv_bit_cost(const MV *mv, const MV *ref, const int *mvjcost,
  39. int *mvcost[2], int weight);
  40. // Utility to compute variance + MV rate cost for a given MV
  41. int vp9_get_mvpred_var(const MACROBLOCK *x, const MV *best_mv,
  42. const MV *center_mv, const vp9_variance_fn_ptr_t *vfp,
  43. int use_mvcost);
  44. int vp9_get_mvpred_av_var(const MACROBLOCK *x, const MV *best_mv,
  45. const MV *center_mv, const uint8_t *second_pred,
  46. const vp9_variance_fn_ptr_t *vfp, int use_mvcost);
  47. struct VP9_COMP;
  48. struct SPEED_FEATURES;
  49. int vp9_init_search_range(int size);
  50. int vp9_refining_search_sad(const struct macroblock *x, struct mv *ref_mv,
  51. int sad_per_bit, int distance,
  52. const struct vp9_variance_vtable *fn_ptr,
  53. const struct mv *center_mv);
  54. // Perform integral projection based motion estimation.
  55. unsigned int vp9_int_pro_motion_estimation(const struct VP9_COMP *cpi,
  56. MACROBLOCK *x, BLOCK_SIZE bsize,
  57. int mi_row, int mi_col);
  58. typedef uint32_t(fractional_mv_step_fp)(
  59. const MACROBLOCK *x, MV *bestmv, const MV *ref_mv, int allow_hp,
  60. int error_per_bit, const vp9_variance_fn_ptr_t *vfp,
  61. int forced_stop, // 0 - full, 1 - qtr only, 2 - half only
  62. int iters_per_step, int *cost_list, int *mvjcost, int *mvcost[2],
  63. uint32_t *distortion, uint32_t *sse1, const uint8_t *second_pred, int w,
  64. int h);
  65. extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree;
  66. extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree_pruned;
  67. extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree_pruned_more;
  68. extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree_pruned_evenmore;
  69. extern fractional_mv_step_fp vp9_skip_sub_pixel_tree;
  70. typedef int (*vp9_full_search_fn_t)(const MACROBLOCK *x, const MV *ref_mv,
  71. int sad_per_bit, int distance,
  72. const vp9_variance_fn_ptr_t *fn_ptr,
  73. const MV *center_mv, MV *best_mv);
  74. typedef int (*vp9_refining_search_fn_t)(const MACROBLOCK *x, MV *ref_mv,
  75. int sad_per_bit, int distance,
  76. const vp9_variance_fn_ptr_t *fn_ptr,
  77. const MV *center_mv);
  78. typedef int (*vp9_diamond_search_fn_t)(
  79. const MACROBLOCK *x, const search_site_config *cfg, MV *ref_mv, MV *best_mv,
  80. int search_param, int sad_per_bit, int *num00,
  81. const vp9_variance_fn_ptr_t *fn_ptr, const MV *center_mv);
  82. int vp9_refining_search_8p_c(const MACROBLOCK *x, MV *ref_mv, int error_per_bit,
  83. int search_range,
  84. const vp9_variance_fn_ptr_t *fn_ptr,
  85. const MV *center_mv, const uint8_t *second_pred);
  86. struct VP9_COMP;
  87. int vp9_full_pixel_search(struct VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
  88. MV *mvp_full, int step_param, int error_per_bit,
  89. int *cost_list, const MV *ref_mv, MV *tmp_mv,
  90. int var_max, int rd);
  91. #ifdef __cplusplus
  92. } // extern "C"
  93. #endif
  94. #endif // VP9_ENCODER_VP9_MCOMP_H_