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/DecLib.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
/** \file     DecLib.h
44
    \brief    decoder class (header)
45
*/
46
47
#pragma once
48
49
#include "PicListManager.h"
50
#include "DecLibParser.h"
51
#include "DecLibRecon.h"
52
53
#include "CommonLib/CommonDef.h"
54
#include "CommonLib/Picture.h"
55
56
#include "Utilities/ThreadPool.h"
57
58
namespace vvdec
59
{
60
61
// ====================================================================================================================
62
// Class definition
63
// ====================================================================================================================
64
65
/// decoder wrapper class
66
class DecLib
67
{
68
  PicListManager           m_picListManager;
69
  DecLibParser             m_decLibParser{ *this, m_picListManager };
70
  std::list<DecLibRecon>   m_decLibRecon{ 2 };
71
72
  std::unique_ptr<ThreadPool> m_decodeThreadPool;
73
74
  unsigned int m_parseFrameDelay = 0;
75
76
  int         m_decodedPictureHashSEIEnabled   = 0;   ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
77
  uint32_t    m_numberOfChecksumErrorsDetected = 0;
78
  std::string m_sDecoderCapabilities;
79
80
  int  m_iMaxTemporalLayer  = -1;
81
  bool m_checkMissingOutput = false;
82
83
public:
84
  DecLib();
85
956
  ~DecLib() = default;
86
87
  void create( int numDecThreads, int parserFrameDelay, const UserAllocator& userAllocator, ErrHandlingFlags errHandlingFlags);
88
  void destroy();
89
90
478
  const char* getDecoderCapabilities() const { return m_sDecoderCapabilities.c_str(); }
91
92
0
  void     setMaxTemporalLayer( int layer ) { m_iMaxTemporalLayer = layer; }
93
94
  Picture* decode( InputNALUnit& nalu );
95
  Picture* flushPic();
96
0
  void     releasePicture   ( Picture* pcPic ) { m_picListManager.releasePicture( pcPic ); }   // notify the decoder-lib that the picture buffers can be reused
97
98
0
  void     setDecodedSEIMessageOutputStream( std::ostream* pOpStream ) { m_decLibParser.setDecodedSEIMessageOutputStream( pOpStream ); }
99
478
  void     setDecodedPictureHashSEIEnabled( int enabled ) { m_decodedPictureHashSEIEnabled = enabled; }
100
0
  uint32_t getNumberOfChecksumErrorsDetected() const { return m_numberOfChecksumErrorsDetected; }
101
  void     checkPictureHashSEI( Picture* pcPic );
102
103
  void     checkNalUnitConstraints( uint32_t naluType );
104
105
106
0
  ThreadPool& getThreadPool() { return *m_decodeThreadPool; }
107
108
private:
109
  void     reconPicture( Picture* pcPic );
110
#if JVET_R0270
111
  int      finishPicture    ( Picture* pcPic, MsgLevel msgl = NOTICE, bool associatedWithNewClvs );
112
#else
113
  int      finishPicture    ( Picture* pcPic, MsgLevel msgl = NOTICE );
114
#endif
115
  Picture* getNextOutputPic ( bool bFlush = false );
116
  void     blockAndFinishPictures( Picture* pcPic = nullptr );   // iterate over DecLibRecon instances and wait to finish picture(s)
117
  void     sanitizeBrokenPicture( Picture* pcParsedPic );
118
  void     xCheckNalUnitConstraintFlags( const ConstraintInfo *cInfo, uint32_t naluType );
119
};
120
121
}