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