1 | |
---|
2 | |
---|
3 | /** \file TComPattern.cpp |
---|
4 | \brief neighbouring pixel access classes |
---|
5 | */ |
---|
6 | |
---|
7 | #include "TComPic.h" |
---|
8 | #include "TComPattern.h" |
---|
9 | #include "TComDataCU.h" |
---|
10 | |
---|
11 | // ==================================================================================================================== |
---|
12 | // Tables |
---|
13 | // ==================================================================================================================== |
---|
14 | |
---|
15 | const UChar g_aaucAvailableBlkMask[16][8] = |
---|
16 | { |
---|
17 | // 4x4 block neighbor availability // MB neighbor availability |
---|
18 | {0x0,0x0,0x0,0x0, 0x0,0x8,0x0,0x08 }, // L, A, AL, AR <== WTF (blkIdx < 8) |
---|
19 | {0x1,0x0,0x0,0x0, 0x1,0x8,0x0,0x08 }, // A, AL, AR |
---|
20 | {0xA,0xE,0xE,0x6, 0x0,0x8,0x0,0x08 }, // L, AL, AR |
---|
21 | {0xB,0xE,0xE,0x6, 0x1,0x8,0x0,0x08 }, // AL, AR |
---|
22 | |
---|
23 | {0x4,0x0,0x0,0x0, 0x0,0x8,0x0,0x08 }, // L, A, AR |
---|
24 | {0x5,0x0,0x0,0x0, 0x1,0x8,0x0,0x08 }, // A, AR |
---|
25 | {0xE,0xE,0xE,0x6, 0x0,0x8,0x0,0x08 }, // L, AR |
---|
26 | {0xF,0xE,0xE,0x6, 0x1,0x8,0x0,0x08 }, // AR |
---|
27 | |
---|
28 | {0x0,0x0,0x0,0x8, 0x0,0x8,0x0,0x08 }, // L, A, AL <== WTF (blkIdx < 8 || blkIdx >= 8) |
---|
29 | {0x1,0x0,0x0,0x8, 0x1,0x8,0x0,0x08 }, // A, AL |
---|
30 | {0xA,0xE,0xE,0xE, 0x0,0x8,0x0,0x08 }, // L, AL |
---|
31 | {0xB,0xE,0xE,0xE, 0x1,0x8,0x0,0x08 }, // AL |
---|
32 | |
---|
33 | {0x4,0x0,0x0,0x8, 0x0,0x8,0x0,0x08 }, // L, A, |
---|
34 | {0x5,0x0,0x0,0x8, 0x1,0x8,0x0,0x08 }, // A, |
---|
35 | {0xE,0xE,0xE,0xE, 0x0,0x8,0x0,0x08 }, // L, |
---|
36 | {0xF,0xE,0xE,0xE, 0x1,0x8,0x0,0x08 } // |
---|
37 | }; |
---|
38 | |
---|
39 | // ==================================================================================================================== |
---|
40 | // Public member functions (TComPatternParam) |
---|
41 | // ==================================================================================================================== |
---|
42 | |
---|
43 | /** \param piTexture pixel data |
---|
44 | \param iRoiWidth pattern width |
---|
45 | \param iRoiHeight pattern height |
---|
46 | \param iStride buffer stride |
---|
47 | \param iOffsetLeft neighbour offset (left) |
---|
48 | \param iOffsetRight neighbour offset (right) |
---|
49 | \param iOffsetAbove neighbour offset (above) |
---|
50 | \param iOffsetBottom neighbour offset (bottom) |
---|
51 | */ |
---|
52 | Void TComPatternParam::setPatternParamPel ( Pel* piTexture, |
---|
53 | Int iRoiWidth, |
---|
54 | Int iRoiHeight, |
---|
55 | Int iStride, |
---|
56 | Int iOffsetLeft, |
---|
57 | Int iOffsetRight, |
---|
58 | Int iOffsetAbove, |
---|
59 | Int iOffsetBottom ) |
---|
60 | { |
---|
61 | m_piPatternOrigin = piTexture; |
---|
62 | m_iROIWidth = iRoiWidth; |
---|
63 | m_iROIHeight = iRoiHeight; |
---|
64 | m_iPatternStride = iStride; |
---|
65 | m_iOffsetLeft = iOffsetLeft; |
---|
66 | m_iOffsetAbove = iOffsetAbove; |
---|
67 | m_iOffsetRight = iOffsetRight; |
---|
68 | m_iOffsetBottom = iOffsetBottom; |
---|
69 | } |
---|
70 | |
---|
71 | /** |
---|
72 | \param pcCU CU data structure |
---|
73 | \param iComp component index (0=Y, 1=Cb, 2=Cr) |
---|
74 | \param iRoiWidth pattern width |
---|
75 | \param iRoiHeight pattern height |
---|
76 | \param iStride buffer stride |
---|
77 | \param iOffsetLeft neighbour offset (left) |
---|
78 | \param iOffsetRight neighbour offset (right) |
---|
79 | \param iOffsetAbove neighbour offset (above) |
---|
80 | \param iOffsetBottom neighbour offset (bottom) |
---|
81 | \param uiPartDepth CU depth |
---|
82 | \param uiAbsPartIdx part index |
---|
83 | */ |
---|
84 | Void TComPatternParam::setPatternParamCU( TComDataCU* pcCU, |
---|
85 | UChar iComp, |
---|
86 | UChar iRoiWidth, |
---|
87 | UChar iRoiHeight, |
---|
88 | Int iOffsetLeft, |
---|
89 | Int iOffsetRight, |
---|
90 | Int iOffsetAbove, |
---|
91 | Int iOffsetBottom, |
---|
92 | UInt uiPartDepth, |
---|
93 | UInt uiAbsPartIdx, |
---|
94 | Bool bPrdDepthMap ) |
---|
95 | { |
---|
96 | m_iOffsetLeft = iOffsetLeft; |
---|
97 | m_iOffsetRight = iOffsetRight; |
---|
98 | m_iOffsetAbove = iOffsetAbove; |
---|
99 | m_iOffsetBottom = iOffsetBottom; |
---|
100 | |
---|
101 | m_iROIWidth = iRoiWidth; |
---|
102 | m_iROIHeight = iRoiHeight; |
---|
103 | |
---|
104 | UInt uiAbsZorderIdx = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
105 | |
---|
106 | TComPicYuv* pcPic = ( bPrdDepthMap ? pcCU->getPic()->getPredDepthMap() : pcCU->getPic()->getPicYuvRec() ); |
---|
107 | if ( iComp == 0 ) |
---|
108 | { |
---|
109 | m_iPatternStride = pcCU->getPic()->getStride(); |
---|
110 | m_piPatternOrigin = pcPic->getLumaAddr(pcCU->getAddr(), uiAbsZorderIdx) - m_iOffsetAbove * m_iPatternStride - m_iOffsetLeft; |
---|
111 | } |
---|
112 | else |
---|
113 | { |
---|
114 | m_iPatternStride = pcCU->getPic()->getCStride(); |
---|
115 | if ( iComp == 1 ) |
---|
116 | m_piPatternOrigin = pcPic->getCbAddr(pcCU->getAddr(), uiAbsZorderIdx) - m_iOffsetAbove * m_iPatternStride - m_iOffsetLeft; |
---|
117 | else |
---|
118 | m_piPatternOrigin = pcPic->getCrAddr(pcCU->getAddr(), uiAbsZorderIdx) - m_iOffsetAbove * m_iPatternStride - m_iOffsetLeft; |
---|
119 | } |
---|
120 | } |
---|
121 | |
---|
122 | // ==================================================================================================================== |
---|
123 | // Public member functions (TComPattern) |
---|
124 | // ==================================================================================================================== |
---|
125 | |
---|
126 | Void TComPattern::initPattern ( Pel* piY, |
---|
127 | Pel* piCb, |
---|
128 | Pel* piCr, |
---|
129 | Int iRoiWidth, |
---|
130 | Int iRoiHeight, |
---|
131 | Int iStride, |
---|
132 | Int iOffsetLeft, |
---|
133 | Int iOffsetRight, |
---|
134 | Int iOffsetAbove, |
---|
135 | Int iOffsetBottom ) |
---|
136 | { |
---|
137 | m_cPatternY. setPatternParamPel( piY, iRoiWidth, iRoiHeight, iStride, iOffsetLeft, iOffsetRight, iOffsetAbove, iOffsetBottom ); |
---|
138 | m_cPatternCb.setPatternParamPel( piCb, iRoiWidth >> 1, iRoiHeight >> 1, iStride >> 1, iOffsetLeft >> 1, iOffsetRight >> 1, iOffsetAbove >> 1, iOffsetBottom >> 1 ); |
---|
139 | m_cPatternCr.setPatternParamPel( piCr, iRoiWidth >> 1, iRoiHeight >> 1, iStride >> 1, iOffsetLeft >> 1, iOffsetRight >> 1, iOffsetAbove >> 1, iOffsetBottom >> 1 ); |
---|
140 | |
---|
141 | return; |
---|
142 | } |
---|
143 | |
---|
144 | Void TComPattern::initPattern( TComDataCU* pcCU, UInt uiPartDepth, UInt uiAbsPartIdx, Bool bPrdDepthMap ) |
---|
145 | { |
---|
146 | Int uiOffsetLeft = 0; |
---|
147 | Int uiOffsetRight = 0; |
---|
148 | Int uiOffsetAbove = 0; |
---|
149 | |
---|
150 | TComPic* pcPic = pcCU->getPic(); |
---|
151 | UChar uiWidth = pcCU->getWidth (0)>>uiPartDepth; |
---|
152 | UChar uiHeight = pcCU->getHeight(0)>>uiPartDepth; |
---|
153 | |
---|
154 | UInt uiAbsZorderIdx = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
155 | UInt uiCurrPicPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsZorderIdx] ]; |
---|
156 | UInt uiCurrPicPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsZorderIdx] ]; |
---|
157 | |
---|
158 | if( uiCurrPicPelX != 0 ) |
---|
159 | uiOffsetLeft = 1; |
---|
160 | if( uiCurrPicPelY != 0 ) |
---|
161 | { |
---|
162 | UInt uiNumPartInWidth = ( uiWidth/pcPic->getMinCUWidth() ); |
---|
163 | uiOffsetAbove = 1; |
---|
164 | |
---|
165 | if( uiCurrPicPelX + uiWidth < pcCU->getSlice()->getSPS()->getWidth() ) |
---|
166 | { |
---|
167 | if( ( g_auiZscanToRaster[uiAbsZorderIdx] + uiNumPartInWidth ) % pcPic->getNumPartInWidth() ) // Not CU boundary |
---|
168 | { |
---|
169 | if( g_auiRasterToZscan[ (Int)g_auiZscanToRaster[uiAbsZorderIdx] - (Int)pcPic->getNumPartInWidth() + (Int)uiNumPartInWidth ] < uiAbsZorderIdx ) |
---|
170 | uiOffsetRight = 1; |
---|
171 | } |
---|
172 | else // if it is CU boundary |
---|
173 | { |
---|
174 | if( g_auiZscanToRaster[uiAbsZorderIdx] < pcPic->getNumPartInWidth() && (uiCurrPicPelX+uiWidth) < pcPic->getPicYuvRec()->getWidth() ) // first line |
---|
175 | { |
---|
176 | uiOffsetRight = 1; |
---|
177 | } |
---|
178 | } |
---|
179 | } |
---|
180 | } |
---|
181 | |
---|
182 | #if LM_CHROMA |
---|
183 | m_bLeftAvailable = uiCurrPicPelX > 0 ? true : false; |
---|
184 | m_bAboveAvailable = uiCurrPicPelY > 0 ? true : false; |
---|
185 | #endif |
---|
186 | |
---|
187 | m_cPatternY .setPatternParamCU( pcCU, 0, uiWidth, uiHeight, uiOffsetLeft, uiOffsetRight, uiOffsetAbove, 0, uiPartDepth, uiAbsPartIdx, bPrdDepthMap ); |
---|
188 | m_cPatternCb.setPatternParamCU( pcCU, 1, uiWidth >> 1, uiHeight >> 1, uiOffsetLeft, uiOffsetRight, uiOffsetAbove, 0, uiPartDepth, uiAbsPartIdx, bPrdDepthMap ); |
---|
189 | m_cPatternCr.setPatternParamCU( pcCU, 2, uiWidth >> 1, uiHeight >> 1, uiOffsetLeft, uiOffsetRight, uiOffsetAbove, 0, uiPartDepth, uiAbsPartIdx, bPrdDepthMap ); |
---|
190 | } |
---|
191 | |
---|
192 | Void TComPattern::initAdiPattern( TComDataCU* pcCU, UInt uiZorderIdxInPart, UInt uiPartDepth, Int* piAdiBuf, Int iOrgBufStride, Int iOrgBufHeight, Bool& bAbove, Bool& bLeft, Bool bPrdDepthMap ) |
---|
193 | { |
---|
194 | Pel* piRoiOrigin; |
---|
195 | Int* piAdiTemp; |
---|
196 | UInt uiCuWidth = pcCU->getWidth(0) >> uiPartDepth; |
---|
197 | UInt uiCuHeight = pcCU->getHeight(0)>> uiPartDepth; |
---|
198 | UInt uiCuWidth2 = uiCuWidth<<1; |
---|
199 | UInt uiCuHeight2 = uiCuHeight<<1; |
---|
200 | UInt uiWidth; |
---|
201 | UInt uiHeight; |
---|
202 | Int iPicStride = pcCU->getPic()->getStride(); |
---|
203 | Int iCuAddr; |
---|
204 | #if REFERENCE_SAMPLE_PADDING |
---|
205 | Int iUnitSize = 0; |
---|
206 | Int iNumUnitsInCu = 0; |
---|
207 | Int iTotalUnits = 0; |
---|
208 | Bool* bNeighborFlags; |
---|
209 | Int iNumIntraNeighbor = 0; |
---|
210 | #else // REFERENCE_SAMPLE_PADDING |
---|
211 | Pel* piRoiTemp; |
---|
212 | Bool bAboveFlag = false; |
---|
213 | Bool bAboveRightFlag = false; |
---|
214 | Bool bLeftFlag = false; |
---|
215 | Bool bBelowLeftFlag = false; |
---|
216 | Bool bAboveLeftFlag = false; |
---|
217 | #endif // REFERENCE_SAMPLE_PADDING |
---|
218 | |
---|
219 | iCuAddr = pcCU->getAddr(); |
---|
220 | |
---|
221 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB, uiPartDum; |
---|
222 | |
---|
223 | pcCU->deriveLeftRightTopIdxAdi( uiPartIdxLT, uiPartIdxRT, uiZorderIdxInPart, uiPartDepth ); |
---|
224 | pcCU->deriveLeftBottomIdxAdi ( uiPartIdxLB, uiZorderIdxInPart, uiPartDepth ); |
---|
225 | |
---|
226 | #if CONSTRAINED_INTRA_PRED |
---|
227 | if ( pcCU->getSlice()->getPPS()->getConstrainedIntraPred() ) |
---|
228 | { |
---|
229 | #if REFERENCE_SAMPLE_PADDING |
---|
230 | iUnitSize = g_uiMaxCUWidth >> g_uiMaxCUDepth; |
---|
231 | iNumUnitsInCu = uiCuWidth / iUnitSize; |
---|
232 | iTotalUnits = (iNumUnitsInCu << 2) + 1; |
---|
233 | bNeighborFlags = new Bool[iTotalUnits]; |
---|
234 | |
---|
235 | bNeighborFlags[iNumUnitsInCu*2] = isAboveLeftAvailableForCIP( pcCU, uiPartIdxLT ); |
---|
236 | iNumIntraNeighbor += (Int)(bNeighborFlags[iNumUnitsInCu*2]); |
---|
237 | iNumIntraNeighbor += isAboveAvailableForCIP ( pcCU, uiPartIdxLT, uiPartIdxRT, bNeighborFlags+(iNumUnitsInCu*2)+1 ); |
---|
238 | iNumIntraNeighbor += isAboveRightAvailableForCIP( pcCU, uiPartIdxLT, uiPartIdxRT, bNeighborFlags+(iNumUnitsInCu*3)+1 ); |
---|
239 | iNumIntraNeighbor += isLeftAvailableForCIP ( pcCU, uiPartIdxLT, uiPartIdxLB, bNeighborFlags+(iNumUnitsInCu*2)-1 ); |
---|
240 | iNumIntraNeighbor += isBelowLeftAvailableForCIP ( pcCU, uiPartIdxLT, uiPartIdxLB, bNeighborFlags+ iNumUnitsInCu -1 ); |
---|
241 | #else // REFERENCE_SAMPLE_PADDING |
---|
242 | bAboveFlag = isAboveAvailableForCIP ( pcCU, uiPartIdxLT, uiPartIdxRT ); |
---|
243 | bAboveRightFlag = isAboveRightAvailableForCIP( pcCU, uiPartIdxLT, uiPartIdxRT ); |
---|
244 | bLeftFlag = isLeftAvailableForCIP ( pcCU, uiPartIdxLT, uiPartIdxLB ); |
---|
245 | bBelowLeftFlag = isBelowLeftAvailableForCIP ( pcCU, uiPartIdxLT, uiPartIdxLB ); |
---|
246 | bAboveLeftFlag = isAboveLeftAvailableForCIP ( pcCU, uiPartIdxLT ); |
---|
247 | #endif // REFERENCE_SAMPLE_PADDING |
---|
248 | } |
---|
249 | else |
---|
250 | { |
---|
251 | #if REFERENCE_SAMPLE_PADDING |
---|
252 | iUnitSize = uiCuWidth; |
---|
253 | iNumUnitsInCu = 1; |
---|
254 | iTotalUnits = 5; |
---|
255 | bNeighborFlags = new Bool[iTotalUnits]; |
---|
256 | |
---|
257 | ::memset(bNeighborFlags, false, sizeof(Bool)*iTotalUnits); |
---|
258 | if( pcCU->getPUAbove ( uiPartDum, uiPartIdxLT, true, false ) ) { bNeighborFlags[3] = true; iNumIntraNeighbor++; } |
---|
259 | if( pcCU->getPUAboveRightAdi( uiPartDum, uiCuWidth, uiPartIdxRT, 1, true, false ) ) { bNeighborFlags[4] = true; iNumIntraNeighbor++; } |
---|
260 | if( pcCU->getPULeft ( uiPartDum, uiPartIdxLT, true, false ) ) { bNeighborFlags[1] = true; iNumIntraNeighbor++; } |
---|
261 | if( pcCU->getPUBelowLeftAdi ( uiPartDum, uiCuHeight, uiPartIdxLB, 1, true, false ) ) { bNeighborFlags[0] = true; iNumIntraNeighbor++; } |
---|
262 | if( pcCU->getPUAboveLeft ( uiPartDum, uiPartIdxLT, true, false ) ) { bNeighborFlags[2] = true; iNumIntraNeighbor++; } |
---|
263 | #if MN_DC_PRED_FILTER |
---|
264 | m_bAboveFlagForDCFilt = bNeighborFlags[3]; |
---|
265 | m_bLeftFlagForDCFilt = bNeighborFlags[1]; |
---|
266 | #endif |
---|
267 | #else // REFERENCE_SAMPLE_PADDING |
---|
268 | if( pcCU->getPUAbove ( uiPartDum, uiPartIdxLT, true, false ) ) bAboveFlag = true; |
---|
269 | if( pcCU->getPUAboveRightAdi( uiPartDum, uiCuWidth, uiPartIdxRT, 1, true, false ) ) bAboveRightFlag = true; |
---|
270 | if( pcCU->getPULeft ( uiPartDum, uiPartIdxLT, true, false ) ) bLeftFlag = true; |
---|
271 | if( pcCU->getPUBelowLeftAdi ( uiPartDum, uiCuHeight, uiPartIdxLB, 1, true, false ) ) bBelowLeftFlag = true; |
---|
272 | if( pcCU->getPUAboveLeft ( uiPartDum, uiPartIdxLT, true, false ) ) bAboveLeftFlag = true; |
---|
273 | #if MN_DC_PRED_FILTER |
---|
274 | m_bAboveFlagForDCFilt = bAboveFlag; |
---|
275 | m_bLeftFlagForDCFilt = bLeftFlag; |
---|
276 | #endif |
---|
277 | #endif // REFERENCE_SAMPLE_PADDING |
---|
278 | } |
---|
279 | #else //CONSTRAINED_INTRA_PRED |
---|
280 | #if REFERENCE_SAMPLE_PADDING |
---|
281 | iUnitSize = uiCuWidth; |
---|
282 | iNumUnitsInCu = 1; |
---|
283 | iTotalUnits = 5; |
---|
284 | bNeighborFlags = new Bool[iTotalUnits]; |
---|
285 | |
---|
286 | ::memset(bNeighborFlags, false, sizeof(Bool)*iTotalUnits); |
---|
287 | if( pcCU->getPUAbove ( uiPartDum, uiPartIdxLT, true, false ) ) { bNeighborFlags[3] = true; iNumIntraNeighbor++; } |
---|
288 | if( pcCU->getPUAboveRightAdi( uiPartDum, uiCuWidth, uiPartIdxRT, true, false ) ) { bNeighborFlags[4] = true; iNumIntraNeighbor++; } |
---|
289 | if( pcCU->getPULeft ( uiPartDum, uiPartIdxLT, true, false ) ) { bNeighborFlags[1] = true; iNumIntraNeighbor++; } |
---|
290 | if( pcCU->getPUBelowLeftAdi ( uiPartDum, uiCuHeight, uiPartIdxLB, true, false ) ) { bNeighborFlags[0] = true; iNumIntraNeighbor++; } |
---|
291 | if( pcCU->getPUAboveLeft ( uiPartDum, uiPartIdxLT, true, false ) ) { bNeighborFlags[2] = true; iNumIntraNeighbor++; } |
---|
292 | #if MN_DC_PRED_FILTER |
---|
293 | m_bAboveFlagForDCFilt = bNeighborFlags[3]; |
---|
294 | m_bLeftFlagForDCFilt = bNeighborFlags[1]; |
---|
295 | #endif |
---|
296 | #else // REFERENCE_SAMPLE_PADDING |
---|
297 | if( pcCU->getPUAbove ( uiPartDum, uiPartIdxLT, true, false ) ) bAboveFlag = true; |
---|
298 | if( pcCU->getPUAboveRightAdi( uiPartDum, uiCuWidth, uiPartIdxRT, true, false ) ) bAboveRightFlag = true; |
---|
299 | if( pcCU->getPULeft ( uiPartDum, uiPartIdxLT, true, false ) ) bLeftFlag = true; |
---|
300 | if( pcCU->getPUBelowLeftAdi ( uiPartDum, uiCuHeight, uiPartIdxLB, true, false ) ) bBelowLeftFlag = true; |
---|
301 | if( pcCU->getPUAboveLeft ( uiPartDum, uiPartIdxLT, true, false ) ) bAboveLeftFlag = true; |
---|
302 | #if MN_DC_PRED_FILTER |
---|
303 | m_bAboveFlagForDCFilt = bAboveFlag; |
---|
304 | m_bLeftFlagForDCFilt = bLeftFlag; |
---|
305 | #endif |
---|
306 | #endif // REFERENCE_SAMPLE_PADDING |
---|
307 | #endif //CONSTRAINED_INTRA_PRED |
---|
308 | |
---|
309 | #if MN_DC_PRED_FILTER |
---|
310 | m_bDCPredFilterFlag = (m_bAboveFlagForDCFilt && m_bLeftFlagForDCFilt) ? true : false; |
---|
311 | #endif |
---|
312 | |
---|
313 | #if REFERENCE_SAMPLE_PADDING |
---|
314 | bAbove = true; |
---|
315 | bLeft = true; |
---|
316 | #else // REFERENCE_SAMPLE_PADDING |
---|
317 | bAbove = bAboveFlag; |
---|
318 | bLeft = bLeftFlag; |
---|
319 | |
---|
320 | Int iDCValue = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); |
---|
321 | #endif // REFERENCE_SAMPLE_PADDING |
---|
322 | |
---|
323 | uiWidth=uiCuWidth2+1; |
---|
324 | uiHeight=uiCuHeight2+1; |
---|
325 | |
---|
326 | if (((uiWidth<<2)>iOrgBufStride)||((uiHeight<<2)>iOrgBufHeight)) |
---|
327 | return; |
---|
328 | |
---|
329 | piRoiOrigin = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiZorderIdxInPart); |
---|
330 | piAdiTemp = piAdiBuf; |
---|
331 | |
---|
332 | if( bPrdDepthMap ) |
---|
333 | { |
---|
334 | piRoiOrigin = pcCU->getPic()->getPredDepthMap()->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiZorderIdxInPart ); |
---|
335 | #if REFERENCE_SAMPLE_PADDING |
---|
336 | #else |
---|
337 | iDCValue = PDM_UNDEFINED_DEPTH; |
---|
338 | #endif |
---|
339 | } |
---|
340 | |
---|
341 | |
---|
342 | #if REFERENCE_SAMPLE_PADDING |
---|
343 | fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride, bPrdDepthMap ); |
---|
344 | delete [] bNeighborFlags; |
---|
345 | bNeighborFlags = NULL; |
---|
346 | #else // REFERENCE_SAMPLE_PADDING |
---|
347 | //BB: fill border with DC value - needed if( bAboveFlag=false || bLeftFlag=false ) |
---|
348 | for (i=0;i<uiWidth;i++) |
---|
349 | piAdiTemp[i]=iDCValue; |
---|
350 | for (i=0;i<uiHeight;i++) //BB: can start from 1? |
---|
351 | piAdiTemp[i*uiWidth]=iDCValue; |
---|
352 | |
---|
353 | piRoiTemp=piRoiOrigin; //BB: not needed? |
---|
354 | |
---|
355 | if (bAboveFlag) |
---|
356 | { |
---|
357 | // BB: fill top border with rec. samples |
---|
358 | piRoiTemp=piRoiOrigin-iPicStride; |
---|
359 | for (i=0;i<uiCuWidth;i++) |
---|
360 | piAdiTemp[1+i]=piRoiTemp[i]; |
---|
361 | // BB: fill top right border with rec. samples |
---|
362 | if (bAboveRightFlag) |
---|
363 | { |
---|
364 | piRoiTemp=piRoiOrigin-iPicStride+uiCuWidth; |
---|
365 | for (i=0;i<uiCuWidth;i++) |
---|
366 | piAdiTemp[1+uiCuWidth+i]=piRoiTemp[i]; |
---|
367 | } |
---|
368 | // BB: fill top right border with last sample from top |
---|
369 | else |
---|
370 | { |
---|
371 | for (i=0;i<uiCuWidth;i++) |
---|
372 | piAdiTemp[1+uiCuWidth+i]=piAdiTemp[uiCuWidth]; |
---|
373 | } |
---|
374 | } |
---|
375 | |
---|
376 | if (bAboveLeftFlag) |
---|
377 | { |
---|
378 | piRoiTemp=piRoiOrigin-iPicStride-1; |
---|
379 | piAdiTemp[0]=piRoiTemp[0]; |
---|
380 | } |
---|
381 | |
---|
382 | if (bLeftFlag) |
---|
383 | { |
---|
384 | // BB: fill left border with rec. samples |
---|
385 | piRoiTemp=piRoiOrigin-1; |
---|
386 | for (i=0;i<uiCuHeight;i++) |
---|
387 | { |
---|
388 | piAdiTemp[(1+i)*uiWidth]=piRoiTemp[0]; |
---|
389 | piRoiTemp+=iPicStride; |
---|
390 | } |
---|
391 | // BB: fill below left border with rec. samples |
---|
392 | if (bBelowLeftFlag) |
---|
393 | { |
---|
394 | for (i=0;i<uiCuHeight;i++) |
---|
395 | { |
---|
396 | piAdiTemp[(1+uiCuHeight+i)*uiWidth]=piRoiTemp[0]; |
---|
397 | piRoiTemp+=iPicStride; |
---|
398 | } |
---|
399 | } |
---|
400 | // BB: fill below left border with last sample from left |
---|
401 | else |
---|
402 | { |
---|
403 | for (i=0;i<uiCuHeight;i++) |
---|
404 | piAdiTemp[(1+uiCuHeight+i)*uiWidth]=piAdiTemp[(uiCuHeight)*uiWidth]; |
---|
405 | } |
---|
406 | } |
---|
407 | #endif // REFERENCE_SAMPLE_PADDING |
---|
408 | |
---|
409 | #if QC_MDIS |
---|
410 | // generate filtered intra prediction samples |
---|
411 | Int iBufSize = uiCuHeight2 + uiCuWidth2 + 1; // left and left above border + above and above right border + top left corner = length of 3. filter buffer |
---|
412 | Int i; |
---|
413 | |
---|
414 | UInt uiWH = uiWidth * uiHeight; // number of elements in one buffer |
---|
415 | |
---|
416 | Int* piFilteredBuf1 = piAdiBuf + uiWH; // 1. filter buffer |
---|
417 | Int* piFilteredBuf2 = piFilteredBuf1 + uiWH; // 2. filter buffer |
---|
418 | Int* piFilterBuf = piFilteredBuf2 + uiWH; // buffer for 2. filtering (sequential) |
---|
419 | Int* piFilterBufN = piFilterBuf + iBufSize; // buffer for 1. filtering (sequential) |
---|
420 | |
---|
421 | Int l = 0; |
---|
422 | // left border from bottom to top |
---|
423 | for (i = 0; i < uiCuHeight2; i++) |
---|
424 | piFilterBuf[l++] = piAdiTemp[uiWidth * (uiCuHeight2 - i)]; |
---|
425 | // top left corner |
---|
426 | piFilterBuf[l++] = piAdiTemp[0]; |
---|
427 | // above border from left to right |
---|
428 | for (i=0; i < uiCuWidth2; i++) |
---|
429 | piFilterBuf[l++] = piAdiTemp[1 + i]; |
---|
430 | |
---|
431 | // 1. filtering with [1 2 1] |
---|
432 | piFilterBufN[0] = piFilterBuf[0]; |
---|
433 | piFilterBufN[iBufSize - 1] = piFilterBuf[iBufSize - 1]; |
---|
434 | for (i = 1; i < iBufSize - 1; i++) |
---|
435 | piFilterBufN[i] = (piFilterBuf[i - 1] + 2 * piFilterBuf[i]+piFilterBuf[i + 1] + 2) >> 2; |
---|
436 | |
---|
437 | // fill 1. filter buffer with filtered values |
---|
438 | l=0; |
---|
439 | for (i = 0; i < uiCuHeight2; i++) |
---|
440 | piFilteredBuf1[uiWidth * (uiCuHeight2 - i)] = piFilterBufN[l++]; |
---|
441 | piFilteredBuf1[0] = piFilterBufN[l++]; |
---|
442 | for (i = 0; i < uiCuWidth2; i++) |
---|
443 | piFilteredBuf1[1 + i] = piFilterBufN[l++]; |
---|
444 | |
---|
445 | #if !MN_MDIS_SIMPLIFICATION |
---|
446 | // 2. filtering with [1 2 1] |
---|
447 | piFilterBuf[0] = piFilterBufN[0]; |
---|
448 | piFilterBuf[iBufSize - 1] = piFilterBufN[iBufSize - 1]; |
---|
449 | for (i = 1; i < iBufSize - 1; i++) |
---|
450 | piFilterBuf[i] = (piFilterBufN[i - 1] + 2 * piFilterBufN[i] + piFilterBufN[i + 1] + 2) >> 2; |
---|
451 | |
---|
452 | // fill 2. filter buffer with filtered values |
---|
453 | l=0; |
---|
454 | for (i = 0; i < uiCuHeight2; i++) |
---|
455 | piFilteredBuf2[uiWidth * (uiCuHeight2 - i)] = piFilterBuf[l++]; |
---|
456 | piFilteredBuf2[0] = piFilterBuf[l++]; |
---|
457 | for (i = 0; i < uiCuWidth2; i++) |
---|
458 | piFilteredBuf2[1 + i] = piFilterBuf[l++]; |
---|
459 | #endif |
---|
460 | #endif //QC_MDIS |
---|
461 | |
---|
462 | } |
---|
463 | |
---|
464 | Void TComPattern::initAdiPatternChroma( TComDataCU* pcCU, UInt uiZorderIdxInPart, UInt uiPartDepth, Int* piAdiBuf, Int iOrgBufStride, Int iOrgBufHeight, Bool& bAbove, Bool& bLeft ) |
---|
465 | { |
---|
466 | Pel* piRoiOrigin; |
---|
467 | Int* piAdiTemp; |
---|
468 | UInt uiCuWidth = pcCU->getWidth (0) >> uiPartDepth; |
---|
469 | UInt uiCuHeight = pcCU->getHeight(0) >> uiPartDepth; |
---|
470 | UInt uiWidth; |
---|
471 | UInt uiHeight; |
---|
472 | Int iPicStride = pcCU->getPic()->getCStride(); |
---|
473 | Int iCuAddr; |
---|
474 | #if REFERENCE_SAMPLE_PADDING |
---|
475 | Int iUnitSize = 0; |
---|
476 | Int iNumUnitsInCu = 0; |
---|
477 | Int iTotalUnits = 0; |
---|
478 | Bool* bNeighborFlags; |
---|
479 | Int iNumIntraNeighbor = 0; |
---|
480 | #else // REFERENCE_SAMPLE_PADDING |
---|
481 | Pel* piRoiTemp; |
---|
482 | Int i; |
---|
483 | Bool bAboveFlag=false; |
---|
484 | Bool bAboveRightFlag=false; |
---|
485 | Bool bLeftFlag=false; |
---|
486 | Bool bBelowLeftFlag=false; |
---|
487 | Bool bAboveLeftFlag = false; |
---|
488 | #endif // REFERENCE_SAMPLE_PADDING |
---|
489 | |
---|
490 | iCuAddr = pcCU->getAddr(); |
---|
491 | |
---|
492 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB,uiPartDum; |
---|
493 | |
---|
494 | pcCU->deriveLeftRightTopIdxAdi( uiPartIdxLT, uiPartIdxRT, uiZorderIdxInPart, uiPartDepth ); |
---|
495 | pcCU->deriveLeftBottomIdxAdi ( uiPartIdxLB, uiZorderIdxInPart, uiPartDepth ); |
---|
496 | |
---|
497 | #if CONSTRAINED_INTRA_PRED |
---|
498 | if ( pcCU->getSlice()->getPPS()->getConstrainedIntraPred() ) |
---|
499 | { |
---|
500 | #if REFERENCE_SAMPLE_PADDING |
---|
501 | iUnitSize = (g_uiMaxCUWidth >> g_uiMaxCUDepth) >> 1; // for chroma |
---|
502 | iNumUnitsInCu = (uiCuWidth / iUnitSize) >> 1; // for chroma |
---|
503 | iTotalUnits = (iNumUnitsInCu << 2) + 1; |
---|
504 | bNeighborFlags = new Bool[iTotalUnits]; |
---|
505 | |
---|
506 | bNeighborFlags[iNumUnitsInCu*2] = isAboveLeftAvailableForCIP( pcCU, uiPartIdxLT ); |
---|
507 | iNumIntraNeighbor += (Int)(bNeighborFlags[iNumUnitsInCu*2]); |
---|
508 | iNumIntraNeighbor += isAboveAvailableForCIP ( pcCU, uiPartIdxLT, uiPartIdxRT, bNeighborFlags+(iNumUnitsInCu*2)+1 ); |
---|
509 | iNumIntraNeighbor += isAboveRightAvailableForCIP( pcCU, uiPartIdxLT, uiPartIdxRT, bNeighborFlags+(iNumUnitsInCu*3)+1 ); |
---|
510 | iNumIntraNeighbor += isLeftAvailableForCIP ( pcCU, uiPartIdxLT, uiPartIdxLB, bNeighborFlags+(iNumUnitsInCu*2)-1 ); |
---|
511 | iNumIntraNeighbor += isBelowLeftAvailableForCIP ( pcCU, uiPartIdxLT, uiPartIdxLB, bNeighborFlags+ iNumUnitsInCu -1 ); |
---|
512 | #else // REFERENCE_SAMPLE_PADDING |
---|
513 | bAboveFlag = isAboveAvailableForCIP ( pcCU, uiPartIdxLT, uiPartIdxRT ); |
---|
514 | bAboveRightFlag = isAboveRightAvailableForCIP( pcCU, uiPartIdxLT, uiPartIdxRT ); |
---|
515 | bLeftFlag = isLeftAvailableForCIP ( pcCU, uiPartIdxLT, uiPartIdxLB ); |
---|
516 | bBelowLeftFlag = isBelowLeftAvailableForCIP ( pcCU, uiPartIdxLT, uiPartIdxLB ); |
---|
517 | bAboveLeftFlag = isAboveLeftAvailableForCIP ( pcCU, uiPartIdxLT ); |
---|
518 | #endif // REFERENCE_SAMPLE_PADDING |
---|
519 | } |
---|
520 | else |
---|
521 | { |
---|
522 | #if REFERENCE_SAMPLE_PADDING |
---|
523 | iUnitSize = uiCuWidth >> 1; |
---|
524 | iNumUnitsInCu = 1; |
---|
525 | iTotalUnits = 5; |
---|
526 | bNeighborFlags = new Bool[iTotalUnits]; |
---|
527 | |
---|
528 | ::memset(bNeighborFlags, false, sizeof(Bool)*iTotalUnits); |
---|
529 | if( pcCU->getPUAbove ( uiPartDum, uiPartIdxLT, true, false ) ) { bNeighborFlags[3] = true; iNumIntraNeighbor++; } |
---|
530 | if( pcCU->getPUAboveRightAdi( uiPartDum, uiCuWidth, uiPartIdxRT, 1, true, false ) ) { bNeighborFlags[4] = true; iNumIntraNeighbor++; } |
---|
531 | if( pcCU->getPULeft ( uiPartDum, uiPartIdxLT, true, false ) ) { bNeighborFlags[1] = true; iNumIntraNeighbor++; } |
---|
532 | if( pcCU->getPUBelowLeftAdi ( uiPartDum, uiCuHeight, uiPartIdxLB, 1, true, false ) ) { bNeighborFlags[0] = true; iNumIntraNeighbor++; } |
---|
533 | if( pcCU->getPUAboveLeft ( uiPartDum, uiPartIdxLT, true, false ) ) { bNeighborFlags[2] = true; iNumIntraNeighbor++; } |
---|
534 | #else // REFERENCE_SAMPLE_PADDING |
---|
535 | if( pcCU->getPUAbove ( uiPartDum, uiPartIdxLT, true, false ) ) bAboveFlag = true; |
---|
536 | if( pcCU->getPUAboveRightAdi( uiPartDum, uiCuWidth, uiPartIdxRT, 1, true, false ) ) bAboveRightFlag = true; |
---|
537 | if( pcCU->getPULeft ( uiPartDum, uiPartIdxLT, true, false ) ) bLeftFlag = true; |
---|
538 | if( pcCU->getPUBelowLeftAdi ( uiPartDum, uiCuHeight, uiPartIdxLB, 1, true, false ) ) bBelowLeftFlag = true; |
---|
539 | if( pcCU->getPUAboveLeft ( uiPartDum, uiPartIdxLT, true, false ) ) bAboveLeftFlag = true; |
---|
540 | #endif // REFERENCE_SAMPLE_PADDING |
---|
541 | } |
---|
542 | #else //CONSTRAINED_INTRA_PRED |
---|
543 | #if REFERENCE_SAMPLE_PADDING |
---|
544 | iUnitSize = uiCuWidth >> 1; |
---|
545 | iNumUnitsInCu = 1; |
---|
546 | iTotalUnits = 5; |
---|
547 | bNeighborFlags = new Bool[iTotalUnits]; |
---|
548 | |
---|
549 | ::memset(bNeighborFlags, false, sizeof(Bool)*iTotalUnits); |
---|
550 | if( pcCU->getPUAbove ( uiPartDum, uiPartIdxLT, true, false ) ) { bNeighborFlags[3] = true; iNumIntraNeighbor++; } |
---|
551 | if( pcCU->getPUAboveRightAdi( uiPartDum, uiCuWidth, uiPartIdxRT, true, false ) ) { bNeighborFlags[4] = true; iNumIntraNeighbor++; } |
---|
552 | if( pcCU->getPULeft ( uiPartDum, uiPartIdxLT, true, false ) ) { bNeighborFlags[1] = true; iNumIntraNeighbor++; } |
---|
553 | if( pcCU->getPUBelowLeftAdi ( uiPartDum, uiCuHeight, uiPartIdxLB, true, false ) ) { bNeighborFlags[0] = true; iNumIntraNeighbor++; } |
---|
554 | if( pcCU->getPUAboveLeft ( uiPartDum, uiPartIdxLT, true, false ) ) { bNeighborFlags[2] = true; iNumIntraNeighbor++; } |
---|
555 | #else // REFERENCE_SAMPLE_PADDING |
---|
556 | if( pcCU->getPUAbove ( uiPartDum, uiPartIdxLT, true, false ) ) bAboveFlag = true; |
---|
557 | if( pcCU->getPUAboveRightAdi( uiPartDum, uiCuWidth, uiPartIdxRT, true, false ) ) bAboveRightFlag = true; |
---|
558 | if( pcCU->getPULeft ( uiPartDum, uiPartIdxLT, true, false ) ) bLeftFlag = true; |
---|
559 | if( pcCU->getPUBelowLeftAdi ( uiPartDum, uiCuHeight, uiPartIdxLB, true, false ) ) bBelowLeftFlag = true; |
---|
560 | if( pcCU->getPUAboveLeft ( uiPartDum, uiPartIdxLT, true, false ) ) bAboveLeftFlag = true; |
---|
561 | #endif // REFERENCE_SAMPLE_PADDING |
---|
562 | #endif //CONSTRAINED_INTRA_PRED |
---|
563 | |
---|
564 | #if REFERENCE_SAMPLE_PADDING |
---|
565 | bAbove = true; |
---|
566 | bLeft = true; |
---|
567 | #else // REFERENCE_SAMPLE_PADDING |
---|
568 | bAbove = bAboveFlag; |
---|
569 | bLeft = bLeftFlag; |
---|
570 | |
---|
571 | Int iDCValue = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); |
---|
572 | #endif // REFERENCE_SAMPLE_PADDING |
---|
573 | |
---|
574 | uiCuWidth=uiCuWidth>>1; // for chroma |
---|
575 | uiCuHeight=uiCuHeight>>1; // for chroma |
---|
576 | |
---|
577 | uiWidth=uiCuWidth*2+1; |
---|
578 | uiHeight=uiCuHeight*2+1; |
---|
579 | |
---|
580 | if ((4*uiWidth>iOrgBufStride)||(4*uiHeight>iOrgBufHeight)) |
---|
581 | return; |
---|
582 | |
---|
583 | // get Cb pattern |
---|
584 | piRoiOrigin = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiZorderIdxInPart); |
---|
585 | piAdiTemp = piAdiBuf; |
---|
586 | |
---|
587 | #if REFERENCE_SAMPLE_PADDING |
---|
588 | fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride, false ); |
---|
589 | #else // REFERENCE_SAMPLE_PADDING |
---|
590 | for (i=0;i<uiWidth;i++) |
---|
591 | piAdiTemp[i]=iDCValue; |
---|
592 | for (i=0;i<uiHeight;i++) |
---|
593 | piAdiTemp[i*uiWidth]=iDCValue; |
---|
594 | |
---|
595 | piRoiTemp=piRoiOrigin; |
---|
596 | |
---|
597 | if (bAboveFlag) |
---|
598 | { |
---|
599 | piRoiTemp=piRoiOrigin-iPicStride; |
---|
600 | for (i=0;i<uiCuWidth;i++) |
---|
601 | piAdiTemp[1+i]=piRoiTemp[i]; |
---|
602 | if (bAboveRightFlag) |
---|
603 | { |
---|
604 | piRoiTemp=piRoiOrigin-iPicStride+uiCuWidth; |
---|
605 | for (i=0;i<uiCuWidth;i++) |
---|
606 | piAdiTemp[1+uiCuWidth+i]=piRoiTemp[i]; |
---|
607 | } |
---|
608 | else |
---|
609 | { |
---|
610 | for (i=0;i<uiCuWidth;i++) |
---|
611 | piAdiTemp[1+uiCuWidth+i]=piAdiTemp[uiCuWidth]; |
---|
612 | } |
---|
613 | } |
---|
614 | |
---|
615 | if (bAboveLeftFlag) |
---|
616 | { |
---|
617 | piRoiTemp=piRoiOrigin-iPicStride-1; |
---|
618 | piAdiTemp[0]=piRoiTemp[0]; |
---|
619 | } |
---|
620 | |
---|
621 | if (bLeftFlag) |
---|
622 | { |
---|
623 | piRoiTemp=piRoiOrigin-1; |
---|
624 | for (i=0;i<uiCuHeight;i++) |
---|
625 | { |
---|
626 | piAdiTemp[(1+i)*uiWidth]=piRoiTemp[0]; |
---|
627 | piRoiTemp+=iPicStride; |
---|
628 | } |
---|
629 | if (bBelowLeftFlag) |
---|
630 | { |
---|
631 | for (i=0;i<uiCuHeight;i++) |
---|
632 | { |
---|
633 | piAdiTemp[(1+uiCuHeight+i)*uiWidth]=piRoiTemp[0]; |
---|
634 | piRoiTemp+=iPicStride; |
---|
635 | } |
---|
636 | } |
---|
637 | else |
---|
638 | { |
---|
639 | for (i=0;i<uiCuHeight;i++) |
---|
640 | piAdiTemp[(1+uiCuHeight+i)*uiWidth]=piAdiTemp[(uiCuHeight)*uiWidth]; |
---|
641 | } |
---|
642 | } |
---|
643 | #endif // REFERENCE_SAMPLE_PADDING |
---|
644 | |
---|
645 | // get Cr pattern |
---|
646 | piRoiOrigin = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiZorderIdxInPart); |
---|
647 | piAdiTemp = piAdiBuf+uiWidth*uiHeight; |
---|
648 | |
---|
649 | #if REFERENCE_SAMPLE_PADDING |
---|
650 | fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride, false ); |
---|
651 | delete [] bNeighborFlags; |
---|
652 | bNeighborFlags = NULL; |
---|
653 | #else // REFERENCE_SAMPLE_PADDING |
---|
654 | for (i=0;i<uiWidth;i++) |
---|
655 | piAdiTemp[i]=iDCValue; |
---|
656 | for (i=0;i<uiHeight;i++) |
---|
657 | piAdiTemp[i*uiWidth]=iDCValue; |
---|
658 | |
---|
659 | piRoiTemp=piRoiOrigin; |
---|
660 | |
---|
661 | if (bAboveFlag) |
---|
662 | { |
---|
663 | piRoiTemp=piRoiOrigin-iPicStride; |
---|
664 | for (i=0;i<uiCuWidth;i++) |
---|
665 | piAdiTemp[1+i]=piRoiTemp[i]; |
---|
666 | if (bAboveRightFlag) |
---|
667 | { |
---|
668 | piRoiTemp=piRoiOrigin-iPicStride+uiCuWidth; |
---|
669 | for (i=0;i<uiCuWidth;i++) |
---|
670 | piAdiTemp[1+uiCuWidth+i]=piRoiTemp[i]; |
---|
671 | } |
---|
672 | else |
---|
673 | { |
---|
674 | for (i=0;i<uiCuWidth;i++) |
---|
675 | piAdiTemp[1+uiCuWidth+i]=piAdiTemp[uiCuWidth]; |
---|
676 | } |
---|
677 | } |
---|
678 | |
---|
679 | if (bAboveLeftFlag) |
---|
680 | { |
---|
681 | piRoiTemp=piRoiOrigin-iPicStride-1; |
---|
682 | piAdiTemp[0]=piRoiTemp[0]; |
---|
683 | } |
---|
684 | |
---|
685 | if (bLeftFlag) |
---|
686 | { |
---|
687 | piRoiTemp=piRoiOrigin-1; |
---|
688 | for (i=0;i<uiCuHeight;i++) |
---|
689 | { |
---|
690 | piAdiTemp[(1+i)*uiWidth]=piRoiTemp[0]; |
---|
691 | piRoiTemp+=iPicStride; |
---|
692 | } |
---|
693 | if (bBelowLeftFlag) |
---|
694 | { |
---|
695 | for (i=0;i<uiCuHeight;i++) |
---|
696 | { |
---|
697 | piAdiTemp[(1+uiCuHeight+i)*uiWidth]=piRoiTemp[0]; |
---|
698 | piRoiTemp+=iPicStride; |
---|
699 | } |
---|
700 | } |
---|
701 | else |
---|
702 | { |
---|
703 | for (i=0;i<uiCuHeight;i++) |
---|
704 | piAdiTemp[(1+uiCuHeight+i)*uiWidth]=piAdiTemp[(uiCuHeight)*uiWidth]; |
---|
705 | } |
---|
706 | } |
---|
707 | #endif // REFERENCE_SAMPLE_PADDING |
---|
708 | } |
---|
709 | |
---|
710 | #if REFERENCE_SAMPLE_PADDING |
---|
711 | Void TComPattern::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, Bool bPrdDepthMap ) |
---|
712 | { |
---|
713 | Pel* piRoiTemp; |
---|
714 | Int i, j; |
---|
715 | Int iDCValue = ( bPrdDepthMap ? PDM_UNDEFINED_DEPTH : ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ) ); |
---|
716 | |
---|
717 | if (iNumIntraNeighbor == 0) |
---|
718 | { |
---|
719 | // Fill border with DC value |
---|
720 | for (i=0; i<uiWidth; i++) |
---|
721 | piAdiTemp[i] = iDCValue; |
---|
722 | for (i=1; i<uiHeight; i++) |
---|
723 | piAdiTemp[i*uiWidth] = iDCValue; |
---|
724 | } |
---|
725 | else if (iNumIntraNeighbor == iTotalUnits) |
---|
726 | { |
---|
727 | // Fill top-left border with rec. samples |
---|
728 | piRoiTemp = piRoiOrigin - iPicStride - 1; |
---|
729 | piAdiTemp[0] = piRoiTemp[0]; |
---|
730 | |
---|
731 | // Fill left border with rec. samples |
---|
732 | piRoiTemp = piRoiOrigin - 1; |
---|
733 | for (i=0; i<uiCuHeight; i++) |
---|
734 | { |
---|
735 | piAdiTemp[(1+i)*uiWidth] = piRoiTemp[0]; |
---|
736 | piRoiTemp += iPicStride; |
---|
737 | } |
---|
738 | |
---|
739 | // Fill below left border with rec. samples |
---|
740 | for (i=0; i<uiCuHeight; i++) |
---|
741 | { |
---|
742 | piAdiTemp[(1+uiCuHeight+i)*uiWidth] = piRoiTemp[0]; |
---|
743 | piRoiTemp += iPicStride; |
---|
744 | } |
---|
745 | |
---|
746 | // Fill top border with rec. samples |
---|
747 | piRoiTemp = piRoiOrigin - iPicStride; |
---|
748 | for (i=0; i<uiCuWidth; i++) |
---|
749 | piAdiTemp[1+i] = piRoiTemp[i]; |
---|
750 | |
---|
751 | // Fill top right border with rec. samples |
---|
752 | piRoiTemp = piRoiOrigin - iPicStride + uiCuWidth; |
---|
753 | for (i=0; i<uiCuWidth; i++) |
---|
754 | piAdiTemp[1+uiCuWidth+i] = piRoiTemp[i]; |
---|
755 | } |
---|
756 | else // reference samples are partially available |
---|
757 | { |
---|
758 | Int iNumUnits2 = iNumUnitsInCu<<1; |
---|
759 | Int iTotalSamples = iTotalUnits*iUnitSize; |
---|
760 | Pel *piAdiLine = new Pel[iTotalSamples]; |
---|
761 | Pel *piAdiLineTemp; |
---|
762 | Bool *pbNeighborFlags; |
---|
763 | Int iPrev, iNext, iCurr; |
---|
764 | Pel piRef = 0; |
---|
765 | |
---|
766 | // Initialize |
---|
767 | for (i=0; i<iTotalSamples; i++) |
---|
768 | piAdiLine[i] = iDCValue; |
---|
769 | |
---|
770 | // Fill top-left sample |
---|
771 | piRoiTemp = piRoiOrigin - iPicStride - 1; |
---|
772 | piAdiLineTemp = piAdiLine + (iNumUnits2*iUnitSize); |
---|
773 | pbNeighborFlags = bNeighborFlags + iNumUnits2; |
---|
774 | if (*pbNeighborFlags) |
---|
775 | { |
---|
776 | piAdiLineTemp[0] = piRoiTemp[0]; |
---|
777 | for (i=1; i<iUnitSize; i++) |
---|
778 | piAdiLineTemp[i] = piAdiLineTemp[0]; |
---|
779 | } |
---|
780 | |
---|
781 | // Fill left & below-left samples |
---|
782 | piRoiTemp += iPicStride; |
---|
783 | piAdiLineTemp--; |
---|
784 | pbNeighborFlags--; |
---|
785 | for (j=0; j<iNumUnits2; j++) |
---|
786 | { |
---|
787 | if (*pbNeighborFlags) |
---|
788 | { |
---|
789 | for (i=0; i<iUnitSize; i++) |
---|
790 | piAdiLineTemp[-i] = piRoiTemp[i*iPicStride]; |
---|
791 | } |
---|
792 | piRoiTemp += iUnitSize*iPicStride; |
---|
793 | piAdiLineTemp -= iUnitSize; |
---|
794 | pbNeighborFlags--; |
---|
795 | } |
---|
796 | |
---|
797 | // Fill above & above-right samples |
---|
798 | piRoiTemp = piRoiOrigin - iPicStride; |
---|
799 | piAdiLineTemp = piAdiLine + ((iNumUnits2+1)*iUnitSize); |
---|
800 | pbNeighborFlags = bNeighborFlags + iNumUnits2 + 1; |
---|
801 | for (j=0; j<iNumUnits2; j++) |
---|
802 | { |
---|
803 | if (*pbNeighborFlags) |
---|
804 | { |
---|
805 | for (i=0; i<iUnitSize; i++) |
---|
806 | piAdiLineTemp[i] = piRoiTemp[i]; |
---|
807 | } |
---|
808 | piRoiTemp += iUnitSize; |
---|
809 | piAdiLineTemp += iUnitSize; |
---|
810 | pbNeighborFlags++; |
---|
811 | } |
---|
812 | |
---|
813 | // Pad reference samples when necessary |
---|
814 | iPrev = -1; |
---|
815 | iCurr = 0; |
---|
816 | iNext = 1; |
---|
817 | piAdiLineTemp = piAdiLine; |
---|
818 | while (iCurr < iTotalUnits) |
---|
819 | { |
---|
820 | if (bNeighborFlags[iCurr]) |
---|
821 | { |
---|
822 | // Move on to next block if current unit is available |
---|
823 | piAdiLineTemp += iUnitSize; |
---|
824 | iPrev++; |
---|
825 | iCurr++; |
---|
826 | iNext++; |
---|
827 | } |
---|
828 | else |
---|
829 | { |
---|
830 | // Interpolate from nearest samples if current unit is not available |
---|
831 | |
---|
832 | while (iNext < iTotalUnits && !bNeighborFlags[iNext]) |
---|
833 | iNext++; |
---|
834 | |
---|
835 | if (iPrev >= 0 && iNext < iTotalUnits) |
---|
836 | piRef = (piAdiLine[iCurr*iUnitSize-1] + piAdiLine[iNext*iUnitSize] + 1) >> 1; |
---|
837 | else if (iPrev >= 0) |
---|
838 | piRef = piAdiLine[iCurr*iUnitSize-1]; |
---|
839 | else if (iNext < iTotalUnits) |
---|
840 | piRef = piAdiLine[iNext*iUnitSize]; |
---|
841 | else |
---|
842 | printf("\nERROR! No valid samples to interpolate.\n"); |
---|
843 | |
---|
844 | // Pad unavailable samples with new value |
---|
845 | while (iCurr < iNext) |
---|
846 | { |
---|
847 | for (i=0; i<iUnitSize; i++) |
---|
848 | piAdiLineTemp[i] = piRef; |
---|
849 | piAdiLineTemp += iUnitSize; |
---|
850 | iPrev++; |
---|
851 | iCurr++; |
---|
852 | } |
---|
853 | iNext++; |
---|
854 | } |
---|
855 | } |
---|
856 | |
---|
857 | // Copy processed samples |
---|
858 | piAdiLineTemp = piAdiLine + uiHeight + iUnitSize - 2; |
---|
859 | for (i=0; i<uiWidth; i++) |
---|
860 | piAdiTemp[i] = piAdiLineTemp[i]; |
---|
861 | piAdiLineTemp = piAdiLine + uiHeight - 1; |
---|
862 | for (i=1; i<uiHeight; i++) |
---|
863 | piAdiTemp[i*uiWidth] = piAdiLineTemp[-i]; |
---|
864 | |
---|
865 | delete [] piAdiLine; |
---|
866 | piAdiLine = NULL; |
---|
867 | } |
---|
868 | } |
---|
869 | #endif // REFERENCE_SAMPLE_PADDING |
---|
870 | |
---|
871 | Int* TComPattern::getAdiOrgBuf( Int iCuWidth, Int iCuHeight, Int* piAdiBuf) |
---|
872 | { |
---|
873 | return piAdiBuf; |
---|
874 | } |
---|
875 | |
---|
876 | Int* TComPattern::getAdiCbBuf( Int iCuWidth, Int iCuHeight, Int* piAdiBuf) |
---|
877 | { |
---|
878 | return piAdiBuf; |
---|
879 | } |
---|
880 | |
---|
881 | Int* TComPattern::getAdiCrBuf(Int iCuWidth,Int iCuHeight, Int* piAdiBuf) |
---|
882 | { |
---|
883 | return piAdiBuf+(iCuWidth*2+1)*(iCuHeight*2+1); |
---|
884 | } |
---|
885 | |
---|
886 | #if QC_MDIS |
---|
887 | #if HHI_DISABLE_INTRA_SMOOTHING_DEPTH |
---|
888 | Int* TComPattern::getPredictorPtr ( UInt uiDirMode, UInt uiWidthBits, Int iCuWidth, Int iCuHeight, Int* piAdiBuf, Bool bDepth ) |
---|
889 | #else |
---|
890 | Int* TComPattern::getPredictorPtr ( UInt uiDirMode, UInt uiWidthBits, Int iCuWidth, Int iCuHeight, Int* piAdiBuf ) |
---|
891 | #endif |
---|
892 | { |
---|
893 | #if MN_MDIS_SIMPLIFICATION |
---|
894 | static const UChar g_aucIntraFilter[7][34] = |
---|
895 | { |
---|
896 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //2x2 |
---|
897 | {0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //4x4 |
---|
898 | {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //8x8 |
---|
899 | {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //16x16 |
---|
900 | {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, //32x32 |
---|
901 | {0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //64x64 |
---|
902 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} //128x128 |
---|
903 | }; |
---|
904 | #else |
---|
905 | static const UChar g_aucIntraFilter[7][34] = |
---|
906 | { |
---|
907 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //2x2 |
---|
908 | {0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //4x4 |
---|
909 | {0, 0, 0, 1, 1, 2, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //8x8 |
---|
910 | {0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //16x16 |
---|
911 | {0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, //32x32 |
---|
912 | {0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //64x64 |
---|
913 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} //128x128 |
---|
914 | }; |
---|
915 | #endif |
---|
916 | |
---|
917 | Int* piSrc; |
---|
918 | #if ADD_PLANAR_MODE |
---|
919 | mapPlanartoDC( uiDirMode ); |
---|
920 | #endif |
---|
921 | #if HHI_DISABLE_INTRA_SMOOTHING_DEPTH |
---|
922 | UChar ucFiltIdx = 0; |
---|
923 | if ( !bDepth ) |
---|
924 | { |
---|
925 | ucFiltIdx = g_aucIntraFilter[uiWidthBits][uiDirMode]; |
---|
926 | } |
---|
927 | #else |
---|
928 | #if HHI_DMM_INTRA |
---|
929 | UChar ucFiltIdx = 0; |
---|
930 | if ( uiDirMode < 34 ) |
---|
931 | { |
---|
932 | ucFiltIdx = g_aucIntraFilter[uiWidthBits][uiDirMode]; |
---|
933 | } |
---|
934 | #else |
---|
935 | UChar ucFiltIdx = g_aucIntraFilter[uiWidthBits][uiDirMode]; |
---|
936 | #endif |
---|
937 | #endif |
---|
938 | |
---|
939 | #if MN_MDIS_SIMPLIFICATION |
---|
940 | assert( ucFiltIdx <= 1 ); |
---|
941 | #else |
---|
942 | assert( ucFiltIdx <= 2 ); |
---|
943 | #endif |
---|
944 | |
---|
945 | piSrc = getAdiOrgBuf( iCuWidth, iCuHeight, piAdiBuf ); |
---|
946 | |
---|
947 | if ( ucFiltIdx ) |
---|
948 | { |
---|
949 | #if MN_MDIS_SIMPLIFICATION |
---|
950 | piSrc += ((iCuWidth << 1) + 1) * ((iCuHeight << 1) + 1); |
---|
951 | #else |
---|
952 | piSrc += (((iCuWidth << 1) + 1) * ((iCuHeight << 1) + 1) << (ucFiltIdx - 1)); |
---|
953 | #endif |
---|
954 | } |
---|
955 | |
---|
956 | return piSrc; |
---|
957 | } |
---|
958 | #endif //QC_MDIS |
---|
959 | |
---|
960 | #if CONSTRAINED_INTRA_PRED |
---|
961 | Bool TComPattern::isAboveLeftAvailableForCIP( TComDataCU* pcCU, UInt uiPartIdxLT ) |
---|
962 | { |
---|
963 | Bool bAboveLeftFlag; |
---|
964 | UInt uiPartAboveLeft; |
---|
965 | TComDataCU* pcCUAboveLeft = pcCU->getPUAboveLeft( uiPartAboveLeft, uiPartIdxLT, true, false ); |
---|
966 | bAboveLeftFlag = ( pcCUAboveLeft && pcCUAboveLeft->getPredictionMode( uiPartAboveLeft ) == MODE_INTRA ); |
---|
967 | return bAboveLeftFlag; |
---|
968 | } |
---|
969 | |
---|
970 | #if REFERENCE_SAMPLE_PADDING |
---|
971 | Int TComPattern::isAboveAvailableForCIP( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags ) |
---|
972 | #else |
---|
973 | Bool TComPattern::isAboveAvailableForCIP( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT ) |
---|
974 | #endif |
---|
975 | { |
---|
976 | const UInt uiRasterPartBegin = g_auiZscanToRaster[uiPartIdxLT]; |
---|
977 | const UInt uiRasterPartEnd = g_auiZscanToRaster[uiPartIdxRT]+1; |
---|
978 | const UInt uiIdxStep = 1; |
---|
979 | #if REFERENCE_SAMPLE_PADDING |
---|
980 | Bool *pbValidFlags = bValidFlags; |
---|
981 | Int iNumIntra = 0; |
---|
982 | #else |
---|
983 | Bool bAboveFlag = true; |
---|
984 | #endif |
---|
985 | #if MN_DC_PRED_FILTER |
---|
986 | m_bAboveFlagForDCFilt = true; |
---|
987 | #endif |
---|
988 | |
---|
989 | for ( UInt uiRasterPart = uiRasterPartBegin; uiRasterPart < uiRasterPartEnd; uiRasterPart += uiIdxStep ) |
---|
990 | { |
---|
991 | UInt uiPartAbove; |
---|
992 | TComDataCU* pcCUAbove = pcCU->getPUAbove( uiPartAbove, g_auiRasterToZscan[uiRasterPart], true, false ); |
---|
993 | #if REFERENCE_SAMPLE_PADDING |
---|
994 | if ( pcCUAbove && pcCUAbove->getPredictionMode( uiPartAbove ) == MODE_INTRA ) |
---|
995 | { |
---|
996 | iNumIntra++; |
---|
997 | *pbValidFlags = true; |
---|
998 | } |
---|
999 | else |
---|
1000 | { |
---|
1001 | *pbValidFlags = false; |
---|
1002 | #if MN_DC_PRED_FILTER |
---|
1003 | m_bAboveFlagForDCFilt = false; |
---|
1004 | #endif |
---|
1005 | } |
---|
1006 | pbValidFlags++; |
---|
1007 | #else |
---|
1008 | if ( !pcCUAbove || pcCUAbove->getPredictionMode( uiPartAbove ) != MODE_INTRA ) |
---|
1009 | { |
---|
1010 | bAboveFlag = false; |
---|
1011 | #if MN_DC_PRED_FILTER |
---|
1012 | m_bAboveFlagForDCFilt = false; |
---|
1013 | #endif |
---|
1014 | break; |
---|
1015 | } |
---|
1016 | #endif |
---|
1017 | } |
---|
1018 | #if REFERENCE_SAMPLE_PADDING |
---|
1019 | return iNumIntra; |
---|
1020 | #else |
---|
1021 | return bAboveFlag; |
---|
1022 | #endif |
---|
1023 | } |
---|
1024 | |
---|
1025 | #if REFERENCE_SAMPLE_PADDING |
---|
1026 | Int TComPattern::isLeftAvailableForCIP( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags ) |
---|
1027 | #else |
---|
1028 | Bool TComPattern::isLeftAvailableForCIP( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB ) |
---|
1029 | #endif |
---|
1030 | { |
---|
1031 | const UInt uiRasterPartBegin = g_auiZscanToRaster[uiPartIdxLT]; |
---|
1032 | const UInt uiRasterPartEnd = g_auiZscanToRaster[uiPartIdxLB]+1; |
---|
1033 | const UInt uiIdxStep = pcCU->getPic()->getNumPartInWidth(); |
---|
1034 | #if REFERENCE_SAMPLE_PADDING |
---|
1035 | Bool *pbValidFlags = bValidFlags; |
---|
1036 | Int iNumIntra = 0; |
---|
1037 | #else |
---|
1038 | Bool bLeftFlag = true; |
---|
1039 | #endif |
---|
1040 | #if MN_DC_PRED_FILTER |
---|
1041 | m_bLeftFlagForDCFilt = true; |
---|
1042 | #endif |
---|
1043 | |
---|
1044 | for ( UInt uiRasterPart = uiRasterPartBegin; uiRasterPart < uiRasterPartEnd; uiRasterPart += uiIdxStep ) |
---|
1045 | { |
---|
1046 | UInt uiPartLeft; |
---|
1047 | TComDataCU* pcCULeft = pcCU->getPULeft( uiPartLeft, g_auiRasterToZscan[uiRasterPart], true, false ); |
---|
1048 | #if REFERENCE_SAMPLE_PADDING |
---|
1049 | if ( pcCULeft && pcCULeft->getPredictionMode( uiPartLeft ) == MODE_INTRA ) |
---|
1050 | { |
---|
1051 | iNumIntra++; |
---|
1052 | *pbValidFlags = true; |
---|
1053 | } |
---|
1054 | else |
---|
1055 | { |
---|
1056 | *pbValidFlags = false; |
---|
1057 | #if MN_DC_PRED_FILTER |
---|
1058 | m_bLeftFlagForDCFilt = false; |
---|
1059 | #endif |
---|
1060 | } |
---|
1061 | pbValidFlags--; // opposite direction |
---|
1062 | #else |
---|
1063 | if ( !pcCULeft || pcCULeft->getPredictionMode( uiPartLeft ) != MODE_INTRA ) |
---|
1064 | { |
---|
1065 | bLeftFlag = false; |
---|
1066 | #if MN_DC_PRED_FILTER |
---|
1067 | m_bLeftFlagForDCFilt = false; |
---|
1068 | #endif |
---|
1069 | break; |
---|
1070 | } |
---|
1071 | #endif |
---|
1072 | } |
---|
1073 | |
---|
1074 | #if REFERENCE_SAMPLE_PADDING |
---|
1075 | return iNumIntra; |
---|
1076 | #else |
---|
1077 | return bLeftFlag; |
---|
1078 | #endif |
---|
1079 | } |
---|
1080 | |
---|
1081 | #if REFERENCE_SAMPLE_PADDING |
---|
1082 | Int TComPattern::isAboveRightAvailableForCIP( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags ) |
---|
1083 | #else |
---|
1084 | Bool TComPattern::isAboveRightAvailableForCIP( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT ) |
---|
1085 | #endif |
---|
1086 | { |
---|
1087 | const UInt uiNumUnitsInPU = g_auiZscanToRaster[uiPartIdxRT] - g_auiZscanToRaster[uiPartIdxLT] + 1; |
---|
1088 | const UInt uiPuWidth = uiNumUnitsInPU * pcCU->getPic()->getMinCUWidth(); |
---|
1089 | #if REFERENCE_SAMPLE_PADDING |
---|
1090 | Bool *pbValidFlags = bValidFlags; |
---|
1091 | Int iNumIntra = 0; |
---|
1092 | #else |
---|
1093 | Bool bAboveRightFlag = true; |
---|
1094 | #endif |
---|
1095 | |
---|
1096 | for ( UInt uiOffset = 1; uiOffset <= uiNumUnitsInPU; uiOffset++ ) |
---|
1097 | { |
---|
1098 | UInt uiPartAboveRight; |
---|
1099 | TComDataCU* pcCUAboveRight = pcCU->getPUAboveRightAdi( uiPartAboveRight, uiPuWidth, uiPartIdxRT, uiOffset, true, false ); |
---|
1100 | #if REFERENCE_SAMPLE_PADDING |
---|
1101 | if ( pcCUAboveRight && pcCUAboveRight->getPredictionMode( uiPartAboveRight ) == MODE_INTRA ) |
---|
1102 | { |
---|
1103 | iNumIntra++; |
---|
1104 | *pbValidFlags = true; |
---|
1105 | } |
---|
1106 | else |
---|
1107 | { |
---|
1108 | *pbValidFlags = false; |
---|
1109 | } |
---|
1110 | pbValidFlags++; |
---|
1111 | #else |
---|
1112 | if ( !pcCUAboveRight || pcCUAboveRight->getPredictionMode( uiPartAboveRight ) != MODE_INTRA ) |
---|
1113 | { |
---|
1114 | bAboveRightFlag = false; |
---|
1115 | break; |
---|
1116 | } |
---|
1117 | #endif |
---|
1118 | } |
---|
1119 | |
---|
1120 | #if REFERENCE_SAMPLE_PADDING |
---|
1121 | return iNumIntra; |
---|
1122 | #else |
---|
1123 | return bAboveRightFlag; |
---|
1124 | #endif |
---|
1125 | } |
---|
1126 | |
---|
1127 | #if REFERENCE_SAMPLE_PADDING |
---|
1128 | Int TComPattern::isBelowLeftAvailableForCIP( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags ) |
---|
1129 | #else |
---|
1130 | Bool TComPattern::isBelowLeftAvailableForCIP( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB ) |
---|
1131 | #endif |
---|
1132 | { |
---|
1133 | const UInt uiNumUnitsInPU = (g_auiZscanToRaster[uiPartIdxLB] - g_auiZscanToRaster[uiPartIdxLT]) / pcCU->getPic()->getNumPartInWidth() + 1; |
---|
1134 | const UInt uiPuHeight = uiNumUnitsInPU * pcCU->getPic()->getMinCUHeight(); |
---|
1135 | #if REFERENCE_SAMPLE_PADDING |
---|
1136 | Bool *pbValidFlags = bValidFlags; |
---|
1137 | Int iNumIntra = 0; |
---|
1138 | #else |
---|
1139 | Bool bBelowLeftFlag = true; |
---|
1140 | #endif |
---|
1141 | |
---|
1142 | for ( UInt uiOffset = 1; uiOffset <= uiNumUnitsInPU; uiOffset++ ) |
---|
1143 | { |
---|
1144 | UInt uiPartBelowLeft; |
---|
1145 | TComDataCU* pcCUBelowLeft = pcCU->getPUBelowLeftAdi( uiPartBelowLeft, uiPuHeight, uiPartIdxLB, uiOffset, true, false ); |
---|
1146 | #if REFERENCE_SAMPLE_PADDING |
---|
1147 | if ( pcCUBelowLeft && pcCUBelowLeft->getPredictionMode( uiPartBelowLeft ) == MODE_INTRA ) |
---|
1148 | { |
---|
1149 | iNumIntra++; |
---|
1150 | *pbValidFlags = true; |
---|
1151 | } |
---|
1152 | else |
---|
1153 | { |
---|
1154 | *pbValidFlags = false; |
---|
1155 | } |
---|
1156 | pbValidFlags--; // opposite direction |
---|
1157 | #else |
---|
1158 | if ( !pcCUBelowLeft || pcCUBelowLeft->getPredictionMode( uiPartBelowLeft ) != MODE_INTRA ) |
---|
1159 | { |
---|
1160 | bBelowLeftFlag = false; |
---|
1161 | break; |
---|
1162 | } |
---|
1163 | #endif |
---|
1164 | } |
---|
1165 | |
---|
1166 | #if REFERENCE_SAMPLE_PADDING |
---|
1167 | return iNumIntra; |
---|
1168 | #else |
---|
1169 | return bBelowLeftFlag; |
---|
1170 | #endif |
---|
1171 | } |
---|
1172 | #endif //CONSTRAINED_INTRA_PRED |
---|