mirror of
				https://github.com/webmproject/libwebp.git
				synced 2025-10-31 18:35:41 +01:00 
			
		
		
		
	add WebPISetIOHooks() to set some custom hooks on the incremental decoder object.
Change-Id: I01e973a1e45e3d60dc11fd284df3cbb938cf0485
This commit is contained in:
		| @@ -621,6 +621,23 @@ uint8_t* WebPIDecGetYUV(const WebPIDecoder* const idec, int* last_y, | ||||
|   return src->u.YUVA.y; | ||||
| } | ||||
|  | ||||
| int WebPISetIOHooks(WebPIDecoder* const idec, | ||||
|                     VP8IoPutHook put, | ||||
|                     VP8IoSetupHook setup, | ||||
|                     VP8IoTeardownHook teardown, | ||||
|                     void* user_data) { | ||||
|   if (!idec || !idec->dec_ || idec->state_ > STATE_HEADER) { | ||||
|     return 0; | ||||
|   } | ||||
|  | ||||
|   idec->io_.put = put; | ||||
|   idec->io_.setup = setup; | ||||
|   idec->io_.teardown = teardown; | ||||
|   idec->io_.opaque = user_data; | ||||
|  | ||||
|   return 1; | ||||
| } | ||||
|  | ||||
| #if defined(__cplusplus) || defined(c_plusplus) | ||||
| }    // extern "C" | ||||
| #endif | ||||
|   | ||||
| @@ -38,6 +38,10 @@ extern "C" { | ||||
|  | ||||
| // Input / Output | ||||
| typedef struct VP8Io VP8Io; | ||||
| typedef int (*VP8IoPutHook)(const VP8Io* io); | ||||
| typedef int (*VP8IoSetupHook)(VP8Io* io); | ||||
| typedef void (*VP8IoTeardownHook)(const VP8Io* io); | ||||
|  | ||||
| struct VP8Io { | ||||
|   // set by VP8GetHeaders() | ||||
|   int width, height;         // picture dimensions, in pixels (invariable). | ||||
| @@ -60,14 +64,14 @@ struct VP8Io { | ||||
|   // in-loop filtering level, e.g.). Should return false in case of error | ||||
|   // or abort request. The actual size of the area to update is mb_w x mb_h | ||||
|   // in size, taking cropping into account. | ||||
|   int (*put)(const VP8Io* io); | ||||
|   VP8IoPutHook put; | ||||
|  | ||||
|   // called just before starting to decode the blocks. | ||||
|   // Should returns 0 in case of error. | ||||
|   int (*setup)(VP8Io* io); | ||||
|   VP8IoSetupHook setup; | ||||
|  | ||||
|   // called just after block decoding is finished (or when an error occurred). | ||||
|   void (*teardown)(const VP8Io* io); | ||||
|   VP8IoTeardownHook teardown; | ||||
|  | ||||
|   // this is a recommendation for the user-side yuv->rgb converter. This flag | ||||
|   // is set when calling setup() hook and can be overwritten by it. It then | ||||
| @@ -99,6 +103,15 @@ struct VP8Io { | ||||
| // Internal, version-checked, entry point | ||||
| int VP8InitIoInternal(VP8Io* const, int); | ||||
|  | ||||
| // Set the custom IO function pointers and user-data. The setter for IO hooks | ||||
| // should be called before initiating incremental decoding. Returns true if | ||||
| // WebPIdecoder object is successfully modified, false otherwise. | ||||
| int WebPISetIOHooks(WebPIDecoder* const idec, | ||||
|                     VP8IoPutHook put, | ||||
|                     VP8IoSetupHook setup, | ||||
|                     VP8IoTeardownHook teardown, | ||||
|                     void* user_data); | ||||
|  | ||||
| // Main decoding object. This is an opaque structure. | ||||
| typedef struct VP8Decoder VP8Decoder; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user