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-2011, 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 | DMM3_IDX = 1, |
---|
54 | DMM4_IDX = 2, |
---|
55 | RBC_IDX = 3 |
---|
56 | }; |
---|
57 | |
---|
58 | #define DMM_NUM_TYPE 3 |
---|
59 | #define RBC_NUM_TYPE 1 |
---|
60 | #define DIM_NUM_TYPE (DMM_NUM_TYPE+RBC_NUM_TYPE) |
---|
61 | #define DIM_NO_IDX MAX_UINT |
---|
62 | |
---|
63 | __inline UInt getDimType ( Int intraMode ) { Int dimType = (intraMode-DIM_OFFSET)/2; return (dimType >= 0 && dimType < DIM_NUM_TYPE) ? (UInt)dimType : DIM_NO_IDX; } |
---|
64 | __inline Bool isDimMode ( Int intraMode ) { return (getDimType( intraMode ) < DIM_NUM_TYPE); } |
---|
65 | __inline Bool isDimDeltaDC( Int intraMode ) { return (isDimMode( intraMode ) && ((intraMode-DIM_OFFSET)%2) == 1); } |
---|
66 | #endif |
---|
67 | |
---|
68 | #if H_3D_DIM_RBC |
---|
69 | #define RBC_THRESHOLD 20 |
---|
70 | #define RBC_MAX_EDGE_NUM_PER_4x4 8 |
---|
71 | #define RBC_MAX_DISTANCE 255 |
---|
72 | #endif |
---|
73 | |
---|
74 | #if H_3D_DIM_DMM |
---|
75 | #define DMM_NO_WEDGEINDEX MAX_UINT |
---|
76 | #define DMM_NUM_WEDGE_REFINES 8 |
---|
77 | #define DMM3_SIMPLIFY_TR 1 |
---|
78 | |
---|
79 | enum WedgeResolution |
---|
80 | { |
---|
81 | DOUBLE_PEL, |
---|
82 | FULL_PEL, |
---|
83 | HALF_PEL |
---|
84 | }; |
---|
85 | |
---|
86 | |
---|
87 | // ==================================================================================================================== |
---|
88 | // Class definition TComWedgelet |
---|
89 | // ==================================================================================================================== |
---|
90 | class TComWedgelet |
---|
91 | { |
---|
92 | private: |
---|
93 | UChar m_uhXs; // line start X pos |
---|
94 | UChar m_uhYs; // line start Y pos |
---|
95 | UChar m_uhXe; // line end X pos |
---|
96 | UChar m_uhYe; // line end Y pos |
---|
97 | UChar m_uhOri; // orientation index |
---|
98 | WedgeResolution m_eWedgeRes; // start/end pos resolution |
---|
99 | Bool m_bIsCoarse; |
---|
100 | UInt m_uiAng; |
---|
101 | |
---|
102 | UInt m_uiWidth; |
---|
103 | UInt m_uiHeight; |
---|
104 | |
---|
105 | Bool* m_pbPattern; |
---|
106 | |
---|
107 | Void xGenerateWedgePattern(); |
---|
108 | Void xDrawEdgeLine( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, Bool* pbPattern, Int iPatternStride ); |
---|
109 | |
---|
110 | public: |
---|
111 | TComWedgelet( UInt uiWidth, UInt uiHeight ); |
---|
112 | TComWedgelet( const TComWedgelet &rcWedge ); |
---|
113 | virtual ~TComWedgelet(); |
---|
114 | |
---|
115 | Void create ( UInt iWidth, UInt iHeight ); ///< create wedgelet pattern |
---|
116 | Void destroy(); ///< destroy wedgelet pattern |
---|
117 | Void clear (); ///< clear wedgelet pattern |
---|
118 | |
---|
119 | UInt getWidth () { return m_uiWidth; } |
---|
120 | UInt getStride () { return m_uiWidth; } |
---|
121 | UInt getHeight () { return m_uiHeight; } |
---|
122 | WedgeResolution getWedgeRes() { return m_eWedgeRes; } |
---|
123 | Bool* getPattern () { return m_pbPattern; } |
---|
124 | UChar getStartX () { return m_uhXs; } |
---|
125 | UChar getStartY () { return m_uhYs; } |
---|
126 | UChar getEndX () { return m_uhXe; } |
---|
127 | UChar getEndY () { return m_uhYe; } |
---|
128 | UChar getOri () { return m_uhOri; } |
---|
129 | Bool getIsCoarse() { return m_bIsCoarse; } |
---|
130 | UInt getAng () { return m_uiAng; } |
---|
131 | |
---|
132 | Void setWedgelet( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UChar uhOri, WedgeResolution eWedgeRes, Bool bIsCoarse = false ); |
---|
133 | Void findClosestAngle(); |
---|
134 | |
---|
135 | Bool checkNotPlain(); |
---|
136 | Bool checkIdentical( Bool* pbRefPattern ); |
---|
137 | Bool checkInvIdentical( Bool* pbRefPattern ); |
---|
138 | |
---|
139 | }; // END CLASS DEFINITION TComWedgelet |
---|
140 | |
---|
141 | // type definition wedgelet pattern list |
---|
142 | typedef std::vector<TComWedgelet> WedgeList; |
---|
143 | |
---|
144 | // ==================================================================================================================== |
---|
145 | // Class definition TComWedgeRef |
---|
146 | // ==================================================================================================================== |
---|
147 | class TComWedgeRef |
---|
148 | { |
---|
149 | private: |
---|
150 | UChar m_uhXs; // line start X pos |
---|
151 | UChar m_uhYs; // line start Y pos |
---|
152 | UChar m_uhXe; // line end X pos |
---|
153 | UChar m_uhYe; // line end Y pos |
---|
154 | UInt m_uiRefIdx; // index of corresponding pattern of TComWedgelet object in wedge list |
---|
155 | |
---|
156 | public: |
---|
157 | TComWedgeRef() {} |
---|
158 | virtual ~TComWedgeRef() {} |
---|
159 | |
---|
160 | UChar getStartX () { return m_uhXs; } |
---|
161 | UChar getStartY () { return m_uhYs; } |
---|
162 | UChar getEndX () { return m_uhXe; } |
---|
163 | UChar getEndY () { return m_uhYe; } |
---|
164 | UInt getRefIdx () { return m_uiRefIdx; } |
---|
165 | |
---|
166 | 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; } |
---|
167 | }; // END CLASS DEFINITION TComWedgeRef |
---|
168 | |
---|
169 | // type definition wedgelet reference list |
---|
170 | typedef std::vector<TComWedgeRef> WedgeRefList; |
---|
171 | |
---|
172 | // ==================================================================================================================== |
---|
173 | // Class definition TComWedgeNode |
---|
174 | // ==================================================================================================================== |
---|
175 | class TComWedgeNode |
---|
176 | { |
---|
177 | private: |
---|
178 | UInt m_uiPatternIdx; |
---|
179 | UInt m_uiRefineIdx[DMM_NUM_WEDGE_REFINES]; |
---|
180 | |
---|
181 | public: |
---|
182 | TComWedgeNode(); |
---|
183 | virtual ~TComWedgeNode() {} |
---|
184 | |
---|
185 | UInt getPatternIdx(); |
---|
186 | UInt getRefineIdx ( UInt uiPos ); |
---|
187 | |
---|
188 | Void setPatternIdx( UInt uiIdx ); |
---|
189 | Void setRefineIdx ( UInt uiIdx, UInt uiPos ); |
---|
190 | }; // END CLASS DEFINITION TComWedgeNode |
---|
191 | |
---|
192 | // type definition wedgelet node list |
---|
193 | typedef std::vector<TComWedgeNode> WedgeNodeList; |
---|
194 | #endif //H_3D_DIM_DMM |
---|
195 | |
---|
196 | |
---|
197 | // ==================================================================================================================== |
---|
198 | // Function definition roftoi (mathematically correct rounding of float to int) |
---|
199 | // ==================================================================================================================== |
---|
200 | __inline Int roftoi( Double value ) |
---|
201 | { |
---|
202 | (value < -0.5) ? (value -= 0.5) : (value += 0.5); |
---|
203 | return ( (Int)value ); |
---|
204 | } |
---|
205 | #endif // __TCOMWEDGELET__ |
---|