diff --git a/examples/dwebp.c b/examples/dwebp.c index 19bdcced..ce1bac24 100644 --- a/examples/dwebp.c +++ b/examples/dwebp.c @@ -366,10 +366,19 @@ int main(int argc, const char *argv[]) { if (external_buffer == NULL) goto Exit; } - if (incremental) { - status = DecodeWebPIncremental(data, data_size, verbose, &config); - } else { - status = DecodeWebP(data, data_size, verbose, &config); + { + Stopwatch stop_watch; + if (verbose) StopwatchReset(&stop_watch); + + if (incremental) { + status = DecodeWebPIncremental(data, data_size, &config); + } else { + status = DecodeWebP(data, data_size, &config); + } + if (verbose) { + const double decode_time = StopwatchReadAndReset(&stop_watch); + fprintf(stderr, "Time to decode picture: %.3fs\n", decode_time); + } } ok = (status == VP8_STATUS_OK); diff --git a/imageio/webpdec.c b/imageio/webpdec.c index 3a725121..8fa803ec 100644 --- a/imageio/webpdec.c +++ b/imageio/webpdec.c @@ -16,7 +16,6 @@ #include "webp/decode.h" #include "webp/encode.h" -#include "../examples/stopwatch.h" #include "./imageio_util.h" #include "./metadata.h" @@ -71,36 +70,20 @@ int LoadWebP(const char* const in_file, //------------------------------------------------------------------------------ VP8StatusCode DecodeWebP(const uint8_t* const data, size_t data_size, - int verbose, WebPDecoderConfig* const config) { - Stopwatch stop_watch; - VP8StatusCode status = VP8_STATUS_OK; + WebPDecoderConfig* const config) { if (config == NULL) return VP8_STATUS_INVALID_PARAM; - PrintAnimationWarning(config); - - StopwatchReset(&stop_watch); - - // Decoding call. - status = WebPDecode(data, data_size, config); - - if (verbose) { - const double decode_time = StopwatchReadAndReset(&stop_watch); - fprintf(stderr, "Time to decode picture: %.3fs\n", decode_time); - } - return status; + return WebPDecode(data, data_size, config); } VP8StatusCode DecodeWebPIncremental( const uint8_t* const data, size_t data_size, - int verbose, WebPDecoderConfig* const config) { - Stopwatch stop_watch; + WebPDecoderConfig* const config) { VP8StatusCode status = VP8_STATUS_OK; if (config == NULL) return VP8_STATUS_INVALID_PARAM; PrintAnimationWarning(config); - StopwatchReset(&stop_watch); - // Decoding call. { WebPIDecoder* const idec = WebPIDecode(data, data_size, config); @@ -124,11 +107,6 @@ VP8StatusCode DecodeWebPIncremental( WebPIDelete(idec); } } - - if (verbose) { - const double decode_time = StopwatchReadAndReset(&stop_watch); - fprintf(stderr, "Time to decode picture: %.3fs\n", decode_time); - } return status; } @@ -168,7 +146,7 @@ int ReadWebP(const uint8_t* const data, size_t data_size, output_buffer->colorspace = has_alpha ? MODE_YUVA : MODE_YUV; } - status = DecodeWebP(data, data_size, 0, &config); + status = DecodeWebP(data, data_size, &config); if (status == VP8_STATUS_OK) { pic->width = output_buffer->width; pic->height = output_buffer->height; diff --git a/imageio/webpdec.h b/imageio/webpdec.h index 085c19af..6db801f6 100644 --- a/imageio/webpdec.h +++ b/imageio/webpdec.h @@ -38,17 +38,16 @@ int LoadWebP(const char* const in_file, // Decodes the WebP contained in 'data'. // 'config' is a structure previously initialized by WebPInitDecoderConfig(). -// 'config->output' should have the desired colorspace selected. 'verbose' will -// cause decode timing to be reported. +// 'config->output' should have the desired colorspace selected. // Returns the decoder status. On success 'config->output' will contain the // decoded picture. VP8StatusCode DecodeWebP(const uint8_t* const data, size_t data_size, - int verbose, WebPDecoderConfig* const config); + WebPDecoderConfig* const config); // Same as DecodeWebP(), but using the incremental decoder. VP8StatusCode DecodeWebPIncremental( const uint8_t* const data, size_t data_size, - int verbose, WebPDecoderConfig* const config); + WebPDecoderConfig* const config); //------------------------------------------------------------------------------