Linux's Stateless H.264 Decode Interface Ready to Be Deemed Stable
phoronix.com
phoronix.com
If kernel developers writing drivers for hardware video acceleration were to build to a standard set of kernel interfaces, then userspace would just have one interface to work with, simplifying things and reducing overall effort.
Furthermore stateless H.264 decoders are a specific subset of hardware decoders that, like the name implies, don't maintain any state by themselves.
The V4L2 layer keeps a bit of the state (more like caching, to avoid re-uploading too much information for each jobs). The userspace is responsible for bitstream parsing and DPB management (including re-ordering).
Say 4-8kiB per frame on input leads to 4MiB frame on output.
Not having to decompress the reference frame for every decoded frame seems like a win.
From an information theory perspective, you absolutely must have some way to pass intermediate frames around, otherwise you are just talking about some variant of an intraframe technique and all of the video efficiency losses that would go along with that (i.e. encoding each video frame as JPEG).
Exception to FMO and ASO mode, which is rarely supported in HW, even FFMPEG sw decoder didn't bother implementing that
[1]: https://wiki.pine64.org/index.php?title=PinePhone_v1.1_-_Bra...
I used kmssink for testing:
gst-play-1.0 --use-playbin3 a.mkv --videosink="queue ! kmssink connector-id=52 palne-id=42 plane-properties=s,zpos=2"
(I had to patch the kernel too, because kmssink has trouble selecting a correct plane/connector. But if you'll not use kmssink, you should be fine.)If you want to use it from within some compositor, you'll need to select some other video sink. You'll probably have less trouble if you use some wayland compositor that supports HW planes properly.
I don't know many players that use gstreamer (is totem still alive?), so hard to tell what GUI to use.
Obviously OpenGL is a lot more complex than the syscall example I gave, but the principle is similar.
Of course it is. The kernel knows absolutely nothing about the hardware shaders' instruction set or machine code format. The userspace libraries have an entire compiler in them. The kernel just forwards the output of this compiler to the hardware.
The root-level comment is basically asking why the kernel needs to know anything at all about H.264, rather than just shuffling bytes back and forth between a hardware accelerator and a userspace library (which has a gigantic complex H.264 protocol encoder/decoder in it).
I pointed out that in the 3D acceleration world, the kernel doesn't know anything at all about shader ISAs, and just shuffles bytes back and forth between a hardware 3D accelerator and a userspace library (which has a gigantic complex compiler in it).
I still don't feel the question has been addressed. H.264 is hideously complicated, like shader ISAs. Why don't we move all that hideous complexity out of the kernel for H.264 the way we have for shader ISAs?
Even though most ancient CODEC and it's existing content decodes fine on CPU, the HW decoder uses less power and is better for battery life. This work enables mostly lower power SoC like Allwinner, Rockchip, i.MX8M, RPi4 (HEVC), Mediatek, Microchip, and so on, but also higher capacity chips that can be connted through PCIe to surpass your CPU capacity (Blaize).
Also, understand that difference between the V4L2 and the GPU accelerators. GPU uses command stream channel, which need to be centrally managed. That landed into DRM + Mesa, under the VA-API. DRM drivers could have been an option, but would have required per-HW userspace in Mesa. VA-API also being a miss-fit for some of the sillicon (Hantro based) would have made things more complex then needed.
Certainly. Very happy to see this work progressing. Hope I can video call on my pinebook pro without it burning a whole in my laptop one day haha.
How do things like Nvidia Nvenc fit in?
Explanation in meme format below
--------------------------------
Scientists: Alien life found!
You: Life found? I am life. I've been life for 30 years. This is not a big deal.
Relevant reading: https://www.kernel.org/doc/html/latest/userspace-api/media/v...