android: camera_metadata: Add functions for instrumenting resizing
Add utility functions to CameraMetadata to check if it has been resized, and for outputting the actual entry and data count. This is meant to be used to output information on resizing, to assist developers in choosing proper initial sizes to avoid resizing. Also make CameraDevice use these functions for static and result metadata. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
This commit is contained in:
@@ -14,17 +14,19 @@ using namespace libcamera;
|
||||
LOG_DEFINE_CATEGORY(CameraMetadata)
|
||||
|
||||
CameraMetadata::CameraMetadata()
|
||||
: metadata_(nullptr), valid_(false)
|
||||
: metadata_(nullptr), valid_(false), resized_(false)
|
||||
{
|
||||
}
|
||||
|
||||
CameraMetadata::CameraMetadata(size_t entryCapacity, size_t dataCapacity)
|
||||
: resized_(false)
|
||||
{
|
||||
metadata_ = allocate_camera_metadata(entryCapacity, dataCapacity);
|
||||
valid_ = metadata_ != nullptr;
|
||||
}
|
||||
|
||||
CameraMetadata::CameraMetadata(const camera_metadata_t *metadata)
|
||||
: resized_(false)
|
||||
{
|
||||
metadata_ = clone_camera_metadata(metadata);
|
||||
valid_ = metadata_ != nullptr;
|
||||
@@ -55,6 +57,14 @@ CameraMetadata &CameraMetadata::operator=(const CameraMetadata &other)
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::tuple<size_t, size_t> CameraMetadata::usage() const
|
||||
{
|
||||
size_t currentEntryCount = get_camera_metadata_entry_count(metadata_);
|
||||
size_t currentDataCount = get_camera_metadata_data_count(metadata_);
|
||||
|
||||
return { currentEntryCount, currentDataCount };
|
||||
}
|
||||
|
||||
bool CameraMetadata::getEntry(uint32_t tag, camera_metadata_ro_entry_t *entry) const
|
||||
{
|
||||
if (find_camera_metadata_ro_entry(metadata_, tag, entry))
|
||||
@@ -104,6 +114,8 @@ bool CameraMetadata::resize(size_t count, size_t size)
|
||||
|
||||
append_camera_metadata(metadata_, oldMetadata);
|
||||
free_camera_metadata(oldMetadata);
|
||||
|
||||
resized_ = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user