t4_t6_encode.c File Reference

#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 <tgmath.h>
#include <math.h>
#include "floating_fudge.h"
#include <tiffio.h>
#include "spandsp/telephony.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/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/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"

Classes

struct  t4_run_table_entry_t

Defines

#define EOLS_TO_END_T4_TX_PAGE   6
#define EOLS_TO_END_T6_TX_PAGE   2
#define STATE_TRACE(...)
#define pixel_is_black(x, bit)   (((x)[(bit) >> 3] << ((bit) & 7)) & 0x80)

Functions

int t4_t6_encode_image_complete (t4_t6_encode_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.
int t4_t6_encode_get_bit (t4_t6_encode_state_t *s)
 Get the next bit of the current image. The image will be padded for the current minimum scan line time.
int t4_t6_encode_get (t4_t6_encode_state_t *s, uint8_t buf[], int max_len)
 Get the next chunk of the current document page. The document will be padded for the current minimum scan line time.
int t4_t6_encode_set_row_read_handler (t4_t6_encode_state_t *s, t4_row_read_handler_t handler, void *user_data)
 Set the row read handler for a T.4/T.6 encode context.
int t4_t6_encode_set_encoding (t4_t6_encode_state_t *s, int encoding)
 Set the encoding for the encoded data.
void t4_t6_encode_set_min_bits_per_row (t4_t6_encode_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.
int t4_t6_encode_set_image_width (t4_t6_encode_state_t *s, int image_width)
 Set the width of the image.
uint32_t t4_t6_encode_get_image_width (t4_t6_encode_state_t *s)
 Get the width of the image.
uint32_t t4_t6_encode_get_image_length (t4_t6_encode_state_t *s)
 Get the length of the image.
int t4_t6_encode_get_compressed_image_size (t4_t6_encode_state_t *s)
 Get the size of the compressed image, in bits.
void t4_t6_encode_set_max_2d_rows_per_1d_row (t4_t6_encode_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.
int t4_t6_encode_restart (t4_t6_encode_state_t *s, int image_width)
 Restart a T.4 or T.6 encode context.
t4_t6_encode_state_tt4_t6_encode_init (t4_t6_encode_state_t *s, int encoding, int image_width, t4_row_read_handler_t handler, void *user_data)
 Prepare to encode an image in T.4 or T.6 format.
int t4_t6_encode_release (t4_t6_encode_state_t *s)
int t4_t6_encode_free (t4_t6_encode_state_t *s)

Detailed Description


Define Documentation

#define EOLS_TO_END_T4_TX_PAGE   6

The number of EOLs to be sent at the end of a T.4 page

#define EOLS_TO_END_T6_TX_PAGE   2

The number of EOLs to be sent at the end of a T.6 page


Function Documentation

int t4_t6_encode_get ( t4_t6_encode_state_t s,
uint8_t  buf[],
int  max_len 
)

Get the next chunk of the current document page. The document will be padded for the current minimum scan line time.

Parameters:
s The T.4/T.6 context.
buf The buffer into which the chunk is to written.
max_len The maximum length of the chunk.
Returns:
The actual length of the chunk. If this is less than max_len it indicates that the end of the document has been reached.

Referenced by t4_tx_get().

int t4_t6_encode_get_bit ( t4_t6_encode_state_t s  ) 

Get the next bit of the current image. The image will be padded for the current minimum scan line time.

Parameters:
s The T.4/T.6 context.
Returns:
The next bit (i.e. 0 or 1). SIG_STATUS_END_OF_DATA for no more data.

References SIG_STATUS_END_OF_DATA.

Referenced by t4_tx_get_bit().

int t4_t6_encode_get_compressed_image_size ( t4_t6_encode_state_t s  ) 

Get the size of the compressed image, in bits.

Parameters:
s The T.4/T.6 context.
Returns:
The size of the compressed image, in bits.

Referenced by t4_tx_get_transfer_statistics().

uint32_t t4_t6_encode_get_image_length ( t4_t6_encode_state_t s  ) 

Get the length of the image.

Parameters:
s The T.4/T.6 context.
Returns:
The length of the image, in pixels.

Referenced by t4_tx_get_transfer_statistics().

uint32_t t4_t6_encode_get_image_width ( t4_t6_encode_state_t s  ) 

Get the width of the image.

Parameters:
s The T.4/T.6 context.
Returns:
The width of the image, in pixels.

Referenced by t4_tx_get_transfer_statistics().

int t4_t6_encode_image_complete ( t4_t6_encode_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.

Parameters:
s The T.4/T.6 context.
Returns:
0 for more data to come. SIG_STATUS_END_OF_DATA for no more data.

References SIG_STATUS_END_OF_DATA.

Referenced by t4_tx_image_complete().

t4_t6_encode_state_t* t4_t6_encode_init ( t4_t6_encode_state_t s,
int  encoding,
int  image_width,
t4_row_read_handler_t  handler,
void *  user_data 
)

Prepare to encode an image in T.4 or T.6 format.

Parameters:
s The T.4/T.6 context.
encoding The encoding mode.
image width The image width, in pixels.
handler A callback routine to handle decoded image rows.
user_data An opaque pointer passed to handler.
Returns:
A pointer to the context, or NULL if there was a problem.

References t4_t6_encode_restart().

Referenced by t4_tx_set_tx_encoding().

int t4_t6_encode_restart ( t4_t6_encode_state_t s,
int  image_width 
)

Restart a T.4 or T.6 encode context.

Parameters:
s The T.4/T.6 context.
image width The image width, in pixels.
Returns:
0 for success, otherwise -1.

References T4_COMPRESSION_ITU_T6, and t4_t6_encode_set_image_width().

Referenced by t4_t6_encode_init(), and t4_tx_start_page().

int t4_t6_encode_set_encoding ( t4_t6_encode_state_t s,
int  encoding 
)

Set the encoding for the encoded data.

Parameters:
s The T.4/T.6 context.
encoding The encoding.
Returns:
0 for success, otherwise -1.

References T4_COMPRESSION_ITU_T4_1D, T4_COMPRESSION_ITU_T4_2D, and T4_COMPRESSION_ITU_T6.

Referenced by t4_tx_set_tx_encoding().

int t4_t6_encode_set_image_width ( t4_t6_encode_state_t s,
int  image_width 
)

Set the width of the image.

Parameters:
s The T.4/T.6 context.
image_width The image width, in pixels.
Returns:
0 for success, otherwise -1.

Referenced by t4_t6_encode_restart(), and t4_tx_set_image_width().

void t4_t6_encode_set_max_2d_rows_per_1d_row ( t4_t6_encode_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.

Parameters:
s The T.4/T.6 context.
max The "K" parameter defined in the T.4 specification. This means the value is one greater than the maximum number of 2D rows between each 1D row.

Referenced by t4_tx_set_max_2d_rows_per_1d_row(), and t4_tx_set_tx_encoding().

void t4_t6_encode_set_min_bits_per_row ( t4_t6_encode_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.

Parameters:
s The T.4/T.6 context.
bits The minimum number of bits per row.

Referenced by t4_tx_set_min_bits_per_row().

int t4_t6_encode_set_row_read_handler ( t4_t6_encode_state_t s,
t4_row_read_handler_t  handler,
void *  user_data 
)

Set the row read handler for a T.4/T.6 encode context.

Parameters:
s The T.4/T.6 context.
handler A pointer to the handler routine.
user_data An opaque pointer passed to the handler routine.
Returns:
0 for success, otherwise -1.

Generated on 15 Sep 2012 for spandsp by  doxygen 1.6.1