diff options
author | David Plowman <david.plowman@raspberrypi.com> | 2022-03-03 12:11:13 +0000 |
---|---|---|
committer | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2022-03-04 16:21:03 +0000 |
commit | cdad084a913540c15050dd0a5d6b10f612b2730b (patch) | |
tree | 9cd8529a56fd012edaf67468fa467d896ddcf63a | |
parent | e68e0f1ed2880ea26b5e317f94e2bbd5332e1598 (diff) |
libcamera: pipeline: raspberrypi: Fix scaler crop when sensor is configured
We must calculate the initial scaler crop when the camera is
configured, otherwise the metadata will report this rectangle as being
all zeroes.
Because the calculation is identical to that performed later in handling
the scaler crop control, we factor it into a small helper function,
RPiCameraData::scaleIspCrop.
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r-- | src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 29bff9d6..c2230199 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -212,6 +212,7 @@ public: void handleStreamBuffer(FrameBuffer *buffer, RPi::Stream *stream); void handleExternalBuffer(FrameBuffer *buffer, RPi::Stream *stream); void handleState(); + Rectangle scaleIspCrop(const Rectangle &ispCrop) const; void applyScalerCrop(const ControlList &controls); std::unique_ptr<ipa::RPi::IPAProxyRPi> ipa_; @@ -888,6 +889,12 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) LOG(RPI, Error) << "Failed to configure the IPA: " << ret; /* + * Set the scaler crop to the value we are using (scaled to native sensor + * coordinates). + */ + data->scalerCrop_ = data->scaleIspCrop(data->ispCrop_); + + /* * Configure the Unicam embedded data output format only if the sensor * supports it. */ @@ -1974,6 +1981,18 @@ void RPiCameraData::checkRequestCompleted() } } +Rectangle RPiCameraData::scaleIspCrop(const Rectangle &ispCrop) const +{ + /* + * Scale a crop rectangle defined in the ISP's coordinates into native sensor + * coordinates. + */ + Rectangle nativeCrop = ispCrop.scaledBy(sensorInfo_.analogCrop.size(), + sensorInfo_.outputSize); + nativeCrop.translateBy(sensorInfo_.analogCrop.topLeft()); + return nativeCrop; +} + void RPiCameraData::applyScalerCrop(const ControlList &controls) { if (controls.contains(controls::ScalerCrop)) { @@ -2006,9 +2025,7 @@ void RPiCameraData::applyScalerCrop(const ControlList &controls) * used. But we must first rescale that from ISP (camera mode) pixels * back into sensor native pixels. */ - scalerCrop_ = ispCrop_.scaledBy(sensorInfo_.analogCrop.size(), - sensorInfo_.outputSize); - scalerCrop_.translateBy(sensorInfo_.analogCrop.topLeft()); + scalerCrop_ = scaleIspCrop(ispCrop_); } } } |