1ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang/*
2ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang *
4ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang *  Use of this source code is governed by a BSD-style license
5ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang *  that can be found in the LICENSE file in the root of the source
6ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang *  tree. An additional intellectual property rights grant can be found
7ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang *  in the file PATENTS.  All contributing project authors may
8ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang *  be found in the AUTHORS file in the root of the source tree.
9ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */
10ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
11ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#ifndef VP9_COMMON_VP9_MV_H_
12ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#define VP9_COMMON_VP9_MV_H_
13ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
14ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#include "vpx/vpx_integer.h"
15ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
16f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang#include "vp9/common/vp9_common.h"
17f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang
18b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#ifdef __cplusplus
19b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanianextern "C" {
20b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#endif
21b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian
22b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramaniantypedef struct mv {
23ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int16_t row;
24ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int16_t col;
25ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang} MV;
26ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
27ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuangtypedef union int_mv {
28ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  uint32_t as_int;
29ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  MV as_mv;
30ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang} int_mv; /* facilitates faster equality tests and copies */
31ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
32b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramaniantypedef struct mv32 {
33ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int32_t row;
34ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int32_t col;
3591037db265ecdd914a26e056cf69207b4f50924ehkuang} MV32;
36ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
37b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanianstatic INLINE void clamp_mv(MV *mv, int min_col, int max_col,
38b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian                            int min_row, int max_row) {
39f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang  mv->col = clamp(mv->col, min_col, max_col);
40f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang  mv->row = clamp(mv->row, min_row, max_row);
41f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang}
42f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang
43b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#ifdef __cplusplus
44b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian}  // extern "C"
45b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#endif
46b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian
47ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#endif  // VP9_COMMON_VP9_MV_H_
48