mirror of
				https://github.com/webmproject/libwebp.git
				synced 2025-10-30 18:05:36 +01:00 
			
		
		
		
	Merge "remove the dependency to stop_watch.[ch] in imageio"
This commit is contained in:
		| @@ -366,10 +366,19 @@ int main(int argc, const char *argv[]) { | |||||||
|       if (external_buffer == NULL) goto Exit; |       if (external_buffer == NULL) goto Exit; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (incremental) { |     { | ||||||
|       status = DecodeWebPIncremental(data, data_size, verbose, &config); |       Stopwatch stop_watch; | ||||||
|     } else { |       if (verbose) StopwatchReset(&stop_watch); | ||||||
|       status = DecodeWebP(data, data_size, verbose, &config); |  | ||||||
|  |       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); |     ok = (status == VP8_STATUS_OK); | ||||||
|   | |||||||
| @@ -16,7 +16,6 @@ | |||||||
|  |  | ||||||
| #include "webp/decode.h" | #include "webp/decode.h" | ||||||
| #include "webp/encode.h" | #include "webp/encode.h" | ||||||
| #include "../examples/stopwatch.h" |  | ||||||
| #include "./imageio_util.h" | #include "./imageio_util.h" | ||||||
| #include "./metadata.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, | VP8StatusCode DecodeWebP(const uint8_t* const data, size_t data_size, | ||||||
|                          int verbose, WebPDecoderConfig* const config) { |                          WebPDecoderConfig* const config) { | ||||||
|   Stopwatch stop_watch; |  | ||||||
|   VP8StatusCode status = VP8_STATUS_OK; |  | ||||||
|   if (config == NULL) return VP8_STATUS_INVALID_PARAM; |   if (config == NULL) return VP8_STATUS_INVALID_PARAM; | ||||||
|  |  | ||||||
|   PrintAnimationWarning(config); |   PrintAnimationWarning(config); | ||||||
|  |   return WebPDecode(data, data_size, 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; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| VP8StatusCode DecodeWebPIncremental( | VP8StatusCode DecodeWebPIncremental( | ||||||
|     const uint8_t* const data, size_t data_size, |     const uint8_t* const data, size_t data_size, | ||||||
|     int verbose, WebPDecoderConfig* const config) { |     WebPDecoderConfig* const config) { | ||||||
|   Stopwatch stop_watch; |  | ||||||
|   VP8StatusCode status = VP8_STATUS_OK; |   VP8StatusCode status = VP8_STATUS_OK; | ||||||
|   if (config == NULL) return VP8_STATUS_INVALID_PARAM; |   if (config == NULL) return VP8_STATUS_INVALID_PARAM; | ||||||
|  |  | ||||||
|   PrintAnimationWarning(config); |   PrintAnimationWarning(config); | ||||||
|  |  | ||||||
|   StopwatchReset(&stop_watch); |  | ||||||
|  |  | ||||||
|   // Decoding call. |   // Decoding call. | ||||||
|   { |   { | ||||||
|     WebPIDecoder* const idec = WebPIDecode(data, data_size, config); |     WebPIDecoder* const idec = WebPIDecode(data, data_size, config); | ||||||
| @@ -124,11 +107,6 @@ VP8StatusCode DecodeWebPIncremental( | |||||||
|       WebPIDelete(idec); |       WebPIDelete(idec); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   if (verbose) { |  | ||||||
|     const double decode_time = StopwatchReadAndReset(&stop_watch); |  | ||||||
|     fprintf(stderr, "Time to decode picture: %.3fs\n", decode_time); |  | ||||||
|   } |  | ||||||
|   return status; |   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; |       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) { |     if (status == VP8_STATUS_OK) { | ||||||
|       pic->width = output_buffer->width; |       pic->width = output_buffer->width; | ||||||
|       pic->height = output_buffer->height; |       pic->height = output_buffer->height; | ||||||
|   | |||||||
| @@ -38,17 +38,16 @@ int LoadWebP(const char* const in_file, | |||||||
|  |  | ||||||
| // Decodes the WebP contained in 'data'. | // Decodes the WebP contained in 'data'. | ||||||
| // 'config' is a structure previously initialized by WebPInitDecoderConfig(). | // 'config' is a structure previously initialized by WebPInitDecoderConfig(). | ||||||
| // 'config->output' should have the desired colorspace selected. 'verbose' will | // 'config->output' should have the desired colorspace selected. | ||||||
| // cause decode timing to be reported. |  | ||||||
| // Returns the decoder status. On success 'config->output' will contain the | // Returns the decoder status. On success 'config->output' will contain the | ||||||
| // decoded picture. | // decoded picture. | ||||||
| VP8StatusCode DecodeWebP(const uint8_t* const data, size_t data_size, | 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. | // Same as DecodeWebP(), but using the incremental decoder. | ||||||
| VP8StatusCode DecodeWebPIncremental( | VP8StatusCode DecodeWebPIncremental( | ||||||
|     const uint8_t* const data, size_t data_size, |     const uint8_t* const data, size_t data_size, | ||||||
|     int verbose, WebPDecoderConfig* const config); |     WebPDecoderConfig* const config); | ||||||
|  |  | ||||||
| //------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user