From 13221082d9eb550c7e9638cd55876a0567e9a0fb Mon Sep 17 00:00:00 2001 From: Vladimir Date: Mon, 14 Aug 2023 16:43:35 +0300 Subject: [PATCH] Delete packmatrix.cpp --- packmatrix.cpp | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 packmatrix.cpp diff --git a/packmatrix.cpp b/packmatrix.cpp deleted file mode 100644 index d285111..0000000 --- a/packmatrix.cpp +++ /dev/null @@ -1,41 +0,0 @@ - -#include -#include -#include -#include -#include -#include "huffman.hpp" -#include "packmatrix.hpp" -namespace huffman { - -std::vector compress(const the_matrix& matrix) { - auto data = flatten(matrix); - compress::Huffman henc; - BitWriter enc_w; - henc.buildHuffmanTree(data.begin(), data.end()); - henc.encodeHuffmanTree(enc_w); - - std::cerr << "haffmantable size = " << enc_w.size() << std::endl; - - enc_w.writeBits(16, matrix[0].size()); - enc_w.writeBits(16, matrix.size()); - henc.encode(enc_w,data.begin(),data.end()); - enc_w.flush(); - - return std::vector(enc_w.data(), enc_w.data() + enc_w.size()); -} - - - -the_matrix decompress(const std::vector& compressed) { - compress::Huffman hdec; - BitReader enc_r(compressed.data(),compressed.size()); - hdec.decodeHuffmanTree(enc_r); - return make_matrix( enc_r.readBits(16), enc_r.readBits(16), - [&](int &v) { - v = hdec.decode(enc_r); - } - ); -} - -}; // namespace huffman \ No newline at end of file