[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 |
---|
[1200] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[1200] | 6 | * Copyright (c) 2010-2015, 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 TComPic.cpp |
---|
| 35 | \brief picture class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include "TComPic.h" |
---|
| 39 | #include "SEI.h" |
---|
| 40 | |
---|
[56] | 41 | //! \ingroup TLibCommon |
---|
| 42 | //! \{ |
---|
| 43 | |
---|
[2] | 44 | // ==================================================================================================================== |
---|
| 45 | // Constructor / destructor / create / destroy |
---|
| 46 | // ==================================================================================================================== |
---|
| 47 | |
---|
| 48 | TComPic::TComPic() |
---|
[608] | 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) |
---|
[1200] | 56 | #if NH_MV |
---|
[964] | 57 | , m_bPicOutputFlag (false) |
---|
| 58 | #endif |
---|
[608] | 59 | , m_uiCurrSliceIdx (0) |
---|
| 60 | , m_bCheckLTMSB (false) |
---|
[1200] | 61 | #if NH_MV |
---|
[608] | 62 | , m_layerId (0) |
---|
| 63 | , m_viewId (0) |
---|
[1305] | 64 | #if NH_3D |
---|
[608] | 65 | , m_viewIndex (0) |
---|
| 66 | , m_isDepth (false) |
---|
| 67 | , m_aaiCodedScale (0) |
---|
| 68 | , m_aaiCodedOffset (0) |
---|
| 69 | #endif |
---|
| 70 | #endif |
---|
[1200] | 71 | |
---|
[2] | 72 | { |
---|
[1200] | 73 | for(UInt i=0; i<NUM_PIC_YUV; i++) |
---|
| 74 | { |
---|
| 75 | m_apcPicYuv[i] = NULL; |
---|
| 76 | } |
---|
[1279] | 77 | #if NH_3D_QTLPC |
---|
[189] | 78 | m_bReduceBitsQTL = 0; |
---|
| 79 | #endif |
---|
[1279] | 80 | #if NH_3D_NBDV |
---|
[608] | 81 | m_iNumDdvCandPics = 0; |
---|
| 82 | m_eRapRefList = REF_PIC_LIST_0; |
---|
| 83 | m_uiRapRefIdx = 0; |
---|
[189] | 84 | #endif |
---|
[2] | 85 | } |
---|
| 86 | |
---|
| 87 | TComPic::~TComPic() |
---|
| 88 | { |
---|
| 89 | } |
---|
| 90 | |
---|
[1200] | 91 | Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const Bool bIsVirtual) |
---|
| 92 | { |
---|
| 93 | const ChromaFormat chromaFormatIDC = sps.getChromaFormatIdc(); |
---|
| 94 | const Int iWidth = sps.getPicWidthInLumaSamples(); |
---|
| 95 | const Int iHeight = sps.getPicHeightInLumaSamples(); |
---|
| 96 | const UInt uiMaxCuWidth = sps.getMaxCUWidth(); |
---|
| 97 | const UInt uiMaxCuHeight = sps.getMaxCUHeight(); |
---|
| 98 | const UInt uiMaxDepth = sps.getMaxTotalCUDepth(); |
---|
[608] | 99 | |
---|
[1200] | 100 | m_picSym.create( sps, pps, uiMaxDepth ); |
---|
[56] | 101 | if (!bIsVirtual) |
---|
| 102 | { |
---|
[1200] | 103 | m_apcPicYuv[PIC_YUV_ORG ] = new TComPicYuv; m_apcPicYuv[PIC_YUV_ORG ]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true ); |
---|
| 104 | m_apcPicYuv[PIC_YUV_TRUE_ORG] = new TComPicYuv; m_apcPicYuv[PIC_YUV_TRUE_ORG]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true ); |
---|
[56] | 105 | } |
---|
[1200] | 106 | m_apcPicYuv[PIC_YUV_REC] = new TComPicYuv; m_apcPicYuv[PIC_YUV_REC]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true ); |
---|
| 107 | |
---|
[608] | 108 | // there are no SEI messages associated with this picture initially |
---|
| 109 | if (m_SEIs.size() > 0) |
---|
| 110 | { |
---|
| 111 | deleteSEIs (m_SEIs); |
---|
| 112 | } |
---|
[56] | 113 | m_bUsedByCurr = false; |
---|
[608] | 114 | |
---|
[655] | 115 | #if H_3D_FCO |
---|
[872] | 116 | /* initialize the texture to depth reference status */ |
---|
[655] | 117 | for (int j=0; j<2; j++) |
---|
| 118 | { |
---|
| 119 | for (int i=0; i<MAX_NUM_REF; i++) |
---|
| 120 | { |
---|
| 121 | m_aiTexToDepRef[j][i] = -1; |
---|
| 122 | } |
---|
| 123 | } |
---|
| 124 | #endif |
---|
| 125 | |
---|
[2] | 126 | } |
---|
| 127 | |
---|
| 128 | Void TComPic::destroy() |
---|
| 129 | { |
---|
[1200] | 130 | m_picSym.destroy(); |
---|
| 131 | |
---|
| 132 | for(UInt i=0; i<NUM_PIC_YUV; i++) |
---|
[2] | 133 | { |
---|
[1200] | 134 | if (m_apcPicYuv[i]) |
---|
| 135 | { |
---|
| 136 | m_apcPicYuv[i]->destroy(); |
---|
| 137 | delete m_apcPicYuv[i]; |
---|
| 138 | m_apcPicYuv[i] = NULL; |
---|
| 139 | } |
---|
[2] | 140 | } |
---|
[1200] | 141 | |
---|
[608] | 142 | deleteSEIs(m_SEIs); |
---|
[2] | 143 | } |
---|
[1200] | 144 | #if NH_3D |
---|
[1279] | 145 | #if NH_3D_ARP |
---|
| 146 | Void TComPic::getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx ) |
---|
| 147 | { |
---|
| 148 | Int iMaxCUWidth = (Int) ( getPicSym()->getSPS().getMaxCUWidth() ); |
---|
| 149 | Int iMaxCuHeight = (Int) ( getPicSym()->getSPS().getMaxCUHeight() ); |
---|
| 150 | |
---|
| 151 | UInt uiMaxTotalCUDepth = getPicSym()->getSPS().getMaxTotalCUDepth(); |
---|
| 152 | Int iBaseUnitWidth = iMaxCUWidth >> uiMaxTotalCUDepth; |
---|
| 153 | Int iBaseUnitHeight = iMaxCUWidth >> uiMaxTotalCUDepth; |
---|
| 154 | |
---|
| 155 | Int iNumCuInWidth = getPicYuvRec()->getWidth(COMPONENT_Y) / iMaxCUWidth; |
---|
| 156 | iNumCuInWidth += ( getPicYuvRec()->getWidth(COMPONENT_Y) % iMaxCUWidth ) ? 1 : 0; |
---|
| 157 | |
---|
| 158 | |
---|
| 159 | Int iCuX = iX / iMaxCUWidth; |
---|
| 160 | Int iCuY = iY / iMaxCuHeight; |
---|
| 161 | Int iBaseX = ( iX - iCuX * iMaxCUWidth ) / iBaseUnitWidth; |
---|
| 162 | Int iBaseY = ( iY - iCuY * iMaxCuHeight ) / iBaseUnitHeight; |
---|
| 163 | Int iCuSizeInBases = iMaxCuHeight / iBaseUnitWidth; |
---|
| 164 | |
---|
| 165 | riCuAddr = iCuY * iNumCuInWidth + iCuX; |
---|
| 166 | Int iRastPartIdx = iBaseY * iCuSizeInBases + iBaseX; |
---|
| 167 | riAbsZorderIdx = g_auiRasterToZscan[ iRastPartIdx ]; |
---|
| 168 | } |
---|
| 169 | #endif |
---|
[655] | 170 | Void TComPic::compressMotion(Int scale) |
---|
[608] | 171 | #else |
---|
[2] | 172 | Void TComPic::compressMotion() |
---|
[608] | 173 | #endif |
---|
[2] | 174 | { |
---|
[1200] | 175 | TComPicSym* pPicSym = getPicSym(); |
---|
| 176 | for ( UInt uiCUAddr = 0; uiCUAddr < pPicSym->getNumberOfCtusInFrame(); uiCUAddr++ ) |
---|
[2] | 177 | { |
---|
[1200] | 178 | TComDataCU* pCtu = pPicSym->getCtu(uiCUAddr); |
---|
| 179 | #if NH_3D |
---|
| 180 | pCtu->compressMV(scale); |
---|
[608] | 181 | #else |
---|
[1200] | 182 | pCtu->compressMV(); |
---|
[608] | 183 | #endif |
---|
[1200] | 184 | |
---|
| 185 | } |
---|
[2] | 186 | } |
---|
| 187 | |
---|
[872] | 188 | Bool TComPic::getSAOMergeAvailability(Int currAddr, Int mergeAddr) |
---|
[56] | 189 | { |
---|
[1200] | 190 | Bool mergeCtbInSliceSeg = (mergeAddr >= getPicSym()->getCtuTsToRsAddrMap(getCtu(currAddr)->getSlice()->getSliceCurStartCtuTsAddr())); |
---|
[872] | 191 | Bool mergeCtbInTile = (getPicSym()->getTileIdxMap(mergeAddr) == getPicSym()->getTileIdxMap(currAddr)); |
---|
| 192 | return (mergeCtbInSliceSeg && mergeCtbInTile); |
---|
[56] | 193 | } |
---|
[2] | 194 | |
---|
[1200] | 195 | UInt TComPic::getSubstreamForCtuAddr(const UInt ctuAddr, const Bool bAddressInRaster, TComSlice *pcSlice) |
---|
| 196 | { |
---|
| 197 | UInt subStrm; |
---|
| 198 | const bool bWPPEnabled=pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag(); |
---|
| 199 | const TComPicSym &picSym = *(getPicSym()); |
---|
| 200 | |
---|
| 201 | if ((bWPPEnabled && picSym.getFrameHeightInCtus()>1) || (picSym.getNumTiles()>1)) // wavefronts, and possibly tiles being used. |
---|
| 202 | { |
---|
| 203 | if (bWPPEnabled) |
---|
| 204 | { |
---|
| 205 | const UInt ctuRsAddr = bAddressInRaster?ctuAddr : picSym.getCtuTsToRsAddrMap(ctuAddr); |
---|
| 206 | const UInt frameWidthInCtus = picSym.getFrameWidthInCtus(); |
---|
| 207 | const UInt tileIndex = picSym.getTileIdxMap(ctuRsAddr); |
---|
| 208 | const UInt numTileColumns = (picSym.getNumTileColumnsMinus1()+1); |
---|
| 209 | const TComTile *pTile = picSym.getTComTile(tileIndex); |
---|
| 210 | const UInt firstCtuRsAddrOfTile = pTile->getFirstCtuRsAddr(); |
---|
| 211 | const UInt tileYInCtus = firstCtuRsAddrOfTile / frameWidthInCtus; |
---|
| 212 | // independent tiles => substreams are "per tile" |
---|
| 213 | const UInt ctuLine = ctuRsAddr / frameWidthInCtus; |
---|
| 214 | const UInt startingSubstreamForTile =(tileYInCtus*numTileColumns) + (pTile->getTileHeightInCtus()*(tileIndex%numTileColumns)); |
---|
| 215 | subStrm = startingSubstreamForTile + (ctuLine - tileYInCtus); |
---|
| 216 | } |
---|
| 217 | else |
---|
| 218 | { |
---|
| 219 | const UInt ctuRsAddr = bAddressInRaster?ctuAddr : picSym.getCtuTsToRsAddrMap(ctuAddr); |
---|
| 220 | const UInt tileIndex = picSym.getTileIdxMap(ctuRsAddr); |
---|
| 221 | subStrm=tileIndex; |
---|
| 222 | } |
---|
| 223 | } |
---|
| 224 | else |
---|
| 225 | { |
---|
| 226 | // dependent tiles => substreams are "per frame". |
---|
| 227 | subStrm = 0; |
---|
| 228 | } |
---|
| 229 | return subStrm; |
---|
| 230 | } |
---|
| 231 | |
---|
| 232 | #if NH_MV |
---|
[608] | 233 | Void TComPic::print( Bool legend ) |
---|
| 234 | { |
---|
| 235 | if ( legend ) |
---|
[738] | 236 | std::cout << std::endl << "LId" << "\t" << "POC" << "\t" << "Rec" << "\t" << "Ref" << "\t" << "LT" << "\t" << "OutMark" << "\t" << "OutFlag" << std::endl; |
---|
[608] | 237 | else |
---|
[738] | 238 | std::cout << getLayerId() << "\t" << getPOC()<< "\t" << getReconMark() << "\t" << getSlice(0)->isReferenced() << "\t" << getIsLongTerm() << "\t" << getOutputMark() << "\t" << getSlice(0)->getPicOutputFlag() <<std::endl; |
---|
[608] | 239 | } |
---|
[56] | 240 | |
---|
[608] | 241 | TComPic* TComPicLists::getPic( Int layerIdInNuh, Int poc ) |
---|
| 242 | { |
---|
| 243 | TComPic* pcPic = NULL; |
---|
| 244 | for(TComList<TComList<TComPic*>*>::iterator itL = m_lists.begin(); ( itL != m_lists.end() && pcPic == NULL ); itL++) |
---|
| 245 | { |
---|
| 246 | for(TComList<TComPic*>::iterator itP=(*itL)->begin(); ( itP!=(*itL)->end() && pcPic == NULL ); itP++) |
---|
| 247 | { |
---|
| 248 | TComPic* currPic = (*itP); |
---|
| 249 | if ( ( currPic->getPOC() == poc ) && ( currPic->getLayerId() == layerIdInNuh ) ) |
---|
| 250 | { |
---|
| 251 | pcPic = currPic ; |
---|
| 252 | } |
---|
| 253 | } |
---|
| 254 | } |
---|
| 255 | return pcPic; |
---|
| 256 | } |
---|
[56] | 257 | |
---|
[1200] | 258 | #if NH_3D |
---|
[608] | 259 | TComPic* TComPicLists::getPic( Int viewIndex, Bool depthFlag, Int poc ) |
---|
| 260 | { |
---|
| 261 | return getPic ( m_vps->getLayerIdInNuh( viewIndex, depthFlag ), poc ); |
---|
| 262 | } |
---|
[738] | 263 | #endif |
---|
[608] | 264 | Void TComPicLists::print() |
---|
| 265 | { |
---|
| 266 | Bool first = true; |
---|
| 267 | for(TComList<TComList<TComPic*>*>::iterator itL = m_lists.begin(); ( itL != m_lists.end() ); itL++) |
---|
| 268 | { |
---|
| 269 | for(TComList<TComPic*>::iterator itP=(*itL)->begin(); ( itP!=(*itL)->end() ); itP++) |
---|
| 270 | { |
---|
| 271 | if ( first ) |
---|
| 272 | { |
---|
| 273 | (*itP)->print( true ); |
---|
| 274 | first = false; |
---|
| 275 | } |
---|
| 276 | (*itP)->print( false ); |
---|
| 277 | } |
---|
| 278 | } |
---|
| 279 | } |
---|
| 280 | |
---|
| 281 | TComPicYuv* TComPicLists::getPicYuv( Int layerIdInNuh, Int poc, Bool reconFlag ) |
---|
| 282 | { |
---|
| 283 | TComPic* pcPic = getPic( layerIdInNuh, poc ); |
---|
| 284 | TComPicYuv* pcPicYuv = NULL; |
---|
| 285 | |
---|
| 286 | if (pcPic != NULL) |
---|
| 287 | { |
---|
| 288 | if( reconFlag ) |
---|
| 289 | { |
---|
| 290 | if ( pcPic->getReconMark() ) |
---|
| 291 | { |
---|
| 292 | pcPicYuv = pcPic->getPicYuvRec(); |
---|
| 293 | } |
---|
| 294 | } |
---|
| 295 | else |
---|
| 296 | { |
---|
| 297 | pcPicYuv = pcPic->getPicYuvOrg(); |
---|
| 298 | } |
---|
| 299 | }; |
---|
| 300 | |
---|
| 301 | return pcPicYuv; |
---|
| 302 | } |
---|
| 303 | |
---|
[1200] | 304 | #if NH_3D |
---|
[608] | 305 | TComPicYuv* TComPicLists::getPicYuv( Int viewIndex, Bool depthFlag, Int poc, Bool recon ) |
---|
| 306 | { |
---|
| 307 | Int layerIdInNuh = m_vps->getLayerIdInNuh( viewIndex, depthFlag ); |
---|
| 308 | return getPicYuv( layerIdInNuh, poc, recon ); |
---|
| 309 | } |
---|
[1279] | 310 | #if NH_3D_ARP |
---|
[608] | 311 | TComList<TComPic*>* TComPicLists::getPicList( Int layerIdInNuh ) |
---|
| 312 | { |
---|
| 313 | TComList<TComList<TComPic*>*>::iterator itL = m_lists.begin(); |
---|
| 314 | Int iLayer = 0; |
---|
| 315 | |
---|
| 316 | assert( layerIdInNuh < m_lists.size() ); |
---|
| 317 | |
---|
| 318 | while( iLayer != layerIdInNuh ) |
---|
| 319 | { |
---|
| 320 | itL++; |
---|
| 321 | iLayer++; |
---|
| 322 | } |
---|
| 323 | |
---|
| 324 | return *itL; |
---|
| 325 | } |
---|
| 326 | #endif |
---|
[738] | 327 | #endif |
---|
[1200] | 328 | #endif // NH_MV |
---|
[608] | 329 | |
---|
[1279] | 330 | #if NH_3D_NBDV |
---|
| 331 | Int TComPic::getDisCandRefPictures(Int iColPOC) |
---|
[608] | 332 | { |
---|
| 333 | UInt uiTempLayerCurr = 7; |
---|
| 334 | TComSlice* currSlice = getSlice(getCurrSliceIdx()); |
---|
| 335 | UInt numDdvCandPics = 0; |
---|
| 336 | |
---|
[1279] | 337 | if(!currSlice->getEnableTMVPFlag()) |
---|
| 338 | { |
---|
[608] | 339 | return numDdvCandPics; |
---|
[1279] | 340 | } |
---|
[608] | 341 | |
---|
| 342 | numDdvCandPics += 1; |
---|
| 343 | |
---|
| 344 | UInt pocCurr = currSlice->getPOC(); |
---|
| 345 | UInt pocDiff = 255; |
---|
| 346 | |
---|
[1279] | 347 | for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr++) |
---|
[608] | 348 | { |
---|
[1279] | 349 | Bool x = lpNr ? currSlice->getColFromL0Flag() : 1 - currSlice->getColFromL0Flag(); |
---|
[608] | 350 | |
---|
[1279] | 351 | for(UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++) |
---|
[608] | 352 | { |
---|
| 353 | if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)x, i)->getViewIndex() |
---|
[1279] | 354 | && (x == currSlice->getColFromL0Flag() || currSlice->getRefPOC((RefPicList)x, i) != iColPOC) && numDdvCandPics != 2) |
---|
[608] | 355 | { |
---|
| 356 | TComSlice* refSlice = currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx()); |
---|
[1279] | 357 | Bool bRAP = (refSlice->getViewIndex() && refSlice->isIRAP()) ? 1 : 0; |
---|
[608] | 358 | UInt uiTempLayer = currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx())->getTLayer(); |
---|
| 359 | |
---|
[1279] | 360 | if(bRAP) |
---|
[608] | 361 | { |
---|
| 362 | this->setRapRefIdx(i); |
---|
| 363 | this->setRapRefList((RefPicList)x); |
---|
| 364 | numDdvCandPics = 2; |
---|
| 365 | |
---|
| 366 | return numDdvCandPics; |
---|
| 367 | } |
---|
| 368 | else if (uiTempLayerCurr > uiTempLayer) |
---|
| 369 | { |
---|
| 370 | uiTempLayerCurr = uiTempLayer; |
---|
| 371 | } |
---|
| 372 | } |
---|
| 373 | } |
---|
| 374 | } |
---|
| 375 | |
---|
| 376 | UInt z = -1; // GT: Added to make code compile needs to be checked! |
---|
| 377 | UInt idx = 0; |
---|
| 378 | |
---|
[1279] | 379 | for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2 : 1); lpNr++) |
---|
[608] | 380 | { |
---|
[1279] | 381 | Bool x = lpNr ? currSlice->getColFromL0Flag() : 1 - currSlice->getColFromL0Flag(); |
---|
[608] | 382 | |
---|
[1279] | 383 | for(UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++) |
---|
[608] | 384 | { |
---|
| 385 | Int iTempPoc = currSlice->getRefPic((RefPicList)x, i)->getPOC(); |
---|
[1279] | 386 | Int iTempDiff = (iTempPoc > pocCurr) ? (iTempPoc - pocCurr) : (pocCurr - iTempPoc); |
---|
[608] | 387 | |
---|
[1279] | 388 | if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)x, i)->getViewIndex() && (x == currSlice->getColFromL0Flag() || currSlice->getRefPOC((RefPicList)x, i) != iColPOC) |
---|
| 389 | && currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx())->getTLayer() == uiTempLayerCurr && pocDiff > iTempDiff) |
---|
[608] | 390 | { |
---|
| 391 | pocDiff = iTempDiff; |
---|
| 392 | z = x; |
---|
| 393 | idx = i; |
---|
| 394 | } |
---|
| 395 | } |
---|
| 396 | } |
---|
| 397 | |
---|
[1279] | 398 | if(pocDiff < 255) |
---|
[608] | 399 | { |
---|
| 400 | this->setRapRefIdx(idx); |
---|
[1279] | 401 | this->setRapRefList((RefPicList) z); |
---|
[608] | 402 | numDdvCandPics = 2; |
---|
| 403 | } |
---|
| 404 | |
---|
| 405 | return numDdvCandPics; |
---|
| 406 | } |
---|
[655] | 407 | |
---|
[608] | 408 | Void TComPic::checkTemporalIVRef() |
---|
| 409 | { |
---|
| 410 | TComSlice* currSlice = getSlice(getCurrSliceIdx()); |
---|
| 411 | const Int numCandPics = this->getNumDdvCandPics(); |
---|
[1279] | 412 | |
---|
[608] | 413 | for(Int curCandPic = 0; curCandPic < numCandPics; curCandPic++) |
---|
| 414 | { |
---|
| 415 | RefPicList eCurRefPicList = REF_PIC_LIST_0 ; |
---|
| 416 | Int curCandPicRefIdx = 0; |
---|
[1279] | 417 | if(curCandPic == 0) |
---|
[608] | 418 | { |
---|
[1279] | 419 | eCurRefPicList = RefPicList(currSlice->isInterB() ? 1 - currSlice->getColFromL0Flag() : 0); |
---|
[608] | 420 | curCandPicRefIdx = currSlice->getColRefIdx(); |
---|
| 421 | } |
---|
| 422 | else |
---|
| 423 | { |
---|
| 424 | eCurRefPicList = this->getRapRefList(); |
---|
| 425 | curCandPicRefIdx = this->getRapRefIdx(); |
---|
| 426 | } |
---|
| 427 | |
---|
[1279] | 428 | TComPic* pcCandColPic = currSlice->getRefPic(eCurRefPicList, curCandPicRefIdx); |
---|
| 429 | TComSlice* pcCandColSlice = pcCandColPic->getSlice(0); // currently only support single slice |
---|
| 430 | |
---|
[608] | 431 | if(!pcCandColSlice->isIntra()) |
---|
| 432 | { |
---|
[1279] | 433 | for(Int iColRefDir = 0; iColRefDir < (pcCandColSlice->isInterB() ? 2 : 1); iColRefDir++) |
---|
[608] | 434 | { |
---|
[1279] | 435 | for(Int iColRefIdx = 0; iColRefIdx < pcCandColSlice->getNumRefIdx((RefPicList)iColRefDir); iColRefIdx++) |
---|
[608] | 436 | { |
---|
| 437 | m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] = false; |
---|
| 438 | Int iColViewIdx = pcCandColSlice->getViewIndex(); |
---|
[1279] | 439 | Int iColRefViewIdx = pcCandColSlice->getRefPic((RefPicList)iColRefDir, iColRefIdx)->getViewIndex(); |
---|
[608] | 440 | if(iColViewIdx == iColRefViewIdx) |
---|
[1279] | 441 | { |
---|
[608] | 442 | continue; |
---|
[1279] | 443 | } |
---|
[608] | 444 | |
---|
[1279] | 445 | for(Int iCurrRefDir = 0; (iCurrRefDir < (currSlice->isInterB() ? 2 : 1)) && (m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] == false); iCurrRefDir++) |
---|
[608] | 446 | { |
---|
[1279] | 447 | for(Int iCurrRefIdx = 0; iCurrRefIdx < currSlice->getNumRefIdx((RefPicList)iCurrRefDir); iCurrRefIdx++) |
---|
[608] | 448 | { |
---|
[1279] | 449 | if(currSlice->getRefPic((RefPicList)iCurrRefDir, iCurrRefIdx)->getViewIndex() == iColRefViewIdx) |
---|
[608] | 450 | { |
---|
| 451 | m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] = true; |
---|
| 452 | break; |
---|
| 453 | } |
---|
| 454 | } |
---|
| 455 | } |
---|
| 456 | } |
---|
| 457 | } |
---|
| 458 | } |
---|
| 459 | } |
---|
| 460 | } |
---|
[1279] | 461 | |
---|
[608] | 462 | Bool TComPic::isTempIVRefValid(Int currCandPic, Int iColRefDir, Int iColRefIdx) |
---|
| 463 | { |
---|
| 464 | return m_abTIVRINCurrRL[currCandPic][iColRefDir][iColRefIdx]; |
---|
| 465 | } |
---|
[655] | 466 | |
---|
[1279] | 467 | Void TComPic::checkTextureRef() |
---|
[608] | 468 | { |
---|
| 469 | TComSlice* pcCurrSlice = getSlice(getCurrSliceIdx()); |
---|
[1279] | 470 | TComPic* pcTextPic = pcCurrSlice->getIvPic(0, getViewIndex()); |
---|
[655] | 471 | #if H_3D_FCO |
---|
| 472 | if ( pcTextPic ) |
---|
| 473 | { |
---|
| 474 | #endif |
---|
[1200] | 475 | TComSlice* pcTextSlice = pcTextPic->getSlice(0); // currently only support single slice |
---|
[608] | 476 | |
---|
[1279] | 477 | for(Int iTextRefDir = 0; (iTextRefDir < (pcTextSlice->isInterB() ? 2 :1) ) && !pcTextSlice->isIntra(); iTextRefDir++) |
---|
[608] | 478 | { |
---|
[1279] | 479 | for(Int iTextRefIdx =0; iTextRefIdx < pcTextSlice->getNumRefIdx((RefPicList)iTextRefDir); iTextRefIdx++) |
---|
[608] | 480 | { |
---|
[1279] | 481 | Int iTextRefPOC = pcTextSlice->getRefPOC((RefPicList)iTextRefDir, iTextRefIdx); |
---|
| 482 | Int iTextRefViewId = pcTextSlice->getRefPic((RefPicList)iTextRefDir, iTextRefIdx)->getViewIndex(); |
---|
[1200] | 483 | m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = -1; |
---|
| 484 | Int iCurrRefDir = iTextRefDir; |
---|
[1279] | 485 | |
---|
| 486 | for(Int iCurrRefIdx = 0; (iCurrRefIdx<pcCurrSlice->getNumRefIdx((RefPicList)iCurrRefDir)) && (m_aiTexToDepRef[iTextRefDir][iTextRefIdx] < 0); iCurrRefIdx++) |
---|
[1200] | 487 | { |
---|
[1279] | 488 | if(pcCurrSlice->getRefPOC((RefPicList)iCurrRefDir, iCurrRefIdx ) == iTextRefPOC && |
---|
| 489 | pcCurrSlice->getRefPic((RefPicList)iCurrRefDir, iCurrRefIdx)->getViewIndex() == iTextRefViewId) |
---|
[1200] | 490 | { |
---|
| 491 | m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = iCurrRefIdx; |
---|
| 492 | } |
---|
[608] | 493 | } |
---|
| 494 | } |
---|
| 495 | } |
---|
[655] | 496 | #if H_3D_FCO |
---|
| 497 | } |
---|
| 498 | #endif |
---|
[608] | 499 | } |
---|
| 500 | |
---|
| 501 | Int TComPic::isTextRefValid(Int iTextRefDir, Int iTextRefIdx) |
---|
| 502 | { |
---|
| 503 | return m_aiTexToDepRef[iTextRefDir][iTextRefIdx]; |
---|
| 504 | } |
---|
| 505 | #endif |
---|
[1200] | 506 | |
---|
| 507 | |
---|
[56] | 508 | //! \} |
---|