Coverage Report

Created: 2026-05-30 06:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/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
  std::vector<NalUnitType>  m_pictureUnitNals;
100
  std::list<InputNALUnit>   m_pictureSeiNalus;
101
  std::list<InputNALUnit>   m_prefixSEINALUs;   /// Buffered up prefix SEI NAL Units.
102
103
  std::ostream*             m_pDecodedSEIOutputStream = nullptr;
104
105
  seiMessages               m_seiMessageList;       ///< List of SEI messages that have been received before the first slice and between slices,
106
                                                    ///< excluding prefix SEIs...
107
108
  HRD                       m_HRD;
109
110
  ThreadPool*               m_threadPool = nullptr;
111
112
  // functional classes
113
  HLSyntaxReader            m_HLSReader;
114
  SEIReader                 m_seiReader;
115
  DecSlice                  m_cSliceDecoder;
116
117
  DecLib&                   m_decLib;
118
  ParameterSetManager       m_parameterSetManager;   // storage for parameter sets
119
  PicListManager&           m_picListManager;
120
121
  std::shared_ptr<PicHeader> m_picHeader;            // picture header
122
123
  unsigned int              m_numDecThreads   = 0;
124
  unsigned int              m_parseFrameDelay = 0;
125
  PicList                   m_parseFrameList;
126
  PicList                   m_dpbReferencePics;   // this mirrors the reference pictures from the DPB but is only used for parsing
127
  std::unordered_set<int>   m_tmpSeenPocs;
128
  int                       m_maxPicReconSkip = 1;
129
  ErrHandlingFlags          m_errHandlingFlags = ERR_HANDLING_OFF;
130
131
  CUChunkCache              m_cuChunkCache;
132
  TUChunkCache              m_tuChunkCache;
133
134
public:
135
0
  DecLibParser( DecLib& decLib, PicListManager& picListManager ) : m_decLib( decLib ), m_picListManager( picListManager ) {}
136
  ~DecLibParser();
137
138
  void create                   ( ThreadPool* tp, int parserFrameDelay, int numReconInst, int numDecThreads, ErrHandlingFlags errHandlingFlags );
139
  void destroy                  ();
140
141
#if 0
142
  void fillMissingPicBuf        ( Picture* pcPic, bool copyClosest );
143
#endif
144
145
  bool     parse                ( InputNALUnit& nalu );
146
  Picture* getNextDecodablePicture();
147
148
  void checkNoOutputPriorPics   ();
149
0
  void setNoOutputPriorPicsFlag (bool val)              { m_isNoOutputPriorPics = val; }
150
0
  bool getNoOutputPriorPicsFlag () const                { return m_isNoOutputPriorPics; }
151
152
0
  void setDecodedSEIMessageOutputStream( std::ostream* pOpStream ) { m_pDecodedSEIOutputStream = pOpStream; }
153
154
  void checkAPSInPictureUnit    ();
155
0
  void resetPictureUnitNals     ()                      { m_pictureUnitNals.clear(); }
156
157
0
  const ParameterSetManager& getParameterSetManager() const { return m_parameterSetManager; }
158
159
private:
160
  bool xDecodeSliceHead( InputNALUnit& nalu );
161
  bool xDecodeSliceMain( InputNALUnit& nalu );
162
163
  void xActivateParameterSets( const int layerId );
164
  void prepareUnavailablePicture( bool isLost, const PPS* pps, int iUnavailablePoc, const int layerId, const bool longTermFlag, const int temporalId );
165
  void applyReferencePictureListBasedMarking( Slice* currSlice, const int layerId, const PPS& pps );
166
167
  void xParsePrefixSEImessages();
168
  void xParsePrefixSEIsForUnknownVCLNal();
169
170
  void xDecodePicHeader       ( InputNALUnit& nalu );
171
  void xDecodeVPS             ( InputNALUnit& nalu );
172
  void xDecodeDCI             ( InputNALUnit& nalu );
173
  void xDecodeSPS             ( InputNALUnit& nalu );
174
  void xDecodePPS             ( InputNALUnit& nalu );
175
  void xDecodeAPS             ( InputNALUnit& nalu );
176
  void xUpdatePreviousTid0POC ( Slice* pSlice );
177
178
  bool isRandomAccessSkipPicture();
179
  void xCheckMixedNalUnit     ( Slice* pcSlice, const InputNALUnit& nalu );
180
181
  void waitForPicsToFinishParsing( const std::vector<Picture*>& refPics );
182
};
183
184
}