[v2,0/2] libcamera: Vector right-shift operators and SwStatsCpu use site
mbox series

Message ID 177827984964.786021.2242634090011461397@jetm.me
Headers show
Series
  • libcamera: Vector right-shift operators and SwStatsCpu use site
Related show

Message

Javier Tia May 8, 2026, 9:35 p.m. UTC
Small follow-up suggested by Barnabás and Laurent during review of the
sumShift_ cleanup in the OV2740 v2 series:

  https://patchwork.libcamera.org/project/libcamera/list/?series=5926

Patch 1/2 adds operator>> and operator>>= to the Vector class.
Patch 2/2 uses the new operator in SwStatsCpu::finishFrame() to
collapse the three per-component right-shifts on RGB<uint64_t>::sum_
into a single sum_ >>= sumShift_ statement.

Depends on the v2 OV2740 series above (specifically v2 1/3, which
removes the if (sumShift_) guard around the three right-shifts that
2/2 here further simplifies). It does not apply on top of master
without v2.

Changes since v1:
- Patch 1/2: rewrote operator>> and operator>>= to use the existing
  apply() helper for consistency with the other Vector operators;
  templated apply() on the scalar type to accept unsigned int. Added
  Doxygen \fn blocks for both operators in src/libcamera/vector.cpp.
  Verified with -Ddocumentation=enabled -Ddoc_werror=true.
- Patch 1/2: added static_assert(std::is_integral_v<T>) in both shift
  operators to enforce integer element type, per Laurent's follow-up
  review.
- Patch 2/2: picked up Laurent's Reviewed-by.

Link to v1: https://patchwork.libcamera.org/project/libcamera/list/?series=5927

Javier Tia (2):
  libcamera: libipa: Add right-shift operators to Vector
  libcamera: software_isp: Use Vector operator>>= in finishFrame

 include/libcamera/internal/vector.h        | 22 ++++++++++++++++++----
 src/libcamera/software_isp/swstats_cpu.cpp |  4 +---
 src/libcamera/vector.cpp                   | 14 ++++++++++++++
 3 files changed, 33 insertions(+), 7 deletions(-)