home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1997 December / Internet_Info_CD-ROM_Walnut_Creek_December_1997.iso / rfc / rfc803 < prev    next >
Text File  |  1991-04-21  |  33KB  |  717 lines

  1.  
  2.  
  3.  
  4.  
  5. RFC 803
  6.  
  7.  
  8.  
  9.           Dacom 450/500 Facsimile Data Transcoding
  10.          A. Agarwal, M. J. O'Connor and D. L. Mills
  11.                       2 November 1981
  12.  
  13.  
  14. 1.  Introduction
  15.  
  16.      As part of our effort in support of  the  DARPA  Internet  Program,
  17. software  modules  to encode and decode facsimile data for the Dacom 450
  18. and 500 models Computerfax facsimile  machines  have  been  constructed.
  19. The  purpose of these modules is to map the data representations used by
  20. these machines to and from bit-map  and  run-length  representations  in
  21. programs  for editing, transmission and archiving facsimile images.  The
  22. modules are written in the PDP-11 MACRO-11 assembly language and can  be
  23. incorporated into programs for, among others, the RT-11 operating system
  24. and the DCNET BOS or VOS operating systems.
  25.  
  26.      The first part of this report describes in  detail  the  Dacom  450
  27. data compression algorithm and is an update and correction to an earlier
  28. memorandum [2].  Following this, the encoding  and  decoding  algorithms
  29. are  described  along  with  the  supporting  programs and file formats.
  30. Reference  [3]  describes  another  implementation   of   the   decoding
  31. algorithm.   Grateful  acknowledgment  is made to E.  A.  Poe of Rapicom
  32. for his assistance in this effort.
  33.  
  34.      The second part of this report describes briefly the Dacom 500 data
  35. compression  algorithm  as used by the INTELPOST electronic-mail network
  36. under  development  by  the  US  Postal  Service  and  several   foreign
  37. administrations.    These  machines  conform  to  the  CCITT  T.4  Draft
  38. Recommendation, described in [5].  Supporting programs and file  formats
  39. are described.
  40.  
  41. 2.  Dacom 450 Data Compression Principles
  42.  
  43.      The encoding algorithm for the Dacom 450 processes lines scanned by
  44. the  machine  to  produce a two-dimensional run-length code described by
  45. Weber [1]; however,  this  article  contains  a  number  of  errors  and
  46. omissions,  many  of  which  were  discovered  only  after  considerable
  47. analysis  and  experimentation  [2,3].   The  machine  operates  over  a
  48. coordinate   space   of   l726   by  approximately  2200  pels  when  in
  49. high-resolution (detail) mode.  In normal (quality)  mode  the  vertical
  50. resolution is halved, so that about 1100 lines are transmitted, while in
  51. express mode about 733 lines are transmitted (missed lines are filled in
  52. on playback by replicating previous lines).
  53.  
  54.      Data are encoded  two  rows  at  a  time  using  a  two-dimensional
  55. run-length  code.   Each  row-pair  is  scanned  left-to-right  and  the
  56. line-pairs themselves processed top-to-bottom of the document.  Figure 1
  57. shows how the pels are represented.
  58.  
  59. Dacom 450/500 Facsimile Data Transcoding                        PAGE   2
  60.  
  61.  
  62.  
  63.                     |          |          |
  64.                 ----+----------+----------+----
  65.                 ... |  x(1,j)  | x(1,j+1) | ...
  66.                 ----+----------+----------+----
  67.                 ... |  x(2,j)  | x(2,j+1) | ...
  68.                 ----+----------+----------+----
  69.                     |          |          |
  70.                       Direction of scan ->
  71.  
  72.                Figure 1. Data Representation
  73.  
  74.      For each j the vector (x(1,j),x(2,j)) represents  the  contents  of
  75. the  jth  column, where x(i,j) can take on values of zero (white) or one
  76. (black).  Each of the four possible vectors ranging  over  these  values
  77. will  be  called a state (Dacom calls these "modes") with the succession
  78. of transitions between these states determined by the picture content of
  79. the  particular line-pair.  Scanning of the line-pairs follows one after
  80. the other with no special end-of-line code in the data itself.  For  the
  81. purpose  of later discussion and comparison with the published data, the
  82. following conventions will be used (note: the pels read top-bottom):
  83.  
  84.                 Pels    Vector  State
  85.                 ---------------------   
  86.                 W-W     (0,0)   0
  87.                 B-W     (1,0)   1
  88.                 W-B     (0,1)   2
  89.                 B-B     (1,1)   3
  90.  
  91.      The algorithm used by Dacom to generate the transmitted data as the
  92. columns   are   scanned   can  be  described  as  the  non-deterministic
  93. finite-state automaton (nfsa) shown in Figure 2.  Conceptually, the nfsa
  94. starts  at  the beginning of a page in a designated state and at a point
  95. just after scanning the jth column in the jth state.  It then scans  the
  96. (j + 1)th column and enters that state while emitting the string of bits
  97. shown in the figure.
  98.  
  99.      In the states corresponding to  W-W  (0)  and  B-B  (3)  a  special
  100. run-length  encoding  techniques is used.  There are two state variables
  101. associated with each of  these  two  states,  one  variable  used  as  a
  102. run-length  counter  and  the  other  the field length (in bits) of this
  103. counter.  Upon each entry to either of these two states the  counter  is
  104. initialized  at  zero  and  counts up for every additional column of the
  105. same state.  At the end  of  the  run  the  value  of  this  counter  is
  106. transmitted  extending  with high-order zeros, if necessary, to fill the
  107. field length specified.  If, however, the counter equals 2**n - 1, where
  108. n  is the field length, then a sequence of n one-bits is emitted and the
  109. counter re-initialized at zero with a field length of n + 1.   Thus,  if
  110. n = 3, a run length of three is transmitted as {010} and a run length of
  111. seven as {110}, while a run length of eight as two words, {111} followed
  112. by  {0000}.   The  field-length  variables are maintained separately for
  113. both the W-W and B-B states, and at each re-entry  to  either  of  these
  114. states the previous values are used.
  115.  
  116. Dacom 450/500 Facsimile Data Transcoding                        PAGE   3
  117.  
  118.  
  119.  
  120.   
  121.                                  0100
  122.            .--------------------->----------------------------------.
  123.            |                                                        |
  124.            |   .-----------------<------------------------------.   |
  125.            |   |                1                               |   |
  126.            |   V                                                |   |
  127.      .--------------.                     .---------------.     |   |
  128.      |              |                     |               |     |   |
  129.      |              |        010          |               |     |   |
  130.   .->|      1       |-------------------->|       2       |->.  |   |
  131.   |  |              |                     |               |  |  |   |
  132.  0|  |     B-W      |        101          |      W-B      |  |1 |   |
  133.   \<-|              |<--------------------|               |<-'  |   |
  134.      |              |                     |               |     |   |
  135.      |              |               .---->|               |     |   |
  136.      \--------------'               |     \---------------'     |   |
  137.          |   A                      |      |     |   A          |   |
  138.          |   |     .--------->------'      |     |   |          |   |
  139.          |   |     |         1             |     |   |          |   |
  140.          |   |     |                       |     |   |          A   V
  141.          |   |     |                       |     |   |          |   |
  142.      0111|   |1    |                       | 1000|   |1         |   |
  143.          |   |     |                       |     |   |          |   |
  144.          |   |     |                       |     |   |          |   |
  145.          |   |     |                       |     |   |          |   |
  146.          |   |     |          1011         |     |   |          |   |
  147.          |   |     |    .-------<----------'     |   |          |   |
  148.          V   |     |    |                        V   |          |   |
  149.      .--------------.   |                 .---------------.     |   |
  150.      |              |<--'                 |               |     |   |
  151.      |              |        0            |               |     |   |
  152.      |      3       |<--------------------|       0       |-----'   |
  153.      |              |                     |               |         |
  154.      |     B-B      |                     |      W-W      |         |
  155.      |              |-------------------->|               |<--------'
  156.      |              |        0            |               |
  157.      |              |                     |               |
  158.      \--------------'                     \---------------'
  159.          |    A                                 |    A
  160.          |    |                                 |    |
  161.          \----'                                 \----'
  162.           run                                    run
  163.     
  164.                 Figure 2.  NFSA Model of Encoding 
  165.     
  166.  
  167. Dacom 450/500 Facsimile Data Transcoding                        PAGE   4
  168.  
  169.  
  170.  
  171.      Field-length values are constrained not to exceed  seven,  so  that
  172. runs  exceeding  l27 with n = 7 will be encoded as a separate 7-bit word
  173. of one-bits for each run of l27  except  the  last,  which  must  always
  174. contain  at  least one zero-bit.  The field length n is decreased by one
  175. under the following circumstances: the current run has been encoded as a
  176. single  n-bit  field,  and for n in the range four through seven the two
  177. high-order bits are zero or for n equal to three the  single  high-order
  178. bit  is  zero.   The field length is not allowed to be reduced below two
  179. bits.
  180.  
  181.      The encoding algorithm starts in state 0 with  both  field  lengths
  182. set to 7.
  183.  
  184. 2.1.  Dacom 450 Decoding Algorithm
  185.  
  186.      For reasons of speed and simplicity it is desirable that the  Dacom
  187. 450  decoding  algorithm  be  modeled  on  the  basis of a deterministic
  188. finite-state automaton (dfsa).  Using straightforward formal procedures,
  189. the  dfsa  of Figure 3 can be constructed.  This machine makes one state
  190. transition for every bit, except for the W-W (0)  and  B-B  (3)  states,
  191. which  must be treated specially in any case.  The states are labeled in
  192. such a way as to correspond to those of Figure  2  for  states  numbered
  193. from zero to three.
  194.  
  195.      The decoded output symbols, in this case the columns  corresponding
  196. to  each  of the states, are represented by the states themselves.  Upon
  197. entry to state B-W (1) or W-B (2) a run-length counter is initialized to
  198. one.   Each  traversal  of a loop back to the same state increments this
  199. counter and, upon exit to any other state, the  value  of  this  counter
  200. represents  the  number  of columns to be produced.  Upon entry to state
  201. W-W (0) or B-B (3) the run-length counter is initialized to zero and the
  202. associated   field-length   state  variable  n  established.   For  each
  203. successive n bits of all-ones, the counter is increased by 2**n - 1  and
  204. then n itself increased by one, but not above seven.  If the next n bits
  205. are not all ones, then the counter is increased by the value represented
  206. by the n-bit field plus one.  Finally, if upon entry to either state the
  207. next n bits are not all ones, n is decreased by  one  according  to  the
  208. rule mentioned in the preceding section.
  209.  
  210. Dacom 450/500 Facsimile Data Transcoding                        PAGE   5
  211.  
  212.  
  213.  
  214.     
  215.         
  216.      
  217.      
  218.         .-----------.                     .-----------.
  219.   .-----|           |                     |           |-----.
  220.   |     |     9     |                     |     6     |     |
  221.   |   .-|           |<--.             .-->|           |-.   |
  222.   |   | \-----------'    \           /    \-----------' |   |
  223.  1|  0|                   \         /                   |1  |0
  224.   |   |    .->Error        \       /        Error<-.    |   |
  225.   |   |   0|                \     /                |1   |   |
  226.   |   | .-----------.        \   /        .-----------. |   |
  227.   | 1 | |           |         \ /         |           | | 0 |
  228.   | .---|     7     |          \          |    10     |---. |
  229.   | | | |           |         / \         |           | | | |
  230.   | | | \-----------'        /   \        \-----------' | | |
  231.   | | |       A             /     \             A       | | |
  232.   | | |       |            /       \            |       | | |
  233.   | | |      1|           /         \           |0      | | |
  234.   | | | .-----------.  0 /           \ 1  .-----------. | | |
  235.   | | | |           |---'             \---|           | | | |
  236.   | | | |     5     |                     |     8     | | | |
  237.   | | | |           |                     |           | | | |
  238.   | | | \-----------'                     \-----------' | | |
  239.   | | |       A                                 A       | | |
  240.   | | |       |                                 |       | | |
  241.   | | |      1|                                 |0      | | |
  242.   | | | .-----------.                     .-----------. | | |
  243.   | | ->|           |                     |           |<- | |
  244.   | |   |     1     |                     |     2     |   | |
  245.   | |   |    B-W    |<-----.       .----->|    W-B    |   | |
  246.   | |   \-----------'      |       |      \-----------'   | |
  247.   | |      |     A         |       |         A     |      | |
  248.   | |      |     |         |0     1|         |     |      | |
  249.   | |      \-----'         |       |         \-----'      | |
  250.   | |         0          .-----------.          0         | |
  251.   | |                    |           |                    | |
  252.   | |                    |     4     |                    | |
  253.   | |        RUN         |           |         RUN        | |
  254.   | |      .-----.       \-----------'       .-----.      | |
  255.   | |      |     |         A       A         |     |      | |
  256.   | |      |     V         |       |         V     |      | |
  257.   | |   .-----------.   1  |       |  1   .-----------.   | |
  258.   | \-->|           |------'   0   \------|           |<--' |
  259.   |     |     3     |<--------------------|     0     |     |
  260.   \---->|    B-B    |-------------------->|    W-W    |<----'
  261.         \-----------'          0          \-----------'      
  262.                          
  263.                 Figure 3.  DFSA Model of Encoding 
  264.  
  265. Dacom 450/500 Facsimile Data Transcoding                        PAGE   6
  266.  
  267.  
  268.  
  269. 2.2.  Formatting Considerations
  270.  
  271.      Data are encoded for transmission  by  the  Dacom  450  in  585-bit
  272. frames,  consisting  of  a  24-bit  synchronization code, 37-bit leader,
  273. 512-bit information area and l2-bit checksum.  There are  two  kinds  of
  274. frames  distinguished  by leader format, one for setup or initialization
  275. and the other for the data itself.  Serial binary image data are  placed
  276. in the data area of succeeding data frames.
  277.  
  278.      The header of each frame is shown in Figure 4.  The various  fields
  279. are defined in Table 1 following the Figure.
  280.  
  281.     
  282.            
  283.  
  284.    +-----------+--------+-------------------+----------+
  285.    | Sync Code | Leader |        Data       | CRC Code |
  286.    +-----------+--------+-------------------+----------+
  287.         24    /    37    \       512             12
  288.      .-------'            \----------------------.
  289.     /                                             \
  290.    +-------+-------+-------+-------+-------+-------+
  291.    | Flags | Count | X Pos | Black | White | State |
  292.    +-------+-------+-------+-------+-------+-------+
  293.    |   7    \ 10      12       3       3       2
  294.    |         \--------------------------.
  295.    |                                     \
  296.    +-----+-----+------+-----+-------+-----+
  297.    | Seq | RUN | COFB | RPT | Spare | SUB |
  298.    +-----+-----+------+-----+-------+-----+
  299.       2     1     1      1      1      1
  300.  
  301.                    Figure 4. Frame Format
  302.  
  303. Dacom 450/500 Facsimile Data Transcoding                        PAGE   7
  304.  
  305.  
  306.  
  307.              Table 1. Header Field Definitions 
  308.  
  309.        
  310.  
  311. Field   Width   Function                Setup   Data
  312.        (bits)                           Block   Block
  313. -----------------------------------------------------
  314.  
  315. Sync Code  24   Synchronization         30474730 (octal)
  316.  
  317. Seq         2   Sequence number         00      00,01,10,11
  318.  
  319. RUN         1   Initialize-start        0       1
  320.  
  321. COFB        1   Unknown                 0       0
  322.  
  323. RPT         1   Unknown                 1       0
  324.  
  325. Spare       1   Unknown                 0       0
  326.  
  327. SUB         1   Indicates setup frame   1       0
  328.  
  329. Count      10   Number of bits in data  All 1's
  330.                 field (0 - 512)
  331.  
  332. X Pos      12   Current position on     All 1's
  333.                 scan line (0 - 1725)
  334.  
  335. Black       3   Current black field     All 1's
  336.                 length (2 - 7)
  337.  
  338. White       3   Current white field     All 1's
  339.                 length (2 - 7)
  340.  
  341. State       2   Current state (0 - 3)   All 1's
  342.  
  343. Data      512   Data (0 - 512 bits)
  344.  
  345. CRC Code   12   CRC checksum. Uses polynomial
  346.                 x**12 + x**8 + x**7  + x**5 + x**3 + 1
  347.  
  348. Dacom 450/500 Facsimile Data Transcoding                        PAGE   8
  349.  
  350.  
  351.  
  352.      Setup frames have additional information in  the  data  field;  the
  353. various fields and their functions are described in Table 2.
  354.  
  355.  
  356.         Table 2. Field Definitions for Setup Frame.
  357.      
  358.  
  359. Field       Width       Function
  360. --------------------------------
  361.  
  362. Start bit       1       Always zero
  363.  
  364. Speed bit       1       Set if express mode
  365.  
  366. Detail bit      1       Set if detail mode (speed and detail
  367.                         bits both zero for quality mode)
  368.  
  369. 14 inch         1       Set if 14-inch paper 
  370.  
  371. 5 inch          1       Set if 5-inch inch paper (14-inch
  372.                         and 5-inch inch paper bits both zero
  373.                         for 11-inch paper)
  374.  
  375. Paper present   1       Set if paper present in scanner
  376.  
  377. Spare           5       Can have any value
  378.  
  379. Multi-page      1       Set if multi-page mode
  380.  
  381.                20       All 0's
  382.  
  383.               480       Alternate 1's and 0's
  384.  
  385.  
  386.      The tailing setup frames differ from the leading setup frames  only
  387. in  bits  which  indicate  whether  the system is operating in single or
  388. multiple page mode and whether paper is present in the scanner.
  389.  
  390.      All n-bit numeric fields (except Seq) are transmitted by the  Dacom
  391. 450  machine  least-significant-bit  (LSB)  first  (i.e.   Count, X Pos,
  392. Black,  White,  State, CRC, and run length words  in  the  data  field).
  393. All other fields are transmitted left-most bit first.
  394.  
  395.      There are a few important points to be considered in regard to  the
  396. header  of  a  data frame.  The header contains enough information about
  397. the state of the decoding algorithm to be able to  re-establish  correct
  398. decoding  in  the  event  of  loss  or  mutilation of a data frame.  The
  399. decoding algorithm resets its state variables to  those  in  the  header
  400. each  time  it  begins  decoding  a  new  data  frame.   One of the most
  401. difficult problems encountered while constructing the decoding algorithm
  402. was  the  correct synchronization of the algorithm as it proceeds across
  403. the frame boundary with respect to the header information.  In order for
  404. synchronization  to  be  maintained, the operation of the algorithm must
  405.  
  406. Dacom 450/500 Facsimile Data Transcoding                        PAGE   9
  407.  
  408.  
  409.  
  410. follow exactly that described in the previous section.
  411.  
  412.      This requirement for every data  frame  to  be  self-synchronizing,
  413. leads  to  a  few  subtleties in the encoding algorithm which seem quite
  414. natural, but were not very obvious in the beginning.
  415.  
  416. 1.  Transition bits(s) labeling the arcs on the state transition diagram
  417.     in  Figure  2  are  not broken across frames.  Similarly, individual
  418.     run-length words are not broken across frames.
  419.  
  420. 2.  If a frame ends with a transition, the  header  of  the  next  frame
  421.     contains the state to which the transition is made.
  422.  
  423. 3.  If a frame ends with a transition out of state  0  or  3,  then  the
  424.     transition  bit (0 or 1) is inserted at the end of the current frame
  425.     (not at the beginning of the next frame).
  426.  
  427. 4.  The field lengths for black and white runs  in  the  header  include
  428.     changes that may have been caused at the end of the previous frame.
  429.  
  430. 5.  If a frame begins with a white  or  black  run,  then  this  run  is
  431.     treated  (for  purpose of decreasing its field length) as if it were
  432.     the beginning of a new run, since there is  no  information  in  the
  433.     header to indicate otherwise.
  434.  
  435.      The decoding algorithm is  initialized  at  the  first  data  frame
  436. received  after  the  sequence  of  setup  frames  at  the  beginning of
  437. transmission.  The first data frame has a count of zero,  indicating  no
  438. data  bits  are  in  the frame.  The second data frame begins the actual
  439. document; however, its X position appears to be irrelevant.  Instead, we
  440. assume the initial X position at this time is one pel to the left of the
  441. right margin  (-l  mod  l726).   With  these  assumptions  succeeding  X
  442. positions of the algorithm and the frame headers agree.
  443.  
  444. 2.3.  The Decoding Program
  445.  
  446.      The decoding algorithm described above has been implemented in  the
  447. PDP-11  MACRO-11 assembly language for the RT-11 operating system.  This
  448. program contains extensive features for selectively dumping  frames  and
  449. tracing  the operation of the algorithm.  It is designed to operate on a
  450. file containing the raw data generated  by  the  machine  and  does  not
  451. depend  upon  any  prior  reformatting  of  the  data.  However, it will
  452. operate also on files in the so-called UCL format [4],  which  has  been
  453. adopted  as  the standard for use in the Internet Program.  The existing
  454. DCNET supporting software for the Dacom 450  uses  the  UCL  format  and
  455. operates  normally  to  copy  data  directly between the machine and the
  456. file, with decoding operations done at a later time.  However, there  is
  457. no  intrinsic factor, except processing-rate limitations, why input data
  458. could not be decoded directly from the machine.
  459.  
  460.      In operation, the program scans the input data one bit  at  a  time
  461. and  searches  for  the  synchronization  pattern.   Note  that all data
  462. processed are inverted from the natural interface conventions.   When  a
  463.  
  464. Dacom 450/500 Facsimile Data Transcoding                        PAGE  10
  465.  
  466.  
  467.  
  468. synchronization  pattern  is  found,  the  header  and data portions are
  469. extracted  and  the  various  state  variable  checked  and  reset,   if
  470. necessary.    Checksum   verification  is  performed  according  to  the
  471. polynomial 1 + x**3 + x**5 + x**7 + x**8 + x**12.  In the case of  setup
  472. frames  the  format  (detail, quality, express), page length (14, 8-l/2,
  473. 5-l/4) and multiple-page indicators are extracted from  the  data  area.
  474. Finally,  under  control  of  specified  options,  the  header  and data
  475. portions of the frame are printed with appropriate headings.
  476.  
  477.      The decoding algorithm itself is called for each  data  frame.   It
  478. produces  an  output  consisting of a sequence of run-length pairs which
  479. can be used to form bit maps and  other  representations  of  the  data.
  480. Optionally, a printed trace of the operations performed by the algorithm
  481. can be produced.
  482.  
  483. 2.4.  The Encoding Program
  484.  
  485.      The encoding algorithm has been implemented in the PDP-11  MACRO-11
  486. assembly  language  for the RT-11 operating system.  The program accepts
  487. facsimile data in 16-bit run-length format or bit-map format.  The input
  488. data  would normally be in a file, possibly obtained by translating some
  489. other representation (e.g., T.4 format) to run-length or bit-map format.
  490. The  program  produces  an output consisting of data compressed in Dacom
  491. 450 format and packed in 585-bit frames  along  with  the  corresponding
  492. header and checksum information.
  493.  
  494.      The encoding program needs to be careful about how  to  break  data
  495. across  frames  and  how many bits of data to insert in each frame.  The
  496. rules mentioned in section 2.2.  help to solve the first  problem.   The
  497. second  problem is a little less understood.  The problem arises because
  498. data bits are required by the printing mechanism at a constant rate, but
  499. successive  frames  transmitted  at  the line rate can contain different
  500. amounts of decoded information, leading to  buffer  overrun  in  extreme
  501. cases.
  502.  
  503.      In order to compensate for the rate mismatch,  it  has  been  found
  504. sufficient  to  control  the  size  of  the  data  portion  of the frame
  505. according to a simple set of empirical rules which produce results quite
  506. similar  to  the  scanner  iteslf.  According to these rules, a frame is
  507. "full" when it contains more than 500 bits of  data  or  when  the  data
  508. represents more than 4800*X pels (or columns) of information,
  509.  
  510. where   X = 2 for transmission rate 2.4 kbs,
  511.         X = 1 for transmission rate 4.8 kbs,
  512.         X = 1/2 for transmission rate 9.6 kbs.
  513.  
  514. 2.5.  Dacom 450 File Formats
  515.  
  516.      Dacom 450 facsimile data is ordinarily stored as an RT-11  file  in
  517. the  so-called  UCL  format  [4].  In this format, each 585-bit frame is
  518. stored in a 76-byte record.  The first byte specifies the length of  the
  519. record,  the  second  specifies  a  command  and  the remaining 72 bytes
  520. contain the 585 bits of the original Dacom 450 frame zero-filled at  the
  521.  
  522. Dacom 450/500 Facsimile Data Transcoding                        PAGE  11
  523.  
  524.  
  525.  
  526. end.  The command byte is coded as follows:
  527.  
  528. a.  56 (70 octal): The data field contains  a  setup  frame  (the  first
  529.     record of the file).  The length byte is 76 (114 octal).
  530.  
  531. b.  57 (71 octal): The data field contains a data frame  (the  remaining
  532.     records  in  the  file  except the last one).  The length byte is 76
  533.     (114 octal).
  534.  
  535. c.  58 (72 octal): End of file (the last frame of the file).   There  is
  536.     no data field and the length byte is 2.
  537.  
  538. 2.6.  Run-Length and Bit-Map File Formats
  539.  
  540.      The decode program produces 16-bit run length words as its  output.
  541. Each  run  is encoded in a 16-bit word, with white in positive and black
  542. in negative two's complement values.  A zero word terminates each  line,
  543. with the trailing white run suppressed if present.  An all-white line is
  544. encoded as a single run of length one followed by a zero word.  The file
  545. is terminated by a line of length zero, that is, a single zero word.
  546.  
  547.      Bit-map files consist of a four-byte header followed by  the  data.
  548. The  header  consists  of  two  2-byte  quantities,  the  first of which
  549. represents the number of pels in a line and the  second  the  number  of
  550. lines  in  the  page.   Each  scanning line of data is represented in an
  551. integral number of bytes,  the  last  byte  of  a  line  zero-filled  if
  552. necessary.
  553.  
  554. 3.  Dacom 500 Data Compression Principles
  555.  
  556.      The Dacom 500 machines are high-speed versions  of  the  Dacom  450
  557. machines  and  operate  in  the  50-Kbps range using the T.4 compression
  558. algorithm.  This algorithm, described in the [5], is  a  one-dimensional
  559. one,  rather  than  the  two-dimensional  one  used in the Dacom 450 and
  560. described in previous sections.  Since this algorithm is well known  and
  561. the  subject  of  an  international  standard,  it  will  not be further
  562. discussed here.
  563.  
  564. 3.1.  Dacom 500 Decoding Algorithm
  565.  
  566.      The decoding program has been implemented in  the  PDP-11  MACRO-11
  567. assembly  language  for  the  DCNET  and  RT-11  operating  systems.  It
  568. operates on a file containing  facsimile  data  encoded  using  the  T.4
  569. algorithm and produces a file in bit-map format.
  570.  
  571.      The decoding program scans the input data bit-by-bit and recognizes
  572. sequences  of  bits which form valid run-length codes (see the tables in
  573. [5]).  The table of Huffman codes can be represented as  a  binary  tree
  574. with  the  values of the run lengths (e.g.  1, 2, 64, 1728, etc.) at the
  575. terminal nodes and each branch labeled 0 or 1.  The  code  for  any  run
  576. length  then  is the sequence of branch labels on the path from the root
  577. to the terminal node representing this length.
  578.  
  579. Dacom 450/500 Facsimile Data Transcoding                        PAGE  12
  580.  
  581.  
  582.  
  583.      The tables for black and  white  run-length  codes  are  stored  as
  584. separate  binary  trees in the decoding program.  The decoding algorithm
  585. starts by initializing an accumulator at zero.  It then  begins  at  the
  586. root  of  the  corresponding  tree and traverses the tree as it consumes
  587. bits one-by-one from the input.  When a terminal node  is  reached,  the
  588. value  stored  at  that  node is added to the accumulator.  If a make-up
  589. node is reached, the value at that node is added to the accumulator  and
  590. the  search  is  resumed  with  the  same tree to obtain the terminating
  591. value; otherwise, the accumulator represents the current run length  and
  592. the search resumes with the alternate tree.
  593.  
  594. 3.2.  Dacom 500 Encoding Program
  595.  
  596.      The encoding program is also implemented  in  the  PDP-11  MACRO-11
  597. assembly  language  for the DCNET and RT-11 operating systems.  It scans
  598. the bit-map input and encodes each run of  black  or  white  pels  by  a
  599. simple  table  lookup  of  the  Huffman  codes.   It  operates on a file
  600. containing facsimile data in bit-map format and produces a file  in  T.4
  601. format.   The T.4 specifications [5] require a minimum transmission time
  602. per scan line of 4.3 milliseconds, which at 50-Kbps corresponds  to  242
  603. bits  (DATA bits plus any required FILL bits plus the EOL bits equal 242
  604. bits minimum).
  605.  
  606. 3.3.  Dacom 500 File Formats
  607.  
  608.      The file consists of a number of  512-byte  blocks,  the  first  of
  609. which  is  the  header.  The header contains a list of two-byte entries,
  610. the first of which contains the number of pages and  the  remaining  the
  611. lengths  (in  blocks) of each page in turn.  The remaining blocks of the
  612. file contain the data for each page in T.4 format.  The  data  for  each
  613. page   is   preceded   by  a  page-setup  command  and  succeeded  by  a
  614. page-end-of-record command, as transmitted by the Dacom 500.  The format
  615. of  both  commands  consists  of  the 12-bit T.4 EOL code (000000000001)
  616. repeated six times and followed  by  a  special  4-bit  code  word  also
  617. repeated  six  times.  The special code word consists of bits B1 through
  618. B4 as defined below.
  619.  
  620.  
  621. B1: VERTICAL RESOLUTION
  622.     0 = 7.7 lines per millimeter
  623.     1 = future option, not implemented 
  624.  
  625. B2: OUTPUT PAPER LENGTH
  626.     0 = short length (Letter size)
  627.     1 = long length (Legal size)
  628.  
  629. B3: DOCUMENT IN SCANNER
  630.     0 = no document present (end of page)
  631.     1 = document present (beginning of page)
  632.  
  633. B4: ODD PARITY OVER B1-B4
  634.  
  635. Dacom 450/500 Facsimile Data Transcoding                        PAGE  13
  636.  
  637.  
  638.  
  639. 3.4.  Comparison of Facsimile Formats and Transcoding Speeds
  640.  
  641.      Four different file formats are presently used in  our  system  for
  642. facsimile  data  storage:  Dacom 450, Dacom 500 (T.4), 16-bit run-length
  643. and bit-map.  The sizes of typical files (in megabits) in these  formats
  644. are shown below for comparison.
  645.  
  646.        
  647.  
  648.         File    Dacom   Dacom   16-bit
  649.                 450     500     run-length
  650.         ----------------------------------
  651.  
  652.         PNGUIN  0.22    0.5     0.27
  653.         INTELP  0.62    0.77    3.3
  654.         PANDA   1.02    2.03    6.41
  655.  
  656.  
  657. The file called PNGUIN is  a  block  drawing  of  dancing  penguins  and
  658. represents  a  "small"  file.   The  file  called  INTELP is a composite
  659. INTELPOST test image with text and graphics and  represents  a  "medium"
  660. file.    Finally,  the  file  called  PANDA  is  a  half-tone  newspaper
  661. photograph of a giant panda and represents a "monster" file  (this  file
  662. was  recorded  on  the  Dacom 450 in quality mode and is therefore about
  663. half the size it would be in detail mode).  The size of the bit-map file
  664. for all these images is 3.8 megabits.  
  665.  
  666.      Figure 5 shows the file sizes (in 512-byte blocks) and  transcoding
  667. times  (in  seconds)  for  the  INTELPOST test page.  The file sizes are
  668. indicated on the boxes, while the transcoding times are indicated on the
  669. arrows.  All times were obtained on the LSI-11/23 processor.
  670.  
  671.     
  672.              193                      925
  673.         +-----------+     95     +-----------+
  674.         |           |----------->|           |
  675.         |    T.4    |            |  Bit-map  |
  676.         |           |<-----------|           |
  677.         +-----------+    165     +-----------+
  678.                                      A   |
  679.                           60         |   |
  680.               .----------------------'   |110
  681.               |                          |
  682.               |                          V
  683.         +-----------+     89     +-----------+
  684.         |           |----------->|           |
  685.         |Run-length |            | Dacom 450 |
  686.         |           |<-----------|           |
  687.         +-----------+    153     +-----------+
  688.              413                      155
  689.  
  690.          Figure 5. File Sizes and Transcoding Times
  691.  
  692. Dacom 450/500 Facsimile Data Transcoding                        PAGE  14
  693.  
  694.  
  695.  
  696. 4.  References
  697.  
  698. 1.  Weber, D.R.  An adaptive  run-length  encoding  algorithm.   ICC-75,
  699.     IEEE, San Francisco, California, June 1975.
  700.  
  701. 2.  Palmer, L.C.  Final Report, COMSAT Participation in the DARPA Packet
  702.     Satellite  Internetworking  and Speech Applications Program.  COMSAT
  703.     Laboratories, July 1980.
  704.  
  705. 3.  Katz, A.  Decoding Facsimile  Data  from  the  Rapicom  450.   DARPA
  706.     Network  Working  Group  Report  RFC-798,  USC/Information  Sciences
  707.     Institute, September 1981.
  708.  
  709. 4.  Postel, J.  Rapicom 450  Facsimile  File  Formats.   DARPA   Network
  710.     Working Group Report RFC-769,   USC/Information  Sciences Institute,
  711.     September 1980.
  712.  
  713. 5.  Draft Recommendation T.4 - Standardization of Group 3 Facsimile  for
  714.     Document  Transmission.   CCITT  Study Group XIV Contribution #25-E,
  715.     December 1977.  (Also in RFC-804).
  716.  
  717.