encode.h: remove '* const' from function parameters

makes the public interface consistent and more readable

Change-Id: Ib93614e901e0af44bb64782357cfd9e724e050be
This commit is contained in:
James Zern 2012-07-17 15:01:30 -07:00
parent 9838e5d5ff
commit 31426ebaec
4 changed files with 61 additions and 66 deletions

View File

@ -19,7 +19,7 @@ extern "C" {
// WebPConfig // WebPConfig
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int WebPConfigInitInternal(WebPConfig* const config, int WebPConfigInitInternal(WebPConfig* config,
WebPPreset preset, float quality, int version) { WebPPreset preset, float quality, int version) {
if (version != WEBP_ENCODER_ABI_VERSION) { if (version != WEBP_ENCODER_ABI_VERSION) {
return 0; // caller/system version mismatch! return 0; // caller/system version mismatch!
@ -80,7 +80,7 @@ int WebPConfigInitInternal(WebPConfig* const config,
return WebPValidateConfig(config); return WebPValidateConfig(config);
} }
int WebPValidateConfig(const WebPConfig* const config) { int WebPValidateConfig(const WebPConfig* config) {
if (config == NULL) return 0; if (config == NULL) return 0;
if (config->quality < 0 || config->quality > 100) if (config->quality < 0 || config->quality > 100)
return 0; return 0;

View File

@ -34,7 +34,7 @@ static const union {
// WebPPicture // WebPPicture
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int WebPPictureAlloc(WebPPicture* const picture) { int WebPPictureAlloc(WebPPicture* picture) {
if (picture != NULL) { if (picture != NULL) {
const WebPEncCSP uv_csp = picture->colorspace & WEBP_CSP_UV_MASK; const WebPEncCSP uv_csp = picture->colorspace & WEBP_CSP_UV_MASK;
const int has_alpha = picture->colorspace & WEBP_CSP_ALPHA_BIT; const int has_alpha = picture->colorspace & WEBP_CSP_ALPHA_BIT;
@ -184,7 +184,7 @@ static int PictureAllocARGB(WebPPicture* const picture) {
} }
// Release memory owned by 'picture' (both YUV and ARGB buffers). // Release memory owned by 'picture' (both YUV and ARGB buffers).
void WebPPictureFree(WebPPicture* const picture) { void WebPPictureFree(WebPPicture* picture) {
if (picture != NULL) { if (picture != NULL) {
free(picture->memory_); free(picture->memory_);
free(picture->memory_argb_); free(picture->memory_argb_);
@ -230,7 +230,7 @@ static int AdjustAndCheckRectangle(const WebPPicture* const pic,
return 1; return 1;
} }
int WebPPictureCopy(const WebPPicture* const src, WebPPicture* const dst) { int WebPPictureCopy(const WebPPicture* src, WebPPicture* dst) {
if (src == NULL || dst == NULL) return 0; if (src == NULL || dst == NULL) return 0;
if (src == dst) return 1; if (src == dst) return 1;
@ -268,7 +268,7 @@ int WebPPictureCopy(const WebPPicture* const src, WebPPicture* const dst) {
return 1; return 1;
} }
int WebPPictureIsView(const WebPPicture* const picture) { int WebPPictureIsView(const WebPPicture* picture) {
if (picture == NULL) return 0; if (picture == NULL) return 0;
if (picture->use_argb_input) { if (picture->use_argb_input) {
return (picture->memory_argb_ == NULL); return (picture->memory_argb_ == NULL);
@ -276,9 +276,9 @@ int WebPPictureIsView(const WebPPicture* const picture) {
return (picture->memory_ == NULL); return (picture->memory_ == NULL);
} }
int WebPPictureView(const WebPPicture* const src, int WebPPictureView(const WebPPicture* src,
int left, int top, int width, int height, int left, int top, int width, int height,
WebPPicture* const dst) { WebPPicture* dst) {
if (src == NULL || dst == NULL) return 0; if (src == NULL || dst == NULL) return 0;
// verify rectangle position. // verify rectangle position.
@ -313,7 +313,7 @@ int WebPPictureView(const WebPPicture* const src,
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Picture cropping // Picture cropping
int WebPPictureCrop(WebPPicture* const pic, int WebPPictureCrop(WebPPicture* pic,
int left, int top, int width, int height) { int left, int top, int width, int height) {
WebPPicture tmp; WebPPicture tmp;
@ -391,7 +391,7 @@ static void RescalePlane(const uint8_t* src,
} }
} }
int WebPPictureRescale(WebPPicture* const pic, int width, int height) { int WebPPictureRescale(WebPPicture* pic, int width, int height) {
WebPPicture tmp; WebPPicture tmp;
int prev_width, prev_height; int prev_width, prev_height;
int32_t* work; int32_t* work;
@ -471,14 +471,14 @@ int WebPPictureRescale(WebPPicture* const pic, int width, int height) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// WebPMemoryWriter: Write-to-memory // WebPMemoryWriter: Write-to-memory
void WebPMemoryWriterInit(WebPMemoryWriter* const writer) { void WebPMemoryWriterInit(WebPMemoryWriter* writer) {
writer->mem = NULL; writer->mem = NULL;
writer->size = 0; writer->size = 0;
writer->max_size = 0; writer->max_size = 0;
} }
int WebPMemoryWrite(const uint8_t* data, size_t data_size, int WebPMemoryWrite(const uint8_t* data, size_t data_size,
const WebPPicture* const picture) { const WebPPicture* picture) {
WebPMemoryWriter* const w = (WebPMemoryWriter*)picture->custom_ptr; WebPMemoryWriter* const w = (WebPMemoryWriter*)picture->custom_ptr;
size_t next_size; size_t next_size;
if (w == NULL) { if (w == NULL) {
@ -526,7 +526,7 @@ static int CheckNonOpaque(const uint8_t* alpha, int width, int height,
} }
// Checking for the presence of non-opaque alpha. // Checking for the presence of non-opaque alpha.
int WebPPictureHasTransparency(const WebPPicture* const picture) { int WebPPictureHasTransparency(const WebPPicture* picture) {
if (picture == NULL) return 0; if (picture == NULL) return 0;
if (!picture->use_argb_input) { if (!picture->use_argb_input) {
return CheckNonOpaque(picture->a, picture->width, picture->height, return CheckNonOpaque(picture->a, picture->width, picture->height,
@ -750,40 +750,40 @@ static int Import(WebPPicture* const picture,
#undef SUM1 #undef SUM1
#undef RGB_TO_UV #undef RGB_TO_UV
int WebPPictureImportRGB(WebPPicture* const picture, int WebPPictureImportRGB(WebPPicture* picture,
const uint8_t* const rgb, int rgb_stride) { const uint8_t* rgb, int rgb_stride) {
return Import(picture, rgb, rgb_stride, 3, 0, 0); return Import(picture, rgb, rgb_stride, 3, 0, 0);
} }
int WebPPictureImportBGR(WebPPicture* const picture, int WebPPictureImportBGR(WebPPicture* picture,
const uint8_t* const rgb, int rgb_stride) { const uint8_t* rgb, int rgb_stride) {
return Import(picture, rgb, rgb_stride, 3, 1, 0); return Import(picture, rgb, rgb_stride, 3, 1, 0);
} }
int WebPPictureImportRGBA(WebPPicture* const picture, int WebPPictureImportRGBA(WebPPicture* picture,
const uint8_t* const rgba, int rgba_stride) { const uint8_t* rgba, int rgba_stride) {
return Import(picture, rgba, rgba_stride, 4, 0, 1); return Import(picture, rgba, rgba_stride, 4, 0, 1);
} }
int WebPPictureImportBGRA(WebPPicture* const picture, int WebPPictureImportBGRA(WebPPicture* picture,
const uint8_t* const rgba, int rgba_stride) { const uint8_t* rgba, int rgba_stride) {
return Import(picture, rgba, rgba_stride, 4, 1, 1); return Import(picture, rgba, rgba_stride, 4, 1, 1);
} }
int WebPPictureImportRGBX(WebPPicture* const picture, int WebPPictureImportRGBX(WebPPicture* picture,
const uint8_t* const rgba, int rgba_stride) { const uint8_t* rgba, int rgba_stride) {
return Import(picture, rgba, rgba_stride, 4, 0, 0); return Import(picture, rgba, rgba_stride, 4, 0, 0);
} }
int WebPPictureImportBGRX(WebPPicture* const picture, int WebPPictureImportBGRX(WebPPicture* picture,
const uint8_t* const rgba, int rgba_stride) { const uint8_t* rgba, int rgba_stride) {
return Import(picture, rgba, rgba_stride, 4, 1, 0); return Import(picture, rgba, rgba_stride, 4, 1, 0);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Automatic YUV <-> ARGB conversions. // Automatic YUV <-> ARGB conversions.
int WebPPictureYUVAToARGB(WebPPicture* const picture) { int WebPPictureYUVAToARGB(WebPPicture* picture) {
if (picture == NULL) return 0; if (picture == NULL) return 0;
if (picture->memory_ == NULL || picture->y == NULL || if (picture->memory_ == NULL || picture->y == NULL ||
picture->u == NULL || picture->v == NULL) { picture->u == NULL || picture->v == NULL) {
@ -842,7 +842,7 @@ int WebPPictureYUVAToARGB(WebPPicture* const picture) {
return 1; return 1;
} }
int WebPPictureARGBToYUVA(WebPPicture* const picture, WebPEncCSP colorspace) { int WebPPictureARGBToYUVA(WebPPicture* picture, WebPEncCSP colorspace) {
if (picture == NULL) return 0; if (picture == NULL) return 0;
if (picture->argb == NULL) { if (picture->argb == NULL) {
return WebPEncodingSetError(picture, VP8_ENC_ERROR_NULL_PARAMETER); return WebPEncodingSetError(picture, VP8_ENC_ERROR_NULL_PARAMETER);
@ -896,7 +896,7 @@ static WEBP_INLINE void flatten(uint8_t* ptr, int v, int stride, int size) {
} }
} }
void WebPCleanupTransparentArea(WebPPicture* const pic) { void WebPCleanupTransparentArea(WebPPicture* pic) {
int x, y, w, h; int x, y, w, h;
const uint8_t* a_ptr; const uint8_t* a_ptr;
int values[3] = { 0 }; int values[3] = { 0 };
@ -942,8 +942,7 @@ void WebPCleanupTransparentArea(WebPPicture* const pic) {
// Max value returned in case of exact similarity. // Max value returned in case of exact similarity.
static const double kMinDistortion_dB = 99.; static const double kMinDistortion_dB = 99.;
int WebPPictureDistortion(const WebPPicture* const pic1, int WebPPictureDistortion(const WebPPicture* pic1, const WebPPicture* pic2,
const WebPPicture* const pic2,
int type, float result[5]) { int type, float result[5]) {
int c; int c;
DistoStats stats[5]; DistoStats stats[5];

View File

@ -46,7 +46,7 @@ static int DummyWriter(const uint8_t* data, size_t data_size,
return 1; return 1;
} }
int WebPPictureInitInternal(WebPPicture* const picture, int version) { int WebPPictureInitInternal(WebPPicture* picture, int version) {
if (version != WEBP_ENCODER_ABI_VERSION) { if (version != WEBP_ENCODER_ABI_VERSION) {
return 0; // caller/system version mismatch! return 0; // caller/system version mismatch!
} }
@ -328,7 +328,7 @@ int WebPReportProgress(const WebPPicture* const pic,
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int WebPEncode(const WebPConfig* const config, WebPPicture* const pic) { int WebPEncode(const WebPConfig* config, WebPPicture* pic) {
int ok; int ok;
if (pic == NULL) if (pic == NULL)

View File

@ -118,13 +118,12 @@ typedef enum {
} WebPPreset; } WebPPreset;
// Internal, version-checked, entry point // Internal, version-checked, entry point
WEBP_EXTERN(int) WebPConfigInitInternal( WEBP_EXTERN(int) WebPConfigInitInternal(WebPConfig*, WebPPreset, float, int);
WebPConfig* const, WebPPreset, float, int);
// Should always be called, to initialize a fresh WebPConfig structure before // Should always be called, to initialize a fresh WebPConfig structure before
// modification. Returns false in case of version mismatch. WebPConfigInit() // modification. Returns false in case of version mismatch. WebPConfigInit()
// must have succeeded before using the 'config' object. // must have succeeded before using the 'config' object.
static WEBP_INLINE int WebPConfigInit(WebPConfig* const config) { static WEBP_INLINE int WebPConfigInit(WebPConfig* config) {
return WebPConfigInitInternal(config, WEBP_PRESET_DEFAULT, 75.f, return WebPConfigInitInternal(config, WEBP_PRESET_DEFAULT, 75.f,
WEBP_ENCODER_ABI_VERSION); WEBP_ENCODER_ABI_VERSION);
} }
@ -133,7 +132,7 @@ static WEBP_INLINE int WebPConfigInit(WebPConfig* const config) {
// set of parameters (referred to by 'preset') and a given quality factor. // set of parameters (referred to by 'preset') and a given quality factor.
// This function can be called as a replacement to WebPConfigInit(). Will // This function can be called as a replacement to WebPConfigInit(). Will
// return false in case of error. // return false in case of error.
static WEBP_INLINE int WebPConfigPreset(WebPConfig* const config, static WEBP_INLINE int WebPConfigPreset(WebPConfig* config,
WebPPreset preset, float quality) { WebPPreset preset, float quality) {
return WebPConfigInitInternal(config, preset, quality, return WebPConfigInitInternal(config, preset, quality,
WEBP_ENCODER_ABI_VERSION); WEBP_ENCODER_ABI_VERSION);
@ -141,7 +140,7 @@ static WEBP_INLINE int WebPConfigPreset(WebPConfig* const config,
// Returns true if 'config' is non-NULL and all configuration parameters are // Returns true if 'config' is non-NULL and all configuration parameters are
// within their valid ranges. // within their valid ranges.
WEBP_EXTERN(int) WebPValidateConfig(const WebPConfig* const config); WEBP_EXTERN(int) WebPValidateConfig(const WebPConfig* config);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Input / Output // Input / Output
@ -172,7 +171,7 @@ typedef struct {
// data/data_size is the segment of data to write, and 'picture' is for // 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). // reference (and so one can make use of picture->custom_ptr).
typedef int (*WebPWriterFunction)(const uint8_t* data, size_t data_size, typedef int (*WebPWriterFunction)(const uint8_t* data, size_t data_size,
const WebPPicture* const picture); const WebPPicture* picture);
// WebPMemoryWrite: a special WebPWriterFunction that writes to memory using // WebPMemoryWrite: a special WebPWriterFunction that writes to memory using
// the following WebPMemoryWriter object (to be set as a custom_ptr). // the following WebPMemoryWriter object (to be set as a custom_ptr).
@ -183,17 +182,17 @@ typedef struct {
} WebPMemoryWriter; } WebPMemoryWriter;
// The following must be called first before any use. // The following must be called first before any use.
WEBP_EXTERN(void) WebPMemoryWriterInit(WebPMemoryWriter* const writer); WEBP_EXTERN(void) WebPMemoryWriterInit(WebPMemoryWriter* writer);
// The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon // The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon
// completion, writer.mem and writer.size will hold the coded data. // completion, writer.mem and writer.size will hold the coded data.
WEBP_EXTERN(int) WebPMemoryWrite(const uint8_t* data, size_t data_size, WEBP_EXTERN(int) WebPMemoryWrite(const uint8_t* data, size_t data_size,
const WebPPicture* const picture); const WebPPicture* picture);
// Progress hook, called from time to time to report progress. It can return // 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 // false to request an abort of the encoding process, or true otherwise if
// everything is OK. // everything is OK.
typedef int (*WebPProgressHook)(int percent, const WebPPicture* const picture); typedef int (*WebPProgressHook)(int percent, const WebPPicture* picture);
typedef enum { typedef enum {
// chroma sampling // chroma sampling
@ -273,12 +272,12 @@ struct WebPPicture {
}; };
// Internal, version-checked, entry point // Internal, version-checked, entry point
WEBP_EXTERN(int) WebPPictureInitInternal(WebPPicture* const, int); WEBP_EXTERN(int) WebPPictureInitInternal(WebPPicture*, int);
// Should always be called, to initialize the structure. Returns false in case // Should always be called, to initialize the structure. Returns false in case
// of version mismatch. WebPPictureInit() must have succeeded before using the // of version mismatch. WebPPictureInit() must have succeeded before using the
// 'picture' object. // 'picture' object.
static WEBP_INLINE int WebPPictureInit(WebPPicture* const picture) { static WEBP_INLINE int WebPPictureInit(WebPPicture* picture) {
return WebPPictureInitInternal(picture, WEBP_ENCODER_ABI_VERSION); return WebPPictureInitInternal(picture, WEBP_ENCODER_ABI_VERSION);
} }
@ -289,25 +288,24 @@ static WEBP_INLINE int WebPPictureInit(WebPPicture* const picture) {
// Allocate y/u/v buffers as per colorspace/width/height specification. // Allocate y/u/v buffers as per colorspace/width/height specification.
// Note! This function will free the previous buffer if needed. // Note! This function will free the previous buffer if needed.
// Returns false in case of memory error. // Returns false in case of memory error.
WEBP_EXTERN(int) WebPPictureAlloc(WebPPicture* const picture); WEBP_EXTERN(int) WebPPictureAlloc(WebPPicture* picture);
// Release the memory allocated by WebPPictureAlloc() or WebPPictureImport*(). // Release the memory allocated by WebPPictureAlloc() or WebPPictureImport*().
// Note that this function does _not_ free the memory used by the 'picture' // Note that this function does _not_ free the memory used by the 'picture'
// object itself. // object itself.
WEBP_EXTERN(void) WebPPictureFree(WebPPicture* const picture); WEBP_EXTERN(void) WebPPictureFree(WebPPicture* picture);
// Copy the pixels of *src into *dst, using WebPPictureAlloc. Upon return, // Copy the pixels of *src into *dst, using WebPPictureAlloc. Upon return,
// *dst will fully own the copied pixels (this is not a view). // *dst will fully own the copied pixels (this is not a view).
// Returns false in case of memory allocation error. // Returns false in case of memory allocation error.
WEBP_EXTERN(int) WebPPictureCopy(const WebPPicture* const src, WEBP_EXTERN(int) WebPPictureCopy(const WebPPicture* src, WebPPicture* dst);
WebPPicture* const dst);
// Compute PSNR or SSIM distortion between two pictures. // Compute PSNR or SSIM distortion between two pictures.
// Result is in dB, stores in result[] in the Y/U/V/Alpha/All order. // Result is in dB, stores in result[] in the Y/U/V/Alpha/All order.
// Returns false in case of error (pic1 and pic2 don't have same dimension, ...) // Returns false in case of error (pic1 and pic2 don't have same dimension, ...)
// Warning: this function is rather CPU-intensive. // Warning: this function is rather CPU-intensive.
WEBP_EXTERN(int) WebPPictureDistortion( WEBP_EXTERN(int) WebPPictureDistortion(
const WebPPicture* const pic1, const WebPPicture* const pic2, const WebPPicture* pic1, const WebPPicture* pic2,
int metric_type, // 0 = PSNR, 1 = SSIM int metric_type, // 0 = PSNR, 1 = SSIM
float result[5]); float result[5]);
@ -319,7 +317,7 @@ WEBP_EXTERN(int) WebPPictureDistortion(
// must be fully be comprised inside the 'src' source picture. If the source // 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 // picture uses the YUV420 colorspace, the top and left coordinates will be
// snapped to even values. // snapped to even values.
WEBP_EXTERN(int) WebPPictureCrop(WebPPicture* const picture, WEBP_EXTERN(int) WebPPictureCrop(WebPPicture* picture,
int left, int top, int width, int height); int left, int top, int width, int height);
// Extracts a view from 'src' picture into 'dst'. The rectangle for the view // Extracts a view from 'src' picture into 'dst'. The rectangle for the view
@ -331,49 +329,48 @@ WEBP_EXTERN(int) WebPPictureCrop(WebPPicture* const picture,
// ('src' equal to 'dst') as a mean of fast-cropping (but note that doing so, // ('src' equal to 'dst') as a mean of fast-cropping (but note that doing so,
// the original dimension will be lost). // the original dimension will be lost).
// Returns false in case of memory allocation error or invalid parameters. // Returns false in case of memory allocation error or invalid parameters.
WEBP_EXTERN(int) WebPPictureView(const WebPPicture* const src, WEBP_EXTERN(int) WebPPictureView(const WebPPicture* src,
int left, int top, int width, int height, int left, int top, int width, int height,
WebPPicture* const dst); WebPPicture* dst);
// Returns true if the 'picture' is actually a view and therefore does // Returns true if the 'picture' is actually a view and therefore does
// not own the memory for pixels. // not own the memory for pixels.
WEBP_EXTERN(int) WebPPictureIsView(const WebPPicture* const picture); WEBP_EXTERN(int) WebPPictureIsView(const WebPPicture* picture);
// Rescale a picture to new dimension width x height. // Rescale a picture to new dimension width x height.
// Now gamma correction is applied. // Now gamma correction is applied.
// Returns false in case of error (invalid parameter or insufficient memory). // Returns false in case of error (invalid parameter or insufficient memory).
WEBP_EXTERN(int) WebPPictureRescale(WebPPicture* const pic, WEBP_EXTERN(int) WebPPictureRescale(WebPPicture* pic, int width, int height);
int width, int height);
// Colorspace conversion function to import RGB samples. // Colorspace conversion function to import RGB samples.
// Previous buffer will be free'd, if any. // Previous buffer will be free'd, if any.
// *rgb buffer should have a size of at least height * rgb_stride. // *rgb buffer should have a size of at least height * rgb_stride.
// Returns false in case of memory error. // Returns false in case of memory error.
WEBP_EXTERN(int) WebPPictureImportRGB( WEBP_EXTERN(int) WebPPictureImportRGB(
WebPPicture* const picture, const uint8_t* const rgb, int rgb_stride); WebPPicture* picture, const uint8_t* rgb, int rgb_stride);
// Same, but for RGBA buffer. // Same, but for RGBA buffer.
WEBP_EXTERN(int) WebPPictureImportRGBA( WEBP_EXTERN(int) WebPPictureImportRGBA(
WebPPicture* const picture, const uint8_t* const rgba, int rgba_stride); WebPPicture* picture, const uint8_t* rgba, int rgba_stride);
// Same, but for RGBA buffer. Imports the RGB direct from the 32-bit format // 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 // input buffer ignoring the alpha channel. Avoids needing to copy the data
// to a temporary 24-bit RGB buffer to import the RGB only. // to a temporary 24-bit RGB buffer to import the RGB only.
WEBP_EXTERN(int) WebPPictureImportRGBX( WEBP_EXTERN(int) WebPPictureImportRGBX(
WebPPicture* const picture, const uint8_t* const rgbx, int rgbx_stride); WebPPicture* picture, const uint8_t* rgbx, int rgbx_stride);
// Variants of the above, but taking BGR(A|X) input. // Variants of the above, but taking BGR(A|X) input.
WEBP_EXTERN(int) WebPPictureImportBGR( WEBP_EXTERN(int) WebPPictureImportBGR(
WebPPicture* const picture, const uint8_t* const bgr, int bgr_stride); WebPPicture* picture, const uint8_t* bgr, int bgr_stride);
WEBP_EXTERN(int) WebPPictureImportBGRA( WEBP_EXTERN(int) WebPPictureImportBGRA(
WebPPicture* const picture, const uint8_t* const bgra, int bgra_stride); WebPPicture* picture, const uint8_t* bgra, int bgra_stride);
WEBP_EXTERN(int) WebPPictureImportBGRX( WEBP_EXTERN(int) WebPPictureImportBGRX(
WebPPicture* const picture, const uint8_t* const bgrx, int bgrx_stride); WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride);
// Converts picture->argb data to the YUVA format specified by 'colorspace'. // Converts picture->argb data to the YUVA format specified by 'colorspace'.
// Upon return, picture->use_argb_input is set to false. The presence of // Upon return, picture->use_argb_input is set to false. The presence of
// real non-opaque transparent values is detected, and 'colorspace' will be // real non-opaque transparent values is detected, and 'colorspace' will be
// adjusted accordingly. Note that this method is lossy. // adjusted accordingly. Note that this method is lossy.
// Returns false in case of error. // Returns false in case of error.
WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* const picture, WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* picture,
WebPEncCSP colorspace); WebPEncCSP colorspace);
// Converts picture->yuv to picture->argb and sets picture->use_argb_input // Converts picture->yuv to picture->argb and sets picture->use_argb_input
@ -382,17 +379,17 @@ WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* const picture,
// raw ARGB samples, since using YUV420 is comparatively lossy. Also, the // raw ARGB samples, since using YUV420 is comparatively lossy. Also, the
// conversion from YUV420 to ARGB incurs a small loss too. // conversion from YUV420 to ARGB incurs a small loss too.
// Returns false in case of error. // Returns false in case of error.
WEBP_EXTERN(int) WebPPictureYUVAToARGB(WebPPicture* const picture); WEBP_EXTERN(int) WebPPictureYUVAToARGB(WebPPicture* picture);
// Helper function: given a width x height plane of YUV(A) samples // Helper function: given a width x height plane of YUV(A) samples
// (with stride 'stride'), clean-up the YUV samples under fully transparent // (with stride 'stride'), clean-up the YUV samples under fully transparent
// area, to help compressibility (no guarantee, though). // area, to help compressibility (no guarantee, though).
WEBP_EXTERN(void) WebPCleanupTransparentArea(WebPPicture* const picture); WEBP_EXTERN(void) WebPCleanupTransparentArea(WebPPicture* picture);
// Scan the picture 'picture' for the presence of non fully opaque alpha values. // Scan the picture 'picture' for the presence of non fully opaque alpha values.
// Returns true in such case. Otherwise returns false (indicating that the // Returns true in such case. Otherwise returns false (indicating that the
// alpha plane can be ignored altogether e.g.). // alpha plane can be ignored altogether e.g.).
WEBP_EXTERN(int) WebPPictureHasTransparency(const WebPPicture* const picture); WEBP_EXTERN(int) WebPPictureHasTransparency(const WebPPicture* picture);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Main call // Main call
@ -407,8 +404,7 @@ WEBP_EXTERN(int) WebPPictureHasTransparency(const WebPPicture* const picture);
// use the former for lossy encoding, and the latter for lossless encoding // use the former for lossy encoding, and the latter for lossless encoding
// (when config.lossless is true). Automatic conversion from one format to // (when config.lossless is true). Automatic conversion from one format to
// another is provided but they both incur some loss. // another is provided but they both incur some loss.
WEBP_EXTERN(int) WebPEncode(const WebPConfig* const config, WEBP_EXTERN(int) WebPEncode(const WebPConfig* config, WebPPicture* picture);
WebPPicture* const picture);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------