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:
Pascal Massimino
2011-06-02 06:55:03 -07:00
parent 6c9405dbfb
commit ca7a2fd66d
5 changed files with 74 additions and 19 deletions

View File

@ -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) {