1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:37:46 +00:00

LibGfx+JPGLoader: Fix decoding outside of LibWeb

The DC reset interval was initialized to garbage :)
This commit is contained in:
devashish 2020-06-27 20:50:16 +05:30 committed by Andreas Kling
parent 58a5af1dcd
commit 1eb338ab71

View file

@ -135,21 +135,21 @@ struct Macroblock {
}; };
struct MacroblockMeta { struct MacroblockMeta {
u32 total; u32 total { 0 };
u32 padded_total; u32 padded_total { 0 };
u32 hcount; u32 hcount { 0 };
u32 vcount; u32 vcount { 0 };
u32 hpadded_count; u32 hpadded_count { 0 };
u32 vpadded_count; u32 vpadded_count { 0 };
}; };
struct ComponentSpec { struct ComponentSpec {
i8 id { -1 }; i8 id { -1 };
u8 hsample_factor { 1 }; // Horizontal sampling factor. u8 hsample_factor { 1 }; // Horizontal sampling factor.
u8 vsample_factor { 1 }; // Vertical sampling factor. u8 vsample_factor { 1 }; // Vertical sampling factor.
u8 ac_destination_id; u8 ac_destination_id { 0 };
u8 dc_destination_id; u8 dc_destination_id { 0 };
u8 qtable_id; // Quantization table id. u8 qtable_id { 0 }; // Quantization table id.
}; };
struct StartOfFrame { struct StartOfFrame {
@ -159,14 +159,14 @@ struct StartOfFrame {
}; };
FrameType type { FrameType::Baseline }; FrameType type { FrameType::Baseline };
u8 precision; u8 precision { 0 };
u16 height; u16 height { 0 };
u16 width; u16 width { 0 };
}; };
struct HuffmanTableSpec { struct HuffmanTableSpec {
u8 type; u8 type { 0 };
u8 destination_id; u8 destination_id { 0 };
u8 code_counts[16] = { 0 }; u8 code_counts[16] = { 0 };
Vector<u8> symbols; Vector<u8> symbols;
Vector<u16> codes; Vector<u16> codes;
@ -189,16 +189,16 @@ struct JPGLoadingContext {
State state { State::NotDecoded }; State state { State::NotDecoded };
const u8* data { nullptr }; const u8* data { nullptr };
size_t data_size { 0 }; size_t data_size { 0 };
u32 luma_table[64]; u32 luma_table[64] = { 0 };
u32 chroma_table[64]; u32 chroma_table[64] = { 0 };
StartOfFrame frame; StartOfFrame frame;
u8 hsample_factor; u8 hsample_factor { 0 };
u8 vsample_factor; u8 vsample_factor { 0 };
bool has_zero_based_ids; bool has_zero_based_ids { false };
u8 component_count; u8 component_count { 0 };
ComponentSpec components[3]; ComponentSpec components[3];
RefPtr<Gfx::Bitmap> bitmap; RefPtr<Gfx::Bitmap> bitmap;
u16 dc_reset_interval; u16 dc_reset_interval { 0 };
Vector<HuffmanTableSpec> dc_tables; Vector<HuffmanTableSpec> dc_tables;
Vector<HuffmanTableSpec> ac_tables; Vector<HuffmanTableSpec> ac_tables;
HuffmanStreamState huffman_stream; HuffmanStreamState huffman_stream;