<div dir="ltr"><div dir="ltr">Hi David,<div><br></div><div>Thank you for your patch.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 3 Mar 2022 at 12:11, David Plowman <<a href="mailto:david.plowman@raspberrypi.com">david.plowman@raspberrypi.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">We must calculate the initial scaler crop when the camera is<br>
configured, otherwise the metadata will report this rectangle as being<br>
all zeroes.<br>
<br>
Because the calculation is identical to that performed later in handling<br>
the scaler crop control, we factor it into a small helper function,<br>
RPiCameraData::scaleIspCrop.<br>
<br>
Signed-off-by: David Plowman <<a href="mailto:david.plowman@raspberrypi.com" target="_blank">david.plowman@raspberrypi.com</a>><br></blockquote><div><br></div><div>Reviewed-by: Naushir Patuck <<a href="mailto:naush@raspberrypi.com">naush@raspberrypi.com</a>></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
.../pipeline/raspberrypi/raspberrypi.cpp | 20 ++++++++++++++++---<br>
1 file changed, 17 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp<br>
index 29bff9d6..eede78e6 100644<br>
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp<br>
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp<br>
@@ -212,6 +212,7 @@ public:<br>
void handleStreamBuffer(FrameBuffer *buffer, RPi::Stream *stream);<br>
void handleExternalBuffer(FrameBuffer *buffer, RPi::Stream *stream);<br>
void handleState();<br>
+ Rectangle scaleIspCrop(const Rectangle &ispCrop) const;<br>
void applyScalerCrop(const ControlList &controls);<br>
<br>
std::unique_ptr<ipa::RPi::IPAProxyRPi> ipa_;<br>
@@ -887,6 +888,9 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)<br>
if (ret)<br>
LOG(RPI, Error) << "Failed to configure the IPA: " << ret;<br>
<br>
+ /* Set the scaler crop to the value we are using (scaled to native sensor coordinates). */<br>
+ data->scalerCrop_ = data->scaleIspCrop(data->ispCrop_);<br>
+<br>
/*<br>
* Configure the Unicam embedded data output format only if the sensor<br>
* supports it.<br>
@@ -1974,6 +1978,18 @@ void RPiCameraData::checkRequestCompleted()<br>
}<br>
}<br>
<br>
+Rectangle RPiCameraData::scaleIspCrop(const Rectangle &ispCrop) const<br>
+{<br>
+ /*<br>
+ * Scale a crop rectangle defined in the ISP's coordinates into native sensor<br>
+ * coordinates.<br>
+ */<br>
+ Rectangle nativeCrop = ispCrop.scaledBy(sensorInfo_.analogCrop.size(),<br>
+ sensorInfo_.outputSize);<br>
+ nativeCrop.translateBy(sensorInfo_.analogCrop.topLeft());<br>
+ return nativeCrop;<br>
+}<br>
+<br>
void RPiCameraData::applyScalerCrop(const ControlList &controls)<br>
{<br>
if (controls.contains(controls::ScalerCrop)) {<br>
@@ -2006,9 +2022,7 @@ void RPiCameraData::applyScalerCrop(const ControlList &controls)<br>
* used. But we must first rescale that from ISP (camera mode) pixels<br>
* back into sensor native pixels.<br>
*/<br>
- scalerCrop_ = ispCrop_.scaledBy(sensorInfo_.analogCrop.size(),<br>
- sensorInfo_.outputSize);<br>
- scalerCrop_.translateBy(sensorInfo_.analogCrop.topLeft());<br>
+ scalerCrop_ = scaleIspCrop(ispCrop_);<br>
}<br>
}<br>
}<br>
-- <br>
2.30.2<br>
<br>
</blockquote></div></div>