Skip to main content

Module codec

Module codec 

Source
Expand description

Codec identities, wire framing, quantizer domains, level ladders, bitstream reads. What every encoder backend shares about a codec: its name and wire identity, the quantizer domain the session-wide quality index maps onto, the level a stream of a given geometry advertises, and the bitstream reads that label a frame on the wire.

Enums§

Codec
The picture codec of a capture session, and of a virtual-camera uplink. Jpeg is the striped still-image mode; the rest are video codecs, which stream as whole frames except H.264, whose software path may also stripe. The discriminants are the codec ids the Python API speaks (VirtualCamera.CODEC_*) and the video wire ids.
Hardware
The hardware encoder family a session’s quantizer curve is read for (Codec::hardware_quantizer).

Constants§

FRAME_ANCHOR
A bit ORed into a delta frame’s kind: the session keeps the frame as a long-term reference and it predicts from one every client holds (ReferenceWindow::settle), so every client can decode it.
FRAME_DELTA
FRAME_INTRA
FRAME_KEY
Frame kinds in the low nibble of the video type byte: a decode entry point, an intra-coded picture that is not one, and a predicted picture.
JPEG_HEADER_LEN
Bytes of the two stripe headers.
VIDEO_HEADER_LEN
VP8_LEVEL_QINDEX
VP8 quantizer index of each libvpx VP8 quantizer level 0..=63.
VPX_QINDEX
base_q_idx of each libvpx / libaom quantizer level 0..=63, as those libraries map their --min-q / --max-q / --cq-level arguments.
WIRE_JPEG
Wire tag of a JPEG stripe: u8 reserved, u16 frame id, u16 stripe Y, JPEG data.
WIRE_VIDEO
Wire tag of an encoded video frame or stripe: a type byte whose low nibble is the frame kind and whose high nibble is the codec’s Codec::wire_id, then u16 frame id, u16 stripe Y, u16 width, u16 height, u16 reference (the frame it predicts from, its own id where it names none), and the codec’s own bitstream.

Functions§

av1_is_key
Whether an AV1 temporal unit opens with a key frame: the first frame header or frame OBU’s frame_type, read past any temporal delimiter and sequence header. A show existing frame, or a unit without a frame, is a delta.
av1_level
Lowest AV1 level whose Annex A limits admit a width x height stream at fps carrying up to bitrate_bps (0 where no rate is declared), as seq_level_idx (8 = 4.0, 13 = 5.1, 19 = 6.3).
frame_type_from_key
The frame kind of a key/delta answer an encoder reports without a bitstream parse.
h264_dpb_frames
The decoded picture buffer, in frames, an H.264 stream at level may declare for a width x height picture: the level’s MaxDpbMbs over the picture’s macroblocks, at most REFERENCE_FRAMES.
h264_frame_type
Wire frame kind of one encoded H.264 access unit, read from the bitstream itself: IDR = key, intra-only non-IDR = intra, predicted = delta. The stripe header labels real decode entry points, so the NAL and slice types the encoder actually produced decide, never what was requested of it. An access unit whose slices cannot be parsed is labeled delta: a false delta costs one skipped entry point, a false key breaks the decoder.
h264_level
Lowest H.264 level whose Annex-A Table A-1 limits admit a width x height stream at fps carrying up to bitrate_bps (0 where no rate is declared), as level_idc (41 = 4.1, 52 = 5.2, 62 = 6.2).
h264_reference_level
The level an x264 session declares so its decoded picture buffer holds REFERENCE_FRAMES: the lowest from level up to 5.2 whose buffer admits them at width x height, else 5.2, or level itself above 5.2.
h265_dpb_frames
The reference frames an H.265 stream at level may hold for a width x height picture: the decoded picture buffer A.4.2 sizes (six pictures at the level’s full MaxLumaPs, more for a smaller picture) less the picture being decoded, at most REFERENCE_FRAMES.
h265_frame_type
Wire frame kind of one encoded H.265 access unit: an IRAP picture (BLA, IDR, or CRA, which every backend here emits as an IDR with its parameter sets) is a key, anything else a delta.
h265_level
Lowest H.265 level whose Annex-A Tables A.8 and A.9 limits admit a width x height stream at fps carrying up to bitrate_bps (0 where no rate is declared) at the High tier or the Main one, as general_level_idc (123 = 4.1, 156 = 5.2, 186 = 6.2).
h265_tier
The tier an H.265 session declares at level (general_level_idc): High (1) from level 4.0 up, where Annex A defines one and every decoder of those levels takes it, so a CBR target above the level’s Main-tier MaxBR is not refused by an encoder that validates the two together; Main (0) below, where no High tier exists.
parse_video_type
The codec and frame kind a video type byte carries.
push_jpeg_header
Append the header of one JPEG stripe.
push_video_header
Append the header of one encoded video frame or stripe: the tag, the codec and frame kind, then the frame id, the stripe’s top row, its width and height, and the id of the frame it predicts from, all big-endian u16. A frame that predicts from none, or whose encoder does not say, names itself there.
vp8_is_key
Whether a VP8 frame is a key frame: the frame tag’s lowest bit is clear.
vp9_base_q_idx
The base_q_idx of a VP9 frame, read from its uncompressed header past the color configuration, the frame size, the references, and the loop filter; None for a shown existing frame or a header cut short.
vp9_is_key
Whether a VP9 frame is a key frame, read from its uncompressed header: not a shown existing frame, and frame_type KEY_FRAME. Profile 3 carries one reserved bit ahead of those two.
vpx_level
The libvpx / SVT-AV1 quantizer level (0..=63) closest to a quantizer index of codec’s domain: the software encoders take the level, the hardware ones the index.