Coverage Report

Created: 2026-10-28 06:18

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::list<InputNALUnit>   m_prefixSEINALUs;   /// Buffered up prefix SEI NAL Units.
100
101
  std::ostream*             m_pDecodedSEIOutputStream = nullptr;
102
103
  seiMessages               m_seiMessageList;       ///< List of SEI messages that have been received before the first slice and between slices,
104
                                                    ///< excluding prefix SEIs...
105
106
  HRD                       m_HRD;
107
108
  ThreadPool*               m_threadPool = nullptr;
109
110
  // functional classes
111
  HLSyntaxReader            m_HLSReader;
112
  SEIReader                 m_seiReader;
113
  DecSlice                  m_cSliceDecoder;
114
115
  DecLib&                   m_decLib;
116
  ParameterSetManager       m_parameterSetManager;   // storage for parameter sets
117
  PicListManager&           m_picListManager;
118
119
  std::shared_ptr<PicHeader> m_picHeader;            // picture header
120
121
  unsigned int              m_numDecThreads   = 0;
122
  unsigned int              m_parseFrameDelay = 0;
123
  PicList                   m_parseFrameList;
124
  PicList                   m_dpbReferencePics;   // this mirrors the reference pictures from the DPB but is only used for parsing
125
  std::unordered_set<int>   m_tmpSeenPocs;
126
  int                       m_maxPicReconSkip = 1;
127
  ErrHandlingFlags          m_errHandlingFlags = ERR_HANDLING_OFF;
128
129
  CUChunkCache              m_cuChunkCache;
130
  TUChunkCache              m_tuChunkCache;
131
  CUMapCache                m_cuMapCache;
132
  CUMapCache                m_chromaCuMapCache;
133
134
public:
135
956
  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
  void     failIncompleteParsePic();
148
149
  void checkNoOutputPriorPics   ();
150
0
  void setNoOutputPriorPicsFlag (bool val)              { m_isNoOutputPriorPics = val; }
151
0
  bool getNoOutputPriorPicsFlag () const                { return m_isNoOutputPriorPics; }
152
153
0
  void setDecodedSEIMessageOutputStream( std::ostream* pOpStream ) { m_pDecodedSEIOutputStream = pOpStream; }
154
155
0
  const ParameterSetManager& getParameterSetManager() const { return m_parameterSetManager; }
156
157
private:
158
  bool xDecodeSliceHead( InputNALUnit& nalu );
159
  bool xDecodeSliceMain( InputNALUnit& nalu );
160
161
  void xActivateParameterSets( const int layerId );
162
  void prepareUnavailablePicture( bool isLost, const PPS* pps, int iUnavailablePoc, const int layerId, const bool longTermFlag, const int temporalId );
163
  void markAllRefPicsUnused( const int layerId );
164
  void applyReferencePictureListBasedMarking( Slice* currSlice, const int layerId );
165
166
  void xParsePrefixSEImessages();
167
  void xParsePrefixSEIsForUnknownVCLNal();
168
169
  void xDecodePicHeader       ( InputNALUnit& nalu );
170
  void xDecodeVPS             ( InputNALUnit& nalu );
171
  void xDecodeDCI             ( InputNALUnit& nalu );
172
  void xDecodeSPS             ( InputNALUnit& nalu );
173
  void xDecodePPS             ( InputNALUnit& nalu );
174
  void xDecodeAPS             ( InputNALUnit& nalu );
175
  void xUpdatePreviousTid0POC ( Slice* pSlice );
176
177
  bool isRandomAccessSkipPicture();
178
  void xCheckMixedNalUnit     ( Slice* pcSlice, const InputNALUnit& nalu );
179
};
180
181
}