From fb887f7fe6214d547cd3b8f1fb260b178bace968 Mon Sep 17 00:00:00 2001 From: Urvang Joshi Date: Mon, 30 Sep 2013 14:25:58 -0700 Subject: [PATCH] gif2webp: Different kmin/kmax defaults for lossy and lossless These were the best values found considering the compression gain and decoding speed. Change-Id: Iddae4c5b78c6aa42b1f8a034d1c1b93843071a81 --- examples/gif2webp.c | 16 ++++++++++++++-- man/gif2webp.1 | 6 +++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/examples/gif2webp.c b/examples/gif2webp.c index 2f9b1e65..24e2d35c 100644 --- a/examples/gif2webp.c +++ b/examples/gif2webp.c @@ -307,8 +307,11 @@ int main(int argc, const char *argv[]) { WebPData webp_data = { NULL, 0 }; int stored_icc = 0; // Whether we have already stored an ICC profile. int stored_xmp = 0; - size_t kmin = 9; - size_t kmax = 17; + + int default_kmin = 1; // Whether to use default kmin value. + int default_kmax = 1; + size_t kmin = 0; + size_t kmax = 0; memset(&frame, 0, sizeof(frame)); frame.id = WEBP_CHUNK_ANMF; @@ -341,8 +344,10 @@ int main(int argc, const char *argv[]) { config.method = strtol(argv[++c], NULL, 0); } else if (!strcmp(argv[c], "-kmax") && c < argc - 1) { kmax = strtoul(argv[++c], NULL, 0); + default_kmax = 0; } else if (!strcmp(argv[c], "-kmin") && c < argc - 1) { kmin = strtoul(argv[++c], NULL, 0); + default_kmin = 0; } else if (!strcmp(argv[c], "-f") && c < argc - 1) { config.filter_strength = strtol(argv[++c], NULL, 0); } else if (!strcmp(argv[c], "-version")) { @@ -366,6 +371,13 @@ int main(int argc, const char *argv[]) { } } + // Appropriate default kmin, kmax values for lossy and lossless. + if (default_kmin) { + kmin = config.lossless ? 9 : 3; + } + if (default_kmax) { + kmax = config.lossless ? 17 : 5; + } SanitizeKeyFrameIntervals(&kmin, &kmax); cache = WebPFrameCacheNew(kmin, kmax); diff --git a/man/gif2webp.1 b/man/gif2webp.1 index f2fcfcb8..ed5feb83 100644 --- a/man/gif2webp.1 +++ b/man/gif2webp.1 @@ -1,5 +1,5 @@ .\" Hey, EMACS: -*- nroff -*- -.TH GIF2WEBP 1 "February 01, 2013" +.TH GIF2WEBP 1 "September 30, 2013" .SH NAME gif2webp \- Convert a GIF image to WebP .SH SYNOPSIS @@ -58,8 +58,8 @@ some key frames into the output animation as needed so that this criteria is satisfied. .br A 'kmin' value of 0 will turn off insertion of key frames. -Typical values are in the range 5 to 30. Default values are kmin = 9 and -kmax = 17. +Typical values are in the range 3 to 30. Default values are kmin = 9, +kmax = 17 for lossless compression and kmin = 3, kmax = 5 for lossy compression. .br These two options are relevant only for animated images with large number of frames (>50).