From 027515914372fffe87b51a54da69c211e2d305b6 Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Wed, 20 Jun 2012 09:20:34 +0000 Subject: [PATCH] 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 --- examples/cwebp.c | 6 +----- src/enc/vp8l.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/examples/cwebp.c b/examples/cwebp.c index d94ac531..14589263 100644 --- a/examples/cwebp.c +++ b/examples/cwebp.c @@ -1049,7 +1049,7 @@ int main(int argc, const char *argv[]) { // 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 @@ int main(int argc, const char *argv[]) { 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 a1ac9860..68fb5f17 100644 --- a/src/enc/vp8l.c +++ b/src/enc/vp8l.c @@ -1027,6 +1027,7 @@ int VP8LEncodeImage(const WebPConfig* const config, int width, height; int has_alpha; size_t coded_size; + int percent = 0; WebPEncodingError err = VP8_ENC_OK; VP8LBitWriter bw; @@ -1039,6 +1040,11 @@ int VP8LEncodeImage(const WebPConfig* const config, 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 @@ int VP8LEncodeImage(const WebPConfig* const config, 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;