mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-26 13:48:21 +01:00
AnimEncoder: Bugfix for kmin = 1 and kmax = 2.
SanitizeEncoderOptions() was changing kmin to 2 too, which resulted in a bad state with kmin == kmax. Change-Id: Ie7273f1949bac469e7e6c8efbc98b154caf6de0f
This commit is contained in:
parent
0f027a72bf
commit
9a062b8ea6
@ -122,14 +122,17 @@ static void SanitizeEncoderOptions(WebPAnimEncoderOptions* const enc_options) {
|
||||
fprintf(stderr, "WARNING: Setting kmin = %d, so that kmin < kmax.\n",
|
||||
(int)enc_options->kmin);
|
||||
}
|
||||
} else if (enc_options->kmin < (enc_options->kmax / 2 + 1)) {
|
||||
// This ensures that enc.keyframe + kmin >= kmax is always true. So, we
|
||||
// can flush all the frames in the 'count_since_key_frame == kmax' case.
|
||||
enc_options->kmin = (enc_options->kmax / 2 + 1);
|
||||
if (print_warning) {
|
||||
fprintf(stderr,
|
||||
"WARNING: Setting kmin = %d, so that kmin >= kmax / 2 + 1.\n",
|
||||
(int)enc_options->kmin);
|
||||
} else {
|
||||
const size_t kmin_limit = enc_options->kmax / 2 + 1;
|
||||
if (enc_options->kmin < kmin_limit && kmin_limit < enc_options->kmax) {
|
||||
// This ensures that enc.keyframe + kmin >= kmax is always true. So, we
|
||||
// can flush all the frames in the 'count_since_key_frame == kmax' case.
|
||||
enc_options->kmin = kmin_limit;
|
||||
if (print_warning) {
|
||||
fprintf(stderr,
|
||||
"WARNING: Setting kmin = %d, so that kmin >= kmax / 2 + 1.\n",
|
||||
(int)enc_options->kmin);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Limit the max number of frames that are allocated.
|
||||
@ -141,6 +144,7 @@ static void SanitizeEncoderOptions(WebPAnimEncoderOptions* const enc_options) {
|
||||
(int)enc_options->kmin, MAX_CACHED_FRAMES);
|
||||
}
|
||||
}
|
||||
assert(enc_options->kmin <= enc_options->kmax);
|
||||
}
|
||||
|
||||
#undef MAX_CACHED_FRAMES
|
||||
|
Loading…
Reference in New Issue
Block a user