diff --git a/src/dec/idec.c b/src/dec/idec.c index 4b5111b1..628ff611 100644 --- a/src/dec/idec.c +++ b/src/dec/idec.c @@ -578,10 +578,20 @@ static const WebPDecBuffer* GetOutputBuffer(const WebPIDecoder* const idec) { return idec->params_.output; } -const WebPDecBuffer* WebPIDecGetSamples(const WebPIDecoder* const idec, - int* last_y) { +const WebPDecBuffer* WebPIDecodedArea(const WebPIDecoder* const idec, + int* const left, int* const top, + int* const width, int* const height) { const WebPDecBuffer* const src = GetOutputBuffer(idec); - if (last_y) *last_y = idec->params_.last_y; + if (left) *left = 0; + if (top) *top = 0; + // TODO(skal): later include handling of rotations. + if (src) { + if (width) *width = src->width; + if (height) *height = idec->params_.last_y; + } else { + if (width) *width = 0; + if (height) *height = 0; + } return src; } diff --git a/src/webp/decode.h b/src/webp/decode.h index af132190..dbf5aad1 100644 --- a/src/webp/decode.h +++ b/src/webp/decode.h @@ -249,13 +249,15 @@ uint8_t* WebPIDecGetYUV(const WebPIDecoder* const idec, int* last_y, uint8_t** u, uint8_t** v, int* width, int* height, int* stride, int* uv_stride); -// Generic call to retrieve output buffer information. -// Returns NULL in case of error, otherwise returns the pointer to the internal -// representation. This structure is read-only and shouldn't be modified. -// TODO(skal): instead of 'last_y' only, we should pass *left/top/right/bottom, -// to get the visible area. Esp. useful for rotation. -const WebPDecBuffer* WebPIDecGetSamples(const WebPIDecoder* const idec, - int* last_y); +// Generic call to retrieve information about the displayable area. +// If non NULL, the left/right/width/height pointers are filled with the visible +// rectangular area so far. +// Returns NULL in case the incremental decoder object is in an invalid state. +// Otherwise returns the pointer to the internal representation. This structure +// is read-only, tied to WebPIDecoder's lifespan and should not be modified. +const WebPDecBuffer* WebPIDecodedArea(const WebPIDecoder* const idec, + int* const left, int* const top, + int* const width, int* const height); //----------------------------------------------------------------------------- // Advanced decoding parametrization