]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
media: videodev2.h: RGB BT2020 and HSV are always full range
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Thu, 20 Aug 2020 10:47:16 +0000 (12:47 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Nov 2020 10:43:15 +0000 (11:43 +0100)
[ Upstream commit b305dfe2e93434b12d438434461b709641f62af4 ]

The default RGB quantization range for BT.2020 is full range (just as for
all the other RGB pixel encodings), not limited range.

Update the V4L2_MAP_QUANTIZATION_DEFAULT macro and documentation
accordingly.

Also mention that HSV is always full range and cannot be limited range.

When RGB BT2020 was introduced in V4L2 it was not clear whether it should
be limited or full range, but full range is the right (and consistent)
choice.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Documentation/media/uapi/v4l/colorspaces-defs.rst
Documentation/media/uapi/v4l/colorspaces-details.rst
include/uapi/linux/videodev2.h

index e122bbe3d799d36b5492542758a0a54ef6f3894a..aabb08130354a897b192b941fad44c0e372de294 100644 (file)
@@ -36,8 +36,7 @@ whole range, 0-255, dividing the angular value by 1.41. The enum
 :c:type:`v4l2_hsv_encoding` specifies which encoding is used.
 
 .. note:: The default R'G'B' quantization is full range for all
-   colorspaces except for BT.2020 which uses limited range R'G'B'
-   quantization.
+   colorspaces. HSV formats are always full range.
 
 .. tabularcolumns:: |p{6.7cm}|p{10.8cm}|
 
@@ -169,8 +168,8 @@ whole range, 0-255, dividing the angular value by 1.41. The enum
       - Details
     * - ``V4L2_QUANTIZATION_DEFAULT``
       - Use the default quantization encoding as defined by the
-       colorspace. This is always full range for R'G'B' (except for the
-       BT.2020 colorspace) and HSV. It is usually limited range for Y'CbCr.
+       colorspace. This is always full range for R'G'B' and HSV.
+       It is usually limited range for Y'CbCr.
     * - ``V4L2_QUANTIZATION_FULL_RANGE``
       - Use the full range quantization encoding. I.e. the range [0…1] is
        mapped to [0…255] (with possible clipping to [1…254] to avoid the
@@ -180,4 +179,4 @@ whole range, 0-255, dividing the angular value by 1.41. The enum
     * - ``V4L2_QUANTIZATION_LIM_RANGE``
       - Use the limited range quantization encoding. I.e. the range [0…1]
        is mapped to [16…235]. Cb and Cr are mapped from [-0.5…0.5] to
-       [16…240].
+       [16…240]. Limited Range cannot be used with HSV.
index 8b0ba3668101d6ac500641005a6150b5b06cef7c..fd0cf57691d8793e42dae11a1f35394abdf328b9 100644 (file)
@@ -377,9 +377,8 @@ Colorspace BT.2020 (V4L2_COLORSPACE_BT2020)
 The :ref:`itu2020` standard defines the colorspace used by Ultra-high
 definition television (UHDTV). The default transfer function is
 ``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
-``V4L2_YCBCR_ENC_BT2020``. The default R'G'B' quantization is limited
-range (!), and so is the default Y'CbCr quantization. The chromaticities
-of the primary colors and the white reference are:
+``V4L2_YCBCR_ENC_BT2020``. The default Y'CbCr quantization is limited range.
+The chromaticities of the primary colors and the white reference are:
 
 
 
index 530638dffd934128352cd39ef1fa3f1de0c6e444..3210b3c82a4a2637a562746d7f0f8709d90b298e 100644 (file)
@@ -371,9 +371,9 @@ enum v4l2_hsv_encoding {
 
 enum v4l2_quantization {
        /*
-        * The default for R'G'B' quantization is always full range, except
-        * for the BT2020 colorspace. For Y'CbCr the quantization is always
-        * limited range, except for COLORSPACE_JPEG: this is full range.
+        * The default for R'G'B' quantization is always full range.
+        * For Y'CbCr the quantization is always limited range, except
+        * for COLORSPACE_JPEG: this is full range.
         */
        V4L2_QUANTIZATION_DEFAULT     = 0,
        V4L2_QUANTIZATION_FULL_RANGE  = 1,
@@ -382,14 +382,13 @@ enum v4l2_quantization {
 
 /*
  * Determine how QUANTIZATION_DEFAULT should map to a proper quantization.
- * This depends on whether the image is RGB or not, the colorspace and the
- * Y'CbCr encoding.
+ * This depends on whether the image is RGB or not, the colorspace.
+ * The Y'CbCr encoding is not used anymore, but is still there for backwards
+ * compatibility.
  */
 #define V4L2_MAP_QUANTIZATION_DEFAULT(is_rgb_or_hsv, colsp, ycbcr_enc) \
-       (((is_rgb_or_hsv) && (colsp) == V4L2_COLORSPACE_BT2020) ? \
-        V4L2_QUANTIZATION_LIM_RANGE : \
-        (((is_rgb_or_hsv) || (colsp) == V4L2_COLORSPACE_JPEG) ? \
-        V4L2_QUANTIZATION_FULL_RANGE : V4L2_QUANTIZATION_LIM_RANGE))
+       (((is_rgb_or_hsv) || (colsp) == V4L2_COLORSPACE_JPEG) ? \
+        V4L2_QUANTIZATION_FULL_RANGE : V4L2_QUANTIZATION_LIM_RANGE)
 
 /*
  * Deprecated names for opRGB colorspace (IEC 61966-2-5)