1.. Permission is granted to copy, distribute and/or modify this 2.. document under the terms of the GNU Free Documentation License, 3.. Version 1.1 or any later version published by the Free Software 4.. Foundation, with no Invariant Sections, no Front-Cover Texts 5.. and no Back-Cover Texts. A copy of the license is included at 6.. Documentation/userspace-api/media/fdl-appendix.rst. 7.. 8.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections 9 10****************************** 11Single-planar format structure 12****************************** 13 14.. tabularcolumns:: |p{4.0cm}|p{2.5cm}|p{11.0cm}| 15 16.. c:type:: v4l2_pix_format 17 18.. cssclass:: longtable 19 20.. flat-table:: struct v4l2_pix_format 21 :header-rows: 0 22 :stub-columns: 0 23 :widths: 1 1 2 24 25 * - __u32 26 - ``width`` 27 - Image width in pixels. 28 * - __u32 29 - ``height`` 30 - Image height in pixels. If ``field`` is one of ``V4L2_FIELD_TOP``, 31 ``V4L2_FIELD_BOTTOM`` or ``V4L2_FIELD_ALTERNATE`` then height 32 refers to the number of lines in the field, otherwise it refers to 33 the number of lines in the frame (which is twice the field height 34 for interlaced formats). 35 * - :cspan:`2` Applications set these fields to request an image 36 size, drivers return the closest possible values. In case of 37 planar formats the ``width`` and ``height`` applies to the largest 38 plane. To avoid ambiguities drivers must return values rounded up 39 to a multiple of the scale factor of any smaller planes. For 40 example when the image format is YUV 4:2:0, ``width`` and 41 ``height`` must be multiples of two. 42 43 For compressed formats that contain the resolution information encoded 44 inside the stream, when fed to a stateful mem2mem decoder, the fields 45 may be zero to rely on the decoder to detect the right values. For more 46 details see :ref:`decoder` and format descriptions. 47 48 For compressed formats on the CAPTURE side of a stateful mem2mem 49 encoder, the fields must be zero, since the coded size is expected to 50 be calculated internally by the encoder itself, based on the OUTPUT 51 side. For more details see :ref:`encoder` and format descriptions. 52 * - __u32 53 - ``pixelformat`` 54 - The pixel format or type of compression, set by the application. 55 This is a little endian 56 :ref:`four character code <v4l2-fourcc>`. V4L2 defines standard 57 RGB formats in :ref:`pixfmt-rgb`, YUV formats in 58 :ref:`yuv-formats`, and reserved codes in 59 :ref:`reserved-formats` 60 * - __u32 61 - ``field`` 62 - Field order, from enum :c:type:`v4l2_field`. 63 Video images are typically interlaced. Applications can request to 64 capture or output only the top or bottom field, or both fields 65 interlaced or sequentially stored in one buffer or alternating in 66 separate buffers. Drivers return the actual field order selected. 67 For more details on fields see :ref:`field-order`. 68 * - __u32 69 - ``bytesperline`` 70 - Distance in bytes between the leftmost pixels in two adjacent 71 lines. 72 * - :cspan:`2` 73 74 Both applications and drivers can set this field to request 75 padding bytes at the end of each line. Drivers however may ignore 76 the value requested by the application, returning ``width`` times 77 bytes per pixel or a larger value required by the hardware. That 78 implies applications can just set this field to zero to get a 79 reasonable default. 80 81 Video hardware may access padding bytes, therefore they must 82 reside in accessible memory. Consider cases where padding bytes 83 after the last line of an image cross a system page boundary. 84 Input devices may write padding bytes, the value is undefined. 85 Output devices ignore the contents of padding bytes. 86 87 When the image format is planar the ``bytesperline`` value applies 88 to the first plane and is divided by the same factor as the 89 ``width`` field for the other planes. For example the Cb and Cr 90 planes of a YUV 4:2:0 image have half as many padding bytes 91 following each line as the Y plane. To avoid ambiguities drivers 92 must return a ``bytesperline`` value rounded up to a multiple of 93 the scale factor. 94 95 For compressed formats the ``bytesperline`` value makes no sense. 96 Applications and drivers must set this to 0 in that case. 97 * - __u32 98 - ``sizeimage`` 99 - Size in bytes of the buffer to hold a complete image, set by the 100 driver. Usually this is ``bytesperline`` times ``height``. When 101 the image consists of variable length compressed data this is the 102 number of bytes required by the codec to support the worst-case 103 compression scenario. 104 105 The driver will set the value for uncompressed images. 106 107 Clients are allowed to set the sizeimage field for variable length 108 compressed data flagged with ``V4L2_FMT_FLAG_COMPRESSED`` at 109 :ref:`VIDIOC_ENUM_FMT`, but the driver may ignore it and set the 110 value itself, or it may modify the provided value based on 111 alignment requirements or minimum/maximum size requirements. 112 If the client wants to leave this to the driver, then it should 113 set sizeimage to 0. 114 * - __u32 115 - ``colorspace`` 116 - Image colorspace, from enum :c:type:`v4l2_colorspace`. 117 This information supplements the ``pixelformat`` and must be set 118 by the driver for capture streams and by the application for 119 output streams, see :ref:`colorspaces`. 120 * - __u32 121 - ``priv`` 122 - This field indicates whether the remaining fields of the 123 struct :c:type:`v4l2_pix_format`, also called the 124 extended fields, are valid. When set to 125 ``V4L2_PIX_FMT_PRIV_MAGIC``, it indicates that the extended fields 126 have been correctly initialized. When set to any other value it 127 indicates that the extended fields contain undefined values. 128 129 Applications that wish to use the pixel format extended fields 130 must first ensure that the feature is supported by querying the 131 device for the :ref:`V4L2_CAP_EXT_PIX_FORMAT <querycap>` 132 capability. If the capability isn't set the pixel format extended 133 fields are not supported and using the extended fields will lead 134 to undefined results. 135 136 To use the extended fields, applications must set the ``priv`` 137 field to ``V4L2_PIX_FMT_PRIV_MAGIC``, initialize all the extended 138 fields and zero the unused bytes of the 139 struct :c:type:`v4l2_format` ``raw_data`` field. 140 141 When the ``priv`` field isn't set to ``V4L2_PIX_FMT_PRIV_MAGIC`` 142 drivers must act as if all the extended fields were set to zero. 143 On return drivers must set the ``priv`` field to 144 ``V4L2_PIX_FMT_PRIV_MAGIC`` and all the extended fields to 145 applicable values. 146 * - __u32 147 - ``flags`` 148 - Flags set by the application or driver, see :ref:`format-flags`. 149 * - union { 150 - (anonymous) 151 * - __u32 152 - ``ycbcr_enc`` 153 - Y'CbCr encoding, from enum :c:type:`v4l2_ycbcr_encoding`. 154 This information supplements the ``colorspace`` and must be set by 155 the driver for capture streams and by the application for output 156 streams, see :ref:`colorspaces`. 157 * - __u32 158 - ``hsv_enc`` 159 - HSV encoding, from enum :c:type:`v4l2_hsv_encoding`. 160 This information supplements the ``colorspace`` and must be set by 161 the driver for capture streams and by the application for output 162 streams, see :ref:`colorspaces`. 163 * - } 164 - 165 * - __u32 166 - ``quantization`` 167 - Quantization range, from enum :c:type:`v4l2_quantization`. 168 This information supplements the ``colorspace`` and must be set by 169 the driver for capture streams and by the application for output 170 streams, see :ref:`colorspaces`. 171 * - __u32 172 - ``xfer_func`` 173 - Transfer function, from enum :c:type:`v4l2_xfer_func`. 174 This information supplements the ``colorspace`` and must be set by 175 the driver for capture streams and by the application for output 176 streams, see :ref:`colorspaces`. 177