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

Add compression level config opt

parent 445076c7
No related branches found
No related tags found
1 merge request!40Implements #89 PNG chunking
Pipeline #11600 passed
...@@ -112,6 +112,7 @@ class Streamer : public ftl::Configurable { ...@@ -112,6 +112,7 @@ class Streamer : public ftl::Configurable {
std::mutex job_mtx_; std::mutex job_mtx_;
std::condition_variable job_cv_; std::condition_variable job_cv_;
std::atomic<int> jobs_; std::atomic<int> jobs_;
int compress_level_;
void _schedule(); void _schedule();
void _swap(detail::StreamSource *); void _swap(detail::StreamSource *);
......
...@@ -28,6 +28,8 @@ Streamer::Streamer(nlohmann::json &config, Universe *net) ...@@ -28,6 +28,8 @@ Streamer::Streamer(nlohmann::json &config, Universe *net)
active_ = false; active_ = false;
net_ = net; net_ = net;
compress_level_ = value("compression", 1);
net->bind("find_stream", [this](const std::string &uri) -> optional<UUID> { net->bind("find_stream", [this](const std::string &uri) -> optional<UUID> {
SHARED_LOCK(mutex_,slk); SHARED_LOCK(mutex_,slk);
...@@ -307,7 +309,7 @@ void Streamer::_schedule() { ...@@ -307,7 +309,7 @@ void Streamer::_schedule() {
//if (delta) d3 = (d2 * 2) - chunkDepthPrev; //if (delta) d3 = (d2 * 2) - chunkDepthPrev;
//else d3 = d2; //else d3 = d2;
//d2.copyTo(chunkDepthPrev); //d2.copyTo(chunkDepthPrev);
vector<int> pngparams = {cv::IMWRITE_PNG_COMPRESSION, 1}; // Default is 1 for fast, 9 = small but slow. vector<int> pngparams = {cv::IMWRITE_PNG_COMPRESSION, compress_level_}; // Default is 1 for fast, 9 = small but slow.
cv::imencode(".png", d2, d_buf, pngparams); cv::imencode(".png", d2, d_buf, pngparams);
//LOG(INFO) << "Sending chunk " << chunk << " : size = " << (d_buf.size()+rgb_buf.size()) / 1024 << "kb"; //LOG(INFO) << "Sending chunk " << chunk << " : size = " << (d_buf.size()+rgb_buf.size()) / 1024 << "kb";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment