From: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Nicolas Dufresne <nicolas@ndufresne.ca>,
Jernej Skrabec <jernej.skrabec@siol.net>,
Tomasz Figa <tfiga@chromium.org>, Jonas Karlman <jonas@kwiboo.se>,
linux-sunxi@googlegroups.com, Maxime Ripard <mripard@kernel.org>,
linux-kernel@vger.kernel.org, Chen-Yu Tsai <wens@csie.org>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Ezequiel Garcia <ezequiel@collabora.com>,
linux-arm-kernel@lists.infradead.org,
linux-media@vger.kernel.org
Subject: Re: [PATCH v8 3/3] media: cedrus: Add HEVC/H.265 decoding support
Date: Tue, 22 Oct 2019 16:01:29 +0200 [thread overview]
Message-ID: <20191022140129.GA1926725@aptenodytes> (raw)
In-Reply-To: <62ddccd3-38c0-89c5-7f0c-35f24494c3f9@xs4all.nl>
[-- Attachment #1.1: Type: text/plain, Size: 3764 bytes --]
Hi,
On Tue 22 Oct 19, 15:37, Hans Verkuil wrote:
> On 10/22/19 3:17 PM, Paul Kocialkowski wrote:
> > Hi again,
> >
> > On Tue 22 Oct 19, 14:40, Paul Kocialkowski wrote:
> >> Hi Mauro and thanks for the review,
> >>
> >> On Thu 17 Oct 19, 09:57, Mauro Carvalho Chehab wrote:
> >>> Em Fri, 27 Sep 2019 16:34:11 +0200
> >>> Paul Kocialkowski <paul.kocialkowski@bootlin.com> escreveu:
> >>>
> >>>> This introduces support for HEVC/H.265 to the Cedrus VPU driver, with
> >>>> both uni-directional and bi-directional prediction modes supported.
> >>>>
> >>>> Field-coded (interlaced) pictures, custom quantization matrices and
> >>>> 10-bit output are not supported at this point.
> >>>>
> >>>> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> >>>> ---
> >>>
> >>> ...
> >>>
> >>>> + unsigned int ctb_size_luma =
> >>>> + 1 << log2_max_luma_coding_block_size;
> >>>
> >>> Shifts like this is a little scary. "1" constant is signed. So, if
> >>> log2_max_luma_coding_block_size is 31, the above logic has undefined
> >>> behavior. Different archs and C compilers may handle it on different
> >>> ways.
> >>
> >> I wasn't aware that it was the case, thanks for bringing this to light!
> >> I'll make it 1UL then.
> >>
> >>>> +#define VE_DEC_H265_LOW_ADDR_PRIMARY_CHROMA(a) \
> >>>> + (((a) << 24) & GENMASK(31, 24))
> >>>
> >>> Same applies here and on other similar macros. You need to enforce
> >>> (a) to be unsigned, as otherwise the behavior is undefined.
> >>>
> >>> Btw, this is a recurrent pattern on this file. I would define a
> >>> macro, e. g. something like:
> >>>
> >>> #define MASK_BITS_AND_SHIFT(v, high, low) \
> >>> ((UL(v) << low) & GENMASK(high, low))
> >>>
> >>> And use it for all similar patterns here.
> >>
> >> Sounds good! I find that the reverse wording (SHIFT_AND_MASK_BITS) would be
> >> a bit more explicit since the shift happens prior to the mask.
> >
> > Apparently the UL(v) macro just appends UL to v in preprocessor, so it won't
> > work with anything else than direct integers.
> >
> > I'll replace it with a (unsigned long) cast, that seems to do the job.
>
> Shouldn't that be a (u32) cast? Since this is used with 32 bit registers?
This would work for cedrus, but I think that what Mauro had in mind was to
migrate this macro to linux/bits.h, where everthing else (including GENMASK)
is apparently defined in terms of unsigned long and not types with explicit
numbers of bits. So I find it more consistent to go with unsigned long.
In our case, 64-bit platforms that use cedrus would calculate the macro on
64 bits and use it in 32-bit variables. Since we're never masking beyond the
lower 32 bits, I don't see how things could go wrong and the situation looks
fairly similar to the use of GENMASK in similar conditions.
Does that sound right to you or am I missing something here?
Cheers,
Paul
> Regards,
>
> Hans
>
> >
> > Cheers,
> >
> > Paul
> >
> >> Also we probably need to have parenthesis around "low", right?
> >>
> >>> The best would be to include such macro at linux/bits.h, although some
> >>> upstream discussion is required.
> >>>
> >>> So, for now, let's add it at this header file, but work upstream
> >>> to have it merged there.
> >>
> >> Understood, I'll include it in that header for now and send a separate patch
> >> for inclusion in linux/bits.h (apparently the preprocessor doesn't care about
> >> redefinitions so we can just remove the cedrus fashion once the common one is
> >> in).
> >>
> >> What do you think?
> >>
> >> Cheers,
> >>
> >> Paul
> >
> >
> >
>
--
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-10-22 14:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-27 14:34 [PATCH v8 0/3] HEVC/H.265 stateless support for V4L2 and Cedrus Paul Kocialkowski
2019-09-27 14:34 ` [PATCH v8 1/3] media: v4l: Add definitions for HEVC stateless decoding Paul Kocialkowski
2019-09-27 14:34 ` [PATCH v8 2/3] media: pixfmt: Document the HEVC slice pixel format Paul Kocialkowski
2019-09-27 14:34 ` [PATCH v8 3/3] media: cedrus: Add HEVC/H.265 decoding support Paul Kocialkowski
2019-10-17 12:57 ` Mauro Carvalho Chehab
2019-10-22 12:40 ` Paul Kocialkowski
2019-10-22 13:17 ` Paul Kocialkowski
2019-10-22 13:37 ` Hans Verkuil
2019-10-22 14:01 ` Paul Kocialkowski [this message]
2019-10-22 14:02 ` Hans Verkuil
2019-10-08 21:48 ` [PATCH v8 0/3] HEVC/H.265 stateless support for V4L2 and Cedrus Jernej Škrabec
2019-10-09 7:12 ` Paul Kocialkowski
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=20191022140129.GA1926725@aptenodytes \
--to=paul.kocialkowski@bootlin.com \
--cc=ezequiel@collabora.com \
--cc=hverkuil@xs4all.nl \
--cc=jernej.skrabec@siol.net \
--cc=jonas@kwiboo.se \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-sunxi@googlegroups.com \
--cc=mchehab@kernel.org \
--cc=mripard@kernel.org \
--cc=nicolas@ndufresne.ca \
--cc=tfiga@chromium.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=wens@csie.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).