aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2017-02-10 04:18:36 -0500
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-02-13 11:33:56 -0500
commit35879ee4769099905fa3bda0b21e73d434e2df6a (patch)
tree7f6040964025552c31bc3ab8b84761d3522aef46
parentf9f96fc10c09ca16e336854c08bc1563eed97985 (diff)
[media] videodev2.h: go back to limited range Y'CbCr for SRGB and, ADOBERGB
This reverts 'commit 7e0739cd9c40 ("[media] videodev2.h: fix sYCC/AdobeYCC default quantization range"). The problem is that many drivers can convert R'G'B' content (often from sensors) to Y'CbCr, but they all produce limited range Y'CbCr. To stay backwards compatible the default quantization range for sRGB and AdobeRGB Y'CbCr encoding should be limited range, not full range, even though the corresponding standards specify full range. Update the V4L2_MAP_QUANTIZATION_DEFAULT define accordingly and also update the documentation. Fixes: 7e0739cd9c40 ("[media] videodev2.h: fix sYCC/AdobeYCC default quantization range") Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Cc: <stable@vger.kernel.org> # for v4.9 and up Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-007.rst23
-rw-r--r--include/uapi/linux/videodev2.h7
2 files changed, 20 insertions, 10 deletions
diff --git a/Documentation/media/uapi/v4l/pixfmt-007.rst b/Documentation/media/uapi/v4l/pixfmt-007.rst
index 44bb5a7059b3..95a23a28c595 100644
--- a/Documentation/media/uapi/v4l/pixfmt-007.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-007.rst
@@ -211,7 +211,13 @@ Colorspace sRGB (V4L2_COLORSPACE_SRGB)
211The :ref:`srgb` standard defines the colorspace used by most webcams 211The :ref:`srgb` standard defines the colorspace used by most webcams
212and computer graphics. The default transfer function is 212and computer graphics. The default transfer function is
213``V4L2_XFER_FUNC_SRGB``. The default Y'CbCr encoding is 213``V4L2_XFER_FUNC_SRGB``. The default Y'CbCr encoding is
214``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is full range. 214``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited range.
215
216Note that the :ref:`sycc` standard specifies full range quantization,
217however all current capture hardware supported by the kernel convert
218R'G'B' to limited range Y'CbCr. So choosing full range as the default
219would break how applications interpret the quantization range.
220
215The chromaticities of the primary colors and the white reference are: 221The chromaticities of the primary colors and the white reference are:
216 222
217 223
@@ -276,7 +282,7 @@ the following ``V4L2_YCBCR_ENC_601`` encoding as defined by :ref:`sycc`:
276 282
277Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range 283Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
278[-0.5…0.5]. This transform is identical to one defined in SMPTE 284[-0.5…0.5]. This transform is identical to one defined in SMPTE
279170M/BT.601. The Y'CbCr quantization is full range. 285170M/BT.601. The Y'CbCr quantization is limited range.
280 286
281 287
282.. _col-adobergb: 288.. _col-adobergb:
@@ -288,10 +294,15 @@ The :ref:`adobergb` standard defines the colorspace used by computer
288graphics that use the AdobeRGB colorspace. This is also known as the 294graphics that use the AdobeRGB colorspace. This is also known as the
289:ref:`oprgb` standard. The default transfer function is 295:ref:`oprgb` standard. The default transfer function is
290``V4L2_XFER_FUNC_ADOBERGB``. The default Y'CbCr encoding is 296``V4L2_XFER_FUNC_ADOBERGB``. The default Y'CbCr encoding is
291``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is full 297``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited
292range. The chromaticities of the primary colors and the white reference 298range.
293are: 299
300Note that the :ref:`oprgb` standard specifies full range quantization,
301however all current capture hardware supported by the kernel convert
302R'G'B' to limited range Y'CbCr. So choosing full range as the default
303would break how applications interpret the quantization range.
294 304
305The chromaticities of the primary colors and the white reference are:
295 306
296 307
297.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}| 308.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
@@ -344,7 +355,7 @@ the following ``V4L2_YCBCR_ENC_601`` encoding:
344 355
345Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range 356Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
346[-0.5…0.5]. This transform is identical to one defined in SMPTE 357[-0.5…0.5]. This transform is identical to one defined in SMPTE
347170M/BT.601. The Y'CbCr quantization is full range. 358170M/BT.601. The Y'CbCr quantization is limited range.
348 359
349 360
350.. _col-bt2020: 361.. _col-bt2020:
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 46e8a2e369f9..45184a2ef66c 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -362,8 +362,8 @@ enum v4l2_quantization {
362 /* 362 /*
363 * The default for R'G'B' quantization is always full range, except 363 * The default for R'G'B' quantization is always full range, except
364 * for the BT2020 colorspace. For Y'CbCr the quantization is always 364 * for the BT2020 colorspace. For Y'CbCr the quantization is always
365 * limited range, except for COLORSPACE_JPEG, SRGB, ADOBERGB, 365 * limited range, except for COLORSPACE_JPEG, XV601 or XV709: those
366 * XV601 or XV709: those are full range. 366 * are full range.
367 */ 367 */
368 V4L2_QUANTIZATION_DEFAULT = 0, 368 V4L2_QUANTIZATION_DEFAULT = 0,
369 V4L2_QUANTIZATION_FULL_RANGE = 1, 369 V4L2_QUANTIZATION_FULL_RANGE = 1,
@@ -379,8 +379,7 @@ enum v4l2_quantization {
379 (((is_rgb_or_hsv) && (colsp) == V4L2_COLORSPACE_BT2020) ? \ 379 (((is_rgb_or_hsv) && (colsp) == V4L2_COLORSPACE_BT2020) ? \
380 V4L2_QUANTIZATION_LIM_RANGE : \ 380 V4L2_QUANTIZATION_LIM_RANGE : \
381 (((is_rgb_or_hsv) || (ycbcr_enc) == V4L2_YCBCR_ENC_XV601 || \ 381 (((is_rgb_or_hsv) || (ycbcr_enc) == V4L2_YCBCR_ENC_XV601 || \
382 (ycbcr_enc) == V4L2_YCBCR_ENC_XV709 || (colsp) == V4L2_COLORSPACE_JPEG) || \ 382 (ycbcr_enc) == V4L2_YCBCR_ENC_XV709 || (colsp) == V4L2_COLORSPACE_JPEG) ? \
383 (colsp) == V4L2_COLORSPACE_ADOBERGB || (colsp) == V4L2_COLORSPACE_SRGB ? \
384 V4L2_QUANTIZATION_FULL_RANGE : V4L2_QUANTIZATION_LIM_RANGE)) 383 V4L2_QUANTIZATION_FULL_RANGE : V4L2_QUANTIZATION_LIM_RANGE))
385 384
386enum v4l2_priority { 385enum v4l2_priority {