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-2016, 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 NH_3D |
---|
46 | #define DMM_OFFSET (NUM_INTRA_MODE+1) // offset for DMM and RBC mode numbers |
---|
47 | #define DMM_MIN_SIZE 4 // min. block size for DMM and RBC modes |
---|
48 | #define DMM_MAX_SIZE 32 // max. block size for DMM and RBC modes |
---|
49 | |
---|
50 | enum DmmID |
---|
51 | { |
---|
52 | DMM1_IDX = 0, |
---|
53 | DMM4_IDX = 1, |
---|
54 | NUM_DMM = 2, |
---|
55 | DMM_NO_IDX = MAX_UINT |
---|
56 | }; |
---|
57 | |
---|
58 | __inline DmmID getDmmType( Int intraMode ) |
---|
59 | { |
---|
60 | Int dmmType = intraMode-DMM_OFFSET; |
---|
61 | return (dmmType >= 0 && dmmType < NUM_DMM) ? (DmmID)dmmType : DMM_NO_IDX; |
---|
62 | } |
---|
63 | __inline Bool isDmmMode( Int intraMode ) { return ((UInt)getDmmType( intraMode ) < NUM_DMM); } |
---|
64 | |
---|
65 | |
---|
66 | // Wedgelets |
---|
67 | #define DMM_NO_WEDGE_IDX MAX_UINT |
---|
68 | #define DMM_NUM_WEDGE_REFINES 8 |
---|
69 | |
---|
70 | enum WedgeResolution |
---|
71 | { |
---|
72 | FULL_PEL, |
---|
73 | HALF_PEL |
---|
74 | }; |
---|
75 | |
---|
76 | |
---|
77 | // ==================================================================================================================== |
---|
78 | // Class definition TComWedgelet |
---|
79 | // ==================================================================================================================== |
---|
80 | class TComWedgelet |
---|
81 | { |
---|
82 | private: |
---|
83 | UChar m_uhXs; // line start X pos |
---|
84 | UChar m_uhYs; // line start Y pos |
---|
85 | UChar m_uhXe; // line end X pos |
---|
86 | UChar m_uhYe; // line end Y pos |
---|
87 | UChar m_uhOri; // orientation index |
---|
88 | WedgeResolution m_eWedgeRes; // start/end pos resolution |
---|
89 | Bool m_bIsCoarse; |
---|
90 | |
---|
91 | UInt m_uiWidth; |
---|
92 | UInt m_uiHeight; |
---|
93 | |
---|
94 | Bool* m_pbPattern; |
---|
95 | Bool* m_pbScaledPattern; |
---|
96 | |
---|
97 | Void xGenerateWedgePattern(); |
---|
98 | Void xDrawEdgeLine( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, Bool* pbPattern, Int iPatternStride ); |
---|
99 | |
---|
100 | public: |
---|
101 | TComWedgelet( UInt uiWidth, UInt uiHeight ); |
---|
102 | TComWedgelet( const TComWedgelet &rcWedge ); |
---|
103 | virtual ~TComWedgelet(); |
---|
104 | |
---|
105 | Void create ( UInt iWidth, UInt iHeight ); ///< create wedgelet pattern |
---|
106 | Void destroy(); ///< destroy wedgelet pattern |
---|
107 | Void clear (); ///< clear wedgelet pattern |
---|
108 | |
---|
109 | UInt getWidth () { return m_uiWidth; } |
---|
110 | UInt getStride () { return m_uiWidth; } |
---|
111 | UInt getHeight () { return m_uiHeight; } |
---|
112 | WedgeResolution getWedgeRes() { return m_eWedgeRes; } |
---|
113 | Bool* getPattern () { return m_pbPattern; } |
---|
114 | UChar getStartX () { return m_uhXs; } |
---|
115 | UChar getStartY () { return m_uhYs; } |
---|
116 | UChar getEndX () { return m_uhXe; } |
---|
117 | UChar getEndY () { return m_uhYe; } |
---|
118 | UChar getOri () { return m_uhOri; } |
---|
119 | Bool getIsCoarse() { return m_bIsCoarse; } |
---|
120 | |
---|
121 | Void generateWedgePatternByRotate(const TComWedgelet &rcWedge, Int rotate); |
---|
122 | Void setWedgelet( UChar uhXs, UChar uhYs, UChar uhXe, UChar uhYe, UChar uhOri, WedgeResolution eWedgeRes, Bool bIsCoarse = false ); |
---|
123 | |
---|
124 | Bool checkNotPlain(); |
---|
125 | Bool checkIdentical( Bool* pbRefPattern ); |
---|
126 | Bool checkInvIdentical( Bool* pbRefPattern ); |
---|
127 | |
---|
128 | Bool* getPatternScaled ( UInt dstSize ); |
---|
129 | Void getPatternScaledCopy( UInt dstSize, Bool* dstBuf ); |
---|
130 | |
---|
131 | }; // END CLASS DEFINITION TComWedgelet |
---|
132 | |
---|
133 | // type definition wedgelet pattern list |
---|
134 | typedef std::vector<TComWedgelet> WedgeList; |
---|
135 | |
---|
136 | // ==================================================================================================================== |
---|
137 | // Class definition TComWedgeRef |
---|
138 | // ==================================================================================================================== |
---|
139 | class TComWedgeRef |
---|
140 | { |
---|
141 | private: |
---|
142 | UChar m_uhXs; // line start X pos |
---|
143 | UChar m_uhYs; // line start Y pos |
---|
144 | UChar m_uhXe; // line end X pos |
---|
145 | UChar m_uhYe; // line end Y pos |
---|
146 | UInt m_uiRefIdx; // index of corresponding pattern of TComWedgelet object in wedge list |
---|
147 | |
---|
148 | public: |
---|
149 | TComWedgeRef() {} |
---|
150 | virtual ~TComWedgeRef() {} |
---|
151 | |
---|
152 | UChar getStartX () { return m_uhXs; } |
---|
153 | UChar getStartY () { return m_uhYs; } |
---|
154 | UChar getEndX () { return m_uhXe; } |
---|
155 | UChar getEndY () { return m_uhYe; } |
---|
156 | UInt getRefIdx () { return m_uiRefIdx; } |
---|
157 | |
---|
158 | 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; } |
---|
159 | }; // END CLASS DEFINITION TComWedgeRef |
---|
160 | |
---|
161 | |
---|
162 | // ==================================================================================================================== |
---|
163 | // Class definition TComWedgeNode |
---|
164 | // ==================================================================================================================== |
---|
165 | class TComWedgeNode |
---|
166 | { |
---|
167 | private: |
---|
168 | UInt m_uiPatternIdx; |
---|
169 | UInt m_uiRefineIdx[DMM_NUM_WEDGE_REFINES]; |
---|
170 | |
---|
171 | public: |
---|
172 | TComWedgeNode(); |
---|
173 | virtual ~TComWedgeNode() {} |
---|
174 | |
---|
175 | UInt getPatternIdx(); |
---|
176 | UInt getRefineIdx ( UInt uiPos ); |
---|
177 | |
---|
178 | Void setPatternIdx( UInt uiIdx ); |
---|
179 | Void setRefineIdx ( UInt uiIdx, UInt uiPos ); |
---|
180 | }; // END CLASS DEFINITION TComWedgeNode |
---|
181 | |
---|
182 | // type definition wedgelet node list |
---|
183 | typedef std::vector<TComWedgeNode> WedgeNodeList; |
---|
184 | #endif //NH_3D |
---|
185 | |
---|
186 | #endif // __TCOMWEDGELET__ |
---|