[5] | 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 |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[56] | 6 | * Copyright (c) 2010-2012, ITU/ISO/IEC |
---|
[5] | 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. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 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 | */ |
---|
[2] | 33 | |
---|
| 34 | /** \file TComPattern.cpp |
---|
| 35 | \brief neighbouring pixel access classes |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include "TComPic.h" |
---|
| 39 | #include "TComPattern.h" |
---|
| 40 | #include "TComDataCU.h" |
---|
| 41 | |
---|
[56] | 42 | //! \ingroup TLibCommon |
---|
| 43 | //! \{ |
---|
| 44 | |
---|
[2] | 45 | // ==================================================================================================================== |
---|
| 46 | // Tables |
---|
| 47 | // ==================================================================================================================== |
---|
| 48 | |
---|
[56] | 49 | #if LOGI_INTRA_NAME_3MPM |
---|
| 50 | const UChar TComPattern::m_aucIntraFilter[5] = |
---|
[2] | 51 | { |
---|
[56] | 52 | 10, //4x4 |
---|
| 53 | 7, //8x8 |
---|
| 54 | 1, //16x16 |
---|
| 55 | 0, //32x32 |
---|
| 56 | 10, //64x64 |
---|
[2] | 57 | }; |
---|
[56] | 58 | #else |
---|
| 59 | const UChar TComPattern::m_aucIntraFilter[5][NUM_INTRA_MODE] = |
---|
| 60 | { |
---|
| 61 | {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, 0, 0 |
---|
| 62 | }, //4x4 |
---|
| 63 | {1, 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, 0 |
---|
| 64 | }, //8x8 |
---|
| 65 | {1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0 |
---|
| 66 | }, //16x16 |
---|
| 67 | {1, 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, 0 |
---|
| 68 | }, //32x32 |
---|
| 69 | {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, 0, 0 |
---|
| 70 | }, //64x64 |
---|
| 71 | }; |
---|
| 72 | #endif |
---|
[2] | 73 | |
---|
| 74 | // ==================================================================================================================== |
---|
| 75 | // Public member functions (TComPatternParam) |
---|
| 76 | // ==================================================================================================================== |
---|
| 77 | |
---|
| 78 | /** \param piTexture pixel data |
---|
| 79 | \param iRoiWidth pattern width |
---|
| 80 | \param iRoiHeight pattern height |
---|
| 81 | \param iStride buffer stride |
---|
| 82 | \param iOffsetLeft neighbour offset (left) |
---|
| 83 | \param iOffsetRight neighbour offset (right) |
---|
| 84 | \param iOffsetAbove neighbour offset (above) |
---|
| 85 | \param iOffsetBottom neighbour offset (bottom) |
---|
| 86 | */ |
---|
| 87 | Void TComPatternParam::setPatternParamPel ( Pel* piTexture, |
---|
| 88 | Int iRoiWidth, |
---|
| 89 | Int iRoiHeight, |
---|
| 90 | Int iStride, |
---|
| 91 | Int iOffsetLeft, |
---|
| 92 | Int iOffsetRight, |
---|
| 93 | Int iOffsetAbove, |
---|
| 94 | Int iOffsetBottom ) |
---|
| 95 | { |
---|
| 96 | m_piPatternOrigin = piTexture; |
---|
| 97 | m_iROIWidth = iRoiWidth; |
---|
| 98 | m_iROIHeight = iRoiHeight; |
---|
| 99 | m_iPatternStride = iStride; |
---|
| 100 | m_iOffsetLeft = iOffsetLeft; |
---|
| 101 | m_iOffsetAbove = iOffsetAbove; |
---|
| 102 | m_iOffsetRight = iOffsetRight; |
---|
| 103 | m_iOffsetBottom = iOffsetBottom; |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | /** |
---|
| 107 | \param pcCU CU data structure |
---|
| 108 | \param iComp component index (0=Y, 1=Cb, 2=Cr) |
---|
| 109 | \param iRoiWidth pattern width |
---|
| 110 | \param iRoiHeight pattern height |
---|
| 111 | \param iStride buffer stride |
---|
| 112 | \param iOffsetLeft neighbour offset (left) |
---|
| 113 | \param iOffsetRight neighbour offset (right) |
---|
| 114 | \param iOffsetAbove neighbour offset (above) |
---|
| 115 | \param iOffsetBottom neighbour offset (bottom) |
---|
| 116 | \param uiPartDepth CU depth |
---|
| 117 | \param uiAbsPartIdx part index |
---|
| 118 | */ |
---|
| 119 | Void TComPatternParam::setPatternParamCU( TComDataCU* pcCU, |
---|
| 120 | UChar iComp, |
---|
| 121 | UChar iRoiWidth, |
---|
| 122 | UChar iRoiHeight, |
---|
| 123 | Int iOffsetLeft, |
---|
| 124 | Int iOffsetRight, |
---|
| 125 | Int iOffsetAbove, |
---|
| 126 | Int iOffsetBottom, |
---|
| 127 | UInt uiPartDepth, |
---|
[56] | 128 | UInt uiAbsPartIdx |
---|
[5] | 129 | #if DEPTH_MAP_GENERATION |
---|
[56] | 130 | ,Bool bPrdDepthMap |
---|
[5] | 131 | #endif |
---|
| 132 | ) |
---|
[2] | 133 | { |
---|
| 134 | m_iOffsetLeft = iOffsetLeft; |
---|
| 135 | m_iOffsetRight = iOffsetRight; |
---|
| 136 | m_iOffsetAbove = iOffsetAbove; |
---|
| 137 | m_iOffsetBottom = iOffsetBottom; |
---|
| 138 | |
---|
| 139 | m_iROIWidth = iRoiWidth; |
---|
| 140 | m_iROIHeight = iRoiHeight; |
---|
| 141 | |
---|
| 142 | UInt uiAbsZorderIdx = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
| 143 | |
---|
[5] | 144 | #if DEPTH_MAP_GENERATION |
---|
[2] | 145 | TComPicYuv* pcPic = ( bPrdDepthMap ? pcCU->getPic()->getPredDepthMap() : pcCU->getPic()->getPicYuvRec() ); |
---|
[5] | 146 | #else |
---|
| 147 | TComPicYuv* pcPic = pcCU->getPic()->getPicYuvRec(); |
---|
| 148 | #endif |
---|
[56] | 149 | |
---|
[2] | 150 | if ( iComp == 0 ) |
---|
| 151 | { |
---|
[21] | 152 | #if DEPTH_MAP_GENERATION |
---|
| 153 | m_iPatternStride = ( bPrdDepthMap ? pcCU->getPic()->getPredDepthMap()->getStride() : pcCU->getPic()->getStride() ); |
---|
| 154 | #else |
---|
[2] | 155 | m_iPatternStride = pcCU->getPic()->getStride(); |
---|
[21] | 156 | #endif |
---|
[2] | 157 | m_piPatternOrigin = pcPic->getLumaAddr(pcCU->getAddr(), uiAbsZorderIdx) - m_iOffsetAbove * m_iPatternStride - m_iOffsetLeft; |
---|
| 158 | } |
---|
| 159 | else |
---|
| 160 | { |
---|
[21] | 161 | #if DEPTH_MAP_GENERATION |
---|
| 162 | m_iPatternStride = ( bPrdDepthMap ? pcCU->getPic()->getPredDepthMap()->getCStride() : pcCU->getPic()->getCStride() ); |
---|
| 163 | #else |
---|
[2] | 164 | m_iPatternStride = pcCU->getPic()->getCStride(); |
---|
[21] | 165 | #endif |
---|
[2] | 166 | if ( iComp == 1 ) |
---|
[56] | 167 | { |
---|
[2] | 168 | m_piPatternOrigin = pcPic->getCbAddr(pcCU->getAddr(), uiAbsZorderIdx) - m_iOffsetAbove * m_iPatternStride - m_iOffsetLeft; |
---|
[56] | 169 | } |
---|
[2] | 170 | else |
---|
[56] | 171 | { |
---|
[2] | 172 | m_piPatternOrigin = pcPic->getCrAddr(pcCU->getAddr(), uiAbsZorderIdx) - m_iOffsetAbove * m_iPatternStride - m_iOffsetLeft; |
---|
[56] | 173 | } |
---|
[2] | 174 | } |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | // ==================================================================================================================== |
---|
| 178 | // Public member functions (TComPattern) |
---|
| 179 | // ==================================================================================================================== |
---|
| 180 | |
---|
| 181 | Void TComPattern::initPattern ( Pel* piY, |
---|
| 182 | Pel* piCb, |
---|
| 183 | Pel* piCr, |
---|
| 184 | Int iRoiWidth, |
---|
| 185 | Int iRoiHeight, |
---|
| 186 | Int iStride, |
---|
| 187 | Int iOffsetLeft, |
---|
| 188 | Int iOffsetRight, |
---|
| 189 | Int iOffsetAbove, |
---|
| 190 | Int iOffsetBottom ) |
---|
| 191 | { |
---|
| 192 | m_cPatternY. setPatternParamPel( piY, iRoiWidth, iRoiHeight, iStride, iOffsetLeft, iOffsetRight, iOffsetAbove, iOffsetBottom ); |
---|
| 193 | m_cPatternCb.setPatternParamPel( piCb, iRoiWidth >> 1, iRoiHeight >> 1, iStride >> 1, iOffsetLeft >> 1, iOffsetRight >> 1, iOffsetAbove >> 1, iOffsetBottom >> 1 ); |
---|
| 194 | m_cPatternCr.setPatternParamPel( piCr, iRoiWidth >> 1, iRoiHeight >> 1, iStride >> 1, iOffsetLeft >> 1, iOffsetRight >> 1, iOffsetAbove >> 1, iOffsetBottom >> 1 ); |
---|
| 195 | |
---|
| 196 | return; |
---|
| 197 | } |
---|
| 198 | |
---|
[56] | 199 | Void TComPattern::initPattern( TComDataCU* pcCU, UInt uiPartDepth, UInt uiAbsPartIdx |
---|
[5] | 200 | #if DEPTH_MAP_GENERATION |
---|
[56] | 201 | , Bool bPrdDepthMap |
---|
[5] | 202 | #endif |
---|
[56] | 203 | ) |
---|
[2] | 204 | { |
---|
| 205 | Int uiOffsetLeft = 0; |
---|
| 206 | Int uiOffsetRight = 0; |
---|
| 207 | Int uiOffsetAbove = 0; |
---|
| 208 | |
---|
| 209 | TComPic* pcPic = pcCU->getPic(); |
---|
| 210 | UChar uiWidth = pcCU->getWidth (0)>>uiPartDepth; |
---|
| 211 | UChar uiHeight = pcCU->getHeight(0)>>uiPartDepth; |
---|
| 212 | |
---|
| 213 | UInt uiAbsZorderIdx = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
| 214 | UInt uiCurrPicPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsZorderIdx] ]; |
---|
| 215 | UInt uiCurrPicPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsZorderIdx] ]; |
---|
| 216 | |
---|
| 217 | if( uiCurrPicPelX != 0 ) |
---|
[56] | 218 | { |
---|
[2] | 219 | uiOffsetLeft = 1; |
---|
[56] | 220 | } |
---|
| 221 | |
---|
[2] | 222 | if( uiCurrPicPelY != 0 ) |
---|
| 223 | { |
---|
| 224 | UInt uiNumPartInWidth = ( uiWidth/pcPic->getMinCUWidth() ); |
---|
| 225 | uiOffsetAbove = 1; |
---|
| 226 | |
---|
[56] | 227 | if( uiCurrPicPelX + uiWidth < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) |
---|
[2] | 228 | { |
---|
| 229 | if( ( g_auiZscanToRaster[uiAbsZorderIdx] + uiNumPartInWidth ) % pcPic->getNumPartInWidth() ) // Not CU boundary |
---|
| 230 | { |
---|
| 231 | if( g_auiRasterToZscan[ (Int)g_auiZscanToRaster[uiAbsZorderIdx] - (Int)pcPic->getNumPartInWidth() + (Int)uiNumPartInWidth ] < uiAbsZorderIdx ) |
---|
[56] | 232 | { |
---|
[2] | 233 | uiOffsetRight = 1; |
---|
[56] | 234 | } |
---|
[2] | 235 | } |
---|
| 236 | else // if it is CU boundary |
---|
| 237 | { |
---|
| 238 | if( g_auiZscanToRaster[uiAbsZorderIdx] < pcPic->getNumPartInWidth() && (uiCurrPicPelX+uiWidth) < pcPic->getPicYuvRec()->getWidth() ) // first line |
---|
| 239 | { |
---|
| 240 | uiOffsetRight = 1; |
---|
| 241 | } |
---|
| 242 | } |
---|
| 243 | } |
---|
| 244 | } |
---|
| 245 | |
---|
[5] | 246 | #if DEPTH_MAP_GENERATION |
---|
[2] | 247 | m_cPatternY .setPatternParamCU( pcCU, 0, uiWidth, uiHeight, uiOffsetLeft, uiOffsetRight, uiOffsetAbove, 0, uiPartDepth, uiAbsPartIdx, bPrdDepthMap ); |
---|
| 248 | m_cPatternCb.setPatternParamCU( pcCU, 1, uiWidth >> 1, uiHeight >> 1, uiOffsetLeft, uiOffsetRight, uiOffsetAbove, 0, uiPartDepth, uiAbsPartIdx, bPrdDepthMap ); |
---|
| 249 | m_cPatternCr.setPatternParamCU( pcCU, 2, uiWidth >> 1, uiHeight >> 1, uiOffsetLeft, uiOffsetRight, uiOffsetAbove, 0, uiPartDepth, uiAbsPartIdx, bPrdDepthMap ); |
---|
[5] | 250 | #else |
---|
| 251 | m_cPatternY .setPatternParamCU( pcCU, 0, uiWidth, uiHeight, uiOffsetLeft, uiOffsetRight, uiOffsetAbove, 0, uiPartDepth, uiAbsPartIdx ); |
---|
| 252 | m_cPatternCb.setPatternParamCU( pcCU, 1, uiWidth >> 1, uiHeight >> 1, uiOffsetLeft, uiOffsetRight, uiOffsetAbove, 0, uiPartDepth, uiAbsPartIdx ); |
---|
| 253 | m_cPatternCr.setPatternParamCU( pcCU, 2, uiWidth >> 1, uiHeight >> 1, uiOffsetLeft, uiOffsetRight, uiOffsetAbove, 0, uiPartDepth, uiAbsPartIdx ); |
---|
| 254 | #endif |
---|
[2] | 255 | } |
---|
| 256 | |
---|
[56] | 257 | Void TComPattern::initAdiPattern( TComDataCU* pcCU, UInt uiZorderIdxInPart, UInt uiPartDepth, Int* piAdiBuf, Int iOrgBufStride, Int iOrgBufHeight, Bool& bAbove, Bool& bLeft, Bool bLMmode |
---|
[5] | 258 | #if DEPTH_MAP_GENERATION |
---|
[56] | 259 | , Bool bPrdDepthMap, UInt uiSubSampExpX, UInt uiSubSampExpY |
---|
[5] | 260 | #endif |
---|
[56] | 261 | ) |
---|
[2] | 262 | { |
---|
| 263 | Pel* piRoiOrigin; |
---|
| 264 | Int* piAdiTemp; |
---|
| 265 | UInt uiCuWidth = pcCU->getWidth(0) >> uiPartDepth; |
---|
| 266 | UInt uiCuHeight = pcCU->getHeight(0)>> uiPartDepth; |
---|
| 267 | UInt uiCuWidth2 = uiCuWidth<<1; |
---|
| 268 | UInt uiCuHeight2 = uiCuHeight<<1; |
---|
| 269 | UInt uiWidth; |
---|
| 270 | UInt uiHeight; |
---|
[21] | 271 | #if DEPTH_MAP_GENERATION |
---|
| 272 | Int iPicStride = ( bPrdDepthMap ? pcCU->getPic()->getPredDepthMap()->getStride() : pcCU->getPic()->getStride() ); |
---|
| 273 | #else |
---|
[2] | 274 | Int iPicStride = pcCU->getPic()->getStride(); |
---|
[21] | 275 | #endif |
---|
[2] | 276 | Int iUnitSize = 0; |
---|
| 277 | Int iNumUnitsInCu = 0; |
---|
| 278 | Int iTotalUnits = 0; |
---|
[56] | 279 | Bool bNeighborFlags[4 * MAX_NUM_SPU_W + 1]; |
---|
[2] | 280 | Int iNumIntraNeighbor = 0; |
---|
| 281 | |
---|
[56] | 282 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
| 283 | |
---|
[2] | 284 | |
---|
| 285 | pcCU->deriveLeftRightTopIdxAdi( uiPartIdxLT, uiPartIdxRT, uiZorderIdxInPart, uiPartDepth ); |
---|
| 286 | pcCU->deriveLeftBottomIdxAdi ( uiPartIdxLB, uiZorderIdxInPart, uiPartDepth ); |
---|
| 287 | |
---|
[56] | 288 | iUnitSize = g_uiMaxCUWidth >> g_uiMaxCUDepth; |
---|
| 289 | iNumUnitsInCu = uiCuWidth / iUnitSize; |
---|
| 290 | iTotalUnits = (iNumUnitsInCu << 2) + 1; |
---|
[2] | 291 | |
---|
[56] | 292 | bNeighborFlags[iNumUnitsInCu*2] = isAboveLeftAvailable( pcCU, uiPartIdxLT ); |
---|
| 293 | iNumIntraNeighbor += (Int)(bNeighborFlags[iNumUnitsInCu*2]); |
---|
| 294 | iNumIntraNeighbor += isAboveAvailable ( pcCU, uiPartIdxLT, uiPartIdxRT, bNeighborFlags+(iNumUnitsInCu*2)+1 ); |
---|
| 295 | iNumIntraNeighbor += isAboveRightAvailable( pcCU, uiPartIdxLT, uiPartIdxRT, bNeighborFlags+(iNumUnitsInCu*3)+1 ); |
---|
| 296 | iNumIntraNeighbor += isLeftAvailable ( pcCU, uiPartIdxLT, uiPartIdxLB, bNeighborFlags+(iNumUnitsInCu*2)-1 ); |
---|
| 297 | iNumIntraNeighbor += isBelowLeftAvailable ( pcCU, uiPartIdxLT, uiPartIdxLB, bNeighborFlags+ iNumUnitsInCu -1 ); |
---|
[2] | 298 | |
---|
| 299 | bAbove = true; |
---|
| 300 | bLeft = true; |
---|
| 301 | |
---|
[21] | 302 | #if DEPTH_MAP_GENERATION |
---|
| 303 | if ( bPrdDepthMap ) |
---|
| 304 | { |
---|
| 305 | uiWidth = ( uiCuWidth2 >> uiSubSampExpX ) + 1; |
---|
| 306 | uiHeight = ( uiCuHeight2 >> uiSubSampExpY ) + 1; |
---|
| 307 | } |
---|
| 308 | else |
---|
| 309 | { |
---|
[56] | 310 | uiWidth=uiCuWidth2+1; |
---|
| 311 | uiHeight=uiCuHeight2+1; |
---|
[21] | 312 | } |
---|
| 313 | #else |
---|
| 314 | uiWidth=uiCuWidth2+1; |
---|
| 315 | uiHeight=uiCuHeight2+1; |
---|
| 316 | #endif |
---|
[2] | 317 | |
---|
| 318 | if (((uiWidth<<2)>iOrgBufStride)||((uiHeight<<2)>iOrgBufHeight)) |
---|
[56] | 319 | { |
---|
[2] | 320 | return; |
---|
[56] | 321 | } |
---|
[2] | 322 | |
---|
| 323 | piRoiOrigin = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiZorderIdxInPart); |
---|
| 324 | piAdiTemp = piAdiBuf; |
---|
| 325 | |
---|
[5] | 326 | #if DEPTH_MAP_GENERATION |
---|
[2] | 327 | if( bPrdDepthMap ) |
---|
| 328 | { |
---|
| 329 | piRoiOrigin = pcCU->getPic()->getPredDepthMap()->getLumaAddr( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiZorderIdxInPart ); |
---|
| 330 | } |
---|
[5] | 331 | #endif |
---|
[2] | 332 | |
---|
[5] | 333 | #if DEPTH_MAP_GENERATION |
---|
[21] | 334 | if ( bPrdDepthMap ) |
---|
[56] | 335 | fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize >> uiSubSampExpX, iNumUnitsInCu, iTotalUnits, uiCuWidth >> uiSubSampExpX, uiCuHeight >> uiSubSampExpY, uiWidth, uiHeight, iPicStride, bLMmode, bPrdDepthMap ); |
---|
[21] | 336 | else |
---|
[56] | 337 | fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride, bLMmode, bPrdDepthMap ); |
---|
[5] | 338 | #else |
---|
[56] | 339 | fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride, bLMmode); |
---|
[5] | 340 | #endif |
---|
[2] | 341 | |
---|
| 342 | |
---|
[56] | 343 | Int i; |
---|
[2] | 344 | // generate filtered intra prediction samples |
---|
| 345 | Int iBufSize = uiCuHeight2 + uiCuWidth2 + 1; // left and left above border + above and above right border + top left corner = length of 3. filter buffer |
---|
| 346 | |
---|
| 347 | UInt uiWH = uiWidth * uiHeight; // number of elements in one buffer |
---|
| 348 | |
---|
| 349 | Int* piFilteredBuf1 = piAdiBuf + uiWH; // 1. filter buffer |
---|
| 350 | Int* piFilteredBuf2 = piFilteredBuf1 + uiWH; // 2. filter buffer |
---|
| 351 | Int* piFilterBuf = piFilteredBuf2 + uiWH; // buffer for 2. filtering (sequential) |
---|
| 352 | Int* piFilterBufN = piFilterBuf + iBufSize; // buffer for 1. filtering (sequential) |
---|
| 353 | |
---|
| 354 | Int l = 0; |
---|
| 355 | // left border from bottom to top |
---|
| 356 | for (i = 0; i < uiCuHeight2; i++) |
---|
[56] | 357 | { |
---|
[2] | 358 | piFilterBuf[l++] = piAdiTemp[uiWidth * (uiCuHeight2 - i)]; |
---|
[56] | 359 | } |
---|
[2] | 360 | // top left corner |
---|
| 361 | piFilterBuf[l++] = piAdiTemp[0]; |
---|
| 362 | // above border from left to right |
---|
| 363 | for (i=0; i < uiCuWidth2; i++) |
---|
[56] | 364 | { |
---|
[2] | 365 | piFilterBuf[l++] = piAdiTemp[1 + i]; |
---|
[56] | 366 | } |
---|
[2] | 367 | |
---|
| 368 | // 1. filtering with [1 2 1] |
---|
| 369 | piFilterBufN[0] = piFilterBuf[0]; |
---|
| 370 | piFilterBufN[iBufSize - 1] = piFilterBuf[iBufSize - 1]; |
---|
| 371 | for (i = 1; i < iBufSize - 1; i++) |
---|
[56] | 372 | { |
---|
[2] | 373 | piFilterBufN[i] = (piFilterBuf[i - 1] + 2 * piFilterBuf[i]+piFilterBuf[i + 1] + 2) >> 2; |
---|
[56] | 374 | } |
---|
[2] | 375 | |
---|
| 376 | // fill 1. filter buffer with filtered values |
---|
| 377 | l=0; |
---|
| 378 | for (i = 0; i < uiCuHeight2; i++) |
---|
[56] | 379 | { |
---|
[2] | 380 | piFilteredBuf1[uiWidth * (uiCuHeight2 - i)] = piFilterBufN[l++]; |
---|
[56] | 381 | } |
---|
[2] | 382 | piFilteredBuf1[0] = piFilterBufN[l++]; |
---|
| 383 | for (i = 0; i < uiCuWidth2; i++) |
---|
[56] | 384 | { |
---|
[2] | 385 | piFilteredBuf1[1 + i] = piFilterBufN[l++]; |
---|
[56] | 386 | } |
---|
[2] | 387 | } |
---|
| 388 | |
---|
| 389 | Void TComPattern::initAdiPatternChroma( TComDataCU* pcCU, UInt uiZorderIdxInPart, UInt uiPartDepth, Int* piAdiBuf, Int iOrgBufStride, Int iOrgBufHeight, Bool& bAbove, Bool& bLeft ) |
---|
| 390 | { |
---|
| 391 | Pel* piRoiOrigin; |
---|
| 392 | Int* piAdiTemp; |
---|
| 393 | UInt uiCuWidth = pcCU->getWidth (0) >> uiPartDepth; |
---|
| 394 | UInt uiCuHeight = pcCU->getHeight(0) >> uiPartDepth; |
---|
| 395 | UInt uiWidth; |
---|
| 396 | UInt uiHeight; |
---|
| 397 | Int iPicStride = pcCU->getPic()->getCStride(); |
---|
[56] | 398 | |
---|
[2] | 399 | Int iUnitSize = 0; |
---|
| 400 | Int iNumUnitsInCu = 0; |
---|
| 401 | Int iTotalUnits = 0; |
---|
[56] | 402 | Bool bNeighborFlags[4 * MAX_NUM_SPU_W + 1]; |
---|
[2] | 403 | Int iNumIntraNeighbor = 0; |
---|
| 404 | |
---|
[56] | 405 | UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB; |
---|
[2] | 406 | |
---|
| 407 | pcCU->deriveLeftRightTopIdxAdi( uiPartIdxLT, uiPartIdxRT, uiZorderIdxInPart, uiPartDepth ); |
---|
| 408 | pcCU->deriveLeftBottomIdxAdi ( uiPartIdxLB, uiZorderIdxInPart, uiPartDepth ); |
---|
| 409 | |
---|
[56] | 410 | iUnitSize = (g_uiMaxCUWidth >> g_uiMaxCUDepth) >> 1; // for chroma |
---|
| 411 | iNumUnitsInCu = (uiCuWidth / iUnitSize) >> 1; // for chroma |
---|
| 412 | iTotalUnits = (iNumUnitsInCu << 2) + 1; |
---|
[2] | 413 | |
---|
[56] | 414 | bNeighborFlags[iNumUnitsInCu*2] = isAboveLeftAvailable( pcCU, uiPartIdxLT ); |
---|
| 415 | iNumIntraNeighbor += (Int)(bNeighborFlags[iNumUnitsInCu*2]); |
---|
| 416 | iNumIntraNeighbor += isAboveAvailable ( pcCU, uiPartIdxLT, uiPartIdxRT, bNeighborFlags+(iNumUnitsInCu*2)+1 ); |
---|
| 417 | iNumIntraNeighbor += isAboveRightAvailable( pcCU, uiPartIdxLT, uiPartIdxRT, bNeighborFlags+(iNumUnitsInCu*3)+1 ); |
---|
| 418 | iNumIntraNeighbor += isLeftAvailable ( pcCU, uiPartIdxLT, uiPartIdxLB, bNeighborFlags+(iNumUnitsInCu*2)-1 ); |
---|
| 419 | iNumIntraNeighbor += isBelowLeftAvailable ( pcCU, uiPartIdxLT, uiPartIdxLB, bNeighborFlags+ iNumUnitsInCu -1 ); |
---|
[2] | 420 | |
---|
| 421 | bAbove = true; |
---|
| 422 | bLeft = true; |
---|
| 423 | |
---|
| 424 | uiCuWidth=uiCuWidth>>1; // for chroma |
---|
| 425 | uiCuHeight=uiCuHeight>>1; // for chroma |
---|
| 426 | |
---|
| 427 | uiWidth=uiCuWidth*2+1; |
---|
| 428 | uiHeight=uiCuHeight*2+1; |
---|
| 429 | |
---|
| 430 | if ((4*uiWidth>iOrgBufStride)||(4*uiHeight>iOrgBufHeight)) |
---|
[56] | 431 | { |
---|
[2] | 432 | return; |
---|
[56] | 433 | } |
---|
[2] | 434 | |
---|
| 435 | // get Cb pattern |
---|
| 436 | piRoiOrigin = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiZorderIdxInPart); |
---|
| 437 | piAdiTemp = piAdiBuf; |
---|
| 438 | |
---|
[5] | 439 | #if DEPTH_MAP_GENERATION |
---|
[56] | 440 | fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride, false, false ); |
---|
[5] | 441 | #else |
---|
[56] | 442 | fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride); |
---|
[5] | 443 | #endif |
---|
[2] | 444 | |
---|
| 445 | // get Cr pattern |
---|
| 446 | piRoiOrigin = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiZorderIdxInPart); |
---|
| 447 | piAdiTemp = piAdiBuf+uiWidth*uiHeight; |
---|
| 448 | |
---|
[5] | 449 | #if DEPTH_MAP_GENERATION |
---|
[56] | 450 | fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride, false, false ); |
---|
[5] | 451 | #else |
---|
[56] | 452 | fillReferenceSamples ( pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor, iUnitSize, iNumUnitsInCu, iTotalUnits, uiCuWidth, uiCuHeight, uiWidth, uiHeight, iPicStride); |
---|
[5] | 453 | #endif |
---|
[2] | 454 | |
---|
| 455 | } |
---|
| 456 | |
---|
[56] | 457 | Void TComPattern::fillReferenceSamples( TComDataCU* pcCU, Pel* piRoiOrigin, Int* piAdiTemp, Bool* bNeighborFlags, Int iNumIntraNeighbor, Int iUnitSize, Int iNumUnitsInCu, Int iTotalUnits, UInt uiCuWidth, UInt uiCuHeight, UInt uiWidth, UInt uiHeight, Int iPicStride, Bool bLMmode |
---|
[5] | 458 | #if DEPTH_MAP_GENERATION |
---|
[56] | 459 | , Bool bPrdDepthMap |
---|
[5] | 460 | #endif |
---|
[56] | 461 | ) |
---|
[2] | 462 | { |
---|
| 463 | Pel* piRoiTemp; |
---|
| 464 | Int i, j; |
---|
[5] | 465 | #if DEPTH_MAP_GENERATION |
---|
[2] | 466 | Int iDCValue = ( bPrdDepthMap ? PDM_UNDEFINED_DEPTH : ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ) ); |
---|
[5] | 467 | #else |
---|
| 468 | Int iDCValue = ( 1<<( g_uiBitDepth + g_uiBitIncrement - 1) ); |
---|
| 469 | #endif |
---|
[56] | 470 | |
---|
[2] | 471 | if (iNumIntraNeighbor == 0) |
---|
| 472 | { |
---|
| 473 | // Fill border with DC value |
---|
| 474 | for (i=0; i<uiWidth; i++) |
---|
[56] | 475 | { |
---|
[2] | 476 | piAdiTemp[i] = iDCValue; |
---|
[56] | 477 | } |
---|
[2] | 478 | for (i=1; i<uiHeight; i++) |
---|
[56] | 479 | { |
---|
[2] | 480 | piAdiTemp[i*uiWidth] = iDCValue; |
---|
[56] | 481 | } |
---|
[2] | 482 | } |
---|
| 483 | else if (iNumIntraNeighbor == iTotalUnits) |
---|
| 484 | { |
---|
| 485 | // Fill top-left border with rec. samples |
---|
| 486 | piRoiTemp = piRoiOrigin - iPicStride - 1; |
---|
| 487 | piAdiTemp[0] = piRoiTemp[0]; |
---|
| 488 | |
---|
| 489 | // Fill left border with rec. samples |
---|
| 490 | piRoiTemp = piRoiOrigin - 1; |
---|
[56] | 491 | |
---|
| 492 | if (bLMmode) |
---|
| 493 | { |
---|
| 494 | piRoiTemp --; // move to the second left column |
---|
| 495 | } |
---|
| 496 | |
---|
[2] | 497 | for (i=0; i<uiCuHeight; i++) |
---|
| 498 | { |
---|
| 499 | piAdiTemp[(1+i)*uiWidth] = piRoiTemp[0]; |
---|
| 500 | piRoiTemp += iPicStride; |
---|
| 501 | } |
---|
| 502 | |
---|
| 503 | // Fill below left border with rec. samples |
---|
| 504 | for (i=0; i<uiCuHeight; i++) |
---|
| 505 | { |
---|
| 506 | piAdiTemp[(1+uiCuHeight+i)*uiWidth] = piRoiTemp[0]; |
---|
| 507 | piRoiTemp += iPicStride; |
---|
| 508 | } |
---|
| 509 | |
---|
| 510 | // Fill top border with rec. samples |
---|
| 511 | piRoiTemp = piRoiOrigin - iPicStride; |
---|
| 512 | for (i=0; i<uiCuWidth; i++) |
---|
[56] | 513 | { |
---|
[2] | 514 | piAdiTemp[1+i] = piRoiTemp[i]; |
---|
[56] | 515 | } |
---|
| 516 | |
---|
[2] | 517 | // Fill top right border with rec. samples |
---|
| 518 | piRoiTemp = piRoiOrigin - iPicStride + uiCuWidth; |
---|
| 519 | for (i=0; i<uiCuWidth; i++) |
---|
[56] | 520 | { |
---|
[2] | 521 | piAdiTemp[1+uiCuWidth+i] = piRoiTemp[i]; |
---|
[56] | 522 | } |
---|
[2] | 523 | } |
---|
| 524 | else // reference samples are partially available |
---|
| 525 | { |
---|
| 526 | Int iNumUnits2 = iNumUnitsInCu<<1; |
---|
| 527 | Int iTotalSamples = iTotalUnits*iUnitSize; |
---|
[56] | 528 | Pel piAdiLine[5 * MAX_CU_SIZE]; |
---|
[2] | 529 | Pel *piAdiLineTemp; |
---|
| 530 | Bool *pbNeighborFlags; |
---|
[56] | 531 | Int iNext, iCurr; |
---|
[2] | 532 | Pel piRef = 0; |
---|
| 533 | |
---|
| 534 | // Initialize |
---|
| 535 | for (i=0; i<iTotalSamples; i++) |
---|
[56] | 536 | { |
---|
[2] | 537 | piAdiLine[i] = iDCValue; |
---|
[56] | 538 | } |
---|
| 539 | |
---|
[2] | 540 | // Fill top-left sample |
---|
| 541 | piRoiTemp = piRoiOrigin - iPicStride - 1; |
---|
| 542 | piAdiLineTemp = piAdiLine + (iNumUnits2*iUnitSize); |
---|
| 543 | pbNeighborFlags = bNeighborFlags + iNumUnits2; |
---|
| 544 | if (*pbNeighborFlags) |
---|
| 545 | { |
---|
| 546 | piAdiLineTemp[0] = piRoiTemp[0]; |
---|
| 547 | for (i=1; i<iUnitSize; i++) |
---|
[56] | 548 | { |
---|
[2] | 549 | piAdiLineTemp[i] = piAdiLineTemp[0]; |
---|
[56] | 550 | } |
---|
[2] | 551 | } |
---|
| 552 | |
---|
| 553 | // Fill left & below-left samples |
---|
| 554 | piRoiTemp += iPicStride; |
---|
[56] | 555 | if (bLMmode) |
---|
| 556 | { |
---|
| 557 | piRoiTemp --; // move the second left column |
---|
| 558 | } |
---|
[2] | 559 | piAdiLineTemp--; |
---|
| 560 | pbNeighborFlags--; |
---|
| 561 | for (j=0; j<iNumUnits2; j++) |
---|
| 562 | { |
---|
| 563 | if (*pbNeighborFlags) |
---|
| 564 | { |
---|
| 565 | for (i=0; i<iUnitSize; i++) |
---|
[56] | 566 | { |
---|
[2] | 567 | piAdiLineTemp[-i] = piRoiTemp[i*iPicStride]; |
---|
[56] | 568 | } |
---|
[2] | 569 | } |
---|
| 570 | piRoiTemp += iUnitSize*iPicStride; |
---|
| 571 | piAdiLineTemp -= iUnitSize; |
---|
| 572 | pbNeighborFlags--; |
---|
| 573 | } |
---|
| 574 | |
---|
| 575 | // Fill above & above-right samples |
---|
| 576 | piRoiTemp = piRoiOrigin - iPicStride; |
---|
| 577 | piAdiLineTemp = piAdiLine + ((iNumUnits2+1)*iUnitSize); |
---|
| 578 | pbNeighborFlags = bNeighborFlags + iNumUnits2 + 1; |
---|
| 579 | for (j=0; j<iNumUnits2; j++) |
---|
| 580 | { |
---|
| 581 | if (*pbNeighborFlags) |
---|
| 582 | { |
---|
| 583 | for (i=0; i<iUnitSize; i++) |
---|
[56] | 584 | { |
---|
[2] | 585 | piAdiLineTemp[i] = piRoiTemp[i]; |
---|
[56] | 586 | } |
---|
[2] | 587 | } |
---|
| 588 | piRoiTemp += iUnitSize; |
---|
| 589 | piAdiLineTemp += iUnitSize; |
---|
| 590 | pbNeighborFlags++; |
---|
| 591 | } |
---|
| 592 | |
---|
| 593 | // Pad reference samples when necessary |
---|
| 594 | iCurr = 0; |
---|
| 595 | iNext = 1; |
---|
| 596 | piAdiLineTemp = piAdiLine; |
---|
| 597 | while (iCurr < iTotalUnits) |
---|
| 598 | { |
---|
[56] | 599 | if (!bNeighborFlags[iCurr]) |
---|
[2] | 600 | { |
---|
[56] | 601 | if(iCurr == 0) |
---|
| 602 | { |
---|
| 603 | while (iNext < iTotalUnits && !bNeighborFlags[iNext]) |
---|
| 604 | { |
---|
| 605 | iNext++; |
---|
| 606 | } |
---|
[2] | 607 | piRef = piAdiLine[iNext*iUnitSize]; |
---|
[56] | 608 | // Pad unavailable samples with new value |
---|
| 609 | while (iCurr < iNext) |
---|
| 610 | { |
---|
| 611 | for (i=0; i<iUnitSize; i++) |
---|
| 612 | { |
---|
| 613 | piAdiLineTemp[i] = piRef; |
---|
| 614 | } |
---|
| 615 | piAdiLineTemp += iUnitSize; |
---|
| 616 | iCurr++; |
---|
| 617 | } |
---|
| 618 | } |
---|
[2] | 619 | else |
---|
| 620 | { |
---|
[56] | 621 | piRef = piAdiLine[iCurr*iUnitSize-1]; |
---|
[2] | 622 | for (i=0; i<iUnitSize; i++) |
---|
[56] | 623 | { |
---|
[2] | 624 | piAdiLineTemp[i] = piRef; |
---|
[56] | 625 | } |
---|
[2] | 626 | piAdiLineTemp += iUnitSize; |
---|
| 627 | iCurr++; |
---|
| 628 | } |
---|
| 629 | } |
---|
[56] | 630 | else |
---|
| 631 | { |
---|
| 632 | piAdiLineTemp += iUnitSize; |
---|
| 633 | iCurr++; |
---|
| 634 | } |
---|
[2] | 635 | } |
---|
| 636 | |
---|
| 637 | // Copy processed samples |
---|
| 638 | piAdiLineTemp = piAdiLine + uiHeight + iUnitSize - 2; |
---|
| 639 | for (i=0; i<uiWidth; i++) |
---|
[56] | 640 | { |
---|
[2] | 641 | piAdiTemp[i] = piAdiLineTemp[i]; |
---|
[56] | 642 | } |
---|
[2] | 643 | piAdiLineTemp = piAdiLine + uiHeight - 1; |
---|
| 644 | for (i=1; i<uiHeight; i++) |
---|
[56] | 645 | { |
---|
[2] | 646 | piAdiTemp[i*uiWidth] = piAdiLineTemp[-i]; |
---|
[56] | 647 | } |
---|
[2] | 648 | } |
---|
| 649 | } |
---|
| 650 | |
---|
| 651 | Int* TComPattern::getAdiOrgBuf( Int iCuWidth, Int iCuHeight, Int* piAdiBuf) |
---|
| 652 | { |
---|
| 653 | return piAdiBuf; |
---|
| 654 | } |
---|
| 655 | |
---|
| 656 | Int* TComPattern::getAdiCbBuf( Int iCuWidth, Int iCuHeight, Int* piAdiBuf) |
---|
| 657 | { |
---|
| 658 | return piAdiBuf; |
---|
| 659 | } |
---|
| 660 | |
---|
| 661 | Int* TComPattern::getAdiCrBuf(Int iCuWidth,Int iCuHeight, Int* piAdiBuf) |
---|
| 662 | { |
---|
| 663 | return piAdiBuf+(iCuWidth*2+1)*(iCuHeight*2+1); |
---|
| 664 | } |
---|
| 665 | |
---|
[56] | 666 | /** Get pointer to reference samples for intra prediction |
---|
| 667 | * \param uiDirMode prediction mode index |
---|
| 668 | * \param log2BlkSize size of block (2 = 4x4, 3 = 8x8, 4 = 16x16, 5 = 32x32, 6 = 64x64) |
---|
| 669 | * \param piAdiBuf pointer to unfiltered reference samples |
---|
| 670 | * \return pointer to (possibly filtered) reference samples |
---|
| 671 | * |
---|
| 672 | * The prediction mode index is used to determine whether a smoothed reference sample buffer is returned. |
---|
| 673 | */ |
---|
| 674 | Int* TComPattern::getPredictorPtr( UInt uiDirMode, UInt log2BlkSize, Int* piAdiBuf ) |
---|
[2] | 675 | { |
---|
| 676 | Int* piSrc; |
---|
[100] | 677 | #if LGE_EDGE_INTRA |
---|
| 678 | mapEdgeIntratoDC( uiDirMode ); |
---|
| 679 | #endif |
---|
[56] | 680 | assert(log2BlkSize >= 2 && log2BlkSize < 7); |
---|
| 681 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
| 682 | mapDMMtoIntraMode( uiDirMode ); |
---|
[2] | 683 | #endif |
---|
[56] | 684 | #if LOGI_INTRA_NAME_3MPM |
---|
| 685 | Int diff = min<Int>(abs((Int) uiDirMode - HOR_IDX), abs((Int)uiDirMode - VER_IDX)); |
---|
| 686 | UChar ucFiltIdx = diff > m_aucIntraFilter[log2BlkSize - 2] ? 1 : 0; |
---|
| 687 | if (uiDirMode == DC_IDX || uiDirMode == LM_CHROMA_IDX) |
---|
[2] | 688 | { |
---|
[56] | 689 | ucFiltIdx = 0; //no smoothing for DC or LM chroma |
---|
[2] | 690 | } |
---|
| 691 | #else |
---|
[56] | 692 | UChar ucFiltIdx = m_aucIntraFilter[log2BlkSize - 2][uiDirMode]; |
---|
[2] | 693 | #endif |
---|
| 694 | |
---|
| 695 | assert( ucFiltIdx <= 1 ); |
---|
| 696 | |
---|
[56] | 697 | Int width = 1 << log2BlkSize; |
---|
| 698 | Int height = 1 << log2BlkSize; |
---|
| 699 | |
---|
| 700 | piSrc = getAdiOrgBuf( width, height, piAdiBuf ); |
---|
[2] | 701 | |
---|
| 702 | if ( ucFiltIdx ) |
---|
| 703 | { |
---|
[56] | 704 | piSrc += (2 * width + 1) * (2 * height + 1); |
---|
[2] | 705 | } |
---|
| 706 | |
---|
| 707 | return piSrc; |
---|
| 708 | } |
---|
| 709 | |
---|
[56] | 710 | Bool TComPattern::isAboveLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT ) |
---|
[2] | 711 | { |
---|
| 712 | Bool bAboveLeftFlag; |
---|
| 713 | UInt uiPartAboveLeft; |
---|
| 714 | TComDataCU* pcCUAboveLeft = pcCU->getPUAboveLeft( uiPartAboveLeft, uiPartIdxLT, true, false ); |
---|
[56] | 715 | if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred()) |
---|
| 716 | { |
---|
| 717 | bAboveLeftFlag = ( pcCUAboveLeft && pcCUAboveLeft->getPredictionMode( uiPartAboveLeft ) == MODE_INTRA ); |
---|
| 718 | } |
---|
| 719 | else |
---|
| 720 | { |
---|
| 721 | bAboveLeftFlag = (pcCUAboveLeft ? true : false); |
---|
| 722 | } |
---|
[2] | 723 | return bAboveLeftFlag; |
---|
| 724 | } |
---|
| 725 | |
---|
[56] | 726 | Int TComPattern::isAboveAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags ) |
---|
[2] | 727 | { |
---|
| 728 | const UInt uiRasterPartBegin = g_auiZscanToRaster[uiPartIdxLT]; |
---|
| 729 | const UInt uiRasterPartEnd = g_auiZscanToRaster[uiPartIdxRT]+1; |
---|
| 730 | const UInt uiIdxStep = 1; |
---|
| 731 | Bool *pbValidFlags = bValidFlags; |
---|
| 732 | Int iNumIntra = 0; |
---|
| 733 | |
---|
| 734 | for ( UInt uiRasterPart = uiRasterPartBegin; uiRasterPart < uiRasterPartEnd; uiRasterPart += uiIdxStep ) |
---|
| 735 | { |
---|
| 736 | UInt uiPartAbove; |
---|
| 737 | TComDataCU* pcCUAbove = pcCU->getPUAbove( uiPartAbove, g_auiRasterToZscan[uiRasterPart], true, false ); |
---|
[56] | 738 | if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred()) |
---|
[2] | 739 | { |
---|
[56] | 740 | if ( pcCUAbove && pcCUAbove->getPredictionMode( uiPartAbove ) == MODE_INTRA ) |
---|
| 741 | { |
---|
| 742 | iNumIntra++; |
---|
| 743 | *pbValidFlags = true; |
---|
| 744 | } |
---|
| 745 | else |
---|
| 746 | { |
---|
| 747 | *pbValidFlags = false; |
---|
| 748 | } |
---|
[2] | 749 | } |
---|
| 750 | else |
---|
| 751 | { |
---|
[56] | 752 | if (pcCUAbove) |
---|
| 753 | { |
---|
| 754 | iNumIntra++; |
---|
| 755 | *pbValidFlags = true; |
---|
| 756 | } |
---|
| 757 | else |
---|
| 758 | { |
---|
| 759 | *pbValidFlags = false; |
---|
| 760 | } |
---|
[2] | 761 | } |
---|
| 762 | pbValidFlags++; |
---|
| 763 | } |
---|
| 764 | return iNumIntra; |
---|
| 765 | } |
---|
| 766 | |
---|
[56] | 767 | Int TComPattern::isLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags ) |
---|
[2] | 768 | { |
---|
| 769 | const UInt uiRasterPartBegin = g_auiZscanToRaster[uiPartIdxLT]; |
---|
| 770 | const UInt uiRasterPartEnd = g_auiZscanToRaster[uiPartIdxLB]+1; |
---|
| 771 | const UInt uiIdxStep = pcCU->getPic()->getNumPartInWidth(); |
---|
| 772 | Bool *pbValidFlags = bValidFlags; |
---|
| 773 | Int iNumIntra = 0; |
---|
| 774 | |
---|
| 775 | for ( UInt uiRasterPart = uiRasterPartBegin; uiRasterPart < uiRasterPartEnd; uiRasterPart += uiIdxStep ) |
---|
| 776 | { |
---|
| 777 | UInt uiPartLeft; |
---|
| 778 | TComDataCU* pcCULeft = pcCU->getPULeft( uiPartLeft, g_auiRasterToZscan[uiRasterPart], true, false ); |
---|
[56] | 779 | if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred()) |
---|
[2] | 780 | { |
---|
[56] | 781 | if ( pcCULeft && pcCULeft->getPredictionMode( uiPartLeft ) == MODE_INTRA ) |
---|
| 782 | { |
---|
| 783 | iNumIntra++; |
---|
| 784 | *pbValidFlags = true; |
---|
| 785 | } |
---|
| 786 | else |
---|
| 787 | { |
---|
| 788 | *pbValidFlags = false; |
---|
| 789 | } |
---|
[2] | 790 | } |
---|
| 791 | else |
---|
| 792 | { |
---|
[56] | 793 | if ( pcCULeft ) |
---|
| 794 | { |
---|
| 795 | iNumIntra++; |
---|
| 796 | *pbValidFlags = true; |
---|
| 797 | } |
---|
| 798 | else |
---|
| 799 | { |
---|
| 800 | *pbValidFlags = false; |
---|
| 801 | } |
---|
[2] | 802 | } |
---|
| 803 | pbValidFlags--; // opposite direction |
---|
| 804 | } |
---|
| 805 | |
---|
| 806 | return iNumIntra; |
---|
| 807 | } |
---|
| 808 | |
---|
[56] | 809 | Int TComPattern::isAboveRightAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags ) |
---|
[2] | 810 | { |
---|
| 811 | const UInt uiNumUnitsInPU = g_auiZscanToRaster[uiPartIdxRT] - g_auiZscanToRaster[uiPartIdxLT] + 1; |
---|
| 812 | const UInt uiPuWidth = uiNumUnitsInPU * pcCU->getPic()->getMinCUWidth(); |
---|
| 813 | Bool *pbValidFlags = bValidFlags; |
---|
| 814 | Int iNumIntra = 0; |
---|
| 815 | |
---|
| 816 | for ( UInt uiOffset = 1; uiOffset <= uiNumUnitsInPU; uiOffset++ ) |
---|
| 817 | { |
---|
| 818 | UInt uiPartAboveRight; |
---|
| 819 | TComDataCU* pcCUAboveRight = pcCU->getPUAboveRightAdi( uiPartAboveRight, uiPuWidth, uiPartIdxRT, uiOffset, true, false ); |
---|
[56] | 820 | if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred()) |
---|
[2] | 821 | { |
---|
[56] | 822 | if ( pcCUAboveRight && pcCUAboveRight->getPredictionMode( uiPartAboveRight ) == MODE_INTRA ) |
---|
| 823 | { |
---|
| 824 | iNumIntra++; |
---|
| 825 | *pbValidFlags = true; |
---|
| 826 | } |
---|
| 827 | else |
---|
| 828 | { |
---|
| 829 | *pbValidFlags = false; |
---|
| 830 | } |
---|
[2] | 831 | } |
---|
| 832 | else |
---|
| 833 | { |
---|
[56] | 834 | if ( pcCUAboveRight ) |
---|
| 835 | { |
---|
| 836 | iNumIntra++; |
---|
| 837 | *pbValidFlags = true; |
---|
| 838 | } |
---|
| 839 | else |
---|
| 840 | { |
---|
| 841 | *pbValidFlags = false; |
---|
| 842 | } |
---|
[2] | 843 | } |
---|
| 844 | pbValidFlags++; |
---|
| 845 | } |
---|
| 846 | |
---|
| 847 | return iNumIntra; |
---|
| 848 | } |
---|
| 849 | |
---|
[56] | 850 | Int TComPattern::isBelowLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags ) |
---|
[2] | 851 | { |
---|
| 852 | const UInt uiNumUnitsInPU = (g_auiZscanToRaster[uiPartIdxLB] - g_auiZscanToRaster[uiPartIdxLT]) / pcCU->getPic()->getNumPartInWidth() + 1; |
---|
| 853 | const UInt uiPuHeight = uiNumUnitsInPU * pcCU->getPic()->getMinCUHeight(); |
---|
| 854 | Bool *pbValidFlags = bValidFlags; |
---|
| 855 | Int iNumIntra = 0; |
---|
| 856 | |
---|
| 857 | for ( UInt uiOffset = 1; uiOffset <= uiNumUnitsInPU; uiOffset++ ) |
---|
| 858 | { |
---|
| 859 | UInt uiPartBelowLeft; |
---|
| 860 | TComDataCU* pcCUBelowLeft = pcCU->getPUBelowLeftAdi( uiPartBelowLeft, uiPuHeight, uiPartIdxLB, uiOffset, true, false ); |
---|
[56] | 861 | if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred()) |
---|
[2] | 862 | { |
---|
[56] | 863 | if ( pcCUBelowLeft && pcCUBelowLeft->getPredictionMode( uiPartBelowLeft ) == MODE_INTRA ) |
---|
| 864 | { |
---|
| 865 | iNumIntra++; |
---|
| 866 | *pbValidFlags = true; |
---|
| 867 | } |
---|
| 868 | else |
---|
| 869 | { |
---|
| 870 | *pbValidFlags = false; |
---|
| 871 | } |
---|
[2] | 872 | } |
---|
| 873 | else |
---|
| 874 | { |
---|
[56] | 875 | if ( pcCUBelowLeft ) |
---|
| 876 | { |
---|
| 877 | iNumIntra++; |
---|
| 878 | *pbValidFlags = true; |
---|
| 879 | } |
---|
| 880 | else |
---|
| 881 | { |
---|
| 882 | *pbValidFlags = false; |
---|
| 883 | } |
---|
[2] | 884 | } |
---|
| 885 | pbValidFlags--; // opposite direction |
---|
| 886 | } |
---|
| 887 | |
---|
| 888 | return iNumIntra; |
---|
| 889 | } |
---|
[56] | 890 | //! \} |
---|