Skip to main content

Module format

Module format 

Source
Expand description

The shared pixel-format contract between g2g and the gst-python-ml backend.

gst-python-ml’s tasks/frame_format.py and its FrameIO.read_frame(s) speak GStreamer-style format strings ("RGBA", "NV12", …). g2g speaks RawVideoFormat. Caps negotiation (which format the link carries) and the per-frame call (which fmt string Python is handed) must agree, so the mapping lives in one place here rather than being re-derived on each side.

Only the formats g2g currently models are mapped; an unmapped string from the Python side is a negotiation error, not a silent guess.

Functions§

format_from_py
Parse a gst-python-ml format string back into a g2g RawVideoFormat. Returns None for a format g2g does not model. YUYV is accepted as an alias for YUY2 (V4L2 vs GStreamer spelling of the same packed 4:2:2).
format_to_py
The GStreamer-style format string for a g2g raw-video format, as the gst-python-ml FrameIO / frame_format code expects it.
frame_bytes
Bytes one width x height frame of fmt occupies, for allocating a blank source buffer. Packed formats are exact; the fully-planar YUV family derives its size from the format’s own subsampling and sample depth.