mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 14:36:36 +08:00
Merge pull request #24438 from vrabaud:avif_check
Check the return value of avifDecoderSetIOMemory.
This commit is contained in:
commit
3429c27477
@ -147,18 +147,6 @@ AvifDecoder::~AvifDecoder() {
|
||||
|
||||
size_t AvifDecoder::signatureLength() const { return kAvifSignatureSize; }
|
||||
|
||||
bool AvifDecoder::checkSignature(const String &signature) const {
|
||||
avifDecoder *decoder = avifDecoderCreate();
|
||||
if (!decoder) return false;
|
||||
avifDecoderSetIOMemory(decoder,
|
||||
reinterpret_cast<const uint8_t *>(signature.c_str()),
|
||||
signature.size());
|
||||
decoder->io->sizeHint = 1e9;
|
||||
const avifResult status = avifDecoderParse(decoder);
|
||||
avifDecoderDestroy(decoder);
|
||||
return (status == AVIF_RESULT_OK || status == AVIF_RESULT_TRUNCATED_DATA);
|
||||
}
|
||||
|
||||
#define OPENCV_AVIF_CHECK_STATUS(X, ENCDEC) \
|
||||
{ \
|
||||
const avifResult status = (X); \
|
||||
@ -170,6 +158,20 @@ bool AvifDecoder::checkSignature(const String &signature) const {
|
||||
} \
|
||||
}
|
||||
|
||||
bool AvifDecoder::checkSignature(const String &signature) const {
|
||||
avifDecoder *decoder = avifDecoderCreate();
|
||||
if (!decoder) return false;
|
||||
OPENCV_AVIF_CHECK_STATUS(
|
||||
avifDecoderSetIOMemory(
|
||||
decoder, reinterpret_cast<const uint8_t *>(signature.c_str()),
|
||||
signature.size()),
|
||||
decoder);
|
||||
decoder->io->sizeHint = 1e9;
|
||||
const avifResult status = avifDecoderParse(decoder);
|
||||
avifDecoderDestroy(decoder);
|
||||
return (status == AVIF_RESULT_OK || status == AVIF_RESULT_TRUNCATED_DATA);
|
||||
}
|
||||
|
||||
ImageDecoder AvifDecoder::newDecoder() const { return makePtr<AvifDecoder>(); }
|
||||
|
||||
bool AvifDecoder::readHeader() {
|
||||
|
Loading…
Reference in New Issue
Block a user