All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: Hans Verkuil <hverkuil@xs4all.nl>, linux-media@vger.kernel.org
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>, kernel@pengutronix.de
Subject: Re: [PATCH 5/7] media: coda: fix default JPEG colorimetry
Date: Thu, 21 Apr 2022 16:54:51 +0200	[thread overview]
Message-ID: <84356b059e572118136d93d294069ae976c22743.camel@pengutronix.de> (raw)
In-Reply-To: <0f5d9c16-860b-015f-8028-234d2fb96959@xs4all.nl>

On Do, 2022-04-21 at 12:02 +0200, Hans Verkuil wrote:
[...]
> > -	if (fmt->pixelformat == V4L2_PIX_FMT_JPEG)
> > -		colorspace = V4L2_COLORSPACE_JPEG;
> 
> It's perfectly fine to keep this, the problem occurs with the raw image side
> (capture for the decoder, output for the encoder).
> 
> There the colorspace must be SRGB, the xfer_func may be 0 or SRGB,

v4l2-compliance doesn't allow xfer_func 0:

		fail: v4l2-test-formats.cpp(835): fmt_jpeg.g_xfer_func() != V4L2_XFER_FUNC_SRGB
	test VIDIOC_S_FMT: FAIL

Is this too strict?

> and the
> ycbcr_enc is 0 (if not a YUV pixelformat) or ENC_601 (if it is a YUV format).

Why does it have to be ENC_601 for YUV formats? Both
V4L2_MAP_YCBCR_ENC_DEFAULT(V4L2_COLORSPACE_JPEG) and
V4L2_MAP_YCBCR_ENC_DEFAULT(V4L2_COLORSPACE_SRGB) map to
V4L2_YCBCR_ENC_601 regardless of the pixel format, so there should be
no difference if 0 was allowed as well.

On the other hand, quantization should be set to
V4L2_QUANTIZATION_FULL_RANGE for YUV formats on the raw image side, as
that defaults to LIM_RANGE for raw YUV images with SRGB colorspace.

Basically, I wonder whether or not it would be a good idea to apply the
following change to v4l2-compliance:

diff --git a/utils/v4l2-compliance/v4l2-test-formats.cpp b/utils/v4l2-compliance/v4l2-test-formats.cpp
index 269a3832fcdf..902c66367ff7 100644
--- a/utils/v4l2-compliance/v4l2-test-formats.cpp
+++ b/utils/v4l2-compliance/v4l2-test-formats.cpp
@@ -832,8 +832,10 @@ static int testJPEGColorspace(const cv4l_fmt &fmt_raw, const cv4l_fmt &fmt_jpeg,
        }
        /* V4L2_COLORSPACE_JPEG is shorthand for these values: */
        fail_on_test(fmt_jpeg.g_colorspace() != V4L2_COLORSPACE_SRGB);
-       fail_on_test(fmt_jpeg.g_xfer_func() != V4L2_XFER_FUNC_SRGB);
-       fail_on_test(fmt_jpeg.g_ycbcr_enc() != V4L2_YCBCR_ENC_601);
+       fail_on_test(fmt_jpeg.g_xfer_func() != V4L2_XFER_FUNC_DEFAULT &&
+                    fmt_jpeg.g_xfer_func() != V4L2_XFER_FUNC_SRGB);
+       fail_on_test(fmt_jpeg.g_ycbcr_enc() != V4L2_YCBCR_ENC_DEFAULT &&
+                    fmt_jpeg.g_ycbcr_enc() != V4L2_YCBCR_ENC_601);
        fail_on_test(fmt_jpeg.g_quantization() != V4L2_QUANTIZATION_FULL_RANGE);
        return 0;
 }

Actually, if the hardware can convert from other YUV encodings such as 709,
then other YUV encodings are valid, but I assume that's not the case.

True, the hardware is completely oblivious to colorimetry.

regards
Philipp

  parent reply	other threads:[~2022-04-21 14:55 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-04 16:35 [PATCH 1/7] media: coda: set output buffer bytesused to appease v4l2-compliance Philipp Zabel
2022-04-04 16:35 ` [PATCH 2/7] media: coda: disable encoder cmd ioctl on decoder and vice versa Philipp Zabel
2022-04-05 14:07   ` Nicolas Dufresne
2022-04-04 16:35 ` [PATCH 3/7] media: coda: disable encoder ioctls for decoder devices Philipp Zabel
2022-04-05 14:13   ` Nicolas Dufresne
2022-04-04 16:35 ` [PATCH 4/7] media: coda: disable stateful encoder ioctls for jpeg encoder Philipp Zabel
2022-04-05 14:14   ` Nicolas Dufresne
2022-04-04 16:35 ` [PATCH 5/7] media: coda: fix default JPEG colorimetry Philipp Zabel
2022-04-05 14:15   ` Nicolas Dufresne
2022-04-21 10:02   ` Hans Verkuil
2022-04-21 10:38     ` Philipp Zabel
2022-04-21 11:06       ` Hans Verkuil
2022-04-26  9:21         ` Philipp Zabel
2022-04-21 14:54     ` Philipp Zabel [this message]
2022-04-21 15:28       ` Philipp Zabel
2022-04-04 16:35 ` [PATCH 6/7] media: coda: enable capture G_PARM for stateful encoder Philipp Zabel
2022-04-05 14:19   ` Nicolas Dufresne
2022-04-21 10:30   ` Hans Verkuil
2022-04-21 14:58     ` Philipp Zabel
2022-04-25  5:34       ` Hans Verkuil
2022-04-04 16:35 ` [PATCH 7/7] media: coda: enable capture S_PARM " Philipp Zabel
2022-04-05 14:22   ` Nicolas Dufresne
2022-04-05 15:03     ` Philipp Zabel
2022-04-05 16:00       ` Nicolas Dufresne
2022-04-05 14:05 ` [PATCH 1/7] media: coda: set output buffer bytesused to appease v4l2-compliance Nicolas Dufresne
2022-04-21  9:44 ` Hans Verkuil
2022-04-21 10:24   ` Philipp Zabel
2022-04-26  5:52     ` Hans Verkuil
2022-04-26  9:32       ` Philipp Zabel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=84356b059e572118136d93d294069ae976c22743.camel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=hverkuil@xs4all.nl \
    --cc=kernel@pengutronix.de \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.