[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 |
---|
[1313] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[1413] | 6 | * Copyright (c) 2010-2017, 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 | */ |
---|
[56] | 37 | #include "NALread.h" |
---|
[2] | 38 | #include "TDecTop.h" |
---|
[1413] | 39 | #include "TDecConformance.h" |
---|
| 40 | |
---|
[1313] | 41 | #if NH_MV |
---|
| 42 | ParameterSetManager TDecTop::m_parameterSetManager; |
---|
| 43 | #endif |
---|
[2] | 44 | |
---|
[56] | 45 | //! \ingroup TLibDecoder |
---|
| 46 | //! \{ |
---|
[2] | 47 | |
---|
[1313] | 48 | #if NH_3D |
---|
[2] | 49 | CamParsCollector::CamParsCollector() |
---|
| 50 | : m_bInitialized( false ) |
---|
| 51 | { |
---|
[608] | 52 | m_aaiCodedOffset = new Int* [ MAX_NUM_LAYERS ]; |
---|
| 53 | m_aaiCodedScale = new Int* [ MAX_NUM_LAYERS ]; |
---|
| 54 | for( UInt uiId = 0; uiId < MAX_NUM_LAYERS; uiId++ ) |
---|
[2] | 55 | { |
---|
[608] | 56 | m_aaiCodedOffset [ uiId ] = new Int [ MAX_NUM_LAYERS ]; |
---|
| 57 | m_aaiCodedScale [ uiId ] = new Int [ MAX_NUM_LAYERS ]; |
---|
[2] | 58 | } |
---|
[296] | 59 | |
---|
[608] | 60 | xCreateLUTs( (UInt)MAX_NUM_LAYERS, (UInt)MAX_NUM_LAYERS, m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT ); |
---|
[296] | 61 | m_iLog2Precision = LOG2_DISP_PREC_LUT; |
---|
| 62 | m_uiBitDepthForLUT = 8; // fixed |
---|
[1356] | 63 | m_receivedIdc = NULL; |
---|
| 64 | m_vps = NULL; |
---|
[2] | 65 | } |
---|
| 66 | |
---|
| 67 | CamParsCollector::~CamParsCollector() |
---|
| 68 | { |
---|
[608] | 69 | for( UInt uiId = 0; uiId < MAX_NUM_LAYERS; uiId++ ) |
---|
[2] | 70 | { |
---|
| 71 | delete [] m_aaiCodedOffset [ uiId ]; |
---|
| 72 | delete [] m_aaiCodedScale [ uiId ]; |
---|
| 73 | } |
---|
| 74 | delete [] m_aaiCodedOffset; |
---|
| 75 | delete [] m_aaiCodedScale; |
---|
[296] | 76 | |
---|
[608] | 77 | xDeleteArray( m_adBaseViewShiftLUT, MAX_NUM_LAYERS, MAX_NUM_LAYERS, 2 ); |
---|
| 78 | xDeleteArray( m_aiBaseViewShiftLUT, MAX_NUM_LAYERS, MAX_NUM_LAYERS, 2 ); |
---|
[1356] | 79 | if ( m_receivedIdc != NULL ) |
---|
| 80 | { |
---|
| 81 | xDeleteArray( m_receivedIdc, m_vps->getNumViews() ); |
---|
| 82 | } |
---|
[2] | 83 | } |
---|
| 84 | |
---|
[872] | 85 | |
---|
[2] | 86 | Void |
---|
[1313] | 87 | CamParsCollector::init( const TComVPS* vps) |
---|
[872] | 88 | { |
---|
| 89 | assert( !isInitialized() ); // Only one initialization currently supported |
---|
| 90 | m_bInitialized = true; |
---|
[1356] | 91 | m_vps = vps; |
---|
| 92 | m_bCamParsVaryOverTime = false; |
---|
| 93 | m_lastPoc = -1; |
---|
| 94 | m_firstReceivedPoc = -2; |
---|
[872] | 95 | |
---|
[1179] | 96 | for (Int i = 0; i <= vps->getMaxLayersMinus1(); i++) |
---|
| 97 | { |
---|
[1356] | 98 | Int curViewIdxInVps = m_vps->getVoiInVps( m_vps->getViewIndex( m_vps->getLayerIdInNuh( i ) ) ) ; |
---|
| 99 | m_bCamParsVaryOverTime = m_bCamParsVaryOverTime || vps->getCpInSliceSegmentHeaderFlag( curViewIdxInVps ); |
---|
[1179] | 100 | } |
---|
| 101 | |
---|
[1356] | 102 | assert( m_receivedIdc == NULL ); |
---|
| 103 | m_receivedIdc = new Int*[ m_vps->getNumViews() ]; |
---|
[1179] | 104 | for (Int i = 0; i < m_vps->getNumViews(); i++) |
---|
| 105 | { |
---|
[1356] | 106 | m_receivedIdc[i] = new Int[ m_vps->getNumViews() ]; |
---|
[1179] | 107 | } |
---|
| 108 | |
---|
[1356] | 109 | xResetReceivedIdc( true ); |
---|
[1179] | 110 | |
---|
| 111 | for (Int voiInVps = 0; voiInVps < m_vps->getNumViews(); voiInVps++ ) |
---|
| 112 | { |
---|
[1356] | 113 | if( !m_vps->getCpInSliceSegmentHeaderFlag( voiInVps ) ) |
---|
[1179] | 114 | { |
---|
| 115 | for (Int baseVoiInVps = 0; baseVoiInVps < m_vps->getNumViews(); baseVoiInVps++ ) |
---|
[1356] | 116 | { |
---|
[1179] | 117 | if( m_vps->getCpPresentFlag( voiInVps, baseVoiInVps ) ) |
---|
| 118 | { |
---|
[1356] | 119 | m_receivedIdc [ baseVoiInVps ][ voiInVps ] = -1; |
---|
[1179] | 120 | m_aaiCodedScale [ baseVoiInVps ][ voiInVps ] = m_vps->getCodedScale (voiInVps) [ baseVoiInVps ]; |
---|
| 121 | m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ] = m_vps->getCodedOffset (voiInVps) [ baseVoiInVps ]; |
---|
| 122 | |
---|
[1356] | 123 | m_receivedIdc [ voiInVps ][ baseVoiInVps ] = -1; |
---|
[1179] | 124 | m_aaiCodedScale [ voiInVps ][ baseVoiInVps ] = m_vps->getInvCodedScale (voiInVps) [ baseVoiInVps ]; |
---|
| 125 | m_aaiCodedOffset[ voiInVps ][ baseVoiInVps ] = m_vps->getInvCodedOffset(voiInVps) [ baseVoiInVps ]; |
---|
| 126 | xInitLUTs( baseVoiInVps, voiInVps, m_aaiCodedScale[ baseVoiInVps ][ voiInVps ], m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT ); |
---|
| 127 | xInitLUTs( voiInVps, baseVoiInVps, m_aaiCodedScale[ voiInVps ][ baseVoiInVps ], m_aaiCodedOffset[ voiInVps ][ baseVoiInVps ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT ); |
---|
| 128 | } |
---|
| 129 | } |
---|
| 130 | } |
---|
| 131 | } |
---|
| 132 | } |
---|
| 133 | |
---|
[872] | 134 | Void |
---|
| 135 | CamParsCollector::xResetReceivedIdc( Bool overWriteFlag ) |
---|
| 136 | { |
---|
[1179] | 137 | for (Int i = 0; i < m_vps->getNumViews(); i++) |
---|
[1356] | 138 | { |
---|
[1179] | 139 | for (Int j = 0; j < m_vps->getNumViews(); j++) |
---|
| 140 | { |
---|
[872] | 141 | if ( overWriteFlag || ( m_receivedIdc[i][j] != -1 ) ) |
---|
| 142 | { |
---|
[1356] | 143 | m_receivedIdc[i][j] = 0; |
---|
| 144 | } |
---|
[872] | 145 | } |
---|
| 146 | } |
---|
| 147 | } |
---|
[2] | 148 | |
---|
[872] | 149 | |
---|
[2] | 150 | Void |
---|
[296] | 151 | CamParsCollector::xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT) |
---|
| 152 | { |
---|
| 153 | |
---|
[608] | 154 | uiNumberSourceViews = std::max( (UInt) 1, uiNumberSourceViews ); |
---|
| 155 | uiNumberTargetViews = std::max( (UInt) 1, uiNumberTargetViews ); |
---|
[296] | 156 | |
---|
| 157 | radLUT = new Double***[ uiNumberSourceViews ]; |
---|
| 158 | raiLUT = new Int ***[ uiNumberSourceViews ]; |
---|
| 159 | |
---|
| 160 | for( UInt uiSourceView = 0; uiSourceView < uiNumberSourceViews; uiSourceView++ ) |
---|
| 161 | { |
---|
| 162 | radLUT [ uiSourceView ] = new Double**[ uiNumberTargetViews ]; |
---|
| 163 | raiLUT [ uiSourceView ] = new Int **[ uiNumberTargetViews ]; |
---|
| 164 | |
---|
| 165 | for( UInt uiTargetView = 0; uiTargetView < uiNumberTargetViews; uiTargetView++ ) |
---|
| 166 | { |
---|
| 167 | radLUT [ uiSourceView ][ uiTargetView ] = new Double*[ 2 ]; |
---|
| 168 | radLUT [ uiSourceView ][ uiTargetView ][ 0 ] = new Double [ 257 ]; |
---|
| 169 | radLUT [ uiSourceView ][ uiTargetView ][ 1 ] = new Double [ 257 ]; |
---|
| 170 | |
---|
| 171 | raiLUT [ uiSourceView ][ uiTargetView ] = new Int* [ 2 ]; |
---|
| 172 | raiLUT [ uiSourceView ][ uiTargetView ][ 0 ] = new Int [ 257 ]; |
---|
| 173 | raiLUT [ uiSourceView ][ uiTargetView ][ 1 ] = new Int [ 257 ]; |
---|
| 174 | } |
---|
| 175 | } |
---|
| 176 | } |
---|
| 177 | |
---|
[1356] | 178 | Void |
---|
[296] | 179 | CamParsCollector::xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT) |
---|
| 180 | { |
---|
[1179] | 181 | Int iLog2DivLuma = m_uiBitDepthForLUT + m_vps->getCpPrecision() + 1 - m_iLog2Precision; AOF( iLog2DivLuma > 0 ); |
---|
[296] | 182 | Int iLog2DivChroma = iLog2DivLuma + 1; |
---|
| 183 | |
---|
| 184 | iOffset <<= m_uiBitDepthForLUT; |
---|
| 185 | |
---|
| 186 | Double dScale = (Double) iScale / (( Double ) ( 1 << iLog2DivLuma )); |
---|
| 187 | Double dOffset = (Double) iOffset / (( Double ) ( 1 << iLog2DivLuma )); |
---|
| 188 | |
---|
| 189 | // offsets including rounding offsets |
---|
| 190 | Int64 iOffsetLuma = iOffset + ( ( 1 << iLog2DivLuma ) >> 1 ); |
---|
| 191 | Int64 iOffsetChroma = iOffset + ( ( 1 << iLog2DivChroma ) >> 1 ); |
---|
| 192 | |
---|
| 193 | |
---|
| 194 | for( UInt uiDepthValue = 0; uiDepthValue < 256; uiDepthValue++ ) |
---|
| 195 | { |
---|
| 196 | |
---|
| 197 | // real-valued look-up tables |
---|
| 198 | Double dShiftLuma = ( (Double)uiDepthValue * dScale + dOffset ) * Double( 1 << m_iLog2Precision ); |
---|
| 199 | Double dShiftChroma = dShiftLuma / 2; |
---|
| 200 | radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = dShiftLuma; |
---|
| 201 | radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = dShiftChroma; |
---|
| 202 | |
---|
| 203 | // integer-valued look-up tables |
---|
| 204 | Int64 iTempScale = (Int64)uiDepthValue * iScale; |
---|
| 205 | Int64 iShiftLuma = ( iTempScale + iOffsetLuma ) >> iLog2DivLuma; |
---|
| 206 | Int64 iShiftChroma = ( iTempScale + iOffsetChroma ) >> iLog2DivChroma; |
---|
| 207 | raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = (Int)iShiftLuma; |
---|
| 208 | raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = (Int)iShiftChroma; |
---|
| 209 | } |
---|
| 210 | |
---|
| 211 | radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ]; |
---|
| 212 | radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ]; |
---|
| 213 | raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ]; |
---|
| 214 | raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ]; |
---|
| 215 | } |
---|
| 216 | |
---|
| 217 | Void |
---|
[2] | 218 | CamParsCollector::uninit() |
---|
| 219 | { |
---|
| 220 | m_bInitialized = false; |
---|
| 221 | } |
---|
| 222 | |
---|
[1313] | 223 | Void CamParsCollector::setSlice( const TComSlice* pcSlice ) |
---|
[2] | 224 | { |
---|
| 225 | if( pcSlice == 0 ) |
---|
| 226 | { |
---|
[872] | 227 | xOutput( m_lastPoc ); |
---|
| 228 | return; |
---|
| 229 | } |
---|
| 230 | |
---|
| 231 | if ( pcSlice->getIsDepth()) |
---|
| 232 | { |
---|
| 233 | return; |
---|
| 234 | } |
---|
| 235 | |
---|
| 236 | Int curPoc = pcSlice->getPOC(); |
---|
| 237 | if( m_firstReceivedPoc == -2 ) |
---|
| 238 | { |
---|
[1356] | 239 | m_firstReceivedPoc = curPoc; |
---|
[872] | 240 | } |
---|
| 241 | |
---|
[1356] | 242 | Bool newPocFlag = ( m_lastPoc != curPoc ); |
---|
[872] | 243 | |
---|
| 244 | if ( newPocFlag ) |
---|
[1356] | 245 | { |
---|
[872] | 246 | if( m_lastPoc != -1 ) |
---|
| 247 | { |
---|
| 248 | xOutput( m_lastPoc ); |
---|
| 249 | } |
---|
| 250 | |
---|
[1356] | 251 | xResetReceivedIdc( false ); |
---|
[872] | 252 | m_lastPoc = pcSlice->getPOC(); |
---|
| 253 | } |
---|
| 254 | |
---|
[1356] | 255 | UInt voiInVps = m_vps->getVoiInVps(pcSlice->getViewIndex()); |
---|
[1179] | 256 | if( m_vps->getCpInSliceSegmentHeaderFlag( voiInVps ) ) // check consistency of slice parameters here |
---|
[1356] | 257 | { |
---|
[1179] | 258 | for( Int baseVoiInVps = 0; baseVoiInVps < m_vps->getNumViews(); baseVoiInVps++ ) |
---|
[1356] | 259 | { |
---|
[1179] | 260 | if ( m_vps->getCpPresentFlag( voiInVps, baseVoiInVps ) ) |
---|
| 261 | { |
---|
| 262 | if ( m_receivedIdc[ voiInVps ][ baseVoiInVps ] != 0 ) |
---|
[1356] | 263 | { |
---|
[1179] | 264 | AOF( m_aaiCodedScale [ voiInVps ][ baseVoiInVps ] == pcSlice->getInvCodedScale () [ baseVoiInVps ] ); |
---|
| 265 | AOF( m_aaiCodedOffset[ voiInVps ][ baseVoiInVps ] == pcSlice->getInvCodedOffset() [ baseVoiInVps ] ); |
---|
| 266 | } |
---|
| 267 | else |
---|
[1356] | 268 | { |
---|
| 269 | m_receivedIdc [ voiInVps ][ baseVoiInVps ] = 1; |
---|
[1179] | 270 | m_aaiCodedScale [ voiInVps ][ baseVoiInVps ] = pcSlice->getInvCodedScale () [ baseVoiInVps ]; |
---|
| 271 | m_aaiCodedOffset[ voiInVps ][ baseVoiInVps ] = pcSlice->getInvCodedOffset() [ baseVoiInVps ]; |
---|
| 272 | xInitLUTs( voiInVps, baseVoiInVps, m_aaiCodedScale[ voiInVps ][ baseVoiInVps ], m_aaiCodedOffset[ voiInVps ][ baseVoiInVps ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT); |
---|
| 273 | } |
---|
| 274 | if ( m_receivedIdc[ baseVoiInVps ][ voiInVps ] != 0 ) |
---|
[1356] | 275 | { |
---|
[1179] | 276 | AOF( m_aaiCodedScale [ baseVoiInVps ][ voiInVps ] == pcSlice->getCodedScale () [ baseVoiInVps ] ); |
---|
| 277 | AOF( m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ] == pcSlice->getCodedOffset () [ baseVoiInVps ] ); |
---|
| 278 | } |
---|
| 279 | else |
---|
[1356] | 280 | { |
---|
| 281 | m_receivedIdc [ baseVoiInVps ][ voiInVps ] = 1; |
---|
[1179] | 282 | m_aaiCodedScale [ baseVoiInVps ][ voiInVps ] = pcSlice->getCodedScale () [ baseVoiInVps ]; |
---|
| 283 | m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ] = pcSlice->getCodedOffset () [ baseVoiInVps ]; |
---|
| 284 | xInitLUTs( baseVoiInVps, voiInVps, m_aaiCodedScale[ baseVoiInVps ][ voiInVps ], m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT); |
---|
| 285 | } |
---|
| 286 | } |
---|
| 287 | } |
---|
[1356] | 288 | } |
---|
[872] | 289 | } |
---|
| 290 | |
---|
[724] | 291 | Void |
---|
[2] | 292 | CamParsCollector::xOutput( Int iPOC ) |
---|
| 293 | { |
---|
| 294 | if( m_pCodedScaleOffsetFile ) |
---|
| 295 | { |
---|
[872] | 296 | if( iPOC == m_firstReceivedPoc ) |
---|
[2] | 297 | { |
---|
[1179] | 298 | fprintf( m_pCodedScaleOffsetFile, "#ViewOrderIdx ViewIdVal\n" ); |
---|
| 299 | fprintf( m_pCodedScaleOffsetFile, "#------------ -------------\n" ); |
---|
[1356] | 300 | |
---|
[1179] | 301 | for( UInt voiInVps = 0; voiInVps < m_vps->getNumViews(); voiInVps++ ) |
---|
| 302 | { |
---|
| 303 | fprintf( m_pCodedScaleOffsetFile, "%13d %13d\n", m_vps->getViewOIdxList( voiInVps ), m_vps->getViewIdVal( m_vps->getViewOIdxList( voiInVps ) ) ); |
---|
| 304 | } |
---|
| 305 | fprintf( m_pCodedScaleOffsetFile, "\n\n"); |
---|
| 306 | fprintf( m_pCodedScaleOffsetFile, "# StartFrame EndFrame TargetVOI BaseVOI CodedScale CodedOffset Precision\n" ); |
---|
| 307 | fprintf( m_pCodedScaleOffsetFile, "#----------- ------------ ------------ ------------ ------------ ------------ ------------\n" ); |
---|
| 308 | } |
---|
| 309 | if( iPOC == m_firstReceivedPoc || m_bCamParsVaryOverTime ) |
---|
| 310 | { |
---|
| 311 | Int iS = iPOC; |
---|
| 312 | Int iE = ( m_bCamParsVaryOverTime ? iPOC : ~( 1 << 31 ) ); |
---|
| 313 | for( UInt voiInVps = 0; voiInVps < m_vps->getNumViews(); voiInVps++ ) |
---|
| 314 | { |
---|
| 315 | for( UInt baseVoiInVps = 0; baseVoiInVps < m_vps->getNumViews(); baseVoiInVps++ ) |
---|
| 316 | { |
---|
| 317 | if( voiInVps != baseVoiInVps ) |
---|
| 318 | { |
---|
| 319 | if ( m_receivedIdc[baseVoiInVps][voiInVps] != 0 ) |
---|
[1356] | 320 | { |
---|
[1179] | 321 | fprintf( m_pCodedScaleOffsetFile, "%12d %12d %12d %12d %12d %12d %12d\n", |
---|
[1356] | 322 | iS, iE, m_vps->getViewOIdxList( voiInVps ), m_vps->getViewOIdxList( baseVoiInVps ), |
---|
| 323 | m_aaiCodedScale [ baseVoiInVps ][ voiInVps ], |
---|
[1179] | 324 | m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ], m_vps->getCpPrecision() ); |
---|
[1356] | 325 | } |
---|
[2] | 326 | } |
---|
| 327 | } |
---|
| 328 | } |
---|
| 329 | } |
---|
| 330 | } |
---|
| 331 | } |
---|
[608] | 332 | #endif |
---|
[1196] | 333 | |
---|
[1313] | 334 | |
---|
[2] | 335 | TDecTop::TDecTop() |
---|
[1313] | 336 | : m_iMaxRefPicNum(0) |
---|
[1321] | 337 | #if !NH_MV |
---|
[1313] | 338 | , m_associatedIRAPType(NAL_UNIT_INVALID) |
---|
[1356] | 339 | , m_pocCRA(0) |
---|
[1313] | 340 | , m_pocRandomAccess(MAX_INT) |
---|
| 341 | , m_cListPic() |
---|
| 342 | , m_parameterSetManager() |
---|
| 343 | #endif |
---|
| 344 | , m_apcSlicePilot(NULL) |
---|
| 345 | , m_SEIs() |
---|
| 346 | , m_cPrediction() |
---|
| 347 | , m_cTrQuant() |
---|
| 348 | , m_cGopDecoder() |
---|
| 349 | , m_cSliceDecoder() |
---|
| 350 | , m_cCuDecoder() |
---|
| 351 | , m_cEntropyDecoder() |
---|
| 352 | , m_cCavlcDecoder() |
---|
| 353 | , m_cSbacDecoder() |
---|
| 354 | , m_cBinCABAC() |
---|
| 355 | , m_seiReader() |
---|
| 356 | , m_cLoopFilter() |
---|
| 357 | , m_cSAO() |
---|
| 358 | , m_pcPic(NULL) |
---|
[1321] | 359 | #if !NH_MV |
---|
[1313] | 360 | , m_prevPOC(MAX_INT) |
---|
| 361 | , m_prevTid0POC(0) |
---|
| 362 | , m_bFirstSliceInPicture(true) |
---|
| 363 | , m_bFirstSliceInSequence(true) |
---|
| 364 | , m_prevSliceSkipped(false) |
---|
| 365 | , m_skippedPOC(0) |
---|
| 366 | , m_bFirstSliceInBitstream(true) |
---|
| 367 | , m_lastPOCNoOutputPriorPics(-1) |
---|
| 368 | , m_isNoOutputPriorPics(false) |
---|
| 369 | , m_craNoRaslOutputFlag(false) |
---|
[1321] | 370 | #endif |
---|
[1313] | 371 | #if O0043_BEST_EFFORT_DECODING |
---|
| 372 | , m_forceDecodeBitDepth(8) |
---|
| 373 | #endif |
---|
| 374 | , m_pDecodedSEIOutputStream(NULL) |
---|
[1321] | 375 | #if !NH_MV |
---|
[1313] | 376 | , m_warningMessageSkipPicture(false) |
---|
[1321] | 377 | #endif |
---|
[1413] | 378 | #if MCTS_ENC_CHECK |
---|
| 379 | , m_tmctsCheckEnabled(false) |
---|
| 380 | #endif |
---|
[1313] | 381 | , m_prefixSEINALUs() |
---|
[2] | 382 | { |
---|
[1321] | 383 | #if !NH_MV |
---|
[2] | 384 | #if ENC_DEC_TRACE |
---|
[1313] | 385 | if (g_hTrace == NULL) |
---|
| 386 | { |
---|
| 387 | g_hTrace = fopen( "TraceDec.txt", "wb" ); |
---|
| 388 | } |
---|
[2] | 389 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
| 390 | g_nSymbolCounter = 0; |
---|
| 391 | #endif |
---|
[608] | 392 | #endif |
---|
[1321] | 393 | |
---|
[1313] | 394 | #if NH_MV |
---|
[1321] | 395 | m_layerId = 0; |
---|
| 396 | m_viewId = 0; |
---|
| 397 | |
---|
[1313] | 398 | #if NH_3D |
---|
[1321] | 399 | m_viewIndex = 0; |
---|
| 400 | m_isDepth = false; |
---|
| 401 | m_pcCamParsCollector = 0; |
---|
[210] | 402 | #endif |
---|
[1321] | 403 | |
---|
| 404 | m_decodingProcess = CLAUSE_8; |
---|
| 405 | m_targetOlsIdx = -1; |
---|
| 406 | m_smallestLayerId = -1; |
---|
| 407 | m_isInOwnTargetDecLayerIdList = 0; |
---|
| 408 | m_prevPicOrderCnt = 0; |
---|
| 409 | m_pocDecrementedInDpbFlag = NULL; |
---|
| 410 | m_firstPicInLayerDecodedFlag = NULL; |
---|
| 411 | m_lastPresentPocResetIdc = NULL; |
---|
| 412 | |
---|
| 413 | m_prevIrapPoc = MIN_INT; |
---|
| 414 | m_prevIrapDecodingOrder = MIN_INT; |
---|
| 415 | m_prevStsaDecOrder = MIN_INT; |
---|
| 416 | m_prevStsaTemporalId = MIN_INT; |
---|
[608] | 417 | #endif |
---|
[2] | 418 | } |
---|
| 419 | |
---|
| 420 | TDecTop::~TDecTop() |
---|
| 421 | { |
---|
| 422 | #if ENC_DEC_TRACE |
---|
[1321] | 423 | #if NH_MV |
---|
[1313] | 424 | if (g_hTrace != stdout && g_hTrace != NULL) |
---|
[1321] | 425 | { |
---|
| 426 | fclose( g_hTrace ); |
---|
| 427 | g_hTrace = NULL; |
---|
| 428 | } |
---|
[1313] | 429 | #else |
---|
| 430 | if (g_hTrace != stdout) |
---|
| 431 | { |
---|
| 432 | fclose( g_hTrace ); |
---|
| 433 | } |
---|
| 434 | #endif |
---|
[1356] | 435 | #endif |
---|
[1313] | 436 | while (!m_prefixSEINALUs.empty()) |
---|
| 437 | { |
---|
| 438 | delete m_prefixSEINALUs.front(); |
---|
| 439 | m_prefixSEINALUs.pop_front(); |
---|
| 440 | } |
---|
[2] | 441 | } |
---|
| 442 | |
---|
| 443 | Void TDecTop::create() |
---|
| 444 | { |
---|
| 445 | m_cGopDecoder.create(); |
---|
| 446 | m_apcSlicePilot = new TComSlice; |
---|
[608] | 447 | m_uiSliceIdx = 0; |
---|
[2] | 448 | } |
---|
| 449 | |
---|
| 450 | Void TDecTop::destroy() |
---|
| 451 | { |
---|
[1321] | 452 | |
---|
| 453 | #if NH_MV |
---|
| 454 | m_cSAO.destroy(); |
---|
| 455 | m_cLoopFilter. destroy(); |
---|
| 456 | #endif |
---|
| 457 | |
---|
[2] | 458 | m_cGopDecoder.destroy(); |
---|
[1313] | 459 | |
---|
[2] | 460 | delete m_apcSlicePilot; |
---|
| 461 | m_apcSlicePilot = NULL; |
---|
[1313] | 462 | |
---|
[2] | 463 | m_cSliceDecoder.destroy(); |
---|
| 464 | } |
---|
| 465 | |
---|
[608] | 466 | Void TDecTop::init() |
---|
[2] | 467 | { |
---|
| 468 | // initialize ROM |
---|
[1313] | 469 | #if !NH_MV |
---|
[56] | 470 | initROM(); |
---|
[5] | 471 | #endif |
---|
[1313] | 472 | #if NH_MV |
---|
[1356] | 473 | m_cCavlcDecoder.setDecTop( this ); |
---|
[1179] | 474 | #endif |
---|
[1313] | 475 | m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO); |
---|
[1413] | 476 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder, &m_conformanceCheck ); |
---|
| 477 | #if MCTS_ENC_CHECK |
---|
| 478 | m_cEntropyDecoder.init(&m_cPrediction, &m_conformanceCheck ); |
---|
| 479 | #else |
---|
[2] | 480 | m_cEntropyDecoder.init(&m_cPrediction); |
---|
[1413] | 481 | #endif |
---|
[2] | 482 | } |
---|
| 483 | |
---|
[1321] | 484 | #if !NH_MV |
---|
[2] | 485 | Void TDecTop::deletePicBuffer ( ) |
---|
| 486 | { |
---|
[1321] | 487 | |
---|
[2] | 488 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 489 | Int iSize = Int( m_cListPic.size() ); |
---|
[1313] | 490 | |
---|
[2] | 491 | for (Int i = 0; i < iSize; i++ ) |
---|
| 492 | { |
---|
[608] | 493 | TComPic* pcPic = *(iterPic++); |
---|
| 494 | pcPic->destroy(); |
---|
[1313] | 495 | |
---|
[608] | 496 | delete pcPic; |
---|
| 497 | pcPic = NULL; |
---|
[2] | 498 | } |
---|
[1313] | 499 | |
---|
[2] | 500 | m_cSAO.destroy(); |
---|
[1313] | 501 | |
---|
[2] | 502 | m_cLoopFilter. destroy(); |
---|
[1313] | 503 | |
---|
[2] | 504 | // destroy ROM |
---|
[608] | 505 | destroyROM(); |
---|
[2] | 506 | } |
---|
| 507 | |
---|
[1313] | 508 | Void TDecTop::xGetNewPicBuffer ( const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer ) |
---|
[56] | 509 | { |
---|
[1313] | 510 | m_iMaxRefPicNum = sps.getMaxDecPicBuffering(temporalLayer); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
[2] | 511 | if (m_cListPic.size() < (UInt)m_iMaxRefPicNum) |
---|
| 512 | { |
---|
[56] | 513 | rpcPic = new TComPic(); |
---|
[1313] | 514 | |
---|
[1413] | 515 | #if REDUCED_ENCODER_MEMORY |
---|
| 516 | rpcPic->create ( sps, pps, false, true); |
---|
| 517 | #else |
---|
[1313] | 518 | rpcPic->create ( sps, pps, true); |
---|
[1413] | 519 | #endif |
---|
[1313] | 520 | |
---|
[2] | 521 | m_cListPic.pushBack( rpcPic ); |
---|
[1313] | 522 | |
---|
[2] | 523 | return; |
---|
| 524 | } |
---|
[1313] | 525 | |
---|
[2] | 526 | Bool bBufferIsAvailable = false; |
---|
| 527 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 528 | while (iterPic != m_cListPic.end()) |
---|
| 529 | { |
---|
| 530 | rpcPic = *(iterPic++); |
---|
[56] | 531 | if ( rpcPic->getReconMark() == false && rpcPic->getOutputMark() == false) |
---|
[2] | 532 | { |
---|
[56] | 533 | rpcPic->setOutputMark(false); |
---|
[2] | 534 | bBufferIsAvailable = true; |
---|
| 535 | break; |
---|
| 536 | } |
---|
[56] | 537 | |
---|
| 538 | if ( rpcPic->getSlice( 0 )->isReferenced() == false && rpcPic->getOutputMark() == false) |
---|
| 539 | { |
---|
| 540 | rpcPic->setOutputMark(false); |
---|
| 541 | rpcPic->setReconMark( false ); |
---|
| 542 | rpcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
| 543 | bBufferIsAvailable = true; |
---|
| 544 | break; |
---|
| 545 | } |
---|
[2] | 546 | } |
---|
[1313] | 547 | |
---|
[2] | 548 | if ( !bBufferIsAvailable ) |
---|
| 549 | { |
---|
[56] | 550 | //There is no room for this picture, either because of faulty encoder or dropped NAL. Extend the buffer. |
---|
| 551 | m_iMaxRefPicNum++; |
---|
| 552 | rpcPic = new TComPic(); |
---|
| 553 | m_cListPic.pushBack( rpcPic ); |
---|
[2] | 554 | } |
---|
[608] | 555 | rpcPic->destroy(); |
---|
[1413] | 556 | #if REDUCED_ENCODER_MEMORY |
---|
| 557 | rpcPic->create ( sps, pps, false, true); |
---|
| 558 | #else |
---|
[1313] | 559 | rpcPic->create ( sps, pps, true); |
---|
[1413] | 560 | #endif |
---|
[2] | 561 | } |
---|
[1321] | 562 | |
---|
[608] | 563 | Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic) |
---|
[56] | 564 | { |
---|
| 565 | if (!m_pcPic) |
---|
| 566 | { |
---|
| 567 | /* nothing to deblock */ |
---|
| 568 | return; |
---|
| 569 | } |
---|
[2] | 570 | |
---|
[1313] | 571 | TComPic* pcPic = m_pcPic; |
---|
| 572 | |
---|
[608] | 573 | // Execute Deblock + Cleanup |
---|
[56] | 574 | |
---|
[608] | 575 | m_cGopDecoder.filterPicture(pcPic); |
---|
[56] | 576 | |
---|
| 577 | TComSlice::sortPicList( m_cListPic ); // sorting for application output |
---|
[608] | 578 | poc = pcPic->getSlice(m_uiSliceIdx-1)->getPOC(); |
---|
[1313] | 579 | rpcListPic = &m_cListPic; |
---|
| 580 | m_cCuDecoder.destroy(); |
---|
[56] | 581 | m_bFirstSliceInPicture = true; |
---|
| 582 | return; |
---|
| 583 | } |
---|
| 584 | |
---|
[1313] | 585 | Void TDecTop::checkNoOutputPriorPics (TComList<TComPic*>* pcListPic) |
---|
[964] | 586 | { |
---|
[1313] | 587 | if (!pcListPic || !m_isNoOutputPriorPics) |
---|
| 588 | { |
---|
| 589 | return; |
---|
| 590 | } |
---|
[964] | 591 | |
---|
[1313] | 592 | TComList<TComPic*>::iterator iterPic = pcListPic->begin(); |
---|
[964] | 593 | |
---|
[1313] | 594 | while (iterPic != pcListPic->end()) |
---|
[964] | 595 | { |
---|
[1313] | 596 | TComPic* pcPicTmp = *(iterPic++); |
---|
[964] | 597 | if (m_lastPOCNoOutputPriorPics != pcPicTmp->getPOC()) |
---|
| 598 | { |
---|
| 599 | pcPicTmp->setOutputMark(false); |
---|
| 600 | } |
---|
| 601 | } |
---|
| 602 | } |
---|
| 603 | |
---|
[1313] | 604 | Void TDecTop::xCreateLostPicture(Int iLostPoc) |
---|
[2] | 605 | { |
---|
[56] | 606 | printf("\ninserting lost poc : %d\n",iLostPoc); |
---|
| 607 | TComPic *cFillPic; |
---|
[1313] | 608 | xGetNewPicBuffer(*(m_parameterSetManager.getFirstSPS()), *(m_parameterSetManager.getFirstPPS()), cFillPic, 0); |
---|
[56] | 609 | cFillPic->getSlice(0)->initSlice(); |
---|
[1313] | 610 | |
---|
[56] | 611 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 612 | Int closestPoc = 1000000; |
---|
| 613 | while ( iterPic != m_cListPic.end()) |
---|
[2] | 614 | { |
---|
[56] | 615 | TComPic * rpcPic = *(iterPic++); |
---|
| 616 | 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] | 617 | { |
---|
[56] | 618 | closestPoc=abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc); |
---|
| 619 | } |
---|
| 620 | } |
---|
| 621 | iterPic = m_cListPic.begin(); |
---|
| 622 | while ( iterPic != m_cListPic.end()) |
---|
| 623 | { |
---|
| 624 | TComPic *rpcPic = *(iterPic++); |
---|
| 625 | if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)==closestPoc&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC()) |
---|
| 626 | { |
---|
| 627 | printf("copying picture %d to %d (%d)\n",rpcPic->getPicSym()->getSlice(0)->getPOC() ,iLostPoc,m_apcSlicePilot->getPOC()); |
---|
| 628 | rpcPic->getPicYuvRec()->copyToPic(cFillPic->getPicYuvRec()); |
---|
[2] | 629 | break; |
---|
| 630 | } |
---|
| 631 | } |
---|
[56] | 632 | cFillPic->setCurrSliceIdx(0); |
---|
[1313] | 633 | for(Int ctuRsAddr=0; ctuRsAddr<cFillPic->getNumberOfCtusInFrame(); ctuRsAddr++) |
---|
[2] | 634 | { |
---|
[1313] | 635 | cFillPic->getCtu(ctuRsAddr)->initCtu(cFillPic, ctuRsAddr); |
---|
[2] | 636 | } |
---|
[56] | 637 | cFillPic->getSlice(0)->setReferenced(true); |
---|
| 638 | cFillPic->getSlice(0)->setPOC(iLostPoc); |
---|
[1313] | 639 | xUpdatePreviousTid0POC(cFillPic->getSlice(0)); |
---|
[56] | 640 | cFillPic->setReconMark(true); |
---|
| 641 | cFillPic->setOutputMark(true); |
---|
| 642 | if(m_pocRandomAccess == MAX_INT) |
---|
| 643 | { |
---|
| 644 | m_pocRandomAccess = iLostPoc; |
---|
| 645 | } |
---|
[2] | 646 | } |
---|
[1321] | 647 | #endif |
---|
[2] | 648 | |
---|
[56] | 649 | |
---|
[1321] | 650 | #if NH_MV |
---|
| 651 | Void TDecTop::activatePSsAndInitPicOrSlice( TComPic* newPic ) |
---|
| 652 | { |
---|
| 653 | if ( m_apcSlicePilot->getFirstSliceSegementInPicFlag() ) |
---|
| 654 | { |
---|
| 655 | assert( newPic != NULL ); |
---|
| 656 | |
---|
| 657 | #else |
---|
[56] | 658 | Void TDecTop::xActivateParameterSets() |
---|
[2] | 659 | { |
---|
[1313] | 660 | if (m_bFirstSliceInPicture) |
---|
| 661 | { |
---|
[1321] | 662 | #endif |
---|
[1313] | 663 | const TComPPS *pps = m_parameterSetManager.getPPS(m_apcSlicePilot->getPPSId()); // this is a temporary PPS object. Do not store this value |
---|
| 664 | assert (pps != 0); |
---|
[56] | 665 | |
---|
[1313] | 666 | const TComSPS *sps = m_parameterSetManager.getSPS(pps->getSPSId()); // this is a temporary SPS object. Do not store this value |
---|
| 667 | assert (sps != 0); |
---|
[608] | 668 | |
---|
[1313] | 669 | m_parameterSetManager.clearSPSChangedFlag(sps->getSPSId()); |
---|
| 670 | m_parameterSetManager.clearPPSChangedFlag(pps->getPPSId()); |
---|
| 671 | #if NH_MV |
---|
| 672 | const TComVPS* vps = m_parameterSetManager.getVPS(sps->getVPSId()); |
---|
[1356] | 673 | assert (vps != 0); |
---|
| 674 | // TBD: check the condition on m_firstPicInLayerDecodedFlag |
---|
[1321] | 675 | if (!m_parameterSetManager.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP() || !m_firstPicInLayerDecodedFlag[m_layerId] , m_layerId ) ) |
---|
[622] | 676 | #else |
---|
[1313] | 677 | if (false == m_parameterSetManager.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP())) |
---|
[622] | 678 | #endif |
---|
[1313] | 679 | { |
---|
| 680 | printf ("Parameter set activation failed!"); |
---|
| 681 | assert (0); |
---|
| 682 | } |
---|
[608] | 683 | |
---|
[1313] | 684 | #if NH_MV |
---|
[1321] | 685 | if ( decProcAnnexG() ) |
---|
| 686 | { |
---|
| 687 | // When the value of vps_num_rep_formats_minus1 in the active VPS is equal to 0 |
---|
| 688 | if ( vps->getVpsNumRepFormatsMinus1() == 0 ) |
---|
| 689 | { |
---|
| 690 | //, it is a requirement of bitstream conformance that the value of update_rep_format_flag shall be equal to 0. |
---|
[1356] | 691 | assert( sps->getUpdateRepFormatFlag() == false ); |
---|
[1321] | 692 | } |
---|
[1356] | 693 | sps->checkRpsMaxNumPics( vps, getLayerId() ); |
---|
[1066] | 694 | |
---|
[1356] | 695 | // It is a requirement of bitstream conformance that, when the SPS is referred to by |
---|
| 696 | // any current picture that belongs to an independent non-base layer, the value of |
---|
[1321] | 697 | // MultiLayerExtSpsFlag derived from the SPS shall be equal to 0. |
---|
[1066] | 698 | |
---|
[1321] | 699 | if ( m_layerId > 0 && vps->getNumRefLayers( m_layerId ) == 0 ) |
---|
[1356] | 700 | { |
---|
| 701 | assert( sps->getMultiLayerExtSpsFlag() == 0 ); |
---|
[1321] | 702 | } |
---|
| 703 | } |
---|
[1356] | 704 | m_seiReader.setLayerId ( newPic->getLayerId ( ) ); |
---|
| 705 | m_seiReader.setDecOrder( newPic->getDecodingOrder( ) ); |
---|
[1313] | 706 | #endif |
---|
[1066] | 707 | |
---|
[1313] | 708 | xParsePrefixSEImessages(); |
---|
[1413] | 709 | #if MCTS_ENC_CHECK |
---|
| 710 | xAnalysePrefixSEImessages(); |
---|
| 711 | #endif |
---|
[1313] | 712 | |
---|
| 713 | #if RExt__HIGH_BIT_DEPTH_SUPPORT==0 |
---|
| 714 | if (sps->getSpsRangeExtension().getExtendedPrecisionProcessingFlag() || sps->getBitDepth(CHANNEL_TYPE_LUMA)>12 || sps->getBitDepth(CHANNEL_TYPE_CHROMA)>12 ) |
---|
| 715 | { |
---|
| 716 | printf("High bit depth support must be enabled at compile-time in order to decode this bitstream\n"); |
---|
| 717 | assert (0); |
---|
| 718 | exit(1); |
---|
| 719 | } |
---|
[964] | 720 | #endif |
---|
| 721 | |
---|
[1313] | 722 | // NOTE: globals were set up here originally. You can now use: |
---|
| 723 | // g_uiMaxCUDepth = sps->getMaxTotalCUDepth(); |
---|
| 724 | // g_uiAddCUDepth = sps->getMaxTotalCUDepth() - sps->getLog2DiffMaxMinCodingBlockSize() |
---|
[608] | 725 | |
---|
[1313] | 726 | // 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. |
---|
[1321] | 727 | #if !NH_MV |
---|
[1313] | 728 | xGetNewPicBuffer (*(sps), *(pps), m_pcPic, m_apcSlicePilot->getTLayer()); |
---|
[1321] | 729 | |
---|
[1313] | 730 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
---|
[1321] | 731 | #else |
---|
[1356] | 732 | m_pcPic = newPic; |
---|
[1313] | 733 | #endif |
---|
| 734 | |
---|
| 735 | // make the slice-pilot a real slice, and set up the slice-pilot for the next slice |
---|
| 736 | assert(m_pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
| 737 | m_apcSlicePilot = m_pcPic->getPicSym()->swapSliceObject(m_apcSlicePilot, m_uiSliceIdx); |
---|
| 738 | |
---|
| 739 | // we now have a real slice: |
---|
| 740 | TComSlice *pSlice = m_pcPic->getSlice(m_uiSliceIdx); |
---|
| 741 | |
---|
| 742 | // Update the PPS and SPS pointers with the ones of the picture. |
---|
| 743 | pps=pSlice->getPPS(); |
---|
| 744 | sps=pSlice->getSPS(); |
---|
| 745 | |
---|
[1413] | 746 | #if NH_MV |
---|
[1321] | 747 | pSlice->setPic( m_pcPic ); |
---|
[1356] | 748 | vps=pSlice->getVPS(); |
---|
[1313] | 749 | // 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. |
---|
[1356] | 750 | assert( pps->getLayerId() == m_layerId || pps->getLayerId( ) == 0 || vps->getDependencyFlag( m_layerId, pps->getLayerId() ) ); |
---|
[1313] | 751 | // 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. |
---|
| 752 | assert( sps->getLayerId() == m_layerId || sps->getLayerId( ) == 0 || vps->getDependencyFlag( m_layerId, sps->getLayerId() ) ); |
---|
| 753 | #endif |
---|
| 754 | |
---|
| 755 | #if NH_3D |
---|
| 756 | if ( !m_pcCamParsCollector->isInitialized() ) |
---|
[608] | 757 | { |
---|
[1313] | 758 | m_pcCamParsCollector->init( vps ); |
---|
| 759 | } |
---|
| 760 | #endif |
---|
| 761 | // Initialise the various objects for the new set of settings |
---|
| 762 | 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) ); |
---|
| 763 | m_cLoopFilter.create( sps->getMaxTotalCUDepth() ); |
---|
| 764 | m_cPrediction.initTempBuff(sps->getChromaFormatIdc()); |
---|
| 765 | |
---|
| 766 | |
---|
| 767 | Bool isField = false; |
---|
| 768 | Bool isTopField = false; |
---|
| 769 | |
---|
| 770 | if(!m_SEIs.empty()) |
---|
| 771 | { |
---|
| 772 | // Check if any new Picture Timing SEI has arrived |
---|
| 773 | SEIMessages pictureTimingSEIs = getSeisByType(m_SEIs, SEI::PICTURE_TIMING); |
---|
| 774 | if (pictureTimingSEIs.size()>0) |
---|
[608] | 775 | { |
---|
[1313] | 776 | SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin()); |
---|
| 777 | 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); |
---|
| 778 | isTopField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 9) || (pictureTiming->m_picStruct == 11); |
---|
[608] | 779 | } |
---|
| 780 | } |
---|
[1313] | 781 | |
---|
| 782 | //Set Field/Frame coding mode |
---|
| 783 | m_pcPic->setField(isField); |
---|
| 784 | m_pcPic->setTopField(isTopField); |
---|
| 785 | |
---|
| 786 | // transfer any SEI messages that have been received to the picture |
---|
| 787 | m_pcPic->setSEIs(m_SEIs); |
---|
| 788 | m_SEIs.clear(); |
---|
| 789 | |
---|
| 790 | // Recursive structure |
---|
| 791 | m_cCuDecoder.create ( sps->getMaxTotalCUDepth(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getChromaFormatIdc() ); |
---|
[1413] | 792 | #if MCTS_ENC_CHECK |
---|
| 793 | m_cCuDecoder.init ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction, &m_conformanceCheck ); |
---|
| 794 | #else |
---|
[1313] | 795 | m_cCuDecoder.init ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction ); |
---|
[1413] | 796 | #endif |
---|
[1313] | 797 | m_cTrQuant.init ( sps->getMaxTrSize() ); |
---|
| 798 | |
---|
| 799 | m_cSliceDecoder.create(); |
---|
[608] | 800 | } |
---|
[1313] | 801 | else |
---|
| 802 | { |
---|
[1321] | 803 | #if NH_MV |
---|
[1356] | 804 | assert( m_pcPic != NULL ); |
---|
| 805 | assert( newPic == NULL ); |
---|
[1321] | 806 | #endif |
---|
[1313] | 807 | // make the slice-pilot a real slice, and set up the slice-pilot for the next slice |
---|
| 808 | m_pcPic->allocateNewSlice(); |
---|
| 809 | assert(m_pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
| 810 | m_apcSlicePilot = m_pcPic->getPicSym()->swapSliceObject(m_apcSlicePilot, m_uiSliceIdx); |
---|
[608] | 811 | |
---|
[1313] | 812 | TComSlice *pSlice = m_pcPic->getSlice(m_uiSliceIdx); // we now have a real slice. |
---|
[1066] | 813 | |
---|
[1313] | 814 | const TComSPS *sps = pSlice->getSPS(); |
---|
| 815 | const TComPPS *pps = pSlice->getPPS(); |
---|
[56] | 816 | |
---|
[1313] | 817 | // check that the current active PPS has not changed... |
---|
| 818 | if (m_parameterSetManager.getSPSChangedFlag(sps->getSPSId()) ) |
---|
| 819 | { |
---|
| 820 | printf("Error - a new SPS has been decoded while processing a picture\n"); |
---|
| 821 | exit(1); |
---|
| 822 | } |
---|
| 823 | if (m_parameterSetManager.getPPSChangedFlag(pps->getPPSId()) ) |
---|
| 824 | { |
---|
| 825 | printf("Error - a new PPS has been decoded while processing a picture\n"); |
---|
| 826 | exit(1); |
---|
| 827 | } |
---|
[608] | 828 | |
---|
[1313] | 829 | xParsePrefixSEImessages(); |
---|
| 830 | |
---|
[1413] | 831 | #if MCTS_ENC_CHECK |
---|
| 832 | xAnalysePrefixSEImessages(); |
---|
| 833 | #endif |
---|
[1313] | 834 | // Check if any new SEI has arrived |
---|
[1321] | 835 | if(!m_SEIs.empty()) |
---|
| 836 | { |
---|
| 837 | // Currently only decoding Unit SEI message occurring between VCL NALUs copied |
---|
| 838 | SEIMessages &picSEI = m_pcPic->getSEIs(); |
---|
| 839 | SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO); |
---|
| 840 | picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end()); |
---|
| 841 | deleteSEIs(m_SEIs); |
---|
| 842 | } |
---|
[1313] | 843 | } |
---|
| 844 | } |
---|
[1321] | 845 | |
---|
[1313] | 846 | Void TDecTop::xParsePrefixSEIsForUnknownVCLNal() |
---|
| 847 | { |
---|
| 848 | while (!m_prefixSEINALUs.empty()) |
---|
[2] | 849 | { |
---|
[1313] | 850 | // do nothing? |
---|
| 851 | printf("Discarding Prefix SEI associated with unknown VCL NAL unit.\n"); |
---|
| 852 | delete m_prefixSEINALUs.front(); |
---|
[2] | 853 | } |
---|
[1313] | 854 | // TODO: discard following suffix SEIs as well? |
---|
| 855 | } |
---|
[56] | 856 | |
---|
[1313] | 857 | |
---|
| 858 | Void TDecTop::xParsePrefixSEImessages() |
---|
| 859 | { |
---|
| 860 | while (!m_prefixSEINALUs.empty()) |
---|
[56] | 861 | { |
---|
[1313] | 862 | InputNALUnit &nalu=*m_prefixSEINALUs.front(); |
---|
| 863 | #if NH_MV |
---|
[1356] | 864 | m_seiReader.parseSEImessage(&(nalu.getBitstream()), m_SEIs, nalu.m_nalUnitType, m_parameterSetManager.getActiveVPS(), m_parameterSetManager.getActiveSPS(getLayerId()), m_pDecodedSEIOutputStream); |
---|
| 865 | #else |
---|
[1313] | 866 | m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_SEIs, nalu.m_nalUnitType, m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream ); |
---|
| 867 | #endif |
---|
| 868 | delete m_prefixSEINALUs.front(); |
---|
| 869 | m_prefixSEINALUs.pop_front(); |
---|
[56] | 870 | } |
---|
[2] | 871 | } |
---|
[56] | 872 | |
---|
[1413] | 873 | #if MCTS_ENC_CHECK |
---|
| 874 | Void TDecTop::xAnalysePrefixSEImessages() |
---|
| 875 | { |
---|
| 876 | if (m_tmctsCheckEnabled) |
---|
| 877 | { |
---|
| 878 | SEIMessages mctsSEIs = getSeisByType(m_SEIs, SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS); |
---|
| 879 | for (SEIMessages::iterator it = mctsSEIs.begin(); it != mctsSEIs.end(); it++) |
---|
| 880 | { |
---|
| 881 | SEITempMotionConstrainedTileSets *mcts = (SEITempMotionConstrainedTileSets*)(*it); |
---|
| 882 | if (!mcts->m_each_tile_one_tile_set_flag) |
---|
| 883 | { |
---|
| 884 | printf("cannot (yet) check Temporal constrained MCTS if each_tile_one_tile_set_flag is not enabled\n"); |
---|
| 885 | exit(1); |
---|
| 886 | } |
---|
| 887 | else |
---|
| 888 | { |
---|
| 889 | printf("MCTS check enabled!\n"); |
---|
| 890 | m_conformanceCheck.enableTMctsCheck(true); |
---|
| 891 | } |
---|
| 892 | } |
---|
| 893 | } |
---|
| 894 | } |
---|
| 895 | #endif |
---|
| 896 | |
---|
| 897 | |
---|
[1321] | 898 | #if !NH_MV |
---|
[56] | 899 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay ) |
---|
[2] | 900 | { |
---|
[1313] | 901 | m_apcSlicePilot->initSlice(); // the slice pilot is an object to prepare for a new slice |
---|
[1321] | 902 | // it is not associated with picture, sps or pps structures. |
---|
[56] | 903 | if (m_bFirstSliceInPicture) |
---|
[2] | 904 | { |
---|
[1321] | 905 | #else |
---|
| 906 | Void TDecTop::decodeSliceHeader(InputNALUnit &nalu ) |
---|
| 907 | { |
---|
| 908 | // Initialize entropy decoder |
---|
| 909 | m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); |
---|
| 910 | m_cEntropyDecoder.setBitstream (&(nalu.getBitstream())); |
---|
| 911 | |
---|
[1356] | 912 | assert( nalu.m_nuhLayerId == m_layerId ); |
---|
[1321] | 913 | m_apcSlicePilot->initSlice(); // the slice pilot is an object to prepare for a new slice |
---|
| 914 | // it is not associated with picture, sps or pps structures. |
---|
[1356] | 915 | m_apcSlicePilot->setLayerId( nalu.m_nuhLayerId ); |
---|
| 916 | m_cEntropyDecoder.decodeFirstSliceSegmentInPicFlag( m_apcSlicePilot ); |
---|
[1321] | 917 | if ( m_apcSlicePilot->getFirstSliceSegementInPicFlag() ) |
---|
| 918 | { |
---|
[1356] | 919 | #endif |
---|
[1313] | 920 | m_uiSliceIdx = 0; |
---|
[2] | 921 | } |
---|
[872] | 922 | else |
---|
[56] | 923 | { |
---|
[1313] | 924 | m_apcSlicePilot->copySliceInfo( m_pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) ); |
---|
[56] | 925 | } |
---|
[872] | 926 | m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); |
---|
[2] | 927 | |
---|
[56] | 928 | m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); |
---|
[608] | 929 | Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
[1321] | 930 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
| 931 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
| 932 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
| 933 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N); |
---|
[608] | 934 | m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag); |
---|
[1321] | 935 | #if !NH_MV |
---|
[608] | 936 | m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS |
---|
[1321] | 937 | #endif |
---|
[56] | 938 | m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId); |
---|
[1321] | 939 | #if NH_MV |
---|
| 940 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManager ); |
---|
| 941 | #else |
---|
[1313] | 942 | #if ENC_DEC_TRACE |
---|
| 943 | const UInt64 originalSymbolCount = g_nSymbolCounter; |
---|
| 944 | #endif |
---|
[1321] | 945 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManager, m_prevTid0POC); |
---|
| 946 | #endif |
---|
[1313] | 947 | |
---|
| 948 | #if NH_MV |
---|
[1321] | 949 | } |
---|
| 950 | #else |
---|
[655] | 951 | // set POC for dependent slices in skipped pictures |
---|
[1313] | 952 | if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) |
---|
[655] | 953 | { |
---|
| 954 | m_apcSlicePilot->setPOC(m_skippedPOC); |
---|
| 955 | } |
---|
| 956 | |
---|
[1313] | 957 | xUpdatePreviousTid0POC(m_apcSlicePilot); |
---|
[655] | 958 | m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA); |
---|
| 959 | m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType); |
---|
[738] | 960 | |
---|
[1321] | 961 | |
---|
[964] | 962 | //For inference of NoOutputOfPriorPicsFlag |
---|
| 963 | if (m_apcSlicePilot->getRapPicFlag()) |
---|
| 964 | { |
---|
[1356] | 965 | if ((m_apcSlicePilot->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_apcSlicePilot->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP) || |
---|
[964] | 966 | (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_bFirstSliceInSequence) || |
---|
| 967 | (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getHandleCraAsBlaFlag())) |
---|
[1321] | 968 | { |
---|
| 969 | m_apcSlicePilot->setNoRaslOutputFlag(true); |
---|
| 970 | } |
---|
[964] | 971 | //the inference for NoOutputPriorPicsFlag |
---|
| 972 | if (!m_bFirstSliceInBitstream && m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag()) |
---|
| 973 | { |
---|
| 974 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
| 975 | { |
---|
| 976 | m_apcSlicePilot->setNoOutputPriorPicsFlag(true); |
---|
| 977 | } |
---|
| 978 | } |
---|
| 979 | else |
---|
| 980 | { |
---|
[1356] | 981 | m_apcSlicePilot->setNoOutputPriorPicsFlag(false); |
---|
[964] | 982 | } |
---|
| 983 | |
---|
| 984 | if(m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
| 985 | { |
---|
| 986 | m_craNoRaslOutputFlag = m_apcSlicePilot->getNoRaslOutputFlag(); |
---|
| 987 | } |
---|
| 988 | } |
---|
| 989 | if (m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoOutputPriorPicsFlag()) |
---|
| 990 | { |
---|
| 991 | m_lastPOCNoOutputPriorPics = m_apcSlicePilot->getPOC(); |
---|
| 992 | m_isNoOutputPriorPics = true; |
---|
| 993 | } |
---|
| 994 | else |
---|
| 995 | { |
---|
| 996 | m_isNoOutputPriorPics = false; |
---|
| 997 | } |
---|
| 998 | |
---|
| 999 | //For inference of PicOutputFlag |
---|
| 1000 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
| 1001 | { |
---|
| 1002 | if ( m_craNoRaslOutputFlag ) |
---|
| 1003 | { |
---|
| 1004 | m_apcSlicePilot->setPicOutputFlag(false); |
---|
| 1005 | } |
---|
| 1006 | } |
---|
[1356] | 1007 | |
---|
[964] | 1008 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_craNoRaslOutputFlag) //Reset POC MSB when CRA has NoRaslOutputFlag equal to 1 |
---|
| 1009 | { |
---|
[1313] | 1010 | TComPPS *pps = m_parameterSetManager.getPPS(m_apcSlicePilot->getPPSId()); |
---|
| 1011 | assert (pps != 0); |
---|
| 1012 | TComSPS *sps = m_parameterSetManager.getSPS(pps->getSPSId()); |
---|
| 1013 | assert (sps != 0); |
---|
| 1014 | Int iMaxPOClsb = 1 << sps->getBitsForPOC(); |
---|
[964] | 1015 | m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) ); |
---|
[1313] | 1016 | xUpdatePreviousTid0POC(m_apcSlicePilot); |
---|
[964] | 1017 | } |
---|
[1313] | 1018 | |
---|
| 1019 | // Skip pictures due to random access |
---|
| 1020 | if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) |
---|
| 1021 | { |
---|
[655] | 1022 | m_prevSliceSkipped = true; |
---|
| 1023 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
[1313] | 1024 | return false; |
---|
| 1025 | } |
---|
| 1026 | // Skip TFD pictures associated with BLA/BLANT pictures |
---|
| 1027 | if (isSkipPictureForBLA(iPOCLastDisplay)) |
---|
| 1028 | { |
---|
[655] | 1029 | m_prevSliceSkipped = true; |
---|
| 1030 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
[1313] | 1031 | return false; |
---|
| 1032 | } |
---|
[608] | 1033 | |
---|
[655] | 1034 | // clear previous slice skipped flag |
---|
| 1035 | m_prevSliceSkipped = false; |
---|
| 1036 | |
---|
[608] | 1037 | //we should only get a different poc for a new picture (with CTU address==0) |
---|
[1313] | 1038 | if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCtuTsAddr() != 0)) |
---|
[608] | 1039 | { |
---|
| 1040 | printf ("Warning, the first slice of a picture might have been lost!\n"); |
---|
[56] | 1041 | } |
---|
[1313] | 1042 | |
---|
[56] | 1043 | // exit when a new picture is found |
---|
[1313] | 1044 | if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (m_apcSlicePilot->getSliceCurStartCtuTsAddr() == 0 && !m_bFirstSliceInPicture) ) |
---|
[56] | 1045 | { |
---|
| 1046 | if (m_prevPOC >= m_pocRandomAccess) |
---|
| 1047 | { |
---|
| 1048 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
[1321] | 1049 | |
---|
[1313] | 1050 | #if ENC_DEC_TRACE |
---|
| 1051 | //rewind the trace counter since we didn't actually decode the slice |
---|
| 1052 | g_nSymbolCounter = originalSymbolCount; |
---|
| 1053 | #endif |
---|
[56] | 1054 | return true; |
---|
| 1055 | } |
---|
| 1056 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 1057 | } |
---|
[1313] | 1058 | |
---|
| 1059 | //detect lost reference picture and insert copy of earlier frame. |
---|
[1179] | 1060 | { |
---|
[1313] | 1061 | Int lostPoc; |
---|
| 1062 | while((lostPoc=m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess)) > 0) |
---|
| 1063 | { |
---|
| 1064 | xCreateLostPicture(lostPoc-1); |
---|
| 1065 | } |
---|
[1179] | 1066 | } |
---|
| 1067 | |
---|
[1313] | 1068 | if (!m_apcSlicePilot->getDependentSliceSegmentFlag()) |
---|
[56] | 1069 | { |
---|
| 1070 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 1071 | } |
---|
[1313] | 1072 | // actual decoding starts here |
---|
| 1073 | xActivateParameterSets(); |
---|
| 1074 | |
---|
[2] | 1075 | |
---|
[42] | 1076 | |
---|
[1313] | 1077 | TComSlice* pcSlice = m_pcPic->getPicSym()->getSlice(m_uiSliceIdx); |
---|
[42] | 1078 | |
---|
[1413] | 1079 | if (TDecConformanceCheck::doChecking()) |
---|
| 1080 | { |
---|
| 1081 | m_conformanceCheck.checkSliceActivation(*pcSlice, nalu, *m_pcPic, m_bFirstSliceInBitstream, m_bFirstSliceInSequence, m_bFirstSliceInPicture); |
---|
| 1082 | } |
---|
| 1083 | |
---|
| 1084 | m_bFirstSliceInSequence = false; |
---|
| 1085 | m_bFirstSliceInBitstream = false; |
---|
| 1086 | |
---|
[1321] | 1087 | #endif |
---|
[2] | 1088 | |
---|
[1321] | 1089 | #if NH_MV |
---|
| 1090 | Void TDecTop::decodeSliceSegment(InputNALUnit &nalu ) |
---|
| 1091 | { |
---|
| 1092 | TComSlice* pcSlice = m_pcPic->getPicSym()->getSlice(m_uiSliceIdx); |
---|
[56] | 1093 | |
---|
[1321] | 1094 | if ( m_pcPic->getHasGeneratedRefPics() ) |
---|
[56] | 1095 | { |
---|
[1321] | 1096 | if ( pcSlice->getFirstSliceSegementInPicFlag() ) |
---|
| 1097 | { |
---|
| 1098 | std::cout << std:: setfill(' ') |
---|
| 1099 | << "Layer " << std::setw(2) << m_pcPic->getLayerId() |
---|
| 1100 | << " POC " << std::setw(4) << m_pcPic->getPOC() |
---|
| 1101 | << " Reference pictures missing. Skipping picture." << std::endl; |
---|
| 1102 | } |
---|
[56] | 1103 | } |
---|
[1321] | 1104 | else |
---|
[56] | 1105 | { |
---|
[1321] | 1106 | //Check Multiview Main profile constraint in G.11.1.1 |
---|
[1356] | 1107 | // When ViewOrderIdx[ i ] derived according to any active VPS is equal to 1 |
---|
| 1108 | // for the layer with nuh_layer_id equal to i in subBitstream, |
---|
| 1109 | // inter_view_mv_vert_constraint_flag shall be equal to 1 |
---|
[1321] | 1110 | // in the sps_multilayer_extension( ) syntax structure in each active SPS for that layer. |
---|
| 1111 | if( pcSlice->getSPS()->getPTL()->getGeneralPTL()->getProfileIdc()==Profile::MULTIVIEWMAIN |
---|
| 1112 | && |
---|
[1356] | 1113 | pcSlice->getVPS()->getViewOrderIdx(pcSlice->getVPS()->getLayerIdInNuh(getLayerId()))==1 |
---|
[1321] | 1114 | ) |
---|
| 1115 | { |
---|
| 1116 | assert( pcSlice->getSPS()->getInterViewMvVertConstraintFlag()==1 ); |
---|
| 1117 | } |
---|
[622] | 1118 | |
---|
[1321] | 1119 | m_pcPic->setLayerId( nalu.m_nuhLayerId ); |
---|
| 1120 | m_pcPic->setViewId ( getViewId() ); |
---|
[1396] | 1121 | #if NH_3D || NH_3D_VSO |
---|
[1321] | 1122 | m_pcPic->setViewIndex( getViewIndex() ); |
---|
| 1123 | m_pcPic->setIsDepth ( getIsDepth () ); |
---|
[1356] | 1124 | pcSlice->setIvPicLists( m_dpb ); |
---|
[655] | 1125 | #endif |
---|
[210] | 1126 | #endif |
---|
[1356] | 1127 | |
---|
[1321] | 1128 | // When decoding the slice header, the stored start and end addresses were actually RS addresses, not TS addresses. |
---|
| 1129 | // Now, having set up the maps, convert them to the correct form. |
---|
| 1130 | pcSlice->setSliceSegmentCurStartCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr()) ); |
---|
| 1131 | pcSlice->setSliceSegmentCurEndCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurEndCtuTsAddr()) ); |
---|
| 1132 | if(!pcSlice->getDependentSliceSegmentFlag()) |
---|
[1066] | 1133 | { |
---|
[1321] | 1134 | pcSlice->setSliceCurStartCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurStartCtuTsAddr())); |
---|
| 1135 | pcSlice->setSliceCurEndCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurEndCtuTsAddr())); |
---|
[1066] | 1136 | } |
---|
| 1137 | |
---|
[1321] | 1138 | m_pcPic->setTLayer(nalu.m_temporalId); |
---|
| 1139 | |
---|
| 1140 | |
---|
| 1141 | if (!pcSlice->getDependentSliceSegmentFlag()) |
---|
[56] | 1142 | { |
---|
[1321] | 1143 | #if !NH_MV |
---|
| 1144 | pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic ); |
---|
| 1145 | // Set reference list |
---|
| 1146 | pcSlice->setRefPicList( m_cListPic, true ); |
---|
| 1147 | #else |
---|
| 1148 | if (pcSlice->getSliceType() != I_SLICE ) |
---|
[56] | 1149 | { |
---|
[1321] | 1150 | if( m_decProcPocAndRps == ANNEX_F ) |
---|
| 1151 | { |
---|
| 1152 | pcSlice->f834decProcForRefPicListConst(); |
---|
| 1153 | } |
---|
| 1154 | else if ( m_decProcPocAndRps == CLAUSE_8 ) |
---|
| 1155 | { |
---|
| 1156 | pcSlice->cl834DecProcForRefPicListConst(); |
---|
| 1157 | } |
---|
| 1158 | else |
---|
| 1159 | { |
---|
[1356] | 1160 | assert( false ); |
---|
[1321] | 1161 | } |
---|
[56] | 1162 | } |
---|
[1413] | 1163 | #if NH_3D |
---|
[1321] | 1164 | pcSlice->setDefaultRefView(); |
---|
[1356] | 1165 | pcSlice->setPocsInCurrRPSs(); |
---|
[1321] | 1166 | pcSlice->setARPStepNum(m_dpb); |
---|
| 1167 | #endif |
---|
[1356] | 1168 | #endif |
---|
[56] | 1169 | |
---|
[1321] | 1170 | // For generalized B |
---|
| 1171 | // note: maybe not existed case (always L0 is copied to L1 if L1 is empty) |
---|
| 1172 | if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0) |
---|
[56] | 1173 | { |
---|
[1321] | 1174 | Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0); |
---|
| 1175 | pcSlice->setNumRefIdx ( REF_PIC_LIST_1, iNumRefIdx ); |
---|
| 1176 | |
---|
| 1177 | for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++) |
---|
[21] | 1178 | { |
---|
[1321] | 1179 | pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx); |
---|
[21] | 1180 | } |
---|
[2] | 1181 | } |
---|
[1321] | 1182 | if (!pcSlice->isIntra()) |
---|
[56] | 1183 | { |
---|
[1321] | 1184 | Bool bLowDelay = true; |
---|
| 1185 | Int iCurrPOC = pcSlice->getPOC(); |
---|
| 1186 | Int iRefIdx = 0; |
---|
| 1187 | |
---|
| 1188 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++) |
---|
[56] | 1189 | { |
---|
[1321] | 1190 | if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC ) |
---|
[608] | 1191 | { |
---|
| 1192 | bLowDelay = false; |
---|
| 1193 | } |
---|
[1313] | 1194 | } |
---|
[1321] | 1195 | if (pcSlice->isInterB()) |
---|
| 1196 | { |
---|
| 1197 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++) |
---|
| 1198 | { |
---|
| 1199 | if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC ) |
---|
| 1200 | { |
---|
| 1201 | bLowDelay = false; |
---|
| 1202 | } |
---|
| 1203 | } |
---|
| 1204 | } |
---|
| 1205 | |
---|
| 1206 | pcSlice->setCheckLDC(bLowDelay); |
---|
[56] | 1207 | } |
---|
[2] | 1208 | |
---|
[1321] | 1209 | //--------------- |
---|
| 1210 | pcSlice->setRefPOCList(); |
---|
[1413] | 1211 | #if NH_3D |
---|
[1321] | 1212 | if(pcSlice->getLayerId()) |
---|
| 1213 | { |
---|
| 1214 | pcSlice->generateAlterRefforTMVP(); |
---|
| 1215 | } |
---|
| 1216 | #endif |
---|
[1196] | 1217 | } |
---|
[56] | 1218 | |
---|
[1321] | 1219 | m_pcPic->setCurrSliceIdx(m_uiSliceIdx); |
---|
| 1220 | if(pcSlice->getSPS()->getScalingListFlag()) |
---|
[56] | 1221 | { |
---|
[1321] | 1222 | TComScalingList scalingList; |
---|
| 1223 | if(pcSlice->getPPS()->getScalingListPresentFlag()) |
---|
| 1224 | { |
---|
| 1225 | scalingList = pcSlice->getPPS()->getScalingList(); |
---|
| 1226 | } |
---|
| 1227 | else if (pcSlice->getSPS()->getScalingListPresentFlag()) |
---|
| 1228 | { |
---|
| 1229 | scalingList = pcSlice->getSPS()->getScalingList(); |
---|
| 1230 | } |
---|
| 1231 | else |
---|
| 1232 | { |
---|
| 1233 | scalingList.setDefaultScalingList(); |
---|
| 1234 | } |
---|
| 1235 | m_cTrQuant.setScalingListDec(scalingList); |
---|
| 1236 | m_cTrQuant.setUseScalingList(true); |
---|
[56] | 1237 | } |
---|
[1313] | 1238 | else |
---|
| 1239 | { |
---|
[1321] | 1240 | const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE] = |
---|
| 1241 | { |
---|
[1313] | 1242 | pcSlice->getSPS()->getMaxLog2TrDynamicRange(CHANNEL_TYPE_LUMA), |
---|
| 1243 | pcSlice->getSPS()->getMaxLog2TrDynamicRange(CHANNEL_TYPE_CHROMA) |
---|
[1321] | 1244 | }; |
---|
| 1245 | m_cTrQuant.setFlatScalingList(maxLog2TrDynamicRange, pcSlice->getSPS()->getBitDepths()); |
---|
| 1246 | m_cTrQuant.setUseScalingList(false); |
---|
| 1247 | } |
---|
[2] | 1248 | |
---|
[1321] | 1249 | #if NH_3D |
---|
| 1250 | if ( decProcAnnexI() ) |
---|
| 1251 | { |
---|
[1356] | 1252 | pcSlice->checkInCompPredRefLayers(); |
---|
[1321] | 1253 | } |
---|
[1066] | 1254 | #endif |
---|
[1321] | 1255 | |
---|
| 1256 | // Decode a picture |
---|
| 1257 | m_cGopDecoder.decompressSlice(&(nalu.getBitstream()), m_pcPic); |
---|
| 1258 | |
---|
| 1259 | #if NH_3D |
---|
| 1260 | if( m_pcCamParsCollector ) |
---|
| 1261 | { |
---|
| 1262 | m_pcCamParsCollector->setSlice( pcSlice ); |
---|
| 1263 | } |
---|
[724] | 1264 | #endif |
---|
| 1265 | |
---|
[1321] | 1266 | #if !NH_MV |
---|
| 1267 | m_bFirstSliceInPicture = false; |
---|
| 1268 | #else |
---|
[57] | 1269 | } |
---|
[758] | 1270 | #endif |
---|
[56] | 1271 | m_uiSliceIdx++; |
---|
| 1272 | |
---|
[1321] | 1273 | #if !NH_MV |
---|
[56] | 1274 | return false; |
---|
[1321] | 1275 | #endif |
---|
[56] | 1276 | } |
---|
| 1277 | |
---|
[1321] | 1278 | |
---|
[1313] | 1279 | Void TDecTop::xDecodeVPS(const std::vector<UChar> &naluData) |
---|
[77] | 1280 | { |
---|
| 1281 | TComVPS* vps = new TComVPS(); |
---|
[1313] | 1282 | |
---|
[77] | 1283 | m_cEntropyDecoder.decodeVPS( vps ); |
---|
[1313] | 1284 | m_parameterSetManager.storeVPS(vps, naluData); |
---|
[77] | 1285 | } |
---|
[56] | 1286 | |
---|
[1313] | 1287 | Void TDecTop::xDecodeSPS(const std::vector<UChar> &naluData) |
---|
[56] | 1288 | { |
---|
| 1289 | TComSPS* sps = new TComSPS(); |
---|
[1313] | 1290 | #if NH_MV |
---|
[1356] | 1291 | sps->setLayerId( getLayerId() ); |
---|
[608] | 1292 | #endif |
---|
[1313] | 1293 | #if O0043_BEST_EFFORT_DECODING |
---|
| 1294 | sps->setForceDecodeBitDepth(m_forceDecodeBitDepth); |
---|
| 1295 | #endif |
---|
| 1296 | #if NH_3D |
---|
| 1297 | // GT: Please don't add parsing dependency of SPS from VPS here again!!! |
---|
| 1298 | #endif |
---|
[1124] | 1299 | m_cEntropyDecoder.decodeSPS( sps ); |
---|
[1313] | 1300 | m_parameterSetManager.storeSPS(sps, naluData); |
---|
[56] | 1301 | } |
---|
[2] | 1302 | |
---|
[1313] | 1303 | Void TDecTop::xDecodePPS(const std::vector<UChar> &naluData) |
---|
[56] | 1304 | { |
---|
| 1305 | TComPPS* pps = new TComPPS(); |
---|
[1313] | 1306 | #if NH_MV |
---|
[1356] | 1307 | pps->setLayerId( getLayerId() ); |
---|
[622] | 1308 | #endif |
---|
[1413] | 1309 | #if NH_3D |
---|
[1313] | 1310 | // create mapping from depth layer indexes to layer ids |
---|
| 1311 | Int j=0; |
---|
| 1312 | for( Int i=0; i<=m_parameterSetManager.getFirstVPS()->getMaxLayersMinus1(); i++ ) |
---|
[608] | 1313 | { |
---|
[1313] | 1314 | Int layerId = m_parameterSetManager.getFirstVPS()->getLayerIdInNuh(i); |
---|
| 1315 | if( m_parameterSetManager.getFirstVPS()->getDepthId(layerId) ) |
---|
| 1316 | pps->getDLT()->setDepthIdxToLayerId(j++, layerId); |
---|
[608] | 1317 | } |
---|
[622] | 1318 | #endif |
---|
[1313] | 1319 | m_cEntropyDecoder.decodePPS( pps ); |
---|
| 1320 | |
---|
| 1321 | m_parameterSetManager.storePPS( pps, naluData); |
---|
[56] | 1322 | } |
---|
[2] | 1323 | |
---|
[1313] | 1324 | #if NH_MV |
---|
[1321] | 1325 | Bool TDecTop::decodeNonVclNalu(InputNALUnit& nalu ) |
---|
[738] | 1326 | #else |
---|
[56] | 1327 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
[608] | 1328 | #endif |
---|
[56] | 1329 | { |
---|
[1313] | 1330 | #if !NH_MV |
---|
| 1331 | // ignore all NAL units of layers > 0 |
---|
| 1332 | if (nalu.m_nuhLayerId > 0) |
---|
| 1333 | { |
---|
| 1334 | fprintf (stderr, "Warning: found NAL unit with nuh_layer_id equal to %d. Ignoring.\n", nalu.m_nuhLayerId); |
---|
| 1335 | return false; |
---|
| 1336 | } |
---|
| 1337 | #endif |
---|
[56] | 1338 | // Initialize entropy decoder |
---|
| 1339 | m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); |
---|
[1313] | 1340 | m_cEntropyDecoder.setBitstream (&(nalu.getBitstream())); |
---|
[2] | 1341 | |
---|
[56] | 1342 | switch (nalu.m_nalUnitType) |
---|
| 1343 | { |
---|
[77] | 1344 | case NAL_UNIT_VPS: |
---|
[1313] | 1345 | xDecodeVPS(nalu.getBitstream().getFifo()); |
---|
[77] | 1346 | return false; |
---|
[1313] | 1347 | |
---|
[56] | 1348 | case NAL_UNIT_SPS: |
---|
[1313] | 1349 | xDecodeSPS(nalu.getBitstream().getFifo()); |
---|
[56] | 1350 | return false; |
---|
| 1351 | |
---|
| 1352 | case NAL_UNIT_PPS: |
---|
[1313] | 1353 | xDecodePPS(nalu.getBitstream().getFifo()); |
---|
[56] | 1354 | return false; |
---|
[1313] | 1355 | |
---|
[608] | 1356 | case NAL_UNIT_PREFIX_SEI: |
---|
[1313] | 1357 | // Buffer up prefix SEI messages until SPS of associated VCL is known. |
---|
| 1358 | m_prefixSEINALUs.push_back(new InputNALUnit(nalu)); |
---|
| 1359 | return false; |
---|
| 1360 | |
---|
[608] | 1361 | case NAL_UNIT_SUFFIX_SEI: |
---|
[1313] | 1362 | if (m_pcPic) |
---|
| 1363 | { |
---|
| 1364 | #if NH_MV |
---|
[1356] | 1365 | m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_pcPic->getSEIs(), nalu.m_nalUnitType, m_parameterSetManager.getActiveVPS(), m_parameterSetManager.getActiveSPS(getLayerId()), m_pDecodedSEIOutputStream); |
---|
[1313] | 1366 | #else |
---|
| 1367 | m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_pcPic->getSEIs(), nalu.m_nalUnitType, m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream ); |
---|
| 1368 | #endif |
---|
| 1369 | } |
---|
| 1370 | else |
---|
| 1371 | { |
---|
| 1372 | printf ("Note: received suffix SEI but no picture currently active.\n"); |
---|
| 1373 | } |
---|
[56] | 1374 | return false; |
---|
| 1375 | |
---|
[608] | 1376 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
| 1377 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
[872] | 1378 | case NAL_UNIT_CODED_SLICE_TSA_R: |
---|
[608] | 1379 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
| 1380 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
| 1381 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
| 1382 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
| 1383 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
| 1384 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
| 1385 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
| 1386 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
[56] | 1387 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
[608] | 1388 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
| 1389 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
| 1390 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
| 1391 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
[1313] | 1392 | #if NH_MV |
---|
[1356] | 1393 | assert( false ); |
---|
| 1394 | return 1; |
---|
[738] | 1395 | #else |
---|
[56] | 1396 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay); |
---|
[608] | 1397 | #endif |
---|
[2] | 1398 | break; |
---|
[1313] | 1399 | |
---|
[872] | 1400 | case NAL_UNIT_EOS: |
---|
[1321] | 1401 | #if !NH_MV |
---|
[872] | 1402 | m_associatedIRAPType = NAL_UNIT_INVALID; |
---|
| 1403 | m_pocCRA = 0; |
---|
| 1404 | m_pocRandomAccess = MAX_INT; |
---|
| 1405 | m_prevPOC = MAX_INT; |
---|
| 1406 | m_prevSliceSkipped = false; |
---|
| 1407 | m_skippedPOC = 0; |
---|
[1321] | 1408 | #endif |
---|
[872] | 1409 | return false; |
---|
[1313] | 1410 | |
---|
[872] | 1411 | case NAL_UNIT_ACCESS_UNIT_DELIMITER: |
---|
[1313] | 1412 | { |
---|
| 1413 | AUDReader audReader; |
---|
| 1414 | UInt picType; |
---|
| 1415 | audReader.parseAccessUnitDelimiter(&(nalu.getBitstream()),picType); |
---|
| 1416 | printf ("Note: found NAL_UNIT_ACCESS_UNIT_DELIMITER\n"); |
---|
[872] | 1417 | return false; |
---|
[1313] | 1418 | } |
---|
| 1419 | |
---|
[872] | 1420 | case NAL_UNIT_EOB: |
---|
| 1421 | return false; |
---|
[1313] | 1422 | |
---|
[964] | 1423 | case NAL_UNIT_FILLER_DATA: |
---|
[1313] | 1424 | { |
---|
| 1425 | FDReader fdReader; |
---|
| 1426 | UInt size; |
---|
| 1427 | fdReader.parseFillerData(&(nalu.getBitstream()),size); |
---|
| 1428 | printf ("Note: found NAL_UNIT_FILLER_DATA with %u bytes payload.\n", size); |
---|
[964] | 1429 | return false; |
---|
[1313] | 1430 | } |
---|
| 1431 | |
---|
[872] | 1432 | case NAL_UNIT_RESERVED_VCL_N10: |
---|
| 1433 | case NAL_UNIT_RESERVED_VCL_R11: |
---|
| 1434 | case NAL_UNIT_RESERVED_VCL_N12: |
---|
| 1435 | case NAL_UNIT_RESERVED_VCL_R13: |
---|
| 1436 | case NAL_UNIT_RESERVED_VCL_N14: |
---|
| 1437 | case NAL_UNIT_RESERVED_VCL_R15: |
---|
[1313] | 1438 | |
---|
[872] | 1439 | case NAL_UNIT_RESERVED_IRAP_VCL22: |
---|
| 1440 | case NAL_UNIT_RESERVED_IRAP_VCL23: |
---|
[1313] | 1441 | |
---|
[872] | 1442 | case NAL_UNIT_RESERVED_VCL24: |
---|
| 1443 | case NAL_UNIT_RESERVED_VCL25: |
---|
| 1444 | case NAL_UNIT_RESERVED_VCL26: |
---|
| 1445 | case NAL_UNIT_RESERVED_VCL27: |
---|
| 1446 | case NAL_UNIT_RESERVED_VCL28: |
---|
| 1447 | case NAL_UNIT_RESERVED_VCL29: |
---|
| 1448 | case NAL_UNIT_RESERVED_VCL30: |
---|
| 1449 | case NAL_UNIT_RESERVED_VCL31: |
---|
[1313] | 1450 | printf ("Note: found reserved VCL NAL unit.\n"); |
---|
| 1451 | xParsePrefixSEIsForUnknownVCLNal(); |
---|
| 1452 | return false; |
---|
| 1453 | |
---|
[872] | 1454 | case NAL_UNIT_RESERVED_NVCL41: |
---|
| 1455 | case NAL_UNIT_RESERVED_NVCL42: |
---|
| 1456 | case NAL_UNIT_RESERVED_NVCL43: |
---|
| 1457 | case NAL_UNIT_RESERVED_NVCL44: |
---|
| 1458 | case NAL_UNIT_RESERVED_NVCL45: |
---|
| 1459 | case NAL_UNIT_RESERVED_NVCL46: |
---|
| 1460 | case NAL_UNIT_RESERVED_NVCL47: |
---|
[1313] | 1461 | printf ("Note: found reserved NAL unit.\n"); |
---|
| 1462 | return false; |
---|
[872] | 1463 | case NAL_UNIT_UNSPECIFIED_48: |
---|
| 1464 | case NAL_UNIT_UNSPECIFIED_49: |
---|
| 1465 | case NAL_UNIT_UNSPECIFIED_50: |
---|
| 1466 | case NAL_UNIT_UNSPECIFIED_51: |
---|
| 1467 | case NAL_UNIT_UNSPECIFIED_52: |
---|
| 1468 | case NAL_UNIT_UNSPECIFIED_53: |
---|
| 1469 | case NAL_UNIT_UNSPECIFIED_54: |
---|
| 1470 | case NAL_UNIT_UNSPECIFIED_55: |
---|
| 1471 | case NAL_UNIT_UNSPECIFIED_56: |
---|
| 1472 | case NAL_UNIT_UNSPECIFIED_57: |
---|
| 1473 | case NAL_UNIT_UNSPECIFIED_58: |
---|
| 1474 | case NAL_UNIT_UNSPECIFIED_59: |
---|
| 1475 | case NAL_UNIT_UNSPECIFIED_60: |
---|
| 1476 | case NAL_UNIT_UNSPECIFIED_61: |
---|
| 1477 | case NAL_UNIT_UNSPECIFIED_62: |
---|
| 1478 | case NAL_UNIT_UNSPECIFIED_63: |
---|
[1313] | 1479 | printf ("Note: found unspecified NAL unit.\n"); |
---|
| 1480 | return false; |
---|
[2] | 1481 | default: |
---|
[872] | 1482 | assert (0); |
---|
[1313] | 1483 | break; |
---|
[2] | 1484 | } |
---|
| 1485 | |
---|
| 1486 | return false; |
---|
| 1487 | } |
---|
| 1488 | |
---|
[1321] | 1489 | #if !NH_MV |
---|
[608] | 1490 | /** Function for checking if picture should be skipped because of association with a previous BLA picture |
---|
| 1491 | * \param iPOCLastDisplay POC of last picture displayed |
---|
| 1492 | * \returns true if the picture should be skipped |
---|
| 1493 | * This function skips all TFD pictures that follow a BLA picture |
---|
| 1494 | * in decoding order and precede it in output order. |
---|
| 1495 | */ |
---|
| 1496 | Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay) |
---|
[210] | 1497 | { |
---|
[1313] | 1498 | 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] | 1499 | m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) |
---|
[608] | 1500 | { |
---|
| 1501 | iPOCLastDisplay++; |
---|
| 1502 | return true; |
---|
| 1503 | } |
---|
| 1504 | return false; |
---|
[210] | 1505 | } |
---|
| 1506 | |
---|
[2] | 1507 | /** Function for checking if picture should be skipped because of random access |
---|
| 1508 | * \param iSkipFrame skip frame counter |
---|
| 1509 | * \param iPOCLastDisplay POC of last picture displayed |
---|
| 1510 | * \returns true if the picture shold be skipped in the random access. |
---|
| 1511 | * This function checks the skipping of pictures in the case of -s option random access. |
---|
| 1512 | * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped. |
---|
| 1513 | * It also checks the type of Nal unit type at the random access point. |
---|
[608] | 1514 | * 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] | 1515 | * If the random access point is IDR all pictures after the random access point are decoded. |
---|
[1313] | 1516 | * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC |
---|
| 1517 | * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random |
---|
[2] | 1518 | * access point there is no guarantee that the decoder will not crash. |
---|
| 1519 | */ |
---|
[1313] | 1520 | Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay ) |
---|
[2] | 1521 | { |
---|
[1313] | 1522 | if (iSkipFrame) |
---|
[2] | 1523 | { |
---|
| 1524 | iSkipFrame--; // decrement the counter |
---|
| 1525 | return true; |
---|
| 1526 | } |
---|
[56] | 1527 | else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet. |
---|
[2] | 1528 | { |
---|
[608] | 1529 | if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA |
---|
| 1530 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 1531 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
| 1532 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ) |
---|
[2] | 1533 | { |
---|
[738] | 1534 | |
---|
[608] | 1535 | // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT. |
---|
| 1536 | m_pocRandomAccess = m_apcSlicePilot->getPOC(); |
---|
[2] | 1537 | } |
---|
[608] | 1538 | else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
[2] | 1539 | { |
---|
[738] | 1540 | m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable. |
---|
| 1541 | } |
---|
[1313] | 1542 | else |
---|
[738] | 1543 | { |
---|
[1313] | 1544 | if(!m_warningMessageSkipPicture) |
---|
[56] | 1545 | { |
---|
| 1546 | printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture"); |
---|
[1313] | 1547 | m_warningMessageSkipPicture = true; |
---|
[56] | 1548 | } |
---|
| 1549 | return true; |
---|
[2] | 1550 | } |
---|
| 1551 | } |
---|
[608] | 1552 | // skip the reordered pictures, if necessary |
---|
| 1553 | 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] | 1554 | { |
---|
| 1555 | iPOCLastDisplay++; |
---|
| 1556 | return true; |
---|
| 1557 | } |
---|
[1313] | 1558 | // if we reach here, then the picture is not skipped. |
---|
| 1559 | return false; |
---|
[2] | 1560 | } |
---|
[1321] | 1561 | |
---|
| 1562 | #else |
---|
| 1563 | |
---|
| 1564 | Int TDecTop::preDecodePoc( Bool firstPicInLayerDecodedFlag, Bool isFstPicOfAllLayOfPocResetPer, Bool isPocResettingPicture ) |
---|
[56] | 1565 | { |
---|
[1321] | 1566 | //Output of this process is PicOrderCntVal, the picture order count of the current picture. |
---|
[1356] | 1567 | // Picture order counts are used to identify pictures, for deriving motion parameters in merge mode and |
---|
[1321] | 1568 | // motion vector prediction and for decoder conformance checking (see clause F.13.5). |
---|
| 1569 | |
---|
| 1570 | // Each coded picture is associated with a picture order count variable, denoted as PicOrderCntVal. |
---|
| 1571 | |
---|
| 1572 | TComSlice* slice = m_apcSlicePilot; |
---|
| 1573 | const Int nuhLayerId = slice->getLayerId(); |
---|
[1356] | 1574 | const TComVPS* vps = slice->getVPS(); |
---|
| 1575 | const TComSPS* sps = slice->getSPS(); |
---|
[1321] | 1576 | |
---|
[1356] | 1577 | Int pocDecrementedInDpbFlag = m_pocDecrementedInDpbFlag[ nuhLayerId ]; |
---|
[1321] | 1578 | |
---|
| 1579 | if ( isFstPicOfAllLayOfPocResetPer ) |
---|
[608] | 1580 | { |
---|
[1356] | 1581 | // When the current picture is the first picture among all layers of a POC resetting period, |
---|
[1321] | 1582 | // the variable PocDecrementedInDPBFlag[ i ] is set equal to 0 for each value of i in the range of 0 to 62, inclusive. |
---|
[1356] | 1583 | pocDecrementedInDpbFlag = false; |
---|
[1321] | 1584 | } |
---|
| 1585 | |
---|
| 1586 | // The variable pocResettingFlag is derived as follows: |
---|
[1356] | 1587 | Bool pocResettingFlag; |
---|
[1321] | 1588 | if ( isPocResettingPicture ) |
---|
| 1589 | { |
---|
[1356] | 1590 | //- If the current picture is a POC resetting picture, the following applies: |
---|
[1321] | 1591 | if( vps->getVpsPocLsbAlignedFlag() ) |
---|
[608] | 1592 | { |
---|
[1321] | 1593 | // - If vps_poc_lsb_aligned_flag is equal to 0, pocResettingFlag is set equal to 1. |
---|
[1356] | 1594 | pocResettingFlag = true; |
---|
[608] | 1595 | } |
---|
[1321] | 1596 | else if ( pocDecrementedInDpbFlag ) |
---|
| 1597 | { |
---|
| 1598 | // - Otherwise, if PocDecrementedInDPBFlag[ nuh_layer_id ] is equal to 1, pocResettingFlag is set equal to 0. |
---|
[1356] | 1599 | pocResettingFlag = false; |
---|
[1321] | 1600 | } |
---|
| 1601 | else |
---|
| 1602 | { |
---|
| 1603 | // - Otherwise, pocResettingFlag is set equal to 1. |
---|
[1356] | 1604 | pocResettingFlag = true; |
---|
[1321] | 1605 | } |
---|
[608] | 1606 | } |
---|
[1321] | 1607 | else |
---|
| 1608 | { |
---|
| 1609 | // - Otherwise, pocResettingFlag is set equal to 0. |
---|
[1356] | 1610 | pocResettingFlag = false; |
---|
[1321] | 1611 | } |
---|
| 1612 | |
---|
[1356] | 1613 | Int picOrderCntMsb; |
---|
| 1614 | Int picOrderCntVal; |
---|
[1321] | 1615 | |
---|
| 1616 | // Depending on pocResettingFlag, the following applies: |
---|
| 1617 | if ( pocResettingFlag ) |
---|
| 1618 | { |
---|
| 1619 | //- The PicOrderCntVal of the current picture is derived as follows: |
---|
| 1620 | if( slice->getPocResetIdc() == 1 ) |
---|
| 1621 | { |
---|
[1356] | 1622 | picOrderCntVal = slice->getSlicePicOrderCntLsb(); |
---|
[1321] | 1623 | } |
---|
[1356] | 1624 | else if (slice->getPocResetIdc() == 2 ) |
---|
[1321] | 1625 | { |
---|
[1356] | 1626 | picOrderCntVal = 0; |
---|
[1321] | 1627 | } |
---|
| 1628 | else |
---|
| 1629 | { |
---|
[1356] | 1630 | picOrderCntMsb = xGetCurrMsb( slice->getSlicePicOrderCntLsb(), slice->getFullPocResetFlag() ? 0 : slice->getPocLsbVal(), 0, sps->getMaxPicOrderCntLsb() ); |
---|
| 1631 | picOrderCntVal = picOrderCntMsb + slice->getSlicePicOrderCntLsb(); |
---|
[1321] | 1632 | } |
---|
| 1633 | } |
---|
| 1634 | else |
---|
| 1635 | { |
---|
| 1636 | //- Otherwise (pocResettingFlag is equal to 0), the following applies: |
---|
| 1637 | //- The PicOrderCntVal of the current picture is derived as follows: |
---|
| 1638 | |
---|
| 1639 | if( slice->getPocMsbCycleValPresentFlag() ) |
---|
| 1640 | { |
---|
[1356] | 1641 | picOrderCntMsb = slice->getPocMsbCycleVal() * sps->getMaxPicOrderCntLsb(); |
---|
[1321] | 1642 | } |
---|
| 1643 | else if( !firstPicInLayerDecodedFlag || |
---|
| 1644 | slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL ) |
---|
| 1645 | { |
---|
| 1646 | picOrderCntMsb = 0; // (F 62) |
---|
[1356] | 1647 | } |
---|
[1321] | 1648 | else |
---|
| 1649 | { |
---|
| 1650 | Int prevPicOrderCntLsb = m_prevPicOrderCnt & ( sps->getMaxPicOrderCntLsb() - 1 ); |
---|
[1356] | 1651 | Int prevPicOrderCntMsb = m_prevPicOrderCnt - prevPicOrderCntLsb; |
---|
| 1652 | picOrderCntMsb = xGetCurrMsb( slice->getSlicePicOrderCntLsb(), prevPicOrderCntLsb, prevPicOrderCntMsb, sps->getMaxPicOrderCntLsb() ); |
---|
[1321] | 1653 | } |
---|
[1356] | 1654 | picOrderCntVal = picOrderCntMsb + slice->getSlicePicOrderCntLsb(); |
---|
| 1655 | } |
---|
[1321] | 1656 | return picOrderCntVal; |
---|
[56] | 1657 | } |
---|
[2] | 1658 | |
---|
[1321] | 1659 | Void TDecTop::inferPocResetPeriodId() |
---|
| 1660 | { |
---|
| 1661 | // Infer PocResetPeriodId |
---|
| 1662 | // When not present, the value of poc_reset_period_id is inferred as follows: |
---|
| 1663 | |
---|
| 1664 | if ( !m_apcSlicePilot->getHasPocResetPeriodIdPresent() ) |
---|
| 1665 | { |
---|
| 1666 | if ( m_lastPresentPocResetIdc[ m_apcSlicePilot->getLayerId() ] != MIN_INT ) |
---|
| 1667 | { |
---|
[1356] | 1668 | // - If the previous picture picA that has poc_reset_period_id present in the slice segment header is present in the same layer |
---|
| 1669 | // of the bitstream as the current picture, the value of poc_reset_period_id is inferred to be equal to the value of the |
---|
[1321] | 1670 | // poc_reset_period_id of picA. |
---|
| 1671 | |
---|
[1356] | 1672 | m_apcSlicePilot->setPocResetPeriodId( m_lastPresentPocResetIdc[ m_apcSlicePilot->getLayerId() ] ); |
---|
[1321] | 1673 | } |
---|
| 1674 | else |
---|
| 1675 | { |
---|
| 1676 | //- Otherwise, the value of poc_reset_period_id is inferred to be equal to 0. |
---|
[1356] | 1677 | m_apcSlicePilot->setPocResetPeriodId( 0 ); |
---|
[1321] | 1678 | } |
---|
| 1679 | } |
---|
| 1680 | else |
---|
| 1681 | { |
---|
[1356] | 1682 | m_lastPresentPocResetIdc[ m_apcSlicePilot->getLayerId() ] = m_apcSlicePilot->getPocResetPeriodId(); |
---|
[1321] | 1683 | } |
---|
| 1684 | } |
---|
| 1685 | |
---|
| 1686 | |
---|
| 1687 | Void TDecTop::decodePocAndRps( ) |
---|
[1356] | 1688 | { |
---|
[1321] | 1689 | assert( m_uiSliceIdx == 0 ); |
---|
| 1690 | Int nuhLayerId = m_pcPic->getLayerId(); |
---|
| 1691 | if ( m_decProcPocAndRps == CLAUSE_8 ) |
---|
| 1692 | { |
---|
| 1693 | // 8.1.3 Decoding process for a coded picture with nuh_layer_id equal to 0 |
---|
| 1694 | |
---|
[1356] | 1695 | // Variables and functions relating to picture order count are derived as |
---|
| 1696 | // specified in clause 8.3.1. This needs to be invoked only for the first slice |
---|
[1321] | 1697 | // segment of a picture. |
---|
| 1698 | x831DecProcForPicOrderCount( ); |
---|
| 1699 | |
---|
[1356] | 1700 | // The decoding process for RPS in clause 8.3.2 is invoked, wherein reference |
---|
| 1701 | // pictures may be marked as "unused for reference" or "used for long-term |
---|
| 1702 | // reference". This needs to be invoked only for the first slice segment of a |
---|
[1321] | 1703 | // picture. |
---|
| 1704 | x832DecProcForRefPicSet ( false ); |
---|
| 1705 | } |
---|
| 1706 | else if( m_decProcPocAndRps == ANNEX_F ) |
---|
| 1707 | { |
---|
| 1708 | // F.8.1.3 Common decoding process for a coded picture |
---|
| 1709 | |
---|
| 1710 | if (nuhLayerId == 0 ) |
---|
| 1711 | { |
---|
| 1712 | // F.8.1.4 Decoding process for a coded picture with nuh_layer_id equal to |
---|
| 1713 | // --> Clause 8.1.3 is invoked with replacments of 8.3.1, 8.3.2, and 8.3.3 by F.8.3.1, 8.3.2, and 8.3.3 |
---|
| 1714 | |
---|
[1356] | 1715 | // Variables and functions relating to picture order count are derived as |
---|
| 1716 | // specified in clause 8.3.1. This needs to be invoked only for the first slice |
---|
[1321] | 1717 | // segment of a picture. |
---|
| 1718 | xF831DecProcForPicOrderCount( ); |
---|
| 1719 | |
---|
[1356] | 1720 | // The decoding process for RPS in clause 8.3.2 is invoked, wherein reference |
---|
| 1721 | // pictures may be marked as "unused for reference" or "used for long-term |
---|
| 1722 | // reference". This needs to be invoked only for the first slice segment of a |
---|
[1321] | 1723 | // picture. |
---|
| 1724 | xF832DecProcForRefPicSet( ); |
---|
| 1725 | } |
---|
| 1726 | else |
---|
| 1727 | { |
---|
| 1728 | // F.8.1.5 Decoding process for starting the decoding of a coded picture with |
---|
| 1729 | // nuh_layer_id greater than 0 |
---|
| 1730 | |
---|
[1356] | 1731 | // Variables and functions relating to picture order count are derived in clause F.8.3.1. |
---|
| 1732 | // This needs to be invoked only for the first slice segment of a picture. It is a requirement |
---|
| 1733 | // of bitstream conformance that PicOrderCntVal of each picture in an access unit shall have the |
---|
[1321] | 1734 | // same value during and at the end of decoding of the access unit |
---|
| 1735 | xF831DecProcForPicOrderCount( ); |
---|
| 1736 | |
---|
[1356] | 1737 | // The decoding process for RPS in clause F.8.3.2 is invoked, wherein only reference pictures with |
---|
| 1738 | // nuh_layer_id equal to that of CurrPic may be marked as "unused for reference" or "used for |
---|
| 1739 | // long-term reference" and any picture with a different value of nuh_layer_id is not marked. |
---|
[1321] | 1740 | // This needs to be invoked only for the first slice segment of a picture. |
---|
| 1741 | xF832DecProcForRefPicSet( ); |
---|
| 1742 | } |
---|
| 1743 | } |
---|
| 1744 | else |
---|
| 1745 | { |
---|
[1356] | 1746 | assert( false ); |
---|
[1321] | 1747 | } |
---|
[608] | 1748 | } |
---|
| 1749 | |
---|
[1321] | 1750 | Void TDecTop::genUnavailableRefPics( ) |
---|
[1356] | 1751 | { |
---|
[1321] | 1752 | assert( m_uiSliceIdx == 0 ); |
---|
| 1753 | Int nuhLayerId = m_pcPic->getLayerId(); |
---|
| 1754 | if ( m_decProcPocAndRps == CLAUSE_8 ) |
---|
| 1755 | { |
---|
| 1756 | // 8.1.3 Decoding process for a coded picture with nuh_layer_id equal to 0 |
---|
| 1757 | |
---|
| 1758 | if ( m_pcPic->isBla() || ( m_pcPic->isCra() && m_pcPic->getNoRaslOutputFlag() ) ) |
---|
| 1759 | { |
---|
[1356] | 1760 | // When the current picture is a BLA picture or is a CRA picture |
---|
| 1761 | // with NoRaslOutputFlag equal to 1, the decoding process for generating |
---|
| 1762 | // unavailable reference pictures specified in clause 8.3.3 is invoked, |
---|
[1321] | 1763 | // which needs to be invoked only for the first slice segment of a picture. |
---|
[1356] | 1764 | x8331GenDecProcForGenUnavilRefPics(); |
---|
[1321] | 1765 | } |
---|
| 1766 | } |
---|
| 1767 | else if( m_decProcPocAndRps == ANNEX_F ) |
---|
| 1768 | { |
---|
| 1769 | // F.8.1.3 Common decoding process for a coded picture |
---|
| 1770 | |
---|
| 1771 | if (nuhLayerId == 0 ) |
---|
| 1772 | { |
---|
| 1773 | // F.8.1.4 Decoding process for a coded picture with nuh_layer_id equal to |
---|
| 1774 | // --> Clause 8.1.3 is invoked with replacments of 8.3.1, 8.3.2, and 8.3.3 by F.8.3.1, 8.3.2, and 8.3.3 |
---|
| 1775 | |
---|
| 1776 | if ( m_pcPic->isBla() || ( m_pcPic->isCra() && m_pcPic->getNoRaslOutputFlag() ) ) |
---|
| 1777 | { |
---|
[1356] | 1778 | // When the current picture is a BLA picture or is a CRA picture |
---|
| 1779 | // with NoRaslOutputFlag equal to 1, the decoding process for generating |
---|
| 1780 | // unavailable reference pictures specified in clause 8.3.3 is invoked, |
---|
[1321] | 1781 | // which needs to be invoked only for the first slice segment of a picture. |
---|
[1356] | 1782 | xF833DecProcForGenUnavRefPics(); |
---|
[1321] | 1783 | } |
---|
| 1784 | #if NH_MV_FIX_INIT_NUM_ACTIVE_REF_LAYER_PICS |
---|
[1356] | 1785 | TComDecodedRps* decRps = m_pcPic->getDecodedRps(); |
---|
[1321] | 1786 | decRps->m_numActiveRefLayerPics0 = 0; |
---|
[1356] | 1787 | decRps->m_numActiveRefLayerPics1 = 0; |
---|
[1321] | 1788 | #endif |
---|
| 1789 | } |
---|
| 1790 | else |
---|
| 1791 | { |
---|
| 1792 | // F.8.1.5 Decoding process for starting the decoding of a coded picture with |
---|
| 1793 | // nuh_layer_id greater than 0 |
---|
| 1794 | |
---|
| 1795 | if ( !m_firstPicInLayerDecodedFlag[ nuhLayerId ] ) |
---|
| 1796 | { |
---|
[1356] | 1797 | // When FirstPicInLayerDecodedFlag[ nuh_layer_id ] is equal to 0, the decoding process for generating |
---|
| 1798 | // unavailable reference pictures for pictures first in decoding order within a layer specified in |
---|
[1321] | 1799 | // clause F.8.1.7 is invoked, which needs to be invoked only for the first slice segment of a picture. |
---|
| 1800 | xF817DecProcForGenUnavRefPicForPicsFrstInDecOrderInLay(); |
---|
| 1801 | } |
---|
| 1802 | |
---|
| 1803 | if ( m_firstPicInLayerDecodedFlag[ nuhLayerId ] && ( m_pcPic->isIrap() && m_pcPic->getNoRaslOutputFlag() ) ) |
---|
| 1804 | { |
---|
[1356] | 1805 | // When FirstPicInLayerDecodedFlag[ nuh_layer_id ] is equal to 1 and the current picture is an IRAP |
---|
| 1806 | // picture with NoRaslOutputFlag equal to 1, the decoding process for generating unavailable reference |
---|
| 1807 | // pictures specified in clause F.8.3.3 is invoked, which needs to be invoked only for the first slice |
---|
[1321] | 1808 | // segment of a picture. |
---|
[1356] | 1809 | xF833DecProcForGenUnavRefPics(); |
---|
[1321] | 1810 | } |
---|
| 1811 | |
---|
| 1812 | if ( decProcAnnexG() ) |
---|
| 1813 | { |
---|
| 1814 | // G.1.2 --> G.1.3 |
---|
| 1815 | xG813DecProcForInterLayerRefPicSet(); |
---|
| 1816 | } |
---|
[1386] | 1817 | else |
---|
| 1818 | { |
---|
| 1819 | #if NH_MV_FIX_INIT_NUM_ACTIVE_REF_LAYER_PICS |
---|
| 1820 | TComDecodedRps* decRps = m_pcPic->getDecodedRps(); |
---|
| 1821 | decRps->m_numActiveRefLayerPics0 = 0; |
---|
| 1822 | decRps->m_numActiveRefLayerPics1 = 0; |
---|
| 1823 | #endif |
---|
| 1824 | } |
---|
[1321] | 1825 | } |
---|
| 1826 | } |
---|
| 1827 | else |
---|
| 1828 | { |
---|
[1356] | 1829 | assert( false ); |
---|
[1321] | 1830 | } |
---|
| 1831 | |
---|
[1356] | 1832 | xCheckUnavailableRefPics(); |
---|
[1321] | 1833 | } |
---|
| 1834 | Void TDecTop::executeLoopFilters( ) |
---|
[622] | 1835 | { |
---|
[1356] | 1836 | assert( m_pcPic != NULL ); |
---|
[1321] | 1837 | if ( !m_pcPic->getHasGeneratedRefPics() && !m_pcPic->getIsGenerated() ) |
---|
[622] | 1838 | { |
---|
[1321] | 1839 | m_cGopDecoder.filterPicture( m_pcPic ); |
---|
| 1840 | } |
---|
| 1841 | m_cCuDecoder.destroy(); |
---|
| 1842 | } |
---|
| 1843 | |
---|
| 1844 | Void TDecTop::finalizePic() |
---|
| 1845 | { |
---|
| 1846 | if( m_pcPic->isIrap() ) |
---|
| 1847 | { |
---|
[1356] | 1848 | m_prevIrapPoc = m_pcPic->getPOC(); |
---|
| 1849 | m_prevIrapDecodingOrder = m_pcPic->getDecodingOrder(); |
---|
[1321] | 1850 | } |
---|
| 1851 | if( m_pcPic->isStsa() ) |
---|
| 1852 | { |
---|
| 1853 | m_prevStsaDecOrder = m_pcPic->getDecodingOrder(); |
---|
| 1854 | m_prevStsaTemporalId = m_pcPic->getTemporalId() ; |
---|
| 1855 | } |
---|
| 1856 | } |
---|
| 1857 | |
---|
| 1858 | |
---|
| 1859 | Void TDecTop::initFromActiveVps( const TComVPS* vps ) |
---|
[1356] | 1860 | { |
---|
| 1861 | setViewId ( vps->getViewId ( getLayerId() ) ); |
---|
[1321] | 1862 | #if NH_3D |
---|
[1356] | 1863 | setViewIndex( vps->getViewIndex( getLayerId() ) ); |
---|
| 1864 | setIsDepth ( vps->getDepthId ( getLayerId() ) == 1 ); |
---|
[1321] | 1865 | #endif |
---|
| 1866 | |
---|
| 1867 | if ( !vps->getVpsExtensionFlag() ) |
---|
| 1868 | { |
---|
[1356] | 1869 | m_decodingProcess = CLAUSE_8; |
---|
[1321] | 1870 | m_isInOwnTargetDecLayerIdList = ( getLayerId() == 0 ); |
---|
| 1871 | } |
---|
| 1872 | else |
---|
[1356] | 1873 | { |
---|
[1321] | 1874 | if ( m_targetOlsIdx == -1 ) |
---|
[622] | 1875 | { |
---|
[1356] | 1876 | // Corresponds to specification by "External Means". (Should be set equal to 0, when no external means available. ) |
---|
| 1877 | m_targetOlsIdx = vps->getVpsNumLayerSetsMinus1(); |
---|
[1321] | 1878 | } |
---|
| 1879 | |
---|
[1356] | 1880 | Int targetDecLayerSetIdx = vps->olsIdxToLsIdx( m_targetOlsIdx ); |
---|
[1321] | 1881 | |
---|
| 1882 | if ( targetDecLayerSetIdx <= vps->getVpsNumLayerSetsMinus1() && vps->getVpsBaseLayerInternalFlag() ) |
---|
| 1883 | { |
---|
[1356] | 1884 | m_smallestLayerId = 0; |
---|
[1321] | 1885 | } |
---|
| 1886 | else if ( targetDecLayerSetIdx <= vps->getVpsNumLayerSetsMinus1() && !vps->getVpsBaseLayerInternalFlag() ) |
---|
| 1887 | { |
---|
[1356] | 1888 | m_smallestLayerId = 0; |
---|
[1321] | 1889 | } |
---|
| 1890 | else if ( targetDecLayerSetIdx > vps->getVpsNumLayerSetsMinus1() && vps->getNumLayersInIdList( targetDecLayerSetIdx) == 1 ) |
---|
| 1891 | { |
---|
[1356] | 1892 | |
---|
| 1893 | // m_smallestLayerId = 0; |
---|
| 1894 | // For now don't do change of layer id here. |
---|
| 1895 | m_smallestLayerId = vps->getTargetDecLayerIdList( targetDecLayerSetIdx )[ 0 ]; |
---|
[1321] | 1896 | } |
---|
| 1897 | else |
---|
| 1898 | { |
---|
[1356] | 1899 | m_smallestLayerId = vps->getTargetDecLayerIdList( targetDecLayerSetIdx )[ 0 ]; |
---|
[1321] | 1900 | } |
---|
| 1901 | |
---|
| 1902 | |
---|
| 1903 | // Set profile |
---|
| 1904 | Int lsIdx = vps->olsIdxToLsIdx( m_targetOlsIdx ); |
---|
[1356] | 1905 | Int lIdx = -1; |
---|
[1321] | 1906 | for (Int j = 0; j < vps->getNumLayersInIdList( lsIdx ) ; j++ ) |
---|
| 1907 | { |
---|
| 1908 | if ( vps->getLayerSetLayerIdList( lsIdx, j ) == getLayerId() ) |
---|
[1356] | 1909 | { |
---|
| 1910 | lIdx = j; |
---|
| 1911 | break; |
---|
| 1912 | } |
---|
[1321] | 1913 | } |
---|
[1356] | 1914 | m_isInOwnTargetDecLayerIdList = (lIdx != -1); |
---|
[1321] | 1915 | |
---|
| 1916 | if ( m_isInOwnTargetDecLayerIdList ) |
---|
| 1917 | { |
---|
| 1918 | Int profileIdc = vps->getPTL( vps->getProfileTierLevelIdx( m_targetOlsIdx, lIdx ) )->getGeneralPTL()->getProfileIdc(); |
---|
| 1919 | |
---|
[1413] | 1920 | #if !NH_MV_ALLOW_NON_CONFORMING |
---|
| 1921 | assert( profileIdc == Profile::MAIN || profileIdc == Profile::MULTIVIEWMAIN|| profileIdc == Profile::MAIN3D ); |
---|
| 1922 | #else |
---|
| 1923 | assert( profileIdc == Profile::MAIN || profileIdc == Profile::MAIN10 || profileIdc == Profile::MULTIVIEWMAIN|| profileIdc == Profile::MAIN3D || profileIdc == Profile::NONE || profileIdc == Profile::MULTIVIEWMAIN_NONCONFORMING || profileIdc == Profile::MAIN3D_NONCONFORMING ); |
---|
| 1924 | #endif |
---|
| 1925 | |
---|
| 1926 | if ( profileIdc == Profile::MULTIVIEWMAIN |
---|
| 1927 | #if NH_MV_ALLOW_NON_CONFORMING |
---|
| 1928 | || profileIdc == Profile::MULTIVIEWMAIN_NONCONFORMING |
---|
| 1929 | #endif |
---|
| 1930 | ) |
---|
[622] | 1931 | { |
---|
[1321] | 1932 | m_decodingProcess = ANNEX_G; |
---|
| 1933 | } |
---|
| 1934 | else if (profileIdc == 7 ) |
---|
| 1935 | { |
---|
| 1936 | m_decodingProcess = ANNEX_H; |
---|
| 1937 | } |
---|
[1413] | 1938 | else if (profileIdc == Profile::MAIN3D |
---|
| 1939 | #if NH_MV_ALLOW_NON_CONFORMING |
---|
| 1940 | || profileIdc == Profile::MAIN3D_NONCONFORMING |
---|
| 1941 | #endif |
---|
| 1942 | ) |
---|
[1321] | 1943 | { |
---|
| 1944 | m_decodingProcess = ANNEX_I; |
---|
| 1945 | } |
---|
| 1946 | } |
---|
[622] | 1947 | } |
---|
| 1948 | } |
---|
[738] | 1949 | |
---|
[1321] | 1950 | |
---|
| 1951 | Bool TDecTop::getFirstSliceSegementInPicFlag() |
---|
[738] | 1952 | { |
---|
[1321] | 1953 | return m_apcSlicePilot->getFirstSliceSegementInPicFlag(); |
---|
| 1954 | } |
---|
[738] | 1955 | |
---|
[1321] | 1956 | Void TDecTop::x831DecProcForPicOrderCount() |
---|
| 1957 | { |
---|
| 1958 | ///////////////////////////////////////////////////// |
---|
| 1959 | // 8.3.1 Decoding process for picture order count // |
---|
| 1960 | ///////////////////////////////////////////////////// |
---|
[738] | 1961 | |
---|
[1321] | 1962 | // Output of this process is PicOrderCntVal, the picture order count of the current picture. |
---|
[1356] | 1963 | // Picture order counts are used to identify pictures, for deriving motion parameters in merge mode and |
---|
[1321] | 1964 | // motion vector prediction, and for decoder conformance checking (see clause C.5). |
---|
| 1965 | // Each coded picture is associated with a picture order count variable, denoted as PicOrderCntVal. |
---|
| 1966 | |
---|
[1356] | 1967 | const TComSlice* curSlice = m_pcPic->getSlice(0); |
---|
[1321] | 1968 | |
---|
[1356] | 1969 | Int prevPicOrderCntLsb = MIN_INT; |
---|
| 1970 | Int prevPicOrderCntMsb = MIN_INT; |
---|
| 1971 | if (!(m_pcPic->isIrap() && m_pcPic->getNoRaslOutputFlag() ) ) |
---|
[1321] | 1972 | { |
---|
[1356] | 1973 | // When the current picture is not an IRAP picture with NoRaslOutputFlag equal to 1, |
---|
[1321] | 1974 | // the variables prevPicOrderCntLsb and prevPicOrderCntMsb are derived as follows: |
---|
| 1975 | |
---|
[1356] | 1976 | // - Let prevTid0Pic be the previous picture in decoding order that has TemporalId equal to 0 and that is not a RASL picture, |
---|
[1321] | 1977 | // a RADL picture or an SLNR picture. |
---|
| 1978 | |
---|
| 1979 | // - The variable prevPicOrderCntLsb is set equal to slice_pic_order_cnt_lsb of prevTid0Pic. |
---|
[1356] | 1980 | prevPicOrderCntLsb = m_prevTid0PicSlicePicOrderCntLsb; |
---|
[1321] | 1981 | |
---|
| 1982 | // - The variable prevPicOrderCntMsb is set equal to PicOrderCntMsb of prevTid0Pic. |
---|
[1356] | 1983 | prevPicOrderCntMsb = m_prevTid0PicPicOrderCntMsb; |
---|
[1321] | 1984 | } |
---|
| 1985 | |
---|
[1356] | 1986 | // The variable PicOrderCntMsb of the current picture is derived as follows: |
---|
| 1987 | |
---|
[1321] | 1988 | Int slicePicOrderCntLsb = curSlice->getSlicePicOrderCntLsb(); |
---|
| 1989 | |
---|
[1356] | 1990 | Int picOrderCntMsb; |
---|
[1321] | 1991 | |
---|
| 1992 | if (m_pcPic->isIrap() && m_pcPic->getNoRaslOutputFlag() ) |
---|
| 1993 | { |
---|
| 1994 | //- If the current picture is an IRAP picture with NoRaslOutputFlag equal to 1, PicOrderCntMsb is set equal to 0. |
---|
[1356] | 1995 | picOrderCntMsb = 0; |
---|
[1321] | 1996 | } |
---|
| 1997 | else |
---|
| 1998 | { |
---|
[1356] | 1999 | Int maxPicOrderCntLsb = curSlice->getSPS()->getMaxPicOrderCntLsb(); |
---|
[1321] | 2000 | |
---|
| 2001 | // - Otherwise, PicOrderCntMsb is derived as follows: |
---|
| 2002 | |
---|
| 2003 | if( ( slicePicOrderCntLsb < prevPicOrderCntLsb ) && |
---|
| 2004 | ( ( prevPicOrderCntLsb - slicePicOrderCntLsb ) >= ( maxPicOrderCntLsb / 2 ) ) ) |
---|
[738] | 2005 | { |
---|
[1321] | 2006 | picOrderCntMsb = prevPicOrderCntMsb + maxPicOrderCntLsb; // (8 1) |
---|
| 2007 | } |
---|
| 2008 | else if( (slicePicOrderCntLsb > prevPicOrderCntLsb ) && |
---|
| 2009 | ( ( slicePicOrderCntLsb - prevPicOrderCntLsb ) > ( maxPicOrderCntLsb / 2 ) ) ) |
---|
| 2010 | { |
---|
| 2011 | picOrderCntMsb = prevPicOrderCntMsb - maxPicOrderCntLsb; |
---|
| 2012 | } |
---|
| 2013 | else |
---|
| 2014 | { |
---|
[1356] | 2015 | picOrderCntMsb = prevPicOrderCntMsb; |
---|
[1321] | 2016 | } |
---|
| 2017 | } |
---|
[1356] | 2018 | |
---|
[1321] | 2019 | //PicOrderCntVal is derived as follows: |
---|
| 2020 | Int picOrderCntVal = picOrderCntMsb + slicePicOrderCntLsb; // (8 2) |
---|
| 2021 | |
---|
[1356] | 2022 | // NOTE 1 - All IDR pictures will have PicOrderCntVal equal to 0 since slice_pic_order_cnt_lsb is inferred to be 0 for IDR |
---|
[1321] | 2023 | // pictures and prevPicOrderCntLsb and prevPicOrderCntMsb are both set equal to 0. |
---|
| 2024 | |
---|
[1356] | 2025 | m_pcPic->getSlice(0)->setPOC( picOrderCntVal ); |
---|
[1321] | 2026 | |
---|
| 2027 | // Update prevTid0Pic |
---|
| 2028 | // Let prevTid0Pic be the previous picture in decoding order that has TemporalId equal to 0 and that is not a RASL picture, a RADL picture or an SLNR picture. |
---|
| 2029 | if( curSlice->getTemporalId() == 0 && !m_pcPic->isRasl() && !m_pcPic->isRadl() && !m_pcPic->isSlnr() ) |
---|
| 2030 | { |
---|
[1356] | 2031 | m_prevTid0PicSlicePicOrderCntLsb = slicePicOrderCntLsb; |
---|
| 2032 | m_prevTid0PicPicOrderCntMsb = picOrderCntMsb; |
---|
[1321] | 2033 | } |
---|
| 2034 | } |
---|
| 2035 | |
---|
| 2036 | Void TDecTop::xF831DecProcForPicOrderCount() |
---|
| 2037 | { |
---|
| 2038 | //Output of this process is PicOrderCntVal, the picture order count of the current picture. |
---|
[1356] | 2039 | // Picture order counts are used to identify pictures, for deriving motion parameters in merge mode and |
---|
[1321] | 2040 | // motion vector prediction and for decoder conformance checking (see clause F.13.5). |
---|
| 2041 | |
---|
| 2042 | // Each coded picture is associated with a picture order count variable, denoted as PicOrderCntVal. |
---|
| 2043 | |
---|
[1356] | 2044 | const TComSlice* slice = m_pcPic->getSlice(0); |
---|
| 2045 | const Int nuhLayerId = m_pcPic->getLayerId(); |
---|
| 2046 | const TComVPS* vps = slice->getVPS(); |
---|
| 2047 | const TComSPS* sps = slice->getSPS(); |
---|
[1321] | 2048 | if ( m_pcPic->getIsFstPicOfAllLayOfPocResetPer() ) |
---|
| 2049 | { |
---|
[1356] | 2050 | // When the current picture is the first picture among all layers of a POC resetting period, |
---|
[1321] | 2051 | // the variable PocDecrementedInDPBFlag[ i ] is set equal to 0 for each value of i in the range of 0 to 62, inclusive. |
---|
| 2052 | for (Int i = 0; i <= 62; i++) |
---|
| 2053 | { |
---|
[1356] | 2054 | m_pocDecrementedInDpbFlag[ i ] = 0; |
---|
[1321] | 2055 | } |
---|
| 2056 | } |
---|
| 2057 | |
---|
| 2058 | // The variable pocResettingFlag is derived as follows: |
---|
[1356] | 2059 | Bool pocResettingFlag; |
---|
[1321] | 2060 | if (m_pcPic->getIsPocResettingPic() ) |
---|
| 2061 | { |
---|
[1356] | 2062 | //- If the current picture is a POC resetting picture, the following applies: |
---|
[1321] | 2063 | if( vps->getVpsPocLsbAlignedFlag() ) |
---|
| 2064 | { |
---|
| 2065 | // - If vps_poc_lsb_aligned_flag is equal to 0, pocResettingFlag is set equal to 1. |
---|
[1356] | 2066 | pocResettingFlag = true; |
---|
[1321] | 2067 | } |
---|
| 2068 | else if ( m_pocDecrementedInDpbFlag[ nuhLayerId ] ) |
---|
| 2069 | { |
---|
| 2070 | // - Otherwise, if PocDecrementedInDPBFlag[ nuh_layer_id ] is equal to 1, pocResettingFlag is set equal to 0. |
---|
[1356] | 2071 | pocResettingFlag = false; |
---|
[1321] | 2072 | } |
---|
| 2073 | else |
---|
| 2074 | { |
---|
| 2075 | // - Otherwise, pocResettingFlag is set equal to 1. |
---|
[1356] | 2076 | pocResettingFlag = true; |
---|
[1321] | 2077 | } |
---|
| 2078 | } |
---|
| 2079 | else |
---|
| 2080 | { |
---|
| 2081 | // - Otherwise, pocResettingFlag is set equal to 0. |
---|
[1356] | 2082 | pocResettingFlag = false; |
---|
[1321] | 2083 | } |
---|
| 2084 | |
---|
| 2085 | // The list affectedLayerList is derived as follows: |
---|
[1356] | 2086 | std::vector<Int> affectedLayerList; |
---|
[1321] | 2087 | if (! vps->getVpsPocLsbAlignedFlag() ) |
---|
| 2088 | { |
---|
| 2089 | //- If vps_poc_lsb_aligned_flag is equal to 0, affectedLayerList consists of the nuh_layer_id of the current picture. |
---|
[1356] | 2090 | affectedLayerList.push_back( nuhLayerId ); |
---|
[1321] | 2091 | } |
---|
| 2092 | else |
---|
| 2093 | { |
---|
[1356] | 2094 | // - Otherwise, affectedLayerList consists of the nuh_layer_id of the current picture and the nuh_layer_id values |
---|
| 2095 | // equal to IdPredictedLayer[ currNuhLayerId ][ j ] for all values of j in the range of 0 to NumPredictedLayers[ currNuhLayerId ] - 1, |
---|
[1321] | 2096 | // inclusive, where currNuhLayerId is the nuh_layer_id value of the current picture. |
---|
[1356] | 2097 | affectedLayerList.push_back( nuhLayerId ); |
---|
| 2098 | Int currNuhLayerId = nuhLayerId; |
---|
[1321] | 2099 | for (Int j = 0; j <= vps->getNumPredictedLayers( currNuhLayerId )-1; j++ ) |
---|
| 2100 | { |
---|
| 2101 | affectedLayerList.push_back( vps->getIdPredictedLayer(currNuhLayerId, j ) ); |
---|
| 2102 | } |
---|
| 2103 | } |
---|
| 2104 | |
---|
[1356] | 2105 | Int picOrderCntMsb; |
---|
| 2106 | Int picOrderCntVal; |
---|
| 2107 | |
---|
[1321] | 2108 | // Depending on pocResettingFlag, the following applies: |
---|
| 2109 | if ( pocResettingFlag ) |
---|
| 2110 | { |
---|
| 2111 | //- If pocResettingFlag is equal to 1, the following applies: |
---|
| 2112 | if ( m_firstPicInLayerDecodedFlag[ nuhLayerId ] ) |
---|
| 2113 | { |
---|
| 2114 | //- The variables pocMsbDelta, pocLsbDelta and DeltaPocVal are derived as follows: |
---|
[1356] | 2115 | Int pocMsbDelta; |
---|
| 2116 | Int pocLsbDelta; |
---|
| 2117 | Int deltaPocVal; |
---|
[1321] | 2118 | |
---|
[738] | 2119 | { |
---|
[1356] | 2120 | Int pocLsbVal; |
---|
| 2121 | Int prevPicOrderCntLsb; |
---|
| 2122 | Int prevPicOrderCntMsb; |
---|
[1321] | 2123 | |
---|
| 2124 | if( slice->getPocResetIdc() == 3 ) |
---|
| 2125 | { |
---|
[1356] | 2126 | pocLsbVal = slice->getPocLsbVal(); |
---|
| 2127 | } |
---|
[1321] | 2128 | else |
---|
| 2129 | { |
---|
[1356] | 2130 | pocLsbVal = slice->getSlicePicOrderCntLsb(); |
---|
[1321] | 2131 | } |
---|
| 2132 | |
---|
| 2133 | if( slice->getPocMsbCycleValPresentFlag() ) |
---|
| 2134 | { |
---|
| 2135 | pocMsbDelta = slice->getPocMsbCycleVal() * sps->getMaxPicOrderCntLsb(); // (F 60) |
---|
[1356] | 2136 | } |
---|
[1321] | 2137 | else |
---|
| 2138 | { |
---|
[1356] | 2139 | prevPicOrderCntLsb = m_prevPicOrderCnt & ( sps->getMaxPicOrderCntLsb() - 1 ); |
---|
| 2140 | prevPicOrderCntMsb = m_prevPicOrderCnt - prevPicOrderCntLsb; |
---|
[1321] | 2141 | |
---|
[1356] | 2142 | pocMsbDelta = xGetCurrMsb( pocLsbVal, prevPicOrderCntLsb, prevPicOrderCntMsb, sps->getMaxPicOrderCntLsb() ); |
---|
[1321] | 2143 | } |
---|
| 2144 | |
---|
| 2145 | if( slice->getPocResetIdc() == 2 || ( slice->getPocResetIdc() == 3 && slice->getFullPocResetFlag() ) ) |
---|
| 2146 | { |
---|
[1356] | 2147 | pocLsbDelta = pocLsbVal; |
---|
[1321] | 2148 | } |
---|
| 2149 | else |
---|
| 2150 | { |
---|
[1356] | 2151 | pocLsbDelta = 0; |
---|
[1321] | 2152 | } |
---|
[1356] | 2153 | deltaPocVal = pocMsbDelta + pocLsbDelta; |
---|
[1321] | 2154 | } |
---|
| 2155 | |
---|
[1356] | 2156 | //- The PicOrderCntVal of each picture that has nuh_layer_id value nuhLayerId for which PocDecrementedInDPBFlag[ nuhLayerId ] is equal to 0 |
---|
[1321] | 2157 | // and that is equal to any value in affectedLayerList is decremented by DeltaPocVal. |
---|
| 2158 | for (Int i = 0; i < (Int) affectedLayerList.size(); i++ ) |
---|
| 2159 | { |
---|
| 2160 | if ( !m_pocDecrementedInDpbFlag[ affectedLayerList[i] ] ) |
---|
| 2161 | { |
---|
[1356] | 2162 | m_dpb->decrementPocsInSubDpb( affectedLayerList[i], deltaPocVal ); |
---|
[1321] | 2163 | } |
---|
| 2164 | } |
---|
| 2165 | |
---|
| 2166 | //- PocDecrementedInDPBFlag[ nuhLayerId ] is set equal to 1 for each value of nuhLayerId included in affectedLayerList. |
---|
| 2167 | for (Int i = 0; i < (Int) affectedLayerList.size(); i++ ) |
---|
| 2168 | { |
---|
[1356] | 2169 | m_pocDecrementedInDpbFlag[ affectedLayerList[i] ] = true; |
---|
[1321] | 2170 | } |
---|
[1356] | 2171 | } |
---|
[1321] | 2172 | |
---|
| 2173 | //- The PicOrderCntVal of the current picture is derived as follows: |
---|
| 2174 | if( slice->getPocResetIdc() == 1 ) |
---|
| 2175 | { |
---|
[1356] | 2176 | picOrderCntVal = slice->getSlicePicOrderCntLsb(); |
---|
[1321] | 2177 | } |
---|
[1356] | 2178 | else if (slice->getPocResetIdc() == 2 ) |
---|
[1321] | 2179 | { |
---|
[1356] | 2180 | picOrderCntVal = 0; |
---|
[1321] | 2181 | } |
---|
| 2182 | else |
---|
| 2183 | { |
---|
[1356] | 2184 | picOrderCntMsb = xGetCurrMsb( slice->getSlicePicOrderCntLsb(), slice->getFullPocResetFlag() ? 0 : slice->getPocLsbVal(), 0, sps->getMaxPicOrderCntLsb() ); |
---|
| 2185 | picOrderCntVal = picOrderCntMsb + slice->getSlicePicOrderCntLsb(); |
---|
[1321] | 2186 | } |
---|
| 2187 | } |
---|
| 2188 | else |
---|
| 2189 | { |
---|
| 2190 | //- Otherwise (pocResettingFlag is equal to 0), the following applies: |
---|
| 2191 | //- The PicOrderCntVal of the current picture is derived as follows: |
---|
[1356] | 2192 | |
---|
[1321] | 2193 | if( slice->getPocMsbCycleValPresentFlag() ) |
---|
| 2194 | { |
---|
[1356] | 2195 | picOrderCntMsb = slice->getPocMsbCycleVal() * sps->getMaxPicOrderCntLsb(); |
---|
[1321] | 2196 | } |
---|
| 2197 | else if( !m_firstPicInLayerDecodedFlag[ nuhLayerId ] || |
---|
| 2198 | slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL ) |
---|
| 2199 | { |
---|
| 2200 | picOrderCntMsb = 0; // (F 62) |
---|
[1356] | 2201 | } |
---|
[1321] | 2202 | else |
---|
| 2203 | { |
---|
| 2204 | Int prevPicOrderCntLsb = m_prevPicOrderCnt & ( sps->getMaxPicOrderCntLsb() - 1 ); |
---|
[1356] | 2205 | Int prevPicOrderCntMsb = m_prevPicOrderCnt - prevPicOrderCntLsb; |
---|
| 2206 | picOrderCntMsb = xGetCurrMsb( slice->getSlicePicOrderCntLsb(), prevPicOrderCntLsb, prevPicOrderCntMsb, sps->getMaxPicOrderCntLsb() ); |
---|
[1321] | 2207 | } |
---|
[1356] | 2208 | picOrderCntVal = picOrderCntMsb + slice->getSlicePicOrderCntLsb(); |
---|
[1321] | 2209 | } |
---|
[1356] | 2210 | |
---|
| 2211 | m_pcPic->getSlice(0)->setPOC( picOrderCntVal ); |
---|
| 2212 | |
---|
[1321] | 2213 | for (Int lId = 0; lId < (Int) affectedLayerList.size(); lId++ ) |
---|
[1356] | 2214 | { |
---|
[1321] | 2215 | // The value of PrevPicOrderCnt[ lId ] for each of the lId values included in affectedLayerList is derived as follows: |
---|
| 2216 | |
---|
| 2217 | if (!m_pcPic->isRasl() && !m_pcPic->isRadl() && !m_pcPic->isSlnr() && slice->getTemporalId() == 0 && !slice->getDiscardableFlag() ) |
---|
| 2218 | { |
---|
[1356] | 2219 | //- If the current picture is not a RASL picture, a RADL picture or a sub-layer non-reference picture, and the current picture |
---|
[1321] | 2220 | // has TemporalId equal to 0 and discardable_flag equal to 0, PrevPicOrderCnt[ lId ] is set equal to PicOrderCntVal. |
---|
[1356] | 2221 | m_prevPicOrderCnt = picOrderCntVal; |
---|
[1321] | 2222 | } |
---|
| 2223 | else if ( slice->getPocResetIdc() == 3 && ( |
---|
[1356] | 2224 | ( !m_firstPicInLayerDecodedFlag[ nuhLayerId ]) || |
---|
| 2225 | ( m_firstPicInLayerDecodedFlag[ nuhLayerId ] && m_pcPic->getIsPocResettingPic() ) |
---|
[1321] | 2226 | ) ) |
---|
| 2227 | { |
---|
| 2228 | // - Otherwise, when poc_reset_idc is equal to 3 and one of the following conditions is true, PrevPicOrderCnt[ lId ] is set equal to ( full_poc_reset_flag ? 0 : poc_lsb_val ): |
---|
| 2229 | // - FirstPicInLayerDecodedFlag[ nuh_layer_id ] is equal to 0. |
---|
| 2230 | // - FirstPicInLayerDecodedFlag[ nuh_layer_id ] is equal to 1 and the current picture is a POC resetting picture. |
---|
[1356] | 2231 | m_prevPicOrderCnt = ( slice->getFullPocResetFlag() ? 0 : slice->getPocLsbVal() ); |
---|
[1321] | 2232 | } |
---|
| 2233 | } |
---|
| 2234 | } |
---|
| 2235 | |
---|
| 2236 | Int TDecTop::xGetCurrMsb( Int cl, Int pl, Int pm, Int ml ) |
---|
| 2237 | { |
---|
[1356] | 2238 | Int currMsb; |
---|
[1321] | 2239 | if ((pl - cl) >= (ml/ 2)) |
---|
| 2240 | { |
---|
| 2241 | currMsb = pm + ml; |
---|
| 2242 | } |
---|
| 2243 | else if ( (cl - pl) > (ml / 2)) |
---|
| 2244 | { |
---|
[1356] | 2245 | currMsb = pm - ml; |
---|
[1321] | 2246 | } |
---|
| 2247 | else |
---|
| 2248 | { |
---|
[1356] | 2249 | currMsb = pm; |
---|
[1321] | 2250 | } |
---|
| 2251 | |
---|
[1356] | 2252 | return currMsb; |
---|
| 2253 | } |
---|
[1321] | 2254 | |
---|
| 2255 | |
---|
| 2256 | |
---|
| 2257 | Void TDecTop::x832DecProcForRefPicSet( Bool annexFModifications ) |
---|
| 2258 | { |
---|
| 2259 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
| 2260 | // 8.3.2 8.3.2 Decoding process for reference picture set |
---|
| 2261 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
| 2262 | |
---|
[1356] | 2263 | TComSlice* slice = m_pcPic->getSlice( 0 ); |
---|
| 2264 | const TComSPS* sps = slice->getSPS(); |
---|
| 2265 | // This process is invoked once per picture, after decoding of a slice header but prior to the decoding of any coding unit and prior |
---|
| 2266 | // to the decoding process for reference picture list construction for the slice as specified in clause 8.3.3. |
---|
| 2267 | // This process may result in one or more reference pictures in the DPB being marked as "unused for reference" or |
---|
[1321] | 2268 | // "used for long-term reference". |
---|
| 2269 | |
---|
| 2270 | // The variable currPicLayerId is set equal to nuh_layer_id of the current picture. |
---|
[1356] | 2271 | Int currPicLayerId = m_pcPic->getLayerId(); |
---|
| 2272 | Int picOrderCntVal = m_pcPic->getPOC(); |
---|
[1321] | 2273 | |
---|
| 2274 | if (m_pcPic->isIrap() && m_pcPic->getNoRaslOutputFlag() ) |
---|
[1356] | 2275 | { |
---|
| 2276 | // When the current picture is an IRAP picture with NoRaslOutputFlag equal to 1, |
---|
| 2277 | // all reference pictures with nuh_layer_id equal to currPicLayerId currently in the |
---|
[1321] | 2278 | // DPB (if any) are marked as "unused for reference". |
---|
[1356] | 2279 | m_dpb->markSubDpbAsUnusedForReference( currPicLayerId ); |
---|
[1321] | 2280 | } |
---|
[1356] | 2281 | // Short-term reference pictures are identified by their PicOrderCntVal values. Long-term reference pictures are identified either by |
---|
[1321] | 2282 | // their PicOrderCntVal values or their slice_pic_order_cnt_lsb values. |
---|
| 2283 | |
---|
[1356] | 2284 | // Five lists of picture order count values are constructed to derive the RPS. These five lists are PocStCurrBefore, |
---|
| 2285 | // PocStCurrAfter, PocStFoll, PocLtCurr and PocLtFoll, with NumPocStCurrBefore, NumPocStCurrAfter, NumPocStFoll, |
---|
[1321] | 2286 | // NumPocLtCurr and NumPocLtFoll number of elements, respectively. The five lists and the five variables are derived as follows: |
---|
| 2287 | |
---|
[1356] | 2288 | TComDecodedRps* decRps = m_pcPic->getDecodedRps(); |
---|
| 2289 | |
---|
[1321] | 2290 | std::vector<Int>& pocStCurrBefore = decRps->m_pocStCurrBefore; |
---|
| 2291 | std::vector<Int>& pocStCurrAfter = decRps->m_pocStCurrAfter; |
---|
| 2292 | std::vector<Int>& pocStFoll = decRps->m_pocStFoll; |
---|
| 2293 | std::vector<Int>& pocLtCurr = decRps->m_pocLtCurr; |
---|
| 2294 | std::vector<Int>& pocLtFoll = decRps->m_pocLtFoll; |
---|
| 2295 | |
---|
[1356] | 2296 | Int& numPocStCurrBefore = decRps->m_numPocStCurrBefore; |
---|
[1321] | 2297 | Int& numPocStCurrAfter = decRps->m_numPocStCurrAfter; |
---|
| 2298 | Int& numPocStFoll = decRps->m_numPocStFoll; |
---|
| 2299 | Int& numPocLtCurr = decRps->m_numPocLtCurr; |
---|
[1356] | 2300 | Int& numPocLtFoll = decRps->m_numPocLtFoll; |
---|
[1321] | 2301 | |
---|
[1356] | 2302 | std::vector<Int> currDeltaPocMsbPresentFlag, follDeltaPocMsbPresentFlag; |
---|
[1321] | 2303 | |
---|
| 2304 | if (m_pcPic->isIdr() ) |
---|
| 2305 | { |
---|
[1356] | 2306 | // - If the current picture is an IDR picture, PocStCurrBefore, PocStCurrAfter, PocStFoll, |
---|
| 2307 | // PocLtCurr and PocLtFoll are all set to be empty, and NumPocStCurrBefore, |
---|
[1321] | 2308 | // NumPocStCurrAfter, NumPocStFoll, NumPocLtCurr and NumPocLtFoll are all set equal to 0. |
---|
| 2309 | |
---|
| 2310 | pocStCurrBefore.clear(); |
---|
| 2311 | pocStCurrAfter .clear(); |
---|
| 2312 | pocStFoll .clear(); |
---|
| 2313 | pocLtCurr .clear(); |
---|
| 2314 | pocLtFoll .clear(); |
---|
[1356] | 2315 | numPocStCurrBefore = 0; |
---|
| 2316 | numPocStCurrAfter = 0; |
---|
| 2317 | numPocStFoll = 0; |
---|
| 2318 | numPocLtCurr = 0; |
---|
| 2319 | numPocLtFoll = 0; |
---|
[1321] | 2320 | } |
---|
| 2321 | else |
---|
| 2322 | { |
---|
| 2323 | const TComStRefPicSet* stRps = slice->getStRps( slice->getCurrRpsIdx() ); |
---|
| 2324 | // - Otherwise, the following applies: |
---|
| 2325 | |
---|
[1356] | 2326 | Int j = 0; |
---|
| 2327 | Int k = 0; |
---|
[1321] | 2328 | for( Int i = 0; i < stRps->getNumNegativePicsVar() ; i++ ) |
---|
| 2329 | { |
---|
| 2330 | if( stRps->getUsedByCurrPicS0Var( i ) ) |
---|
| 2331 | { |
---|
| 2332 | pocStCurrBefore.push_back( picOrderCntVal + stRps->getDeltaPocS0Var( i ) ); j++; |
---|
| 2333 | } |
---|
| 2334 | else |
---|
| 2335 | { |
---|
| 2336 | pocStFoll .push_back( picOrderCntVal + stRps->getDeltaPocS0Var( i ) ); k++; |
---|
| 2337 | } |
---|
| 2338 | } |
---|
[1356] | 2339 | numPocStCurrBefore = j; |
---|
[1321] | 2340 | |
---|
[1356] | 2341 | j = 0; |
---|
[1321] | 2342 | for (Int i = 0; i < stRps->getNumPositivePicsVar(); i++ ) |
---|
| 2343 | { |
---|
| 2344 | if (stRps->getUsedByCurrPicS1Var( i ) ) |
---|
| 2345 | { |
---|
[1356] | 2346 | pocStCurrAfter.push_back( picOrderCntVal + stRps->getDeltaPocS1Var( i ) ); j++; |
---|
[1321] | 2347 | } |
---|
| 2348 | else |
---|
| 2349 | { |
---|
| 2350 | pocStFoll .push_back( picOrderCntVal + stRps->getDeltaPocS1Var( i ) ); k++; |
---|
| 2351 | } |
---|
| 2352 | } |
---|
| 2353 | numPocStCurrAfter = j; |
---|
| 2354 | numPocStFoll = k; // (8 5) |
---|
| 2355 | |
---|
| 2356 | |
---|
[1356] | 2357 | j = 0; |
---|
| 2358 | k = 0; |
---|
[1321] | 2359 | for( Int i = 0; i < slice->getNumLongTermSps( ) + slice->getNumLongTermPics(); i++ ) |
---|
| 2360 | { |
---|
[1356] | 2361 | Int pocLt = slice->getPocLsbLtVar( i ); |
---|
[1321] | 2362 | if( slice->getDeltaPocMsbPresentFlag( i ) ) |
---|
| 2363 | { |
---|
| 2364 | pocLt += picOrderCntVal - slice->getDeltaPocMsbCycleLtVar( i ) * sps->getMaxPicOrderCntLsb() - |
---|
| 2365 | ( picOrderCntVal & ( sps->getMaxPicOrderCntLsb() - 1 ) ); |
---|
| 2366 | } |
---|
| 2367 | |
---|
[1356] | 2368 | if( slice->getUsedByCurrPicLtVar(i)) |
---|
[1321] | 2369 | { |
---|
| 2370 | pocLtCurr.push_back( pocLt ); |
---|
[1356] | 2371 | currDeltaPocMsbPresentFlag.push_back( slice->getDeltaPocMsbPresentFlag( i ) ); j++; |
---|
| 2372 | } |
---|
[1321] | 2373 | else |
---|
| 2374 | { |
---|
| 2375 | pocLtFoll.push_back( pocLt ); |
---|
[1356] | 2376 | follDeltaPocMsbPresentFlag.push_back( slice->getDeltaPocMsbPresentFlag( i ) ); k++; |
---|
[1321] | 2377 | } |
---|
[738] | 2378 | } |
---|
[1321] | 2379 | numPocLtCurr = j; |
---|
| 2380 | numPocLtFoll = k; |
---|
[738] | 2381 | } |
---|
[1321] | 2382 | |
---|
| 2383 | assert(numPocStCurrAfter == pocStCurrAfter .size() ); |
---|
| 2384 | assert(numPocStCurrBefore == pocStCurrBefore .size() ); |
---|
[1356] | 2385 | assert(numPocStFoll == pocStFoll .size() ); |
---|
| 2386 | assert(numPocLtCurr == pocLtCurr .size() ); |
---|
[1321] | 2387 | assert(numPocLtFoll == pocLtFoll .size() ); |
---|
| 2388 | |
---|
| 2389 | // where PicOrderCntVal is the picture order count of the current picture as specified in clause 8.3.1. |
---|
| 2390 | |
---|
[1356] | 2391 | // NOTE 2 - A value of CurrRpsIdx in the range of 0 to num_short_term_ref_pic_sets - 1, inclusive, |
---|
| 2392 | // indicates that a candidate short-term RPS from the active SPS for the current layer is being used, |
---|
| 2393 | // where CurrRpsIdx is the index of the candidate short-term RPS into the list of candidate short-term RPSs signalled |
---|
| 2394 | // in the active SPS for the current layer. CurrRpsIdx equal to num_short_term_ref_pic_sets indicates that |
---|
[1321] | 2395 | // the short-term RPS of the current picture is directly signalled in the slice header. |
---|
| 2396 | |
---|
| 2397 | for (Int i = 0; i <= numPocLtCurr - 1; i++ ) |
---|
| 2398 | { |
---|
[1356] | 2399 | // For each i in the range of 0 to NumPocLtCurr - 1, inclusive, when CurrDeltaPocMsbPresentFlag[ i ] is equal to 1, |
---|
[1321] | 2400 | // it is a requirement of bitstream conformance that the following conditions apply: |
---|
| 2401 | if ( currDeltaPocMsbPresentFlag[i] ) |
---|
| 2402 | { |
---|
[1356] | 2403 | // - There shall be no j in the range of 0 to NumPocStCurrBefore - 1, inclusive, |
---|
[1321] | 2404 | // for which PocLtCurr[ i ] is equal to PocStCurrBefore[ j ]. |
---|
| 2405 | for (Int j = 0; j <= numPocStCurrBefore - 1; j++ ) |
---|
| 2406 | { |
---|
| 2407 | assert(!( pocLtCurr[ i ] == pocStCurrBefore[ j ] ) ); |
---|
| 2408 | } |
---|
| 2409 | |
---|
[1356] | 2410 | // - There shall be no j in the range of 0 to NumPocStCurrAfter - 1, inclusive, |
---|
| 2411 | // for which PocLtCurr[ i ] is equal to PocStCurrAfter[ j ]. |
---|
[1321] | 2412 | for (Int j = 0; j <= numPocStCurrAfter - 1; j++ ) |
---|
| 2413 | { |
---|
| 2414 | assert(!( pocLtCurr[ i ] == pocStCurrAfter[ j ] ) ); |
---|
| 2415 | } |
---|
| 2416 | |
---|
[1356] | 2417 | // - There shall be no j in the range of 0 to NumPocStFoll - 1, inclusive, |
---|
[1321] | 2418 | // for which PocLtCurr[ i ] is equal to PocStFoll[ j ]. |
---|
| 2419 | for (Int j = 0; j <= numPocStFoll - 1; j++ ) |
---|
| 2420 | { |
---|
| 2421 | assert(!( pocLtCurr[ i ] == pocStFoll[ j ] ) ); |
---|
| 2422 | } |
---|
| 2423 | |
---|
[1356] | 2424 | // - There shall be no j in the range of 0 to NumPocLtCurr - 1, inclusive, |
---|
[1321] | 2425 | // where j is not equal to i, for which PocLtCurr[ i ] is equal to PocLtCurr[ j ]. |
---|
| 2426 | for (Int j = 0; j <= numPocLtCurr - 1; j++ ) |
---|
| 2427 | { |
---|
| 2428 | if ( i != j ) |
---|
[1356] | 2429 | { |
---|
[1321] | 2430 | assert(!( pocLtCurr[ i ] == pocLtCurr[ j ] ) ); |
---|
| 2431 | } |
---|
| 2432 | } |
---|
| 2433 | } |
---|
| 2434 | } |
---|
| 2435 | |
---|
| 2436 | for (Int i = 0; i <= numPocLtFoll - 1; i++ ) |
---|
| 2437 | { |
---|
[1356] | 2438 | // For each i in the range of 0 to NumPocLtFoll - 1, inclusive, when FollDeltaPocMsbPresentFlag[ i ] is equal to 1, |
---|
[1321] | 2439 | // it is a requirement of bitstream conformance that the following conditions apply: |
---|
| 2440 | if ( follDeltaPocMsbPresentFlag[i] ) |
---|
| 2441 | { |
---|
[1356] | 2442 | // - There shall be no j in the range of 0 to NumPocStCurrBefore - 1, inclusive, |
---|
[1321] | 2443 | // for which PocLtFoll[ i ] is equal to PocStCurrBefore[ j ]. |
---|
| 2444 | for (Int j = 0; j <= numPocStCurrBefore - 1; j++ ) |
---|
| 2445 | { |
---|
| 2446 | assert(!( pocLtFoll[ i ] == pocStCurrBefore[ j ] ) ); |
---|
| 2447 | } |
---|
| 2448 | |
---|
[1356] | 2449 | // - There shall be no j in the range of 0 to NumPocStCurrAfter - 1, inclusive, |
---|
[1321] | 2450 | // for which PocLtFoll[ i ] is equal to PocStCurrAfter[ j ]. |
---|
| 2451 | for (Int j = 0; j <= numPocStCurrAfter - 1; j++ ) |
---|
| 2452 | { |
---|
| 2453 | assert(!( pocLtFoll[ i ] == pocStCurrAfter[ j ] ) ); |
---|
| 2454 | } |
---|
| 2455 | |
---|
[1356] | 2456 | // - There shall be no j in the range of 0 to NumPocStFoll - 1, inclusive, |
---|
[1321] | 2457 | // for which PocLtFoll[ i ] is equal to PocStFoll[ j ]. |
---|
| 2458 | for (Int j = 0; j <= numPocStFoll - 1; j++ ) |
---|
| 2459 | { |
---|
| 2460 | assert(!( pocLtFoll[ i ] == pocStFoll[ j ] ) ); |
---|
| 2461 | } |
---|
| 2462 | |
---|
[1356] | 2463 | // - There shall be no j in the range of 0 to NumPocLtFoll - 1, inclusive, |
---|
[1321] | 2464 | // where j is not equal to i, for which PocLtFoll[ i ] is equal to PocLtFoll[ j ]. |
---|
| 2465 | for (Int j = 0; j <= numPocLtFoll - 1; j++ ) |
---|
| 2466 | { |
---|
| 2467 | if (j != i) |
---|
| 2468 | { |
---|
| 2469 | assert(!( pocLtFoll[ i ] == pocLtFoll[ j ] ) ); |
---|
| 2470 | } |
---|
| 2471 | } |
---|
| 2472 | |
---|
[1356] | 2473 | // - There shall be no j in the range of 0 to NumPocLtCurr - 1, inclusive, |
---|
[1321] | 2474 | // for which PocLtFoll[ i ] is equal to PocLtCurr[ j ]. |
---|
| 2475 | for (Int j = 0; j <= numPocLtCurr - 1; j++ ) |
---|
| 2476 | { |
---|
| 2477 | assert(!( pocLtFoll[ i ] == pocLtCurr[ j ] ) ); |
---|
| 2478 | } |
---|
| 2479 | } |
---|
| 2480 | } |
---|
| 2481 | |
---|
[1356] | 2482 | Int maxPicOrderCntLsb = sps->getMaxPicOrderCntLsb(); |
---|
[1321] | 2483 | for (Int i = 0; i <= numPocLtCurr - 1; i++ ) |
---|
| 2484 | { |
---|
[1356] | 2485 | // For each i in the range of 0 to NumPocLtCurr - 1, inclusive, when CurrDeltaPocMsbPresentFlag[ i ] is equal to 0, |
---|
[1321] | 2486 | // it is a requirement of bitstream conformance that the following conditions apply: |
---|
| 2487 | if ( currDeltaPocMsbPresentFlag[ i ] == 0 ) |
---|
| 2488 | { |
---|
[1356] | 2489 | // - There shall be no j in the range of 0 to NumPocStCurrBefore - 1, inclusive, |
---|
[1321] | 2490 | // for which PocLtCurr[ i ] is equal to ( PocStCurrBefore[ j ] & ( MaxPicOrderCntLsb - 1 ) ). |
---|
| 2491 | for (Int j = 0; j <= numPocStCurrBefore - 1; j++ ) |
---|
| 2492 | { |
---|
| 2493 | assert(!( pocLtCurr[ i ] == ( pocStCurrBefore[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) ); |
---|
| 2494 | } |
---|
| 2495 | |
---|
| 2496 | // - There shall be no j in the range of 0 to NumPocStCurrAfter - 1, inclusive, |
---|
| 2497 | // for which PocLtCurr[ i ] is equal to ( PocStCurrAfter[ j ] & ( MaxPicOrderCntLsb - 1 ) ). |
---|
| 2498 | for (Int j = 0; j <= numPocStCurrAfter - 1; j++ ) |
---|
| 2499 | { |
---|
| 2500 | assert(!( pocLtCurr[ i ] == ( pocStCurrAfter[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) ); |
---|
| 2501 | } |
---|
| 2502 | |
---|
| 2503 | // - There shall be no j in the range of 0 to NumPocStFoll - 1, inclusive, |
---|
| 2504 | // for which PocLtCurr[ i ] is equal to ( PocStFoll[ j ] & ( MaxPicOrderCntLsb - 1 ) ). |
---|
| 2505 | for (Int j = 0; j <= numPocStFoll - 1; j++ ) |
---|
| 2506 | { |
---|
| 2507 | assert(!( pocLtCurr[ i ] == ( pocStFoll[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) ); |
---|
| 2508 | } |
---|
| 2509 | |
---|
| 2510 | // - There shall be no j in the range of 0 to NumPocLtCurr - 1, inclusive, |
---|
| 2511 | // where j is not equal to i, for which PocLtCurr[ i ] is equal to ( PocLtCurr[ j ] & ( MaxPicOrderCntLsb - 1 ) ). |
---|
| 2512 | for (Int j = 0; j <= numPocLtCurr - 1; j++ ) |
---|
| 2513 | { |
---|
| 2514 | if (j != i) |
---|
| 2515 | { |
---|
| 2516 | assert(!( pocLtCurr[ i ] == ( pocLtCurr[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) ); |
---|
| 2517 | } |
---|
| 2518 | } |
---|
| 2519 | } |
---|
| 2520 | } |
---|
| 2521 | |
---|
| 2522 | for (Int i = 0; i <= numPocLtFoll - 1; i++ ) |
---|
| 2523 | { |
---|
[1356] | 2524 | // For each i in the range of 0 to NumPocLtFoll - 1, inclusive, when FollDeltaPocMsbPresentFlag[ i ] is equal to 0, |
---|
[1321] | 2525 | // it is a requirement of bitstream conformance that the following conditions apply: |
---|
| 2526 | if ( follDeltaPocMsbPresentFlag[ i ] == 0 ) |
---|
| 2527 | { |
---|
| 2528 | // - There shall be no j in the range of 0 to NumPocStCurrBefore - 1, inclusive, |
---|
| 2529 | // for which PocLtFoll[ i ] is equal to ( PocStCurrBefore[ j ] & ( MaxPicOrderCntLsb - 1 ) ). |
---|
| 2530 | for (Int j = 0; j <= numPocStCurrBefore - 1; j++ ) |
---|
| 2531 | { |
---|
| 2532 | assert(!( pocLtFoll[ i ] == ( pocStCurrBefore[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) ); |
---|
| 2533 | } |
---|
| 2534 | |
---|
| 2535 | // - There shall be no j in the range of 0 to NumPocStCurrAfter - 1, inclusive, |
---|
| 2536 | // for which PocLtFoll[ i ] is equal to ( PocStCurrAfter[ j ] & ( MaxPicOrderCntLsb - 1 ) ). |
---|
| 2537 | for (Int j = 0; j <= numPocStCurrAfter - 1; j++ ) |
---|
| 2538 | { |
---|
| 2539 | assert(!( pocLtFoll[ i ] == ( pocStCurrAfter[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) ); |
---|
| 2540 | } |
---|
| 2541 | |
---|
| 2542 | // - There shall be no j in the range of 0 to NumPocStFoll - 1, inclusive, |
---|
| 2543 | // for which PocLtFoll[ i ] is equal to ( PocStFoll[ j ] & ( MaxPicOrderCntLsb - 1 ) ). |
---|
| 2544 | for (Int j = 0; j <= numPocStFoll - 1; j++ ) |
---|
| 2545 | { |
---|
| 2546 | assert(!( pocLtFoll[ i ] == ( pocStFoll[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) ); |
---|
| 2547 | } |
---|
| 2548 | |
---|
| 2549 | // - There shall be no j in the range of 0 to NumPocLtFoll - 1, inclusive, |
---|
| 2550 | // where j is not equal to i, for which PocLtFoll[ i ] is equal to ( PocLtFoll[ j ] & ( MaxPicOrderCntLsb - 1 ) ). |
---|
| 2551 | for (Int j = 0; j <= numPocLtFoll - 1; j++ ) |
---|
| 2552 | { |
---|
| 2553 | if (j != i) |
---|
| 2554 | { |
---|
| 2555 | assert(!( pocLtFoll[ i ] == ( pocLtFoll[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) ); |
---|
[1356] | 2556 | } |
---|
[1321] | 2557 | } |
---|
| 2558 | |
---|
| 2559 | // - There shall be no j in the range of 0 to NumPocLtCurr - 1, inclusive, |
---|
| 2560 | // for which PocLtFoll[ i ] is equal to ( PocLtCurr[ j ] & ( MaxPicOrderCntLsb - 1 ) ). |
---|
| 2561 | for (Int j = 0; j <= numPocLtCurr - 1; j++ ) |
---|
| 2562 | { |
---|
| 2563 | assert(!( pocLtFoll[ i ] == ( pocLtCurr[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) ); |
---|
| 2564 | } |
---|
| 2565 | } |
---|
| 2566 | } |
---|
| 2567 | |
---|
| 2568 | if ( !annexFModifications ) |
---|
[1356] | 2569 | { |
---|
| 2570 | // The variable NumPicTotalCurr is derived as specified in clause 7.4.7.2. |
---|
[1321] | 2571 | |
---|
| 2572 | // It is a requirement of bitstream conformance that the following applies to the value of NumPicTotalCurr: |
---|
| 2573 | if ( m_pcPic->isBla() || m_pcPic->isCra() ) |
---|
| 2574 | { |
---|
| 2575 | // - If the current picture is a BLA or CRA picture, the value of NumPicTotalCurr shall be equal to 0. |
---|
[1356] | 2576 | assert( slice->getNumPicTotalCurr() == 0 ); |
---|
[1321] | 2577 | } |
---|
| 2578 | else |
---|
| 2579 | { |
---|
[1356] | 2580 | // - Otherwise, |
---|
[1321] | 2581 | if ( slice->isInterP() || slice->isInterB() ) |
---|
| 2582 | { |
---|
| 2583 | // when the current picture contains a P or B slice, the value of NumPicTotalCurr shall not be equal to 0. |
---|
[1356] | 2584 | assert( slice->getNumPicTotalCurr() != 0 ); |
---|
[1321] | 2585 | } |
---|
| 2586 | } |
---|
| 2587 | } |
---|
[1356] | 2588 | |
---|
| 2589 | // The RPS of the current picture consists of five RPS lists; RefPicSetStCurrBefore, RefPicSetStCurrAfter, RefPicSetStFoll, |
---|
| 2590 | // RefPicSetLtCurr and RefPicSetLtFoll. RefPicSetStCurrBefore, RefPicSetStCurrAfter and RefPicSetStFoll are collectively |
---|
[1321] | 2591 | // referred to as the short-term RPS. RefPicSetLtCurr and RefPicSetLtFoll are collectively referred to as the long-term RPS. |
---|
| 2592 | |
---|
| 2593 | std::vector<TComPic*>& refPicSetStCurrBefore = decRps->m_refPicSetStCurrBefore; |
---|
| 2594 | std::vector<TComPic*>& refPicSetStCurrAfter = decRps->m_refPicSetStCurrAfter ; |
---|
| 2595 | std::vector<TComPic*>& refPicSetStFoll = decRps->m_refPicSetStFoll ; |
---|
| 2596 | std::vector<TComPic*>& refPicSetLtCurr = decRps->m_refPicSetLtCurr ; |
---|
| 2597 | std::vector<TComPic*>& refPicSetLtFoll = decRps->m_refPicSetLtFoll ; |
---|
[1356] | 2598 | |
---|
[1321] | 2599 | std::vector<TComPic*>** refPicSetsCurr = decRps->m_refPicSetsCurr ; |
---|
| 2600 | std::vector<TComPic*>** refPicSetsLt = decRps->m_refPicSetsLt ; |
---|
| 2601 | std::vector<TComPic*>** refPicSetsAll = decRps->m_refPicSetsAll ; |
---|
[1356] | 2602 | // NOTE 3 - RefPicSetStCurrBefore, RefPicSetStCurrAfter and RefPicSetLtCurr contain all reference pictures that may be |
---|
[1321] | 2603 | // used for inter prediction of the current picture and one or more pictures that follow the current picture in decoding order. |
---|
[1356] | 2604 | // RefPicSetStFoll and RefPicSetLtFoll consist of all reference pictures that are not used for inter prediction of the current |
---|
[1321] | 2605 | // picture but may be used in inter prediction for one or more pictures that follow the current picture in decoding order. |
---|
| 2606 | |
---|
| 2607 | // The derivation process for the RPS and picture marking are performed according to the following ordered steps: |
---|
| 2608 | // 1. The following applies: |
---|
| 2609 | |
---|
[1356] | 2610 | TComSubDpb* dpb = m_dpb->getSubDpb( getLayerId(), false ); |
---|
[1321] | 2611 | assert( refPicSetLtCurr.empty() ); |
---|
[1356] | 2612 | for( Int i = 0; i < numPocLtCurr; i++ ) |
---|
[1321] | 2613 | { |
---|
[1356] | 2614 | if( !currDeltaPocMsbPresentFlag[ i ] ) |
---|
| 2615 | { |
---|
| 2616 | refPicSetLtCurr.push_back( dpb->getPicFromLsb( pocLtCurr[ i ], maxPicOrderCntLsb ) ); |
---|
[1321] | 2617 | } |
---|
| 2618 | else |
---|
| 2619 | { |
---|
[1356] | 2620 | refPicSetLtCurr.push_back(dpb->getPic( pocLtCurr[ i ] )); |
---|
| 2621 | } |
---|
[1321] | 2622 | } |
---|
| 2623 | |
---|
| 2624 | assert( refPicSetLtFoll.empty() ); |
---|
| 2625 | for( Int i = 0; i < numPocLtFoll; i++ ) |
---|
| 2626 | { |
---|
| 2627 | if( !follDeltaPocMsbPresentFlag[ i ] ) |
---|
| 2628 | { |
---|
| 2629 | refPicSetLtFoll.push_back(dpb->getPicFromLsb(pocLtFoll[ i ], maxPicOrderCntLsb )); |
---|
| 2630 | } |
---|
| 2631 | else |
---|
| 2632 | { |
---|
[1356] | 2633 | refPicSetLtFoll.push_back(dpb->getPic( pocLtFoll[ i ] )); |
---|
[1321] | 2634 | } |
---|
| 2635 | } |
---|
[1356] | 2636 | |
---|
| 2637 | // 2. All reference pictures that are included in RefPicSetLtCurr or RefPicSetLtFoll and have nuh_layer_id equal |
---|
[1321] | 2638 | // to currPicLayerId are marked as "used for long-term reference". |
---|
| 2639 | for (Int i = 0; i < numPocLtCurr; i++) |
---|
| 2640 | { |
---|
| 2641 | if ( refPicSetLtCurr[i] != NULL ) |
---|
| 2642 | { |
---|
[1356] | 2643 | refPicSetLtCurr[i]->markAsUsedForLongTermReference(); |
---|
| 2644 | } |
---|
[1321] | 2645 | } |
---|
| 2646 | |
---|
| 2647 | for (Int i = 0; i < numPocLtFoll; i++) |
---|
| 2648 | { |
---|
| 2649 | if ( refPicSetLtFoll[i] != NULL ) |
---|
| 2650 | { |
---|
[1356] | 2651 | refPicSetLtFoll[i]->markAsUsedForLongTermReference(); |
---|
| 2652 | } |
---|
[1321] | 2653 | } |
---|
| 2654 | |
---|
| 2655 | // 3. The following applies: |
---|
| 2656 | assert( refPicSetStCurrBefore.empty() ); |
---|
| 2657 | for( Int i = 0; i < numPocStCurrBefore; i++ ) |
---|
| 2658 | { |
---|
[1356] | 2659 | refPicSetStCurrBefore.push_back(dpb->getShortTermRefPic( pocStCurrBefore[ i ] )); |
---|
[1321] | 2660 | } |
---|
| 2661 | |
---|
| 2662 | assert( refPicSetStCurrAfter.empty() ); |
---|
| 2663 | for( Int i = 0; i < numPocStCurrAfter; i++ ) |
---|
| 2664 | { |
---|
[1356] | 2665 | refPicSetStCurrAfter.push_back(dpb->getShortTermRefPic( pocStCurrAfter[ i ] )); |
---|
[1321] | 2666 | } |
---|
| 2667 | |
---|
| 2668 | assert( refPicSetStFoll.empty() ); |
---|
| 2669 | for( Int i = 0; i < numPocStFoll; i++ ) |
---|
| 2670 | { |
---|
[1356] | 2671 | refPicSetStFoll.push_back(dpb->getShortTermRefPic( pocStFoll[ i ] )); |
---|
[1321] | 2672 | } |
---|
[1356] | 2673 | |
---|
| 2674 | // 4. All reference pictures in the DPB that are not included in RefPicSetLtCurr, RefPicSetLtFoll, RefPicSetStCurrBefore, |
---|
[1321] | 2675 | // RefPicSetStCurrAfter, or RefPicSetStFoll and have nuh_layer_id equal to currPicLayerId are marked as "unused for reference". |
---|
[1356] | 2676 | TComSubDpb picsToMark = (*dpb); |
---|
[1321] | 2677 | for (Int j = 0; j < 5; j++ ) |
---|
| 2678 | { |
---|
[1356] | 2679 | picsToMark.removePics( *refPicSetsAll[j] ); |
---|
| 2680 | } |
---|
| 2681 | picsToMark.markAllAsUnusedForReference(); |
---|
| 2682 | |
---|
| 2683 | // NOTE 4 - There may be one or more entries in the RPS lists that are equal to "no reference picture" because |
---|
| 2684 | // the corresponding pictures are not present in the DPB. Entries in RefPicSetStFoll or RefPicSetLtFoll that are equal |
---|
| 2685 | // to "no reference picture" should be ignored. An unintentional picture loss should be inferred for each entry in |
---|
[1321] | 2686 | // RefPicSetStCurrBefore, RefPicSetStCurrAfter, or RefPicSetLtCurr that is equal to "no reference picture". |
---|
| 2687 | |
---|
| 2688 | // NOTE 5 - A picture cannot be included in more than one of the five RPS lists. |
---|
| 2689 | |
---|
[1356] | 2690 | |
---|
[1321] | 2691 | // It is a requirement of bitstream conformance that the RPS is restricted as follows: |
---|
| 2692 | |
---|
| 2693 | |
---|
| 2694 | #if NH_MV_FIX_NO_REF_PICS_CHECK |
---|
| 2695 | if ( !annexFModifications || m_firstPicInLayerDecodedFlag[ m_pcPic->getLayerId() ] ) |
---|
[1356] | 2696 | { |
---|
[1321] | 2697 | #endif |
---|
| 2698 | for (Int j = 0; j < 3; j++ ) |
---|
| 2699 | { |
---|
[1356] | 2700 | // - There shall be no entry in RefPicSetStCurrBefore, RefPicSetStCurrAfter or RefPicSetLtCurr |
---|
[1321] | 2701 | // for which one or more of the following are true: |
---|
| 2702 | |
---|
[1356] | 2703 | std::vector<TComPic*>* currSet = refPicSetsCurr[j]; |
---|
[1321] | 2704 | for (Int i = 0; i < currSet->size(); i++) |
---|
| 2705 | { |
---|
[1356] | 2706 | TComPic* pic = (*currSet)[i]; |
---|
[1321] | 2707 | |
---|
| 2708 | // - The entry is equal to "no reference picture". |
---|
[1356] | 2709 | assert( ! (pic == NULL ) ); |
---|
[1321] | 2710 | |
---|
| 2711 | // - The entry is an SLNR picture and has TemporalId equal to that of the current picture. |
---|
[1356] | 2712 | assert( !( pic->isSlnr() && pic->getTemporalId() == m_pcPic->getTemporalId() ) ); |
---|
[1321] | 2713 | |
---|
| 2714 | // - The entry is a picture that has TemporalId greater than that of the current picture. |
---|
[1356] | 2715 | assert( !( pic->getTemporalId() > m_pcPic->getTemporalId() ) ); |
---|
| 2716 | } |
---|
[1321] | 2717 | } |
---|
| 2718 | #if NH_MV_FIX_NO_REF_PICS_CHECK |
---|
| 2719 | } |
---|
| 2720 | #endif |
---|
[1356] | 2721 | |
---|
| 2722 | // - There shall be no entry in RefPicSetLtCurr or RefPicSetLtFoll for which the |
---|
| 2723 | // difference between the picture order count value of the current picture and the picture order count |
---|
[1321] | 2724 | // value of the entry is greater than or equal to 2^24. |
---|
| 2725 | for (Int j = 0; j < 2; j++ ) |
---|
[1356] | 2726 | { |
---|
| 2727 | std::vector<TComPic*>* ltSet = refPicSetsLt[j]; |
---|
[1321] | 2728 | for (Int i = 0; i < ltSet->size(); i++) |
---|
| 2729 | { |
---|
[1356] | 2730 | TComPic* pic = (*ltSet)[i]; |
---|
[1321] | 2731 | if( pic != NULL ) |
---|
| 2732 | { |
---|
[1356] | 2733 | assert(!( abs( m_pcPic->getPOC() - pic->getPOC() ) >= (1 << 24) )); |
---|
[1321] | 2734 | } |
---|
| 2735 | } |
---|
| 2736 | } |
---|
| 2737 | |
---|
[1356] | 2738 | // - When the current picture is a temporal sub-layer access (TSA) picture, there shall be no picture |
---|
[1321] | 2739 | // included in the RPS with TemporalId greater than or equal to the TemporalId of the current picture. |
---|
| 2740 | if (m_pcPic->isTsa() ) |
---|
| 2741 | { |
---|
| 2742 | for (Int j = 0; j < 5; j++ ) |
---|
[1356] | 2743 | { |
---|
| 2744 | std::vector<TComPic*>* aSet = refPicSetsAll[j]; |
---|
[1321] | 2745 | for (Int i = 0; i < aSet->size(); i++) |
---|
| 2746 | { |
---|
[1356] | 2747 | TComPic* pic = (*aSet)[i]; |
---|
[1321] | 2748 | if( pic != NULL ) |
---|
| 2749 | { |
---|
[1356] | 2750 | assert( ! (pic->getTemporalId() >= m_pcPic->getTemporalId() ) ); |
---|
[1321] | 2751 | } |
---|
| 2752 | } |
---|
| 2753 | } |
---|
| 2754 | } |
---|
| 2755 | |
---|
[1356] | 2756 | // - When the current picture is a step-wise temporal sub-layer access (STSA) picture, |
---|
[1321] | 2757 | // there shall be no picture included in RefPicSetStCurrBefore, RefPicSetStCurrAfter or RefPicSetLtCurr that has |
---|
| 2758 | // TemporalId equal to that of the current picture. |
---|
| 2759 | if (m_pcPic->isStsa() ) |
---|
| 2760 | { |
---|
| 2761 | for (Int j = 0; j < 3; j++ ) |
---|
[1356] | 2762 | { |
---|
| 2763 | std::vector<TComPic*>* cSet = refPicSetsCurr[j]; |
---|
[1321] | 2764 | for (Int i = 0; i < cSet->size(); i++) |
---|
| 2765 | { |
---|
[1356] | 2766 | TComPic* pic = (*cSet)[i]; |
---|
[1321] | 2767 | if( pic != NULL ) |
---|
| 2768 | { |
---|
[1356] | 2769 | assert( ! (pic->getTemporalId() == m_pcPic->getTemporalId() ) ); |
---|
[1321] | 2770 | } |
---|
| 2771 | } |
---|
| 2772 | } |
---|
| 2773 | } |
---|
| 2774 | |
---|
| 2775 | // - When the current picture is a picture that follows, in decoding order, an STSA picture |
---|
| 2776 | // that has TemporalId equal to that of the current picture, there shall be no picture that has |
---|
| 2777 | // TemporalId equal to that of the current picture included in RefPicSetStCurrBefore, RefPicSetStCurrAfter |
---|
| 2778 | // or RefPicSetLtCurr that precedes the STSA picture in decoding order. |
---|
| 2779 | if ( m_pcPic->getDecodingOrder() > m_prevStsaDecOrder && m_pcPic->getTemporalId() == m_prevStsaTemporalId ) |
---|
| 2780 | { |
---|
| 2781 | for (Int j = 0; j < 3; j++ ) |
---|
[1356] | 2782 | { |
---|
| 2783 | std::vector<TComPic*>* cSet = refPicSetsCurr[j]; |
---|
[1321] | 2784 | for (Int i = 0; i < cSet->size(); i++) |
---|
| 2785 | { |
---|
[1356] | 2786 | TComPic* pic = (*cSet)[i]; |
---|
[1321] | 2787 | if( pic != NULL ) |
---|
| 2788 | { |
---|
[1356] | 2789 | assert( ! (pic->getTemporalId() == m_pcPic->getTemporalId() && pic->getDecodingOrder() < m_prevStsaDecOrder ) ); |
---|
[1321] | 2790 | } |
---|
| 2791 | } |
---|
| 2792 | } |
---|
| 2793 | } |
---|
[1356] | 2794 | |
---|
[1321] | 2795 | // - When the current picture is a CRA picture, there shall be no picture included in the RPS that |
---|
| 2796 | // precedes, in output order or decoding order, any preceding IRAP picture in decoding order (when present). |
---|
| 2797 | if ( m_pcPic->isCra() ) |
---|
| 2798 | { |
---|
| 2799 | for (Int j = 0; j < 5; j++ ) |
---|
[1356] | 2800 | { |
---|
| 2801 | std::vector<TComPic*>* aSet = refPicSetsAll[j]; |
---|
[1321] | 2802 | for (Int i = 0; i < aSet->size(); i++) |
---|
| 2803 | { |
---|
| 2804 | // TBD check whether it sufficient to test only the last IRAP |
---|
[1356] | 2805 | TComPic* pic = (*aSet)[i]; |
---|
[1321] | 2806 | if( pic != NULL ) |
---|
[1356] | 2807 | { |
---|
| 2808 | assert( ! (pic->getPOC() < m_prevIrapPoc ) ); |
---|
| 2809 | assert( ! (pic->getDecodingOrder() < m_prevIrapDecodingOrder ) ); |
---|
[1321] | 2810 | } |
---|
| 2811 | } |
---|
| 2812 | } |
---|
| 2813 | } |
---|
[1356] | 2814 | |
---|
[1321] | 2815 | Bool isTrailingPicture = ( !m_pcPic->isIrap() ) && ( m_pcPic->getPOC() > m_prevIrapPoc ); |
---|
| 2816 | // - When the current picture is a trailing picture, there shall be no picture in RefPicSetStCurrBefore, |
---|
| 2817 | // RefPicSetStCurrAfter or RefPicSetLtCurr that was generated by the decoding process for generating unavailable |
---|
| 2818 | // reference pictures as specified in clause 8.3.3. |
---|
| 2819 | if ( isTrailingPicture ) |
---|
| 2820 | { |
---|
| 2821 | for (Int j = 0; j < 3; j++ ) |
---|
[1356] | 2822 | { |
---|
| 2823 | std::vector<TComPic*>* cSet = refPicSetsCurr[j]; |
---|
[1321] | 2824 | for (Int i = 0; i < cSet->size(); i++) |
---|
| 2825 | { |
---|
[1356] | 2826 | TComPic* pic = (*cSet)[i]; |
---|
[1321] | 2827 | if( pic != NULL ) |
---|
| 2828 | { |
---|
[1356] | 2829 | assert( ! (pic->getIsGeneratedCl833() ) ); |
---|
[1321] | 2830 | } |
---|
| 2831 | } |
---|
| 2832 | } |
---|
| 2833 | } |
---|
| 2834 | |
---|
| 2835 | // - When the current picture is a trailing picture, there shall be no picture in the RPS that precedes the |
---|
| 2836 | // associated IRAP picture in output order or decoding order. |
---|
| 2837 | if ( isTrailingPicture ) |
---|
| 2838 | { |
---|
| 2839 | for (Int j = 0; j < 5; j++ ) |
---|
[1356] | 2840 | { |
---|
| 2841 | std::vector<TComPic*>* aSet = refPicSetsAll[j]; |
---|
[1321] | 2842 | for (Int i = 0; i < aSet->size(); i++) |
---|
| 2843 | { |
---|
| 2844 | // TBD check whether it sufficient to test only the last IRAP |
---|
[1356] | 2845 | TComPic* pic = (*aSet)[i]; |
---|
[1321] | 2846 | if( pic != NULL ) |
---|
[1356] | 2847 | { |
---|
| 2848 | assert( ! (pic->getPOC() < m_prevIrapPoc ) ); |
---|
| 2849 | assert( ! (pic->getDecodingOrder() < m_prevIrapDecodingOrder ) ); |
---|
[1321] | 2850 | } |
---|
| 2851 | } |
---|
| 2852 | } |
---|
| 2853 | } |
---|
| 2854 | |
---|
| 2855 | // - When the current picture is a RADL picture, there shall be no picture included in RefPicSetStCurrBefore, |
---|
| 2856 | // RefPicSetStCurrAfter or RefPicSetLtCurr that is any of the following: |
---|
| 2857 | if ( m_pcPic->isRadl() ) |
---|
| 2858 | { |
---|
| 2859 | for (Int j = 0; j < 3; j++ ) |
---|
[1356] | 2860 | { |
---|
| 2861 | std::vector<TComPic*>* cSet = refPicSetsCurr[j]; |
---|
[1321] | 2862 | for (Int i = 0; i < cSet->size(); i++) |
---|
[1356] | 2863 | { |
---|
| 2864 | TComPic* pic = (*cSet)[i]; |
---|
[1321] | 2865 | if( pic != NULL ) |
---|
[1356] | 2866 | { |
---|
[1321] | 2867 | // - A RASL picture |
---|
[1356] | 2868 | assert( ! (pic->isRasl() ) ); |
---|
| 2869 | // - A picture that was generated by the decoding process for generating unavailable reference pictures |
---|
[1321] | 2870 | // as specified in clause 8.3.3 |
---|
[1356] | 2871 | assert( ! (pic->getIsGeneratedCl833() ) ); |
---|
[1321] | 2872 | // - A picture that precedes the associated IRAP picture in decoding order |
---|
[1356] | 2873 | assert( ! (pic->getDecodingOrder() < m_prevIrapDecodingOrder ) ); |
---|
[1321] | 2874 | } |
---|
| 2875 | } |
---|
| 2876 | } |
---|
| 2877 | } |
---|
[1356] | 2878 | |
---|
| 2879 | |
---|
[1321] | 2880 | if ( sps->getTemporalIdNestingFlag() ) |
---|
| 2881 | { |
---|
| 2882 | // - When sps_temporal_id_nesting_flag is equal to 1, the following applies: |
---|
| 2883 | // - Let tIdA be the value of TemporalId of the current picture picA. |
---|
[1356] | 2884 | TComPic* picA = m_pcPic; |
---|
[1321] | 2885 | Int tIdA = picA->getTemporalId(); |
---|
[1356] | 2886 | // - Any picture picB with TemporalId equal to tIdB that is less than or equal to tIdA shall not be included in |
---|
| 2887 | // RefPicSetStCurrBefore, RefPicSetStCurrAfter or RefPicSetLtCurr of picA when there exists a picture picC that |
---|
[1321] | 2888 | // has TemporalId less than tIdB, follows picB in decoding order, and precedes picA in decoding order. |
---|
| 2889 | for (Int j = 0; j < 3; j++ ) |
---|
[1356] | 2890 | { |
---|
| 2891 | std::vector<TComPic*>* cSet = refPicSetsCurr[j]; |
---|
[1321] | 2892 | for (Int i = 0; i < cSet->size(); i++) |
---|
| 2893 | { |
---|
[1356] | 2894 | TComPic* picB = (*cSet)[i]; |
---|
[1321] | 2895 | if( picB != NULL ) |
---|
| 2896 | { |
---|
[1356] | 2897 | Int tIdB = picB->getTemporalId(); |
---|
[1321] | 2898 | |
---|
| 2899 | if (tIdB <= tIdA) |
---|
| 2900 | { |
---|
| 2901 | for ( TComSubDpb::iterator itP = dpb->begin(); itP != dpb->end(); itP++ ) |
---|
| 2902 | { |
---|
[1356] | 2903 | TComPic* picC = (*itP); |
---|
| 2904 | assert(! ( picC->getTemporalId() < tIdB && picC->getDecodingOrder() > picB->getDecodingOrder() && picC->getDecodingOrder() < picA->getDecodingOrder() ) ); |
---|
[1321] | 2905 | } |
---|
| 2906 | } |
---|
| 2907 | } |
---|
| 2908 | } |
---|
| 2909 | } |
---|
[1356] | 2910 | } |
---|
[738] | 2911 | } |
---|
| 2912 | |
---|
[1321] | 2913 | |
---|
| 2914 | Void TDecTop::xF832DecProcForRefPicSet() |
---|
[738] | 2915 | { |
---|
[1321] | 2916 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
| 2917 | // F.8.3.2 Decoding process for reference picture set |
---|
| 2918 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
| 2919 | |
---|
| 2920 | // The specifications in clause 8.3.2 apply with the following changes: |
---|
[1356] | 2921 | // - The references to clauses 7.4.7.2, 8.3.1, 8.3.3 and 8.3.4 are replaced with references to |
---|
[1321] | 2922 | // clauses F.7.4.7.2, F.8.3.1, F.8.3.3 and F.8.3.4, respectively. |
---|
| 2923 | |
---|
[1356] | 2924 | x832DecProcForRefPicSet( true ); |
---|
[1321] | 2925 | |
---|
| 2926 | // - The following specifications are added: |
---|
| 2927 | if (m_pcPic->isIrap() && m_pcPic->getLayerId() == m_smallestLayerId ) |
---|
[738] | 2928 | { |
---|
[1356] | 2929 | // - When the current picture is an IRAP picture with nuh_layer_id equal to SmallestLayerId, |
---|
| 2930 | // all reference pictures with any value of nuh_layer_id currently in the DPB (if any) are marked |
---|
[1321] | 2931 | // as "unused for reference" when at least one of the following conditions is true: |
---|
| 2932 | |
---|
| 2933 | if ( m_pcPic->getNoClrasOutputFlag() || m_pcPic->getActivatesNewVps() ) |
---|
| 2934 | { |
---|
| 2935 | // - The current picture has NoClrasOutputFlag is equal to 1. |
---|
| 2936 | // - The current picture activates a new VPS. |
---|
| 2937 | m_dpb->markAllSubDpbAsUnusedForReference( ); |
---|
| 2938 | } |
---|
[738] | 2939 | } |
---|
| 2940 | |
---|
[1321] | 2941 | // - It is a requirement of bitstream conformance that the RPS is restricted as follows: |
---|
[1356] | 2942 | // - When the current picture is a CRA picture, there shall be no picture in RefPicSetStCurrBefore, RefPicSetStCurrAfter |
---|
[1321] | 2943 | // or RefPicSetLtCurr. |
---|
| 2944 | |
---|
| 2945 | std::vector<TComPic*>** refPicSetsCurr = m_pcPic->getDecodedRps()->m_refPicSetsCurr; |
---|
| 2946 | |
---|
| 2947 | if ( m_pcPic->isCra() ) |
---|
| 2948 | { |
---|
[1356] | 2949 | for (Int j = 0; j < 3; j++ ) |
---|
| 2950 | { |
---|
| 2951 | std::vector<TComPic*>* cSet = refPicSetsCurr[j]; |
---|
| 2952 | assert ( cSet->size() == 0 ); |
---|
[1321] | 2953 | } |
---|
| 2954 | } |
---|
| 2955 | |
---|
| 2956 | // - The constraints specified in clause 8.3.2 on the value of NumPicTotalCurr are replaced with the following: |
---|
| 2957 | // - It is a requirement of bitstream conformance that the following applies to the value of NumPicTotalCurr: |
---|
[1356] | 2958 | Int numPicTotalCurr = m_pcPic->getSlice(0)->getNumPicTotalCurr(); |
---|
| 2959 | Int currPicLayerId = m_pcPic->getLayerId(); |
---|
| 2960 | const TComVPS* vps = m_pcPic->getSlice(0)->getVPS(); |
---|
[1321] | 2961 | |
---|
| 2962 | if ( ( m_pcPic->isBla() || m_pcPic->isCra() ) && ( (currPicLayerId == 0 ) || ( vps->getNumDirectRefLayers( currPicLayerId ) == 0 ) ) ) |
---|
[1356] | 2963 | { |
---|
| 2964 | assert( numPicTotalCurr == 0 ); |
---|
| 2965 | // - If the current picture is a BLA or CRA picture and either currPicLayerId is equal to 0 or |
---|
[1321] | 2966 | // NumDirectRefLayers[ currPicLayerId ] is equal to 0, the value of NumPicTotalCurr shall be equal to 0. |
---|
| 2967 | } |
---|
| 2968 | else |
---|
| 2969 | { |
---|
| 2970 | // TBD: check all slices |
---|
| 2971 | if ( m_pcPic->getSlice(0)->getSliceType() == P_SLICE || m_pcPic->getSlice(0)->getSliceType() == B_SLICE ) |
---|
| 2972 | { |
---|
| 2973 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPicTotalCurr shall not be equal to 0. |
---|
[1356] | 2974 | assert( numPicTotalCurr != 0 ); |
---|
[1321] | 2975 | } |
---|
| 2976 | } |
---|
[738] | 2977 | } |
---|
[1196] | 2978 | |
---|
[1313] | 2979 | |
---|
[1321] | 2980 | Void TDecTop::xG813DecProcForInterLayerRefPicSet() |
---|
[1196] | 2981 | { |
---|
[1321] | 2982 | //////////////////////////////////////////////////////////////////// |
---|
| 2983 | // G.8.1.3 Decoding process for inter-layer reference picture set // |
---|
| 2984 | //////////////////////////////////////////////////////////////////// |
---|
| 2985 | |
---|
[1356] | 2986 | // Outputs of this process are updated lists of inter-layer reference pictures RefPicSetInterLayer0 and RefPicSetInterLayer1 |
---|
[1321] | 2987 | // and the variables NumActiveRefLayerPics0 and NumActiveRefLayerPics1. |
---|
| 2988 | |
---|
[1356] | 2989 | TComDecodedRps* decRps = m_pcPic->getDecodedRps(); |
---|
| 2990 | TComSlice* slice = m_pcPic->getSlice( 0 ); |
---|
| 2991 | const TComVPS* vps = slice->getVPS(); |
---|
[1321] | 2992 | |
---|
| 2993 | Int& numActiveRefLayerPics0 = decRps->m_numActiveRefLayerPics0; |
---|
| 2994 | Int& numActiveRefLayerPics1 = decRps->m_numActiveRefLayerPics1; |
---|
| 2995 | |
---|
| 2996 | std::vector<TComPic*>& refPicSetInterLayer0 = decRps->m_refPicSetInterLayer0; |
---|
[1356] | 2997 | std::vector<TComPic*>& refPicSetInterLayer1 = decRps->m_refPicSetInterLayer1; |
---|
[1321] | 2998 | |
---|
| 2999 | // The variable currLayerId is set equal to nuh_layer_id of the current picture. |
---|
[1356] | 3000 | Int currLayerId = getLayerId(); |
---|
[1321] | 3001 | |
---|
[1356] | 3002 | // The lists RefPicSetInterLayer0 and RefPicSetInterLayer1 are first emptied, NumActiveRefLayerPics0 and NumActiveRefLayerPics1 |
---|
[1321] | 3003 | // are set equal to 0 and the following applies: |
---|
| 3004 | |
---|
[1356] | 3005 | refPicSetInterLayer0.clear(); |
---|
| 3006 | refPicSetInterLayer1.clear(); |
---|
[1321] | 3007 | |
---|
[1356] | 3008 | numActiveRefLayerPics0 = 0; |
---|
| 3009 | numActiveRefLayerPics1 = 0; |
---|
[1321] | 3010 | |
---|
[1356] | 3011 | Int viewIdCurrLayerId = vps->getViewId( currLayerId ); |
---|
[1321] | 3012 | Int viewId0 = vps->getViewId( 0 ); |
---|
| 3013 | |
---|
[1356] | 3014 | for( Int i = 0; i < slice->getNumActiveRefLayerPics(); i++ ) |
---|
[1313] | 3015 | { |
---|
[1356] | 3016 | Int viewIdRefPicLayerIdi = vps->getViewId( slice->getRefPicLayerId( i ) ); |
---|
[1321] | 3017 | |
---|
| 3018 | Bool refPicSet0Flag = |
---|
| 3019 | ( ( viewIdCurrLayerId <= viewId0 && viewIdCurrLayerId <= viewIdRefPicLayerIdi ) || |
---|
| 3020 | ( viewIdCurrLayerId >= viewId0 && viewIdCurrLayerId >= viewIdRefPicLayerIdi ) ); |
---|
| 3021 | |
---|
| 3022 | TComPic* picX = m_dpb->getAu(slice->getPOC(), false )->getPic( slice->getRefPicLayerId( i ) ); |
---|
| 3023 | if ( picX != NULL ) |
---|
| 3024 | { |
---|
| 3025 | // there is a picture picX in the DPB that is in the same access unit as the current picture and has |
---|
[1356] | 3026 | // nuh_layer_id equal to RefPicLayerId[ i ] |
---|
[1321] | 3027 | |
---|
| 3028 | if ( refPicSet0Flag ) |
---|
| 3029 | { |
---|
| 3030 | refPicSetInterLayer0.push_back( picX ); |
---|
| 3031 | refPicSetInterLayer0[ numActiveRefLayerPics0++ ]->markAsUsedForLongTermReference(); |
---|
| 3032 | } |
---|
| 3033 | else |
---|
| 3034 | { |
---|
| 3035 | refPicSetInterLayer1.push_back( picX ); |
---|
| 3036 | refPicSetInterLayer1[ numActiveRefLayerPics1++ ]->markAsUsedForLongTermReference(); |
---|
| 3037 | } |
---|
| 3038 | |
---|
| 3039 | // There shall be no picture that has discardable_flag equal to 1 in RefPicSetInterLayer0 or RefPicSetInterLayer1. |
---|
| 3040 | assert( ! picX->getSlice(0)->getDiscardableFlag() ); |
---|
| 3041 | |
---|
[1356] | 3042 | // If the current picture is a RADL picture, there shall be no entry in RefPicSetInterLayer0 or RefPicSetInterLayer1 |
---|
[1321] | 3043 | // that is a RASL picture. |
---|
| 3044 | if ( m_pcPic->isRadl() ) |
---|
| 3045 | { |
---|
| 3046 | assert( ! picX->isRasl() ); |
---|
| 3047 | } |
---|
| 3048 | } |
---|
| 3049 | else |
---|
| 3050 | { |
---|
| 3051 | if( refPicSet0Flag ) |
---|
| 3052 | { |
---|
| 3053 | refPicSetInterLayer0.push_back( NULL ); // "no reference picture" (G 1) |
---|
| 3054 | numActiveRefLayerPics0++; |
---|
| 3055 | } |
---|
| 3056 | else |
---|
| 3057 | { |
---|
| 3058 | refPicSetInterLayer1.push_back( NULL ); // "no reference picture"; |
---|
| 3059 | numActiveRefLayerPics1++; |
---|
| 3060 | } |
---|
| 3061 | // There shall be no entry equal to "no reference picture" in RefPicSetInterLayer0 or RefPicSetInterLayer1. |
---|
| 3062 | assert( false ); |
---|
| 3063 | } |
---|
[1313] | 3064 | } |
---|
[1321] | 3065 | } |
---|
| 3066 | |
---|
| 3067 | |
---|
| 3068 | Void TDecTop::x8331GenDecProcForGenUnavilRefPics() |
---|
| 3069 | { |
---|
| 3070 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
| 3071 | // 8.3.3.1 General decoding process for generating unavailable reference pictures //// |
---|
| 3072 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
| 3073 | |
---|
[1356] | 3074 | // This process is invoked once per coded picture when the current picture is a |
---|
[1321] | 3075 | // BLA picture or is a CRA picture with NoRaslOutputFlag equal to 1. |
---|
| 3076 | |
---|
| 3077 | assert( m_pcPic->isBla() || (m_pcPic->isCra() && m_pcPic->getNoRaslOutputFlag() ) ); |
---|
[1356] | 3078 | TComDecodedRps* decRps = m_pcPic->getDecodedRps(); |
---|
[1321] | 3079 | |
---|
| 3080 | std::vector<TComPic*>& refPicSetStFoll = decRps->m_refPicSetStFoll; |
---|
[1356] | 3081 | std::vector<TComPic*>& refPicSetLtFoll = decRps->m_refPicSetLtFoll; |
---|
[1321] | 3082 | |
---|
| 3083 | const std::vector<Int>& pocStFoll = decRps->m_pocStFoll; |
---|
| 3084 | const std::vector<Int>& pocLtFoll = decRps->m_pocLtFoll; |
---|
| 3085 | |
---|
| 3086 | const Int numPocStFoll = decRps->m_numPocStFoll; |
---|
[1356] | 3087 | const Int numPocLtFoll = decRps->m_numPocLtFoll; |
---|
[1321] | 3088 | |
---|
| 3089 | // When this process is invoked, the following applies: |
---|
| 3090 | for ( Int i = 0 ; i <= numPocStFoll - 1; i++ ) |
---|
[1313] | 3091 | { |
---|
[1321] | 3092 | if ( refPicSetStFoll[ i ] == NULL ) |
---|
[1196] | 3093 | { |
---|
[1356] | 3094 | //- For each RefPicSetStFoll[ i ], with i in the range of 0 to NumPocStFoll - 1, inclusive, that is equal |
---|
[1321] | 3095 | // to "no reference picture", a picture is generated as specified in clause 8.3.3.2, and the following applies: |
---|
[1356] | 3096 | TComPic* genPic = x8332GenOfOneUnavailPic( true ); |
---|
[1321] | 3097 | |
---|
| 3098 | // - The value of PicOrderCntVal for the generated picture is set equal to PocStFoll[ i ]. |
---|
| 3099 | genPic->getSlice(0)->setPOC( pocStFoll[ i ] ); |
---|
| 3100 | |
---|
[1356] | 3101 | //- The value of PicOutputFlag for the generated picture is set equal to 0. |
---|
| 3102 | genPic->setPicOutputFlag( false ); |
---|
[1321] | 3103 | |
---|
| 3104 | // - The generated picture is marked as "used for short-term reference". |
---|
| 3105 | genPic->markAsUsedForShortTermReference(); |
---|
| 3106 | |
---|
| 3107 | // - RefPicSetStFoll[ i ] is set to be the generated reference picture. |
---|
| 3108 | refPicSetStFoll[ i ] = genPic; |
---|
| 3109 | |
---|
| 3110 | // - The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id of the current picture. |
---|
[1356] | 3111 | genPic->setLayerId( m_pcPic-> getLayerId() ); |
---|
[1321] | 3112 | |
---|
| 3113 | // Insert to DPB |
---|
[1356] | 3114 | m_dpb->addNewPic( genPic ); |
---|
[1321] | 3115 | } |
---|
[1313] | 3116 | } |
---|
[1196] | 3117 | |
---|
[1321] | 3118 | for ( Int i = 0 ; i <= numPocLtFoll - 1; i++ ) |
---|
| 3119 | { |
---|
| 3120 | if ( refPicSetLtFoll[ i ] == NULL ) |
---|
| 3121 | { |
---|
[1356] | 3122 | //- For each RefPicSetLtFoll[ i ], with i in the range of 0 to NumPocLtFoll - 1, inclusive, that is equal to |
---|
[1321] | 3123 | // "no reference picture", a picture is generated as specified in clause 8.3.3.2, and the following applies: |
---|
[1356] | 3124 | TComPic* genPic = x8332GenOfOneUnavailPic( true ); |
---|
[1321] | 3125 | |
---|
| 3126 | //- The value of PicOrderCntVal for the generated picture is set equal to PocLtFoll[ i ]. |
---|
| 3127 | genPic->getSlice(0)->setPOC( pocStFoll[ i ] ); |
---|
| 3128 | |
---|
| 3129 | // - The value of slice_pic_order_cnt_lsb for the generated picture is inferred to be equal to ( PocLtFoll[ i ] & ( MaxPicOrderCntLsb - 1 ) ). |
---|
[1356] | 3130 | genPic->getSlice(0)->setSlicePicOrderCntLsb( ( pocLtFoll[ i ] & ( m_pcPic->getSlice(0)->getSPS()->getMaxPicOrderCntLsb() - 1 ) ) ); |
---|
[1321] | 3131 | |
---|
[1356] | 3132 | // - The value of PicOutputFlag for the generated picture is set equal to 0. |
---|
| 3133 | genPic->setPicOutputFlag( false ); |
---|
[1321] | 3134 | |
---|
| 3135 | // - The generated picture is marked as "used for long-term reference". |
---|
| 3136 | genPic->markAsUsedForLongTermReference(); |
---|
| 3137 | |
---|
| 3138 | // - RefPicSetLtFoll[ i ] is set to be the generated reference picture. |
---|
| 3139 | refPicSetLtFoll[ i ] = genPic; |
---|
| 3140 | |
---|
| 3141 | // - The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id of the current picture. |
---|
[1356] | 3142 | genPic->setLayerId( m_pcPic-> getLayerId() ); |
---|
[1321] | 3143 | |
---|
| 3144 | // Insert to DPB |
---|
[1356] | 3145 | m_dpb->addNewPic( genPic ); |
---|
[1321] | 3146 | } |
---|
| 3147 | } |
---|
[1196] | 3148 | } |
---|
[1321] | 3149 | |
---|
| 3150 | |
---|
| 3151 | TComPic* TDecTop::x8332GenOfOneUnavailPic( Bool calledFromCl8331 ) |
---|
| 3152 | { |
---|
| 3153 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
| 3154 | // 8.3.3.2 Generation of one unavailable picture |
---|
| 3155 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
| 3156 | |
---|
[1356] | 3157 | TComPic* genPic = new TComPic; |
---|
| 3158 | genPic->create( *m_pcPic->getSlice(0)->getSPS(), *m_pcPic->getSlice(0)->getPPS(), true ); |
---|
| 3159 | genPic->setIsGenerated( true ); |
---|
| 3160 | genPic->setIsGeneratedCl833( calledFromCl8331 ); |
---|
[1321] | 3161 | return genPic; |
---|
| 3162 | } |
---|
| 3163 | |
---|
| 3164 | |
---|
| 3165 | Void TDecTop::xF817DecProcForGenUnavRefPicForPicsFrstInDecOrderInLay() |
---|
| 3166 | { |
---|
| 3167 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
[1356] | 3168 | // F.8.1.7 Decoding process for generating unavailable reference pictures for pictures |
---|
[1321] | 3169 | // first in decoding order within a layer |
---|
| 3170 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
| 3171 | |
---|
[1356] | 3172 | // This process is invoked for a picture with nuh_layer_id equal to layerId, when FirstPicInLayerDecodedFlag[layerId ] is equal to 0. |
---|
[1321] | 3173 | assert( !m_firstPicInLayerDecodedFlag[ getLayerId() ] ); |
---|
| 3174 | |
---|
| 3175 | |
---|
[1356] | 3176 | TComDecodedRps* decRps = m_pcPic->getDecodedRps(); |
---|
[1321] | 3177 | |
---|
[1356] | 3178 | std::vector<TComPic*>& refPicSetStCurrBefore = decRps->m_refPicSetStCurrBefore; |
---|
[1321] | 3179 | std::vector<TComPic*>& refPicSetStCurrAfter = decRps->m_refPicSetStCurrAfter; |
---|
| 3180 | std::vector<TComPic*>& refPicSetStFoll = decRps->m_refPicSetStFoll; |
---|
[1356] | 3181 | std::vector<TComPic*>& refPicSetLtCurr = decRps->m_refPicSetLtCurr; |
---|
| 3182 | std::vector<TComPic*>& refPicSetLtFoll = decRps->m_refPicSetLtFoll; |
---|
[1321] | 3183 | |
---|
| 3184 | |
---|
| 3185 | const std::vector<Int>& pocStCurrBefore = decRps->m_pocStCurrBefore; |
---|
| 3186 | const std::vector<Int>& pocStCurrAfter = decRps->m_pocStCurrAfter; |
---|
| 3187 | const std::vector<Int>& pocStFoll = decRps->m_pocStFoll; |
---|
| 3188 | const std::vector<Int>& pocLtCurr = decRps->m_pocLtCurr; |
---|
| 3189 | const std::vector<Int>& pocLtFoll = decRps->m_pocLtFoll; |
---|
| 3190 | |
---|
[1356] | 3191 | const Int numPocStCurrBefore = decRps->m_numPocStCurrBefore; |
---|
[1321] | 3192 | const Int numPocStCurrAfter = decRps->m_numPocStCurrAfter; |
---|
| 3193 | const Int numPocStFoll = decRps->m_numPocStFoll; |
---|
| 3194 | const Int numPocLtCurr = decRps->m_numPocLtCurr; |
---|
[1356] | 3195 | const Int numPocLtFoll = decRps->m_numPocLtFoll; |
---|
[1321] | 3196 | |
---|
[1356] | 3197 | Int nuhLayerId = m_pcPic-> getLayerId(); |
---|
[1321] | 3198 | for ( Int i = 0 ; i <= numPocStCurrBefore - 1; i++ ) |
---|
| 3199 | { |
---|
| 3200 | if ( refPicSetStCurrBefore[ i ] == NULL ) |
---|
| 3201 | { |
---|
[1356] | 3202 | //- For each RefPicSetStCurrBefore[ i ], with i in the range of 0 to NumPocStCurrBefore - 1, inclusive, that is |
---|
[1321] | 3203 | // equal to "no reference picture", a picture is generated as specified in clause 8.3.3.2 and the following applies: |
---|
[1356] | 3204 | TComPic* genPic = x8332GenOfOneUnavailPic( false ); |
---|
[1321] | 3205 | |
---|
| 3206 | //- The value of PicOrderCntVal for the generated picture is set equal to PocStCurrBefore[ i ]. |
---|
| 3207 | genPic->getSlice(0)->setPOC( pocStCurrBefore[ i ] ); |
---|
| 3208 | |
---|
| 3209 | // - The value of PicOutputFlag for the generated picture is set equal to 0. |
---|
[1356] | 3210 | genPic->setPicOutputFlag( false ); |
---|
[1321] | 3211 | |
---|
| 3212 | // - The generated picture is marked as "used for short-term reference". |
---|
| 3213 | genPic->markAsUsedForShortTermReference(); |
---|
| 3214 | |
---|
| 3215 | // - RefPicSetStCurrBefore[ i ] is set to be the generated reference picture. |
---|
| 3216 | refPicSetStCurrBefore[ i ] = genPic; |
---|
| 3217 | |
---|
| 3218 | // - The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id. |
---|
[1356] | 3219 | genPic->setLayerId( nuhLayerId ); |
---|
[1321] | 3220 | |
---|
| 3221 | // Insert to DPB |
---|
[1356] | 3222 | m_dpb->addNewPic( genPic ); |
---|
[1321] | 3223 | } |
---|
| 3224 | } |
---|
| 3225 | |
---|
| 3226 | for ( Int i = 0 ; i <= numPocStCurrAfter - 1; i++ ) |
---|
| 3227 | { |
---|
| 3228 | if ( refPicSetStCurrAfter[ i ] == NULL ) |
---|
| 3229 | { |
---|
[1356] | 3230 | // - For each RefPicSetStCurrAfter[ i ], with i in the range of 0 to NumPocStCurrAfter - 1, inclusive, that is equal |
---|
[1321] | 3231 | // to "no reference picture", a picture is generated as specified in clause 8.3.3.2 and the following applies: |
---|
[1356] | 3232 | TComPic* genPic = x8332GenOfOneUnavailPic( false ); |
---|
[1321] | 3233 | |
---|
| 3234 | // - The value of PicOrderCntVal for the generated picture is set equal to PocStCurrAfter[ i ]. |
---|
| 3235 | genPic->getSlice(0)->setPOC( pocStCurrAfter[ i ] ); |
---|
| 3236 | |
---|
| 3237 | // - The value of PicOutputFlag for the generated picture is set equal to 0. |
---|
[1356] | 3238 | genPic->setPicOutputFlag( false ); |
---|
[1321] | 3239 | |
---|
| 3240 | // - The generated picture is marked as "used for short-term reference". |
---|
| 3241 | genPic->markAsUsedForShortTermReference(); |
---|
| 3242 | |
---|
| 3243 | // - RefPicSetStCurrAfter[ i ] is set to be the generated reference picture. |
---|
| 3244 | refPicSetStCurrAfter[ i ] = genPic; |
---|
| 3245 | |
---|
| 3246 | // - The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id. |
---|
[1356] | 3247 | genPic->setLayerId( nuhLayerId ); |
---|
[1321] | 3248 | |
---|
| 3249 | // Insert to DPB |
---|
[1356] | 3250 | m_dpb->addNewPic( genPic ); |
---|
[1321] | 3251 | |
---|
| 3252 | } |
---|
| 3253 | } |
---|
| 3254 | |
---|
| 3255 | for ( Int i = 0 ; i <= numPocStFoll - 1; i++ ) |
---|
| 3256 | { |
---|
| 3257 | if ( refPicSetStFoll[ i ] == NULL ) |
---|
| 3258 | { |
---|
[1356] | 3259 | // - For each RefPicSetStFoll[ i ], with i in the range of 0 to NumPocStFoll - 1, inclusive, that is equal to "no |
---|
[1321] | 3260 | // reference picture", a picture is generated as specified in clause 8.3.3.2 and the following applies: |
---|
[1356] | 3261 | TComPic* genPic = x8332GenOfOneUnavailPic( false ); |
---|
[1321] | 3262 | |
---|
| 3263 | // - The value of PicOrderCntVal for the generated picture is set equal to PocStFoll[ i ]. |
---|
| 3264 | genPic->getSlice(0)->setPOC( pocStFoll[ i ] ); |
---|
| 3265 | |
---|
| 3266 | // - The value of PicOutputFlag for the generated picture is set equal to 0. |
---|
[1356] | 3267 | genPic->setPicOutputFlag( false ); |
---|
[1321] | 3268 | |
---|
| 3269 | // - The generated picture is marked as "used for short-term reference". |
---|
| 3270 | genPic->markAsUsedForShortTermReference(); |
---|
| 3271 | |
---|
| 3272 | // - RefPicSetStFoll[ i ] is set to be the generated reference picture. |
---|
| 3273 | refPicSetStFoll[ i ] = genPic; |
---|
| 3274 | |
---|
| 3275 | // - The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id. |
---|
[1356] | 3276 | genPic->setLayerId( nuhLayerId ); |
---|
[1321] | 3277 | |
---|
| 3278 | // Insert to DPB |
---|
[1356] | 3279 | m_dpb->addNewPic( genPic ); |
---|
[1321] | 3280 | } |
---|
| 3281 | } |
---|
| 3282 | |
---|
[1356] | 3283 | Int maxPicOrderCntLsb = m_pcPic->getSlice(0)->getSPS()->getMaxPicOrderCntLsb(); |
---|
[1321] | 3284 | for ( Int i = 0 ; i <= numPocLtCurr - 1; i++ ) |
---|
| 3285 | { |
---|
| 3286 | if ( refPicSetLtCurr[ i ] == NULL ) |
---|
| 3287 | { |
---|
[1356] | 3288 | // - For each RefPicSetLtCurr[ i ], with i in the range of 0 to NumPocLtCurr - 1, inclusive, that is equal to "no |
---|
[1321] | 3289 | // reference picture", a picture is generated as specified in clause 8.3.3.2 and the following applies: |
---|
[1356] | 3290 | TComPic* genPic = x8332GenOfOneUnavailPic( false ); |
---|
[1321] | 3291 | |
---|
| 3292 | // - The value of PicOrderCntVal for the generated picture is set equal to PocLtCurr[ i ]. |
---|
| 3293 | genPic->getSlice(0)->setPOC( pocLtCurr[ i ] ); |
---|
| 3294 | |
---|
[1356] | 3295 | // - The value of slice_pic_order_cnt_lsb for the generated picture is inferred to be equal to ( PocLtCurr[ i ] & ( |
---|
[1321] | 3296 | // MaxPicOrderCntLsb - 1 ) ). |
---|
[1356] | 3297 | genPic->getSlice(0)->setSlicePicOrderCntLsb( ( pocLtCurr[ i ] & ( maxPicOrderCntLsb - 1 ) ) ); |
---|
[1321] | 3298 | |
---|
| 3299 | // - The value of PicOutputFlag for the generated picture is set equal to 0. |
---|
[1356] | 3300 | genPic->setPicOutputFlag( false ); |
---|
[1321] | 3301 | |
---|
| 3302 | // - The generated picture is marked as "used for long-term reference". |
---|
| 3303 | genPic->markAsUsedForLongTermReference(); |
---|
| 3304 | |
---|
| 3305 | // - RefPicSetLtCurr[ i ] is set to be the generated reference picture. |
---|
| 3306 | refPicSetLtCurr[ i ] = genPic; |
---|
| 3307 | |
---|
| 3308 | // - The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id. |
---|
[1356] | 3309 | genPic->setLayerId( nuhLayerId ); |
---|
[1321] | 3310 | |
---|
| 3311 | // Insert to DPB |
---|
[1356] | 3312 | m_dpb->addNewPic( genPic ); |
---|
[1321] | 3313 | } |
---|
| 3314 | } |
---|
| 3315 | |
---|
| 3316 | for ( Int i = 0 ; i <= numPocLtFoll - 1; i++ ) |
---|
| 3317 | { |
---|
| 3318 | if ( refPicSetLtFoll[ i ] == NULL ) |
---|
| 3319 | { |
---|
[1356] | 3320 | // - For each RefPicSetLtFoll[ i ], with i in the range of 0 to NumPocLtFoll - 1, inclusive, that is equal to "no |
---|
[1321] | 3321 | // reference picture", a picture is generated as specified in clause 8.3.3.2 and the following applies: |
---|
[1356] | 3322 | TComPic* genPic = x8332GenOfOneUnavailPic( false ); |
---|
[1321] | 3323 | |
---|
| 3324 | // - The value of PicOrderCntVal for the generated picture is set equal to PocLtFoll[ i ]. |
---|
| 3325 | genPic->getSlice(0)->setPOC( pocLtFoll[ i ] ); |
---|
| 3326 | |
---|
[1356] | 3327 | // - The value of slice_pic_order_cnt_lsb for the generated picture is inferred to be equal to ( PocLtCurr[ i ] & ( |
---|
[1321] | 3328 | // MaxPicOrderCntLsb - 1 ) ). |
---|
[1356] | 3329 | genPic->getSlice(0)->setSlicePicOrderCntLsb( ( pocLtCurr[ i ] & ( maxPicOrderCntLsb - 1 ) ) ); |
---|
[1321] | 3330 | |
---|
| 3331 | // - The value of PicOutputFlag for the generated picture is set equal to 0. |
---|
[1356] | 3332 | genPic->setPicOutputFlag( false ); |
---|
[1321] | 3333 | |
---|
| 3334 | // - The generated picture is marked as "used for long-term reference". |
---|
| 3335 | genPic->markAsUsedForLongTermReference(); |
---|
| 3336 | |
---|
| 3337 | // - RefPicSetLtFoll[ i ] is set to be the generated reference picture. |
---|
| 3338 | refPicSetLtFoll[ i ] = genPic; |
---|
| 3339 | |
---|
| 3340 | // - The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id. |
---|
[1356] | 3341 | genPic->setLayerId( nuhLayerId ); |
---|
[1321] | 3342 | |
---|
| 3343 | // Insert to DPB |
---|
[1356] | 3344 | m_dpb->addNewPic( genPic ); |
---|
[1321] | 3345 | } |
---|
| 3346 | } |
---|
| 3347 | } |
---|
| 3348 | |
---|
| 3349 | Void TDecTop::xF833DecProcForGenUnavRefPics() |
---|
| 3350 | { |
---|
| 3351 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
| 3352 | // F.8.3.3 Decoding process for generating unavailable reference picture |
---|
| 3353 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
| 3354 | |
---|
| 3355 | x8331GenDecProcForGenUnavilRefPics(); |
---|
| 3356 | } |
---|
| 3357 | |
---|
| 3358 | Void TDecTop::xCheckUnavailableRefPics() |
---|
| 3359 | { |
---|
| 3360 | std::vector<TComPic*>** refPicSetsCurr = m_pcPic->getDecodedRps()->m_refPicSetsCurr; |
---|
| 3361 | |
---|
[1356] | 3362 | Bool hasGeneratedRefPic = false; |
---|
| 3363 | for (Int j = 0; j < 3; j++ ) |
---|
| 3364 | { |
---|
| 3365 | std::vector<TComPic*>* cSet = refPicSetsCurr[j]; |
---|
[1321] | 3366 | for (Int i = 0 ; i < cSet->size(); i++ ) |
---|
| 3367 | { |
---|
| 3368 | assert( (*cSet)[i] != NULL ); |
---|
| 3369 | if ((*cSet)[i]->getIsGenerated() ) |
---|
| 3370 | { |
---|
[1356] | 3371 | hasGeneratedRefPic = true; |
---|
[1321] | 3372 | } |
---|
| 3373 | } |
---|
| 3374 | } |
---|
[1356] | 3375 | m_pcPic->setHasGeneratedRefPics( hasGeneratedRefPic ); |
---|
[1321] | 3376 | } |
---|
| 3377 | |
---|
[608] | 3378 | #endif |
---|
[1313] | 3379 | |
---|
[56] | 3380 | //! \} |
---|