161 points · by mfilion · 6y ago · 49 comments
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).
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).
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.
[1]: https://wiki.pine64.org/index.php?title=PinePhone_v1.1_-_Bra...
Obviously OpenGL is a lot more complex than the syscall example I gave, but the principle is similar.
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...
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.
How do things like Nvidia Nvenc fit in?
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.