/work/vvdec/source/Lib/vvdec/vvdecimpl.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 "vvdec/vvdec.h" |
46 | | #include "DecoderLib/DecLib.h" // internal decoder |
47 | | |
48 | | namespace vvdec { |
49 | | |
50 | | class FilmGrain; |
51 | | |
52 | | static const char * const vvdecNalTypeNames[] = { "NAL_UNIT_CODED_SLICE_TRAIL", "NAL_UNIT_CODED_SLICE_STSA", "NAL_UNIT_CODED_SLICE_RADL", "NAL_UNIT_CODED_SLICE_RASL", |
53 | | "NAL_UNIT_RESERVED_VCL_4", "NAL_UNIT_RESERVED_VCL_5", "NAL_UNIT_RESERVED_VCL_6", |
54 | | "NAL_UNIT_CODED_SLICE_IDR_W_RADL","NAL_UNIT_CODED_SLICE_IDR_N_LP","NAL_UNIT_CODED_SLICE_CRA","NAL_UNIT_CODED_SLICE_GDR", |
55 | | "NAL_UNIT_RESERVED_IRAP_VCL_11","NAL_UNIT_RESERVED_IRAP_VCL_12", |
56 | | "NAL_UNIT_DCI","NAL_UNIT_VPS","NAL_UNIT_SPS","NAL_UNIT_PPS", |
57 | | "NAL_UNIT_PREFIX_APS","NAL_UNIT_SUFFIX_APS","NAL_UNIT_PH","NAL_UNIT_ACCESS_UNIT_DELIMITER", |
58 | | "NAL_UNIT_EOS","NAL_UNIT_EOB","NAL_UNIT_PREFIX_SEI","NAL_UNIT_SUFFIX_SEI","NAL_UNIT_FD", |
59 | | "NAL_UNIT_RESERVED_NVCL_26","NAL_UNIT_RESERVED_NVCL_27", |
60 | | "NAL_UNIT_UNSPECIFIED_28","NAL_UNIT_UNSPECIFIED_29","NAL_UNIT_UNSPECIFIED_30","NAL_UNIT_UNSPECIFIED_31", |
61 | | "NAL_UNIT_INVALID", 0 }; |
62 | | |
63 | | static const char * const vvdecErrorMsg[] = { "expected behavior", |
64 | | "unspecified malfunction", |
65 | | "decoder not initialized or tried to initialize multiple times", |
66 | | "internal allocation error", |
67 | | "decoder input data error", |
68 | | "allocated memory too small to receive decoded data", |
69 | | "inconsistent or invalid parameters", |
70 | | "unsupported request", |
71 | | "decoder requires restart", |
72 | | "unsupported CPU - SSE 4.1 needed", |
73 | | "more bitstream data needed. try again", |
74 | | "end of stream", |
75 | | "unknown error code", 0 }; |
76 | | |
77 | | /** |
78 | | \ingroup hhivvcdeclibExternalInterfaces |
79 | | The class HhiVvcDec provides the decoder user interface. The simplest way to use the decoder is to call init() to initialize an decoder instance with the |
80 | | the given VVCDecoderParameters. After initialization the decoding of the video is performed by using the decoder() method to hand over compressed packets (bitstream chunks) in decoding order |
81 | | and retrieve uncompressed pictures. The decoding can be end by calling flush() that causes the decoder to finish decoding of all pending packets. |
82 | | Finally calling uninit() releases all allocated resources held by the decoder internally. |
83 | | */ |
84 | | class VVDecImpl |
85 | | { |
86 | | public: |
87 | | |
88 | | enum VVDecInternalState |
89 | | { |
90 | | INTERNAL_STATE_UNINITIALIZED = 0, |
91 | | INTERNAL_STATE_INITIALIZED = 1, |
92 | | INTERNAL_STATE_TUNING_IN = 2, |
93 | | INTERNAL_STATE_DECODING = 3, |
94 | | INTERNAL_STATE_FLUSHING = 4, |
95 | | INTERNAL_STATE_FINALIZED = 5, |
96 | | INTERNAL_STATE_RESTART_REQUIRED = 6, |
97 | | INTERNAL_STATE_NOT_SUPPORTED = 7 |
98 | | }; |
99 | | |
100 | | public: |
101 | | |
102 | | VVDecImpl(); |
103 | | ~VVDecImpl(); |
104 | | |
105 | | class FrameStorage |
106 | | { |
107 | | public: |
108 | | int allocateStorage( size_t size ) |
109 | 0 | { |
110 | 0 | if( size == 0 ){ return VVDEC_ERR_ALLOCATE; } |
111 | 0 | m_ptr.reset( new unsigned char[size] ); |
112 | 0 | m_size = size; |
113 | 0 | return 0; |
114 | 0 | } |
115 | | |
116 | | int freeStorage() |
117 | 0 | { |
118 | 0 | if( !m_ptr ) { return VVDEC_ERR_ALLOCATE; } |
119 | 0 | m_ptr.reset(); |
120 | 0 | m_size = 0; |
121 | 0 | return 0; |
122 | 0 | } |
123 | | |
124 | | unsigned char * getStorage() |
125 | 0 | { |
126 | 0 | return m_ptr.get(); |
127 | 0 | } |
128 | | |
129 | 0 | bool isAllocated() { return !!m_ptr; } |
130 | 0 | bool isExternAllocator() { return m_isExternAllocator; } |
131 | 0 | void setExternAllocator() { m_isExternAllocator = true; } |
132 | | |
133 | | private: |
134 | | std::unique_ptr<unsigned char[]> m_ptr = nullptr; // pointer to plane buffer |
135 | | size_t m_size = 0; |
136 | | bool m_isExternAllocator = false; |
137 | | }; |
138 | | |
139 | | public: |
140 | | |
141 | | int init( const vvdecParams& params, vvdecCreateBufferCallback callbackCreateBuf = nullptr, vvdecUnrefBufferCallback callbackUnrefBuf = nullptr ); |
142 | | |
143 | | int uninit(); |
144 | | int reset(); |
145 | | |
146 | | void setLoggingCallback( vvdecLoggingCallback callback ); |
147 | | |
148 | | int decode( vvdecAccessUnit& accessUnit, vvdecFrame** ppframe ); |
149 | | |
150 | | int flush( vvdecFrame** ppcFrame ); |
151 | | |
152 | | vvdecSEI* findFrameSei( vvdecSEIPayloadType payloadType, vvdecFrame *frame ); |
153 | | |
154 | | int objectUnref( vvdecFrame* pframe ); |
155 | | |
156 | | int getNumberOfErrorsPictureHashSEI( ); |
157 | | |
158 | | int setAndRetErrorMsg( int Ret, std::string errString = "" ); |
159 | | |
160 | | const char* getDecoderInfo(); |
161 | | |
162 | | template<class MembFunc, class... Args> |
163 | | auto catchExceptions( MembFunc fn, Args... args ); |
164 | | |
165 | | static const char* getErrorMsg( int nRet ); |
166 | | static const char* getVersionNumber(); |
167 | | |
168 | | static vvdecNalType getNalUnitType ( vvdecAccessUnit& accessUnit ); |
169 | | static const char* getNalUnitTypeAsString( vvdecNalType t ); |
170 | | static bool isNalUnitSlice ( vvdecNalType t ); |
171 | | |
172 | | std::string m_cErrorString; |
173 | | std::string m_cAdditionalErrorString; |
174 | | |
175 | | private: |
176 | | int xAddPicture ( Picture* pcPic ); |
177 | | int xCreateFrame ( vvdecFrame& frame, |
178 | | const CPelUnitBuf& rcPicBuf, |
179 | | uint32_t uiWidth, |
180 | | uint32_t uiHeight, |
181 | | const BitDepths& rcBitDepths, |
182 | | bool bCreateStorage, |
183 | | bool origStride = false ); |
184 | | |
185 | | void xUpdateFGC ( vvdecSEI *sei ); |
186 | | void xAddGrain ( vvdecFrame *frame ); |
187 | | |
188 | | static int xRetrieveNalStartCode ( unsigned char *pB, int iZerosInStartcode ); |
189 | | static int xConvertPayloadToRBSP ( const uint8_t* payload, size_t payloadLen, InputBitstream* bitstream, bool isVclNalUnit ); |
190 | | static int xReadNalUnitHeader ( InputNALUnit& nalu ); |
191 | | |
192 | | int xHandleOutput( Picture* pcPic ); |
193 | | bool isFrameConverted( vvdecFrame* frame ); |
194 | | |
195 | | static int copyComp( const unsigned char* pucSrc, unsigned char* pucDest, unsigned int uiWidth, unsigned int uiHeight, ptrdiff_t iStrideSrc, ptrdiff_t iStrideDest, int iBytesPerSample ); |
196 | | |
197 | | void vvdec_picAttributes_default(vvdecPicAttributes *attributes); |
198 | | void vvdec_frame_default(vvdecFrame *frame); |
199 | | void vvdec_plane_default(vvdecPlane *plane); |
200 | | void vvdec_frame_reset(vvdecFrame *frame ); |
201 | | |
202 | | private: |
203 | | typedef std::tuple<vvdecFrame, Picture*> FrameListEntry; |
204 | | typedef std::map<uint64_t, FrameStorage> FrameStorageMap; |
205 | | typedef FrameStorageMap::value_type FrameStorageMapType; |
206 | | |
207 | | bool m_bInitialized = false; |
208 | | VVDecInternalState m_eState = INTERNAL_STATE_UNINITIALIZED; |
209 | | ErrHandlingFlags m_eErrHandlingFlags = ERR_HANDLING_TRY_CONTINUE; |
210 | | |
211 | | std::unique_ptr<DecLib> m_cDecLib; |
212 | | |
213 | | std::list<FrameListEntry> m_rcFrameList; |
214 | | std::list<FrameListEntry>::iterator m_pcFrameNext = m_rcFrameList.begin(); |
215 | | |
216 | | FrameStorageMap m_cFrameStorageMap; // map of frame storage class( converted frames) |
217 | | UserAllocator m_cUserAllocator; // user allocator object, valid if buffers are managed external |
218 | | |
219 | | std::string m_sDecoderInfo; |
220 | | std::string m_sDecoderCapabilities; |
221 | | |
222 | | uint64_t m_uiSeqNumber = 0; |
223 | | uint64_t m_uiSeqNumOutput = 0; |
224 | | enum |
225 | | { |
226 | | FgcNone = 0, |
227 | | FgcDontPersist = 1, |
228 | | FgcPersist = 2 |
229 | | } m_filmGrainCharacteristicsState = FgcNone; |
230 | | bool m_enableFilmGrain = false; |
231 | | std::unique_ptr<FilmGrain> m_filmGrainSynth; |
232 | | }; |
233 | | |
234 | | template<class MembFunc, class... Args> |
235 | | inline auto VVDecImpl::catchExceptions( MembFunc fn, Args... args ) |
236 | 2.84k | { |
237 | 2.84k | using TRet = decltype( ( this->*fn )( args... ) ); // return type of the wapped function |
238 | | |
239 | | // helper function to either return an error value or a null-pointer based on the wrapped function's return type |
240 | 2.84k | static auto returnErrOrNullptr = []( intptr_t err ) |
241 | 2.84k | { |
242 | 8 | if( std::is_pointer<TRet>() ) |
243 | 0 | return (TRet) 0; |
244 | 8 | return (TRet) err; |
245 | 8 | }; Unexecuted instantiation: vvdec::VVDecImpl::catchExceptions<int (vvdec::VVDecImpl::*)(vvdecParams const&, void* (*)(void*, vvdecComponentType, unsigned int, unsigned int, void**), void (*)(void*, void*)), vvdecParams, decltype(nullptr), decltype(nullptr)>(int (vvdec::VVDecImpl::*)(vvdecParams const&, void* (*)(void*, vvdecComponentType, unsigned int, unsigned int, void**), void (*)(void*, void*)), vvdecParams, decltype(nullptr), decltype(nullptr))::{lambda(long)#1}::operator()(long) constUnexecuted instantiation: vvdec::VVDecImpl::catchExceptions<int (vvdec::VVDecImpl::*)(vvdecParams const&, void* (*)(void*, vvdecComponentType, unsigned int, unsigned int, void**), void (*)(void*, void*)), vvdecParams, void* (*)(void*, vvdecComponentType, unsigned int, unsigned int, void**), void (*)(void*, void*)>(int (vvdec::VVDecImpl::*)(vvdecParams const&, void* (*)(void*, vvdecComponentType, unsigned int, unsigned int, void**), void (*)(void*, void*)), vvdecParams, void* (*)(void*, vvdecComponentType, unsigned int, unsigned int, void**), void (*)(void*, void*))::{lambda(long)#1}::operator()(long) constUnexecuted instantiation: vvdec::VVDecImpl::catchExceptions<int (vvdec::VVDecImpl::*)()>(int (vvdec::VVDecImpl::*)())::{lambda(long)#1}::operator()(long) constvvdec::VVDecImpl::catchExceptions<int (vvdec::VVDecImpl::*)(vvdecAccessUnit&, vvdecFrame**), vvdecAccessUnit, vvdecFrame**>(int (vvdec::VVDecImpl::*)(vvdecAccessUnit&, vvdecFrame**), vvdecAccessUnit, vvdecFrame**)::{lambda(long)#1}::operator()(long) constLine | Count | Source | 241 | 8 | { | 242 | 8 | if( std::is_pointer<TRet>() ) | 243 | 0 | return (TRet) 0; | 244 | 8 | return (TRet) err; | 245 | 8 | }; |
Unexecuted instantiation: vvdec::VVDecImpl::catchExceptions<int (vvdec::VVDecImpl::*)(vvdecFrame**), vvdecFrame**>(int (vvdec::VVDecImpl::*)(vvdecFrame**), vvdecFrame**)::{lambda(long)#1}::operator()(long) constUnexecuted instantiation: vvdec::VVDecImpl::catchExceptions<vvdecSEI* (vvdec::VVDecImpl::*)(vvdecSEIPayloadType, vvdecFrame*), vvdecSEIPayloadType, vvdecFrame*>(vvdecSEI* (vvdec::VVDecImpl::*)(vvdecSEIPayloadType, vvdecFrame*), vvdecSEIPayloadType, vvdecFrame*)::{lambda(long)#1}::operator()(long) constUnexecuted instantiation: vvdec::VVDecImpl::catchExceptions<int (vvdec::VVDecImpl::*)(vvdecFrame*), vvdecFrame*>(int (vvdec::VVDecImpl::*)(vvdecFrame*), vvdecFrame*)::{lambda(long)#1}::operator()(long) constUnexecuted instantiation: vvdec::VVDecImpl::catchExceptions<char const* (vvdec::VVDecImpl::*)()>(char const* (vvdec::VVDecImpl::*)())::{lambda(long)#1}::operator()(long) const |
246 | | |
247 | 2.84k | try |
248 | 2.84k | { |
249 | 2.84k | return ( this->*fn )( args... ); |
250 | 2.84k | } |
251 | 2.84k | catch( UnsupportedFeatureException& e ) |
252 | 2.84k | { |
253 | 8 | m_cErrorString = "unsupported feature exception"; |
254 | 8 | m_cAdditionalErrorString = std::string( "caught exception for unsupported feature: " ) + e.what(); |
255 | 8 | m_eState = INTERNAL_STATE_NOT_SUPPORTED; |
256 | 8 | return returnErrOrNullptr( VVDEC_ERR_NOT_SUPPORTED ); |
257 | 8 | } |
258 | 2.84k | catch( Exception& e ) |
259 | 2.84k | { |
260 | 0 | m_cErrorString = "decoder exception"; |
261 | 0 | m_cAdditionalErrorString = std::string( "caught decoder exception: " ) + e.what(); |
262 | 0 | m_eState = INTERNAL_STATE_RESTART_REQUIRED; |
263 | 0 | return returnErrOrNullptr( VVDEC_ERR_RESTART_REQUIRED ); |
264 | 0 | } |
265 | 2.84k | catch( std::overflow_error& e ) |
266 | 2.84k | { |
267 | 0 | m_cErrorString = "overflow exception"; |
268 | 0 | m_cAdditionalErrorString = std::string( "caught overflow exception: " ) + e.what(); |
269 | 0 | m_eState = INTERNAL_STATE_RESTART_REQUIRED; |
270 | 0 | return returnErrOrNullptr( VVDEC_ERR_RESTART_REQUIRED ); |
271 | 0 | } |
272 | 2.84k | catch( std::exception& e ) |
273 | 2.84k | { |
274 | 0 | m_cErrorString = "unknown exception"; |
275 | 0 | m_cAdditionalErrorString = std::string( "caught unknown exception: " ) + e.what(); |
276 | 0 | m_eState = INTERNAL_STATE_RESTART_REQUIRED; |
277 | 0 | return returnErrOrNullptr( VVDEC_ERR_RESTART_REQUIRED ); |
278 | 0 | } |
279 | 2.84k | catch( ... ) |
280 | 2.84k | { |
281 | 0 | m_cErrorString = "unknown exception"; |
282 | 0 | m_cAdditionalErrorString = "no details available"; |
283 | 0 | m_eState = INTERNAL_STATE_RESTART_REQUIRED; |
284 | 0 | return returnErrOrNullptr( VVDEC_ERR_RESTART_REQUIRED ); |
285 | 0 | } |
286 | 2.84k | } auto vvdec::VVDecImpl::catchExceptions<int (vvdec::VVDecImpl::*)(vvdecParams const&, void* (*)(void*, vvdecComponentType, unsigned int, unsigned int, void**), void (*)(void*, void*)), vvdecParams, decltype(nullptr), decltype(nullptr)>(int (vvdec::VVDecImpl::*)(vvdecParams const&, void* (*)(void*, vvdecComponentType, unsigned int, unsigned int, void**), void (*)(void*, void*)), vvdecParams, decltype(nullptr), decltype(nullptr)) Line | Count | Source | 236 | 676 | { | 237 | 676 | using TRet = decltype( ( this->*fn )( args... ) ); // return type of the wapped function | 238 | | | 239 | | // helper function to either return an error value or a null-pointer based on the wrapped function's return type | 240 | 676 | static auto returnErrOrNullptr = []( intptr_t err ) | 241 | 676 | { | 242 | 676 | if( std::is_pointer<TRet>() ) | 243 | 676 | return (TRet) 0; | 244 | 676 | return (TRet) err; | 245 | 676 | }; | 246 | | | 247 | 676 | try | 248 | 676 | { | 249 | 676 | return ( this->*fn )( args... ); | 250 | 676 | } | 251 | 676 | catch( UnsupportedFeatureException& e ) | 252 | 676 | { | 253 | 0 | m_cErrorString = "unsupported feature exception"; | 254 | 0 | m_cAdditionalErrorString = std::string( "caught exception for unsupported feature: " ) + e.what(); | 255 | 0 | m_eState = INTERNAL_STATE_NOT_SUPPORTED; | 256 | 0 | return returnErrOrNullptr( VVDEC_ERR_NOT_SUPPORTED ); | 257 | 0 | } | 258 | 676 | catch( Exception& e ) | 259 | 676 | { | 260 | 0 | m_cErrorString = "decoder exception"; | 261 | 0 | m_cAdditionalErrorString = std::string( "caught decoder exception: " ) + e.what(); | 262 | 0 | m_eState = INTERNAL_STATE_RESTART_REQUIRED; | 263 | 0 | return returnErrOrNullptr( VVDEC_ERR_RESTART_REQUIRED ); | 264 | 0 | } | 265 | 676 | catch( std::overflow_error& e ) | 266 | 676 | { | 267 | 0 | m_cErrorString = "overflow exception"; | 268 | 0 | m_cAdditionalErrorString = std::string( "caught overflow exception: " ) + e.what(); | 269 | 0 | m_eState = INTERNAL_STATE_RESTART_REQUIRED; | 270 | 0 | return returnErrOrNullptr( VVDEC_ERR_RESTART_REQUIRED ); | 271 | 0 | } | 272 | 676 | catch( std::exception& e ) | 273 | 676 | { | 274 | 0 | m_cErrorString = "unknown exception"; | 275 | 0 | m_cAdditionalErrorString = std::string( "caught unknown exception: " ) + e.what(); | 276 | 0 | m_eState = INTERNAL_STATE_RESTART_REQUIRED; | 277 | 0 | return returnErrOrNullptr( VVDEC_ERR_RESTART_REQUIRED ); | 278 | 0 | } | 279 | 676 | catch( ... ) | 280 | 676 | { | 281 | 0 | m_cErrorString = "unknown exception"; | 282 | 0 | m_cAdditionalErrorString = "no details available"; | 283 | 0 | m_eState = INTERNAL_STATE_RESTART_REQUIRED; | 284 | 0 | return returnErrOrNullptr( VVDEC_ERR_RESTART_REQUIRED ); | 285 | 0 | } | 286 | 676 | } |
Unexecuted instantiation: auto vvdec::VVDecImpl::catchExceptions<int (vvdec::VVDecImpl::*)(vvdecParams const&, void* (*)(void*, vvdecComponentType, unsigned int, unsigned int, void**), void (*)(void*, void*)), vvdecParams, void* (*)(void*, vvdecComponentType, unsigned int, unsigned int, void**), void (*)(void*, void*)>(int (vvdec::VVDecImpl::*)(vvdecParams const&, void* (*)(void*, vvdecComponentType, unsigned int, unsigned int, void**), void (*)(void*, void*)), vvdecParams, void* (*)(void*, vvdecComponentType, unsigned int, unsigned int, void**), void (*)(void*, void*)) auto vvdec::VVDecImpl::catchExceptions<int (vvdec::VVDecImpl::*)()>(int (vvdec::VVDecImpl::*)()) Line | Count | Source | 236 | 676 | { | 237 | 676 | using TRet = decltype( ( this->*fn )( args... ) ); // return type of the wapped function | 238 | | | 239 | | // helper function to either return an error value or a null-pointer based on the wrapped function's return type | 240 | 676 | static auto returnErrOrNullptr = []( intptr_t err ) | 241 | 676 | { | 242 | 676 | if( std::is_pointer<TRet>() ) | 243 | 676 | return (TRet) 0; | 244 | 676 | return (TRet) err; | 245 | 676 | }; | 246 | | | 247 | 676 | try | 248 | 676 | { | 249 | 676 | return ( this->*fn )( args... ); | 250 | 676 | } | 251 | 676 | catch( UnsupportedFeatureException& e ) | 252 | 676 | { | 253 | 0 | m_cErrorString = "unsupported feature exception"; | 254 | 0 | m_cAdditionalErrorString = std::string( "caught exception for unsupported feature: " ) + e.what(); | 255 | 0 | m_eState = INTERNAL_STATE_NOT_SUPPORTED; | 256 | 0 | return returnErrOrNullptr( VVDEC_ERR_NOT_SUPPORTED ); | 257 | 0 | } | 258 | 676 | catch( Exception& e ) | 259 | 676 | { | 260 | 0 | m_cErrorString = "decoder exception"; | 261 | 0 | m_cAdditionalErrorString = std::string( "caught decoder exception: " ) + e.what(); | 262 | 0 | m_eState = INTERNAL_STATE_RESTART_REQUIRED; | 263 | 0 | return returnErrOrNullptr( VVDEC_ERR_RESTART_REQUIRED ); | 264 | 0 | } | 265 | 676 | catch( std::overflow_error& e ) | 266 | 676 | { | 267 | 0 | m_cErrorString = "overflow exception"; | 268 | 0 | m_cAdditionalErrorString = std::string( "caught overflow exception: " ) + e.what(); | 269 | 0 | m_eState = INTERNAL_STATE_RESTART_REQUIRED; | 270 | 0 | return returnErrOrNullptr( VVDEC_ERR_RESTART_REQUIRED ); | 271 | 0 | } | 272 | 676 | catch( std::exception& e ) | 273 | 676 | { | 274 | 0 | m_cErrorString = "unknown exception"; | 275 | 0 | m_cAdditionalErrorString = std::string( "caught unknown exception: " ) + e.what(); | 276 | 0 | m_eState = INTERNAL_STATE_RESTART_REQUIRED; | 277 | 0 | return returnErrOrNullptr( VVDEC_ERR_RESTART_REQUIRED ); | 278 | 0 | } | 279 | 676 | catch( ... ) | 280 | 676 | { | 281 | 0 | m_cErrorString = "unknown exception"; | 282 | 0 | m_cAdditionalErrorString = "no details available"; | 283 | 0 | m_eState = INTERNAL_STATE_RESTART_REQUIRED; | 284 | 0 | return returnErrOrNullptr( VVDEC_ERR_RESTART_REQUIRED ); | 285 | 0 | } | 286 | 676 | } |
auto vvdec::VVDecImpl::catchExceptions<int (vvdec::VVDecImpl::*)(vvdecAccessUnit&, vvdecFrame**), vvdecAccessUnit, vvdecFrame**>(int (vvdec::VVDecImpl::*)(vvdecAccessUnit&, vvdecFrame**), vvdecAccessUnit, vvdecFrame**) Line | Count | Source | 236 | 664 | { | 237 | 664 | using TRet = decltype( ( this->*fn )( args... ) ); // return type of the wapped function | 238 | | | 239 | | // helper function to either return an error value or a null-pointer based on the wrapped function's return type | 240 | 664 | static auto returnErrOrNullptr = []( intptr_t err ) | 241 | 664 | { | 242 | 664 | if( std::is_pointer<TRet>() ) | 243 | 664 | return (TRet) 0; | 244 | 664 | return (TRet) err; | 245 | 664 | }; | 246 | | | 247 | 664 | try | 248 | 664 | { | 249 | 664 | return ( this->*fn )( args... ); | 250 | 664 | } | 251 | 664 | catch( UnsupportedFeatureException& e ) | 252 | 664 | { | 253 | 8 | m_cErrorString = "unsupported feature exception"; | 254 | 8 | m_cAdditionalErrorString = std::string( "caught exception for unsupported feature: " ) + e.what(); | 255 | 8 | m_eState = INTERNAL_STATE_NOT_SUPPORTED; | 256 | 8 | return returnErrOrNullptr( VVDEC_ERR_NOT_SUPPORTED ); | 257 | 8 | } | 258 | 664 | catch( Exception& e ) | 259 | 664 | { | 260 | 0 | m_cErrorString = "decoder exception"; | 261 | 0 | m_cAdditionalErrorString = std::string( "caught decoder exception: " ) + e.what(); | 262 | 0 | m_eState = INTERNAL_STATE_RESTART_REQUIRED; | 263 | 0 | return returnErrOrNullptr( VVDEC_ERR_RESTART_REQUIRED ); | 264 | 0 | } | 265 | 664 | catch( std::overflow_error& e ) | 266 | 664 | { | 267 | 0 | m_cErrorString = "overflow exception"; | 268 | 0 | m_cAdditionalErrorString = std::string( "caught overflow exception: " ) + e.what(); | 269 | 0 | m_eState = INTERNAL_STATE_RESTART_REQUIRED; | 270 | 0 | return returnErrOrNullptr( VVDEC_ERR_RESTART_REQUIRED ); | 271 | 0 | } | 272 | 664 | catch( std::exception& e ) | 273 | 664 | { | 274 | 0 | m_cErrorString = "unknown exception"; | 275 | 0 | m_cAdditionalErrorString = std::string( "caught unknown exception: " ) + e.what(); | 276 | 0 | m_eState = INTERNAL_STATE_RESTART_REQUIRED; | 277 | 0 | return returnErrOrNullptr( VVDEC_ERR_RESTART_REQUIRED ); | 278 | 0 | } | 279 | 664 | catch( ... ) | 280 | 664 | { | 281 | 0 | m_cErrorString = "unknown exception"; | 282 | 0 | m_cAdditionalErrorString = "no details available"; | 283 | 0 | m_eState = INTERNAL_STATE_RESTART_REQUIRED; | 284 | 0 | return returnErrOrNullptr( VVDEC_ERR_RESTART_REQUIRED ); | 285 | 0 | } | 286 | 664 | } |
auto vvdec::VVDecImpl::catchExceptions<int (vvdec::VVDecImpl::*)(vvdecFrame**), vvdecFrame**>(int (vvdec::VVDecImpl::*)(vvdecFrame**), vvdecFrame**) Line | Count | Source | 236 | 824 | { | 237 | 824 | using TRet = decltype( ( this->*fn )( args... ) ); // return type of the wapped function | 238 | | | 239 | | // helper function to either return an error value or a null-pointer based on the wrapped function's return type | 240 | 824 | static auto returnErrOrNullptr = []( intptr_t err ) | 241 | 824 | { | 242 | 824 | if( std::is_pointer<TRet>() ) | 243 | 824 | return (TRet) 0; | 244 | 824 | return (TRet) err; | 245 | 824 | }; | 246 | | | 247 | 824 | try | 248 | 824 | { | 249 | 824 | return ( this->*fn )( args... ); | 250 | 824 | } | 251 | 824 | catch( UnsupportedFeatureException& e ) | 252 | 824 | { | 253 | 0 | m_cErrorString = "unsupported feature exception"; | 254 | 0 | m_cAdditionalErrorString = std::string( "caught exception for unsupported feature: " ) + e.what(); | 255 | 0 | m_eState = INTERNAL_STATE_NOT_SUPPORTED; | 256 | 0 | return returnErrOrNullptr( VVDEC_ERR_NOT_SUPPORTED ); | 257 | 0 | } | 258 | 824 | catch( Exception& e ) | 259 | 824 | { | 260 | 0 | m_cErrorString = "decoder exception"; | 261 | 0 | m_cAdditionalErrorString = std::string( "caught decoder exception: " ) + e.what(); | 262 | 0 | m_eState = INTERNAL_STATE_RESTART_REQUIRED; | 263 | 0 | return returnErrOrNullptr( VVDEC_ERR_RESTART_REQUIRED ); | 264 | 0 | } | 265 | 824 | catch( std::overflow_error& e ) | 266 | 824 | { | 267 | 0 | m_cErrorString = "overflow exception"; | 268 | 0 | m_cAdditionalErrorString = std::string( "caught overflow exception: " ) + e.what(); | 269 | 0 | m_eState = INTERNAL_STATE_RESTART_REQUIRED; | 270 | 0 | return returnErrOrNullptr( VVDEC_ERR_RESTART_REQUIRED ); | 271 | 0 | } | 272 | 824 | catch( std::exception& e ) | 273 | 824 | { | 274 | 0 | m_cErrorString = "unknown exception"; | 275 | 0 | m_cAdditionalErrorString = std::string( "caught unknown exception: " ) + e.what(); | 276 | 0 | m_eState = INTERNAL_STATE_RESTART_REQUIRED; | 277 | 0 | return returnErrOrNullptr( VVDEC_ERR_RESTART_REQUIRED ); | 278 | 0 | } | 279 | 824 | catch( ... ) | 280 | 824 | { | 281 | 0 | m_cErrorString = "unknown exception"; | 282 | 0 | m_cAdditionalErrorString = "no details available"; | 283 | 0 | m_eState = INTERNAL_STATE_RESTART_REQUIRED; | 284 | 0 | return returnErrOrNullptr( VVDEC_ERR_RESTART_REQUIRED ); | 285 | 0 | } | 286 | 824 | } |
Unexecuted instantiation: auto vvdec::VVDecImpl::catchExceptions<vvdecSEI* (vvdec::VVDecImpl::*)(vvdecSEIPayloadType, vvdecFrame*), vvdecSEIPayloadType, vvdecFrame*>(vvdecSEI* (vvdec::VVDecImpl::*)(vvdecSEIPayloadType, vvdecFrame*), vvdecSEIPayloadType, vvdecFrame*) Unexecuted instantiation: auto vvdec::VVDecImpl::catchExceptions<int (vvdec::VVDecImpl::*)(vvdecFrame*), vvdecFrame*>(int (vvdec::VVDecImpl::*)(vvdecFrame*), vvdecFrame*) Unexecuted instantiation: auto vvdec::VVDecImpl::catchExceptions<char const* (vvdec::VVDecImpl::*)()>(char const* (vvdec::VVDecImpl::*)()) |
287 | | |
288 | | // this is needed by the vvdecapp to implement upscaling, but is not an official API for libvvdec |
289 | | VVDEC_DECL void rescalePlane( const vvdecPlane& srcPlane, |
290 | | vvdecPlane& dstPlane, |
291 | | int planeComponent, |
292 | | const vvdecColorFormat colorFormat, |
293 | | int bitDepth, |
294 | | const bool horCollocatedChromaFlag, |
295 | | const bool verCollocatedChromaFlag ); |
296 | | |
297 | | } // namespace vvdec |