Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp881232pxb; Tue, 3 Nov 2020 15:23:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJyLW27YZ42zVU1HbHJgS0K9ZE6CPPr1ZcvYE81d8sJmPaH8Rbwf0S5T5BUaNoOYoNw6O8r8 X-Received: by 2002:a17:906:af8c:: with SMTP id mj12mr21637899ejb.85.1604445818125; Tue, 03 Nov 2020 15:23:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604445818; cv=none; d=google.com; s=arc-20160816; b=v0cNuYvHmLHAgDrRr25azTIniOQ3zyZntHBkc8PzU6IgIDL9OKLPdfqltfi2msflQR Zn8ut4vNreG0Oz8f8gGeORkYWdW6CFw3u8frpWoneR5s/WIXmR8M/4MoJ3F7zzBcyiwN OlvvoFEBEc5Dux3LJJUNfO1VlqYOUav1EehLetn/KUGVlCIdnDzEay6y4XCvg48LRwwO mUX1j1wqR8nJ953S+VwQv+cIhmzGrOhGw4Bm9VsS/TUl+sjFE8PfiBeNecvLWz0PCYGg I7cvP6c9DFoUqFHOAPyYpWOL++hag7koG8PdO10H21fYwCoLtuZYnm2ww5UJrICjjPDL 11qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=L9o93Zr3/kYYsuDubxOFAQOf6+Ab1GxosSZyV2XVG9E=; b=kgnK17Bvwze/yksF9iLmE8Gomkf3OUkQMI6ycAF6fwxQcp4Qs+ZRM04z01YIDGtJdq XvHDOouQfMXwBnFe/hogm0j/+vmXeCi50AcxmLww5+QVcPDs9PulXtCOeO09sjIg+w9o i6eESY/AgDpRsjSvUiKPsv0Te9Vkh09WCacLY03myrLuMciyngxScAScgyPAorURyYpW OKr/X4e+mSWqvmRSxWxrk4yVcYHz4gv7ucDfNStGbn5/qSr1uLY1/evwykdNt4baNA8o BLWVh1a2AblIKQtCq6E3Hra45vMR16zGXz+PIugMjen/kvdKTasR7Q0yCLNaNED2PUqm Vyrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bqDJqjOC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mm25si232099ejb.610.2020.11.03.15.23.11; Tue, 03 Nov 2020 15:23:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bqDJqjOC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730050AbgKCVDs (ORCPT + 99 others); Tue, 3 Nov 2020 16:03:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:41388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387854AbgKCVDm (ORCPT ); Tue, 3 Nov 2020 16:03:42 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AFE0320658; Tue, 3 Nov 2020 21:03:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437421; bh=JydxxHQrARDjHnVnBxCCMV35v8F7GdQ26nfLSXRDVQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bqDJqjOCx7Vt/JinyZVBCWo7WkRQFbF7dy0nVPBqBC0bt/ectpmKcN5y01MX1419h UMpddwwpljIkR1mhNVSlioI0pBPuMM8Zdy2jNRwW2wJNwApCmmnONB17KO93ZBEPsg 7OowWu6TW0KtbkBhPYawfK5raxQqjzpTA3puI/KE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.19 069/191] media: videodev2.h: RGB BT2020 and HSV are always full range Date: Tue, 3 Nov 2020 21:36:01 +0100 Message-Id: <20201103203240.925609600@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203232.656475008@linuxfoundation.org> References: <20201103203232.656475008@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans Verkuil [ 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 Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- .../media/uapi/v4l/colorspaces-defs.rst | 9 ++++----- .../media/uapi/v4l/colorspaces-details.rst | 5 ++--- include/uapi/linux/videodev2.h | 17 ++++++++--------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Documentation/media/uapi/v4l/colorspaces-defs.rst b/Documentation/media/uapi/v4l/colorspaces-defs.rst index f24615544792b..16e46bec80934 100644 --- a/Documentation/media/uapi/v4l/colorspaces-defs.rst +++ b/Documentation/media/uapi/v4l/colorspaces-defs.rst @@ -29,8 +29,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.0cm}|p{11.5cm}| @@ -162,8 +161,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 @@ -173,4 +172,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. diff --git a/Documentation/media/uapi/v4l/colorspaces-details.rst b/Documentation/media/uapi/v4l/colorspaces-details.rst index 09fabf4cd4126..ca7176cae8dd8 100644 --- a/Documentation/media/uapi/v4l/colorspaces-details.rst +++ b/Documentation/media/uapi/v4l/colorspaces-details.rst @@ -370,9 +370,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: diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 1aae2e4b8f102..b73f4423bc09d 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -362,9 +362,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, @@ -373,14 +373,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) -- 2.27.0