All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: John Cox <jsc66@cam.ac.uk>, linux-media@vger.kernel.org
Subject: Re: [RFC] media: v4l2: Variable length controls (for h265 slice headers)
Date: Fri, 9 Apr 2021 12:52:17 +0200	[thread overview]
Message-ID: <8ff86418-5fa3-e1ae-51e4-b10788be7991@xs4all.nl> (raw)
In-Reply-To: <o8sj5g9fq0jkganestl771ld2dqrp2fqu7@4ax.com>

Hi John,

On 23/03/2021 15:12, John Cox wrote:
> Hi all
> 
> I am developing a H265 V4L2 stateless decoder. After some
> experimentation it looks like the best way to achieve performance would
> be to submit bitstream data for an entire frame in a single buffer with
> an array of slice headers that point into it. The number of slices in a
> frame can be very variable, often there will be just one, in nearly all
> cases there will be less than 16 but the worst case could be hundreds
> (actually theoretically it could be thousands but I'm prepared to, and
> it is probably sensible to, reject any stream that looks like this).
> 
> Given the large range of possible array sizes a (large) fixed length
> array is very wasteful and probably slow in nearly all cases. As it
> stands V4L2 has no variable length structure so there is a problem here.
> My experience with v4l2 controls in minimal so trying to add a variable
> length array control myself seems brave.  Luckily (in other channels) I
> was told "Hans offered multiple times to implement variable array
> controls himself, he just needs someone to send an RFC with details on
> what's needed." so here I am.
> 
> So as a suggestion for the interface:
> 
> From the user point of view:
> 
> Only the last dimension of the array can be dynamic (like a C array "int
> a[10][15][];")  Otherwise we add a lot of complexity.

I would limit this to single dimensional arrays for now.

I think it is the first (not the last) dimension that can be dynamic: if
you want 8 3x3 matrices, then you would set dims to [8][3][3]. So a variable
length array of 3x3 matrices would have the first dimension as the variable
one.

> 
> VIDIOC_S_EXT_CTRLS
> In v4l2_ext_control the user can pass in any size that is a multiple of
> the element size.  If greater than the max then .size is set to the max
> by the ioctl on return.
> 
> VIDIOC_G_EXT_CTRLS
> On entry .size contains the buffer size to receive the values and on
> return it contains the size actually wanted - if the buffer can contain
> the data then it is also the number filled in.
> 
> VIDIOC_QUERY_EXT_CTRLS
> Add a flag to indicate variable length and either use .maximum/.minimum
> or some of the currently reserved structure to give max/min sizes

dims[0] can set the maximum size of the array.

> 
> From the driver point of view - frankly anything will do as long as I
> can find out how many headers I have. I think it is probably a good idea
> to dynamically allocate the storage for such an array rather than having
> a fixed size block on the end of the ctrl structure to avoid unnecessary
> overallocation.

The hevc slice structures are quite large, so it definitely has to be a
dynamic allocation.

> 
> I imagine that I've missed many important details in the sketch above,
> but probably good to start the discussion and Hans, am I trying to take
> you up on an offer you didn't actually make?

So the uAPI part is fairly simple, the biggest problem is in the internal
implementation. As the control framework becomes ever more complex (esp.
with the requests support) it is getting harder and harder to add new features.

I think that this might be a good time to start refactoring code, but for
that I also need to add better testing in v4l2-compliance of esp. requests.

It will also make it more time consuming, but I don't feel comfortable
to continue hacking on the code without doing a cleanup first.

Regards,

	Hans

  reply	other threads:[~2021-04-09 10:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-23 14:12 [RFC] media: v4l2: Variable length controls (for h265 slice headers) John Cox
2021-04-09 10:52 ` Hans Verkuil [this message]
2021-04-09 12:07   ` John Cox

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=8ff86418-5fa3-e1ae-51e4-b10788be7991@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=jsc66@cam.ac.uk \
    --cc=linux-media@vger.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.