[libcamera-devel] [PATCH v2 0/5] generate and use fixed-sized Span Control types

Laurent Pinchart laurent.pinchart at ideasonboard.com
Tue Apr 5 18:41:13 CEST 2022


Hi Christian,

On Tue, Apr 05, 2022 at 01:42:10AM +0100, Christian Rauch via libcamera-devel wrote:
> Hello,
> 
> This is version 2 of my fixed-sized Span patch set. The changes from
> version 1 include changes to the code style in "gen-controls.py" and
> the way how memory for default constructed fixed-sized Spans is
> allocated.
> 
> The default Span constructor in version 1 used a temporarily
> constructed "std::array<>" resulting in the Span storing a pointer to
> deallocated memory. Version 2 replaced this with an empty Span. In
> practice, this means that a Span will store its target fixed-size as
> the "extent" and its current storage capacity by "size_".

That's not how std::span<> is meant to work. Spans can have a fixed
extent or a dynamic extent, and when they have fixed extents, the number
of elements (the size) is always equal to the extent. There's no size_
member to the fixed extent span for that reason. As explained in another
e-mail in this series, I'd like to avoid departing from the std::span
API in order to be able to switch to that class in the future.

> Christian Rauch (5):
>   define Span size as shape vector
>   generate fixed- and variable-sized Span Controls
>   provide a default fixed-sized Span constructor
>   apply clang-format style
>   apply explicit fixed-sized Span type casts
> 
>  include/libcamera/base/span.h                 |  47 +++---
>  include/libcamera/controls.h                  |   2 +-
>  src/ipa/raspberrypi/raspberrypi.cpp           |  21 +--
>  src/libcamera/control_ids.yaml                |   2 +-
>  .../pipeline/raspberrypi/raspberrypi.cpp      |  36 +++--
>  src/libcamera/property_ids.yaml               |   4 +-
>  src/qcam/dng_writer.cpp                       | 142 +++++++++---------
>  test/span.cpp                                 |   4 +-
>  utils/gen-controls.py                         |  33 ++--
>  9 files changed, 154 insertions(+), 137 deletions(-)
> 
> --
> 2.25.1

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list