Home | History | Annotate | Download | only in encoder
      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 
     11 
     12 #ifndef VP9_ENCODER_VP9_MCOMP_H_
     13 #define VP9_ENCODER_VP9_MCOMP_H_
     14 
     15 #include "vp9/encoder/vp9_block.h"
     16 #include "vp9/encoder/vp9_variance.h"
     17 
     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))
     25 // Allowed motion vector pixel distance outside image border
     26 // for Block_16x16
     27 #define BORDER_MV_PIXELS_B16 (16 + VP9_INTERP_EXTEND)
     28 
     29 
     30 void vp9_clamp_mv_min_max(MACROBLOCK *x, MV *mv);
     31 int vp9_mv_bit_cost(const MV *mv, const MV *ref,
     32                     const int *mvjcost, int *mvcost[2], int weight);
     33 void vp9_init_dsmotion_compensation(MACROBLOCK *x, int stride);
     34 void vp9_init3smotion_compensation(MACROBLOCK *x,  int stride);
     35 
     36 struct VP9_COMP;
     37 int vp9_init_search_range(struct VP9_COMP *cpi, int size);
     38 
     39 // Runs sequence of diamond searches in smaller steps for RD
     40 int vp9_full_pixel_diamond(struct VP9_COMP *cpi, MACROBLOCK *x,
     41                            int_mv *mvp_full, int step_param,
     42                            int sadpb, int further_steps, int do_refine,
     43                            vp9_variance_fn_ptr_t *fn_ptr,
     44                            int_mv *ref_mv, int_mv *dst_mv);
     45 
     46 int vp9_hex_search(MACROBLOCK *x,
     47                    MV *ref_mv,
     48                    int search_param,
     49                    int error_per_bit,
     50                    int do_init_search,
     51                    const vp9_variance_fn_ptr_t *vf,
     52                    int use_mvcost,
     53                    const MV *center_mv,
     54                    MV *best_mv);
     55 int vp9_bigdia_search(MACROBLOCK *x,
     56                       MV *ref_mv,
     57                       int search_param,
     58                       int error_per_bit,
     59                       int do_init_search,
     60                       const vp9_variance_fn_ptr_t *vf,
     61                       int use_mvcost,
     62                       const MV *center_mv,
     63                       MV *best_mv);
     64 int vp9_square_search(MACROBLOCK *x,
     65                       MV *ref_mv,
     66                       int search_param,
     67                       int error_per_bit,
     68                       int do_init_search,
     69                       const vp9_variance_fn_ptr_t *vf,
     70                       int use_mvcost,
     71                       const MV *center_mv,
     72                       MV *best_mv);
     73 
     74 typedef int (fractional_mv_step_fp) (
     75     MACROBLOCK *x,
     76     MV *bestmv, const MV *ref_mv,
     77     int allow_hp,
     78     int error_per_bit,
     79     const vp9_variance_fn_ptr_t *vfp,
     80     int forced_stop,  // 0 - full, 1 - qtr only, 2 - half only
     81     int iters_per_step,
     82     int *mvjcost,
     83     int *mvcost[2],
     84     int *distortion,
     85     unsigned int *sse);
     86 extern fractional_mv_step_fp vp9_find_best_sub_pixel_iterative;
     87 extern fractional_mv_step_fp vp9_find_best_sub_pixel_tree;
     88 
     89 typedef int (fractional_mv_step_comp_fp) (
     90     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 *mvjcost, int *mvcost[2],
     98     int *distortion, unsigned int *sse1,
     99     const uint8_t *second_pred,
    100     int w, int h);
    101 extern fractional_mv_step_comp_fp vp9_find_best_sub_pixel_comp_iterative;
    102 extern fractional_mv_step_comp_fp vp9_find_best_sub_pixel_comp_tree;
    103 
    104 typedef int (*vp9_full_search_fn_t)(MACROBLOCK *x,
    105                                     int_mv *ref_mv, int sad_per_bit,
    106                                     int distance, vp9_variance_fn_ptr_t *fn_ptr,
    107                                     int *mvjcost, int *mvcost[2],
    108                                     int_mv *center_mv, int n);
    109 
    110 typedef int (*vp9_refining_search_fn_t)(MACROBLOCK *x,
    111                                         int_mv *ref_mv, int sad_per_bit,
    112                                         int distance,
    113                                         vp9_variance_fn_ptr_t *fn_ptr,
    114                                         int *mvjcost, int *mvcost[2],
    115                                         int_mv *center_mv);
    116 
    117 typedef int (*vp9_diamond_search_fn_t)(MACROBLOCK *x,
    118                                        int_mv *ref_mv, int_mv *best_mv,
    119                                        int search_param, int sad_per_bit,
    120                                        int *num00,
    121                                        vp9_variance_fn_ptr_t *fn_ptr,
    122                                        int *mvjcost, int *mvcost[2],
    123                                        int_mv *center_mv);
    124 
    125 int vp9_refining_search_8p_c(MACROBLOCK *x,
    126                              int_mv *ref_mv, int error_per_bit,
    127                              int search_range, vp9_variance_fn_ptr_t *fn_ptr,
    128                              int *mvjcost, int *mvcost[2],
    129                              int_mv *center_mv, const uint8_t *second_pred,
    130                              int w, int h);
    131 #endif  // VP9_ENCODER_VP9_MCOMP_H_
    132