Skip to content

Commit 42bfb15

Browse files
authored
Merge pull request #1362 from luxonis/lnotspotl/xlinkin_lazy_allocation
XLinkIn lazy buffer allocation
2 parents 487e34c + 307eb5e commit 42bfb15

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed

cmake/Depthai/DepthaiDeviceSideConfig.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set(DEPTHAI_DEVICE_SIDE_MATURITY "snapshot")
33

44
# "full commit hash of device side binary"
5-
set(DEPTHAI_DEVICE_SIDE_COMMIT "185b62d2d420d12e8558705e7ce4a022e7a499c5")
5+
set(DEPTHAI_DEVICE_SIDE_COMMIT "11b35efacca28894f2b3fc930a4b15d4b8a4213d")
66

77
# "version if applicable"
88
set(DEPTHAI_DEVICE_SIDE_VERSION "")

include/depthai/properties/internal/XLinkInProperties.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ struct XLinkInProperties : PropertiesSerializable<Properties, XLinkInProperties>
1616
std::string streamName;
1717

1818
/**
19-
* Maximum input data size
19+
* Maximum input data size:
20+
* NV12 --> 1.5 = (3/2) bytes per pixel, roughly 17.6MB for a 4032x3056 frame
2021
*/
21-
std::uint32_t maxDataSize = dai::device::XLINK_USB_BUFFER_MAX_SIZE;
22+
std::uint32_t maxDataSize = ((4032 * 3056) * 3) / 2;
2223

2324
/**
2425
* Number of frames in pool

tests/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,3 +479,7 @@ dai_set_test_labels(camera_test ondevice rvc2_all rvc4 ci)
479479
# VideoEncoder test
480480
dai_add_test(video_encoder_test src/ondevice_tests/video_encoder_test.cpp)
481481
dai_set_test_labels(video_encoder_test ondevice rvc2_all rvc4 ci)
482+
483+
# XLinkIn test
484+
dai_add_test(xlink_test src/ondevice_tests/xlink_tests.cpp)
485+
dai_set_test_labels(xlink_test ondevice rvc2_all ci)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <catch2/catch_all.hpp>
2+
#include <catch2/catch_test_macros.hpp>
3+
#include <depthai/depthai.hpp>
4+
#include <depthai/pipeline/node/internal/XLinkIn.hpp>
5+
6+
#include <thread>
7+
#include <chrono>
8+
using namespace std::chrono_literals;
9+
10+
TEST_CASE("XLinkIn lazy allocation test") {
11+
dai::Pipeline p;
12+
auto manip = p.create<dai::node::ImageManip>()->build();
13+
14+
auto xLinkInImage = p.create<dai::node::internal::XLinkIn>();
15+
auto xLinkInConfig = p.create<dai::node::internal::XLinkIn>();
16+
17+
xLinkInImage->setMaxDataSize(1024 * 1024 * 1024); // 1GB per frame
18+
xLinkInImage->setNumFrames(64);
19+
20+
xLinkInConfig->setMaxDataSize(1024 * 1024 * 1024); // 1GB per frame
21+
xLinkInConfig->setNumFrames(64);
22+
23+
xLinkInImage->out.link(manip->inputImage);
24+
xLinkInConfig->out.link(manip->inputConfig);
25+
26+
auto run = [&]() {
27+
p.start();
28+
std::this_thread::sleep_for(1s);
29+
};
30+
31+
// Without lazy allocation, this will throw as all the above XLinkIn nodes
32+
// would allocate all the frames at once.
33+
REQUIRE_NOTHROW(p.build());
34+
REQUIRE_NOTHROW(run());
35+
}

0 commit comments

Comments
 (0)