From a1530f1b16f093a91edbbbaf7dac9f9809867817 Mon Sep 17 00:00:00 2001 From: Zhijun He Date: Sun, 14 Sep 2014 12:44:20 -0700 Subject: Camera3: Update ZSL post-processing tags Update ZSL processing tags according the still capture template Also cache the request template to avoid extra cost of querying into HAL every time. Bug: 17463102 Change-Id: I2eeffefb0a4131c99a85dd3e4484cc6f0f025efa --- .../api1/client2/ZslProcessor3.cpp | 47 ++++++++++++++++++++++ .../libcameraservice/api1/client2/ZslProcessor3.h | 3 ++ .../libcameraservice/device3/Camera3Device.cpp | 6 +++ .../libcameraservice/device3/Camera3Device.h | 2 + 4 files changed, 58 insertions(+) (limited to 'services/camera') diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor3.cpp b/services/camera/libcameraservice/api1/client2/ZslProcessor3.cpp index fa65b74..de31e23 100644 --- a/services/camera/libcameraservice/api1/client2/ZslProcessor3.cpp +++ b/services/camera/libcameraservice/api1/client2/ZslProcessor3.cpp @@ -244,6 +244,46 @@ int ZslProcessor3::getStreamId() const { return mZslStreamId; } +status_t ZslProcessor3::updateRequestWithDefaultStillRequest(CameraMetadata &request) const { + sp client = mClient.promote(); + if (client == 0) { + ALOGE("%s: Camera %d: Client does not exist", __FUNCTION__, mId); + return INVALID_OPERATION; + } + sp device = + static_cast(client->getCameraDevice().get()); + if (device == 0) { + ALOGE("%s: Camera %d: Device does not exist", __FUNCTION__, mId); + return INVALID_OPERATION; + } + + CameraMetadata stillTemplate; + device->createDefaultRequest(CAMERA3_TEMPLATE_STILL_CAPTURE, &stillTemplate); + + // Find some of the post-processing tags, and assign the value from template to the request. + // Only check the aberration mode and noise reduction mode for now, as they are very important + // for image quality. + uint32_t postProcessingTags[] = { + ANDROID_NOISE_REDUCTION_MODE, + ANDROID_COLOR_CORRECTION_ABERRATION_MODE, + ANDROID_COLOR_CORRECTION_MODE, + ANDROID_TONEMAP_MODE, + ANDROID_SHADING_MODE, + ANDROID_HOT_PIXEL_MODE, + ANDROID_EDGE_MODE + }; + + camera_metadata_entry_t entry; + for (size_t i = 0; i < sizeof(postProcessingTags) / sizeof(uint32_t); i++) { + entry = stillTemplate.find(postProcessingTags[i]); + if (entry.count > 0) { + request.update(postProcessingTags[i], entry.data.u8, 1); + } + } + + return OK; +} + status_t ZslProcessor3::pushToReprocess(int32_t requestId) { ALOGV("%s: Send in reprocess request with id %d", __FUNCTION__, requestId); @@ -369,6 +409,13 @@ status_t ZslProcessor3::pushToReprocess(int32_t requestId) { } } + // Update post-processing settings + res = updateRequestWithDefaultStillRequest(request); + if (res != OK) { + ALOGW("%s: Unable to update post-processing tags, the reprocessed image quality " + "may be compromised", __FUNCTION__); + } + mLatestCapturedRequest = request; res = client->getCameraDevice()->capture(request); if (res != OK ) { diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor3.h b/services/camera/libcameraservice/api1/client2/ZslProcessor3.h index 2975f7c..fc9f70c 100644 --- a/services/camera/libcameraservice/api1/client2/ZslProcessor3.h +++ b/services/camera/libcameraservice/api1/client2/ZslProcessor3.h @@ -135,6 +135,9 @@ class ZslProcessor3 : nsecs_t getCandidateTimestampLocked(size_t* metadataIdx) const; bool isFixedFocusMode(uint8_t afMode) const; + + // Update the post-processing metadata with the default still capture request template + status_t updateRequestWithDefaultStillRequest(CameraMetadata &request) const; }; diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp index fafe349..690f675 100644 --- a/services/camera/libcameraservice/device3/Camera3Device.cpp +++ b/services/camera/libcameraservice/device3/Camera3Device.cpp @@ -1044,6 +1044,11 @@ status_t Camera3Device::createDefaultRequest(int templateId, return INVALID_OPERATION; } + if (!mRequestTemplateCache[templateId].isEmpty()) { + *request = mRequestTemplateCache[templateId]; + return OK; + } + const camera_metadata_t *rawRequest; ATRACE_BEGIN("camera3->construct_default_request_settings"); rawRequest = mHal3Device->ops->construct_default_request_settings( @@ -1055,6 +1060,7 @@ status_t Camera3Device::createDefaultRequest(int templateId, return DEAD_OBJECT; } *request = rawRequest; + mRequestTemplateCache[templateId] = rawRequest; return OK; } diff --git a/services/camera/libcameraservice/device3/Camera3Device.h b/services/camera/libcameraservice/device3/Camera3Device.h index b99ed7e..ec6bba1 100644 --- a/services/camera/libcameraservice/device3/Camera3Device.h +++ b/services/camera/libcameraservice/device3/Camera3Device.h @@ -174,6 +174,8 @@ class Camera3Device : CameraMetadata mDeviceInfo; + CameraMetadata mRequestTemplateCache[CAMERA3_TEMPLATE_COUNT]; + uint32_t mDeviceVersion; enum Status { -- cgit v1.1