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

Yield to wait for last frame decode

parent 1deec973
No related branches found
No related tags found
No related merge requests found
...@@ -121,6 +121,12 @@ void NetSource::_recvChunk(int64_t frame, int chunk, bool delta, const vector<un ...@@ -121,6 +121,12 @@ void NetSource::_recvChunk(int64_t frame, int chunk, bool delta, const vector<un
int cx = (chunk % chunks_dim_) * chunk_width_; int cx = (chunk % chunks_dim_) * chunk_width_;
int cy = (chunk / chunks_dim_) * chunk_height_; int cy = (chunk / chunks_dim_) * chunk_height_;
// Make certain last frame has finished decoding before swap
while (frame > current_frame_ && chunk_count_ < 16 && chunk_count_ > 0) {
LOG(WARNING) << "Previous frame not complete: " << frame;
std::this_thread::yield();
}
// Lock host to prevent grab // Lock host to prevent grab
UNIQUE_LOCK(host_->mutex(),lk); UNIQUE_LOCK(host_->mutex(),lk);
...@@ -129,6 +135,8 @@ void NetSource::_recvChunk(int64_t frame, int chunk, bool delta, const vector<un ...@@ -129,6 +135,8 @@ void NetSource::_recvChunk(int64_t frame, int chunk, bool delta, const vector<un
// Lock host to prevent grab // Lock host to prevent grab
//UNIQUE_LOCK(host_->mutex(),lk); //UNIQUE_LOCK(host_->mutex(),lk);
chunk_count_ = 0;
// Swap the double buffers // Swap the double buffers
cv::Mat tmp; cv::Mat tmp;
tmp = rgb_; tmp = rgb_;
...@@ -176,6 +184,7 @@ void NetSource::_recvChunk(int64_t frame, int chunk, bool delta, const vector<un ...@@ -176,6 +184,7 @@ void NetSource::_recvChunk(int64_t frame, int chunk, bool delta, const vector<un
} }
} }
++chunk_count_;
if (chunk == 0) { if (chunk == 0) {
N_--; N_--;
} }
...@@ -232,6 +241,7 @@ void NetSource::_updateURI() { ...@@ -232,6 +241,7 @@ void NetSource::_updateURI() {
chunks_dim_ = ftl::rgbd::kChunkDim; chunks_dim_ = ftl::rgbd::kChunkDim;
chunk_width_ = params_.width / chunks_dim_; chunk_width_ = params_.width / chunks_dim_;
chunk_height_ = params_.height / chunks_dim_; chunk_height_ = params_.height / chunks_dim_;
chunk_count_ = 0;
rgb_ = cv::Mat(cv::Size(params_.width, params_.height), CV_8UC3, cv::Scalar(0,0,0)); rgb_ = cv::Mat(cv::Size(params_.width, params_.height), CV_8UC3, cv::Scalar(0,0,0));
depth_ = cv::Mat(cv::Size(params_.width, params_.height), CV_32FC1, 0.0f); depth_ = cv::Mat(cv::Size(params_.width, params_.height), CV_32FC1, 0.0f);
d_rgb_ = cv::Mat(cv::Size(params_.width, params_.height), CV_8UC3, cv::Scalar(0,0,0)); d_rgb_ = cv::Mat(cv::Size(params_.width, params_.height), CV_8UC3, cv::Scalar(0,0,0));
......
...@@ -48,6 +48,7 @@ class NetSource : public detail::Source { ...@@ -48,6 +48,7 @@ class NetSource : public detail::Source {
int default_quality_; int default_quality_;
ftl::rgbd::channel_t prev_chan_; ftl::rgbd::channel_t prev_chan_;
int64_t current_frame_; int64_t current_frame_;
int chunk_count_;
// Double buffering // Double buffering
cv::Mat d_depth_; cv::Mat d_depth_;
......
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