Expand description
Hardware H.264 through a generic stateful V4L2 M2M encoder: boards whose encoder sits behind the kernel’s own interface rather than a vendor library or a render node, such as a Raspberry Pi 4, RK356x, or i.MX8M. Built everywhere, since the interface is the kernel’s. Hardware H.264 through a generic stateful V4L2 M2M encoder.
Boards that carry an encoder behind the kernel’s own M2M interface publish no render node the
VA-API backend can probe and no vendor library the NVENC one can load, so the ladder reaches
software on hardware that encodes. A Raspberry Pi 4 is the case at hand (bcm2835-codec), and
RK356x and i.MX8M carry the same interface, so the node is discovered by what it offers rather
than by the board it sits on.
One host frame becomes one access unit: the frame is copied into the output buffer, queued, and
the access unit comes back on the capture queue. The copy is the floor here as it is on Tegra —
X11 capture hands over host memory — and it costs 3.81 ms for a 1080p frame on a Pi 4, which is
the same speed as a copy between two ordinary allocations: the videobuf2-dma-contig buffer
takes a write stream at full memory bandwidth.
Three things about such a device were measured rather than assumed, and each shapes the code:
- The output queue takes packed 32-bit color and the firmware converts it, so nothing converts
on the CPU. The fourcc names are the opposite way round from the memory a caller holds:
AB24takes the BGRA an X11 capture produces, andBGR4takes RGBA. Decoding an encoded chart is what settled that; reading the names would have swapped red and blue. - The conversion is BT.601 at full range, and it cannot be steered: a
S_FMTasking for REC709 at limited range comes back echoed and changes nothing. The stream also carries novideo_signal_type, so what the session declares has to be written into the SPS on the way out, whichcollectis the place for. - Constant bitrate is not available, and asking for it does not merely fail: the driver hands
the firmware a rate control mode it refuses, and the next
STREAMONanswersESRCH. A control this session cannot set is therefore a refusal, never a warning — the node has to be closed and reopened to be usable again.
Structs§
Functions§
- available
- Whether this machine carries an M2M encode node at all.
- coded_
fourcc - The capture-queue format for a codec the kernel’s interface names, or
Nonefor one it does not. The queues, the controls, and the input format are the same whichever of these a node carries, so the codec is a parameter rather than a second backend. - encodes
- Whether a session of this codec and size would come up on it, so the ladder can fall through to software before a session exists rather than after one has failed.
- served
- The codecs the node encodes, for the report a caller reads before any session exists.