/* * Copyright (c) 2012 The WebM project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef VPX_VP9_COMMON_VP9_MVREF_COMMON_H_ #define VPX_VP9_COMMON_VP9_MVREF_COMMON_H_ #include "vp9/common/vp9_onyxc_int.h" #include "vp9/common/vp9_blockd.h" #ifdef __cplusplus extern "C" { #endif #define LEFT_TOP_MARGIN … #define RIGHT_BOTTOM_MARGIN … #define MVREF_NEIGHBOURS … POSITION; motion_vector_context; // This is used to figure out a context for the ref blocks. The code flattens // an array that would have 3 possible counts (0, 1 & 2) for 3 choices by // adding 9 for each intra block, 3 for each zero mv and 1 for each new // motion vector. This single number is then converted into a context // with a single lookup ( counter_to_context ). static const int mode_2_counter[MB_MODE_COUNT] = …; // There are 3^3 different combinations of 3 counts that can be either 0,1 or // 2. However the actual count can never be greater than 2 so the highest // counter we need is 18. 9 is an invalid counter that's never used. static const int counter_to_context[19] = …; static const POSITION mv_ref_blocks[BLOCK_SIZES][MVREF_NEIGHBOURS] = …; static const int idx_n_column_to_subblock[4][2] = …; // clamp_mv_ref #define MV_BORDER … static INLINE void clamp_mv_ref(MV *mv, const MACROBLOCKD *xd) { … } // This function returns either the appropriate sub block or block's mv // on whether the block_size < 8x8 and we have check_sub_blocks set. static INLINE int_mv get_sub_block_mv(const MODE_INFO *candidate, int which_mv, int search_col, int block_idx) { … } // Performs mv sign inversion if indicated by the reference frame combination. static INLINE int_mv scale_mv(const MODE_INFO *mi, int ref, const MV_REFERENCE_FRAME this_ref_frame, const int *ref_sign_bias) { … } // This macro is used to add a motion vector mv_ref list if it isn't // already in the list. If it's the second motion vector it will also // skip all additional processing and jump to Done! #define ADD_MV_REF_LIST(mv, refmv_count, mv_ref_list, Done) … // If either reference frame is different, not INTRA, and they // are different from each other scale and add the mv to our list. #define IF_DIFF_REF_FRAME_ADD_MV(mbmi, ref_frame, ref_sign_bias, refmv_count, \ mv_ref_list, Done) … // Checks that the given mi_row, mi_col and search point // are inside the borders of the tile. static INLINE int is_inside(const TileInfo *const tile, int mi_col, int mi_row, int mi_rows, const POSITION *mi_pos) { … } // TODO(jingning): this mv clamping function should be block size dependent. static INLINE void clamp_mv2(MV *mv, const MACROBLOCKD *xd) { … } static INLINE void lower_mv_precision(MV *mv, int allow_hp) { … } find_mv_refs_sync; void vp9_find_mv_refs(const VP9_COMMON *cm, const MACROBLOCKD *xd, MODE_INFO *mi, MV_REFERENCE_FRAME ref_frame, int_mv *mv_ref_list, int mi_row, int mi_col, uint8_t *mode_context); // check a list of motion vectors by sad score using a number rows of pixels // above and a number cols of pixels in the left to select the one with best // score to use as ref motion vector void vp9_find_best_ref_mvs(MACROBLOCKD *xd, int allow_hp, int_mv *mvlist, int_mv *nearest_mv, int_mv *near_mv); void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd, int block, int ref, int mi_row, int mi_col, int_mv *nearest_mv, int_mv *near_mv, uint8_t *mode_context); #ifdef __cplusplus } // extern "C" #endif #endif // VPX_VP9_COMMON_VP9_MVREF_COMMON_H_