From: Paul Kocialkowski <contact-W9ppeneeCTY@public.gmane.org>
To: Ezequiel Garcia
<ezequiel-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>,
linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
Nicolas Dufresne
<nicolas.dufresne-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>,
Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>,
Tomasz Figa <tfiga-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Hans Verkuil
<hans.verkuil-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>,
Miouyouyou <myy-tmjzNUIc0P1+EYZtW95mkQ@public.gmane.org>,
kernel-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org,
Shunqian Zheng <zhengsq-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Subject: Re: [PATCH v5 5/6] media: Add controls for JPEG quantization tables
Date: Thu, 13 Sep 2018 21:40:45 +0200 [thread overview]
Message-ID: <d31f23e13d5e9da56148c89f07a1c4a3eca87957.camel@paulk.fr> (raw)
In-Reply-To: <e7126e89d8984eb93216ec75c83ce1fc5afc437d.camel-W9ppeneeCTY@public.gmane.org>
Hi,
On Thu, 2018-09-13 at 14:14 +0200, Paul Kocialkowski wrote:
> Hi,
>
> On Wed, 2018-09-05 at 19:00 -0300, Ezequiel Garcia wrote:
> > From: Shunqian Zheng <zhengsq-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
> >
> > Add V4L2_CID_JPEG_QUANTIZATION compound control to allow userspace
> > configure the JPEG quantization tables.
> >
> > Signed-off-by: Shunqian Zheng <zhengsq-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
> > Signed-off-by: Ezequiel Garcia <ezequiel-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
> > ---
> > .../media/uapi/v4l/extended-controls.rst | 31 +++++++++++++++++++
> > .../media/videodev2.h.rst.exceptions | 1 +
> > drivers/media/v4l2-core/v4l2-ctrls.c | 10 ++++++
> > include/uapi/linux/v4l2-controls.h | 12 +++++++
> > include/uapi/linux/videodev2.h | 1 +
> > 5 files changed, 55 insertions(+)
> >
> > diff --git a/Documentation/media/uapi/v4l/extended-controls.rst b/Documentation/media/uapi/v4l/extended-controls.rst
> > index 9f7312bf3365..1335d27d30f3 100644
> > --- a/Documentation/media/uapi/v4l/extended-controls.rst
> > +++ b/Documentation/media/uapi/v4l/extended-controls.rst
> > @@ -3354,7 +3354,38 @@ JPEG Control IDs
> > Specify which JPEG markers are included in compressed stream. This
> > control is valid only for encoders.
> >
> > +.. _jpeg-quant-tables-control:
>
> I just had a look at how the Allwinner VPU handles JPEG decoding and it
> seems to require the following information (in addition to
> quantization):
>
> * Horizontal and vertical sampling factors for each Y/U/V component:
>
> The number of components and sampling factors are coded separately in
> the bitstream, but it's probably easier to use the already-existing
> V4L2_CID_JPEG_CHROMA_SUBSAMPLING control for specifying that.
>
> However, this is potentially very much related to the destination
> format. If we decide that this format should match the format resulting
> from decompression, we don't need to specify it through an external
> control. On the other hand, it's possible that the VPU has format
> conversion block integrated in its pipeline so it would also make sense
> to consider the destination format as independent.
>
> * Custom Huffman tables (DC and AC), both for luma and chroma
>
> It seems that there is a default table when no Huffman table is provided
> in the bitstream (I'm not too sure how standard that is, just started
> learning about JPEG). We probably need a specific control for that.
>
> * Reset interval
>
> That's extracted from the bitstream as well and there's a
> V4L2_CID_JPEG_RESTART_INTERVAL control already.
>
> In addition to these points, I see that among all the JPEG profiles,
> some have to do with arithmetic coding which will probably require a
> specific control on its own (not sure how it should look at this point
> though).
>
> What do you think?
For clarification: these are required for decoding, not for encoding.
For encoding, it seems that the Allwinner hardware only requires
quantization tables.
Cheers,
Paul
> > +``V4L2_CID_JPEG_QUANTIZATION (struct)``
> > + Specifies the luma and chroma quantization matrices for encoding
> > + or decoding a V4L2_PIX_FMT_JPEG_RAW format buffer. The :ref:`itu-t81`
> > + specification allows 8-bit quantization coefficients for
> > + baseline profile images, and 8-bit or 16-bit for extended profile
> > + images. Supporting or not 16-bit precision coefficients is driver-specific.
> > + Coefficients must be set in JPEG zigzag scan order.
> > +
> > +
> > +.. c:type:: struct v4l2_ctrl_jpeg_quantization
> > +
> > +.. cssclass:: longtable
> > +
> > +.. flat-table:: struct v4l2_ctrl_jpeg_quantization
> > + :header-rows: 0
> > + :stub-columns: 0
> > + :widths: 1 1 2
> > +
> > + * - __u8
> > + - ``precision``
> > + - Specifies the coefficient precision. User shall set 0
> > + for 8-bit, and 1 for 16-bit.
> > +
> > + * - __u16
> > + - ``luma_quantization_matrix[64]``
> > + - Sets the luma quantization table.
> > +
> > + * - __u16
> > + - ``chroma_quantization_matrix[64]``
> > + - Sets the chroma quantization table.
> >
> > .. flat-table::
> > :header-rows: 0
> > diff --git a/Documentation/media/videodev2.h.rst.exceptions b/Documentation/media/videodev2.h.rst.exceptions
> > index ca9f0edc579e..a0a38e92bf38 100644
> > --- a/Documentation/media/videodev2.h.rst.exceptions
> > +++ b/Documentation/media/videodev2.h.rst.exceptions
> > @@ -129,6 +129,7 @@ replace symbol V4L2_CTRL_TYPE_STRING :c:type:`v4l2_ctrl_type`
> > replace symbol V4L2_CTRL_TYPE_U16 :c:type:`v4l2_ctrl_type`
> > replace symbol V4L2_CTRL_TYPE_U32 :c:type:`v4l2_ctrl_type`
> > replace symbol V4L2_CTRL_TYPE_U8 :c:type:`v4l2_ctrl_type`
> > +replace symbol V4L2_CTRL_TYPE_JPEG_QUANTIZATION :c:type:`v4l2_ctrl_type`
> >
> > # V4L2 capability defines
> > replace define V4L2_CAP_VIDEO_CAPTURE device-capabilities
> > diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
> > index 599c1cbff3b9..305bd7a9b7f1 100644
> > --- a/drivers/media/v4l2-core/v4l2-ctrls.c
> > +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
> > @@ -999,6 +999,7 @@ const char *v4l2_ctrl_get_name(u32 id)
> > case V4L2_CID_JPEG_RESTART_INTERVAL: return "Restart Interval";
> > case V4L2_CID_JPEG_COMPRESSION_QUALITY: return "Compression Quality";
> > case V4L2_CID_JPEG_ACTIVE_MARKER: return "Active Markers";
> > + case V4L2_CID_JPEG_QUANTIZATION: return "JPEG Quantization Tables";
> >
> > /* Image source controls */
> > /* Keep the order of the 'case's the same as in v4l2-controls.h! */
> > @@ -1286,6 +1287,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
> > case V4L2_CID_DETECT_MD_REGION_GRID:
> > *type = V4L2_CTRL_TYPE_U8;
> > break;
> > + case V4L2_CID_JPEG_QUANTIZATION:
> > + *type = V4L2_CTRL_TYPE_JPEG_QUANTIZATION;
> > + break;
> > case V4L2_CID_DETECT_MD_THRESHOLD_GRID:
> > *type = V4L2_CTRL_TYPE_U16;
> > break;
> > @@ -1612,6 +1616,9 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx,
> > return -ERANGE;
> > return 0;
> >
> > + case V4L2_CTRL_TYPE_JPEG_QUANTIZATION:
> > + return 0;
> > +
> > default:
> > return -EINVAL;
> > }
> > @@ -2133,6 +2140,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
> > case V4L2_CTRL_TYPE_U32:
> > elem_size = sizeof(u32);
> > break;
> > + case V4L2_CTRL_TYPE_JPEG_QUANTIZATION:
> > + elem_size = sizeof(struct v4l2_ctrl_jpeg_quantization);
> > + break;
> > default:
> > if (type < V4L2_CTRL_COMPOUND_TYPES)
> > elem_size = sizeof(s32);
> > diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
> > index e4ee10ee917d..856b3325052f 100644
> > --- a/include/uapi/linux/v4l2-controls.h
> > +++ b/include/uapi/linux/v4l2-controls.h
> > @@ -987,6 +987,18 @@ enum v4l2_jpeg_chroma_subsampling {
> > #define V4L2_JPEG_ACTIVE_MARKER_DQT (1 << 17)
> > #define V4L2_JPEG_ACTIVE_MARKER_DHT (1 << 18)
> >
> > +#define V4L2_CID_JPEG_QUANTIZATION (V4L2_CID_JPEG_CLASS_BASE + 5)
> > +struct v4l2_ctrl_jpeg_quantization {
> > + /* ITU-T.81 specifies two quantization coefficient precisions:
> > + * 8-bit for baseline profile,
> > + * 8-bit or 16-bit for extended profile.
> > + *
> > + * User shall set "precision" to 0 for 8-bit and 1 for 16-bit.
> > + */
> > + __u8 precision;
> > + __u16 luma_quantization_matrix[64];
> > + __u16 chroma_quantization_matrix[64];
> > +};
> >
> > /* Image source controls */
> > #define V4L2_CID_IMAGE_SOURCE_CLASS_BASE (V4L2_CTRL_CLASS_IMAGE_SOURCE | 0x900)
> > diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
> > index f9f3ae5b489e..8ace47cb1003 100644
> > --- a/include/uapi/linux/videodev2.h
> > +++ b/include/uapi/linux/videodev2.h
> > @@ -1637,6 +1637,7 @@ enum v4l2_ctrl_type {
> > V4L2_CTRL_TYPE_U8 = 0x0100,
> > V4L2_CTRL_TYPE_U16 = 0x0101,
> > V4L2_CTRL_TYPE_U32 = 0x0102,
> > + V4L2_CTRL_TYPE_JPEG_QUANTIZATION = 0x0103,
> > };
> >
> > /* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
--
Developer of free digital technology and hardware support.
Website: https://www.paulk.fr/
Coding blog: https://code.paulk.fr/
Git repositories: https://git.paulk.fr/ https://git.code.paulk.fr/
next prev parent reply other threads:[~2018-09-13 19:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-05 22:00 [PATCH v5 0/6] Add Rockchip VPU JPEG encoder Ezequiel Garcia
[not found] ` <20180905220011.16612-1-ezequiel-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2018-09-05 22:00 ` [PATCH v5 1/6] dt-bindings: Document the Rockchip VPU bindings Ezequiel Garcia
2018-09-05 22:00 ` [PATCH v5 2/6] ARM: dts: rockchip: add VPU device node for RK3288 Ezequiel Garcia
2018-09-05 22:00 ` [PATCH v5 3/6] arm64: dts: rockchip: add VPU device node for RK3399 Ezequiel Garcia
2018-09-05 22:00 ` [PATCH v5 4/6] media: Add JPEG_RAW format Ezequiel Garcia
2018-09-05 22:00 ` [PATCH v5 5/6] media: Add controls for JPEG quantization tables Ezequiel Garcia
[not found] ` <20180905220011.16612-6-ezequiel-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2018-09-10 12:42 ` Hans Verkuil
[not found] ` <718d8a73-008a-a610-d090-91cc54a992ad-qWit8jRvyhVmR6Xm/wNWPw@public.gmane.org>
2018-09-10 13:25 ` Ezequiel Garcia
[not found] ` <710d4e77de63b46e6ffd440c9c98ca9af133117f.camel-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2018-09-15 16:48 ` Paul Kocialkowski
[not found] ` <928a021c1e402f99eadd20e00aa5ec0cc218edbd.camel-W9ppeneeCTY@public.gmane.org>
2018-09-19 4:21 ` Tomasz Figa
2018-09-13 12:14 ` Paul Kocialkowski
[not found] ` <e7126e89d8984eb93216ec75c83ce1fc5afc437d.camel-W9ppeneeCTY@public.gmane.org>
2018-09-13 19:40 ` Paul Kocialkowski [this message]
2018-09-19 4:28 ` Tomasz Figa
[not found] ` <CAAFQd5Bir0uMsaJPHdgQDvcYHpxZ4sUSn10OPpRXcnn-THUx2A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-10-12 20:00 ` Paul Kocialkowski
[not found] ` <2878c8fa36f6e775079f53ba79518a53e1ea6bc5.camel-W9ppeneeCTY@public.gmane.org>
2018-10-15 16:07 ` Ezequiel Garcia
2018-09-05 22:00 ` [PATCH v5 6/6] media: add Rockchip VPU JPEG encoder driver Ezequiel Garcia
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=d31f23e13d5e9da56148c89f07a1c4a3eca87957.camel@paulk.fr \
--to=contact-w9ppeneecty@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ezequiel-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org \
--cc=hans.verkuil-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org \
--cc=heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org \
--cc=kernel-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org \
--cc=linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=myy-tmjzNUIc0P1+EYZtW95mkQ@public.gmane.org \
--cc=nicolas.dufresne-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=tfiga-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
--cc=zhengsq-TNX95d0MmH7DzftRWevZcw@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).