explicitly mark library functions as extern

Add WEBP_EXTERN(type) macro which should make Windows DLL builds simpler
by allowing the signature to be changed.

Change-Id: I0cfa45dff779985680b1a38ddff30973a0d26639
This commit is contained in:
James Zern 2011-07-12 19:43:15 -07:00
parent 19db59f80f
commit cd7c5292e9
4 changed files with 122 additions and 101 deletions

View File

@ -22,35 +22,35 @@ extern "C" {
// Return the decoder's version number, packed in hexadecimal using 8bits for // Return the decoder's version number, packed in hexadecimal using 8bits for
// each of major/minor/revision. E.g: v2.5.7 is 0x020507. // each of major/minor/revision. E.g: v2.5.7 is 0x020507.
int WebPGetDecoderVersion(void); WEBP_EXTERN(int) WebPGetDecoderVersion(void);
// Retrieve basic header information: width, height. // Retrieve basic header information: width, height.
// This function will also validate the header and return 0 in // This function will also validate the header and return 0 in
// case of formatting error. // case of formatting error.
// Pointers *width/*height can be passed NULL if deemed irrelevant. // Pointers *width/*height can be passed NULL if deemed irrelevant.
int WebPGetInfo(const uint8_t* data, uint32_t data_size, WEBP_EXTERN(int) WebPGetInfo(const uint8_t* data, uint32_t data_size,
int* width, int* height); int* width, int* height);
// Decodes WEBP images pointed to by *data and returns RGB samples, along // Decodes WEBP images pointed to by *data and returns RGB samples, along
// with the dimensions in *width and *height. // with the dimensions in *width and *height.
// The returned pointer should be deleted calling free(). // The returned pointer should be deleted calling free().
// Returns NULL in case of error. // Returns NULL in case of error.
uint8_t* WebPDecodeRGB(const uint8_t* data, uint32_t data_size, WEBP_EXTERN(uint8_t*) WebPDecodeRGB(const uint8_t* data, uint32_t data_size,
int* width, int* height); int* width, int* height);
// Same as WebPDecodeRGB, but returning RGBA data. // Same as WebPDecodeRGB, but returning RGBA data.
uint8_t* WebPDecodeRGBA(const uint8_t* data, uint32_t data_size, WEBP_EXTERN(uint8_t*) WebPDecodeRGBA(const uint8_t* data, uint32_t data_size,
int* width, int* height); int* width, int* height);
// Same as WebPDecodeRGBA, but returning ARGB data. // Same as WebPDecodeRGBA, but returning ARGB data.
uint8_t* WebPDecodeARGB(const uint8_t* data, uint32_t data_size, WEBP_EXTERN(uint8_t*) WebPDecodeARGB(const uint8_t* data, uint32_t data_size,
int* width, int* height); int* width, int* height);
// This variant decode to BGR instead of RGB. // This variant decode to BGR instead of RGB.
uint8_t* WebPDecodeBGR(const uint8_t* data, uint32_t data_size, WEBP_EXTERN(uint8_t*) WebPDecodeBGR(const uint8_t* data, uint32_t data_size,
int* width, int* height); int* width, int* height);
// This variant decodes to BGRA instead of RGBA. // This variant decodes to BGRA instead of RGBA.
uint8_t* WebPDecodeBGRA(const uint8_t* data, uint32_t data_size, WEBP_EXTERN(uint8_t*) WebPDecodeBGRA(const uint8_t* data, uint32_t data_size,
int* width, int* height); int* width, int* height);
// Decode WEBP images stored in *data in Y'UV format(*). The pointer returned is // Decode WEBP images stored in *data in Y'UV format(*). The pointer returned is
@ -62,8 +62,9 @@ uint8_t* WebPDecodeBGRA(const uint8_t* data, uint32_t data_size,
// have a common stride returned as '*uv_stride'. // have a common stride returned as '*uv_stride'.
// Return NULL in case of error. // Return NULL in case of error.
// (*) Also named Y'CbCr. See: http://en.wikipedia.org/wiki/YCbCr // (*) Also named Y'CbCr. See: http://en.wikipedia.org/wiki/YCbCr
uint8_t* WebPDecodeYUV(const uint8_t* data, uint32_t data_size, WEBP_EXTERN(uint8_t*) WebPDecodeYUV(const uint8_t* data, uint32_t data_size,
int* width, int* height, uint8_t** u, uint8_t** v, int* width, int* height,
uint8_t** u, uint8_t** v,
int* stride, int* uv_stride); int* stride, int* uv_stride);
// These three functions are variants of the above ones, that decode the image // These three functions are variants of the above ones, that decode the image
@ -74,19 +75,19 @@ uint8_t* WebPDecodeYUV(const uint8_t* data, uint32_t data_size,
// The parameter 'output_stride' specifies the distance (in bytes) // The parameter 'output_stride' specifies the distance (in bytes)
// between scanlines. Hence, output_buffer_size is expected to be at least // between scanlines. Hence, output_buffer_size is expected to be at least
// output_stride x picture-height. // output_stride x picture-height.
uint8_t* WebPDecodeRGBInto(const uint8_t* data, uint32_t data_size, WEBP_EXTERN(uint8_t*) WebPDecodeRGBInto(
uint8_t* output_buffer, int output_buffer_size, const uint8_t* data, uint32_t data_size,
int output_stride); uint8_t* output_buffer, int output_buffer_size, int output_stride);
uint8_t* WebPDecodeRGBAInto(const uint8_t* data, uint32_t data_size, WEBP_EXTERN(uint8_t*) WebPDecodeRGBAInto(
uint8_t* output_buffer, int output_buffer_size, const uint8_t* data, uint32_t data_size,
int output_stride); uint8_t* output_buffer, int output_buffer_size, int output_stride);
// BGR variants // BGR variants
uint8_t* WebPDecodeBGRInto(const uint8_t* data, uint32_t data_size, WEBP_EXTERN(uint8_t*) WebPDecodeBGRInto(
uint8_t* output_buffer, int output_buffer_size, const uint8_t* data, uint32_t data_size,
int output_stride); uint8_t* output_buffer, int output_buffer_size, int output_stride);
uint8_t* WebPDecodeBGRAInto(const uint8_t* data, uint32_t data_size, WEBP_EXTERN(uint8_t*) WebPDecodeBGRAInto(
uint8_t* output_buffer, int output_buffer_size, const uint8_t* data, uint32_t data_size,
int output_stride); uint8_t* output_buffer, int output_buffer_size, int output_stride);
// WebPDecodeYUVInto() is a variant of WebPDecodeYUV() that operates directly // WebPDecodeYUVInto() is a variant of WebPDecodeYUV() that operates directly
// into pre-allocated luma/chroma plane buffers. This function requires the // into pre-allocated luma/chroma plane buffers. This function requires the
@ -95,7 +96,8 @@ uint8_t* WebPDecodeBGRAInto(const uint8_t* data, uint32_t data_size,
// 'u_size' and 'v_size' respectively. // 'u_size' and 'v_size' respectively.
// Pointer to the luma plane ('*luma') is returned or NULL if an error occurred // 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). // during decoding (or because some buffers were found to be too small).
uint8_t* WebPDecodeYUVInto(const uint8_t* data, uint32_t data_size, WEBP_EXTERN(uint8_t*) WebPDecodeYUVInto(
const uint8_t* data, uint32_t data_size,
uint8_t* luma, int luma_size, int luma_stride, uint8_t* luma, int luma_size, int luma_stride,
uint8_t* u, int u_size, int u_stride, uint8_t* u, int u_size, int u_stride,
uint8_t* v, int v_size, int v_stride); uint8_t* v, int v_size, int v_stride);
@ -143,7 +145,7 @@ typedef struct {
} WebPDecBuffer; } WebPDecBuffer;
// Internal, version-checked, entry point // Internal, version-checked, entry point
int WebPInitDecBufferInternal(WebPDecBuffer* const, int); WEBP_EXTERN(int) WebPInitDecBufferInternal(WebPDecBuffer* const, int);
// Initialize the structure as empty. Must be called before any other use. // Initialize the structure as empty. Must be called before any other use.
// Returns false in case of version mismatch // Returns false in case of version mismatch
@ -153,7 +155,7 @@ static inline int WebPInitDecBuffer(WebPDecBuffer* const buffer) {
// Free any memory associated with the buffer. Must always be called last. // Free any memory associated with the buffer. Must always be called last.
// Note: doesn't free the 'buffer' structure itself. // Note: doesn't free the 'buffer' structure itself.
void WebPFreeDecBuffer(WebPDecBuffer* const buffer); WEBP_EXTERN(void) WebPFreeDecBuffer(WebPDecBuffer* const buffer);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Enumeration of the status codes // Enumeration of the status codes
@ -200,19 +202,20 @@ typedef struct WebPIDecoder WebPIDecoder;
// is kept, which means that the lifespan of 'output_buffer' must be larger than // is kept, which means that the lifespan of 'output_buffer' must be larger than
// that of the returned WebPIDecoder object. // that of the returned WebPIDecoder object.
// Returns NULL if the allocation failed. // Returns NULL if the allocation failed.
WebPIDecoder* WebPINewDecoder(WebPDecBuffer* const output_buffer); WEBP_EXTERN(WebPIDecoder*) WebPINewDecoder(WebPDecBuffer* const output_buffer);
// Creates a WebPIDecoder object. Returns NULL in case of failure. // Creates a WebPIDecoder object. Returns NULL in case of failure.
// TODO(skal): DEPRECATED. Prefer using WebPINewDecoder(). // TODO(skal): DEPRECATED. Prefer using WebPINewDecoder().
WebPIDecoder* WebPINew(WEBP_CSP_MODE mode); WEBP_EXTERN(WebPIDecoder*) WebPINew(WEBP_CSP_MODE mode);
// This function allocates and initializes an incremental-decoder object, which // This function allocates and initializes an incremental-decoder object, which
// will output the r/g/b(/a) samples specified by 'mode' into a preallocated // will output the r/g/b(/a) samples specified by 'mode' into a preallocated
// buffer 'output_buffer'. The size of this buffer is at least // buffer 'output_buffer'. The size of this buffer is at least
// 'output_buffer_size' and the stride (distance in bytes between two scanlines) // 'output_buffer_size' and the stride (distance in bytes between two scanlines)
// is specified by 'output_stride'. Returns NULL if the allocation failed. // is specified by 'output_stride'. Returns NULL if the allocation failed.
WebPIDecoder* WebPINewRGB(WEBP_CSP_MODE mode, uint8_t* output_buffer, WEBP_EXTERN(WebPIDecoder*) WebPINewRGB(
int output_buffer_size, int output_stride); WEBP_CSP_MODE mode,
uint8_t* output_buffer, int output_buffer_size, int output_stride);
// This function allocates and initializes an incremental-decoder object, which // This function allocates and initializes an incremental-decoder object, which
// will output the raw luma/chroma samples into a preallocated planes. The luma // will output the raw luma/chroma samples into a preallocated planes. The luma
@ -221,39 +224,42 @@ WebPIDecoder* WebPINewRGB(WEBP_CSP_MODE mode, uint8_t* output_buffer,
// 'u_size' and 'u_stride' parameters, and the chroma-v plane by 'v', 'v_size' // 'u_size' and 'u_stride' parameters, and the chroma-v plane by 'v', 'v_size'
// and 'v_size'. // and 'v_size'.
// Returns NULL if the allocation failed. // Returns NULL if the allocation failed.
WebPIDecoder* WebPINewYUV(uint8_t* luma, int luma_size, int luma_stride, WEBP_EXTERN(WebPIDecoder*) WebPINewYUV(
uint8_t* luma, int luma_size, int luma_stride,
uint8_t* u, int u_size, int u_stride, uint8_t* u, int u_size, int u_stride,
uint8_t* v, int v_size, int v_stride); uint8_t* v, int v_size, int v_stride);
// Deletes the WebpBuffer object and associated memory. Must always be called // Deletes the WebpBuffer object and associated memory. Must always be called
// if WebPINew, WebPINewRGB or WebPINewYUV succeeded. // if WebPINew, WebPINewRGB or WebPINewYUV succeeded.
void WebPIDelete(WebPIDecoder* const idec); WEBP_EXTERN(void) WebPIDelete(WebPIDecoder* const idec);
// Copies and decodes the next available data. Returns VP8_STATUS_OK when // Copies and decodes the next available data. Returns VP8_STATUS_OK when
// the image is successfully decoded. Returns VP8_STATUS_SUSPENDED when more // the image is successfully decoded. Returns VP8_STATUS_SUSPENDED when more
// data is expected. Returns error in other cases. // data is expected. Returns error in other cases.
VP8StatusCode WebPIAppend(WebPIDecoder* const idec, const uint8_t* data, WEBP_EXTERN(VP8StatusCode) WebPIAppend(
uint32_t data_size); WebPIDecoder* const idec, const uint8_t* data, uint32_t data_size);
// A variant of the above function to be used when data buffer contains // 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 // partial data from the beginning. In this case data buffer is not copied
// to the internal memory. // to the internal memory.
// Note that the value of the 'data' pointer can change between calls to // 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. // WebPIUpdate, for instance when the data buffer is resized to fit larger data.
VP8StatusCode WebPIUpdate(WebPIDecoder* const idec, const uint8_t* data, WEBP_EXTERN(VP8StatusCode) WebPIUpdate(
uint32_t data_size); WebPIDecoder* const idec, const uint8_t* data, uint32_t data_size);
// Returns the r/g/b/(a) image decoded so far. Returns NULL if output params // Returns the r/g/b/(a) image decoded so far. Returns NULL if output params
// are not initialized yet. The r/g/b/(a) output type corresponds to the mode // are not initialized yet. The r/g/b/(a) output type corresponds to the mode
// specified in WebPINew()/WebPINewRGB(). *last_y is the index of last decoded // specified in WebPINew()/WebPINewRGB(). *last_y is the index of last decoded
// row in raster scan order. Some pointers (*last_y, *width etc.) can be NULL if // row in raster scan order. Some pointers (*last_y, *width etc.) can be NULL if
// corresponding information is not needed. // corresponding information is not needed.
uint8_t* WebPIDecGetRGB(const WebPIDecoder* const idec, int* last_y, WEBP_EXTERN(uint8_t*) WebPIDecGetRGB(
const WebPIDecoder* const idec, int* last_y,
int* width, int* height, int* stride); int* width, int* height, int* stride);
// Same as above function to get YUV image. Returns pointer to the luma plane // Same as above function to get YUV image. Returns pointer to the luma plane
// or NULL in case of error. // or NULL in case of error.
uint8_t* WebPIDecGetYUV(const WebPIDecoder* const idec, int* last_y, WEBP_EXTERN(uint8_t*) WebPIDecGetYUV(
const WebPIDecoder* const idec, int* last_y,
uint8_t** u, uint8_t** v, uint8_t** u, uint8_t** v,
int* width, int* height, int* stride, int* uv_stride); int* width, int* height, int* stride, int* uv_stride);
@ -263,7 +269,8 @@ uint8_t* WebPIDecGetYUV(const WebPIDecoder* const idec, int* last_y,
// Returns NULL in case the incremental decoder object is in an invalid state. // Returns NULL in case the incremental decoder object is in an invalid state.
// Otherwise returns the pointer to the internal representation. This structure // Otherwise returns the pointer to the internal representation. This structure
// is read-only, tied to WebPIDecoder's lifespan and should not be modified. // is read-only, tied to WebPIDecoder's lifespan and should not be modified.
const WebPDecBuffer* WebPIDecodedArea(const WebPIDecoder* const idec, WEBP_EXTERN(const WebPDecBuffer*) WebPIDecodedArea(
const WebPIDecoder* const idec,
int* const left, int* const top, int* const left, int* const top,
int* const width, int* const height); int* const width, int* const height);
@ -313,8 +320,8 @@ typedef struct {
} WebPBitstreamFeatures; } WebPBitstreamFeatures;
// Internal, version-checked, entry point // Internal, version-checked, entry point
extern VP8StatusCode WebPGetFeaturesInternal(const uint8_t*, uint32_t, WEBP_EXTERN(VP8StatusCode) WebPGetFeaturesInternal(
WebPBitstreamFeatures* const, int); const uint8_t*, uint32_t, WebPBitstreamFeatures* const, int);
// Retrieve features from the bitstream. The *features structure is filled // Retrieve features from the bitstream. The *features structure is filled
// with informations gathered from the bitstream. // with informations gathered from the bitstream.
@ -349,7 +356,7 @@ typedef struct {
} WebPDecoderConfig; } WebPDecoderConfig;
// Internal, version-checked, entry point // Internal, version-checked, entry point
extern int WebPInitDecoderConfigInternal(WebPDecoderConfig* const, int); WEBP_EXTERN(int) WebPInitDecoderConfigInternal(WebPDecoderConfig* const, int);
// Initialize the configuration as empty. This function must always be // Initialize the configuration as empty. This function must always be
// called first, unless WebPGetFeatures() is to be called. // called first, unless WebPGetFeatures() is to be called.
@ -367,13 +374,13 @@ static inline int WebPInitDecoderConfig(WebPDecoderConfig* const config) {
// The return WebPIDecoder object must always be deleted calling WebPIDelete(). // The return WebPIDecoder object must always be deleted calling WebPIDelete().
// Returns NULL in case of error (and config->status will then reflect // Returns NULL in case of error (and config->status will then reflect
// the error condition). // the error condition).
WebPIDecoder* WebPIDecode(const uint8_t* data, uint32_t data_size, WEBP_EXTERN(WebPIDecoder*) WebPIDecode(const uint8_t* data, uint32_t data_size,
WebPDecoderConfig* const config); WebPDecoderConfig* const config);
// Non-incremental version. This version decodes the full data at once, taking // Non-incremental version. This version decodes the full data at once, taking
// 'config' into account. Return decoding status (VP8_STATUS_OK if decoding // 'config' into account. Return decoding status (VP8_STATUS_OK if decoding
// was successful). // was successful).
VP8StatusCode WebPDecode(const uint8_t* data, uint32_t data_size, WEBP_EXTERN(VP8StatusCode) WebPDecode(const uint8_t* data, uint32_t data_size,
WebPDecoderConfig* const config); WebPDecoderConfig* const config);
#if defined(__cplusplus) || defined(c_plusplus) #if defined(__cplusplus) || defined(c_plusplus)

View File

@ -101,12 +101,12 @@ struct VP8Io {
}; };
// Internal, version-checked, entry point // Internal, version-checked, entry point
int VP8InitIoInternal(VP8Io* const, int); WEBP_EXTERN(int) VP8InitIoInternal(VP8Io* const, int);
// Set the custom IO function pointers and user-data. The setter for IO hooks // Set the custom IO function pointers and user-data. The setter for IO hooks
// should be called before initiating incremental decoding. Returns true if // should be called before initiating incremental decoding. Returns true if
// WebPIdecoder object is successfully modified, false otherwise. // WebPIdecoder object is successfully modified, false otherwise.
int WebPISetIOHooks(WebPIDecoder* const idec, WEBP_EXTERN(int) WebPISetIOHooks(WebPIDecoder* const idec,
VP8IoPutHook put, VP8IoPutHook put,
VP8IoSetupHook setup, VP8IoSetupHook setup,
VP8IoTeardownHook teardown, VP8IoTeardownHook teardown,
@ -116,7 +116,7 @@ int WebPISetIOHooks(WebPIDecoder* const idec,
typedef struct VP8Decoder VP8Decoder; typedef struct VP8Decoder VP8Decoder;
// Create a new decoder object. // Create a new decoder object.
VP8Decoder* VP8New(void); WEBP_EXTERN(VP8Decoder*) VP8New(void);
// Must be called to make sure 'io' is initialized properly. // Must be called to make sure 'io' is initialized properly.
// Returns false in case of version mismatch. Upon such failure, no other // Returns false in case of version mismatch. Upon such failure, no other
@ -126,24 +126,24 @@ static inline int VP8InitIo(VP8Io* const io) {
} }
// Start decoding a new picture. Returns true if ok. // Start decoding a new picture. Returns true if ok.
int VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io); WEBP_EXTERN(int) VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io);
// Decode a picture. Will call VP8GetHeaders() if it wasn't done already. // Decode a picture. Will call VP8GetHeaders() if it wasn't done already.
// Returns false in case of error. // Returns false in case of error.
int VP8Decode(VP8Decoder* const dec, VP8Io* const io); WEBP_EXTERN(int) VP8Decode(VP8Decoder* const dec, VP8Io* const io);
// Return current status of the decoder: // Return current status of the decoder:
VP8StatusCode VP8Status(VP8Decoder* const dec); WEBP_EXTERN(VP8StatusCode) VP8Status(VP8Decoder* const dec);
// return readable string corresponding to the last status. // return readable string corresponding to the last status.
const char* VP8StatusMessage(VP8Decoder* const dec); WEBP_EXTERN(const char*) VP8StatusMessage(VP8Decoder* const dec);
// Resets the decoder in its initial state, reclaiming memory. // Resets the decoder in its initial state, reclaiming memory.
// Not a mandatory call between calls to VP8Decode(). // Not a mandatory call between calls to VP8Decode().
void VP8Clear(VP8Decoder* const dec); WEBP_EXTERN(void) VP8Clear(VP8Decoder* const dec);
// Destroy the decoder object. // Destroy the decoder object.
void VP8Delete(VP8Decoder* const dec); WEBP_EXTERN(void) VP8Delete(VP8Decoder* const dec);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -24,7 +24,7 @@ extern "C" {
// Return the encoder's version number, packed in hexadecimal using 8bits for // Return the encoder's version number, packed in hexadecimal using 8bits for
// each of major/minor/revision. E.g: v2.5.7 is 0x020507. // each of major/minor/revision. E.g: v2.5.7 is 0x020507.
int WebPGetEncoderVersion(void); WEBP_EXTERN(int) WebPGetEncoderVersion(void);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// One-stop-shop call! No questions asked: // One-stop-shop call! No questions asked:
@ -32,13 +32,17 @@ int WebPGetEncoderVersion(void);
// Returns the size of the compressed data (pointed to by *output), or 0 if // 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 // an error occurred. The compressed data must be released by the caller
// using the call 'free(*output)'. // using the call 'free(*output)'.
size_t WebPEncodeRGB(const uint8_t* rgb, int width, int height, int stride, WEBP_EXTERN(size_t) WebPEncodeRGB(const uint8_t* rgb,
int width, int height, int stride,
float quality_factor, uint8_t** output); float quality_factor, uint8_t** output);
size_t WebPEncodeBGR(const uint8_t* bgr, int width, int height, int stride, WEBP_EXTERN(size_t) WebPEncodeBGR(const uint8_t* bgr,
int width, int height, int stride,
float quality_factor, uint8_t** output); float quality_factor, uint8_t** output);
size_t WebPEncodeRGBA(const uint8_t* rgba, int width, int height, int stride, WEBP_EXTERN(size_t) WebPEncodeRGBA(const uint8_t* rgba,
int width, int height, int stride,
float quality_factor, uint8_t** output); float quality_factor, uint8_t** output);
size_t WebPEncodeBGRA(const uint8_t* bgra, int width, int height, int stride, WEBP_EXTERN(size_t) WebPEncodeBGRA(const uint8_t* bgra,
int width, int height, int stride,
float quality_factor, uint8_t** output); float quality_factor, uint8_t** output);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -80,7 +84,8 @@ typedef enum {
} WebPPreset; } WebPPreset;
// Internal, version-checked, entry point // Internal, version-checked, entry point
int WebPConfigInitInternal(WebPConfig* const, WebPPreset, float, int); WEBP_EXTERN(int) WebPConfigInitInternal(
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 0 in case of version mismatch. WebPConfigInit() must // modification. Returns 0 in case of version mismatch. WebPConfigInit() must
@ -101,7 +106,7 @@ static inline int WebPConfigPreset(WebPConfig* const config,
} }
// Returns 1 if all parameters are in valid range and the configuration is OK. // Returns 1 if all parameters are in valid range and the configuration is OK.
int WebPValidateConfig(const WebPConfig* const config); WEBP_EXTERN(int) WebPValidateConfig(const WebPConfig* const config);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Input / Output // Input / Output
@ -193,7 +198,7 @@ struct WebPPicture {
}; };
// Internal, version-checked, entry point // Internal, version-checked, entry point
int WebPPictureInitInternal(WebPPicture* const, int); WEBP_EXTERN(int) WebPPictureInitInternal(WebPPicture* const, int);
// Should always be called, to initialize the structure. Returns 0 in case of // Should always be called, to initialize the structure. Returns 0 in case of
// version mismatch. WebPPictureInit() must have succeeded before using the // version mismatch. WebPPictureInit() must have succeeded before using the
@ -209,42 +214,44 @@ static 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 0 in case of memory error. // Returns 0 in case of memory error.
int WebPPictureAlloc(WebPPicture* const picture); WEBP_EXTERN(int) WebPPictureAlloc(WebPPicture* const picture);
// Release memory allocated by WebPPictureAlloc() or WebPPictureImport*() // Release memory allocated by WebPPictureAlloc() or WebPPictureImport*()
// Note that this function does _not_ free the memory pointed to by 'picture'. // Note that this function does _not_ free the memory pointed to by 'picture'.
void WebPPictureFree(WebPPicture* const picture); WEBP_EXTERN(void) WebPPictureFree(WebPPicture* const picture);
// Copy the pixels of *src into *dst, using WebPPictureAlloc. // Copy the pixels of *src into *dst, using WebPPictureAlloc.
// Returns 0 in case of memory allocation error. // Returns 0 in case of memory allocation error.
int WebPPictureCopy(const WebPPicture* const src, WebPPicture* const dst); WEBP_EXTERN(int) WebPPictureCopy(const WebPPicture* const src,
WebPPicture* const dst);
// self-crops a picture to the rectangle defined by top/left/width/height. // self-crops a picture to the rectangle defined by top/left/width/height.
// Returns 0 in case of memory allocation error, or if the rectangle is // Returns 0 in case of memory allocation error, or if the rectangle is
// outside of the source picture. // outside of the source picture.
int WebPPictureCrop(WebPPicture* const picture, WEBP_EXTERN(int) WebPPictureCrop(WebPPicture* const picture,
int left, int top, int width, int height); int left, int top, int width, int height);
// 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).
int WebPPictureRescale(WebPPicture* const pic, int width, int height); WEBP_EXTERN(int) WebPPictureRescale(WebPPicture* const pic,
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 0 in case of memory error. // Returns 0 in case of memory error.
int WebPPictureImportRGB(WebPPicture* const picture, WEBP_EXTERN(int) WebPPictureImportRGB(
const uint8_t* const rgb, int rgb_stride); WebPPicture* const picture, const uint8_t* const rgb, int rgb_stride);
// Same, but for RGBA buffer // Same, but for RGBA buffer
int WebPPictureImportRGBA(WebPPicture* const picture, WEBP_EXTERN(int) WebPPictureImportRGBA(
const uint8_t* const rgba, int rgba_stride); WebPPicture* const picture, const uint8_t* const rgba, int rgba_stride);
// Variant of the above, but taking BGR(A) input: // Variant of the above, but taking BGR(A) input:
int WebPPictureImportBGR(WebPPicture* const picture, WEBP_EXTERN(int) WebPPictureImportBGR(
const uint8_t* const bgr, int bgr_stride); WebPPicture* const picture, const uint8_t* const bgr, int bgr_stride);
int WebPPictureImportBGRA(WebPPicture* const picture, WEBP_EXTERN(int) WebPPictureImportBGRA(
const uint8_t* const bgra, int bgra_stride); WebPPicture* const picture, const uint8_t* const bgra, int bgra_stride);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Main call // Main call
@ -254,7 +261,8 @@ int WebPPictureImportBGRA(WebPPicture* const picture,
// must be a valid one. // must be a valid one.
// Returns false in case of error, true otherwise. // Returns false in case of error, true otherwise.
// In case of error, picture->error_code is updated accordingly. // In case of error, picture->error_code is updated accordingly.
int WebPEncode(const WebPConfig* const config, WebPPicture* const picture); WEBP_EXTERN(int) WebPEncode(
const WebPConfig* const config, WebPPicture* const picture);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -29,4 +29,10 @@ typedef long long int int64_t;
#define inline __forceinline #define inline __forceinline
#endif /* _MSC_VER */ #endif /* _MSC_VER */
#ifndef WEBP_EXTERN
// This explicitly marks library functions and allows for changing the
// signature for e.g., Windows DLL builds.
#define WEBP_EXTERN(type) extern type
#endif /* WEBP_EXTERN */
#endif /* WEBP_WEBP_TYPES_H_ */ #endif /* WEBP_WEBP_TYPES_H_ */