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:
@ -637,6 +637,21 @@ static void HelpLong(void) {
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Error messages
|
||||
|
||||
static const char* const kErrorMessages[] = {
|
||||
"OK",
|
||||
"OUT_OF_MEMORY: Out of memory allocating objects",
|
||||
"BITSTREAM_OUT_OF_MEMORY: Out of memory re-allocating byte buffer",
|
||||
"NULL_PARAMETER: NULL parameter passed to function",
|
||||
"INVALID_CONFIGURATION: configuration is invalid",
|
||||
"BAD_DIMENSION: Bad picture dimension",
|
||||
"PARTITION0_OVERFLOW: Partition #0 is too big to fit 512k",
|
||||
"PARTITION_OVERFLOW: Partition is too big to fir 16M",
|
||||
"BAD_WRITE: Picture writer returned an error"
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
@ -833,6 +848,8 @@ int main(int argc, const char *argv[]) {
|
||||
}
|
||||
if (!WebPEncode(&config, &picture)) {
|
||||
fprintf(stderr, "Error! Cannot encode picture as WebP\n");
|
||||
fprintf(stderr, "Error code: %d (%s)\n",
|
||||
picture.error_code, kErrorMessages[picture.error_code]);
|
||||
goto Error;
|
||||
}
|
||||
if (verbose) {
|
||||
|
Reference in New Issue
Block a user