[5] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
[1200] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[1200] | 6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
---|
[5] | 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
| 33 | |
---|
[2] | 34 | /** \file TDecTop.cpp |
---|
| 35 | \brief decoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
[56] | 38 | #include "NALread.h" |
---|
[2] | 39 | #include "TDecTop.h" |
---|
[1200] | 40 | #if NH_MV |
---|
| 41 | ParameterSetManager TDecTop::m_parameterSetManager; |
---|
| 42 | #endif |
---|
[2] | 43 | |
---|
[56] | 44 | //! \ingroup TLibDecoder |
---|
| 45 | //! \{ |
---|
[2] | 46 | |
---|
[1200] | 47 | #if NH_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 ); |
---|
[1179] | 78 | xDeleteArray( m_receivedIdc, m_vps->getNumViews() ); |
---|
[2] | 79 | } |
---|
| 80 | |
---|
[872] | 81 | |
---|
[2] | 82 | Void |
---|
[1200] | 83 | CamParsCollector::init( const TComVPS* vps) |
---|
[872] | 84 | { |
---|
| 85 | assert( !isInitialized() ); // Only one initialization currently supported |
---|
| 86 | m_bInitialized = true; |
---|
| 87 | m_vps = vps; |
---|
[1200] | 88 | m_bCamParsVaryOverTime = false; |
---|
[872] | 89 | m_lastPoc = -1; |
---|
| 90 | m_firstReceivedPoc = -2; |
---|
| 91 | |
---|
[1179] | 92 | for (Int i = 0; i <= vps->getMaxLayersMinus1(); i++) |
---|
| 93 | { |
---|
| 94 | Int curViewIdxInVps = m_vps->getVoiInVps( m_vps->getViewIndex( m_vps->getLayerIdInNuh( i ) ) ) ; |
---|
| 95 | m_bCamParsVaryOverTime = m_bCamParsVaryOverTime || vps->getCpInSliceSegmentHeaderFlag( curViewIdxInVps ); |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | assert( m_receivedIdc == NULL ); |
---|
| 99 | m_receivedIdc = new Int*[ m_vps->getNumViews() ]; |
---|
| 100 | for (Int i = 0; i < m_vps->getNumViews(); i++) |
---|
| 101 | { |
---|
| 102 | m_receivedIdc[i] = new Int[ m_vps->getNumViews() ]; |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | xResetReceivedIdc( true ); |
---|
| 106 | |
---|
| 107 | for (Int voiInVps = 0; voiInVps < m_vps->getNumViews(); voiInVps++ ) |
---|
| 108 | { |
---|
| 109 | if( !m_vps->getCpInSliceSegmentHeaderFlag( voiInVps ) ) |
---|
| 110 | { |
---|
| 111 | for (Int baseVoiInVps = 0; baseVoiInVps < m_vps->getNumViews(); baseVoiInVps++ ) |
---|
| 112 | { |
---|
| 113 | if( m_vps->getCpPresentFlag( voiInVps, baseVoiInVps ) ) |
---|
| 114 | { |
---|
| 115 | m_receivedIdc [ baseVoiInVps ][ voiInVps ] = -1; |
---|
| 116 | m_aaiCodedScale [ baseVoiInVps ][ voiInVps ] = m_vps->getCodedScale (voiInVps) [ baseVoiInVps ]; |
---|
| 117 | m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ] = m_vps->getCodedOffset (voiInVps) [ baseVoiInVps ]; |
---|
| 118 | |
---|
| 119 | m_receivedIdc [ voiInVps ][ baseVoiInVps ] = -1; |
---|
| 120 | m_aaiCodedScale [ voiInVps ][ baseVoiInVps ] = m_vps->getInvCodedScale (voiInVps) [ baseVoiInVps ]; |
---|
| 121 | m_aaiCodedOffset[ voiInVps ][ baseVoiInVps ] = m_vps->getInvCodedOffset(voiInVps) [ baseVoiInVps ]; |
---|
| 122 | xInitLUTs( baseVoiInVps, voiInVps, m_aaiCodedScale[ baseVoiInVps ][ voiInVps ], m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT ); |
---|
| 123 | xInitLUTs( voiInVps, baseVoiInVps, m_aaiCodedScale[ voiInVps ][ baseVoiInVps ], m_aaiCodedOffset[ voiInVps ][ baseVoiInVps ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT ); |
---|
| 124 | } |
---|
| 125 | } |
---|
| 126 | } |
---|
| 127 | } |
---|
| 128 | } |
---|
| 129 | |
---|
[872] | 130 | |
---|
| 131 | |
---|
| 132 | |
---|
| 133 | Void |
---|
| 134 | CamParsCollector::xResetReceivedIdc( Bool overWriteFlag ) |
---|
| 135 | { |
---|
[1179] | 136 | for (Int i = 0; i < m_vps->getNumViews(); i++) |
---|
| 137 | { |
---|
| 138 | for (Int j = 0; j < m_vps->getNumViews(); j++) |
---|
| 139 | { |
---|
[872] | 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 | { |
---|
[1179] | 180 | Int iLog2DivLuma = m_uiBitDepthForLUT + m_vps->getCpPrecision() + 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 | |
---|
[1179] | 257 | UInt voiInVps = m_vps->getVoiInVps(pcSlice->getViewIndex()); |
---|
| 258 | if( m_vps->getCpInSliceSegmentHeaderFlag( voiInVps ) ) // check consistency of slice parameters here |
---|
| 259 | { |
---|
| 260 | for( Int baseVoiInVps = 0; baseVoiInVps < m_vps->getNumViews(); baseVoiInVps++ ) |
---|
| 261 | { |
---|
| 262 | if ( m_vps->getCpPresentFlag( voiInVps, baseVoiInVps ) ) |
---|
| 263 | { |
---|
| 264 | if ( m_receivedIdc[ voiInVps ][ baseVoiInVps ] != 0 ) |
---|
| 265 | { |
---|
| 266 | AOF( m_aaiCodedScale [ voiInVps ][ baseVoiInVps ] == pcSlice->getInvCodedScale () [ baseVoiInVps ] ); |
---|
| 267 | AOF( m_aaiCodedOffset[ voiInVps ][ baseVoiInVps ] == pcSlice->getInvCodedOffset() [ baseVoiInVps ] ); |
---|
| 268 | } |
---|
| 269 | else |
---|
| 270 | { |
---|
| 271 | m_receivedIdc [ voiInVps ][ baseVoiInVps ] = 1; |
---|
| 272 | m_aaiCodedScale [ voiInVps ][ baseVoiInVps ] = pcSlice->getInvCodedScale () [ baseVoiInVps ]; |
---|
| 273 | m_aaiCodedOffset[ voiInVps ][ baseVoiInVps ] = pcSlice->getInvCodedOffset() [ baseVoiInVps ]; |
---|
| 274 | xInitLUTs( voiInVps, baseVoiInVps, m_aaiCodedScale[ voiInVps ][ baseVoiInVps ], m_aaiCodedOffset[ voiInVps ][ baseVoiInVps ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT); |
---|
| 275 | } |
---|
| 276 | if ( m_receivedIdc[ baseVoiInVps ][ voiInVps ] != 0 ) |
---|
| 277 | { |
---|
| 278 | AOF( m_aaiCodedScale [ baseVoiInVps ][ voiInVps ] == pcSlice->getCodedScale () [ baseVoiInVps ] ); |
---|
| 279 | AOF( m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ] == pcSlice->getCodedOffset () [ baseVoiInVps ] ); |
---|
| 280 | } |
---|
| 281 | else |
---|
| 282 | { |
---|
| 283 | m_receivedIdc [ baseVoiInVps ][ voiInVps ] = 1; |
---|
| 284 | m_aaiCodedScale [ baseVoiInVps ][ voiInVps ] = pcSlice->getCodedScale () [ baseVoiInVps ]; |
---|
| 285 | m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ] = pcSlice->getCodedOffset () [ baseVoiInVps ]; |
---|
| 286 | xInitLUTs( baseVoiInVps, voiInVps, m_aaiCodedScale[ baseVoiInVps ][ voiInVps ], m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT); |
---|
| 287 | } |
---|
| 288 | } |
---|
| 289 | } |
---|
| 290 | } |
---|
[872] | 291 | } |
---|
| 292 | |
---|
| 293 | |
---|
[1279] | 294 | #if NH_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 | { |
---|
[1179] | 313 | fprintf( m_pCodedScaleOffsetFile, "#ViewOrderIdx ViewIdVal\n" ); |
---|
| 314 | fprintf( m_pCodedScaleOffsetFile, "#------------ -------------\n" ); |
---|
| 315 | |
---|
| 316 | for( UInt voiInVps = 0; voiInVps < m_vps->getNumViews(); voiInVps++ ) |
---|
| 317 | { |
---|
| 318 | fprintf( m_pCodedScaleOffsetFile, "%13d %13d\n", m_vps->getViewOIdxList( voiInVps ), m_vps->getViewIdVal( m_vps->getViewOIdxList( voiInVps ) ) ); |
---|
| 319 | } |
---|
| 320 | fprintf( m_pCodedScaleOffsetFile, "\n\n"); |
---|
| 321 | fprintf( m_pCodedScaleOffsetFile, "# StartFrame EndFrame TargetVOI BaseVOI CodedScale CodedOffset Precision\n" ); |
---|
| 322 | fprintf( m_pCodedScaleOffsetFile, "#----------- ------------ ------------ ------------ ------------ ------------ ------------\n" ); |
---|
| 323 | } |
---|
| 324 | if( iPOC == m_firstReceivedPoc || m_bCamParsVaryOverTime ) |
---|
| 325 | { |
---|
| 326 | Int iS = iPOC; |
---|
| 327 | Int iE = ( m_bCamParsVaryOverTime ? iPOC : ~( 1 << 31 ) ); |
---|
| 328 | for( UInt voiInVps = 0; voiInVps < m_vps->getNumViews(); voiInVps++ ) |
---|
| 329 | { |
---|
| 330 | for( UInt baseVoiInVps = 0; baseVoiInVps < m_vps->getNumViews(); baseVoiInVps++ ) |
---|
| 331 | { |
---|
| 332 | if( voiInVps != baseVoiInVps ) |
---|
| 333 | { |
---|
| 334 | if ( m_receivedIdc[baseVoiInVps][voiInVps] != 0 ) |
---|
| 335 | { |
---|
| 336 | fprintf( m_pCodedScaleOffsetFile, "%12d %12d %12d %12d %12d %12d %12d\n", |
---|
| 337 | iS, iE, m_vps->getViewOIdxList( voiInVps ), m_vps->getViewOIdxList( baseVoiInVps ), |
---|
| 338 | m_aaiCodedScale [ baseVoiInVps ][ voiInVps ], |
---|
| 339 | m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ], m_vps->getCpPrecision() ); |
---|
[872] | 340 | } |
---|
[2] | 341 | } |
---|
| 342 | } |
---|
| 343 | } |
---|
| 344 | } |
---|
| 345 | } |
---|
| 346 | } |
---|
[608] | 347 | #endif |
---|
[1196] | 348 | |
---|
[1200] | 349 | |
---|
[2] | 350 | TDecTop::TDecTop() |
---|
[1200] | 351 | : m_iMaxRefPicNum(0) |
---|
| 352 | , m_associatedIRAPType(NAL_UNIT_INVALID) |
---|
| 353 | , m_pocCRA(0) |
---|
| 354 | , m_pocRandomAccess(MAX_INT) |
---|
| 355 | , m_cListPic() |
---|
| 356 | #if !NH_MV |
---|
| 357 | , m_parameterSetManager() |
---|
| 358 | #endif |
---|
| 359 | , m_apcSlicePilot(NULL) |
---|
| 360 | , m_SEIs() |
---|
| 361 | , m_cPrediction() |
---|
| 362 | , m_cTrQuant() |
---|
| 363 | , m_cGopDecoder() |
---|
| 364 | , m_cSliceDecoder() |
---|
| 365 | , m_cCuDecoder() |
---|
| 366 | , m_cEntropyDecoder() |
---|
| 367 | , m_cCavlcDecoder() |
---|
| 368 | , m_cSbacDecoder() |
---|
| 369 | , m_cBinCABAC() |
---|
| 370 | , m_seiReader() |
---|
| 371 | , m_cLoopFilter() |
---|
| 372 | , m_cSAO() |
---|
| 373 | , m_pcPic(NULL) |
---|
| 374 | , m_prevPOC(MAX_INT) |
---|
| 375 | , m_prevTid0POC(0) |
---|
| 376 | , m_bFirstSliceInPicture(true) |
---|
| 377 | , m_bFirstSliceInSequence(true) |
---|
| 378 | , m_prevSliceSkipped(false) |
---|
| 379 | , m_skippedPOC(0) |
---|
| 380 | , m_bFirstSliceInBitstream(true) |
---|
| 381 | , m_lastPOCNoOutputPriorPics(-1) |
---|
| 382 | , m_isNoOutputPriorPics(false) |
---|
| 383 | , m_craNoRaslOutputFlag(false) |
---|
| 384 | #if O0043_BEST_EFFORT_DECODING |
---|
| 385 | , m_forceDecodeBitDepth(8) |
---|
| 386 | #endif |
---|
| 387 | , m_pDecodedSEIOutputStream(NULL) |
---|
| 388 | , m_warningMessageSkipPicture(false) |
---|
| 389 | , m_prefixSEINALUs() |
---|
[2] | 390 | { |
---|
| 391 | #if ENC_DEC_TRACE |
---|
[1200] | 392 | #if NH_MV |
---|
[608] | 393 | if ( g_hTrace == NULL ) |
---|
| 394 | { |
---|
| 395 | #endif |
---|
[1200] | 396 | if (g_hTrace == NULL) |
---|
| 397 | { |
---|
| 398 | g_hTrace = fopen( "TraceDec.txt", "wb" ); |
---|
| 399 | } |
---|
[2] | 400 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
| 401 | g_nSymbolCounter = 0; |
---|
[1200] | 402 | #if NH_MV |
---|
[608] | 403 | } |
---|
[2] | 404 | #endif |
---|
[608] | 405 | #endif |
---|
[1200] | 406 | #if NH_MV |
---|
[964] | 407 | m_isLastNALWasEos = false; |
---|
[608] | 408 | m_layerId = 0; |
---|
| 409 | m_viewId = 0; |
---|
[1200] | 410 | #if NH_3D |
---|
[608] | 411 | m_viewIndex = 0; |
---|
| 412 | m_isDepth = false; |
---|
[57] | 413 | m_pcCamParsCollector = 0; |
---|
[210] | 414 | #endif |
---|
[1200] | 415 | #if NH_MV |
---|
| 416 | m_targetOlsIdx = -1; |
---|
[608] | 417 | #endif |
---|
[964] | 418 | #endif |
---|
[1200] | 419 | |
---|
[2] | 420 | } |
---|
| 421 | |
---|
| 422 | TDecTop::~TDecTop() |
---|
| 423 | { |
---|
| 424 | #if ENC_DEC_TRACE |
---|
[1279] | 425 | #if H_MV_ENC_DEC_TRAC_FIX |
---|
| 426 | if (g_hTrace != stdout && g_hTrace != NULL) |
---|
| 427 | #else |
---|
[1200] | 428 | if (g_hTrace != stdout) |
---|
[1279] | 429 | #endif |
---|
[1200] | 430 | { |
---|
| 431 | fclose( g_hTrace ); |
---|
[1279] | 432 | #if H_MV_ENC_DEC_TRAC_FIX |
---|
| 433 | g_hTrace = NULL; |
---|
| 434 | #endif |
---|
[1200] | 435 | } |
---|
[2] | 436 | #endif |
---|
[1200] | 437 | while (!m_prefixSEINALUs.empty()) |
---|
| 438 | { |
---|
| 439 | delete m_prefixSEINALUs.front(); |
---|
| 440 | m_prefixSEINALUs.pop_front(); |
---|
| 441 | } |
---|
[2] | 442 | } |
---|
| 443 | |
---|
| 444 | Void TDecTop::create() |
---|
| 445 | { |
---|
| 446 | m_cGopDecoder.create(); |
---|
| 447 | m_apcSlicePilot = new TComSlice; |
---|
[608] | 448 | m_uiSliceIdx = 0; |
---|
[2] | 449 | } |
---|
| 450 | |
---|
| 451 | Void TDecTop::destroy() |
---|
| 452 | { |
---|
| 453 | m_cGopDecoder.destroy(); |
---|
[1200] | 454 | |
---|
[2] | 455 | delete m_apcSlicePilot; |
---|
| 456 | m_apcSlicePilot = NULL; |
---|
[1200] | 457 | |
---|
[2] | 458 | m_cSliceDecoder.destroy(); |
---|
| 459 | } |
---|
| 460 | |
---|
[608] | 461 | Void TDecTop::init() |
---|
[2] | 462 | { |
---|
| 463 | // initialize ROM |
---|
[1200] | 464 | #if !NH_MV |
---|
[56] | 465 | initROM(); |
---|
[5] | 466 | #endif |
---|
[1200] | 467 | #if NH_MV |
---|
[1179] | 468 | m_cCavlcDecoder.setDecTop( this ); |
---|
| 469 | #endif |
---|
[1200] | 470 | m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO); |
---|
[2] | 471 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder ); |
---|
| 472 | m_cEntropyDecoder.init(&m_cPrediction); |
---|
| 473 | } |
---|
| 474 | |
---|
| 475 | Void TDecTop::deletePicBuffer ( ) |
---|
| 476 | { |
---|
| 477 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 478 | Int iSize = Int( m_cListPic.size() ); |
---|
[1200] | 479 | |
---|
[2] | 480 | for (Int i = 0; i < iSize; i++ ) |
---|
| 481 | { |
---|
[608] | 482 | TComPic* pcPic = *(iterPic++); |
---|
[1200] | 483 | #if NH_MV |
---|
[608] | 484 | if( pcPic ) |
---|
[56] | 485 | { |
---|
[608] | 486 | #endif |
---|
| 487 | pcPic->destroy(); |
---|
[1200] | 488 | |
---|
[608] | 489 | delete pcPic; |
---|
| 490 | pcPic = NULL; |
---|
[1200] | 491 | #if NH_MV |
---|
[56] | 492 | } |
---|
[608] | 493 | #endif |
---|
[2] | 494 | } |
---|
[1200] | 495 | |
---|
[2] | 496 | m_cSAO.destroy(); |
---|
[1200] | 497 | |
---|
[2] | 498 | m_cLoopFilter. destroy(); |
---|
[1200] | 499 | |
---|
| 500 | #if !NH_MV |
---|
[2] | 501 | // destroy ROM |
---|
[608] | 502 | destroyROM(); |
---|
| 503 | #endif |
---|
[2] | 504 | } |
---|
| 505 | |
---|
[1200] | 506 | Void TDecTop::xGetNewPicBuffer ( const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer ) |
---|
[56] | 507 | { |
---|
[1200] | 508 | #if NH_MV |
---|
[872] | 509 | if ( getLayerId() == 0 ) |
---|
| 510 | { |
---|
[1200] | 511 | m_iMaxRefPicNum = sps.getMaxDecPicBuffering(temporalLayer); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
[872] | 512 | } |
---|
| 513 | else |
---|
| 514 | { |
---|
[1200] | 515 | //GTCIC |
---|
| 516 | //m_iMaxRefPicNum = pcSlice->getVPS()->getMaxDecPicBuffering(pcSlice->getTLayer()); |
---|
| 517 | #if H_MV_HLS7_GEN |
---|
[872] | 518 | TComVPS* vps = pcSlice->getVPS(); |
---|
| 519 | TComDpbSize* dpbSize = vps->getDpbSize(); |
---|
[964] | 520 | Int lsIdx = vps->olsIdxToLsIdx( getTargetOutputLayerSetIdx()); // Is this correct, seems to be missing in spec? |
---|
[872] | 521 | Int layerIdx = vps->getIdxInLayerSet ( lsIdx, getLayerId() ); |
---|
| 522 | Int subDpbIdx = dpbSize->getSubDpbAssigned( lsIdx, layerIdx ); |
---|
| 523 | m_iMaxRefPicNum = dpbSize->getMaxVpsDecPicBufferingMinus1(getTargetOutputLayerSetIdx(), subDpbIdx , vps->getSubLayersVpsMaxMinus1( vps->getLayerIdInVps( getLayerId() ) ) + 1 ) + 1 ; |
---|
| 524 | #endif |
---|
| 525 | } |
---|
| 526 | #else |
---|
[1200] | 527 | m_iMaxRefPicNum = sps.getMaxDecPicBuffering(temporalLayer); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
[872] | 528 | #endif |
---|
[2] | 529 | if (m_cListPic.size() < (UInt)m_iMaxRefPicNum) |
---|
| 530 | { |
---|
[56] | 531 | rpcPic = new TComPic(); |
---|
[1200] | 532 | |
---|
| 533 | rpcPic->create ( sps, pps, true); |
---|
| 534 | |
---|
[2] | 535 | m_cListPic.pushBack( rpcPic ); |
---|
[1200] | 536 | |
---|
[2] | 537 | return; |
---|
| 538 | } |
---|
[1200] | 539 | |
---|
[2] | 540 | Bool bBufferIsAvailable = false; |
---|
| 541 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 542 | while (iterPic != m_cListPic.end()) |
---|
| 543 | { |
---|
| 544 | rpcPic = *(iterPic++); |
---|
[56] | 545 | if ( rpcPic->getReconMark() == false && rpcPic->getOutputMark() == false) |
---|
[2] | 546 | { |
---|
[56] | 547 | rpcPic->setOutputMark(false); |
---|
[1200] | 548 | #if NH_MV |
---|
[964] | 549 | rpcPic->setPicOutputFlag(false); |
---|
| 550 | #endif |
---|
[2] | 551 | bBufferIsAvailable = true; |
---|
| 552 | break; |
---|
| 553 | } |
---|
[56] | 554 | |
---|
| 555 | if ( rpcPic->getSlice( 0 )->isReferenced() == false && rpcPic->getOutputMark() == false) |
---|
| 556 | { |
---|
| 557 | rpcPic->setOutputMark(false); |
---|
[1200] | 558 | #if NH_MV |
---|
[964] | 559 | rpcPic->setPicOutputFlag(false); |
---|
| 560 | #endif |
---|
[56] | 561 | rpcPic->setReconMark( false ); |
---|
| 562 | rpcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
| 563 | bBufferIsAvailable = true; |
---|
| 564 | break; |
---|
| 565 | } |
---|
[2] | 566 | } |
---|
[1200] | 567 | |
---|
[2] | 568 | if ( !bBufferIsAvailable ) |
---|
| 569 | { |
---|
[56] | 570 | //There is no room for this picture, either because of faulty encoder or dropped NAL. Extend the buffer. |
---|
| 571 | m_iMaxRefPicNum++; |
---|
| 572 | rpcPic = new TComPic(); |
---|
| 573 | m_cListPic.pushBack( rpcPic ); |
---|
[2] | 574 | } |
---|
[608] | 575 | rpcPic->destroy(); |
---|
[1200] | 576 | rpcPic->create ( sps, pps, true); |
---|
[2] | 577 | } |
---|
[1200] | 578 | #if NH_MV |
---|
[608] | 579 | Void TDecTop::endPicDecoding(Int& poc, TComList<TComPic*>*& rpcListPic, std::vector<Int>& targetDecLayerIdSet ) |
---|
| 580 | #else |
---|
| 581 | Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic) |
---|
| 582 | #endif |
---|
[56] | 583 | { |
---|
| 584 | if (!m_pcPic) |
---|
| 585 | { |
---|
| 586 | /* nothing to deblock */ |
---|
| 587 | return; |
---|
| 588 | } |
---|
[2] | 589 | |
---|
[1200] | 590 | TComPic* pcPic = m_pcPic; |
---|
| 591 | |
---|
[608] | 592 | // Execute Deblock + Cleanup |
---|
[56] | 593 | |
---|
[608] | 594 | m_cGopDecoder.filterPicture(pcPic); |
---|
[56] | 595 | |
---|
| 596 | TComSlice::sortPicList( m_cListPic ); // sorting for application output |
---|
[608] | 597 | poc = pcPic->getSlice(m_uiSliceIdx-1)->getPOC(); |
---|
[1200] | 598 | rpcListPic = &m_cListPic; |
---|
| 599 | m_cCuDecoder.destroy(); |
---|
| 600 | #if NH_MV |
---|
[622] | 601 | TComSlice::markIvRefPicsAsShortTerm( m_refPicSetInterLayer0, m_refPicSetInterLayer1 ); |
---|
[608] | 602 | TComSlice::markCurrPic( pcPic ); |
---|
| 603 | #endif |
---|
[56] | 604 | m_bFirstSliceInPicture = true; |
---|
| 605 | |
---|
| 606 | return; |
---|
| 607 | } |
---|
| 608 | |
---|
[1200] | 609 | Void TDecTop::checkNoOutputPriorPics (TComList<TComPic*>* pcListPic) |
---|
[964] | 610 | { |
---|
[1200] | 611 | if (!pcListPic || !m_isNoOutputPriorPics) |
---|
| 612 | { |
---|
| 613 | return; |
---|
| 614 | } |
---|
[964] | 615 | |
---|
[1200] | 616 | TComList<TComPic*>::iterator iterPic = pcListPic->begin(); |
---|
[964] | 617 | |
---|
[1200] | 618 | while (iterPic != pcListPic->end()) |
---|
[964] | 619 | { |
---|
[1200] | 620 | TComPic* pcPicTmp = *(iterPic++); |
---|
[964] | 621 | if (m_lastPOCNoOutputPriorPics != pcPicTmp->getPOC()) |
---|
| 622 | { |
---|
| 623 | pcPicTmp->setOutputMark(false); |
---|
[1200] | 624 | #if NH_MV |
---|
[964] | 625 | pcPicTmp->setPicOutputFlag(false); |
---|
| 626 | #endif |
---|
| 627 | } |
---|
| 628 | } |
---|
| 629 | } |
---|
| 630 | |
---|
[1200] | 631 | Void TDecTop::xCreateLostPicture(Int iLostPoc) |
---|
[2] | 632 | { |
---|
[56] | 633 | printf("\ninserting lost poc : %d\n",iLostPoc); |
---|
| 634 | TComPic *cFillPic; |
---|
[1200] | 635 | xGetNewPicBuffer(*(m_parameterSetManager.getFirstSPS()), *(m_parameterSetManager.getFirstPPS()), cFillPic, 0); |
---|
[56] | 636 | cFillPic->getSlice(0)->initSlice(); |
---|
[1200] | 637 | |
---|
[56] | 638 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 639 | Int closestPoc = 1000000; |
---|
| 640 | while ( iterPic != m_cListPic.end()) |
---|
[2] | 641 | { |
---|
[56] | 642 | TComPic * rpcPic = *(iterPic++); |
---|
| 643 | 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] | 644 | { |
---|
[56] | 645 | closestPoc=abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc); |
---|
| 646 | } |
---|
| 647 | } |
---|
| 648 | iterPic = m_cListPic.begin(); |
---|
| 649 | while ( iterPic != m_cListPic.end()) |
---|
| 650 | { |
---|
| 651 | TComPic *rpcPic = *(iterPic++); |
---|
| 652 | if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)==closestPoc&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC()) |
---|
| 653 | { |
---|
| 654 | printf("copying picture %d to %d (%d)\n",rpcPic->getPicSym()->getSlice(0)->getPOC() ,iLostPoc,m_apcSlicePilot->getPOC()); |
---|
| 655 | rpcPic->getPicYuvRec()->copyToPic(cFillPic->getPicYuvRec()); |
---|
[2] | 656 | break; |
---|
| 657 | } |
---|
| 658 | } |
---|
[56] | 659 | cFillPic->setCurrSliceIdx(0); |
---|
[1200] | 660 | for(Int ctuRsAddr=0; ctuRsAddr<cFillPic->getNumberOfCtusInFrame(); ctuRsAddr++) |
---|
[2] | 661 | { |
---|
[1200] | 662 | cFillPic->getCtu(ctuRsAddr)->initCtu(cFillPic, ctuRsAddr); |
---|
[2] | 663 | } |
---|
[56] | 664 | cFillPic->getSlice(0)->setReferenced(true); |
---|
| 665 | cFillPic->getSlice(0)->setPOC(iLostPoc); |
---|
[1200] | 666 | xUpdatePreviousTid0POC(cFillPic->getSlice(0)); |
---|
[56] | 667 | cFillPic->setReconMark(true); |
---|
| 668 | cFillPic->setOutputMark(true); |
---|
| 669 | if(m_pocRandomAccess == MAX_INT) |
---|
| 670 | { |
---|
| 671 | m_pocRandomAccess = iLostPoc; |
---|
| 672 | } |
---|
[2] | 673 | } |
---|
| 674 | |
---|
[56] | 675 | |
---|
| 676 | Void TDecTop::xActivateParameterSets() |
---|
[2] | 677 | { |
---|
[1200] | 678 | if (m_bFirstSliceInPicture) |
---|
| 679 | { |
---|
| 680 | const TComPPS *pps = m_parameterSetManager.getPPS(m_apcSlicePilot->getPPSId()); // this is a temporary PPS object. Do not store this value |
---|
| 681 | assert (pps != 0); |
---|
[56] | 682 | |
---|
[1200] | 683 | const TComSPS *sps = m_parameterSetManager.getSPS(pps->getSPSId()); // this is a temporary SPS object. Do not store this value |
---|
| 684 | assert (sps != 0); |
---|
[608] | 685 | |
---|
[1200] | 686 | m_parameterSetManager.clearSPSChangedFlag(sps->getSPSId()); |
---|
| 687 | m_parameterSetManager.clearPPSChangedFlag(pps->getPPSId()); |
---|
| 688 | #if NH_MV |
---|
| 689 | const TComVPS* vps = m_parameterSetManager.getVPS(sps->getVPSId()); |
---|
| 690 | assert (vps != 0); |
---|
| 691 | if (!m_parameterSetManager.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP(), m_layerId ) ) |
---|
[622] | 692 | #else |
---|
[1200] | 693 | if (false == m_parameterSetManager.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP())) |
---|
[622] | 694 | #endif |
---|
[1200] | 695 | { |
---|
| 696 | printf ("Parameter set activation failed!"); |
---|
| 697 | assert (0); |
---|
| 698 | } |
---|
[608] | 699 | |
---|
[1200] | 700 | #if NH_MV |
---|
[964] | 701 | // When the value of vps_num_rep_formats_minus1 in the active VPS is equal to 0 |
---|
| 702 | if ( vps->getVpsNumRepFormatsMinus1() == 0 ) |
---|
| 703 | { |
---|
| 704 | //, it is a requirement of bitstream conformance that the value of update_rep_format_flag shall be equal to 0. |
---|
| 705 | assert( sps->getUpdateRepFormatFlag() == false ); |
---|
| 706 | } |
---|
| 707 | sps->checkRpsMaxNumPics( vps, getLayerId() ); |
---|
[1066] | 708 | |
---|
| 709 | // It is a requirement of bitstream conformance that, when the SPS is referred to by |
---|
| 710 | // any current picture that belongs to an independent non-base layer, the value of |
---|
| 711 | // MultiLayerExtSpsFlag derived from the SPS shall be equal to 0. |
---|
| 712 | |
---|
| 713 | if ( m_layerId > 0 && vps->getNumRefLayers( m_layerId ) == 0 ) |
---|
| 714 | { |
---|
| 715 | assert( sps->getMultiLayerExtSpsFlag() == 0 ); |
---|
| 716 | } |
---|
[1200] | 717 | #endif |
---|
[1066] | 718 | |
---|
[1200] | 719 | xParsePrefixSEImessages(); |
---|
| 720 | |
---|
| 721 | #if RExt__HIGH_BIT_DEPTH_SUPPORT==0 |
---|
| 722 | if (sps->getSpsRangeExtension().getExtendedPrecisionProcessingFlag() || sps->getBitDepth(CHANNEL_TYPE_LUMA)>12 || sps->getBitDepth(CHANNEL_TYPE_CHROMA)>12 ) |
---|
| 723 | { |
---|
| 724 | printf("High bit depth support must be enabled at compile-time in order to decode this bitstream\n"); |
---|
| 725 | assert (0); |
---|
| 726 | exit(1); |
---|
| 727 | } |
---|
[964] | 728 | #endif |
---|
| 729 | |
---|
[1200] | 730 | // NOTE: globals were set up here originally. You can now use: |
---|
| 731 | // g_uiMaxCUDepth = sps->getMaxTotalCUDepth(); |
---|
| 732 | // g_uiAddCUDepth = sps->getMaxTotalCUDepth() - sps->getLog2DiffMaxMinCodingBlockSize() |
---|
[608] | 733 | |
---|
[1200] | 734 | // Get a new picture buffer. This will also set up m_pcPic, and therefore give us a SPS and PPS pointer that we can use. |
---|
| 735 | xGetNewPicBuffer (*(sps), *(pps), m_pcPic, m_apcSlicePilot->getTLayer()); |
---|
| 736 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
---|
| 737 | #if NH_MV |
---|
| 738 | m_apcSlicePilot->createInterLayerReferencePictureSet( m_ivPicLists, m_refPicSetInterLayer0, m_refPicSetInterLayer1 ); |
---|
| 739 | #endif |
---|
| 740 | |
---|
| 741 | // make the slice-pilot a real slice, and set up the slice-pilot for the next slice |
---|
| 742 | assert(m_pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
| 743 | m_apcSlicePilot = m_pcPic->getPicSym()->swapSliceObject(m_apcSlicePilot, m_uiSliceIdx); |
---|
| 744 | |
---|
| 745 | // we now have a real slice: |
---|
| 746 | TComSlice *pSlice = m_pcPic->getSlice(m_uiSliceIdx); |
---|
| 747 | |
---|
| 748 | // Update the PPS and SPS pointers with the ones of the picture. |
---|
| 749 | pps=pSlice->getPPS(); |
---|
| 750 | sps=pSlice->getSPS(); |
---|
| 751 | |
---|
| 752 | #if NH_MV |
---|
| 753 | vps=pSlice->getVPS(); |
---|
| 754 | // 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. |
---|
| 755 | assert( pps->getLayerId() == m_layerId || pps->getLayerId( ) == 0 || vps->getDependencyFlag( m_layerId, pps->getLayerId() ) ); |
---|
| 756 | // 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. |
---|
| 757 | assert( sps->getLayerId() == m_layerId || sps->getLayerId( ) == 0 || vps->getDependencyFlag( m_layerId, sps->getLayerId() ) ); |
---|
| 758 | #endif |
---|
| 759 | |
---|
| 760 | #if NH_3D |
---|
| 761 | if ( !m_pcCamParsCollector->isInitialized() ) |
---|
[608] | 762 | { |
---|
[1200] | 763 | m_pcCamParsCollector->init( vps ); |
---|
| 764 | } |
---|
| 765 | #endif |
---|
| 766 | // Initialise the various objects for the new set of settings |
---|
| 767 | m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxTotalCUDepth(), pps->getPpsRangeExtension().getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA), pps->getPpsRangeExtension().getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA) ); |
---|
| 768 | m_cLoopFilter.create( sps->getMaxTotalCUDepth() ); |
---|
| 769 | m_cPrediction.initTempBuff(sps->getChromaFormatIdc()); |
---|
| 770 | |
---|
| 771 | |
---|
| 772 | Bool isField = false; |
---|
| 773 | Bool isTopField = false; |
---|
| 774 | |
---|
| 775 | if(!m_SEIs.empty()) |
---|
| 776 | { |
---|
| 777 | // Check if any new Picture Timing SEI has arrived |
---|
| 778 | SEIMessages pictureTimingSEIs = getSeisByType(m_SEIs, SEI::PICTURE_TIMING); |
---|
| 779 | if (pictureTimingSEIs.size()>0) |
---|
[608] | 780 | { |
---|
[1200] | 781 | SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin()); |
---|
| 782 | isField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 2) || (pictureTiming->m_picStruct == 9) || (pictureTiming->m_picStruct == 10) || (pictureTiming->m_picStruct == 11) || (pictureTiming->m_picStruct == 12); |
---|
| 783 | isTopField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 9) || (pictureTiming->m_picStruct == 11); |
---|
[608] | 784 | } |
---|
| 785 | } |
---|
[1200] | 786 | |
---|
| 787 | //Set Field/Frame coding mode |
---|
| 788 | m_pcPic->setField(isField); |
---|
| 789 | m_pcPic->setTopField(isTopField); |
---|
| 790 | |
---|
| 791 | // transfer any SEI messages that have been received to the picture |
---|
| 792 | m_pcPic->setSEIs(m_SEIs); |
---|
| 793 | m_SEIs.clear(); |
---|
| 794 | |
---|
| 795 | // Recursive structure |
---|
| 796 | m_cCuDecoder.create ( sps->getMaxTotalCUDepth(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getChromaFormatIdc() ); |
---|
| 797 | m_cCuDecoder.init ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction ); |
---|
| 798 | m_cTrQuant.init ( sps->getMaxTrSize() ); |
---|
| 799 | |
---|
| 800 | m_cSliceDecoder.create(); |
---|
[608] | 801 | } |
---|
[1200] | 802 | else |
---|
| 803 | { |
---|
| 804 | // make the slice-pilot a real slice, and set up the slice-pilot for the next slice |
---|
| 805 | m_pcPic->allocateNewSlice(); |
---|
| 806 | assert(m_pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
| 807 | m_apcSlicePilot = m_pcPic->getPicSym()->swapSliceObject(m_apcSlicePilot, m_uiSliceIdx); |
---|
[608] | 808 | |
---|
[1200] | 809 | TComSlice *pSlice = m_pcPic->getSlice(m_uiSliceIdx); // we now have a real slice. |
---|
[1066] | 810 | |
---|
[1200] | 811 | const TComSPS *sps = pSlice->getSPS(); |
---|
| 812 | const TComPPS *pps = pSlice->getPPS(); |
---|
[56] | 813 | |
---|
[1200] | 814 | // check that the current active PPS has not changed... |
---|
| 815 | if (m_parameterSetManager.getSPSChangedFlag(sps->getSPSId()) ) |
---|
| 816 | { |
---|
| 817 | printf("Error - a new SPS has been decoded while processing a picture\n"); |
---|
| 818 | exit(1); |
---|
| 819 | } |
---|
| 820 | if (m_parameterSetManager.getPPSChangedFlag(pps->getPPSId()) ) |
---|
| 821 | { |
---|
| 822 | printf("Error - a new PPS has been decoded while processing a picture\n"); |
---|
| 823 | exit(1); |
---|
| 824 | } |
---|
[608] | 825 | |
---|
[1200] | 826 | xParsePrefixSEImessages(); |
---|
| 827 | |
---|
| 828 | // Check if any new SEI has arrived |
---|
| 829 | if(!m_SEIs.empty()) |
---|
| 830 | { |
---|
| 831 | // Currently only decoding Unit SEI message occurring between VCL NALUs copied |
---|
| 832 | SEIMessages &picSEI = m_pcPic->getSEIs(); |
---|
| 833 | SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO); |
---|
| 834 | picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end()); |
---|
| 835 | deleteSEIs(m_SEIs); |
---|
| 836 | } |
---|
| 837 | } |
---|
| 838 | } |
---|
| 839 | Void TDecTop::xParsePrefixSEIsForUnknownVCLNal() |
---|
| 840 | { |
---|
| 841 | while (!m_prefixSEINALUs.empty()) |
---|
[2] | 842 | { |
---|
[1200] | 843 | // do nothing? |
---|
| 844 | printf("Discarding Prefix SEI associated with unknown VCL NAL unit.\n"); |
---|
| 845 | delete m_prefixSEINALUs.front(); |
---|
[2] | 846 | } |
---|
[1200] | 847 | // TODO: discard following suffix SEIs as well? |
---|
| 848 | } |
---|
[56] | 849 | |
---|
[1200] | 850 | |
---|
| 851 | Void TDecTop::xParsePrefixSEImessages() |
---|
| 852 | { |
---|
| 853 | while (!m_prefixSEINALUs.empty()) |
---|
[56] | 854 | { |
---|
[1200] | 855 | InputNALUnit &nalu=*m_prefixSEINALUs.front(); |
---|
| 856 | #if NH_MV |
---|
| 857 | m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_SEIs, nalu.m_nalUnitType, m_parameterSetManager.getActiveSPS( getLayerId() ), m_pDecodedSEIOutputStream ); |
---|
| 858 | #else |
---|
| 859 | m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_SEIs, nalu.m_nalUnitType, m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream ); |
---|
| 860 | #endif |
---|
| 861 | delete m_prefixSEINALUs.front(); |
---|
| 862 | m_prefixSEINALUs.pop_front(); |
---|
[56] | 863 | } |
---|
[2] | 864 | } |
---|
[56] | 865 | |
---|
[1200] | 866 | |
---|
| 867 | #if NH_MV |
---|
[738] | 868 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag ) |
---|
[608] | 869 | { |
---|
[1200] | 870 | assert( nalu.m_nuhLayerId == m_layerId ); |
---|
[608] | 871 | #else |
---|
[56] | 872 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay ) |
---|
[2] | 873 | { |
---|
[608] | 874 | #endif |
---|
[1200] | 875 | m_apcSlicePilot->initSlice(); // the slice pilot is an object to prepare for a new slice |
---|
| 876 | // it is not associated with picture, sps or pps structures. |
---|
[2] | 877 | |
---|
[56] | 878 | if (m_bFirstSliceInPicture) |
---|
[2] | 879 | { |
---|
[1200] | 880 | m_uiSliceIdx = 0; |
---|
[2] | 881 | } |
---|
[872] | 882 | else |
---|
[56] | 883 | { |
---|
[1200] | 884 | m_apcSlicePilot->copySliceInfo( m_pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) ); |
---|
[56] | 885 | } |
---|
[872] | 886 | m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); |
---|
[2] | 887 | |
---|
[56] | 888 | m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); |
---|
[608] | 889 | Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
| 890 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
| 891 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
| 892 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 893 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N); |
---|
| 894 | m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag); |
---|
| 895 | m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS |
---|
[56] | 896 | m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId); |
---|
[42] | 897 | |
---|
[1200] | 898 | #if ENC_DEC_TRACE |
---|
| 899 | const UInt64 originalSymbolCount = g_nSymbolCounter; |
---|
| 900 | #endif |
---|
| 901 | |
---|
| 902 | #if NH_MV |
---|
[622] | 903 | m_apcSlicePilot->setRefPicSetInterLayer( & m_refPicSetInterLayer0, &m_refPicSetInterLayer1 ); |
---|
[1200] | 904 | m_apcSlicePilot->setLayerId( nalu.m_nuhLayerId ); |
---|
[964] | 905 | #endif |
---|
[1200] | 906 | |
---|
| 907 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManager, m_prevTid0POC); |
---|
| 908 | |
---|
[655] | 909 | // set POC for dependent slices in skipped pictures |
---|
[1200] | 910 | if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) |
---|
[655] | 911 | { |
---|
| 912 | m_apcSlicePilot->setPOC(m_skippedPOC); |
---|
| 913 | } |
---|
| 914 | |
---|
[1200] | 915 | xUpdatePreviousTid0POC(m_apcSlicePilot); |
---|
| 916 | |
---|
[655] | 917 | m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA); |
---|
| 918 | m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType); |
---|
[1200] | 919 | #if NH_MV |
---|
| 920 | const TComVPS* vps = m_apcSlicePilot->getVPS(); |
---|
| 921 | Int layerId = nalu.m_nuhLayerId; |
---|
[622] | 922 | setViewId ( vps->getViewId ( layerId ) ); |
---|
[1200] | 923 | #if NH_3D |
---|
[622] | 924 | setViewIndex( vps->getViewIndex( layerId ) ); |
---|
| 925 | setIsDepth ( vps->getDepthId ( layerId ) == 1 ); |
---|
| 926 | m_ivPicLists->setVPS( vps ); |
---|
| 927 | #endif |
---|
[608] | 928 | #endif |
---|
[738] | 929 | |
---|
[964] | 930 | //For inference of NoOutputOfPriorPicsFlag |
---|
| 931 | if (m_apcSlicePilot->getRapPicFlag()) |
---|
| 932 | { |
---|
| 933 | if ((m_apcSlicePilot->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_apcSlicePilot->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP) || |
---|
| 934 | (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_bFirstSliceInSequence) || |
---|
| 935 | (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getHandleCraAsBlaFlag())) |
---|
| 936 | { |
---|
| 937 | m_apcSlicePilot->setNoRaslOutputFlag(true); |
---|
| 938 | } |
---|
| 939 | //the inference for NoOutputPriorPicsFlag |
---|
| 940 | if (!m_bFirstSliceInBitstream && m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag()) |
---|
| 941 | { |
---|
| 942 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
| 943 | { |
---|
| 944 | m_apcSlicePilot->setNoOutputPriorPicsFlag(true); |
---|
| 945 | } |
---|
| 946 | } |
---|
| 947 | else |
---|
| 948 | { |
---|
| 949 | m_apcSlicePilot->setNoOutputPriorPicsFlag(false); |
---|
| 950 | } |
---|
| 951 | |
---|
| 952 | if(m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
| 953 | { |
---|
| 954 | m_craNoRaslOutputFlag = m_apcSlicePilot->getNoRaslOutputFlag(); |
---|
| 955 | } |
---|
| 956 | } |
---|
| 957 | if (m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoOutputPriorPicsFlag()) |
---|
| 958 | { |
---|
| 959 | m_lastPOCNoOutputPriorPics = m_apcSlicePilot->getPOC(); |
---|
| 960 | m_isNoOutputPriorPics = true; |
---|
| 961 | } |
---|
| 962 | else |
---|
| 963 | { |
---|
| 964 | m_isNoOutputPriorPics = false; |
---|
| 965 | } |
---|
| 966 | |
---|
| 967 | //For inference of PicOutputFlag |
---|
| 968 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
| 969 | { |
---|
| 970 | if ( m_craNoRaslOutputFlag ) |
---|
| 971 | { |
---|
| 972 | m_apcSlicePilot->setPicOutputFlag(false); |
---|
| 973 | } |
---|
| 974 | } |
---|
| 975 | |
---|
| 976 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_craNoRaslOutputFlag) //Reset POC MSB when CRA has NoRaslOutputFlag equal to 1 |
---|
| 977 | { |
---|
[1200] | 978 | TComPPS *pps = m_parameterSetManager.getPPS(m_apcSlicePilot->getPPSId()); |
---|
| 979 | assert (pps != 0); |
---|
| 980 | TComSPS *sps = m_parameterSetManager.getSPS(pps->getSPSId()); |
---|
| 981 | assert (sps != 0); |
---|
| 982 | Int iMaxPOClsb = 1 << sps->getBitsForPOC(); |
---|
[964] | 983 | m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) ); |
---|
[1200] | 984 | xUpdatePreviousTid0POC(m_apcSlicePilot); |
---|
[964] | 985 | } |
---|
[1200] | 986 | #if NH_MV |
---|
[738] | 987 | xCeckNoClrasOutput(); |
---|
| 988 | #endif |
---|
[1200] | 989 | |
---|
| 990 | // Skip pictures due to random access |
---|
| 991 | |
---|
| 992 | #if NH_MV |
---|
| 993 | if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay, vps)) |
---|
| 994 | #else |
---|
| 995 | if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) |
---|
| 996 | #endif |
---|
| 997 | { |
---|
[655] | 998 | m_prevSliceSkipped = true; |
---|
| 999 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
[1200] | 1000 | #if NH_MV |
---|
[773] | 1001 | sliceSkippedFlag = true; |
---|
[738] | 1002 | #endif |
---|
[1200] | 1003 | return false; |
---|
| 1004 | } |
---|
| 1005 | // Skip TFD pictures associated with BLA/BLANT pictures |
---|
| 1006 | if (isSkipPictureForBLA(iPOCLastDisplay)) |
---|
| 1007 | { |
---|
[655] | 1008 | m_prevSliceSkipped = true; |
---|
| 1009 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
[1200] | 1010 | #if NH_MV |
---|
[773] | 1011 | sliceSkippedFlag = true; |
---|
[738] | 1012 | #endif |
---|
[1200] | 1013 | return false; |
---|
| 1014 | } |
---|
[608] | 1015 | |
---|
[655] | 1016 | // clear previous slice skipped flag |
---|
| 1017 | m_prevSliceSkipped = false; |
---|
| 1018 | |
---|
[608] | 1019 | //we should only get a different poc for a new picture (with CTU address==0) |
---|
[1200] | 1020 | if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCtuTsAddr() != 0)) |
---|
[608] | 1021 | { |
---|
| 1022 | printf ("Warning, the first slice of a picture might have been lost!\n"); |
---|
[56] | 1023 | } |
---|
[1200] | 1024 | |
---|
[56] | 1025 | // exit when a new picture is found |
---|
[1200] | 1026 | if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (m_apcSlicePilot->getSliceCurStartCtuTsAddr() == 0 && !m_bFirstSliceInPicture) ) |
---|
[56] | 1027 | { |
---|
| 1028 | if (m_prevPOC >= m_pocRandomAccess) |
---|
| 1029 | { |
---|
| 1030 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
[1200] | 1031 | #if ENC_DEC_TRACE |
---|
| 1032 | //rewind the trace counter since we didn't actually decode the slice |
---|
| 1033 | g_nSymbolCounter = originalSymbolCount; |
---|
| 1034 | #endif |
---|
[56] | 1035 | return true; |
---|
| 1036 | } |
---|
| 1037 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 1038 | } |
---|
[1200] | 1039 | #if NH_MV |
---|
[608] | 1040 | if ( newLayerFlag ) |
---|
| 1041 | { |
---|
| 1042 | return false; |
---|
| 1043 | } |
---|
| 1044 | #if ENC_DEC_TRACE |
---|
| 1045 | #if H_MV_ENC_DEC_TRAC |
---|
| 1046 | // parse remainder of SH |
---|
| 1047 | g_disableHLSTrace = false; |
---|
| 1048 | #endif |
---|
| 1049 | #endif |
---|
| 1050 | #endif |
---|
[1200] | 1051 | |
---|
| 1052 | #if NH_MV |
---|
[622] | 1053 | // This part needs further testing ! |
---|
| 1054 | if ( m_apcSlicePilot->getPocResetFlag() ) |
---|
| 1055 | { |
---|
| 1056 | xResetPocInPicBuffer(); |
---|
| 1057 | } |
---|
[1084] | 1058 | |
---|
| 1059 | if ( m_apcSlicePilot->getTLayer() == 0 && m_apcSlicePilot->getEnableTMVPFlag() == 0 ) |
---|
[1066] | 1060 | { |
---|
| 1061 | //update all pics in the DPB such that they cannot be used for TMPV ref |
---|
| 1062 | TComList<TComPic*>::iterator iterRefPic = m_cListPic.begin(); |
---|
| 1063 | while( iterRefPic != m_cListPic.end() ) |
---|
| 1064 | { |
---|
| 1065 | TComPic *refPic = *iterRefPic; |
---|
| 1066 | if( ( refPic->getLayerId() == m_apcSlicePilot->getLayerId() ) && refPic->getReconMark() ) |
---|
| 1067 | { |
---|
| 1068 | for(Int i = refPic->getNumAllocatedSlice()-1; i >= 0; i--) |
---|
| 1069 | { |
---|
| 1070 | |
---|
| 1071 | TComSlice *refSlice = refPic->getSlice(i); |
---|
| 1072 | refSlice->setAvailableForTMVPRefFlag( false ); |
---|
| 1073 | } |
---|
| 1074 | } |
---|
| 1075 | iterRefPic++; |
---|
| 1076 | } |
---|
| 1077 | } |
---|
| 1078 | m_apcSlicePilot->setAvailableForTMVPRefFlag( true ); |
---|
| 1079 | #endif |
---|
| 1080 | |
---|
[1200] | 1081 | //detect lost reference picture and insert copy of earlier frame. |
---|
[1179] | 1082 | { |
---|
[1200] | 1083 | Int lostPoc; |
---|
| 1084 | while((lostPoc=m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess)) > 0) |
---|
| 1085 | { |
---|
| 1086 | xCreateLostPicture(lostPoc-1); |
---|
| 1087 | } |
---|
[1179] | 1088 | } |
---|
| 1089 | |
---|
[1200] | 1090 | if (!m_apcSlicePilot->getDependentSliceSegmentFlag()) |
---|
[56] | 1091 | { |
---|
| 1092 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 1093 | } |
---|
[1200] | 1094 | |
---|
| 1095 | // actual decoding starts here |
---|
| 1096 | xActivateParameterSets(); |
---|
| 1097 | |
---|
[56] | 1098 | m_bFirstSliceInSequence = false; |
---|
[964] | 1099 | m_bFirstSliceInBitstream = false; |
---|
[2] | 1100 | |
---|
[42] | 1101 | |
---|
[1200] | 1102 | TComSlice* pcSlice = m_pcPic->getPicSym()->getSlice(m_uiSliceIdx); |
---|
[42] | 1103 | |
---|
[1200] | 1104 | // When decoding the slice header, the stored start and end addresses were actually RS addresses, not TS addresses. |
---|
| 1105 | // Now, having set up the maps, convert them to the correct form. |
---|
| 1106 | pcSlice->setSliceSegmentCurStartCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr()) ); |
---|
| 1107 | pcSlice->setSliceSegmentCurEndCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurEndCtuTsAddr()) ); |
---|
| 1108 | if(!pcSlice->getDependentSliceSegmentFlag()) |
---|
[608] | 1109 | { |
---|
[1200] | 1110 | pcSlice->setSliceCurStartCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurStartCtuTsAddr())); |
---|
| 1111 | pcSlice->setSliceCurEndCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurEndCtuTsAddr())); |
---|
[56] | 1112 | } |
---|
[2] | 1113 | |
---|
[1200] | 1114 | m_pcPic->setTLayer(nalu.m_temporalId); |
---|
[56] | 1115 | |
---|
[1200] | 1116 | #if NH_MV |
---|
| 1117 | //Check Multiview Main profile constraint in G.11.1.1 |
---|
| 1118 | // When ViewOrderIdx[ i ] derived according to any active VPS is equal to 1 |
---|
| 1119 | // for the layer with nuh_layer_id equal to i in subBitstream, |
---|
| 1120 | // inter_view_mv_vert_constraint_flag shall be equal to 1 |
---|
| 1121 | // in the sps_multilayer_extension( ) syntax structure in each active SPS for that layer. |
---|
| 1122 | if( pcSlice->getSPS()->getPTL()->getGeneralPTL()->getProfileIdc()==Profile::MULTIVIEWMAIN |
---|
| 1123 | && |
---|
| 1124 | pcSlice->getVPS()->getViewOrderIdx(pcSlice->getVPS()->getLayerIdInNuh(getLayerId()))==1 |
---|
| 1125 | ) |
---|
[56] | 1126 | { |
---|
[1200] | 1127 | assert( pcSlice->getSPS()->getInterViewMvVertConstraintFlag()==1 ); |
---|
[56] | 1128 | } |
---|
[1200] | 1129 | #endif |
---|
| 1130 | #if NH_MV |
---|
| 1131 | m_pcPic->setLayerId( nalu.m_nuhLayerId ); |
---|
| 1132 | m_pcPic->setViewId ( getViewId() ); |
---|
| 1133 | #if NH_3D |
---|
| 1134 | m_pcPic->setViewIndex( getViewIndex() ); |
---|
| 1135 | m_pcPic->setIsDepth ( getIsDepth () ); |
---|
[1196] | 1136 | pcSlice->setIvPicLists( m_ivPicLists ); |
---|
[608] | 1137 | #endif |
---|
| 1138 | #endif |
---|
[1179] | 1139 | |
---|
[1200] | 1140 | if (!pcSlice->getDependentSliceSegmentFlag()) |
---|
[56] | 1141 | { |
---|
[655] | 1142 | pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic ); |
---|
[608] | 1143 | // Set reference list |
---|
[1200] | 1144 | #if NH_MV |
---|
[622] | 1145 | std::vector< TComPic* > tempRefPicLists[2]; |
---|
| 1146 | std::vector< Bool > usedAsLongTerm [2]; |
---|
| 1147 | Int numPocTotalCurr; |
---|
| 1148 | |
---|
| 1149 | pcSlice->getTempRefPicLists( m_cListPic, m_refPicSetInterLayer0, m_refPicSetInterLayer1, tempRefPicLists, usedAsLongTerm, numPocTotalCurr); |
---|
| 1150 | pcSlice->setRefPicList ( tempRefPicLists, usedAsLongTerm, numPocTotalCurr, true ); |
---|
[1279] | 1151 | #if NH_3D_NBDV |
---|
[1124] | 1152 | pcSlice->setDefaultRefView(); |
---|
| 1153 | #endif |
---|
[1279] | 1154 | #if NH_3D_ARP |
---|
[724] | 1155 | pcSlice->setARPStepNum(m_ivPicLists); |
---|
[77] | 1156 | #endif |
---|
| 1157 | #else |
---|
[608] | 1158 | pcSlice->setRefPicList( m_cListPic, true ); |
---|
[21] | 1159 | #endif |
---|
| 1160 | |
---|
[1200] | 1161 | #if NH_3D |
---|
[1179] | 1162 | pcSlice->checkInCompPredRefLayers(); |
---|
[1279] | 1163 | #if NH_3D_IV_MERGE |
---|
[655] | 1164 | #if H_3D_FCO |
---|
| 1165 | //assert( !getIsDepth() ); |
---|
| 1166 | #else |
---|
[608] | 1167 | assert( !getIsDepth() || ( pcSlice->getTexturePic() != 0 ) ); |
---|
[655] | 1168 | #endif |
---|
[608] | 1169 | #endif |
---|
[210] | 1170 | #endif |
---|
[1200] | 1171 | #if NH_MV |
---|
[1066] | 1172 | if( m_layerId > 0 && !pcSlice->isIntra() && pcSlice->getEnableTMVPFlag() ) |
---|
| 1173 | { |
---|
| 1174 | TComPic* refPic = pcSlice->getRefPic(RefPicList(1 - pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx()); |
---|
| 1175 | |
---|
| 1176 | assert ( refPic ); |
---|
| 1177 | assert ( refPic->getPicSym()->getSlice(0)->getAvailableForTMVPRefFlag() == true ); |
---|
| 1178 | } |
---|
| 1179 | #endif |
---|
| 1180 | |
---|
| 1181 | // For generalized B |
---|
[56] | 1182 | // note: maybe not existed case (always L0 is copied to L1 if L1 is empty) |
---|
| 1183 | if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0) |
---|
| 1184 | { |
---|
| 1185 | Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0); |
---|
| 1186 | pcSlice->setNumRefIdx ( REF_PIC_LIST_1, iNumRefIdx ); |
---|
[2] | 1187 | |
---|
[56] | 1188 | for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++) |
---|
| 1189 | { |
---|
| 1190 | pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx); |
---|
| 1191 | } |
---|
| 1192 | } |
---|
[608] | 1193 | if (!pcSlice->isIntra()) |
---|
[56] | 1194 | { |
---|
| 1195 | Bool bLowDelay = true; |
---|
| 1196 | Int iCurrPOC = pcSlice->getPOC(); |
---|
| 1197 | Int iRefIdx = 0; |
---|
| 1198 | |
---|
| 1199 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++) |
---|
| 1200 | { |
---|
| 1201 | if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC ) |
---|
[21] | 1202 | { |
---|
[56] | 1203 | bLowDelay = false; |
---|
[21] | 1204 | } |
---|
[2] | 1205 | } |
---|
[608] | 1206 | if (pcSlice->isInterB()) |
---|
[56] | 1207 | { |
---|
[608] | 1208 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++) |
---|
[56] | 1209 | { |
---|
[608] | 1210 | if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC ) |
---|
| 1211 | { |
---|
| 1212 | bLowDelay = false; |
---|
| 1213 | } |
---|
[1200] | 1214 | } |
---|
[56] | 1215 | } |
---|
[2] | 1216 | |
---|
[1200] | 1217 | pcSlice->setCheckLDC(bLowDelay); |
---|
[56] | 1218 | } |
---|
| 1219 | |
---|
| 1220 | //--------------- |
---|
[608] | 1221 | pcSlice->setRefPOCList(); |
---|
[1279] | 1222 | #if NH_3D_TMVP |
---|
[608] | 1223 | if(pcSlice->getLayerId()) |
---|
[1196] | 1224 | { |
---|
[608] | 1225 | pcSlice->generateAlterRefforTMVP(); |
---|
[1196] | 1226 | } |
---|
[313] | 1227 | #endif |
---|
[56] | 1228 | } |
---|
| 1229 | |
---|
[1200] | 1230 | m_pcPic->setCurrSliceIdx(m_uiSliceIdx); |
---|
[56] | 1231 | if(pcSlice->getSPS()->getScalingListFlag()) |
---|
| 1232 | { |
---|
[1200] | 1233 | TComScalingList scalingList; |
---|
[608] | 1234 | if(pcSlice->getPPS()->getScalingListPresentFlag()) |
---|
[56] | 1235 | { |
---|
[1200] | 1236 | scalingList = pcSlice->getPPS()->getScalingList(); |
---|
[56] | 1237 | } |
---|
[1200] | 1238 | else if (pcSlice->getSPS()->getScalingListPresentFlag()) |
---|
[608] | 1239 | { |
---|
[1200] | 1240 | scalingList = pcSlice->getSPS()->getScalingList(); |
---|
[608] | 1241 | } |
---|
[1200] | 1242 | else |
---|
| 1243 | { |
---|
| 1244 | scalingList.setDefaultScalingList(); |
---|
| 1245 | } |
---|
| 1246 | m_cTrQuant.setScalingListDec(scalingList); |
---|
[56] | 1247 | m_cTrQuant.setUseScalingList(true); |
---|
| 1248 | } |
---|
| 1249 | else |
---|
| 1250 | { |
---|
[1200] | 1251 | const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE] = |
---|
| 1252 | { |
---|
| 1253 | pcSlice->getSPS()->getMaxLog2TrDynamicRange(CHANNEL_TYPE_LUMA), |
---|
| 1254 | pcSlice->getSPS()->getMaxLog2TrDynamicRange(CHANNEL_TYPE_CHROMA) |
---|
| 1255 | }; |
---|
| 1256 | m_cTrQuant.setFlatScalingList(maxLog2TrDynamicRange, pcSlice->getSPS()->getBitDepths()); |
---|
[56] | 1257 | m_cTrQuant.setUseScalingList(false); |
---|
| 1258 | } |
---|
[2] | 1259 | |
---|
[1279] | 1260 | #if NH_3D_IV_MERGE |
---|
[1084] | 1261 | #if H_3D_FCO |
---|
[1066] | 1262 | if( !pcSlice->getIsDepth() && m_pcCamParsCollector ) |
---|
| 1263 | #else |
---|
[724] | 1264 | if( pcSlice->getIsDepth() && m_pcCamParsCollector ) |
---|
[1066] | 1265 | #endif |
---|
[724] | 1266 | { |
---|
| 1267 | m_pcCamParsCollector->copyCamParamForSlice( pcSlice ); |
---|
| 1268 | } |
---|
| 1269 | #endif |
---|
[1200] | 1270 | // Decode a picture |
---|
| 1271 | m_cGopDecoder.decompressSlice(&(nalu.getBitstream()), m_pcPic); |
---|
[724] | 1272 | |
---|
[1200] | 1273 | #if NH_3D |
---|
[57] | 1274 | if( m_pcCamParsCollector ) |
---|
| 1275 | { |
---|
| 1276 | m_pcCamParsCollector->setSlice( pcSlice ); |
---|
| 1277 | } |
---|
[758] | 1278 | #endif |
---|
[1200] | 1279 | |
---|
[56] | 1280 | m_bFirstSliceInPicture = false; |
---|
| 1281 | m_uiSliceIdx++; |
---|
| 1282 | |
---|
| 1283 | return false; |
---|
| 1284 | } |
---|
| 1285 | |
---|
[1200] | 1286 | Void TDecTop::xDecodeVPS(const std::vector<UChar> &naluData) |
---|
[77] | 1287 | { |
---|
| 1288 | TComVPS* vps = new TComVPS(); |
---|
[1200] | 1289 | |
---|
[77] | 1290 | m_cEntropyDecoder.decodeVPS( vps ); |
---|
[1200] | 1291 | m_parameterSetManager.storeVPS(vps, naluData); |
---|
[77] | 1292 | } |
---|
[56] | 1293 | |
---|
[1200] | 1294 | Void TDecTop::xDecodeSPS(const std::vector<UChar> &naluData) |
---|
[56] | 1295 | { |
---|
| 1296 | TComSPS* sps = new TComSPS(); |
---|
[1200] | 1297 | #if NH_MV |
---|
[608] | 1298 | sps->setLayerId( getLayerId() ); |
---|
| 1299 | #endif |
---|
[1200] | 1300 | #if O0043_BEST_EFFORT_DECODING |
---|
| 1301 | sps->setForceDecodeBitDepth(m_forceDecodeBitDepth); |
---|
| 1302 | #endif |
---|
| 1303 | #if NH_3D |
---|
| 1304 | // GT: Please don't add parsing dependency of SPS from VPS here again!!! |
---|
| 1305 | #endif |
---|
[1124] | 1306 | m_cEntropyDecoder.decodeSPS( sps ); |
---|
[1200] | 1307 | m_parameterSetManager.storeSPS(sps, naluData); |
---|
[56] | 1308 | } |
---|
[2] | 1309 | |
---|
[1200] | 1310 | Void TDecTop::xDecodePPS(const std::vector<UChar> &naluData) |
---|
[56] | 1311 | { |
---|
| 1312 | TComPPS* pps = new TComPPS(); |
---|
[1200] | 1313 | #if NH_MV |
---|
[622] | 1314 | pps->setLayerId( getLayerId() ); |
---|
| 1315 | #endif |
---|
[1219] | 1316 | #if NH_3D_DLT |
---|
| 1317 | // create mapping from depth layer indexes to layer ids |
---|
| 1318 | Int j=0; |
---|
| 1319 | for( Int i=0; i<=m_parameterSetManager.getFirstVPS()->getMaxLayersMinus1(); i++ ) |
---|
| 1320 | { |
---|
| 1321 | Int layerId = m_parameterSetManager.getFirstVPS()->getLayerIdInNuh(i); |
---|
| 1322 | if( m_parameterSetManager.getFirstVPS()->getDepthId(layerId) ) |
---|
[1251] | 1323 | pps->getDLT()->setDepthIdxToLayerId(j++, layerId); |
---|
[1219] | 1324 | } |
---|
| 1325 | #endif |
---|
[608] | 1326 | m_cEntropyDecoder.decodePPS( pps ); |
---|
[2] | 1327 | |
---|
[1200] | 1328 | m_parameterSetManager.storePPS( pps, naluData); |
---|
[56] | 1329 | } |
---|
[2] | 1330 | |
---|
[1200] | 1331 | #if NH_MV |
---|
[738] | 1332 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag ) |
---|
| 1333 | #else |
---|
[56] | 1334 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
[608] | 1335 | #endif |
---|
[56] | 1336 | { |
---|
[1200] | 1337 | #if !NH_MV |
---|
| 1338 | // ignore all NAL units of layers > 0 |
---|
| 1339 | if (nalu.m_nuhLayerId > 0) |
---|
| 1340 | { |
---|
| 1341 | fprintf (stderr, "Warning: found NAL unit with nuh_layer_id equal to %d. Ignoring.\n", nalu.m_nuhLayerId); |
---|
| 1342 | return false; |
---|
| 1343 | } |
---|
| 1344 | #endif |
---|
[56] | 1345 | // Initialize entropy decoder |
---|
| 1346 | m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); |
---|
[1200] | 1347 | m_cEntropyDecoder.setBitstream (&(nalu.getBitstream())); |
---|
[2] | 1348 | |
---|
[56] | 1349 | switch (nalu.m_nalUnitType) |
---|
| 1350 | { |
---|
[77] | 1351 | case NAL_UNIT_VPS: |
---|
[1200] | 1352 | xDecodeVPS(nalu.getBitstream().getFifo()); |
---|
| 1353 | #if NH_MV |
---|
[964] | 1354 | m_isLastNALWasEos = false; |
---|
| 1355 | #endif |
---|
[77] | 1356 | return false; |
---|
[1200] | 1357 | |
---|
[56] | 1358 | case NAL_UNIT_SPS: |
---|
[1200] | 1359 | xDecodeSPS(nalu.getBitstream().getFifo()); |
---|
[56] | 1360 | return false; |
---|
| 1361 | |
---|
| 1362 | case NAL_UNIT_PPS: |
---|
[1200] | 1363 | xDecodePPS(nalu.getBitstream().getFifo()); |
---|
[56] | 1364 | return false; |
---|
[1200] | 1365 | |
---|
[608] | 1366 | case NAL_UNIT_PREFIX_SEI: |
---|
[1200] | 1367 | // Buffer up prefix SEI messages until SPS of associated VCL is known. |
---|
| 1368 | m_prefixSEINALUs.push_back(new InputNALUnit(nalu)); |
---|
| 1369 | return false; |
---|
| 1370 | |
---|
[608] | 1371 | case NAL_UNIT_SUFFIX_SEI: |
---|
[1200] | 1372 | #if NH_MV |
---|
[964] | 1373 | if ( nalu.m_nalUnitType == NAL_UNIT_SUFFIX_SEI ) |
---|
| 1374 | { |
---|
| 1375 | assert( m_isLastNALWasEos == false ); |
---|
| 1376 | } |
---|
| 1377 | #endif |
---|
[1200] | 1378 | if (m_pcPic) |
---|
| 1379 | { |
---|
| 1380 | #if NH_MV |
---|
| 1381 | m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_pcPic->getSEIs(), nalu.m_nalUnitType, m_parameterSetManager.getActiveSPS( getLayerId() ), m_pDecodedSEIOutputStream ); |
---|
| 1382 | #else |
---|
| 1383 | m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_pcPic->getSEIs(), nalu.m_nalUnitType, m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream ); |
---|
| 1384 | #endif |
---|
| 1385 | } |
---|
| 1386 | else |
---|
| 1387 | { |
---|
| 1388 | printf ("Note: received suffix SEI but no picture currently active.\n"); |
---|
| 1389 | } |
---|
[56] | 1390 | return false; |
---|
| 1391 | |
---|
[608] | 1392 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
| 1393 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
[872] | 1394 | case NAL_UNIT_CODED_SLICE_TSA_R: |
---|
[608] | 1395 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
| 1396 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
| 1397 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
| 1398 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
| 1399 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
| 1400 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
| 1401 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
| 1402 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
[56] | 1403 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
[608] | 1404 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
| 1405 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
| 1406 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
| 1407 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
[1200] | 1408 | #if NH_MV |
---|
[964] | 1409 | if (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
| 1410 | nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
| 1411 | nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
| 1412 | nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 1413 | nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N ) |
---|
| 1414 | { |
---|
| 1415 | assert( m_isLastNALWasEos == false ); |
---|
| 1416 | } |
---|
| 1417 | else |
---|
| 1418 | { |
---|
| 1419 | m_isLastNALWasEos = false; |
---|
| 1420 | } |
---|
[738] | 1421 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, newLayerFlag, sliceSkippedFlag ); |
---|
| 1422 | #else |
---|
[56] | 1423 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay); |
---|
[608] | 1424 | #endif |
---|
[2] | 1425 | break; |
---|
[1200] | 1426 | |
---|
[872] | 1427 | case NAL_UNIT_EOS: |
---|
[1200] | 1428 | #if NH_MV |
---|
[964] | 1429 | assert( m_isLastNALWasEos == false ); |
---|
| 1430 | //Check layer id of the nalu. if it is not 0, give a warning message and just return without doing anything. |
---|
[1200] | 1431 | if (nalu.m_nuhLayerId > 0) |
---|
[964] | 1432 | { |
---|
| 1433 | printf( "\nThis bitstream has EOS with non-zero layer id.\n" ); |
---|
| 1434 | return false; |
---|
| 1435 | } |
---|
| 1436 | m_isLastNALWasEos = true; |
---|
| 1437 | #endif |
---|
[872] | 1438 | m_associatedIRAPType = NAL_UNIT_INVALID; |
---|
| 1439 | m_pocCRA = 0; |
---|
| 1440 | m_pocRandomAccess = MAX_INT; |
---|
| 1441 | m_prevPOC = MAX_INT; |
---|
| 1442 | m_prevSliceSkipped = false; |
---|
| 1443 | m_skippedPOC = 0; |
---|
| 1444 | return false; |
---|
[1200] | 1445 | |
---|
[872] | 1446 | case NAL_UNIT_ACCESS_UNIT_DELIMITER: |
---|
[1200] | 1447 | { |
---|
| 1448 | AUDReader audReader; |
---|
| 1449 | UInt picType; |
---|
| 1450 | audReader.parseAccessUnitDelimiter(&(nalu.getBitstream()),picType); |
---|
| 1451 | printf ("Note: found NAL_UNIT_ACCESS_UNIT_DELIMITER\n"); |
---|
[872] | 1452 | return false; |
---|
[1200] | 1453 | } |
---|
| 1454 | |
---|
[872] | 1455 | case NAL_UNIT_EOB: |
---|
| 1456 | return false; |
---|
[1200] | 1457 | |
---|
[964] | 1458 | case NAL_UNIT_FILLER_DATA: |
---|
[1200] | 1459 | { |
---|
| 1460 | FDReader fdReader; |
---|
| 1461 | UInt size; |
---|
| 1462 | fdReader.parseFillerData(&(nalu.getBitstream()),size); |
---|
| 1463 | printf ("Note: found NAL_UNIT_FILLER_DATA with %u bytes payload.\n", size); |
---|
| 1464 | #if NH_MV |
---|
[964] | 1465 | assert( m_isLastNALWasEos == false ); |
---|
| 1466 | #endif |
---|
| 1467 | return false; |
---|
[1200] | 1468 | } |
---|
| 1469 | |
---|
[872] | 1470 | case NAL_UNIT_RESERVED_VCL_N10: |
---|
| 1471 | case NAL_UNIT_RESERVED_VCL_R11: |
---|
| 1472 | case NAL_UNIT_RESERVED_VCL_N12: |
---|
| 1473 | case NAL_UNIT_RESERVED_VCL_R13: |
---|
| 1474 | case NAL_UNIT_RESERVED_VCL_N14: |
---|
| 1475 | case NAL_UNIT_RESERVED_VCL_R15: |
---|
[1200] | 1476 | |
---|
[872] | 1477 | case NAL_UNIT_RESERVED_IRAP_VCL22: |
---|
| 1478 | case NAL_UNIT_RESERVED_IRAP_VCL23: |
---|
[1200] | 1479 | |
---|
[872] | 1480 | case NAL_UNIT_RESERVED_VCL24: |
---|
| 1481 | case NAL_UNIT_RESERVED_VCL25: |
---|
| 1482 | case NAL_UNIT_RESERVED_VCL26: |
---|
| 1483 | case NAL_UNIT_RESERVED_VCL27: |
---|
| 1484 | case NAL_UNIT_RESERVED_VCL28: |
---|
| 1485 | case NAL_UNIT_RESERVED_VCL29: |
---|
| 1486 | case NAL_UNIT_RESERVED_VCL30: |
---|
| 1487 | case NAL_UNIT_RESERVED_VCL31: |
---|
[1200] | 1488 | printf ("Note: found reserved VCL NAL unit.\n"); |
---|
| 1489 | xParsePrefixSEIsForUnknownVCLNal(); |
---|
| 1490 | return false; |
---|
| 1491 | |
---|
[872] | 1492 | case NAL_UNIT_RESERVED_NVCL41: |
---|
| 1493 | case NAL_UNIT_RESERVED_NVCL42: |
---|
| 1494 | case NAL_UNIT_RESERVED_NVCL43: |
---|
| 1495 | case NAL_UNIT_RESERVED_NVCL44: |
---|
| 1496 | case NAL_UNIT_RESERVED_NVCL45: |
---|
| 1497 | case NAL_UNIT_RESERVED_NVCL46: |
---|
| 1498 | case NAL_UNIT_RESERVED_NVCL47: |
---|
[1200] | 1499 | printf ("Note: found reserved NAL unit.\n"); |
---|
| 1500 | return false; |
---|
[872] | 1501 | case NAL_UNIT_UNSPECIFIED_48: |
---|
| 1502 | case NAL_UNIT_UNSPECIFIED_49: |
---|
| 1503 | case NAL_UNIT_UNSPECIFIED_50: |
---|
| 1504 | case NAL_UNIT_UNSPECIFIED_51: |
---|
| 1505 | case NAL_UNIT_UNSPECIFIED_52: |
---|
| 1506 | case NAL_UNIT_UNSPECIFIED_53: |
---|
| 1507 | case NAL_UNIT_UNSPECIFIED_54: |
---|
| 1508 | case NAL_UNIT_UNSPECIFIED_55: |
---|
| 1509 | case NAL_UNIT_UNSPECIFIED_56: |
---|
| 1510 | case NAL_UNIT_UNSPECIFIED_57: |
---|
| 1511 | case NAL_UNIT_UNSPECIFIED_58: |
---|
| 1512 | case NAL_UNIT_UNSPECIFIED_59: |
---|
| 1513 | case NAL_UNIT_UNSPECIFIED_60: |
---|
| 1514 | case NAL_UNIT_UNSPECIFIED_61: |
---|
| 1515 | case NAL_UNIT_UNSPECIFIED_62: |
---|
| 1516 | case NAL_UNIT_UNSPECIFIED_63: |
---|
[1200] | 1517 | printf ("Note: found unspecified NAL unit.\n"); |
---|
| 1518 | return false; |
---|
[2] | 1519 | default: |
---|
[872] | 1520 | assert (0); |
---|
[1200] | 1521 | break; |
---|
[2] | 1522 | } |
---|
| 1523 | |
---|
| 1524 | return false; |
---|
| 1525 | } |
---|
| 1526 | |
---|
[608] | 1527 | /** Function for checking if picture should be skipped because of association with a previous BLA picture |
---|
| 1528 | * \param iPOCLastDisplay POC of last picture displayed |
---|
| 1529 | * \returns true if the picture should be skipped |
---|
| 1530 | * This function skips all TFD pictures that follow a BLA picture |
---|
| 1531 | * in decoding order and precede it in output order. |
---|
| 1532 | */ |
---|
| 1533 | Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay) |
---|
[210] | 1534 | { |
---|
[1200] | 1535 | 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) && |
---|
[655] | 1536 | m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) |
---|
[608] | 1537 | { |
---|
| 1538 | iPOCLastDisplay++; |
---|
| 1539 | return true; |
---|
| 1540 | } |
---|
| 1541 | return false; |
---|
[210] | 1542 | } |
---|
| 1543 | |
---|
[2] | 1544 | /** Function for checking if picture should be skipped because of random access |
---|
| 1545 | * \param iSkipFrame skip frame counter |
---|
| 1546 | * \param iPOCLastDisplay POC of last picture displayed |
---|
| 1547 | * \returns true if the picture shold be skipped in the random access. |
---|
| 1548 | * This function checks the skipping of pictures in the case of -s option random access. |
---|
| 1549 | * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped. |
---|
| 1550 | * It also checks the type of Nal unit type at the random access point. |
---|
[608] | 1551 | * 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] | 1552 | * If the random access point is IDR all pictures after the random access point are decoded. |
---|
[1200] | 1553 | * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC |
---|
| 1554 | * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random |
---|
[2] | 1555 | * access point there is no guarantee that the decoder will not crash. |
---|
| 1556 | */ |
---|
[1200] | 1557 | #if NH_MV |
---|
| 1558 | Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay, const TComVPS* vps) |
---|
| 1559 | #else |
---|
| 1560 | Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay ) |
---|
| 1561 | #endif |
---|
[2] | 1562 | { |
---|
[1200] | 1563 | if (iSkipFrame) |
---|
[2] | 1564 | { |
---|
| 1565 | iSkipFrame--; // decrement the counter |
---|
| 1566 | return true; |
---|
| 1567 | } |
---|
[1200] | 1568 | #if NH_MV |
---|
[738] | 1569 | else if ( !m_layerInitilizedFlag[ m_layerId ] ) // start of random access point, m_pocRandomAccess has not been set yet. |
---|
| 1570 | #else |
---|
[56] | 1571 | else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet. |
---|
[738] | 1572 | #endif |
---|
[2] | 1573 | { |
---|
[608] | 1574 | if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA |
---|
| 1575 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 1576 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
| 1577 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ) |
---|
[2] | 1578 | { |
---|
[738] | 1579 | |
---|
[1200] | 1580 | #if NH_MV |
---|
| 1581 | if ( xAllRefLayersInitilized( vps ) ) |
---|
[738] | 1582 | { |
---|
| 1583 | m_layerInitilizedFlag[ m_layerId ] = true; |
---|
| 1584 | m_pocRandomAccess = m_apcSlicePilot->getPOC(); |
---|
| 1585 | } |
---|
| 1586 | else |
---|
| 1587 | { |
---|
| 1588 | return true; |
---|
| 1589 | } |
---|
| 1590 | #else |
---|
[608] | 1591 | // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT. |
---|
| 1592 | m_pocRandomAccess = m_apcSlicePilot->getPOC(); |
---|
[738] | 1593 | #endif |
---|
[2] | 1594 | } |
---|
[608] | 1595 | else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
[2] | 1596 | { |
---|
[1200] | 1597 | #if NH_MV |
---|
| 1598 | if ( xAllRefLayersInitilized( vps) ) |
---|
[738] | 1599 | { |
---|
| 1600 | m_layerInitilizedFlag[ m_layerId ] = true; |
---|
[773] | 1601 | m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable. |
---|
| 1602 | } |
---|
| 1603 | else |
---|
| 1604 | { |
---|
[738] | 1605 | return true; |
---|
| 1606 | } |
---|
| 1607 | #else |
---|
| 1608 | m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable. |
---|
| 1609 | #endif |
---|
| 1610 | } |
---|
[1200] | 1611 | else |
---|
[738] | 1612 | { |
---|
[1200] | 1613 | #if NH_MV |
---|
[738] | 1614 | static Bool warningMessage[MAX_NUM_LAYERS]; |
---|
| 1615 | static Bool warningInitFlag = false; |
---|
| 1616 | |
---|
| 1617 | if (!warningInitFlag) |
---|
| 1618 | { |
---|
| 1619 | for ( Int i = 0; i < MAX_NUM_LAYERS; i++) |
---|
| 1620 | { |
---|
| 1621 | warningMessage[i] = true; |
---|
| 1622 | } |
---|
| 1623 | warningInitFlag = true; |
---|
| 1624 | } |
---|
| 1625 | |
---|
| 1626 | if ( warningMessage[getLayerId()] ) |
---|
| 1627 | { |
---|
| 1628 | printf("\nLayer%3d No valid random access point. VCL NAL units of this layer are discarded until next layer initialization picture. ", getLayerId() ); |
---|
| 1629 | warningMessage[m_layerId] = false; |
---|
| 1630 | } |
---|
| 1631 | #else |
---|
[1200] | 1632 | if(!m_warningMessageSkipPicture) |
---|
[56] | 1633 | { |
---|
| 1634 | printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture"); |
---|
[1200] | 1635 | m_warningMessageSkipPicture = true; |
---|
[56] | 1636 | } |
---|
[738] | 1637 | #endif |
---|
[56] | 1638 | return true; |
---|
[2] | 1639 | } |
---|
| 1640 | } |
---|
[608] | 1641 | // skip the reordered pictures, if necessary |
---|
| 1642 | 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] | 1643 | { |
---|
| 1644 | iPOCLastDisplay++; |
---|
| 1645 | return true; |
---|
| 1646 | } |
---|
[1200] | 1647 | // if we reach here, then the picture is not skipped. |
---|
| 1648 | #if NH_MV |
---|
[738] | 1649 | return !m_layerInitilizedFlag[ getLayerId() ]; |
---|
| 1650 | #else |
---|
[1200] | 1651 | return false; |
---|
[738] | 1652 | #endif |
---|
[2] | 1653 | } |
---|
[1200] | 1654 | #if NH_MV |
---|
[608] | 1655 | TComPic* TDecTop::getPic( Int poc ) |
---|
[56] | 1656 | { |
---|
[608] | 1657 | xGetPic( m_layerId, poc ); |
---|
| 1658 | TComList<TComPic*>* listPic = getListPic(); |
---|
| 1659 | TComPic* pcPic = NULL; |
---|
| 1660 | for(TComList<TComPic*>::iterator it=listPic->begin(); it!=listPic->end(); it++) |
---|
| 1661 | { |
---|
| 1662 | if( (*it)->getPOC() == poc ) |
---|
| 1663 | { |
---|
| 1664 | pcPic = *it ; |
---|
| 1665 | break ; |
---|
| 1666 | } |
---|
| 1667 | } |
---|
| 1668 | return pcPic; |
---|
[56] | 1669 | } |
---|
[2] | 1670 | |
---|
[608] | 1671 | TComPic* TDecTop::xGetPic( Int layerId, Int poc ) |
---|
| 1672 | { |
---|
| 1673 | return m_ivPicLists->getPic( layerId, poc ) ; |
---|
| 1674 | } |
---|
| 1675 | |
---|
[622] | 1676 | Void TDecTop::xResetPocInPicBuffer() |
---|
| 1677 | { |
---|
| 1678 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 1679 | while (iterPic != m_cListPic.end()) |
---|
| 1680 | { |
---|
| 1681 | TComPic* pic = *(iterPic++); |
---|
| 1682 | if ( pic->getReconMark() ) |
---|
| 1683 | { |
---|
| 1684 | for( Int i = 0; i < pic->getNumAllocatedSlice(); i++) |
---|
| 1685 | { |
---|
| 1686 | TComSlice* slice = pic->getSlice( i ); |
---|
| 1687 | slice->setPOC ( slice->getPOC() - m_apcSlicePilot->getPocBeforeReset() ); |
---|
| 1688 | } |
---|
| 1689 | } |
---|
| 1690 | } |
---|
| 1691 | } |
---|
[738] | 1692 | |
---|
| 1693 | Void TDecTop::xCeckNoClrasOutput() |
---|
| 1694 | { |
---|
| 1695 | // This part needs further testing! |
---|
| 1696 | if ( getLayerId() == 0 ) |
---|
| 1697 | { |
---|
| 1698 | NalUnitType nut = m_apcSlicePilot->getNalUnitType(); |
---|
| 1699 | |
---|
| 1700 | 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 ); |
---|
| 1701 | Bool isIDR = ( nut == NAL_UNIT_CODED_SLICE_IDR_W_RADL ) || ( nut == NAL_UNIT_CODED_SLICE_IDR_N_LP ); |
---|
| 1702 | Bool noClrasOutputFlag = isBLA || ( isIDR && m_apcSlicePilot->getCrossLayerBlaFlag() ); |
---|
| 1703 | |
---|
| 1704 | if ( noClrasOutputFlag ) |
---|
| 1705 | { |
---|
| 1706 | for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++) |
---|
| 1707 | { |
---|
| 1708 | m_layerInitilizedFlag[i] = false; |
---|
| 1709 | } |
---|
| 1710 | } |
---|
| 1711 | } |
---|
| 1712 | } |
---|
| 1713 | |
---|
[1200] | 1714 | Bool TDecTop::xAllRefLayersInitilized( const TComVPS* vps ) |
---|
[738] | 1715 | { |
---|
[1200] | 1716 | Bool allRefLayersInitilizedFlag = true; |
---|
[738] | 1717 | for (Int i = 0; i < vps->getNumDirectRefLayers( getLayerId() ); i++ ) |
---|
| 1718 | { |
---|
[1066] | 1719 | Int refLayerId = vps->getIdDirectRefLayer( m_layerId, i ); |
---|
[738] | 1720 | allRefLayersInitilizedFlag = allRefLayersInitilizedFlag && m_layerInitilizedFlag[ refLayerId ]; |
---|
| 1721 | } |
---|
| 1722 | |
---|
| 1723 | return allRefLayersInitilizedFlag; |
---|
| 1724 | } |
---|
[1196] | 1725 | |
---|
[1200] | 1726 | |
---|
| 1727 | Void TDecTop::initFromActiveVps( const TComVPS* vps ) |
---|
[1196] | 1728 | { |
---|
[1200] | 1729 | if ( m_targetOlsIdx == -1 ) |
---|
| 1730 | { |
---|
| 1731 | // Not normative! Corresponds to specification by "External Means". (Should be set equal to 0, when no external means available. ) |
---|
| 1732 | m_targetOlsIdx = vps->getVpsNumLayerSetsMinus1(); |
---|
| 1733 | } |
---|
| 1734 | #if NH_3D |
---|
| 1735 | // Set profile |
---|
| 1736 | Int lsIdx = vps->olsIdxToLsIdx( m_targetOlsIdx ); |
---|
| 1737 | Int lIdx = -1; |
---|
| 1738 | for (Int j = 0; j < vps->getNumLayersInIdList( lsIdx ); j++ ) |
---|
| 1739 | { |
---|
| 1740 | if ( vps->getLayerSetLayerIdList( lsIdx, j ) == getLayerId() ) |
---|
[1196] | 1741 | { |
---|
[1200] | 1742 | lIdx = j; |
---|
| 1743 | break; |
---|
| 1744 | } |
---|
| 1745 | } |
---|
| 1746 | assert( lIdx != -1 ); |
---|
[1196] | 1747 | |
---|
[1200] | 1748 | Int profileIdc = vps->getPTL( vps->getProfileTierLevelIdx( m_targetOlsIdx, lIdx ) )->getGeneralPTL()->getProfileIdc(); |
---|
| 1749 | assert( profileIdc == 1 || profileIdc == 6 || profileIdc == 8 ); |
---|
| 1750 | m_profileIdc = profileIdc; |
---|
| 1751 | #endif |
---|
[1196] | 1752 | } |
---|
[608] | 1753 | #endif |
---|
[1200] | 1754 | |
---|
[56] | 1755 | //! \} |
---|