Skip to content
Snippets Groups Projects
Commit ecc53aa0 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Switch to zlib level 4 compression to balance speed on my laptop

parent 70fe9d41
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <glog/logging.h> #include <glog/logging.h>
#include <ftl/config.h> #include <ftl/config.h>
#include <zlib.h> #include <zlib.h>
// #include <lz4.h>
#include <string> #include <string>
#include <map> #include <map>
...@@ -147,6 +148,9 @@ static void run(const string &file) { ...@@ -147,6 +148,9 @@ static void run(const string &file) {
inflateInit(&infstream); inflateInit(&infstream);
inflate(&infstream, Z_NO_FLUSH); inflate(&infstream, Z_NO_FLUSH);
inflateEnd(&infstream); inflateEnd(&infstream);
//LZ4_decompress_safe((char*)d.data(), (char*)depth.data, d.size(), depth.step*depth.rows);
//cv::imdecode(d, cv::IMREAD_GRAYSCALE, &depth); //cv::imdecode(d, cv::IMREAD_GRAYSCALE, &depth);
//depth.convertTo(depth, CV_32FC1); //, 1.0f/16.0f); //, 1.0f/256.0f); //depth.convertTo(depth, CV_32FC1); //, 1.0f/16.0f); //, 1.0f/256.0f);
}); });
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <ftl/streamer.hpp> #include <ftl/streamer.hpp>
#include <vector> #include <vector>
#include <zlib.h> #include <zlib.h>
// #include <lz4.h>
using ftl::Streamer; using ftl::Streamer;
using ftl::net::Universe; using ftl::net::Universe;
...@@ -35,11 +36,17 @@ void Streamer::send(const Mat &rgb, const Mat &depth) { ...@@ -35,11 +36,17 @@ void Streamer::send(const Mat &rgb, const Mat &depth) {
defstream.avail_out = (uInt)depth.step*depth.rows; // size of output defstream.avail_out = (uInt)depth.step*depth.rows; // size of output
defstream.next_out = (Bytef *)d_buf.data(); // output char array defstream.next_out = (Bytef *)d_buf.data(); // output char array
deflateInit(&defstream, Z_DEFAULT_COMPRESSION); deflateInit(&defstream, 4); // Z_DEFAULT_COMPRESSION
deflate(&defstream, Z_FINISH); deflate(&defstream, Z_FINISH);
deflateEnd(&defstream); deflateEnd(&defstream);
d_buf.resize(defstream.total_out); d_buf.resize(defstream.total_out);
// LZ4 Version
// d_buf.resize(LZ4_compressBound(depth.step*depth.rows));
// int s = LZ4_compress_default((char*)depth.data, (char*)d_buf.data(), depth.step*depth.rows, d_buf.size());
// d_buf.resize(s);
//Mat d2; //Mat d2;
//depth.convertTo(d2, CV_16UC1, 256); //depth.convertTo(d2, CV_16UC1, 256);
//cv::imencode(".png", depth, d_buf); //cv::imencode(".png", depth, d_buf);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment