Skip to contentSkip to conversation

media/doc: Allow sizeimage to be set by v4l clients

RFC PATCH In review Stanimir Varbanov 2 participants 7 messages Jan 16, 2019 – Apr 10, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 media/doc: Allow sizeimage to be set by v4l clients

This changes v4l2_pix_format and v4l2_plane_pix_format sizeimage field description to allow v4l clients to set bigger image size in case of variable length compressed data.

---
 Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst | 5 ++++-
 Documentation/media/uapi/v4l/pixfmt-v4l2.rst        | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)
Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst +4 -1
index 7f82dad9013a..dbe0b74e9ba4 100644
@@ -30,7 +30,10 @@ describing all planes of that format.
 
     * - __u32
       - ``sizeimage``
-      - Maximum size in bytes required for image data in this plane.
+      - Maximum size in bytes required for image data in this plane,
+        set by the driver. When the image consists of variable length
+        compressed data this is the maximum number of bytes required
+        to hold an image, and it is allowed to be set by the client.
     * - __u32
       - ``bytesperline``
       - Distance in bytes between the leftmost pixels in two adjacent
Documentation/media/uapi/v4l/pixfmt-v4l2.rst +2 -1
index 71eebfc6d853..54b6d2b67bd7 100644
@@ -89,7 +89,8 @@ Single-planar format structure
       - Size in bytes of the buffer to hold a complete image, set by the
 	driver. Usually this is ``bytesperline`` times ``height``. When
 	the image consists of variable length compressed data this is the
-	maximum number of bytes required to hold an image.
+	maximum number of bytes required to hold an image, and it is
+	allowed to be set by the client.
     * - __u32
       - ``colorspace``
       - Image colorspace, from enum :c:type:`v4l2_colorspace`.
Signature · 1 line
2.17.1
#1 lore raw
Quoted 32 lines · Stanimir Varbanov

This changes v4l2_pix_format and v4l2_plane_pix_format sizeimage field description to allow v4l clients to set bigger image size in case of variable length compressed data.

---
 Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst | 5 ++++-
 Documentation/media/uapi/v4l/pixfmt-v4l2.rst        | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)
Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst +4 -1
index 7f82dad9013a..dbe0b74e9ba4 100644
@@ -30,7 +30,10 @@ describing all planes of that format.
 
     * - __u32
       - ``sizeimage``
-      - Maximum size in bytes required for image data in this plane.
+      - Maximum size in bytes required for image data in this plane,
+        set by the driver. When the image consists of variable length
+        compressed data this is the maximum number of bytes required
+        to hold an image, and it is allowed to be set by the client.
     * - __u32
       - ``bytesperline``
       - Distance in bytes between the leftmost pixels in two adjacent
Documentation/media/uapi/v4l/pixfmt-v4l2.rst +0 -0
index 71eebfc6d853..54b6d2b67bd7 100644

Documentation/media/uapi/v4l/pixfmt-v4l2.rst Single-planar format structure · line 96

Quoted 9 lines
Documentation/media/uapi/v4l/pixfmt-v4l2.rst +2 -1
@@ -89,7 +89,8 @@ Single-planar format structure
       - Size in bytes of the buffer to hold a complete image, set by the
 	driver. Usually this is ``bytesperline`` times ``height``. When
 	the image consists of variable length compressed data this is the
-	maximum number of bytes required to hold an image.
+	maximum number of bytes required to hold an image, and it is
+	allowed to be set by the client.
     * - __u32
       - ``colorspace``
       - Image colorspace, from enum :c:type:`v4l2_colorspace`.

Hmm. "maximum number of bytes required to hold an image": that's not actually true for bitstream formats like MPEG. It's just the size of the buffer used to store the bitstream, i.e. one buffer may actually contain multiple compressed images, or a compressed image is split over multiple buffers.

Only for MJPEG is this statement true since each buffer will contain a single compressed JPEG image.

Regards,

Hans

#2 lore raw

Hi Hans,

Quoted 39 lines · Hans Verkuil
Quoted 38 lines · Stanimir Varbanov

This changes v4l2_pix_format and v4l2_plane_pix_format sizeimage field description to allow v4l clients to set bigger image size in case of variable length compressed data.

---
 Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst | 5 ++++-
 Documentation/media/uapi/v4l/pixfmt-v4l2.rst        | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)
Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst +4 -1
index 7f82dad9013a..dbe0b74e9ba4 100644
@@ -30,7 +30,10 @@ describing all planes of that format.
 
     * - __u32
       - ``sizeimage``
-      - Maximum size in bytes required for image data in this plane.
+      - Maximum size in bytes required for image data in this plane,
+        set by the driver. When the image consists of variable length
+        compressed data this is the maximum number of bytes required
+        to hold an image, and it is allowed to be set by the client.
     * - __u32
       - ``bytesperline``
       - Distance in bytes between the leftmost pixels in two adjacent
Documentation/media/uapi/v4l/pixfmt-v4l2.rst +2 -1
index 71eebfc6d853..54b6d2b67bd7 100644
@@ -89,7 +89,8 @@ Single-planar format structure
       - Size in bytes of the buffer to hold a complete image, set by the
 	driver. Usually this is ``bytesperline`` times ``height``. When
 	the image consists of variable length compressed data this is the
-	maximum number of bytes required to hold an image.
+	maximum number of bytes required to hold an image, and it is
+	allowed to be set by the client.
     * - __u32
Quoted 9 lines

Documentation/media/uapi/v4l/pixfmt-v4l2.rst Single-planar format structure · line 96

Quoted 3 lines
Documentation/media/uapi/v4l/pixfmt-v4l2.rst +0 -0
       - ``colorspace``
       - Image colorspace, from enum :c:type:`v4l2_colorspace`.

Hmm. "maximum number of bytes required to hold an image": that's not actually true for bitstream formats like MPEG. It's just the size of the buffer used to store the bitstream, i.e. one buffer may actually contain multiple compressed images, or a compressed image is split over multiple buffers.

Do you want me to change something in the current documentation, i.e. the quoted above?

Quoted 7 lines

Only for MJPEG is this statement true since each buffer will contain a single compressed JPEG image.

Regards,

Hans

Signature · 2 lines
regards,
Stan
#3 lore raw
Quoted 52 lines · Stanimir Varbanov

Hi Hans,

Quoted 39 lines · Hans Verkuil
Quoted 38 lines · Stanimir Varbanov

This changes v4l2_pix_format and v4l2_plane_pix_format sizeimage field description to allow v4l clients to set bigger image size in case of variable length compressed data.

---
 Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst | 5 ++++-
 Documentation/media/uapi/v4l/pixfmt-v4l2.rst        | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)
Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst +4 -1
index 7f82dad9013a..dbe0b74e9ba4 100644
@@ -30,7 +30,10 @@ describing all planes of that format.
 
     * - __u32
       - ``sizeimage``
-      - Maximum size in bytes required for image data in this plane.
+      - Maximum size in bytes required for image data in this plane,
+        set by the driver. When the image consists of variable length
+        compressed data this is the maximum number of bytes required
+        to hold an image, and it is allowed to be set by the client.
     * - __u32
       - ``bytesperline``
       - Distance in bytes between the leftmost pixels in two adjacent
Documentation/media/uapi/v4l/pixfmt-v4l2.rst +2 -1
index 71eebfc6d853..54b6d2b67bd7 100644
@@ -89,7 +89,8 @@ Single-planar format structure
       - Size in bytes of the buffer to hold a complete image, set by the
 	driver. Usually this is ``bytesperline`` times ``height``. When
 	the image consists of variable length compressed data this is the
-	maximum number of bytes required to hold an image.
+	maximum number of bytes required to hold an image, and it is
+	allowed to be set by the client.
     * - __u32
Quoted 9 lines

Documentation/media/uapi/v4l/pixfmt-v4l2.rst Single-planar format structure · line 96

Quoted 3 lines
Documentation/media/uapi/v4l/pixfmt-v4l2.rst +0 -0
       - ``colorspace``
       - Image colorspace, from enum :c:type:`v4l2_colorspace`.

Hmm. "maximum number of bytes required to hold an image": that's not actually true for bitstream formats like MPEG. It's just the size of the buffer used to store the bitstream, i.e. one buffer may actually contain multiple compressed images, or a compressed image is split over multiple buffers.

Quoted 2 lines

Do you want me to change something in the current documentation, i.e. the quoted above?

Hmm, it looks like this discussion stalled (i.e. I forgot to reply).

How about this:

"When the image consists of variable length compressed data this is the number of bytes required by the encoder to support the worst-case compression scenario. Clients are allowed to set this field. However, drivers may ignore the value or modify it."

Regards,

Hans

Quoted 9 lines
Quoted 8 lines

Only for MJPEG is this statement true since each buffer will contain a single compressed JPEG image.

Regards,

Hans

#4 lore raw

Hi Hans,

Quoted 56 lines · Hans Verkuil
Quoted 52 lines · Stanimir Varbanov

Hi Hans,

Quoted 39 lines · Hans Verkuil
Quoted 38 lines · Stanimir Varbanov

This changes v4l2_pix_format and v4l2_plane_pix_format sizeimage field description to allow v4l clients to set bigger image size in case of variable length compressed data.

---
 Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst | 5 ++++-
 Documentation/media/uapi/v4l/pixfmt-v4l2.rst        | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)
Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst +4 -1
index 7f82dad9013a..dbe0b74e9ba4 100644
@@ -30,7 +30,10 @@ describing all planes of that format.
 
     * - __u32
       - ``sizeimage``
-      - Maximum size in bytes required for image data in this plane.
+      - Maximum size in bytes required for image data in this plane,
+        set by the driver. When the image consists of variable length
+        compressed data this is the maximum number of bytes required
+        to hold an image, and it is allowed to be set by the client.
     * - __u32
       - ``bytesperline``
       - Distance in bytes between the leftmost pixels in two adjacent
Documentation/media/uapi/v4l/pixfmt-v4l2.rst +2 -1
index 71eebfc6d853..54b6d2b67bd7 100644
@@ -89,7 +89,8 @@ Single-planar format structure
       - Size in bytes of the buffer to hold a complete image, set by the
 	driver. Usually this is ``bytesperline`` times ``height``. When
 	the image consists of variable length compressed data this is the
-	maximum number of bytes required to hold an image.
+	maximum number of bytes required to hold an image, and it is
+	allowed to be set by the client.
     * - __u32
Quoted 9 lines

Documentation/media/uapi/v4l/pixfmt-v4l2.rst Single-planar format structure · line 96

Quoted 3 lines
Documentation/media/uapi/v4l/pixfmt-v4l2.rst +0 -0
       - ``colorspace``
       - Image colorspace, from enum :c:type:`v4l2_colorspace`.

Hmm. "maximum number of bytes required to hold an image": that's not actually true for bitstream formats like MPEG. It's just the size of the buffer used to store the bitstream, i.e. one buffer may actually contain multiple compressed images, or a compressed image is split over multiple buffers.

Quoted 2 lines

Do you want me to change something in the current documentation, i.e. the quoted above?

Quoted 6 lines

Hmm, it looks like this discussion stalled (i.e. I forgot to reply).

How about this:

"When the image consists of variable length compressed data this is the number of bytes required by the encoder to support the worst-case

I don't think 'encoder' is the right word here:

s/encoder/encoder or decoder

Quoted 2 lines

compression scenario. Clients are allowed to set this field. However, drivers may ignore the value or modify it."

Can we rephrase to:

"Clients are allowed to set sizeimage field, but however drivers my ignore the value or modify it."

Signature · 2 lines
regards,
Stan
#5 lore raw
Quoted 61 lines · Stanimir Varbanov

Hi Hans,

Quoted 58 lines · Hans Verkuil
Quoted 52 lines · Stanimir Varbanov

Hi Hans,

Quoted 39 lines · Hans Verkuil
Quoted 38 lines · Stanimir Varbanov

This changes v4l2_pix_format and v4l2_plane_pix_format sizeimage field description to allow v4l clients to set bigger image size in case of variable length compressed data.

---
 Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst | 5 ++++-
 Documentation/media/uapi/v4l/pixfmt-v4l2.rst        | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)
Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst +4 -1
index 7f82dad9013a..dbe0b74e9ba4 100644
@@ -30,7 +30,10 @@ describing all planes of that format.
 
     * - __u32
       - ``sizeimage``
-      - Maximum size in bytes required for image data in this plane.
+      - Maximum size in bytes required for image data in this plane,
+        set by the driver. When the image consists of variable length
+        compressed data this is the maximum number of bytes required
+        to hold an image, and it is allowed to be set by the client.
     * - __u32
       - ``bytesperline``
       - Distance in bytes between the leftmost pixels in two adjacent
Documentation/media/uapi/v4l/pixfmt-v4l2.rst +2 -1
index 71eebfc6d853..54b6d2b67bd7 100644
@@ -89,7 +89,8 @@ Single-planar format structure
       - Size in bytes of the buffer to hold a complete image, set by the
 	driver. Usually this is ``bytesperline`` times ``height``. When
 	the image consists of variable length compressed data this is the
-	maximum number of bytes required to hold an image.
+	maximum number of bytes required to hold an image, and it is
+	allowed to be set by the client.
     * - __u32
Quoted 9 lines

Documentation/media/uapi/v4l/pixfmt-v4l2.rst Single-planar format structure · line 96

Quoted 3 lines
Documentation/media/uapi/v4l/pixfmt-v4l2.rst +0 -0
       - ``colorspace``
       - Image colorspace, from enum :c:type:`v4l2_colorspace`.

Hmm. "maximum number of bytes required to hold an image": that's not actually true for bitstream formats like MPEG. It's just the size of the buffer used to store the bitstream, i.e. one buffer may actually contain multiple compressed images, or a compressed image is split over multiple buffers.

Quoted 2 lines

Do you want me to change something in the current documentation, i.e. the quoted above?

Hmm, it looks like this discussion stalled (i.e. I forgot to reply).

Quoted 8 lines
Quoted 4 lines

How about this:

"When the image consists of variable length compressed data this is the number of bytes required by the encoder to support the worst-case

I don't think 'encoder' is the right word here:

s/encoder/encoder or decoder

or perhaps just 'codec'? Either is fine by me.

Quoted 9 lines
Quoted 3 lines

compression scenario. Clients are allowed to set this field. However, drivers may ignore the value or modify it."

Can we rephrase to:

"Clients are allowed to set sizeimage field, but however drivers my ignore the value or modify it."

How about this:

"Clients are allowed to set the sizeimage field, but drivers may
modify it."

'ignore the value' isn't right, since that suggests that the sizeimage value that is returned may not be in actual use. Since sizeimage can now be set by userspace, this means that a sanity check is needed in drivers as well (i.e. what if userspace sets sizeimage to ~0?)

This should be tested in v4l2-compliance as well.

Regards,

Hans

#6 lore raw
Quoted 64 lines · Hans Verkuil
Quoted 63 lines · Stanimir Varbanov

Hi Hans,

Quoted 60 lines · Hans Verkuil
Quoted 52 lines · Stanimir Varbanov

Hi Hans,

Quoted 39 lines · Hans Verkuil
Quoted 38 lines · Stanimir Varbanov

This changes v4l2_pix_format and v4l2_plane_pix_format sizeimage field description to allow v4l clients to set bigger image size in case of variable length compressed data.

---
 Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst | 5 ++++-
 Documentation/media/uapi/v4l/pixfmt-v4l2.rst        | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)
Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst +4 -1
index 7f82dad9013a..dbe0b74e9ba4 100644
@@ -30,7 +30,10 @@ describing all planes of that format.
 
     * - __u32
       - ``sizeimage``
-      - Maximum size in bytes required for image data in this plane.
+      - Maximum size in bytes required for image data in this plane,
+        set by the driver. When the image consists of variable length
+        compressed data this is the maximum number of bytes required
+        to hold an image, and it is allowed to be set by the client.
     * - __u32
       - ``bytesperline``
       - Distance in bytes between the leftmost pixels in two adjacent
Documentation/media/uapi/v4l/pixfmt-v4l2.rst +2 -1
index 71eebfc6d853..54b6d2b67bd7 100644
@@ -89,7 +89,8 @@ Single-planar format structure
       - Size in bytes of the buffer to hold a complete image, set by the
 	driver. Usually this is ``bytesperline`` times ``height``. When
 	the image consists of variable length compressed data this is the
-	maximum number of bytes required to hold an image.
+	maximum number of bytes required to hold an image, and it is
+	allowed to be set by the client.
     * - __u32
Quoted 9 lines

Documentation/media/uapi/v4l/pixfmt-v4l2.rst Single-planar format structure · line 96

Quoted 3 lines
Documentation/media/uapi/v4l/pixfmt-v4l2.rst +0 -0
       - ``colorspace``
       - Image colorspace, from enum :c:type:`v4l2_colorspace`.

Hmm. "maximum number of bytes required to hold an image": that's not actually true for bitstream formats like MPEG. It's just the size of the buffer used to store the bitstream, i.e. one buffer may actually contain multiple compressed images, or a compressed image is split over multiple buffers.

Quoted 2 lines

Do you want me to change something in the current documentation, i.e. the quoted above?

Hmm, it looks like this discussion stalled (i.e. I forgot to reply).

How about this:

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

"When the image consists of variable length compressed data this is the number of bytes required by the encoder to support the worst-case

I don't think 'encoder' is the right word here:

s/encoder/encoder or decoder

or perhaps just 'codec'? Either is fine by me.

OK, then just 'codec'.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

compression scenario. Clients are allowed to set this field. However, drivers may ignore the value or modify it."

Can we rephrase to:

Quoted 8 lines
Quoted 3 lines

"Clients are allowed to set sizeimage field, but however drivers my ignore the value or modify it."

How about this:

"Clients are allowed to set the sizeimage field, but drivers may
modify it."

I'm fine with that.

I'll send with those changes and as regular patch. Thanks!

Quoted 12 lines

'ignore the value' isn't right, since that suggests that the sizeimage value that is returned may not be in actual use. Since sizeimage can now be set by userspace, this means that a sanity check is needed in drivers as well (i.e. what if userspace sets sizeimage to ~0?)

This should be tested in v4l2-compliance as well.

Regards,

Hans

Signature · 2 lines
regards,
Stan