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