spandsp  3.0.0
t42.h File Reference

Go to the source code of this file.

Typedefs

typedef struct t42_encode_state_s t42_encode_state_t
 
typedef struct t42_decode_state_s t42_decode_state_t
 
typedef struct lab_params_s lab_params_t
 

Functions

int xyz_to_corrected_color_temp (float *temp, float xyz[3])
 Convert an X0, Y0, Z0 coordinate to a colour tempature.
 
int colour_temp_to_xyz (float xyz[3], float temp)
 Convert a colour temperature to an X0, Y0, Z0 coordinate.
 
void srgb_to_lab (lab_params_t *s, uint8_t lab[], const uint8_t srgb[], int pixels)
 Convert a row of 8 bit pixels from Lab to sRGB. More...
 
void lab_to_srgb (lab_params_t *s, uint8_t srgb[], const uint8_t lab[], int pixels)
 Convert a row of 8 bit pixels from sRGB to Lab. More...
 
void set_lab_illuminant (lab_params_t *s, float new_xn, float new_yn, float new_zn)
 
void set_lab_gamut (lab_params_t *s, int L_min, int L_max, int a_min, int a_max, int b_min, int b_max, int ab_are_signed)
 
void set_lab_gamut2 (lab_params_t *s, int L_P, int L_Q, int a_P, int a_Q, int b_P, int b_Q)
 
void get_lab_gamut2 (lab_params_t *s, int *L_P, int *L_Q, int *a_P, int *a_Q, int *b_P, int *b_Q)
 
bool t42_analyse_header (uint32_t *width, uint32_t *length, const uint8_t data[], size_t len)
 
void t42_encode_set_options (t42_encode_state_t *s, uint32_t l0, int quality, int options)
 
int t42_encode_set_image_width (t42_encode_state_t *s, uint32_t image_width)
 
int t42_encode_set_image_length (t42_encode_state_t *s, uint32_t length)
 
int t42_encode_set_image_type (t42_encode_state_t *s, int image_type)
 
void t42_encode_abort (t42_encode_state_t *s)
 
void t42_encode_comment (t42_encode_state_t *s, const uint8_t comment[], size_t len)
 
int t42_encode_image_complete (t42_encode_state_t *s)
 Check if we are at the end of the current document page. More...
 
int t42_encode_get (t42_encode_state_t *s, uint8_t buf[], size_t max_len)
 
uint32_t t42_encode_get_image_width (t42_encode_state_t *s)
 
uint32_t t42_encode_get_image_length (t42_encode_state_t *s)
 
int t42_encode_get_compressed_image_size (t42_encode_state_t *s)
 Get the size of the compressed image in bits. More...
 
int t42_encode_set_row_read_handler (t42_encode_state_t *s, t4_row_read_handler_t handler, void *user_data)
 
logging_state_tt42_encode_get_logging_state (t42_encode_state_t *s)
 Get the logging context associated with a T.42 encode context. More...
 
int t42_encode_restart (t42_encode_state_t *s, uint32_t image_width, uint32_t image_length)
 Restart a T.42 encode context. More...
 
t42_encode_state_tt42_encode_init (t42_encode_state_t *s, uint32_t image_width, uint32_t image_length, t4_row_read_handler_t handler, void *user_data)
 Prepare to encode an image in T.42 format. More...
 
int t42_encode_release (t42_encode_state_t *s)
 Release a T.42 encode context. More...
 
int t42_encode_free (t42_encode_state_t *s)
 Free a T.42 encode context. More...
 
void t42_decode_rx_status (t42_decode_state_t *s, int status)
 
int t42_decode_put (t42_decode_state_t *s, const uint8_t data[], size_t len)
 Decode a chunk of T.42 data. More...
 
int t42_decode_set_row_write_handler (t42_decode_state_t *s, t4_row_write_handler_t handler, void *user_data)
 Set the row handler routine. More...
 
int t42_decode_set_comment_handler (t42_decode_state_t *s, uint32_t max_comment_len, t4_row_write_handler_t handler, void *user_data)
 Set the comment handler routine. More...
 
int t42_decode_set_image_size_constraints (t42_decode_state_t *s, uint32_t max_xd, uint32_t max_yd)
 Set constraints on the received image size. More...
 
uint32_t t42_decode_get_image_width (t42_decode_state_t *s)
 Get the width of the image. More...
 
uint32_t t42_decode_get_image_length (t42_decode_state_t *s)
 Get the length of the image. More...
 
int t42_decode_get_compressed_image_size (t42_decode_state_t *s)
 Get the size of the compressed image in bits. More...
 
logging_state_tt42_decode_get_logging_state (t42_decode_state_t *s)
 Get the logging context associated with a T.42 decode context. More...
 
int t42_decode_restart (t42_decode_state_t *s)
 Restart a T.42 decode context. More...
 
t42_decode_state_tt42_decode_init (t42_decode_state_t *s, t4_row_write_handler_t handler, void *user_data)
 Prepare to decode an image in T.42 format. More...
 
int t42_decode_release (t42_decode_state_t *s)
 Release a T.42 decode context. More...
 
int t42_decode_free (t42_decode_state_t *s)
 Free a T.42 decode context. More...
 

Typedef Documentation

◆ t42_decode_state_t

State of a working instance of the T.42 decoder

◆ t42_encode_state_t

State of a working instance of the T.42 encoder

Function Documentation

◆ lab_to_srgb()

void lab_to_srgb ( lab_params_t s,
uint8_t  srgb[],
const uint8_t  lab[],
int  pixels 
)

Convert a row of 8 bit pixels from sRGB to Lab.

Parameters
sThe Lab parameters context.
srgbThe output pixels
labThe input pixels
pixelThe number of pixels in the row.

◆ srgb_to_lab()

void srgb_to_lab ( lab_params_t s,
uint8_t  lab[],
const uint8_t  srgb[],
int  pixels 
)

Convert a row of 8 bit pixels from Lab to sRGB.

Parameters
sThe Lab parameters context.
labThe output pixels
srgbThe input pixels
pixelThe number of pixels in the row.

◆ t42_decode_free()

int t42_decode_free ( t42_decode_state_t s)

Free a T.42 decode context.

Parameters
sThe T.42 decode context.
Returns
0 for OK, else -1.

References t42_decode_release().

◆ t42_decode_get_compressed_image_size()

int t42_decode_get_compressed_image_size ( t42_decode_state_t s)

Get the size of the compressed image in bits.

Parameters
sThe T.42 context.
Returns
The size of the image, in bits.

References t42_decode_state_s::compressed_image_size.

◆ t42_decode_get_image_length()

uint32_t t42_decode_get_image_length ( t42_decode_state_t s)

Get the length of the image.

Parameters
sThe T.42 context.
Returns
The length of the image, in pixels.

◆ t42_decode_get_image_width()

uint32_t t42_decode_get_image_width ( t42_decode_state_t s)

Get the width of the image.

Parameters
sThe T.42 context.
Returns
The width of the image, in pixels.

◆ t42_decode_get_logging_state()

logging_state_t* t42_decode_get_logging_state ( t42_decode_state_t s)

Get the logging context associated with a T.42 decode context.

Get the logging context associated with a T.42 decode context.

Parameters
sThe T.42 decode context.
Returns
A pointer to the logging context

References t42_decode_state_s::logging.

◆ t42_decode_init()

t42_decode_state_t* t42_decode_init ( t42_decode_state_t s,
t4_row_write_handler_t  handler,
void *  user_data 
)

Prepare to decode an image in T.42 format.

Parameters
sThe T.42 context.
handlerA callback routine to handle decoded image rows.
user_dataAn opaque pointer passed to handler.
Returns
A pointer to the context, or NULL if there was a problem.

◆ t42_decode_put()

int t42_decode_put ( t42_decode_state_t s,
const uint8_t  data[],
size_t  len 
)

Decode a chunk of T.42 data.

Parameters
sThe T.42 context.
dataThe data to be decoded.
lenThe length of the data to be decoded.
Returns
0 for OK.

◆ t42_decode_release()

int t42_decode_release ( t42_decode_state_t s)

Release a T.42 decode context.

Parameters
sThe T.42 decode context.
Returns
0 for OK, else -1.

Referenced by t42_decode_free().

◆ t42_decode_restart()

int t42_decode_restart ( t42_decode_state_t s)

Restart a T.42 decode context.

Parameters
sThe T.42 context.

◆ t42_decode_set_comment_handler()

int t42_decode_set_comment_handler ( t42_decode_state_t s,
uint32_t  max_comment_len,
t4_row_write_handler_t  handler,
void *  user_data 
)

Set the comment handler routine.

Parameters
sThe T.42 context.
max_comment_lenThe maximum length of comment to be passed to the handler.
handlerA callback routine to handle decoded comment.
user_dataAn opaque pointer passed to handler.
Returns
0 for OK.

References t42_decode_state_s::comment_handler, t42_decode_state_s::comment_user_data, and t42_decode_state_s::max_comment_len.

◆ t42_decode_set_image_size_constraints()

int t42_decode_set_image_size_constraints ( t42_decode_state_t s,
uint32_t  max_xd,
uint32_t  max_yd 
)

Set constraints on the received image size.

A maliciously constructed T.42 image could consume too much memory, and constitute a denial of service attack on the system. This function allows constraints to be applied.

Parameters
sThe T.42 context.
max_xdThe maximum permitted width of the full image, in pixels
max_ydThe maximum permitted height of the full image, in pixels
Returns
0 for OK

◆ t42_decode_set_row_write_handler()

int t42_decode_set_row_write_handler ( t42_decode_state_t s,
t4_row_write_handler_t  handler,
void *  user_data 
)

Set the row handler routine.

Parameters
sThe T.42 context.
handlerA callback routine to handle decoded image rows.
user_dataAn opaque pointer passed to handler.
Returns
0 for OK.

References t42_decode_state_s::row_write_handler, and t42_decode_state_s::row_write_user_data.

Referenced by t4_rx_set_row_write_handler().

◆ t42_encode_free()

int t42_encode_free ( t42_encode_state_t s)

Free a T.42 encode context.

Parameters
sThe T.42 encode context.
Returns
0 for OK, else -1.

References t42_encode_release().

◆ t42_encode_get_compressed_image_size()

int t42_encode_get_compressed_image_size ( t42_encode_state_t s)

Get the size of the compressed image in bits.

Parameters
sThe T.42 context.
Returns
The size of the image, in bits.

References t42_encode_state_s::compressed_image_size.

◆ t42_encode_get_logging_state()

logging_state_t* t42_encode_get_logging_state ( t42_encode_state_t s)

Get the logging context associated with a T.42 encode context.

Get the logging context associated with a T.42 encode context.

Parameters
sThe T.42 encode context.
Returns
A pointer to the logging context

References t42_encode_state_s::logging.

◆ t42_encode_image_complete()

int t42_encode_image_complete ( t42_encode_state_t s)

Check if we are at the end of the current document page.

Parameters
sThe T.42 context.
Returns
0 for more data to come. SIG_STATUS_END_OF_DATA for no more data.

Referenced by t4_tx_image_complete().

◆ t42_encode_init()

t42_encode_state_t* t42_encode_init ( t42_encode_state_t s,
uint32_t  image_width,
uint32_t  image_length,
t4_row_read_handler_t  handler,
void *  user_data 
)

Prepare to encode an image in T.42 format.

Parameters
sThe T.42 context.
image_widthImage width, in pixels.
image_lengthImage length, in pixels.
handlerA callback routine to handle encoded image rows.
user_dataAn opaque pointer passed to handler.
Returns
A pointer to the context, or NULL if there was a problem.

◆ t42_encode_release()

int t42_encode_release ( t42_encode_state_t s)

Release a T.42 encode context.

Parameters
sThe T.42 encode context.
Returns
0 for OK, else -1.

Referenced by t42_encode_free().

◆ t42_encode_restart()

int t42_encode_restart ( t42_encode_state_t s,
uint32_t  image_width,
uint32_t  image_length 
)

Restart a T.42 encode context.

Parameters
sThe T.42 context.
imageimage_width The image width, in pixels.
imageimage_width The image length, in pixels.
Returns
0 for success, otherwise -1.