Commit 0e9f7563 authored by Wei Lee's avatar Wei Lee Committed by Commit Bot

VCD: Avoid wrong orientation for reprocess request

Originally, for reprocess request, we will put the Jpeg orientation
information when constructing the second request. However, the frame
data is actually filled when processing the first request. If the
orientation changes between these two requests, we might put the wrong
orientation into the second request which is inconsistant to the actual
image data.

Therefore, this CL stores the orientation information when constructing
the first request and use that info for the second request.

Bug: b/153828264
Test: Manually test on Kukui and it works as expectation
Change-Id: Ic19a395b21ed934efca46b160ae18fd223ded6fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2143179
Commit-Queue: Wei Lee <wtlee@chromium.org>
Reviewed-by: default avatarShik Chen <shik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759140}
parent aa6e0142
...@@ -227,11 +227,10 @@ void RequestManager::UnsetRepeatingCaptureMetadata( ...@@ -227,11 +227,10 @@ void RequestManager::UnsetRepeatingCaptureMetadata(
} }
void RequestManager::SetJpegOrientation( void RequestManager::SetJpegOrientation(
cros::mojom::CameraMetadataPtr* settings) { cros::mojom::CameraMetadataPtr* settings,
int32_t orientation) {
auto e = BuildMetadataEntry( auto e = BuildMetadataEntry(
cros::mojom::CameraMetadataTag::ANDROID_JPEG_ORIENTATION, cros::mojom::CameraMetadataTag::ANDROID_JPEG_ORIENTATION, orientation);
base::checked_cast<int32_t>(
device_context_->GetCameraFrameOrientation()));
AddOrUpdateMetadataEntry(settings, std::move(e)); AddOrUpdateMetadataEntry(settings, std::move(e));
} }
...@@ -319,6 +318,7 @@ void RequestManager::PrepareCaptureRequest() { ...@@ -319,6 +318,7 @@ void RequestManager::PrepareCaptureRequest() {
pending_result.input_buffer_id = input_buffer_id; pending_result.input_buffer_id = input_buffer_id;
pending_result.reprocess_effect = reprocess_effect; pending_result.reprocess_effect = reprocess_effect;
pending_result.still_capture_callback = std::move(callback); pending_result.still_capture_callback = std::move(callback);
pending_result.orientation = device_context_->GetCameraFrameOrientation();
// For reprocess supported devices, bind the ReprocessTaskQueue with this // For reprocess supported devices, bind the ReprocessTaskQueue with this
// frame number. Once the shot result is returned, we will rebind the // frame number. Once the shot result is returned, we will rebind the
...@@ -377,7 +377,7 @@ bool RequestManager::TryPrepareReprocessRequest( ...@@ -377,7 +377,7 @@ bool RequestManager::TryPrepareReprocessRequest(
// Prepare metadata by adding extra metadata. // Prepare metadata by adding extra metadata.
*settings = reprocess_job_info->metadata.Clone(); *settings = reprocess_job_info->metadata.Clone();
SetSensorTimestamp(settings, reprocess_job_info->shutter_timestamp); SetSensorTimestamp(settings, reprocess_job_info->shutter_timestamp);
SetJpegOrientation(settings); SetJpegOrientation(settings, reprocess_job_info->orientation);
for (auto& metadata : task.extra_metadata) { for (auto& metadata : task.extra_metadata) {
AddOrUpdateMetadataEntry(settings, std::move(metadata)); AddOrUpdateMetadataEntry(settings, std::move(metadata));
} }
...@@ -440,7 +440,7 @@ bool RequestManager::TryPrepareOneShotRequest( ...@@ -440,7 +440,7 @@ bool RequestManager::TryPrepareOneShotRequest(
take_photo_callback_queue_.pop(); take_photo_callback_queue_.pop();
*settings = std::move(take_photo_settings_queue_.front()); *settings = std::move(take_photo_settings_queue_.front());
SetJpegOrientation(settings); SetJpegOrientation(settings, device_context_->GetCameraFrameOrientation());
} }
SetZeroShutterLag(settings, true); SetZeroShutterLag(settings, true);
take_photo_settings_queue_.pop(); take_photo_settings_queue_.pop();
...@@ -795,7 +795,8 @@ void RequestManager::SubmitCaptureResult( ...@@ -795,7 +795,8 @@ void RequestManager::SubmitCaptureResult(
DCHECK_GT(pending_result.shutter_timestamp, 0UL); DCHECK_GT(pending_result.shutter_timestamp, 0UL);
ReprocessJobInfo reprocess_job_info( ReprocessJobInfo reprocess_job_info(
std::move(frame_number_reprocess_tasks_map_[frame_number]), std::move(frame_number_reprocess_tasks_map_[frame_number]),
std::move(pending_result.metadata), pending_result.shutter_timestamp); std::move(pending_result.metadata), pending_result.shutter_timestamp,
pending_result.orientation);
buffer_id_reprocess_job_info_map_.emplace(buffer_ipc_id, buffer_id_reprocess_job_info_map_.emplace(buffer_ipc_id,
std::move(reprocess_job_info)); std::move(reprocess_job_info));
frame_number_reprocess_tasks_map_.erase(frame_number); frame_number_reprocess_tasks_map_.erase(frame_number);
...@@ -947,15 +948,18 @@ RequestManager::CaptureResult::~CaptureResult() = default; ...@@ -947,15 +948,18 @@ RequestManager::CaptureResult::~CaptureResult() = default;
RequestManager::ReprocessJobInfo::ReprocessJobInfo( RequestManager::ReprocessJobInfo::ReprocessJobInfo(
ReprocessTaskQueue queue, ReprocessTaskQueue queue,
cros::mojom::CameraMetadataPtr metadata, cros::mojom::CameraMetadataPtr metadata,
uint64_t timestamp) uint64_t timestamp,
int32_t orientation)
: task_queue(std::move(queue)), : task_queue(std::move(queue)),
metadata(std::move(metadata)), metadata(std::move(metadata)),
shutter_timestamp(timestamp) {} shutter_timestamp(timestamp),
orientation(orientation) {}
RequestManager::ReprocessJobInfo::ReprocessJobInfo(ReprocessJobInfo&& info) RequestManager::ReprocessJobInfo::ReprocessJobInfo(ReprocessJobInfo&& info)
: task_queue(std::move(info.task_queue)), : task_queue(std::move(info.task_queue)),
metadata(std::move(info.metadata)), metadata(std::move(info.metadata)),
shutter_timestamp(info.shutter_timestamp) {} shutter_timestamp(info.shutter_timestamp),
orientation(info.orientation) {}
RequestManager::ReprocessJobInfo::~ReprocessJobInfo() = default; RequestManager::ReprocessJobInfo::~ReprocessJobInfo() = default;
......
...@@ -119,6 +119,9 @@ class CAPTURE_EXPORT RequestManager final ...@@ -119,6 +119,9 @@ class CAPTURE_EXPORT RequestManager final
cros::mojom::Effect reprocess_effect; cros::mojom::Effect reprocess_effect;
// The input buffer id for this capture request. // The input buffer id for this capture request.
base::Optional<uint64_t> input_buffer_id; base::Optional<uint64_t> input_buffer_id;
// The orientation which is stored at the time the request is prepared. It
// can be used to construct the reprocess job info when the result is back.
int32_t orientation;
}; };
RequestManager(mojo::PendingReceiver<cros::mojom::Camera3CallbackOps> RequestManager(mojo::PendingReceiver<cros::mojom::Camera3CallbackOps>
...@@ -207,17 +210,20 @@ class CAPTURE_EXPORT RequestManager final ...@@ -207,17 +210,20 @@ class CAPTURE_EXPORT RequestManager final
struct ReprocessJobInfo { struct ReprocessJobInfo {
ReprocessJobInfo(ReprocessTaskQueue queue, ReprocessJobInfo(ReprocessTaskQueue queue,
cros::mojom::CameraMetadataPtr metadata, cros::mojom::CameraMetadataPtr metadata,
uint64_t timestamp); uint64_t timestamp,
int32_t orientation);
ReprocessJobInfo(ReprocessJobInfo&& info); ReprocessJobInfo(ReprocessJobInfo&& info);
~ReprocessJobInfo(); ~ReprocessJobInfo();
ReprocessTaskQueue task_queue; ReprocessTaskQueue task_queue;
cros::mojom::CameraMetadataPtr metadata; cros::mojom::CameraMetadataPtr metadata;
uint64_t shutter_timestamp; uint64_t shutter_timestamp;
int32_t orientation;
}; };
// Puts Jpeg orientation information into the metadata. // Puts Jpeg orientation information into the metadata.
void SetJpegOrientation(cros::mojom::CameraMetadataPtr* settings); void SetJpegOrientation(cros::mojom::CameraMetadataPtr* settings,
int32_t orientation);
// Puts sensor timestamp into the metadata for reprocess request. // Puts sensor timestamp into the metadata for reprocess request.
void SetSensorTimestamp(cros::mojom::CameraMetadataPtr* settings, void SetSensorTimestamp(cros::mojom::CameraMetadataPtr* settings,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment