Skip to content

Commit

Permalink
Implement the change a bit differently.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianFeldmann committed Dec 3, 2023
1 parent 29779b7 commit 94e061a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
5 changes: 0 additions & 5 deletions YUViewLib/src/common/Typedef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned>(width);
this->height = (height < 0) ? 0 : static_cast<unsigned>(height);
}
constexpr Size() = default;

constexpr bool operator==(const Size &other) const
Expand Down
7 changes: 7 additions & 0 deletions YUViewLib/src/decoder/decoderDav1d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned>(curPicture.p.w), static_cast<unsigned>(curPicture.p.h)});
}

Subsampling Dav1dPictureWrapper::getSubsampling() const
{
return convertFromInternalSubsampling(curPicture.p.layout);
Expand Down
2 changes: 1 addition & 1 deletion YUViewLib/src/decoder/decoderDav1d.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
4 changes: 3 additions & 1 deletion YUViewLib/src/ffmpeg/AVCodecContextWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned>(this->width), static_cast<unsigned>(this->height)};
}

AVColorSpace AVCodecContextWrapper::getColorspace()
Expand Down
4 changes: 3 additions & 1 deletion YUViewLib/src/playlistitem/playlistItemRawFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 94e061a

Please sign in to comment.