From 81dc19c75612b7fc6d32a3d5eab26eeec5e82c54 Mon Sep 17 00:00:00 2001 From: christian Date: Wed, 22 Mar 2017 21:21:44 +0100 Subject: [PATCH] Also parse _10b_ as bit depth --- source/fileSource.cpp | 49 ++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/source/fileSource.cpp b/source/fileSource.cpp index 11c78feb7..07f5843fa 100644 --- a/source/fileSource.cpp +++ b/source/fileSource.cpp @@ -161,36 +161,33 @@ void fileSource::formatFromFilename(QSize &frameSize, int &frameRate, int &bitDe // First, we will try to get a frame size from the name if (!frameSize.isValid()) { - QRegExp rxExtended("([0-9]+)x([0-9]+)_([0-9]+)_([0-9]+)[\\._]"); // Something_2160x1440_60_8_more.yuv or Something_2160x1440_60_8.yuv - QRegExp rxDefault("([0-9]+)x([0-9]+)_([0-9]+)[\\._]"); // Something_2160x1440_60_more.yuv or Something_2160x1440_60.yuv - QRegExp rxSizeOnly("([0-9]+)x([0-9]+)[\\._]"); // Something_2160x1440_more.yuv or Something_2160x1440.yuv - - if (rxExtended.indexIn(name) > -1) + // The regular expressions to match. They are sorted from most detailed to least so that the most + // detailed ones are tested first. + QStringList regExprList; + regExprList << "([0-9]+)x([0-9]+)_([0-9]+)_([0-9]+)b?[\\._]"; // Something_2160x1440_60_8_more.yuv or Something_2160x1440_60_8b.yuv + regExprList << "([0-9]+)x([0-9]+)_([0-9]+)[\\._]"; // Something_2160x1440_60_more.yuv or Something_2160x1440_60.yuv + regExprList << "([0-9]+)x([0-9]+)[\\._]"; // Something_2160x1440_more.yuv or Something_2160x1440.yuv + + for (QString regExpStr : regExprList) { - QString widthString = rxExtended.cap(1); - QString heightString = rxExtended.cap(2); - frameSize = QSize(widthString.toInt(), heightString.toInt()); + QRegExp exp(regExpStr); + if (exp.indexIn(name) > -1) + { + QString widthString = exp.cap(1); + QString heightString = exp.cap(2); + frameSize = QSize(widthString.toInt(), heightString.toInt()); - QString rateString = rxExtended.cap(3); - frameRate = rateString.toDouble(); + QString rateString = exp.cap(3); + if (!rateString.isEmpty()) + frameRate = rateString.toDouble(); - QString bitDepthString = rxExtended.cap(4); - bitDepth = bitDepthString.toInt(); - } - else if (rxDefault.indexIn(name) > -1) - { - QString widthString = rxDefault.cap(1); - QString heightString = rxDefault.cap(2); - frameSize = QSize(widthString.toInt(), heightString.toInt()); + QString bitDepthString = exp.cap(4); + if (!bitDepthString.isEmpty()) + bitDepth = bitDepthString.toInt(); - QString rateString = rxDefault.cap(3); - frameRate = rateString.toDouble(); - } - else if (rxSizeOnly.indexIn(name) > -1) - { - QString widthString = rxSizeOnly.cap(1); - QString heightString = rxSizeOnly.cap(2); - frameSize = QSize(widthString.toInt(), heightString.toInt()); + // Don't check the following expressions + break; + } } }