/src/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 | | std::vector<NalUnitType> m_pictureUnitNals; |
84 | | std::list<InputNALUnit> m_pictureSeiNalus; |
85 | | |
86 | | public: |
87 | | DecLib(); |
88 | 0 | ~DecLib() = default; |
89 | | |
90 | | void create( int numDecThreads, int parserFrameDelay, const UserAllocator& userAllocator, ErrHandlingFlags errHandlingFlags); |
91 | | void destroy(); |
92 | | |
93 | 0 | const char* getDecoderCapabilities() const { return m_sDecoderCapabilities.c_str(); } |
94 | | |
95 | 0 | void setMaxTemporalLayer( int layer ) { m_iMaxTemporalLayer = layer; } |
96 | | |
97 | | Picture* decode( InputNALUnit& nalu ); |
98 | | Picture* flushPic(); |
99 | 0 | void releasePicture ( Picture* pcPic ) { m_picListManager.releasePicture( pcPic ); } // notify the decoder-lib that the picture buffers can be reused |
100 | | |
101 | 0 | void setDecodedSEIMessageOutputStream( std::ostream* pOpStream ) { m_decLibParser.setDecodedSEIMessageOutputStream( pOpStream ); } |
102 | 0 | void setDecodedPictureHashSEIEnabled( int enabled ) { m_decodedPictureHashSEIEnabled = enabled; } |
103 | 0 | uint32_t getNumberOfChecksumErrorsDetected() const { return m_numberOfChecksumErrorsDetected; } |
104 | | void checkPictureHashSEI( Picture* pcPic ); |
105 | | |
106 | | void checkNalUnitConstraints( uint32_t naluType ); |
107 | | void checkSeiInPictureUnit(); |
108 | | void resetPictureSeiNalus(); |
109 | | void checkAPSInPictureUnit(); |
110 | 0 | void resetPictureUnitNals() { m_pictureUnitNals.clear(); } |
111 | | |
112 | | |
113 | 0 | ThreadPool& getThreadPool() { return *m_decodeThreadPool; } |
114 | | |
115 | | private: |
116 | | void reconPicture( Picture* pcPic ); |
117 | | #if JVET_R0270 |
118 | | int finishPicture ( Picture* pcPic, MsgLevel msgl = NOTICE, bool associatedWithNewClvs ); |
119 | | #else |
120 | | int finishPicture ( Picture* pcPic, MsgLevel msgl = NOTICE ); |
121 | | #endif |
122 | | Picture* getNextOutputPic ( bool bFlush = false ); |
123 | | void blockAndFinishPictures( Picture* pcPic = nullptr ); // iterate over DecLibRecon instances and wait to finish picture(s) |
124 | | void xCheckNalUnitConstraintFlags( const ConstraintInfo *cInfo, uint32_t naluType ); |
125 | | }; |
126 | | |
127 | | } |