Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp905241pxx; Tue, 27 Oct 2020 03:36:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+7vIS3/f5I1Ucwa+fF/bwiEWRxcdwf1zLn0VLcd/7kG92rV+smvCe3vV26nVyd7l1uwS/ X-Received: by 2002:a17:906:f8d2:: with SMTP id lh18mr1752776ejb.457.1603794980831; Tue, 27 Oct 2020 03:36:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603794980; cv=none; d=google.com; s=arc-20160816; b=lWMqMNYsDQQ3FFO5lcwI/aArNWsTa92Dd21odBPGYQnMU3yr4EkGgHutYoOCWMvvRB cUzX2xiRpxpabM7oVJCgmncrCGoXMPHQiBNSejbd8VqsOAQOy+02/oRjKO8xVnvBhFWm tT4XS01JN3vdc5ja5l119Bk+nXsFn2VH6E1mdCmjEpm699bKFMbuhL512JwrlKRvpgUX Y01r03v+pgURyRSp+bjrZiMTe3wPL28g0QDSqAefAVzBB4PsoMnpJvL6jJ7LnCKahxK5 55+CH528v/KlK2q8egs6CglMXcgZ2uAdnKxdTqnDK5sKm94k5x661HviV7ALEihTqCxv dIBw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Qp3EySMXCO/t8VSVIvCf5tYznzcP5ojMFjfSjONMzrI=; b=E+Y5EPewEddUov2mXDwkiXH0qtZXAX2+pI1sGSaS/QnPSfcJI3y2hTBcAC6JwZVlrx bpzKen0ZOP9iAeKDMKZrUDLX1x/fN4kVH+z4p4KTLw77QiFE/mcURomJjTsXeDSE+VSs GvVzgV6VdWWo1Jk5PPFEPevO5XSietB1XoxalTRLPa+oCyJ8Z/J9jpxgRl4HXhU5eUDh oWVKeLnwN7+NVxztamgENr1YwYm3fFrU0nuZUkpyq5JHm5wxOVAhzh8i8BvlgkWwRR4B 0d0JeeAnuIjpTJbEBs/fJ1oYzINGe+K6l6GWR0hQQpY7Dl2c7c6v12jDBeRA+Emh0dzv LwNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nyRPW1JG; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 96si570998edq.498.2020.10.27.03.35.58; Tue, 27 Oct 2020 03:36:20 -0700 (PDT) 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=nyRPW1JG; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436943AbgJZX6L (ORCPT + 99 others); Mon, 26 Oct 2020 19:58:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:34602 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2410956AbgJZXzr (ORCPT ); Mon, 26 Oct 2020 19:55:47 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0139121655; Mon, 26 Oct 2020 23:55:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756542; bh=12+N3Sl8anEqlF04IUgnWUIyuoEjcEJ7JjgNNWWKPJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nyRPW1JGbcBM7xtXUMzs46mQBvVhAB/dQRLokASpD8uOPOCrnpvR5N44uOpT0MxzX r8clV80Z1ZDRdL9V9G89EEjWgMwNTWr/Kn14sW/Oqrjbsin4VBNRLdwdQx98fpOqMW AhBnjcIuOH4LPBG5s1L3jHbB7ofp/2WquSItDFuQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin , linux-doc@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 21/80] media: videodev2.h: RGB BT2020 and HSV are always full range Date: Mon, 26 Oct 2020 19:54:17 -0400 Message-Id: <20201026235516.1025100-21-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026235516.1025100-1-sashal@kernel.org> References: <20201026235516.1025100-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 e122bbe3d799d..aabb08130354a 100644 --- a/Documentation/media/uapi/v4l/colorspaces-defs.rst +++ b/Documentation/media/uapi/v4l/colorspaces-defs.rst @@ -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. diff --git a/Documentation/media/uapi/v4l/colorspaces-details.rst b/Documentation/media/uapi/v4l/colorspaces-details.rst index 8b0ba3668101d..fd0cf57691d87 100644 --- a/Documentation/media/uapi/v4l/colorspaces-details.rst +++ b/Documentation/media/uapi/v4l/colorspaces-details.rst @@ -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: diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 530638dffd934..3210b3c82a4a2 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -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) -- 2.25.1