libcamera: software_isp: debayer: Take DebayerParams by ref
When calling `Debayer::process()` from `SoftwareIsp::process()`, the
`DebayerParams` object is copied multiple times:
(1) call of `BoundMethodMember<...>::activate()`
inside `Object::invokeMethod()`
(2) constructor of `BoundMethodArgs<...>`
inside `BoundMethodMember<...>::activate()`
(3) call of `BoundMethodMember<...>::invoke()`
inside `BoundMethodArgs::invokePack()`
(4) call of the actual pointer to member function
inside `BoundMethodMember::invoke()`
While compilers might avoid one or two of the above copies, this is still
not ideal. By making `Debayer::process()` take the parameter object by
const lvalue reference, only the copy in the `BoundMethodArgs` constructor
remains. So do that.
Before:
[0:12:51.133836595] [12424] DEBUG SoftwareIsp software_isp.cpp:399 params=0x7d0a691f57d0
copy from 0x7d0a691f57d0 into 0x7baa65f2bf30
copy from 0x7baa65f2bf30 into 0x7c6a69209758
copy from 0x7c6a69209758 into 0x7baa63223930
copy from 0x7baa63223930 into 0x7baa63223a70
[0:12:51.134559602] [12426] DEBUG eGL debayer_egl.cpp:538 params=0x7baa63223a70
771.099877 (30.06 fps) cam0-stream0 seq: 000031 bytesused: 8666112
After:
[0:13:42.861691943] [12543] DEBUG SoftwareIsp software_isp.cpp:399 params=0x7cfaad5f57d0
copy from 0x7cfaad5f57d0 into 0x7c5aad609758
[0:13:42.862453917] [12545] DEBUG eGL debayer_egl.cpp:538 params=0x7c5aad609758
822.827388 (30.02 fps) cam0-stream0 seq: 000031 bytesused: 8666112
Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
This commit is contained in:
@@ -47,7 +47,7 @@ public:
|
||||
virtual std::tuple<unsigned int, unsigned int>
|
||||
strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) = 0;
|
||||
|
||||
virtual void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params) = 0;
|
||||
virtual void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms) = 0;
|
||||
virtual int start() { return 0; }
|
||||
virtual void stop() {}
|
||||
|
||||
|
||||
@@ -750,7 +750,7 @@ void DebayerCpu::process4(uint32_t frame, const uint8_t *src, uint8_t *dst)
|
||||
}
|
||||
}
|
||||
|
||||
void DebayerCpu::updateGammaTable(DebayerParams ¶ms)
|
||||
void DebayerCpu::updateGammaTable(const DebayerParams ¶ms)
|
||||
{
|
||||
const RGB<float> blackLevel = params.blackLevel;
|
||||
/* Take let's say the green channel black level */
|
||||
@@ -780,7 +780,7 @@ void DebayerCpu::updateGammaTable(DebayerParams ¶ms)
|
||||
gammaTable_[blackIndex]);
|
||||
}
|
||||
|
||||
void DebayerCpu::updateLookupTables(DebayerParams ¶ms)
|
||||
void DebayerCpu::updateLookupTables(const DebayerParams ¶ms)
|
||||
{
|
||||
const bool gammaUpdateNeeded =
|
||||
params.gamma != params_.gamma ||
|
||||
@@ -842,7 +842,7 @@ void DebayerCpu::updateLookupTables(DebayerParams ¶ms)
|
||||
params_ = params;
|
||||
}
|
||||
|
||||
void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params)
|
||||
void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms)
|
||||
{
|
||||
bench_.startFrame();
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
std::vector<PixelFormat> formats(PixelFormat input);
|
||||
std::tuple<unsigned int, unsigned int>
|
||||
strideAndFrameSize(const PixelFormat &outputFormat, const Size &size);
|
||||
void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params);
|
||||
void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms);
|
||||
SizeRange sizes(PixelFormat inputFormat, const Size &inputSize);
|
||||
const SharedFD &getStatsFD() { return stats_->getStatsFD(); }
|
||||
|
||||
@@ -110,8 +110,8 @@ private:
|
||||
void memcpyNextLine(const uint8_t *linePointers[]);
|
||||
void process2(uint32_t frame, const uint8_t *src, uint8_t *dst);
|
||||
void process4(uint32_t frame, const uint8_t *src, uint8_t *dst);
|
||||
void updateGammaTable(DebayerParams ¶ms);
|
||||
void updateLookupTables(DebayerParams ¶ms);
|
||||
void updateGammaTable(const DebayerParams ¶ms);
|
||||
void updateLookupTables(const DebayerParams ¶ms);
|
||||
|
||||
/* Max. supported Bayer pattern height is 4, debayering this requires 5 lines */
|
||||
static constexpr unsigned int kMaxLineBuffers = 5;
|
||||
|
||||
@@ -383,7 +383,7 @@ DebayerEGL::strideAndFrameSize(const PixelFormat &outputFormat, const Size &size
|
||||
return std::make_tuple(stride, stride * size.height);
|
||||
}
|
||||
|
||||
void DebayerEGL::setShaderVariableValues(DebayerParams ¶ms)
|
||||
void DebayerEGL::setShaderVariableValues(const DebayerParams ¶ms)
|
||||
{
|
||||
/*
|
||||
* Raw Bayer 8-bit, and packed raw Bayer 10-bit/12-bit formats
|
||||
@@ -506,7 +506,7 @@ void DebayerEGL::setShaderVariableValues(DebayerParams ¶ms)
|
||||
return;
|
||||
}
|
||||
|
||||
int DebayerEGL::debayerGPU(MappedFrameBuffer &in, int out_fd, DebayerParams ¶ms)
|
||||
int DebayerEGL::debayerGPU(MappedFrameBuffer &in, int out_fd, const DebayerParams ¶ms)
|
||||
{
|
||||
/* eGL context switch */
|
||||
egl_.makeCurrent();
|
||||
@@ -533,7 +533,7 @@ int DebayerEGL::debayerGPU(MappedFrameBuffer &in, int out_fd, DebayerParams &par
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params)
|
||||
void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms)
|
||||
{
|
||||
bench_.startFrame();
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
std::vector<PixelFormat> formats(PixelFormat input);
|
||||
std::tuple<unsigned int, unsigned int> strideAndFrameSize(const PixelFormat &outputFormat, const Size &size);
|
||||
|
||||
void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params);
|
||||
void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, const DebayerParams ¶ms);
|
||||
int start();
|
||||
void stop();
|
||||
|
||||
@@ -72,9 +72,9 @@ private:
|
||||
std::vector<std::string> shaderEnv);
|
||||
int linkShaderProgram(void);
|
||||
int getShaderVariableLocations();
|
||||
void setShaderVariableValues(DebayerParams ¶ms);
|
||||
void setShaderVariableValues(const DebayerParams ¶ms);
|
||||
void configureTexture(GLuint &texture);
|
||||
int debayerGPU(MappedFrameBuffer &in, int out_fd, DebayerParams ¶ms);
|
||||
int debayerGPU(MappedFrameBuffer &in, int out_fd, const DebayerParams ¶ms);
|
||||
|
||||
/* Shader program identifiers */
|
||||
GLuint vertexShaderId_ = 0;
|
||||
|
||||
Reference in New Issue
Block a user