summaryrefslogtreecommitdiffstats
path: root/third_party/libwebp/enc/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/libwebp/enc/config.c')
-rw-r--r--third_party/libwebp/enc/config.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/third_party/libwebp/enc/config.c b/third_party/libwebp/enc/config.c
index af7f0b0..4b7aa0f 100644
--- a/third_party/libwebp/enc/config.c
+++ b/third_party/libwebp/enc/config.c
@@ -138,3 +138,25 @@ int WebPValidateConfig(const WebPConfig* config) {
//------------------------------------------------------------------------------
+#if WEBP_ENCODER_ABI_VERSION > 0x0202
+#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;
+}
+#endif
+
+//------------------------------------------------------------------------------