webp

API documentation

Overview

All public functionality in the webp module is wrapped in the class WebPDecoder. This class mirrors the ImageDecoder class. The flow of decoding an image goes something like this:

Important Functions

ImageDecoderWebP::Check
A static method to mirror ImageDecoderFactory::CheckType - attempts to determine whether a chunk of data contains a WebP image.
ImageDecoderWebP::Peek
A static method to mirror ImageDecoderFactory::CheckSize - attempts to determine the dimensions of a WebP image.
ImageDecoderWebP::Decode
Called whenever more image data is available. It will incrementally decode the data it receives.
ImageDecoderWebP::SetImageDecoderListener
The decoder listener that should be informed about the decoding progress - must be called before Decode is called.

Memory management

OOM policy

Out of memory handling is mainly handled by propagating OP_STATUS values.

Memory usage

WebPDecoder doesn't maintain any image data (except for the image header) on its own, it does however implicitly store image data due to its use of libwebp. The libwebp incremental decoder uses two buffers when decoding an image: one intermediate buffer for input data and an output buffer for the decoded data. The intermediate buffer discards already decoded data when growing; as a result it will typically be smaller than the total WebP image data. The output buffer will grow until it eventually stores the entire decoded image.