michael@0: /* michael@0: * Copyright (c) 2010 The WebM project authors. All Rights Reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license michael@0: * that can be found in the LICENSE file in the root of the source michael@0: * tree. An additional intellectual property rights grant can be found michael@0: * in the file PATENTS. All contributing project authors may michael@0: * be found in the AUTHORS file in the root of the source tree. michael@0: */ michael@0: michael@0: michael@0: #ifndef VP9_ENCODER_VP9_MCOMP_H_ michael@0: #define VP9_ENCODER_VP9_MCOMP_H_ michael@0: michael@0: #include "vp9/encoder/vp9_block.h" michael@0: #include "vp9/encoder/vp9_variance.h" michael@0: michael@0: // The maximum number of steps in a step search given the largest michael@0: // allowed initial step michael@0: #define MAX_MVSEARCH_STEPS 11 michael@0: // Max full pel mv specified in 1 pel units michael@0: #define MAX_FULL_PEL_VAL ((1 << (MAX_MVSEARCH_STEPS)) - 1) michael@0: // Maximum size of the first step in full pel units michael@0: #define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS-1)) michael@0: // Allowed motion vector pixel distance outside image border michael@0: // for Block_16x16 michael@0: #define BORDER_MV_PIXELS_B16 (16 + VP9_INTERP_EXTEND) michael@0: michael@0: michael@0: void vp9_clamp_mv_min_max(MACROBLOCK *x, MV *mv); michael@0: int vp9_mv_bit_cost(const MV *mv, const MV *ref, michael@0: const int *mvjcost, int *mvcost[2], int weight); michael@0: void vp9_init_dsmotion_compensation(MACROBLOCK *x, int stride); michael@0: void vp9_init3smotion_compensation(MACROBLOCK *x, int stride); michael@0: michael@0: struct VP9_COMP; michael@0: int vp9_init_search_range(struct VP9_COMP *cpi, int size); michael@0: michael@0: // Runs sequence of diamond searches in smaller steps for RD michael@0: int vp9_full_pixel_diamond(struct VP9_COMP *cpi, MACROBLOCK *x, michael@0: int_mv *mvp_full, int step_param, michael@0: int sadpb, int further_steps, int do_refine, michael@0: vp9_variance_fn_ptr_t *fn_ptr, michael@0: int_mv *ref_mv, int_mv *dst_mv); michael@0: michael@0: int vp9_hex_search(MACROBLOCK *x, michael@0: MV *ref_mv, michael@0: int search_param, michael@0: int error_per_bit, michael@0: int do_init_search, michael@0: const vp9_variance_fn_ptr_t *vf, michael@0: int use_mvcost, michael@0: const MV *center_mv, michael@0: MV *best_mv); michael@0: int vp9_bigdia_search(MACROBLOCK *x, michael@0: MV *ref_mv, michael@0: int search_param, michael@0: int error_per_bit, michael@0: int do_init_search, michael@0: const vp9_variance_fn_ptr_t *vf, michael@0: int use_mvcost, michael@0: const MV *center_mv, michael@0: MV *best_mv); michael@0: int vp9_square_search(MACROBLOCK *x, michael@0: MV *ref_mv, michael@0: int search_param, michael@0: int error_per_bit, michael@0: int do_init_search, michael@0: const vp9_variance_fn_ptr_t *vf, michael@0: int use_mvcost, michael@0: const MV *center_mv, michael@0: MV *best_mv); michael@0: michael@0: typedef int (fractional_mv_step_fp) ( michael@0: MACROBLOCK *x, michael@0: MV *bestmv, const MV *ref_mv, michael@0: int allow_hp, michael@0: int error_per_bit, michael@0: const vp9_variance_fn_ptr_t *vfp, michael@0: int forced_stop, // 0 - full, 1 - qtr only, 2 - half only michael@0: int iters_per_step, michael@0: int *mvjcost, michael@0: int *mvcost[2], michael@0: int *distortion, michael@0: unsigned int *sse); michael@0: extern fractional_mv_step_fp vp9_find_best_sub_pixel_iterative; michael@0: extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree; michael@0: michael@0: typedef int (fractional_mv_step_comp_fp) ( michael@0: MACROBLOCK *x, michael@0: MV *bestmv, const MV *ref_mv, michael@0: int allow_hp, michael@0: int error_per_bit, michael@0: const vp9_variance_fn_ptr_t *vfp, michael@0: int forced_stop, // 0 - full, 1 - qtr only, 2 - half only michael@0: int iters_per_step, michael@0: int *mvjcost, int *mvcost[2], michael@0: int *distortion, unsigned int *sse1, michael@0: const uint8_t *second_pred, michael@0: int w, int h); michael@0: extern fractional_mv_step_comp_fp vp9_find_best_sub_pixel_comp_iterative; michael@0: extern fractional_mv_step_comp_fp vp9_find_best_sub_pixel_comp_tree; michael@0: michael@0: typedef int (*vp9_full_search_fn_t)(MACROBLOCK *x, michael@0: int_mv *ref_mv, int sad_per_bit, michael@0: int distance, vp9_variance_fn_ptr_t *fn_ptr, michael@0: int *mvjcost, int *mvcost[2], michael@0: int_mv *center_mv, int n); michael@0: michael@0: typedef int (*vp9_refining_search_fn_t)(MACROBLOCK *x, michael@0: int_mv *ref_mv, int sad_per_bit, michael@0: int distance, michael@0: vp9_variance_fn_ptr_t *fn_ptr, michael@0: int *mvjcost, int *mvcost[2], michael@0: int_mv *center_mv); michael@0: michael@0: typedef int (*vp9_diamond_search_fn_t)(MACROBLOCK *x, michael@0: int_mv *ref_mv, int_mv *best_mv, michael@0: int search_param, int sad_per_bit, michael@0: int *num00, michael@0: vp9_variance_fn_ptr_t *fn_ptr, michael@0: int *mvjcost, int *mvcost[2], michael@0: int_mv *center_mv); michael@0: michael@0: int vp9_refining_search_8p_c(MACROBLOCK *x, michael@0: int_mv *ref_mv, int error_per_bit, michael@0: int search_range, vp9_variance_fn_ptr_t *fn_ptr, michael@0: int *mvjcost, int *mvcost[2], michael@0: int_mv *center_mv, const uint8_t *second_pred, michael@0: int w, int h); michael@0: #endif // VP9_ENCODER_VP9_MCOMP_H_