[libcamera-devel] [PATCH] v4l2: v4l2_camera_proxy: Fix timestamp calculation
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Tue Feb 15 07:42:13 CET 2022
Hi Kieran,
Thank you for the patch.
On Mon, Feb 14, 2022 at 12:39:51PM +0000, Kieran Bingham wrote:
> The V4L2 Compatibility layer is returning timestamps for buffers which
> are incorrectly calculated from the frame metadata.
>
> The sec component of the timestamp is correct, but the nsec component is
Did you mean usec ?
> out, leaving frame captures reporting non-monotonically increasing
> timestamps, and incorrect frame rate calculations.
>
> Fix the usecs calculation reported by the V4L2 adaptation layer.
>
> Bug: https://bugs.libcamera.org/show_bug.cgi?id=118
> Fixes: 0ce8f2390b52 ("v4l2: v4l2_compat: Add V4L2 compatibility layer")
> Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> ---
> src/v4l2/v4l2_camera_proxy.cpp | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
> index 45822feff317..67b2c50c0f7e 100644
> --- a/src/v4l2/v4l2_camera_proxy.cpp
> +++ b/src/v4l2/v4l2_camera_proxy.cpp
> @@ -234,7 +234,7 @@ void V4L2CameraProxy::updateBuffers()
> });
> buf.field = V4L2_FIELD_NONE;
> buf.timestamp.tv_sec = fmd.timestamp / 1000000000;
> - buf.timestamp.tv_usec = fmd.timestamp % 1000000;
> + buf.timestamp.tv_usec = fmd.timestamp / 1000 % 1000000;
I'd have written
buf.timestamp.tv_usec = (fmd.timestamp / 1000) % 1000000;
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
either way.
> buf.sequence = fmd.sequence;
>
> buf.flags |= V4L2_BUF_FLAG_DONE;
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list