<div dir="ltr"><div dir="ltr">Hi Naush,</div><div dir="ltr"><br></div><div dir="ltr">Thanks - that seems to fix it</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 13 Jul 2022 at 13:00, Naushir Patuck <<a href="mailto:naush@raspberrypi.com" target="_blank">naush@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">The logic used to match asynchronous image and embedded buffers was being overly<br>
aggressive by possibly allowing an unmatched image buffer to be sent to the IPA<br>
if the matching embedded buffer had not yet been dequeued. This condition only<br>
occurs when the system is heavily loaded and dropping frames.<br>
<br>
Fix this by holding image buffer in the queue during these conditions until the<br>
next embedded buffer dequeue event.<br>
<br>
Reported-by: Nick Hollinghurst <<a href="mailto:nick.hollinghurst@raspberrypi.com" target="_blank">nick.hollinghurst@raspberrypi.com</a>><br>
Signed-off-by: Naushir Patuck <<a href="mailto:naush@raspberrypi.com" target="_blank">naush@raspberrypi.com</a>></blockquote><div>Reviewed-by: Nick Hollinghurst <<a href="mailto:nick.hollinghurst@raspberrypi.com" target="_blank">nick.hollinghurst@raspberrypi.com</a>><br></div><div>Tested-by: Nick Hollinghurst <<a href="mailto:nick.hollinghurst@raspberrypi.com" target="_blank">nick.hollinghurst@raspberrypi.com</a>></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 | 19 ++++++++++++++-----<br>
1 file changed, 14 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp<br>
index 66a84b1dfb97..ef3c2d11d253 100644<br>
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp<br>
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp<br>
@@ -2159,16 +2159,12 @@ bool RPiCameraData::findMatchingBuffers(BayerFrame &bayerFrame, FrameBuffer *&em<br>
if (bayerQueue_.empty())<br>
return false;<br>
<br>
- /* Start with the front of the bayer queue. */<br>
- bayerFrame = std::move(bayerQueue_.front());<br>
- bayerQueue_.pop();<br>
-<br>
/*<br>
* Find the embedded data buffer with a matching timestamp to pass to<br>
* the IPA. Any embedded buffers with a timestamp lower than the<br>
* current bayer buffer will be removed and re-queued to the driver.<br>
*/<br>
- uint64_t ts = bayerFrame.buffer->metadata().timestamp;<br>
+ uint64_t ts = bayerQueue_.front().buffer->metadata().timestamp;<br>
embeddedBuffer = nullptr;<br>
while (!embeddedQueue_.empty()) {<br>
FrameBuffer *b = embeddedQueue_.front();<br>
@@ -2188,10 +2184,23 @@ bool RPiCameraData::findMatchingBuffers(BayerFrame &bayerFrame, FrameBuffer *&em<br>
}<br>
<br>
if (!embeddedBuffer && sensorMetadata_) {<br>
+ if (embeddedQueue_.empty()) {<br>
+ /*<br>
+ * If the embedded buffer queue is empty, wait for the next<br>
+ * buffer to arrive - dequeue ordering may send the image<br>
+ * buffer first.<br>
+ */<br>
+ LOG(RPI, Debug) << "Waiting for next embedded buffer.";<br>
+ return false;<br>
+ }<br>
+<br>
/* Log if there is no matching embedded data buffer found. */<br>
LOG(RPI, Debug) << "Returning bayer frame without a matching embedded buffer.";<br>
}<br>
<br>
+ bayerFrame = std::move(bayerQueue_.front());<br>
+ bayerQueue_.pop();<br>
+<br>
return true;<br>
}<br>
<br>
-- <br>
2.25.1<br>
<br>
</blockquote></div></div>