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 | /** \file TComPattern.h |
---|
37 | \brief neighbouring pixel access classes (header) |
---|
38 | */ |
---|
39 | |
---|
40 | #ifndef __TCOMPATTERN__ |
---|
41 | #define __TCOMPATTERN__ |
---|
42 | |
---|
43 | // Include files |
---|
44 | #include <stdio.h> |
---|
45 | #include "CommonDef.h" |
---|
46 | |
---|
47 | // ==================================================================================================================== |
---|
48 | // Class definition |
---|
49 | // ==================================================================================================================== |
---|
50 | |
---|
51 | class TComDataCU; |
---|
52 | |
---|
53 | /// neighbouring pixel access class for one component |
---|
54 | class TComPatternParam |
---|
55 | { |
---|
56 | private: |
---|
57 | Int m_iOffsetLeft; |
---|
58 | Int m_iOffsetRight; |
---|
59 | Int m_iOffsetAbove; |
---|
60 | Int m_iOffsetBottom; |
---|
61 | Pel* m_piPatternOrigin; |
---|
62 | |
---|
63 | public: |
---|
64 | Int m_iROIWidth; |
---|
65 | Int m_iROIHeight; |
---|
66 | Int m_iPatternStride; |
---|
67 | |
---|
68 | /// return starting position of buffer |
---|
69 | Pel* getPatternOrigin() { return m_piPatternOrigin; } |
---|
70 | |
---|
71 | /// return starting position of ROI (ROI = &pattern[AboveOffset][LeftOffset]) |
---|
72 | __inline Pel* getROIOrigin() |
---|
73 | { |
---|
74 | return m_piPatternOrigin + m_iPatternStride * m_iOffsetAbove + m_iOffsetLeft; |
---|
75 | } |
---|
76 | |
---|
77 | /// set parameters from Pel buffer for accessing neighbouring pixels |
---|
78 | Void setPatternParamPel ( Pel* piTexture, |
---|
79 | Int iRoiWidth, |
---|
80 | Int iRoiHeight, |
---|
81 | Int iStride, |
---|
82 | Int iOffsetLeft, |
---|
83 | Int iOffsetRight, |
---|
84 | Int iOffsetAbove, |
---|
85 | Int iOffsetBottom ); |
---|
86 | |
---|
87 | /// set parameters of one color component from CU data for accessing neighbouring pixels |
---|
88 | Void setPatternParamCU ( TComDataCU* pcCU, |
---|
89 | UChar iComp, |
---|
90 | UChar iRoiWidth, |
---|
91 | UChar iRoiHeight, |
---|
92 | Int iOffsetLeft, |
---|
93 | Int iOffsetRight, |
---|
94 | Int iOffsetAbove, |
---|
95 | Int iOffsetBottom, |
---|
96 | UInt uiPartDepth, |
---|
97 | UInt uiAbsZorderIdx |
---|
98 | #if DEPTH_MAP_GENERATION |
---|
99 | ,Bool bPrdDepthMap = false |
---|
100 | #endif |
---|
101 | ); |
---|
102 | }; |
---|
103 | |
---|
104 | /// neighbouring pixel access class for all components |
---|
105 | class TComPattern |
---|
106 | { |
---|
107 | private: |
---|
108 | TComPatternParam m_cPatternY; |
---|
109 | TComPatternParam m_cPatternCb; |
---|
110 | TComPatternParam m_cPatternCr; |
---|
111 | #if MN_DC_PRED_FILTER |
---|
112 | Bool m_bAboveFlagForDCFilt; |
---|
113 | Bool m_bLeftFlagForDCFilt; |
---|
114 | Bool m_bDCPredFilterFlag; |
---|
115 | #endif |
---|
116 | |
---|
117 | #if LM_CHROMA |
---|
118 | Bool m_bLeftAvailable; |
---|
119 | Bool m_bAboveAvailable; |
---|
120 | #endif |
---|
121 | |
---|
122 | public: |
---|
123 | |
---|
124 | // ROI & pattern information, (ROI = &pattern[AboveOffset][LeftOffset]) |
---|
125 | Pel* getROIY() { return m_cPatternY.getROIOrigin(); } |
---|
126 | Int getROIYWidth() { return m_cPatternY.m_iROIWidth; } |
---|
127 | Int getROIYHeight() { return m_cPatternY.m_iROIHeight; } |
---|
128 | Int getPatternLStride() { return m_cPatternY.m_iPatternStride; } |
---|
129 | #if MN_DC_PRED_FILTER |
---|
130 | Bool getDCPredFilterFlag() { return m_bDCPredFilterFlag; } |
---|
131 | #endif |
---|
132 | |
---|
133 | // access functions of ADI buffers |
---|
134 | Int* getAdiOrgBuf ( Int iCuWidth, Int iCuHeight, Int* piAdiBuf ); |
---|
135 | Int* getAdiCbBuf ( Int iCuWidth, Int iCuHeight, Int* piAdiBuf ); |
---|
136 | Int* getAdiCrBuf ( Int iCuWidth, Int iCuHeight, Int* piAdiBuf ); |
---|
137 | |
---|
138 | #if QC_MDIS |
---|
139 | Int* getPredictorPtr ( UInt uiDirMode, UInt uiWidthBits, Int iCuWidth, Int iCuHeight, Int* piAdiBuf ); |
---|
140 | #endif //QC_MDIS |
---|
141 | // ------------------------------------------------------------------------------------------------------------------- |
---|
142 | // initialization functions |
---|
143 | // ------------------------------------------------------------------------------------------------------------------- |
---|
144 | |
---|
145 | /// set parameters from Pel buffers for accessing neighbouring pixels |
---|
146 | Void initPattern ( Pel* piY, |
---|
147 | Pel* piCb, |
---|
148 | Pel* piCr, |
---|
149 | Int iRoiWidth, |
---|
150 | Int iRoiHeight, |
---|
151 | Int iStride, |
---|
152 | Int iOffsetLeft, |
---|
153 | Int iOffsetRight, |
---|
154 | Int iOffsetAbove, |
---|
155 | Int iOffsetBottom ); |
---|
156 | |
---|
157 | /// set parameters from CU data for accessing neighbouring pixels |
---|
158 | Void initPattern ( TComDataCU* pcCU, |
---|
159 | UInt uiPartDepth, |
---|
160 | UInt uiAbsPartIdx |
---|
161 | #if DEPTH_MAP_GENERATION |
---|
162 | ,Bool bPrdDepthMap = false |
---|
163 | #endif |
---|
164 | ); |
---|
165 | |
---|
166 | /// set luma parameters from CU data for accessing ADI data |
---|
167 | Void initAdiPattern ( TComDataCU* pcCU, |
---|
168 | UInt uiZorderIdxInPart, |
---|
169 | UInt uiPartDepth, |
---|
170 | Int* piAdiBuf, |
---|
171 | Int iOrgBufStride, |
---|
172 | Int iOrgBufHeight, |
---|
173 | Bool& bAbove, |
---|
174 | Bool& bLeft |
---|
175 | #if DEPTH_MAP_GENERATION |
---|
176 | ,Bool bPrdDepthMap = false |
---|
177 | #endif |
---|
178 | ); |
---|
179 | |
---|
180 | /// set chroma parameters from CU data for accessing ADI data |
---|
181 | Void initAdiPatternChroma ( TComDataCU* pcCU, |
---|
182 | UInt uiZorderIdxInPart, |
---|
183 | UInt uiPartDepth, |
---|
184 | Int* piAdiBuf, |
---|
185 | Int iOrgBufStride, |
---|
186 | Int iOrgBufHeight, |
---|
187 | Bool& bAbove, |
---|
188 | Bool& bLeft ); |
---|
189 | |
---|
190 | #if LM_CHROMA |
---|
191 | Bool isLeftAvailable() { return m_bLeftAvailable; } |
---|
192 | Bool isAboveAvailable() { return m_bAboveAvailable; } |
---|
193 | #endif |
---|
194 | |
---|
195 | #if (CONSTRAINED_INTRA_PRED || REFERENCE_SAMPLE_PADDING) |
---|
196 | private: |
---|
197 | |
---|
198 | #if REFERENCE_SAMPLE_PADDING |
---|
199 | /// padding of unavailable reference samples for intra prediction |
---|
200 | Void fillReferenceSamples ( TComDataCU* pcCU, Pel* piRoiOrigin, Int* piAdiTemp, Bool* bNeighborFlags, Int iNumIntraNeighbor, Int iUnitSize, Int iNumUnitsInCu, Int iTotalUnits, UInt uiCuWidth, UInt uiCuHeight, UInt uiWidth, UInt uiHeight, Int iPicStride |
---|
201 | #if DEPTH_MAP_GENERATION |
---|
202 | , Bool bPrdDepthMap |
---|
203 | #endif |
---|
204 | ); |
---|
205 | #endif |
---|
206 | #if CONSTRAINED_INTRA_PRED |
---|
207 | /// constrained intra prediction |
---|
208 | Bool isAboveLeftAvailableForCIP ( TComDataCU* pcCU, UInt uiPartIdxLT ); |
---|
209 | #if REFERENCE_SAMPLE_PADDING |
---|
210 | Int isAboveAvailableForCIP ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool* bValidFlags ); |
---|
211 | Int isLeftAvailableForCIP ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool* bValidFlags ); |
---|
212 | Int isAboveRightAvailableForCIP ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool* bValidFlags ); |
---|
213 | Int isBelowLeftAvailableForCIP ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool* bValidFlags ); |
---|
214 | #else |
---|
215 | Bool isAboveAvailableForCIP ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT ); |
---|
216 | Bool isLeftAvailableForCIP ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB ); |
---|
217 | Bool isAboveRightAvailableForCIP ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT ); |
---|
218 | Bool isBelowLeftAvailableForCIP ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB ); |
---|
219 | #endif |
---|
220 | #endif // CONSTRAINED_INTRA_PRED |
---|
221 | #endif |
---|
222 | }; |
---|
223 | |
---|
224 | #endif // __TCOMPATTERN__ |
---|
225 | |
---|