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