Documentation
¶
Overview ¶
Package h264 holds the H.264 bitstream helpers the containers share: avcC decoder-configuration parsing and AVCC (length-prefixed) to Annex B (start-code) conversion. Inside goav, H.264 packets travel as Annex B; the demuxers of length-prefixed containers convert on read and the muxers of those containers convert back on write.
Index ¶
- Constants
- Variables
- func AppendAVC(dst []byte, src []byte) ([]byte, error)
- func AppendAnnexB(dst []byte, src []byte, lengthSize int) ([]byte, error)
- func ConfigFromAnnexB(units ...[]byte) ([]byte, error)
- func ContainsNAL(data []byte, nalType byte) bool
- func ForEachNAL(data []byte, fn func(nal []byte) error) error
- func HasStartCode(data []byte) bool
- type Config
Constants ¶
const ( NALIDR = 5 NALSPS = 7 NALPPS = 8 )
NAL unit types the helpers inspect.
Variables ¶
var ErrInvalid = errors.New("h264: invalid bitstream")
ErrInvalid reports a malformed avcC record or AVCC sample.
var StartCode = [4]byte{0, 0, 0, 1}
StartCode is the 4-byte Annex B start code.
Functions ¶
func AppendAVC ¶
AppendAVC appends the Annex B access unit src to dst as an AVCC sample with 4-byte NAL lengths.
func AppendAnnexB ¶
AppendAnnexB appends the AVCC sample src, converted to Annex B, to dst.
func ConfigFromAnnexB ¶
ConfigFromAnnexB builds an avcC record, with 4-byte NAL lengths, from the parameter sets the Annex B access units carry.
func ContainsNAL ¶
ContainsNAL reports whether the Annex B access unit data carries a NAL unit of nalType.
func ForEachNAL ¶
ForEachNAL calls fn with each NAL unit of the Annex B access unit data, without its start code. Data must begin with a start code, after optional leading zero bytes.
func HasStartCode ¶
HasStartCode reports whether data begins with an Annex B start code.
Types ¶
type Config ¶
type Config struct {
// LengthSize is the byte width (1, 2, or 4) of each NAL length prefix in
// AVCC samples.
LengthSize int
SPS [][]byte
PPS [][]byte
}
Config is the subset of an AVCDecoderConfigurationRecord (avcC) the conversions need.
func ParseConfig ¶
ParseConfig parses an avcC record. The SPS/PPS slices alias record.
func (Config) AppendParameterSets ¶
AppendParameterSets appends the config's SPS and PPS NAL units to dst as Annex B, each behind a start code.