From 94e061ab7001cef4a6de44533b6cc1dd532d1c4f Mon Sep 17 00:00:00 2001 From: Christian Feldmann Date: Sun, 3 Dec 2023 21:07:10 +0100 Subject: [PATCH] Implement the change a bit differently. --- YUViewLib/src/common/Typedef.h | 5 ----- YUViewLib/src/decoder/decoderDav1d.cpp | 7 +++++++ YUViewLib/src/decoder/decoderDav1d.h | 2 +- YUViewLib/src/ffmpeg/AVCodecContextWrapper.cpp | 4 +++- YUViewLib/src/playlistitem/playlistItemRawFile.cpp | 4 +++- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/YUViewLib/src/common/Typedef.h b/YUViewLib/src/common/Typedef.h index 65c3118f8..12a44b90c 100644 --- a/YUViewLib/src/common/Typedef.h +++ b/YUViewLib/src/common/Typedef.h @@ -263,11 +263,6 @@ struct Ratio struct Size { constexpr Size(unsigned width, unsigned height) : width(width), height(height) {} - constexpr Size(int width, int height) - { - this->width = (width < 0) ? 0 : static_cast(width); - this->height = (height < 0) ? 0 : static_cast(height); - } constexpr Size() = default; constexpr bool operator==(const Size &other) const diff --git a/YUViewLib/src/decoder/decoderDav1d.cpp b/YUViewLib/src/decoder/decoderDav1d.cpp index 895d75b96..8f7915671 100644 --- a/YUViewLib/src/decoder/decoderDav1d.cpp +++ b/YUViewLib/src/decoder/decoderDav1d.cpp @@ -89,6 +89,13 @@ Subsampling convertFromInternalSubsampling(Dav1dPixelLayout layout) } // namespace +Size Dav1dPictureWrapper::getFrameSize() const +{ + if (this->curPicture.p.w < 0 || this->curPicture.p.h < 0) + return {}; + return Size({static_cast(curPicture.p.w), static_cast(curPicture.p.h)}); +} + Subsampling Dav1dPictureWrapper::getSubsampling() const { return convertFromInternalSubsampling(curPicture.p.layout); diff --git a/YUViewLib/src/decoder/decoderDav1d.h b/YUViewLib/src/decoder/decoderDav1d.h index 640244b21..44333e3f2 100644 --- a/YUViewLib/src/decoder/decoderDav1d.h +++ b/YUViewLib/src/decoder/decoderDav1d.h @@ -69,7 +69,7 @@ class Dav1dPictureWrapper void setInternalsSupported() { internalsSupported = true; } void clear() { memset(&curPicture, 0, sizeof(Dav1dPicture)); } - Size getFrameSize() const { return Size({curPicture.p.w, curPicture.p.h}); } + Size getFrameSize() const; Dav1dPicture * getPicture() const { return (Dav1dPicture *)(&curPicture); } video::yuv::Subsampling getSubsampling() const; int getBitDepth() const { return curPicture.p.bpc; } diff --git a/YUViewLib/src/ffmpeg/AVCodecContextWrapper.cpp b/YUViewLib/src/ffmpeg/AVCodecContextWrapper.cpp index dea86930a..7efc759af 100644 --- a/YUViewLib/src/ffmpeg/AVCodecContextWrapper.cpp +++ b/YUViewLib/src/ffmpeg/AVCodecContextWrapper.cpp @@ -452,7 +452,9 @@ AVPixelFormat AVCodecContextWrapper::getPixelFormat() Size AVCodecContextWrapper::getSize() { this->update(); - return {this->width, this->height}; + if (this->width < 0 || this->height < 0) + return {}; + return {static_cast(this->width), static_cast(this->height)}; } AVColorSpace AVCodecContextWrapper::getColorspace() diff --git a/YUViewLib/src/playlistitem/playlistItemRawFile.cpp b/YUViewLib/src/playlistitem/playlistItemRawFile.cpp index 474df60fa..d4f409a62 100644 --- a/YUViewLib/src/playlistitem/playlistItemRawFile.cpp +++ b/YUViewLib/src/playlistitem/playlistItemRawFile.cpp @@ -69,7 +69,9 @@ playlistItemRawFile::playlistItemRawFile(const QString &rawFilePath, return; } - auto frameSize = Size(qFrameSize.width(), qFrameSize.height()); + Size frameSize; + if (qFrameSize.width() > 0 && qFrameSize.height() > 0) + frameSize = Size(qFrameSize.width(), qFrameSize.height()); // Create a new videoHandler instance depending on the input format QFileInfo fi(rawFilePath);