summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMinghui Tan <mhtan@google.com>2022-03-01 19:34:47 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2022-03-01 19:34:47 +0000
commit18e5d7e67c5a6a1446ca1f6c1cdd3a45e650cb1d (patch)
treee748579ecd9de44a53fcfaa0be1a9f252deb0139 /common
parent1ab64a9877a484af72a17130ec2fc8840661adc6 (diff)
parentbb4dd49d059e067ac17c3fbbdd6f99ecf0eed1c5 (diff)
downloadcamera-18e5d7e67c5a6a1446ca1f6c1cdd3a45e650cb1d.tar.gz
Merge "Separate RealtimeZslResultProcessor and RealtimeZslResultRequestProcessor." into tm-dev
Diffstat (limited to 'common')
-rw-r--r--common/hal/google_camera_hal/Android.bp1
-rw-r--r--common/hal/google_camera_hal/hdrplus_capture_session.cc7
-rw-r--r--common/hal/google_camera_hal/realtime_zsl_result_processor.cc275
-rw-r--r--common/hal/google_camera_hal/realtime_zsl_result_processor.h111
-rw-r--r--common/hal/google_camera_hal/realtime_zsl_result_request_processor.cc166
-rw-r--r--common/hal/google_camera_hal/realtime_zsl_result_request_processor.h68
-rw-r--r--common/hal/google_camera_hal/zsl_snapshot_capture_session.cc23
-rw-r--r--common/hal/google_camera_hal/zsl_snapshot_capture_session.h5
8 files changed, 414 insertions, 242 deletions
diff --git a/common/hal/google_camera_hal/Android.bp b/common/hal/google_camera_hal/Android.bp
index 6f0e6da..59640ea 100644
--- a/common/hal/google_camera_hal/Android.bp
+++ b/common/hal/google_camera_hal/Android.bp
@@ -69,6 +69,7 @@ cc_library_shared {
"pending_requests_tracker.cc",
"realtime_process_block.cc",
"realtime_zsl_request_processor.cc",
+ "realtime_zsl_result_processor.cc",
"realtime_zsl_result_request_processor.cc",
"rgbird_capture_session.cc",
"rgbird_depth_result_processor.cc",
diff --git a/common/hal/google_camera_hal/hdrplus_capture_session.cc b/common/hal/google_camera_hal/hdrplus_capture_session.cc
index 98fdf99..c7b676a 100644
--- a/common/hal/google_camera_hal/hdrplus_capture_session.cc
+++ b/common/hal/google_camera_hal/hdrplus_capture_session.cc
@@ -32,7 +32,7 @@
#include "hdrplus_result_processor.h"
#include "realtime_process_block.h"
#include "realtime_zsl_request_processor.h"
-#include "realtime_zsl_result_request_processor.h"
+#include "realtime_zsl_result_processor.h"
#include "vendor_tag_defs.h"
namespace android {
@@ -374,11 +374,10 @@ status_t HdrplusCaptureSession::SetupRealtimeProcessChain(
}
// Create realtime result processor.
- auto result_processor = RealtimeZslResultRequestProcessor::Create(
+ auto result_processor = RealtimeZslResultProcessor::Create(
internal_stream_manager_.get(), *raw_stream_id, HAL_PIXEL_FORMAT_RAW10);
if (result_processor == nullptr) {
- ALOGE("%s: Creating RealtimeZslResultRequestProcessor failed.",
- __FUNCTION__);
+ ALOGE("%s: Creating RealtimeZslResultProcessor failed.", __FUNCTION__);
return UNKNOWN_ERROR;
}
result_processor->SetResultCallback(process_capture_result, notify);
diff --git a/common/hal/google_camera_hal/realtime_zsl_result_processor.cc b/common/hal/google_camera_hal/realtime_zsl_result_processor.cc
new file mode 100644
index 0000000..0475c46
--- /dev/null
+++ b/common/hal/google_camera_hal/realtime_zsl_result_processor.cc
@@ -0,0 +1,275 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#include "hal_types.h"
+#define LOG_TAG "GCH_RealtimeZslResultProcessor"
+#define ATRACE_TAG ATRACE_TAG_CAMERA
+
+#include <inttypes.h>
+#include <log/log.h>
+#include <utils/Trace.h>
+
+#include "hal_utils.h"
+#include "realtime_zsl_result_processor.h"
+
+namespace android {
+namespace google_camera_hal {
+
+std::unique_ptr<RealtimeZslResultProcessor> RealtimeZslResultProcessor::Create(
+ InternalStreamManager* internal_stream_manager, int32_t stream_id,
+ android_pixel_format_t pixel_format, uint32_t partial_result_count) {
+ ATRACE_CALL();
+ if (internal_stream_manager == nullptr) {
+ ALOGE("%s: internal_stream_manager is nullptr.", __FUNCTION__);
+ return nullptr;
+ }
+
+ auto result_processor = std::unique_ptr<RealtimeZslResultProcessor>(
+ new RealtimeZslResultProcessor(internal_stream_manager, stream_id,
+ pixel_format, partial_result_count));
+ if (result_processor == nullptr) {
+ ALOGE("%s: Creating RealtimeZslResultProcessor failed.", __FUNCTION__);
+ return nullptr;
+ }
+
+ return result_processor;
+}
+
+RealtimeZslResultProcessor::RealtimeZslResultProcessor(
+ InternalStreamManager* internal_stream_manager, int32_t stream_id,
+ android_pixel_format_t pixel_format, uint32_t partial_result_count) {
+ internal_stream_manager_ = internal_stream_manager;
+ stream_id_ = stream_id;
+ pixel_format_ = pixel_format;
+ partial_result_count_ = partial_result_count;
+}
+
+void RealtimeZslResultProcessor::SetResultCallback(
+ ProcessCaptureResultFunc process_capture_result, NotifyFunc notify) {
+ std::lock_guard<std::mutex> lock(callback_lock_);
+ process_capture_result_ = process_capture_result;
+ notify_ = notify;
+}
+
+void RealtimeZslResultProcessor::SaveLsForHdrplus(const CaptureRequest& request) {
+ if (request.settings != nullptr) {
+ uint8_t lens_shading_map_mode;
+ status_t res =
+ hal_utils::GetLensShadingMapMode(request, &lens_shading_map_mode);
+ if (res == OK) {
+ current_lens_shading_map_mode_ = lens_shading_map_mode;
+ }
+ }
+
+ {
+ std::lock_guard<std::mutex> lock(lens_shading_lock_);
+ requested_lens_shading_map_modes_.emplace(request.frame_number,
+ current_lens_shading_map_mode_);
+ }
+}
+
+status_t RealtimeZslResultProcessor::HandleLsResultForHdrplus(
+ uint32_t frameNumber, HalCameraMetadata* metadata) {
+ if (metadata == nullptr) {
+ ALOGE("%s: metadata is nullptr", __FUNCTION__);
+ return BAD_VALUE;
+ }
+ std::lock_guard<std::mutex> lock(lens_shading_lock_);
+ auto iter = requested_lens_shading_map_modes_.find(frameNumber);
+ if (iter == requested_lens_shading_map_modes_.end()) {
+ ALOGW("%s: can't find frame (%d)", __FUNCTION__, frameNumber);
+ return OK;
+ }
+
+ if (iter->second == ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_OFF) {
+ status_t res = hal_utils::RemoveLsInfoFromResult(metadata);
+ if (res != OK) {
+ ALOGW("%s: RemoveLsInfoFromResult fail", __FUNCTION__);
+ }
+ }
+ requested_lens_shading_map_modes_.erase(iter);
+
+ return OK;
+}
+
+void RealtimeZslResultProcessor::SaveFdForHdrplus(const CaptureRequest& request) {
+ // Enable face detect mode for internal use
+ if (request.settings != nullptr) {
+ uint8_t fd_mode;
+ status_t res = hal_utils::GetFdMode(request, &fd_mode);
+ if (res == OK) {
+ current_face_detect_mode_ = fd_mode;
+ }
+ }
+
+ {
+ std::lock_guard<std::mutex> lock(face_detect_lock_);
+ requested_face_detect_modes_.emplace(request.frame_number,
+ current_face_detect_mode_);
+ }
+}
+
+status_t RealtimeZslResultProcessor::HandleFdResultForHdrplus(
+ uint32_t frameNumber, HalCameraMetadata* metadata) {
+ if (metadata == nullptr) {
+ ALOGE("%s: metadata is nullptr", __FUNCTION__);
+ return BAD_VALUE;
+ }
+ std::lock_guard<std::mutex> lock(face_detect_lock_);
+ auto iter = requested_face_detect_modes_.find(frameNumber);
+ if (iter == requested_face_detect_modes_.end()) {
+ ALOGW("%s: can't find frame (%d)", __FUNCTION__, frameNumber);
+ return OK;
+ }
+
+ if (iter->second == ANDROID_STATISTICS_FACE_DETECT_MODE_OFF) {
+ status_t res = hal_utils::RemoveFdInfoFromResult(metadata);
+ if (res != OK) {
+ ALOGW("%s: RestoreFdMetadataForHdrplus fail", __FUNCTION__);
+ }
+ }
+ requested_face_detect_modes_.erase(iter);
+
+ return OK;
+}
+
+status_t RealtimeZslResultProcessor::AddPendingRequests(
+ const std::vector<ProcessBlockRequest>& process_block_requests,
+ const CaptureRequest& remaining_session_request) {
+ ATRACE_CALL();
+ // This is the last result processor. Sanity check if requests contains
+ // all remaining output buffers.
+ if (!hal_utils::AreAllRemainingBuffersRequested(process_block_requests,
+ remaining_session_request)) {
+ ALOGE("%s: Some output buffers will not be completed.", __FUNCTION__);
+ return BAD_VALUE;
+ }
+
+ if (pixel_format_ == HAL_PIXEL_FORMAT_RAW10) {
+ SaveFdForHdrplus(remaining_session_request);
+ SaveLsForHdrplus(remaining_session_request);
+ }
+
+ return OK;
+}
+
+void RealtimeZslResultProcessor::ProcessResult(ProcessBlockResult block_result) {
+ ATRACE_CALL();
+ std::lock_guard<std::mutex> lock(callback_lock_);
+ std::unique_ptr<CaptureResult> result = std::move(block_result.result);
+ if (result == nullptr) {
+ ALOGW("%s: Received a nullptr result.", __FUNCTION__);
+ return;
+ }
+
+ if (process_capture_result_ == nullptr) {
+ ALOGE("%s: process_capture_result_ is nullptr. Dropping a result.",
+ __FUNCTION__);
+ return;
+ }
+
+ // Return filled raw buffer to internal stream manager
+ // And remove raw buffer from result
+ bool returned_output = false;
+ status_t res;
+ std::vector<StreamBuffer> modified_output_buffers;
+ for (uint32_t i = 0; i < result->output_buffers.size(); i++) {
+ if (stream_id_ == result->output_buffers[i].stream_id) {
+ returned_output = true;
+ res = internal_stream_manager_->ReturnFilledBuffer(
+ result->frame_number, result->output_buffers[i]);
+ if (res != OK) {
+ ALOGW("%s: (%d)ReturnStreamBuffer fail", __FUNCTION__,
+ result->frame_number);
+ }
+ } else {
+ modified_output_buffers.push_back(result->output_buffers[i]);
+ }
+ }
+
+ if (result->output_buffers.size() > 0) {
+ result->output_buffers.clear();
+ result->output_buffers = modified_output_buffers;
+ }
+
+ if (result->result_metadata) {
+ result->result_metadata->Erase(ANDROID_CONTROL_ENABLE_ZSL);
+
+ res = internal_stream_manager_->ReturnMetadata(
+ stream_id_, result->frame_number, result->result_metadata.get(),
+ result->partial_result);
+ if (res != OK) {
+ ALOGW("%s: (%d)ReturnMetadata fail", __FUNCTION__, result->frame_number);
+ }
+
+ if (result->partial_result == partial_result_count_) {
+ res =
+ hal_utils::SetEnableZslMetadata(result->result_metadata.get(), false);
+ if (res != OK) {
+ ALOGW("%s: SetEnableZslMetadata (%d) fail", __FUNCTION__,
+ result->frame_number);
+ }
+
+ if (pixel_format_ == HAL_PIXEL_FORMAT_RAW10) {
+ res = HandleFdResultForHdrplus(result->frame_number,
+ result->result_metadata.get());
+ if (res != OK) {
+ ALOGE("%s: HandleFdResultForHdrplus(%d) fail", __FUNCTION__,
+ result->frame_number);
+ return;
+ }
+
+ res = HandleLsResultForHdrplus(result->frame_number,
+ result->result_metadata.get());
+ if (res != OK) {
+ ALOGE("%s: HandleLsResultForHdrplus(%d) fail", __FUNCTION__,
+ result->frame_number);
+ return;
+ }
+ }
+ }
+ }
+
+ // Don't send result to framework if only internal raw callback
+ if (returned_output && result->result_metadata == nullptr &&
+ result->output_buffers.size() == 0) {
+ return;
+ }
+
+ process_capture_result_(std::move(result));
+}
+
+void RealtimeZslResultProcessor::Notify(
+ const ProcessBlockNotifyMessage& block_message) {
+ ATRACE_CALL();
+ std::lock_guard<std::mutex> lock(callback_lock_);
+ const NotifyMessage& message = block_message.message;
+ if (notify_ == nullptr) {
+ ALOGE("%s: notify_ is nullptr. Dropping a message.", __FUNCTION__);
+ return;
+ }
+
+ notify_(message);
+}
+
+status_t RealtimeZslResultProcessor::FlushPendingRequests() {
+ ATRACE_CALL();
+ return INVALID_OPERATION;
+}
+
+} // namespace google_camera_hal
+} // namespace android \ No newline at end of file
diff --git a/common/hal/google_camera_hal/realtime_zsl_result_processor.h b/common/hal/google_camera_hal/realtime_zsl_result_processor.h
new file mode 100644
index 0000000..736a7f8
--- /dev/null
+++ b/common/hal/google_camera_hal/realtime_zsl_result_processor.h
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_REALTIME_ZSL_RESULT_PROCESSOR_H_
+#define HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_REALTIME_ZSL_RESULT_PROCESSOR_H_
+
+#include <shared_mutex>
+
+#include "internal_stream_manager.h"
+#include "result_processor.h"
+
+namespace android {
+namespace google_camera_hal {
+
+// RealtimeZslResultProcessor implements a ResultProcessor that return
+// filled raw buffer and metadata to internal stream manager.
+class RealtimeZslResultProcessor : public ResultProcessor {
+ public:
+ static std::unique_ptr<RealtimeZslResultProcessor> Create(
+ InternalStreamManager* internal_stream_manager, int32_t stream_id,
+ android_pixel_format_t pixel_format, uint32_t partial_result_count = 1);
+
+ virtual ~RealtimeZslResultProcessor() = default;
+
+ // Override functions of ResultProcessor start.
+ void SetResultCallback(ProcessCaptureResultFunc process_capture_result,
+ NotifyFunc notify) override;
+
+ status_t AddPendingRequests(
+ const std::vector<ProcessBlockRequest>& process_block_requests,
+ const CaptureRequest& remaining_session_request) override;
+
+ // Return filled raw buffer and metadata to internal stream manager
+ // and forwards the results without raw buffer to its callback functions.
+ void ProcessResult(ProcessBlockResult block_result) override;
+
+ void Notify(const ProcessBlockNotifyMessage& block_message) override;
+
+ status_t FlushPendingRequests() override;
+ // Override functions of ResultProcessor end.
+
+ protected:
+ RealtimeZslResultProcessor(InternalStreamManager* internal_stream_manager,
+ int32_t stream_id,
+ android_pixel_format_t pixel_format,
+ uint32_t partial_result_count);
+
+ InternalStreamManager* internal_stream_manager_;
+ int32_t stream_id_ = -1;
+ // Partial result count reported by HAL
+ uint32_t partial_result_count_;
+
+ std::mutex callback_lock_;
+
+ private:
+ // Save face detect mode for HDR+
+ void SaveFdForHdrplus(const CaptureRequest& request);
+ // Handle face detect metadata from result for HDR+
+ status_t HandleFdResultForHdrplus(uint32_t frameNumber,
+ HalCameraMetadata* metadata);
+ // Save lens shading map mode for HDR+
+ void SaveLsForHdrplus(const CaptureRequest& request);
+ // Handle Lens shading metadata from result for HDR+
+ status_t HandleLsResultForHdrplus(uint32_t frameNumber,
+ HalCameraMetadata* metadata);
+
+ // The following callbacks must be protected by callback_lock_.
+ ProcessCaptureResultFunc process_capture_result_;
+ NotifyFunc notify_;
+
+ android_pixel_format_t pixel_format_;
+
+ // Current face detect mode set by framework.
+ uint8_t current_face_detect_mode_ = ANDROID_STATISTICS_FACE_DETECT_MODE_OFF;
+
+ std::mutex face_detect_lock_;
+ // Map from frame number to face detect mode requested for that frame by
+ // framework. And requested_face_detect_modes_ is protected by
+ // face_detect_lock_
+ std::unordered_map<uint32_t, uint8_t> requested_face_detect_modes_;
+
+ // Current lens shading map mode set by framework.
+ uint8_t current_lens_shading_map_mode_ =
+ ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_OFF;
+
+ std::mutex lens_shading_lock_;
+ // Map from frame number to lens shading map mode requested for that frame
+ // by framework. And requested_lens_shading_map_modes_ is protected by
+ // lens_shading_lock_
+ std::unordered_map<uint32_t, uint8_t> requested_lens_shading_map_modes_;
+
+ std::shared_mutex process_block_shared_lock_;
+};
+
+} // namespace google_camera_hal
+} // namespace android
+
+#endif // HARDWARE_GOOGLE_CAMERA_HAL_GOOGLE_CAMERA_HAL_REALTIME_ZSL_RESULT_REQUEST_PROCESSOR_H_
diff --git a/common/hal/google_camera_hal/realtime_zsl_result_request_processor.cc b/common/hal/google_camera_hal/realtime_zsl_result_request_processor.cc
index fae83ff..04f428d 100644
--- a/common/hal/google_camera_hal/realtime_zsl_result_request_processor.cc
+++ b/common/hal/google_camera_hal/realtime_zsl_result_request_processor.cc
@@ -15,16 +15,16 @@
*/
//#define LOG_NDEBUG 0
+#include "realtime_zsl_result_processor.h"
#define LOG_TAG "GCH_RealtimeZslResultRequestProcessor"
#define ATRACE_TAG ATRACE_TAG_CAMERA
-#include "realtime_zsl_result_request_processor.h"
-
#include <inttypes.h>
#include <log/log.h>
#include <utils/Trace.h>
#include "hal_utils.h"
+#include "realtime_zsl_result_request_processor.h"
namespace android {
namespace google_camera_hal {
@@ -53,122 +53,9 @@ RealtimeZslResultRequestProcessor::Create(
RealtimeZslResultRequestProcessor::RealtimeZslResultRequestProcessor(
InternalStreamManager* internal_stream_manager, int32_t stream_id,
- android_pixel_format_t pixel_format, uint32_t partial_result_count) {
- internal_stream_manager_ = internal_stream_manager;
- stream_id_ = stream_id;
- pixel_format_ = pixel_format;
- partial_result_count_ = partial_result_count;
-}
-
-void RealtimeZslResultRequestProcessor::SetResultCallback(
- ProcessCaptureResultFunc process_capture_result, NotifyFunc notify) {
- std::lock_guard<std::mutex> lock(callback_lock_);
- process_capture_result_ = process_capture_result;
- notify_ = notify;
-}
-
-void RealtimeZslResultRequestProcessor::SaveLsForHdrplus(
- const CaptureRequest& request) {
- if (request.settings != nullptr) {
- uint8_t lens_shading_map_mode;
- status_t res =
- hal_utils::GetLensShadingMapMode(request, &lens_shading_map_mode);
- if (res == OK) {
- current_lens_shading_map_mode_ = lens_shading_map_mode;
- }
- }
-
- {
- std::lock_guard<std::mutex> lock(lens_shading_lock_);
- requested_lens_shading_map_modes_.emplace(request.frame_number,
- current_lens_shading_map_mode_);
- }
-}
-
-status_t RealtimeZslResultRequestProcessor::HandleLsResultForHdrplus(
- uint32_t frameNumber, HalCameraMetadata* metadata) {
- if (metadata == nullptr) {
- ALOGE("%s: metadata is nullptr", __FUNCTION__);
- return BAD_VALUE;
- }
- std::lock_guard<std::mutex> lock(lens_shading_lock_);
- auto iter = requested_lens_shading_map_modes_.find(frameNumber);
- if (iter == requested_lens_shading_map_modes_.end()) {
- ALOGW("%s: can't find frame (%d)", __FUNCTION__, frameNumber);
- return OK;
- }
-
- if (iter->second == ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_OFF) {
- status_t res = hal_utils::RemoveLsInfoFromResult(metadata);
- if (res != OK) {
- ALOGW("%s: RemoveLsInfoFromResult fail", __FUNCTION__);
- }
- }
- requested_lens_shading_map_modes_.erase(iter);
-
- return OK;
-}
-
-void RealtimeZslResultRequestProcessor::SaveFdForHdrplus(
- const CaptureRequest& request) {
- // Enable face detect mode for internal use
- if (request.settings != nullptr) {
- uint8_t fd_mode;
- status_t res = hal_utils::GetFdMode(request, &fd_mode);
- if (res == OK) {
- current_face_detect_mode_ = fd_mode;
- }
- }
-
- {
- std::lock_guard<std::mutex> lock(face_detect_lock_);
- requested_face_detect_modes_.emplace(request.frame_number,
- current_face_detect_mode_);
- }
-}
-
-status_t RealtimeZslResultRequestProcessor::HandleFdResultForHdrplus(
- uint32_t frameNumber, HalCameraMetadata* metadata) {
- if (metadata == nullptr) {
- ALOGE("%s: metadata is nullptr", __FUNCTION__);
- return BAD_VALUE;
- }
- std::lock_guard<std::mutex> lock(face_detect_lock_);
- auto iter = requested_face_detect_modes_.find(frameNumber);
- if (iter == requested_face_detect_modes_.end()) {
- ALOGW("%s: can't find frame (%d)", __FUNCTION__, frameNumber);
- return OK;
- }
-
- if (iter->second == ANDROID_STATISTICS_FACE_DETECT_MODE_OFF) {
- status_t res = hal_utils::RemoveFdInfoFromResult(metadata);
- if (res != OK) {
- ALOGW("%s: RestoreFdMetadataForHdrplus fail", __FUNCTION__);
- }
- }
- requested_face_detect_modes_.erase(iter);
-
- return OK;
-}
-
-status_t RealtimeZslResultRequestProcessor::AddPendingRequests(
- const std::vector<ProcessBlockRequest>& process_block_requests,
- const CaptureRequest& remaining_session_request) {
- ATRACE_CALL();
- // This is the last result processor. Sanity check if requests contains
- // all remaining output buffers.
- if (!hal_utils::AreAllRemainingBuffersRequested(process_block_requests,
- remaining_session_request)) {
- ALOGE("%s: Some output buffers will not be completed.", __FUNCTION__);
- return BAD_VALUE;
- }
-
- if (pixel_format_ == HAL_PIXEL_FORMAT_RAW10) {
- SaveFdForHdrplus(remaining_session_request);
- SaveLsForHdrplus(remaining_session_request);
- }
-
- return OK;
+ android_pixel_format_t pixel_format, uint32_t partial_result_count)
+ : RealtimeZslResultProcessor(internal_stream_manager, stream_id,
+ pixel_format, partial_result_count) {
}
void RealtimeZslResultRequestProcessor::ProcessResult(
@@ -181,12 +68,6 @@ void RealtimeZslResultRequestProcessor::ProcessResult(
return;
}
- if (process_capture_result_ == nullptr) {
- ALOGE("%s: process_capture_result_ is nullptr. Dropping a result.",
- __FUNCTION__);
- return;
- }
-
// Return filled raw buffer to internal stream manager
// And remove raw buffer from result
bool returned_output = false;
@@ -228,24 +109,6 @@ void RealtimeZslResultRequestProcessor::ProcessResult(
ALOGW("%s: SetEnableZslMetadata (%d) fail", __FUNCTION__,
result->frame_number);
}
-
- if (pixel_format_ == HAL_PIXEL_FORMAT_RAW10) {
- res = HandleFdResultForHdrplus(result->frame_number,
- result->result_metadata.get());
- if (res != OK) {
- ALOGE("%s: HandleFdResultForHdrplus(%d) fail", __FUNCTION__,
- result->frame_number);
- return;
- }
-
- res = HandleLsResultForHdrplus(result->frame_number,
- result->result_metadata.get());
- if (res != OK) {
- ALOGE("%s: HandleLsResultForHdrplus(%d) fail", __FUNCTION__,
- result->frame_number);
- return;
- }
- }
}
}
@@ -254,25 +117,6 @@ void RealtimeZslResultRequestProcessor::ProcessResult(
result->output_buffers.size() == 0) {
return;
}
- process_capture_result_(std::move(result));
-}
-
-void RealtimeZslResultRequestProcessor::Notify(
- const ProcessBlockNotifyMessage& block_message) {
- ATRACE_CALL();
- std::lock_guard<std::mutex> lock(callback_lock_);
- const NotifyMessage& message = block_message.message;
- if (notify_ == nullptr) {
- ALOGE("%s: notify_ is nullptr. Dropping a message.", __FUNCTION__);
- return;
- }
-
- notify_(message);
-}
-
-status_t RealtimeZslResultRequestProcessor::FlushPendingRequests() {
- ATRACE_CALL();
- return INVALID_OPERATION;
}
status_t RealtimeZslResultRequestProcessor::ConfigureStreams(
diff --git a/common/hal/google_camera_hal/realtime_zsl_result_request_processor.h b/common/hal/google_camera_hal/realtime_zsl_result_request_processor.h
index 6ee1675..84a1ba1 100644
--- a/common/hal/google_camera_hal/realtime_zsl_result_request_processor.h
+++ b/common/hal/google_camera_hal/realtime_zsl_result_request_processor.h
@@ -20,16 +20,17 @@
#include <shared_mutex>
#include "internal_stream_manager.h"
+#include "realtime_zsl_result_processor.h"
#include "request_processor.h"
#include "result_processor.h"
namespace android {
namespace google_camera_hal {
-// RealtimeZslResultRequestProcessor implements a ResultProcessor that return
-// filled raw buffer and metadata to internal stream manager. It also implements
-// a RequestProcess to forward the results.
-class RealtimeZslResultRequestProcessor : public ResultProcessor,
+// RealtimeZslResultRequestProcessor implements a RealtimeZslResultProcessor
+// that return filled raw buffer and metadata to internal stream manager. It
+// also implements a RequestProcess to forward the results.
+class RealtimeZslResultRequestProcessor : public RealtimeZslResultProcessor,
RequestProcessor {
public:
static std::unique_ptr<RealtimeZslResultRequestProcessor> Create(
@@ -38,22 +39,9 @@ class RealtimeZslResultRequestProcessor : public ResultProcessor,
virtual ~RealtimeZslResultRequestProcessor() = default;
- // Override functions of ResultProcessor start.
- void SetResultCallback(ProcessCaptureResultFunc process_capture_result,
- NotifyFunc notify) override;
-
- status_t AddPendingRequests(
- const std::vector<ProcessBlockRequest>& process_block_requests,
- const CaptureRequest& remaining_session_request) override;
-
- // Return filled raw buffer and matedata to internal stream manager
- // and forwards the results without raw buffer to its callback functions.
+ // Override functions of RealtimeZslResultProcessor start.
void ProcessResult(ProcessBlockResult block_result) override;
-
- void Notify(const ProcessBlockNotifyMessage& block_message) override;
-
- status_t FlushPendingRequests() override;
- // Override functions of ResultProcessor end.
+ // Override functions of RealtimeZslResultProcessor end.
// Override functions of RequestProcessor start.
status_t ConfigureStreams(
@@ -74,48 +62,6 @@ class RealtimeZslResultRequestProcessor : public ResultProcessor,
android_pixel_format_t pixel_format, uint32_t partial_result_count);
private:
- // Save face detect mode for HDR+
- void SaveFdForHdrplus(const CaptureRequest& request);
- // Handle face detect metadata from result for HDR+
- status_t HandleFdResultForHdrplus(uint32_t frameNumber,
- HalCameraMetadata* metadata);
- // Save lens shading map mode for HDR+
- void SaveLsForHdrplus(const CaptureRequest& request);
- // Handle Lens shading metadata from result for HDR+
- status_t HandleLsResultForHdrplus(uint32_t frameNumber,
- HalCameraMetadata* metadata);
- std::mutex callback_lock_;
-
- // The following callbacks must be protected by callback_lock_.
- ProcessCaptureResultFunc process_capture_result_;
- NotifyFunc notify_;
-
- InternalStreamManager* internal_stream_manager_;
- int32_t stream_id_ = -1;
- android_pixel_format_t pixel_format_;
-
- // Current face detect mode set by framework.
- uint8_t current_face_detect_mode_ = ANDROID_STATISTICS_FACE_DETECT_MODE_OFF;
-
- std::mutex face_detect_lock_;
- // Map from frame number to face detect mode requested for that frame by
- // framework. And requested_face_detect_modes_ is protected by
- // face_detect_lock_
- std::unordered_map<uint32_t, uint8_t> requested_face_detect_modes_;
-
- // Current lens shading map mode set by framework.
- uint8_t current_lens_shading_map_mode_ =
- ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_OFF;
-
- std::mutex lens_shading_lock_;
- // Map from frame number to lens shading map mode requested for that frame
- // by framework. And requested_lens_shading_map_modes_ is protected by
- // lens_shading_lock_
- std::unordered_map<uint32_t, uint8_t> requested_lens_shading_map_modes_;
-
- // Partial result count reported by HAL
- uint32_t partial_result_count_;
-
std::shared_mutex process_block_shared_lock_;
// Protected by process_block_shared_lock_.
diff --git a/common/hal/google_camera_hal/zsl_snapshot_capture_session.cc b/common/hal/google_camera_hal/zsl_snapshot_capture_session.cc
index f6afbed..77d5660 100644
--- a/common/hal/google_camera_hal/zsl_snapshot_capture_session.cc
+++ b/common/hal/google_camera_hal/zsl_snapshot_capture_session.cc
@@ -405,20 +405,17 @@ status_t ZslSnapshotCaptureSession::ConfigureStreams(
}
// Create preview result processor. Stream ID is not set at this stage.
- auto realtime_result_request_processor =
- RealtimeZslResultRequestProcessor::Create(
- internal_stream_manager_.get(), additional_stream_id,
- HAL_PIXEL_FORMAT_YCBCR_420_888, partial_result_count_);
- if (realtime_result_request_processor == nullptr) {
+ auto realtime_result_processor = RealtimeZslResultProcessor::Create(
+ internal_stream_manager_.get(), additional_stream_id,
+ HAL_PIXEL_FORMAT_YCBCR_420_888, partial_result_count_);
+ if (realtime_result_processor == nullptr) {
ALOGE("%s: Creating RealtimeZslResultProcessor failed.", __FUNCTION__);
return UNKNOWN_ERROR;
}
- realtime_result_request_processor_ = realtime_result_request_processor.get();
- realtime_result_request_processor->SetResultCallback(process_capture_result,
- notify);
+ realtime_result_processor_ = realtime_result_processor.get();
+ realtime_result_processor->SetResultCallback(process_capture_result, notify);
- res = process_block->SetResultProcessor(
- std::move(realtime_result_request_processor));
+ res = process_block->SetResultProcessor(std::move(realtime_result_processor));
if (res != OK) {
ALOGE("%s: Setting result process in process block failed.", __FUNCTION__);
return res;
@@ -542,14 +539,14 @@ status_t ZslSnapshotCaptureSession::SetupRealtimeProcessChain(
ProcessCaptureResultFunc process_capture_result, NotifyFunc notify) {
ATRACE_CALL();
if (realtime_process_block_ != nullptr ||
- realtime_result_request_processor_ != nullptr ||
+ realtime_result_processor_ != nullptr ||
realtime_request_processor_ != nullptr) {
ALOGE(
"%s: realtime_process_block_(%p) or realtime_result_processor_(%p) or "
"realtime_request_processor_(%p) is/are "
"already set",
- __FUNCTION__, realtime_process_block_,
- realtime_result_request_processor_, realtime_request_processor_.get());
+ __FUNCTION__, realtime_process_block_, realtime_result_processor_,
+ realtime_request_processor_.get());
return BAD_VALUE;
}
diff --git a/common/hal/google_camera_hal/zsl_snapshot_capture_session.h b/common/hal/google_camera_hal/zsl_snapshot_capture_session.h
index 7e34cba..04cc63d 100644
--- a/common/hal/google_camera_hal/zsl_snapshot_capture_session.h
+++ b/common/hal/google_camera_hal/zsl_snapshot_capture_session.h
@@ -25,7 +25,7 @@
#include "hwl_types.h"
#include "process_block.h"
#include "realtime_zsl_request_processor.h"
-#include "realtime_zsl_result_request_processor.h"
+#include "realtime_zsl_result_processor.h"
#include "request_processor.h"
#include "result_processor.h"
#include "snapshot_request_processor.h"
@@ -144,8 +144,7 @@ class ZslSnapshotCaptureSession : public CaptureSession {
CaptureSessionWrapperProcessBlock* realtime_process_block_ = nullptr;
// RealtimeZslResultRequestProcessor will be owned and released by
// CaptureSessionWrapperProcessBlock.
- RealtimeZslResultRequestProcessor* realtime_result_request_processor_ =
- nullptr;
+ RealtimeZslResultProcessor* realtime_result_processor_ = nullptr;
std::unique_ptr<SnapshotRequestProcessor> snapshot_request_processor_;
// SnapshotProcessBlock will be owned and released by