Message ID | 20250331144352.736700-6-stefan.klug@ideasonboard.com |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
Quoting Stefan Klug (2025-03-31 15:43:44) > Add functions to check for empty parameter blocks. Modify the constructor > so that a parameter block constructed from an empty span stays empty. > > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> > --- > src/ipa/rkisp1/params.cpp | 3 +++ > src/ipa/rkisp1/params.h | 13 +++++++++++++ > 2 files changed, 16 insertions(+) > > diff --git a/src/ipa/rkisp1/params.cpp b/src/ipa/rkisp1/params.cpp > index 4c0b051ce65d..b4a889e415fc 100644 > --- a/src/ipa/rkisp1/params.cpp > +++ b/src/ipa/rkisp1/params.cpp > @@ -82,6 +82,9 @@ RkISP1ParamsBlockBase::RkISP1ParamsBlockBase(RkISP1Params *params, BlockType typ > const Span<uint8_t> &data) > : params_(params), type_(type) > { > + if (data.empty()) > + return; > + > if (params_->format() == V4L2_META_FMT_RK_ISP1_EXT_PARAMS) { > header_ = data.subspan(0, sizeof(rkisp1_ext_params_block_header)); > data_ = data.subspan(sizeof(rkisp1_ext_params_block_header)); > diff --git a/src/ipa/rkisp1/params.h b/src/ipa/rkisp1/params.h > index 40450e34497a..e0aa04ae0f8d 100644 > --- a/src/ipa/rkisp1/params.h > +++ b/src/ipa/rkisp1/params.h > @@ -89,6 +89,9 @@ public: > > void setEnabled(bool enabled); > > + bool isValid() const { return !data_.empty(); } > + explicit operator bool() const { return !data_.empty(); } > + > private: > LIBCAMERA_DISABLE_COPY(RkISP1ParamsBlockBase) > > @@ -109,6 +112,16 @@ public: > { > } > > + const Type *get() const > + { > + return reinterpret_cast<const Type *>(data().data()); > + } > + > + Type *get() > + { > + return reinterpret_cast<Type *>(data().data()); > + } > + These seem unrelated ? -- Kieran > const Type *operator->() const > { > return reinterpret_cast<const Type *>(data().data()); > -- > 2.43.0 >
diff --git a/src/ipa/rkisp1/params.cpp b/src/ipa/rkisp1/params.cpp index 4c0b051ce65d..b4a889e415fc 100644 --- a/src/ipa/rkisp1/params.cpp +++ b/src/ipa/rkisp1/params.cpp @@ -82,6 +82,9 @@ RkISP1ParamsBlockBase::RkISP1ParamsBlockBase(RkISP1Params *params, BlockType typ const Span<uint8_t> &data) : params_(params), type_(type) { + if (data.empty()) + return; + if (params_->format() == V4L2_META_FMT_RK_ISP1_EXT_PARAMS) { header_ = data.subspan(0, sizeof(rkisp1_ext_params_block_header)); data_ = data.subspan(sizeof(rkisp1_ext_params_block_header)); diff --git a/src/ipa/rkisp1/params.h b/src/ipa/rkisp1/params.h index 40450e34497a..e0aa04ae0f8d 100644 --- a/src/ipa/rkisp1/params.h +++ b/src/ipa/rkisp1/params.h @@ -89,6 +89,9 @@ public: void setEnabled(bool enabled); + bool isValid() const { return !data_.empty(); } + explicit operator bool() const { return !data_.empty(); } + private: LIBCAMERA_DISABLE_COPY(RkISP1ParamsBlockBase) @@ -109,6 +112,16 @@ public: { } + const Type *get() const + { + return reinterpret_cast<const Type *>(data().data()); + } + + Type *get() + { + return reinterpret_cast<Type *>(data().data()); + } + const Type *operator->() const { return reinterpret_cast<const Type *>(data().data());
Add functions to check for empty parameter blocks. Modify the constructor so that a parameter block constructed from an empty span stays empty. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> --- src/ipa/rkisp1/params.cpp | 3 +++ src/ipa/rkisp1/params.h | 13 +++++++++++++ 2 files changed, 16 insertions(+)