Message ID | 20250821134141.83236-3-mzamazal@redhat.com |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
Hi Maciej, Milan Zamazal <mzamazal@redhat.com> writes: > The window set by SwStatsCpu::setWindow is relative to the processed > image area. But debayering passes the processed line y-coordinate to > the stats relative to the whole image area. This can result in > gathering stats from a wrong image area or in not gathering stats at > all. > > Let's pass the correct y-coordinate to the stats processing methods. > > Bug: https://bugs.libcamera.org/show_bug.cgi?id=280 > Co-developed-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name> Feel free to attach your Signed-off-by here to get this line replaced by it. > Signed-off-by: Milan Zamazal <mzamazal@redhat.com> > --- > src/libcamera/software_isp/debayer_cpu.cpp | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp > index bcc847ae6..185edd814 100644 > --- a/src/libcamera/software_isp/debayer_cpu.cpp > +++ b/src/libcamera/software_isp/debayer_cpu.cpp > @@ -648,7 +648,7 @@ void DebayerCpu::memcpyNextLine(const uint8_t *linePointers[]) > > void DebayerCpu::process2(const uint8_t *src, uint8_t *dst) > { > - unsigned int yEnd = window_.y + window_.height; > + unsigned int yEnd = window_.height; > /* Holds [0] previous- [1] current- [2] next-line */ > const uint8_t *linePointers[3]; > > @@ -664,12 +664,12 @@ void DebayerCpu::process2(const uint8_t *src, uint8_t *dst) > linePointers[1] = src + inputConfig_.stride; > linePointers[2] = src; > /* Last 2 lines also need special handling */ > - yEnd -= 2; > + yEnd = (yEnd > 2 ? yEnd - 2 : 0); > } > > setupInputMemcpy(linePointers); > > - for (unsigned int y = window_.y; y < yEnd; y += 2) { > + for (unsigned int y = 0; y < yEnd; y += 2) { > shiftLinePointers(linePointers, src); > memcpyNextLine(linePointers); > stats_->processLine0(y, linePointers); > @@ -703,7 +703,7 @@ void DebayerCpu::process2(const uint8_t *src, uint8_t *dst) > > void DebayerCpu::process4(const uint8_t *src, uint8_t *dst) > { > - const unsigned int yEnd = window_.y + window_.height; > + const unsigned int yEnd = window_.height; > /* > * This holds pointers to [0] 2-lines-up [1] 1-line-up [2] current-line > * [3] 1-line-down [4] 2-lines-down. > @@ -721,7 +721,7 @@ void DebayerCpu::process4(const uint8_t *src, uint8_t *dst) > > setupInputMemcpy(linePointers); > > - for (unsigned int y = window_.y; y < yEnd; y += 4) { > + for (unsigned int y = 0; y < yEnd; y += 4) { > shiftLinePointers(linePointers, src); > memcpyNextLine(linePointers); > stats_->processLine0(y, linePointers);
Hi Milan, On 21.08.2025 15:52, Milan Zamazal wrote: > Hi Maciej, > > Milan Zamazal <mzamazal@redhat.com> writes: > >> The window set by SwStatsCpu::setWindow is relative to the processed >> image area. But debayering passes the processed line y-coordinate to >> the stats relative to the whole image area. This can result in >> gathering stats from a wrong image area or in not gathering stats at >> all. >> >> Let's pass the correct y-coordinate to the stats processing methods. >> >> Bug: https://bugs.libcamera.org/show_bug.cgi?id=280 >> Co-developed-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name> Thanks for including this patch in your series. > Feel free to attach your Signed-off-by here to get this line replaced by > it. > >> Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Sure, here's my SoB tag: Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name> Thanks, Maciej
diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index bcc847ae6..185edd814 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -648,7 +648,7 @@ void DebayerCpu::memcpyNextLine(const uint8_t *linePointers[]) void DebayerCpu::process2(const uint8_t *src, uint8_t *dst) { - unsigned int yEnd = window_.y + window_.height; + unsigned int yEnd = window_.height; /* Holds [0] previous- [1] current- [2] next-line */ const uint8_t *linePointers[3]; @@ -664,12 +664,12 @@ void DebayerCpu::process2(const uint8_t *src, uint8_t *dst) linePointers[1] = src + inputConfig_.stride; linePointers[2] = src; /* Last 2 lines also need special handling */ - yEnd -= 2; + yEnd = (yEnd > 2 ? yEnd - 2 : 0); } setupInputMemcpy(linePointers); - for (unsigned int y = window_.y; y < yEnd; y += 2) { + for (unsigned int y = 0; y < yEnd; y += 2) { shiftLinePointers(linePointers, src); memcpyNextLine(linePointers); stats_->processLine0(y, linePointers); @@ -703,7 +703,7 @@ void DebayerCpu::process2(const uint8_t *src, uint8_t *dst) void DebayerCpu::process4(const uint8_t *src, uint8_t *dst) { - const unsigned int yEnd = window_.y + window_.height; + const unsigned int yEnd = window_.height; /* * This holds pointers to [0] 2-lines-up [1] 1-line-up [2] current-line * [3] 1-line-down [4] 2-lines-down. @@ -721,7 +721,7 @@ void DebayerCpu::process4(const uint8_t *src, uint8_t *dst) setupInputMemcpy(linePointers); - for (unsigned int y = window_.y; y < yEnd; y += 4) { + for (unsigned int y = 0; y < yEnd; y += 4) { shiftLinePointers(linePointers, src); memcpyNextLine(linePointers); stats_->processLine0(y, linePointers);
The window set by SwStatsCpu::setWindow is relative to the processed image area. But debayering passes the processed line y-coordinate to the stats relative to the whole image area. This can result in gathering stats from a wrong image area or in not gathering stats at all. Let's pass the correct y-coordinate to the stats processing methods. Bug: https://bugs.libcamera.org/show_bug.cgi?id=280 Co-developed-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name> Signed-off-by: Milan Zamazal <mzamazal@redhat.com> --- src/libcamera/software_isp/debayer_cpu.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)