mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-12 22:14:29 +02:00
add a -z option to cwebp, and WebPConfigLosslessPreset() function
These are presets for lossless coding, similar to zlib. The shortcut for lossless coding is now, e.g.: cwebp -z 5 in.png -o out_lossless.webp There are 10 possible values for -z parameter: 0 (fastest, lowest compression) to 9 (slowest, best compression) A reasonable tradeoff is -z 6, e.g. -z 9 can be quite slow, so use with care. This -z option is just a shortcut for some pre-defined '-lossless -m xx -q yy' combinations. Change-Id: I6ae716456456aea065469c916c2d5ca4d6c6cf04
This commit is contained in:
@ -138,3 +138,23 @@ int WebPValidateConfig(const WebPConfig* config) {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#define MAX_LEVEL 9
|
||||
|
||||
// Mapping between -z level and -m / -q parameter settings.
|
||||
static const struct {
|
||||
uint8_t method_;
|
||||
uint8_t quality_;
|
||||
} kLosslessPresets[MAX_LEVEL + 1] = {
|
||||
{ 0, 0 }, { 1, 20 }, { 2, 25 }, { 3, 30 }, { 3, 50 },
|
||||
{ 4, 50 }, { 4, 75 }, { 4, 90 }, { 5, 90 }, { 6, 100 }
|
||||
};
|
||||
|
||||
int WebPConfigLosslessPreset(WebPConfig* config, int level) {
|
||||
if (config == NULL || level < 0 || level > MAX_LEVEL) return 0;
|
||||
config->lossless = 1;
|
||||
config->method = kLosslessPresets[level].method_;
|
||||
config->quality = kLosslessPresets[level].quality_;
|
||||
return 1;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user