/* * Copyright (c) 2016, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License * was not distributed with this source code in the LICENSE file, you can * obtain it at www.aomedia.org/license/software. If the Alliance for Open * Media Patent License 1.0 was not distributed with this source code in the * PATENTS file, you can obtain it at www.aomedia.org/license/patent. */ #ifndef AOM_AV1_COMMON_MV_H_ #define AOM_AV1_COMMON_MV_H_ #include <stdlib.h> #include "av1/common/common.h" #include "av1/common/common_data.h" #include "aom_dsp/aom_filter.h" #include "aom_dsp/flow_estimation/flow_estimation.h" #ifdef __cplusplus extern "C" { #endif #define INVALID_MV … #define INVALID_MV_ROW_COL … #define GET_MV_RAWPEL(x) … #define GET_MV_SUBPEL(x) … #define MARK_MV_INVALID(mv) … #define CHECK_MV_EQUAL(x, y) … // The motion vector in units of full pixel FULLPEL_MV; // The motion vector in units of 1/8-pel MV; static const MV kZeroMv = …; static const FULLPEL_MV kZeroFullMv = …; int_mv; /* facilitates faster equality tests and copies */ MV32; // The mv limit for fullpel mvs FullMvLimits; // The mv limit for subpel mvs SubpelMvLimits; static inline FULLPEL_MV get_fullmv_from_mv(const MV *subpel_mv) { … } static inline MV get_mv_from_fullmv(const FULLPEL_MV *full_mv) { … } static inline void convert_fullmv_to_mv(int_mv *mv) { … } // Bits of precision used for the model #define WARPEDMODEL_PREC_BITS … #define WARPEDMODEL_TRANS_CLAMP … #define WARPEDMODEL_NONDIAGAFFINE_CLAMP … // Bits of subpel precision for warped interpolation #define WARPEDPIXEL_PREC_BITS … #define WARPEDPIXEL_PREC_SHIFTS … #define WARP_PARAM_REDUCE_BITS … #define WARPEDDIFF_PREC_BITS … WarpTypesAllowed; // The order of values in the wmmat matrix below is best described // by the affine transformation: // [x' (m2 m3 m0 [x // z . y' = m4 m5 m1 * y // 1] 0 0 1) 1] WarpedMotionParams; /* clang-format off */ static const WarpedMotionParams default_warp_params = …; /* clang-format on */ // The following constants describe the various precisions // of different parameters in the global motion experiment. // // Given the general homography: // [x' (a b c [x // z . y' = d e f * y // 1] g h i) 1] // // Constants using the name ALPHA here are related to parameters // a, b, d, e. Constants using the name TRANS are related // to parameters c and f. // // Anything ending in PREC_BITS is the number of bits of precision // to maintain when converting from double to integer. // // The ABS parameters are used to create an upper and lower bound // for each parameter. In other words, after a parameter is integerized // it is clamped between -(1 << ABS_XXX_BITS) and (1 << ABS_XXX_BITS). // // XXX_PREC_DIFF and XXX_DECODE_FACTOR // are computed once here to prevent repetitive // computation on the decoder side. These are // to allow the global motion parameters to be encoded in a lower // precision than the warped model precision. This means that they // need to be changed to warped precision when they are decoded. // // XX_MIN, XX_MAX are also computed to avoid repeated computation #define SUBEXPFIN_K … #define GM_TRANS_PREC_BITS … #define GM_ABS_TRANS_BITS … #define GM_ABS_TRANS_ONLY_BITS … #define GM_TRANS_PREC_DIFF … #define GM_TRANS_ONLY_PREC_DIFF … #define GM_TRANS_DECODE_FACTOR … #define GM_TRANS_ONLY_DECODE_FACTOR … #define GM_ALPHA_PREC_BITS … #define GM_ABS_ALPHA_BITS … #define GM_ALPHA_PREC_DIFF … #define GM_ALPHA_DECODE_FACTOR … #define GM_TRANS_MAX … #define GM_ALPHA_MAX … #define GM_TRANS_MIN … #define GM_ALPHA_MIN … static inline int block_center_x(int mi_col, BLOCK_SIZE bs) { … } static inline int block_center_y(int mi_row, BLOCK_SIZE bs) { … } static inline int convert_to_trans_prec(int allow_hp, int coor) { … } static inline void integer_mv_precision(MV *mv) { … } // Convert a global motion vector into a motion vector at the centre of the // given block. // // The resulting motion vector will have three fractional bits of precision. If // allow_hp is zero, the bottom bit will always be zero. If CONFIG_AMVR and // is_integer is true, the bottom three bits will be zero (so the motion vector // represents an integer) static inline int_mv gm_get_motion_vector(const WarpedMotionParams *gm, int allow_hp, BLOCK_SIZE bsize, int mi_col, int mi_row, int is_integer) { … } static inline TransformationType get_wmtype(const WarpedMotionParams *gm) { … } CANDIDATE_MV; static inline int is_zero_mv(const MV *mv) { … } static inline int is_equal_mv(const MV *a, const MV *b) { … } static inline void clamp_mv(MV *mv, const SubpelMvLimits *mv_limits) { … } static inline void clamp_fullmv(FULLPEL_MV *mv, const FullMvLimits *mv_limits) { … } #ifdef __cplusplus } // extern "C" #endif #endif // AOM_AV1_COMMON_MV_H_