mv.h 1.51 KB
Newer Older
Jingning Han's avatar
Jingning Han committed
1
/*
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Jingning Han's avatar
Jingning Han committed
3
 *
4 5 6 7 8 9
 * 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.
Jingning Han's avatar
Jingning Han committed
10 11
 */

12 13
#ifndef AV1_COMMON_MV_H_
#define AV1_COMMON_MV_H_
Jingning Han's avatar
Jingning Han committed
14

Adrian Grange's avatar
Adrian Grange committed
15
#include "aom/aom_integer.h"
Jingning Han's avatar
Jingning Han committed
16

Yaowu Xu's avatar
Yaowu Xu committed
17
#include "av1/common/common.h"
Jingning Han's avatar
Jingning Han committed
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

#ifdef __cplusplus
extern "C" {
#endif

typedef struct mv {
  int16_t row;
  int16_t col;
} MV;

typedef union int_mv {
  uint32_t as_int;
  MV as_mv;
} int_mv; /* facilitates faster equality tests and copies */

typedef struct mv32 {
  int32_t row;
  int32_t col;
} MV32;

38 39 40
#if CONFIG_REF_MV
typedef struct candidate_mv {
  int_mv this_mv;
41
  int_mv comp_mv;
42
  int_mv pred_mv;
43 44 45 46
  int weight;
} CANDIDATE_MV;
#endif

Jingning Han's avatar
Jingning Han committed
47 48 49 50 51
static INLINE int is_zero_mv(const MV *mv) {
  return *((const uint32_t *)mv) == 0;
}

static INLINE int is_equal_mv(const MV *a, const MV *b) {
clang-format's avatar
clang-format committed
52
  return *((const uint32_t *)a) == *((const uint32_t *)b);
Jingning Han's avatar
Jingning Han committed
53 54
}

clang-format's avatar
clang-format committed
55 56
static INLINE void clamp_mv(MV *mv, int min_col, int max_col, int min_row,
                            int max_row) {
Jingning Han's avatar
Jingning Han committed
57 58 59 60 61 62 63 64
  mv->col = clamp(mv->col, min_col, max_col);
  mv->row = clamp(mv->row, min_row, max_row);
}

#ifdef __cplusplus
}  // extern "C"
#endif

65
#endif  // AV1_COMMON_MV_H_