PcloudAmbienceStimBuff: Parse postrinThreshold as percentage

This commit is contained in:
2025-12-02 14:05:51 -04:00
parent 33681059b0
commit e06b2d7e06
@@ -40,36 +40,21 @@ public:
callbacks, flags), callbacks, flags),
nStencils(nStencils_) nStencils(nStencils_)
{ {
// Parse postrinInterestThreshold from qualeIfaceApiParams // Parse postrinInterestPercentage (interpreted as percentage 0-100)
const std::vector<std::string> postrinInterestThresholdParamNames = { const std::vector<std::string> postrinInterestThresholdParamNames = {
"postrin-interest-threshold", "postrin-interest-threshold",
"postrin-interest" "postrin-interest"
}; };
/** EXPLANATION: postrinInterestPercentage = static_cast<uint32_t>(
* 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( device::DeviceAttachmentSpec::parseOptionalParamAsIntWithSynonyms(
deviceAttachmentSpec->qualeIfaceApiParams, deviceAttachmentSpec->qualeIfaceApiParams,
postrinInterestThresholdParamNames, postrinInterestThresholdParamNames,
defaultPostrinThreshold)); 90));
// Convert percentage to absolute frame count
postrinInterestThreshold = static_cast<uint32_t>(
(nDgramsPerFrame_ * postrinInterestPercentage) / 100);
// Parse ambienceIntensityLowVal from qualeIfaceApiParams // Parse ambienceIntensityLowVal from qualeIfaceApiParams
const std::vector<std::string> ambienceIntensityLowValParamNames = { const std::vector<std::string> ambienceIntensityLowValParamNames = {
"ambience-intensity-low-val" "ambience-intensity-low-val"
@@ -94,6 +79,7 @@ public:
PcloudAmbienceStimulusBuffer& operator=(PcloudAmbienceStimulusBuffer&&) = default; PcloudAmbienceStimulusBuffer& operator=(PcloudAmbienceStimulusBuffer&&) = default;
public: public:
uint32_t postrinInterestPercentage;
uint32_t postrinInterestThreshold; uint32_t postrinInterestThreshold;
uint32_t ambienceIntensityLowVal; uint32_t ambienceIntensityLowVal;
size_t nStencils; size_t nStencils;