[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 | * |
---|
[872] | 6 | * Copyright (c) 2010-2014, 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 | */ |
---|
[2] | 33 | |
---|
| 34 | /** \file TDecTop.h |
---|
| 35 | \brief decoder class (header) |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #ifndef __TDECTOP__ |
---|
| 39 | #define __TDECTOP__ |
---|
| 40 | |
---|
[56] | 41 | #include "TLibCommon/CommonDef.h" |
---|
| 42 | #include "TLibCommon/TComList.h" |
---|
| 43 | #include "TLibCommon/TComPicYuv.h" |
---|
| 44 | #include "TLibCommon/TComPic.h" |
---|
| 45 | #include "TLibCommon/TComTrQuant.h" |
---|
| 46 | #include "TLibCommon/SEI.h" |
---|
[2] | 47 | |
---|
| 48 | #include "TDecGop.h" |
---|
| 49 | #include "TDecEntropy.h" |
---|
| 50 | #include "TDecSbac.h" |
---|
| 51 | #include "TDecCAVLC.h" |
---|
[608] | 52 | #include "SEIread.h" |
---|
[2] | 53 | |
---|
[56] | 54 | struct InputNALUnit; |
---|
| 55 | |
---|
| 56 | //! \ingroup TLibDecoder |
---|
| 57 | //! \{ |
---|
| 58 | |
---|
[2] | 59 | // ==================================================================================================================== |
---|
| 60 | // Class definition |
---|
| 61 | // ==================================================================================================================== |
---|
| 62 | |
---|
[608] | 63 | #if H_MV |
---|
[56] | 64 | class TAppDecTop; |
---|
[608] | 65 | #endif |
---|
| 66 | #if H_3D |
---|
[2] | 67 | class CamParsCollector |
---|
| 68 | { |
---|
| 69 | public: |
---|
| 70 | CamParsCollector (); |
---|
| 71 | ~CamParsCollector (); |
---|
| 72 | |
---|
[872] | 73 | #if FIX_CAM_PARS_COLLECTOR |
---|
| 74 | Void init ( FILE* pCodedScaleOffsetFile, TComVPS* vps ); |
---|
| 75 | #else |
---|
[2] | 76 | Void init ( FILE* pCodedScaleOffsetFile ); |
---|
[872] | 77 | #endif |
---|
| 78 | |
---|
[2] | 79 | Void uninit (); |
---|
| 80 | Void setSlice ( TComSlice* pcSlice ); |
---|
| 81 | |
---|
[608] | 82 | Bool isInitialized() const { return m_bInitialized; } |
---|
| 83 | Int**** getBaseViewShiftLUTI() { return m_aiBaseViewShiftLUT; } |
---|
[57] | 84 | |
---|
[773] | 85 | #if H_3D_IV_MERGE |
---|
[724] | 86 | Void copyCamParamForSlice( TComSlice* pcSlice ); |
---|
| 87 | #endif |
---|
| 88 | |
---|
[833] | 89 | #if MTK_DDD_G0063 |
---|
| 90 | Int getCodedScale( Int iBaseView, Int iCureView){ return m_aaiCodedScale[ iBaseView ][ iCureView ];} |
---|
| 91 | Int getCodedOffset( Int iBaseView, Int iCureView){ return m_aaiCodedOffset[ iBaseView ][ iCureView ];} |
---|
[872] | 92 | UInt getCamParsCodedPrecision(){ return m_vps->getCamParPrecision(); } |
---|
[833] | 93 | #endif |
---|
| 94 | |
---|
[2] | 95 | private: |
---|
[872] | 96 | #if FIX_CAM_PARS_COLLECTOR |
---|
| 97 | Void xResetReceivedIdc( Bool overWriteFlag ); |
---|
| 98 | #else |
---|
[2] | 99 | Bool xIsComplete (); |
---|
[872] | 100 | #endif |
---|
[2] | 101 | Void xOutput ( Int iPOC ); |
---|
| 102 | |
---|
| 103 | private: |
---|
| 104 | Bool m_bInitialized; |
---|
| 105 | FILE* m_pCodedScaleOffsetFile; |
---|
| 106 | |
---|
| 107 | Int** m_aaiCodedOffset; |
---|
| 108 | Int** m_aaiCodedScale; |
---|
[872] | 109 | |
---|
| 110 | #if !FIX_CAM_PARS_COLLECTOR |
---|
[608] | 111 | Int* m_aiViewId; |
---|
[872] | 112 | #else |
---|
| 113 | TComVPS* m_vps; |
---|
| 114 | Int** m_receivedIdc; |
---|
| 115 | Int m_uiMaxViewIndex; |
---|
| 116 | Int m_lastPoc; |
---|
| 117 | Int m_firstReceivedPoc; |
---|
| 118 | #endif |
---|
[608] | 119 | |
---|
[872] | 120 | |
---|
| 121 | #if !FIX_CAM_PARS_COLLECTOR |
---|
[608] | 122 | Bool* m_bViewReceived; |
---|
[2] | 123 | UInt m_uiCamParsCodedPrecision; |
---|
[872] | 124 | #endif |
---|
[2] | 125 | Bool m_bCamParsVaryOverTime; |
---|
[872] | 126 | #if !FIX_CAM_PARS_COLLECTOR |
---|
[608] | 127 | Int m_iLastViewIndex; |
---|
[2] | 128 | Int m_iLastPOC; |
---|
[608] | 129 | UInt m_uiMaxViewIndex; |
---|
[872] | 130 | #endif |
---|
[296] | 131 | |
---|
[608] | 132 | |
---|
[296] | 133 | UInt m_uiBitDepthForLUT; |
---|
| 134 | UInt m_iLog2Precision; |
---|
| 135 | UInt m_uiInputBitDepth; |
---|
[608] | 136 | |
---|
[296] | 137 | // look-up tables |
---|
| 138 | Double**** m_adBaseViewShiftLUT; ///< Disparity LUT |
---|
| 139 | Int**** m_aiBaseViewShiftLUT; ///< Disparity LUT |
---|
| 140 | Void xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT); |
---|
| 141 | Void xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT); |
---|
| 142 | template<class T> Void xDeleteArray ( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 ); |
---|
| 143 | template<class T> Void xDeleteArray ( T*& rpt, UInt uiSize1, UInt uiSize2 ); |
---|
| 144 | template<class T> Void xDeleteArray ( T*& rpt, UInt uiSize ); |
---|
| 145 | |
---|
[2] | 146 | }; |
---|
| 147 | |
---|
[296] | 148 | template <class T> |
---|
| 149 | Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2, UInt uiSize3 ) |
---|
| 150 | { |
---|
| 151 | if( rpt ) |
---|
| 152 | { |
---|
| 153 | for( UInt uiK = 0; uiK < uiSize1; uiK++ ) |
---|
| 154 | { |
---|
| 155 | for( UInt uiL = 0; uiL < uiSize2; uiL++ ) |
---|
| 156 | { |
---|
| 157 | for( UInt uiM = 0; uiM < uiSize3; uiM++ ) |
---|
| 158 | { |
---|
| 159 | delete[] rpt[ uiK ][ uiL ][ uiM ]; |
---|
| 160 | } |
---|
| 161 | delete[] rpt[ uiK ][ uiL ]; |
---|
| 162 | } |
---|
| 163 | delete[] rpt[ uiK ]; |
---|
| 164 | } |
---|
| 165 | delete[] rpt; |
---|
| 166 | } |
---|
| 167 | rpt = NULL; |
---|
| 168 | }; |
---|
| 169 | |
---|
| 170 | |
---|
| 171 | template <class T> |
---|
| 172 | Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize1, UInt uiSize2 ) |
---|
| 173 | { |
---|
| 174 | if( rpt ) |
---|
| 175 | { |
---|
| 176 | for( UInt uiK = 0; uiK < uiSize1; uiK++ ) |
---|
| 177 | { |
---|
| 178 | for( UInt uiL = 0; uiL < uiSize2; uiL++ ) |
---|
| 179 | { |
---|
| 180 | delete[] rpt[ uiK ][ uiL ]; |
---|
| 181 | } |
---|
| 182 | delete[] rpt[ uiK ]; |
---|
| 183 | } |
---|
| 184 | delete[] rpt; |
---|
| 185 | } |
---|
| 186 | rpt = NULL; |
---|
| 187 | }; |
---|
| 188 | |
---|
| 189 | |
---|
| 190 | template <class T> |
---|
| 191 | Void CamParsCollector::xDeleteArray( T*& rpt, UInt uiSize ) |
---|
| 192 | { |
---|
| 193 | if( rpt ) |
---|
| 194 | { |
---|
| 195 | for( UInt uiK = 0; uiK < uiSize; uiK++ ) |
---|
| 196 | { |
---|
| 197 | delete[] rpt[ uiK ]; |
---|
| 198 | } |
---|
| 199 | delete[] rpt; |
---|
| 200 | } |
---|
| 201 | rpt = NULL; |
---|
| 202 | }; |
---|
| 203 | |
---|
[608] | 204 | #endif //H_3D |
---|
[2] | 205 | /// decoder class |
---|
| 206 | class TDecTop |
---|
| 207 | { |
---|
| 208 | private: |
---|
[608] | 209 | Int m_iMaxRefPicNum; |
---|
[56] | 210 | |
---|
[655] | 211 | NalUnitType m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture |
---|
[56] | 212 | Int m_pocCRA; ///< POC number of the latest CRA picture |
---|
| 213 | Int m_pocRandomAccess; ///< POC number of the random access point (the first IDR or CRA picture) |
---|
[2] | 214 | |
---|
| 215 | TComList<TComPic*> m_cListPic; // Dynamic buffer |
---|
[608] | 216 | #if H_MV |
---|
[738] | 217 | Bool* m_layerInitilizedFlag; // initialization Layers |
---|
[608] | 218 | static ParameterSetManagerDecoder m_parameterSetManagerDecoder; // storage for parameter sets |
---|
| 219 | #else |
---|
[56] | 220 | ParameterSetManagerDecoder m_parameterSetManagerDecoder; // storage for parameter sets |
---|
[608] | 221 | #endif |
---|
[2] | 222 | TComSlice* m_apcSlicePilot; |
---|
[56] | 223 | |
---|
[608] | 224 | SEIMessages m_SEIs; ///< List of SEI messages that have been received before the first slice and between slices |
---|
[2] | 225 | |
---|
| 226 | // functional classes |
---|
| 227 | TComPrediction m_cPrediction; |
---|
| 228 | TComTrQuant m_cTrQuant; |
---|
| 229 | TDecGop m_cGopDecoder; |
---|
| 230 | TDecSlice m_cSliceDecoder; |
---|
| 231 | TDecCu m_cCuDecoder; |
---|
| 232 | TDecEntropy m_cEntropyDecoder; |
---|
| 233 | TDecCavlc m_cCavlcDecoder; |
---|
| 234 | TDecSbac m_cSbacDecoder; |
---|
| 235 | TDecBinCABAC m_cBinCABAC; |
---|
[608] | 236 | SEIReader m_seiReader; |
---|
[2] | 237 | TComLoopFilter m_cLoopFilter; |
---|
| 238 | TComSampleAdaptiveOffset m_cSAO; |
---|
[56] | 239 | |
---|
[608] | 240 | Bool isSkipPictureForBLA(Int& iPOCLastDisplay); |
---|
[2] | 241 | Bool isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
| 242 | TComPic* m_pcPic; |
---|
| 243 | UInt m_uiSliceIdx; |
---|
[56] | 244 | Int m_prevPOC; |
---|
[2] | 245 | Bool m_bFirstSliceInPicture; |
---|
| 246 | Bool m_bFirstSliceInSequence; |
---|
[655] | 247 | Bool m_prevSliceSkipped; |
---|
| 248 | Int m_skippedPOC; |
---|
| 249 | |
---|
[608] | 250 | #if H_MV |
---|
| 251 | // For H_MV m_bFirstSliceInSequence indicates first slice in sequence of the particular layer |
---|
| 252 | Int m_layerId; |
---|
[56] | 253 | Int m_viewId; |
---|
[608] | 254 | TComPicLists* m_ivPicLists; |
---|
[622] | 255 | std::vector<TComPic*> m_refPicSetInterLayer0; |
---|
| 256 | std::vector<TComPic*> m_refPicSetInterLayer1; |
---|
[608] | 257 | #if H_3D |
---|
| 258 | Int m_viewIndex; |
---|
[56] | 259 | Bool m_isDepth; |
---|
[57] | 260 | CamParsCollector* m_pcCamParsCollector; |
---|
[608] | 261 | #endif |
---|
| 262 | #endif |
---|
[56] | 263 | |
---|
[2] | 264 | public: |
---|
| 265 | TDecTop(); |
---|
| 266 | virtual ~TDecTop(); |
---|
[56] | 267 | |
---|
[2] | 268 | Void create (); |
---|
| 269 | Void destroy (); |
---|
| 270 | |
---|
[608] | 271 | void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); } |
---|
| 272 | |
---|
| 273 | Void init(); |
---|
| 274 | #if H_MV |
---|
[738] | 275 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer, Bool& sliceSkippedFlag ); |
---|
[608] | 276 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer ); |
---|
| 277 | #else |
---|
[56] | 278 | Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay); |
---|
[608] | 279 | #endif |
---|
[56] | 280 | |
---|
| 281 | Void deletePicBuffer(); |
---|
[608] | 282 | |
---|
| 283 | #if H_MV |
---|
| 284 | Void endPicDecoding(Int& poc, TComList<TComPic*>*& rpcListPic, std::vector<Int>& targetDecLayerIdSet); |
---|
| 285 | #else |
---|
| 286 | Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic); |
---|
[210] | 287 | #endif |
---|
[608] | 288 | |
---|
| 289 | #if H_MV |
---|
| 290 | TComPic* getPic ( Int poc ); |
---|
| 291 | TComList<TComPic*>* getListPic () { return &m_cListPic; } |
---|
| 292 | Void setIvPicLists ( TComPicLists* picLists) { m_ivPicLists = picLists; } |
---|
[738] | 293 | Void setLayerInitilizedFlags( Bool* val ) { m_layerInitilizedFlag = val; } |
---|
| 294 | TComVPS* getPrefetchedVPS () { return m_parameterSetManagerDecoder.getPrefetchedVPS( 0 ); }; //Assuming that currently only one VPS is present. |
---|
[608] | 295 | Int getCurrPoc () { return m_apcSlicePilot->getPOC(); } |
---|
| 296 | Void setLayerId ( Int layer) { m_layerId = layer; } |
---|
| 297 | Int getLayerId () { return m_layerId; } |
---|
| 298 | Void setViewId ( Int viewId ) { m_viewId = viewId; } |
---|
| 299 | Int getViewId () { return m_viewId; } |
---|
| 300 | #if H_3D |
---|
| 301 | Void setViewIndex ( Int viewIndex ) { m_viewIndex = viewIndex; } |
---|
| 302 | Int getViewIndex () { return m_viewIndex; } |
---|
| 303 | Void setIsDepth ( Bool isDepth ) { m_isDepth = isDepth; } |
---|
| 304 | Bool getIsDepth () { return m_isDepth; } |
---|
| 305 | Void setCamParsCollector( CamParsCollector* pcCamParsCollector ) { m_pcCamParsCollector = pcCamParsCollector; } |
---|
[42] | 306 | #endif |
---|
[21] | 307 | #endif |
---|
[2] | 308 | protected: |
---|
| 309 | Void xGetNewPicBuffer (TComSlice* pcSlice, TComPic*& rpcPic); |
---|
[56] | 310 | Void xCreateLostPicture (Int iLostPOC); |
---|
[5] | 311 | |
---|
[56] | 312 | Void xActivateParameterSets(); |
---|
[608] | 313 | #if H_MV |
---|
| 314 | TComPic* xGetPic( Int layerId, Int poc ); |
---|
[738] | 315 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag ); |
---|
[622] | 316 | Void xResetPocInPicBuffer(); |
---|
[738] | 317 | Void xCeckNoClrasOutput(); |
---|
| 318 | |
---|
| 319 | Bool xAllRefLayersInitilized(); |
---|
[608] | 320 | #else |
---|
[56] | 321 | Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay); |
---|
[608] | 322 | #endif |
---|
[100] | 323 | Void xDecodeVPS(); |
---|
[56] | 324 | Void xDecodeSPS(); |
---|
| 325 | Void xDecodePPS(); |
---|
[608] | 326 | Void xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ); |
---|
[56] | 327 | |
---|
[2] | 328 | };// END CLASS DEFINITION TDecTop |
---|
| 329 | |
---|
| 330 | |
---|
[56] | 331 | //! \} |
---|
| 332 | |
---|
[2] | 333 | #endif // __TDECTOP__ |
---|
| 334 | |
---|