File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 8
8
9
9
#include < avif/avif.h>
10
10
#include < fstream>
11
+ #include < memory>
11
12
12
13
#include < opencv2/core/utils/configuration.private.hpp>
13
14
#include " opencv2/imgproc.hpp"
@@ -159,16 +160,16 @@ size_t AvifDecoder::signatureLength() const { return kAvifSignatureSize; }
159
160
}
160
161
161
162
bool AvifDecoder::checkSignature (const String &signature) const {
162
- avifDecoder *decoder = avifDecoderCreate ();
163
+ std::unique_ptr<avifDecoder, decltype (&avifDecoderDestroy)> decoder (
164
+ avifDecoderCreate (), avifDecoderDestroy);
163
165
if (!decoder) return false ;
164
166
OPENCV_AVIF_CHECK_STATUS (
165
167
avifDecoderSetIOMemory (
166
- decoder, reinterpret_cast <const uint8_t *>(signature.c_str ()),
168
+ decoder. get () , reinterpret_cast <const uint8_t *>(signature.c_str ()),
167
169
signature.size ()),
168
170
decoder);
169
171
decoder->io ->sizeHint = 1e9 ;
170
- const avifResult status = avifDecoderParse (decoder);
171
- avifDecoderDestroy (decoder);
172
+ const avifResult status = avifDecoderParse (decoder.get ());
172
173
return (status == AVIF_RESULT_OK || status == AVIF_RESULT_TRUNCATED_DATA);
173
174
}
174
175
You can’t perform that action at this time.
0 commit comments