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
This commit is contained in:
Pascal Massimino 2012-06-20 09:20:34 +00:00 committed by James Zern
parent ce156afccf
commit 0275159143
2 changed files with 14 additions and 5 deletions

View File

@ -1049,7 +1049,7 @@ int main(int argc, const char *argv[]) {
// Check for unsupported command line options for lossless mode and log // Check for unsupported command line options for lossless mode and log
// warning for such options. // warning for such options.
if (config.lossless == 1) { if (!quiet && config.lossless == 1) {
if (config.target_size > 0 || config.target_PSNR > 0) { if (config.target_size > 0 || config.target_PSNR > 0) {
fprintf(stderr, "Encoding for specified size or PSNR is not supported" fprintf(stderr, "Encoding for specified size or PSNR is not supported"
" for lossless encoding. Ignoring such option(s)!\n"); " 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" fprintf(stderr, "Partition limit option is not required for lossless"
" encoding. Ignoring this option!\n"); " 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)) { if (!WebPValidateConfig(&config)) {

View File

@ -1027,6 +1027,7 @@ int VP8LEncodeImage(const WebPConfig* const config,
int width, height; int width, height;
int has_alpha; int has_alpha;
size_t coded_size; size_t coded_size;
int percent = 0;
WebPEncodingError err = VP8_ENC_OK; WebPEncodingError err = VP8_ENC_OK;
VP8LBitWriter bw; VP8LBitWriter bw;
@ -1039,6 +1040,11 @@ int VP8LEncodeImage(const WebPConfig* const config,
width = picture->width; width = picture->width;
height = picture->height; height = picture->height;
if (!WebPReportProgress(picture, 1, &percent)) {
UserAbort:
err = VP8_ENC_ERROR_USER_ABORT;
goto Error;
}
// Write image size. // Write image size.
VP8LBitWriterInit(&bw, (width * height) >> 1); VP8LBitWriterInit(&bw, (width * height) >> 1);
@ -1054,14 +1060,21 @@ int VP8LEncodeImage(const WebPConfig* const config,
goto Error; goto Error;
} }
if (!WebPReportProgress(picture, 5, &percent)) goto UserAbort;
// Encode main image stream. // Encode main image stream.
err = VP8LEncodeStream(config, picture, &bw); err = VP8LEncodeStream(config, picture, &bw);
if (err != VP8_ENC_OK) goto Error; 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. // Finish the RIFF chunk.
err = WriteImage(picture, &bw, &coded_size); err = WriteImage(picture, &bw, &coded_size);
if (err != VP8_ENC_OK) goto Error; if (err != VP8_ENC_OK) goto Error;
if (!WebPReportProgress(picture, 100, &percent)) goto UserAbort;
// Collect some stats if needed. // Collect some stats if needed.
if (picture->stats != NULL) { if (picture->stats != NULL) {
WebPAuxStats* const stats = picture->stats; WebPAuxStats* const stats = picture->stats;