mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-27 06:08:21 +01:00
libwebp: Fix VP8EncTokenLoop() progress
Encoding the image found in the user bug report below would result in
a progress rising up to 173% because of the extra 20% caused by each
of the 4 extra lossy passes. It happened at methods 3 to 6.
https://groups.google.com/a/webmproject.org/g/webp-discuss/c/yOiP8APubgc/m/FP3r5X2rDAAJ
Change-Id: I95318d0dc4df546044eb926c786c04bb7f915cbe
(cherry picked from commit db25f1b4ed
)
This commit is contained in:
parent
827a307fec
commit
6db8248c01
@ -778,6 +778,7 @@ int VP8EncTokenLoop(VP8Encoder* const enc) {
|
|||||||
// Roughly refresh the proba eight times per pass
|
// Roughly refresh the proba eight times per pass
|
||||||
int max_count = (enc->mb_w_ * enc->mb_h_) >> 3;
|
int max_count = (enc->mb_w_ * enc->mb_h_) >> 3;
|
||||||
int num_pass_left = enc->config_->pass;
|
int num_pass_left = enc->config_->pass;
|
||||||
|
int remaining_progress = 40; // percents
|
||||||
const int do_search = enc->do_search_;
|
const int do_search = enc->do_search_;
|
||||||
VP8EncIterator it;
|
VP8EncIterator it;
|
||||||
VP8EncProba* const proba = &enc->proba_;
|
VP8EncProba* const proba = &enc->proba_;
|
||||||
@ -805,6 +806,9 @@ int VP8EncTokenLoop(VP8Encoder* const enc) {
|
|||||||
uint64_t size_p0 = 0;
|
uint64_t size_p0 = 0;
|
||||||
uint64_t distortion = 0;
|
uint64_t distortion = 0;
|
||||||
int cnt = max_count;
|
int cnt = max_count;
|
||||||
|
// The final number of passes is not trivial to know in advance.
|
||||||
|
const int pass_progress = remaining_progress / (2 + num_pass_left);
|
||||||
|
remaining_progress -= pass_progress;
|
||||||
VP8IteratorInit(enc, &it);
|
VP8IteratorInit(enc, &it);
|
||||||
SetLoopParams(enc, stats.q);
|
SetLoopParams(enc, stats.q);
|
||||||
if (is_last_pass) {
|
if (is_last_pass) {
|
||||||
@ -832,7 +836,7 @@ int VP8EncTokenLoop(VP8Encoder* const enc) {
|
|||||||
StoreSideInfo(&it);
|
StoreSideInfo(&it);
|
||||||
VP8StoreFilterStats(&it);
|
VP8StoreFilterStats(&it);
|
||||||
VP8IteratorExport(&it);
|
VP8IteratorExport(&it);
|
||||||
ok = VP8IteratorProgress(&it, 20);
|
ok = VP8IteratorProgress(&it, pass_progress);
|
||||||
}
|
}
|
||||||
VP8IteratorSaveBoundary(&it);
|
VP8IteratorSaveBoundary(&it);
|
||||||
} while (ok && VP8IteratorNext(&it));
|
} while (ok && VP8IteratorNext(&it));
|
||||||
@ -878,7 +882,8 @@ int VP8EncTokenLoop(VP8Encoder* const enc) {
|
|||||||
ok = VP8EmitTokens(&enc->tokens_, enc->parts_ + 0,
|
ok = VP8EmitTokens(&enc->tokens_, enc->parts_ + 0,
|
||||||
(const uint8_t*)proba->coeffs_, 1);
|
(const uint8_t*)proba->coeffs_, 1);
|
||||||
}
|
}
|
||||||
ok = ok && WebPReportProgress(enc->pic_, enc->percent_ + 20, &enc->percent_);
|
ok = ok && WebPReportProgress(enc->pic_, enc->percent_ + remaining_progress,
|
||||||
|
&enc->percent_);
|
||||||
return PostLoopFinalize(&it, ok);
|
return PostLoopFinalize(&it, ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user