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

Swap buffers after decode

parent 688f2465
No related branches found
No related tags found
No related merge requests found
Pipeline #12292 passed
......@@ -110,10 +110,24 @@ void NetSource::_recvChunk(int64_t frame, int chunk, bool delta, const vector<un
if (!active_) return;
// Decode in temporary buffers to prevent long locks
cv::imdecode(jpg, cv::IMREAD_COLOR, &tmp_rgb);
if (d.size() > 0) cv::imdecode(d, cv::IMREAD_UNCHANGED, &tmp_depth);
// Apply colour correction to chunk
ftl::rgbd::colourCorrection(tmp_rgb, gamma_, temperature_);
// Build chunk head
int cx = (chunk % chunks_dim_) * chunk_width_;
int cy = (chunk / chunks_dim_) * chunk_height_;
// Lock host to prevent grab
UNIQUE_LOCK(host_->mutex(),lk);
// A new frame has been started... finish the last one
if (frame > current_frame_) {
// Lock host to prevent grab
UNIQUE_LOCK(host_->mutex(),lk);
//UNIQUE_LOCK(host_->mutex(),lk);
// Swap the double buffers
cv::Mat tmp;
......@@ -130,20 +144,6 @@ void NetSource::_recvChunk(int64_t frame, int chunk, bool delta, const vector<un
LOG(WARNING) << "Chunk dropped";
}
// Decode in temporary buffers to prevent long locks
cv::imdecode(jpg, cv::IMREAD_COLOR, &tmp_rgb);
if (d.size() > 0) cv::imdecode(d, cv::IMREAD_UNCHANGED, &tmp_depth);
// Apply colour correction to chunk
ftl::rgbd::colourCorrection(tmp_rgb, gamma_, temperature_);
// Build chunk head
int cx = (chunk % chunks_dim_) * chunk_width_;
int cy = (chunk / chunks_dim_) * chunk_height_;
// Lock host to prevent grab
UNIQUE_LOCK(host_->mutex(),lk);
// TODO:(Nick) Decode directly into double buffer if no scaling
cv::Rect roi(cx,cy,chunk_width_,chunk_height_);
......
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