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