mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-27 06:08: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",
|
fprintf(stderr, "WARNING: Setting kmin = %d, so that kmin < kmax.\n",
|
||||||
(int)enc_options->kmin);
|
(int)enc_options->kmin);
|
||||||
}
|
}
|
||||||
} else if (enc_options->kmin < (enc_options->kmax / 2 + 1)) {
|
} else {
|
||||||
// This ensures that enc.keyframe + kmin >= kmax is always true. So, we
|
const size_t kmin_limit = enc_options->kmax / 2 + 1;
|
||||||
// can flush all the frames in the 'count_since_key_frame == kmax' case.
|
if (enc_options->kmin < kmin_limit && kmin_limit < enc_options->kmax) {
|
||||||
enc_options->kmin = (enc_options->kmax / 2 + 1);
|
// This ensures that enc.keyframe + kmin >= kmax is always true. So, we
|
||||||
if (print_warning) {
|
// can flush all the frames in the 'count_since_key_frame == kmax' case.
|
||||||
fprintf(stderr,
|
enc_options->kmin = kmin_limit;
|
||||||
"WARNING: Setting kmin = %d, so that kmin >= kmax / 2 + 1.\n",
|
if (print_warning) {
|
||||||
(int)enc_options->kmin);
|
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.
|
// 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);
|
(int)enc_options->kmin, MAX_CACHED_FRAMES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
assert(enc_options->kmin <= enc_options->kmax);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef MAX_CACHED_FRAMES
|
#undef MAX_CACHED_FRAMES
|
||||||
|
Loading…
Reference in New Issue
Block a user