Re: [PATCHv3 1/5] media: docs-rst: Document memory-to-memory video encoder interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 10, 2020 at 3:08 PM Nicolas Dufresne <nicolas@xxxxxxxxxxxx> wrote:
>
> Le mercredi 10 juin 2020 à 14:28 +0200, Tomasz Figa a écrit :
> > On Fri, Jun 5, 2020 at 11:24 PM Nicolas Dufresne <nicolas@xxxxxxxxxxxx> wrote:
> > > Le vendredi 05 juin 2020 à 10:19 +0300, Stanimir Varbanov a écrit :
> > > > On 5/26/20 1:09 PM, Hans Verkuil wrote:
> > > > > From: Tomasz Figa <tfiga@xxxxxxxxxxxx>
> > > > >
> > > > > Due to complexity of the video encoding process, the V4L2 drivers of
> > > > > stateful encoder hardware require specific sequences of V4L2 API calls
> > > > > to be followed. These include capability enumeration, initialization,
> > > > > encoding, encode parameters change, drain and reset.
> > > > >
> > > > > Specifics of the above have been discussed during Media Workshops at
> > > > > LinuxCon Europe 2012 in Barcelona and then later Embedded Linux
> > > > > Conference Europe 2014 in Düsseldorf. The de facto Codec API that
> > > > > originated at those events was later implemented by the drivers we already
> > > > > have merged in mainline, such as s5p-mfc or coda.
> > > > >
> > > > > The only thing missing was the real specification included as a part of
> > > > > Linux Media documentation. Fix it now and document the encoder part of
> > > > > the Codec API.
> > > > >
> > > > > Signed-off-by: Tomasz Figa <tfiga@xxxxxxxxxxxx>
> > > > > Signed-off-by: Hans Verkuil <hverkuil-cisco@xxxxxxxxx>
> > > > > ---
> > > > >  .../userspace-api/media/v4l/dev-encoder.rst   | 728 ++++++++++++++++++
> > > > >  .../userspace-api/media/v4l/dev-mem2mem.rst   |   1 +
> > > > >  .../userspace-api/media/v4l/pixfmt-v4l2.rst   |   5 +
> > > > >  .../userspace-api/media/v4l/v4l2.rst          |   2 +
> > > > >  .../media/v4l/vidioc-encoder-cmd.rst          |  51 +-
> > > > >  5 files changed, 767 insertions(+), 20 deletions(-)
> > > > >  create mode 100644 Documentation/userspace-api/media/v4l/dev-encoder.rst
> > > > >
> > > > > diff --git a/Documentation/userspace-api/media/v4l/dev-encoder.rst b/Documentation/userspace-api/media/v4l/dev-encoder.rst
> > > > > new file mode 100644
> > > > > index 000000000000..aace7b812a9c
> > > > > --- /dev/null
> > > > > +++ b/Documentation/userspace-api/media/v4l/dev-encoder.rst
> > > > > @@ -0,0 +1,728 @@
> > > > > +.. SPDX-License-Identifier: GPL-2.0
> > > > > +
> > > > > +.. _encoder:
> > > > > +
> > > > > +*************************************************
> > > > > +Memory-to-Memory Stateful Video Encoder Interface
> > > > > +*************************************************
> > > > > +
> > > > > +A stateful video encoder takes raw video frames in display order and encodes
> > > > > +them into a bytestream. It generates complete chunks of the bytestream, including
> > > > > +all metadata, headers, etc. The resulting bytestream does not require any
> > > > > +further post-processing by the client.
> > > > > +
> > > > > +Performing software stream processing, header generation etc. in the driver
> > > > > +in order to support this interface is strongly discouraged. In case such
> > > > > +operations are needed, use of the Stateless Video Encoder Interface (in
> > > > > +development) is strongly advised.
> > > > > +
> > > >
> > > > <cut>
> > > >
> > > > > +Encoding Parameter Changes
> > > > > +==========================
> > > > > +
> > > > > +The client is allowed to use :c:func:`VIDIOC_S_CTRL` to change encoder
> > > > > +parameters at any time. The availability of parameters is encoder-specific
> > > > > +and the client must query the encoder to find the set of available controls.
> > > > > +
> > > > > +The ability to change each parameter during encoding is encoder-specific, as
> > > > > +per the standard semantics of the V4L2 control interface. The client may
> > > > > +attempt to set a control during encoding and if the operation fails with the
> > > > > +-EBUSY error code, the ``CAPTURE`` queue needs to be stopped for the
> > > > > +configuration change to be allowed. To do this, it may follow the `Drain`
> > > > > +sequence to avoid losing the already queued/encoded frames.
> > > > > +
> > > > > +The timing of parameter updates is encoder-specific, as per the standard
> > > > > +semantics of the V4L2 control interface. If the client needs to apply the
> > > > > +parameters exactly at specific frame, using the Request API
> > > > > +(:ref:`media-request-api`) should be considered, if supported by the encoder.
> > > >
> > > > In request-api case does the control will return EBUSY immediately when
> > > > S_CTRL is called from the client? I'm asking in the context of the
> > > > controls which are not dynamic (cannot set during streaming and Reset
> > > > sequence is needed).
> > >
> > > This is all hypothetical, as nothing of that has been implemented. But
> > > I suppose there should be instant validation to allow that, even if
> > > that means more plumbing inside the kernel. It would be better then
> > > just running the request ignoring silently that control. Ideally
> > > userspace should not have to go into trial and errors, so controls that
> > > are means for the should be marked.
> > >
> >
> > There isn't much to be implemented here, as it's the same standard
> > V4L2 behavior as existed for a while. If a device supports changing
> > the control on the fly, a call to S_CTRL succeeds, if not, it fails
> > with -EBUSY. This is regardless of whether requests are used or not.
>
> Are you against introducing flags to signal generically when a control
> will have live effect, delayed effect or will simply be rejected (-
> EBUSY) if set while streaming ? I'm particularly concern for cases
> where the same control may work live for one driver, and not for
> another. It would be very disappointing to get an EBUSY on a bitrate
> control of an encoder as an example. So if someone foresee having
> bitrate control that cannot be adapted while streaming (or that will
> only be applied if a key frame is generated), I'd rather prefer to know
> in advance, and likely not select this encoder for WebRTC purpose as an
> example. Having to do all the steps to get the driver in streaming in
> order to set the control and discover that it's not suitable for the
> purpose seems quite sub-optimal.
>
> I'm just saying, but the "standard" that existed for a while has always
> been hardcoded to the control (through control documentation, and
> that's fine with me) or the HW driver being used (which isn't fine in
> my opinion).

I was just clarifying the behavior of S_(EXT_)CTRL(S).

A way to query the behavior in advance is an orthogonal problem, which
I agree that should be solved and I guess a flag returned by
VIDIOC_QUERY_EXT_CTRLS could do.

Best regards,
Tomasz




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux