diff --git a/libvisual/libvisual/lv_video.cpp b/libvisual/libvisual/lv_video.cpp index 9bb5f1b1..6367418e 100644 --- a/libvisual/libvisual/lv_video.cpp +++ b/libvisual/libvisual/lv_video.cpp @@ -392,6 +392,10 @@ namespace LV { } } + // Videos must have the same palette. + if (m_impl->palette != video->m_impl->palette) + return false; + return true; } diff --git a/libvisual/libvisual/private/lv_video_bmp.cpp b/libvisual/libvisual/private/lv_video_bmp.cpp index fdfdf68c..90a37b7a 100644 --- a/libvisual/libvisual/private/lv_video_bmp.cpp +++ b/libvisual/libvisual/private/lv_video_bmp.cpp @@ -31,9 +31,12 @@ #include #include -#define BI_RGB 0 -#define BI_RLE8 1 -#define BI_RLE4 2 +/* BMP compression methods */ +#define BI_RGB 0 +#define BI_RLE8 1 +#define BI_RLE4 2 +#define BI_BITFIELDS 3 + namespace LV { @@ -286,6 +289,8 @@ namespace LV { fp.read (reinterpret_cast (&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 (&bi_size), 4); bi_size = VISUAL_ENDIAN_LEI32 (bi_size); @@ -341,13 +346,19 @@ namespace LV { return nullptr; } - if (bi_compression > 3) { + if (bi_compression >= BI_BITFIELDS) { visual_log (VISUAL_LOG_ERROR, "Bitmap uses an invalid or unsupported compression scheme"); fp.seekg (saved_stream_pos); return nullptr; } /* Load the palette */ + + /* Skip past DIB header to color table */ + /* BI_BITFIELDS and BI_ALPHABITFIELDS are unsupported, so there are + no bitmasks after the DIB header. */ + fp.seekg (dib_header_pos + std::streampos {bi_size}, std::ios::beg); + if (bi_bitcount < 24) { if (bi_clrused == 0) { /* When the colors used variable is zero, use the @@ -385,6 +396,8 @@ namespace LV { if (palette) video->set_palette (*palette); + /* Read and decode image data */ + /* Set to the beginning of image data, note that MickeySoft likes stuff upside down .. */ fp.seekg (bf_bits, std::ios::beg);