libwebsockets
Lightweight C library for HTML5 websockets
|
Go to the source code of this file.
Typedefs | |
typedef enum lws_upng_format_t | lws_upng_format_t |
typedef struct lws_upng_t | lws_upng_t |
typedef enum lws_upng_format_t lws_upng_format_t |
typedef struct lws_upng_t lws_upng_t |
Definition at line 1 of file lws-upng.h.
enum lws_upng_format_t |
Definition at line 34 of file lws-upng.h.
LWS_VISIBLE LWS_EXTERN lws_upng_t* lws_upng_new | ( | void | ) |
lws_upng_new() - Create new UPNG decode object
Returns a new PNG decoding object, which should be destroyed with lws_upng_free() when done with, or NULL if OOM.
LWS_VISIBLE LWS_EXTERN void lws_upng_free | ( | lws_upng_t ** | upng | ) |
lws_upng_free() - Destroy a PNG decode object
upng | Pointer to the decode object to destroy and set to NULL |
This also frees any sub-allocations in the object.
LWS_VISIBLE LWS_EXTERN lws_stateful_ret_t lws_upng_emit_next_line | ( | lws_upng_t * | upng, |
const uint8_t ** | ppix, | ||
const uint8_t ** | buf, | ||
size_t * | size, | ||
char | hold_at_metadata | ||
) |
lws_upng_emit_next_line() - deocde the next line
upng | the decode object |
ppix | pointer to a pointer set to the line's decoded pixel data |
buf | pointer to a const uint8_t array of PNG input |
size | pointer to the count of bytes available at *buf |
hold_at_metadata | true if we should not advance to decode |
Make PNG input available to the decoder so it can issue the next line's worth of pixels. If the call consumed any input, *buf and *size are adjusted accordingly.
The decoder is stateful so it is not sensitive to the chunk size for the input.
If hold_at_metadata
is set, then the decoder will only go as far as picking out the metadata like image dimensions, but not start the decode, which requires the >30KB heap allocation. This lets you put off for as long as possible committing to the decode allocation... this only helps overall if you have flow controlled the incoming PNG data.
Return will be one of LWS_SRET_WANT_INPUT is the decoder is stalled waiting for more input to be provided, LWS_SRET_WANT_OUTPUT is the decoder stopped because it had produced a whole line of output pixels (which can be found starting at *ppix), LWS_SRET_OK is it completed and LWS_SRET_FATAL or larger if the decode failed.
LWS_VISIBLE LWS_EXTERN unsigned int lws_upng_get_width | ( | const lws_upng_t * | upng | ) |
LWS_VISIBLE LWS_EXTERN unsigned int lws_upng_get_height | ( | const lws_upng_t * | upng | ) |
LWS_VISIBLE LWS_EXTERN unsigned int lws_upng_get_bpp | ( | const lws_upng_t * | upng | ) |
LWS_VISIBLE LWS_EXTERN unsigned int lws_upng_get_bitdepth | ( | const lws_upng_t * | upng | ) |
LWS_VISIBLE LWS_EXTERN unsigned int lws_upng_get_components | ( | const lws_upng_t * | upng | ) |
LWS_VISIBLE LWS_EXTERN unsigned int lws_upng_get_pixelsize | ( | const lws_upng_t * | upng | ) |
LWS_VISIBLE LWS_EXTERN lws_upng_format_t lws_upng_get_format | ( | const lws_upng_t * | upng | ) |
LWS_VISIBLE LWS_EXTERN struct inflator_ctx* lws_upng_inflator_create | ( | const uint8_t ** | outring, |
size_t * | outringlen, | ||
size_t ** | opl, | ||
size_t ** | cl | ||
) |
lws_upng_inflator_create() - create a gzip inflator context
outring | pointer set to the output ringbuffer on exit |
outringlen | size of the output ringbuffer set on exit |
opl | pointer to set to point to ctx outpos_linear |
cl | pointer to set to point to ctx consumed_linear |
Creates an opaque gzip inflator object.
LWS_VISIBLE LWS_EXTERN lws_stateful_ret_t lws_upng_inflate_data | ( | struct inflator_ctx * | inf, |
const void * | buf, | ||
size_t | len | ||
) |
lws_upng_inflate_data() - inflate compressed data statefully
inf | inflator context created with lws_upng_inflator_create() |
buf | NULL to continue consumption of existing input, or new input |
len | ignored if buf is NULL, else amount of new input at buf |
Tries to progress the inflation. If output is available, *opl
will be further along than before it was called. *cl
should be set to opl
to consume the available output data.
Output is into a ringfuffer, typically sized at 32KB. opl
and cl
are "linear", that is extend beyond the ringbuffer. They should be modulo outringlen (given when the inflator was created) when accessing outring.
LWS_VISIBLE LWS_EXTERN void lws_upng_inflator_destroy | ( | struct inflator_ctx ** | inf | ) |
lws_upng_inflator_destroy() - destroys the inflation context and ringbuffer
inf:
pointer to pointer to inflation context
Frees the inflation context and its allocations, and sets *inf
to NULL.