Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions libvisual/libvisual/lv_video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ namespace LV {
}
}

// Videos must have the same palette.
if (m_impl->palette != video->m_impl->palette)
return false;

return true;
}

Expand Down
6 changes: 5 additions & 1 deletion libvisual/libvisual/private/lv_video_bmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ namespace LV {
fp.read (reinterpret_cast<char*> (&bf_bits), 4);
bf_bits = VISUAL_ENDIAN_LEI32 (bf_bits);

auto dib_header_pos = fp.tellg ();

/* Read the info structure size */
fp.read (reinterpret_cast<char*> (&bi_size), 4);
bi_size = VISUAL_ENDIAN_LEI32 (bi_size);
Expand Down Expand Up @@ -341,12 +343,14 @@ namespace LV {
return nullptr;
}

if (bi_compression > 3) {
if (bi_compression >= 3) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of approach "undocumented unnamed magic number". This seems to be 3 because BI_BITFIELDS == 3 in Windows. If we cannot use that constant without including Windows headers, let's either (a) add a good comment or (b) make our own copy of that constant (or both)?

visual_log (VISUAL_LOG_ERROR, "Bitmap uses an invalid or unsupported compression scheme");
fp.seekg (saved_stream_pos);
return nullptr;
}

fp.seekg (dib_header_pos + std::streampos {bi_size}, std::ios::beg);
Copy link
Member

@hartwork hartwork Jan 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add comments (or make otherwise more obvious) that…

  • that we're jumping to the start of the palette here (— we could also move the line_below_ comment /* Load the palette */ to better show it's part of palette loading?)
  • that this is the correct value (only) because we ruled out both BI_BITFIELDS and BI_ALPHABITFIELDS earlier (referring to the first paragraph at https://en.wikipedia.org/wiki/BMP_file_format#Color_table)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, let me make that change.


/* Load the palette */
if (bi_bitcount < 24) {
if (bi_clrused == 0) {
Expand Down