From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
To: "Jernej Škrabec" <jernej.skrabec@gmail.com>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Hans Verkuil" <hverkuil@kernel.org>
Cc: Maxime Ripard <mripard@kernel.org>,
Paul Kocialkowski <paulk@sys-base.io>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Chen-Yu Tsai <wens@kernel.org>,
Samuel Holland <samuel@sholland.org>,
linux-media@vger.kernel.org, linux-staging@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 04/10] staging: media: cedrus: mpeg2: use the field height for field pictures
Date: Tue, 03 Nov 2026 13:51:47 -0500 [thread overview]
Message-ID: <5520799bbd58327a2fd3926e989735e02af64602.camel@collabora.com> (raw)
In-Reply-To: <vCPa4waZQ6-kwYC7OOX3Kg@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3995 bytes --]
Le mardi 03 novembre 2026 à 19:12 +0100, Jernej Škrabec a écrit :
> Dne ponedeljek, 2. november 2026 ob 19:56:52 Srednjeevropski standardni čas je Nicolas Dufresne napisal(a):
> > Le lundi 02 novembre 2026 à 18:02 +0100, Jernej Skrabec a écrit :
> > > A field picture covers only half of the macroblock rows of a frame, but
> > > the driver programs the coded and the boundary size of the whole frame
> > > for it, as for a frame picture.
> > >
> > > Program the height of a field for field pictures, like the vendor
> > > library does.
> > >
> > > Fixes: 50e761516f2b ("media: platform: Add Cedrus VPU decoder driver")
> > > Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
> > > ---
> > > drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c | 13 +++++++++++--
> > > 1 file changed, 11 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c
> > > index 10e98f08aafc..ca66a3c6b830 100644
> > > --- a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c
> > > +++ b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c
> > > @@ -58,6 +58,7 @@ static int cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run)
> > > struct vb2_queue *vq;
> > > const u8 *matrix;
> > > unsigned int i;
> > > + bool field;
> > > u32 reg;
> > >
> > > seq = run->mpeg2.sequence;
> > > @@ -108,13 +109,21 @@ static int cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run)
> > >
> > > /* Set frame dimensions. */
> > >
> > > + /*
> > > + * Field pictures cover half of the frame's macroblock rows; the
> > > + * vendor library halves both the coded and the boundary height.
> > > + */
> > > + field = pic->picture_structure != V4L2_MPEG2_PIC_FRAME;
> > > +
> > > reg = VE_DEC_MPEG_PICCODEDSIZE_WIDTH(seq->horizontal_size);
> > > - reg |= VE_DEC_MPEG_PICCODEDSIZE_HEIGHT(seq->vertical_size);
> > > + reg |= VE_DEC_MPEG_PICCODEDSIZE_HEIGHT(field ?
> > > + ALIGN(seq->vertical_size, 32) / 2 : seq->vertical_size);
> > >
> > > cedrus_write(dev, VE_DEC_MPEG_PICCODEDSIZE, reg);
> > >
> > > reg = VE_DEC_MPEG_PICBOUNDSIZE_WIDTH(ctx->src_fmt.width);
> > > - reg |= VE_DEC_MPEG_PICBOUNDSIZE_HEIGHT(ctx->src_fmt.height);
> > > + reg |= VE_DEC_MPEG_PICBOUNDSIZE_HEIGHT(field ? ctx->src_fmt.height / 2 :
> > > + ctx->src_fmt.height);
> >
> > I'm not entirely sure, but I see:
> >
> > fsize->stepwise.step_height = 1;
>
> Where? I don't see this in Cedrus.
In the framesize enumeration, it returns a contiguous dimension set, with a step
of 1, which then requires no special treatment. Other drivers uses:
struct v4l2_frmsize_stepwise frmsize
in a static per PIX_FMT configuration and helpers in try_fmt. Perhaps worth
reminding the following:
https://docs.kernel.org/userspace-api/media/v4l/dev-stateless-decoder.html#initialization
width, height
*coded* width and height parsed from the stream.
Since the dimension is coded, its quite unlikely Cedrus is correct. Most decoder
don't have postprocessor or croper, this is why stateless is like this. The
display dimension would be something set through S_SELECTION if this was needed
to crop (e.g. Hantro could support that, but currently don't, and the PP needs
16 pixels alignment both directions).
>
> >
> > But I don't think interlaced video can have odd height in the first place. But
> > it also have an implication here as you are not rounding up to a multiple of 2.
> > Not sure what is the proper fix, but I have this impression something is
> > missing.
>
> Odd height shouldn't exist in practice, but I'll use
> DIV_ROUND_UP(ctx->src_fmt.height, 2) in v2 if you agree.
I guess it makes it "safe", but perhaps feed the todo?
>
> Best regards,
> Jernej
>
> >
> > Nicolas
> >
> > >
> > > cedrus_write(dev, VE_DEC_MPEG_PICBOUNDSIZE, reg);
> > >
> >
>
>
>
>
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-11-03 18:52 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 17:02 [PATCH 00/10] staging: media: cedrus: assorted fixes and VP8 4K support Jernej Skrabec
2026-11-02 17:02 ` [PATCH 01/10] staging: media: cedrus: free MV-col buffers in buf_cleanup Jernej Skrabec
2026-11-02 18:37 ` Nicolas Dufresne
2026-11-02 17:02 ` [PATCH 02/10] staging: media: cedrus: reject too large H.264/HEVC SPS Jernej Skrabec
2026-11-02 18:44 ` Nicolas Dufresne
2026-11-03 18:02 ` Jernej Škrabec
2026-11-03 18:38 ` Nicolas Dufresne
2026-11-02 17:02 ` [PATCH 03/10] staging: media: cedrus: h264: mark long-term references in the frame info Jernej Skrabec
2026-11-02 18:50 ` Nicolas Dufresne
2026-11-03 18:06 ` Jernej Škrabec
2026-11-03 18:39 ` Nicolas Dufresne
2026-11-02 17:02 ` [PATCH 04/10] staging: media: cedrus: mpeg2: use the field height for field pictures Jernej Skrabec
2026-11-02 18:56 ` Nicolas Dufresne
2026-11-03 18:12 ` Jernej Škrabec
2026-11-03 18:51 ` Nicolas Dufresne [this message]
2026-11-02 17:02 ` [PATCH 05/10] staging: media: cedrus: mpeg2: derive the field order of " Jernej Skrabec
2026-11-02 19:00 ` Nicolas Dufresne
2026-11-02 17:02 ` [PATCH 06/10] staging: media: cedrus: mpeg2: fix the references " Jernej Skrabec
2026-11-02 19:03 ` Nicolas Dufresne
2026-11-02 17:03 ` [PATCH 07/10] staging: media: cedrus: validate VP8 frame size Jernej Skrabec
2026-11-02 19:04 ` Nicolas Dufresne
2026-11-02 17:03 ` [PATCH 08/10] staging: media: cedrus: vp8: use the vendor probability table size Jernej Skrabec
2026-11-02 19:11 ` Nicolas Dufresne
2026-11-02 17:03 ` [PATCH 09/10] staging: media: cedrus: h616: use the 256-bit DDR mode Jernej Skrabec
2026-11-02 19:13 ` Nicolas Dufresne
2026-11-02 17:03 ` [PATCH 10/10] staging: media: cedrus: vp8: support frames wider than 2048 pixels Jernej Skrabec
2026-11-02 19:15 ` Nicolas Dufresne
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=5520799bbd58327a2fd3926e989735e02af64602.camel@collabora.com \
--to=nicolas.dufresne@collabora.com \
--cc=gregkh@linuxfoundation.org \
--cc=hverkuil@kernel.org \
--cc=jernej.skrabec@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=linux-sunxi@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=mripard@kernel.org \
--cc=paulk@sys-base.io \
--cc=samuel@sholland.org \
--cc=wens@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox