spandsp 3.0.0
|
#include <inttypes.h>
#include <stdlib.h>
#include <limits.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <time.h>
#include <memory.h>
#include <string.h>
#include "spandsp/stdbool.h"
#include "floating_fudge.h"
#include <tiffio.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/bit_operations.h"
#include "spandsp/async.h"
#include "spandsp/timezone.h"
#include "spandsp/t4_rx.h"
#include "spandsp/t4_tx.h"
#include "spandsp/image_translate.h"
#include "spandsp/t81_t82_arith_coding.h"
#include "spandsp/t85.h"
#include "spandsp/t42.h"
#include "spandsp/t43.h"
#include "spandsp/t4_t6_decode.h"
#include "spandsp/t4_t6_encode.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 "spandsp/private/t43.h"
#include "spandsp/private/t4_t6_decode.h"
#include "spandsp/private/t4_t6_encode.h"
#include "spandsp/private/image_translate.h"
#include "spandsp/private/t4_rx.h"
#include "spandsp/private/t4_tx.h"
#include "faxfont.h"
Classes | |
struct | packer_t |
Macros | |
#define | CM_PER_INCH 2.54f |
Functions | |
int | t4_tx_next_page_has_different_format (t4_tx_state_t *s) |
Check for the existance of the next page, and whether its format is like the current one. This information can be needed before it is determined that the current page is finished with. More... | |
int | t4_tx_set_row_read_handler (t4_tx_state_t *s, t4_row_read_handler_t handler, void *user_data) |
Set the row read handler for a T.4 transmit context. More... | |
int | t4_tx_set_tx_image_format (t4_tx_state_t *s, int supported_compressions, int supported_image_sizes, int supported_bilevel_resolutions, int supported_colour_resolutions) |
Auto-select the format in which to send the image. More... | |
int | t4_tx_get_tx_compression (t4_tx_state_t *s) |
Get the compression for the encoded data. More... | |
int | t4_tx_get_tx_image_type (t4_tx_state_t *s) |
Get the image type of the encoded data. More... | |
int | t4_tx_get_tx_resolution (t4_tx_state_t *s) |
Get the X and Y resolution code of the current page. More... | |
int | t4_tx_get_tx_x_resolution (t4_tx_state_t *s) |
Get the column-to-column (x) resolution of the current page. More... | |
int | t4_tx_get_tx_y_resolution (t4_tx_state_t *s) |
Get the row-to-row (y) resolution of the current page. More... | |
int | t4_tx_get_tx_image_width (t4_tx_state_t *s) |
Get the width of the encoded data. More... | |
int | t4_tx_get_tx_image_width_code (t4_tx_state_t *s) |
Get the width code of the encoded data. More... | |
void | t4_tx_set_min_bits_per_row (t4_tx_state_t *s, int bits) |
Set the minimum number of encoded bits per row. This allows the makes the encoding process to be set to comply with the minimum row time specified by a remote receiving machine. More... | |
void | t4_tx_set_max_2d_rows_per_1d_row (t4_tx_state_t *s, int max) |
Set the maximum number of 2D encoded rows between 1D encoded rows. This is only valid for T.4 2D encoding. More... | |
void | t4_tx_set_header_overlays_image (t4_tx_state_t *s, bool header_overlays_image) |
Set page header overlay mode. More... | |
void | t4_tx_set_local_ident (t4_tx_state_t *s, const char *ident) |
Set the identity of the local machine, for inclusion in page headers. More... | |
void | t4_tx_set_header_info (t4_tx_state_t *s, const char *info) |
Set the header info. More... | |
void | t4_tx_set_header_tz (t4_tx_state_t *s, struct tz_s *tz) |
Set the header timezone. More... | |
int | t4_tx_get_pages_in_file (t4_tx_state_t *s) |
Get the number of pages in the file. More... | |
int | t4_tx_get_current_page_in_file (t4_tx_state_t *s) |
Get the currnet page number in the file. More... | |
void | t4_tx_get_transfer_statistics (t4_tx_state_t *s, t4_stats_t *t) |
Get the current transfer statistics. More... | |
int | t4_tx_image_complete (t4_tx_state_t *s) |
Return the next bit of the current document page, without actually moving forward in the buffer. The document will be padded for the current minimum scan line time. More... | |
int | t4_tx_get_bit (t4_tx_state_t *s) |
Get the next bit of the current document page. The document will be padded for the current minimum scan line time. More... | |
int | t4_tx_get (t4_tx_state_t *s, uint8_t buf[], size_t max_len) |
Get the next chunk of the current document page. The document will be padded for the current minimum scan line time. More... | |
int | t4_tx_start_page (t4_tx_state_t *s) |
Prepare to send the next page of the current document. More... | |
int | t4_tx_restart_page (t4_tx_state_t *s) |
Prepare the current page for a resend. More... | |
int | t4_tx_end_page (t4_tx_state_t *s) |
Complete the sending of a page. More... | |
logging_state_t * | t4_tx_get_logging_state (t4_tx_state_t *s) |
Get the logging context associated with a T.4 transmit context. More... | |
t4_tx_state_t * | t4_tx_init (t4_tx_state_t *s, const char *file, int start_page, int stop_page) |
Prepare for transmission of a document. More... | |
int | t4_tx_release (t4_tx_state_t *s) |
End the transmission of a document. Tidy up and close the file. This should be used to end T.4 transmission started with t4_tx_init. More... | |
int | t4_tx_free (t4_tx_state_t *s) |
End the transmission of a document. Tidy up, close the file and free the context. This should be used to end T.4 transmission started with t4_tx_init. More... | |
#define CM_PER_INCH 2.54f |
The number of centimetres in one inch
int t4_tx_end_page | ( | t4_tx_state_t * | s | ) |
Complete the sending of a page.
s | The T.4 context. |
References t4_tx_state_s::current_page.
int t4_tx_free | ( | t4_tx_state_t * | s | ) |
End the transmission of a document. Tidy up, close the file and free the context. This should be used to end T.4 transmission started with t4_tx_init.
s | The T.4 context. |
References t4_tx_release().
int t4_tx_get | ( | t4_tx_state_t * | s, |
uint8_t | buf[], | ||
size_t | max_len | ||
) |
Get the next chunk of the current document page. The document will be padded for the current minimum scan line time.
s | The T.4 context. |
buf | The buffer into which the chunk is to written. |
max_len | The maximum length of the chunk. |
int t4_tx_get_bit | ( | t4_tx_state_t * | s | ) |
Get the next bit of the current document page. The document will be padded for the current minimum scan line time.
s | The T.4 context. |
References SIG_STATUS_END_OF_DATA, and t4_t6_encode_get_bit().
int t4_tx_get_current_page_in_file | ( | t4_tx_state_t * | s | ) |
Get the currnet page number in the file.
s | The T.4 context. |
References t4_tx_state_s::current_page.
logging_state_t * t4_tx_get_logging_state | ( | t4_tx_state_t * | s | ) |
Get the logging context associated with a T.4 transmit context.
Get the logging context associated with a T.4 transmit context.
s | The T.4 transmit context. |
References t4_tx_state_s::logging.
int t4_tx_get_pages_in_file | ( | t4_tx_state_t * | s | ) |
Get the number of pages in the file.
s | The T.4 context. |
References t4_tx_tiff_state_t::file, and t4_tx_state_s::tiff.
void t4_tx_get_transfer_statistics | ( | t4_tx_state_t * | s, |
t4_stats_t * | t | ||
) |
Get the current transfer statistics.
Get the current image transfer statistics.
s | The T.4 context. |
t | A pointer to a statistics structure. |
References t4_tx_metadata_t::compression, t4_stats_t::compression, t4_tx_state_s::current_page, t4_tx_tiff_state_t::image_length, t4_stats_t::image_length, t4_tx_tiff_state_t::image_type, t4_tx_metadata_t::image_type, t4_stats_t::image_type, t4_tx_tiff_state_t::image_width, t4_stats_t::image_width, t4_stats_t::image_x_resolution, t4_stats_t::image_y_resolution, t4_stats_t::length, t4_stats_t::line_image_size, t4_tx_state_s::metadata, t4_tx_tiff_state_t::pages_in_file, t4_stats_t::pages_in_file, t4_stats_t::pages_transferred, t4_tx_state_s::start_page, T4_COMPRESSION_SYCC_T81, T4_COMPRESSION_T42_T81, T4_COMPRESSION_T4_1D, T4_COMPRESSION_T4_2D, T4_COMPRESSION_T6, T4_COMPRESSION_T85, T4_COMPRESSION_T85_L0, T4_COMPRESSION_T88, t4_t6_encode_get_compressed_image_size(), t4_t6_encode_get_image_length(), t4_t6_encode_get_image_width(), t85_encode_get_compressed_image_size(), t85_encode_get_image_length(), t85_encode_get_image_width(), t4_tx_state_s::tiff, t4_stats_t::type, t4_stats_t::width, t4_tx_tiff_state_t::x_resolution, t4_tx_metadata_t::x_resolution, t4_stats_t::x_resolution, t4_tx_tiff_state_t::y_resolution, t4_tx_metadata_t::y_resolution, and t4_stats_t::y_resolution.
int t4_tx_get_tx_compression | ( | t4_tx_state_t * | s | ) |
Get the compression for the encoded data.
s | The T.4 context. |
References t4_tx_metadata_t::compression, and t4_tx_state_s::metadata.
int t4_tx_get_tx_image_type | ( | t4_tx_state_t * | s | ) |
Get the image type of the encoded data.
s | The T.4 context. |
References t4_tx_metadata_t::image_type, and t4_tx_state_s::metadata.
int t4_tx_get_tx_image_width | ( | t4_tx_state_t * | s | ) |
Get the width of the encoded data.
s | The T.4 context. |
References t4_tx_metadata_t::image_width, and t4_tx_state_s::metadata.
int t4_tx_get_tx_image_width_code | ( | t4_tx_state_t * | s | ) |
Get the width code of the encoded data.
s | The T.4 context. |
References t4_tx_state_s::metadata, and t4_tx_metadata_t::width_code.
int t4_tx_get_tx_resolution | ( | t4_tx_state_t * | s | ) |
Get the X and Y resolution code of the current page.
s | The T.4 context. |
References t4_tx_state_s::metadata, and t4_tx_metadata_t::resolution_code.
int t4_tx_get_tx_x_resolution | ( | t4_tx_state_t * | s | ) |
Get the column-to-column (x) resolution of the current page.
s | The T.4 context. |
References t4_tx_state_s::metadata, and t4_tx_metadata_t::x_resolution.
int t4_tx_get_tx_y_resolution | ( | t4_tx_state_t * | s | ) |
Get the row-to-row (y) resolution of the current page.
s | The T.4 context. |
References t4_tx_state_s::metadata, and t4_tx_metadata_t::y_resolution.
int t4_tx_image_complete | ( | t4_tx_state_t * | s | ) |
Return the next bit of the current document page, without actually moving forward in the buffer. The document will be padded for the current minimum scan line time.
s | The T.4 context. |
References t4_tx_metadata_t::compression, t4_tx_state_s::metadata, SIG_STATUS_END_OF_DATA, t42_encode_image_complete(), t43_encode_image_complete(), T4_COMPRESSION_SYCC_T81, T4_COMPRESSION_T42_T81, T4_COMPRESSION_T43, T4_COMPRESSION_T45, T4_COMPRESSION_T4_1D, T4_COMPRESSION_T4_2D, T4_COMPRESSION_T6, T4_COMPRESSION_T85, T4_COMPRESSION_T85_L0, T4_COMPRESSION_T88, t4_t6_encode_image_complete(), and t85_encode_image_complete().
t4_tx_state_t * t4_tx_init | ( | t4_tx_state_t * | s, |
const char * | file, | ||
int | start_page, | ||
int | stop_page | ||
) |
Prepare for transmission of a document.
s | The T.4 context. |
file | The name of the file to be sent. |
start_page | The first page to send. -1 for no restriction. |
stop_page | The last page to send. -1 for no restriction. |
int t4_tx_next_page_has_different_format | ( | t4_tx_state_t * | s | ) |
Check for the existance of the next page, and whether its format is like the current one. This information can be needed before it is determined that the current page is finished with.
s | The T.4 context. |
References t4_tx_state_s::logging, and span_log().
int t4_tx_release | ( | t4_tx_state_t * | s | ) |
End the transmission of a document. Tidy up and close the file. This should be used to end T.4 transmission started with t4_tx_init.
s | The T.4 context. |
References t4_tx_tiff_state_t::file, and t4_tx_state_s::tiff.
Referenced by t4_tx_free().
int t4_tx_restart_page | ( | t4_tx_state_t * | s | ) |
Prepare the current page for a resend.
s | The T.4 context. |
References t4_tx_start_page().
void t4_tx_set_header_info | ( | t4_tx_state_t * | s, |
const char * | info | ||
) |
Set the header info.
Set the info field, included in the header line included in each page of an encoded FAX. This is a string of up to 50 characters. Other information (date, local ident, etc.) are automatically included in the header. If the header info is set to NULL or a zero length string, no header lines will be added to the encoded FAX.
s | The T.4 context. |
info | A string, of up to 50 bytes, which will form the info field. |
References t4_tx_state_s::header_info.
void t4_tx_set_header_overlays_image | ( | t4_tx_state_t * | s, |
bool | header_overlays_image | ||
) |
Set page header overlay mode.
Set page header extends or overlays the image mode.
s | The T.4 context. |
header_overlays_image | True for overlay, or false to extend the page. |
References t4_tx_state_s::header_overlays_image.
Referenced by t30_set_tx_page_header_overlays_image().
void t4_tx_set_header_tz | ( | t4_tx_state_t * | s, |
tz_t * | tz | ||
) |
Set the header timezone.
Set the time zone for the time stamp in page header lines. If this function is not used the current time zone of the program's environment is used.
s | The T.4 context. |
tz | A time zone descriptor. |
References t4_tx_state_s::tz.
void t4_tx_set_local_ident | ( | t4_tx_state_t * | s, |
const char * | ident | ||
) |
Set the identity of the local machine, for inclusion in page headers.
s | The T.4 context. |
ident | The identity string. |
References t4_tx_state_s::local_ident.
void t4_tx_set_max_2d_rows_per_1d_row | ( | t4_tx_state_t * | s, |
int | max | ||
) |
Set the maximum number of 2D encoded rows between 1D encoded rows. This is only valid for T.4 2D encoding.
s | The T.4 context. |
max | The maximum number of 2D rows. |
References t4_tx_metadata_t::compression, t4_tx_state_s::metadata, T4_COMPRESSION_T4_1D, T4_COMPRESSION_T4_2D, T4_COMPRESSION_T6, and t4_t6_encode_set_max_2d_rows_per_1d_row().
void t4_tx_set_min_bits_per_row | ( | t4_tx_state_t * | s, |
int | bits | ||
) |
Set the minimum number of encoded bits per row. This allows the makes the encoding process to be set to comply with the minimum row time specified by a remote receiving machine.
s | The T.4 context. |
bits | The minimum number of bits per row. |
int t4_tx_set_row_read_handler | ( | t4_tx_state_t * | s, |
t4_row_read_handler_t | handler, | ||
void * | user_data | ||
) |
Set the row read handler for a T.4 transmit context.
s | The T.4 transmit context. |
handler | A pointer to the handler routine. |
user_data | An opaque pointer passed to the handler routine. |
References t4_tx_state_s::row_handler, and t4_tx_state_s::row_handler_user_data.
int t4_tx_set_tx_image_format | ( | t4_tx_state_t * | s, |
int | supported_compressions, | ||
int | supported_image_sizes, | ||
int | supported_bilevel_resolutions, | ||
int | supported_colour_resolutions | ||
) |
Auto-select the format in which to send the image.
s | The T.4 context. |
supported_compressions | The set of compressions supported for this transmission |
supported_image_sizes | The set of image sizes supported for this transmission |
supported_bilevel_resolutions | The set of bi-level resolutions supported for this transmission |
supported_colour_resolutions | The set of gray scale and colour resolutions supported for this transmission |
int t4_tx_start_page | ( | t4_tx_state_t * | s | ) |
Prepare to send the next page of the current document.
s | The T.4 context. |
References t4_tx_state_s::logging, and span_log().
Referenced by t4_tx_restart_page().