1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | |
---|
35 | |
---|
36 | #ifndef __TCOMWEDGELET__ |
---|
37 | #define __TCOMWEDGELET__ |
---|
38 | |
---|
39 | // Include files |
---|
40 | #include <assert.h> |
---|
41 | #include "CommonDef.h" |
---|
42 | |
---|
43 | #include <vector> |
---|
44 | |
---|
45 | #if H_3D_DIM |
---|
46 | #define DIM_OFFSET (NUM_INTRA_MODE+1) // offset for DMM and RBC mode numbers (PM: not consistent with spec, but non-overlapping with chroma, see DM_CHROMA_IDX) |
---|
47 | #define DIM_MIN_SIZE 4 // min. block size for DMM and RBC modes |
---|
48 | #define DIM_MAX_SIZE 32 // max. block size for DMM and RBC modes |
---|
49 | |
---|
50 | enum DIM_IDX |
---|
51 | { |
---|
52 | DMM1_IDX = 0, |
---|
53 | DMM4_IDX = 1, |
---|
54 | }; |
---|
55 | |
---|
56 | #define DMM_NUM_TYPE 2 |
---|
57 | #define DIM_NUM_TYPE (DMM_NUM_TYPE) |
---|
58 | #define DIM_NO_IDX MAX_UINT |
---|
59 | |
---|
60 | __inline UInt getDimType ( Int intraMode ) |
---|
61 | { |
---|
62 | Int dimType = intraMode-DIM_OFFSET; |
---|
63 | return (dimType >= 0 && dimType < DIM_NUM_TYPE) ? (UInt)dimType : DIM_NO_IDX; |
---|
64 | } |
---|
65 | __inline Bool isDimMode ( Int intraMode ) { return (getDimType( intraMode ) < DIM_NUM_TYPE); } |
---|
66 | #endif |
---|
67 | |
---|
68 | #if H_3D_DIM_DMM |
---|
69 | #define DMM_NO_WEDGEINDEX MAX_UINT |
---|
70 | #define DMM_NUM_WEDGE_REFINES 8 |
---|
71 | |
---|
72 | enum WedgeResolution |
---|
73 | { |
---|
74 | FULL_PEL, |
---|
75 | HALF_PEL |
---|
76 | }; |
---|
77 | |
---|
78 | |
---|
79 | // ==================================================================================================================== |
---|
80 | // Class definition TComWedgelet |
---|
81 | // ==================================================================================================================== |
---|
82 | class TComWedgelet |
---|
83 | { |
---|
84 | private: |
---|
85 | UChar m_uhXs; // line start X pos |
---|
86 | UChar m_uhYs; // line start Y pos |
---|
87 | UChar m_uhXe; // line end X pos |
---|
88 | UChar m_uhYe; // line end Y pos |
---|
89 | UChar m_uhOri; // orientation index |
---|
90 | WedgeResolution m_eWedgeRes; // start/end pos resolution |
---|
91 | Bool m_bIsCoarse; |
---|
92 | UInt m_uiAng; |
---|
93 | |
---|
94 | UInt m_uiWidth; |
---|
95 | UInt m_uiHeight; |
---|
96 | |
---|
97 | Bool* m_pbPattern; |
---|
98 | Bool* m_pbScaledPattern; |
---|
99 | |
---|
100 | Void xGenerateWedgePattern(); |
---|
101 | Void xDrawEdgeLine( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, Bool* pbPattern, Int iPatternStride ); |
---|
102 | |
---|
103 | public: |
---|
104 | TComWedgelet( UInt uiWidth, UInt uiHeight ); |
---|
105 | TComWedgelet( const TComWedgelet &rcWedge ); |
---|
106 | virtual ~TComWedgelet(); |
---|
107 | |
---|
108 | Void create ( UInt iWidth, UInt iHeight ); ///< create wedgelet pattern |
---|
109 | Void destroy(); ///< destroy wedgelet pattern |
---|
110 | Void clear (); ///< clear wedgelet pattern |
---|
111 | |
---|
112 | UInt getWidth () { return m_uiWidth; } |
---|
113 | UInt getStride () { return m_uiWidth; } |
---|
114 | UInt getHeight () { return m_uiHeight; } |
---|
115 | WedgeResolution getWedgeRes() { return m_eWedgeRes; } |
---|
116 | Bool* getPattern () { return m_pbPattern; } |
---|
117 | UChar getStartX () { return m_uhXs; } |
---|
118 | UChar getStartY () { return m_uhYs; } |
---|
119 | UChar getEndX () { return m_uhXe; } |
---|
120 | UChar getEndY () { return m_uhYe; } |
---|
121 | UChar getOri () { return m_uhOri; } |
---|
122 | Bool getIsCoarse() { return m_bIsCoarse; } |
---|
123 | UInt getAng () { return m_uiAng; } |
---|
124 | Bool* getScaledPattern(UInt uiWidth); |
---|
125 | |
---|
126 | Void generateWedgePatternByRotate(const TComWedgelet &rcWedge, Int rotate); |
---|
127 | Void setWedgelet( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UChar uhOri, WedgeResolution eWedgeRes, Bool bIsCoarse = false ); |
---|
128 | Void findClosestAngle(); |
---|
129 | |
---|
130 | Bool checkNotPlain(); |
---|
131 | Bool checkIdentical( Bool* pbRefPattern ); |
---|
132 | Bool checkInvIdentical( Bool* pbRefPattern ); |
---|
133 | |
---|
134 | }; // END CLASS DEFINITION TComWedgelet |
---|
135 | |
---|
136 | // type definition wedgelet pattern list |
---|
137 | typedef std::vector<TComWedgelet> WedgeList; |
---|
138 | |
---|
139 | // ==================================================================================================================== |
---|
140 | // Class definition TComWedgeRef |
---|
141 | // ==================================================================================================================== |
---|
142 | class TComWedgeRef |
---|
143 | { |
---|
144 | private: |
---|
145 | UChar m_uhXs; // line start X pos |
---|
146 | UChar m_uhYs; // line start Y pos |
---|
147 | UChar m_uhXe; // line end X pos |
---|
148 | UChar m_uhYe; // line end Y pos |
---|
149 | UInt m_uiRefIdx; // index of corresponding pattern of TComWedgelet object in wedge list |
---|
150 | |
---|
151 | public: |
---|
152 | TComWedgeRef() {} |
---|
153 | virtual ~TComWedgeRef() {} |
---|
154 | |
---|
155 | UChar getStartX () { return m_uhXs; } |
---|
156 | UChar getStartY () { return m_uhYs; } |
---|
157 | UChar getEndX () { return m_uhXe; } |
---|
158 | UChar getEndY () { return m_uhYe; } |
---|
159 | UInt getRefIdx () { return m_uiRefIdx; } |
---|
160 | |
---|
161 | Void setWedgeRef( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UInt uiRefIdx ) { m_uhXs = uhXs; m_uhYs = uhYs; m_uhXe = uhXe; m_uhYe = uhYe; m_uiRefIdx = uiRefIdx; } |
---|
162 | }; // END CLASS DEFINITION TComWedgeRef |
---|
163 | |
---|
164 | // type definition wedgelet reference list |
---|
165 | typedef std::vector<TComWedgeRef> WedgeRefList; |
---|
166 | |
---|
167 | // ==================================================================================================================== |
---|
168 | // Class definition TComWedgeNode |
---|
169 | // ==================================================================================================================== |
---|
170 | class TComWedgeNode |
---|
171 | { |
---|
172 | private: |
---|
173 | UInt m_uiPatternIdx; |
---|
174 | UInt m_uiRefineIdx[DMM_NUM_WEDGE_REFINES]; |
---|
175 | |
---|
176 | public: |
---|
177 | TComWedgeNode(); |
---|
178 | virtual ~TComWedgeNode() {} |
---|
179 | |
---|
180 | UInt getPatternIdx(); |
---|
181 | UInt getRefineIdx ( UInt uiPos ); |
---|
182 | |
---|
183 | Void setPatternIdx( UInt uiIdx ); |
---|
184 | Void setRefineIdx ( UInt uiIdx, UInt uiPos ); |
---|
185 | }; // END CLASS DEFINITION TComWedgeNode |
---|
186 | |
---|
187 | // type definition wedgelet node list |
---|
188 | typedef std::vector<TComWedgeNode> WedgeNodeList; |
---|
189 | #endif //H_3D_DIM_DMM |
---|
190 | |
---|
191 | |
---|
192 | // ==================================================================================================================== |
---|
193 | // Function definition roftoi (mathematically correct rounding of float to int) |
---|
194 | // ==================================================================================================================== |
---|
195 | __inline Int roftoi( Double value ) |
---|
196 | { |
---|
197 | (value < -0.5) ? (value -= 0.5) : (value += 0.5); |
---|
198 | return ( (Int)value ); |
---|
199 | } |
---|
200 | #endif // __TCOMWEDGELET__ |
---|