[v1,1/2] libcamera: software_isp: Drop redundant sumShift_ guard in finishFrame
diff mbox series

Message ID 20260507161101.7D2CD1EA006B@mailuser.phl.internal
State Superseded
Headers show
Series
  • ipa: simple: OV2740 tuning file and swstats sumShift cleanup
Related show

Commit Message

Javier Tia May 7, 2026, 4:03 p.m. UTC
Right-shifting by zero is a no-op, so the if (sumShift_) check before
the three >>= sumShift_ assignments is unnecessary. Remove it.

Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Suggested-by: Barnabas Pocze <barnabas.pocze@ideasonboard.com>
Signed-off-by: Javier Tia <floss@jetm.me>
---
 src/libcamera/software_isp/swstats_cpu.cpp | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Barnabás Pőcze May 8, 2026, 6:59 a.m. UTC | #1
2026. 05. 07. 18:03 keltezéssel, Javier Tia írta:
> Right-shifting by zero is a no-op, so the if (sumShift_) check before
> the three >>= sumShift_ assignments is unnecessary. Remove it.
> 
> Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Suggested-by: Barnabas Pocze <barnabas.pocze@ideasonboard.com>
> Signed-off-by: Javier Tia <floss@jetm.me>
> ---
>   src/libcamera/software_isp/swstats_cpu.cpp | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp
> index b40d3334..d9011f41 100644
> --- a/src/libcamera/software_isp/swstats_cpu.cpp
> +++ b/src/libcamera/software_isp/swstats_cpu.cpp
> @@ -362,11 +362,9 @@ void SwStatsCpu::finishFrame(uint32_t frame, uint32_t bufferId)
>   			for (unsigned int j = 0; j < SwIspStats::kYHistogramSize; j++)
>   				sharedStats_->yHistogram[j] += s.yHistogram[j];
>   		}
> -		if (sumShift_) {
> -			sharedStats_->sum_.r() >>= sumShift_;
> -			sharedStats_->sum_.g() >>= sumShift_;
> -			sharedStats_->sum_.b() >>= sumShift_;
> -		}
> +		sharedStats_->sum_.r() >>= sumShift_;
> +		sharedStats_->sum_.g() >>= sumShift_;
> +		sharedStats_->sum_.b() >>= sumShift_;

I kind of wanted to suggest adding `operator>>{,=}` to the `Vector` class
but let's not get too carried away.

Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>


>   	}
>   
>   	sharedStats_->valid = valid;
Laurent Pinchart May 8, 2026, 9:31 a.m. UTC | #2
On Fri, May 08, 2026 at 08:59:32AM +0200, Barnabás Pőcze wrote:
> 2026. 05. 07. 18:03 keltezéssel, Javier Tia írta:
> > Right-shifting by zero is a no-op, so the if (sumShift_) check before
> > the three >>= sumShift_ assignments is unnecessary. Remove it.
> > 
> > Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Suggested-by: Barnabas Pocze <barnabas.pocze@ideasonboard.com>
> > Signed-off-by: Javier Tia <floss@jetm.me>
> > ---
> >   src/libcamera/software_isp/swstats_cpu.cpp | 8 +++-----
> >   1 file changed, 3 insertions(+), 5 deletions(-)
> > 
> > diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp
> > index b40d3334..d9011f41 100644
> > --- a/src/libcamera/software_isp/swstats_cpu.cpp
> > +++ b/src/libcamera/software_isp/swstats_cpu.cpp
> > @@ -362,11 +362,9 @@ void SwStatsCpu::finishFrame(uint32_t frame, uint32_t bufferId)
> >   			for (unsigned int j = 0; j < SwIspStats::kYHistogramSize; j++)
> >   				sharedStats_->yHistogram[j] += s.yHistogram[j];
> >   		}
> > -		if (sumShift_) {
> > -			sharedStats_->sum_.r() >>= sumShift_;
> > -			sharedStats_->sum_.g() >>= sumShift_;
> > -			sharedStats_->sum_.b() >>= sumShift_;
> > -		}
> > +		sharedStats_->sum_.r() >>= sumShift_;
> > +		sharedStats_->sum_.g() >>= sumShift_;
> > +		sharedStats_->sum_.b() >>= sumShift_;
> 
> I kind of wanted to suggest adding `operator>>{,=}` to the `Vector` class
> but let's not get too carried away.

I thought about the same :-) On top of this patch of course.

> Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> 
> >   	}
> >   
> >   	sharedStats_->valid = valid;

Patch
diff mbox series

diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp
index b40d3334..d9011f41 100644
--- a/src/libcamera/software_isp/swstats_cpu.cpp
+++ b/src/libcamera/software_isp/swstats_cpu.cpp
@@ -362,11 +362,9 @@  void SwStatsCpu::finishFrame(uint32_t frame, uint32_t bufferId)
 			for (unsigned int j = 0; j < SwIspStats::kYHistogramSize; j++)
 				sharedStats_->yHistogram[j] += s.yHistogram[j];
 		}
-		if (sumShift_) {
-			sharedStats_->sum_.r() >>= sumShift_;
-			sharedStats_->sum_.g() >>= sumShift_;
-			sharedStats_->sum_.b() >>= sumShift_;
-		}
+		sharedStats_->sum_.r() >>= sumShift_;
+		sharedStats_->sum_.g() >>= sumShift_;
+		sharedStats_->sum_.b() >>= sumShift_;
 	}
 
 	sharedStats_->valid = valid;