add a very crude progress report for lossless
better than nothing. Removed the warning in cwebp.c
(and silenced the warning in quiet mode too)
Change-Id: I85bbeaf77e0f60ead798886043dc053e6b44def5
diff --git a/examples/cwebp.c b/examples/cwebp.c
index d94ac53..1458926 100644
--- a/examples/cwebp.c
+++ b/examples/cwebp.c
@@ -1049,7 +1049,7 @@
// Check for unsupported command line options for lossless mode and log
// warning for such options.
- if (config.lossless == 1) {
+ if (!quiet && config.lossless == 1) {
if (config.target_size > 0 || config.target_PSNR > 0) {
fprintf(stderr, "Encoding for specified size or PSNR is not supported"
" for lossless encoding. Ignoring such option(s)!\n");
@@ -1058,10 +1058,6 @@
fprintf(stderr, "Partition limit option is not required for lossless"
" encoding. Ignoring this option!\n");
}
- if (show_progress) {
- fprintf(stderr, "Progress reporting option is not supported for lossless"
- " encoding. Ignoring this option!\n");
- }
}
if (!WebPValidateConfig(&config)) {
diff --git a/src/enc/vp8l.c b/src/enc/vp8l.c
index a1ac986..68fb5f1 100644
--- a/src/enc/vp8l.c
+++ b/src/enc/vp8l.c
@@ -1027,6 +1027,7 @@
int width, height;
int has_alpha;
size_t coded_size;
+ int percent = 0;
WebPEncodingError err = VP8_ENC_OK;
VP8LBitWriter bw;
@@ -1039,6 +1040,11 @@
width = picture->width;
height = picture->height;
+ if (!WebPReportProgress(picture, 1, &percent)) {
+ UserAbort:
+ err = VP8_ENC_ERROR_USER_ABORT;
+ goto Error;
+ }
// Write image size.
VP8LBitWriterInit(&bw, (width * height) >> 1);
@@ -1054,14 +1060,21 @@
goto Error;
}
+ if (!WebPReportProgress(picture, 5, &percent)) goto UserAbort;
+
// Encode main image stream.
err = VP8LEncodeStream(config, picture, &bw);
if (err != VP8_ENC_OK) goto Error;
+ // TODO(skal): have a fine-grained progress report in VP8LEncodeStream().
+ if (!WebPReportProgress(picture, 90, &percent)) goto UserAbort;
+
// Finish the RIFF chunk.
err = WriteImage(picture, &bw, &coded_size);
if (err != VP8_ENC_OK) goto Error;
+ if (!WebPReportProgress(picture, 100, &percent)) goto UserAbort;
+
// Collect some stats if needed.
if (picture->stats != NULL) {
WebPAuxStats* const stats = picture->stats;