mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-12 22:14:29 +02:00
Fix "all|no frames are keyframes" settings.
Documentation says: "if kmin == 0, then key-frame insertion is disabled;
and if kmax == 0, then all frames will be key-frames."
Reading this, you'd expect that if kmax == 0, then with any kmin <= 0
all frames will be key-frames. But actually the kmin <= 0 test is caught
first and you get the opposite (no keyframes but the first). You'd have
instead to set kmax == 0 and any value kmin > 0, which is absolutely
counter-intuitive (reversing order).
Moreover kmax == 1 has no valid kmin (kmin == 1 conflicts with the
`kmax > kmin` rule and kmin == 0 conflicts with `kmin >= kmax / 2 + 1`).
So it should be considered an exception too.
Instead I propose this new logic:
- kmax == 1 means that all frames are keyframes (you are explicitly
requesting a keyframe every 1 frame at most, i.e. all frames).
- kmax == 0 means no keyframes (you ask for a keyframe every 0 frames,
i.e. never).
This is more "logical" language-wise, and also does not involve any
conflicts about what if both kmax and kmin are 0, since now a single
property value is meaningful for the 2 exceptional cases.
Change-Id: Ia90fb963bc26904ff078d2e4ef9f74b22b13a0fd
(cherry picked from commit 2dc0bdcaee
)
This commit is contained in:
@ -129,14 +129,13 @@ static void SanitizeEncoderOptions(WebPAnimEncoderOptions* const enc_options) {
|
||||
DisableKeyframes(enc_options);
|
||||
}
|
||||
|
||||
if (enc_options->kmin <= 0) {
|
||||
DisableKeyframes(enc_options);
|
||||
print_warning = 0;
|
||||
}
|
||||
if (enc_options->kmax <= 0) { // All frames will be key-frames.
|
||||
if (enc_options->kmax == 1) { // All frames will be key-frames.
|
||||
enc_options->kmin = 0;
|
||||
enc_options->kmax = 0;
|
||||
return;
|
||||
} else if (enc_options->kmax <= 0) {
|
||||
DisableKeyframes(enc_options);
|
||||
print_warning = 0;
|
||||
}
|
||||
|
||||
if (enc_options->kmin >= enc_options->kmax) {
|
||||
|
@ -21,7 +21,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define WEBP_MUX_ABI_VERSION 0x0107 // MAJOR(8b) + MINOR(8b)
|
||||
#define WEBP_MUX_ABI_VERSION 0x0108 // MAJOR(8b) + MINOR(8b)
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Mux API
|
||||
@ -430,9 +430,10 @@ struct WebPAnimEncoderOptions {
|
||||
// frames in the output. The library may insert some key
|
||||
// frames as needed to satisfy this criteria.
|
||||
// Note that these conditions should hold: kmax > kmin
|
||||
// and kmin >= kmax / 2 + 1. Also, if kmin == 0, then
|
||||
// key-frame insertion is disabled; and if kmax == 0,
|
||||
// then all frames will be key-frames.
|
||||
// and kmin >= kmax / 2 + 1. Also, if kmax <= 0, then
|
||||
// key-frame insertion is disabled; and if kmax == 1,
|
||||
// then all frames will be key-frames (kmin value does
|
||||
// not matter for these special cases).
|
||||
int allow_mixed; // If true, use mixed compression mode; may choose
|
||||
// either lossy and lossless for each frame.
|
||||
int verbose; // If true, print info and warning messages to stderr.
|
||||
|
Reference in New Issue
Block a user