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(
}
void RequestManager::SetJpegOrientation(
cros::mojom::CameraMetadataPtr* settings) {
cros::mojom::CameraMetadataPtr* settings,
int32_t orientation) {
auto e = BuildMetadataEntry(
cros::mojom::CameraMetadataTag::ANDROID_JPEG_ORIENTATION,
base::checked_cast<int32_t>(
device_context_->GetCameraFrameOrientation()));
cros::mojom::CameraMetadataTag::ANDROID_JPEG_ORIENTATION, orientation);
AddOrUpdateMetadataEntry(settings, std::move(e));
}
......@@ -319,6 +318,7 @@ void RequestManager::PrepareCaptureRequest() {
pending_result.input_buffer_id = input_buffer_id;
pending_result.reprocess_effect = reprocess_effect;
pending_result.still_capture_callback = std::move(callback);
pending_result.orientation = device_context_->GetCameraFrameOrientation();
// For reprocess supported devices, bind the ReprocessTaskQueue with this
// frame number. Once the shot result is returned, we will rebind the
......@@ -377,7 +377,7 @@ bool RequestManager::TryPrepareReprocessRequest(
// Prepare metadata by adding extra metadata.
*settings = reprocess_job_info->metadata.Clone();
SetSensorTimestamp(settings, reprocess_job_info->shutter_timestamp);
SetJpegOrientation(settings);
SetJpegOrientation(settings, reprocess_job_info->orientation);
for (auto& metadata : task.extra_metadata) {
AddOrUpdateMetadataEntry(settings, std::move(metadata));
}
......@@ -440,7 +440,7 @@ bool RequestManager::TryPrepareOneShotRequest(
take_photo_callback_queue_.pop();
*settings = std::move(take_photo_settings_queue_.front());
SetJpegOrientation(settings);
SetJpegOrientation(settings, device_context_->GetCameraFrameOrientation());
}
SetZeroShutterLag(settings, true);
take_photo_settings_queue_.pop();
......@@ -795,7 +795,8 @@ void RequestManager::SubmitCaptureResult(
DCHECK_GT(pending_result.shutter_timestamp, 0UL);
ReprocessJobInfo reprocess_job_info(
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,
std::move(reprocess_job_info));
frame_number_reprocess_tasks_map_.erase(frame_number);
......@@ -947,15 +948,18 @@ RequestManager::CaptureResult::~CaptureResult() = default;
RequestManager::ReprocessJobInfo::ReprocessJobInfo(
ReprocessTaskQueue queue,
cros::mojom::CameraMetadataPtr metadata,
uint64_t timestamp)
uint64_t timestamp,
int32_t orientation)
: task_queue(std::move(queue)),
metadata(std::move(metadata)),
shutter_timestamp(timestamp) {}
shutter_timestamp(timestamp),
orientation(orientation) {}
RequestManager::ReprocessJobInfo::ReprocessJobInfo(ReprocessJobInfo&& info)
: task_queue(std::move(info.task_queue)),
metadata(std::move(info.metadata)),
shutter_timestamp(info.shutter_timestamp) {}
shutter_timestamp(info.shutter_timestamp),
orientation(info.orientation) {}
RequestManager::ReprocessJobInfo::~ReprocessJobInfo() = default;
......
......@@ -119,6 +119,9 @@ class CAPTURE_EXPORT RequestManager final
cros::mojom::Effect reprocess_effect;
// The input buffer id for this capture request.
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>
......@@ -207,17 +210,20 @@ class CAPTURE_EXPORT RequestManager final
struct ReprocessJobInfo {
ReprocessJobInfo(ReprocessTaskQueue queue,
cros::mojom::CameraMetadataPtr metadata,
uint64_t timestamp);
uint64_t timestamp,
int32_t orientation);
ReprocessJobInfo(ReprocessJobInfo&& info);
~ReprocessJobInfo();
ReprocessTaskQueue task_queue;
cros::mojom::CameraMetadataPtr metadata;
uint64_t shutter_timestamp;
int32_t orientation;
};
// 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.
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