Coverage Report

Created: 2026-04-01 07:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vvdec/source/Lib/DecoderLib/DecLibParser.h
Line
Count
Source
1
/* -----------------------------------------------------------------------------
2
The copyright in this software is being made available under the Clear BSD
3
License, included below. No patent rights, trademark rights and/or 
4
other Intellectual Property Rights other than the copyrights concerning 
5
the Software are granted under this license.
6
7
The Clear BSD License
8
9
Copyright (c) 2018-2026, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. & The VVdeC Authors.
10
All rights reserved.
11
12
Redistribution and use in source and binary forms, with or without modification,
13
are permitted (subject to the limitations in the disclaimer below) provided that
14
the following conditions are met:
15
16
     * Redistributions of source code must retain the above copyright notice,
17
     this list of conditions and the following disclaimer.
18
19
     * Redistributions in binary form must reproduce the above copyright
20
     notice, this list of conditions and the following disclaimer in the
21
     documentation and/or other materials provided with the distribution.
22
23
     * Neither the name of the copyright holder nor the names of its
24
     contributors may be used to endorse or promote products derived from this
25
     software without specific prior written permission.
26
27
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY
28
THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
29
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
31
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
32
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
33
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
34
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
35
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
36
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38
POSSIBILITY OF SUCH DAMAGE.
39
40
41
------------------------------------------------------------------------------------------- */
42
43
#pragma once
44
45
#include "CommonLib/CommonDef.h"
46
#include "CommonLib/Picture.h"
47
48
#include "DecSlice.h"
49
#include "SEIread.h"
50
#include "NALread.h"
51
#include "HLSyntaxReader.h"
52
53
#include "CommonLib/ParameterSetManager.h"
54
55
#include <unordered_set>
56
57
namespace vvdec
58
{
59
60
class InputNALUnit;
61
class ThreadPool;
62
class DecLib;
63
class PicListManager;
64
65
class DecLibParser
66
{
67
private:
68
  NalUnitType m_associatedIRAPType[MAX_VPS_LAYERS];   ///< NAL unit type of the associated IRAP picture
69
  int         m_pocCRA            [MAX_VPS_LAYERS];   ///< POC number of the latest CRA picture
70
  int         m_pocRandomAccess      = MAX_INT;       ///< POC number of the random access point (the first IDR or CRA picture)
71
  int         m_decodingOrderCounter = 0;
72
  uint32_t    m_prevLayerID          = MAX_INT;
73
74
  int m_prevPOC                   = MAX_INT;
75
  int m_prevTid0POC               = 0;
76
77
  int  m_skippedPOC               = 0;
78
  bool m_warningMessageSkipPicture = false;
79
  bool m_prevSliceSkipped         = false;
80
81
  bool m_bFirstSliceInPicture     = true;
82
  bool m_bFirstSliceInSequence[MAX_VPS_LAYERS] = { true };
83
  bool m_bFirstSliceInBitstream   = true;
84
85
  int      m_lastPOCNoOutputPriorPics                       = -1;
86
  bool     m_isNoOutputPriorPics                            = false;
87
  bool     m_lastNoOutputBeforeRecoveryFlag[MAX_VPS_LAYERS] = { false };   // value of variable NoOutputBeforeRecoveryFlag of the assocated CRA/GDR pic
88
  int      m_gdrRecoveryPointPocVal        [MAX_VPS_LAYERS];
89
  bool     m_gdrRecovered                  [MAX_VPS_LAYERS] = { false };
90
  uint32_t m_uiSliceSegmentIdx    = 0;
91
92
  int m_nonVCLbits                = 0;
93
94
  Picture* m_pcParsePic           = nullptr;
95
  Slice*   m_apcSlicePilot        = nullptr;
96
97
  DCI*     m_dci                  = nullptr;
98
99
  struct AccessUnitPicInfo
100
  {
101
    NalUnitType m_nalUnitType; ///< nal_unit_type
102
    uint32_t    m_temporalId;  ///< temporal_id
103
    uint32_t    m_nuhLayerId;  ///< nuh_layer_id
104
    int         m_POC;
105
  };
106
  std::vector<AccessUnitPicInfo> m_accessUnitPicInfo;
107
108
  struct NalUnitInfo
109
  {
110
    NalUnitType m_nalUnitType; ///< nal_unit_type
111
    uint32_t    m_nuhLayerId;  ///< nuh_layer_id
112
    uint32_t    m_firstCTUinSlice; /// the first CTU in slice, specified with raster scan order ctu address
113
    int         m_POC;             /// the picture order
114
  };
115
  std::vector<NalUnitInfo>  m_nalUnitInfo[MAX_VPS_LAYERS];
116
117
  std::vector<NalUnitType>  m_pictureUnitNals;
118
  std::list<InputNALUnit>   m_pictureSeiNalus;
119
  std::list<InputNALUnit>   m_prefixSEINALUs;   /// Buffered up prefix SEI NAL Units.
120
121
  std::ostream*             m_pDecodedSEIOutputStream = nullptr;
122
123
  seiMessages               m_seiMessageList;       ///< List of SEI messages that have been received before the first slice and between slices,
124
                                                    ///< excluding prefix SEIs...
125
126
  HRD                       m_HRD;
127
128
  ThreadPool*               m_threadPool = nullptr;
129
130
  // functional classes
131
  HLSyntaxReader            m_HLSReader;
132
  SEIReader                 m_seiReader;
133
  DecSlice                  m_cSliceDecoder;
134
135
  DecLib&                   m_decLib;
136
  ParameterSetManager       m_parameterSetManager;   // storage for parameter sets
137
  PicListManager&           m_picListManager;
138
139
  std::shared_ptr<PicHeader> m_picHeader;            // picture header
140
141
  unsigned int              m_numDecThreads   = 0;
142
  unsigned int              m_parseFrameDelay = 0;
143
  PicList                   m_parseFrameList;
144
  PicList                   m_dpbReferencePics;   // this mirrors the reference pictures from the DPB but is only used for parsing
145
  std::unordered_set<int>   m_tmpSeenPocs;
146
  int                       m_maxPicReconSkip = 1;
147
  ErrHandlingFlags          m_errHandlingFlags = ERR_HANDLING_OFF;
148
149
  CUChunkCache              m_cuChunkCache;
150
  TUChunkCache              m_tuChunkCache;
151
152
public:
153
0
  DecLibParser( DecLib& decLib, PicListManager& picListManager ) : m_decLib( decLib ), m_picListManager( picListManager ) {}
154
  ~DecLibParser();
155
156
  void create                   ( ThreadPool* tp, int parserFrameDelay, int numReconInst, int numDecThreads, ErrHandlingFlags errHandlingFlags );
157
  void destroy                  ();
158
159
#if 0
160
  void fillMissingPicBuf        ( Picture* pcPic, bool copyClosest );
161
#endif
162
163
  bool     parse                ( InputNALUnit& nalu );
164
  Picture* getNextDecodablePicture();
165
166
  void checkNoOutputPriorPics   ();
167
0
  void setNoOutputPriorPicsFlag (bool val)              { m_isNoOutputPriorPics = val; }
168
0
  bool getNoOutputPriorPicsFlag () const                { return m_isNoOutputPriorPics; }
169
170
0
  void setDecodedSEIMessageOutputStream( std::ostream* pOpStream ) { m_pDecodedSEIOutputStream = pOpStream; }
171
172
  void checkAPSInPictureUnit    ();
173
0
  void resetPictureUnitNals     ()                      { m_pictureUnitNals.clear(); }
174
175
0
  const ParameterSetManager& getParameterSetManager() const { return m_parameterSetManager; }
176
177
private:
178
  bool xDecodeSliceHead( InputNALUnit& nalu );
179
  bool xDecodeSliceMain( InputNALUnit& nalu );
180
181
  void xActivateParameterSets( const int layerId );
182
  void prepareUnavailablePicture( bool isLost, const PPS* pps, int iUnavailablePoc, const int layerId, const bool longTermFlag, const int temporalId );
183
  void applyReferencePictureListBasedMarking( Slice* currSlice, const int layerId, const PPS& pps );
184
185
  void xParsePrefixSEImessages();
186
  void xParsePrefixSEIsForUnknownVCLNal();
187
188
  void xDecodePicHeader       ( InputNALUnit& nalu );
189
  void xDecodeVPS             ( InputNALUnit& nalu );
190
  void xDecodeDCI             ( InputNALUnit& nalu );
191
  void xDecodeSPS             ( InputNALUnit& nalu );
192
  void xDecodePPS             ( InputNALUnit& nalu );
193
  void xDecodeAPS             ( InputNALUnit& nalu );
194
  void xUpdatePreviousTid0POC ( Slice* pSlice );
195
196
  bool isRandomAccessSkipPicture();
197
  void xCheckMixedNalUnit     ( Slice* pcSlice, const InputNALUnit& nalu );
198
199
  void waitForPicsToFinishParsing( const std::vector<Picture*>& refPics );
200
};
201
202
}