diff --git a/YUViewLib/src/filesource/FrameFormatGuess.cpp b/YUViewLib/src/filesource/FrameFormatGuess.cpp index adfbed9a0..51d9300af 100644 --- a/YUViewLib/src/filesource/FrameFormatGuess.cpp +++ b/YUViewLib/src/filesource/FrameFormatGuess.cpp @@ -53,9 +53,9 @@ GuessedFrameFormat guessFrameSizeFPSAndBitDepthFromName(const std::string &name) // Something_2160x1440_60Hz_8_more.yuv Second matches Something_2160x1440_60_more.yuv or // Something_2160x1440_60.yuv Thirs matches Something_2160x1440_more.yuv or // Something_2160x1440.yuv - const auto REGEXP_LIST = {"([0-9]+)(?:x|X|\\*)([0-9]+)_([0-9]+)(?:Hz)?_([0-9]+)b?[\\._]", - "([0-9]+)(?:x|X|\\*)([0-9]+)_([0-9]+)(?:Hz)?[\\._]", - "([0-9]+)(?:x|X|\\*)([0-9]+)[\\._]"}; + const auto REGEXP_LIST = {"([0-9]+)(?:x|\\*)([0-9]+)_([0-9]+)(?:hz)?_([0-9]+)b?[\\._]", + "([0-9]+)(?:x|\\*)([0-9]+)_([0-9]+)(?:hz)?[\\._]", + "([0-9]+)(?:x|\\*)([0-9]+)[\\._]"}; for (const auto ®ExpStr : REGEXP_LIST) { @@ -111,20 +111,19 @@ GuessedFrameFormat guessFrameSizeAndFrameRateFromResolutionIndicators(const std: std::optional guessFrameSizeFromAcronymResolutionIndicators(const std::string &name) { - const auto nameLower = functions::toLower(name); - if (nameLower.find("_cif") != std::string::npos) + if (name.find("_cif") != std::string::npos) return Size(352, 288); - else if (nameLower.find("_qcif") != std::string::npos) + else if (name.find("_qcif") != std::string::npos) return Size(176, 144); - else if (nameLower.find("_4cif") != std::string::npos) + else if (name.find("_4cif") != std::string::npos) return Size(704, 576); - else if (nameLower.find("UHD") != std::string::npos) + else if (name.find("uhd") != std::string::npos) return Size(3840, 2160); - else if (nameLower.find("HD") != std::string::npos) + else if (name.find("hd") != std::string::npos) return Size(1920, 1080); - else if (nameLower.find("1080p") != std::string::npos) + else if (name.find("1080p") != std::string::npos) return Size(1920, 1080); - else if (nameLower.find("720p") != std::string::npos) + else if (name.find("720p") != std::string::npos) return Size(1280, 720); return {}; @@ -133,7 +132,7 @@ std::optional guessFrameSizeFromAcronymResolutionIndicators(const std::str std::optional guessFPSFromFPSOrHzIndicators(const std::string &name) { std::smatch frameSizeMatch; - const std::regex strExpr("([0-9]+)(FPS|fps|HZ|Hz)"); + const std::regex strExpr("([0-9]+)(fps|hz)"); if (std::regex_search(name, frameSizeMatch, strExpr)) return toUnsigned(frameSizeMatch[1].str()); return {}; @@ -142,7 +141,7 @@ std::optional guessFPSFromFPSOrHzIndicators(const std::string &name) std::optional guessBitDepthFromName(const std::string &name) { const auto REGEXP_LIST = { - "(8|9|10|12|16)-?(BIT|Bit|bit)", // E.g. 10bit, 10BIT, 10-bit, 10-BIT + "(8|9|10|12|16)-?(bit)", // E.g. 10bit, 10BIT, 10-bit, 10-BIT "(?:_|\\.|-)(8|9|10|12|16)b(?:_|\\.|-)" // E.g. _16b_ .8b. -12b- }; @@ -208,25 +207,28 @@ GuessedFrameFormat guessFrameFormat(const FileInfoForGuess &fileInfo) for (auto const &name : {fileInfo.filename, fileInfo.parentFolderName}) { + const auto nameLower = functions::toLower(name); + if (!result.frameSize) - result = guessFrameSizeFPSAndBitDepthFromName(name); + result = guessFrameSizeFPSAndBitDepthFromName(nameLower); if (!result.frameSize) - result = guessFrameSizeAndFrameRateFromResolutionIndicators(name); + result = guessFrameSizeAndFrameRateFromResolutionIndicators(nameLower); if (!result.frameSize) - result.frameSize = guessFrameSizeFromAcronymResolutionIndicators(name); + result.frameSize = guessFrameSizeFromAcronymResolutionIndicators(nameLower); if (!result.frameSize) continue; if (!result.frameRate) - result.frameRate = guessFPSFromFPSOrHzIndicators(name); + result.frameRate = guessFPSFromFPSOrHzIndicators(nameLower); if (!result.bitDepth) - result.bitDepth = guessBitDepthFromName(name); + result.bitDepth = guessBitDepthFromName(nameLower); - result.dataLayout = guessIsPackedFromName(name); + if (!result.dataLayout) + result.dataLayout = guessIsPackedFromName(nameLower); } return result; diff --git a/YUViewLib/src/video/rgb/PixelFormatRGBGuess.cpp b/YUViewLib/src/video/rgb/PixelFormatRGBGuess.cpp index e6a344b03..56539cc27 100644 --- a/YUViewLib/src/video/rgb/PixelFormatRGBGuess.cpp +++ b/YUViewLib/src/video/rgb/PixelFormatRGBGuess.cpp @@ -44,6 +44,11 @@ using filesource::frameFormatGuess::GuessedFrameFormat; namespace video::rgb { +namespace +{ + +const auto DEFAULT_PIXEL_FORMAT = PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RGB); + DataLayout findDataLayoutInName(const std::string &fileName) { std::string matcher = "(?:_|\\.|-)(packed|planar)(?:_|\\.|-)"; @@ -74,6 +79,8 @@ bool doesPixelFormatMatchFileSize(const PixelFormatRGB &pixelFormat, return isFileSizeAMultipleOfFrameSize; } +} // namespace + std::optional checkForPixelFormatIndicatorInName( const std::string &filename, const Size &frameSize, const std::optional &fileSize) { @@ -141,7 +148,7 @@ std::optional checkForPixelFormatIndicatorInFileExtension( for (const auto &[channelOrder, name] : ChannelOrderMapper) { - if (fileExtension == functions::toLower(name)) + if (fileExtension == ("." + functions::toLower(name))) { auto format = PixelFormatRGB(8, DataLayout::Packed, channelOrder); if (doesPixelFormatMatchFileSize(format, frameSize, fileSize)) @@ -160,7 +167,7 @@ std::optional checkSpecificFileExtensions( { const auto fileExtension = std::filesystem::path(filename).extension(); - if (fileExtension == "cmyk") + if (fileExtension == ".cmyk") { const auto format = PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RGB, AlphaMode::Last); if (doesPixelFormatMatchFileSize(format, frameSize, fileSize)) @@ -194,6 +201,9 @@ PixelFormatRGB guessPixelFormatFromSizeAndName(const GuessedFrameFormat &guessed functions::toLower(fileInfo.parentFolderName), frameSize, fileSize)) return *pixelFormat; + if (guessedFrameFormat.frameSize) + return DEFAULT_PIXEL_FORMAT; + return {}; } diff --git a/YUViewLib/src/video/yuv/PixelFormatYUVGuess.cpp b/YUViewLib/src/video/yuv/PixelFormatYUVGuess.cpp index d03dff2fe..69a8d43ea 100644 --- a/YUViewLib/src/video/yuv/PixelFormatYUVGuess.cpp +++ b/YUViewLib/src/video/yuv/PixelFormatYUVGuess.cpp @@ -62,19 +62,11 @@ Subsampling findSubsamplingTypeIndicatorInName(const std::string &name) return Subsampling::UNKNOWN; } -std::vector -getDetectionBitDepthList(const std::optional &bitDepthToForceAsFirst) +std::vector getDetectionBitDepthList(const std::optional &detectedBitrate) { - std::vector bitDepthList; - if (bitDepthToForceAsFirst && *bitDepthToForceAsFirst >= 8 && *bitDepthToForceAsFirst <= 16) - bitDepthList.push_back(*bitDepthToForceAsFirst); - - for (auto bitDepth : {10u, 12u, 14u, 16u, 8u}) - { - if (bitDepth == bitDepthToForceAsFirst) - bitDepthList.push_back(bitDepth); - } - return bitDepthList; + if (detectedBitrate) + return {*detectedBitrate}; + return {10u, 12u, 14u, 16u, 8u}; } std::vector getDetectionSubsamplingList(Subsampling subsamplingToForceAsFirst, @@ -96,7 +88,7 @@ std::vector getDetectionSubsamplingList(Subsampling subsamplingToFo if (subsamplingToForceAsFirst != Subsampling::UNKNOWN) subsamplingList.push_back(subsamplingToForceAsFirst); for (auto subsampling : detectionSubsampleList) - if (subsampling == subsamplingToForceAsFirst) + if (subsampling != subsamplingToForceAsFirst) subsamplingList.push_back(subsampling); return subsamplingList; } @@ -247,7 +239,7 @@ checkSpecificFileExtensions(const GuessedFrameFormat &guessedFrameFormat, { const auto fileExtension = std::filesystem::path(fileInfo.filename).extension(); - if (fileExtension == "raw") + if (fileExtension == ".raw") { const auto rawBayerFormat = PixelFormatYUV(Subsampling::YUV_400, guessedFrameFormat.bitDepth.value_or(8)); @@ -256,7 +248,7 @@ checkSpecificFileExtensions(const GuessedFrameFormat &guessedFrameFormat, return rawBayerFormat; } - if (fileExtension == "v210" || fileExtension == "V210") + if (fileExtension == ".v210" || fileExtension == ".V210") { const auto v210Format = PixelFormatYUV(PredefinedPixelFormat::V210); if (doesPixelFormatMatchFileSize(v210Format, *guessedFrameFormat.frameSize, fileInfo.fileSize)) @@ -383,22 +375,18 @@ checkForSubsamplingIndiatorInName(const std::string &name, std::optional ignoreNameAndJustCheckIfSomeBasicFormatsMatchTheFileSize( const GuessedFrameFormat &guessedFrameFormat, const FileInfoForGuess &fileInfo) { - // Nothing using the name worked so far. Check some formats. The first one that matches the file - // size wins. const auto testSubsamplings = std::vector({Subsampling::YUV_420, Subsampling::YUV_444, Subsampling::YUV_422}); std::vector testBitDepths; - if (guessedFrameFormat.bitDepth != 0) - // We already extracted a bit depth from the name. Only try that. + if (guessedFrameFormat.bitDepth) testBitDepths.push_back(*guessedFrameFormat.bitDepth); else - // We don't know the bit depth. Try different values. testBitDepths = {8, 9, 10, 12, 14, 16}; for (const auto &subsampling : testSubsamplings) { - for (auto bd : testBitDepths) + for (const auto bd : testBitDepths) { auto fmt = PixelFormatYUV(subsampling, bd, PlaneOrder::YUV); if (doesPixelFormatMatchFileSize(fmt, *guessedFrameFormat.frameSize, fileInfo.fileSize)) diff --git a/YUViewUnitTest/filesource/FormatGuessingParameters.h b/YUViewUnitTest/filesource/FormatGuessingParameters.h index 359e790c0..a06db3711 100644 --- a/YUViewUnitTest/filesource/FormatGuessingParameters.h +++ b/YUViewUnitTest/filesource/FormatGuessingParameters.h @@ -38,21 +38,23 @@ namespace filesource::frameFormatGuess::test { -static std::string -formatFileInfoForGuessAndGuessedFrameFormat(const FileInfoForGuess &fileInfoForGuess, - const GuessedFrameFormat &guessedFrameFormat) +static std::string formatFileInfoForGuessForTestName(const FileInfoForGuess &fileInfoForGuess) { - auto name = yuviewTest::formatTestName("TestName", - fileInfoForGuess.filename, - "ParentPath", - fileInfoForGuess.parentFolderName, - "fileSize", - fileInfoForGuess.fileSize, - "Size", + return yuviewTest::formatTestName("Filename", + fileInfoForGuess.filename, + "parentFolderName", + fileInfoForGuess.parentFolderName, + "fileSize", + fileInfoForGuess.fileSize); +} + +static std::string formatGuessedFrameFormatForTestName(const GuessedFrameFormat &guessedFrameFormat) +{ + auto name = yuviewTest::formatTestName("frameSize", guessedFrameFormat.frameSize, - "fps", + "frameRate", guessedFrameFormat.frameRate, - "BitDepth", + "bitDepth", guessedFrameFormat.bitDepth); name += "_DataLayout_"; diff --git a/YUViewUnitTest/filesource/guessFormatFromFilenameTest.cpp b/YUViewUnitTest/filesource/guessFormatFromFilenameTest.cpp index 5f382261c..0f4326d5d 100644 --- a/YUViewUnitTest/filesource/guessFormatFromFilenameTest.cpp +++ b/YUViewUnitTest/filesource/guessFormatFromFilenameTest.cpp @@ -50,7 +50,8 @@ class GuessFormatFromFilenameTest : public TestWithParam std::string getTestName(const testing::TestParamInfo &testParam) { const auto [fileInfoForGuess, expectedFormat] = testParam.param; - return formatFileInfoForGuessAndGuessedFrameFormat(fileInfoForGuess, expectedFormat); + return formatFileInfoForGuessForTestName(fileInfoForGuess) + "_" + + formatGuessedFrameFormatForTestName(expectedFormat); } TEST_P(GuessFormatFromFilenameTest, TestFormatFromFilename) @@ -66,6 +67,7 @@ INSTANTIATE_TEST_SUITE_P( FilesourceTest, GuessFormatFromFilenameTest, Values( + // Resolution must use an 'x' (case irrelevant) or a '*' between width/height std::make_pair(FileInfoForGuess({"something_1920x1080.yuv", "", {}}), ExpectedGuessResult({Size(1920, 1080), {}, {}, {}})), std::make_pair(FileInfoForGuess({"something_295x289.yuv", "", {}}), @@ -78,15 +80,18 @@ INSTANTIATE_TEST_SUITE_P( ExpectedGuessResult({Size(1920, 1080), {}, {}, {}})), std::make_pair(FileInfoForGuess({"something_1920x1080_something.yuv", "", {}}), ExpectedGuessResult({Size(1920, 1080), {}, {}, {}})), + + // Other characters are not supported std::make_pair(FileInfoForGuess({"something_1920_1080.yuv", "", {}}), - ExpectedGuessResult({Size(0, 0), {}, {}, {}})), + ExpectedGuessResult({{}, {}, {}, {}})), std::make_pair(FileInfoForGuess({"something_19201080.yuv", "", {}}), - ExpectedGuessResult({Size(0, 0), {}, {}, {}})), + ExpectedGuessResult({{}, {}, {}, {}})), std::make_pair(FileInfoForGuess({"something_1280-720.yuv", "", {}}), - ExpectedGuessResult({Size(0, 0), {}, {}, {}})), + ExpectedGuessResult({{}, {}, {}, {}})), std::make_pair(FileInfoForGuess({"something_1920-1080_something.yuv", "", {}}), - ExpectedGuessResult({Size(0, 0), {}, {}, {}})), + ExpectedGuessResult({{}, {}, {}, {}})), + // Test fps detection with 'xxxhz' or 'xxfps'. Cases should not matter. std::make_pair(FileInfoForGuess({"something_1920x1080_25.yuv", "", {}}), ExpectedGuessResult({Size(1920, 1080), 25, {}, {}})), std::make_pair(FileInfoForGuess({"something_1920x1080_999.yuv", "", {}}), @@ -99,10 +104,17 @@ INSTANTIATE_TEST_SUITE_P( ExpectedGuessResult({Size(1920, 1080), 60, {}, {}})), std::make_pair(FileInfoForGuess({"something_1920x1080_60HZ.yuv", "", {}}), ExpectedGuessResult({Size(1920, 1080), 60, {}, {}})), + std::make_pair(FileInfoForGuess({"something_1920x1080_60hZ.yuv", "", {}}), + ExpectedGuessResult({Size(1920, 1080), 60, {}, {}})), std::make_pair(FileInfoForGuess({"something_1920x1080_60fps.yuv", "", {}}), ExpectedGuessResult({Size(1920, 1080), 60, {}, {}})), std::make_pair(FileInfoForGuess({"something_1920x1080_60FPS.yuv", "", {}}), ExpectedGuessResult({Size(1920, 1080), 60, {}, {}})), + std::make_pair(FileInfoForGuess({"something_1920x1080_60fPs.yuv", "", {}}), + ExpectedGuessResult({Size(1920, 1080), 60, {}, {}})), + // The indicator can even be anywhere + std::make_pair(FileInfoForGuess({"something240fPssomething_1920x1080.yuv", "", {}}), + ExpectedGuessResult({Size(1920, 1080), 240, {}, {}})), std::make_pair(FileInfoForGuess({"something_1920x1080_25_8.yuv", "", {}}), ExpectedGuessResult({Size(1920, 1080), 25, 8, {}})), diff --git a/YUViewUnitTest/video/rgb/PixelFormatRGBGuessTest.cpp b/YUViewUnitTest/video/rgb/PixelFormatRGBGuessTest.cpp index 5f104f29c..3b132a8f7 100644 --- a/YUViewUnitTest/video/rgb/PixelFormatRGBGuessTest.cpp +++ b/YUViewUnitTest/video/rgb/PixelFormatRGBGuessTest.cpp @@ -43,9 +43,8 @@ using filesource::frameFormatGuess::GuessedFrameFormat; struct TestParameters { - FileInfoForGuess fileInfoForGuess; - GuessedFrameFormat guessedFrameFormat; - PixelFormatRGB expectedPixelFormat{}; + FileInfoForGuess fileInfoForGuess; + PixelFormatRGB expectedPixelFormat{}; }; class GuessRGBFormatFromFilenameFrameSizeAndFileSize : public TestWithParam @@ -55,22 +54,24 @@ class GuessRGBFormatFromFilenameFrameSizeAndFileSize : public TestWithParam &testParametersInfo) { const auto testParameters = testParametersInfo.param; - auto name = filesource::frameFormatGuess::test::formatFileInfoForGuessAndGuessedFrameFormat( - testParameters.fileInfoForGuess, testParameters.guessedFrameFormat); - name += - "_" + yuviewTest::replaceNonSupportedCharacters(testParameters.expectedPixelFormat.getName()); - return name; + return filesource::frameFormatGuess::test::formatFileInfoForGuessForTestName( + testParameters.fileInfoForGuess) + + "_" + + yuviewTest::replaceNonSupportedCharacters(testParameters.expectedPixelFormat.getName()); } TEST_P(GuessRGBFormatFromFilenameFrameSizeAndFileSize, TestGuess) { const auto parameters = GetParam(); - const auto guessedRGBFormat = video::rgb::guessPixelFormatFromSizeAndName( - parameters.guessedFrameFormat, parameters.fileInfoForGuess); + const auto guessedFrameFormat = + filesource::frameFormatGuess::guessFrameFormat(parameters.fileInfoForGuess); - EXPECT_TRUE(guessedRGBFormat.isValid()); - EXPECT_EQ(guessedRGBFormat, parameters.expectedPixelFormat); + const auto guessedFormat = + video::rgb::guessPixelFormatFromSizeAndName(guessedFrameFormat, parameters.fileInfoForGuess); + + EXPECT_EQ(guessedFormat.isValid(), parameters.expectedPixelFormat.isValid()); + EXPECT_EQ(guessedFormat, parameters.expectedPixelFormat); } constexpr auto BytesNoAlpha = 1920u * 1080 * 12u * 3u; // 12 frames RGB @@ -84,159 +85,132 @@ INSTANTIATE_TEST_SUITE_P( Values( // Cases that should not detect anything TestParameters({FileInfoForGuess({"noIndicatorHere.yuv", "", 0}), - GuessedFrameFormat({Size(0, 0), {}, {}, {}}), - PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RGB)}), + PixelFormatRGB()}), TestParameters({FileInfoForGuess({"something_1920x1080.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RGB)}), // No Alpha TestParameters({FileInfoForGuess({"something_1920x1080_rgb.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RGB)}), TestParameters({FileInfoForGuess({"something_1920x1080_rbg.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RBG)}), TestParameters({FileInfoForGuess({"something_1920x1080_grb.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::GRB)}), TestParameters({FileInfoForGuess({"something_1920x1080_gbr.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::GBR)}), TestParameters({FileInfoForGuess({"something_1920x1080_brg.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::BRG)}), TestParameters({FileInfoForGuess({"something_1920x1080_bgr.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::BGR)}), // Alpha First TestParameters( {FileInfoForGuess({"something_1920x1080_argb.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RGB, AlphaMode::First)}), TestParameters( {FileInfoForGuess({"something_1920x1080_arbg.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RBG, AlphaMode::First)}), TestParameters( {FileInfoForGuess({"something_1920x1080_agrb.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::GRB, AlphaMode::First)}), TestParameters( {FileInfoForGuess({"something_1920x1080_agbr.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::GBR, AlphaMode::First)}), TestParameters( {FileInfoForGuess({"something_1920x1080_abrg.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::BRG, AlphaMode::First)}), TestParameters( {FileInfoForGuess({"something_1920x1080_abgr.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::BGR, AlphaMode::First)}), // Alpha Last TestParameters({FileInfoForGuess({"something_1920x1080_rgba.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RGB, AlphaMode::Last)}), TestParameters({FileInfoForGuess({"something_1920x1080_rbga.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RBG, AlphaMode::Last)}), TestParameters({FileInfoForGuess({"something_1920x1080_grba.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::GRB, AlphaMode::Last)}), TestParameters({FileInfoForGuess({"something_1920x1080_gbra.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::GBR, AlphaMode::Last)}), TestParameters({FileInfoForGuess({"something_1920x1080_brga.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::BRG, AlphaMode::Last)}), TestParameters({FileInfoForGuess({"something_1920x1080_bgra.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::BGR, AlphaMode::Last)}), // Bit dephts TestParameters({FileInfoForGuess({"something_1920x1080_rgb10.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(10, DataLayout::Packed, ChannelOrder::RGB)}), TestParameters({FileInfoForGuess({"something_1920x1080_rgb12.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(12, DataLayout::Packed, ChannelOrder::RGB)}), TestParameters({FileInfoForGuess({"something_1920x1080_rgb16.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(16, DataLayout::Packed, ChannelOrder::RGB)}), TestParameters({FileInfoForGuess({"something_1920x1080_rgb48.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(16, DataLayout::Packed, ChannelOrder::RGB)}), TestParameters({FileInfoForGuess({"something_1920x1080_rgb64.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(16, DataLayout::Packed, ChannelOrder::RGB)}), TestParameters({FileInfoForGuess({"something_1920x1080_rgb11.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RGB)}), // Endianness TestParameters({FileInfoForGuess({"something_1920x1080_rgb8le.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RGB)}), TestParameters({FileInfoForGuess({"something_1920x1080_rgb8be.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RGB)}), TestParameters({FileInfoForGuess({"something_1920x1080_rgb10le.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(10, DataLayout::Packed, ChannelOrder::RGB)}), TestParameters( {FileInfoForGuess({"something_1920x1080_rgb10be.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB( 10, DataLayout::Packed, ChannelOrder::RGB, AlphaMode::None, Endianness::Big)}), TestParameters( {FileInfoForGuess({"something_1920x1080_rgb16be.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB( 16, DataLayout::Packed, ChannelOrder::RGB, AlphaMode::None, Endianness::Big)}), // DataLayout TestParameters({FileInfoForGuess({"something_1920x1080_rgb_packed.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RGB)}), TestParameters({FileInfoForGuess({"something_1920x1080_rgb_planar.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Planar, ChannelOrder::RGB)}), TestParameters( {FileInfoForGuess({"something_1920x1080_rgb10le_planar.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(10, DataLayout::Planar, ChannelOrder::RGB)}), TestParameters( {FileInfoForGuess({"something_1920x1080_rgb10be_planar.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB( 10, DataLayout::Planar, ChannelOrder::RGB, AlphaMode::None, Endianness::Big)}), TestParameters( {FileInfoForGuess({"something_1920x1080_rgb16_planar.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(16, DataLayout::Planar, ChannelOrder::RGB)}), TestParameters( {FileInfoForGuess({"something_1920x1080_rgb16be_planar.yuv", "", BytesNoAlpha}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB( 16, DataLayout::Planar, ChannelOrder::RGB, AlphaMode::None, Endianness::Big)}), // File size check TestParameters({FileInfoForGuess({"something_1920x1080_rgb10.yuv", "", NotEnoughBytes}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RGB)}), TestParameters({FileInfoForGuess({"something_1920x1080_rgb16be.yuv", "", NotEnoughBytes}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RGB)}), TestParameters({FileInfoForGuess({"something_1920x1080_rgb16be.yuv", "", UnfittingBytes}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RGB)}), + // Format from file extension + TestParameters({FileInfoForGuess({"something_1920x1080.rgb", "", BytesNoAlpha}), + PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RGB)}), + TestParameters({FileInfoForGuess({"something_1920x1080.rbg", "", BytesNoAlpha}), + PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RBG)}), + TestParameters({FileInfoForGuess({"something_1920x1080.grb", "", BytesNoAlpha}), + PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::GRB)}), + TestParameters({FileInfoForGuess({"something_1920x1080.gbr", "", BytesNoAlpha}), + PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::GBR)}), + TestParameters({FileInfoForGuess({"something_1920x1080.brg", "", BytesNoAlpha}), + PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::BRG)}), + TestParameters({FileInfoForGuess({"something_1920x1080.bgr", "", BytesNoAlpha}), + PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::BGR)}), + // CMYK file TestParameters({FileInfoForGuess({"something_512x768.cmyk", "", BytesBayerFile}), - GuessedFrameFormat({Size(1920, 1080), {}, {}, {}}), PixelFormatRGB(8, DataLayout::Packed, ChannelOrder::RGB, AlphaMode::Last)}) ), diff --git a/YUViewUnitTest/video/yuv/PixelFormatYUVGuessTest.cpp b/YUViewUnitTest/video/yuv/PixelFormatYUVGuessTest.cpp index 4323a6acb..d72707e8e 100644 --- a/YUViewUnitTest/video/yuv/PixelFormatYUVGuessTest.cpp +++ b/YUViewUnitTest/video/yuv/PixelFormatYUVGuessTest.cpp @@ -33,6 +33,7 @@ #include #include +#include #include