Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
0002 
0003 ****************************
0004 Defining Colorspaces in V4L2
0005 ****************************
0006 
0007 In V4L2 colorspaces are defined by four values. The first is the
0008 colorspace identifier (enum :c:type:`v4l2_colorspace`)
0009 which defines the chromaticities, the default transfer function, the
0010 default Y'CbCr encoding and the default quantization method. The second
0011 is the transfer function identifier (enum
0012 :c:type:`v4l2_xfer_func`) to specify non-standard
0013 transfer functions. The third is the Y'CbCr encoding identifier (enum
0014 :c:type:`v4l2_ycbcr_encoding`) to specify
0015 non-standard Y'CbCr encodings and the fourth is the quantization
0016 identifier (enum :c:type:`v4l2_quantization`) to
0017 specify non-standard quantization methods. Most of the time only the
0018 colorspace field of struct :c:type:`v4l2_pix_format`
0019 or struct :c:type:`v4l2_pix_format_mplane`
0020 needs to be filled in.
0021 
0022 .. _hsv-colorspace:
0023 
0024 On :ref:`HSV formats <hsv-formats>` the *Hue* is defined as the angle on
0025 the cylindrical color representation. Usually this angle is measured in
0026 degrees, i.e. 0-360. When we map this angle value into 8 bits, there are
0027 two basic ways to do it: Divide the angular value by 2 (0-179), or use the
0028 whole range, 0-255, dividing the angular value by 1.41. The enum
0029 :c:type:`v4l2_hsv_encoding` specifies which encoding is used.
0030 
0031 .. note:: The default R'G'B' quantization is full range for all
0032    colorspaces. HSV formats are always full range.
0033 
0034 .. tabularcolumns:: |p{6.7cm}|p{10.8cm}|
0035 
0036 .. c:type:: v4l2_colorspace
0037 
0038 .. flat-table:: V4L2 Colorspaces
0039     :header-rows:  1
0040     :stub-columns: 0
0041 
0042     * - Identifier
0043       - Details
0044     * - ``V4L2_COLORSPACE_DEFAULT``
0045       - The default colorspace. This can be used by applications to let
0046         the driver fill in the colorspace.
0047     * - ``V4L2_COLORSPACE_SMPTE170M``
0048       - See :ref:`col-smpte-170m`.
0049     * - ``V4L2_COLORSPACE_REC709``
0050       - See :ref:`col-rec709`.
0051     * - ``V4L2_COLORSPACE_SRGB``
0052       - See :ref:`col-srgb`.
0053     * - ``V4L2_COLORSPACE_OPRGB``
0054       - See :ref:`col-oprgb`.
0055     * - ``V4L2_COLORSPACE_BT2020``
0056       - See :ref:`col-bt2020`.
0057     * - ``V4L2_COLORSPACE_DCI_P3``
0058       - See :ref:`col-dcip3`.
0059     * - ``V4L2_COLORSPACE_SMPTE240M``
0060       - See :ref:`col-smpte-240m`.
0061     * - ``V4L2_COLORSPACE_470_SYSTEM_M``
0062       - See :ref:`col-sysm`.
0063     * - ``V4L2_COLORSPACE_470_SYSTEM_BG``
0064       - See :ref:`col-sysbg`.
0065     * - ``V4L2_COLORSPACE_JPEG``
0066       - See :ref:`col-jpeg`.
0067     * - ``V4L2_COLORSPACE_RAW``
0068       - The raw colorspace. This is used for raw image capture where the
0069         image is minimally processed and is using the internal colorspace
0070         of the device. The software that processes an image using this
0071         'colorspace' will have to know the internals of the capture
0072         device.
0073 
0074 
0075 
0076 .. c:type:: v4l2_xfer_func
0077 
0078 .. tabularcolumns:: |p{5.5cm}|p{12.0cm}|
0079 
0080 .. flat-table:: V4L2 Transfer Function
0081     :header-rows:  1
0082     :stub-columns: 0
0083 
0084     * - Identifier
0085       - Details
0086     * - ``V4L2_XFER_FUNC_DEFAULT``
0087       - Use the default transfer function as defined by the colorspace.
0088     * - ``V4L2_XFER_FUNC_709``
0089       - Use the Rec. 709 transfer function.
0090     * - ``V4L2_XFER_FUNC_SRGB``
0091       - Use the sRGB transfer function.
0092     * - ``V4L2_XFER_FUNC_OPRGB``
0093       - Use the opRGB transfer function.
0094     * - ``V4L2_XFER_FUNC_SMPTE240M``
0095       - Use the SMPTE 240M transfer function.
0096     * - ``V4L2_XFER_FUNC_NONE``
0097       - Do not use a transfer function (i.e. use linear RGB values).
0098     * - ``V4L2_XFER_FUNC_DCI_P3``
0099       - Use the DCI-P3 transfer function.
0100     * - ``V4L2_XFER_FUNC_SMPTE2084``
0101       - Use the SMPTE 2084 transfer function. See :ref:`xf-smpte-2084`.
0102 
0103 
0104 
0105 .. c:type:: v4l2_ycbcr_encoding
0106 
0107 .. tabularcolumns:: |p{7.2cm}|p{10.3cm}|
0108 
0109 .. flat-table:: V4L2 Y'CbCr Encodings
0110     :header-rows:  1
0111     :stub-columns: 0
0112 
0113     * - Identifier
0114       - Details
0115     * - ``V4L2_YCBCR_ENC_DEFAULT``
0116       - Use the default Y'CbCr encoding as defined by the colorspace.
0117     * - ``V4L2_YCBCR_ENC_601``
0118       - Use the BT.601 Y'CbCr encoding.
0119     * - ``V4L2_YCBCR_ENC_709``
0120       - Use the Rec. 709 Y'CbCr encoding.
0121     * - ``V4L2_YCBCR_ENC_XV601``
0122       - Use the extended gamut xvYCC BT.601 encoding.
0123     * - ``V4L2_YCBCR_ENC_XV709``
0124       - Use the extended gamut xvYCC Rec. 709 encoding.
0125     * - ``V4L2_YCBCR_ENC_BT2020``
0126       - Use the default non-constant luminance BT.2020 Y'CbCr encoding.
0127     * - ``V4L2_YCBCR_ENC_BT2020_CONST_LUM``
0128       - Use the constant luminance BT.2020 Yc'CbcCrc encoding.
0129     * - ``V4L2_YCBCR_ENC_SMPTE_240M``
0130       - Use the SMPTE 240M Y'CbCr encoding.
0131 
0132 
0133 
0134 .. c:type:: v4l2_hsv_encoding
0135 
0136 .. tabularcolumns:: |p{6.5cm}|p{11.0cm}|
0137 
0138 .. flat-table:: V4L2 HSV Encodings
0139     :header-rows:  1
0140     :stub-columns: 0
0141 
0142     * - Identifier
0143       - Details
0144     * - ``V4L2_HSV_ENC_180``
0145       - For the Hue, each LSB is two degrees.
0146     * - ``V4L2_HSV_ENC_256``
0147       - For the Hue, the 360 degrees are mapped into 8 bits, i.e. each
0148         LSB is roughly 1.41 degrees.
0149 
0150 
0151 
0152 .. c:type:: v4l2_quantization
0153 
0154 .. tabularcolumns:: |p{6.5cm}|p{11.0cm}|
0155 
0156 .. flat-table:: V4L2 Quantization Methods
0157     :header-rows:  1
0158     :stub-columns: 0
0159 
0160     * - Identifier
0161       - Details
0162     * - ``V4L2_QUANTIZATION_DEFAULT``
0163       - Use the default quantization encoding as defined by the
0164         colorspace. This is always full range for R'G'B' and HSV.
0165         It is usually limited range for Y'CbCr.
0166     * - ``V4L2_QUANTIZATION_FULL_RANGE``
0167       - Use the full range quantization encoding. I.e. the range [0…1] is
0168         mapped to [0…255] (with possible clipping to [1…254] to avoid the
0169         0x00 and 0xff values). Cb and Cr are mapped from [-0.5…0.5] to
0170         [0…255] (with possible clipping to [1…254] to avoid the 0x00 and
0171         0xff values).
0172     * - ``V4L2_QUANTIZATION_LIM_RANGE``
0173       - Use the limited range quantization encoding. I.e. the range [0…1]
0174         is mapped to [16…235]. Cb and Cr are mapped from [-0.5…0.5] to
0175         [16…240]. Limited Range cannot be used with HSV.