BruteForceCompress( xi , xi − 1 , n, y ) |
// is the current sensor reading(s) |
// _1 is the immediate past sensor reading(s) |
// n is the block size (the number of samples read each time) |
// y is the final encoded bitstream |
// 2TableALECencoder() is the 2-Huffman Table ALEC encode function |
// 3TableALECencoder() is the 3-Huffman Table ALEC encode function |
|
// compute the residue |
SET TO –
|
// encode the residue |
// encode block of n using the 2-Huffman Table ALEC encode function |
CALL 2TablesALECencoder() with block of n RETURNING code |
SET codeA To code |
// compute the size of the encoded bitstream codeA |
SET size_A TO length(codeA) |
// encode the same block of n using the 3-Huffman Table ALEC encode function |
CALL 3TablesALECencoder() with the same block of n RETURNING code |
SET codeB To code |
// compute the size of the encoded bitstream codeB |
SET size_B TO length(codeB) |
// compare size_A and size_B and select the encoded bitstream with the least compressed size |
IF size_A <= size_B THEN |
// generate the code option identifier for the 2-Huffman Table ALEC encoder |
SET ID TO “0” |
// append encoded bitstream codeA to ID |
SET strm TO ID * codeA |
ELSE |
// generate the code option identifier for the 3-Huffman Table ALEC encoder |
SET ID TO “1” |
// append encoded bitstream codeB to ID |
SET strm TO ID * codeB |
ENDIF |
// append bitstream strm to y |
SET y TO y * strm |
RETURN y |