Commit graph

14 commits

Author SHA1 Message Date
Nico Weber
3c5450b8be LibGfx: Implement is_animated() and frame_count() for webp plugin 2023-02-26 15:54:22 +01:00
Nico Weber
0393a37843 LibGfx: Add some chunk validation to decode_webp_extended() 2023-02-26 15:54:22 +01:00
Nico Weber
9864963a08 LibGfx: In WebP, rename decode_webp_size to decode_webp_first_chunk
...and make it store the decoded details in the context.
2023-02-26 15:54:22 +01:00
Nico Weber
15d2e8ca2b LibGfx: In WebP, rename decode_webp_first_chunk to read_webp_first_chunk 2023-02-26 15:54:22 +01:00
Nico Weber
19ca8d7fb7 LibGfx: Decode WebP canvas size
This reorganizes things so that:

* When initially decoding chunks, we only store pointers to
  their data and don't look at the contents
* We allow pausing decoding after decoding the first chunk, since
  that's where the dimensions are stored, and we don't need to read
  more than that if we only care about dimensions. (Currently
  inconsequential, but maybe we want to get dimensions after
  receiving the first few bytes off the network in the future.)
* We then have separate methods to interpret chunk data
  (only for the first few bytes which store the size, so far.)
2023-02-25 22:30:32 +01:00
Nico Weber
7c1455c357 LibGfx: Parse WebP VP8L chunk header
For now, just dbgln_if() all data. Eventually we'll want to use at
least width and height.
2023-02-25 16:02:51 +01:00
Nico Weber
d5875b5962 LibGfx: Fix lossless fourcc in VP8X chunk decoder 2023-02-25 16:02:51 +01:00
Nico Weber
d78c70c28c LibGfx: Add link to webp overview 2023-02-25 16:02:51 +01:00
Nico Weber
0774d2135c LibGfx: Parse some of WebP 'VP8 ' chunk
This is for lossy compression, in which case a WebP file is
a single VP8 key frame.

This only parses the 10-byte frame header, which contains image
dimensions (and some other things).

For now, just dbgln_if() all data. Eventually we'll want to use at
least width and height.
2023-02-25 16:02:51 +01:00
Nico Weber
e56e7db9d4 LibGfx: Parse WebP VP8X chunk
For now, just dbgln_if() all data. Eventually we'll want to use at
least width and height.
2023-02-25 16:02:51 +01:00
Nico Weber
58a5038420 LibGfx: Add a FIXME to WebPImageDecoderPlugin::icc_data() 2023-02-25 16:02:51 +01:00
Nico Weber
65d41f8ed9 LibGfx: Add a WebPLoadingContext::error() helper
No behavior change.

(Well, technically, this now correctly sets the state to Error
if the first chunk is neither of 'VP8 ', 'VP8L', 'VP8X'. But no
*interesting* behavior change.)
2023-02-25 16:02:51 +01:00
Nico Weber
14c0bae704 LibGfx+Tests: Add test for webp ICC loading and fix bug
I drew the two webp files in Photoshop and saved them using the
"Save a Copy..." dialog, with ICC profile and all other boxes checked.

(I also tried saving with all the boxes unchecked, but it still wrote an
extended webp instead of a basic file.)

The lossless file exposed a bug: I didn't handle chunk padding
correctly before this patch.
2023-02-24 20:13:52 +01:00
Nico Weber
f7e152d049 LibGfx: Add scaffolding for a webp decoder
At the moment, this processes the RIFF chunk structure and extracts
the ICCP chunk, so that `icc` can now print ICC profiles embedded
in webp files. (And are image files really more than containers
of icc profiles?)

It doesn't even decode image dimensions yet.

The lossy format is a VP8 video frame. Once we get to that, we
might want to move all the image decoders into a new LibImageDecoders
that depends on both LibGfx and LibVideo. (Other newer image formats
like heic and av1f also use video frames for image data.)
2023-02-24 19:44:20 +01:00