summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Kostovsky <nikita@kostovsky.me>2025-11-08 18:24:01 +0100
committerNikita Kostovsky <nikita@kostovsky.me>2025-11-08 18:24:01 +0100
commit69c5e9c07941212ac77368effd1c60db3140d4a3 (patch)
treef7ae2f9d333a7405c6f046cb51f0aa7db9c4789f
parentc38edfbd30aae121ebdaaac8e8e25f8784da318d (diff)
use vld1q_u32/vst1q_u32 for memcpy
-rw-r--r--src/camera/veyeimx287m.cpp18
-rw-r--r--src/main.cpp4
-rw-r--r--src/mem_utils.cpp1
-rw-r--r--src/mem_utils.h25
4 files changed, 43 insertions, 5 deletions
diff --git a/src/camera/veyeimx287m.cpp b/src/camera/veyeimx287m.cpp
index c7e519a..d4c19fe 100644
--- a/src/camera/veyeimx287m.cpp
+++ b/src/camera/veyeimx287m.cpp
@@ -16,6 +16,7 @@
#include "constants.h"
#include "imagealgos.h"
+#include "mem_utils.h"
#include "pixels.h"
// #include "rotaryencoder.h"
@@ -80,7 +81,8 @@ std::vector<std::shared_ptr<ICamera> > VeyeIMX287m::search()
if (!cam->init())
return {};
- if (!cam->setExposureTimeUs(30))
+ // if (!cam->setExposureTimeUs(30))
+ if (!cam->setExposureTimeUs(250))
return {};
if (!cam->setLaserLevel(1))
@@ -143,7 +145,8 @@ bool VeyeIMX287m::init()
bool VeyeIMX287m::setExposureTimeUs(int valueUs)
{
//return true;
- std::cout << __func__ << ": " << valueUs << std::endl << std::flush;
+ std::cout << __func__ << ": " << V4L2_CID_EXPOSURE << " - " << valueUs << std::endl
+ << std::flush;
/*
* Shutter Time. Value is from 8721ns to 8721*885ns, must be integral
@@ -162,6 +165,7 @@ bool VeyeIMX287m::setExposureTimeUs(int valueUs)
// setLaserLevel(rand() % 100);
// int exp = rand() % 10;
// return setCamParam(V4L2_CID_EXPOSURE, exp * exp * exp * exp * exp * exp);
+ // return setCamParam(V4L2_CID_EXPOSURE, valueUs);
return setCamParam(V4L2_CID_EXPOSURE, valueUs);
}
@@ -218,7 +222,7 @@ bool VeyeIMX287m::setCamParam(unsigned int v4l2controlId, int value)
return false;
}
- // std::cout << __func__ << ": new value is " << ctl.value << std::endl;
+ std::cout << __func__ << ": new value is " << ctl.value << std::endl;
return true;
}
@@ -374,7 +378,13 @@ void VeyeIMX287m::calcFrameLoop(std::stop_token stopToken)
{
t.start();
// std::lock_guard buffer_lock{m_bufferMutexes[bufferIdx]};
- memcpy(&image.data, m_videoBuffers[bufferIdx], img_size);
+ // get: 4100-4500
+ // memcpy(&image.data, m_videoBuffers[bufferIdx], img_size);
+ // get: 5000-5100
+ // memcpy_1by1<img_size>((std::byte *) &image.data,
+ // (std::byte *) m_videoBuffers[bufferIdx]);
+ memcpy_neon<img_size / sizeof(ARRAY_TYPE)>((ARRAY_TYPE *) &image.data,
+ (ARRAY_TYPE *) m_videoBuffers[bufferIdx]);
get_elapsed_ns += t.nsecsElapsed();
}
diff --git a/src/main.cpp b/src/main.cpp
index ca2da6f..46f8d6d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -656,9 +656,11 @@ int main(int argc, char* argv[])
// qDebug() << "set new exposure time:" << value;
// requested_params.exposureTime = value;
- if (!camera->setExposureTimeUs(value))
+ if (!camera->setExposureTimeUs(value)) {
+ qDebug() << "cannot set exp";
return QHttpServerResponse::StatusCode::
RequestRangeNotSatisfiable;
+ }
}
if (json.contains(gainKey))
diff --git a/src/mem_utils.cpp b/src/mem_utils.cpp
new file mode 100644
index 0000000..f5fae0f
--- /dev/null
+++ b/src/mem_utils.cpp
@@ -0,0 +1 @@
+#include "mem_utils.h"
diff --git a/src/mem_utils.h b/src/mem_utils.h
new file mode 100644
index 0000000..8601f78
--- /dev/null
+++ b/src/mem_utils.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include <cstddef>
+
+#include <arm_neon.h>
+
+template<std::size_t S>
+void memcpy_1by1(std::byte *dst, const std::byte *src)
+{
+ for (std::size_t i{0}; i < S; ++i) {
+ dst[i] = src[i];
+ }
+}
+
+using ARRAY_TYPE = uint32_t;
+template<std::size_t S>
+void memcpy_neon(ARRAY_TYPE *dst, const ARRAY_TYPE *src)
+{
+ uint32x4_t tmp;
+
+ for (std::size_t i{0}; i < (S / 4); i += 4) {
+ tmp = vld1q_u32(src + i);
+ vst1q_u32(&dst[i], tmp);
+ }
+}