1 | |
---|
2 | |
---|
3 | /** \file TComMv.h |
---|
4 | \brief motion vector class (header) |
---|
5 | */ |
---|
6 | |
---|
7 | #ifndef __TCOMMV__ |
---|
8 | #define __TCOMMV__ |
---|
9 | |
---|
10 | #include <math.h> |
---|
11 | #include "CommonDef.h" |
---|
12 | |
---|
13 | #include <cstdlib> |
---|
14 | using namespace std; |
---|
15 | |
---|
16 | // ==================================================================================================================== |
---|
17 | // Class definition |
---|
18 | // ==================================================================================================================== |
---|
19 | |
---|
20 | /// basic motion vector class |
---|
21 | class TComMv |
---|
22 | { |
---|
23 | private: |
---|
24 | Int m_iHor; ///< horizontal component of motion vector |
---|
25 | Int m_iVer; ///< vertical component of motion vector |
---|
26 | |
---|
27 | public: |
---|
28 | |
---|
29 | // ------------------------------------------------------------------------------------------------------------------ |
---|
30 | // constructors |
---|
31 | // ------------------------------------------------------------------------------------------------------------------ |
---|
32 | |
---|
33 | TComMv() : |
---|
34 | m_iHor(0), |
---|
35 | m_iVer(0) |
---|
36 | { |
---|
37 | } |
---|
38 | |
---|
39 | TComMv( Int iHor, Int iVer ) : |
---|
40 | m_iHor(iHor), |
---|
41 | m_iVer(iVer) |
---|
42 | { |
---|
43 | } |
---|
44 | |
---|
45 | // ------------------------------------------------------------------------------------------------------------------ |
---|
46 | // set |
---|
47 | // ------------------------------------------------------------------------------------------------------------------ |
---|
48 | |
---|
49 | Void set ( Int iHor, Int iVer) { m_iHor = iHor; m_iVer = iVer; } |
---|
50 | Void setHor ( Int i ) { m_iHor = i; } |
---|
51 | Void setVer ( Int i ) { m_iVer = i; } |
---|
52 | Void setZero () { m_iHor = m_iVer = 0; } |
---|
53 | |
---|
54 | // ------------------------------------------------------------------------------------------------------------------ |
---|
55 | // get |
---|
56 | // ------------------------------------------------------------------------------------------------------------------ |
---|
57 | |
---|
58 | Int getHor () { return m_iHor; } |
---|
59 | Int getVer () { return m_iVer; } |
---|
60 | Int getAbsHor () { return abs( m_iHor ); } |
---|
61 | Int getAbsVer () { return abs( m_iVer ); } |
---|
62 | |
---|
63 | // ------------------------------------------------------------------------------------------------------------------ |
---|
64 | // operations |
---|
65 | // ------------------------------------------------------------------------------------------------------------------ |
---|
66 | |
---|
67 | const TComMv& operator = (const TComMv& rcMv) |
---|
68 | { |
---|
69 | m_iHor = rcMv.m_iHor; |
---|
70 | m_iVer = rcMv.m_iVer; |
---|
71 | return *this; |
---|
72 | } |
---|
73 | |
---|
74 | const TComMv& operator += (const TComMv& rcMv) |
---|
75 | { |
---|
76 | m_iHor += rcMv.m_iHor; |
---|
77 | m_iVer += rcMv.m_iVer; |
---|
78 | return *this; |
---|
79 | } |
---|
80 | |
---|
81 | const TComMv& operator-= (const TComMv& rcMv) |
---|
82 | { |
---|
83 | m_iHor -= rcMv.m_iHor; |
---|
84 | m_iVer -= rcMv.m_iVer; |
---|
85 | return *this; |
---|
86 | } |
---|
87 | |
---|
88 | const TComMv& operator>>= (const Int i) |
---|
89 | { |
---|
90 | m_iHor >>= i; |
---|
91 | m_iVer >>= i; |
---|
92 | return *this; |
---|
93 | } |
---|
94 | |
---|
95 | const TComMv& operator<<= (const Int i) |
---|
96 | { |
---|
97 | m_iHor <<= i; |
---|
98 | m_iVer <<= i; |
---|
99 | return *this; |
---|
100 | } |
---|
101 | |
---|
102 | const TComMv operator - ( const TComMv& rcMv ) const |
---|
103 | { |
---|
104 | return TComMv( m_iHor - rcMv.m_iHor, m_iVer - rcMv.m_iVer ); |
---|
105 | } |
---|
106 | |
---|
107 | const TComMv operator + ( const TComMv& rcMv ) |
---|
108 | { |
---|
109 | return TComMv( m_iHor + rcMv.m_iHor, m_iVer + rcMv.m_iVer ); |
---|
110 | } |
---|
111 | |
---|
112 | Bool operator== ( const TComMv& rcMv ) |
---|
113 | { |
---|
114 | return (m_iHor==rcMv.m_iHor && m_iVer==rcMv.m_iVer); |
---|
115 | } |
---|
116 | |
---|
117 | Bool operator!= ( const TComMv& rcMv ) |
---|
118 | { |
---|
119 | return (m_iHor!=rcMv.m_iHor || m_iVer!=rcMv.m_iVer); |
---|
120 | } |
---|
121 | |
---|
122 | const TComMv scaleMv( Int iScale ) |
---|
123 | { |
---|
124 | return TComMv( (iScale * getHor() + 128) >> 8, (iScale * getVer() + 128) >> 8); |
---|
125 | } |
---|
126 | };// END CLASS DEFINITION TComMV |
---|
127 | |
---|
128 | |
---|
129 | #endif // __TCOMMV__ |
---|
130 | |
---|