CAPS Universe documentation  1.0.4
All you need to know to be successful
The Printer Data Encoding Method "1027"

The 1027 encoding method uses a block oriented data set in conjunction with bands which split a page vertically in small pieces.

There is a limit of 64 lines (max. line count in a band) and the size of the encoding in one data block must not exceed 32 k words (64 kiB).

Encodes a line by replacing words, repeating nibbles, bytes and words and copy words from a previous line. Everything which does not fit into one of the encoding types is copied as-is. Thus, the compression ratio is very lousy if the content is complex. Maybe the yet unknown 'edit' functions (see below) add more features to gain a better compression ratio for complex content. Volunteers? :)

Encoding works in pieces of 'edits'. Due to the absence of an offset component, matching line content cannot be skipped like in the The Printer Data Encoding Method "3" or The Printer Data Encoding Method "1030" method. Each 'edit' is a 16 bit word where the topmost one or three bits define a function. The word itself must be encoded in big-endian:

  • Non compressed data (e.g. bit 7 of the first byte is zero)
     76543210 76543210
     0ccccccc ccccxxxx <word>…
    
    With:
     ccccccccccc 11 bit of count of following words
     xxxx not used
    
  • Function: repeat the following 16 bit word count times
     76543210 76543210
     100ccccc cccccccc <word>
    
    With:
     ccccccccccccc 13 bit of count (e.g. max 8191 words)
    
  • Function: repeat the embedded 8 bit data count * two times
     76543210 76543210
     110ccccc dddddddd
    
    With:
     dddddddd data
     ccccc 5 bit of count (e.g. max 31 words)
    
  • Function: repeat the embedded data nibble count * four times
     76543210 76543210
     101ddddc cccccccc
    
    With:
       dddd lower nibble of data
       ccccccccc 9 bit of count (e.g. max 511 words)
    
  • Function: Copy count words from the previous line
     76543210 76543210
     111ccccc cccccccc
    
    With:
     ccccccccccccc 13 bit of count (max. 8191 words)
    
    For all encodings it's unclear, what a count of zero means.

A single band can be described by multiple blocks of up to 64 kiB data each.

Each block of data starts with "\033*b<number>W".

According to some documentation I found, the bands have fixed positions and are always of 64 lines. The data blocks can only be inside each band and should never cross its boundaries.

Each encoded data block comes with a #cm1027_band_data_header which defines its position on the paper like this:

  paper           |                                                           paper
left border       |                                                        right border
    |             |                                                             |
    v             |                                                             v
    +-------------|-------------------------------------------------------------+ <- (n * 64)
    |             |                                                     Band    |
    |             |                                                             |
    |             |                                                             |
    |             | 'border_top'                                                |
    |             |                                                             |
    |             |                                                             |
    |             |                                                             |
    |             V                                                             |
    |         +-------------------------------------------------------------+   |
    |-------->|   |                                                  Block  |   |
    | border_ |   | line_cnt                                                |   |
    |  left   |   |                                 pixel_cnt               |   |
    |         |---V-------------------------------------------------------->|   |
    |         +-------------------------------------------------------------+   |
    |                                                                           |
    |                                                                           |
    |                                                                           |
    |                                                                           |
    |                                                                           |
    |                                                                           |
    |                                                                           |
    +---------------------------------------------------------------------------+ <- (n * 64 + 63)
Note
cm1027_block_data_header::border_top and cm1027_block_data_header::border_left are always paper related.
Attention
The block line start and line end must lie in a band of 64 lines. The bands always start at the top of the page to count. Thus, if a block would cross band boundaries, it must be split into sub blocks.

So, for print jobs with only a few objects spread over the page the compression is very well. But if you have many objects (or a background image) the compression is very lousy.