| Message ID | 20260521155906.120373-5-robert.mader@collabora.com |
|---|---|
| State | Superseded |
| Headers | show |
| Series |
|
| Related | show |
On 21/05/2026 16:59, Robert Mader wrote: > -void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *input) > +void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, MappedFrameBuffer *input) > { > - if (frame % kStatPerNumFrames) { > + if (!input || frame % kStatPerNumFrames) { > finishFrame(frame, bufferId); > return; > } Why pass NULL at all ? It just occurs to me its probably better to change the logic calling the function than make the function handle null. --- bod
On 26.05.26 19:40, Bryan O'Donoghue wrote: > On 21/05/2026 16:59, Robert Mader wrote: >> -void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *input) >> +void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, MappedFrameBuffer *input) >> { >> - if (frame % kStatPerNumFrames) { >> + if (!input || frame % kStatPerNumFrames) { >> finishFrame(frame, bufferId); >> return; >> } > Why pass NULL at all ? > > It just occurs to me its probably better to change the logic calling the > function than make the function handle null. Did that in v5 > > --- > bod >
diff --git a/include/libcamera/internal/software_isp/swstats_cpu.h b/include/libcamera/internal/software_isp/swstats_cpu.h index b5348c6fe..c9ed1d0a6 100644 --- a/include/libcamera/internal/software_isp/swstats_cpu.h +++ b/include/libcamera/internal/software_isp/swstats_cpu.h @@ -56,7 +56,7 @@ public: void setWindow(const Rectangle &window); void startFrame(uint32_t frame); void finishFrame(uint32_t frame, uint32_t bufferId); - void processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *input); + void processFrame(uint32_t frame, uint32_t bufferId, MappedFrameBuffer *input); void processLine0(uint32_t frame, unsigned int y, const uint8_t *src[], unsigned int statsBufferIndex = 0) { diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index 696498a58..d15f3cd48 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -555,7 +555,7 @@ void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output metadata.planes()[0].bytesused = output->planes()[0].length; /* Calculate stats for the whole frame */ - stats_->processFrame(frame, 0, input); + stats_->processFrame(frame, 0, &in); dmaSyncers.clear(); egl_.syncOutput(); diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp index 0815ec9a3..b182a1a2b 100644 --- a/src/libcamera/software_isp/swstats_cpu.cpp +++ b/src/libcamera/software_isp/swstats_cpu.cpp @@ -543,23 +543,16 @@ void SwStatsCpu::processBayerFrame2(MappedFrameBuffer &in) * * This may only be called after a successful setWindow() call. */ -void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *input) +void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, MappedFrameBuffer *input) { - if (frame % kStatPerNumFrames) { + if (!input || frame % kStatPerNumFrames) { finishFrame(frame, bufferId); return; } bench_.startFrame(); startFrame(frame); - - MappedFrameBuffer in(input, MappedFrameBuffer::MapFlag::Read); - if (!in.isValid()) { - LOG(SwStatsCpu, Error) << "mmap-ing buffer(s) failed"; - return; - } - - (this->*processFrame_)(in); + (this->*processFrame_)(*input); finishFrame(frame, bufferId); bench_.finishFrame(); }
As the only current user - DebayerEGL::process() - already has the buffer mapped. Currently this shouldn't impact performance as the kernel should already avoid remapping the dmabuf - i.e. we implicitly benefit from the fact that the mentioned function holds its mapping during the runtime of processFrame(). In a following commit DebayerEGL::process() will change in a way that would make keeping the mapping counter-intuitive. Thus this change ensures we'll not accidentally start mapping the buffer twice per frame. Signed-off-by: Robert Mader <robert.mader@collabora.com> --- .../libcamera/internal/software_isp/swstats_cpu.h | 2 +- src/libcamera/software_isp/debayer_egl.cpp | 2 +- src/libcamera/software_isp/swstats_cpu.cpp | 13 +++---------- 3 files changed, 5 insertions(+), 12 deletions(-)