Add -incremental option to dwebp
useful for testing. Not listed in the man or README, since it's only useful for testing the incremental decoding (e.g. measuring the timing difference compared to non-incremental) Change-Id: I8df8046e031d21006242babb5bcac09f8ff9f710
This commit is contained in:
parent
54b8e3f6e2
commit
5cd43e4316
@ -559,6 +559,7 @@ static void Help(void) {
|
|||||||
" -crop <x> <y> <w> <h> ... crop output with the given rectangle\n"
|
" -crop <x> <y> <w> <h> ... crop output with the given rectangle\n"
|
||||||
" -scale <w> <h> .......... scale the output (*after* any cropping)\n"
|
" -scale <w> <h> .......... scale the output (*after* any cropping)\n"
|
||||||
" -alpha ....... only save the alpha plane.\n"
|
" -alpha ....... only save the alpha plane.\n"
|
||||||
|
" -incremental . use incremental decoding (useful for tests)\n"
|
||||||
" -h ....... this help message.\n"
|
" -h ....... this help message.\n"
|
||||||
" -v ....... verbose (e.g. print encoding/decoding times)\n"
|
" -v ....... verbose (e.g. print encoding/decoding times)\n"
|
||||||
#ifndef WEBP_DLL
|
#ifndef WEBP_DLL
|
||||||
@ -581,6 +582,7 @@ int main(int argc, const char *argv[]) {
|
|||||||
WebPDecBuffer* const output_buffer = &config.output;
|
WebPDecBuffer* const output_buffer = &config.output;
|
||||||
WebPBitstreamFeatures* const bitstream = &config.input;
|
WebPBitstreamFeatures* const bitstream = &config.input;
|
||||||
OutputFileFormat format = PNG;
|
OutputFileFormat format = PNG;
|
||||||
|
int incremental = 0;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
if (!WebPInitDecoderConfig(&config)) {
|
if (!WebPInitDecoderConfig(&config)) {
|
||||||
@ -635,6 +637,8 @@ int main(int argc, const char *argv[]) {
|
|||||||
} else if (!strcmp(argv[c], "-noasm")) {
|
} else if (!strcmp(argv[c], "-noasm")) {
|
||||||
VP8GetCPUInfo = NULL;
|
VP8GetCPUInfo = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
} else if (!strcmp(argv[c], "-incremental")) {
|
||||||
|
incremental = 1;
|
||||||
} else if (argv[c][0] == '-') {
|
} else if (argv[c][0] == '-') {
|
||||||
fprintf(stderr, "Unknown option '%s'\n", argv[c]);
|
fprintf(stderr, "Unknown option '%s'\n", argv[c]);
|
||||||
Help();
|
Help();
|
||||||
@ -706,7 +710,21 @@ int main(int argc, const char *argv[]) {
|
|||||||
free((void*)data);
|
free((void*)data);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Decoding call.
|
||||||
|
if (!incremental) {
|
||||||
status = WebPDecode(data, data_size, &config);
|
status = WebPDecode(data, data_size, &config);
|
||||||
|
} else {
|
||||||
|
WebPIDecoder* const idec = WebPINewDecoder(output_buffer);
|
||||||
|
if (idec == NULL) {
|
||||||
|
fprintf(stderr, "Failed during WebPINewDecoder().\n");
|
||||||
|
status = VP8_STATUS_OUT_OF_MEMORY;
|
||||||
|
ok = 0;
|
||||||
|
} else {
|
||||||
|
status = WebPIUpdate(idec, data, data_size);
|
||||||
|
WebPIDelete(idec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
const double decode_time = StopwatchReadAndReset(&stop_watch);
|
const double decode_time = StopwatchReadAndReset(&stop_watch);
|
||||||
@ -718,7 +736,7 @@ int main(int argc, const char *argv[]) {
|
|||||||
if (!ok) {
|
if (!ok) {
|
||||||
fprintf(stderr, "Decoding of %s failed.\n", in_file);
|
fprintf(stderr, "Decoding of %s failed.\n", in_file);
|
||||||
fprintf(stderr, "Status: %d (%s)\n", status, kStatusMessages[status]);
|
fprintf(stderr, "Status: %d (%s)\n", status, kStatusMessages[status]);
|
||||||
return -1;
|
goto Exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -734,8 +752,8 @@ int main(int argc, const char *argv[]) {
|
|||||||
fprintf(stderr, "Nothing written; "
|
fprintf(stderr, "Nothing written; "
|
||||||
"use -o flag to save the result as e.g. PNG.\n");
|
"use -o flag to save the result as e.g. PNG.\n");
|
||||||
}
|
}
|
||||||
|
Exit:
|
||||||
WebPFreeDecBuffer(output_buffer);
|
WebPFreeDecBuffer(output_buffer);
|
||||||
|
|
||||||
return ok ? 0 : -1;
|
return ok ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user