Skip to content

Commit

Permalink
clarify the value range and meaning of the extracted ControlId extent
Browse files Browse the repository at this point in the history
  • Loading branch information
christianrauch committed Aug 5, 2024
1 parent 1a8a59d commit 36b8504
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/type_extent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@ template<typename T, std::enable_if_t<!libcamera::details::is_span<T>::value, bo
std::size_t
get_extent(const libcamera::Control<T> &)
{
// return an extent of 0 for non-span types
return 0;
}

template<typename T, std::enable_if_t<libcamera::details::is_span<T>::value, bool> = true>
std::size_t
get_extent(const libcamera::Control<T> &)
{
return libcamera::Control<T>::type::extent;
// return the span extent, excluding 0
// This assumes that libcamera does not define control types
// with a fixed size span that does not hold any elements
constexpr std::size_t extent = libcamera::Control<T>::type::extent;
static_assert(extent != 0);
return extent;
}

#define IF(T) \
Expand All @@ -35,7 +41,7 @@ get_extent(const libcamera::Control<T> &)


std::size_t
get_extent(const libcamera::ControlId *id)
get_extent(const libcamera::ControlId *const id)
{
#if LIBCAMERA_VER_GE(0, 1, 0)
IF(AeEnable)
Expand Down
8 changes: 7 additions & 1 deletion src/type_extent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,11 @@ namespace libcamera
class ControlId;
}

/**
* @brief get the extent of a libcamera::ControlId
* @param id
* @return the extent of the control: 0 if the control is not a span,
* otherwise [1 ... libcamera::dynamic_extent]
*/
std::size_t
get_extent(const libcamera::ControlId *id);
get_extent(const libcamera::ControlId *const id);

0 comments on commit 36b8504

Please sign in to comment.