@@ -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)
{
@@ -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();
@@ -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(-)