Skip to content

Commit

Permalink
kernel: fix QOIStreamDecoder::finished() and zero init the array
Browse files Browse the repository at this point in the history
  • Loading branch information
matcool committed Aug 12, 2023
1 parent 013ed74 commit 59fb818
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 5 additions & 0 deletions kernel/window/qoi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ QOIStreamDecoder::QOIStreamDecoder(Span<const u8> data) : m_data(data) {

// ignore colorspace and channels
m_data = m_data.sub(2);

for (auto& col : m_prev_pixels) {
col = Color(0, 0, 0, 0);
}
}

static constexpr u8 QOI_OP_INDEX = 0b0000'0000;
Expand Down Expand Up @@ -87,6 +91,7 @@ Color QOIStreamDecoder::next_pixel() {
}

bool QOIStreamDecoder::finished() const {
if (m_run_counter) return false;
if (!m_data || m_data.size() < 8) return true;
// if the next 7 bytes are 0 and the one after is a 1, then qoi's stream is finished.
return !m_data.iter().take(7).any() && m_data[7] == 1;
Expand Down
1 change: 0 additions & 1 deletion kernel/window/qoi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
class QOIStreamDecoder {
Span<const u8> m_data;

// TODO: should be entirely 0, instead of 255 alpha
Array<Color, 64> m_prev_pixels;
Color m_last_pixel = Color(0, 0, 0, 255);
u8 m_run_counter = 0;
Expand Down

0 comments on commit 59fb818

Please sign in to comment.