mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-26 13:48:21 +01:00
AnimEncode API: kmax=0 should imply all keyframes.
Earlier, it wasn't adding any keyframes at all. Change-Id: If3824fc8e57548b8610a52e875fb9279f862fa57
This commit is contained in:
parent
2c906c407c
commit
b9df35f714
@ -68,7 +68,8 @@ Specify the minimum and maximum distance between consecutive key frames
|
|||||||
some key frames into the output animation as needed so that this criteria is
|
some key frames into the output animation as needed so that this criteria is
|
||||||
satisfied.
|
satisfied.
|
||||||
.br
|
.br
|
||||||
A 'kmin' value of 0 will turn off insertion of key frames.
|
A 'kmin' value of 0 will turn off insertion of key frames. A 'kmax' value of 0
|
||||||
|
will result in all frames being key frames.
|
||||||
Typical values are in the range 3 to 30. Default values are kmin = 9,
|
Typical values are in the range 3 to 30. Default values are kmin = 9,
|
||||||
kmax = 17 for lossless compression and kmin = 3, kmax = 5 for lossy compression.
|
kmax = 17 for lossless compression and kmin = 3, kmax = 5 for lossy compression.
|
||||||
.br
|
.br
|
||||||
|
@ -111,9 +111,9 @@ static void SanitizeEncoderOptions(WebPAnimEncoderOptions* const enc_options) {
|
|||||||
DisableKeyframes(enc_options);
|
DisableKeyframes(enc_options);
|
||||||
print_warning = 0;
|
print_warning = 0;
|
||||||
}
|
}
|
||||||
if (enc_options->kmax == 0) {
|
if (enc_options->kmax == 0) { // All frames will be key-frames.
|
||||||
enc_options->kmax = ~0;
|
enc_options->kmin = 0;
|
||||||
print_warning = 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enc_options->kmin >= enc_options->kmax) {
|
if (enc_options->kmin >= enc_options->kmax) {
|
||||||
@ -144,7 +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);
|
assert(enc_options->kmin < enc_options->kmax);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef MAX_CACHED_FRAMES
|
#undef MAX_CACHED_FRAMES
|
||||||
@ -242,6 +242,9 @@ WebPAnimEncoder* WebPAnimEncoderNewInternal(
|
|||||||
ResetCounters(enc);
|
ResetCounters(enc);
|
||||||
// Note: one extra storage is for the previous frame.
|
// Note: one extra storage is for the previous frame.
|
||||||
enc->size_ = enc->options_.kmax - enc->options_.kmin + 1;
|
enc->size_ = enc->options_.kmax - enc->options_.kmin + 1;
|
||||||
|
// We need space for at least 2 frames. But when kmin, kmax are both zero,
|
||||||
|
// enc->size_ will be 1. So we handle that special case below.
|
||||||
|
if (enc->size_ < 2) enc->size_ = 2;
|
||||||
enc->encoded_frames_ =
|
enc->encoded_frames_ =
|
||||||
(EncodedFrame*)WebPSafeCalloc(enc->size_, sizeof(*enc->encoded_frames_));
|
(EncodedFrame*)WebPSafeCalloc(enc->size_, sizeof(*enc->encoded_frames_));
|
||||||
if (enc->encoded_frames_ == NULL) goto Err;
|
if (enc->encoded_frames_ == NULL) goto Err;
|
||||||
@ -972,7 +975,9 @@ static int CacheFrame(WebPAnimEncoder* const enc, int duration,
|
|||||||
} else {
|
} else {
|
||||||
encoded_frame->is_key_frame_ = 0;
|
encoded_frame->is_key_frame_ = 0;
|
||||||
}
|
}
|
||||||
if (enc->count_since_key_frame_ == enc->options_.kmax) {
|
// Note: We need '>=' below because when kmin and kmax are both zero,
|
||||||
|
// count_since_key_frame will always be > kmax.
|
||||||
|
if (enc->count_since_key_frame_ >= enc->options_.kmax) {
|
||||||
enc->flush_count_ = enc->count_ - 1;
|
enc->flush_count_ = enc->count_ - 1;
|
||||||
enc->count_since_key_frame_ = 0;
|
enc->count_since_key_frame_ = 0;
|
||||||
enc->keyframe_ = KEYFRAME_NONE;
|
enc->keyframe_ = KEYFRAME_NONE;
|
||||||
|
@ -427,7 +427,8 @@ typedef struct {
|
|||||||
// frames as needed to satisfy this criteria.
|
// frames as needed to satisfy this criteria.
|
||||||
// Note that these conditions should hold: kmax > kmin
|
// Note that these conditions should hold: kmax > kmin
|
||||||
// and kmin >= kmax / 2 + 1. Also, if kmin == 0, then
|
// and kmin >= kmax / 2 + 1. Also, if kmin == 0, then
|
||||||
// key-frame insertion is disabled.
|
// key-frame insertion is disabled; and if kmax == 0,
|
||||||
|
// then all frames will be key-frames.
|
||||||
int allow_mixed; // If true, use mixed compression mode; may choose
|
int allow_mixed; // If true, use mixed compression mode; may choose
|
||||||
// either lossy and lossless for each frame.
|
// either lossy and lossless for each frame.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user