[PATCH] v4l: Cast timestamp tv_usec to singned

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some of the MPEG4 standards allows negative timestamps. Correct
tv_usec cast to s32.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@xxxxxxxxxx>
---
 include/media/v4l2-common.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index 3eb202259e8c..1ed61416003a 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -544,11 +544,11 @@ static inline u64 v4l2_buffer_get_timestamp(const struct v4l2_buffer *buf)
 {
 	/*
 	 * When the timestamp comes from 32-bit user space, there may be
-	 * uninitialized data in tv_usec, so cast it to u32.
+	 * uninitialized data in tv_usec, so cast it to s32.
 	 * Otherwise allow invalid input for backwards compatibility.
 	 */
 	return buf->timestamp.tv_sec * NSEC_PER_SEC +
-		(u32)buf->timestamp.tv_usec * NSEC_PER_USEC;
+		(s32)buf->timestamp.tv_usec * NSEC_PER_USEC;
 }
 
 static inline void v4l2_buffer_set_timestamp(struct v4l2_buffer *buf,
-- 
2.25.1




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux