@@ -541,7 +541,11 @@ int DebayerCpu::configure(const StreamConfiguration &inputCfg,
window_.width = outputCfg.size.width;
window_.height = outputCfg.size.height;
- /* Don't pass x,y since process() already adjusts src before passing it */
+ /*
+ * Set the stats window to the whole processed window. Its coordinates are
+ * relative to the debayered area since debayering passes only the part of
+ * data to be processed to the stats; see SwStatsCpu::setWindow.
+ */
stats_->setWindow(Rectangle(window_.size()));
/* pad with patternSize.Width on both left and right side */
@@ -416,6 +416,22 @@ int SwStatsCpu::configure(const StreamConfiguration &inputCfg)
/**
* \brief Specify window coordinates over which to gather statistics
* \param[in] window The window object.
+ *
+ * This method specifies the image area over which to gather the statistics.
+ * It must be called to set the area, otherwise the default zero-sized
+ * \a Rectangle is used and no statistics is gathered.
+ *
+ * The specified \a window is relative to what is passed to processLine*
+ * methods. Typically, this means processLine* methods get only data from the
+ * processed area and \a window is \a Rectangle with (0, 0) top-left point and
+ * of the same size as the processed area. But if statistics is gathered only
+ * from some part of the image, e.g. its centre, \a window should specify such a
+ * restriction accordingly.
+ *
+ * The method may adjust the window slightly if it is not aligned according to
+ * the bayer pattern determined in \a SwStatsCpu::configure(). Such an
+ * adjustment is guaranteed to not exceed the bounds of
+ * Rectangle(0, 0, window.width, window.height).
*/
void SwStatsCpu::setWindow(const Rectangle &window)
{
The window coordinates passed to SwStatsCpu::setWindow are confusing. Let's clarify what the coordinates should be. A source of confusion is that the specified window is relative to the processed area. Debayering adjusts line pointers for its processed area and this is what's also passed to stats processing. The window passed to SwStatsCpu::setWindow should either specify the size of the whole processed (not image) area, or its cropping in case the stats shouldn't be gathered over the whole processed area. This patch should clarify this in the code. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> --- src/libcamera/software_isp/debayer_cpu.cpp | 6 +++++- src/libcamera/software_isp/swstats_cpu.cpp | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-)