From 36555983f0860d85eb1cc2ff47e652385477f132 Mon Sep 17 00:00:00 2001 From: Urvang Joshi Date: Thu, 31 Oct 2013 17:17:37 -0700 Subject: [PATCH] gif2webp: kmin = 0 should suppress key-frame addition. This is to conform to man/gif2webp.1 Earlier, one needed to give both '-kmin 0' and '-kmax 0' for this to work. Also, suppress further warnings for kmin = 0 and/or kmax = 0 case. Change-Id: I6f5eeb609aeffc159d0252a40a5734162f7e4e7d --- examples/gif2webp.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/examples/gif2webp.c b/examples/gif2webp.c index 349207bc..c23abcbe 100644 --- a/examples/gif2webp.c +++ b/examples/gif2webp.c @@ -42,27 +42,42 @@ static void SanitizeKeyFrameIntervals(size_t* const kmin_ptr, size_t* const kmax_ptr) { size_t kmin = *kmin_ptr; size_t kmax = *kmax_ptr; + int print_warning = 1; - if (kmin == 0) kmin = ~0; // Disable keyframe insertion. - if (kmax == 0) kmax = ~0; + if (kmin == 0) { // Disable keyframe insertion. + kmax = ~0; + kmin = kmax - 1; + print_warning = 0; + } + if (kmax == 0) { + kmax = ~0; + print_warning = 0; + } if (kmin >= kmax) { kmin = kmax - 1; - fprintf(stderr, - "WARNING: Setting kmin = %zu, so that kmin < kmax.\n", kmin); + if (print_warning) { + fprintf(stderr, + "WARNING: Setting kmin = %zu, so that kmin < kmax.\n", kmin); + } } else if (kmin < (kmax / 2 + 1)) { // This ensures that cache.keyframe + kmin >= kmax is always true. So, we // can flush all the frames in the ‘count_since_key_frame == kmax’ case. kmin = (kmax / 2 + 1); - fprintf(stderr, - "WARNING: Setting kmin = %zu, so that kmin >= kmax / 2 + 1.\n", - kmin); + if (print_warning) { + fprintf(stderr, + "WARNING: Setting kmin = %zu, so that kmin >= kmax / 2 + 1.\n", + kmin); + } } // Limit the max number of frames that are allocated. if (kmax - kmin > MAX_CACHE_SIZE) { kmin = kmax - MAX_CACHE_SIZE; - fprintf(stderr, - "WARNING: Setting kmin = %zu, so that kmax - kmin <= 30.\n", kmin); + if (print_warning) { + fprintf(stderr, + "WARNING: Setting kmin = %zu, so that kmax - kmin <= 30.\n", + kmin); + } } *kmin_ptr = kmin; *kmax_ptr = kmax;