package vendor:webp
Overview
Copyright 2010 Google Inc. All Rights Reserved.
Use of this source code is governed by a BSD-style license that can be found in the COPYING file in the root of the source tree. An additional intellectual property rights grant can be found in the file PATENTS. All contributing project authors may be found in the AUTHORS file in the root of the source tree. -----------------------------------------------------------------------------
Main decoding functions for WebP images.
Author: Skal (pascal.massimino@gmail.com)
Copyright 2012 Google Inc. All Rights Reserved.
Use of this source code is governed by a BSD-style license that can be found in the COPYING file in the root of the source tree. An additional intellectual property rights grant can be found in the file PATENTS. All contributing project authors may be found in the AUTHORS file in the root of the source tree. -----------------------------------------------------------------------------
Demux API. Enables extraction of image and extended format data from WebP files. Code Example: Demuxing WebP data to extract all the frames, ICC profile and EXIF/XMP metadata.
WebPDemuxer* demux = WebPDemux(&webp_data);
uint32_t width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH); uint32_t height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT); // ... (Get information about the features present in the WebP file). uint32_t flags = WebPDemuxGetI(demux, WEBP_FF_FORMAT_FLAGS);
// ... (Iterate over all frames). WebPIterator iter; if (WebPDemuxGetFrame(demux, 1, &iter)) { do { // ... (Consume 'iter'; e.g. Decode 'iter.fragment' with WebPDecode(), // ... and get other frame properties like width, height, offsets etc. // ... see 'struct WebPIterator' below for more info). } while (WebPDemuxNextFrame(&iter)); WebPDemuxReleaseIterator(&iter); }
// ... (Extract metadata). WebPChunkIterator chunk_iter; if (flags & ICCP_FLAG) WebPDemuxGetChunk(demux, "ICCP", 1, &chunk_iter); // ... (Consume the ICC profile in 'chunk_iter.chunk'). WebPDemuxReleaseChunkIterator(&chunk_iter); if (flags & EXIF_FLAG) WebPDemuxGetChunk(demux, "EXIF", 1, &chunk_iter); // ... (Consume the EXIF metadata in 'chunk_iter.chunk'). WebPDemuxReleaseChunkIterator(&chunk_iter); if (flags & XMP_FLAG) WebPDemuxGetChunk(demux, "XMP ", 1, &chunk_iter); // ... (Consume the XMP metadata in 'chunk_iter.chunk'). WebPDemuxReleaseChunkIterator(&chunk_iter); WebPDemuxDelete(demux);
Copyright 2011 Google Inc. All Rights Reserved.
Use of this source code is governed by a BSD-style license that can be found in the COPYING file in the root of the source tree. An additional intellectual property rights grant can be found in the file PATENTS. All contributing project authors may be found in the AUTHORS file in the root of the source tree. -----------------------------------------------------------------------------
WebP encoder: main interface
Author: Skal (pascal.massimino@gmail.com)
Copyright 2012 Google Inc. All Rights Reserved.
Use of this source code is governed by a BSD-style license that can be found in the COPYING file in the root of the source tree. An additional intellectual property rights grant can be found in the file PATENTS. All contributing project authors may be found in the AUTHORS file in the root of the source tree. -----------------------------------------------------------------------------
Internal header for constants related to WebP file format.
Author: Urvang (urvang@google.com)
Copyright 2011 Google Inc. All Rights Reserved.
Use of this source code is governed by a BSD-style license that can be found in the COPYING file in the root of the source tree. An additional intellectual property rights grant can be found in the file PATENTS. All contributing project authors may be found in the AUTHORS file in the root of the source tree. -----------------------------------------------------------------------------
RIFF container manipulation and encoding for WebP images.
Authors: Urvang (urvang@google.com) Vikas (vikasa@google.com)
Copyright 2012 Google Inc. All Rights Reserved.
Use of this source code is governed by a BSD-style license that can be found in the COPYING file in the root of the source tree. An additional intellectual property rights grant can be found in the file PATENTS. All contributing project authors may be found in the AUTHORS file in the root of the source tree. -----------------------------------------------------------------------------
Data-types common to the mux and demux libraries.
Author: Urvang (urvang@google.com)
Copyright 2010 Google Inc. All Rights Reserved.
Use of this source code is governed by a BSD-style license that can be found in the COPYING file in the root of the source tree. An additional intellectual property rights grant can be found in the file PATENTS. All contributing project authors may be found in the AUTHORS file in the root of the source tree. -----------------------------------------------------------------------------
Common types + memory wrappers
Author: Skal (pascal.massimino@gmail.com)
Index
Types (42)
- CSP_MODE
- VP8LImageTransformType
- VP8StatusCode
- WebPAnimDecoder
- WebPAnimDecoderOptions
- WebPAnimEncoder
- WebPAnimEncoderOptions
- WebPAnimInfo
- WebPAuxStats
- WebPBitstreamFeatures
- WebPChunkId
- WebPChunkIterator
- WebPConfig
- WebPData
- WebPDecBuffer
- WebPDecoderConfig
- WebPDecoderOptions
- WebPDemuxState
- WebPDemuxer
- WebPEncCSP
- WebPEncodingError
- WebPFeatureFlags
- WebPFormatFeature
- WebPIDecoder
- WebPImageHint
- WebPIterator
- WebPMemoryWriter
- WebPMux
- WebPMuxAnimBlend
- WebPMuxAnimDispose
- WebPMuxAnimParams
- WebPMuxError
- WebPMuxFrameInfo
- WebPPicture
- WebPPreset
- WebPProgressHook
- WebPRGBABuffer
- WebPWriterFunction
- WebPYUVABuffer
- WebP_Error
- WebP_Error_In
- webp_converter
Constants (47)
- ALPHA_HEADER_LEN
- ALPHA_LOSSLESS_COMPRESSION
- ALPHA_NO_COMPRESSION
- ALPHA_PREPROCESSED_LEVELS
- ANIM_CHUNK_SIZE
- ANMF_CHUNK_SIZE
- ARGB_BLACK
- CHUNK_HEADER_SIZE
- CHUNK_SIZE_BYTES
- CODE_LENGTH_CODES
- DEFAULT_CODE_LENGTH
- HUFFMAN_CODES_PER_META_CODE
- MAX_ALLOWED_CODE_LENGTH
- MAX_CACHE_BITS
- MAX_CANVAS_SIZE
- MAX_DURATION
- MAX_IMAGE_AREA
- MAX_LOOP_COUNT
- MAX_PALETTE_SIZE
- MAX_POSITION_OFFSET
- MIN_HUFFMAN_BITS
- MIN_TRANSFORM_BITS
- NUM_DISTANCE_CODES
- NUM_HUFFMAN_BITS
- NUM_LENGTH_CODES
- NUM_LITERAL_CODES
- NUM_TRANSFORMS
- NUM_TRANSFORM_BITS
- RIFF_HEADER_SIZE
- TAG_SIZE
- TRANSFORM_PRESENT
- VP8L_FRAME_HEADER_SIZE
- VP8L_IMAGE_SIZE_BITS
- VP8L_MAGIC_BYTE
- VP8L_SIGNATURE_SIZE
- VP8L_VERSION
- VP8L_VERSION_BITS
- VP8X_CHUNK_SIZE
- VP8_FRAME_HEADER_SIZE
- VP8_MAX_PARTITION0_SIZE
- VP8_MAX_PARTITION_SIZE
- VP8_SIGNATURE
- WEBP_DECODER_ABI_VERSION
- WEBP_DEMUX_ABI_VERSION
- WEBP_ENCODER_ABI_VERSION
- WEBP_MAX_DIMENSION
- WEBP_MUX_ABI_VERSION
Variables (0)
This section is empty.
Procedures (147)
- WebPAnimDecoderDelete
- WebPAnimDecoderGetDemuxer
- WebPAnimDecoderGetInfo
- WebPAnimDecoderGetNext
- WebPAnimDecoderHasMoreFrames
- WebPAnimDecoderNew
- WebPAnimDecoderNewInternal
- WebPAnimDecoderOptionsInit
- WebPAnimDecoderOptionsInitInternal
- WebPAnimDecoderReset
- WebPAnimEncoderAdd
- WebPAnimEncoderAssemble
- WebPAnimEncoderDelete
- WebPAnimEncoderDeleteChunk
- WebPAnimEncoderGetChunk
- WebPAnimEncoderGetError
- WebPAnimEncoderNew
- WebPAnimEncoderNewInternal
- WebPAnimEncoderOptionsInit
- WebPAnimEncoderOptionsInitInternal
- WebPAnimEncoderSetChunk
- WebPBlendAlpha
- WebPCleanupTransparentArea
- WebPConfigInit
- WebPConfigInitInternal
- WebPConfigLosslessPreset
- WebPConfigPreset
- WebPDataClear
- WebPDataCopy
- WebPDataInit
- WebPDecode
- WebPDecodeARGB
- WebPDecodeARGBInto
- WebPDecodeBGR
- WebPDecodeBGRA
- WebPDecodeBGRAInto
- WebPDecodeBGRInto
- WebPDecodeRGB
- WebPDecodeRGBA
- WebPDecodeRGBAInto
- WebPDecodeRGBInto
- WebPDecodeYUV
- WebPDecodeYUVInto
- WebPDemux
- WebPDemuxDelete
- WebPDemuxGetChunk
- WebPDemuxGetFrame
- WebPDemuxGetI
- WebPDemuxInternal
- WebPDemuxNextChunk
- WebPDemuxNextFrame
- WebPDemuxPartial
- WebPDemuxPrevChunk
- WebPDemuxPrevFrame
- WebPDemuxReleaseChunkIterator
- WebPDemuxReleaseIterator
- WebPEncode
- WebPEncodeBGR
- WebPEncodeBGRA
- WebPEncodeLosslessBGR
- WebPEncodeLosslessBGRA
- WebPEncodeLosslessRGB
- WebPEncodeLosslessRGBA
- WebPEncodeRGB
- WebPEncodeRGBA
- WebPFree
- WebPFreeDecBuffer
- WebPGetDecoderVersion
- WebPGetDemuxVersion
- WebPGetEncoderVersion
- WebPGetFeatures
- WebPGetFeaturesInternal
- WebPGetInfo
- WebPGetMuxVersion
- WebPIAppend
- WebPIDecGetRGB
- WebPIDecGetYUV
- WebPIDecGetYUVA
- WebPIDecode
- WebPIDecodedArea
- WebPIDelete
- WebPINewDecoder
- WebPINewRGB
- WebPINewYUV
- WebPINewYUVA
- WebPIUpdate
- WebPInitDecBuffer
- WebPInitDecBufferInternal
- WebPInitDecoderConfig
- WebPInitDecoderConfigInternal
- WebPIsAlphaMode
- WebPIsPremultipliedMode
- WebPIsRGBMode
- WebPMalloc
- WebPMemoryWrite
- WebPMemoryWriterClear
- WebPMemoryWriterInit
- WebPMuxAssemble
- WebPMuxCreate
- WebPMuxCreateInternal
- WebPMuxDelete
- WebPMuxDeleteChunk
- WebPMuxDeleteFrame
- WebPMuxGetAnimationParams
- WebPMuxGetCanvasSize
- WebPMuxGetChunk
- WebPMuxGetFeatures
- WebPMuxGetFrame
- WebPMuxNew
- WebPMuxNumChunks
- WebPMuxPushFrame
- WebPMuxSetAnimationParams
- WebPMuxSetCanvasSize
- WebPMuxSetChunk
- WebPMuxSetImage
- WebPNewInternal
- WebPPictureARGBToYUVA
- WebPPictureARGBToYUVADithered
- WebPPictureAlloc
- WebPPictureCopy
- WebPPictureCrop
- WebPPictureDistortion
- WebPPictureFree
- WebPPictureHasTransparency
- WebPPictureImportBGR
- WebPPictureImportBGRA
- WebPPictureImportBGRX
- WebPPictureImportRGB
- WebPPictureImportRGBA
- WebPPictureImportRGBX
- WebPPictureInit
- WebPPictureInitInternal
- WebPPictureIsView
- WebPPictureRescale
- WebPPictureSharpARGBToYUVA
- WebPPictureSmartARGBToYUVA
- WebPPictureView
- WebPPictureYUVAToARGB
- WebPPlaneDistortion
- WebPValidateConfig
- webp_converter_deinit
- webp_converter_frame_cnt
- webp_converter_height
- webp_converter_load
- webp_converter_load_file
- webp_converter_size
- webp_converter_width
Procedure Groups (0)
This section is empty.
Types
CSP_MODE ¶
CSP_MODE :: enum i32 { RGB = 0, RGBA = 1, BGR = 2, BGRA = 3, ARGB = 4, RGBA_4444 = 5, RGB_565 = 6, // RGB-premultiplied transparent modes (alpha value is preserved) rgbA = 7, // RGB-premultiplied transparent modes (alpha value is preserved) bgrA = 8, // RGB-premultiplied transparent modes (alpha value is preserved) Argb = 9, // RGB-premultiplied transparent modes (alpha value is preserved) rgbA_4444 = 10, YUV = 11, // yuv 4:2:0 YUVA = 12, // yuv 4:2:0 LAST = 13, }
Colorspaces Note: the naming describes the byte-ordering of packed samples in memory. For instance, MODE_BGRA relates to samples ordered as B,G,R,A,B,G,R,A,... Non-capital names (e.g.:MODE_Argb) relates to pre-multiplied RGB channels. RGBA-4444 and RGB-565 colorspaces are represented by following byte-order: RGBA-4444: [r3 r2 r1 r0 g3 g2 g1 g0], [b3 b2 b1 b0 a3 a2 a1 a0], ... RGB-565: [r4 r3 r2 r1 r0 g5 g4 g3], [g2 g1 g0 b4 b3 b2 b1 b0], ... In the case WEBP_SWAP_16BITS_CSP is defined, the bytes are swapped for these two modes: RGBA-4444: [b3 b2 b1 b0 a3 a2 a1 a0], [r3 r2 r1 r0 g3 g2 g1 g0], ... RGB-565: [g2 g1 g0 b4 b3 b2 b1 b0], [r4 r3 r2 r1 r0 g5 g4 g3], ...
Related Procedures With Parameters
VP8LImageTransformType ¶
VP8LImageTransformType :: enum i32 { PREDICTOR_TRANSFORM = 0, CROSS_COLOR_TRANSFORM = 1, SUBTRACT_GREEN_TRANSFORM = 2, COLOR_INDEXING_TRANSFORM = 3, }
VP8StatusCode ¶
VP8StatusCode :: enum i32 { OK = 0, OUT_OF_MEMORY, INVALID_PARAM, BITSTREAM_ERROR, UNSUPPORTED_FEATURE, SUSPENDED, USER_ABORT, NOT_ENOUGH_DATA, }
------------------------------------------------------------------------------ Enumeration of the status codes
Related Procedures With Returns
WebPAnimDecoder ¶
WebPAnimDecoder :: struct {}
Related Procedures With Parameters
Related Procedures With Returns
WebPAnimDecoderOptions ¶
WebPAnimDecoderOptions :: struct { // Output colorspace. Only the following modes are supported: // MODE_RGBA, MODE_BGRA, MODE_rgbA and MODE_bgrA. color_mode: CSP_MODE, use_threads: i32, // If true, use multi-threaded decoding. padding: [7]u32, }
Global options.
Related Procedures With Parameters
WebPAnimEncoder ¶
WebPAnimEncoder :: struct {}
Related Procedures With Parameters
Related Procedures With Returns
WebPAnimEncoderOptions ¶
WebPAnimEncoderOptions :: struct { anim_params: WebPMuxAnimParams, // Animation parameters. minimize_size: i32, // disables key-frame insertion. kmin: i32, kmax: i32, // frames in the output. The library may insert some key // frames as needed to satisfy this criteria. // Note that these conditions should hold: kmax > kmin // and kmin >= kmax / 2 + 1. Also, if kmax <= 0, then // key-frame insertion is disabled; and if kmax == 1, // then all frames will be key-frames (kmin value does // not matter for these special cases). allow_mixed: i32, // either lossy and lossless for each frame. verbose: i32, // If true, print info and warning messages to stderr. padding: [4]u32, }
Global options.
Related Procedures With Parameters
WebPAnimInfo ¶
WebPAnimInfo :: struct { canvas_width: u32, canvas_height: u32, loop_count: u32, bgcolor: u32, frame_count: u32, pad: [4]u32, }
Global information about the animation..
Related Procedures With Parameters
WebPAuxStats ¶
WebPAuxStats :: struct { coded_size: i32, // final size PSNR: [5]f32, // peak-signal-to-noise ratio for Y/U/V/All/Alpha block_count: [3]i32, // number of intra4/intra16/skipped macroblocks header_bytes: [2]i32, // and mode-partition #0 residual_bytes: [3][4]i32, // DC/AC/uv coefficients for each (0..3) segments. segment_size: [4]i32, // number of macroblocks in each segments segment_quant: [4]i32, // quantizer values for each segments segment_level: [4]i32, // filtering strength for each segments [0..63] alpha_data_size: i32, // size of the transparency data layer_data_size: i32, // size of the enhancement layer data lossless_features: u32, // bit2:subtract-green bit3:color indexing histogram_bits: i32, // number of precision bits of histogram transform_bits: i32, // precision bits for predictor transform cache_bits: i32, // number of bits for color cache lookup palette_size: i32, // number of color in palette, if used lossless_size: i32, // final lossless size lossless_hdr_size: i32, // lossless header (transform, huffman etc) size lossless_data_size: i32, // lossless image data size cross_color_transform_bits: i32, // precision bits for cross-color transform pad: [1]u32, }
------------------------------------------------------------------------------ Input / Output Structure for storing auxiliary statistics.
WebPBitstreamFeatures ¶
WebPBitstreamFeatures :: struct { width: i32, // Width in pixels, as read from the bitstream. height: i32, // Height in pixels, as read from the bitstream. has_alpha: b32, // True if the bitstream contains an alpha channel. has_animation: b32, // True if the bitstream is an animation. format: i32, // 0 = undefined (/mixed), 1 = lossy, 2 = lossless pad: [5]u32, }
Features gathered from the bitstream
Related Procedures With Parameters
WebPChunkId ¶
WebPChunkId :: enum i32 { VP8X, // VP8X ICCP, // ICCP ANIM, // ANIM ANMF, // ANMF DEPRECATED, // (deprecated from FRGM) ALPHA, // ALPH IMAGE, // VP8/VP8L EXIF, // EXIF XMP, // XMP UNKNOWN, // Other chunks. NIL, }
IDs for different types of chunks.
Related Procedures With Parameters
WebPChunkIterator ¶
WebPChunkIterator :: struct { // The current and total number of chunks with the fourcc given to // WebPDemuxGetChunk(). chunk_num: i32, num_chunks: i32, chunk: WebPData, // The payload of the chunk. pad: [6]u32, // padding for later use private_: rawptr, }
------------------------------------------------------------------------------ Chunk iteration.
Related Procedures With Parameters
WebPConfig ¶
WebPConfig :: struct { lossless: i32, // Lossless encoding (0=lossy(default), 1=lossless). quality: f32, // size and 100 the largest. For lossless, this // parameter is the amount of effort put into the // compression: 0 is the fastest but gives larger // files compared to the slowest, but best, 100. method: i32, // quality/speed trade-off (0=fast, 6=slower-better) image_hint: WebPImageHint, // Hint for image type (lossless only for now). target_size: i32, // Takes precedence over the 'compression' parameter. target_PSNR: f32, // try to achieve. Takes precedence over target_size. segments: i32, // maximum number of segments to use, in [1..4] sns_strength: i32, // Spatial Noise Shaping. 0=off, 100=maximum. filter_strength: i32, // range: [0 = off .. 100 = strongest] filter_sharpness: i32, // range: [0 = off .. 7 = least sharp] filter_type: i32, // if filter_strength > 0 or autofilter > 0) autofilter: i32, // Auto adjust filter's strength [0 = off, 1 = on] alpha_compression: i32, // 1 = compressed with WebP lossless). Default is 1. alpha_filtering: i32, // 0: none, 1: fast, 2: best. Default if 1. alpha_quality: i32, // Default is 100. pass: i32, // number of entropy-analysis passes (in [1..10]). show_compressed: i32, // In-loop filtering is not applied. preprocessing: i32, // 0=none, 1=segment-smooth, 2=pseudo-random dithering partitions: i32, // is set to 0 for easier progressive decoding. partition_limit: i32, // on prediction modes coding (0: no degradation, // 100: maximum possible degradation). emulate_jpeg_size: i32, // to better match the expected output size from // JPEG compression. Generally, the output size will // be similar but the degradation will be lower. thread_level: i32, // If non-zero, try and use multi-threaded encoding. low_memory: i32, // If set, reduce memory usage (but increase CPU use). near_lossless: i32, // (default)]. exact: i32, // transparent area. Otherwise, discard this invisible // RGB information for better compression. The default // value is 0. use_delta_palette: i32, // reserved use_sharp_yuv: i32, // if needed, use sharp (and slow) RGB->YUV conversion qmin: i32, // minimum permissible quality factor qmax: i32, }
Compression parameters.
Related Procedures With Parameters
WebPData ¶
Data type used to describe 'raw' data, e.g., chunk data (ICC profile, metadata) and WebP compressed image data. 'bytes' memory must be allocated using WebPMalloc() and such.
Related Procedures With Parameters
- WebPAnimDecoderNew
- WebPAnimDecoderNewInternal
- WebPAnimEncoderAssemble
- WebPAnimEncoderGetChunk
- WebPAnimEncoderSetChunk
- WebPDataClear
- WebPDataCopy
- WebPDataInit
- WebPDemux
- WebPDemuxInternal
- WebPDemuxPartial
- WebPMuxAssemble
- WebPMuxCreate
- WebPMuxCreateInternal
- WebPMuxGetChunk
- WebPMuxSetChunk
- WebPMuxSetImage
WebPDecBuffer ¶
WebPDecBuffer :: struct { colorspace: CSP_MODE, // Colorspace. width: i32, height: i32, // Dimensions. is_external_memory: i32, // used. If value is '2' or more, the external // memory is considered 'slow' and multiple // read/write will be avoided. u: struct #raw_union { RGBA: WebPRGBABuffer, YUVA: WebPYUVABuffer, }, // Nameless union of buffer parameters. pad: [4]u32, // padding for later use private_memory: ^u8, }
Output buffer
Related Procedures With Parameters
Related Procedures With Returns
WebPDecoderConfig ¶
WebPDecoderConfig :: struct { input: WebPBitstreamFeatures, // Immutable bitstream features (optional) output: WebPDecBuffer, // Output buffer (can point to external mem) options: WebPDecoderOptions, }
Main object storing the configuration for advanced decoding.
Related Procedures With Parameters
WebPDecoderOptions ¶
WebPDecoderOptions :: struct { bypass_filtering: b32, // if true, skip the in-loop filtering no_fancy_upsampling: b32, // if true, use faster pointwise upsampler use_cropping: b32, // if true, cropping is applied _first_ crop_left: i32, crop_top: i32, // Will be snapped to even values. crop_width: i32, crop_height: i32, // dimension of the cropping area use_scaling: b32, // if true, scaling is applied _afterward_ scaled_width: i32, scaled_height: i32, // final resolution use_threads: b32, // if true, use multi-threaded decoding dithering_strength: i32, // dithering strength (0=Off, 100=full) flip: b32, // if true, flip output vertically alpha_dithering_strength: i32, // alpha dithering strength in [0..100] pad: [5]u32, }
Decoding options
WebPDemuxState ¶
WebPDemuxState :: enum i32 { PARSE_ERROR = -1, // An error occurred while parsing. PARSING_HEADER = 0, // Not enough data to parse full header. PARSED_HEADER = 1, // Header parsing complete, // data may be available. DONE = 2, // Entire file has been parsed. }
------------------------------------------------------------------------------ Life of a Demux object
Related Procedures With Parameters
WebPDemuxer ¶
WebPDemuxer :: struct {}
Related Procedures With Parameters
Related Procedures With Returns
WebPEncCSP ¶
WebPEncCSP :: enum i32 { YUV420 = 0, // 4:2:0 YUV420A = 4, // alpha channel variant CSP_UV_MASK = 3, // bit-mask to get the UV sampling factors CSP_ALPHA_BIT = 4, // bit that is set if alpha is present }
Color spaces.
Related Procedures With Parameters
WebPEncodingError ¶
WebPEncodingError :: enum i32 { OK = 0, ERROR_OUT_OF_MEMORY, // memory error allocating objects ERROR_BITSTREAM_OUT_OF_MEMORY, // memory error while flushing bits ERROR_NULL_PARAMETER, // a pointer parameter is NULL ERROR_INVALID_CONFIGURATION, // configuration is invalid ERROR_BAD_DIMENSION, // picture has invalid width/height ERROR_PARTITION0_OVERFLOW, // partition is bigger than 512k ERROR_PARTITION_OVERFLOW, // partition is bigger than 16M ERROR_BAD_WRITE, // error while flushing bytes ERROR_FILE_TOO_BIG, // file is bigger than 4G ERROR_USER_ABORT, // abort request by user ERROR_LAST, // list terminator. always last. }
Encoding error conditions.
WebPFeatureFlags ¶
WebPFeatureFlags :: enum i32 { ANIMATION_FLAG = 2, XMP_FLAG = 4, EXIF_FLAG = 8, ALPHA_FLAG = 16, ICCP_FLAG = 32, ALL_VALID_FLAGS = 62, }
VP8X Feature Flags.
WebPFormatFeature ¶
WebPFormatFeature :: enum i32 { FORMAT_FLAGS, // bit-wise combination of WebPFeatureFlags // corresponding to the 'VP8X' chunk (if present). CANVAS_WIDTH, CANVAS_HEIGHT, LOOP_COUNT, // only relevant for animated file BACKGROUND_COLOR, // idem. FRAME_COUNT, // Number of frames present in the demux object. }
------------------------------------------------------------------------------ Data/information extraction.
Related Procedures With Parameters
WebPIDecoder ¶
WebPIDecoder :: struct {}
Related Procedures With Parameters
Related Procedures With Returns
WebPImageHint ¶
WebPImageHint :: enum i32 { DEFAULT = 0, // default preset. PICTURE, // digital picture, like portrait, inner shot PHOTO, // outdoor photograph, with natural lighting GRAPH, // Discrete tone image (graph, map-tile etc). LAST, }
Image characteristics hint for the underlying encoder.
WebPIterator ¶
WebPIterator :: struct { frame_num: i32, num_frames: i32, // equivalent to WEBP_FF_FRAME_COUNT. x_offset: i32, y_offset: i32, // offset relative to the canvas. width: i32, height: i32, // dimensions of this frame. duration: i32, // display duration in milliseconds. dispose_method: WebPMuxAnimDispose, // dispose method for the frame. complete: i32, // may still be decoded with the WebP incremental decoder. fragment: WebPData, // reasons this is called a fragment. has_alpha: i32, // True if the frame contains transparency. blend_method: WebPMuxAnimBlend, // Blend operation for the frame. pad: [2]u32, // padding for later use. private_: rawptr, }
------------------------------------------------------------------------------ Frame iteration.
Related Procedures With Parameters
WebPMemoryWriter ¶
WebPMemoryWriter :: struct { mem: ^u8, // final buffer (of size 'max_size', larger than 'size'). size: uint, // final size max_size: uint, // total capacity pad: [1]u32, }
WebPMemoryWrite: a special WebPWriterFunction that writes to memory using the following WebPMemoryWriter object (to be set as a custom_ptr).
Related Procedures With Parameters
WebPMuxAnimBlend ¶
WebPMuxAnimBlend :: enum i32 { BLEND, // Blend. NO_BLEND, // Do not blend. }
Blend operation (animation only). Indicates how transparent pixels of the current frame are blended with those of the previous canvas.
WebPMuxAnimDispose ¶
WebPMuxAnimDispose :: enum i32 { NONE, // Do not dispose. BACKGROUND, // Dispose to background color. }
Dispose method (animation only). Indicates how the area used by the current frame is to be treated before rendering the next frame on the canvas.
WebPMuxAnimParams ¶
WebPMuxAnimParams :: struct { bgcolor: u32, // Bits 00 to 07: Alpha. // Bits 08 to 15: Red. // Bits 16 to 23: Green. // Bits 24 to 31: Blue. loop_count: i32, }
Animation parameters.
Related Procedures With Parameters
WebPMuxError ¶
WebPMuxError :: enum i32 { OK = 1, NOT_FOUND = 0, INVALID_ARGUMENT = -1, BAD_DATA = -2, MEMORY_ERROR = -3, NOT_ENOUGH_DATA = -4, }
Error codes
Related Procedures With Returns
- WebPAnimEncoderDeleteChunk
- WebPAnimEncoderGetChunk
- WebPAnimEncoderSetChunk
- WebPMuxAssemble
- WebPMuxDeleteChunk
- WebPMuxDeleteFrame
- WebPMuxGetAnimationParams
- WebPMuxGetCanvasSize
- WebPMuxGetChunk
- WebPMuxGetFeatures
- WebPMuxGetFrame
- WebPMuxNumChunks
- WebPMuxPushFrame
- WebPMuxSetAnimationParams
- WebPMuxSetCanvasSize
- WebPMuxSetChunk
- WebPMuxSetImage
WebPMuxFrameInfo ¶
WebPMuxFrameInfo :: struct { bitstream: WebPData, // or a single-image WebP file. x_offset: i32, // x-offset of the frame. y_offset: i32, // y-offset of the frame. duration: i32, // duration of the frame (in milliseconds). id: WebPChunkId, // or WEBP_CHUNK_IMAGE dispose_method: WebPMuxAnimDispose, // Disposal method for the frame. blend_method: WebPMuxAnimBlend, // Blend operation for the frame. pad: [1]u32, }
Encapsulates data about a single frame.
Related Procedures With Parameters
WebPPicture ¶
WebPPicture :: struct { // INPUT // //////////// // Main flag for encoder selecting between ARGB or YUV input. // It is recommended to use ARGB input (*argb, argb_stride) for lossless // compression, and YUV input (*y, *u, *v, etc.) for lossy compression // since these are the respective native colorspace for these formats. use_argb: i32, // YUV input (mostly used for input to lossy compression) colorspace: WebPEncCSP, // colorspace: should be YUV420 for now (=Y'CbCr). width: i32, height: i32, // dimensions (less or equal to WEBP_MAX_DIMENSION) y: ^u8, u: ^u8, v: ^u8, // pointers to luma/chroma planes. y_stride: i32, uv_stride: i32, // luma/chroma strides. a: ^u8, // pointer to the alpha plane a_stride: i32, // stride of the alpha plane pad1: [2]u32, // ARGB input (mostly used for input to lossless compression) argb: ^u32, // Pointer to argb (32 bit) plane. argb_stride: i32, // This is stride in pixels units, not bytes. pad2: [3]u32, // OUTPUT // ///////////// // Byte-emission hook, to store compressed bytes as they are ready. writer: WebPWriterFunction, // can be NULL custom_ptr: rawptr, // map for extra information (only for lossy compression mode) extra_info_type: i32, // 4: intra-16 prediction mode, // 5: chroma prediction mode, // 6: bit cost, 7: distortion extra_info: ^u8, // STATS AND REPORTS // ///////////////////////// // Pointer to side statistics (updated only if not NULL) stats: ^WebPAuxStats, // Error code for the latest error encountered during encoding error_code: WebPEncodingError, // If not NULL, report progress during encoding. progress_hook: WebPProgressHook, user_data: rawptr, pad3: [3]u32, // Unused for now pad4: ^u8, pad5: ^u8, pad6: [8]u32, // PRIVATE FIELDS // ////////////////// memory_: rawptr, // row chunk of memory for yuva planes memory_argb_: rawptr, // and for argb too. pad7: [2]rawptr, }
Related Procedures With Parameters
- WebPAnimEncoderAdd
- WebPBlendAlpha
- WebPCleanupTransparentArea
- WebPEncode
- WebPMemoryWrite
- WebPPictureARGBToYUVA
- WebPPictureARGBToYUVADithered
- WebPPictureAlloc
- WebPPictureCopy
- WebPPictureCrop
- WebPPictureDistortion
- WebPPictureFree
- WebPPictureHasTransparency
- WebPPictureImportBGR
- WebPPictureImportBGRA
- WebPPictureImportBGRX
- WebPPictureImportRGB
- WebPPictureImportRGBA
- WebPPictureImportRGBX
- WebPPictureInit
- WebPPictureInitInternal
- WebPPictureIsView
- WebPPictureRescale
- WebPPictureSharpARGBToYUVA
- WebPPictureSmartARGBToYUVA
- WebPPictureView
- WebPPictureYUVAToARGB
WebPPreset ¶
WebPPreset :: enum i32 { DEFAULT = 0, // default preset. PICTURE, // digital picture, like portrait, inner shot PHOTO, // outdoor photograph, with natural lighting DRAWING, // hand or line drawing, with high-contrast details ICON, // small-sized colorful images TEXT, // text-like }
Enumerate some predefined settings for WebPConfig, depending on the type of source picture. These presets are used when calling WebPConfigPreset().
Related Procedures With Parameters
WebPProgressHook ¶
WebPProgressHook :: proc "c" (i32, ^WebPPicture) -> i32
Progress hook, called from time to time to report progress. It can return false to request an abort of the encoding process, or true otherwise if everything is OK.
WebPRGBABuffer ¶
WebPRGBABuffer :: struct { rgba: ^u8, // pointer to RGBA samples stride: i32, // stride in bytes from one scanline to the next. size: uint, }
------------------------------------------------------------------------------ WebPDecBuffer: Generic structure for describing the output sample buffer.
WebPWriterFunction ¶
WebPWriterFunction :: proc "c" (^u8, uint, ^WebPPicture) -> i32
Signature for output function. Should return true if writing was successful. data/data_size is the segment of data to write, and 'picture' is for reference (and so one can make use of picture->custom_ptr).
WebPYUVABuffer ¶
WebPYUVABuffer :: struct { y: ^u8, u: ^u8, v: ^u8, a: ^u8, // pointer to luma, chroma U/V, alpha samples y_stride: i32, // luma stride u_stride: i32, v_stride: i32, // chroma strides a_stride: i32, // alpha stride y_size: uint, // luma plane size u_size: uint, v_size: uint, // chroma planes size a_size: uint, }
WebP_Error ¶
WebP_Error :: union { WebP_Error_In, VP8StatusCode, os2.Error, runtime.Allocator_Error, }
Related Procedures With Returns
WebP_Error_In ¶
WebP_Error_In :: enum int { WebPAnimDecoderNew_Failed, WebPAnimDecoderGetNext_Failed, }
webp_converter ¶
webp_converter :: struct { anim_dec: ^WebPAnimDecoder, anim_info: WebPAnimInfo, out_fmt: image.color_fmt, config: webp_config, out_data: []u8, allocator: runtime.Allocator, }
WebP image converter structure
Supports both static images and animated WebP images
Related Procedures With Parameters
Constants
ALPHA_LOSSLESS_COMPRESSION ¶
ALPHA_LOSSLESS_COMPRESSION: int : 1
ALPHA_NO_COMPRESSION ¶
ALPHA_NO_COMPRESSION: int : 0
ALPHA_PREPROCESSED_LEVELS ¶
ALPHA_PREPROCESSED_LEVELS: int : 1
ARGB_BLACK ¶
ARGB_BLACK: int : 0
CODE_LENGTH_CODES ¶
CODE_LENGTH_CODES: int : 19
DEFAULT_CODE_LENGTH ¶
DEFAULT_CODE_LENGTH: int : 8
HUFFMAN_CODES_PER_META_CODE ¶
HUFFMAN_CODES_PER_META_CODE: int : 5
MAX_ALLOWED_CODE_LENGTH ¶
MAX_ALLOWED_CODE_LENGTH: int : 15
MAX_CACHE_BITS ¶
MAX_CACHE_BITS: int : 11
MAX_PALETTE_SIZE ¶
MAX_PALETTE_SIZE: int : 256
MIN_TRANSFORM_BITS ¶
MIN_TRANSFORM_BITS: int : 2
the maximum number of bits defining a transform is MIN_TRANSFORM_BITS + (1 << NUM_TRANSFORM_BITS) - 1
NUM_DISTANCE_CODES ¶
NUM_DISTANCE_CODES: int : 40
NUM_HUFFMAN_BITS ¶
NUM_HUFFMAN_BITS: int : 3
NUM_LENGTH_CODES ¶
NUM_LENGTH_CODES: int : 24
NUM_LITERAL_CODES ¶
NUM_LITERAL_CODES: int : 256
NUM_TRANSFORM_BITS ¶
NUM_TRANSFORM_BITS: int : 3
WEBP_MAX_DIMENSION ¶
WEBP_MAX_DIMENSION: int : 16383
maximum width/height allowed (inclusive), in pixels
Variables
This section is empty.
Procedures
WebPAnimDecoderDelete ¶
WebPAnimDecoderDelete :: proc "c" (dec: ^WebPAnimDecoder) ---
Deletes the WebPAnimDecoder object. Parameters: dec - (in/out) decoder instance to be deleted
WebPAnimDecoderGetDemuxer ¶
WebPAnimDecoderGetDemuxer :: proc "c" (dec: ^WebPAnimDecoder) -> ^WebPDemuxer ---
Grab the internal demuxer object. Getting the demuxer object can be useful if one wants to use operations only available through demuxer; e.g. to get XMP/EXIF/ICC metadata. The returned demuxer object is owned by 'dec' and is valid only until the next call to WebPAnimDecoderDelete().
Parameters: dec - (in) decoder instance from which the demuxer object is to be fetched.
WebPAnimDecoderGetInfo ¶
WebPAnimDecoderGetInfo :: proc "c" (dec: ^WebPAnimDecoder, info: ^WebPAnimInfo) -> i32 ---
Get global information about the animation. Parameters: dec - (in) decoder instance to get information from. info - (out) global information fetched from the animation. Returns: True on success.
WebPAnimDecoderGetNext ¶
WebPAnimDecoderGetNext :: proc "c" (dec: ^WebPAnimDecoder, buf: ^[^]u8, timestamp: ^i32) -> i32 ---
Fetch the next frame from 'dec' based on options supplied to WebPAnimDecoderNew(). This will be a fully reconstructed canvas of size 'canvas_width 4 canvas_height', and not just the frame sub-rectangle. The returned buffer 'buf' is valid only until the next call to WebPAnimDecoderGetNext(), WebPAnimDecoderReset() or WebPAnimDecoderDelete(). Parameters: dec - (in/out) decoder instance from which the next frame is to be fetched. buf - (out) decoded frame. timestamp - (out) timestamp of the frame in milliseconds. Returns: False if any of the arguments are NULL, or if there is a parsing or decoding error, or if there are no more frames. Otherwise, returns true.
WebPAnimDecoderHasMoreFrames ¶
WebPAnimDecoderHasMoreFrames :: proc "c" (dec: ^WebPAnimDecoder) -> i32 ---
Check if there are more frames left to decode. Parameters: dec - (in) decoder instance to be checked. Returns: True if 'dec' is not NULL and some frames are yet to be decoded. Otherwise, returns false.
WebPAnimDecoderNew ¶
WebPAnimDecoderNew :: proc "contextless" (webp_data: ^WebPData, dec_options: ^WebPAnimDecoderOptions) -> ^WebPAnimDecoder {…}
Creates and initializes a WebPAnimDecoder object. Parameters: webp_data - (in) WebP bitstream. This should remain unchanged during the lifetime of the output WebPAnimDecoder object. dec_options - (in) decoding options. Can be passed NULL to choose reasonable defaults (in particular, color mode MODE_RGBA will be picked). Returns: A pointer to the newly created WebPAnimDecoder object, or NULL in case of parsing error, invalid option or memory error.
WebPAnimDecoderNewInternal ¶
WebPAnimDecoderNewInternal :: proc "c" (webp_data: ^WebPData, dec_options: ^WebPAnimDecoderOptions, version: i32) -> ^WebPAnimDecoder ---
Internal, version-checked, entry point.
WebPAnimDecoderOptionsInit ¶
WebPAnimDecoderOptionsInit :: proc "contextless" (dec_options: ^WebPAnimDecoderOptions) -> i32 {…}
Should always be called, to initialize a fresh WebPAnimDecoderOptions structure before modification. Returns false in case of version mismatch. WebPAnimDecoderOptionsInit() must have succeeded before using the 'dec_options' object.
WebPAnimDecoderOptionsInitInternal ¶
WebPAnimDecoderOptionsInitInternal :: proc "c" (dec_options: ^WebPAnimDecoderOptions, version: i32) -> i32 ---
Internal, version-checked, entry point.
WebPAnimDecoderReset ¶
WebPAnimDecoderReset :: proc "c" (dec: ^WebPAnimDecoder) ---
Resets the WebPAnimDecoder object, so that next call to WebPAnimDecoderGetNext() will restart decoding from 1st frame. This would be helpful when all frames need to be decoded multiple times (e.g. info.loop_count times) without destroying and recreating the 'dec' object. Parameters: dec - (in/out) decoder instance to be reset
WebPAnimEncoderAdd ¶
WebPAnimEncoderAdd :: proc "c" (enc: ^WebPAnimEncoder, frame: ^WebPPicture, timestamp_ms: i32, config: ^WebPConfig) -> i32 ---
Optimize the given frame for WebP, encode it and add it to the WebPAnimEncoder object. The last call to 'WebPAnimEncoderAdd' should be with frame = NULL, which indicates that no more frames are to be added. This call is also used to determine the duration of the last frame. Parameters: enc - (in/out) object to which the frame is to be added. frame - (in/out) frame data in ARGB or YUV(A) format. If it is in YUV(A) format, it will be converted to ARGB, which incurs a small loss. timestamp_ms - (in) timestamp of this frame in milliseconds. Duration of a frame would be calculated as "timestamp of next frame - timestamp of this frame". Hence, timestamps should be in non-decreasing order. config - (in) encoding options; can be passed NULL to pick reasonable defaults. Returns: On error, returns false and frame->error_code is set appropriately. Otherwise, returns true.
WebPAnimEncoderAssemble ¶
WebPAnimEncoderAssemble :: proc "c" (enc: ^WebPAnimEncoder, webp_data: ^WebPData) -> i32 ---
Assemble all frames added so far into a WebP bitstream. This call should be preceded by a call to 'WebPAnimEncoderAdd' with frame = NULL; if not, the duration of the last frame will be internally estimated. Parameters: enc - (in/out) object from which the frames are to be assembled. webp_data - (out) generated WebP bitstream. Returns: True on success.
WebPAnimEncoderDelete ¶
WebPAnimEncoderDelete :: proc "c" (enc: ^WebPAnimEncoder) ---
Deletes the WebPAnimEncoder object. Parameters: enc - (in/out) object to be deleted
WebPAnimEncoderDeleteChunk ¶
WebPAnimEncoderDeleteChunk :: proc "c" (enc: ^WebPAnimEncoder, fourcc: cstring) -> WebPMuxError ---
Deletes the chunk with the given 'fourcc' from the enc object. Parameters: enc - (in/out) object from which the chunk is to be deleted fourcc - (in) a character array containing the fourcc of the chunk; e.g., "ICCP", "XMP ", "EXIF", etc. Returns: WEBP_MUX_INVALID_ARGUMENT - if enc or fourcc is NULL. WEBP_MUX_NOT_FOUND - If enc does not contain a chunk with the given fourcc. WEBP_MUX_OK - on success.
WebPAnimEncoderGetChunk ¶
WebPAnimEncoderGetChunk :: proc "c" (enc: ^WebPAnimEncoder, fourcc: cstring, chunk_data: ^WebPData) -> WebPMuxError ---
Gets a reference to the data of the chunk with id 'fourcc' in the enc object. The caller should NOT free the returned data. Parameters: enc - (in) object from which the chunk data is to be fetched fourcc - (in) a character array containing the fourcc of the chunk; e.g., "ICCP", "XMP ", "EXIF", etc. chunk_data - (out) returned chunk data Returns: WEBP_MUX_INVALID_ARGUMENT - if enc, fourcc or chunk_data is NULL. WEBP_MUX_NOT_FOUND - If enc does not contain a chunk with the given id. WEBP_MUX_OK - on success.
WebPAnimEncoderGetError ¶
WebPAnimEncoderGetError :: proc "c" (enc: ^WebPAnimEncoder) -> cstring ---
Get error string corresponding to the most recent call using 'enc'. The returned string is owned by 'enc' and is valid only until the next call to WebPAnimEncoderAdd() or WebPAnimEncoderAssemble() or WebPAnimEncoderDelete(). Parameters: enc - (in/out) object from which the error string is to be fetched. Returns: NULL if 'enc' is NULL. Otherwise, returns the error string if the last call to 'enc' had an error, or an empty string if the last call was a success.
WebPAnimEncoderNew ¶
WebPAnimEncoderNew :: proc "c" (width: i32, height: i32, enc_options: ^WebPAnimEncoderOptions) -> ^WebPAnimEncoder ---
Creates and initializes a WebPAnimEncoder object. Parameters: width/height - (in) canvas width and height of the animation. enc_options - (in) encoding options; can be passed NULL to pick reasonable defaults. Returns: A pointer to the newly created WebPAnimEncoder object. Or NULL in case of memory error.
WebPAnimEncoderNewInternal ¶
WebPAnimEncoderNewInternal :: proc "c" (i32, i32, ^WebPAnimEncoderOptions, i32) -> ^WebPAnimEncoder ---
Internal, version-checked, entry point.
WebPAnimEncoderOptionsInit ¶
WebPAnimEncoderOptionsInit :: proc "c" (enc_options: ^WebPAnimEncoderOptions) -> i32 ---
Should always be called, to initialize a fresh WebPAnimEncoderOptions structure before modification. Returns false in case of version mismatch. WebPAnimEncoderOptionsInit() must have succeeded before using the 'enc_options' object.
WebPAnimEncoderOptionsInitInternal ¶
WebPAnimEncoderOptionsInitInternal :: proc "c" (^WebPAnimEncoderOptions, i32) -> i32 ---
Internal, version-checked, entry point.
WebPAnimEncoderSetChunk ¶
WebPAnimEncoderSetChunk :: proc "c" (enc: ^WebPAnimEncoder, fourcc: cstring, chunk_data: ^WebPData, copy_data: i32) -> WebPMuxError ---
Adds a chunk with id 'fourcc' and data 'chunk_data' in the enc object. Any existing chunk(s) with the same id will be removed. Parameters: enc - (in/out) object to which the chunk is to be added fourcc - (in) a character array containing the fourcc of the given chunk; e.g., "ICCP", "XMP ", "EXIF", etc. chunk_data - (in) the chunk data to be added copy_data - (in) value 1 indicates given data WILL be copied to the enc object and value 0 indicates data will NOT be copied. If the data is not copied, it must exist until a call to WebPAnimEncoderAssemble() is made. Returns: WEBP_MUX_INVALID_ARGUMENT - if enc, fourcc or chunk_data is NULL. WEBP_MUX_MEMORY_ERROR - on memory allocation error. WEBP_MUX_OK - on success.
WebPBlendAlpha ¶
WebPBlendAlpha :: proc "c" (picture: ^WebPPicture, background_rgb: u32) ---
Remove the transparency information (if present) by blending the color with the background color 'background_rgb' (specified as 24bit RGB triplet). After this call, all alpha values are reset to 0xff.
WebPCleanupTransparentArea ¶
WebPCleanupTransparentArea :: proc "c" (picture: ^WebPPicture) ---
Helper function: given a width x height plane of RGBA or YUV(A) samples clean-up or smoothen the YUV or RGB samples under fully transparent area, to help compressibility (no guarantee, though).
WebPConfigInit ¶
WebPConfigInit :: proc "c" (config: ^WebPConfig) -> i32 ---
Should always be called, to initialize a fresh WebPConfig structure before modification. Returns false in case of version mismatch. WebPConfigInit() must have succeeded before using the 'config' object. Note that the default values are lossless=0 and quality=75.
WebPConfigInitInternal ¶
WebPConfigInitInternal :: proc "c" (^WebPConfig, WebPPreset, f32, i32) -> i32 ---
Internal, version-checked, entry point
WebPConfigLosslessPreset ¶
WebPConfigLosslessPreset :: proc "c" (config: ^WebPConfig, level: i32) -> i32 ---
Activate the lossless compression mode with the desired efficiency level between 0 (fastest, lowest compression) and 9 (slower, best compression). A good default level is '6', providing a fair tradeoff between compression speed and final compressed size. This function will overwrite several fields from config: 'method', 'quality' and 'lossless'. Returns false in case of parameter error.
WebPConfigPreset ¶
WebPConfigPreset :: proc "c" (config: ^WebPConfig, preset: WebPPreset, quality: f32) -> i32 ---
This function will initialize the configuration according to a predefined set of parameters (referred to by 'preset') and a given quality factor. This function can be called as a replacement to WebPConfigInit(). Will return false in case of error.
WebPDataClear ¶
WebPDataClear :: proc "c" (webp_data: ^WebPData) ---
Clears the contents of the 'webp_data' object by calling WebPFree(). Does not deallocate the object itself.
WebPDataCopy ¶
Allocates necessary storage for 'dst' and copies the contents of 'src'. Returns true on success.
WebPDataInit ¶
WebPDataInit :: proc "c" (webp_data: ^WebPData) ---
Initializes the contents of the 'webp_data' object with default values.
WebPDecode ¶
WebPDecode :: proc "c" (data: ^u8, data_size: uint, config: ^WebPDecoderConfig) -> VP8StatusCode ---
Non-incremental version. This version decodes the full data at once, taking 'config' into account. Returns decoding status (which should be VP8_STATUS_OK if the decoding was successful). Note that 'config' cannot be NULL.
WebPDecodeARGB ¶
Same as WebPDecodeRGBA, but returning A, R, G, B, A, R, G, B... ordered data.
WebPDecodeBGR ¶
Same as WebPDecodeRGB, but returning B, G, R, B, G, R... ordered data.
WebPDecodeBGRA ¶
Same as WebPDecodeRGBA, but returning B, G, R, A, B, G, R, A... ordered data.
WebPDecodeRGB ¶
Same as WebPDecodeRGBA, but returning R, G, B, R, G, B... ordered data. If the bitstream contains transparency, it is ignored.
WebPDecodeRGBA ¶
Decodes WebP images pointed to by 'data' and returns RGBA samples, along with the dimensions in width and height. The ordering of samples in memory is R, G, B, A, R, G, B, A... in scan order (endian-independent). The returned pointer should be deleted calling WebPFree(). Returns NULL in case of error.
WebPDecodeRGBAInto ¶
WebPDecodeRGBAInto :: proc "c" (data: ^u8, data_size: uint, output_buffer: ^u8, output_buffer_size: uint, output_stride: i32) -> ^u8 ---
These five functions are variants of the above ones, that decode the image directly into a pre-allocated buffer 'output_buffer'. The maximum storage available in this buffer is indicated by 'output_buffer_size'. If this storage is not sufficient (or an error occurred), NULL is returned. Otherwise, output_buffer is returned, for convenience. The parameter 'output_stride' specifies the distance (in bytes) between scanlines. Hence, output_buffer_size is expected to be at least output_stride x picture-height.
WebPDecodeRGBInto ¶
WebPDecodeRGBInto :: proc "c" (data: ^u8, data_size: uint, output_buffer: ^u8, output_buffer_size: uint, output_stride: i32) -> ^u8 ---
RGB and BGR variants. Here too the transparency information, if present, will be dropped and ignored.
WebPDecodeYUV ¶
WebPDecodeYUV :: proc "c" ( data: ^u8, data_size: uint, width: ^i32, height: ^i32, u: ^^u8, v: ^^u8, stride: ^i32, uv_stride: ^i32, ) -> ^u8 ---
Decode WebP images pointed to by 'data' to Y'UV format(*). The pointer returned is the Y samples buffer. Upon return, u and v will point to the U and V chroma data. These U and V buffers need NOT be passed to WebPFree(), unlike the returned Y luma one. The dimension of the U and V planes are both (width + 1) / 2 and (height + 1) / 2. Upon return, the Y buffer has a stride returned as '*stride', while U and V have a common stride returned as '*uv_stride'. 'width' and 'height' may be NULL, the other pointers must not be. Returns NULL in case of error. (*) Also named Y'CbCr. See: https://en.wikipedia.org/wiki/YCbCr
WebPDecodeYUVInto ¶
WebPDecodeYUVInto :: proc "c" ( data: ^u8, data_size: uint, luma: ^u8, luma_size: uint, luma_stride: i32, u: ^u8, u_size: uint, u_stride: i32, v: ^u8, v_size: uint, v_stride: i32, ) -> ^u8 ---
WebPDecodeYUVInto() is a variant of WebPDecodeYUV() that operates directly into pre-allocated luma/chroma plane buffers. This function requires the strides to be passed: one for the luma plane and one for each of the chroma ones. The size of each plane buffer is passed as 'luma_size', 'u_size' and 'v_size' respectively. Pointer to the luma plane ('*luma') is returned or NULL if an error occurred during decoding (or because some buffers were found to be too small).
WebPDemux ¶
WebPDemux :: proc "c" (data: ^WebPData) -> ^WebPDemuxer ---
Parses the full WebP file given by 'data'. For single images the WebP file header alone or the file header and the chunk header may be absent. Returns a WebPDemuxer object on successful parse, NULL otherwise.
WebPDemuxDelete ¶
WebPDemuxDelete :: proc "c" (dmux: ^WebPDemuxer) ---
Frees memory associated with 'dmux'.
WebPDemuxGetChunk ¶
WebPDemuxGetChunk :: proc "c" (dmux: ^WebPDemuxer, fourcc: cstring, chunk_number: i32, iter: ^WebPChunkIterator) -> i32 ---
Retrieves the 'chunk_number' instance of the chunk with id 'fourcc' from 'dmux'. 'fourcc' is a character array containing the fourcc of the chunk to return, e.g., "ICCP", "XMP ", "EXIF", etc. Setting 'chunk_number' equal to 0 will return the last chunk in a set. Returns true if the chunk is found, false otherwise. Image related chunk payloads are accessed through WebPDemuxGetFrame() and related functions. Call WebPDemuxReleaseChunkIterator() when use of the iterator is complete. NOTE: 'dmux' must persist for the lifetime of the iterator.
WebPDemuxGetFrame ¶
WebPDemuxGetFrame :: proc "c" (dmux: ^WebPDemuxer, frame_number: i32, iter: ^WebPIterator) -> i32 ---
Retrieves frame 'frame_number' from 'dmux'. 'iter->fragment' points to the frame on return from this function. Setting 'frame_number' equal to 0 will return the last frame of the image. Returns false if 'dmux' is NULL or frame 'frame_number' is not present. Call WebPDemuxReleaseIterator() when use of the iterator is complete. NOTE: 'dmux' must persist for the lifetime of 'iter'.
WebPDemuxGetI ¶
WebPDemuxGetI :: proc "c" (dmux: ^WebPDemuxer, feature: WebPFormatFeature) -> u32 ---
Get the 'feature' value from the 'dmux'. NOTE: values are only valid if WebPDemux() was used or WebPDemuxPartial() returned a state > WEBP_DEMUX_PARSING_HEADER. If 'feature' is WEBP_FF_FORMAT_FLAGS, the returned value is a bit-wise combination of WebPFeatureFlags values. If 'feature' is WEBP_FF_LOOP_COUNT, WEBP_FF_BACKGROUND_COLOR, the returned value is only meaningful if the bitstream is animated.
WebPDemuxInternal ¶
WebPDemuxInternal :: proc "c" (^WebPData, i32, ^WebPDemuxState, i32) -> ^WebPDemuxer ---
Internal, version-checked, entry point
WebPDemuxNextChunk ¶
WebPDemuxNextChunk :: proc "c" (iter: ^WebPChunkIterator) -> i32 ---
Sets 'iter->chunk' to point to the next ('iter->chunk_num' + 1) or previous ('iter->chunk_num' - 1) chunk. These functions do not loop. Returns true on success, false otherwise.
WebPDemuxNextFrame ¶
WebPDemuxNextFrame :: proc "c" (iter: ^WebPIterator) -> i32 ---
Sets 'iter->fragment' to point to the next ('iter->frame_num' + 1) or previous ('iter->frame_num' - 1) frame. These functions do not loop. Returns true on success, false otherwise.
WebPDemuxPartial ¶
WebPDemuxPartial :: proc "c" (data: ^WebPData, state: ^WebPDemuxState) -> ^WebPDemuxer ---
Parses the possibly incomplete WebP file given by 'data'. If 'state' is non-NULL it will be set to indicate the status of the demuxer. Returns NULL in case of error or if there isn't enough data to start parsing; and a WebPDemuxer object on successful parse. Note that WebPDemuxer keeps internal pointers to 'data' memory segment. If this data is volatile, the demuxer object should be deleted (by calling WebPDemuxDelete()) and WebPDemuxPartial() called again on the new data. This is usually an inexpensive operation.
WebPDemuxPrevChunk ¶
WebPDemuxPrevChunk :: proc "c" (iter: ^WebPChunkIterator) -> i32 ---
WebPDemuxPrevFrame ¶
WebPDemuxPrevFrame :: proc "c" (iter: ^WebPIterator) -> i32 ---
WebPDemuxReleaseChunkIterator ¶
WebPDemuxReleaseChunkIterator :: proc "c" (iter: ^WebPChunkIterator) ---
Releases any memory associated with 'iter'. Must be called before destroying the associated WebPDemuxer with WebPDemuxDelete().
WebPDemuxReleaseIterator ¶
WebPDemuxReleaseIterator :: proc "c" (iter: ^WebPIterator) ---
Releases any memory associated with 'iter'. Must be called before any subsequent calls to WebPDemuxGetChunk() on the same iter. Also, must be called before destroying the associated WebPDemuxer with WebPDemuxDelete().
WebPEncode ¶
WebPEncode :: proc "c" (config: ^WebPConfig, picture: ^WebPPicture) -> i32 ---
Main encoding call, after config and picture have been initialized. 'picture' must be less than 16384x16384 in dimension (cf WEBP_MAX_DIMENSION), and the 'config' object must be a valid one. Returns false in case of error, true otherwise. In case of error, picture->error_code is updated accordingly. 'picture' can hold the source samples in both YUV(A) or ARGB input, depending on the value of 'picture->use_argb'. It is highly recommended to use the former for lossy encoding, and the latter for lossless encoding (when config.lossless is true). Automatic conversion from one format to another is provided but they both incur some loss.
WebPEncodeLosslessRGB ¶
WebPEncodeLosslessRGB :: proc "c" (rgb: ^u8, width: i32, height: i32, stride: i32, output: ^^u8) -> uint ---
These functions are the equivalent of the above, but compressing in a lossless manner. Files are usually larger than lossy format, but will not suffer any compression loss. Note these functions, like the lossy versions, use the library's default settings. For lossless this means 'exact' is disabled. RGB values in transparent areas will be modified to improve compression. To avoid this, use WebPEncode() and set WebPConfig::exact to 1.
WebPEncodeRGB ¶
WebPEncodeRGB :: proc "c" ( rgb: ^u8, width: i32, height: i32, stride: i32, quality_factor: f32, output: ^^u8, ) -> uint ---
Returns the size of the compressed data (pointed to by *output), or 0 if an error occurred. The compressed data must be released by the caller using the call 'WebPFree(*output)'. These functions compress using the lossy format, and the quality_factor can go from 0 (smaller output, lower quality) to 100 (best quality, larger output).
WebPFree ¶
WebPFree :: proc "c" (ptr: rawptr) ---
Releases memory returned by the WebPDecode*() functions (from decode.h).
WebPFreeDecBuffer ¶
WebPFreeDecBuffer :: proc "c" (buffer: ^WebPDecBuffer) ---
Free any memory associated with the buffer. Must always be called last. Note: doesn't free the 'buffer' structure itself.
WebPGetDecoderVersion ¶
WebPGetDecoderVersion :: proc "c" () -> i32 ---
Return the decoder's version number, packed in hexadecimal using 8bits for each of major/minor/revision. E.g: v2.5.7 is 0x020507.
WebPGetDemuxVersion ¶
WebPGetDemuxVersion :: proc "c" () -> i32 ---
Returns the version number of the demux library, packed in hexadecimal using 8bits for each of major/minor/revision. E.g: v2.5.7 is 0x020507.
WebPGetEncoderVersion ¶
WebPGetEncoderVersion :: proc "c" () -> i32 ---
Return the encoder's version number, packed in hexadecimal using 8bits for each of major/minor/revision. E.g: v2.5.7 is 0x020507.
WebPGetFeatures ¶
WebPGetFeatures :: proc "contextless" (data: ^u8, data_size: uint, features: ^WebPBitstreamFeatures) -> VP8StatusCode {…}
Retrieve features from the bitstream. The *features structure is filled with information gathered from the bitstream. Returns VP8_STATUS_OK when the features are successfully retrieved. Returns VP8_STATUS_NOT_ENOUGH_DATA when more data is needed to retrieve the features from headers. Returns error in other cases. Note: The following chunk sequences (before the raw VP8/VP8L data) are considered valid by this function: RIFF + VP8(L) RIFF + VP8X + (optional chunks) + VP8(L) ALPH + VP8 <-- Not a valid WebP format: only allowed for internal purpose. VP8(L) <-- Not a valid WebP format: only allowed for internal purpose.
WebPGetFeaturesInternal ¶
WebPGetFeaturesInternal :: proc "c" (data: ^u8, data_size: uint, features: ^WebPBitstreamFeatures, version: i32) -> VP8StatusCode ---
Internal, version-checked, entry point
WebPGetInfo ¶
Retrieve basic header information: width, height. This function will also validate the header, returning true on success, false otherwise. 'width' and 'height' are only valid on successful return. Pointers 'width' and 'height' can be passed NULL if deemed irrelevant. Note: The following chunk sequences (before the raw VP8/VP8L data) are considered valid by this function: RIFF + VP8(L) RIFF + VP8X + (optional chunks) + VP8(L) ALPH + VP8 <-- Not a valid WebP format: only allowed for internal purpose. VP8(L) <-- Not a valid WebP format: only allowed for internal purpose.
WebPGetMuxVersion ¶
WebPGetMuxVersion :: proc "c" () -> i32 ---
Returns the version number of the mux library, packed in hexadecimal using 8bits for each of major/minor/revision. E.g: v2.5.7 is 0x020507.
WebPIAppend ¶
WebPIAppend :: proc "c" (idec: ^WebPIDecoder, data: ^u8, data_size: uint) -> VP8StatusCode ---
Copies and decodes the next available data. Returns VP8_STATUS_OK when the image is successfully decoded. Returns VP8_STATUS_SUSPENDED when more data is expected. Returns error in other cases.
WebPIDecGetRGB ¶
WebPIDecGetRGB :: proc "c" (idec: ^WebPIDecoder, last_y: ^i32, width: ^i32, height: ^i32, stride: ^i32) -> ^u8 ---
Returns the RGB/A image decoded so far. Returns NULL if output params are not initialized yet. The RGB/A output type corresponds to the colorspace specified during call to WebPINewDecoder() or WebPINewRGB(). *last_y is the index of last decoded row in raster scan order. Some pointers (last_y, width etc.) can be NULL if corresponding information is not needed. The values in these pointers are only valid on successful (non-NULL) return.
WebPIDecGetYUV ¶
WebPIDecGetYUV :: proc "c" ( idec: ^WebPIDecoder, last_y: ^i32, u: ^^u8, v: ^^u8, width: ^i32, height: ^i32, stride: ^i32, uv_stride: ^i32, ) -> ^u8 ---
Deprecated alpha-less version of WebPIDecGetYUVA(): it will ignore the alpha information (if present). Kept for backward compatibility.
WebPIDecGetYUVA ¶
WebPIDecGetYUVA :: proc "c" ( idec: ^WebPIDecoder, last_y: ^i32, u: ^^u8, v: ^^u8, a: ^^u8, width: ^i32, height: ^i32, stride: ^i32, uv_stride: ^i32, a_stride: ^i32, ) -> ^u8 ---
Same as above function to get a YUVA image. Returns pointer to the luma plane or NULL in case of error. If there is no alpha information the alpha pointer '*a' will be returned NULL.
WebPIDecode ¶
WebPIDecode :: proc "c" (data: ^u8, data_size: uint, config: ^WebPDecoderConfig) -> ^WebPIDecoder ---
Instantiate a new incremental decoder object with the requested configuration. The bitstream can be passed using 'data' and 'data_size' parameter, in which case the features will be parsed and stored into config->input. Otherwise, 'data' can be NULL and no parsing will occur. Note that 'config' can be NULL too, in which case a default configuration is used. If 'config' is not NULL, it must outlive the WebPIDecoder object as some references to its fields will be used. No internal copy of 'config' is made. The return WebPIDecoder object must always be deleted calling WebPIDelete(). Returns NULL in case of error (and config->status will then reflect the error condition, if available).
WebPIDecodedArea ¶
WebPIDecodedArea :: proc "c" (idec: ^WebPIDecoder, left: ^i32, top: ^i32, width: ^i32, height: ^i32) -> ^WebPDecBuffer ---
Generic call to retrieve information about the displayable area. If non NULL, the left/right/width/height pointers are filled with the visible rectangular area so far. Returns NULL in case the incremental decoder object is in an invalid state. Otherwise returns the pointer to the internal representation. This structure is read-only, tied to WebPIDecoder's lifespan and should not be modified.
WebPIDelete ¶
WebPIDelete :: proc "c" (idec: ^WebPIDecoder) ---
Deletes the WebPIDecoder object and associated memory. Must always be called if WebPINewDecoder, WebPINewRGB or WebPINewYUV succeeded.
WebPINewDecoder ¶
WebPINewDecoder :: proc "c" (output_buffer: ^WebPDecBuffer) -> ^WebPIDecoder ---
Creates a new incremental decoder with the supplied buffer parameter. This output_buffer can be passed NULL, in which case a default output buffer is used (with MODE_RGB). Otherwise, an internal reference to 'output_buffer' is kept, which means that the lifespan of 'output_buffer' must be larger than that of the returned WebPIDecoder object. The supplied 'output_buffer' content MUST NOT be changed between calls to WebPIAppend() or WebPIUpdate() unless 'output_buffer.is_external_memory' is not set to 0. In such a case, it is allowed to modify the pointers, size and stride of output_buffer.u.RGBA or output_buffer.u.YUVA, provided they remain within valid bounds. All other fields of WebPDecBuffer MUST remain constant between calls. Returns NULL if the allocation failed.
WebPINewRGB ¶
WebPINewRGB :: proc "c" (csp: CSP_MODE, output_buffer: ^u8, output_buffer_size: uint, output_stride: i32) -> ^WebPIDecoder ---
This function allocates and initializes an incremental-decoder object, which will output the RGB/A samples specified by 'csp' into a preallocated buffer 'output_buffer'. The size of this buffer is at least 'output_buffer_size' and the stride (distance in bytes between two scanlines) is specified by 'output_stride'. Additionally, output_buffer can be passed NULL in which case the output buffer will be allocated automatically when the decoding starts. The colorspace 'csp' is taken into account for allocating this buffer. All other parameters are ignored. Returns NULL if the allocation failed, or if some parameters are invalid.
WebPINewYUV ¶
WebPINewYUV :: proc "c" ( luma: ^u8, luma_size: uint, luma_stride: i32, u: ^u8, u_size: uint, u_stride: i32, v: ^u8, v_size: uint, v_stride: i32, ) -> ^WebPIDecoder ---
Deprecated version of the above, without the alpha plane. Kept for backward compatibility.
WebPINewYUVA ¶
WebPINewYUVA :: proc "c" ( luma: ^u8, luma_size: uint, luma_stride: i32, u: ^u8, u_size: uint, u_stride: i32, v: ^u8, v_size: uint, v_stride: i32, a: ^u8, a_size: uint, a_stride: i32, ) -> ^WebPIDecoder ---
This function allocates and initializes an incremental-decoder object, which will output the raw luma/chroma samples into a preallocated planes if supplied. The luma plane is specified by its pointer 'luma', its size 'luma_size' and its stride 'luma_stride'. Similarly, the chroma-u plane is specified by the 'u', 'u_size' and 'u_stride' parameters, and the chroma-v plane by 'v' and 'v_size'. And same for the alpha-plane. The 'a' pointer can be pass NULL in case one is not interested in the transparency plane. Conversely, 'luma' can be passed NULL if no preallocated planes are supplied. In this case, the output buffer will be automatically allocated (using MODE_YUVA) when decoding starts. All parameters are then ignored. Returns NULL if the allocation failed or if a parameter is invalid.
WebPIUpdate ¶
WebPIUpdate :: proc "c" (idec: ^WebPIDecoder, data: ^u8, data_size: uint) -> VP8StatusCode ---
A variant of the above function to be used when data buffer contains partial data from the beginning. In this case data buffer is not copied to the internal memory. Note that the value of the 'data' pointer can change between calls to WebPIUpdate, for instance when the data buffer is resized to fit larger data.
WebPInitDecBuffer ¶
WebPInitDecBuffer :: proc "contextless" (buffer: ^WebPDecBuffer) -> i32 {…}
Initialize the structure as empty. Must be called before any other use. Returns false in case of version mismatch
WebPInitDecBufferInternal ¶
WebPInitDecBufferInternal :: proc "c" (buffer: ^WebPDecBuffer, version: i32) -> i32 ---
Internal, version-checked, entry point
WebPInitDecoderConfig ¶
WebPInitDecoderConfig :: proc "contextless" (config: ^WebPDecoderConfig) -> i32 {…}
Initialize the configuration as empty. This function must always be called first, unless WebPGetFeatures() is to be called. Returns false in case of mismatched version.
WebPInitDecoderConfigInternal ¶
WebPInitDecoderConfigInternal :: proc "c" (config: ^WebPDecoderConfig, version: i32) -> i32 ---
Internal, version-checked, entry point
WebPMalloc ¶
Allocates 'size' bytes of memory. Returns NULL upon error. Memory must be deallocated by calling WebPFree(). This function is made available by the core 'libwebp' library.
WebPMemoryWrite ¶
WebPMemoryWrite :: proc "c" (data: ^u8, data_size: uint, picture: ^WebPPicture) -> i32 ---
The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon completion, writer.mem and writer.size will hold the coded data. writer.mem must be freed by calling WebPMemoryWriterClear.
WebPMemoryWriterClear ¶
WebPMemoryWriterClear :: proc "c" (writer: ^WebPMemoryWriter) ---
The following must be called to deallocate writer->mem memory. The 'writer' object itself is not deallocated.
WebPMemoryWriterInit ¶
WebPMemoryWriterInit :: proc "c" (writer: ^WebPMemoryWriter) ---
The following must be called first before any use.
WebPMuxAssemble ¶
WebPMuxAssemble :: proc "c" (mux: ^WebPMux, assembled_data: ^WebPData) -> WebPMuxError ---
Assembles all chunks in WebP RIFF format and returns in 'assembled_data'. This function also validates the mux object. Note: The content of 'assembled_data' will be ignored and overwritten. Also, the content of 'assembled_data' is allocated using WebPMalloc(), and NOT owned by the 'mux' object. It MUST be deallocated by the caller by calling WebPDataClear(). It's always safe to call WebPDataClear() upon return, even in case of error. Parameters: mux - (in/out) object whose chunks are to be assembled assembled_data - (out) assembled WebP data Returns: WEBP_MUX_BAD_DATA - if mux object is invalid. WEBP_MUX_INVALID_ARGUMENT - if mux or assembled_data is NULL. WEBP_MUX_MEMORY_ERROR - on memory allocation error. WEBP_MUX_OK - on success.
WebPMuxCreate ¶
Creates a mux object from raw data given in WebP RIFF format. Parameters: bitstream - (in) the bitstream data in WebP RIFF format copy_data - (in) value 1 indicates given data WILL be copied to the mux object and value 0 indicates data will NOT be copied. If the data is not copied, it must exist for the lifetime of the mux object. Returns: A pointer to the mux object created from given data - on success. NULL - In case of invalid data or memory error.
WebPMuxCreateInternal ¶
Internal, version-checked, entry point
WebPMuxDelete ¶
WebPMuxDelete :: proc "c" (mux: ^WebPMux) ---
Deletes the mux object. Parameters: mux - (in/out) object to be deleted
WebPMuxDeleteChunk ¶
WebPMuxDeleteChunk :: proc "c" (mux: ^WebPMux, fourcc: cstring) -> WebPMuxError ---
Deletes the chunk with the given 'fourcc' from the mux object. Parameters: mux - (in/out) object from which the chunk is to be deleted fourcc - (in) a character array containing the fourcc of the chunk; e.g., "ICCP", "XMP ", "EXIF" etc. Returns: WEBP_MUX_INVALID_ARGUMENT - if mux or fourcc is NULL or if fourcc corresponds to an image chunk. WEBP_MUX_NOT_FOUND - If mux does not contain a chunk with the given fourcc. WEBP_MUX_OK - on success.
WebPMuxDeleteFrame ¶
WebPMuxDeleteFrame :: proc "c" (mux: ^WebPMux, nth: u32) -> WebPMuxError ---
Deletes a frame from the mux object. nth=0 has a special meaning - last position. Parameters: mux - (in/out) object from which a frame is to be deleted nth - (in) The position from which the frame is to be deleted Returns: WEBP_MUX_INVALID_ARGUMENT - if mux is NULL. WEBP_MUX_NOT_FOUND - If there are less than nth frames in the mux object before deletion. WEBP_MUX_OK - on success.
WebPMuxGetAnimationParams ¶
WebPMuxGetAnimationParams :: proc "c" (mux: ^WebPMux, params: ^WebPMuxAnimParams) -> WebPMuxError ---
Gets the animation parameters from the mux object. Parameters: mux - (in) object from which the animation parameters to be fetched params - (out) animation parameters extracted from the ANIM chunk Returns: WEBP_MUX_INVALID_ARGUMENT - if mux or params is NULL. WEBP_MUX_NOT_FOUND - if ANIM chunk is not present in mux object. WEBP_MUX_OK - on success.
WebPMuxGetCanvasSize ¶
WebPMuxGetCanvasSize :: proc "c" (mux: ^WebPMux, width: ^i32, height: ^i32) -> WebPMuxError ---
Gets the canvas size from the mux object. Note: This method assumes that the VP8X chunk, if present, is up-to-date. That is, the mux object hasn't been modified since the last call to WebPMuxAssemble() or WebPMuxCreate(). Parameters: mux - (in) object from which the canvas size is to be fetched width - (out) canvas width height - (out) canvas height Returns: WEBP_MUX_INVALID_ARGUMENT - if mux, width or height is NULL. WEBP_MUX_BAD_DATA - if VP8X/VP8/VP8L chunk or canvas size is invalid. WEBP_MUX_OK - on success.
WebPMuxGetChunk ¶
WebPMuxGetChunk :: proc "c" (mux: ^WebPMux, fourcc: cstring, chunk_data: ^WebPData) -> WebPMuxError ---
Gets a reference to the data of the chunk with id 'fourcc' in the mux object. The caller should NOT free the returned data. Parameters: mux - (in) object from which the chunk data is to be fetched fourcc - (in) a character array containing the fourcc of the chunk; e.g., "ICCP", "XMP ", "EXIF" etc. chunk_data - (out) returned chunk data Returns: WEBP_MUX_INVALID_ARGUMENT - if mux, fourcc or chunk_data is NULL or if fourcc corresponds to an image chunk. WEBP_MUX_NOT_FOUND - If mux does not contain a chunk with the given id. WEBP_MUX_OK - on success.
WebPMuxGetFeatures ¶
WebPMuxGetFeatures :: proc "c" (mux: ^WebPMux, flags: ^u32) -> WebPMuxError ---
Gets the feature flags from the mux object. Note: This method assumes that the VP8X chunk, if present, is up-to-date. That is, the mux object hasn't been modified since the last call to WebPMuxAssemble() or WebPMuxCreate(). Parameters: mux - (in) object from which the features are to be fetched flags - (out) the flags specifying which features are present in the mux object. This will be an OR of various flag values. Enum 'WebPFeatureFlags' can be used to test individual flag values. Returns: WEBP_MUX_INVALID_ARGUMENT - if mux or flags is NULL. WEBP_MUX_BAD_DATA - if VP8X/VP8/VP8L chunk or canvas size is invalid. WEBP_MUX_OK - on success.
WebPMuxGetFrame ¶
WebPMuxGetFrame :: proc "c" (mux: ^WebPMux, nth: u32, frame: ^WebPMuxFrameInfo) -> WebPMuxError ---
Gets the nth frame from the mux object. The content of 'frame->bitstream' is allocated using WebPMalloc(), and NOT owned by the 'mux' object. It MUST be deallocated by the caller by calling WebPDataClear(). nth=0 has a special meaning - last position. Parameters: mux - (in) object from which the info is to be fetched nth - (in) index of the frame in the mux object frame - (out) data of the returned frame Returns: WEBP_MUX_INVALID_ARGUMENT - if mux or frame is NULL. WEBP_MUX_NOT_FOUND - if there are less than nth frames in the mux object. WEBP_MUX_BAD_DATA - if nth frame chunk in mux is invalid. WEBP_MUX_MEMORY_ERROR - on memory allocation error. WEBP_MUX_OK - on success.
WebPMuxNew ¶
WebPMuxNew :: proc "c" () -> ^WebPMux ---
Creates an empty mux object. Returns: A pointer to the newly created empty mux object. Or NULL in case of memory error.
WebPMuxNumChunks ¶
WebPMuxNumChunks :: proc "c" (mux: ^WebPMux, id: WebPChunkId, num_elements: ^i32) -> WebPMuxError ---
Gets number of chunks with the given 'id' in the mux object. Parameters: mux - (in) object from which the info is to be fetched id - (in) chunk id specifying the type of chunk num_elements - (out) number of chunks with the given chunk id Returns: WEBP_MUX_INVALID_ARGUMENT - if mux, or num_elements is NULL. WEBP_MUX_OK - on success.
WebPMuxPushFrame ¶
WebPMuxPushFrame :: proc "c" (mux: ^WebPMux, frame: ^WebPMuxFrameInfo, copy_data: i32) -> WebPMuxError ---
Adds a frame at the end of the mux object. Notes: (1) frame.id should be WEBP_CHUNK_ANMF (2) For setting a non-animated image, use WebPMuxSetImage() instead. (3) Type of frame being pushed must be same as the frames in mux. (4) As WebP only supports even offsets, any odd offset will be snapped to an even location using: offset &= ~1 Parameters: mux - (in/out) object to which the frame is to be added frame - (in) frame data. copy_data - (in) value 1 indicates given data WILL be copied to the mux object and value 0 indicates data will NOT be copied. If the data is not copied, it must exist until a call to WebPMuxAssemble() is made. Returns: WEBP_MUX_INVALID_ARGUMENT - if mux or frame is NULL or if content of 'frame' is invalid. WEBP_MUX_MEMORY_ERROR - on memory allocation error. WEBP_MUX_OK - on success.
WebPMuxSetAnimationParams ¶
WebPMuxSetAnimationParams :: proc "c" (mux: ^WebPMux, params: ^WebPMuxAnimParams) -> WebPMuxError ---
Sets the animation parameters in the mux object. Any existing ANIM chunks will be removed. Parameters: mux - (in/out) object in which ANIM chunk is to be set/added params - (in) animation parameters. Returns: WEBP_MUX_INVALID_ARGUMENT - if mux or params is NULL. WEBP_MUX_MEMORY_ERROR - on memory allocation error. WEBP_MUX_OK - on success.
WebPMuxSetCanvasSize ¶
WebPMuxSetCanvasSize :: proc "c" (mux: ^WebPMux, width: i32, height: i32) -> WebPMuxError ---
Sets the canvas size for the mux object. The width and height can be specified explicitly or left as zero (0, 0). * When width and height are specified explicitly, then this frame bound is enforced during subsequent calls to WebPMuxAssemble() and an error is reported if any animated frame does not completely fit within the canvas. * When unspecified (0, 0), the constructed canvas will get the frame bounds from the bounding-box over all frames after calling WebPMuxAssemble(). Parameters: mux - (in) object to which the canvas size is to be set width - (in) canvas width height - (in) canvas height Returns: WEBP_MUX_INVALID_ARGUMENT - if mux is NULL; or width or height are invalid or out of bounds WEBP_MUX_OK - on success.
WebPMuxSetChunk ¶
WebPMuxSetChunk :: proc "c" (mux: ^WebPMux, fourcc: cstring, chunk_data: ^WebPData, copy_data: i32) -> WebPMuxError ---
Adds a chunk with id 'fourcc' and data 'chunk_data' in the mux object. Any existing chunk(s) with the same id will be removed. Parameters: mux - (in/out) object to which the chunk is to be added fourcc - (in) a character array containing the fourcc of the given chunk; e.g., "ICCP", "XMP ", "EXIF" etc. chunk_data - (in) the chunk data to be added copy_data - (in) value 1 indicates given data WILL be copied to the mux object and value 0 indicates data will NOT be copied. If the data is not copied, it must exist until a call to WebPMuxAssemble() is made. Returns: WEBP_MUX_INVALID_ARGUMENT - if mux, fourcc or chunk_data is NULL or if fourcc corresponds to an image chunk. WEBP_MUX_MEMORY_ERROR - on memory allocation error. WEBP_MUX_OK - on success.
WebPMuxSetImage ¶
WebPMuxSetImage :: proc "c" (mux: ^WebPMux, bitstream: ^WebPData, copy_data: i32) -> WebPMuxError ---
Sets the (non-animated) image in the mux object. Note: Any existing images (including frames) will be removed. Parameters: mux - (in/out) object in which the image is to be set bitstream - (in) can be a raw VP8/VP8L bitstream or a single-image WebP file (non-animated) copy_data - (in) value 1 indicates given data WILL be copied to the mux object and value 0 indicates data will NOT be copied. If the data is not copied, it must exist until a call to WebPMuxAssemble() is made. Returns: WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or bitstream is NULL. WEBP_MUX_MEMORY_ERROR - on memory allocation error. WEBP_MUX_OK - on success.
WebPNewInternal ¶
Internal, version-checked, entry point
WebPPictureARGBToYUVA ¶
WebPPictureARGBToYUVA :: proc "c" (picture: ^WebPPicture, colorspace: WebPEncCSP) -> i32 ---
Converts picture->argb data to the YUV420A format. The 'colorspace' parameter is deprecated and should be equal to WEBP_YUV420. Upon return, picture->use_argb is set to false. The presence of real non-opaque transparent values is detected, and 'colorspace' will be adjusted accordingly. Note that this method is lossy. Returns false in case of error.
WebPPictureARGBToYUVADithered ¶
WebPPictureARGBToYUVADithered :: proc "c" (picture: ^WebPPicture, colorspace: WebPEncCSP, dithering: f32) -> i32 ---
Same as WebPPictureARGBToYUVA(), but the conversion is done using pseudo-random dithering with a strength 'dithering' between 0.0 (no dithering) and 1.0 (maximum dithering). This is useful for photographic picture.
WebPPictureAlloc ¶
WebPPictureAlloc :: proc "c" (picture: ^WebPPicture) -> i32 ---
Convenience allocation / deallocation based on picture->width/height: Allocate y/u/v buffers as per colorspace/width/height specification. Note! This function will free the previous buffer if needed. Returns false in case of memory error.
WebPPictureCopy ¶
WebPPictureCopy :: proc "c" (src: ^WebPPicture, dst: ^WebPPicture) -> i32 ---
Copy the pixels of src into dst, using WebPPictureAlloc. Upon return, *dst will fully own the copied pixels (this is not a view). The 'dst' picture need not be initialized as its content is overwritten. Returns false in case of memory allocation error.
WebPPictureCrop ¶
WebPPictureCrop :: proc "c" (picture: ^WebPPicture, left: i32, top: i32, width: i32, height: i32) -> i32 ---
self-crops a picture to the rectangle defined by top/left/width/height. Returns false in case of memory allocation error, or if the rectangle is outside of the source picture. The rectangle for the view is defined by the top-left corner pixel coordinates (left, top) as well as its width and height. This rectangle must be fully be comprised inside the 'src' source picture. If the source picture uses the YUV420 colorspace, the top and left coordinates will be snapped to even values.
WebPPictureDistortion ¶
WebPPictureDistortion :: proc "c" (src: ^WebPPicture, ref: ^WebPPicture, metric_type: i32, result: ^f32) -> i32 ---
Compute PSNR, SSIM or LSIM distortion metric between two pictures. Results are in dB, stored in result[] in the B/G/R/A/All order. The distortion is always performed using ARGB samples. Hence if the input is YUV(A), the picture will be internally converted to ARGB (just for the measurement). Warning: this function is rather CPU-intensive.
WebPPictureFree ¶
WebPPictureFree :: proc "c" (picture: ^WebPPicture) ---
Release the memory allocated by WebPPictureAlloc() or WebPPictureImport*(). Note that this function does _not_ free the memory used by the 'picture' object itself. Besides memory (which is reclaimed) all other fields of 'picture' are preserved.
WebPPictureHasTransparency ¶
WebPPictureHasTransparency :: proc "c" (picture: ^WebPPicture) -> i32 ---
Scan the picture 'picture' for the presence of non fully opaque alpha values. Returns true in such case. Otherwise returns false (indicating that the alpha plane can be ignored altogether e.g.).
WebPPictureImportBGR ¶
WebPPictureImportBGR :: proc "c" (picture: ^WebPPicture, bgr: ^u8, bgr_stride: i32) -> i32 ---
Variants of the above, but taking BGR(A|X) input.
WebPPictureImportBGRA ¶
WebPPictureImportBGRA :: proc "c" (picture: ^WebPPicture, bgra: ^u8, bgra_stride: i32) -> i32 ---
WebPPictureImportBGRX ¶
WebPPictureImportBGRX :: proc "c" (picture: ^WebPPicture, bgrx: ^u8, bgrx_stride: i32) -> i32 ---
WebPPictureImportRGB ¶
WebPPictureImportRGB :: proc "c" (picture: ^WebPPicture, rgb: ^u8, rgb_stride: i32) -> i32 ---
Colorspace conversion function to import RGB samples. Previous buffer will be free'd, if any. rgb buffer should have a size of at least height rgb_stride. Returns false in case of memory error.
WebPPictureImportRGBA ¶
WebPPictureImportRGBA :: proc "c" (picture: ^WebPPicture, rgba: ^u8, rgba_stride: i32) -> i32 ---
Same, but for RGBA buffer.
WebPPictureImportRGBX ¶
WebPPictureImportRGBX :: proc "c" (picture: ^WebPPicture, rgbx: ^u8, rgbx_stride: i32) -> i32 ---
Same, but for RGBA buffer. Imports the RGB direct from the 32-bit format input buffer ignoring the alpha channel. Avoids needing to copy the data to a temporary 24-bit RGB buffer to import the RGB only.
WebPPictureInit ¶
WebPPictureInit :: proc "contextless" (picture: ^WebPPicture) -> i32 {…}
Should always be called, to initialize the structure. Returns false in case of version mismatch. WebPPictureInit() must have succeeded before using the 'picture' object. Note that, by default, use_argb is false and colorspace is WEBP_YUV420.
WebPPictureInitInternal ¶
WebPPictureInitInternal :: proc "c" (^WebPPicture, i32) -> i32 ---
Internal, version-checked, entry point
WebPPictureIsView ¶
WebPPictureIsView :: proc "c" (picture: ^WebPPicture) -> i32 ---
Returns true if the 'picture' is actually a view and therefore does not own the memory for pixels.
WebPPictureRescale ¶
WebPPictureRescale :: proc "c" (picture: ^WebPPicture, width: i32, height: i32) -> i32 ---
Rescale a picture to new dimension width x height. If either 'width' or 'height' (but not both) is 0 the corresponding dimension will be calculated preserving the aspect ratio. No gamma correction is applied. Returns false in case of error (invalid parameter or insufficient memory).
WebPPictureSharpARGBToYUVA ¶
WebPPictureSharpARGBToYUVA :: proc "c" (picture: ^WebPPicture) -> i32 ---
Performs 'sharp' RGBA->YUVA420 downsampling and colorspace conversion Downsampling is handled with extra care in case of color clipping. This method is roughly 2x slower than WebPPictureARGBToYUVA() but produces better and sharper YUV representation. Returns false in case of error.
WebPPictureSmartARGBToYUVA ¶
WebPPictureSmartARGBToYUVA :: proc "c" (picture: ^WebPPicture) -> i32 ---
kept for backward compatibility:
WebPPictureView ¶
WebPPictureView :: proc "c" ( src: ^WebPPicture, left: i32, top: i32, width: i32, height: i32, dst: ^WebPPicture, ) -> i32 ---
Extracts a view from 'src' picture into 'dst'. The rectangle for the view is defined by the top-left corner pixel coordinates (left, top) as well as its width and height. This rectangle must be fully be comprised inside the 'src' source picture. If the source picture uses the YUV420 colorspace, the top and left coordinates will be snapped to even values. Picture 'src' must out-live 'dst' picture. Self-extraction of view is allowed ('src' equal to 'dst') as a mean of fast-cropping (but note that doing so, the original dimension will be lost). Picture 'dst' need not be initialized with WebPPictureInit() if it is different from 'src', since its content will be overwritten. Returns false in case of invalid parameters.
WebPPictureYUVAToARGB ¶
WebPPictureYUVAToARGB :: proc "c" (picture: ^WebPPicture) -> i32 ---
Converts picture->yuv to picture->argb and sets picture->use_argb to true. The input format must be YUV_420 or YUV_420A. The conversion from YUV420 to ARGB incurs a small loss too. Note that the use of this colorspace is discouraged if one has access to the raw ARGB samples, since using YUV420 is comparatively lossy. Returns false in case of error.
WebPPlaneDistortion ¶
WebPPlaneDistortion :: proc "c" ( src: ^u8, src_stride: uint, ref: ^u8, ref_stride: uint, width: i32, height: i32, x_step: uint, type: i32, distortion: ^f32, result: ^f32, ) -> i32 ---
Compute the single distortion for packed planes of samples. 'src' will be compared to 'ref', and the raw distortion stored into '*distortion'. The refined metric (log(MSE), log(1 - ssim),...' will be stored in '*result'. 'x_step' is the horizontal stride (in bytes) between samples. 'src/ref_stride' is the byte distance between rows. Returns false in case of error (bad parameter, memory allocation error, ...).
WebPValidateConfig ¶
WebPValidateConfig :: proc "c" (config: ^WebPConfig) -> i32 ---
Returns true if 'config' is non-NULL and all configuration parameters are within their valid ranges.
webp_converter_deinit ¶
webp_converter_deinit :: proc(self: ^webp_converter) {…}
webp_converter_frame_cnt ¶
webp_converter_frame_cnt :: proc "contextless" (self: ^webp_converter) -> int {…}
Gets the number of frames in the WebP image
Inputs:
self: Pointer to the WebP converter
Returns:
The number of frames (1 for static images), or -1 if no image is loaded
webp_converter_height ¶
webp_converter_height :: proc "contextless" (self: ^webp_converter) -> u32 {…}
Gets the height of the loaded WebP image
Inputs:
self: Pointer to the WebP converter
Returns:
The height of the image in pixels, or 0 if no image is loaded
webp_converter_load ¶
webp_converter_load :: proc(self: ^webp_converter, data: []u8, out_fmt: image.color_fmt, allocator := context.allocator) -> ([]u8, WebP_Error) {…}
Loads a WebP image from byte data
Supports both static and animated WebP images
Inputs:
self: Pointer to the WebP converter
data: The WebP image data as bytes
out_fmt: The desired output color format
allocator: The allocator to use (default: context.allocator)
Returns:
The decoded image data as bytes (all frames for animated images)
An error if loading failed
webp_converter_load_file ¶
webp_converter_load_file :: proc(self: ^webp_converter, file_path: string, out_fmt: image.color_fmt, allocator := context.allocator) -> ([]u8, WebP_Error) {…}
Loads a WebP image from a file
Inputs:
self: Pointer to the WebP converter
file_path: Path to the WebP image file
out_fmt: The desired output color format
allocator: The allocator to use (default: context.allocator)
Returns:
The decoded image data as bytes
An error if loading failed
An error if loading failed
webp_converter_size ¶
webp_converter_size :: proc "contextless" (self: ^webp_converter) -> u32 {…}
Gets the size in bytes of the loaded WebP image
For animated WebP, returns the total size of all frames
Inputs:
self: Pointer to the WebP converter
Returns:
The size of the image data in bytes, or 0 if no image is loaded
webp_converter_width ¶
webp_converter_width :: proc "contextless" (self: ^webp_converter) -> u32 {…}
Gets the width of the loaded WebP image
Inputs:
self: Pointer to the WebP converter
Returns:
The width of the image in pixels, or 0 if no image is loaded
Procedure Groups
This section is empty.
Source Files
- common.odin
- decode.odin
- demux.odin
- encode.odin
- format_constants.odin
- mux.odin
- mux_types.odin
- types.odin
- webp_converter.odin
Generation Information
Generated with odin version dev-v0.0.1 (vendor "odin") Linux_amd64 @ 2026-01-30 10:23:19.117759522 +0000 UTC