Skip to content

Commit 0d6d22f

Browse files
Hans Verkuilgregkh
authored andcommitted
media: videodev2.h: RGB BT2020 and HSV are always full range
[ Upstream commit b305dfe ] 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>
1 parent 7edf069 commit 0d6d22f

3 files changed

Lines changed: 14 additions & 17 deletions

File tree

Documentation/userspace-api/media/v4l/colorspaces-defs.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ whole range, 0-255, dividing the angular value by 1.41. The enum
3636
:c:type:`v4l2_hsv_encoding` specifies which encoding is used.
3737

3838
.. note:: The default R'G'B' quantization is full range for all
39-
colorspaces except for BT.2020 which uses limited range R'G'B'
40-
quantization.
39+
colorspaces. HSV formats are always full range.
4140

4241
.. tabularcolumns:: |p{6.7cm}|p{10.8cm}|
4342

@@ -169,8 +168,8 @@ whole range, 0-255, dividing the angular value by 1.41. The enum
169168
- Details
170169
* - ``V4L2_QUANTIZATION_DEFAULT``
171170
- Use the default quantization encoding as defined by the
172-
colorspace. This is always full range for R'G'B' (except for the
173-
BT.2020 colorspace) and HSV. It is usually limited range for Y'CbCr.
171+
colorspace. This is always full range for R'G'B' and HSV.
172+
It is usually limited range for Y'CbCr.
174173
* - ``V4L2_QUANTIZATION_FULL_RANGE``
175174
- Use the full range quantization encoding. I.e. the range [0…1] is
176175
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
180179
* - ``V4L2_QUANTIZATION_LIM_RANGE``
181180
- Use the limited range quantization encoding. I.e. the range [0…1]
182181
is mapped to [16…235]. Cb and Cr are mapped from [-0.5…0.5] to
183-
[16…240].
182+
[16…240]. Limited Range cannot be used with HSV.

Documentation/userspace-api/media/v4l/colorspaces-details.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,8 @@ Colorspace BT.2020 (V4L2_COLORSPACE_BT2020)
377377
The :ref:`itu2020` standard defines the colorspace used by Ultra-high
378378
definition television (UHDTV). The default transfer function is
379379
``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
380-
``V4L2_YCBCR_ENC_BT2020``. The default R'G'B' quantization is limited
381-
range (!), and so is the default Y'CbCr quantization. The chromaticities
382-
of the primary colors and the white reference are:
380+
``V4L2_YCBCR_ENC_BT2020``. The default Y'CbCr quantization is limited range.
381+
The chromaticities of the primary colors and the white reference are:
383382

384383

385384

include/uapi/linux/videodev2.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,9 @@ enum v4l2_hsv_encoding {
373373

374374
enum v4l2_quantization {
375375
/*
376-
* The default for R'G'B' quantization is always full range, except
377-
* for the BT2020 colorspace. For Y'CbCr the quantization is always
378-
* limited range, except for COLORSPACE_JPEG: this is full range.
376+
* The default for R'G'B' quantization is always full range.
377+
* For Y'CbCr the quantization is always limited range, except
378+
* for COLORSPACE_JPEG: this is full range.
379379
*/
380380
V4L2_QUANTIZATION_DEFAULT = 0,
381381
V4L2_QUANTIZATION_FULL_RANGE = 1,
@@ -384,14 +384,13 @@ enum v4l2_quantization {
384384

385385
/*
386386
* Determine how QUANTIZATION_DEFAULT should map to a proper quantization.
387-
* This depends on whether the image is RGB or not, the colorspace and the
388-
* Y'CbCr encoding.
387+
* This depends on whether the image is RGB or not, the colorspace.
388+
* The Y'CbCr encoding is not used anymore, but is still there for backwards
389+
* compatibility.
389390
*/
390391
#define V4L2_MAP_QUANTIZATION_DEFAULT(is_rgb_or_hsv, colsp, ycbcr_enc) \
391-
(((is_rgb_or_hsv) && (colsp) == V4L2_COLORSPACE_BT2020) ? \
392-
V4L2_QUANTIZATION_LIM_RANGE : \
393-
(((is_rgb_or_hsv) || (colsp) == V4L2_COLORSPACE_JPEG) ? \
394-
V4L2_QUANTIZATION_FULL_RANGE : V4L2_QUANTIZATION_LIM_RANGE))
392+
(((is_rgb_or_hsv) || (colsp) == V4L2_COLORSPACE_JPEG) ? \
393+
V4L2_QUANTIZATION_FULL_RANGE : V4L2_QUANTIZATION_LIM_RANGE)
395394

396395
/*
397396
* Deprecated names for opRGB colorspace (IEC 61966-2-5)

0 commit comments

Comments
 (0)