2025-11-14 23:19:32 -04:00
|
|
|
#ifndef _LIVOX_GEN1_PCLOUD_AMBIENCE_STIMULUS_BUFFER_H
|
|
|
|
|
#define _LIVOX_GEN1_PCLOUD_AMBIENCE_STIMULUS_BUFFER_H
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
2025-11-23 07:20:55 -04:00
|
|
|
#include <cstdint>
|
2025-11-26 13:00:24 -04:00
|
|
|
#include <list>
|
|
|
|
|
#include <cstddef>
|
2025-11-28 00:12:18 -04:00
|
|
|
#include <vector>
|
|
|
|
|
#include <string>
|
2025-11-14 23:19:32 -04:00
|
|
|
#include <user/stimulusBuffer.h>
|
2025-11-16 16:09:35 -04:00
|
|
|
#include <user/stagingBuffer.h>
|
2025-11-28 00:12:18 -04:00
|
|
|
#include <user/deviceAttachmentSpec.h>
|
2025-11-26 13:00:24 -04:00
|
|
|
#include "lg1PcloudAmbienceStencil.h"
|
2025-11-14 23:19:32 -04:00
|
|
|
|
|
|
|
|
namespace smo {
|
|
|
|
|
namespace stim_buff {
|
|
|
|
|
|
|
|
|
|
// Forward declaration
|
|
|
|
|
class StimulusProducer;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* PcloudAmbienceStimulusBuffer is a specialized StimulusBuffer for ambience point cloud data.
|
|
|
|
|
*/
|
|
|
|
|
class PcloudAmbienceStimulusBuffer
|
|
|
|
|
: public StimulusBuffer
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
explicit PcloudAmbienceStimulusBuffer(
|
2025-11-15 01:15:57 -04:00
|
|
|
StimulusProducer& parent,
|
2025-11-14 23:19:32 -04:00
|
|
|
const std::shared_ptr<device::DeviceAttachmentSpec>& deviceAttachmentSpec,
|
|
|
|
|
int histbuffMs,
|
2025-11-16 16:09:35 -04:00
|
|
|
const StagingBuffer::IOEngineConstraints& inputEngineConstraints,
|
2025-11-19 23:43:17 -04:00
|
|
|
const StagingBuffer::IOEngineConstraints& outputEngineConstraints,
|
|
|
|
|
const SmoCallbacks& callbacks,
|
2025-11-23 07:20:55 -04:00
|
|
|
cl_mem_flags flags,
|
2025-11-26 13:00:24 -04:00
|
|
|
size_t nStencils_, size_t nDgramsPerFrame_)
|
2025-11-14 23:19:32 -04:00
|
|
|
: StimulusBuffer(
|
2025-11-16 16:09:35 -04:00
|
|
|
parent, deviceAttachmentSpec, histbuffMs,
|
2025-11-19 23:43:17 -04:00
|
|
|
inputEngineConstraints, outputEngineConstraints,
|
2025-11-23 07:20:55 -04:00
|
|
|
callbacks, flags),
|
2025-11-26 13:00:24 -04:00
|
|
|
nStencils(nStencils_)
|
|
|
|
|
{
|
2025-11-28 00:12:18 -04:00
|
|
|
// Parse postrinInterestThreshold from qualeIfaceApiParams
|
|
|
|
|
const std::vector<std::string> postrinInterestThresholdParamNames = {
|
|
|
|
|
"postrin-interest-threshold",
|
|
|
|
|
"postrin-interest"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** EXPLANATION:
|
|
|
|
|
* The default postrin threshold is determined as follows:
|
|
|
|
|
* We want 90% of the scanned points to have intensity under the
|
|
|
|
|
* lowVal to consider the ambience criterion met.
|
|
|
|
|
*
|
|
|
|
|
* If nDgramsPerFrame_ (the number of datagrams per frame) is less
|
|
|
|
|
* than 10, we require that all frames (100%) be under the lowVal.
|
|
|
|
|
* This is because, for such small sample sizes, calculating 90%
|
|
|
|
|
* does not yield a meaningful integer; for example, 90% of 7 is
|
|
|
|
|
* 6.3, but we must count whole frames that meet the threshold. By
|
|
|
|
|
* using nDgramsPerFrame_ as the threshold in this case, we ensure
|
|
|
|
|
* logical, all-or-nothing evaluation at low sample counts while
|
|
|
|
|
* maintaining an approximate 90% requirement for larger frame
|
|
|
|
|
* sizes.
|
|
|
|
|
*/
|
|
|
|
|
uint32_t defaultPostrinThreshold = (nDgramsPerFrame_ < 10)
|
|
|
|
|
? static_cast<uint32_t>(nDgramsPerFrame_)
|
|
|
|
|
: static_cast<uint32_t>(nDgramsPerFrame_ * 9 / 10);
|
|
|
|
|
|
|
|
|
|
postrinInterestThreshold = static_cast<uint32_t>(
|
|
|
|
|
device::DeviceAttachmentSpec::parseOptionalParamAsIntWithSynonyms(
|
|
|
|
|
deviceAttachmentSpec->qualeIfaceApiParams,
|
|
|
|
|
postrinInterestThresholdParamNames,
|
|
|
|
|
defaultPostrinThreshold));
|
|
|
|
|
// Parse ambienceIntensityLowVal from qualeIfaceApiParams
|
|
|
|
|
const std::vector<std::string> ambienceIntensityLowValParamNames = {
|
|
|
|
|
"ambience-intensity-low-val"
|
|
|
|
|
};
|
|
|
|
|
ambienceIntensityLowVal = static_cast<uint32_t>(
|
|
|
|
|
device::DeviceAttachmentSpec::parseOptionalParamAsIntWithSynonyms(
|
|
|
|
|
deviceAttachmentSpec->qualeIfaceApiParams,
|
|
|
|
|
ambienceIntensityLowValParamNames, 8));
|
|
|
|
|
|
2025-11-26 13:00:24 -04:00
|
|
|
// Construct stencils and add to list (FIFO behavior)
|
|
|
|
|
for (size_t i = 0; i < nStencils; ++i) {
|
|
|
|
|
stencils.emplace_back(nDgramsPerFrame_);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-11-14 23:19:32 -04:00
|
|
|
|
|
|
|
|
~PcloudAmbienceStimulusBuffer() = default;
|
|
|
|
|
|
|
|
|
|
// Non-copyable, movable
|
|
|
|
|
PcloudAmbienceStimulusBuffer(const PcloudAmbienceStimulusBuffer&) = delete;
|
|
|
|
|
PcloudAmbienceStimulusBuffer& operator=(const PcloudAmbienceStimulusBuffer&) = delete;
|
|
|
|
|
PcloudAmbienceStimulusBuffer(PcloudAmbienceStimulusBuffer&&) = default;
|
|
|
|
|
PcloudAmbienceStimulusBuffer& operator=(PcloudAmbienceStimulusBuffer&&) = default;
|
2025-11-23 07:20:55 -04:00
|
|
|
|
|
|
|
|
public:
|
2025-11-28 00:12:18 -04:00
|
|
|
uint32_t postrinInterestThreshold;
|
|
|
|
|
uint32_t ambienceIntensityLowVal;
|
2025-11-26 13:00:24 -04:00
|
|
|
size_t nStencils;
|
|
|
|
|
std::list<LG1PcloudAmbienceStencil> stencils;
|
2025-11-14 23:19:32 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace stim_buff
|
|
|
|
|
} // namespace smo
|
|
|
|
|
|
|
|
|
|
#endif // _LIVOX_GEN1_PCLOUD_AMBIENCE_STIMULUS_BUFFER_H
|