From 20b2d697f7b66f2f89278f28dacb2ed19cdecaee Mon Sep 17 00:00:00 2001 From: ChristianFeldmann Date: Thu, 5 Dec 2024 22:20:47 +0100 Subject: [PATCH] Use more ByteVector --- .../src/playlistitem/playlistItemRawFile.cpp | 84 +++++++++++++------ .../src/playlistitem/playlistItemRawFile.h | 19 ++--- YUViewLib/src/video/rgb/videoHandlerRGB.cpp | 2 +- YUViewLib/src/video/rgb/videoHandlerRGB.h | 2 +- YUViewLib/src/video/videoHandler.cpp | 16 ++-- YUViewLib/src/video/videoHandler.h | 8 +- YUViewLib/src/video/yuv/videoHandlerYUV.cpp | 50 +++++------ YUViewLib/src/video/yuv/videoHandlerYUV.h | 8 +- 8 files changed, 107 insertions(+), 82 deletions(-) diff --git a/YUViewLib/src/playlistitem/playlistItemRawFile.cpp b/YUViewLib/src/playlistitem/playlistItemRawFile.cpp index 1fc6b18a2..1b8bbf7b9 100644 --- a/YUViewLib/src/playlistitem/playlistItemRawFile.cpp +++ b/YUViewLib/src/playlistitem/playlistItemRawFile.cpp @@ -67,6 +67,18 @@ bool isInExtensions(const QString &testValue, const std::initializer_listprop.isFileSource = true; this->prop.propertiesWidgetTitle = "Raw File Properties"; - this->dataSource.openFile(std::filesystem::path(rawFilePath.toStdString())); + this->dataSource = std::make_unique( + std::filesystem::path(rawFilePath.toStdString())); - if (!this->dataSource.isOk()) + if (!this->dataSource->isOk()) { - // Opening the file failed. this->setError("Error opening the input file."); return; } @@ -133,9 +145,9 @@ playlistItemRawFile::playlistItemRawFile(const QString &rawFilePath, if (!this->video->isFormatValid()) { // Load 24883200 bytes from the input and try to get the format from the correlation. - QByteArray rawData; - this->dataSource.readBytes(rawData, 0, 24883200); - this->video->setFormatFromCorrelation(rawData, this->dataSource.getFileSize().value_or(-1)); + ByteVector rawData; + this->dataSource->read(rawData, 24883200); + this->video->setFormatFromCorrelation(rawData, this->dataSource->getFileSize().value_or(-1)); } } else @@ -172,7 +184,7 @@ playlistItemRawFile::playlistItemRawFile(const QString &rawFilePath, void playlistItemRawFile::updateStartEndRange() { - if (!this->dataSource.isOk() || !this->video->isFormatValid()) + if (!this->dataSource->isOk() || !this->video->isFormatValid()) { this->prop.startEndRange = indexRange(-1, -1); return; @@ -189,7 +201,7 @@ void playlistItemRawFile::updateStartEndRange() this->prop.startEndRange = indexRange(-1, -1); return; } - nrFrames = this->dataSource.getFileSize().value_or(0) / bpf; + nrFrames = this->dataSource->getFileSize().value_or(0) / bpf; } this->prop.startEndRange = indexRange(0, std::max(nrFrames - 1, 0)); @@ -200,7 +212,7 @@ InfoData playlistItemRawFile::getInfo() const InfoData info((rawFormat == video::RawFormat::YUV) ? "YUV File Info" : "RGB File Info"); // At first append the file information part (path, date created, file size...) - for (const auto &infoItem : this->dataSource.getFileInfoList()) + for (const auto &infoItem : this->dataSource->getInfoList()) info.items.append(infoItem); const auto nrFrames = @@ -208,14 +220,14 @@ InfoData playlistItemRawFile::getInfo() const info.items.append(InfoItem("Num Frames", std::to_string(nrFrames))); info.items.append(InfoItem("Bytes per Frame", std::to_string(this->video->getBytesPerFrame()))); - if (this->dataSource.isOk() && this->video->isFormatValid() && !this->isY4MFile) + if (this->dataSource->isOk() && this->video->isFormatValid() && !this->isY4MFile) { // Check if the size of the file and the number of bytes per frame can be divided // without any remainder. If not, then there is probably something wrong with the // selected YUV format / width / height ... auto bpf = this->video->getBytesPerFrame(); - if (const auto fileSize = this->dataSource.getFileSize()) + if (const auto fileSize = this->dataSource->getFileSize()) { if ((*fileSize % bpf) != 0) info.items.append(InfoItem( @@ -232,13 +244,13 @@ bool playlistItemRawFile::parseY4MFile() { // Read a chunck of data from the file. Thecnically, the header can be arbitrarily long, but in // practice, 512 bytes should cover the length of all headers - QByteArray rawData; - this->dataSource.readBytes(rawData, 0, 512); + ByteVector rawData; + this->dataSource->read(rawData, 512); DEBUG_RAWFILE("playlistItemRawFile::parseY4MFile Read Y4M"); // A Y4M file must start with the signature string "YUV4MPEG2 ". - if (rawData.left(10) != "YUV4MPEG2 ") + if (extractStringFromByteVector(rawData, 0, 10) != "YUV4MPEG2 ") return setError("Y4M File header does not start with YUV4MPEG2 header signature."); DEBUG_RAWFILE("playlistItemRawFile::parseY4MFile Found signature YUV4MPEG2"); @@ -319,7 +331,7 @@ bool playlistItemRawFile::parseY4MFile() else if (parameterIndicator == 'C') { // Get 3 bytes and check them - auto formatName = rawData.mid(offset, 3); + const auto formatName = extractStringFromByteVector(rawData, offset, 3); offset += 3; // The YUV format. By default, YUV420 is setup. @@ -405,10 +417,13 @@ bool playlistItemRawFile::parseY4MFile() while (true) { // Seek the file to 'offset' and read a few bytes - if (this->dataSource.readBytes(rawData, offset, 20) < 20) + if (!this->dataSource->seek(offset)) + return setError( + QString("Error parsing the Y4M header: Unable to seek to position %1").arg(offset)); + if (this->dataSource->read(rawData, 20) < 20) return setError("Error parsing the Y4M header: The file ended unexpectedly."); - auto frameIndicator = rawData.mid(0, 5); + const auto frameIndicator = extractStringFromByteVector(rawData, 0, 5); if (frameIndicator != "FRAME") return setError("Error parsing the Y4M header: Could not locate the next 'FRAME' indicator."); @@ -434,7 +449,7 @@ bool playlistItemRawFile::parseY4MFile() DEBUG_RAWFILE("playlistItemRawFile::parseY4MFile Found FRAME at offset " << offset); offset += stride; - if (offset >= this->dataSource.getFileSize()) + if (offset >= this->dataSource->getFileSize()) break; } @@ -449,8 +464,8 @@ bool playlistItemRawFile::parseY4MFile() void playlistItemRawFile::setFormatFromFileName() { - const auto fileInfoForGuess = filesource::frameFormatGuess::getFileInfoForGuessFromPath( - this->dataSource.getAbsoluteFilePath()); + const auto fileInfoForGuess = + filesource::frameFormatGuess::getFileInfoForGuessFromPath(this->dataSource->getFilePath()); const auto frameFormat = filesource::frameFormatGuess::guessFrameFormat(fileInfoForGuess); @@ -491,10 +506,10 @@ void playlistItemRawFile::createPropertiesWidget() void playlistItemRawFile::savePlaylist(QDomElement &root, const QDir &playlistDir) const { - QUrl fileURL(QString::fromStdString(dataSource.getAbsoluteFilePath())); + QUrl fileURL(QString::fromStdString(dataSource->getFilePath())); fileURL.setScheme("file"); auto relativePath = - playlistDir.relativeFilePath(QString::fromStdString(dataSource.getAbsoluteFilePath())); + playlistDir.relativeFilePath(QString::fromStdString(dataSource->getFilePath())); auto d = YUViewDomElement(root.ownerDocument().createElement("playlistItemRawFile")); @@ -550,7 +565,9 @@ void playlistItemRawFile::loadRawData(int frameIdx) DEBUG_RAWFILE("playlistItemRawFile::loadRawData Start loading frame " << frameIdx << " bytes " << int(nrBytes)); - if (this->dataSource.readBytes(this->video->rawData, fileStartPos, nrBytes) < nrBytes) + if (!this->dataSource->seek(fileStartPos)) + return; + if (this->dataSource->read(this->video->rawData, nrBytes) < nrBytes) return; // Error this->video->rawData_frameIndex = frameIdx; @@ -589,12 +606,18 @@ void playlistItemRawFile::getSupportedFileExtensions(QStringList &allExtensions, filters.append("Raw CMYK File (*.cmyk)"); } +bool playlistItemRawFile::isSourceChanged() +{ + if (!this->dataSource) + return false; + return this->dataSource->wasSourceModified(); +} + void playlistItemRawFile::reloadItemSource() { // Reopen the file - this->dataSource.openFile(this->properties().name.toStdString()); - if (!this->dataSource.isOk()) - // Opening the file failed. + this->dataSource->reloadAndResetDataSource(); + if (!this->dataSource->isOk()) return; this->video->invalidateAllBuffers(); @@ -603,3 +626,12 @@ void playlistItemRawFile::reloadItemSource() // Emit that the item needs redrawing and the cache changed. emit SignalItemChanged(true, RECACHE_NONE); } + +void playlistItemRawFile::cacheFrame(int idx, bool testMode) +{ + if (!this->dataSource) + return; + if (testMode) + this->dataSource->clearFileCache(); + playlistItemWithVideo::cacheFrame(idx, testMode); +} diff --git a/YUViewLib/src/playlistitem/playlistItemRawFile.h b/YUViewLib/src/playlistitem/playlistItemRawFile.h index d28688195..171ca34d4 100644 --- a/YUViewLib/src/playlistitem/playlistItemRawFile.h +++ b/YUViewLib/src/playlistitem/playlistItemRawFile.h @@ -33,7 +33,8 @@ #pragma once #include -#include +#include +#include #include #include @@ -64,7 +65,7 @@ class playlistItemRawFile : public playlistItemWithVideo // Create a new playlistItemRawFile from the playlist file entry. Return nullptr if parsing // failed. static playlistItemRawFile *newplaylistItemRawFile(const YUViewDomElement &root, - const QString & playlistFilePath); + const QString &playlistFilePath); virtual bool canBeUsedInProcessing() const override { return true; } @@ -73,18 +74,10 @@ class playlistItemRawFile : public playlistItemWithVideo // Add the file type filters and the extensions of files that we can load. static void getSupportedFileExtensions(QStringList &allExtensions, QStringList &filters); - // ----- Detection of source/file change events ----- - virtual bool isSourceChanged() override { return this->dataSource.getAndResetFileChangedFlag(); } + virtual bool isSourceChanged() override; virtual void reloadItemSource() override; - virtual void updateSettings() override { this->dataSource.updateFileWatchSetting(); } - // Cache the given frame - virtual void cacheFrame(int idx, bool testMode) override - { - if (testMode) - dataSource.clearFileCache(); - playlistItemWithVideo::cacheFrame(idx, testMode); - } + virtual void cacheFrame(int idx, bool testMode) override; private slots: // Load the raw data for the given frame index from file. This slot is called by the videoHandler @@ -105,7 +98,7 @@ private slots: int getNumberFrames() const; - FileSource dataSource; + std::unique_ptr dataSource; void updateStartEndRange() override; diff --git a/YUViewLib/src/video/rgb/videoHandlerRGB.cpp b/YUViewLib/src/video/rgb/videoHandlerRGB.cpp index 93f28170e..f64a89310 100644 --- a/YUViewLib/src/video/rgb/videoHandlerRGB.cpp +++ b/YUViewLib/src/video/rgb/videoHandlerRGB.cpp @@ -211,7 +211,7 @@ QStringPairList videoHandlerRGB::getPixelValues(const QPoint &pixelPos, return values; } -void videoHandlerRGB::setFormatFromCorrelation(const QByteArray &, int64_t) +void videoHandlerRGB::setFormatFromCorrelation(const ByteVector &, int64_t) { /* TODO */ } diff --git a/YUViewLib/src/video/rgb/videoHandlerRGB.h b/YUViewLib/src/video/rgb/videoHandlerRGB.h index c4c7953ee..a2590bfac 100644 --- a/YUViewLib/src/video/rgb/videoHandlerRGB.h +++ b/YUViewLib/src/video/rgb/videoHandlerRGB.h @@ -85,7 +85,7 @@ class videoHandlerRGB : public videoHandler // Try to guess and set the format (frameSize/srcPixelFormat) from the raw RGB data. // If a file size is given, it is tested if the RGB format and the file size match. - virtual void setFormatFromCorrelation(const QByteArray &rawRGBData, + virtual void setFormatFromCorrelation(const ByteVector &rawRGBData, int64_t fileSize = -1) override; virtual QString getFormatAsString() const override diff --git a/YUViewLib/src/video/videoHandler.cpp b/YUViewLib/src/video/videoHandler.cpp index 796a61a6b..af8f7f08e 100644 --- a/YUViewLib/src/video/videoHandler.cpp +++ b/YUViewLib/src/video/videoHandler.cpp @@ -75,9 +75,9 @@ void videoHandler::setFrameSize(Size size) { if (size != frameSize) { - this->currentFrameRawData_frameIndex = -1; - this->currentImageIndex = -1; - this->rawData_frameIndex = -1; + this->currentFrameRawDataFrameIndex = -1; + this->currentImageIndex = -1; + this->rawData_frameIndex = -1; } FrameHandler::setFrameSize(size); @@ -221,7 +221,7 @@ void videoHandler::drawFrame(QPainter *painter, int frameIdx, double zoomFactor, } } -QImage videoHandler::calculateDifference(FrameHandler * item2, +QImage videoHandler::calculateDifference(FrameHandler *item2, const int frameIdxItem0, const int frameIdxItem1, QList &differenceInfoList, @@ -387,8 +387,8 @@ void videoHandler::loadFrameForCaching(int frameIndex, QImage &frameToCache) void videoHandler::invalidateAllBuffers() { - currentFrameRawData_frameIndex = -1; - rawData_frameIndex = -1; + currentFrameRawDataFrameIndex = -1; + rawData_frameIndex = -1; // Set the current frame in the buffer to be invalid currentImageIndex = -1; @@ -419,8 +419,8 @@ QLayout *videoHandler::createVideoHandlerControls(bool) ItemLoadingState videoHandler::needsLoadingRawValues(int frameIndex) { - return (this->currentFrameRawData_frameIndex == frameIndex) ? ItemLoadingState::LoadingNotNeeded - : ItemLoadingState::LoadingNeeded; + return (this->currentFrameRawDataFrameIndex == frameIndex) ? ItemLoadingState::LoadingNotNeeded + : ItemLoadingState::LoadingNeeded; } } // namespace video diff --git a/YUViewLib/src/video/videoHandler.h b/YUViewLib/src/video/videoHandler.h index ee3ed70e9..045722b2e 100644 --- a/YUViewLib/src/video/videoHandler.h +++ b/YUViewLib/src/video/videoHandler.h @@ -87,7 +87,7 @@ class videoHandler : public FrameHandler // Try to guess and set the format (frameSize/srcPixelFormat) from the raw data in the right raw // format. If a file size is given, it is tested if the guessed format and the file size match. // You can overload this for any specific raw format. The default implementation does nothing. - virtual void setFormatFromCorrelation(const QByteArray &, int64_t fileSize = -1) + virtual void setFormatFromCorrelation(const ByteVector &, int64_t fileSize = -1) { (void)fileSize; } @@ -131,7 +131,7 @@ class videoHandler : public FrameHandler // TODO: Explain better what the difference between these two is (currentFrameRawData and rawData) // A buffer with the raw RGB data (this is filled if signalRequestRawData() is emitted) - QByteArray rawData; + ByteVector rawData; int rawData_frameIndex{-1}; // Do we need to load the raw values (because they are drawn on screen?) @@ -186,8 +186,8 @@ class videoHandler : public FrameHandler // The buffer of the raw data (RGB or YUV) of the current frame (and its frame index) // Before using the currentFrameRawData, you have to check if the currentFrameRawData_frameIndex // is correct. If not, you have to call loadFrame() to load the frame and set it correctly. - QByteArray currentFrameRawData; - int currentFrameRawData_frameIndex{-1}; + ByteVector currentFrameRawData; + int currentFrameRawDataFrameIndex{-1}; // Set the cache to be invalid until a call to removefromCache(-1) clears it. void setCacheInvalid() { cacheValid = false; } diff --git a/YUViewLib/src/video/yuv/videoHandlerYUV.cpp b/YUViewLib/src/video/yuv/videoHandlerYUV.cpp index 825ae1602..5da0615f2 100644 --- a/YUViewLib/src/video/yuv/videoHandlerYUV.cpp +++ b/YUViewLib/src/video/yuv/videoHandlerYUV.cpp @@ -133,8 +133,8 @@ bool isFullRange(const ColorConversion colorConversion) colorConversion == ColorConversion::BT2020_FullRange; } -std::pair convertYUVPackedToPlanar(const QByteArray &sourceBuffer, - QByteArray &targetBuffer, +std::pair convertYUVPackedToPlanar(const ByteVector &sourceBuffer, + ByteVector &targetBuffer, const Size curFrameSize, const PixelFormatYUV &format) { @@ -299,8 +299,8 @@ std::pair convertYUVPackedToPlanar(const QByteArray &s return {true, newFormat}; } -std::pair convertV210PackedToPlanar(const QByteArray &sourceBuffer, - QByteArray &targetBuffer, +std::pair convertV210PackedToPlanar(const ByteVector &sourceBuffer, + ByteVector &targetBuffer, const Size curFrameSize) { // There are 6 pixels values per 16 bytes in the input. @@ -382,7 +382,7 @@ std::pair convertV210PackedToPlanar(const QByteArray &sour return {true, newFormat}; } -yuv_t getPixelValueV210(const QByteArray &sourceBuffer, +yuv_t getPixelValueV210(const ByteVector &sourceBuffer, const Size &curFrameSize, const QPoint &pixelPos) { @@ -433,7 +433,7 @@ yuv_t getPixelValueV210(const QByteArray &sourceBuffer, // yuvMath is supported. // TODO: Correct the chroma subsampling offset. template -bool convertYUV420ToRGB(const QByteArray &sourceBuffer, +bool convertYUV420ToRGB(const ByteVector &sourceBuffer, unsigned char *targetBuffer, const Size &size, const PixelFormatYUV &format, @@ -1988,7 +1988,7 @@ inline void YUVPlaneToRGB_411(const int w, } } -bool convertYUVPlanarToRGB(const QByteArray &sourceBuffer, +bool convertYUVPlanarToRGB(const ByteVector &sourceBuffer, uchar *targetBuffer, const Size curFrameSize, const PixelFormatYUV &sourceBufferFormat, @@ -2137,7 +2137,7 @@ bool convertYUVPlanarToRGB(const QByteArray &sourceBuffer, // If there is a chroma offset, we must resample the chroma components before we convert them // to RGB. If so, the resampled chroma values are saved in these arrays. We only ignore the // chroma offset for other interpolations then nearest neighbor. - QByteArray uvPlaneChromaResampled[2]; + ByteVector uvPlaneChromaResampled[2]; uvPlaneChromaResampled[0].resize(nrBytesChromaPlane); uvPlaneChromaResampled[1].resize(nrBytesChromaPlane); @@ -2378,13 +2378,13 @@ bool convertYUVPlanarToRGB(const QByteArray &sourceBuffer, // Convert the given raw YUV data in sourceBuffer (using srcPixelFormat) to image (RGB-888), using // the buffer tmpRGBBuffer for intermediate RGB values. -void convertYUVToImage(const QByteArray &sourceBuffer, +void convertYUVToImage(const ByteVector &sourceBuffer, QImage &outputImage, const PixelFormatYUV &yuvFormat, const Size &curFrameSize, const ConversionSettings &conversionSettings) { - if (!yuvFormat.canConvertToRGB(curFrameSize) || sourceBuffer.isEmpty()) + if (!yuvFormat.canConvertToRGB(curFrameSize) || sourceBuffer.empty()) { outputImage = QImage(); return; @@ -2447,7 +2447,7 @@ void convertYUVToImage(const QByteArray &sourceBuffer, else { // Convert to a planar format first - QByteArray tmpPlanarYUVSource; + ByteVector tmpPlanarYUVSource; // This is the current format of the buffer. The conversion function will change this. PixelFormatYUV newPixelFormat; @@ -2895,7 +2895,7 @@ void videoHandlerYUV::setSrcPixelFormat(PixelFormatYUV format, bool emitSignal) if (srcPixelFormat.bytesPerFrame(frameSize) != oldFormatBytesPerFrame) // The number of bytes per frame changed. The raw YUV data buffer is also out of date - this->currentFrameRawData_frameIndex = -1; + this->currentFrameRawDataFrameIndex = -1; emit signalHandlerChanged(true, RECACHE_CLEAR); } @@ -2950,7 +2950,7 @@ void videoHandlerYUV::slotYUVControlChanged() this->currentImage_frameIndex = -1; if (this->srcPixelFormat.bytesPerFrame(frameSize) != oldFormatBytesPerFrame) // The number of bytes per frame changed. The raw YUV data buffer also has to be updated. - this->currentFrameRawData_frameIndex = -1; + this->currentFrameRawDataFrameIndex = -1; this->setCacheInvalid(); emit signalHandlerChanged(true, RECACHE_CLEAR); } @@ -2976,8 +2976,8 @@ QStringPairList videoHandlerYUV::getPixelValues(const QPoint &pixelPos, return FrameHandler::getPixelValues(pixelPos, frameIdx, item2, frameIdx1); // Do not get the pixel values if the buffer for the raw YUV values is out of date. - if (currentFrameRawData_frameIndex != frameIdx || - yuvItem2->currentFrameRawData_frameIndex != frameIdx1) + if (currentFrameRawDataFrameIndex != frameIdx || + yuvItem2->currentFrameRawDataFrameIndex != frameIdx1) return QStringPairList(); int width = std::min(frameSize.width, yuvItem2->frameSize.width); @@ -3033,7 +3033,7 @@ QStringPairList videoHandlerYUV::getPixelValues(const QPoint &pixelPos, int height = frameSize.height; // Do not get the pixel values if the buffer for the raw YUV values is out of date. - if (currentFrameRawData_frameIndex != frameIdx) + if (currentFrameRawDataFrameIndex != frameIdx) return QStringPairList(); if (pixelPos.x() < 0 || pixelPos.x() >= width || pixelPos.y() < 0 || pixelPos.y() >= height) @@ -3106,9 +3106,9 @@ void videoHandlerYUV::drawPixelValues(QPainter *painter, // Check if the raw YUV values are up to date. If not, do not draw them. Do not trigger loading of // data here. The needsLoadingRawValues function will return that loading is needed. The caching // in the background should then trigger loading of them. - if (currentFrameRawData_frameIndex != frameIdx) + if (currentFrameRawDataFrameIndex != frameIdx) return; - if (yuvItem2 && yuvItem2->currentFrameRawData_frameIndex != frameIdxItem1) + if (yuvItem2 && yuvItem2->currentFrameRawDataFrameIndex != frameIdxItem1) return; // For difference items, we support difference bit depths for the two items. @@ -3298,7 +3298,7 @@ void videoHandlerYUV::guessAndSetPixelFormat( * that all formats are tested. If a file size is given, we test if the candidates frame size is a * multiple of the fileSize. If fileSize is -1, this test is skipped. */ -void videoHandlerYUV::setFormatFromCorrelation(const QByteArray &rawYUVData, int64_t fileSize) +void videoHandlerYUV::setFormatFromCorrelation(const ByteVector &rawYUVData, int64_t fileSize) { if (rawYUVData.size() < 1) return; @@ -3488,7 +3488,7 @@ void videoHandlerYUV::loadFrameForCaching(int frameIndex, QImage &frameToCache) requestDataMutex.lock(); emit signalRequestRawData(frameIndex, true); - QByteArray tmpBufferRawYUVDataCaching = rawData; + const auto tmpBufferRawYUVDataCaching = rawData; requestDataMutex.unlock(); if (frameIndex != rawData_frameIndex) @@ -3506,7 +3506,7 @@ void videoHandlerYUV::loadFrameForCaching(int frameIndex, QImage &frameToCache) // Load the raw YUV data for the given frame index into currentFrameRawData. bool videoHandlerYUV::loadRawYUVData(int frameIndex) { - if (currentFrameRawData_frameIndex == frameIndex && cacheValid) + if (currentFrameRawDataFrameIndex == frameIndex && cacheValid) // Buffer already up to date return true; @@ -3517,7 +3517,7 @@ bool videoHandlerYUV::loadRawYUVData(int frameIndex) requestDataMutex.lock(); emit signalRequestRawData(frameIndex, false); - if (frameIndex != rawData_frameIndex || rawData.isEmpty()) + if (frameIndex != rawData_frameIndex || rawData.empty()) { // Loading failed DEBUG_YUV("videoHandlerYUV::loadRawYUVData Loading failed"); @@ -3525,8 +3525,8 @@ bool videoHandlerYUV::loadRawYUVData(int frameIndex) return false; } - currentFrameRawData = rawData; - currentFrameRawData_frameIndex = frameIndex; + currentFrameRawData = rawData; + currentFrameRawDataFrameIndex = frameIndex; requestDataMutex.unlock(); DEBUG_YUV("videoHandlerYUV::loadRawYUVData " << frameIndex << " Done"); @@ -3694,7 +3694,7 @@ yuv_t videoHandlerYUV::getPixelValue(const QPoint &pixelPos) const return value; } -bool videoHandlerYUV::markDifferencesYUVPlanarToRGB(const QByteArray &sourceBuffer, +bool videoHandlerYUV::markDifferencesYUVPlanarToRGB(const ByteVector &sourceBuffer, unsigned char *targetBuffer, const Size curFrameSize, const PixelFormatYUV &sourceBufferFormat) const diff --git a/YUViewLib/src/video/yuv/videoHandlerYUV.h b/YUViewLib/src/video/yuv/videoHandlerYUV.h index 0e79d9ce9..091e56c67 100644 --- a/YUViewLib/src/video/yuv/videoHandlerYUV.h +++ b/YUViewLib/src/video/yuv/videoHandlerYUV.h @@ -130,7 +130,7 @@ class videoHandlerYUV : public videoHandler // Try to guess and set the format (frameSize/srcPixelFormat) from the raw YUV data. // If a file size is given, it is tested if the YUV format and the file size match. - virtual void setFormatFromCorrelation(const QByteArray &rawYUVData, + virtual void setFormatFromCorrelation(const ByteVector &rawYUVData, int64_t fileSize = -1) override; virtual QString getFormatAsString() const override @@ -183,7 +183,7 @@ class videoHandlerYUV : public videoHandler // -1. bool showPixelValuesAsDiff{false}; - QByteArray getDiffYUV() const { return this->diffYUV; }; + ByteVector getDiffYUV() const { return this->diffYUV; }; PixelFormatYUV getDiffYUVFormat() const { return this->diffYUVFormat; } bool isDiffReady() const { return this->diffReady; } @@ -219,7 +219,7 @@ class videoHandlerYUV : public videoHandler bool setFormatFromSizeAndNamePacked( QString name, const Size size, int bitDepth, Subsampling subsampling, int64_t fileSize); - bool markDifferencesYUVPlanarToRGB(const QByteArray &sourceBuffer, + bool markDifferencesYUVPlanarToRGB(const ByteVector &sourceBuffer, unsigned char *targetBuffer, const Size frameSize, const PixelFormatYUV &sourceBufferFormat) const; @@ -239,7 +239,7 @@ class videoHandlerYUV : public videoHandler SafeUi ui; bool diffReady{}; - QByteArray diffYUV; + ByteVector diffYUV; PixelFormatYUV diffYUVFormat{}; static std::vector formatPresetList;