From a2bbbab3d22af7ce684931cf321d07819ccbdfd3 Mon Sep 17 00:00:00 2001 From: for13to1 Date: Sat, 27 Jun 2026 21:47:07 +0800 Subject: [PATCH] fix: default to YUV_400 format for .raw files - Initialize YUV video handler to YUV_400 for .raw extension files - Guard against empty frameSize optional in checkSpecificFileExtensions --- YUViewLib/src/playlistitem/playlistItemRawFile.cpp | 4 ++++ YUViewLib/src/video/yuv/PixelFormatYUVGuess.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/YUViewLib/src/playlistitem/playlistItemRawFile.cpp b/YUViewLib/src/playlistitem/playlistItemRawFile.cpp index d3d2054fb..0ae98f5fb 100644 --- a/YUViewLib/src/playlistitem/playlistItemRawFile.cpp +++ b/YUViewLib/src/playlistitem/playlistItemRawFile.cpp @@ -104,6 +104,10 @@ playlistItemRawFile::playlistItemRawFile(const QString &rawFilePath, { this->video = std::make_unique(); this->rawFormat = video::RawFormat::YUV; + if (isInExtensions(ext, RAW_BAYER_EXTENSIONS)) + { + this->getYUVVideo()->setPixelFormatYUV(video::yuv::PixelFormatYUV(video::yuv::Subsampling::YUV_400, 8, video::yuv::PlaneOrder::YUV)); + } } else if (isInExtensions(ext, RGB_EXTENSIONS) || isInExtensions(ext, RGBA_EXTENSIONS) || isInExtensions(ext, CMYK_EXTENSIONS) || fmt.toLower() == "rgb") diff --git a/YUViewLib/src/video/yuv/PixelFormatYUVGuess.cpp b/YUViewLib/src/video/yuv/PixelFormatYUVGuess.cpp index 69a8d43ea..94300d437 100644 --- a/YUViewLib/src/video/yuv/PixelFormatYUVGuess.cpp +++ b/YUViewLib/src/video/yuv/PixelFormatYUVGuess.cpp @@ -243,6 +243,8 @@ checkSpecificFileExtensions(const GuessedFrameFormat &guessedFrameFormat, { const auto rawBayerFormat = PixelFormatYUV(Subsampling::YUV_400, guessedFrameFormat.bitDepth.value_or(8)); + if (!guessedFrameFormat.frameSize) + return rawBayerFormat; if (doesPixelFormatMatchFileSize( rawBayerFormat, *guessedFrameFormat.frameSize, fileInfo.fileSize)) return rawBayerFormat;