[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 | * |
---|
[872] | 6 | * Copyright (c) 2010-2014, 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 | */ |
---|
| 33 | |
---|
[2] | 34 | /** \file TDecTop.cpp |
---|
| 35 | \brief decoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
[56] | 38 | #include "NALread.h" |
---|
[2] | 39 | #include "TDecTop.h" |
---|
| 40 | |
---|
[608] | 41 | #if H_MV |
---|
| 42 | ParameterSetManagerDecoder TDecTop::m_parameterSetManagerDecoder; |
---|
| 43 | #endif |
---|
[56] | 44 | //! \ingroup TLibDecoder |
---|
| 45 | //! \{ |
---|
[2] | 46 | |
---|
[608] | 47 | #if H_3D |
---|
[2] | 48 | CamParsCollector::CamParsCollector() |
---|
| 49 | : m_bInitialized( false ) |
---|
| 50 | { |
---|
[608] | 51 | m_aaiCodedOffset = new Int* [ MAX_NUM_LAYERS ]; |
---|
| 52 | m_aaiCodedScale = new Int* [ MAX_NUM_LAYERS ]; |
---|
| 53 | for( UInt uiId = 0; uiId < MAX_NUM_LAYERS; uiId++ ) |
---|
[2] | 54 | { |
---|
[608] | 55 | m_aaiCodedOffset [ uiId ] = new Int [ MAX_NUM_LAYERS ]; |
---|
| 56 | m_aaiCodedScale [ uiId ] = new Int [ MAX_NUM_LAYERS ]; |
---|
[2] | 57 | } |
---|
[296] | 58 | |
---|
[608] | 59 | xCreateLUTs( (UInt)MAX_NUM_LAYERS, (UInt)MAX_NUM_LAYERS, m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT ); |
---|
[296] | 60 | m_iLog2Precision = LOG2_DISP_PREC_LUT; |
---|
| 61 | m_uiBitDepthForLUT = 8; // fixed |
---|
[872] | 62 | m_receivedIdc = NULL; |
---|
| 63 | m_vps = NULL; |
---|
[2] | 64 | } |
---|
| 65 | |
---|
| 66 | CamParsCollector::~CamParsCollector() |
---|
| 67 | { |
---|
[608] | 68 | for( UInt uiId = 0; uiId < MAX_NUM_LAYERS; uiId++ ) |
---|
[2] | 69 | { |
---|
| 70 | delete [] m_aaiCodedOffset [ uiId ]; |
---|
| 71 | delete [] m_aaiCodedScale [ uiId ]; |
---|
| 72 | } |
---|
| 73 | delete [] m_aaiCodedOffset; |
---|
| 74 | delete [] m_aaiCodedScale; |
---|
[296] | 75 | |
---|
[608] | 76 | xDeleteArray( m_adBaseViewShiftLUT, MAX_NUM_LAYERS, MAX_NUM_LAYERS, 2 ); |
---|
| 77 | xDeleteArray( m_aiBaseViewShiftLUT, MAX_NUM_LAYERS, MAX_NUM_LAYERS, 2 ); |
---|
[872] | 78 | xDeleteArray( m_receivedIdc, m_uiMaxViewIndex + 1 ); |
---|
[2] | 79 | } |
---|
| 80 | |
---|
[872] | 81 | |
---|
[2] | 82 | Void |
---|
[872] | 83 | CamParsCollector::init( FILE* pCodedScaleOffsetFile, TComVPS* vps) |
---|
| 84 | { |
---|
| 85 | assert( !isInitialized() ); // Only one initialization currently supported |
---|
| 86 | m_bInitialized = true; |
---|
| 87 | m_vps = vps; |
---|
| 88 | m_bCamParsVaryOverTime = false; |
---|
| 89 | m_pCodedScaleOffsetFile = pCodedScaleOffsetFile; |
---|
| 90 | m_lastPoc = -1; |
---|
| 91 | m_firstReceivedPoc = -2; |
---|
| 92 | |
---|
| 93 | m_uiMaxViewIndex = -1; |
---|
| 94 | for (Int i = 0; i <= vps->getMaxLayersMinus1(); i++) |
---|
| 95 | { |
---|
| 96 | Int curViewIdx = m_vps->getViewIndex( m_vps->getLayerIdInNuh( i )); |
---|
| 97 | m_bCamParsVaryOverTime = m_bCamParsVaryOverTime || vps->hasCamParInSliceHeader( curViewIdx ); |
---|
| 98 | m_uiMaxViewIndex = std::max( m_uiMaxViewIndex, curViewIdx ) ; |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | assert( m_receivedIdc == NULL ); |
---|
| 102 | m_receivedIdc = new Int*[ m_uiMaxViewIndex + 1]; |
---|
| 103 | for (Int i = 0; i <= m_uiMaxViewIndex; i++) |
---|
| 104 | { |
---|
| 105 | m_receivedIdc[i] = new Int[ m_uiMaxViewIndex + 1 ]; |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | xResetReceivedIdc( true ); |
---|
| 109 | |
---|
| 110 | for (Int viewIndex = 0; viewIndex <= m_uiMaxViewIndex ; viewIndex++ ) |
---|
| 111 | { |
---|
| 112 | if (m_vps->getCamParPresent( viewIndex ) ) |
---|
| 113 | { |
---|
| 114 | if( !m_vps->hasCamParInSliceHeader( viewIndex ) ) |
---|
| 115 | { |
---|
| 116 | for (Int baseViewIndex = 0; baseViewIndex < viewIndex ; baseViewIndex++ ) |
---|
| 117 | { |
---|
| 118 | m_receivedIdc [ baseViewIndex ][ viewIndex ] = -1; |
---|
| 119 | m_aaiCodedScale [ baseViewIndex ][ viewIndex ] = m_vps->getCodedScale (viewIndex) [ baseViewIndex ]; |
---|
| 120 | m_aaiCodedOffset[ baseViewIndex ][ viewIndex ] = m_vps->getCodedOffset (viewIndex) [ baseViewIndex ]; |
---|
| 121 | |
---|
| 122 | m_receivedIdc [ viewIndex ][ baseViewIndex ] = -1; |
---|
| 123 | m_aaiCodedScale [ viewIndex ][ baseViewIndex ] = m_vps->getInvCodedScale (viewIndex) [ baseViewIndex ]; |
---|
| 124 | m_aaiCodedOffset[ viewIndex ][ baseViewIndex ] = m_vps->getInvCodedOffset(viewIndex) [ baseViewIndex ]; |
---|
| 125 | xInitLUTs( baseViewIndex, viewIndex, m_aaiCodedScale[ baseViewIndex ][ viewIndex ], m_aaiCodedOffset[ baseViewIndex ][ viewIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT ); |
---|
| 126 | xInitLUTs( viewIndex, baseViewIndex, m_aaiCodedScale[ viewIndex ][ baseViewIndex ], m_aaiCodedOffset[ viewIndex ][ baseViewIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT ); |
---|
| 127 | } |
---|
| 128 | } |
---|
| 129 | } |
---|
| 130 | } |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | Void |
---|
| 134 | CamParsCollector::xResetReceivedIdc( Bool overWriteFlag ) |
---|
| 135 | { |
---|
| 136 | for (Int i = 0; i <= m_uiMaxViewIndex; i++) |
---|
| 137 | { |
---|
| 138 | for (Int j = 0; j <= m_uiMaxViewIndex; j++) |
---|
| 139 | { |
---|
| 140 | if ( overWriteFlag || ( m_receivedIdc[i][j] != -1 ) ) |
---|
| 141 | { |
---|
| 142 | m_receivedIdc[i][j] = 0; |
---|
| 143 | } |
---|
| 144 | } |
---|
| 145 | } |
---|
| 146 | } |
---|
[2] | 147 | |
---|
[872] | 148 | |
---|
[2] | 149 | Void |
---|
[296] | 150 | CamParsCollector::xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT) |
---|
| 151 | { |
---|
| 152 | |
---|
[608] | 153 | uiNumberSourceViews = std::max( (UInt) 1, uiNumberSourceViews ); |
---|
| 154 | uiNumberTargetViews = std::max( (UInt) 1, uiNumberTargetViews ); |
---|
[296] | 155 | |
---|
| 156 | radLUT = new Double***[ uiNumberSourceViews ]; |
---|
| 157 | raiLUT = new Int ***[ uiNumberSourceViews ]; |
---|
| 158 | |
---|
| 159 | for( UInt uiSourceView = 0; uiSourceView < uiNumberSourceViews; uiSourceView++ ) |
---|
| 160 | { |
---|
| 161 | radLUT [ uiSourceView ] = new Double**[ uiNumberTargetViews ]; |
---|
| 162 | raiLUT [ uiSourceView ] = new Int **[ uiNumberTargetViews ]; |
---|
| 163 | |
---|
| 164 | for( UInt uiTargetView = 0; uiTargetView < uiNumberTargetViews; uiTargetView++ ) |
---|
| 165 | { |
---|
| 166 | radLUT [ uiSourceView ][ uiTargetView ] = new Double*[ 2 ]; |
---|
| 167 | radLUT [ uiSourceView ][ uiTargetView ][ 0 ] = new Double [ 257 ]; |
---|
| 168 | radLUT [ uiSourceView ][ uiTargetView ][ 1 ] = new Double [ 257 ]; |
---|
| 169 | |
---|
| 170 | raiLUT [ uiSourceView ][ uiTargetView ] = new Int* [ 2 ]; |
---|
| 171 | raiLUT [ uiSourceView ][ uiTargetView ][ 0 ] = new Int [ 257 ]; |
---|
| 172 | raiLUT [ uiSourceView ][ uiTargetView ][ 1 ] = new Int [ 257 ]; |
---|
| 173 | } |
---|
| 174 | } |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | Void |
---|
| 178 | CamParsCollector::xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT) |
---|
| 179 | { |
---|
[872] | 180 | Int iLog2DivLuma = m_uiBitDepthForLUT + m_vps->getCamParPrecision() + 1 - m_iLog2Precision; AOF( iLog2DivLuma > 0 ); |
---|
[296] | 181 | Int iLog2DivChroma = iLog2DivLuma + 1; |
---|
| 182 | |
---|
| 183 | iOffset <<= m_uiBitDepthForLUT; |
---|
| 184 | |
---|
| 185 | Double dScale = (Double) iScale / (( Double ) ( 1 << iLog2DivLuma )); |
---|
| 186 | Double dOffset = (Double) iOffset / (( Double ) ( 1 << iLog2DivLuma )); |
---|
| 187 | |
---|
| 188 | // offsets including rounding offsets |
---|
| 189 | Int64 iOffsetLuma = iOffset + ( ( 1 << iLog2DivLuma ) >> 1 ); |
---|
| 190 | Int64 iOffsetChroma = iOffset + ( ( 1 << iLog2DivChroma ) >> 1 ); |
---|
| 191 | |
---|
| 192 | |
---|
| 193 | for( UInt uiDepthValue = 0; uiDepthValue < 256; uiDepthValue++ ) |
---|
| 194 | { |
---|
| 195 | |
---|
| 196 | // real-valued look-up tables |
---|
| 197 | Double dShiftLuma = ( (Double)uiDepthValue * dScale + dOffset ) * Double( 1 << m_iLog2Precision ); |
---|
| 198 | Double dShiftChroma = dShiftLuma / 2; |
---|
| 199 | radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = dShiftLuma; |
---|
| 200 | radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = dShiftChroma; |
---|
| 201 | |
---|
| 202 | // integer-valued look-up tables |
---|
| 203 | Int64 iTempScale = (Int64)uiDepthValue * iScale; |
---|
| 204 | Int64 iShiftLuma = ( iTempScale + iOffsetLuma ) >> iLog2DivLuma; |
---|
| 205 | Int64 iShiftChroma = ( iTempScale + iOffsetChroma ) >> iLog2DivChroma; |
---|
| 206 | raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = (Int)iShiftLuma; |
---|
| 207 | raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = (Int)iShiftChroma; |
---|
| 208 | } |
---|
| 209 | |
---|
| 210 | radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ]; |
---|
| 211 | radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ]; |
---|
| 212 | raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ]; |
---|
| 213 | raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ]; |
---|
| 214 | } |
---|
| 215 | |
---|
| 216 | Void |
---|
[2] | 217 | CamParsCollector::uninit() |
---|
| 218 | { |
---|
| 219 | m_bInitialized = false; |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | Void |
---|
| 223 | CamParsCollector::setSlice( TComSlice* pcSlice ) |
---|
| 224 | { |
---|
| 225 | if( pcSlice == 0 ) |
---|
| 226 | { |
---|
[872] | 227 | xOutput( m_lastPoc ); |
---|
| 228 | return; |
---|
| 229 | } |
---|
| 230 | |
---|
| 231 | if ( pcSlice->getIsDepth()) |
---|
| 232 | { |
---|
| 233 | return; |
---|
| 234 | } |
---|
| 235 | |
---|
| 236 | Int curPoc = pcSlice->getPOC(); |
---|
| 237 | if( m_firstReceivedPoc == -2 ) |
---|
| 238 | { |
---|
| 239 | m_firstReceivedPoc = curPoc; |
---|
| 240 | } |
---|
| 241 | |
---|
| 242 | Bool newPocFlag = ( m_lastPoc != curPoc ); |
---|
| 243 | |
---|
| 244 | if ( newPocFlag ) |
---|
| 245 | { |
---|
| 246 | if( m_lastPoc != -1 ) |
---|
| 247 | { |
---|
| 248 | xOutput( m_lastPoc ); |
---|
| 249 | } |
---|
| 250 | |
---|
| 251 | xResetReceivedIdc( false ); |
---|
| 252 | m_lastPoc = pcSlice->getPOC(); |
---|
| 253 | } |
---|
| 254 | |
---|
| 255 | UInt uiViewIndex = pcSlice->getViewIndex(); |
---|
| 256 | if( m_vps->getCamParPresent( uiViewIndex ) ) |
---|
| 257 | { |
---|
| 258 | if( m_vps->hasCamParInSliceHeader( uiViewIndex ) ) // check consistency of slice parameters here |
---|
| 259 | { |
---|
| 260 | for( UInt uiBaseViewIndex = 0; uiBaseViewIndex < uiViewIndex; uiBaseViewIndex++ ) |
---|
| 261 | { |
---|
| 262 | if ( m_receivedIdc[ uiViewIndex ][ uiBaseViewIndex ] != 0 ) |
---|
| 263 | { |
---|
| 264 | AOF( m_aaiCodedScale [ uiViewIndex ][ uiBaseViewIndex ] == pcSlice->getInvCodedScale () [ uiBaseViewIndex ] ); |
---|
| 265 | AOF( m_aaiCodedOffset[ uiViewIndex ][ uiBaseViewIndex ] == pcSlice->getInvCodedOffset() [ uiBaseViewIndex ] ); |
---|
| 266 | } |
---|
| 267 | else |
---|
| 268 | { |
---|
| 269 | m_receivedIdc [ uiViewIndex ][ uiBaseViewIndex ] = 1; |
---|
| 270 | m_aaiCodedScale [ uiViewIndex ][ uiBaseViewIndex ] = pcSlice->getInvCodedScale () [ uiBaseViewIndex ]; |
---|
| 271 | m_aaiCodedOffset[ uiViewIndex ][ uiBaseViewIndex ] = pcSlice->getInvCodedOffset() [ uiBaseViewIndex ]; |
---|
| 272 | xInitLUTs( uiViewIndex, uiBaseViewIndex, m_aaiCodedScale[ uiViewIndex ][ uiBaseViewIndex ], m_aaiCodedOffset[ uiViewIndex ][ uiBaseViewIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT); |
---|
| 273 | } |
---|
| 274 | if ( m_receivedIdc[ uiBaseViewIndex ][ uiViewIndex ] != 0 ) |
---|
| 275 | { |
---|
| 276 | AOF( m_aaiCodedScale [ uiBaseViewIndex ][ uiViewIndex ] == pcSlice->getCodedScale () [ uiBaseViewIndex ] ); |
---|
| 277 | AOF( m_aaiCodedOffset[ uiBaseViewIndex ][ uiViewIndex ] == pcSlice->getCodedOffset () [ uiBaseViewIndex ] ); |
---|
| 278 | } |
---|
| 279 | else |
---|
| 280 | { |
---|
| 281 | m_receivedIdc [ uiBaseViewIndex ][ uiViewIndex ] = 1; |
---|
| 282 | m_aaiCodedScale [ uiBaseViewIndex ][ uiViewIndex ] = pcSlice->getCodedScale () [ uiBaseViewIndex ]; |
---|
| 283 | m_aaiCodedOffset[ uiBaseViewIndex ][ uiViewIndex ] = pcSlice->getCodedOffset () [ uiBaseViewIndex ]; |
---|
| 284 | xInitLUTs( uiBaseViewIndex, uiViewIndex, m_aaiCodedScale[ uiBaseViewIndex ][ uiViewIndex ], m_aaiCodedOffset[ uiBaseViewIndex ][ uiViewIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT); |
---|
| 285 | } |
---|
| 286 | } |
---|
| 287 | } |
---|
| 288 | } |
---|
| 289 | } |
---|
| 290 | |
---|
| 291 | |
---|
[773] | 292 | #if H_3D_IV_MERGE |
---|
[724] | 293 | Void |
---|
| 294 | CamParsCollector::copyCamParamForSlice( TComSlice* pcSlice ) |
---|
| 295 | { |
---|
| 296 | if( m_bCamParsVaryOverTime ) |
---|
| 297 | { |
---|
| 298 | pcSlice->setCamparaSlice( m_aaiCodedScale, m_aaiCodedOffset ); |
---|
| 299 | } |
---|
| 300 | } |
---|
| 301 | #endif |
---|
| 302 | |
---|
[2] | 303 | |
---|
| 304 | Void |
---|
| 305 | CamParsCollector::xOutput( Int iPOC ) |
---|
| 306 | { |
---|
| 307 | if( m_pCodedScaleOffsetFile ) |
---|
| 308 | { |
---|
[872] | 309 | if( iPOC == m_firstReceivedPoc ) |
---|
[2] | 310 | { |
---|
[608] | 311 | fprintf( m_pCodedScaleOffsetFile, "# ViewIndex ViewId\n" ); |
---|
[2] | 312 | fprintf( m_pCodedScaleOffsetFile, "#----------- ------------\n" ); |
---|
[608] | 313 | for( UInt uiViewIndex = 0; uiViewIndex <= m_uiMaxViewIndex; uiViewIndex++ ) |
---|
[2] | 314 | { |
---|
[872] | 315 | fprintf( m_pCodedScaleOffsetFile, "%12d %12d\n", uiViewIndex, m_vps->getViewIdVal( uiViewIndex ) ); |
---|
[2] | 316 | } |
---|
| 317 | fprintf( m_pCodedScaleOffsetFile, "\n\n"); |
---|
| 318 | fprintf( m_pCodedScaleOffsetFile, "# StartFrame EndFrame TargetView BaseView CodedScale CodedOffset Precision\n" ); |
---|
| 319 | fprintf( m_pCodedScaleOffsetFile, "#----------- ------------ ------------ ------------ ------------ ------------ ------------\n" ); |
---|
| 320 | } |
---|
[872] | 321 | if( iPOC == m_firstReceivedPoc || m_bCamParsVaryOverTime ) |
---|
[2] | 322 | { |
---|
| 323 | Int iS = iPOC; |
---|
| 324 | Int iE = ( m_bCamParsVaryOverTime ? iPOC : ~( 1 << 31 ) ); |
---|
[608] | 325 | for( UInt uiViewIndex = 0; uiViewIndex <= m_uiMaxViewIndex; uiViewIndex++ ) |
---|
[2] | 326 | { |
---|
[608] | 327 | for( UInt uiBaseIndex = 0; uiBaseIndex <= m_uiMaxViewIndex; uiBaseIndex++ ) |
---|
[2] | 328 | { |
---|
[608] | 329 | if( uiViewIndex != uiBaseIndex ) |
---|
[2] | 330 | { |
---|
[872] | 331 | if ( m_receivedIdc[uiBaseIndex][uiViewIndex] != 0 ) |
---|
| 332 | { |
---|
| 333 | fprintf( m_pCodedScaleOffsetFile, "%12d %12d %12d %12d %12d %12d %12d\n", |
---|
| 334 | iS, iE, uiViewIndex, uiBaseIndex, m_aaiCodedScale[ uiBaseIndex ][ uiViewIndex ], m_aaiCodedOffset[ uiBaseIndex ][ uiViewIndex ], m_vps->getCamParPrecision() ); |
---|
| 335 | } |
---|
[2] | 336 | } |
---|
| 337 | } |
---|
| 338 | } |
---|
| 339 | } |
---|
| 340 | } |
---|
| 341 | } |
---|
[608] | 342 | #endif |
---|
[2] | 343 | TDecTop::TDecTop() |
---|
| 344 | { |
---|
[56] | 345 | m_pcPic = 0; |
---|
[2] | 346 | m_iMaxRefPicNum = 0; |
---|
| 347 | #if ENC_DEC_TRACE |
---|
[608] | 348 | #if H_MV |
---|
| 349 | if ( g_hTrace == NULL ) |
---|
| 350 | { |
---|
| 351 | #endif |
---|
| 352 | g_hTrace = fopen( "TraceDec.txt", "wb" ); |
---|
[2] | 353 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
| 354 | g_nSymbolCounter = 0; |
---|
[608] | 355 | #if H_MV |
---|
| 356 | } |
---|
[2] | 357 | #endif |
---|
[608] | 358 | #endif |
---|
[655] | 359 | m_associatedIRAPType = NAL_UNIT_INVALID; |
---|
[56] | 360 | m_pocCRA = 0; |
---|
[608] | 361 | m_pocRandomAccess = MAX_INT; |
---|
[56] | 362 | m_prevPOC = MAX_INT; |
---|
[2] | 363 | m_bFirstSliceInPicture = true; |
---|
| 364 | m_bFirstSliceInSequence = true; |
---|
[655] | 365 | m_prevSliceSkipped = false; |
---|
| 366 | m_skippedPOC = 0; |
---|
[608] | 367 | #if H_MV |
---|
| 368 | m_layerId = 0; |
---|
| 369 | m_viewId = 0; |
---|
| 370 | #if H_3D |
---|
| 371 | m_viewIndex = 0; |
---|
| 372 | m_isDepth = false; |
---|
[57] | 373 | m_pcCamParsCollector = 0; |
---|
[210] | 374 | #endif |
---|
[608] | 375 | #endif |
---|
[2] | 376 | } |
---|
| 377 | |
---|
| 378 | TDecTop::~TDecTop() |
---|
| 379 | { |
---|
| 380 | #if ENC_DEC_TRACE |
---|
[608] | 381 | fclose( g_hTrace ); |
---|
[2] | 382 | #endif |
---|
| 383 | } |
---|
| 384 | |
---|
| 385 | Void TDecTop::create() |
---|
| 386 | { |
---|
| 387 | m_cGopDecoder.create(); |
---|
| 388 | m_apcSlicePilot = new TComSlice; |
---|
[608] | 389 | m_uiSliceIdx = 0; |
---|
[2] | 390 | } |
---|
| 391 | |
---|
| 392 | Void TDecTop::destroy() |
---|
| 393 | { |
---|
| 394 | m_cGopDecoder.destroy(); |
---|
[56] | 395 | |
---|
[2] | 396 | delete m_apcSlicePilot; |
---|
| 397 | m_apcSlicePilot = NULL; |
---|
[56] | 398 | |
---|
[2] | 399 | m_cSliceDecoder.destroy(); |
---|
| 400 | } |
---|
| 401 | |
---|
[608] | 402 | Void TDecTop::init() |
---|
[2] | 403 | { |
---|
| 404 | // initialize ROM |
---|
[608] | 405 | #if !H_MV |
---|
[56] | 406 | initROM(); |
---|
[5] | 407 | #endif |
---|
[608] | 408 | m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO ); |
---|
[2] | 409 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder ); |
---|
| 410 | m_cEntropyDecoder.init(&m_cPrediction); |
---|
| 411 | } |
---|
| 412 | |
---|
| 413 | Void TDecTop::deletePicBuffer ( ) |
---|
| 414 | { |
---|
| 415 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 416 | Int iSize = Int( m_cListPic.size() ); |
---|
[56] | 417 | |
---|
[2] | 418 | for (Int i = 0; i < iSize; i++ ) |
---|
| 419 | { |
---|
[608] | 420 | TComPic* pcPic = *(iterPic++); |
---|
| 421 | #if H_MV |
---|
| 422 | if( pcPic ) |
---|
[56] | 423 | { |
---|
[608] | 424 | #endif |
---|
| 425 | pcPic->destroy(); |
---|
[56] | 426 | |
---|
[608] | 427 | delete pcPic; |
---|
| 428 | pcPic = NULL; |
---|
| 429 | #if H_MV |
---|
[56] | 430 | } |
---|
[608] | 431 | #endif |
---|
[2] | 432 | } |
---|
[56] | 433 | |
---|
[2] | 434 | m_cSAO.destroy(); |
---|
[56] | 435 | |
---|
[2] | 436 | m_cLoopFilter. destroy(); |
---|
[56] | 437 | |
---|
[608] | 438 | #if !H_MV |
---|
[2] | 439 | // destroy ROM |
---|
[608] | 440 | destroyROM(); |
---|
| 441 | #endif |
---|
[2] | 442 | } |
---|
| 443 | |
---|
[608] | 444 | Void TDecTop::xGetNewPicBuffer ( TComSlice* pcSlice, TComPic*& rpcPic ) |
---|
[56] | 445 | { |
---|
[608] | 446 | Int numReorderPics[MAX_TLAYER]; |
---|
| 447 | Window &conformanceWindow = pcSlice->getSPS()->getConformanceWindow(); |
---|
| 448 | Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
[56] | 449 | |
---|
[622] | 450 | #if H_MV |
---|
| 451 | assert( conformanceWindow .getScaledFlag() ); |
---|
| 452 | assert( defaultDisplayWindow.getScaledFlag() ); |
---|
| 453 | #endif |
---|
[608] | 454 | for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) |
---|
[56] | 455 | { |
---|
[884] | 456 | #if H_MV |
---|
[872] | 457 | numReorderPics[temporalLayer] = ( getLayerId() == 0 ) ? pcSlice->getSPS()->getNumReorderPics(temporalLayer) : pcSlice->getVPS()->getNumReorderPics(temporalLayer); |
---|
| 458 | #else |
---|
[608] | 459 | numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer); |
---|
[872] | 460 | #endif |
---|
[56] | 461 | } |
---|
[884] | 462 | #if H_MV |
---|
[872] | 463 | if ( getLayerId() == 0 ) |
---|
| 464 | { |
---|
| 465 | m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer()); |
---|
| 466 | } |
---|
| 467 | else |
---|
| 468 | { |
---|
| 469 | m_iMaxRefPicNum = pcSlice->getVPS()->getMaxDecPicBuffering(pcSlice->getTLayer()); |
---|
| 470 | #if H_MV_HLS7_GEN |
---|
| 471 | TComVPS* vps = pcSlice->getVPS(); |
---|
| 472 | TComDpbSize* dpbSize = vps->getDpbSize(); |
---|
| 473 | Int lsIdx = vps->getLayerSetIdxForOutputLayerSet( getTargetOutputLayerSetIdx()); // Is this correct, seems to be missing in spec? |
---|
| 474 | Int layerIdx = vps->getIdxInLayerSet ( lsIdx, getLayerId() ); |
---|
| 475 | Int subDpbIdx = dpbSize->getSubDpbAssigned( lsIdx, layerIdx ); |
---|
| 476 | m_iMaxRefPicNum = dpbSize->getMaxVpsDecPicBufferingMinus1(getTargetOutputLayerSetIdx(), subDpbIdx , vps->getSubLayersVpsMaxMinus1( vps->getLayerIdInVps( getLayerId() ) ) + 1 ) + 1 ; |
---|
| 477 | #endif |
---|
| 478 | } |
---|
| 479 | #else |
---|
[608] | 480 | m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer()); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
[872] | 481 | #endif |
---|
[2] | 482 | if (m_cListPic.size() < (UInt)m_iMaxRefPicNum) |
---|
| 483 | { |
---|
[56] | 484 | rpcPic = new TComPic(); |
---|
| 485 | |
---|
[608] | 486 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 487 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
[2] | 488 | m_cListPic.pushBack( rpcPic ); |
---|
[56] | 489 | |
---|
[2] | 490 | return; |
---|
| 491 | } |
---|
[56] | 492 | |
---|
[2] | 493 | Bool bBufferIsAvailable = false; |
---|
| 494 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 495 | while (iterPic != m_cListPic.end()) |
---|
| 496 | { |
---|
| 497 | rpcPic = *(iterPic++); |
---|
[56] | 498 | if ( rpcPic->getReconMark() == false && rpcPic->getOutputMark() == false) |
---|
[2] | 499 | { |
---|
[56] | 500 | rpcPic->setOutputMark(false); |
---|
[2] | 501 | bBufferIsAvailable = true; |
---|
| 502 | break; |
---|
| 503 | } |
---|
[56] | 504 | |
---|
| 505 | if ( rpcPic->getSlice( 0 )->isReferenced() == false && rpcPic->getOutputMark() == false) |
---|
| 506 | { |
---|
| 507 | rpcPic->setOutputMark(false); |
---|
| 508 | rpcPic->setReconMark( false ); |
---|
| 509 | rpcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
| 510 | bBufferIsAvailable = true; |
---|
| 511 | break; |
---|
| 512 | } |
---|
[2] | 513 | } |
---|
[56] | 514 | |
---|
[2] | 515 | if ( !bBufferIsAvailable ) |
---|
| 516 | { |
---|
[56] | 517 | //There is no room for this picture, either because of faulty encoder or dropped NAL. Extend the buffer. |
---|
| 518 | m_iMaxRefPicNum++; |
---|
| 519 | rpcPic = new TComPic(); |
---|
| 520 | m_cListPic.pushBack( rpcPic ); |
---|
[2] | 521 | } |
---|
[608] | 522 | rpcPic->destroy(); |
---|
| 523 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
| 524 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
[2] | 525 | } |
---|
| 526 | |
---|
[608] | 527 | #if H_MV |
---|
| 528 | Void TDecTop::endPicDecoding(Int& poc, TComList<TComPic*>*& rpcListPic, std::vector<Int>& targetDecLayerIdSet ) |
---|
| 529 | #else |
---|
| 530 | Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic) |
---|
| 531 | #endif |
---|
[56] | 532 | { |
---|
| 533 | if (!m_pcPic) |
---|
| 534 | { |
---|
| 535 | /* nothing to deblock */ |
---|
| 536 | return; |
---|
| 537 | } |
---|
| 538 | |
---|
| 539 | TComPic*& pcPic = m_pcPic; |
---|
[2] | 540 | |
---|
[608] | 541 | // Execute Deblock + Cleanup |
---|
[56] | 542 | |
---|
[608] | 543 | m_cGopDecoder.filterPicture(pcPic); |
---|
[56] | 544 | |
---|
| 545 | TComSlice::sortPicList( m_cListPic ); // sorting for application output |
---|
[608] | 546 | poc = pcPic->getSlice(m_uiSliceIdx-1)->getPOC(); |
---|
[56] | 547 | rpcListPic = &m_cListPic; |
---|
| 548 | m_cCuDecoder.destroy(); |
---|
[608] | 549 | #if H_MV |
---|
[622] | 550 | TComSlice::markIvRefPicsAsShortTerm( m_refPicSetInterLayer0, m_refPicSetInterLayer1 ); |
---|
[608] | 551 | TComSlice::markCurrPic( pcPic ); |
---|
| 552 | TComSlice::markIvRefPicsAsUnused ( m_ivPicLists, targetDecLayerIdSet, m_parameterSetManagerDecoder.getActiveVPS(), m_layerId, poc ); |
---|
| 553 | #endif |
---|
[56] | 554 | m_bFirstSliceInPicture = true; |
---|
| 555 | |
---|
| 556 | return; |
---|
| 557 | } |
---|
| 558 | |
---|
| 559 | Void TDecTop::xCreateLostPicture(Int iLostPoc) |
---|
[2] | 560 | { |
---|
[56] | 561 | printf("\ninserting lost poc : %d\n",iLostPoc); |
---|
| 562 | TComSlice cFillSlice; |
---|
| 563 | cFillSlice.setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
---|
| 564 | cFillSlice.setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
---|
| 565 | cFillSlice.initSlice(); |
---|
| 566 | TComPic *cFillPic; |
---|
| 567 | xGetNewPicBuffer(&cFillSlice,cFillPic); |
---|
| 568 | cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
---|
| 569 | cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
---|
| 570 | cFillPic->getSlice(0)->initSlice(); |
---|
| 571 | |
---|
| 572 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 573 | Int closestPoc = 1000000; |
---|
| 574 | while ( iterPic != m_cListPic.end()) |
---|
[2] | 575 | { |
---|
[56] | 576 | TComPic * rpcPic = *(iterPic++); |
---|
| 577 | if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)<closestPoc&&abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)!=0&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC()) |
---|
[2] | 578 | { |
---|
[56] | 579 | closestPoc=abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc); |
---|
| 580 | } |
---|
| 581 | } |
---|
| 582 | iterPic = m_cListPic.begin(); |
---|
| 583 | while ( iterPic != m_cListPic.end()) |
---|
| 584 | { |
---|
| 585 | TComPic *rpcPic = *(iterPic++); |
---|
| 586 | if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)==closestPoc&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC()) |
---|
| 587 | { |
---|
| 588 | printf("copying picture %d to %d (%d)\n",rpcPic->getPicSym()->getSlice(0)->getPOC() ,iLostPoc,m_apcSlicePilot->getPOC()); |
---|
| 589 | rpcPic->getPicYuvRec()->copyToPic(cFillPic->getPicYuvRec()); |
---|
[2] | 590 | break; |
---|
| 591 | } |
---|
| 592 | } |
---|
[56] | 593 | cFillPic->setCurrSliceIdx(0); |
---|
| 594 | for(Int i=0; i<cFillPic->getNumCUsInFrame(); i++) |
---|
[2] | 595 | { |
---|
[56] | 596 | cFillPic->getCU(i)->initCU(cFillPic,i); |
---|
[2] | 597 | } |
---|
[56] | 598 | cFillPic->getSlice(0)->setReferenced(true); |
---|
| 599 | cFillPic->getSlice(0)->setPOC(iLostPoc); |
---|
| 600 | cFillPic->setReconMark(true); |
---|
| 601 | cFillPic->setOutputMark(true); |
---|
| 602 | if(m_pocRandomAccess == MAX_INT) |
---|
| 603 | { |
---|
| 604 | m_pocRandomAccess = iLostPoc; |
---|
| 605 | } |
---|
[2] | 606 | } |
---|
| 607 | |
---|
[56] | 608 | |
---|
| 609 | Void TDecTop::xActivateParameterSets() |
---|
[2] | 610 | { |
---|
[56] | 611 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
[608] | 612 | |
---|
[56] | 613 | TComPPS *pps = m_parameterSetManagerDecoder.getPPS(m_apcSlicePilot->getPPSId()); |
---|
| 614 | assert (pps != 0); |
---|
| 615 | |
---|
| 616 | TComSPS *sps = m_parameterSetManagerDecoder.getSPS(pps->getSPSId()); |
---|
| 617 | assert (sps != 0); |
---|
[608] | 618 | |
---|
[622] | 619 | #if H_MV |
---|
| 620 | TComVPS* vps = m_parameterSetManagerDecoder.getVPS(sps->getVPSId()); |
---|
| 621 | assert (vps != 0); |
---|
| 622 | if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP(), m_layerId ) ) |
---|
| 623 | #else |
---|
[608] | 624 | if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP())) |
---|
[622] | 625 | #endif |
---|
[608] | 626 | { |
---|
| 627 | printf ("Parameter set activation failed!"); |
---|
| 628 | assert (0); |
---|
| 629 | } |
---|
| 630 | |
---|
| 631 | if( pps->getDependentSliceSegmentsEnabledFlag() ) |
---|
| 632 | { |
---|
| 633 | Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1; |
---|
| 634 | |
---|
| 635 | if (m_cSliceDecoder.getCtxMemSize() != NumCtx) |
---|
| 636 | { |
---|
| 637 | m_cSliceDecoder.initCtxMem(NumCtx); |
---|
| 638 | for ( UInt st = 0; st < NumCtx; st++ ) |
---|
| 639 | { |
---|
| 640 | TDecSbac* ctx = NULL; |
---|
| 641 | ctx = new TDecSbac; |
---|
| 642 | ctx->init( &m_cBinCABAC ); |
---|
| 643 | m_cSliceDecoder.setCtxMem( ctx, st ); |
---|
| 644 | } |
---|
| 645 | } |
---|
| 646 | } |
---|
| 647 | |
---|
[56] | 648 | m_apcSlicePilot->setPPS(pps); |
---|
| 649 | m_apcSlicePilot->setSPS(sps); |
---|
[608] | 650 | #if H_MV |
---|
[622] | 651 | m_apcSlicePilot->setVPS(vps); |
---|
[738] | 652 | // The nuh_layer_id value of the NAL unit containing the PPS that is activated for a layer layerA with nuh_layer_id equal to nuhLayerIdA shall be equal to 0, or nuhLayerIdA, or the nuh_layer_id of a direct or indirect reference layer of layerA. |
---|
| 653 | assert( pps->getLayerId() == m_layerId || pps->getLayerId( ) == 0 || vps->getInDirectDependencyFlag( m_layerId, pps->getLayerId() ) ); |
---|
| 654 | // The nuh_layer_id value of the NAL unit containing the SPS that is activated for a layer layerA with nuh_layer_id equal to nuhLayerIdA shall be equal to 0, or nuhLayerIdA, or the nuh_layer_id of a direct or indirect reference layer of layerA. |
---|
| 655 | assert( sps->getLayerId() == m_layerId || sps->getLayerId( ) == 0 || vps->getInDirectDependencyFlag( m_layerId, sps->getLayerId() ) ); |
---|
[622] | 656 | sps->inferRepFormat ( vps , m_layerId ); |
---|
| 657 | sps->inferScalingList( m_parameterSetManagerDecoder.getActiveSPS( sps->getSpsScalingListRefLayerId() ) ); |
---|
[210] | 658 | #endif |
---|
[56] | 659 | pps->setSPS(sps); |
---|
[608] | 660 | pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1); |
---|
[56] | 661 | pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) ); |
---|
| 662 | |
---|
[608] | 663 | g_bitDepthY = sps->getBitDepthY(); |
---|
| 664 | g_bitDepthC = sps->getBitDepthC(); |
---|
| 665 | g_uiMaxCUWidth = sps->getMaxCUWidth(); |
---|
| 666 | g_uiMaxCUHeight = sps->getMaxCUHeight(); |
---|
| 667 | g_uiMaxCUDepth = sps->getMaxCUDepth(); |
---|
| 668 | g_uiAddCUDepth = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() ); |
---|
| 669 | |
---|
| 670 | for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++) |
---|
[2] | 671 | { |
---|
[56] | 672 | sps->setAMPAcc( i, sps->getUseAMP() ); |
---|
[2] | 673 | } |
---|
[56] | 674 | |
---|
[608] | 675 | for (Int i = sps->getLog2DiffMaxMinCodingBlockSize(); i < sps->getMaxCUDepth(); i++) |
---|
[56] | 676 | { |
---|
| 677 | sps->setAMPAcc( i, 0 ); |
---|
| 678 | } |
---|
| 679 | |
---|
[608] | 680 | m_cSAO.destroy(); |
---|
[872] | 681 | m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() ); |
---|
[608] | 682 | m_cLoopFilter.create( sps->getMaxCUDepth() ); |
---|
[2] | 683 | } |
---|
[56] | 684 | |
---|
[608] | 685 | #if H_MV |
---|
[738] | 686 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag ) |
---|
[608] | 687 | { |
---|
| 688 | assert( nalu.m_layerId == m_layerId ); |
---|
| 689 | #else |
---|
[56] | 690 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay ) |
---|
[2] | 691 | { |
---|
[608] | 692 | #endif |
---|
[2] | 693 | TComPic*& pcPic = m_pcPic; |
---|
[56] | 694 | m_apcSlicePilot->initSlice(); |
---|
[2] | 695 | |
---|
[56] | 696 | if (m_bFirstSliceInPicture) |
---|
[2] | 697 | { |
---|
[56] | 698 | m_uiSliceIdx = 0; |
---|
[2] | 699 | } |
---|
[872] | 700 | else |
---|
[56] | 701 | { |
---|
| 702 | m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) ); |
---|
| 703 | } |
---|
[872] | 704 | m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); |
---|
[2] | 705 | |
---|
[56] | 706 | m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); |
---|
[608] | 707 | Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
| 708 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
| 709 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
| 710 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 711 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N); |
---|
| 712 | m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag); |
---|
| 713 | |
---|
| 714 | m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS |
---|
[56] | 715 | m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId); |
---|
[42] | 716 | |
---|
[608] | 717 | #if H_MV |
---|
[622] | 718 | m_apcSlicePilot->setRefPicSetInterLayer( & m_refPicSetInterLayer0, &m_refPicSetInterLayer1 ); |
---|
[608] | 719 | m_apcSlicePilot->setLayerId( nalu.m_layerId ); |
---|
[42] | 720 | #endif |
---|
[608] | 721 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder); |
---|
| 722 | |
---|
[655] | 723 | // set POC for dependent slices in skipped pictures |
---|
| 724 | if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) |
---|
| 725 | { |
---|
| 726 | m_apcSlicePilot->setPOC(m_skippedPOC); |
---|
| 727 | } |
---|
| 728 | |
---|
| 729 | m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA); |
---|
| 730 | m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType); |
---|
| 731 | |
---|
[608] | 732 | #if H_MV |
---|
| 733 | TComVPS* vps = m_apcSlicePilot->getVPS(); |
---|
[622] | 734 | Int layerId = nalu.m_layerId; |
---|
| 735 | setViewId ( vps->getViewId ( layerId ) ); |
---|
| 736 | #if H_3D |
---|
| 737 | setViewIndex( vps->getViewIndex( layerId ) ); |
---|
| 738 | setIsDepth ( vps->getDepthId ( layerId ) == 1 ); |
---|
| 739 | m_ivPicLists->setVPS( vps ); |
---|
| 740 | #endif |
---|
[608] | 741 | #endif |
---|
[738] | 742 | |
---|
[773] | 743 | #if H_MV |
---|
[738] | 744 | xCeckNoClrasOutput(); |
---|
| 745 | #endif |
---|
[608] | 746 | // Skip pictures due to random access |
---|
| 747 | if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) |
---|
[56] | 748 | { |
---|
[655] | 749 | m_prevSliceSkipped = true; |
---|
| 750 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
[773] | 751 | #if H_MV |
---|
| 752 | sliceSkippedFlag = true; |
---|
[738] | 753 | #endif |
---|
[608] | 754 | return false; |
---|
[56] | 755 | } |
---|
[608] | 756 | // Skip TFD pictures associated with BLA/BLANT pictures |
---|
| 757 | if (isSkipPictureForBLA(iPOCLastDisplay)) |
---|
| 758 | { |
---|
[655] | 759 | m_prevSliceSkipped = true; |
---|
| 760 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
[773] | 761 | #if H_MV |
---|
| 762 | sliceSkippedFlag = true; |
---|
[738] | 763 | #endif |
---|
[608] | 764 | return false; |
---|
| 765 | } |
---|
| 766 | |
---|
[655] | 767 | // clear previous slice skipped flag |
---|
| 768 | m_prevSliceSkipped = false; |
---|
| 769 | |
---|
[608] | 770 | //we should only get a different poc for a new picture (with CTU address==0) |
---|
| 771 | if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (!m_apcSlicePilot->getSliceCurStartCUAddr()==0)) |
---|
| 772 | { |
---|
| 773 | printf ("Warning, the first slice of a picture might have been lost!\n"); |
---|
[56] | 774 | } |
---|
| 775 | // exit when a new picture is found |
---|
[608] | 776 | if (m_apcSlicePilot->isNextSlice() && (m_apcSlicePilot->getSliceCurStartCUAddr() == 0 && !m_bFirstSliceInPicture) && !m_bFirstSliceInSequence ) |
---|
[56] | 777 | { |
---|
| 778 | if (m_prevPOC >= m_pocRandomAccess) |
---|
| 779 | { |
---|
| 780 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 781 | return true; |
---|
| 782 | } |
---|
| 783 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 784 | } |
---|
[608] | 785 | #if H_MV |
---|
| 786 | if ( newLayerFlag ) |
---|
| 787 | { |
---|
| 788 | return false; |
---|
| 789 | } |
---|
| 790 | #if ENC_DEC_TRACE |
---|
| 791 | #if H_MV_ENC_DEC_TRAC |
---|
| 792 | // parse remainder of SH |
---|
| 793 | g_disableHLSTrace = false; |
---|
| 794 | #endif |
---|
| 795 | #endif |
---|
| 796 | #endif |
---|
[56] | 797 | // actual decoding starts here |
---|
[622] | 798 | #if H_MV |
---|
| 799 | // This part needs further testing ! |
---|
| 800 | if ( m_apcSlicePilot->getPocResetFlag() ) |
---|
| 801 | { |
---|
| 802 | xResetPocInPicBuffer(); |
---|
| 803 | } |
---|
| 804 | #endif |
---|
[56] | 805 | xActivateParameterSets(); |
---|
| 806 | |
---|
| 807 | if (m_apcSlicePilot->isNextSlice()) |
---|
| 808 | { |
---|
| 809 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 810 | } |
---|
| 811 | m_bFirstSliceInSequence = false; |
---|
| 812 | //detect lost reference picture and insert copy of earlier frame. |
---|
[608] | 813 | Int lostPoc; |
---|
| 814 | while((lostPoc=m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess)) > 0) |
---|
[56] | 815 | { |
---|
[608] | 816 | xCreateLostPicture(lostPoc-1); |
---|
[56] | 817 | } |
---|
[2] | 818 | if (m_bFirstSliceInPicture) |
---|
| 819 | { |
---|
[56] | 820 | // Buffer initialize for prediction. |
---|
| 821 | m_cPrediction.initTempBuff(); |
---|
| 822 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
---|
[608] | 823 | #if H_MV |
---|
[622] | 824 | m_apcSlicePilot->createInterLayerReferencePictureSet( m_ivPicLists, m_refPicSetInterLayer0, m_refPicSetInterLayer1 ); |
---|
[608] | 825 | #endif |
---|
[56] | 826 | // Get a new picture buffer |
---|
| 827 | xGetNewPicBuffer (m_apcSlicePilot, pcPic); |
---|
[2] | 828 | |
---|
[655] | 829 | Bool isField = false; |
---|
| 830 | Bool isTff = false; |
---|
| 831 | |
---|
| 832 | if(!m_SEIs.empty()) |
---|
| 833 | { |
---|
| 834 | // Check if any new Picture Timing SEI has arrived |
---|
| 835 | SEIMessages pictureTimingSEIs = extractSeisByType (m_SEIs, SEI::PICTURE_TIMING); |
---|
| 836 | if (pictureTimingSEIs.size()>0) |
---|
| 837 | { |
---|
| 838 | SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin()); |
---|
| 839 | isField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 2); |
---|
| 840 | isTff = (pictureTiming->m_picStruct == 1); |
---|
| 841 | } |
---|
| 842 | } |
---|
| 843 | |
---|
| 844 | //Set Field/Frame coding mode |
---|
| 845 | m_pcPic->setField(isField); |
---|
| 846 | m_pcPic->setTopField(isTff); |
---|
| 847 | |
---|
[608] | 848 | // transfer any SEI messages that have been received to the picture |
---|
[56] | 849 | pcPic->setSEIs(m_SEIs); |
---|
[608] | 850 | m_SEIs.clear(); |
---|
[42] | 851 | |
---|
[56] | 852 | // Recursive structure |
---|
| 853 | m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 854 | m_cCuDecoder.init ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction ); |
---|
| 855 | m_cTrQuant.init ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize()); |
---|
[42] | 856 | |
---|
[608] | 857 | m_cSliceDecoder.create(); |
---|
| 858 | } |
---|
| 859 | else |
---|
| 860 | { |
---|
| 861 | // Check if any new SEI has arrived |
---|
| 862 | if(!m_SEIs.empty()) |
---|
[56] | 863 | { |
---|
[608] | 864 | // Currently only decoding Unit SEI message occurring between VCL NALUs copied |
---|
| 865 | SEIMessages &picSEI = pcPic->getSEIs(); |
---|
| 866 | SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO); |
---|
| 867 | picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end()); |
---|
| 868 | deleteSEIs(m_SEIs); |
---|
[56] | 869 | } |
---|
| 870 | } |
---|
[608] | 871 | |
---|
[56] | 872 | // Set picture slice pointer |
---|
| 873 | TComSlice* pcSlice = m_apcSlicePilot; |
---|
| 874 | Bool bNextSlice = pcSlice->isNextSlice(); |
---|
[2] | 875 | |
---|
[56] | 876 | UInt uiCummulativeTileWidth; |
---|
| 877 | UInt uiCummulativeTileHeight; |
---|
| 878 | UInt i, j, p; |
---|
| 879 | |
---|
[608] | 880 | //set NumColumnsMins1 and NumRowsMinus1 |
---|
| 881 | pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() ); |
---|
| 882 | pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() ); |
---|
[2] | 883 | |
---|
[608] | 884 | //create the TComTileArray |
---|
| 885 | pcPic->getPicSym()->xCreateTComTileArray(); |
---|
| 886 | |
---|
| 887 | if( pcSlice->getPPS()->getUniformSpacingFlag() ) |
---|
[56] | 888 | { |
---|
[608] | 889 | //set the width for each tile |
---|
| 890 | for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) |
---|
[56] | 891 | { |
---|
[608] | 892 | for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++) |
---|
[2] | 893 | { |
---|
[608] | 894 | pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )-> |
---|
| 895 | setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) |
---|
| 896 | - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) ); |
---|
[2] | 897 | } |
---|
[608] | 898 | } |
---|
[2] | 899 | |
---|
[608] | 900 | //set the height for each tile |
---|
| 901 | for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) |
---|
[2] | 902 | { |
---|
[608] | 903 | for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++) |
---|
[2] | 904 | { |
---|
[608] | 905 | pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )-> |
---|
| 906 | setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) |
---|
| 907 | - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) ); |
---|
[2] | 908 | } |
---|
[56] | 909 | } |
---|
| 910 | } |
---|
| 911 | else |
---|
| 912 | { |
---|
[608] | 913 | //set the width for each tile |
---|
| 914 | for(j=0; j < pcSlice->getPPS()->getNumRowsMinus1()+1; j++) |
---|
[56] | 915 | { |
---|
[608] | 916 | uiCummulativeTileWidth = 0; |
---|
| 917 | for(i=0; i < pcSlice->getPPS()->getNumColumnsMinus1(); i++) |
---|
[2] | 918 | { |
---|
[608] | 919 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getPPS()->getColumnWidth(i) ); |
---|
| 920 | uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(i); |
---|
[2] | 921 | } |
---|
[608] | 922 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth ); |
---|
| 923 | } |
---|
[56] | 924 | |
---|
[608] | 925 | //set the height for each tile |
---|
| 926 | for(j=0; j < pcSlice->getPPS()->getNumColumnsMinus1()+1; j++) |
---|
[56] | 927 | { |
---|
[608] | 928 | uiCummulativeTileHeight = 0; |
---|
| 929 | for(i=0; i < pcSlice->getPPS()->getNumRowsMinus1(); i++) |
---|
| 930 | { |
---|
| 931 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getPPS()->getRowHeight(i) ); |
---|
| 932 | uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(i); |
---|
[56] | 933 | } |
---|
[608] | 934 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight ); |
---|
[56] | 935 | } |
---|
| 936 | } |
---|
[2] | 937 | |
---|
[56] | 938 | pcPic->getPicSym()->xInitTiles(); |
---|
[2] | 939 | |
---|
[56] | 940 | //generate the Coding Order Map and Inverse Coding Order Map |
---|
| 941 | UInt uiEncCUAddr; |
---|
| 942 | for(i=0, uiEncCUAddr=0; i<pcPic->getPicSym()->getNumberOfCUsInFrame(); i++, uiEncCUAddr = pcPic->getPicSym()->xCalculateNxtCUAddr(uiEncCUAddr)) |
---|
| 943 | { |
---|
| 944 | pcPic->getPicSym()->setCUOrderMap(i, uiEncCUAddr); |
---|
| 945 | pcPic->getPicSym()->setInverseCUOrderMap(uiEncCUAddr, i); |
---|
| 946 | } |
---|
| 947 | pcPic->getPicSym()->setCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
| 948 | pcPic->getPicSym()->setInverseCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
| 949 | |
---|
[608] | 950 | //convert the start and end CU addresses of the slice and dependent slice into encoding order |
---|
| 951 | pcSlice->setSliceSegmentCurStartCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurStartCUAddr()) ); |
---|
| 952 | pcSlice->setSliceSegmentCurEndCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurEndCUAddr()) ); |
---|
[56] | 953 | if(pcSlice->isNextSlice()) |
---|
| 954 | { |
---|
| 955 | pcSlice->setSliceCurStartCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurStartCUAddr())); |
---|
| 956 | pcSlice->setSliceCurEndCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurEndCUAddr())); |
---|
| 957 | } |
---|
| 958 | |
---|
| 959 | if (m_bFirstSliceInPicture) |
---|
| 960 | { |
---|
| 961 | if(pcPic->getNumAllocatedSlice() != 1) |
---|
| 962 | { |
---|
| 963 | pcPic->clearSliceBuffer(); |
---|
| 964 | } |
---|
| 965 | } |
---|
| 966 | else |
---|
| 967 | { |
---|
| 968 | pcPic->allocateNewSlice(); |
---|
| 969 | } |
---|
| 970 | assert(pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
| 971 | m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx); |
---|
| 972 | pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx); |
---|
| 973 | |
---|
| 974 | pcPic->setTLayer(nalu.m_temporalId); |
---|
| 975 | |
---|
[608] | 976 | #if H_MV |
---|
| 977 | pcPic->setLayerId( nalu.m_layerId ); |
---|
| 978 | pcPic->setViewId ( getViewId() ); |
---|
| 979 | #if H_3D |
---|
| 980 | pcPic->setViewIndex( getViewIndex() ); |
---|
| 981 | pcPic->setIsDepth ( getIsDepth () ); |
---|
| 982 | #endif |
---|
| 983 | #endif |
---|
[56] | 984 | if (bNextSlice) |
---|
| 985 | { |
---|
[655] | 986 | pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic ); |
---|
[608] | 987 | // Set reference list |
---|
| 988 | #if H_MV |
---|
[622] | 989 | std::vector< TComPic* > tempRefPicLists[2]; |
---|
| 990 | std::vector< Bool > usedAsLongTerm [2]; |
---|
| 991 | Int numPocTotalCurr; |
---|
| 992 | |
---|
| 993 | pcSlice->getTempRefPicLists( m_cListPic, m_refPicSetInterLayer0, m_refPicSetInterLayer1, tempRefPicLists, usedAsLongTerm, numPocTotalCurr); |
---|
| 994 | pcSlice->setRefPicList ( tempRefPicLists, usedAsLongTerm, numPocTotalCurr, true ); |
---|
[608] | 995 | #if H_3D_ARP |
---|
[724] | 996 | pcSlice->setARPStepNum(m_ivPicLists); |
---|
[608] | 997 | if( pcSlice->getARPStepNum() > 1 ) |
---|
[56] | 998 | { |
---|
[622] | 999 | // GT: This seems to be broken, not all nuh_layer_ids are necessarily present |
---|
[608] | 1000 | for(Int iLayerId = 0; iLayerId < nalu.m_layerId; iLayerId ++ ) |
---|
| 1001 | { |
---|
| 1002 | Int iViewIdx = pcSlice->getVPS()->getViewIndex(iLayerId); |
---|
| 1003 | Bool bIsDepth = ( pcSlice->getVPS()->getDepthId ( iLayerId ) == 1 ); |
---|
| 1004 | if( iViewIdx<getViewIndex() && !bIsDepth ) |
---|
| 1005 | { |
---|
| 1006 | pcSlice->setBaseViewRefPicList( m_ivPicLists->getPicList( iLayerId ), iViewIdx ); |
---|
| 1007 | } |
---|
| 1008 | } |
---|
[56] | 1009 | } |
---|
[77] | 1010 | #endif |
---|
| 1011 | #else |
---|
[608] | 1012 | pcSlice->setRefPicList( m_cListPic, true ); |
---|
[21] | 1013 | #endif |
---|
| 1014 | |
---|
[608] | 1015 | #if H_3D |
---|
| 1016 | pcSlice->setIvPicLists( m_ivPicLists ); |
---|
[655] | 1017 | #if H_3D_IV_MERGE |
---|
| 1018 | #if H_3D_FCO |
---|
| 1019 | //assert( !getIsDepth() ); |
---|
| 1020 | #else |
---|
[608] | 1021 | assert( !getIsDepth() || ( pcSlice->getTexturePic() != 0 ) ); |
---|
[655] | 1022 | #endif |
---|
[608] | 1023 | #endif |
---|
[210] | 1024 | #endif |
---|
[56] | 1025 | // For generalized B |
---|
| 1026 | // note: maybe not existed case (always L0 is copied to L1 if L1 is empty) |
---|
| 1027 | if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0) |
---|
| 1028 | { |
---|
| 1029 | Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0); |
---|
| 1030 | pcSlice->setNumRefIdx ( REF_PIC_LIST_1, iNumRefIdx ); |
---|
[2] | 1031 | |
---|
[56] | 1032 | for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++) |
---|
| 1033 | { |
---|
| 1034 | pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx); |
---|
| 1035 | } |
---|
| 1036 | } |
---|
[608] | 1037 | if (!pcSlice->isIntra()) |
---|
[56] | 1038 | { |
---|
| 1039 | Bool bLowDelay = true; |
---|
| 1040 | Int iCurrPOC = pcSlice->getPOC(); |
---|
| 1041 | Int iRefIdx = 0; |
---|
| 1042 | |
---|
| 1043 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++) |
---|
| 1044 | { |
---|
| 1045 | if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC ) |
---|
[21] | 1046 | { |
---|
[56] | 1047 | bLowDelay = false; |
---|
[21] | 1048 | } |
---|
[2] | 1049 | } |
---|
[608] | 1050 | if (pcSlice->isInterB()) |
---|
[56] | 1051 | { |
---|
[608] | 1052 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++) |
---|
[56] | 1053 | { |
---|
[608] | 1054 | if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC ) |
---|
| 1055 | { |
---|
| 1056 | bLowDelay = false; |
---|
| 1057 | } |
---|
| 1058 | } |
---|
[56] | 1059 | } |
---|
[2] | 1060 | |
---|
[56] | 1061 | pcSlice->setCheckLDC(bLowDelay); |
---|
| 1062 | } |
---|
| 1063 | |
---|
| 1064 | //--------------- |
---|
[608] | 1065 | pcSlice->setRefPOCList(); |
---|
| 1066 | #if H_3D_TMVP |
---|
| 1067 | if(pcSlice->getLayerId()) |
---|
| 1068 | pcSlice->generateAlterRefforTMVP(); |
---|
[313] | 1069 | #endif |
---|
[56] | 1070 | } |
---|
| 1071 | |
---|
| 1072 | pcPic->setCurrSliceIdx(m_uiSliceIdx); |
---|
| 1073 | if(pcSlice->getSPS()->getScalingListFlag()) |
---|
| 1074 | { |
---|
[608] | 1075 | pcSlice->setScalingList ( pcSlice->getSPS()->getScalingList() ); |
---|
| 1076 | if(pcSlice->getPPS()->getScalingListPresentFlag()) |
---|
[56] | 1077 | { |
---|
[608] | 1078 | pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList() ); |
---|
[56] | 1079 | } |
---|
[608] | 1080 | if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag()) |
---|
| 1081 | { |
---|
| 1082 | pcSlice->setDefaultScalingList(); |
---|
| 1083 | } |
---|
| 1084 | m_cTrQuant.setScalingListDec(pcSlice->getScalingList()); |
---|
[56] | 1085 | m_cTrQuant.setUseScalingList(true); |
---|
| 1086 | } |
---|
| 1087 | else |
---|
| 1088 | { |
---|
| 1089 | m_cTrQuant.setFlatScalingList(); |
---|
| 1090 | m_cTrQuant.setUseScalingList(false); |
---|
| 1091 | } |
---|
[2] | 1092 | |
---|
[773] | 1093 | #if H_3D_IV_MERGE |
---|
[724] | 1094 | if( pcSlice->getIsDepth() && m_pcCamParsCollector ) |
---|
| 1095 | { |
---|
| 1096 | m_pcCamParsCollector->copyCamParamForSlice( pcSlice ); |
---|
| 1097 | } |
---|
| 1098 | #endif |
---|
| 1099 | |
---|
[56] | 1100 | // Decode a picture |
---|
[608] | 1101 | m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic); |
---|
| 1102 | #if H_3D |
---|
[57] | 1103 | if( m_pcCamParsCollector ) |
---|
| 1104 | { |
---|
| 1105 | m_pcCamParsCollector->setSlice( pcSlice ); |
---|
| 1106 | } |
---|
[758] | 1107 | #endif |
---|
[56] | 1108 | m_bFirstSliceInPicture = false; |
---|
| 1109 | m_uiSliceIdx++; |
---|
| 1110 | |
---|
| 1111 | return false; |
---|
| 1112 | } |
---|
| 1113 | |
---|
[77] | 1114 | Void TDecTop::xDecodeVPS() |
---|
| 1115 | { |
---|
| 1116 | TComVPS* vps = new TComVPS(); |
---|
| 1117 | |
---|
| 1118 | m_cEntropyDecoder.decodeVPS( vps ); |
---|
| 1119 | m_parameterSetManagerDecoder.storePrefetchedVPS(vps); |
---|
| 1120 | } |
---|
[56] | 1121 | |
---|
| 1122 | Void TDecTop::xDecodeSPS() |
---|
| 1123 | { |
---|
| 1124 | TComSPS* sps = new TComSPS(); |
---|
[608] | 1125 | #if H_MV |
---|
| 1126 | sps->setLayerId( getLayerId() ); |
---|
| 1127 | #endif |
---|
| 1128 | #if H_3D |
---|
| 1129 | // Preliminary fix. assuming that all sps refer to the same SPS. |
---|
| 1130 | // Parsing dependency should be resolved! |
---|
| 1131 | TComVPS* vps = m_parameterSetManagerDecoder.getPrefetchedVPS( 0 ); |
---|
| 1132 | assert( vps != 0 ); |
---|
[622] | 1133 | m_cEntropyDecoder.decodeSPS( sps, vps->getViewIndex( m_layerId ), ( vps->getDepthId( m_layerId ) == 1 ) ); |
---|
| 1134 | #else |
---|
[56] | 1135 | m_cEntropyDecoder.decodeSPS( sps ); |
---|
[42] | 1136 | #endif |
---|
[56] | 1137 | m_parameterSetManagerDecoder.storePrefetchedSPS(sps); |
---|
| 1138 | } |
---|
[2] | 1139 | |
---|
[56] | 1140 | Void TDecTop::xDecodePPS() |
---|
| 1141 | { |
---|
| 1142 | TComPPS* pps = new TComPPS(); |
---|
[622] | 1143 | #if H_MV |
---|
| 1144 | pps->setLayerId( getLayerId() ); |
---|
| 1145 | #endif |
---|
[773] | 1146 | #if H_3D |
---|
[758] | 1147 | // Assuming that all PPS indirectly refer to the same VPS via different SPS |
---|
| 1148 | // There is no parsing dependency in decoding DLT in PPS. |
---|
| 1149 | // The VPS information passed to decodePPS() is used to arrange the decoded DLT tables to their corresponding layers. |
---|
| 1150 | // This is equivalent to the process of |
---|
| 1151 | // Step 1) decoding DLT tables based on the number of depth layers, and |
---|
| 1152 | // Step 2) mapping DLT tables to the depth layers |
---|
[773] | 1153 | // as described in the 3D-HEVC WD. |
---|
[758] | 1154 | TComVPS* vps = m_parameterSetManagerDecoder.getPrefetchedVPS( 0 ); |
---|
| 1155 | m_cEntropyDecoder.decodePPS( pps, vps ); |
---|
| 1156 | #else |
---|
[608] | 1157 | m_cEntropyDecoder.decodePPS( pps ); |
---|
[758] | 1158 | #endif |
---|
[56] | 1159 | m_parameterSetManagerDecoder.storePrefetchedPPS( pps ); |
---|
| 1160 | } |
---|
[2] | 1161 | |
---|
[608] | 1162 | Void TDecTop::xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ) |
---|
[56] | 1163 | { |
---|
[608] | 1164 | if(nalUnitType == NAL_UNIT_SUFFIX_SEI) |
---|
| 1165 | { |
---|
[622] | 1166 | #if H_MV |
---|
| 1167 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS( m_layerId ) ); |
---|
| 1168 | #else |
---|
[608] | 1169 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
[622] | 1170 | #endif |
---|
[608] | 1171 | } |
---|
| 1172 | else |
---|
| 1173 | { |
---|
[622] | 1174 | #if H_MV |
---|
| 1175 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS( m_layerId ) ); |
---|
| 1176 | #else |
---|
[608] | 1177 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
[622] | 1178 | #endif |
---|
[608] | 1179 | SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); |
---|
| 1180 | if (activeParamSets.size()>0) |
---|
| 1181 | { |
---|
| 1182 | SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); |
---|
| 1183 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
| 1184 | assert(seiAps->activeSeqParamSetId.size()>0); |
---|
[622] | 1185 | #if H_MV |
---|
| 1186 | if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParamSetId[0], m_layerId )) |
---|
| 1187 | #else |
---|
[608] | 1188 | if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParamSetId[0] )) |
---|
[622] | 1189 | #endif |
---|
[608] | 1190 | { |
---|
| 1191 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
| 1192 | } |
---|
| 1193 | } |
---|
| 1194 | } |
---|
[56] | 1195 | } |
---|
[2] | 1196 | |
---|
[608] | 1197 | #if H_MV |
---|
[738] | 1198 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag ) |
---|
| 1199 | #else |
---|
[56] | 1200 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
[608] | 1201 | #endif |
---|
[56] | 1202 | { |
---|
| 1203 | // Initialize entropy decoder |
---|
| 1204 | m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); |
---|
| 1205 | m_cEntropyDecoder.setBitstream (nalu.m_Bitstream); |
---|
[2] | 1206 | |
---|
[56] | 1207 | switch (nalu.m_nalUnitType) |
---|
| 1208 | { |
---|
[77] | 1209 | case NAL_UNIT_VPS: |
---|
| 1210 | xDecodeVPS(); |
---|
| 1211 | return false; |
---|
[608] | 1212 | |
---|
[56] | 1213 | case NAL_UNIT_SPS: |
---|
| 1214 | xDecodeSPS(); |
---|
| 1215 | return false; |
---|
| 1216 | |
---|
| 1217 | case NAL_UNIT_PPS: |
---|
| 1218 | xDecodePPS(); |
---|
| 1219 | return false; |
---|
[608] | 1220 | |
---|
| 1221 | case NAL_UNIT_PREFIX_SEI: |
---|
| 1222 | case NAL_UNIT_SUFFIX_SEI: |
---|
| 1223 | xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType ); |
---|
[56] | 1224 | return false; |
---|
| 1225 | |
---|
[608] | 1226 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
| 1227 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
[872] | 1228 | case NAL_UNIT_CODED_SLICE_TSA_R: |
---|
[608] | 1229 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
| 1230 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
| 1231 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
| 1232 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
| 1233 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
| 1234 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
| 1235 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
| 1236 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
[56] | 1237 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
[608] | 1238 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
| 1239 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
| 1240 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
| 1241 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
| 1242 | #if H_MV |
---|
[738] | 1243 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, newLayerFlag, sliceSkippedFlag ); |
---|
| 1244 | #else |
---|
[56] | 1245 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay); |
---|
[608] | 1246 | #endif |
---|
[2] | 1247 | break; |
---|
[872] | 1248 | case NAL_UNIT_EOS: |
---|
| 1249 | m_associatedIRAPType = NAL_UNIT_INVALID; |
---|
| 1250 | m_pocCRA = 0; |
---|
| 1251 | m_pocRandomAccess = MAX_INT; |
---|
| 1252 | m_prevPOC = MAX_INT; |
---|
| 1253 | m_bFirstSliceInPicture = true; |
---|
| 1254 | m_bFirstSliceInSequence = true; |
---|
| 1255 | m_prevSliceSkipped = false; |
---|
| 1256 | m_skippedPOC = 0; |
---|
| 1257 | return false; |
---|
| 1258 | |
---|
| 1259 | case NAL_UNIT_ACCESS_UNIT_DELIMITER: |
---|
| 1260 | // TODO: process AU delimiter |
---|
| 1261 | return false; |
---|
| 1262 | |
---|
| 1263 | case NAL_UNIT_EOB: |
---|
| 1264 | return false; |
---|
| 1265 | |
---|
| 1266 | |
---|
| 1267 | case NAL_UNIT_RESERVED_VCL_N10: |
---|
| 1268 | case NAL_UNIT_RESERVED_VCL_R11: |
---|
| 1269 | case NAL_UNIT_RESERVED_VCL_N12: |
---|
| 1270 | case NAL_UNIT_RESERVED_VCL_R13: |
---|
| 1271 | case NAL_UNIT_RESERVED_VCL_N14: |
---|
| 1272 | case NAL_UNIT_RESERVED_VCL_R15: |
---|
| 1273 | |
---|
| 1274 | case NAL_UNIT_RESERVED_IRAP_VCL22: |
---|
| 1275 | case NAL_UNIT_RESERVED_IRAP_VCL23: |
---|
| 1276 | |
---|
| 1277 | case NAL_UNIT_RESERVED_VCL24: |
---|
| 1278 | case NAL_UNIT_RESERVED_VCL25: |
---|
| 1279 | case NAL_UNIT_RESERVED_VCL26: |
---|
| 1280 | case NAL_UNIT_RESERVED_VCL27: |
---|
| 1281 | case NAL_UNIT_RESERVED_VCL28: |
---|
| 1282 | case NAL_UNIT_RESERVED_VCL29: |
---|
| 1283 | case NAL_UNIT_RESERVED_VCL30: |
---|
| 1284 | case NAL_UNIT_RESERVED_VCL31: |
---|
| 1285 | |
---|
| 1286 | case NAL_UNIT_FILLER_DATA: |
---|
| 1287 | case NAL_UNIT_RESERVED_NVCL41: |
---|
| 1288 | case NAL_UNIT_RESERVED_NVCL42: |
---|
| 1289 | case NAL_UNIT_RESERVED_NVCL43: |
---|
| 1290 | case NAL_UNIT_RESERVED_NVCL44: |
---|
| 1291 | case NAL_UNIT_RESERVED_NVCL45: |
---|
| 1292 | case NAL_UNIT_RESERVED_NVCL46: |
---|
| 1293 | case NAL_UNIT_RESERVED_NVCL47: |
---|
| 1294 | case NAL_UNIT_UNSPECIFIED_48: |
---|
| 1295 | case NAL_UNIT_UNSPECIFIED_49: |
---|
| 1296 | case NAL_UNIT_UNSPECIFIED_50: |
---|
| 1297 | case NAL_UNIT_UNSPECIFIED_51: |
---|
| 1298 | case NAL_UNIT_UNSPECIFIED_52: |
---|
| 1299 | case NAL_UNIT_UNSPECIFIED_53: |
---|
| 1300 | case NAL_UNIT_UNSPECIFIED_54: |
---|
| 1301 | case NAL_UNIT_UNSPECIFIED_55: |
---|
| 1302 | case NAL_UNIT_UNSPECIFIED_56: |
---|
| 1303 | case NAL_UNIT_UNSPECIFIED_57: |
---|
| 1304 | case NAL_UNIT_UNSPECIFIED_58: |
---|
| 1305 | case NAL_UNIT_UNSPECIFIED_59: |
---|
| 1306 | case NAL_UNIT_UNSPECIFIED_60: |
---|
| 1307 | case NAL_UNIT_UNSPECIFIED_61: |
---|
| 1308 | case NAL_UNIT_UNSPECIFIED_62: |
---|
| 1309 | case NAL_UNIT_UNSPECIFIED_63: |
---|
[2] | 1310 | default: |
---|
[872] | 1311 | assert (0); |
---|
[2] | 1312 | } |
---|
| 1313 | |
---|
| 1314 | return false; |
---|
| 1315 | } |
---|
| 1316 | |
---|
[608] | 1317 | /** Function for checking if picture should be skipped because of association with a previous BLA picture |
---|
| 1318 | * \param iPOCLastDisplay POC of last picture displayed |
---|
| 1319 | * \returns true if the picture should be skipped |
---|
| 1320 | * This function skips all TFD pictures that follow a BLA picture |
---|
| 1321 | * in decoding order and precede it in output order. |
---|
| 1322 | */ |
---|
| 1323 | Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay) |
---|
[210] | 1324 | { |
---|
[655] | 1325 | if ((m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_N_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_RADL) && |
---|
| 1326 | m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) |
---|
[608] | 1327 | { |
---|
| 1328 | iPOCLastDisplay++; |
---|
| 1329 | return true; |
---|
| 1330 | } |
---|
| 1331 | return false; |
---|
[210] | 1332 | } |
---|
| 1333 | |
---|
[2] | 1334 | /** Function for checking if picture should be skipped because of random access |
---|
| 1335 | * \param iSkipFrame skip frame counter |
---|
| 1336 | * \param iPOCLastDisplay POC of last picture displayed |
---|
| 1337 | * \returns true if the picture shold be skipped in the random access. |
---|
| 1338 | * This function checks the skipping of pictures in the case of -s option random access. |
---|
| 1339 | * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped. |
---|
| 1340 | * It also checks the type of Nal unit type at the random access point. |
---|
[608] | 1341 | * If the random access point is CRA/CRANT/BLA/BLANT, TFD pictures with POC less than the POC of the random access point are skipped. |
---|
[2] | 1342 | * If the random access point is IDR all pictures after the random access point are decoded. |
---|
[608] | 1343 | * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC |
---|
| 1344 | * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random |
---|
[2] | 1345 | * access point there is no guarantee that the decoder will not crash. |
---|
| 1346 | */ |
---|
| 1347 | Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
| 1348 | { |
---|
[56] | 1349 | if (iSkipFrame) |
---|
[2] | 1350 | { |
---|
| 1351 | iSkipFrame--; // decrement the counter |
---|
| 1352 | return true; |
---|
| 1353 | } |
---|
[773] | 1354 | #if H_MV |
---|
[738] | 1355 | else if ( !m_layerInitilizedFlag[ m_layerId ] ) // start of random access point, m_pocRandomAccess has not been set yet. |
---|
| 1356 | #else |
---|
[56] | 1357 | else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet. |
---|
[738] | 1358 | #endif |
---|
[2] | 1359 | { |
---|
[608] | 1360 | if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA |
---|
| 1361 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 1362 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
| 1363 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ) |
---|
[2] | 1364 | { |
---|
[738] | 1365 | |
---|
[773] | 1366 | #if H_MV |
---|
[738] | 1367 | if ( xAllRefLayersInitilized() ) |
---|
| 1368 | { |
---|
| 1369 | m_layerInitilizedFlag[ m_layerId ] = true; |
---|
| 1370 | m_pocRandomAccess = m_apcSlicePilot->getPOC(); |
---|
| 1371 | } |
---|
| 1372 | else |
---|
| 1373 | { |
---|
| 1374 | return true; |
---|
| 1375 | } |
---|
| 1376 | #else |
---|
[608] | 1377 | // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT. |
---|
| 1378 | m_pocRandomAccess = m_apcSlicePilot->getPOC(); |
---|
[738] | 1379 | #endif |
---|
[2] | 1380 | } |
---|
[608] | 1381 | else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
[2] | 1382 | { |
---|
[773] | 1383 | #if H_MV |
---|
[738] | 1384 | if ( xAllRefLayersInitilized() ) |
---|
| 1385 | { |
---|
| 1386 | m_layerInitilizedFlag[ m_layerId ] = true; |
---|
[773] | 1387 | m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable. |
---|
| 1388 | } |
---|
| 1389 | else |
---|
| 1390 | { |
---|
[738] | 1391 | return true; |
---|
| 1392 | } |
---|
| 1393 | #else |
---|
| 1394 | m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable. |
---|
| 1395 | #endif |
---|
| 1396 | } |
---|
| 1397 | else |
---|
| 1398 | { |
---|
[773] | 1399 | #if H_MV |
---|
[738] | 1400 | static Bool warningMessage[MAX_NUM_LAYERS]; |
---|
| 1401 | static Bool warningInitFlag = false; |
---|
| 1402 | |
---|
| 1403 | if (!warningInitFlag) |
---|
| 1404 | { |
---|
| 1405 | for ( Int i = 0; i < MAX_NUM_LAYERS; i++) |
---|
| 1406 | { |
---|
| 1407 | warningMessage[i] = true; |
---|
| 1408 | } |
---|
| 1409 | warningInitFlag = true; |
---|
| 1410 | } |
---|
| 1411 | |
---|
| 1412 | if ( warningMessage[getLayerId()] ) |
---|
| 1413 | { |
---|
| 1414 | printf("\nLayer%3d No valid random access point. VCL NAL units of this layer are discarded until next layer initialization picture. ", getLayerId() ); |
---|
| 1415 | warningMessage[m_layerId] = false; |
---|
| 1416 | } |
---|
| 1417 | #else |
---|
[608] | 1418 | static Bool warningMessage = false; |
---|
[56] | 1419 | if(!warningMessage) |
---|
| 1420 | { |
---|
| 1421 | printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture"); |
---|
| 1422 | warningMessage = true; |
---|
| 1423 | } |
---|
[738] | 1424 | #endif |
---|
[56] | 1425 | return true; |
---|
[2] | 1426 | } |
---|
| 1427 | } |
---|
[608] | 1428 | // skip the reordered pictures, if necessary |
---|
| 1429 | else if (m_apcSlicePilot->getPOC() < m_pocRandomAccess && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) |
---|
[2] | 1430 | { |
---|
| 1431 | iPOCLastDisplay++; |
---|
| 1432 | return true; |
---|
| 1433 | } |
---|
[773] | 1434 | #if H_MV |
---|
[738] | 1435 | return !m_layerInitilizedFlag[ getLayerId() ]; |
---|
| 1436 | #else |
---|
[2] | 1437 | // if we reach here, then the picture is not skipped. |
---|
[56] | 1438 | return false; |
---|
[738] | 1439 | #endif |
---|
[2] | 1440 | } |
---|
[56] | 1441 | |
---|
[608] | 1442 | #if H_MV |
---|
| 1443 | TComPic* TDecTop::getPic( Int poc ) |
---|
[56] | 1444 | { |
---|
[608] | 1445 | xGetPic( m_layerId, poc ); |
---|
| 1446 | TComList<TComPic*>* listPic = getListPic(); |
---|
| 1447 | TComPic* pcPic = NULL; |
---|
| 1448 | for(TComList<TComPic*>::iterator it=listPic->begin(); it!=listPic->end(); it++) |
---|
| 1449 | { |
---|
| 1450 | if( (*it)->getPOC() == poc ) |
---|
| 1451 | { |
---|
| 1452 | pcPic = *it ; |
---|
| 1453 | break ; |
---|
| 1454 | } |
---|
| 1455 | } |
---|
| 1456 | return pcPic; |
---|
[56] | 1457 | } |
---|
[2] | 1458 | |
---|
[608] | 1459 | TComPic* TDecTop::xGetPic( Int layerId, Int poc ) |
---|
| 1460 | { |
---|
| 1461 | return m_ivPicLists->getPic( layerId, poc ) ; |
---|
| 1462 | } |
---|
| 1463 | |
---|
[622] | 1464 | Void TDecTop::xResetPocInPicBuffer() |
---|
| 1465 | { |
---|
| 1466 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 1467 | while (iterPic != m_cListPic.end()) |
---|
| 1468 | { |
---|
| 1469 | TComPic* pic = *(iterPic++); |
---|
| 1470 | if ( pic->getReconMark() ) |
---|
| 1471 | { |
---|
| 1472 | for( Int i = 0; i < pic->getNumAllocatedSlice(); i++) |
---|
| 1473 | { |
---|
| 1474 | TComSlice* slice = pic->getSlice( i ); |
---|
| 1475 | slice->setPOC ( slice->getPOC() - m_apcSlicePilot->getPocBeforeReset() ); |
---|
| 1476 | } |
---|
| 1477 | } |
---|
| 1478 | } |
---|
| 1479 | } |
---|
[738] | 1480 | |
---|
[773] | 1481 | #if H_MV |
---|
[738] | 1482 | Void TDecTop::xCeckNoClrasOutput() |
---|
| 1483 | { |
---|
| 1484 | // This part needs further testing! |
---|
| 1485 | if ( getLayerId() == 0 ) |
---|
| 1486 | { |
---|
| 1487 | NalUnitType nut = m_apcSlicePilot->getNalUnitType(); |
---|
| 1488 | |
---|
| 1489 | Bool isBLA = ( nut == NAL_UNIT_CODED_SLICE_BLA_W_LP ) || ( nut == NAL_UNIT_CODED_SLICE_BLA_N_LP ) || ( nut == NAL_UNIT_CODED_SLICE_BLA_W_RADL ); |
---|
| 1490 | Bool isIDR = ( nut == NAL_UNIT_CODED_SLICE_IDR_W_RADL ) || ( nut == NAL_UNIT_CODED_SLICE_IDR_N_LP ); |
---|
| 1491 | Bool noClrasOutputFlag = isBLA || ( isIDR && m_apcSlicePilot->getCrossLayerBlaFlag() ); |
---|
| 1492 | |
---|
| 1493 | if ( noClrasOutputFlag ) |
---|
| 1494 | { |
---|
| 1495 | for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++) |
---|
| 1496 | { |
---|
| 1497 | m_layerInitilizedFlag[i] = false; |
---|
| 1498 | } |
---|
| 1499 | } |
---|
| 1500 | } |
---|
| 1501 | } |
---|
| 1502 | |
---|
| 1503 | Bool TDecTop::xAllRefLayersInitilized() |
---|
| 1504 | { |
---|
| 1505 | Bool allRefLayersInitilizedFlag = true; |
---|
| 1506 | TComVPS* vps = m_parameterSetManagerDecoder.getPrefetchedVPS( 0 ); |
---|
| 1507 | for (Int i = 0; i < vps->getNumDirectRefLayers( getLayerId() ); i++ ) |
---|
| 1508 | { |
---|
| 1509 | Int refLayerId = vps->getRefLayerId( m_layerId, i ); |
---|
| 1510 | allRefLayersInitilizedFlag = allRefLayersInitilizedFlag && m_layerInitilizedFlag[ refLayerId ]; |
---|
| 1511 | } |
---|
| 1512 | |
---|
| 1513 | return allRefLayersInitilizedFlag; |
---|
| 1514 | } |
---|
[608] | 1515 | #endif |
---|
[738] | 1516 | #endif |
---|
[56] | 1517 | //! \} |
---|