oiio: assume it's not an image sequence if the dimensions aren't equal

This commit is contained in:
itsmattkc
2020-09-21 12:21:17 +10:00
parent bb5669c305
commit 7bdaf78af8
2 changed files with 29 additions and 2 deletions
+27 -2
View File
@@ -68,11 +68,17 @@ bool OIIODecoder::Probe(Footage *f, const QAtomicInt *cancelled)
// Heuristically determine whether this file is part of an image sequence or not // Heuristically determine whether this file is part of an image sequence or not
if (GetImageSequenceDigitCount(f->filename()) > 0) { if (GetImageSequenceDigitCount(f->filename()) > 0) {
QSize dim(in->spec().width, in->spec().height);
int64_t ind = GetImageSequenceIndex(f->filename()); int64_t ind = GetImageSequenceIndex(f->filename());
// Check if files around exist around it with that follow a sequence // Check if files around exist around it with that follow a sequence
if (QFileInfo::exists(TransformImageSequenceFileName(f->filename(), ind - 1)) QString previous_img_fn = TransformImageSequenceFileName(f->filename(), ind - 1);
|| QFileInfo::exists(TransformImageSequenceFileName(f->filename(), ind + 1))) { QString next_img_fn = TransformImageSequenceFileName(f->filename(), ind + 1);
// GetImageDimensions will return a 0,0 size if the file doesn't exist, so it's safe to check
// both existence and matching size with this
if (GetImageDimensions(previous_img_fn) == dim || GetImageDimensions(next_img_fn) == dim) {
// We need user feedback here and since UI must occur in the UI thread (and we could be in any thread), we defer // We need user feedback here and since UI must occur in the UI thread (and we could be in any thread), we defer
// to the Core which will definitely be in the UI thread and block here until we get an answer from the user // to the Core which will definitely be in the UI thread and block here until we get an answer from the user
QMetaObject::invokeMethod(Core::instance(), QMetaObject::invokeMethod(Core::instance(),
@@ -316,6 +322,25 @@ bool OIIODecoder::FileTypeIsSupported(const QString& fn)
return true; return true;
} }
QSize OIIODecoder::GetImageDimensions(const QString &fn)
{
QSize sz;
auto in = OIIO::ImageInput::open(fn.toStdString());
if (in) {
sz.setWidth(in->spec().width);
sz.setHeight(in->spec().height);
in->close();
#if OIIO_VERSION < 10903
OIIO::ImageInput::destroy(in);
#endif
}
return sz;
}
bool OIIODecoder::OpenImageHandler(const QString &fn) bool OIIODecoder::OpenImageHandler(const QString &fn)
{ {
image_ = OIIO::ImageInput::open(fn.toStdString()); image_ = OIIO::ImageInput::open(fn.toStdString());
+2
View File
@@ -68,6 +68,8 @@ private:
static bool FileTypeIsSupported(const QString& fn); static bool FileTypeIsSupported(const QString& fn);
static QSize GetImageDimensions(const QString& fn);
bool OpenImageHandler(const QString& fn); bool OpenImageHandler(const QString& fn);
void CloseImageHandle(); void CloseImageHandle();