libwebsockets
Lightweight C library for HTML5 websockets
lws-jpeg.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct lws_jpeg lws_jpeg_t
 

Functions

LWS_VISIBLE LWS_EXTERN lws_jpeg_tlws_jpeg_new (void)
 
LWS_VISIBLE LWS_EXTERN void lws_jpeg_free (lws_jpeg_t **j)
 
LWS_VISIBLE LWS_EXTERN lws_stateful_ret_t lws_jpeg_emit_next_line (lws_jpeg_t *j, const uint8_t **ppix, const uint8_t **buf, size_t *size, char hold_at_metadata)
 
LWS_VISIBLE LWS_EXTERN unsigned int lws_jpeg_get_width (const lws_jpeg_t *j)
 
LWS_VISIBLE LWS_EXTERN unsigned int lws_jpeg_get_height (const lws_jpeg_t *j)
 
LWS_VISIBLE LWS_EXTERN unsigned int lws_jpeg_get_bpp (const lws_jpeg_t *j)
 
LWS_VISIBLE LWS_EXTERN unsigned int lws_jpeg_get_bitdepth (const lws_jpeg_t *j)
 
LWS_VISIBLE LWS_EXTERN unsigned int lws_jpeg_get_components (const lws_jpeg_t *j)
 
LWS_VISIBLE LWS_EXTERN unsigned int lws_jpeg_get_pixelsize (const lws_jpeg_t *j)
 

Typedef Documentation

◆ lws_jpeg_t

typedef struct lws_jpeg lws_jpeg_t

Definition at line 1 of file lws-jpeg.h.

Function Documentation

◆ lws_jpeg_new()

LWS_VISIBLE LWS_EXTERN lws_jpeg_t* lws_jpeg_new ( void  )

lws_jpeg_new() - Create new JPEG decode object

Returns a new jpeg decoding object, which should be destroyed with lws_jpeg_free() when done with, or NULL if OOM.

◆ lws_jpeg_free()

LWS_VISIBLE LWS_EXTERN void lws_jpeg_free ( lws_jpeg_t **  j)

lws_jpeg_free() - Destroy a JPEG decode object

Parameters
jPointer to the decode object to destroy and set to NULL

This also frees any sub-allocations in the object.

◆ lws_jpeg_emit_next_line()

LWS_VISIBLE LWS_EXTERN lws_stateful_ret_t lws_jpeg_emit_next_line ( lws_jpeg_t j,
const uint8_t **  ppix,
const uint8_t **  buf,
size_t *  size,
char  hold_at_metadata 
)

lws_jpeg_emit_next_line() - deocde the next line

Parameters
jthe decode object
ppixpointer to a pointer set to the line's decoded pixel data
bufpointer to a const uint8_t array of jpeg input
sizepointer to the count of bytes available at *buf
hold_at_metadatatrue if we should not advance to decode

Make jpeg 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.

The output at *ppix is either 3-byte per pixel RGB, or 1-byte grayscale, you can query lws_jpeg_get_components() to find out how many bytes per pixel.

◆ lws_jpeg_get_width()

LWS_VISIBLE LWS_EXTERN unsigned int lws_jpeg_get_width ( const lws_jpeg_t j)

◆ lws_jpeg_get_height()

LWS_VISIBLE LWS_EXTERN unsigned int lws_jpeg_get_height ( const lws_jpeg_t j)

◆ lws_jpeg_get_bpp()

LWS_VISIBLE LWS_EXTERN unsigned int lws_jpeg_get_bpp ( const lws_jpeg_t j)

◆ lws_jpeg_get_bitdepth()

LWS_VISIBLE LWS_EXTERN unsigned int lws_jpeg_get_bitdepth ( const lws_jpeg_t j)

◆ lws_jpeg_get_components()

LWS_VISIBLE LWS_EXTERN unsigned int lws_jpeg_get_components ( const lws_jpeg_t j)

◆ lws_jpeg_get_pixelsize()

LWS_VISIBLE LWS_EXTERN unsigned int lws_jpeg_get_pixelsize ( const lws_jpeg_t j)