Skip to content

Commit

Permalink
Merge pull request #549 from IENT/bugfix/547-FilenameFormatGuessBug
Browse files Browse the repository at this point in the history
Fix error in QSize to our Size conversion
  • Loading branch information
ChristianFeldmann authored Dec 3, 2023
2 parents b56c923 + 94e061a commit 8b96878
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 @@ -227,7 +227,6 @@ template <typename T> using vector4d = std::vector<vector3d<T>>;
template <typename T, size_t N> using array = std::array<T, N>;
template <typename T, size_t N1, size_t N2> using array2d = std::array<std::array<T, N2>, N1>;


template <typename T> int indexInVec(const std::vector<T> &vec, const T &item)
{
auto it = std::find(vec.begin(), vec.end(), item);
Expand Down Expand Up @@ -264,10 +263,6 @@ struct Ratio
struct Size
{
constexpr Size(unsigned width, unsigned height) : width(width), height(height) {}
constexpr Size(int width, int height)
: width(static_cast<unsigned>(width)), height(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 8b96878

Please sign in to comment.