[313] | 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 |
---|
[1029] | 4 | * granted under this license. |
---|
[313] | 5 | * |
---|
[1259] | 6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
---|
[313] | 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 ITU/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 | /** \file TComPic.cpp |
---|
| 35 | \brief picture class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include "TComPic.h" |
---|
| 39 | #include "SEI.h" |
---|
| 40 | |
---|
| 41 | //! \ingroup TLibCommon |
---|
| 42 | //! \{ |
---|
| 43 | |
---|
| 44 | // ==================================================================================================================== |
---|
| 45 | // Constructor / destructor / create / destroy |
---|
| 46 | // ==================================================================================================================== |
---|
| 47 | |
---|
| 48 | TComPic::TComPic() |
---|
| 49 | : m_uiTLayer (0) |
---|
| 50 | , m_bUsedByCurr (false) |
---|
| 51 | , m_bIsLongTerm (false) |
---|
| 52 | , m_pcPicYuvPred (NULL) |
---|
| 53 | , m_pcPicYuvResi (NULL) |
---|
| 54 | , m_bReconstructed (false) |
---|
| 55 | , m_bNeededForOutput (false) |
---|
| 56 | , m_uiCurrSliceIdx (0) |
---|
[595] | 57 | , m_bCheckLTMSB (false) |
---|
| 58 | #if SVC_EXTENSION |
---|
| 59 | , m_layerId( 0 ) |
---|
[540] | 60 | #endif |
---|
[313] | 61 | { |
---|
| 62 | #if SVC_EXTENSION |
---|
| 63 | memset( m_pcFullPelBaseRec, 0, sizeof( m_pcFullPelBaseRec ) ); |
---|
[1512] | 64 | memset( m_requireResampling, false, sizeof( m_requireResampling ) ); |
---|
[901] | 65 | memset( m_equalPictureSizeAndOffsetFlag, false, sizeof( m_equalPictureSizeAndOffsetFlag ) ); |
---|
[1420] | 66 | memset( m_mvScalingFactor, 0, sizeof( m_mvScalingFactor ) ); |
---|
| 67 | memset( m_posScalingFactor, 0, sizeof( m_posScalingFactor ) ); |
---|
[313] | 68 | #endif |
---|
[1029] | 69 | for(UInt i=0; i<NUM_PIC_YUV; i++) |
---|
| 70 | { |
---|
| 71 | m_apcPicYuv[i] = NULL; |
---|
| 72 | } |
---|
[313] | 73 | } |
---|
| 74 | |
---|
| 75 | TComPic::~TComPic() |
---|
| 76 | { |
---|
[1540] | 77 | destroy(); |
---|
[313] | 78 | } |
---|
[815] | 79 | #if SVC_EXTENSION |
---|
[1503] | 80 | Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const Bool bIsVirtual, const UInt layerId ) |
---|
[313] | 81 | { |
---|
[1540] | 82 | destroy(); |
---|
| 83 | |
---|
[1502] | 84 | const ChromaFormat chromaFormatIDC = sps.getChromaFormatIdc(); |
---|
| 85 | const Int iWidth = sps.getPicWidthInLumaSamples(); |
---|
| 86 | const Int iHeight = sps.getPicHeightInLumaSamples(); |
---|
[1290] | 87 | const UInt uiMaxCuWidth = sps.getMaxCUWidth(); |
---|
| 88 | const UInt uiMaxCuHeight = sps.getMaxCUHeight(); |
---|
| 89 | const UInt uiMaxDepth = sps.getMaxTotalCUDepth(); |
---|
[1502] | 90 | const Window& conformanceWindow = sps.getConformanceWindow(); |
---|
[1235] | 91 | |
---|
[1485] | 92 | m_layerId = layerId; |
---|
| 93 | |
---|
[1503] | 94 | m_picSym.create( sps, pps, uiMaxDepth, layerId ); |
---|
[1235] | 95 | |
---|
[313] | 96 | if (!bIsVirtual) |
---|
| 97 | { |
---|
[1289] | 98 | m_apcPicYuv[PIC_YUV_ORG] = new TComPicYuv; m_apcPicYuv[PIC_YUV_ORG]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true, &conformanceWindow ); |
---|
| 99 | m_apcPicYuv[PIC_YUV_TRUE_ORG] = new TComPicYuv; m_apcPicYuv[PIC_YUV_TRUE_ORG]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true, &conformanceWindow ); |
---|
[313] | 100 | } |
---|
[1289] | 101 | m_apcPicYuv[PIC_YUV_REC] = new TComPicYuv; m_apcPicYuv[PIC_YUV_REC]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true, &conformanceWindow ); |
---|
[313] | 102 | |
---|
| 103 | for( Int i = 0; i < MAX_LAYERS; i++ ) |
---|
| 104 | { |
---|
[1512] | 105 | if( m_requireResampling[i] ) |
---|
[313] | 106 | { |
---|
[1289] | 107 | m_pcFullPelBaseRec[i] = new TComPicYuv; m_pcFullPelBaseRec[i]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true, &conformanceWindow ); |
---|
[313] | 108 | } |
---|
[1235] | 109 | } |
---|
[313] | 110 | |
---|
| 111 | // there are no SEI messages associated with this picture initially |
---|
| 112 | if (m_SEIs.size() > 0) |
---|
| 113 | { |
---|
| 114 | deleteSEIs (m_SEIs); |
---|
| 115 | } |
---|
| 116 | m_bUsedByCurr = false; |
---|
| 117 | } |
---|
| 118 | #else |
---|
[1290] | 119 | Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const Bool bIsVirtual) |
---|
[313] | 120 | { |
---|
[1540] | 121 | destroy(); |
---|
| 122 | |
---|
[1290] | 123 | const ChromaFormat chromaFormatIDC = sps.getChromaFormatIdc(); |
---|
| 124 | const Int iWidth = sps.getPicWidthInLumaSamples(); |
---|
| 125 | const Int iHeight = sps.getPicHeightInLumaSamples(); |
---|
| 126 | const UInt uiMaxCuWidth = sps.getMaxCUWidth(); |
---|
| 127 | const UInt uiMaxCuHeight = sps.getMaxCUHeight(); |
---|
| 128 | const UInt uiMaxDepth = sps.getMaxTotalCUDepth(); |
---|
[1235] | 129 | |
---|
[1289] | 130 | m_picSym.create( sps, pps, uiMaxDepth ); |
---|
[313] | 131 | if (!bIsVirtual) |
---|
| 132 | { |
---|
[1289] | 133 | m_apcPicYuv[PIC_YUV_ORG ] = new TComPicYuv; m_apcPicYuv[PIC_YUV_ORG ]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true ); |
---|
| 134 | m_apcPicYuv[PIC_YUV_TRUE_ORG] = new TComPicYuv; m_apcPicYuv[PIC_YUV_TRUE_ORG]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true ); |
---|
[313] | 135 | } |
---|
[1289] | 136 | m_apcPicYuv[PIC_YUV_REC] = new TComPicYuv; m_apcPicYuv[PIC_YUV_REC]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true ); |
---|
[1029] | 137 | |
---|
[313] | 138 | // there are no SEI messages associated with this picture initially |
---|
| 139 | if (m_SEIs.size() > 0) |
---|
| 140 | { |
---|
| 141 | deleteSEIs (m_SEIs); |
---|
| 142 | } |
---|
| 143 | m_bUsedByCurr = false; |
---|
| 144 | } |
---|
| 145 | #endif |
---|
| 146 | |
---|
| 147 | Void TComPic::destroy() |
---|
| 148 | { |
---|
[1235] | 149 | m_picSym.destroy(); |
---|
[1029] | 150 | |
---|
| 151 | for(UInt i=0; i<NUM_PIC_YUV; i++) |
---|
[313] | 152 | { |
---|
[1029] | 153 | if (m_apcPicYuv[i]) |
---|
| 154 | { |
---|
| 155 | m_apcPicYuv[i]->destroy(); |
---|
| 156 | delete m_apcPicYuv[i]; |
---|
| 157 | m_apcPicYuv[i] = NULL; |
---|
| 158 | } |
---|
[313] | 159 | } |
---|
[1029] | 160 | |
---|
[313] | 161 | deleteSEIs(m_SEIs); |
---|
[815] | 162 | #if SVC_EXTENSION |
---|
[313] | 163 | for( Int i = 0; i < MAX_LAYERS; i++ ) |
---|
| 164 | { |
---|
[1512] | 165 | if( m_requireResampling[i] && m_pcFullPelBaseRec[i] ) |
---|
[313] | 166 | { |
---|
| 167 | m_pcFullPelBaseRec[i]->destroy(); |
---|
| 168 | delete m_pcFullPelBaseRec[i]; |
---|
| 169 | m_pcFullPelBaseRec[i] = NULL; |
---|
| 170 | } |
---|
| 171 | } |
---|
[1419] | 172 | |
---|
| 173 | for( Int comp = 0; comp < 2; comp++ ) |
---|
| 174 | { |
---|
| 175 | if( m_mvScalingFactor[comp] ) |
---|
| 176 | { |
---|
| 177 | delete [] m_mvScalingFactor[comp]; |
---|
| 178 | m_mvScalingFactor[comp] = NULL; |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | if( m_posScalingFactor[comp] ) |
---|
| 182 | { |
---|
| 183 | delete [] m_posScalingFactor[comp]; |
---|
| 184 | m_posScalingFactor[comp] = NULL; |
---|
| 185 | } |
---|
| 186 | } |
---|
[313] | 187 | #endif |
---|
| 188 | } |
---|
| 189 | |
---|
| 190 | Void TComPic::compressMotion() |
---|
| 191 | { |
---|
[1029] | 192 | TComPicSym* pPicSym = getPicSym(); |
---|
| 193 | for ( UInt uiCUAddr = 0; uiCUAddr < pPicSym->getNumberOfCtusInFrame(); uiCUAddr++ ) |
---|
[313] | 194 | { |
---|
[1029] | 195 | TComDataCU* pCtu = pPicSym->getCtu(uiCUAddr); |
---|
| 196 | pCtu->compressMV(); |
---|
| 197 | } |
---|
[313] | 198 | } |
---|
[595] | 199 | |
---|
[540] | 200 | Bool TComPic::getSAOMergeAvailability(Int currAddr, Int mergeAddr) |
---|
| 201 | { |
---|
[1029] | 202 | Bool mergeCtbInSliceSeg = (mergeAddr >= getPicSym()->getCtuTsToRsAddrMap(getCtu(currAddr)->getSlice()->getSliceCurStartCtuTsAddr())); |
---|
[540] | 203 | Bool mergeCtbInTile = (getPicSym()->getTileIdxMap(mergeAddr) == getPicSym()->getTileIdxMap(currAddr)); |
---|
| 204 | return (mergeCtbInSliceSeg && mergeCtbInTile); |
---|
| 205 | } |
---|
[313] | 206 | |
---|
[1029] | 207 | UInt TComPic::getSubstreamForCtuAddr(const UInt ctuAddr, const Bool bAddressInRaster, TComSlice *pcSlice) |
---|
| 208 | { |
---|
| 209 | UInt subStrm; |
---|
[1235] | 210 | const bool bWPPEnabled=pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag(); |
---|
| 211 | const TComPicSym &picSym = *(getPicSym()); |
---|
[1029] | 212 | |
---|
[1235] | 213 | if ((bWPPEnabled && picSym.getFrameHeightInCtus()>1) || (picSym.getNumTiles()>1)) // wavefronts, and possibly tiles being used. |
---|
[1029] | 214 | { |
---|
[1235] | 215 | if (bWPPEnabled) |
---|
[1029] | 216 | { |
---|
| 217 | const UInt ctuRsAddr = bAddressInRaster?ctuAddr : picSym.getCtuTsToRsAddrMap(ctuAddr); |
---|
| 218 | const UInt frameWidthInCtus = picSym.getFrameWidthInCtus(); |
---|
| 219 | const UInt tileIndex = picSym.getTileIdxMap(ctuRsAddr); |
---|
| 220 | const UInt numTileColumns = (picSym.getNumTileColumnsMinus1()+1); |
---|
| 221 | const TComTile *pTile = picSym.getTComTile(tileIndex); |
---|
| 222 | const UInt firstCtuRsAddrOfTile = pTile->getFirstCtuRsAddr(); |
---|
| 223 | const UInt tileYInCtus = firstCtuRsAddrOfTile / frameWidthInCtus; |
---|
| 224 | // independent tiles => substreams are "per tile" |
---|
| 225 | const UInt ctuLine = ctuRsAddr / frameWidthInCtus; |
---|
| 226 | const UInt startingSubstreamForTile =(tileYInCtus*numTileColumns) + (pTile->getTileHeightInCtus()*(tileIndex%numTileColumns)); |
---|
| 227 | subStrm = startingSubstreamForTile + (ctuLine - tileYInCtus); |
---|
| 228 | } |
---|
| 229 | else |
---|
| 230 | { |
---|
| 231 | const UInt ctuRsAddr = bAddressInRaster?ctuAddr : picSym.getCtuTsToRsAddrMap(ctuAddr); |
---|
| 232 | const UInt tileIndex = picSym.getTileIdxMap(ctuRsAddr); |
---|
| 233 | subStrm=tileIndex; |
---|
| 234 | } |
---|
| 235 | } |
---|
| 236 | else |
---|
| 237 | { |
---|
| 238 | // dependent tiles => substreams are "per frame". |
---|
| 239 | subStrm = 0; |
---|
| 240 | } |
---|
| 241 | return subStrm; |
---|
| 242 | } |
---|
| 243 | |
---|
[442] | 244 | #if SVC_EXTENSION |
---|
[1419] | 245 | Void TComPic::createMvScalingFactor(UInt numOfILRPs) |
---|
| 246 | { |
---|
[1428] | 247 | // picture object might be reused and hence m_mvScalingFactor[0] can be already allocated |
---|
| 248 | if(m_mvScalingFactor[0]) |
---|
| 249 | { |
---|
| 250 | delete m_mvScalingFactor[0]; |
---|
| 251 | } |
---|
[1419] | 252 | m_mvScalingFactor[0] = new Int[numOfILRPs]; |
---|
| 253 | |
---|
[1428] | 254 | // picture object might be reused and hence m_mvScalingFactor[1] can be already allocated |
---|
| 255 | if(m_mvScalingFactor[1]) |
---|
| 256 | { |
---|
| 257 | delete m_mvScalingFactor[1]; |
---|
| 258 | } |
---|
[1419] | 259 | m_mvScalingFactor[1] = new Int[numOfILRPs]; |
---|
| 260 | } |
---|
| 261 | |
---|
| 262 | Void TComPic::createPosScalingFactor(UInt numOfILRPs) |
---|
| 263 | { |
---|
[1428] | 264 | // picture object might be reused and hence m_posScalingFactor[0] can be already allocated |
---|
| 265 | if(m_posScalingFactor[0]) |
---|
| 266 | { |
---|
| 267 | delete m_posScalingFactor[0]; |
---|
| 268 | } |
---|
[1419] | 269 | m_posScalingFactor[0] = new Int[numOfILRPs]; |
---|
| 270 | |
---|
[1428] | 271 | // picture object might be reused and hence m_posScalingFactor[1] can be already allocated |
---|
| 272 | if(m_posScalingFactor[1]) |
---|
| 273 | { |
---|
| 274 | delete m_posScalingFactor[1]; |
---|
| 275 | } |
---|
[1419] | 276 | m_posScalingFactor[1] = new Int[numOfILRPs]; |
---|
| 277 | } |
---|
| 278 | |
---|
[313] | 279 | Void copyOnetoOnePicture( // SVC_NONCOLL |
---|
| 280 | Pel *in, |
---|
| 281 | Pel *out, |
---|
| 282 | Int nCols, |
---|
| 283 | Int nRows, |
---|
| 284 | Int fullRowWidth) |
---|
| 285 | { |
---|
| 286 | Int rX; |
---|
| 287 | |
---|
| 288 | for (rX = 0; rX < nRows; rX++) |
---|
| 289 | { |
---|
| 290 | memcpy( out, in, sizeof(Pel) * nCols ); |
---|
| 291 | in = in + fullRowWidth; |
---|
| 292 | out = out + fullRowWidth; |
---|
| 293 | } |
---|
| 294 | } |
---|
| 295 | |
---|
| 296 | Void TComPic::copyUpsampledPictureYuv(TComPicYuv* pcPicYuvIn, TComPicYuv* pcPicYuvOut) |
---|
| 297 | { |
---|
[1487] | 298 | #if SCALABLE_REXT |
---|
[1029] | 299 | Int upsampledRowWidthLuma = pcPicYuvOut->getStride(COMPONENT_Y); // 2 * pcPicYuvOut->getLumaMargin() + pcPicYuvOut->getWidth(); |
---|
[1487] | 300 | copyOnetoOnePicture( |
---|
| 301 | pcPicYuvIn->getAddr(COMPONENT_Y), |
---|
| 302 | pcPicYuvOut->getAddr(COMPONENT_Y), |
---|
| 303 | pcPicYuvOut->getWidth(COMPONENT_Y), |
---|
| 304 | pcPicYuvOut->getHeight(COMPONENT_Y), |
---|
| 305 | upsampledRowWidthLuma); |
---|
| 306 | |
---|
| 307 | if(pcPicYuvOut->getChromaFormat() != CHROMA_400) |
---|
| 308 | { |
---|
| 309 | Int upsampledRowWidthChroma = pcPicYuvOut->getStride(COMPONENT_Cb); //2 * pcPicYuvOut->getChromaMargin() + (pcPicYuvOut->getWidth()>>1); |
---|
| 310 | |
---|
| 311 | copyOnetoOnePicture( |
---|
| 312 | pcPicYuvIn->getAddr(COMPONENT_Cr), |
---|
| 313 | pcPicYuvOut->getAddr(COMPONENT_Cr), |
---|
| 314 | pcPicYuvOut->getWidth(COMPONENT_Cr), |
---|
| 315 | pcPicYuvOut->getHeight(COMPONENT_Cr), |
---|
| 316 | upsampledRowWidthChroma); |
---|
| 317 | copyOnetoOnePicture( |
---|
| 318 | pcPicYuvIn->getAddr(COMPONENT_Cb), |
---|
| 319 | pcPicYuvOut->getAddr(COMPONENT_Cb), |
---|
| 320 | pcPicYuvOut->getWidth(COMPONENT_Cb), |
---|
| 321 | pcPicYuvOut->getHeight(COMPONENT_Cb), |
---|
| 322 | upsampledRowWidthChroma); |
---|
| 323 | } |
---|
| 324 | #else |
---|
| 325 | Int upsampledRowWidthLuma = pcPicYuvOut->getStride(COMPONENT_Y); // 2 * pcPicYuvOut->getLumaMargin() + pcPicYuvOut->getWidth(); |
---|
[1029] | 326 | Int upsampledRowWidthCroma = pcPicYuvOut->getStride(COMPONENT_Cb); //2 * pcPicYuvOut->getChromaMargin() + (pcPicYuvOut->getWidth()>>1); |
---|
[313] | 327 | |
---|
| 328 | copyOnetoOnePicture( |
---|
[1029] | 329 | pcPicYuvIn->getAddr(COMPONENT_Y), |
---|
| 330 | pcPicYuvOut->getAddr(COMPONENT_Y), |
---|
| 331 | pcPicYuvOut->getWidth(COMPONENT_Y), |
---|
| 332 | pcPicYuvOut->getHeight(COMPONENT_Y), |
---|
[313] | 333 | upsampledRowWidthLuma); |
---|
| 334 | copyOnetoOnePicture( |
---|
[1029] | 335 | pcPicYuvIn->getAddr(COMPONENT_Cr), |
---|
| 336 | pcPicYuvOut->getAddr(COMPONENT_Cr), |
---|
| 337 | pcPicYuvOut->getWidth(COMPONENT_Y)>>1, |
---|
| 338 | pcPicYuvOut->getHeight(COMPONENT_Y)>>1, |
---|
[313] | 339 | upsampledRowWidthCroma); |
---|
| 340 | copyOnetoOnePicture( |
---|
[1029] | 341 | pcPicYuvIn->getAddr(COMPONENT_Cb), |
---|
| 342 | pcPicYuvOut->getAddr(COMPONENT_Cb), |
---|
| 343 | pcPicYuvOut->getWidth(COMPONENT_Y)>>1, |
---|
| 344 | pcPicYuvOut->getHeight(COMPONENT_Y)>>1, |
---|
[313] | 345 | upsampledRowWidthCroma); |
---|
[1487] | 346 | #endif |
---|
[313] | 347 | } |
---|
| 348 | |
---|
[1419] | 349 | Void TComPic::copyUpsampledMvField(UInt refLayerIdc, Int** mvScalingFactor, Int** posScalingFactor) |
---|
[313] | 350 | { |
---|
[1290] | 351 | const TComSPS *sps = getSlice(0)->getSPS(); |
---|
| 352 | const UInt uiMaxDepth = sps->getMaxTotalCUDepth(); |
---|
| 353 | const UInt numPartitions = 1<<(uiMaxDepth<<1); |
---|
| 354 | const UInt widthMinPU = sps->getMaxCUWidth() / (1<<uiMaxDepth); |
---|
| 355 | const UInt heightMinPU = sps->getMaxCUHeight() / (1<<uiMaxDepth); |
---|
| 356 | const Int unitNum = max( 1, (Int)((16/widthMinPU)*(16/heightMinPU)) ); |
---|
[313] | 357 | |
---|
[1029] | 358 | for(UInt cuIdx = 0; cuIdx < getPicSym()->getNumberOfCtusInFrame(); cuIdx++) //each LCU |
---|
[313] | 359 | { |
---|
[1029] | 360 | TComDataCU* pcCUDes = getCtu(cuIdx); |
---|
[313] | 361 | |
---|
| 362 | for(UInt absPartIdx = 0; absPartIdx < numPartitions; absPartIdx+=unitNum ) //each 16x16 unit |
---|
| 363 | { |
---|
| 364 | //pixel position of each unit in up-sampled layer |
---|
[1289] | 365 | UInt pelX = pcCUDes->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[absPartIdx] ]; |
---|
| 366 | UInt pelY = pcCUDes->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[absPartIdx] ]; |
---|
[313] | 367 | UInt baseCUAddr, baseAbsPartIdx; |
---|
| 368 | |
---|
| 369 | TComDataCU *pcColCU = 0; |
---|
[1419] | 370 | pcColCU = pcCUDes->getBaseColCU(refLayerIdc, pelX, pelY, baseCUAddr, baseAbsPartIdx, posScalingFactor, true); |
---|
[313] | 371 | |
---|
[1029] | 372 | if( pcColCU && pcColCU->getPredictionMode(baseAbsPartIdx) == MODE_INTER ) //base layer unit not skip and invalid mode |
---|
[313] | 373 | { |
---|
| 374 | for(UInt refPicList = 0; refPicList < 2; refPicList++) //for each reference list |
---|
| 375 | { |
---|
| 376 | TComMvField sMvFieldBase, sMvField; |
---|
| 377 | pcColCU->getMvField( pcColCU, baseAbsPartIdx, (RefPicList)refPicList, sMvFieldBase); |
---|
[1419] | 378 | pcCUDes->scaleBaseMV( refLayerIdc, sMvField, sMvFieldBase, mvScalingFactor ); |
---|
[313] | 379 | |
---|
| 380 | pcCUDes->getCUMvField((RefPicList)refPicList)->setMvField(sMvField, absPartIdx); |
---|
| 381 | pcCUDes->setPredictionMode(absPartIdx, MODE_INTER); |
---|
| 382 | } |
---|
| 383 | } |
---|
| 384 | else |
---|
| 385 | { |
---|
| 386 | TComMvField zeroMvField; //zero MV and invalid reference index |
---|
| 387 | pcCUDes->getCUMvField(REF_PIC_LIST_0)->setMvField(zeroMvField, absPartIdx); |
---|
| 388 | pcCUDes->getCUMvField(REF_PIC_LIST_1)->setMvField(zeroMvField, absPartIdx); |
---|
| 389 | pcCUDes->setPredictionMode(absPartIdx, MODE_INTRA); |
---|
| 390 | } |
---|
| 391 | |
---|
| 392 | for(UInt i = 1; i < unitNum; i++ ) |
---|
| 393 | { |
---|
| 394 | pcCUDes->getCUMvField(REF_PIC_LIST_0)->setMvField(pcCUDes->getCUMvField(REF_PIC_LIST_0)->getMv(absPartIdx), pcCUDes->getCUMvField(REF_PIC_LIST_0)->getRefIdx(absPartIdx), absPartIdx + i); |
---|
| 395 | pcCUDes->getCUMvField(REF_PIC_LIST_1)->setMvField(pcCUDes->getCUMvField(REF_PIC_LIST_1)->getMv(absPartIdx), pcCUDes->getCUMvField(REF_PIC_LIST_1)->getRefIdx(absPartIdx), absPartIdx + i); |
---|
| 396 | pcCUDes->setPredictionMode(absPartIdx+i, pcCUDes->getPredictionMode(absPartIdx)); |
---|
| 397 | } |
---|
| 398 | } |
---|
[1442] | 399 | memset( pcCUDes->getPartitionSize(), SIZE_2Nx2N, sizeof(SChar)*numPartitions ); |
---|
[313] | 400 | } |
---|
| 401 | } |
---|
| 402 | |
---|
| 403 | Void TComPic::initUpsampledMvField() |
---|
| 404 | { |
---|
[1290] | 405 | const TComSPS *sps = getSlice(0)->getSPS(); |
---|
| 406 | const UInt uiMaxDepth = sps->getMaxTotalCUDepth(); |
---|
| 407 | const UInt uiNumPartitions = 1<<(uiMaxDepth<<1); |
---|
[313] | 408 | |
---|
[1029] | 409 | for(UInt cuIdx = 0; cuIdx < getPicSym()->getNumberOfCtusInFrame(); cuIdx++) //each LCU |
---|
[313] | 410 | { |
---|
[1029] | 411 | TComDataCU* pcCUDes = getCtu(cuIdx); |
---|
[313] | 412 | TComMvField zeroMvField; |
---|
| 413 | for(UInt list = 0; list < 2; list++) //each reference list |
---|
| 414 | { |
---|
| 415 | for(UInt i = 0; i < uiNumPartitions; i++ ) |
---|
| 416 | { |
---|
| 417 | pcCUDes->getCUMvField(REF_PIC_LIST_0)->setMvField(zeroMvField, i); |
---|
| 418 | pcCUDes->getCUMvField(REF_PIC_LIST_1)->setMvField(zeroMvField, i); |
---|
| 419 | pcCUDes->setPredictionMode(i, MODE_INTRA); |
---|
| 420 | pcCUDes->setPartitionSize(i, SIZE_2Nx2N); |
---|
| 421 | } |
---|
| 422 | } |
---|
| 423 | } |
---|
| 424 | return; |
---|
| 425 | } |
---|
| 426 | |
---|
[494] | 427 | Bool TComPic::checkSameRefInfo() |
---|
| 428 | { |
---|
| 429 | Bool bSameRefInfo = true; |
---|
| 430 | TComSlice * pSlice0 = getSlice( 0 ); |
---|
| 431 | for( UInt uSliceID = getNumAllocatedSlice() - 1 ; bSameRefInfo && uSliceID > 0 ; uSliceID-- ) |
---|
| 432 | { |
---|
| 433 | TComSlice * pSliceN = getSlice( uSliceID ); |
---|
| 434 | if( pSlice0->getSliceType() != pSliceN->getSliceType() ) |
---|
| 435 | { |
---|
| 436 | bSameRefInfo = false; |
---|
| 437 | } |
---|
| 438 | else if( pSlice0->getSliceType() != I_SLICE ) |
---|
| 439 | { |
---|
| 440 | Int nListNum = pSlice0->getSliceType() == B_SLICE ? 2 : 1; |
---|
| 441 | for( Int nList = 0 ; nList < nListNum ; nList++ ) |
---|
| 442 | { |
---|
| 443 | RefPicList eRefList = ( RefPicList )nList; |
---|
| 444 | if( pSlice0->getNumRefIdx( eRefList ) == pSliceN->getNumRefIdx( eRefList ) ) |
---|
| 445 | { |
---|
| 446 | for( Int refIdx = pSlice0->getNumRefIdx( eRefList ) - 1 ; refIdx >= 0 ; refIdx-- ) |
---|
| 447 | { |
---|
| 448 | if( pSlice0->getRefPic( eRefList , refIdx ) != pSliceN->getRefPic( eRefList , refIdx ) ) |
---|
| 449 | { |
---|
| 450 | bSameRefInfo = false; |
---|
| 451 | break; |
---|
| 452 | } |
---|
| 453 | } |
---|
| 454 | } |
---|
| 455 | else |
---|
| 456 | { |
---|
| 457 | bSameRefInfo = false; |
---|
| 458 | break; |
---|
| 459 | } |
---|
| 460 | } |
---|
| 461 | } |
---|
| 462 | } |
---|
[313] | 463 | |
---|
[494] | 464 | return( bSameRefInfo ); |
---|
| 465 | } |
---|
[1029] | 466 | #endif //SVC_EXTENSION |
---|
[494] | 467 | |
---|
[313] | 468 | //! \} |
---|