diff --git a/app/codec/oiio/oiiodecoder.cpp b/app/codec/oiio/oiiodecoder.cpp index c01e20e4a..5ef8b4636 100644 --- a/app/codec/oiio/oiiodecoder.cpp +++ b/app/codec/oiio/oiiodecoder.cpp @@ -21,9 +21,12 @@ #include "oiiodecoder.h" #include +#include #include "common/define.h" +QStringList OIIODecoder::supported_formats_; + OIIODecoder::OIIODecoder() : image_(nullptr), frame_(nullptr) @@ -37,6 +40,22 @@ QString OIIODecoder::id() bool OIIODecoder::Probe(Footage *f) { + // We prioritize OIIO over FFmpeg to pick up still images more effectively, but some OIIO decoders (notably OpenJPEG) + // will segfault entirely if given unexpected data (an MPEG-4 for instance). To workaround this issue, we use OIIO's + // "extension_list" attribute and match it with the extension of the file. + + // Check if we've created the supported formats list, create it if not + if (supported_formats_.isEmpty()) { + supported_formats_ = QString::fromStdString(OIIO::get_string_attribute("extension_list")).split(';'); + } + + // + QFileInfo file_info(f->filename()); + + if (!supported_formats_.contains(file_info.completeSuffix())) { + return false; + } + std::string std_filename = f->filename().toStdString(); auto in = OIIO::ImageInput::open(std_filename); diff --git a/app/codec/oiio/oiiodecoder.h b/app/codec/oiio/oiiodecoder.h index 3d392071f..f4977c40f 100644 --- a/app/codec/oiio/oiiodecoder.h +++ b/app/codec/oiio/oiiodecoder.h @@ -64,6 +64,8 @@ private: FramePtr frame_; + static QStringList supported_formats_; + }; #endif // OIIODECODER_H