DAPS: Add intrin specs to nontrin specs

We no longer do intrin specs as a separate stimbuff; rather now we
do them as a specifier segment within the pipeline spec of a normal
nontrin spec.
This commit is contained in:
2026-04-18 12:02:27 -04:00
parent fc1fcae0b0
commit 632a227985
16 changed files with 441 additions and 620 deletions
@@ -1,23 +1,58 @@
#ifndef _LIVOX_GEN1_PCLOUD_AMBIENCE_STIMULUS_BUFFER_H
#define _LIVOX_GEN1_PCLOUD_AMBIENCE_STIMULUS_BUFFER_H
#include <memory>
#include <cstddef>
#include <user/stimulusBuffer.h>
#include <user/stagingBuffer.h>
#include <cstdint>
#include <memory>
#include <optional>
#include <string>
#include <user/deviceAttachmentSpec.h>
#include <user/intrin.h>
#include <user/intrinThresholdParams.h>
#include <user/stagingBuffer.h>
#include <user/stimulusBuffer.h>
#include "pcloudAmbienceQualeIfaceApi.h"
namespace smo {
namespace stim_buff {
class StimulusProducer;
inline intrin::IntrinConfig parseAmbienceIntrinConfigFromParams(
std::string_view intrinKind,
const std::vector<std::pair<std::string, std::string>>& params,
size_t nDgramsPerFrame)
{
intrin::validateIntrinSegmentParams(intrinKind, params);
const auto threshold = intrin::parseOptionalThresholdParam(
params,
intrin::kIntrinInterestPcNames,
intrin::kIntrinInterestThrNames,
/*defaultValue=*/0,
/*defaultUnit=*/intrin::ThresholdUnit::Absolute);
return intrin::IntrinConfig{
.percentage =
threshold.unit == intrin::ThresholdUnit::Percentage
? static_cast<uint32_t>(threshold.value)
: 0U,
.threshold = intrin::resolveThresholdValue(
threshold, nDgramsPerFrame),
};
}
/**
* Sensory PcloudAmbience buffer: per-dgram ambience floats only.
* Intrinsic thresholds and passband comparators are only valid on dedicated
* negtrin/postrin qualeIfaceApi specs (PcloudAmbienceIntrinStimulusBuffer);
* see docs/design/intrin-thresholds.md.
* Sensory PcloudAmbience buffer: per-dgram ambience floats. A DAP spec may
* optionally attach a postrin(...) and/or a negtrin(...) specifier to this
* qualeIfaceApi; when present, interest thresholds from those specifiers and
* passband-count comparators from this spec's own qualeIfaceApi params are
* combined to decide when an intrin event should fire.
*
* Convention: the postrin pipeline pairs with passband-count-lt-val (a sparse
* ambient scene being "too good, stay here"); the negtrin pipeline pairs with
* passband-count-gt-val (a dense ambient scene being "unbearably much, get
* away"). Both comparators may be specified simultaneously on this qualeIface.
*/
class PcloudAmbienceStimulusBuffer
: public StimulusBuffer
@@ -38,9 +73,46 @@ public:
callbacks, flags),
nDgramsPerFrame(nDgramsPerFrame_)
{
intrin::validateIntrinsQualeApiPolicy(
intrin::validateNoIntrinParamsOnQualeIface(
deviceAttachmentSpec->qualeIfaceApi,
deviceAttachmentSpec->qualeIfaceApiParams);
const auto passbandComparators =
parsePcloudAmbiencePassbandComparators(deviceAttachmentSpec);
passbandCountLtComparator = passbandComparators.lt;
passbandCountGtComparator = passbandComparators.gt;
if (!deviceAttachmentSpec->postrin.empty())
{
postrinInterestConfig = parseAmbienceIntrinConfigFromParams(
"postrin",
deviceAttachmentSpec->postrinParams,
nDgramsPerFrame_);
if (!passbandCountLtComparator.has_value())
{
throw std::runtime_error(
"pcloudAmbience DAP spec declares a postrin(...) but no "
"'passband-count-lt-val' on the pcloudAmbience qualeIface "
"params to feed it.");
}
}
if (!deviceAttachmentSpec->negtrin.empty())
{
negtrinInterestConfig = parseAmbienceIntrinConfigFromParams(
"negtrin",
deviceAttachmentSpec->negtrinParams,
nDgramsPerFrame_);
if (!passbandCountGtComparator.has_value())
{
throw std::runtime_error(
"pcloudAmbience DAP spec declares a negtrin(...) but no "
"'passband-count-gt-val' on the pcloudAmbience qualeIface "
"params to feed it.");
}
}
}
~PcloudAmbienceStimulusBuffer() = default;
@@ -52,8 +124,24 @@ public:
PcloudAmbienceStimulusBuffer& operator=(
PcloudAmbienceStimulusBuffer&&) = delete;
bool shouldTriggerPostrinEvent(uint32_t ambiencePassbandCount) const
{
if (!postrinInterestConfig.has_value()) { return false; }
return ambiencePassbandCount >= postrinInterestConfig->threshold;
}
bool shouldTriggerNegtrinEvent(uint32_t ambiencePassbandCount) const
{
if (!negtrinInterestConfig.has_value()) { return false; }
return ambiencePassbandCount >= negtrinInterestConfig->threshold;
}
public:
size_t nDgramsPerFrame;
std::optional<intrin::IntrinConfig> postrinInterestConfig;
std::optional<intrin::IntrinConfig> negtrinInterestConfig;
std::optional<ParamComparator> passbandCountLtComparator;
std::optional<ParamComparator> passbandCountGtComparator;
};
} // namespace stim_buff