Structured Fax File Format Description

Valid XHTML 1.0!


Contents:

Introduction
Data types
Document header
Page header
Page data
Modified Huffman Coding
List of references



Introduction

This article describe the format of a Structured Fax File.

An SFF-formatted document always starts with a header, which is valid for the complete document. Every page starts with a page header. This is followed by the pixel information, line by line.
Back to the table of contents


Data types

The following data type conventions are used:
Byte 8-bit unsigned integer
Word 16-bit unsigned integer, least significant octet first
DWord 32-bit unsigned integer, least significant word first
Back to the table of contents


Document header

Parameter Type Comment
SFF_Id DWord Magic number (identification) of SFF Format: coded as 0x66666653 ("Sfff").
Version Byte Version number of SFF document: coded 0x01.
reserved Byte Reserved for future extensions; coded 0x00.
User Information Word Manufacturer-specific user information (not used by COMMON-ISDN-API, coded as 0x0000).
Page Count Word Number of pages in the document. Must be coded 0x0000 if not known (as in the case of receiving a document).
OffsetFirstPageHeader Word Byte offset of first page header from start of document header. This value is normally equal to the size of the document header (0x14), but there could be additional userspecific data between the document header and the first page header. COMMON-ISDN-API ignores and does not provide such additional data.
OffsetLastPageHeader DWord Byte offset of last page header from start of document header. Must be coded 0x00000000 if not known (as in the case of receiving a document).
OffsetDocumentEnd DWord Byte offset of document end from start of document header. Must be coded 0x00000000 if not known (as in the case of receiving a document).
Back to the table of contents


Page header

Parameter Type Comment
PageHeaderID Byte 254 (Page data record type)
PageHeaderLen Byte 0: Document end
1...255: byte offset of first page data from the Resolution Vertical field of the page header. This value is normally equal to the size of the remainder of the header (0x10), but there may be additional user-specific data between page header and page data. COMMON-ISDN-API ignores and not provide such additional data.
Resolution Vertical Byte Definition of vertical resolution; different resolutions in one document may be ignored by COMMON-ISDN-API
0: 98 lpi (standard)
1: 196 lpi (high resolution)
2...254: reserved
255: End of document (should not be used: PageHeaderLen should be coded 0 instead)
Resolution Horizontal Byte Definition of horizontal resolution
0: 203 dpi (standard)
1...255: reserved
Coding Byte Definition of pixel line coding
0: Modified Huffman coding
1...255: reserved
reserved Byte Coded as 0
Line Length Word Number of pixels per line
1728: Standard G3 fax
2048: B4 (optional)
2432: A3 (optional)
Support for additional values is optional for COMMON-ISDN-API.
Page Length Word Number of pixel lines per page. If not known, coded as 0x0000.
OffsetPreviousPage DWord Byte offset to previous page header or 0x00000000. Coded as 0x00000001 if first page.
OffsetNextPage DWord Byte offset to next page header or 0x00000000. Coded as 0x00000001 if last page.
Back to the table of contents


Page data

Page data is coded line by line: data describes each pixel row. Lines are coded as records of variable length; each line is coded according to the element coding in the page header. At present, only modified Huffman coding is supported.

MH coding is bitoriented: the pixel bits are stored in the bits of code words, least significant first. No EOL code words or fill bits are included. If the data includes EOL code words, COMMON-ISDN-API ignores these.

Each record is identified by the first byte:
Back to the table of contents


Modified Huffman Coding

The bit stream start with bit 0 of the first data byte. The data coding the number of successive pixel with a specific color. The coding start with white color. Black and white are alternate, up to all pixels are decoded or the bit stream is ended. There are Make-up codes and Terminating codes. First is the Make-up code or not. Annotation: A application for decoding should handle more then one Make-up code in sequence. It exist exactly one Terminating code. After the Terminating code the color of pixel alter. The codes are differently for black and white. For line length more then 1728 pixel there are additional Make-up codes. This codes are equal for black and white.

Terminating codes
  white black
Value Code Length Code Length
000110101 80000110111 10
1000111 6010 3
20111 411 2
31000 410 2
41011 4011 3
51100 40011 4
61110 40010 4
71111 400011 5
810011 5000101 6
910100 5000100 6
1000111 50000100 7
1101000 50000101 7
12001000 60000111 7
13000011 600000100 8
14110100 600000111 8
15110101 6000011000 9
16101010 60000010111 10
17101011 60000011000 10
180100111 70000001000 10
190001100 700001100111 11
200001000 700001101000 11
210010111 700001101100 11
220000011 700000110111 11
230000100 700000101000 11
240101000 700000010111 11
250101011 700000011000 11
260010011 7000011001010 12
270100100 7000011001011 12
280011000 7000011001100 12
2900000010 8000011001101 12
3000000011 8000001101000 12
3100011010 8000001101001 12
3200011011 8000001101010 12
3300010010 8000001101011 12
3400010011 8000011010010 12
3500010100 8000011010011 12
3600010101 8000011010100 12
3700010110 8000011010101 12
3800010111 8000011010110 12
3900101000 8000011010111 12
4000101001 8000001101100 12
4100101010 8000001101101 12
4200101011 8000011011010 12
4300101100 8000011011011 12
4400101101 8000001010100 12
4500000100 8000001010101 12
4600000101 8000001010110 12
4700001010 8000001010111 12
4800001011 8000001100100 12
4901010010 8000001100101 12
5001010011 8000001010010 12
5101010100 8000001010011 12
5201010101 8000000100100 12
5300100100 8000000110111 12
5400100101 8000000111000 12
5501011000 8000000100111 12
5601011001 8000000101000 12
5701011010 8000001011000 12
5801011011 8000001011001 12
5901001010 8000000101011 12
6001001011 8000000101100 12
6100110010 8000001011010 12
6200110011 8000001100110 12
6300110100 8000001100111 12
EOL 000000000001 1200000000000 11

Make-up codes
  white black
Value Code Length Code Length
6411011 50000001111 10
12810010 5000011001000 12
192010111 6000011001001 12
2560110111 7000001011011 12
32000110110 8000000110011 12
38400110111 8000000110100 12
44801100100 8000000110101 12
51201100101 80000001101100 13
57601101000 80000001101101 13
64001100111 80000001001010 13
704011001100 90000001001011 13
768011001101 90000001001100 13
832011010010 90000001001101 13
896011010011 90000001110010 13
960011010100 90000001110011 13
1024011010101 90000001110100 13
1088011010110 90000001110101 13
1152011010111 90000001110110 13
1216011011000 90000001110111 13
1280011011001 90000001010010 13
1344011011010 90000001010011 13
1408011011011 90000001010100 13
1472010011000 90000001010101 13
1536010011001 90000001011010 13
1600010011010 90000001011011 13
1664011000 60000001100100 13
1728010011011 90000001100101 13

Additional Make-up codes
Value Code Length
179200000001000 11
185600000001100 11
192000000001101 11
1984000000010010 12
2048000000010011 12
2112000000010100 12
2176000000010101 12
2240000000010110 12
2304000000010111 12
2368000000011100 12
2432000000011101 12
2496000000011110 12
2560000000011111 12
Back to the table of contents


List of references

COMMON-ISDN-API (CAPI) Version 2 Part 1
TIFF (Tagged Image File Format) 6.0 Specification
Back to the table of contents

Mail me at webmaster@pjh2.de. Disclaimer