mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-20 12:28:26 +01:00
Merge "gif2webp: kmin = 0 should suppress key-frame addition."
This commit is contained in:
commit
6d0cb3debf
@ -42,27 +42,42 @@ static void SanitizeKeyFrameIntervals(size_t* const kmin_ptr,
|
|||||||
size_t* const kmax_ptr) {
|
size_t* const kmax_ptr) {
|
||||||
size_t kmin = *kmin_ptr;
|
size_t kmin = *kmin_ptr;
|
||||||
size_t kmax = *kmax_ptr;
|
size_t kmax = *kmax_ptr;
|
||||||
|
int print_warning = 1;
|
||||||
|
|
||||||
if (kmin == 0) kmin = ~0; // Disable keyframe insertion.
|
if (kmin == 0) { // Disable keyframe insertion.
|
||||||
if (kmax == 0) kmax = ~0;
|
kmax = ~0;
|
||||||
|
kmin = kmax - 1;
|
||||||
|
print_warning = 0;
|
||||||
|
}
|
||||||
|
if (kmax == 0) {
|
||||||
|
kmax = ~0;
|
||||||
|
print_warning = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (kmin >= kmax) {
|
if (kmin >= kmax) {
|
||||||
kmin = kmax - 1;
|
kmin = kmax - 1;
|
||||||
fprintf(stderr,
|
if (print_warning) {
|
||||||
"WARNING: Setting kmin = %zu, so that kmin < kmax.\n", kmin);
|
fprintf(stderr,
|
||||||
|
"WARNING: Setting kmin = %zu, so that kmin < kmax.\n", kmin);
|
||||||
|
}
|
||||||
} else if (kmin < (kmax / 2 + 1)) {
|
} else if (kmin < (kmax / 2 + 1)) {
|
||||||
// This ensures that cache.keyframe + kmin >= kmax is always true. So, we
|
// 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.
|
// can flush all the frames in the ‘count_since_key_frame == kmax’ case.
|
||||||
kmin = (kmax / 2 + 1);
|
kmin = (kmax / 2 + 1);
|
||||||
fprintf(stderr,
|
if (print_warning) {
|
||||||
"WARNING: Setting kmin = %zu, so that kmin >= kmax / 2 + 1.\n",
|
fprintf(stderr,
|
||||||
kmin);
|
"WARNING: Setting kmin = %zu, so that kmin >= kmax / 2 + 1.\n",
|
||||||
|
kmin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Limit the max number of frames that are allocated.
|
// Limit the max number of frames that are allocated.
|
||||||
if (kmax - kmin > MAX_CACHE_SIZE) {
|
if (kmax - kmin > MAX_CACHE_SIZE) {
|
||||||
kmin = kmax - MAX_CACHE_SIZE;
|
kmin = kmax - MAX_CACHE_SIZE;
|
||||||
fprintf(stderr,
|
if (print_warning) {
|
||||||
"WARNING: Setting kmin = %zu, so that kmax - kmin <= 30.\n", kmin);
|
fprintf(stderr,
|
||||||
|
"WARNING: Setting kmin = %zu, so that kmax - kmin <= 30.\n",
|
||||||
|
kmin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*kmin_ptr = kmin;
|
*kmin_ptr = kmin;
|
||||||
*kmax_ptr = kmax;
|
*kmax_ptr = kmax;
|
||||||
|
Loading…
Reference in New Issue
Block a user