add WebPISetIOHooks() to set some custom hooks on the incremental decoder object.

Change-Id: I01e973a1e45e3d60dc11fd284df3cbb938cf0485
This commit is contained in:
Pascal Massimino 2011-07-07 16:38:03 -07:00
parent 7643a6f2ef
commit a06bbe2e80
2 changed files with 33 additions and 3 deletions

View File

@ -621,6 +621,23 @@ uint8_t* WebPIDecGetYUV(const WebPIDecoder* const idec, int* last_y,
return src->u.YUVA.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) #if defined(__cplusplus) || defined(c_plusplus)
} // extern "C" } // extern "C"
#endif #endif

View File

@ -38,6 +38,10 @@ extern "C" {
// Input / Output // Input / Output
typedef struct VP8Io VP8Io; typedef struct VP8Io VP8Io;
typedef int (*VP8IoPutHook)(const VP8Io* io);
typedef int (*VP8IoSetupHook)(VP8Io* io);
typedef void (*VP8IoTeardownHook)(const VP8Io* io);
struct VP8Io { struct VP8Io {
// set by VP8GetHeaders() // set by VP8GetHeaders()
int width, height; // picture dimensions, in pixels (invariable). 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 // 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 // or abort request. The actual size of the area to update is mb_w x mb_h
// in size, taking cropping into account. // in size, taking cropping into account.
int (*put)(const VP8Io* io); VP8IoPutHook put;
// called just before starting to decode the blocks. // called just before starting to decode the blocks.
// Should returns 0 in case of error. // 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). // 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 // 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 // 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 // Internal, version-checked, entry point
int VP8InitIoInternal(VP8Io* const, int); 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. // Main decoding object. This is an opaque structure.
typedef struct VP8Decoder VP8Decoder; typedef struct VP8Decoder VP8Decoder;