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