mirror of
https://github.com/opencv/opencv.git
synced 2024-12-16 10:29:11 +08:00
472aad46a6
Add AVIF support through libavif. #23596 This is to fix https://github.com/opencv/opencv/issues/19271 Extra: https://github.com/opencv/opencv_extra/pull/1069 ### 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
63 lines
1.4 KiB
C++
63 lines
1.4 KiB
C++
// This file is part of OpenCV project.
|
|
// It is subject to the license terms in the LICENSE file found in the top-level
|
|
// directory of this distribution and at http://opencv.org/license.html
|
|
|
|
#ifndef _GRFMT_AVIF_H_
|
|
#define _GRFMT_AVIF_H_
|
|
|
|
#include "grfmt_base.hpp"
|
|
|
|
#ifdef HAVE_AVIF
|
|
|
|
struct avifDecoder;
|
|
struct avifEncoder;
|
|
struct avifRWData;
|
|
|
|
namespace cv {
|
|
|
|
class AvifDecoder CV_FINAL : public BaseImageDecoder {
|
|
public:
|
|
AvifDecoder();
|
|
~AvifDecoder();
|
|
|
|
bool readHeader() CV_OVERRIDE;
|
|
bool readData(Mat& img) CV_OVERRIDE;
|
|
bool nextPage() CV_OVERRIDE;
|
|
|
|
size_t signatureLength() const CV_OVERRIDE;
|
|
bool checkSignature(const String& signature) const CV_OVERRIDE;
|
|
ImageDecoder newDecoder() const CV_OVERRIDE;
|
|
|
|
protected:
|
|
int channels_;
|
|
int bit_depth_;
|
|
avifDecoder* decoder_;
|
|
bool is_first_image_;
|
|
};
|
|
|
|
class AvifEncoder CV_FINAL : public BaseImageEncoder {
|
|
public:
|
|
AvifEncoder();
|
|
~AvifEncoder() CV_OVERRIDE;
|
|
|
|
bool isFormatSupported(int depth) const CV_OVERRIDE;
|
|
|
|
bool write(const Mat& img, const std::vector<int>& params) CV_OVERRIDE;
|
|
|
|
bool writemulti(const std::vector<Mat>& img_vec,
|
|
const std::vector<int>& params) CV_OVERRIDE;
|
|
|
|
ImageEncoder newEncoder() const CV_OVERRIDE;
|
|
|
|
private:
|
|
bool writeToOutput(const std::vector<Mat>& img_vec,
|
|
const std::vector<int>& params);
|
|
avifEncoder* encoder_;
|
|
};
|
|
|
|
} // namespace cv
|
|
|
|
#endif
|
|
|
|
#endif /*_GRFMT_AVIF_H_*/
|