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 a00 00 00 01start code), appending toout. - build_
avcc_ record - Build an AVCDecoderConfigurationRecord (the
avcCpayload, no box header) from the SPS and PPS NALs. MP4 wraps it in anavcCbox; 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
avcCbox 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
Noneon any malformed or truncated field.