[libcamera-devel] [PATCH 2/3] android: camera_device: Report pipeline depth
Jacopo Mondi
jacopo at jmondi.org
Wed Dec 9 18:35:18 CET 2020
Report the pipeline depth in the capture results if the pipeline
reports it.
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
src/android/camera_device.cpp | 21 ++++++++++++++++-----
src/android/camera_device.h | 4 ++--
src/android/camera_worker.h | 1 +
3 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 872c7b18ee49..13194d1ea5cc 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -550,10 +550,10 @@ std::tuple<uint32_t, uint32_t> CameraDevice::calculateStaticMetadataSize()
{
/*
* \todo Keep this in sync with the actual number of entries.
- * Currently: 51 entries, 687 bytes of static metadata
+ * Currently: 52 entries, 698 bytes of static metadata
*/
uint32_t numEntries = 52;
- uint32_t byteSize = 694;
+ uint32_t byteSize = 698;
/*
* Calculate space occupation in bytes for dynamically built metadata
@@ -1046,6 +1046,7 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
ANDROID_CONTROL_AWB_STATE,
ANDROID_CONTROL_AWB_LOCK,
ANDROID_LENS_STATE,
+ ANDROID_REQUEST_PIPELINE_DEPTH,
ANDROID_SCALER_CROP_REGION,
ANDROID_SENSOR_TIMESTAMP,
ANDROID_SENSOR_ROLLING_SHUTTER_SKEW,
@@ -1554,7 +1555,7 @@ void CameraDevice::requestComplete(Request *request)
* pipeline handlers) timestamp in the Request itself.
*/
uint64_t timestamp = buffers.begin()->second->metadata().timestamp;
- resultMetadata = getResultMetadata(descriptor->frameNumber_, timestamp);
+ resultMetadata = getResultMetadata(descriptor, timestamp);
/* Handle any JPEG compression. */
for (unsigned int i = 0; i < descriptor->numBuffers_; ++i) {
@@ -1672,15 +1673,17 @@ void CameraDevice::notifyError(uint32_t frameNumber, camera3_stream_t *stream)
* Produce a set of fixed result metadata.
*/
std::unique_ptr<CameraMetadata>
-CameraDevice::getResultMetadata([[maybe_unused]] int frame_number,
+CameraDevice::getResultMetadata(Camera3RequestDescriptor *descriptor,
int64_t timestamp)
{
+ const ControlList &metadata = descriptor->request_->request()->metadata();
+
/*
* \todo Keep this in sync with the actual number of entries.
* Currently: 18 entries, 62 bytes
*/
std::unique_ptr<CameraMetadata> resultMetadata =
- std::make_unique<CameraMetadata>(18, 62);
+ std::make_unique<CameraMetadata>(19, 63);
if (!resultMetadata->isValid()) {
LOG(HAL, Error) << "Failed to allocate static metadata";
return nullptr;
@@ -1730,6 +1733,14 @@ CameraDevice::getResultMetadata([[maybe_unused]] int frame_number,
resultMetadata->addEntry(ANDROID_STATISTICS_SCENE_FLICKER,
&scene_flicker, 1);
+ /* Add metadata tags reported by libcamera. */
+ if (metadata.contains(controls::draft::PipelineDepth)) {
+ uint8_t pipeline_depth =
+ metadata.get<int32_t>(controls::draft::PipelineDepth);
+ resultMetadata->addEntry(ANDROID_REQUEST_PIPELINE_DEPTH,
+ &pipeline_depth, 1);
+ }
+
/*
* Return the result metadata pack even is not valid: get() will return
* nullptr.
diff --git a/src/android/camera_device.h b/src/android/camera_device.h
index 45efcf477436..07d3a846f8e1 100644
--- a/src/android/camera_device.h
+++ b/src/android/camera_device.h
@@ -105,8 +105,8 @@ private:
void notifyError(uint32_t frameNumber, camera3_stream_t *stream);
CameraMetadata *requestTemplatePreview();
libcamera::PixelFormat toPixelFormat(int format) const;
- std::unique_ptr<CameraMetadata> getResultMetadata(int frame_number,
- int64_t timestamp);
+ std::unique_ptr<CameraMetadata> getResultMetadata(
+ Camera3RequestDescriptor *descriptor, int64_t timestamp);
unsigned int id_;
camera3_device_t camera3Device_;
diff --git a/src/android/camera_worker.h b/src/android/camera_worker.h
index fff5021708d7..9417a816c214 100644
--- a/src/android/camera_worker.h
+++ b/src/android/camera_worker.h
@@ -25,6 +25,7 @@ public:
CaptureRequest(libcamera::Camera *camera, uint64_t cookie);
const std::vector<int> &fences() const { return acquireFences_; }
+ const libcamera::Request *request() const { return request_.get(); }
void addBuffer(libcamera::Stream *stream,
libcamera::FrameBuffer *buffer, int fence);
--
2.29.1
More information about the libcamera-devel
mailing list