LG1PCloudAmbStncl: Use RangeDescriptor obj instead of StagingBuffer

We directly use an instance of RangeDescriptor to avoid incurring
the memory cost of using a StagingBuffer here. It's unnecessary
since these stencils will always be 32bits large.
This commit is contained in:
2025-11-28 03:34:35 -04:00
parent 1f35dba2ca
commit 0116523a66
6 changed files with 16 additions and 60 deletions
@@ -3,37 +3,23 @@
#include "livoxGen1.h"
#include <user/pcloudAmbienceStencil.h>
#include <user/stagingBuffer.h>
#include <unistd.h>
#include <user/stencil.h>
namespace smo {
namespace stim_buff {
/**
* LG1PcloudAmbienceStencil represents Livox Gen1-specific stencils for
* ambience data. The StagingBuffer is sized to handle the worst-case scenario
* where every ambience body spot requires its own descriptor
* (nDgramsPerFrame slots).
* ambience data. It holds a single RangeDescriptor with bodySpot=0 and
* nContiguousSpots=1.
*/
class LG1PcloudAmbienceStencil
: public PcloudAmbienceStencil
{
public:
// Common IOEngineConstraints for stencil buffer (used for both input and output)
static const StagingBuffer::IOEngineConstraints stencilBufferConstraints;
/**
* Constructor
* @param nDgramsPerFrame Number of datagrams per frame, used to size the
* stencil buffer for worst-case scenario (one descriptor per dgram)
*/
explicit LG1PcloudAmbienceStencil(size_t nDgramsPerFrame)
explicit LG1PcloudAmbienceStencil()
: PcloudAmbienceStencil(),
stencilBuffer(
stencilBufferConstraints, // Input constraints
stencilBufferConstraints, // Output constraints (same as input)
nDgramsPerFrame),
nRangeDescriptors(0)
rangeDescriptor{0, 1}
{}
~LG1PcloudAmbienceStencil() = default;
@@ -41,36 +27,33 @@ public:
// Implement pure virtual functions from Stencil
bool hasData() const override
{
return nRangeDescriptors > 0;
return true;
}
size_t getRelevantCount() const override
{
// TODO: Implement based on range descriptors
return 0;
return rangeDescriptor.nContiguousSpots;
}
bool isRelevant(size_t offset) const override
{
// TODO: Implement based on range descriptors
(void)offset;
return false;
return (offset >= rangeDescriptor.bodySpot &&
offset < rangeDescriptor.bodySpot + rangeDescriptor.nContiguousSpots);
}
size_t getNRangeDescriptors() const override
{
return nRangeDescriptors;
return 1;
}
bool buildStencilMetadata() override
{
// TODO: Implement stencil metadata building
// Metadata is already built (single fixed descriptor)
return true;
}
public:
StagingBuffer stencilBuffer;
size_t nRangeDescriptors;
smo::cologex::Stencil::RangeDescriptor rangeDescriptor;
};
} // namespace stim_buff