Path: blob/master/thirdparty/libwebp/src/webp/encode.h
20907 views
// Copyright 2011 Google Inc. All Rights Reserved.1//2// Use of this source code is governed by a BSD-style license3// that can be found in the COPYING file in the root of the source4// tree. An additional intellectual property rights grant can be found5// in the file PATENTS. All contributing project authors may6// be found in the AUTHORS file in the root of the source tree.7// -----------------------------------------------------------------------------8//9// WebP encoder: main interface10//11// Author: Skal ([email protected])1213#ifndef WEBP_WEBP_ENCODE_H_14#define WEBP_WEBP_ENCODE_H_1516#include <stddef.h>1718#include "./types.h"1920#ifdef __cplusplus21extern "C" {22#endif2324#define WEBP_ENCODER_ABI_VERSION 0x0210 // MAJOR(8b) + MINOR(8b)2526// Note: forward declaring enumerations is not allowed in (strict) C and C++,27// the types are left here for reference.28// typedef enum WebPImageHint WebPImageHint;29// typedef enum WebPEncCSP WebPEncCSP;30// typedef enum WebPPreset WebPPreset;31// typedef enum WebPEncodingError WebPEncodingError;32typedef struct WebPConfig WebPConfig;33typedef struct WebPPicture WebPPicture; // main structure for I/O34typedef struct WebPAuxStats WebPAuxStats;35typedef struct WebPMemoryWriter WebPMemoryWriter;3637// Return the encoder's version number, packed in hexadecimal using 8bits for38// each of major/minor/revision. E.g: v2.5.7 is 0x020507.39WEBP_EXTERN int WebPGetEncoderVersion(void);4041//------------------------------------------------------------------------------42// One-stop-shop call! No questions asked:4344// Returns the size of the compressed data (pointed to by *output), or 0 if45// an error occurred. The compressed data must be released by the caller46// using the call 'WebPFree(*output)'.47// These functions compress using the lossy format, and the quality_factor48// can go from 0 (smaller output, lower quality) to 100 (best quality,49// larger output).50WEBP_EXTERN size_t WebPEncodeRGB(const uint8_t* rgb,51int width, int height, int stride,52float quality_factor, uint8_t** output);53WEBP_EXTERN size_t WebPEncodeBGR(const uint8_t* bgr,54int width, int height, int stride,55float quality_factor, uint8_t** output);56WEBP_EXTERN size_t WebPEncodeRGBA(const uint8_t* rgba,57int width, int height, int stride,58float quality_factor, uint8_t** output);59WEBP_EXTERN size_t WebPEncodeBGRA(const uint8_t* bgra,60int width, int height, int stride,61float quality_factor, uint8_t** output);6263// These functions are the equivalent of the above, but compressing in a64// lossless manner. Files are usually larger than lossy format, but will65// not suffer any compression loss.66// Note these functions, like the lossy versions, use the library's default67// settings. For lossless this means 'exact' is disabled. RGB values in68// transparent areas will be modified to improve compression. To avoid this,69// use WebPEncode() and set WebPConfig::exact to 1.70WEBP_EXTERN size_t WebPEncodeLosslessRGB(const uint8_t* rgb,71int width, int height, int stride,72uint8_t** output);73WEBP_EXTERN size_t WebPEncodeLosslessBGR(const uint8_t* bgr,74int width, int height, int stride,75uint8_t** output);76WEBP_EXTERN size_t WebPEncodeLosslessRGBA(const uint8_t* rgba,77int width, int height, int stride,78uint8_t** output);79WEBP_EXTERN size_t WebPEncodeLosslessBGRA(const uint8_t* bgra,80int width, int height, int stride,81uint8_t** output);8283//------------------------------------------------------------------------------84// Coding parameters8586// Image characteristics hint for the underlying encoder.87typedef enum WebPImageHint {88WEBP_HINT_DEFAULT = 0, // default preset.89WEBP_HINT_PICTURE, // digital picture, like portrait, inner shot90WEBP_HINT_PHOTO, // outdoor photograph, with natural lighting91WEBP_HINT_GRAPH, // Discrete tone image (graph, map-tile etc).92WEBP_HINT_LAST93} WebPImageHint;9495// Compression parameters.96struct WebPConfig {97int lossless; // Lossless encoding (0=lossy(default), 1=lossless).98float quality; // between 0 and 100. For lossy, 0 gives the smallest99// size and 100 the largest. For lossless, this100// parameter is the amount of effort put into the101// compression: 0 is the fastest but gives larger102// files compared to the slowest, but best, 100.103int method; // quality/speed trade-off (0=fast, 6=slower-better)104105WebPImageHint image_hint; // Hint for image type (lossless only for now).106107int target_size; // if non-zero, set the desired target size in bytes.108// Takes precedence over the 'compression' parameter.109float target_PSNR; // if non-zero, specifies the minimal distortion to110// try to achieve. Takes precedence over target_size.111int segments; // maximum number of segments to use, in [1..4]112int sns_strength; // Spatial Noise Shaping. 0=off, 100=maximum.113int filter_strength; // range: [0 = off .. 100 = strongest]114int filter_sharpness; // range: [0 = off .. 7 = least sharp]115int filter_type; // filtering type: 0 = simple, 1 = strong (only used116// if filter_strength > 0 or autofilter > 0)117int autofilter; // Auto adjust filter's strength [0 = off, 1 = on]118int alpha_compression; // Algorithm for encoding the alpha plane (0 = none,119// 1 = compressed with WebP lossless). Default is 1.120int alpha_filtering; // Predictive filtering method for alpha plane.121// 0: none, 1: fast, 2: best. Default if 1.122int alpha_quality; // Between 0 (smallest size) and 100 (lossless).123// Default is 100.124int pass; // number of entropy-analysis passes (in [1..10]).125126int show_compressed; // if true, export the compressed picture back.127// In-loop filtering is not applied.128int preprocessing; // preprocessing filter:129// 0=none, 1=segment-smooth, 2=pseudo-random dithering130int partitions; // log2(number of token partitions) in [0..3]. Default131// is set to 0 for easier progressive decoding.132int partition_limit; // quality degradation allowed to fit the 512k limit133// on prediction modes coding (0: no degradation,134// 100: maximum possible degradation).135int emulate_jpeg_size; // If true, compression parameters will be remapped136// to better match the expected output size from137// JPEG compression. Generally, the output size will138// be similar but the degradation will be lower.139int thread_level; // If non-zero, try and use multi-threaded encoding.140int low_memory; // If set, reduce memory usage (but increase CPU use).141142int near_lossless; // Near lossless encoding [0 = max loss .. 100 = off143// (default)].144int exact; // if non-zero, preserve the exact RGB values under145// transparent area. Otherwise, discard this invisible146// RGB information for better compression. The default147// value is 0.148149int use_delta_palette; // reserved150int use_sharp_yuv; // if needed, use sharp (and slow) RGB->YUV conversion151152int qmin; // minimum permissible quality factor153int qmax; // maximum permissible quality factor154};155156// Enumerate some predefined settings for WebPConfig, depending on the type157// of source picture. These presets are used when calling WebPConfigPreset().158typedef enum WebPPreset {159WEBP_PRESET_DEFAULT = 0, // default preset.160WEBP_PRESET_PICTURE, // digital picture, like portrait, inner shot161WEBP_PRESET_PHOTO, // outdoor photograph, with natural lighting162WEBP_PRESET_DRAWING, // hand or line drawing, with high-contrast details163WEBP_PRESET_ICON, // small-sized colorful images164WEBP_PRESET_TEXT // text-like165} WebPPreset;166167// Internal, version-checked, entry point168WEBP_NODISCARD WEBP_EXTERN int WebPConfigInitInternal(WebPConfig*, WebPPreset,169float, int);170171// Should always be called, to initialize a fresh WebPConfig structure before172// modification. Returns false in case of version mismatch. WebPConfigInit()173// must have succeeded before using the 'config' object.174// Note that the default values are lossless=0 and quality=75.175WEBP_NODISCARD static WEBP_INLINE int WebPConfigInit(WebPConfig* config) {176return WebPConfigInitInternal(config, WEBP_PRESET_DEFAULT, 75.f,177WEBP_ENCODER_ABI_VERSION);178}179180// This function will initialize the configuration according to a predefined181// set of parameters (referred to by 'preset') and a given quality factor.182// This function can be called as a replacement to WebPConfigInit(). Will183// return false in case of error.184WEBP_NODISCARD static WEBP_INLINE int WebPConfigPreset(WebPConfig* config,185WebPPreset preset,186float quality) {187return WebPConfigInitInternal(config, preset, quality,188WEBP_ENCODER_ABI_VERSION);189}190191// Activate the lossless compression mode with the desired efficiency level192// between 0 (fastest, lowest compression) and 9 (slower, best compression).193// A good default level is '6', providing a fair tradeoff between compression194// speed and final compressed size.195// This function will overwrite several fields from config: 'method', 'quality'196// and 'lossless'. Returns false in case of parameter error.197WEBP_NODISCARD WEBP_EXTERN int WebPConfigLosslessPreset(WebPConfig* config,198int level);199200// Returns true if 'config' is non-NULL and all configuration parameters are201// within their valid ranges.202WEBP_NODISCARD WEBP_EXTERN int WebPValidateConfig(const WebPConfig* config);203204//------------------------------------------------------------------------------205// Input / Output206// Structure for storing auxiliary statistics.207208struct WebPAuxStats {209int coded_size; // final size210211float PSNR[5]; // peak-signal-to-noise ratio for Y/U/V/All/Alpha212int block_count[3]; // number of intra4/intra16/skipped macroblocks213int header_bytes[2]; // approximate number of bytes spent for header214// and mode-partition #0215int residual_bytes[3][4]; // approximate number of bytes spent for216// DC/AC/uv coefficients for each (0..3) segments.217int segment_size[4]; // number of macroblocks in each segments218int segment_quant[4]; // quantizer values for each segments219int segment_level[4]; // filtering strength for each segments [0..63]220221int alpha_data_size; // size of the transparency data222int layer_data_size; // size of the enhancement layer data223224// lossless encoder statistics225uint32_t lossless_features; // bit0:predictor bit1:cross-color transform226// bit2:subtract-green bit3:color indexing227int histogram_bits; // number of precision bits of histogram228int transform_bits; // precision bits for predictor transform229int cache_bits; // number of bits for color cache lookup230int palette_size; // number of color in palette, if used231int lossless_size; // final lossless size232int lossless_hdr_size; // lossless header (transform, huffman etc) size233int lossless_data_size; // lossless image data size234int cross_color_transform_bits; // precision bits for cross-color transform235236uint32_t pad[1]; // padding for later use237};238239// Signature for output function. Should return true if writing was successful.240// data/data_size is the segment of data to write, and 'picture' is for241// reference (and so one can make use of picture->custom_ptr).242typedef int (*WebPWriterFunction)(const uint8_t* data, size_t data_size,243const WebPPicture* picture);244245// WebPMemoryWrite: a special WebPWriterFunction that writes to memory using246// the following WebPMemoryWriter object (to be set as a custom_ptr).247struct WebPMemoryWriter {248uint8_t* mem; // final buffer (of size 'max_size', larger than 'size').249size_t size; // final size250size_t max_size; // total capacity251uint32_t pad[1]; // padding for later use252};253254// The following must be called first before any use.255WEBP_EXTERN void WebPMemoryWriterInit(WebPMemoryWriter* writer);256257// The following must be called to deallocate writer->mem memory. The 'writer'258// object itself is not deallocated.259WEBP_EXTERN void WebPMemoryWriterClear(WebPMemoryWriter* writer);260// The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon261// completion, writer.mem and writer.size will hold the coded data.262// writer.mem must be freed by calling WebPMemoryWriterClear.263WEBP_NODISCARD WEBP_EXTERN int WebPMemoryWrite(264const uint8_t* data, size_t data_size, const WebPPicture* picture);265266// Progress hook, called from time to time to report progress. It can return267// false to request an abort of the encoding process, or true otherwise if268// everything is OK.269typedef int (*WebPProgressHook)(int percent, const WebPPicture* picture);270271// Color spaces.272typedef enum WebPEncCSP {273// chroma sampling274WEBP_YUV420 = 0, // 4:2:0275WEBP_YUV420A = 4, // alpha channel variant276WEBP_CSP_UV_MASK = 3, // bit-mask to get the UV sampling factors277WEBP_CSP_ALPHA_BIT = 4 // bit that is set if alpha is present278} WebPEncCSP;279280// Encoding error conditions.281typedef enum WebPEncodingError {282VP8_ENC_OK = 0,283VP8_ENC_ERROR_OUT_OF_MEMORY, // memory error allocating objects284VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY, // memory error while flushing bits285VP8_ENC_ERROR_NULL_PARAMETER, // a pointer parameter is NULL286VP8_ENC_ERROR_INVALID_CONFIGURATION, // configuration is invalid287VP8_ENC_ERROR_BAD_DIMENSION, // picture has invalid width/height288VP8_ENC_ERROR_PARTITION0_OVERFLOW, // partition is bigger than 512k289VP8_ENC_ERROR_PARTITION_OVERFLOW, // partition is bigger than 16M290VP8_ENC_ERROR_BAD_WRITE, // error while flushing bytes291VP8_ENC_ERROR_FILE_TOO_BIG, // file is bigger than 4G292VP8_ENC_ERROR_USER_ABORT, // abort request by user293VP8_ENC_ERROR_LAST // list terminator. always last.294} WebPEncodingError;295296// maximum width/height allowed (inclusive), in pixels297#define WEBP_MAX_DIMENSION 16383298299// Main exchange structure (input samples, output bytes, statistics)300//301// Once WebPPictureInit() has been called, it's ok to make all the INPUT fields302// (use_argb, y/u/v, argb, ...) point to user-owned data, even if303// WebPPictureAlloc() has been called. Depending on the value use_argb,304// it's guaranteed that either *argb or *y/*u/*v content will be kept untouched.305struct WebPPicture {306// INPUT307//////////////308// Main flag for encoder selecting between ARGB or YUV input.309// It is recommended to use ARGB input (*argb, argb_stride) for lossless310// compression, and YUV input (*y, *u, *v, etc.) for lossy compression311// since these are the respective native colorspace for these formats.312int use_argb;313314// YUV input (mostly used for input to lossy compression)315WebPEncCSP colorspace; // colorspace: should be YUV420 for now (=Y'CbCr).316int width, height; // dimensions (less or equal to WEBP_MAX_DIMENSION)317uint8_t* y, *u, *v; // pointers to luma/chroma planes.318int y_stride, uv_stride; // luma/chroma strides.319uint8_t* a; // pointer to the alpha plane320int a_stride; // stride of the alpha plane321uint32_t pad1[2]; // padding for later use322323// ARGB input (mostly used for input to lossless compression)324uint32_t* argb; // Pointer to argb (32 bit) plane.325int argb_stride; // This is stride in pixels units, not bytes.326uint32_t pad2[3]; // padding for later use327328// OUTPUT329///////////////330// Byte-emission hook, to store compressed bytes as they are ready.331WebPWriterFunction writer; // can be NULL332void* custom_ptr; // can be used by the writer.333334// map for extra information (only for lossy compression mode)335int extra_info_type; // 1: intra type, 2: segment, 3: quant336// 4: intra-16 prediction mode,337// 5: chroma prediction mode,338// 6: bit cost, 7: distortion339uint8_t* extra_info; // if not NULL, points to an array of size340// ((width + 15) / 16) * ((height + 15) / 16) that341// will be filled with a macroblock map, depending342// on extra_info_type.343344// STATS AND REPORTS345///////////////////////////346// Pointer to side statistics (updated only if not NULL)347WebPAuxStats* stats;348349// Error code for the latest error encountered during encoding350WebPEncodingError error_code;351352// If not NULL, report progress during encoding.353WebPProgressHook progress_hook;354355void* user_data; // this field is free to be set to any value and356// used during callbacks (like progress-report e.g.).357358uint32_t pad3[3]; // padding for later use359360// Unused for now361uint8_t* pad4, *pad5;362uint32_t pad6[8]; // padding for later use363364// PRIVATE FIELDS365////////////////////366void* memory_; // row chunk of memory for yuva planes367void* memory_argb_; // and for argb too.368void* pad7[2]; // padding for later use369};370371// Internal, version-checked, entry point372WEBP_NODISCARD WEBP_EXTERN int WebPPictureInitInternal(WebPPicture*, int);373374// Should always be called, to initialize the structure. Returns false in case375// of version mismatch. WebPPictureInit() must have succeeded before using the376// 'picture' object.377// Note that, by default, use_argb is false and colorspace is WEBP_YUV420.378WEBP_NODISCARD static WEBP_INLINE int WebPPictureInit(WebPPicture* picture) {379return WebPPictureInitInternal(picture, WEBP_ENCODER_ABI_VERSION);380}381382//------------------------------------------------------------------------------383// WebPPicture utils384385// Convenience allocation / deallocation based on picture->width/height:386// Allocate y/u/v buffers as per colorspace/width/height specification.387// Note! This function will free the previous buffer if needed.388// Returns false in case of memory error.389WEBP_NODISCARD WEBP_EXTERN int WebPPictureAlloc(WebPPicture* picture);390391// Release the memory allocated by WebPPictureAlloc() or WebPPictureImport*().392// Note that this function does _not_ free the memory used by the 'picture'393// object itself.394// Besides memory (which is reclaimed) all other fields of 'picture' are395// preserved.396WEBP_EXTERN void WebPPictureFree(WebPPicture* picture);397398// Copy the pixels of *src into *dst, using WebPPictureAlloc. Upon return, *dst399// will fully own the copied pixels (this is not a view). The 'dst' picture need400// not be initialized as its content is overwritten.401// Returns false in case of memory allocation error.402WEBP_NODISCARD WEBP_EXTERN int WebPPictureCopy(const WebPPicture* src,403WebPPicture* dst);404405// Compute the single distortion for packed planes of samples.406// 'src' will be compared to 'ref', and the raw distortion stored into407// '*distortion'. The refined metric (log(MSE), log(1 - ssim),...' will be408// stored in '*result'.409// 'x_step' is the horizontal stride (in bytes) between samples.410// 'src/ref_stride' is the byte distance between rows.411// Returns false in case of error (bad parameter, memory allocation error, ...).412WEBP_NODISCARD WEBP_EXTERN int WebPPlaneDistortion(413const uint8_t* src, size_t src_stride,414const uint8_t* ref, size_t ref_stride, int width, int height, size_t x_step,415int type, // 0 = PSNR, 1 = SSIM, 2 = LSIM416float* distortion, float* result);417418// Compute PSNR, SSIM or LSIM distortion metric between two pictures. Results419// are in dB, stored in result[] in the B/G/R/A/All order. The distortion is420// always performed using ARGB samples. Hence if the input is YUV(A), the421// picture will be internally converted to ARGB (just for the measurement).422// Warning: this function is rather CPU-intensive.423WEBP_NODISCARD WEBP_EXTERN int WebPPictureDistortion(424const WebPPicture* src, const WebPPicture* ref,425int metric_type, // 0 = PSNR, 1 = SSIM, 2 = LSIM426float result[5]);427428// self-crops a picture to the rectangle defined by top/left/width/height.429// Returns false in case of memory allocation error, or if the rectangle is430// outside of the source picture.431// The rectangle for the view is defined by the top-left corner pixel432// coordinates (left, top) as well as its width and height. This rectangle433// must be fully be comprised inside the 'src' source picture. If the source434// picture uses the YUV420 colorspace, the top and left coordinates will be435// snapped to even values.436WEBP_NODISCARD WEBP_EXTERN int WebPPictureCrop(437WebPPicture* picture, int left, int top, int width, int height);438439// Extracts a view from 'src' picture into 'dst'. The rectangle for the view440// is defined by the top-left corner pixel coordinates (left, top) as well441// as its width and height. This rectangle must be fully be comprised inside442// the 'src' source picture. If the source picture uses the YUV420 colorspace,443// the top and left coordinates will be snapped to even values.444// Picture 'src' must out-live 'dst' picture. Self-extraction of view is allowed445// ('src' equal to 'dst') as a mean of fast-cropping (but note that doing so,446// the original dimension will be lost). Picture 'dst' need not be initialized447// with WebPPictureInit() if it is different from 'src', since its content will448// be overwritten.449// Returns false in case of invalid parameters.450WEBP_NODISCARD WEBP_EXTERN int WebPPictureView(451const WebPPicture* src, int left, int top, int width, int height,452WebPPicture* dst);453454// Returns true if the 'picture' is actually a view and therefore does455// not own the memory for pixels.456WEBP_EXTERN int WebPPictureIsView(const WebPPicture* picture);457458// Rescale a picture to new dimension width x height.459// If either 'width' or 'height' (but not both) is 0 the corresponding460// dimension will be calculated preserving the aspect ratio.461// No gamma correction is applied.462// Returns false in case of error (invalid parameter or insufficient memory).463WEBP_NODISCARD WEBP_EXTERN int WebPPictureRescale(WebPPicture* picture,464int width, int height);465466// Colorspace conversion function to import RGB samples.467// Previous buffer will be free'd, if any.468// *rgb buffer should have a size of at least height * rgb_stride.469// Returns false in case of memory error.470WEBP_NODISCARD WEBP_EXTERN int WebPPictureImportRGB(471WebPPicture* picture, const uint8_t* rgb, int rgb_stride);472// Same, but for RGBA buffer.473WEBP_NODISCARD WEBP_EXTERN int WebPPictureImportRGBA(474WebPPicture* picture, const uint8_t* rgba, int rgba_stride);475// Same, but for RGBA buffer. Imports the RGB direct from the 32-bit format476// input buffer ignoring the alpha channel. Avoids needing to copy the data477// to a temporary 24-bit RGB buffer to import the RGB only.478WEBP_NODISCARD WEBP_EXTERN int WebPPictureImportRGBX(479WebPPicture* picture, const uint8_t* rgbx, int rgbx_stride);480481// Variants of the above, but taking BGR(A|X) input.482WEBP_NODISCARD WEBP_EXTERN int WebPPictureImportBGR(483WebPPicture* picture, const uint8_t* bgr, int bgr_stride);484WEBP_NODISCARD WEBP_EXTERN int WebPPictureImportBGRA(485WebPPicture* picture, const uint8_t* bgra, int bgra_stride);486WEBP_NODISCARD WEBP_EXTERN int WebPPictureImportBGRX(487WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride);488489// Converts picture->argb data to the YUV420A format. The 'colorspace'490// parameter is deprecated and should be equal to WEBP_YUV420.491// Upon return, picture->use_argb is set to false. The presence of real492// non-opaque transparent values is detected, and 'colorspace' will be493// adjusted accordingly. Note that this method is lossy.494// Returns false in case of error.495WEBP_NODISCARD WEBP_EXTERN int WebPPictureARGBToYUVA(496WebPPicture* picture, WebPEncCSP /*colorspace = WEBP_YUV420*/);497498// Same as WebPPictureARGBToYUVA(), but the conversion is done using499// pseudo-random dithering with a strength 'dithering' between500// 0.0 (no dithering) and 1.0 (maximum dithering). This is useful501// for photographic picture.502WEBP_NODISCARD WEBP_EXTERN int WebPPictureARGBToYUVADithered(503WebPPicture* picture, WebPEncCSP colorspace, float dithering);504505// Performs 'sharp' RGBA->YUVA420 downsampling and colorspace conversion506// Downsampling is handled with extra care in case of color clipping. This507// method is roughly 2x slower than WebPPictureARGBToYUVA() but produces better508// and sharper YUV representation.509// Returns false in case of error.510WEBP_NODISCARD WEBP_EXTERN int WebPPictureSharpARGBToYUVA(WebPPicture* picture);511// kept for backward compatibility:512WEBP_NODISCARD WEBP_EXTERN int WebPPictureSmartARGBToYUVA(WebPPicture* picture);513514// Converts picture->yuv to picture->argb and sets picture->use_argb to true.515// The input format must be YUV_420 or YUV_420A. The conversion from YUV420 to516// ARGB incurs a small loss too.517// Note that the use of this colorspace is discouraged if one has access to the518// raw ARGB samples, since using YUV420 is comparatively lossy.519// Returns false in case of error.520WEBP_NODISCARD WEBP_EXTERN int WebPPictureYUVAToARGB(WebPPicture* picture);521522// Helper function: given a width x height plane of RGBA or YUV(A) samples523// clean-up or smoothen the YUV or RGB samples under fully transparent area,524// to help compressibility (no guarantee, though).525WEBP_EXTERN void WebPCleanupTransparentArea(WebPPicture* picture);526527// Scan the picture 'picture' for the presence of non fully opaque alpha values.528// Returns true in such case. Otherwise returns false (indicating that the529// alpha plane can be ignored altogether e.g.).530WEBP_EXTERN int WebPPictureHasTransparency(const WebPPicture* picture);531532// Remove the transparency information (if present) by blending the color with533// the background color 'background_rgb' (specified as 24bit RGB triplet).534// After this call, all alpha values are reset to 0xff.535WEBP_EXTERN void WebPBlendAlpha(WebPPicture* picture, uint32_t background_rgb);536537//------------------------------------------------------------------------------538// Main call539540// Main encoding call, after config and picture have been initialized.541// 'picture' must be less than 16384x16384 in dimension (cf WEBP_MAX_DIMENSION),542// and the 'config' object must be a valid one.543// Returns false in case of error, true otherwise.544// In case of error, picture->error_code is updated accordingly.545// 'picture' can hold the source samples in both YUV(A) or ARGB input, depending546// on the value of 'picture->use_argb'. It is highly recommended to use547// the former for lossy encoding, and the latter for lossless encoding548// (when config.lossless is true). Automatic conversion from one format to549// another is provided but they both incur some loss.550WEBP_NODISCARD WEBP_EXTERN int WebPEncode(const WebPConfig* config,551WebPPicture* picture);552553//------------------------------------------------------------------------------554555#ifdef __cplusplus556} // extern "C"557#endif558559#endif // WEBP_WEBP_ENCODE_H_560561562