From 062f2459d63f4d731ef2046ef7b87ea5802665dc Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Thu, 12 Dec 2019 15:08:08 +0200 Subject: [PATCH] Disable chunked encoding --- components/codecs/src/opencv_encoder.cpp | 8 ++++++-- components/rgbd-sources/src/sources/net/net.cpp | 13 +++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/components/codecs/src/opencv_encoder.cpp b/components/codecs/src/opencv_encoder.cpp index 6398c72b0..772922e7b 100644 --- a/components/codecs/src/opencv_encoder.cpp +++ b/components/codecs/src/opencv_encoder.cpp @@ -30,7 +30,9 @@ bool OpenCVEncoder::supports(ftl::codecs::codec_t codec) { bool OpenCVEncoder::encode(const cv::cuda::GpuMat &in, definition_t definition, bitrate_t bitrate, const std::function<void(const ftl::codecs::Packet&)> &cb) { bool is_colour = in.type() != CV_32F; - current_definition_ = definition; + + // Ensure definition does not exceed max + current_definition_ = ((int)definition < (int)max_definition) ? max_definition : definition; in.download(tmp_); //CHECK(cv::Size(ftl::codecs::getWidth(definition), ftl::codecs::getHeight(definition)) == in.size()); @@ -47,7 +49,8 @@ bool OpenCVEncoder::encode(const cv::cuda::GpuMat &in, definition_t definition, tmp_.convertTo(tmp_, CV_16UC1, 1000); } - chunk_dim_ = (definition == definition_t::LD360) ? 1 : 4; + // FIXME: Chunking is broken so forced to single chunk + chunk_dim_ = 1; //(definition == definition_t::LD360) ? 1 : 4; chunk_count_ = chunk_dim_ * chunk_dim_; jobs_ = chunk_count_; @@ -95,6 +98,7 @@ bool OpenCVEncoder::_encodeBlock(const cv::Mat &in, ftl::codecs::Packet &pkt, bi int cx = (pkt.block_number % chunk_dim_) * chunk_width; int cy = (pkt.block_number / chunk_dim_) * chunk_height; cv::Rect roi(cx,cy,chunk_width,chunk_height); + cv::Mat chunkHead = in(roi); if (pkt.codec == codec_t::PNG) { diff --git a/components/rgbd-sources/src/sources/net/net.cpp b/components/rgbd-sources/src/sources/net/net.cpp index 04b093490..694aa50f8 100644 --- a/components/rgbd-sources/src/sources/net/net.cpp +++ b/components/rgbd-sources/src/sources/net/net.cpp @@ -52,8 +52,8 @@ NetFrame &NetFrameQueue::getFrame(int64_t ts, const cv::Size &s, int c1type, int f.chunk_total[1] = 0; f.channel_count = 0; f.tx_size = 0; - f.channel[0].create(s, c1type); - f.channel[1].create(s, c2type); + //f.channel[0].create(s, c1type); + //f.channel[1].create(s, c2type); return f; } oldest = (f.timestamp < oldest) ? f.timestamp : oldest; @@ -72,8 +72,8 @@ NetFrame &NetFrameQueue::getFrame(int64_t ts, const cv::Size &s, int c1type, int f.chunk_total[1] = 0; f.channel_count = 0; f.tx_size = 0; - f.channel[0].create(s, c1type); - f.channel[1].create(s, c2type); + //f.channel[0].create(s, c1type); + //f.channel[1].create(s, c2type); return f; } } @@ -283,6 +283,8 @@ void NetSource::_recvPacket(short ttimeoff, const ftl::codecs::StreamPacket &spk // Update frame statistics frame.tx_size += pkt.data.size(); + frame.channel[channum].create(size, (isFloatChannel(rchan) ? CV_32FC1 : CV_8UC3)); + // Only decode if this channel is wanted. if (rchan == Channel::Colour || rchan == chan) { _createDecoder(channum, pkt); @@ -291,8 +293,7 @@ void NetSource::_recvPacket(short ttimeoff, const ftl::codecs::StreamPacket &spk LOG(ERROR) << "No frame decoder available"; return; } - - frame.channel[channum].create(size, frame.channel[channum].type()); // TODO!!! queue_.getFrame() assumes same size + decoder->decode(pkt, frame.channel[channum]); } else if (chan != Channel::None && rchan != Channel::Colour) { // Didn't receive correct second channel so just clear the images -- GitLab