[libcamera-devel,v2,5/5] libcamera: delayed_controls: Fix off-by-one error in get()
diff mbox series

Message ID 20210216085342.1012717-6-naush@raspberrypi.com
State Superseded
Delegated to: Niklas Söderlund
Headers show
Series
  • DelayedControls updates and fixes
Related show

Commit Message

Naushir Patuck Feb. 16, 2021, 8:53 a.m. UTC
There was an off-by-one error in DelayedControls::get() when picking
controls from the queue to return back to the pipeline handler.
This is only noticeable as small oscillations in brightness when closely
viewing frame while AGC is running. The old StaggeredCtrl did not show
this error as the startup queuing mechanism has changed in
DelayedControls.

Fix this by indexing to the correct position in the queue.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reported-by: David Plowman <david.plowman@raspberrypi.com>
Fixes: 3d4b7b005911 ("libcamera: delayed_controls: Add helper for controls that apply with a delay")
---
 src/libcamera/delayed_controls.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paul Elder March 1, 2021, 9:54 a.m. UTC | #1
Hi Naush,

On Tue, Feb 16, 2021 at 08:53:42AM +0000, Naushir Patuck wrote:
> There was an off-by-one error in DelayedControls::get() when picking
> controls from the queue to return back to the pipeline handler.
> This is only noticeable as small oscillations in brightness when closely
> viewing frame while AGC is running. The old StaggeredCtrl did not show
> this error as the startup queuing mechanism has changed in
> DelayedControls.
> 
> Fix this by indexing to the correct position in the queue.
> 
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> Reported-by: David Plowman <david.plowman@raspberrypi.com>
> Fixes: 3d4b7b005911 ("libcamera: delayed_controls: Add helper for controls that apply with a delay")

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  src/libcamera/delayed_controls.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/delayed_controls.cpp b/src/libcamera/delayed_controls.cpp
> index d1b79dc3570e..3f829e8c40f2 100644
> --- a/src/libcamera/delayed_controls.cpp
> +++ b/src/libcamera/delayed_controls.cpp
> @@ -183,7 +183,7 @@ bool DelayedControls::push(const ControlList &controls)
>   */
>  ControlList DelayedControls::get(uint32_t sequence)
>  {
> -	uint32_t adjustedSeq = sequence - firstSequence_ + 1;
> +	uint32_t adjustedSeq = sequence - firstSequence_;
>  	unsigned int index = std::max<int>(0, adjustedSeq - maxDelay_);
>  
>  	ControlList out(device_->controls());
> -- 
> 2.25.1
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch
diff mbox series

diff --git a/src/libcamera/delayed_controls.cpp b/src/libcamera/delayed_controls.cpp
index d1b79dc3570e..3f829e8c40f2 100644
--- a/src/libcamera/delayed_controls.cpp
+++ b/src/libcamera/delayed_controls.cpp
@@ -183,7 +183,7 @@  bool DelayedControls::push(const ControlList &controls)
  */
 ControlList DelayedControls::get(uint32_t sequence)
 {
-	uint32_t adjustedSeq = sequence - firstSequence_ + 1;
+	uint32_t adjustedSeq = sequence - firstSequence_;
 	unsigned int index = std::max<int>(0, adjustedSeq - maxDelay_);
 
 	ControlList out(device_->controls());