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
This commit is contained in:
Urvang Joshi 2013-09-30 14:25:58 -07:00
parent 92d47e4ca9
commit fb887f7fe6
2 changed files with 17 additions and 5 deletions

View File

@ -307,8 +307,11 @@ int main(int argc, const char *argv[]) {
WebPData webp_data = { NULL, 0 }; WebPData webp_data = { NULL, 0 };
int stored_icc = 0; // Whether we have already stored an ICC profile. int stored_icc = 0; // Whether we have already stored an ICC profile.
int stored_xmp = 0; 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)); memset(&frame, 0, sizeof(frame));
frame.id = WEBP_CHUNK_ANMF; frame.id = WEBP_CHUNK_ANMF;
@ -341,8 +344,10 @@ int main(int argc, const char *argv[]) {
config.method = strtol(argv[++c], NULL, 0); config.method = strtol(argv[++c], NULL, 0);
} else if (!strcmp(argv[c], "-kmax") && c < argc - 1) { } else if (!strcmp(argv[c], "-kmax") && c < argc - 1) {
kmax = strtoul(argv[++c], NULL, 0); kmax = strtoul(argv[++c], NULL, 0);
default_kmax = 0;
} else if (!strcmp(argv[c], "-kmin") && c < argc - 1) { } else if (!strcmp(argv[c], "-kmin") && c < argc - 1) {
kmin = strtoul(argv[++c], NULL, 0); kmin = strtoul(argv[++c], NULL, 0);
default_kmin = 0;
} else if (!strcmp(argv[c], "-f") && c < argc - 1) { } else if (!strcmp(argv[c], "-f") && c < argc - 1) {
config.filter_strength = strtol(argv[++c], NULL, 0); config.filter_strength = strtol(argv[++c], NULL, 0);
} else if (!strcmp(argv[c], "-version")) { } 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); SanitizeKeyFrameIntervals(&kmin, &kmax);
cache = WebPFrameCacheNew(kmin, kmax); cache = WebPFrameCacheNew(kmin, kmax);

View File

@ -1,5 +1,5 @@
.\" Hey, EMACS: -*- nroff -*- .\" Hey, EMACS: -*- nroff -*-
.TH GIF2WEBP 1 "February 01, 2013" .TH GIF2WEBP 1 "September 30, 2013"
.SH NAME .SH NAME
gif2webp \- Convert a GIF image to WebP gif2webp \- Convert a GIF image to WebP
.SH SYNOPSIS .SH SYNOPSIS
@ -58,8 +58,8 @@ some key frames into the output animation as needed so that this criteria is
satisfied. satisfied.
.br .br
A 'kmin' value of 0 will turn off insertion of key frames. 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 Typical values are in the range 3 to 30. Default values are kmin = 9,
kmax = 17. kmax = 17 for lossless compression and kmin = 3, kmax = 5 for lossy compression.
.br .br
These two options are relevant only for animated images with large number of These two options are relevant only for animated images with large number of
frames (>50). frames (>50).