[5] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
[56] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[56] | 6 | * Copyright (c) 2010-2012, ITU/ISO/IEC |
---|
[5] | 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
| 33 | |
---|
[2] | 34 | /** \file TDecTop.cpp |
---|
| 35 | \brief decoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
[56] | 38 | #include "NALread.h" |
---|
[2] | 39 | #include "../../App/TAppDecoder/TAppDecTop.h" |
---|
| 40 | #include "TDecTop.h" |
---|
| 41 | |
---|
[56] | 42 | //! \ingroup TLibDecoder |
---|
| 43 | //! \{ |
---|
[2] | 44 | |
---|
| 45 | |
---|
| 46 | CamParsCollector::CamParsCollector() |
---|
| 47 | : m_bInitialized( false ) |
---|
| 48 | { |
---|
[56] | 49 | m_aaiCodedOffset = new Int* [ MAX_VIEW_NUM ]; |
---|
| 50 | m_aaiCodedScale = new Int* [ MAX_VIEW_NUM ]; |
---|
| 51 | m_aiViewOrderIndex = new Int [ MAX_VIEW_NUM ]; |
---|
[210] | 52 | #if QC_MVHEVC_B0046 |
---|
| 53 | m_aiViewId = new Int [ MAX_VIEW_NUM ]; |
---|
| 54 | #endif |
---|
[56] | 55 | m_aiViewReceived = new Int [ MAX_VIEW_NUM ]; |
---|
| 56 | for( UInt uiId = 0; uiId < MAX_VIEW_NUM; uiId++ ) |
---|
[2] | 57 | { |
---|
[56] | 58 | m_aaiCodedOffset [ uiId ] = new Int [ MAX_VIEW_NUM ]; |
---|
| 59 | m_aaiCodedScale [ uiId ] = new Int [ MAX_VIEW_NUM ]; |
---|
[2] | 60 | } |
---|
[231] | 61 | |
---|
| 62 | #if MERL_VSP_C0152 |
---|
| 63 | xCreateLUTs( (UInt)MAX_VIEW_NUM, (UInt)MAX_VIEW_NUM, m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT ); |
---|
| 64 | m_iLog2Precision = LOG2_DISP_PREC_LUT; |
---|
| 65 | m_uiBitDepthForLUT = 8; // fixed |
---|
| 66 | #endif |
---|
[2] | 67 | } |
---|
| 68 | |
---|
| 69 | CamParsCollector::~CamParsCollector() |
---|
| 70 | { |
---|
[56] | 71 | for( UInt uiId = 0; uiId < MAX_VIEW_NUM; uiId++ ) |
---|
[2] | 72 | { |
---|
| 73 | delete [] m_aaiCodedOffset [ uiId ]; |
---|
| 74 | delete [] m_aaiCodedScale [ uiId ]; |
---|
| 75 | } |
---|
| 76 | delete [] m_aaiCodedOffset; |
---|
| 77 | delete [] m_aaiCodedScale; |
---|
| 78 | delete [] m_aiViewOrderIndex; |
---|
| 79 | delete [] m_aiViewReceived; |
---|
[231] | 80 | |
---|
| 81 | #if MERL_VSP_C0152 |
---|
| 82 | xDeleteArray( m_adBaseViewShiftLUT, MAX_VIEW_NUM, MAX_VIEW_NUM, 2 ); |
---|
| 83 | xDeleteArray( m_aiBaseViewShiftLUT, MAX_VIEW_NUM, MAX_VIEW_NUM, 2 ); |
---|
| 84 | #endif |
---|
[2] | 85 | } |
---|
| 86 | |
---|
| 87 | Void |
---|
| 88 | CamParsCollector::init( FILE* pCodedScaleOffsetFile ) |
---|
| 89 | { |
---|
| 90 | m_bInitialized = true; |
---|
| 91 | m_pCodedScaleOffsetFile = pCodedScaleOffsetFile; |
---|
| 92 | m_uiCamParsCodedPrecision = 0; |
---|
| 93 | m_bCamParsVaryOverTime = false; |
---|
| 94 | m_iLastViewId = -1; |
---|
| 95 | m_iLastPOC = -1; |
---|
| 96 | m_uiMaxViewId = 0; |
---|
| 97 | } |
---|
| 98 | |
---|
[231] | 99 | #if MERL_VSP_C0152 |
---|
[2] | 100 | Void |
---|
[231] | 101 | CamParsCollector::xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT) |
---|
| 102 | { |
---|
| 103 | //AOF( m_uiBitDepthForLUT == 8 ); |
---|
| 104 | //AOF(radLUT == NULL && raiLUT == NULL ); |
---|
| 105 | |
---|
| 106 | uiNumberSourceViews = Max( 1, uiNumberSourceViews ); |
---|
| 107 | uiNumberTargetViews = Max( 1, uiNumberTargetViews ); |
---|
| 108 | |
---|
| 109 | radLUT = new Double***[ uiNumberSourceViews ]; |
---|
| 110 | raiLUT = new Int ***[ uiNumberSourceViews ]; |
---|
| 111 | |
---|
| 112 | for( UInt uiSourceView = 0; uiSourceView < uiNumberSourceViews; uiSourceView++ ) |
---|
| 113 | { |
---|
| 114 | radLUT [ uiSourceView ] = new Double**[ uiNumberTargetViews ]; |
---|
| 115 | raiLUT [ uiSourceView ] = new Int **[ uiNumberTargetViews ]; |
---|
| 116 | |
---|
| 117 | for( UInt uiTargetView = 0; uiTargetView < uiNumberTargetViews; uiTargetView++ ) |
---|
| 118 | { |
---|
| 119 | radLUT [ uiSourceView ][ uiTargetView ] = new Double*[ 2 ]; |
---|
| 120 | radLUT [ uiSourceView ][ uiTargetView ][ 0 ] = new Double [ 257 ]; |
---|
| 121 | radLUT [ uiSourceView ][ uiTargetView ][ 1 ] = new Double [ 257 ]; |
---|
| 122 | |
---|
| 123 | raiLUT [ uiSourceView ][ uiTargetView ] = new Int* [ 2 ]; |
---|
| 124 | raiLUT [ uiSourceView ][ uiTargetView ][ 0 ] = new Int [ 257 ]; |
---|
| 125 | raiLUT [ uiSourceView ][ uiTargetView ][ 1 ] = new Int [ 257 ]; |
---|
| 126 | } |
---|
| 127 | } |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | Void |
---|
| 131 | CamParsCollector::xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT) |
---|
| 132 | { |
---|
| 133 | Int iLog2DivLuma = m_uiBitDepthForLUT + m_uiCamParsCodedPrecision + 1 - m_iLog2Precision; AOF( iLog2DivLuma > 0 ); |
---|
| 134 | Int iLog2DivChroma = iLog2DivLuma + 1; |
---|
| 135 | |
---|
| 136 | iOffset <<= m_uiBitDepthForLUT; |
---|
| 137 | |
---|
| 138 | Double dScale = (Double) iScale / (( Double ) ( 1 << iLog2DivLuma )); |
---|
| 139 | Double dOffset = (Double) iOffset / (( Double ) ( 1 << iLog2DivLuma )); |
---|
| 140 | |
---|
| 141 | // offsets including rounding offsets |
---|
| 142 | Int64 iOffsetLuma = iOffset + ( ( 1 << iLog2DivLuma ) >> 1 ); |
---|
| 143 | Int64 iOffsetChroma = iOffset + ( ( 1 << iLog2DivChroma ) >> 1 ); |
---|
| 144 | |
---|
| 145 | |
---|
| 146 | for( UInt uiDepthValue = 0; uiDepthValue < 256; uiDepthValue++ ) |
---|
| 147 | { |
---|
| 148 | |
---|
| 149 | // real-valued look-up tables |
---|
| 150 | Double dShiftLuma = ( (Double)uiDepthValue * dScale + dOffset ) * Double( 1 << m_iLog2Precision ); |
---|
| 151 | Double dShiftChroma = dShiftLuma / 2; |
---|
| 152 | radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = dShiftLuma; |
---|
| 153 | radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = dShiftChroma; |
---|
| 154 | |
---|
| 155 | // integer-valued look-up tables |
---|
| 156 | Int64 iTempScale = (Int64)uiDepthValue * iScale; |
---|
| 157 | Int64 iShiftLuma = ( iTempScale + iOffsetLuma ) >> iLog2DivLuma; |
---|
| 158 | Int64 iShiftChroma = ( iTempScale + iOffsetChroma ) >> iLog2DivChroma; |
---|
| 159 | raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = (Int)iShiftLuma; |
---|
| 160 | raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = (Int)iShiftChroma; |
---|
| 161 | |
---|
| 162 | // maximum deviation |
---|
| 163 | //dMaxDispDev = Max( dMaxDispDev, fabs( Double( (Int) iTestScale ) - dShiftLuma * Double( 1 << iLog2DivLuma ) ) / Double( 1 << iLog2DivLuma ) ); |
---|
| 164 | //dMaxRndDispDvL = Max( dMaxRndDispDvL, fabs( Double( (Int) iShiftLuma ) - dShiftLuma ) ); |
---|
| 165 | //dMaxRndDispDvC = Max( dMaxRndDispDvC, fabs( Double( (Int) iShiftChroma ) - dShiftChroma ) ); |
---|
| 166 | } |
---|
| 167 | |
---|
| 168 | radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ]; |
---|
| 169 | radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ]; |
---|
| 170 | raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ]; |
---|
| 171 | raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ]; |
---|
| 172 | } |
---|
| 173 | #endif // end MERL_VSP_C0152 |
---|
| 174 | |
---|
| 175 | Void |
---|
[2] | 176 | CamParsCollector::uninit() |
---|
| 177 | { |
---|
| 178 | m_bInitialized = false; |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | Void |
---|
| 182 | CamParsCollector::setSlice( TComSlice* pcSlice ) |
---|
| 183 | { |
---|
| 184 | if( pcSlice == 0 ) |
---|
| 185 | { |
---|
| 186 | AOF( xIsComplete() ); |
---|
| 187 | if( m_bCamParsVaryOverTime || m_iLastPOC == 0 ) |
---|
| 188 | { |
---|
| 189 | xOutput( m_iLastPOC ); |
---|
| 190 | } |
---|
| 191 | return; |
---|
| 192 | } |
---|
| 193 | |
---|
[56] | 194 | AOF( pcSlice->getSPS()->getViewId() < MAX_VIEW_NUM ); |
---|
[2] | 195 | if ( pcSlice->getSPS()->isDepth () ) |
---|
| 196 | { |
---|
| 197 | return; |
---|
| 198 | } |
---|
| 199 | Bool bFirstAU = ( pcSlice->getPOC() == 0 ); |
---|
| 200 | Bool bFirstSliceInAU = ( pcSlice->getPOC() != Int ( m_iLastPOC ) ); |
---|
| 201 | Bool bFirstSliceInView = ( pcSlice->getSPS()->getViewId() != UInt( m_iLastViewId ) || bFirstSliceInAU ); |
---|
| 202 | AOT( bFirstSliceInAU && pcSlice->getSPS()->getViewId() != 0 ); |
---|
| 203 | AOT( !bFirstSliceInAU && pcSlice->getSPS()->getViewId() < UInt( m_iLastViewId ) ); |
---|
| 204 | AOT( !bFirstSliceInAU && pcSlice->getSPS()->getViewId() > UInt( m_iLastViewId + 1 ) ); |
---|
| 205 | AOT( !bFirstAU && pcSlice->getSPS()->getViewId() > m_uiMaxViewId ); |
---|
| 206 | if ( !bFirstSliceInView ) |
---|
| 207 | { |
---|
| 208 | if( m_bCamParsVaryOverTime ) // check consistency of slice parameters here |
---|
| 209 | { |
---|
| 210 | UInt uiViewId = pcSlice->getSPS()->getViewId(); |
---|
| 211 | for( UInt uiBaseId = 0; uiBaseId < uiViewId; uiBaseId++ ) |
---|
| 212 | { |
---|
| 213 | AOF( m_aaiCodedScale [ uiBaseId ][ uiViewId ] == pcSlice->getCodedScale () [ uiBaseId ] ); |
---|
| 214 | AOF( m_aaiCodedOffset[ uiBaseId ][ uiViewId ] == pcSlice->getCodedOffset () [ uiBaseId ] ); |
---|
| 215 | AOF( m_aaiCodedScale [ uiViewId ][ uiBaseId ] == pcSlice->getInvCodedScale () [ uiBaseId ] ); |
---|
| 216 | AOF( m_aaiCodedOffset[ uiViewId ][ uiBaseId ] == pcSlice->getInvCodedOffset() [ uiBaseId ] ); |
---|
| 217 | } |
---|
| 218 | } |
---|
| 219 | return; |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | if( bFirstSliceInAU ) |
---|
| 223 | { |
---|
| 224 | if( !bFirstAU ) |
---|
| 225 | { |
---|
| 226 | AOF( xIsComplete() ); |
---|
| 227 | xOutput( m_iLastPOC ); |
---|
| 228 | } |
---|
[56] | 229 | ::memset( m_aiViewReceived, 0x00, MAX_VIEW_NUM * sizeof( Int ) ); |
---|
[2] | 230 | } |
---|
| 231 | |
---|
| 232 | UInt uiViewId = pcSlice->getSPS()->getViewId(); |
---|
| 233 | m_aiViewReceived[ uiViewId ] = 1; |
---|
| 234 | if( bFirstAU ) |
---|
| 235 | { |
---|
| 236 | m_uiMaxViewId = Max( m_uiMaxViewId, uiViewId ); |
---|
| 237 | m_aiViewOrderIndex[ uiViewId ] = pcSlice->getSPS()->getViewOrderIdx(); |
---|
| 238 | if( uiViewId == 1 ) |
---|
| 239 | { |
---|
| 240 | m_uiCamParsCodedPrecision = pcSlice->getSPS()->getCamParPrecision (); |
---|
| 241 | m_bCamParsVaryOverTime = pcSlice->getSPS()->hasCamParInSliceHeader (); |
---|
| 242 | } |
---|
| 243 | else if( uiViewId > 1 ) |
---|
| 244 | { |
---|
| 245 | AOF( m_uiCamParsCodedPrecision == pcSlice->getSPS()->getCamParPrecision () ); |
---|
| 246 | AOF( m_bCamParsVaryOverTime == pcSlice->getSPS()->hasCamParInSliceHeader () ); |
---|
| 247 | } |
---|
| 248 | for( UInt uiBaseId = 0; uiBaseId < uiViewId; uiBaseId++ ) |
---|
| 249 | { |
---|
| 250 | if( m_bCamParsVaryOverTime ) |
---|
| 251 | { |
---|
| 252 | m_aaiCodedScale [ uiBaseId ][ uiViewId ] = pcSlice->getCodedScale () [ uiBaseId ]; |
---|
| 253 | m_aaiCodedOffset[ uiBaseId ][ uiViewId ] = pcSlice->getCodedOffset () [ uiBaseId ]; |
---|
| 254 | m_aaiCodedScale [ uiViewId ][ uiBaseId ] = pcSlice->getInvCodedScale () [ uiBaseId ]; |
---|
| 255 | m_aaiCodedOffset[ uiViewId ][ uiBaseId ] = pcSlice->getInvCodedOffset() [ uiBaseId ]; |
---|
[231] | 256 | #if MERL_VSP_C0152 |
---|
| 257 | xInitLUTs( uiBaseId, uiViewId, m_aaiCodedScale[ uiBaseId ][ uiViewId ], m_aaiCodedOffset[ uiBaseId ][ uiViewId ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT); |
---|
| 258 | xInitLUTs( uiViewId, uiBaseId, m_aaiCodedScale[ uiViewId ][ uiBaseId ], m_aaiCodedOffset[ uiViewId ][ uiBaseId ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT); |
---|
| 259 | #endif |
---|
[2] | 260 | } |
---|
| 261 | else |
---|
| 262 | { |
---|
| 263 | m_aaiCodedScale [ uiBaseId ][ uiViewId ] = pcSlice->getSPS()->getCodedScale () [ uiBaseId ]; |
---|
| 264 | m_aaiCodedOffset[ uiBaseId ][ uiViewId ] = pcSlice->getSPS()->getCodedOffset () [ uiBaseId ]; |
---|
| 265 | m_aaiCodedScale [ uiViewId ][ uiBaseId ] = pcSlice->getSPS()->getInvCodedScale () [ uiBaseId ]; |
---|
| 266 | m_aaiCodedOffset[ uiViewId ][ uiBaseId ] = pcSlice->getSPS()->getInvCodedOffset() [ uiBaseId ]; |
---|
[231] | 267 | #if MERL_VSP_C0152 |
---|
| 268 | xInitLUTs( uiBaseId, uiViewId, m_aaiCodedScale[ uiBaseId ][ uiViewId ], m_aaiCodedOffset[ uiBaseId ][ uiViewId ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT ); |
---|
| 269 | xInitLUTs( uiViewId, uiBaseId, m_aaiCodedScale[ uiViewId ][ uiBaseId ], m_aaiCodedOffset[ uiViewId ][ uiBaseId ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT ); |
---|
| 270 | #endif |
---|
[2] | 271 | } |
---|
| 272 | } |
---|
| 273 | } |
---|
| 274 | else |
---|
| 275 | { |
---|
| 276 | AOF( m_aiViewOrderIndex[ uiViewId ] == pcSlice->getSPS()->getViewOrderIdx() ); |
---|
| 277 | if( m_bCamParsVaryOverTime ) |
---|
| 278 | { |
---|
| 279 | for( UInt uiBaseId = 0; uiBaseId < uiViewId; uiBaseId++ ) |
---|
| 280 | { |
---|
| 281 | m_aaiCodedScale [ uiBaseId ][ uiViewId ] = pcSlice->getCodedScale () [ uiBaseId ]; |
---|
| 282 | m_aaiCodedOffset[ uiBaseId ][ uiViewId ] = pcSlice->getCodedOffset () [ uiBaseId ]; |
---|
| 283 | m_aaiCodedScale [ uiViewId ][ uiBaseId ] = pcSlice->getInvCodedScale () [ uiBaseId ]; |
---|
| 284 | m_aaiCodedOffset[ uiViewId ][ uiBaseId ] = pcSlice->getInvCodedOffset() [ uiBaseId ]; |
---|
[231] | 285 | #if MERL_VSP_C0152 |
---|
| 286 | xInitLUTs( uiBaseId, uiViewId, m_aaiCodedScale[ uiBaseId ][ uiViewId ], m_aaiCodedOffset[ uiBaseId ][ uiViewId ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT ); |
---|
| 287 | xInitLUTs( uiViewId, uiBaseId, m_aaiCodedScale[ uiViewId ][ uiBaseId ], m_aaiCodedOffset[ uiViewId ][ uiBaseId ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT ); |
---|
| 288 | #endif |
---|
[2] | 289 | } |
---|
| 290 | } |
---|
| 291 | } |
---|
| 292 | m_iLastViewId = (Int)pcSlice->getSPS()->getViewId(); |
---|
| 293 | m_iLastPOC = (Int)pcSlice->getPOC(); |
---|
| 294 | } |
---|
| 295 | |
---|
| 296 | Bool |
---|
| 297 | CamParsCollector::xIsComplete() |
---|
| 298 | { |
---|
| 299 | for( UInt uiView = 0; uiView <= m_uiMaxViewId; uiView++ ) |
---|
| 300 | { |
---|
| 301 | if( m_aiViewReceived[ uiView ] == 0 ) |
---|
| 302 | { |
---|
| 303 | return false; |
---|
| 304 | } |
---|
| 305 | } |
---|
| 306 | return true; |
---|
| 307 | } |
---|
| 308 | |
---|
| 309 | Void |
---|
| 310 | CamParsCollector::xOutput( Int iPOC ) |
---|
| 311 | { |
---|
| 312 | if( m_pCodedScaleOffsetFile ) |
---|
| 313 | { |
---|
| 314 | if( iPOC == 0 ) |
---|
| 315 | { |
---|
| 316 | fprintf( m_pCodedScaleOffsetFile, "# ViewId ViewOrderIdx\n" ); |
---|
| 317 | fprintf( m_pCodedScaleOffsetFile, "#----------- ------------\n" ); |
---|
| 318 | for( UInt uiViewId = 0; uiViewId <= m_uiMaxViewId; uiViewId++ ) |
---|
| 319 | { |
---|
| 320 | fprintf( m_pCodedScaleOffsetFile, "%12d %12d\n", uiViewId, m_aiViewOrderIndex[ uiViewId ] ); |
---|
| 321 | } |
---|
| 322 | fprintf( m_pCodedScaleOffsetFile, "\n\n"); |
---|
| 323 | fprintf( m_pCodedScaleOffsetFile, "# StartFrame EndFrame TargetView BaseView CodedScale CodedOffset Precision\n" ); |
---|
| 324 | fprintf( m_pCodedScaleOffsetFile, "#----------- ------------ ------------ ------------ ------------ ------------ ------------\n" ); |
---|
| 325 | } |
---|
| 326 | if( iPOC == 0 || m_bCamParsVaryOverTime ) |
---|
| 327 | { |
---|
| 328 | Int iS = iPOC; |
---|
| 329 | Int iE = ( m_bCamParsVaryOverTime ? iPOC : ~( 1 << 31 ) ); |
---|
| 330 | for( UInt uiViewId = 0; uiViewId <= m_uiMaxViewId; uiViewId++ ) |
---|
| 331 | { |
---|
| 332 | for( UInt uiBaseId = 0; uiBaseId <= m_uiMaxViewId; uiBaseId++ ) |
---|
| 333 | { |
---|
| 334 | if( uiViewId != uiBaseId ) |
---|
| 335 | { |
---|
| 336 | fprintf( m_pCodedScaleOffsetFile, "%12d %12d %12d %12d %12d %12d %12d\n", |
---|
[56] | 337 | iS, iE, uiViewId, uiBaseId, m_aaiCodedScale[ uiBaseId ][ uiViewId ], m_aaiCodedOffset[ uiBaseId ][ uiViewId ], m_uiCamParsCodedPrecision ); |
---|
[2] | 338 | } |
---|
| 339 | } |
---|
| 340 | } |
---|
| 341 | } |
---|
| 342 | } |
---|
| 343 | } |
---|
| 344 | |
---|
| 345 | TDecTop::TDecTop() |
---|
| 346 | : m_SEIs(0) |
---|
[56] | 347 | , m_tAppDecTop( NULL ) |
---|
| 348 | , m_nalUnitTypeBaseView( NAL_UNIT_INVALID ) |
---|
[2] | 349 | { |
---|
[56] | 350 | m_pcPic = 0; |
---|
[2] | 351 | m_iGopSize = 0; |
---|
| 352 | m_bGopSizeSet = false; |
---|
| 353 | m_iMaxRefPicNum = 0; |
---|
| 354 | m_uiValidPS = 0; |
---|
[21] | 355 | #if SONY_COLPIC_AVAILABILITY |
---|
| 356 | m_iViewOrderIdx = 0; |
---|
| 357 | #endif |
---|
[2] | 358 | #if ENC_DEC_TRACE |
---|
[231] | 359 | if(!g_hTrace) g_hTrace = fopen( "TraceDec.txt", "wb" ); |
---|
[2] | 360 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
| 361 | g_nSymbolCounter = 0; |
---|
| 362 | #endif |
---|
| 363 | m_bRefreshPending = 0; |
---|
[56] | 364 | m_pocCRA = 0; |
---|
| 365 | m_pocRandomAccess = MAX_INT; |
---|
| 366 | m_prevPOC = MAX_INT; |
---|
[2] | 367 | m_bFirstSliceInPicture = true; |
---|
| 368 | m_bFirstSliceInSequence = true; |
---|
[57] | 369 | m_pcCamParsCollector = 0; |
---|
[210] | 370 | #if QC_MVHEVC_B0046 |
---|
| 371 | m_bFirstNal = false; |
---|
| 372 | #endif |
---|
[2] | 373 | } |
---|
| 374 | |
---|
| 375 | TDecTop::~TDecTop() |
---|
| 376 | { |
---|
| 377 | #if ENC_DEC_TRACE |
---|
[231] | 378 | if(g_hTrace) fclose( g_hTrace ); |
---|
| 379 | g_hTrace=NULL; |
---|
[2] | 380 | #endif |
---|
| 381 | } |
---|
| 382 | |
---|
| 383 | Void TDecTop::create() |
---|
| 384 | { |
---|
| 385 | m_cGopDecoder.create(); |
---|
| 386 | m_apcSlicePilot = new TComSlice; |
---|
| 387 | m_uiSliceIdx = m_uiLastSliceIdx = 0; |
---|
| 388 | } |
---|
| 389 | |
---|
| 390 | Void TDecTop::destroy() |
---|
| 391 | { |
---|
| 392 | m_cGopDecoder.destroy(); |
---|
[56] | 393 | |
---|
[2] | 394 | delete m_apcSlicePilot; |
---|
| 395 | m_apcSlicePilot = NULL; |
---|
[56] | 396 | |
---|
[2] | 397 | m_cSliceDecoder.destroy(); |
---|
[56] | 398 | m_tAppDecTop = NULL; |
---|
[2] | 399 | |
---|
[5] | 400 | #if DEPTH_MAP_GENERATION |
---|
[2] | 401 | m_cDepthMapGenerator.destroy(); |
---|
[5] | 402 | #endif |
---|
| 403 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 404 | m_cResidualGenerator.destroy(); |
---|
[5] | 405 | #endif |
---|
[231] | 406 | |
---|
[2] | 407 | } |
---|
| 408 | |
---|
| 409 | Void TDecTop::init( TAppDecTop* pcTAppDecTop, Bool bFirstInstance ) |
---|
| 410 | { |
---|
| 411 | // initialize ROM |
---|
| 412 | if( bFirstInstance ) |
---|
[56] | 413 | { |
---|
| 414 | initROM(); |
---|
| 415 | } |
---|
| 416 | m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cAdaptiveLoopFilter, &m_cSAO |
---|
[5] | 417 | #if DEPTH_MAP_GENERATION |
---|
[56] | 418 | , &m_cDepthMapGenerator |
---|
[5] | 419 | #endif |
---|
| 420 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[56] | 421 | , &m_cResidualGenerator |
---|
[5] | 422 | #endif |
---|
[56] | 423 | ); |
---|
[2] | 424 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder ); |
---|
| 425 | m_cEntropyDecoder.init(&m_cPrediction); |
---|
[56] | 426 | m_tAppDecTop = pcTAppDecTop; |
---|
[5] | 427 | #if DEPTH_MAP_GENERATION |
---|
[77] | 428 | #if VIDYO_VPS_INTEGRATION |
---|
| 429 | m_cDepthMapGenerator.init( &m_cPrediction, m_tAppDecTop->getVPSAccess(), m_tAppDecTop->getSPSAccess(), m_tAppDecTop->getAUPicAccess() ); |
---|
| 430 | #else |
---|
[56] | 431 | m_cDepthMapGenerator.init( &m_cPrediction, m_tAppDecTop->getSPSAccess(), m_tAppDecTop->getAUPicAccess() ); |
---|
[5] | 432 | #endif |
---|
[77] | 433 | #endif |
---|
[5] | 434 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
[2] | 435 | m_cResidualGenerator.init( &m_cTrQuant, &m_cDepthMapGenerator ); |
---|
[5] | 436 | #endif |
---|
[2] | 437 | } |
---|
| 438 | |
---|
| 439 | Void TDecTop::deletePicBuffer ( ) |
---|
| 440 | { |
---|
| 441 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 442 | Int iSize = Int( m_cListPic.size() ); |
---|
[56] | 443 | |
---|
[2] | 444 | for (Int i = 0; i < iSize; i++ ) |
---|
| 445 | { |
---|
[56] | 446 | if( *iterPic ) |
---|
| 447 | { |
---|
| 448 | TComPic* pcPic = *(iterPic++); |
---|
| 449 | pcPic->destroy(); |
---|
| 450 | |
---|
| 451 | delete pcPic; |
---|
| 452 | pcPic = NULL; |
---|
| 453 | } |
---|
[2] | 454 | } |
---|
[56] | 455 | |
---|
[2] | 456 | // destroy ALF temporary buffers |
---|
| 457 | m_cAdaptiveLoopFilter.destroy(); |
---|
| 458 | |
---|
| 459 | m_cSAO.destroy(); |
---|
[56] | 460 | |
---|
[2] | 461 | m_cLoopFilter. destroy(); |
---|
[56] | 462 | |
---|
[2] | 463 | // destroy ROM |
---|
[56] | 464 | if(m_viewId == 0 && m_isDepth == false) |
---|
| 465 | { |
---|
[2] | 466 | destroyROM(); |
---|
[56] | 467 | } |
---|
[2] | 468 | } |
---|
| 469 | |
---|
[56] | 470 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 471 | Void |
---|
| 472 | TDecTop::deleteExtraPicBuffers( Int iPoc ) |
---|
| 473 | { |
---|
| 474 | TComPic* pcPic = 0; |
---|
| 475 | TComList<TComPic*>::iterator cIter = m_cListPic.begin(); |
---|
| 476 | TComList<TComPic*>::iterator cEnd = m_cListPic.end (); |
---|
| 477 | for( ; cIter != cEnd; cIter++ ) |
---|
| 478 | { |
---|
| 479 | if( (*cIter)->getPOC() == iPoc ) |
---|
| 480 | { |
---|
| 481 | pcPic = *cIter; |
---|
| 482 | break; |
---|
| 483 | } |
---|
| 484 | } |
---|
| 485 | //AOF( pcPic ); |
---|
| 486 | if ( pcPic ) |
---|
| 487 | { |
---|
| 488 | pcPic->removeResidualBuffer (); |
---|
| 489 | } |
---|
| 490 | } |
---|
| 491 | #endif |
---|
| 492 | |
---|
| 493 | |
---|
| 494 | Void |
---|
| 495 | TDecTop::compressMotion( Int iPoc ) |
---|
| 496 | { |
---|
| 497 | TComPic* pcPic = 0; |
---|
| 498 | TComList<TComPic*>::iterator cIter = m_cListPic.begin(); |
---|
| 499 | TComList<TComPic*>::iterator cEnd = m_cListPic.end (); |
---|
| 500 | for( ; cIter != cEnd; cIter++ ) |
---|
| 501 | { |
---|
| 502 | if( (*cIter)->getPOC() == iPoc ) |
---|
| 503 | { |
---|
| 504 | pcPic = *cIter; |
---|
| 505 | break; |
---|
| 506 | } |
---|
| 507 | } |
---|
| 508 | // AOF( pcPic ); |
---|
| 509 | if ( pcPic ) |
---|
| 510 | { |
---|
| 511 | pcPic->compressMotion(); |
---|
| 512 | } |
---|
| 513 | } |
---|
| 514 | |
---|
| 515 | Void TDecTop::xUpdateGopSize (TComSlice* pcSlice) |
---|
| 516 | { |
---|
| 517 | if ( !pcSlice->isIntra() && !m_bGopSizeSet) |
---|
| 518 | { |
---|
| 519 | m_iGopSize = pcSlice->getPOC(); |
---|
| 520 | m_bGopSizeSet = true; |
---|
| 521 | |
---|
| 522 | m_cGopDecoder.setGopSize(m_iGopSize); |
---|
| 523 | } |
---|
| 524 | } |
---|
| 525 | |
---|
[2] | 526 | Void TDecTop::xGetNewPicBuffer ( TComSlice* pcSlice, TComPic*& rpcPic ) |
---|
| 527 | { |
---|
[56] | 528 | xUpdateGopSize(pcSlice); |
---|
| 529 | |
---|
| 530 | #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
| 531 | m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer())+pcSlice->getSPS()->getNumReorderPics(pcSlice->getTLayer()) + 1; // +1 to have space for the picture currently being decoded |
---|
| 532 | #else |
---|
| 533 | m_iMaxRefPicNum = pcSlice->getSPS()->getMaxNumberOfReferencePictures()+pcSlice->getSPS()->getNumReorderFrames() + 1; // +1 to have space for the picture currently being decoded |
---|
| 534 | #endif |
---|
[2] | 535 | |
---|
[5] | 536 | #if DEPTH_MAP_GENERATION |
---|
[56] | 537 | UInt uiPdm = ( pcSlice->getSPS()->getViewId() ? pcSlice->getSPS()->getPredDepthMapGeneration() : m_tAppDecTop->getSPSAccess()->getPdm() ); |
---|
[21] | 538 | Bool bNeedPrdDepthMapBuffer = ( !pcSlice->getSPS()->isDepth() && uiPdm > 0 ); |
---|
[5] | 539 | #endif |
---|
[2] | 540 | |
---|
| 541 | if (m_cListPic.size() < (UInt)m_iMaxRefPicNum) |
---|
| 542 | { |
---|
[56] | 543 | rpcPic = new TComPic(); |
---|
| 544 | |
---|
| 545 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true); |
---|
| 546 | |
---|
[5] | 547 | #if DEPTH_MAP_GENERATION |
---|
[2] | 548 | if( bNeedPrdDepthMapBuffer ) |
---|
| 549 | { |
---|
[21] | 550 | rpcPic->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) ); |
---|
[2] | 551 | } |
---|
[5] | 552 | #endif |
---|
[56] | 553 | |
---|
[2] | 554 | m_cListPic.pushBack( rpcPic ); |
---|
[56] | 555 | |
---|
[2] | 556 | return; |
---|
| 557 | } |
---|
[56] | 558 | |
---|
[2] | 559 | Bool bBufferIsAvailable = false; |
---|
| 560 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 561 | while (iterPic != m_cListPic.end()) |
---|
| 562 | { |
---|
| 563 | rpcPic = *(iterPic++); |
---|
[56] | 564 | if ( rpcPic->getReconMark() == false && rpcPic->getOutputMark() == false) |
---|
[2] | 565 | { |
---|
[56] | 566 | rpcPic->setOutputMark(false); |
---|
[2] | 567 | bBufferIsAvailable = true; |
---|
| 568 | break; |
---|
| 569 | } |
---|
[56] | 570 | |
---|
| 571 | if ( rpcPic->getSlice( 0 )->isReferenced() == false && rpcPic->getOutputMark() == false) |
---|
| 572 | { |
---|
| 573 | rpcPic->setOutputMark(false); |
---|
| 574 | rpcPic->setReconMark( false ); |
---|
| 575 | rpcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
| 576 | bBufferIsAvailable = true; |
---|
| 577 | break; |
---|
| 578 | } |
---|
[2] | 579 | } |
---|
[56] | 580 | |
---|
[2] | 581 | if ( !bBufferIsAvailable ) |
---|
| 582 | { |
---|
[56] | 583 | //There is no room for this picture, either because of faulty encoder or dropped NAL. Extend the buffer. |
---|
| 584 | m_iMaxRefPicNum++; |
---|
| 585 | rpcPic = new TComPic(); |
---|
| 586 | m_cListPic.pushBack( rpcPic ); |
---|
[2] | 587 | } |
---|
[56] | 588 | rpcPic->destroy(); |
---|
| 589 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true); |
---|
[5] | 590 | #if DEPTH_MAP_GENERATION |
---|
[2] | 591 | if( bNeedPrdDepthMapBuffer && !rpcPic->getPredDepthMap() ) |
---|
| 592 | { |
---|
[21] | 593 | rpcPic->addPrdDepthMapBuffer( PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) ); |
---|
[2] | 594 | } |
---|
[5] | 595 | #endif |
---|
[2] | 596 | } |
---|
| 597 | |
---|
[56] | 598 | Void TDecTop::executeDeblockAndAlf(UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
| 599 | { |
---|
| 600 | if (!m_pcPic) |
---|
| 601 | { |
---|
| 602 | /* nothing to deblock */ |
---|
| 603 | return; |
---|
| 604 | } |
---|
| 605 | |
---|
| 606 | TComPic*& pcPic = m_pcPic; |
---|
[2] | 607 | |
---|
[56] | 608 | // Execute Deblock and ALF only + Cleanup |
---|
| 609 | |
---|
| 610 | m_cGopDecoder.decompressGop(NULL, pcPic, true); |
---|
| 611 | |
---|
| 612 | TComSlice::sortPicList( m_cListPic ); // sorting for application output |
---|
| 613 | ruiPOC = pcPic->getSlice(m_uiSliceIdx-1)->getPOC(); |
---|
| 614 | rpcListPic = &m_cListPic; |
---|
| 615 | m_cCuDecoder.destroy(); |
---|
| 616 | m_bFirstSliceInPicture = true; |
---|
| 617 | |
---|
| 618 | return; |
---|
| 619 | } |
---|
| 620 | |
---|
| 621 | Void TDecTop::xCreateLostPicture(Int iLostPoc) |
---|
[2] | 622 | { |
---|
[56] | 623 | printf("\ninserting lost poc : %d\n",iLostPoc); |
---|
| 624 | TComSlice cFillSlice; |
---|
| 625 | cFillSlice.setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
---|
| 626 | cFillSlice.setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
---|
| 627 | cFillSlice.initSlice(); |
---|
| 628 | cFillSlice.initTiles(); |
---|
| 629 | TComPic *cFillPic; |
---|
| 630 | xGetNewPicBuffer(&cFillSlice,cFillPic); |
---|
| 631 | cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
---|
| 632 | cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
---|
| 633 | cFillPic->getSlice(0)->initSlice(); |
---|
| 634 | cFillPic->getSlice(0)->initTiles(); |
---|
| 635 | |
---|
| 636 | |
---|
| 637 | |
---|
| 638 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
| 639 | Int closestPoc = 1000000; |
---|
| 640 | while ( iterPic != m_cListPic.end()) |
---|
[2] | 641 | { |
---|
[56] | 642 | TComPic * rpcPic = *(iterPic++); |
---|
| 643 | if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)<closestPoc&&abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)!=0&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC()) |
---|
[2] | 644 | { |
---|
[56] | 645 | closestPoc=abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc); |
---|
| 646 | } |
---|
| 647 | } |
---|
| 648 | iterPic = m_cListPic.begin(); |
---|
| 649 | while ( iterPic != m_cListPic.end()) |
---|
| 650 | { |
---|
| 651 | TComPic *rpcPic = *(iterPic++); |
---|
| 652 | if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)==closestPoc&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC()) |
---|
| 653 | { |
---|
| 654 | printf("copying picture %d to %d (%d)\n",rpcPic->getPicSym()->getSlice(0)->getPOC() ,iLostPoc,m_apcSlicePilot->getPOC()); |
---|
| 655 | rpcPic->getPicYuvRec()->copyToPic(cFillPic->getPicYuvRec()); |
---|
[2] | 656 | break; |
---|
| 657 | } |
---|
| 658 | } |
---|
[56] | 659 | cFillPic->setCurrSliceIdx(0); |
---|
| 660 | for(Int i=0; i<cFillPic->getNumCUsInFrame(); i++) |
---|
[2] | 661 | { |
---|
[56] | 662 | cFillPic->getCU(i)->initCU(cFillPic,i); |
---|
[2] | 663 | } |
---|
[56] | 664 | cFillPic->getSlice(0)->setReferenced(true); |
---|
| 665 | cFillPic->getSlice(0)->setPOC(iLostPoc); |
---|
| 666 | cFillPic->setReconMark(true); |
---|
| 667 | cFillPic->setOutputMark(true); |
---|
| 668 | if(m_pocRandomAccess == MAX_INT) |
---|
| 669 | { |
---|
| 670 | m_pocRandomAccess = iLostPoc; |
---|
| 671 | } |
---|
[2] | 672 | } |
---|
| 673 | |
---|
[56] | 674 | |
---|
| 675 | Void TDecTop::xActivateParameterSets() |
---|
[2] | 676 | { |
---|
[56] | 677 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
| 678 | |
---|
| 679 | TComPPS *pps = m_parameterSetManagerDecoder.getPPS(m_apcSlicePilot->getPPSId()); |
---|
| 680 | assert (pps != 0); |
---|
| 681 | |
---|
| 682 | TComSPS *sps = m_parameterSetManagerDecoder.getSPS(pps->getSPSId()); |
---|
| 683 | assert (sps != 0); |
---|
[77] | 684 | #if VIDYO_VPS_INTEGRATION |
---|
| 685 | TComVPS *vps = m_parameterSetManagerDecoder.getVPS(sps->getVPSId()); |
---|
| 686 | assert (vps != 0); |
---|
[210] | 687 | #if !QC_REM_IDV_B0046 |
---|
[77] | 688 | if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) |
---|
[210] | 689 | #else |
---|
| 690 | if( (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) && !sps->getViewId() ) |
---|
| 691 | #endif |
---|
[77] | 692 | // VPS can only be activated on IDR or CRA... |
---|
| 693 | getTAppDecTop()->getVPSAccess()->setActiveVPSId( sps->getVPSId() ); |
---|
| 694 | #endif |
---|
[56] | 695 | m_apcSlicePilot->setPPS(pps); |
---|
| 696 | m_apcSlicePilot->setSPS(sps); |
---|
[210] | 697 | #if QC_MVHEVC_B0046 |
---|
| 698 | TComVPS *vps = m_parameterSetManagerDecoder.getVPS(sps->getVPSId()); |
---|
| 699 | #endif |
---|
| 700 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
[77] | 701 | m_apcSlicePilot->setVPS(vps); |
---|
| 702 | #endif |
---|
[56] | 703 | pps->setSPS(sps); |
---|
| 704 | |
---|
| 705 | if(sps->getUseSAO() || sps->getUseALF()|| sps->getScalingListFlag() || sps->getUseDF()) |
---|
[2] | 706 | { |
---|
[56] | 707 | m_apcSlicePilot->setAPS( m_parameterSetManagerDecoder.getAPS(m_apcSlicePilot->getAPSId()) ); |
---|
[2] | 708 | } |
---|
[56] | 709 | pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) ); |
---|
| 710 | |
---|
| 711 | for (Int i = 0; i < sps->getMaxCUDepth() - 1; i++) |
---|
[2] | 712 | { |
---|
[56] | 713 | sps->setAMPAcc( i, sps->getUseAMP() ); |
---|
[2] | 714 | } |
---|
[56] | 715 | |
---|
| 716 | for (Int i = sps->getMaxCUDepth() - 1; i < sps->getMaxCUDepth(); i++) |
---|
| 717 | { |
---|
| 718 | sps->setAMPAcc( i, 0 ); |
---|
| 719 | } |
---|
| 720 | |
---|
| 721 | #if !LCU_SYNTAX_ALF |
---|
| 722 | // create ALF temporary buffer |
---|
| 723 | m_cAdaptiveLoopFilter.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 724 | #endif |
---|
| 725 | m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 726 | m_cLoopFilter. create( g_uiMaxCUDepth ); |
---|
[2] | 727 | } |
---|
[56] | 728 | |
---|
| 729 | #if SKIPFRAME_BUGFIX |
---|
| 730 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay ) |
---|
| 731 | #else |
---|
| 732 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int iSkipFrame, Int iPOCLastDisplay ) |
---|
[2] | 733 | #endif |
---|
| 734 | { |
---|
| 735 | TComPic*& pcPic = m_pcPic; |
---|
[56] | 736 | m_apcSlicePilot->initSlice(); |
---|
[2] | 737 | |
---|
[56] | 738 | //!!!KS: DIRTY HACK |
---|
| 739 | m_apcSlicePilot->setPPSId(0); |
---|
| 740 | m_apcSlicePilot->setPPS(m_parameterSetManagerDecoder.getPrefetchedPPS(0)); |
---|
| 741 | m_apcSlicePilot->setSPS(m_parameterSetManagerDecoder.getPrefetchedSPS(0)); |
---|
[210] | 742 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
| 743 | #if QC_MVHEVC_B0046 |
---|
| 744 | m_apcSlicePilot->setIsDepth(false); |
---|
| 745 | #endif |
---|
[77] | 746 | m_apcSlicePilot->setVPS(m_parameterSetManagerDecoder.getPrefetchedVPS(0)); |
---|
| 747 | #endif |
---|
[56] | 748 | m_apcSlicePilot->initTiles(); |
---|
[210] | 749 | #if QC_MVHEVC_B0046 |
---|
| 750 | m_apcSlicePilot->setViewId( nalu.m_layerId ); |
---|
| 751 | m_apcSlicePilot->setViewId( nalu.m_layerId ); |
---|
| 752 | m_apcSlicePilot->setViewOrderIdx(m_apcSlicePilot->getVPS()->getViewId(nalu.m_layerId), nalu.m_layerId); |
---|
| 753 | Int iNumDirectRef = m_apcSlicePilot->getVPS()->getNumDirectRefLayer(nalu.m_layerId); |
---|
| 754 | m_apcSlicePilot->getSPS()->setNumberOfUsableInterViewRefs(iNumDirectRef); |
---|
| 755 | for(Int iNumIvRef = 0; iNumIvRef < iNumDirectRef; iNumIvRef ++) |
---|
| 756 | { |
---|
| 757 | Int iDeltaLayerId = m_apcSlicePilot->getVPS()->getDirectRefLayerId( nalu.m_layerId, iNumIvRef); |
---|
| 758 | m_apcSlicePilot->getSPS()->setUsableInterViewRef(iNumIvRef, (iDeltaLayerId-nalu.m_layerId)); |
---|
| 759 | } |
---|
| 760 | #endif |
---|
[56] | 761 | if (m_bFirstSliceInPicture) |
---|
[2] | 762 | { |
---|
[56] | 763 | m_uiSliceIdx = 0; |
---|
| 764 | m_uiLastSliceIdx = 0; |
---|
[2] | 765 | } |
---|
[56] | 766 | m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); |
---|
| 767 | if (!m_bFirstSliceInPicture) |
---|
| 768 | { |
---|
| 769 | m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) ); |
---|
| 770 | } |
---|
[2] | 771 | |
---|
[56] | 772 | m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); |
---|
| 773 | if( m_bFirstSliceInPicture ) |
---|
| 774 | { |
---|
[210] | 775 | #if QC_MVHEVC_B0046 |
---|
| 776 | if( nalu.m_layerId == 0 ) { m_nalUnitTypeBaseView = nalu.m_nalUnitType; } |
---|
| 777 | else { m_nalUnitTypeBaseView = m_tAppDecTop->getTDecTop( 0, 0 )->getNalUnitTypeBaseView(); } |
---|
| 778 | #else |
---|
[77] | 779 | #if VIDYO_VPS_INTEGRATION |
---|
| 780 | if( m_apcSlicePilot->getVPS()->getViewId(nalu.m_layerId) == 0 ) { m_nalUnitTypeBaseView = nalu.m_nalUnitType; } |
---|
| 781 | else { m_nalUnitTypeBaseView = m_tAppDecTop->getTDecTop( 0, m_apcSlicePilot->getVPS()->getDepthFlag(nalu.m_layerId) )->getNalUnitTypeBaseView(); } |
---|
| 782 | #else |
---|
[56] | 783 | if( nalu.m_viewId == 0 ) { m_nalUnitTypeBaseView = nalu.m_nalUnitType; } |
---|
| 784 | else { m_nalUnitTypeBaseView = m_tAppDecTop->getTDecTop( 0, nalu.m_isDepth )->getNalUnitTypeBaseView(); } |
---|
[77] | 785 | #endif |
---|
[210] | 786 | #endif |
---|
[56] | 787 | m_apcSlicePilot->setNalUnitTypeBaseViewMvc( m_nalUnitTypeBaseView ); |
---|
| 788 | } |
---|
[2] | 789 | |
---|
[56] | 790 | #if SONY_COLPIC_AVAILABILITY |
---|
| 791 | m_apcSlicePilot->setViewOrderIdx( m_apcSlicePilot->getSPS()->getViewOrderIdx()); |
---|
| 792 | #endif |
---|
[2] | 793 | |
---|
[56] | 794 | #if NAL_REF_FLAG |
---|
| 795 | m_apcSlicePilot->setReferenced(nalu.m_nalRefFlag); |
---|
[42] | 796 | #else |
---|
[56] | 797 | m_apcSlicePilot->setReferenced(nalu.m_nalRefIDC != NAL_REF_IDC_PRIORITY_LOWEST); |
---|
| 798 | #endif |
---|
| 799 | m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId); |
---|
[42] | 800 | |
---|
[56] | 801 | // ALF CU parameters should be part of the slice header -> needs to be fixed |
---|
| 802 | #if LCU_SYNTAX_ALF |
---|
| 803 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder, m_cGopDecoder.getAlfCuCtrlParam(), m_cGopDecoder.getAlfParamSet()); |
---|
| 804 | #else |
---|
| 805 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder, m_cGopDecoder.getAlfCuCtrlParam() ); |
---|
[42] | 806 | #endif |
---|
[56] | 807 | // byte align |
---|
| 808 | { |
---|
| 809 | Int numBitsForByteAlignment = nalu.m_Bitstream->getNumBitsUntilByteAligned(); |
---|
| 810 | if ( numBitsForByteAlignment > 0 ) |
---|
| 811 | { |
---|
| 812 | UInt bitsForByteAlignment; |
---|
| 813 | nalu.m_Bitstream->read( numBitsForByteAlignment, bitsForByteAlignment ); |
---|
| 814 | assert( bitsForByteAlignment == ( ( 1 << numBitsForByteAlignment ) - 1 ) ); |
---|
| 815 | } |
---|
| 816 | } |
---|
| 817 | |
---|
| 818 | // exit when a new picture is found |
---|
| 819 | if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence) |
---|
| 820 | { |
---|
| 821 | #if START_DECODING_AT_CRA |
---|
| 822 | if (m_prevPOC >= m_pocRandomAccess) |
---|
| 823 | { |
---|
| 824 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 825 | return true; |
---|
| 826 | } |
---|
| 827 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
[2] | 828 | #else |
---|
[56] | 829 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 830 | return true; |
---|
[2] | 831 | #endif |
---|
[56] | 832 | } |
---|
| 833 | // actual decoding starts here |
---|
| 834 | xActivateParameterSets(); |
---|
| 835 | m_apcSlicePilot->initTiles(); |
---|
| 836 | |
---|
| 837 | if (m_apcSlicePilot->isNextSlice()) |
---|
| 838 | { |
---|
| 839 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
| 840 | } |
---|
| 841 | m_bFirstSliceInSequence = false; |
---|
| 842 | if (m_apcSlicePilot->isNextSlice()) |
---|
| 843 | { |
---|
| 844 | // Skip pictures due to random access |
---|
| 845 | if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) |
---|
| 846 | { |
---|
| 847 | return false; |
---|
| 848 | } |
---|
| 849 | } |
---|
| 850 | //detect lost reference picture and insert copy of earlier frame. |
---|
| 851 | #if START_DECODING_AT_CRA |
---|
| 852 | while(m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess) > 0) |
---|
| 853 | #else |
---|
| 854 | while(m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true) > 0) |
---|
| 855 | #endif |
---|
| 856 | { |
---|
| 857 | xCreateLostPicture(m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), false)-1); |
---|
| 858 | } |
---|
[2] | 859 | if (m_bFirstSliceInPicture) |
---|
| 860 | { |
---|
[56] | 861 | // Buffer initialize for prediction. |
---|
| 862 | m_cPrediction.initTempBuff(); |
---|
| 863 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
---|
| 864 | // Get a new picture buffer |
---|
| 865 | xGetNewPicBuffer (m_apcSlicePilot, pcPic); |
---|
[2] | 866 | |
---|
[56] | 867 | #if SONY_COLPIC_AVAILABILITY |
---|
| 868 | pcPic->setViewOrderIdx( m_apcSlicePilot->getSPS()->getViewOrderIdx() ); |
---|
| 869 | #endif |
---|
[2] | 870 | |
---|
[56] | 871 | /* transfer any SEI messages that have been received to the picture */ |
---|
| 872 | pcPic->setSEIs(m_SEIs); |
---|
| 873 | m_SEIs = NULL; |
---|
[42] | 874 | |
---|
[56] | 875 | // Recursive structure |
---|
| 876 | m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
| 877 | m_cCuDecoder.init ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction ); |
---|
| 878 | m_cTrQuant.init ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize()); |
---|
[42] | 879 | |
---|
[56] | 880 | m_cSliceDecoder.create( m_apcSlicePilot, m_apcSlicePilot->getSPS()->getPicWidthInLumaSamples(), m_apcSlicePilot->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 881 | #if DEPTH_MAP_GENERATION |
---|
| 882 | UInt uiPdm = ( m_apcSlicePilot->getSPS()->getViewId() ? m_apcSlicePilot->getSPS()->getPredDepthMapGeneration() : m_tAppDecTop->getSPSAccess()->getPdm() ); |
---|
| 883 | m_cDepthMapGenerator.create( true, m_apcSlicePilot->getSPS()->getPicWidthInLumaSamples(), m_apcSlicePilot->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement, PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) ); |
---|
| 884 | TComDepthMapGenerator* pcDMG0 = m_tAppDecTop->getDecTop0()->getDepthMapGenerator(); |
---|
| 885 | if( m_apcSlicePilot->getSPS()->getViewId() == 1 && ( pcDMG0->getSubSampExpX() != PDM_SUB_SAMP_EXP_X(uiPdm) || pcDMG0->getSubSampExpY() != PDM_SUB_SAMP_EXP_Y(uiPdm) ) ) |
---|
| 886 | { |
---|
| 887 | pcDMG0->create( true, m_apcSlicePilot->getSPS()->getPicWidthInLumaSamples(), m_apcSlicePilot->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement, PDM_SUB_SAMP_EXP_X(uiPdm), PDM_SUB_SAMP_EXP_Y(uiPdm) ); |
---|
| 888 | } |
---|
[42] | 889 | #endif |
---|
[56] | 890 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
| 891 | m_cResidualGenerator.create( true, m_apcSlicePilot->getSPS()->getPicWidthInLumaSamples(), m_apcSlicePilot->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement ); |
---|
| 892 | #endif |
---|
| 893 | } |
---|
[42] | 894 | |
---|
[56] | 895 | // Set picture slice pointer |
---|
| 896 | TComSlice* pcSlice = m_apcSlicePilot; |
---|
| 897 | Bool bNextSlice = pcSlice->isNextSlice(); |
---|
[2] | 898 | |
---|
[56] | 899 | UInt uiCummulativeTileWidth; |
---|
| 900 | UInt uiCummulativeTileHeight; |
---|
| 901 | UInt i, j, p; |
---|
| 902 | |
---|
| 903 | #if !REMOVE_TILE_DEPENDENCE |
---|
| 904 | //set the TileBoundaryIndependenceIdr |
---|
| 905 | if(pcSlice->getPPS()->getTileBehaviorControlPresentFlag() == 1) |
---|
[2] | 906 | { |
---|
[56] | 907 | pcPic->getPicSym()->setTileBoundaryIndependenceIdr( pcSlice->getPPS()->getTileBoundaryIndependenceIdr() ); |
---|
| 908 | } |
---|
| 909 | else |
---|
| 910 | { |
---|
| 911 | pcPic->getPicSym()->setTileBoundaryIndependenceIdr( pcSlice->getPPS()->getSPS()->getTileBoundaryIndependenceIdr() ); |
---|
| 912 | } |
---|
[42] | 913 | #endif |
---|
[2] | 914 | |
---|
[56] | 915 | if( pcSlice->getPPS()->getColumnRowInfoPresent() == 1 ) |
---|
| 916 | { |
---|
| 917 | //set NumColumnsMins1 and NumRowsMinus1 |
---|
| 918 | pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() ); |
---|
| 919 | pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() ); |
---|
| 920 | |
---|
| 921 | //create the TComTileArray |
---|
| 922 | pcPic->getPicSym()->xCreateTComTileArray(); |
---|
| 923 | |
---|
| 924 | if( pcSlice->getPPS()->getUniformSpacingIdr() == 1) |
---|
| 925 | { |
---|
| 926 | //set the width for each tile |
---|
| 927 | for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) |
---|
[2] | 928 | { |
---|
[56] | 929 | for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++) |
---|
| 930 | { |
---|
| 931 | pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )-> |
---|
| 932 | setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) |
---|
| 933 | - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) ); |
---|
| 934 | } |
---|
[2] | 935 | } |
---|
| 936 | |
---|
[56] | 937 | //set the height for each tile |
---|
| 938 | for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) |
---|
[2] | 939 | { |
---|
[56] | 940 | for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++) |
---|
| 941 | { |
---|
| 942 | pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )-> |
---|
| 943 | setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) |
---|
| 944 | - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) ); |
---|
| 945 | } |
---|
[2] | 946 | } |
---|
| 947 | } |
---|
[56] | 948 | else |
---|
[2] | 949 | { |
---|
[56] | 950 | //set the width for each tile |
---|
| 951 | for(j=0; j < pcSlice->getPPS()->getNumRowsMinus1()+1; j++) |
---|
[2] | 952 | { |
---|
[56] | 953 | uiCummulativeTileWidth = 0; |
---|
| 954 | for(i=0; i < pcSlice->getPPS()->getNumColumnsMinus1(); i++) |
---|
| 955 | { |
---|
| 956 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getPPS()->getColumnWidth(i) ); |
---|
| 957 | uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(i); |
---|
| 958 | } |
---|
| 959 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth ); |
---|
[2] | 960 | } |
---|
| 961 | |
---|
[56] | 962 | //set the height for each tile |
---|
| 963 | for(j=0; j < pcSlice->getPPS()->getNumColumnsMinus1()+1; j++) |
---|
[2] | 964 | { |
---|
[56] | 965 | uiCummulativeTileHeight = 0; |
---|
| 966 | for(i=0; i < pcSlice->getPPS()->getNumRowsMinus1(); i++) |
---|
| 967 | { |
---|
| 968 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getPPS()->getRowHeight(i) ); |
---|
| 969 | uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(i); |
---|
| 970 | } |
---|
| 971 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight ); |
---|
[2] | 972 | } |
---|
[56] | 973 | } |
---|
| 974 | } |
---|
| 975 | else |
---|
| 976 | { |
---|
| 977 | //set NumColumnsMins1 and NumRowsMinus1 |
---|
| 978 | pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getSPS()->getNumColumnsMinus1() ); |
---|
| 979 | pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getSPS()->getNumRowsMinus1() ); |
---|
[2] | 980 | |
---|
[56] | 981 | //create the TComTileArray |
---|
| 982 | pcPic->getPicSym()->xCreateTComTileArray(); |
---|
[2] | 983 | |
---|
[56] | 984 | //automatically set the column and row boundary if UniformSpacingIdr = 1 |
---|
| 985 | if( pcSlice->getSPS()->getUniformSpacingIdr() == 1 ) |
---|
| 986 | { |
---|
| 987 | //set the width for each tile |
---|
| 988 | for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) |
---|
[2] | 989 | { |
---|
[56] | 990 | for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++) |
---|
| 991 | { |
---|
| 992 | pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )-> |
---|
| 993 | setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) |
---|
| 994 | - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) ); |
---|
| 995 | } |
---|
[2] | 996 | } |
---|
[56] | 997 | |
---|
| 998 | //set the height for each tile |
---|
| 999 | for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) |
---|
[2] | 1000 | { |
---|
[56] | 1001 | for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++) |
---|
[2] | 1002 | { |
---|
[56] | 1003 | pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )-> |
---|
| 1004 | setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) |
---|
| 1005 | - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) ); |
---|
[2] | 1006 | } |
---|
| 1007 | } |
---|
[56] | 1008 | } |
---|
| 1009 | else |
---|
| 1010 | { |
---|
| 1011 | //set the width for each tile |
---|
| 1012 | for(j=0; j < pcSlice->getSPS()->getNumRowsMinus1()+1; j++) |
---|
| 1013 | { |
---|
| 1014 | uiCummulativeTileWidth = 0; |
---|
| 1015 | for(i=0; i < pcSlice->getSPS()->getNumColumnsMinus1(); i++) |
---|
| 1016 | { |
---|
| 1017 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getSPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getSPS()->getColumnWidth(i) ); |
---|
| 1018 | uiCummulativeTileWidth += pcSlice->getSPS()->getColumnWidth(i); |
---|
| 1019 | } |
---|
| 1020 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getSPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth ); |
---|
| 1021 | } |
---|
[2] | 1022 | |
---|
[56] | 1023 | //set the height for each tile |
---|
| 1024 | for(j=0; j < pcSlice->getSPS()->getNumColumnsMinus1()+1; j++) |
---|
[2] | 1025 | { |
---|
[56] | 1026 | uiCummulativeTileHeight = 0; |
---|
| 1027 | for(i=0; i < pcSlice->getSPS()->getNumRowsMinus1(); i++) |
---|
| 1028 | { |
---|
| 1029 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getSPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getSPS()->getRowHeight(i) ); |
---|
| 1030 | uiCummulativeTileHeight += pcSlice->getSPS()->getRowHeight(i); |
---|
| 1031 | } |
---|
| 1032 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getSPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight ); |
---|
| 1033 | } |
---|
| 1034 | } |
---|
| 1035 | } |
---|
[2] | 1036 | |
---|
[56] | 1037 | pcPic->getPicSym()->xInitTiles(); |
---|
[2] | 1038 | |
---|
[56] | 1039 | //generate the Coding Order Map and Inverse Coding Order Map |
---|
| 1040 | UInt uiEncCUAddr; |
---|
| 1041 | for(i=0, uiEncCUAddr=0; i<pcPic->getPicSym()->getNumberOfCUsInFrame(); i++, uiEncCUAddr = pcPic->getPicSym()->xCalculateNxtCUAddr(uiEncCUAddr)) |
---|
| 1042 | { |
---|
| 1043 | pcPic->getPicSym()->setCUOrderMap(i, uiEncCUAddr); |
---|
| 1044 | pcPic->getPicSym()->setInverseCUOrderMap(uiEncCUAddr, i); |
---|
| 1045 | } |
---|
| 1046 | pcPic->getPicSym()->setCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
| 1047 | pcPic->getPicSym()->setInverseCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
| 1048 | |
---|
| 1049 | //convert the start and end CU addresses of the slice and entropy slice into encoding order |
---|
| 1050 | pcSlice->setEntropySliceCurStartCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getEntropySliceCurStartCUAddr()) ); |
---|
| 1051 | pcSlice->setEntropySliceCurEndCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getEntropySliceCurEndCUAddr()) ); |
---|
| 1052 | if(pcSlice->isNextSlice()) |
---|
| 1053 | { |
---|
| 1054 | pcSlice->setSliceCurStartCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurStartCUAddr())); |
---|
| 1055 | pcSlice->setSliceCurEndCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurEndCUAddr())); |
---|
| 1056 | } |
---|
| 1057 | |
---|
| 1058 | if (m_bFirstSliceInPicture) |
---|
| 1059 | { |
---|
| 1060 | if(pcPic->getNumAllocatedSlice() != 1) |
---|
| 1061 | { |
---|
| 1062 | pcPic->clearSliceBuffer(); |
---|
| 1063 | } |
---|
| 1064 | } |
---|
| 1065 | else |
---|
| 1066 | { |
---|
| 1067 | pcPic->allocateNewSlice(); |
---|
| 1068 | } |
---|
| 1069 | assert(pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
| 1070 | m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx); |
---|
| 1071 | pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx); |
---|
| 1072 | |
---|
| 1073 | pcPic->setTLayer(nalu.m_temporalId); |
---|
| 1074 | |
---|
| 1075 | if (bNextSlice) |
---|
| 1076 | { |
---|
| 1077 | pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_cListPic); |
---|
| 1078 | |
---|
| 1079 | if ( !pcSlice->getPPS()->getEnableTMVPFlag() && pcPic->getTLayer() == 0 ) |
---|
| 1080 | { |
---|
| 1081 | pcSlice->decodingMarkingForNoTMVP( m_cListPic, pcSlice->getPOC() ); |
---|
| 1082 | } |
---|
| 1083 | |
---|
| 1084 | // Set reference list |
---|
[210] | 1085 | #if !QC_MVHEVC_B0046 |
---|
[77] | 1086 | #if VIDYO_VPS_INTEGRATION |
---|
| 1087 | pcSlice->setViewId( pcSlice->getVPS()->getViewId(nalu.m_layerId) ); |
---|
| 1088 | pcSlice->setIsDepth( pcSlice->getVPS()->getDepthFlag(nalu.m_layerId) ); |
---|
| 1089 | #else |
---|
[56] | 1090 | pcSlice->setViewId(m_viewId); |
---|
| 1091 | pcSlice->setIsDepth(m_isDepth); |
---|
[77] | 1092 | #endif |
---|
[210] | 1093 | #endif |
---|
[56] | 1094 | |
---|
[21] | 1095 | #if SONY_COLPIC_AVAILABILITY |
---|
[77] | 1096 | #if VIDYO_VPS_INTEGRATION |
---|
| 1097 | pcSlice->setViewOrderIdx( pcSlice->getVPS()->getViewOrderIdx(nalu.m_layerId) ); |
---|
| 1098 | #else |
---|
[56] | 1099 | pcSlice->setViewOrderIdx( pcPic->getViewOrderIdx() ); |
---|
[21] | 1100 | #endif |
---|
[77] | 1101 | #endif |
---|
[21] | 1102 | |
---|
[56] | 1103 | assert( m_tAppDecTop != NULL ); |
---|
| 1104 | TComPic * const pcTexturePic = m_isDepth ? m_tAppDecTop->getPicFromView( m_viewId, pcSlice->getPOC(), false ) : NULL; |
---|
[210] | 1105 | |
---|
| 1106 | #if FLEX_CODING_ORDER_M23723 |
---|
| 1107 | if (pcTexturePic != NULL) |
---|
| 1108 | { |
---|
| 1109 | assert( !m_isDepth || pcTexturePic != NULL ); |
---|
| 1110 | pcSlice->setTexturePic( pcTexturePic ); |
---|
| 1111 | } |
---|
| 1112 | #else |
---|
[56] | 1113 | assert( !m_isDepth || pcTexturePic != NULL ); |
---|
| 1114 | pcSlice->setTexturePic( pcTexturePic ); |
---|
[210] | 1115 | #endif |
---|
[2] | 1116 | |
---|
[210] | 1117 | |
---|
[56] | 1118 | std::vector<TComPic*> apcInterViewRefPics = m_tAppDecTop->getInterViewRefPics( m_viewId, pcSlice->getPOC(), m_isDepth, pcSlice->getSPS() ); |
---|
| 1119 | pcSlice->setRefPicListMvc( m_cListPic, apcInterViewRefPics ); |
---|
[2] | 1120 | |
---|
[56] | 1121 | // For generalized B |
---|
| 1122 | // note: maybe not existed case (always L0 is copied to L1 if L1 is empty) |
---|
| 1123 | if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0) |
---|
| 1124 | { |
---|
| 1125 | Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0); |
---|
| 1126 | pcSlice->setNumRefIdx ( REF_PIC_LIST_1, iNumRefIdx ); |
---|
[2] | 1127 | |
---|
[56] | 1128 | for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++) |
---|
| 1129 | { |
---|
| 1130 | pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx); |
---|
| 1131 | } |
---|
| 1132 | } |
---|
| 1133 | if (pcSlice->isInterB()) |
---|
| 1134 | { |
---|
| 1135 | Bool bLowDelay = true; |
---|
| 1136 | Int iCurrPOC = pcSlice->getPOC(); |
---|
| 1137 | Int iRefIdx = 0; |
---|
| 1138 | |
---|
| 1139 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++) |
---|
| 1140 | { |
---|
| 1141 | if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC ) |
---|
[21] | 1142 | { |
---|
[56] | 1143 | bLowDelay = false; |
---|
[21] | 1144 | } |
---|
[2] | 1145 | } |
---|
[56] | 1146 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++) |
---|
| 1147 | { |
---|
| 1148 | if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC ) |
---|
| 1149 | { |
---|
| 1150 | bLowDelay = false; |
---|
| 1151 | } |
---|
| 1152 | } |
---|
[2] | 1153 | |
---|
[56] | 1154 | pcSlice->setCheckLDC(bLowDelay); |
---|
| 1155 | } |
---|
| 1156 | |
---|
| 1157 | //--------------- |
---|
| 1158 | pcSlice->setRefPOCnViewListsMvc(); |
---|
| 1159 | |
---|
| 1160 | if(!pcSlice->getRefPicListModificationFlagLC()) |
---|
| 1161 | { |
---|
| 1162 | pcSlice->generateCombinedList(); |
---|
| 1163 | } |
---|
| 1164 | |
---|
| 1165 | if( pcSlice->getRefPicListCombinationFlag() && pcSlice->getPPS()->getWPBiPredIdc()==1 && pcSlice->getSliceType()==B_SLICE ) |
---|
| 1166 | { |
---|
| 1167 | pcSlice->setWpParamforLC(); |
---|
| 1168 | } |
---|
| 1169 | pcSlice->setNoBackPredFlag( false ); |
---|
| 1170 | if ( pcSlice->getSliceType() == B_SLICE && !pcSlice->getRefPicListCombinationFlag()) |
---|
| 1171 | { |
---|
| 1172 | if ( pcSlice->getNumRefIdx(RefPicList( 0 ) ) == pcSlice->getNumRefIdx(RefPicList( 1 ) ) ) |
---|
[2] | 1173 | { |
---|
[56] | 1174 | pcSlice->setNoBackPredFlag( true ); |
---|
| 1175 | for ( i=0; i < pcSlice->getNumRefIdx(RefPicList( 1 ) ); i++ ) |
---|
[2] | 1176 | { |
---|
[56] | 1177 | if ( pcSlice->getRefPOC(RefPicList(1), i) != pcSlice->getRefPOC(RefPicList(0), i) ) |
---|
| 1178 | { |
---|
| 1179 | pcSlice->setNoBackPredFlag( false ); |
---|
| 1180 | break; |
---|
| 1181 | } |
---|
[2] | 1182 | } |
---|
| 1183 | } |
---|
[56] | 1184 | } |
---|
| 1185 | } |
---|
| 1186 | |
---|
| 1187 | pcPic->setCurrSliceIdx(m_uiSliceIdx); |
---|
| 1188 | if(pcSlice->getSPS()->getScalingListFlag()) |
---|
| 1189 | { |
---|
| 1190 | if(pcSlice->getAPS()->getScalingListEnabled()) |
---|
| 1191 | { |
---|
| 1192 | pcSlice->setScalingList ( pcSlice->getAPS()->getScalingList() ); |
---|
| 1193 | if(pcSlice->getScalingList()->getScalingListPresentFlag()) |
---|
[2] | 1194 | { |
---|
[56] | 1195 | pcSlice->setDefaultScalingList(); |
---|
[2] | 1196 | } |
---|
[56] | 1197 | m_cTrQuant.setScalingListDec(pcSlice->getScalingList()); |
---|
| 1198 | } |
---|
| 1199 | m_cTrQuant.setUseScalingList(true); |
---|
| 1200 | } |
---|
| 1201 | else |
---|
| 1202 | { |
---|
| 1203 | m_cTrQuant.setFlatScalingList(); |
---|
| 1204 | m_cTrQuant.setUseScalingList(false); |
---|
| 1205 | } |
---|
[2] | 1206 | |
---|
[56] | 1207 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
| 1208 | if( m_parameterSetManagerDecoder.getPrefetchedSPS(0)->getUseDMM() && g_aacWedgeLists.empty() ) |
---|
| 1209 | { |
---|
| 1210 | initWedgeLists(); |
---|
| 1211 | } |
---|
[2] | 1212 | #endif |
---|
| 1213 | |
---|
[231] | 1214 | #if MERL_VSP_C0152 // set BW LUT |
---|
| 1215 | if( m_pcCamParsCollector ) // Initialize the LUT elements |
---|
| 1216 | { |
---|
| 1217 | m_pcCamParsCollector->setSlice( pcSlice ); |
---|
| 1218 | } |
---|
| 1219 | if( pcSlice->getViewId() !=0 ) |
---|
| 1220 | { |
---|
| 1221 | TComPic* pcBaseTxtPic = m_tAppDecTop->getPicFromView( 0, pcSlice->getPOC(), false ); // get base view reconstructed texture |
---|
| 1222 | TComPic* pcBaseDepthPic = m_tAppDecTop->getPicFromView( 0, pcSlice->getPOC(), true ); // get base view reconstructed depth |
---|
| 1223 | pcSlice->setRefPicBaseTxt(pcBaseTxtPic); |
---|
| 1224 | pcSlice->setRefPicBaseDepth(pcBaseDepthPic); |
---|
| 1225 | } |
---|
| 1226 | getTAppDecTop()->setBWVSPLUT( pcSlice, pcSlice->getViewId(), pcSlice->getPOC() ); // get the LUT for backward warping |
---|
| 1227 | #endif |
---|
| 1228 | |
---|
[56] | 1229 | // Decode a picture |
---|
| 1230 | m_cGopDecoder.decompressGop(nalu.m_Bitstream, pcPic, false); |
---|
[42] | 1231 | |
---|
[210] | 1232 | #if QC_IV_AS_LT_B0046 |
---|
| 1233 | std::vector<TComPic*> apcInterViewRefPics = m_tAppDecTop->getInterViewRefPics( m_viewId, pcSlice->getPOC(), m_isDepth, pcSlice->getSPS() ); |
---|
| 1234 | for( Int k = 0; k < apcInterViewRefPics.size(); k++ ) |
---|
| 1235 | { |
---|
| 1236 | TComPic* pcPicIv = apcInterViewRefPics[k]; |
---|
| 1237 | pcPicIv->setIsLongTerm( 0 ); |
---|
| 1238 | } |
---|
| 1239 | #endif |
---|
[57] | 1240 | if( m_pcCamParsCollector ) |
---|
| 1241 | { |
---|
| 1242 | m_pcCamParsCollector->setSlice( pcSlice ); |
---|
| 1243 | } |
---|
| 1244 | |
---|
[56] | 1245 | m_bFirstSliceInPicture = false; |
---|
| 1246 | m_uiSliceIdx++; |
---|
| 1247 | |
---|
| 1248 | return false; |
---|
| 1249 | } |
---|
| 1250 | |
---|
[210] | 1251 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
[77] | 1252 | Void TDecTop::xDecodeVPS() |
---|
| 1253 | { |
---|
| 1254 | TComVPS* vps = new TComVPS(); |
---|
| 1255 | |
---|
| 1256 | m_cEntropyDecoder.decodeVPS( vps ); |
---|
| 1257 | m_parameterSetManagerDecoder.storePrefetchedVPS(vps); |
---|
[210] | 1258 | #if !QC_MVHEVC_B0046 |
---|
[77] | 1259 | getTAppDecTop()->getVPSAccess()->addVPS( vps ); |
---|
[210] | 1260 | #endif |
---|
[77] | 1261 | } |
---|
| 1262 | #endif |
---|
[56] | 1263 | |
---|
| 1264 | Void TDecTop::xDecodeSPS() |
---|
| 1265 | { |
---|
| 1266 | TComSPS* sps = new TComSPS(); |
---|
| 1267 | #if RPS_IN_SPS |
---|
| 1268 | TComRPSList* rps = new TComRPSList(); |
---|
| 1269 | sps->setRPSList(rps); |
---|
| 1270 | #endif |
---|
| 1271 | #if HHI_MPI |
---|
| 1272 | m_cEntropyDecoder.decodeSPS( sps, m_isDepth ); |
---|
[42] | 1273 | #else |
---|
[56] | 1274 | m_cEntropyDecoder.decodeSPS( sps ); |
---|
[42] | 1275 | #endif |
---|
[56] | 1276 | m_parameterSetManagerDecoder.storePrefetchedSPS(sps); |
---|
| 1277 | #if LCU_SYNTAX_ALF |
---|
| 1278 | m_cAdaptiveLoopFilter.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
[21] | 1279 | #endif |
---|
[56] | 1280 | } |
---|
[2] | 1281 | |
---|
[56] | 1282 | Void TDecTop::xDecodePPS() |
---|
| 1283 | { |
---|
| 1284 | #if !RPS_IN_SPS |
---|
| 1285 | TComRPSList* rps = new TComRPSList(); |
---|
[2] | 1286 | #endif |
---|
[56] | 1287 | TComPPS* pps = new TComPPS(); |
---|
| 1288 | #if !RPS_IN_SPS |
---|
| 1289 | pps->setRPSList(rps); |
---|
| 1290 | #endif |
---|
| 1291 | #if TILES_OR_ENTROPY_SYNC_IDC |
---|
| 1292 | m_cEntropyDecoder.decodePPS( pps, &m_parameterSetManagerDecoder ); |
---|
[2] | 1293 | #else |
---|
[56] | 1294 | m_cEntropyDecoder.decodePPS( pps ); |
---|
[2] | 1295 | #endif |
---|
[56] | 1296 | m_parameterSetManagerDecoder.storePrefetchedPPS( pps ); |
---|
[2] | 1297 | |
---|
[56] | 1298 | //!!!KS: Activate parameter sets for parsing APS (unless dependency is resolved) |
---|
| 1299 | m_apcSlicePilot->setPPSId(pps->getPPSId()); |
---|
| 1300 | xActivateParameterSets(); |
---|
| 1301 | m_apcSlicePilot->initTiles(); |
---|
| 1302 | } |
---|
[2] | 1303 | |
---|
[56] | 1304 | Void TDecTop::xDecodeAPS() |
---|
| 1305 | { |
---|
| 1306 | TComAPS *aps = new TComAPS(); |
---|
| 1307 | allocAPS (aps); |
---|
| 1308 | decodeAPS(aps); |
---|
| 1309 | m_parameterSetManagerDecoder.storePrefetchedAPS(aps); |
---|
| 1310 | } |
---|
[2] | 1311 | |
---|
[56] | 1312 | Void TDecTop::xDecodeSEI() |
---|
| 1313 | { |
---|
| 1314 | m_SEIs = new SEImessages; |
---|
| 1315 | m_cEntropyDecoder.decodeSEI(*m_SEIs); |
---|
| 1316 | } |
---|
[2] | 1317 | |
---|
[56] | 1318 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
| 1319 | { |
---|
| 1320 | // Initialize entropy decoder |
---|
| 1321 | m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); |
---|
| 1322 | m_cEntropyDecoder.setBitstream (nalu.m_Bitstream); |
---|
[2] | 1323 | |
---|
[56] | 1324 | switch (nalu.m_nalUnitType) |
---|
| 1325 | { |
---|
[210] | 1326 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
[77] | 1327 | case NAL_UNIT_VPS: |
---|
| 1328 | xDecodeVPS(); |
---|
| 1329 | return false; |
---|
| 1330 | #endif |
---|
[56] | 1331 | case NAL_UNIT_SPS: |
---|
| 1332 | xDecodeSPS(); |
---|
| 1333 | return false; |
---|
| 1334 | |
---|
| 1335 | case NAL_UNIT_PPS: |
---|
| 1336 | xDecodePPS(); |
---|
| 1337 | return false; |
---|
| 1338 | case NAL_UNIT_APS: |
---|
| 1339 | xDecodeAPS(); |
---|
| 1340 | return false; |
---|
| 1341 | |
---|
| 1342 | case NAL_UNIT_SEI: |
---|
| 1343 | xDecodeSEI(); |
---|
| 1344 | return false; |
---|
| 1345 | |
---|
| 1346 | case NAL_UNIT_CODED_SLICE: |
---|
| 1347 | case NAL_UNIT_CODED_SLICE_IDR: |
---|
| 1348 | #if H0566_TLA |
---|
[210] | 1349 | #if !QC_REM_IDV_B0046 |
---|
[56] | 1350 | case NAL_UNIT_CODED_SLICE_IDV: |
---|
[210] | 1351 | #endif |
---|
[56] | 1352 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
| 1353 | case NAL_UNIT_CODED_SLICE_TLA: |
---|
| 1354 | #else |
---|
| 1355 | case NAL_UNIT_CODED_SLICE_CDR: |
---|
| 1356 | #endif |
---|
| 1357 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay); |
---|
[2] | 1358 | break; |
---|
| 1359 | default: |
---|
| 1360 | assert (1); |
---|
| 1361 | } |
---|
| 1362 | |
---|
| 1363 | return false; |
---|
| 1364 | } |
---|
| 1365 | |
---|
[210] | 1366 | #if QC_MVHEVC_B0046 |
---|
| 1367 | Void TDecTop::xCopyVPS( TComVPS* pVPSV0 ) |
---|
| 1368 | { |
---|
| 1369 | m_parameterSetManagerDecoder.storePrefetchedVPS(pVPSV0); |
---|
| 1370 | } |
---|
| 1371 | |
---|
| 1372 | Void TDecTop::xCopySPS( TComSPS* pSPSV0 ) |
---|
| 1373 | { |
---|
| 1374 | TComSPS* sps = new TComSPS(); |
---|
| 1375 | sps = pSPSV0; |
---|
| 1376 | m_parameterSetManagerDecoder.storePrefetchedSPS(sps); |
---|
| 1377 | #if LCU_SYNTAX_ALF |
---|
| 1378 | m_cAdaptiveLoopFilter.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
| 1379 | #endif |
---|
| 1380 | } |
---|
| 1381 | |
---|
| 1382 | Void TDecTop::xCopyPPS(TComPPS* pPPSV0 ) |
---|
| 1383 | { |
---|
| 1384 | m_parameterSetManagerDecoder.storePrefetchedPPS( pPPSV0 ); |
---|
| 1385 | |
---|
| 1386 | //!!!KS: Activate parameter sets for parsing APS (unless dependency is resolved) |
---|
| 1387 | m_apcSlicePilot->setPPSId(pPPSV0->getPPSId()); |
---|
| 1388 | xActivateParameterSets(); |
---|
| 1389 | m_apcSlicePilot->initTiles(); |
---|
| 1390 | } |
---|
| 1391 | #endif |
---|
[2] | 1392 | /** Function for checking if picture should be skipped because of random access |
---|
| 1393 | * \param iSkipFrame skip frame counter |
---|
| 1394 | * \param iPOCLastDisplay POC of last picture displayed |
---|
| 1395 | * \returns true if the picture shold be skipped in the random access. |
---|
| 1396 | * This function checks the skipping of pictures in the case of -s option random access. |
---|
| 1397 | * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped. |
---|
| 1398 | * It also checks the type of Nal unit type at the random access point. |
---|
[56] | 1399 | * If the random access point is CRA, pictures with POC equal to or greater than the CRA POC are decoded. |
---|
[2] | 1400 | * If the random access point is IDR all pictures after the random access point are decoded. |
---|
[56] | 1401 | * If the random access point is not IDR or CRA, a warning is issues, and decoding of pictures with POC |
---|
| 1402 | * equal to or greater than the random access point POC is attempted. For non IDR/CRA random |
---|
[2] | 1403 | * access point there is no guarantee that the decoder will not crash. |
---|
| 1404 | */ |
---|
| 1405 | Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
| 1406 | { |
---|
[56] | 1407 | if (iSkipFrame) |
---|
[2] | 1408 | { |
---|
| 1409 | iSkipFrame--; // decrement the counter |
---|
| 1410 | return true; |
---|
| 1411 | } |
---|
[56] | 1412 | else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet. |
---|
[2] | 1413 | { |
---|
[56] | 1414 | #if H0566_TLA |
---|
| 1415 | if( m_apcSlicePilot->getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_CRA ) |
---|
| 1416 | #else |
---|
| 1417 | if( m_apcSlicePilot->getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_CDR ) |
---|
| 1418 | #endif |
---|
[2] | 1419 | { |
---|
[56] | 1420 | m_pocRandomAccess = m_apcSlicePilot->getPOC(); // set the POC random access since we need to skip the reordered pictures in CRA. |
---|
[2] | 1421 | } |
---|
[56] | 1422 | else if( m_apcSlicePilot->getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_IDR ) |
---|
[2] | 1423 | { |
---|
[56] | 1424 | m_pocRandomAccess = 0; // no need to skip the reordered pictures in IDR, they are decodable. |
---|
[2] | 1425 | } |
---|
[56] | 1426 | else |
---|
[2] | 1427 | { |
---|
[56] | 1428 | #if START_DECODING_AT_CRA |
---|
| 1429 | static bool warningMessage = false; |
---|
| 1430 | if(!warningMessage) |
---|
| 1431 | { |
---|
| 1432 | printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture"); |
---|
| 1433 | warningMessage = true; |
---|
| 1434 | } |
---|
| 1435 | return true; |
---|
| 1436 | #else |
---|
[2] | 1437 | printf("\nUnsafe random access point. Decoder may crash."); |
---|
[56] | 1438 | m_pocRandomAccess = 0; |
---|
| 1439 | #endif |
---|
[2] | 1440 | } |
---|
| 1441 | } |
---|
[56] | 1442 | else if (m_apcSlicePilot->getPOC() < m_pocRandomAccess) // skip the reordered pictures if necessary |
---|
[2] | 1443 | { |
---|
| 1444 | iPOCLastDisplay++; |
---|
| 1445 | return true; |
---|
| 1446 | } |
---|
| 1447 | // if we reach here, then the picture is not skipped. |
---|
[56] | 1448 | return false; |
---|
[2] | 1449 | } |
---|
[56] | 1450 | |
---|
| 1451 | Void TDecTop::allocAPS (TComAPS* pAPS) |
---|
| 1452 | { |
---|
| 1453 | // we don't know the SPS before it has been activated. These fields could exist |
---|
| 1454 | // depending on the corresponding flags in the APS, but SAO/ALF allocation functions will |
---|
| 1455 | // have to be moved for that |
---|
| 1456 | pAPS->createScalingList(); |
---|
| 1457 | pAPS->createSaoParam(); |
---|
| 1458 | m_cSAO.allocSaoParam(pAPS->getSaoParam()); |
---|
| 1459 | pAPS->createAlfParam(); |
---|
| 1460 | #if !LCU_SYNTAX_ALF |
---|
| 1461 | m_cAdaptiveLoopFilter.allocALFParam(pAPS->getAlfParam()); |
---|
[2] | 1462 | #endif |
---|
[56] | 1463 | } |
---|
[2] | 1464 | |
---|
[56] | 1465 | //! \} |
---|