|
static void | hl_c1030_line_append (struct cm1030_line *c, uint8_t byte) |
|
static void | hl_c1030_line_mark_empty (struct cm1030_line *c) |
|
static void | hl_c1030_line_mark_equal (struct cm1030_line *c) |
|
static void | hl_c1030_overflow_append (struct cm1030_line *c, unsigned value) |
|
static void | hl_c1030_repeat_edit_append (struct cm1030_line *c, unsigned offset, unsigned count, uint8_t pattern) |
|
static void | hl_c1030_substitute_edit_append (struct cm1030_line *c, unsigned offset, unsigned count, const uint8_t pattern[count]) |
|
static bool | hl_c1030_line_check_if_empty (size_t cnt, const uint8_t line[cnt]) |
|
static ssize_t | hl_c1030_edit_find_next_with_ref (size_t cnt, const uint8_t line[cnt], const uint8_t reference[cnt]) |
|
static ssize_t | hl_c1030_edit_find_next (size_t cnt, const uint8_t line[cnt]) |
|
static size_t | hl_c1030_line_shorten (size_t cnt, const uint8_t line[cnt], const uint8_t last[cnt]) |
|
void | hl_c1030_line_edit (struct cm1030_line *c, size_t cnt, const uint8_t line[cnt], const uint8_t *last) |
|
int | hl_c1030_block_flush (struct cm1030_band *block, FILE *outstream) |
|
int | hl_c1030_block_line_add (struct cm1030_band *block, const struct cm1030_line *line, FILE *outstream) |
|
int | hl_c1030_block_pad (struct cm1030_band *block, unsigned missing_line_cnt, FILE *outstream) |
|
void | hl_c1030_block_init (struct cm1030_band *block) |
|
void | hl_c1030_block_exit (struct cm1030_band *block) |
|
Read the corresponding header file for further information about this encoding method.
The printer wants the data to be print as:
- a bit is '0': this dot isn't printed, the paper colour is still visible at this position
- a bit is '1': this dot is printed, a black dot is visible at this position
If the input data doesn't match the printer's data polarity, set the WHITE_BYTE to 0xFF instead.
static void hl_c1030_overflow_append |
( |
struct cm1030_line * |
c, |
|
|
unsigned |
value |
|
) |
| |
|
static |
Append an overflow value to the line buffer
- Parameters
-
[in,out] | c | Compression output buffer |
[in] | value | Overflow value |
An overflow value is a value which is larger then the first byte in the 'edit' can include. An overflow value is encoded into a sequence of bytes. A byte of 0xff
signals more bytes follows. The sequence terminates if a byte less than 0xff is found.
E.g.:
value = 0 -> <0x00>
value = 10 -> <0x0a>
value = 255 -> <0xff> <0x00>
value = 256 -> <0xff> <0x01>
value = 512 -> <0xff> <0xff> <0x02>
This overflow value is used to form the 'offset' and 'count' values in the 'edits'
- Precondition
- The value encoded in the first byte must already be substracted!
static size_t hl_c1030_line_shorten |
( |
size_t |
cnt, |
|
|
const uint8_t |
line[cnt], |
|
|
const uint8_t |
last[cnt] |
|
) |
| |
|
static |
Trim the line to the active content
- Parameters
-
[in] | cnt | Length in bytes of line and last |
[in] | line | Line to shorten |
[in] | last | Last line as reference |
- Returns
- Length in bytes of the active content
It makes no sense to search for 'edits' in the line if trailing bytes are the same than the previous line. To consider this case it complicates the algorithm. So, it is easier to trim the line prior beginning to search for 'edits' in it.
Here an example of a bad encoding:
prev: …0xff 0xff 0xff 0xe0 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00…
curr: …0xff 0xff 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00…
^^^^_ from here on a (useless) substitute or repeat up to the end was encoded
By trimming the line to the active content, the line looks like this:
prev: …0xff 0xff 0xff 0xe0
curr: …0xff 0xff 0x00 0x00
…and the 'edit' encoding was really improved.
- Precondition
- The line must not be empty!
-
The line must not be equal to the previous one!
void hl_c1030_line_edit |
( |
struct cm1030_line * |
c, |
|
|
size_t |
cnt, |
|
|
const uint8_t |
line[cnt], |
|
|
const uint8_t * |
last |
|
) |
| |
Edit one full line as best as possible
- Parameters
-
[in,out] | c | Compression output buffer |
[in] | cnt | Count of bytes with active pixel in both lines |
[in] | line | Line to achieve |
[in] | last | Previous line (can be NULL) |
This function creates all required 'edits' to form the current line inside the printer with the help/reference of the previous (and already existing inside the printer) line. It handles special cases, where the current line is empty (all pixel white) or where the current line is identical to the previous line. To avoid useless encodings (full substitute or repeat until the end) it then first shrinks the length of the line to the really required one (by comparing the current and previous line content) backwards from the end. And then starts the 'edit' based encoding.
If a line has no predecessor (e.g. last is NULL) the first approach was to encode it against an empty line. This seemed to solve some visual artefacts on the paper. But there are still some artefacts with vertical lines, where this approach fails. As a result, if there is no reference line the full line must be encoded.
int hl_c1030_block_pad |
( |
struct cm1030_band * |
block, |
|
|
unsigned |
missing_line_cnt, |
|
|
FILE * |
outstream |
|
) |
| |
Pad the current data block to the full band line count
- Parameters
-
[in] | block | Current block data info |
[in] | missing_line_cnt | Lines to add to pad the current band |
[in,out] | outstream | The stream to send the printer data to |
- Return values
-
0 | On success |
-errno | If the data flushing to the printer's stream has failed |
The printer only prints in bands of n lines. Bands with less than these n lines are skipped entirely (and silently). This hurts at the bottom edge of a page, where the vertical dot count might not be a multiple of these n lines.
This function pads the current data block up to these n lines on demand with empty lines. It must be called once at the end of each page if you know your last band has less lines than these n lines.
- Postcondition
- A call to hl_c1030_block_flush()