Skip to main content

Module avc

Module avc 

Source
Expand description

H.264 bitstream helpers shared by demuxers (FFmpeg’s h264_mp4toannexb bitstream filter plus a minimal SPS reader).

rff’s packet contract for H.264 is Annex-B: every NAL prefixed with a 00 00 00 01 start code, SPS/PPS repeated before each keyframe, and Stream::extradata left empty. Containers that store AVCC (length-prefixed NALs + an avcC config record) — MP4 and Matroska — use parse_avcc + avcc_to_annexb to normalise, so consumers see one format regardless of the container. sps_dimensions recovers coded width/height for containers whose headers carry none (MPEG-TS).

Structs§

AvcConfig
Per-track H.264 config for AVCC→Annex-B conversion, parsed from an avcC (AVCDecoderConfigurationRecord) box.

Functions§

avcc_to_annexb
Convert one AVCC sample (a series of nal_len-byte length + NAL) to Annex-B (each NAL prefixed with a 00 00 00 01 start code), appending to out.
build_avcc_record
Build an AVCDecoderConfigurationRecord (the avcC payload, no box header) from the SPS and PPS NALs. MP4 wraps it in an avcC box; Matroska stores it raw as CodecPrivate.
find_sps_annexb
Find the first SPS NAL (type 7) in an Annex-B stream. Returns the NAL including its header byte, without the start code.
parse_avcc
Parse an avcC box into the NAL length size and Annex-B SPS/PPS headers.
split_annexb
Split an Annex-B bitstream into NAL units (start codes removed). The mux-side inverse of avcc_to_annexb, shared by every container that stores AVCC (MP4, Matroska).
sps_dimensions
Decode coded width/height from an SPS NAL (header byte included), applying the frame cropping rectangle. Handles High-profile chroma/bit-depth fields and scaling matrices. Returns None on any malformed or truncated field.