diff --git a/components/streams/src/sender.cpp b/components/streams/src/sender.cpp index 7429bce945dec4f958bd7096048558cd4a89a7d5..ebd778a3298b212dc5845553ea8473d1ccfb8712 100644 --- a/components/streams/src/sender.cpp +++ b/components/streams/src/sender.cpp @@ -773,12 +773,12 @@ int Sender::_generateTiles(const ftl::rgbd::FrameSet &fs, int offset, Channel c, // Loop over tiles with ROI mats and do colour conversions. while (tilecount > 0 && count+offset < fs.frames.size()) { - if (fs.hasFrame(offset+count)) { - cframe = &fs.frames[offset+count]; + cframe = &fs.frames[offset+count]; + + if (fs.hasFrame(offset+count) && cframe->hasChannel(c)) { auto &m = cframe->get<cv::cuda::GpuMat>(c); cv::Rect roi((count % tx)*rwidth, (count / tx)*rheight, (stereo) ? rwidth/2 : rwidth, rheight); cv::cuda::GpuMat sroi = surface.surface(roi); - m.copyTo(sroi, stream); } else { cv::Rect roi((count % tx)*rwidth, (count / tx)*rheight, rwidth, rheight); diff --git a/components/streams/test/sender_unit.cpp b/components/streams/test/sender_unit.cpp index f16abf8ade90057d682c6604128ac23d670e5e46..753fde010b94071152cc646a90d3f745a2e8b461 100644 --- a/components/streams/test/sender_unit.cpp +++ b/components/streams/test/sender_unit.cpp @@ -220,6 +220,37 @@ TEST_CASE( "Sender::post() video frames" ) { REQUIRE( ftl::codecs::hevc::validNAL(pkt.data.data(), pkt.data.size()) ); } + SECTION("4 depth frames tiled, missing middle") { + stream.select(0, {Channel::Depth}, true); + + fs.resize(4); + + fs.mask = 0xF; + fs.frames[0].create<cv::cuda::GpuMat>(Channel::Depth).create(cv::Size(1280,720), CV_32F); + fs.frames[0].set<cv::cuda::GpuMat>(Channel::Depth).setTo(cv::Scalar(0.0f)); + + for (int i=1; i<4; ++i) { + fs.frames[i].store(); + if (i == 3) continue; + fs.frames[i].create<cv::cuda::GpuMat>(Channel::Depth).create(cv::Size(1280,720), CV_32F); + fs.frames[i].set<cv::cuda::GpuMat>(Channel::Depth).setTo(cv::Scalar(0.0f)); + } + + sender->post(fs, Channel::Depth); + + REQUIRE( count == 1 ); + REQUIRE( spkt.version == 5 ); + REQUIRE( spkt.timestamp == 1000 ); + REQUIRE( (int)spkt.frame_number == 0 ); + REQUIRE( spkt.streamID == 0 ); + REQUIRE( spkt.channel == Channel::Depth ); + REQUIRE( pkt.codec == codec_t::HEVC ); + REQUIRE( pkt.data.size() > 0 ); + REQUIRE( pkt.flags == (ftl::codecs::kFlagFloat | ftl::codecs::kFlagMappedDepth) ); + REQUIRE( pkt.frame_count == 4 ); + REQUIRE( ftl::codecs::hevc::validNAL(pkt.data.data(), pkt.data.size()) ); + } + SECTION("two lossless depth frames tiled") { stream.select(0, {Channel::Depth}, true);