dwebp: move webp decoding to example_util

this will allow reuse by cwebp

Change-Id: I667252fdacfc5436112d21b040ca299273ec1515
This commit is contained in:
James Zern
2014-04-22 19:33:22 -07:00
parent c0220460e9
commit 4a0e73904d
4 changed files with 112 additions and 46 deletions

View File

@ -19,6 +19,9 @@
extern "C" {
#endif
struct WebPDecoderConfig;
struct WebPBitstreamFeatures;
// Allocates storage for entire file 'file_name' and returns contents and size
// in 'data' and 'data_size'. Returns 1 on success, 0 otherwise. '*data' should
// be deleted using free().
@ -35,6 +38,32 @@ int ExUtilReadFromStdin(const uint8_t** data, size_t* data_size);
int ExUtilWriteFile(const char* const file_name,
const uint8_t* data, size_t data_size);
//------------------------------------------------------------------------------
// WebP decoding
// Prints an informative error message regarding decode failure of 'in_file'.
// 'status' is treated as a VP8StatusCode and if valid will be printed as a
// text string.
void ExUtilPrintWebPError(const char* const in_file, int status);
// Reads a WebP from 'in_file', returning the contents and size in 'data' and
// 'data_size'. 'bitstream' is populated using WebPGetFeatures().
// Returns true on success.
int ExUtilLoadWebP(const char* const in_file,
const uint8_t** data, size_t* data_size,
struct WebPBitstreamFeatures* bitstream);
// Decodes the WebP contained in 'data'. 'config' is a structure previously
// initialized by WebPInitDecoderConfig(). 'config->output' should have the
// desired colorspace selected. If 'incremental' is set to true the WebP
// incremental decoder will be used. 'verbose' will cause decode timing to be
// reported.
// Returns the decoder status. On success 'config->output' will contain the
// decoded picture.
enum VP8StatusCode ExUtilDecodeWebP(const uint8_t* const data, size_t data_size,
int incremental, int verbose,
struct WebPDecoderConfig* const config);
#ifdef __cplusplus
} // extern "C"
#endif