libcamera: software_isp: Make measurement configurable
Software ISP performs performance measurement on certain part of initial frames. Let's make this range configurable. For this purpose, this patch introduces new configuration options software_isp.measure.skip and software_isp.measure.number. Setting the latter one to 0 disables the measurement. Instead of the last frame, the class member and its configuration specify the number of frames to measure. This is easier to use for users and doesn't require to adjust two configuration parameters when the number of the initially skipped frames is changed. The patch also changes the names of the class members to make them more accurate. Completes software ISP TODO #7. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
committed by
Laurent Pinchart
parent
6e1d889cfe
commit
79a75b9088
@@ -71,31 +71,6 @@ per-frame buffers like we do for hardware ISPs.
|
||||
|
||||
---
|
||||
|
||||
7. Performance measurement configuration
|
||||
|
||||
> void DebayerCpu::process(FrameBuffer *input, FrameBuffer *output, DebayerParams params)
|
||||
> /* Measure before emitting signals */
|
||||
> if (measuredFrames_ < DebayerCpu::kLastFrameToMeasure &&
|
||||
> ++measuredFrames_ > DebayerCpu::kFramesToSkip) {
|
||||
> timespec frameEndTime = {};
|
||||
> clock_gettime(CLOCK_MONOTONIC_RAW, &frameEndTime);
|
||||
> frameProcessTime_ += timeDiff(frameEndTime, frameStartTime);
|
||||
> if (measuredFrames_ == DebayerCpu::kLastFrameToMeasure) {
|
||||
> const unsigned int measuredFrames = DebayerCpu::kLastFrameToMeasure -
|
||||
> DebayerCpu::kFramesToSkip;
|
||||
> LOG(Debayer, Info)
|
||||
> << "Processed " << measuredFrames
|
||||
> << " frames in " << frameProcessTime_ / 1000 << "us, "
|
||||
> << frameProcessTime_ / (1000 * measuredFrames)
|
||||
> << " us/frame";
|
||||
> }
|
||||
> }
|
||||
|
||||
I wonder if there would be a way to control at runtime when/how to
|
||||
perform those measurements. Maybe that's a bit overkill.
|
||||
|
||||
---
|
||||
|
||||
8. DebayerCpu cleanups
|
||||
|
||||
> >> class DebayerCpu : public Debayer, public Object
|
||||
|
||||
@@ -58,6 +58,13 @@ DebayerCpu::DebayerCpu(std::unique_ptr<SwStatsCpu> stats, const GlobalConfigurat
|
||||
enableInputMemcpy_ =
|
||||
configuration.option<bool>({ "software_isp", "copy_input_buffer" }).value_or(true);
|
||||
|
||||
skipBeforeMeasure_ = configuration.option<unsigned int>(
|
||||
{ "software_isp", "measure", "skip" })
|
||||
.value_or(skipBeforeMeasure_);
|
||||
framesToMeasure_ = configuration.option<unsigned int>(
|
||||
{ "software_isp", "measure", "number" })
|
||||
.value_or(framesToMeasure_);
|
||||
|
||||
/* Initialize color lookup tables */
|
||||
for (unsigned int i = 0; i < DebayerParams::kRGBLookupSize; i++) {
|
||||
red_[i] = green_[i] = blue_[i] = i;
|
||||
@@ -560,7 +567,7 @@ int DebayerCpu::configure(const StreamConfiguration &inputCfg,
|
||||
lineBuffers_[i].resize(lineBufferLength_);
|
||||
}
|
||||
|
||||
measuredFrames_ = 0;
|
||||
encounteredFrames_ = 0;
|
||||
frameProcessTime_ = 0;
|
||||
|
||||
return 0;
|
||||
@@ -766,7 +773,10 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output
|
||||
{
|
||||
timespec frameStartTime;
|
||||
|
||||
if (measuredFrames_ < DebayerCpu::kLastFrameToMeasure) {
|
||||
bool measure = framesToMeasure_ > 0 &&
|
||||
encounteredFrames_ < skipBeforeMeasure_ + framesToMeasure_ &&
|
||||
++encounteredFrames_ > skipBeforeMeasure_;
|
||||
if (measure) {
|
||||
frameStartTime = {};
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &frameStartTime);
|
||||
}
|
||||
@@ -823,18 +833,15 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output
|
||||
dmaSyncers.clear();
|
||||
|
||||
/* Measure before emitting signals */
|
||||
if (measuredFrames_ < DebayerCpu::kLastFrameToMeasure &&
|
||||
++measuredFrames_ > DebayerCpu::kFramesToSkip) {
|
||||
if (measure) {
|
||||
timespec frameEndTime = {};
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &frameEndTime);
|
||||
frameProcessTime_ += timeDiff(frameEndTime, frameStartTime);
|
||||
if (measuredFrames_ == DebayerCpu::kLastFrameToMeasure) {
|
||||
const unsigned int measuredFrames = DebayerCpu::kLastFrameToMeasure -
|
||||
DebayerCpu::kFramesToSkip;
|
||||
if (encounteredFrames_ == skipBeforeMeasure_ + framesToMeasure_) {
|
||||
LOG(Debayer, Info)
|
||||
<< "Processed " << measuredFrames
|
||||
<< "Processed " << framesToMeasure_
|
||||
<< " frames in " << frameProcessTime_ / 1000 << "us, "
|
||||
<< frameProcessTime_ / (1000 * measuredFrames)
|
||||
<< frameProcessTime_ / (1000 * framesToMeasure_)
|
||||
<< " us/frame";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,11 +161,10 @@ private:
|
||||
unsigned int xShift_; /* Offset of 0/1 applied to window_.x */
|
||||
bool enableInputMemcpy_;
|
||||
bool swapRedBlueGains_;
|
||||
unsigned int measuredFrames_;
|
||||
unsigned int encounteredFrames_;
|
||||
int64_t frameProcessTime_;
|
||||
/* Skip 30 frames for things to stabilize then measure 30 frames */
|
||||
static constexpr unsigned int kFramesToSkip = 30;
|
||||
static constexpr unsigned int kLastFrameToMeasure = 60;
|
||||
unsigned int skipBeforeMeasure_ = 30;
|
||||
unsigned int framesToMeasure_ = 30;
|
||||
};
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
||||
Reference in New Issue
Block a user