![]() |
tinyimg 1.0.0
Lightweight image manipulation library for Cloudflare Workers
|
WebP codec, both the lossless and the lossy bitstream. More...
#include "tinyimg/codec/codec.h"Go to the source code of this file.
Functions | |
| void | tiny_webp_plane_codes (uint8_t *out) |
| Fills in the table that maps a short distance code to a nearby pixel. | |
Variables | |
| const TinyCodec | tiny_codec_webp |
| The WebP codec. | |
WebP codec, both the lossless and the lossy bitstream.
| void tiny_webp_plane_codes | ( | uint8_t * | out | ) |
Fills in the table that maps a short distance code to a nearby pixel.
The 120 entries are derived rather than shipped, from the rule that they are every offset with a row of 0 to 7 and a column of -7 to 8 naming an already written pixel, ordered by squared distance, then by descending row, then by descending column. That saves 120 bytes of the module and is only safe if the derivation is exactly right, so this exists for the test that checks it against the specification's own listing.
| out | Receives 120 bytes, each a row in its high nibble and eight minus a column in its low nibble. |
|
extern |
The WebP codec.
Reads the simple and the extended container: a bare VP8 or VP8L chunk, or a VP8X file carrying any of ALPH, ICCP, EXIF and an animation. An animation decodes its first frame composited onto the canvas the file declares, and probe reports the frame count, so an animation is identifiable without decoding it; composing or re-timing frames is out of scope, as it is for GIF.
Lossless is complete: all four transforms, the color cache, meta Huffman groups and LZ77 backward references. Lossy decodes an intra coded frame, which is every still image the format holds, with both loop filters. An ALPH chunk is read whether it is stored raw or through the lossless coder, and its three filtering methods are undone.
Encoding writes lossless for TinyEncodeOpts::lossless and lossy otherwise. The lossy encoder is intra only: it searches the 16x16 and 4x4 luma modes with a rate weighted metric, and its quality number is mapped so that a given quality lands within a few percent of cwebp -q on both size and PSNR.