1*b2055c35SXin Li // Copyright 2014 Google Inc. All Rights Reserved. 2*b2055c35SXin Li // 3*b2055c35SXin Li // Use of this source code is governed by a BSD-style license 4*b2055c35SXin Li // that can be found in the COPYING file in the root of the source 5*b2055c35SXin Li // tree. An additional intellectual property rights grant can be found 6*b2055c35SXin Li // in the file PATENTS. All contributing project authors may 7*b2055c35SXin Li // be found in the AUTHORS file in the root of the source tree. 8*b2055c35SXin Li // ----------------------------------------------------------------------------- 9*b2055c35SXin Li // 10*b2055c35SXin Li // WebP decode. 11*b2055c35SXin Li 12*b2055c35SXin Li #ifndef WEBP_IMAGEIO_WEBPDEC_H_ 13*b2055c35SXin Li #define WEBP_IMAGEIO_WEBPDEC_H_ 14*b2055c35SXin Li 15*b2055c35SXin Li #include "webp/decode.h" 16*b2055c35SXin Li 17*b2055c35SXin Li #ifdef __cplusplus 18*b2055c35SXin Li extern "C" { 19*b2055c35SXin Li #endif 20*b2055c35SXin Li 21*b2055c35SXin Li struct Metadata; 22*b2055c35SXin Li struct WebPPicture; 23*b2055c35SXin Li 24*b2055c35SXin Li //------------------------------------------------------------------------------ 25*b2055c35SXin Li // WebP decoding 26*b2055c35SXin Li 27*b2055c35SXin Li // Prints an informative error message regarding decode failure of 'in_file'. 28*b2055c35SXin Li // 'status' is treated as a VP8StatusCode and if valid will be printed as a 29*b2055c35SXin Li // text string. 30*b2055c35SXin Li void PrintWebPError(const char* const in_file, int status); 31*b2055c35SXin Li 32*b2055c35SXin Li // Reads a WebP from 'in_file', returning the contents and size in 'data' and 33*b2055c35SXin Li // 'data_size'. If not NULL, 'bitstream' is populated using WebPGetFeatures(). 34*b2055c35SXin Li // Returns true on success. 35*b2055c35SXin Li int LoadWebP(const char* const in_file, 36*b2055c35SXin Li const uint8_t** data, size_t* data_size, 37*b2055c35SXin Li WebPBitstreamFeatures* bitstream); 38*b2055c35SXin Li 39*b2055c35SXin Li // Decodes the WebP contained in 'data'. 40*b2055c35SXin Li // 'config' is a structure previously initialized by WebPInitDecoderConfig(). 41*b2055c35SXin Li // 'config->output' should have the desired colorspace selected. 42*b2055c35SXin Li // Returns the decoder status. On success 'config->output' will contain the 43*b2055c35SXin Li // decoded picture. 44*b2055c35SXin Li VP8StatusCode DecodeWebP(const uint8_t* const data, size_t data_size, 45*b2055c35SXin Li WebPDecoderConfig* const config); 46*b2055c35SXin Li 47*b2055c35SXin Li // Same as DecodeWebP(), but using the incremental decoder. 48*b2055c35SXin Li VP8StatusCode DecodeWebPIncremental( 49*b2055c35SXin Li const uint8_t* const data, size_t data_size, 50*b2055c35SXin Li WebPDecoderConfig* const config); 51*b2055c35SXin Li 52*b2055c35SXin Li //------------------------------------------------------------------------------ 53*b2055c35SXin Li 54*b2055c35SXin Li // Decodes a WebP contained in 'data', returning the decoded output in 'pic'. 55*b2055c35SXin Li // Output is RGBA or YUVA, depending on pic->use_argb value. 56*b2055c35SXin Li // If 'keep_alpha' is true and the WebP has an alpha channel, the output is RGBA 57*b2055c35SXin Li // or YUVA. Otherwise, alpha channel is dropped and output is RGB or YUV. 58*b2055c35SXin Li // Returns true on success. 59*b2055c35SXin Li int ReadWebP(const uint8_t* const data, size_t data_size, 60*b2055c35SXin Li struct WebPPicture* const pic, 61*b2055c35SXin Li int keep_alpha, struct Metadata* const metadata); 62*b2055c35SXin Li 63*b2055c35SXin Li #ifdef __cplusplus 64*b2055c35SXin Li } // extern "C" 65*b2055c35SXin Li #endif 66*b2055c35SXin Li 67*b2055c35SXin Li #endif // WEBP_IMAGEIO_WEBPDEC_H_ 68