[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 |
---|
| 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 | |
---|
[2] | 34 | /** \file TDecTop.cpp |
---|
| 35 | \brief decoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include "../../App/TAppDecoder/TAppDecTop.h" |
---|
| 39 | #include "TDecTop.h" |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | CamParsCollector::CamParsCollector() |
---|
| 44 | : m_bInitialized( false ) |
---|
| 45 | { |
---|
| 46 | m_aaiCodedOffset = new Int* [ MAX_NUMBER_VIEWS ]; |
---|
| 47 | m_aaiCodedScale = new Int* [ MAX_NUMBER_VIEWS ]; |
---|
| 48 | m_aiViewOrderIndex = new Int [ MAX_NUMBER_VIEWS ]; |
---|
| 49 | m_aiViewReceived = new Int [ MAX_NUMBER_VIEWS ]; |
---|
| 50 | for( UInt uiId = 0; uiId < MAX_NUMBER_VIEWS; uiId++ ) |
---|
| 51 | { |
---|
| 52 | m_aaiCodedOffset [ uiId ] = new Int [ MAX_NUMBER_VIEWS ]; |
---|
| 53 | m_aaiCodedScale [ uiId ] = new Int [ MAX_NUMBER_VIEWS ]; |
---|
| 54 | } |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | CamParsCollector::~CamParsCollector() |
---|
| 58 | { |
---|
| 59 | for( UInt uiId = 0; uiId < MAX_NUMBER_VIEWS; uiId++ ) |
---|
| 60 | { |
---|
| 61 | delete [] m_aaiCodedOffset [ uiId ]; |
---|
| 62 | delete [] m_aaiCodedScale [ uiId ]; |
---|
| 63 | } |
---|
| 64 | delete [] m_aaiCodedOffset; |
---|
| 65 | delete [] m_aaiCodedScale; |
---|
| 66 | delete [] m_aiViewOrderIndex; |
---|
| 67 | delete [] m_aiViewReceived; |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | Void |
---|
| 71 | CamParsCollector::init( FILE* pCodedScaleOffsetFile ) |
---|
| 72 | { |
---|
| 73 | m_bInitialized = true; |
---|
| 74 | m_pCodedScaleOffsetFile = pCodedScaleOffsetFile; |
---|
| 75 | m_uiCamParsCodedPrecision = 0; |
---|
| 76 | m_bCamParsVaryOverTime = false; |
---|
| 77 | m_iLastViewId = -1; |
---|
| 78 | m_iLastPOC = -1; |
---|
| 79 | m_uiMaxViewId = 0; |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | Void |
---|
| 83 | CamParsCollector::uninit() |
---|
| 84 | { |
---|
| 85 | m_bInitialized = false; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | Void |
---|
| 89 | CamParsCollector::setSlice( TComSlice* pcSlice ) |
---|
| 90 | { |
---|
| 91 | if( pcSlice == 0 ) |
---|
| 92 | { |
---|
| 93 | AOF( xIsComplete() ); |
---|
| 94 | if( m_bCamParsVaryOverTime || m_iLastPOC == 0 ) |
---|
| 95 | { |
---|
| 96 | xOutput( m_iLastPOC ); |
---|
| 97 | } |
---|
| 98 | return; |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | AOF( pcSlice->getSPS()->getViewId() < MAX_NUMBER_VIEWS ); |
---|
| 102 | if ( pcSlice->getSPS()->isDepth () ) |
---|
| 103 | { |
---|
| 104 | return; |
---|
| 105 | } |
---|
| 106 | Bool bFirstAU = ( pcSlice->getPOC() == 0 ); |
---|
| 107 | Bool bFirstSliceInAU = ( pcSlice->getPOC() != Int ( m_iLastPOC ) ); |
---|
| 108 | Bool bFirstSliceInView = ( pcSlice->getSPS()->getViewId() != UInt( m_iLastViewId ) || bFirstSliceInAU ); |
---|
| 109 | AOT( bFirstSliceInAU && pcSlice->getSPS()->getViewId() != 0 ); |
---|
| 110 | AOT( !bFirstSliceInAU && pcSlice->getSPS()->getViewId() < UInt( m_iLastViewId ) ); |
---|
| 111 | AOT( !bFirstSliceInAU && pcSlice->getSPS()->getViewId() > UInt( m_iLastViewId + 1 ) ); |
---|
| 112 | AOT( !bFirstAU && pcSlice->getSPS()->getViewId() > m_uiMaxViewId ); |
---|
| 113 | if ( !bFirstSliceInView ) |
---|
| 114 | { |
---|
| 115 | if( m_bCamParsVaryOverTime ) // check consistency of slice parameters here |
---|
| 116 | { |
---|
| 117 | UInt uiViewId = pcSlice->getSPS()->getViewId(); |
---|
| 118 | for( UInt uiBaseId = 0; uiBaseId < uiViewId; uiBaseId++ ) |
---|
| 119 | { |
---|
| 120 | AOF( m_aaiCodedScale [ uiBaseId ][ uiViewId ] == pcSlice->getCodedScale () [ uiBaseId ] ); |
---|
| 121 | AOF( m_aaiCodedOffset[ uiBaseId ][ uiViewId ] == pcSlice->getCodedOffset () [ uiBaseId ] ); |
---|
| 122 | AOF( m_aaiCodedScale [ uiViewId ][ uiBaseId ] == pcSlice->getInvCodedScale () [ uiBaseId ] ); |
---|
| 123 | AOF( m_aaiCodedOffset[ uiViewId ][ uiBaseId ] == pcSlice->getInvCodedOffset() [ uiBaseId ] ); |
---|
| 124 | } |
---|
| 125 | } |
---|
| 126 | return; |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | if( bFirstSliceInAU ) |
---|
| 130 | { |
---|
| 131 | if( !bFirstAU ) |
---|
| 132 | { |
---|
| 133 | AOF( xIsComplete() ); |
---|
| 134 | xOutput( m_iLastPOC ); |
---|
| 135 | } |
---|
| 136 | ::memset( m_aiViewReceived, 0x00, MAX_NUMBER_VIEWS * sizeof( Int ) ); |
---|
| 137 | } |
---|
| 138 | |
---|
| 139 | UInt uiViewId = pcSlice->getSPS()->getViewId(); |
---|
| 140 | m_aiViewReceived[ uiViewId ] = 1; |
---|
| 141 | if( bFirstAU ) |
---|
| 142 | { |
---|
| 143 | m_uiMaxViewId = Max( m_uiMaxViewId, uiViewId ); |
---|
| 144 | m_aiViewOrderIndex[ uiViewId ] = pcSlice->getSPS()->getViewOrderIdx(); |
---|
| 145 | if( uiViewId == 1 ) |
---|
| 146 | { |
---|
| 147 | m_uiCamParsCodedPrecision = pcSlice->getSPS()->getCamParPrecision (); |
---|
| 148 | m_bCamParsVaryOverTime = pcSlice->getSPS()->hasCamParInSliceHeader (); |
---|
| 149 | } |
---|
| 150 | else if( uiViewId > 1 ) |
---|
| 151 | { |
---|
| 152 | AOF( m_uiCamParsCodedPrecision == pcSlice->getSPS()->getCamParPrecision () ); |
---|
| 153 | AOF( m_bCamParsVaryOverTime == pcSlice->getSPS()->hasCamParInSliceHeader () ); |
---|
| 154 | } |
---|
| 155 | for( UInt uiBaseId = 0; uiBaseId < uiViewId; uiBaseId++ ) |
---|
| 156 | { |
---|
| 157 | if( m_bCamParsVaryOverTime ) |
---|
| 158 | { |
---|
| 159 | m_aaiCodedScale [ uiBaseId ][ uiViewId ] = pcSlice->getCodedScale () [ uiBaseId ]; |
---|
| 160 | m_aaiCodedOffset[ uiBaseId ][ uiViewId ] = pcSlice->getCodedOffset () [ uiBaseId ]; |
---|
| 161 | m_aaiCodedScale [ uiViewId ][ uiBaseId ] = pcSlice->getInvCodedScale () [ uiBaseId ]; |
---|
| 162 | m_aaiCodedOffset[ uiViewId ][ uiBaseId ] = pcSlice->getInvCodedOffset() [ uiBaseId ]; |
---|
| 163 | } |
---|
| 164 | else |
---|
| 165 | { |
---|
| 166 | m_aaiCodedScale [ uiBaseId ][ uiViewId ] = pcSlice->getSPS()->getCodedScale () [ uiBaseId ]; |
---|
| 167 | m_aaiCodedOffset[ uiBaseId ][ uiViewId ] = pcSlice->getSPS()->getCodedOffset () [ uiBaseId ]; |
---|
| 168 | m_aaiCodedScale [ uiViewId ][ uiBaseId ] = pcSlice->getSPS()->getInvCodedScale () [ uiBaseId ]; |
---|
| 169 | m_aaiCodedOffset[ uiViewId ][ uiBaseId ] = pcSlice->getSPS()->getInvCodedOffset() [ uiBaseId ]; |
---|
| 170 | } |
---|
| 171 | } |
---|
| 172 | } |
---|
| 173 | else |
---|
| 174 | { |
---|
| 175 | AOF( m_aiViewOrderIndex[ uiViewId ] == pcSlice->getSPS()->getViewOrderIdx() ); |
---|
| 176 | if( m_bCamParsVaryOverTime ) |
---|
| 177 | { |
---|
| 178 | for( UInt uiBaseId = 0; uiBaseId < uiViewId; uiBaseId++ ) |
---|
| 179 | { |
---|
| 180 | m_aaiCodedScale [ uiBaseId ][ uiViewId ] = pcSlice->getCodedScale () [ uiBaseId ]; |
---|
| 181 | m_aaiCodedOffset[ uiBaseId ][ uiViewId ] = pcSlice->getCodedOffset () [ uiBaseId ]; |
---|
| 182 | m_aaiCodedScale [ uiViewId ][ uiBaseId ] = pcSlice->getInvCodedScale () [ uiBaseId ]; |
---|
| 183 | m_aaiCodedOffset[ uiViewId ][ uiBaseId ] = pcSlice->getInvCodedOffset() [ uiBaseId ]; |
---|
| 184 | } |
---|
| 185 | } |
---|
| 186 | } |
---|
| 187 | m_iLastViewId = (Int)pcSlice->getSPS()->getViewId(); |
---|
| 188 | m_iLastPOC = (Int)pcSlice->getPOC(); |
---|
| 189 | } |
---|
| 190 | |
---|
| 191 | Bool |
---|
| 192 | CamParsCollector::xIsComplete() |
---|
| 193 | { |
---|
| 194 | for( UInt uiView = 0; uiView <= m_uiMaxViewId; uiView++ ) |
---|
| 195 | { |
---|
| 196 | if( m_aiViewReceived[ uiView ] == 0 ) |
---|
| 197 | { |
---|
| 198 | return false; |
---|
| 199 | } |
---|
| 200 | } |
---|
| 201 | return true; |
---|
| 202 | } |
---|
| 203 | |
---|
| 204 | Void |
---|
| 205 | CamParsCollector::xOutput( Int iPOC ) |
---|
| 206 | { |
---|
| 207 | if( m_pCodedScaleOffsetFile ) |
---|
| 208 | { |
---|
| 209 | if( iPOC == 0 ) |
---|
| 210 | { |
---|
| 211 | fprintf( m_pCodedScaleOffsetFile, "# ViewId ViewOrderIdx\n" ); |
---|
| 212 | fprintf( m_pCodedScaleOffsetFile, "#----------- ------------\n" ); |
---|
| 213 | for( UInt uiViewId = 0; uiViewId <= m_uiMaxViewId; uiViewId++ ) |
---|
| 214 | { |
---|
| 215 | fprintf( m_pCodedScaleOffsetFile, "%12d %12d\n", uiViewId, m_aiViewOrderIndex[ uiViewId ] ); |
---|
| 216 | } |
---|
| 217 | fprintf( m_pCodedScaleOffsetFile, "\n\n"); |
---|
| 218 | fprintf( m_pCodedScaleOffsetFile, "# StartFrame EndFrame TargetView BaseView CodedScale CodedOffset Precision\n" ); |
---|
| 219 | fprintf( m_pCodedScaleOffsetFile, "#----------- ------------ ------------ ------------ ------------ ------------ ------------\n" ); |
---|
| 220 | } |
---|
| 221 | if( iPOC == 0 || m_bCamParsVaryOverTime ) |
---|
| 222 | { |
---|
| 223 | Int iS = iPOC; |
---|
| 224 | Int iE = ( m_bCamParsVaryOverTime ? iPOC : ~( 1 << 31 ) ); |
---|
| 225 | for( UInt uiViewId = 0; uiViewId <= m_uiMaxViewId; uiViewId++ ) |
---|
| 226 | { |
---|
| 227 | for( UInt uiBaseId = 0; uiBaseId <= m_uiMaxViewId; uiBaseId++ ) |
---|
| 228 | { |
---|
| 229 | if( uiViewId != uiBaseId ) |
---|
| 230 | { |
---|
| 231 | fprintf( m_pCodedScaleOffsetFile, "%12d %12d %12d %12d %12d %12d %12d\n", |
---|
| 232 | iS, iE, uiViewId, uiBaseId, m_aaiCodedScale[ uiBaseId ][ uiViewId ], m_aaiCodedOffset[ uiBaseId ][ uiViewId ], m_uiCamParsCodedPrecision ); |
---|
| 233 | } |
---|
| 234 | } |
---|
| 235 | } |
---|
| 236 | } |
---|
| 237 | } |
---|
| 238 | } |
---|
| 239 | |
---|
| 240 | |
---|
| 241 | |
---|
| 242 | |
---|
| 243 | TDecTop::TDecTop() |
---|
| 244 | : m_SEIs(0) |
---|
| 245 | { |
---|
| 246 | m_iGopSize = 0; |
---|
| 247 | m_bGopSizeSet = false; |
---|
| 248 | m_iMaxRefPicNum = 0; |
---|
| 249 | m_uiValidPS = 0; |
---|
| 250 | m_bIsDepth = false ; |
---|
| 251 | m_iViewIdx = 0 ; |
---|
[20] | 252 | #if SONY_COLPIC_AVAILABILITY |
---|
| 253 | m_iViewOrderIdx = 0; |
---|
| 254 | #endif |
---|
[2] | 255 | #if ENC_DEC_TRACE |
---|
| 256 | g_hTrace = fopen( "TraceDec.txt", "wb" ); |
---|
| 257 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
| 258 | g_nSymbolCounter = 0; |
---|
| 259 | #endif |
---|
| 260 | #if DCM_DECODING_REFRESH |
---|
| 261 | m_bRefreshPending = 0; |
---|
| 262 | m_uiPOCCDR = 0; |
---|
| 263 | #if DCM_SKIP_DECODING_FRAMES |
---|
| 264 | m_uiPOCRA = MAX_UINT; |
---|
| 265 | #endif |
---|
| 266 | #endif |
---|
| 267 | m_uiPrevPOC = UInt(-1); |
---|
| 268 | m_bFirstSliceInPicture = true; |
---|
| 269 | m_bFirstSliceInSequence = true; |
---|
| 270 | m_pcCamParsCollector = 0; |
---|
| 271 | } |
---|
| 272 | |
---|
| 273 | TDecTop::~TDecTop() |
---|
| 274 | { |
---|
| 275 | #if ENC_DEC_TRACE |
---|
| 276 | fclose( g_hTrace ); |
---|
| 277 | #endif |
---|
| 278 | } |
---|
| 279 | |
---|
| 280 | Void TDecTop::create() |
---|
| 281 | { |
---|
| 282 | m_cGopDecoder.create(); |
---|
| 283 | m_apcSlicePilot = new TComSlice; |
---|
| 284 | m_uiSliceIdx = m_uiLastSliceIdx = 0; |
---|
| 285 | } |
---|
| 286 | |
---|
| 287 | Void TDecTop::destroy() |
---|
| 288 | { |
---|
| 289 | m_cGopDecoder.destroy(); |
---|
| 290 | |
---|
| 291 | delete m_apcSlicePilot; |
---|
| 292 | m_apcSlicePilot = NULL; |
---|
| 293 | |
---|
| 294 | m_cSliceDecoder.destroy(); |
---|
| 295 | |
---|
[5] | 296 | #if DEPTH_MAP_GENERATION |
---|
[2] | 297 | m_cDepthMapGenerator.destroy(); |
---|
[5] | 298 | #endif |
---|
| 299 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 300 | m_cResidualGenerator.destroy(); |
---|
[5] | 301 | #endif |
---|
[2] | 302 | } |
---|
| 303 | |
---|
| 304 | Void TDecTop::init( TAppDecTop* pcTAppDecTop, Bool bFirstInstance ) |
---|
| 305 | { |
---|
| 306 | // initialize ROM |
---|
| 307 | if( bFirstInstance ) |
---|
| 308 | initROM(); |
---|
| 309 | #if MTK_SAO |
---|
[5] | 310 | m_cGopDecoder. init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cAdaptiveLoopFilter, &m_cSAO |
---|
| 311 | #if DEPTH_MAP_GENERATION |
---|
| 312 | , &m_cDepthMapGenerator |
---|
| 313 | #endif |
---|
| 314 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 315 | , &m_cResidualGenerator |
---|
| 316 | #endif |
---|
| 317 | ); |
---|
[2] | 318 | #else |
---|
[5] | 319 | m_cGopDecoder. init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cAdaptiveLoopFilter |
---|
| 320 | #if DEPTH_MAP_GENERATION |
---|
| 321 | , &m_cDepthMapGenerator |
---|
[2] | 322 | #endif |
---|
[5] | 323 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 324 | , &m_cResidualGenerator |
---|
| 325 | #endif |
---|
| 326 | ); |
---|
| 327 | #endif |
---|
[2] | 328 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder ); |
---|
| 329 | m_cEntropyDecoder.init(&m_cPrediction); |
---|
| 330 | |
---|
| 331 | m_pcTAppDecTop = pcTAppDecTop; |
---|
[5] | 332 | #if DEPTH_MAP_GENERATION |
---|
[2] | 333 | m_cDepthMapGenerator.init( &m_cPrediction, m_pcTAppDecTop->getSPSAccess(), m_pcTAppDecTop->getAUPicAccess() ); |
---|
[5] | 334 | #endif |
---|
| 335 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 336 | m_cResidualGenerator.init( &m_cTrQuant, &m_cDepthMapGenerator ); |
---|
[5] | 337 | #endif |
---|
[2] | 338 | } |
---|
| 339 | |
---|
| 340 | Void TDecTop::setSPS(TComSPS cSPS) |
---|
| 341 | { |
---|
| 342 | m_cSPS = cSPS ; |
---|
| 343 | if ( !m_cAdaptiveLoopFilter.isCreated()) |
---|
| 344 | { |
---|
| 345 | m_cAdaptiveLoopFilter.create( m_cSPS.getWidth(), m_cSPS.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 346 | #if MTK_SAO |
---|
| 347 | m_cSAO.create( m_cSPS.getWidth(), m_cSPS.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 348 | #endif |
---|
| 349 | m_cLoopFilter. create( g_uiMaxCUDepth ); |
---|
| 350 | } |
---|
| 351 | m_uiValidPS |= 1; |
---|
| 352 | } |
---|
| 353 | |
---|
| 354 | Void TDecTop::deletePicBuffer ( ) |
---|
| 355 | { |
---|
| 356 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 357 | Int iSize = Int( m_cListPic.size() ); |
---|
| 358 | |
---|
| 359 | for (Int i = 0; i < iSize; i++ ) |
---|
| 360 | { |
---|
| 361 | TComPic* pcPic = *(iterPic++); |
---|
| 362 | pcPic->destroy(); |
---|
| 363 | |
---|
| 364 | delete pcPic; |
---|
| 365 | pcPic = NULL; |
---|
| 366 | } |
---|
| 367 | |
---|
| 368 | // destroy ALF temporary buffers |
---|
| 369 | m_cAdaptiveLoopFilter.destroy(); |
---|
| 370 | |
---|
| 371 | #if MTK_SAO |
---|
| 372 | m_cSAO.destroy(); |
---|
| 373 | #endif |
---|
| 374 | |
---|
| 375 | m_cLoopFilter. destroy(); |
---|
| 376 | |
---|
| 377 | // destroy ROM |
---|
| 378 | if( m_iViewIdx <= 0 && !m_bIsDepth) |
---|
| 379 | destroyROM(); |
---|
| 380 | } |
---|
| 381 | |
---|
| 382 | Void TDecTop::xGetNewPicBuffer ( TComSlice* pcSlice, TComPic*& rpcPic ) |
---|
| 383 | { |
---|
| 384 | m_iMaxRefPicNum = getCodedPictureBufferSize( ); |
---|
| 385 | |
---|
[5] | 386 | #if DEPTH_MAP_GENERATION |
---|
[20] | 387 | UInt uiPdm = ( pcSlice->getSPS()->getViewId() ? pcSlice->getSPS()->getPredDepthMapGeneration() : m_pcTAppDecTop->getSPSAccess()->getPdm() ); |
---|
| 388 | Bool bNeedPrdDepthMapBuffer = ( !pcSlice->getSPS()->isDepth() && uiPdm > 0 ); |
---|
[5] | 389 | #endif |
---|
[2] | 390 | |
---|
| 391 | if (m_cListPic.size() < (UInt)m_iMaxRefPicNum) |
---|
| 392 | { |
---|
| 393 | rpcPic = new TComPic; |
---|
| 394 | rpcPic->create ( pcSlice->getSPS()->getWidth(), pcSlice->getSPS()->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
[5] | 395 | #if DEPTH_MAP_GENERATION |
---|
[2] | 396 | if( bNeedPrdDepthMapBuffer ) |
---|
| 397 | { |
---|
[20] | 398 | rpcPic->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) ); |
---|
[2] | 399 | } |
---|
[5] | 400 | #endif |
---|
[2] | 401 | m_cListPic.pushBack( rpcPic ); |
---|
| 402 | |
---|
| 403 | return; |
---|
| 404 | } |
---|
| 405 | |
---|
| 406 | Bool bBufferIsAvailable = false; |
---|
| 407 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 408 | while (iterPic != m_cListPic.end()) |
---|
| 409 | { |
---|
| 410 | rpcPic = *(iterPic++); |
---|
| 411 | if ( rpcPic->getReconMark() == false ) |
---|
| 412 | { |
---|
| 413 | bBufferIsAvailable = true; |
---|
| 414 | break; |
---|
| 415 | } |
---|
| 416 | } |
---|
| 417 | |
---|
| 418 | if ( !bBufferIsAvailable ) |
---|
| 419 | { |
---|
| 420 | pcSlice->sortPicList(m_cListPic); |
---|
| 421 | iterPic = m_cListPic.begin(); |
---|
| 422 | rpcPic = *(iterPic); |
---|
| 423 | rpcPic->setReconMark(false); |
---|
| 424 | |
---|
| 425 | // mark it should be extended |
---|
| 426 | } |
---|
| 427 | rpcPic->getPicYuvRec()->setBorderExtension(false); |
---|
| 428 | |
---|
[5] | 429 | #if DEPTH_MAP_GENERATION |
---|
[2] | 430 | if( bNeedPrdDepthMapBuffer && !rpcPic->getPredDepthMap() ) |
---|
| 431 | { |
---|
[20] | 432 | rpcPic->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) ); |
---|
[2] | 433 | } |
---|
[5] | 434 | #endif |
---|
[2] | 435 | } |
---|
| 436 | |
---|
| 437 | |
---|
| 438 | Void |
---|
| 439 | TDecTop::deleteExtraPicBuffers( Int iPoc ) |
---|
| 440 | { |
---|
| 441 | TComPic* pcPic = 0; |
---|
| 442 | TComList<TComPic*>::iterator cIter = m_cListPic.begin(); |
---|
| 443 | TComList<TComPic*>::iterator cEnd = m_cListPic.end (); |
---|
| 444 | for( ; cIter != cEnd; cIter++ ) |
---|
| 445 | { |
---|
| 446 | if( (*cIter)->getPOC() == iPoc ) |
---|
| 447 | { |
---|
| 448 | pcPic = *cIter; |
---|
| 449 | break; |
---|
| 450 | } |
---|
| 451 | } |
---|
| 452 | AOF( pcPic ); |
---|
| 453 | if ( pcPic ) |
---|
| 454 | { |
---|
| 455 | pcPic->removeOriginalBuffer (); |
---|
[5] | 456 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
[2] | 457 | pcPic->removeOrgDepthMapBuffer(); |
---|
[5] | 458 | #endif |
---|
| 459 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 460 | pcPic->removeResidualBuffer (); |
---|
[5] | 461 | #endif |
---|
| 462 | #if HHI_INTERVIEW_SKIP |
---|
[2] | 463 | pcPic->removeUsedPelsMapBuffer(); |
---|
[5] | 464 | #endif |
---|
[2] | 465 | } |
---|
| 466 | } |
---|
| 467 | |
---|
| 468 | #if AMVP_BUFFERCOMPRESS |
---|
| 469 | Void |
---|
| 470 | TDecTop::compressMotion( Int iPoc ) |
---|
| 471 | { |
---|
| 472 | TComPic* pcPic = 0; |
---|
| 473 | TComList<TComPic*>::iterator cIter = m_cListPic.begin(); |
---|
| 474 | TComList<TComPic*>::iterator cEnd = m_cListPic.end (); |
---|
| 475 | for( ; cIter != cEnd; cIter++ ) |
---|
| 476 | { |
---|
| 477 | if( (*cIter)->getPOC() == iPoc ) |
---|
| 478 | { |
---|
| 479 | pcPic = *cIter; |
---|
| 480 | break; |
---|
| 481 | } |
---|
| 482 | } |
---|
| 483 | AOF( pcPic ); |
---|
| 484 | if ( pcPic ) |
---|
| 485 | { |
---|
| 486 | pcPic->compressMotion(); |
---|
| 487 | } |
---|
| 488 | } |
---|
| 489 | #endif |
---|
| 490 | |
---|
| 491 | |
---|
| 492 | Void TDecTop::executeDeblockAndAlf(Bool bEos, TComBitstream* pcBitstream, UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
| 493 | { |
---|
| 494 | TComPic*& pcPic = m_pcPic; |
---|
| 495 | |
---|
| 496 | // Execute Deblock and ALF only + Cleanup |
---|
| 497 | TComSlice* pcSlice = pcPic->getPicSym()->getSlice( m_uiSliceIdx ); |
---|
| 498 | m_cGopDecoder.decompressGop ( bEos, pcBitstream, pcPic, true); |
---|
| 499 | |
---|
| 500 | if( m_pcCamParsCollector && bEos ) |
---|
| 501 | { |
---|
| 502 | m_pcCamParsCollector->setSlice( 0 ); |
---|
| 503 | } |
---|
| 504 | |
---|
| 505 | pcSlice->sortPicList ( m_cListPic ); // sorting for application output |
---|
| 506 | ruiPOC = pcPic->getSlice(m_uiSliceIdx-1)->getPOC(); |
---|
| 507 | rpcListPic = &m_cListPic; |
---|
| 508 | m_cCuDecoder.destroy(); |
---|
| 509 | m_bFirstSliceInPicture = true; |
---|
| 510 | |
---|
| 511 | return; |
---|
| 512 | } |
---|
| 513 | |
---|
| 514 | #if DCM_SKIP_DECODING_FRAMES |
---|
| 515 | Bool TDecTop::decode (Bool bEos, TComBitstream* pcBitstream, UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, NalUnitType& reNalUnitType, TComSPS& cComSPS, Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
| 516 | #else |
---|
| 517 | Void TDecTop::decode (Bool bEos, TComBitstream* pcBitstream, UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, NalUnitType& reNalUnitType, TComSPS& cComSPS ) |
---|
| 518 | #endif |
---|
| 519 | { |
---|
| 520 | if (m_bFirstSliceInPicture) |
---|
| 521 | { |
---|
| 522 | rpcListPic = NULL; |
---|
| 523 | } |
---|
| 524 | TComPic*& pcPic = m_pcPic; |
---|
| 525 | |
---|
| 526 | // Initialize entropy decoder |
---|
| 527 | m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); |
---|
| 528 | m_cEntropyDecoder.setBitstream (pcBitstream); |
---|
| 529 | |
---|
| 530 | NalUnitType eNalUnitType; |
---|
| 531 | UInt TemporalId; |
---|
| 532 | Bool OutputFlag; |
---|
| 533 | |
---|
| 534 | m_cEntropyDecoder.decodeNalUnitHeader(eNalUnitType, TemporalId, OutputFlag); |
---|
| 535 | reNalUnitType = eNalUnitType; |
---|
| 536 | |
---|
| 537 | switch (eNalUnitType) |
---|
| 538 | { |
---|
| 539 | case NAL_UNIT_SPS: |
---|
| 540 | { |
---|
| 541 | TComSPS cTempSPS; |
---|
| 542 | m_cEntropyDecoder.decodeSPS( &cTempSPS ); |
---|
| 543 | |
---|
| 544 | if( (m_iViewIdx == cTempSPS.getViewId()) && ( m_bIsDepth == cTempSPS.isDepth() ) ) |
---|
| 545 | { |
---|
| 546 | m_cSPS = cTempSPS; |
---|
| 547 | cComSPS = m_cSPS; |
---|
| 548 | } |
---|
| 549 | else |
---|
| 550 | { |
---|
| 551 | cComSPS = cTempSPS; |
---|
| 552 | return false; |
---|
| 553 | } |
---|
| 554 | |
---|
| 555 | // create ALF temporary buffer |
---|
| 556 | if ( !m_cAdaptiveLoopFilter.isCreated()) |
---|
| 557 | { |
---|
| 558 | m_cAdaptiveLoopFilter.create( m_cSPS.getWidth(), m_cSPS.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 559 | #if MTK_SAO |
---|
| 560 | m_cSAO.create( m_cSPS.getWidth(), m_cSPS.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 561 | #endif |
---|
| 562 | m_cLoopFilter. create( g_uiMaxCUDepth ); |
---|
| 563 | } |
---|
| 564 | m_uiValidPS |= 1; |
---|
| 565 | |
---|
| 566 | return false; |
---|
| 567 | } |
---|
| 568 | |
---|
| 569 | case NAL_UNIT_PPS: |
---|
| 570 | m_cEntropyDecoder.decodePPS( &m_cPPS ); |
---|
| 571 | assert( m_cPPS.getSPSId() == m_cSPS.getSPSId() ); |
---|
| 572 | m_uiValidPS |= 2; |
---|
| 573 | return false; |
---|
| 574 | |
---|
| 575 | case NAL_UNIT_SEI: |
---|
| 576 | m_SEIs = new SEImessages; |
---|
| 577 | m_cEntropyDecoder.decodeSEI(*m_SEIs); |
---|
| 578 | return false; |
---|
| 579 | |
---|
| 580 | case NAL_UNIT_CODED_SLICE: |
---|
| 581 | case NAL_UNIT_CODED_SLICE_IDR: |
---|
| 582 | case NAL_UNIT_CODED_SLICE_CDR: |
---|
| 583 | { |
---|
| 584 | // make sure we already received both parameter sets |
---|
| 585 | assert( 3 == m_uiValidPS ); |
---|
| 586 | if (m_bFirstSliceInPicture) |
---|
| 587 | { |
---|
| 588 | m_apcSlicePilot->initSlice(); |
---|
| 589 | m_uiSliceIdx = 0; |
---|
| 590 | m_uiLastSliceIdx = 0; |
---|
| 591 | } |
---|
| 592 | m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); |
---|
| 593 | |
---|
| 594 | // Read slice header |
---|
| 595 | m_apcSlicePilot->setSPS( &m_cSPS ); |
---|
| 596 | m_apcSlicePilot->setPPS( &m_cPPS ); |
---|
| 597 | m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); |
---|
| 598 | m_apcSlicePilot->setViewIdx( m_cSPS.getViewId() ); |
---|
[20] | 599 | #if SONY_COLPIC_AVAILABILITY |
---|
| 600 | m_apcSlicePilot->setViewOrderIdx( m_cSPS.getViewOrderIdx()); |
---|
| 601 | #endif |
---|
[2] | 602 | if (!m_bFirstSliceInPicture) |
---|
| 603 | { |
---|
| 604 | memcpy(m_apcSlicePilot, pcPic->getPicSym()->getSlice(m_uiSliceIdx-1), sizeof(TComSlice)); |
---|
| 605 | } |
---|
| 606 | |
---|
| 607 | #if DCM_DECODING_REFRESH |
---|
| 608 | m_apcSlicePilot->setNalUnitType (eNalUnitType); |
---|
| 609 | #endif |
---|
| 610 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot); |
---|
| 611 | |
---|
| 612 | // if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_uiPrevPOC && !m_bFirstSliceInSequence) |
---|
| 613 | // if (m_apcSlicePilot->isNextSlice() && ( m_apcSlicePilot->getPOC()!=m_uiPrevPOC || m_apcSlicePilot->getPPSId() != m_cPPS.getPPSId() ) && !m_bFirstSliceInSequence) |
---|
| 614 | if (m_apcSlicePilot->isNextSlice() && ( m_apcSlicePilot->getPOC()!=m_uiPrevPOC || m_apcSlicePilot->getPPSId() != m_cPPS.getPPSId() ) && !m_bFirstSliceInPicture) |
---|
| 615 | { |
---|
| 616 | m_uiPrevPOC = m_apcSlicePilot->getPOC(); |
---|
| 617 | return true; |
---|
| 618 | } |
---|
| 619 | if (m_apcSlicePilot->isNextSlice()) |
---|
| 620 | m_uiPrevPOC = m_apcSlicePilot->getPOC(); |
---|
| 621 | m_bFirstSliceInSequence = false; |
---|
| 622 | if (m_apcSlicePilot->isNextSlice()) |
---|
| 623 | { |
---|
| 624 | #if DCM_SKIP_DECODING_FRAMES |
---|
| 625 | // Skip pictures due to random access |
---|
| 626 | if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) |
---|
| 627 | { |
---|
| 628 | return false; |
---|
| 629 | } |
---|
| 630 | #endif |
---|
| 631 | } |
---|
| 632 | |
---|
| 633 | if (m_bFirstSliceInPicture) |
---|
| 634 | { |
---|
| 635 | // Buffer initialize for prediction. |
---|
| 636 | m_cPrediction.initTempBuff(); |
---|
| 637 | // Get a new picture buffer |
---|
| 638 | xGetNewPicBuffer (m_apcSlicePilot, pcPic); |
---|
| 639 | |
---|
| 640 | pcPic->setViewIdx( m_cSPS.getViewId() ); |
---|
| 641 | |
---|
[20] | 642 | #if SONY_COLPIC_AVAILABILITY |
---|
| 643 | pcPic->setViewOrderIdx( m_cSPS.getViewOrderIdx() ); |
---|
| 644 | #endif |
---|
| 645 | |
---|
[2] | 646 | /* transfer any SEI messages that have been received to the picture */ |
---|
| 647 | pcPic->setSEIs(m_SEIs); |
---|
| 648 | m_SEIs = NULL; |
---|
| 649 | |
---|
| 650 | // Recursive structure |
---|
| 651 | m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 652 | m_cCuDecoder.init ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction ); |
---|
| 653 | m_cTrQuant.init ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize()); |
---|
| 654 | |
---|
| 655 | m_cSliceDecoder.create( m_apcSlicePilot, m_apcSlicePilot->getSPS()->getWidth(), m_apcSlicePilot->getSPS()->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 656 | |
---|
[5] | 657 | #if DEPTH_MAP_GENERATION |
---|
[20] | 658 | UInt uiPdm = ( m_cSPS.getViewId() ? m_cSPS.getPredDepthMapGeneration() : getDecTop()->getSPSAccess()->getPdm() ); |
---|
| 659 | m_cDepthMapGenerator.create( true, m_apcSlicePilot->getSPS()->getWidth(), m_apcSlicePilot->getSPS()->getHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement, PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) ); |
---|
| 660 | TComDepthMapGenerator* pcDMG0 = getDecTop()->getDecTop0()->getDepthMapGenerator(); |
---|
| 661 | if( m_cSPS.getViewId() == 1 && ( pcDMG0->getSubSampExpX() != PDM_SUB_SAMP_EXP_X(uiPdm) || pcDMG0->getSubSampExpY() != PDM_SUB_SAMP_EXP_Y(uiPdm) ) ) |
---|
| 662 | { |
---|
| 663 | pcDMG0->create( true, m_apcSlicePilot->getSPS()->getWidth(), m_apcSlicePilot->getSPS()->getHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement, PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) ); |
---|
| 664 | } |
---|
[5] | 665 | #endif |
---|
| 666 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 667 | m_cResidualGenerator.create( true, m_apcSlicePilot->getSPS()->getWidth(), m_apcSlicePilot->getSPS()->getHeight(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement ); |
---|
[5] | 668 | #endif |
---|
[2] | 669 | } |
---|
| 670 | |
---|
| 671 | // Set picture slice pointer |
---|
| 672 | TComSlice* pcSlice = m_apcSlicePilot; |
---|
| 673 | Bool bNextSlice = pcSlice->isNextSlice(); |
---|
| 674 | if (m_bFirstSliceInPicture) |
---|
| 675 | { |
---|
| 676 | if(pcPic->getNumAllocatedSlice() != 1) |
---|
| 677 | { |
---|
| 678 | pcPic->clearSliceBuffer(); |
---|
| 679 | } |
---|
| 680 | } |
---|
| 681 | else |
---|
| 682 | { |
---|
| 683 | pcPic->allocateNewSlice(); |
---|
| 684 | } |
---|
| 685 | assert(pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
| 686 | m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx); |
---|
| 687 | pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx); |
---|
| 688 | |
---|
| 689 | if (bNextSlice) |
---|
| 690 | { |
---|
| 691 | #if DCM_DECODING_REFRESH |
---|
| 692 | // Do decoding refresh marking if any |
---|
| 693 | pcSlice->decodingRefreshMarking(m_uiPOCCDR, m_bRefreshPending, m_cListPic); |
---|
| 694 | #endif |
---|
| 695 | |
---|
| 696 | // Set reference list |
---|
| 697 | std::vector<TComPic*> apcSpatRefPics = getDecTop()->getSpatialRefPics( pcPic->getViewIdx(), pcSlice->getPOC(), m_cSPS.isDepth() ); |
---|
| 698 | TComPic * const pcTexturePic = m_cSPS.isDepth() ? getDecTop()->getPicFromView( pcPic->getViewIdx(), pcSlice->getPOC(), false ) : NULL; |
---|
| 699 | assert( ! m_cSPS.isDepth() || pcTexturePic != NULL ); |
---|
| 700 | pcSlice->setTexturePic( pcTexturePic ); |
---|
| 701 | pcSlice->setViewIdx( pcPic->getViewIdx() ); |
---|
[20] | 702 | #if SONY_COLPIC_AVAILABILITY |
---|
| 703 | pcSlice->setViewOrderIdx( pcPic->getViewOrderIdx() ); |
---|
| 704 | #endif |
---|
[2] | 705 | pcSlice->setRefPicListExplicitlyDecoderSided(m_cListPic, apcSpatRefPics) ;// temporary solution |
---|
| 706 | |
---|
| 707 | #if DCM_COMB_LIST |
---|
| 708 | if(!pcSlice->getRefPicListModificationFlagLC()) |
---|
| 709 | { |
---|
| 710 | pcSlice->generateCombinedList(); |
---|
| 711 | } |
---|
| 712 | #endif |
---|
| 713 | |
---|
| 714 | pcSlice->setNoBackPredFlag( false ); |
---|
| 715 | #if DCM_COMB_LIST |
---|
| 716 | if ( pcSlice->getSliceType() == B_SLICE && !pcSlice->getRefPicListCombinationFlag()) |
---|
| 717 | #else |
---|
| 718 | if ( pcSlice->getSliceType() == B_SLICE ) |
---|
| 719 | #endif |
---|
| 720 | { |
---|
| 721 | if ( pcSlice->getNumRefIdx(RefPicList( 0 ) ) == pcSlice->getNumRefIdx(RefPicList( 1 ) ) ) |
---|
| 722 | { |
---|
| 723 | pcSlice->setNoBackPredFlag( true ); |
---|
| 724 | int i; |
---|
| 725 | for ( i=0; i < pcSlice->getNumRefIdx(RefPicList( 1 ) ); i++ ) |
---|
| 726 | { |
---|
| 727 | if ( pcSlice->getRefPOC(RefPicList(1), i) != pcSlice->getRefPOC(RefPicList(0), i) ) |
---|
| 728 | { |
---|
| 729 | pcSlice->setNoBackPredFlag( false ); |
---|
| 730 | break; |
---|
| 731 | } |
---|
| 732 | } |
---|
| 733 | } |
---|
| 734 | } |
---|
| 735 | } |
---|
| 736 | |
---|
| 737 | pcPic->setCurrSliceIdx(m_uiSliceIdx); |
---|
| 738 | |
---|
[5] | 739 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
| 740 | if ( m_cSPS.getUseDMM() && g_aacWedgeLists.empty() && m_bIsDepth ) |
---|
[2] | 741 | { |
---|
| 742 | initWedgeLists(); |
---|
| 743 | } |
---|
| 744 | #endif |
---|
| 745 | |
---|
| 746 | // Decode a picture |
---|
| 747 | m_cGopDecoder.decompressGop ( bEos, pcBitstream, pcPic, false ); |
---|
| 748 | |
---|
| 749 | if( m_pcCamParsCollector ) |
---|
| 750 | { |
---|
| 751 | m_pcCamParsCollector->setSlice( pcSlice ); |
---|
| 752 | } |
---|
| 753 | |
---|
| 754 | m_bFirstSliceInPicture = false; |
---|
| 755 | m_uiSliceIdx++; |
---|
| 756 | } |
---|
| 757 | break; |
---|
| 758 | default: |
---|
| 759 | assert (1); |
---|
| 760 | } |
---|
| 761 | |
---|
| 762 | return false; |
---|
| 763 | } |
---|
| 764 | |
---|
| 765 | #if DCM_SKIP_DECODING_FRAMES |
---|
| 766 | /** Function for checking if picture should be skipped because of random access |
---|
| 767 | * \param iSkipFrame skip frame counter |
---|
| 768 | * \param iPOCLastDisplay POC of last picture displayed |
---|
| 769 | * \returns true if the picture shold be skipped in the random access. |
---|
| 770 | * This function checks the skipping of pictures in the case of -s option random access. |
---|
| 771 | * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped. |
---|
| 772 | * It also checks the type of Nal unit type at the random access point. |
---|
| 773 | * If the random access point is CDR, pictures with POC equal to or greater than the CDR POC are decoded. |
---|
| 774 | * If the random access point is IDR all pictures after the random access point are decoded. |
---|
| 775 | * If the random access point is not IDR or CDR, a warning is issues, and decoding of pictures with POC |
---|
| 776 | * equal to or greater than the random access point POC is attempted. For non IDR/CDR random |
---|
| 777 | * access point there is no guarantee that the decoder will not crash. |
---|
| 778 | */ |
---|
| 779 | Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
| 780 | { |
---|
| 781 | if (iSkipFrame) |
---|
| 782 | { |
---|
| 783 | iSkipFrame--; // decrement the counter |
---|
| 784 | return true; |
---|
| 785 | } |
---|
| 786 | else if (m_uiPOCRA == MAX_UINT) // start of random access point, m_uiPOCRA has not been set yet. |
---|
| 787 | { |
---|
| 788 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CDR) |
---|
| 789 | { |
---|
| 790 | m_uiPOCRA = m_apcSlicePilot->getPOC(); // set the POC random access since we need to skip the reordered pictures in CDR. |
---|
| 791 | } |
---|
| 792 | else if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR) |
---|
| 793 | { |
---|
| 794 | m_uiPOCRA = 0; // no need to skip the reordered pictures in IDR, they are decodable. |
---|
| 795 | } |
---|
| 796 | else |
---|
| 797 | { |
---|
| 798 | printf("\nUnsafe random access point. Decoder may crash."); |
---|
| 799 | m_uiPOCRA = m_apcSlicePilot->getPOC(); // set the POC random access skip the reordered pictures and try to decode if possible. This increases the chances of avoiding a decoder crash. |
---|
| 800 | //m_uiPOCRA = 0; |
---|
| 801 | } |
---|
| 802 | } |
---|
| 803 | else if (m_apcSlicePilot->getPOC() < m_uiPOCRA) // skip the reordered pictures if necessary |
---|
| 804 | { |
---|
| 805 | iPOCLastDisplay++; |
---|
| 806 | return true; |
---|
| 807 | } |
---|
| 808 | // if we reach here, then the picture is not skipped. |
---|
| 809 | return false; |
---|
| 810 | } |
---|
| 811 | #endif |
---|
| 812 | |
---|