mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-13 14:34:33 +02:00
Add error reporting from encoding failures.
picture->error_code can be looked up for finer error diagnose. Added readable error messages to cwebp too. Should close bug #75 (http://code.google.com/p/webp/issues/detail?id=75) Change-Id: I8889d06642d90702f698cd5c27441a058ddb3636
This commit is contained in:
@ -146,6 +146,19 @@ typedef enum {
|
||||
WEBP_CSP_ALPHA_BIT = 4 // bit that is set if alpha is present
|
||||
} WebPEncCSP;
|
||||
|
||||
// Encoding error conditions.
|
||||
typedef enum {
|
||||
VP8_ENC_OK = 0,
|
||||
VP8_ENC_ERROR_OUT_OF_MEMORY, // memory error allocating objects
|
||||
VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY, // memory error while flushing bits
|
||||
VP8_ENC_ERROR_NULL_PARAMETER, // a pointer parameter is NULL
|
||||
VP8_ENC_ERROR_INVALID_CONFIGURATION, // configuration is invalid
|
||||
VP8_ENC_ERROR_BAD_DIMENSION, // picture has invalid width/height
|
||||
VP8_ENC_ERROR_PARTITION0_OVERFLOW, // partition is too bigger than 16M
|
||||
VP8_ENC_ERROR_PARTITION_OVERFLOW, // partition is too bigger than 512k
|
||||
VP8_ENC_ERROR_BAD_WRITE, // error while flushing bytes
|
||||
} WebPEncodingError;
|
||||
|
||||
struct WebPPicture {
|
||||
// input
|
||||
WebPEncCSP colorspace; // colorspace: should be YUV420 for now (=Y'CbCr).
|
||||
@ -175,6 +188,8 @@ struct WebPPicture {
|
||||
// original samples (for non-YUV420 modes)
|
||||
uint8_t *u0, *v0;
|
||||
int uv0_stride;
|
||||
|
||||
WebPEncodingError error_code; // error code in case of problem.
|
||||
};
|
||||
|
||||
// Internal, version-checked, entry point
|
||||
@ -238,6 +253,7 @@ int WebPPictureImportBGRA(WebPPicture* const picture,
|
||||
// 'picture' must be less than 16384x16384 in 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.
|
||||
int WebPEncode(const WebPConfig* const config, WebPPicture* const picture);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user