linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Grzeschik <mgr@pengutronix.de>
To: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	"Hans Verkuil" <hverkuil@xs4all.nl>,
	"Sakari Ailus" <sakari.ailus@iki.fi>,
	"Nicolas Dufresne" <nicolas.dufresne@collabora.com>,
	"Andrzej Pietrasiewicz" <andrzej.p@collabora.com>,
	"Michael Tretter" <m.tretter@pengutronix.de>,
	"Jernej Škrabec" <jernej.skrabec@gmail.com>,
	"Chen-Yu Tsai" <wens@csie.org>,
	"Samuel Holland" <samuel@sholland.org>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>
Subject: Re: Stateless Encoding uAPI Discussion and Proposal
Date: Fri, 21 Jul 2023 20:19:51 +0200	[thread overview]
Message-ID: <20230721181951.GL12001@pengutronix.de> (raw)
In-Reply-To: <ZK2NiQd1KnraAr20@aptenodytes>

[-- Attachment #1: Type: text/plain, Size: 4293 bytes --]

Hi everyone!

Just to let you know. I have just pushed a Branch that includes some first
steps to make the h264-stateless encoder working in Gstreamer. The work is
based on the VP8 Stateless Encoder patches Benjamin Gaignard created.

https://gitlab.freedesktop.org/mgrzeschik/gstreamer/-/commits/1.22/topic/h264-stateless-encoder

The codec this is used with, is the rkvenc that can be found on rockchip
rk3568. I will send an RFC driver for that in the next weeks after my vacation.

On Tue, Jul 11, 2023 at 07:12:41PM +0200, Paul Kocialkowski wrote:
>After various discussions following Andrzej's talk at EOSS, feedback from the
>Media Summit (which I could not attend unfortunately) and various direct
>discussions, I have compiled some thoughts and ideas about stateless encoders
>support with various proposals. This is the result of a few years of interest
>in the topic, after working on a PoC for the Hantro H1 using the hantro driver,
>which turned out to have numerous design issues.
>
>I am now working on a H.264 encoder driver for Allwinner platforms (currently
>focusing on the V3/V3s), which already provides some usable bitstream and will
>be published soon.
>
>This is a very long email where I've tried to split things into distinct topics
>and explain a few concepts to make sure everyone is on the same page.
>
># Bitstream Headers
>
>Stateless encoders typically do not generate all the bitstream headers and
>sometimes no header at all (e.g. Allwinner encoder does not even produce slice
>headers). There's often some hardware block that makes bit-level writing to the
>destination buffer easier (deals with alignment, etc).
>
>The values of the bitstream headers must be in line with how the compressed
>data bitstream is generated and generally follow the codec specification.
>Some encoders might allow configuring all the fields found in the headers,
>others may only allow configuring a few or have specific constraints regarding
>which values are allowed.
>
>As a result, we cannot expect that any given encoder is able to produce frames
>for any set of headers. Reporting related constraints and limitations (beyond
>profile/level) seems quite difficult and error-prone.
>
>So it seems that keeping header generation in-kernel only (close to where the
>hardware is actually configured) is the safest approach.

For the case with the rkvenc, the headers are also not created by the
kernel driver. Instead we use the gst_h264_bit_writer_sps/pps functions
that are part of the codecparsers module.

># Codec Features
>
>Codecs have many variable features that can be enabled or not and specific
>configuration fields that can take various values. There is usually some
>top-level indication of profile/level that restricts what can be used.
>
>This is a very similar situation to stateful encoding, where codec-specific
>controls are used to report and set profile/level and configure these aspects.
>A particularly nice thing about it is that we can reuse these existing controls
>and add new ones in the future for features that are not yet covered.
>
>This approach feels more flexible than designing new structures with a selected
>set of parameters (that could match the existing controls) for each codec.

I back the Idea of generic profiles instead of explicit configuration
from the usersapace point of view.

The parameterization works like this:

Read the sane default parameter set from the driver.
Modify the parameters based on the userspace decisions.
 - (currently hardcoded and not based on any user input)
Write the updated parameters back to the driver.

># Reference and Reconstruction Management
<snip>

># Frame Types
<snip>

># Rate Control
<snip>

># Regions of Interest
<snip>

Since the first shot of the rkvenc is I-Frame only code, these other topics are
currently undefined and unimplemented in the Gstreamer stack.


Regards,
Michael

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2023-07-21 18:19 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-11 17:12 Stateless Encoding uAPI Discussion and Proposal Paul Kocialkowski
2023-07-11 18:18 ` Nicolas Dufresne
2023-07-12 14:07   ` Paul Kocialkowski
2023-07-25  3:33     ` Hsia-Jun Li
2023-07-25 12:15       ` Paul Kocialkowski
2023-07-26  2:49         ` Hsia-Jun Li
2023-07-26 19:53           ` Nicolas Dufresne
2023-07-27  2:45             ` Hsia-Jun Li
2023-07-27 17:10               ` Nicolas Dufresne
2023-07-26  8:18   ` Hans Verkuil
2023-08-09 14:43     ` Paul Kocialkowski
2023-08-09 17:24       ` Andrzej Pietrasiewicz
2023-07-21 18:19 ` Michael Grzeschik [this message]
2023-07-24 14:03   ` Nicolas Dufresne
2023-07-25  9:09     ` Paul Kocialkowski
2023-07-26 20:02       ` Nicolas Dufresne
2023-08-10 13:44 ` Paul Kocialkowski
2023-08-10 14:34   ` Nicolas Dufresne
2023-08-11 20:08     ` Paul Kocialkowski
2023-08-21 15:13       ` Nicolas Dufresne
2023-08-22  8:30         ` Hsia-Jun Li
2023-08-22 20:31           ` Nicolas Dufresne
2023-08-23  3:04             ` Hsia-Jun Li
2023-08-30 15:10               ` Nicolas Dufresne
2023-08-30 16:51                 ` Randy Li
2023-08-30 15:18               ` Nicolas Dufresne
2023-08-31  9:32                 ` Hsia-Jun Li
2023-08-23  8:05         ` Paul Kocialkowski
2023-11-15 13:19           ` 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=20230721181951.GL12001@pengutronix.de \
    --to=mgr@pengutronix.de \
    --cc=andrzej.p@collabora.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jernej.skrabec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=m.tretter@pengutronix.de \
    --cc=nicolas.dufresne@collabora.com \
    --cc=paul.kocialkowski@bootlin.com \
    --cc=sakari.ailus@iki.fi \
    --cc=samuel@sholland.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).