From: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
To: Jernej Skrabec <jernej.skrabec@siol.net>
Cc: devel@driverdev.osuosl.org, gregkh@linuxfoundation.org,
linux-kernel@vger.kernel.org, mripard@kernel.org,
hverkuil@xs4all.nl, wens@csie.org, mchehab@kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-media@vger.kernel.org
Subject: Re: [PATCH 1/2] media: cedrus: Fix decoding for some HEVC videos
Date: Wed, 18 Dec 2019 09:40:47 +0100 [thread overview]
Message-ID: <20191218084047.GA2900@aptenodytes> (raw)
In-Reply-To: <20191213161516.54688-2-jernej.skrabec@siol.net>
[-- Attachment #1.1: Type: text/plain, Size: 3870 bytes --]
Hi,
On Fri 13 Dec 19, 17:15, Jernej Skrabec wrote:
> It seems that for some HEVC videos at least one bitstream parsing
> trigger must be called in order to be decoded correctly. There is no
> explanation why this helps, but it was observed that several videos
> with this fix are now decoded correctly and there is no regression with
> others.
>
> Without this fix, those same videos totally crash HEVC decoder (other
> decoder engines are unaffected). After decoding those problematic
> videos, HEVC decoder always returns only green image (all zeros).
> Only complete HW reset helps.
>
> This fix is similar to that for H264.
Thanks for the fix, interesting that the same issue shows up on HEVC!
I suspect that Allwinner folks never really tested the engine without
using it for bitstream parsing.
Acked-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Cheers,
Paul
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
> ---
> .../staging/media/sunxi/cedrus/cedrus_h265.c | 25 ++++++++++++++++---
> .../staging/media/sunxi/cedrus/cedrus_regs.h | 1 +
> 2 files changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c
> index 109d3289418c..5a207f1e137c 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c
> @@ -7,6 +7,7 @@
> * Copyright (C) 2018 Bootlin
> */
>
> +#include <linux/delay.h>
> #include <linux/types.h>
>
> #include <media/videobuf2-dma-contig.h>
> @@ -283,6 +284,23 @@ static void cedrus_h265_write_scaling_list(struct cedrus_ctx *ctx,
> }
> }
>
> +static void cedrus_h265_skip_bits(struct cedrus_dev *dev, int num)
> +{
> + int count = 0;
> +
> + while (count < num) {
> + int tmp = min(num - count, 32);
> +
> + cedrus_write(dev, VE_DEC_H265_TRIGGER,
> + VE_DEC_H265_TRIGGER_FLUSH_BITS |
> + VE_DEC_H265_TRIGGER_TYPE_N_BITS(tmp));
> + while (cedrus_read(dev, VE_DEC_H265_STATUS) & VE_DEC_H265_STATUS_VLD_BUSY)
> + udelay(1);
> +
> + count += tmp;
> + }
> +}
> +
> static void cedrus_h265_setup(struct cedrus_ctx *ctx,
> struct cedrus_run *run)
> {
> @@ -347,10 +365,9 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
>
> /* Source offset and length in bits. */
>
> - reg = slice_params->data_bit_offset;
> - cedrus_write(dev, VE_DEC_H265_BITS_OFFSET, reg);
> + cedrus_write(dev, VE_DEC_H265_BITS_OFFSET, 0);
>
> - reg = slice_params->bit_size - slice_params->data_bit_offset;
> + reg = slice_params->bit_size;
> cedrus_write(dev, VE_DEC_H265_BITS_LEN, reg);
>
> /* Source beginning and end addresses. */
> @@ -385,6 +402,8 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,
> /* Initialize bitstream access. */
> cedrus_write(dev, VE_DEC_H265_TRIGGER, VE_DEC_H265_TRIGGER_INIT_SWDEC);
>
> + cedrus_h265_skip_bits(dev, slice_params->data_bit_offset);
> +
> /* Bitstream parameters. */
>
> reg = VE_DEC_H265_DEC_NAL_HDR_NAL_UNIT_TYPE(slice_params->nal_unit_type) |
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_regs.h b/drivers/staging/media/sunxi/cedrus/cedrus_regs.h
> index 0d9449fe2b28..df1cceef8d93 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus_regs.h
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_regs.h
> @@ -424,6 +424,7 @@
>
> #define VE_DEC_H265_TRIGGER (VE_ENGINE_DEC_H265 + 0x34)
>
> +#define VE_DEC_H265_TRIGGER_TYPE_N_BITS(x) (((x) & 0x3f) << 8)
> #define VE_DEC_H265_TRIGGER_STCD_VC1 (0x02 << 4)
> #define VE_DEC_H265_TRIGGER_STCD_AVS (0x01 << 4)
> #define VE_DEC_H265_TRIGGER_STCD_HEVC (0x00 << 4)
> --
> 2.24.0
>
--
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-12-18 8:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-13 16:15 [PATCH 0/2] media: cedrus: hevc: Minor fixes Jernej Skrabec
2019-12-13 16:15 ` [PATCH 1/2] media: cedrus: Fix decoding for some HEVC videos Jernej Skrabec
2019-12-18 8:40 ` Paul Kocialkowski [this message]
2019-12-18 16:40 ` Jernej Škrabec
2019-12-13 16:15 ` [PATCH 2/2] media: cedrus: hevc: Add luma bit depth Jernej Skrabec
2019-12-18 8:43 ` 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=20191218084047.GA2900@aptenodytes \
--to=paul.kocialkowski@bootlin.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=hverkuil@xs4all.nl \
--cc=jernej.skrabec@siol.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=mripard@kernel.org \
--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).