mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Merge pull request #23943 from vrabaud:avif_tsan
Fix checkSignature not thread safe for AVIF. #23943 A common decoder cannot be shared with checkSignature which is used like a static function (on a static ist of decoders). ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
parent
bb61cc0dba
commit
2af6775c14
@ -148,11 +148,14 @@ AvifDecoder::~AvifDecoder() {
|
||||
size_t AvifDecoder::signatureLength() const { return kAvifSignatureSize; }
|
||||
|
||||
bool AvifDecoder::checkSignature(const String &signature) const {
|
||||
avifDecoderSetIOMemory(decoder_,
|
||||
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_);
|
||||
decoder->io->sizeHint = 1e9;
|
||||
const avifResult status = avifDecoderParse(decoder);
|
||||
avifDecoderDestroy(decoder);
|
||||
return (status == AVIF_RESULT_OK || status == AVIF_RESULT_TRUNCATED_DATA);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user