mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-13 06:24:27 +02:00
add lossless quick encoding functions to the public API
New functions: WebPEncodeLosslessRGB() WebPEncodeLosslessBGR() WebPEncodeLosslessRGBA() WebPEncodeLosslessBGRA() Change-Id: Id56da7569eee80c57de8f1f053fb87b217d33a4b
This commit is contained in:
@ -1008,7 +1008,8 @@ int WebPPictureDistortion(const WebPPicture* const pic1,
|
||||
typedef int (*Importer)(WebPPicture* const, const uint8_t* const, int);
|
||||
|
||||
static size_t Encode(const uint8_t* rgba, int width, int height, int stride,
|
||||
Importer import, float quality_factor, uint8_t** output) {
|
||||
Importer import, float quality_factor, int lossless,
|
||||
uint8_t** output) {
|
||||
WebPPicture pic;
|
||||
WebPConfig config;
|
||||
WebPMemoryWriter wrt;
|
||||
@ -1019,6 +1020,8 @@ static size_t Encode(const uint8_t* rgba, int width, int height, int stride,
|
||||
return 0; // shouldn't happen, except if system installation is broken
|
||||
}
|
||||
|
||||
config.lossless = !!lossless;
|
||||
pic.use_argb_input = !!lossless;
|
||||
pic.width = width;
|
||||
pic.height = height;
|
||||
pic.writer = WebPMemoryWrite;
|
||||
@ -1036,10 +1039,10 @@ static size_t Encode(const uint8_t* rgba, int width, int height, int stride,
|
||||
return wrt.size;
|
||||
}
|
||||
|
||||
#define ENCODE_FUNC(NAME, IMPORTER) \
|
||||
size_t NAME(const uint8_t* in, int w, int h, int bps, float q, \
|
||||
uint8_t** out) { \
|
||||
return Encode(in, w, h, bps, IMPORTER, q, out); \
|
||||
#define ENCODE_FUNC(NAME, IMPORTER) \
|
||||
size_t NAME(const uint8_t* in, int w, int h, int bps, float q, \
|
||||
uint8_t** out) { \
|
||||
return Encode(in, w, h, bps, IMPORTER, q, 0, out); \
|
||||
}
|
||||
|
||||
ENCODE_FUNC(WebPEncodeRGB, WebPPictureImportRGB);
|
||||
@ -1049,6 +1052,19 @@ ENCODE_FUNC(WebPEncodeBGRA, WebPPictureImportBGRA);
|
||||
|
||||
#undef ENCODE_FUNC
|
||||
|
||||
#define LOSSLESS_DEFAULT_QUALITY 70.
|
||||
#define LOSSLESS_ENCODE_FUNC(NAME, IMPORTER) \
|
||||
size_t NAME(const uint8_t* in, int w, int h, int bps, uint8_t** out) { \
|
||||
return Encode(in, w, h, bps, IMPORTER, LOSSLESS_DEFAULT_QUALITY, 1, out); \
|
||||
}
|
||||
|
||||
LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessRGB, WebPPictureImportRGB);
|
||||
LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessBGR, WebPPictureImportBGR);
|
||||
LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessRGBA, WebPPictureImportRGBA);
|
||||
LOSSLESS_ENCODE_FUNC(WebPEncodeLosslessBGRA, WebPPictureImportBGRA);
|
||||
|
||||
#undef LOSSLESS_ENCODE_FUNC
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
|
Reference in New Issue
Block a user