spandsp 3.0.0
|
#include <stdlib.h>
#include <inttypes.h>
#include <limits.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <time.h>
#include <memory.h>
#include <string.h>
#include <float.h>
#include "spandsp/stdbool.h"
#include "floating_fudge.h"
#include <tiffio.h>
#include <assert.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/fast_convert.h"
#include "spandsp/logging.h"
#include "spandsp/saturated.h"
#include "spandsp/async.h"
#include "spandsp/timezone.h"
#include "spandsp/t4_rx.h"
#include "spandsp/t4_tx.h"
#include "spandsp/t81_t82_arith_coding.h"
#include "spandsp/t85.h"
#include "spandsp/t42.h"
#include "spandsp/private/logging.h"
#include "spandsp/private/t81_t82_arith_coding.h"
#include "spandsp/private/t85.h"
#include "spandsp/private/t42.h"
#include "t42_t43_local.h"
#include "cielab_luts.h"
Classes | |
struct | cielab_t |
struct | illuminant_t |
struct | UVT |
Macros | |
#define | T42_USE_LUTS |
#define | LERP(a, b, c) (((b) - (a))*(c) + (a)) |
Typedefs | |
typedef struct UVT | UVT |
Functions | |
bool | t42_analyse_header (uint32_t *width, uint32_t *length, const uint8_t data[], size_t len) |
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 | set_lab_illuminant (lab_params_t *lab, float new_xn, float new_yn, float new_zn) |
void | set_lab_gamut (lab_params_t *lab, 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 *lab, 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 *lab, int *L_P, int *L_Q, int *a_P, int *a_Q, int *b_P, int *b_Q) |
int | set_illuminant_from_code (logging_state_t *logging, lab_params_t *lab, const uint8_t code[4]) |
void | set_gamut_from_code (logging_state_t *logging, lab_params_t *s, const uint8_t code[12]) |
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. | |
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. | |
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 image_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. | |
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. | |
int | t42_encode_set_row_read_handler (t42_encode_state_t *s, t4_row_read_handler_t handler, void *user_data) |
logging_state_t * | t42_encode_get_logging_state (t42_encode_state_t *s) |
Get the logging context associated with a T.42 encode context. | |
int | t42_encode_restart (t42_encode_state_t *s, uint32_t image_width, uint32_t image_length) |
Restart a T.42 encode context. | |
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. | |
int | t42_encode_release (t42_encode_state_t *s) |
Release a T.42 encode context. | |
int | t42_encode_free (t42_encode_state_t *s) |
Free a T.42 encode context. | |
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. | |
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. | |
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. | |
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. | |
uint32_t | t42_decode_get_image_width (t42_decode_state_t *s) |
Get the width of the image. | |
uint32_t | t42_decode_get_image_length (t42_decode_state_t *s) |
Get the length of the image. | |
int | t42_decode_get_compressed_image_size (t42_decode_state_t *s) |
Get the size of the compressed image in bits. | |
logging_state_t * | t42_decode_get_logging_state (t42_decode_state_t *s) |
Get the logging context associated with a T.42 decode context. | |
int | t42_decode_restart (t42_decode_state_t *s) |
Restart a T.42 decode context. | |
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. | |
int | t42_decode_release (t42_decode_state_t *s) |
Release a T.42 decode context. | |
int | t42_decode_free (t42_decode_state_t *s) |
Free a T.42 decode context. | |
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.
s | The Lab parameters context. |
srgb | The output pixels |
lab | The input pixels |
pixel | The number of pixels in the row. |
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.
s | The Lab parameters context. |
lab | The output pixels |
srgb | The input pixels |
pixel | The number of pixels in the row. |
int t42_decode_free | ( | t42_decode_state_t * | s | ) |
Free a T.42 decode context.
s | The T.42 decode context. |
References t42_decode_release().
int t42_decode_get_compressed_image_size | ( | t42_decode_state_t * | s | ) |
Get the size of the compressed image in bits.
s | The T.42 context. |
References t42_decode_state_s::compressed_image_size.
Referenced by t4_rx_get_transfer_statistics().
uint32_t t42_decode_get_image_length | ( | t42_decode_state_t * | s | ) |
Get the length of the image.
s | The T.42 context. |
Referenced by t4_rx_end_page(), and t4_rx_get_transfer_statistics().
uint32_t t42_decode_get_image_width | ( | t42_decode_state_t * | s | ) |
Get the width of the image.
s | The T.42 context. |
Referenced by t4_rx_get_transfer_statistics().
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.
s | The T.42 decode context. |
References t42_decode_state_s::logging.
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.
s | The T.42 context. |
handler | A callback routine to handle decoded image rows. |
user_data | An opaque pointer passed to handler. |
References t42_decode_state_s::logging, t42_decode_state_s::row_write_handler, t42_decode_state_s::row_write_user_data, and t42_decode_restart().
Referenced by t4_rx_set_rx_encoding().
int t42_decode_put | ( | t42_decode_state_t * | s, |
const uint8_t | data[], | ||
size_t | len ) |
Decode a chunk of T.42 data.
s | The T.42 context. |
data | The data to be decoded. |
len | The length of the data to be decoded. |
References t42_decode_state_s::compressed_image_size, t42_decode_state_s::end_of_data, t42_decode_state_s::logging, span_log(), and T4_DECODE_OK.
Referenced by t4_rx_start_page().
int t42_decode_release | ( | t42_decode_state_t * | s | ) |
Release a T.42 decode context.
s | The T.42 decode context. |
References t42_decode_state_s::comment.
Referenced by t42_decode_free().
int t42_decode_restart | ( | t42_decode_state_t * | s | ) |
Restart a T.42 decode context.
s | The T.42 context. |
References t42_decode_state_s::compressed_image_size, and t42_decode_state_s::end_of_data.
Referenced by t42_decode_init(), and t4_rx_start_page().
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.
s | The T.42 context. |
max_comment_len | The maximum length of comment to be passed to the handler. |
handler | A callback routine to handle decoded comment. |
user_data | An opaque pointer passed to handler. |
References t42_decode_state_s::comment_handler, t42_decode_state_s::comment_user_data, and t42_decode_state_s::max_comment_len.
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.
s | The T.42 context. |
max_xd | The maximum permitted width of the full image, in pixels |
max_yd | The maximum permitted height of the full image, in pixels |
Referenced by t4_rx_set_rx_encoding().
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.
s | The T.42 context. |
handler | A callback routine to handle decoded image rows. |
user_data | An opaque pointer passed to handler. |
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().
int t42_encode_free | ( | t42_encode_state_t * | s | ) |
Free a T.42 encode context.
s | The T.42 encode context. |
References t42_encode_release().
int t42_encode_get_compressed_image_size | ( | t42_encode_state_t * | s | ) |
Get the size of the compressed image in bits.
s | The T.42 context. |
References t42_encode_state_s::compressed_image_size.
Referenced by t4_tx_get_transfer_statistics().
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.
s | The T.42 encode context. |
References t42_encode_state_s::logging.
int t42_encode_image_complete | ( | t42_encode_state_t * | s | ) |
Check if we are at the end of the current document page.
s | The T.42 context. |
Referenced by t4_tx_image_complete().
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.
s | The T.42 context. |
image_width | Image width, in pixels. |
image_length | Image length, in pixels. |
handler | A callback routine to handle encoded image rows. |
user_data | An opaque pointer passed to handler. |
References t42_encode_state_s::logging, t42_encode_state_s::row_read_handler, t42_encode_state_s::row_read_user_data, and t42_encode_restart().
Referenced by t4_tx_set_tx_image_format().
int t42_encode_release | ( | t42_encode_state_t * | s | ) |
Release a T.42 encode context.
s | The T.42 encode context. |
Referenced by t42_encode_free().
int t42_encode_restart | ( | t42_encode_state_t * | s, |
uint32_t | image_width, | ||
uint32_t | image_length ) |
Restart a T.42 encode context.
s | The T.42 context. |
image | image_width The image width, in pixels. |
image | image_width The image length, in pixels. |
References t42_encode_state_s::compressed_image_size, t42_encode_state_s::logging, and span_log().
Referenced by t42_encode_init(), and t4_tx_start_page().