fc1fcae0b0
We now specify intrins as separate DAPS lines. This syntax is much nicer and well-grouped than the previous negtrin-*/postrin-* param names. Alas, we're about to replace it in the next few commits already though.
101 lines
2.4 KiB
C++
101 lines
2.4 KiB
C++
#ifndef _LIVOX_GEN1_PCLOUD_AMBIENCE_QUALE_IFACE_API_H
|
|
#define _LIVOX_GEN1_PCLOUD_AMBIENCE_QUALE_IFACE_API_H
|
|
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
#include <user/deviceAttachmentSpec.h>
|
|
#include <vector>
|
|
|
|
namespace smo {
|
|
namespace stim_buff {
|
|
|
|
inline std::string parseRequiredFromStimbuffQualeIfaceName(
|
|
const std::vector<std::pair<std::string, std::string>>& params)
|
|
{
|
|
for (auto it = params.rbegin(); it != params.rend(); ++it)
|
|
{
|
|
if (it->first != "from-stimbuff")
|
|
{ continue; }
|
|
|
|
if (it->second.empty())
|
|
{
|
|
throw std::runtime_error(
|
|
"'from-stimbuff' must name a non-empty sensory qualeIfaceApi");
|
|
}
|
|
|
|
return it->second;
|
|
}
|
|
|
|
throw std::runtime_error(
|
|
"internal: 'from-stimbuff' missing after intrin policy validation");
|
|
}
|
|
|
|
enum ParamComparatorOp
|
|
{
|
|
OP_CMP_GT,
|
|
OP_CMP_LT,
|
|
};
|
|
|
|
struct ParamComparator
|
|
{
|
|
ParamComparatorOp op;
|
|
uint32_t value;
|
|
|
|
bool operator()(float passbandMetricVal) const
|
|
{
|
|
switch (op)
|
|
{
|
|
case OP_CMP_GT:
|
|
return passbandMetricVal > static_cast<float>(value);
|
|
case OP_CMP_LT:
|
|
return passbandMetricVal < static_cast<float>(value);
|
|
}
|
|
|
|
throw std::runtime_error("Unsupported ParamComparatorOp");
|
|
}
|
|
};
|
|
|
|
inline std::optional<ParamComparator> parseOptionalPcloudAmbienceParamComparator(
|
|
const std::shared_ptr<device::DeviceAttachmentSpec>& deviceAttachmentSpec)
|
|
{
|
|
const auto& params = deviceAttachmentSpec->qualeIfaceApiParams;
|
|
constexpr int kParamNotSpecified = -1;
|
|
const int gtVal = device::DeviceAttachmentSpec::parseOptionalParamAsInt(
|
|
params, "passband-count-gt-val", kParamNotSpecified);
|
|
const int ltVal = device::DeviceAttachmentSpec::parseOptionalParamAsInt(
|
|
params, "passband-count-lt-val", kParamNotSpecified);
|
|
|
|
if (gtVal != kParamNotSpecified && ltVal != kParamNotSpecified)
|
|
{
|
|
throw std::runtime_error(
|
|
"Only one of 'passband-count-gt-val' or 'passband-count-lt-val' "
|
|
"may be specified for a PcloudAmbience intrinsic pipeline");
|
|
}
|
|
|
|
if (gtVal != kParamNotSpecified)
|
|
{
|
|
return std::optional<ParamComparator>(ParamComparator{
|
|
.op = OP_CMP_GT,
|
|
.value = static_cast<uint32_t>(gtVal),
|
|
});
|
|
}
|
|
|
|
if (ltVal != kParamNotSpecified)
|
|
{
|
|
return std::optional<ParamComparator>(ParamComparator{
|
|
.op = OP_CMP_LT,
|
|
.value = static_cast<uint32_t>(ltVal),
|
|
});
|
|
}
|
|
|
|
return std::nullopt;
|
|
}
|
|
|
|
} // namespace stim_buff
|
|
} // namespace smo
|
|
|
|
#endif // _LIVOX_GEN1_PCLOUD_AMBIENCE_QUALE_IFACE_API_H
|