Documentation ¶
Index ¶
- func DonDiff(don1 uint16, don2 uint16) (diff int)
- func EBSPToRaw(buf []byte) []byte
- func RBSPToEncapsulated(buf []byte) []byte
- func SplitAnnexB(buf []byte) [][]byte
- type BitReader
- func (r *BitReader) Available() uint
- func (r *BitReader) ReadBits(n uint) (val uint32, err error)
- func (r *BitReader) ReadByteBits(n uint) (val byte, err error)
- func (r *BitReader) ReadFlag() (val bool, err error)
- func (r *BitReader) ReadPayloadParam() (val uint32, err error)
- func (r *BitReader) ReadScalingList(list []int32) (useDefault bool, err error)
- func (r *BitReader) ReadSignedGolomb() (val int32, err error)
- func (r *BitReader) ReadUnsignedGolomb() (val uint32, err error)
- func (r *BitReader) SkipBits(n uint) (err error)
- func (r *BitReader) SkipGolomb() (err error)
- func (r *BitReader) SkipTrailingBits() (err error)
- type NALFragment
- type NALSink
- type NALUnit
- type PPSInfo
- type ParameterSets
- func (s *ParameterSets) GetPPS(id uint32) (pps *PPSInfo, ok bool)
- func (s *ParameterSets) GetSPS(id uint32) (sps *SPSInfo, ok bool)
- func (s *ParameterSets) ParsePPS(buf []byte) (err error)
- func (s *ParameterSets) ParseSPS(buf []byte) (err error)
- func (s *ParameterSets) ParseSprop(buf []byte) (err error)
- type SPSInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EBSPToRaw ¶
EBSPToRaw removes emulation prevention bytes from the buffer transforming Encapsulated Byte Sequence Payload (EBSP) into Raw Byte Sequence Payload (RBSP).
func RBSPToEncapsulated ¶
RBSPToEncapsulated adds emulation prevention bytes to the buffer transforming Raw Byte Sequence Payload (RBSP) into Encapsulated Byte Sequence Payload (EBSP).
func SplitAnnexB ¶
SplitAnnexB attempts to recognize a sequence of NALUs separated by start codes in the buffer. Returns a list of raw/unparsed units with emulation bytes removed.
Types ¶
type BitReader ¶
type BitReader struct {
// contains filtered or unexported fields
}
BitReader implements bit stream reading for H.264 network layer processing.
func NewBitReader ¶
NewBitReader creates a bit stream reader from a slice of bytes.
func (*BitReader) ReadBits ¶
ReadBits attempts to read requested number of bits from the bit stream. Returns an error if running into end of stream prematurely.
func (*BitReader) ReadByteBits ¶
ReadByteBits attempts to read a single byte from the bit stream. Returns an error if running into end of stream prematurely. Useful to assign result directly to byte target.
func (*BitReader) ReadFlag ¶
ReadFlag attempts to read a single bit from the bit stream. Returns an error if running into end of stream prematurely. Useful to assign result directly to boolean target.
func (*BitReader) ReadPayloadParam ¶
ReadPayloadParam parses payload type and size of SEI message from bit reader.
func (*BitReader) ReadScalingList ¶
ReadScalingList reads scaling list into a slice and returns either an indicator to use default matrix or an error. The length of the list to read is driven by the length of the slice.
func (*BitReader) ReadSignedGolomb ¶
ReadSignedGolomb reads and decodes exponential golomb encoded value from a bit stream. and interprets it as signed value. Returns an error if running into end of stream prematurely.
func (*BitReader) ReadUnsignedGolomb ¶
ReadUnsignedGolomb reads and decodes exponential golomb encoded value from a bit stream. Returns an error if running into end of stream prematurely.
func (*BitReader) SkipBits ¶
SkipBits attempts to skip requested number of bits in the bit stream. Returns an error if running into end of stream prematurely.
func (*BitReader) SkipGolomb ¶
SkipGolomb decodes exponential golomb encoded value in the bit stream and skips it. Returns an error if running into end of stream prematurely.
func (*BitReader) SkipTrailingBits ¶
SkipTrailingBits ensures that remaining bits in the buffer consist of stop bit and variable number of aligning zero-bits;
type NALFragment ¶
NALFragment represents NAL unit fragment together with fragment specidfic flags (start, end). +---------------+ |0|1|2|3|4|5|6|7| +-+-+-+-+-+-+-+-+ |S|E|R| Type | +---------------+ Start flag, End flag, Reserved must be 0, NAL payload Type
func (NALFragment) IsEnd ¶
func (f NALFragment) IsEnd() bool
IsEnd returns end flag of the NAL unit fragment.
func (NALFragment) IsStart ¶
func (f NALFragment) IsStart() bool
IsStart returns start flag of the NAL unit fragment.
type NALSink ¶
type NALSink struct { Units []NALUnit Fragments []NALFragment Don uint16 // Decoding Order Number }
NALSink handles NAL unit aggreagates and fragments
func NewNALSink ¶
func NewNALSink() *NALSink
NewNALSink creates a sink to handle NAL unit aggreagates and fragments. Sink combines fragments to emit a unit into the queue and resets unit queue on each subsequent RTP packet. Fragment queue is reset upon receiving first fragment in a series.
func (*NALSink) AddFragment ¶
AddFragment pushes NAL unit fragment into the fragment queue, resetting queue before accepting first fragment in a series. Upon receiving last fragment in a series, all fragments are combined into a NAL unit and added to the unit queue.
type NALUnit ¶
type NALUnit struct { Header byte Don uint16 // Decoding Order Number TS uint32 // Timestamp Data []byte }
NALUnit describes a single Network Access Layer Unit in video stream. +---------------+ |0|1|2|3|4|5|6|7| +-+-+-+-+-+-+-+-+ |F|NRI| Type | +---------------+ Forbidden Zero bit, must be 0; NAL Ref Idc; NAL Type.
type PPSInfo ¶
type PPSInfo struct { PpsID uint32 SpsID uint32 EntropyCodingMode bool BottomFieldPicOorderInFramePresent bool NumSliceGroupsMinus1 uint32 // 0..7, i.e. up to 8 groups SliceGroupMapType uint32 RunLengthMinus1 [8]uint32 TopLeft [8]uint32 BottomRight [8]uint32 SliceGroupChangeDirection bool SliceGroupChangeRateMinus1 uint32 PicSizeInMapUnitsMinus1 uint32 SliceGroupID []byte NumRefIdxL0DefaultActiveMinus1 uint32 NumRefIdxL1DefaultActiveMinus1 uint32 WeightedPred bool WeightedBipredIdc byte PicInitQpMinus26 int32 PicInitQsMinus26 int32 ChromaQpIndexOffset int32 DeblockingFilterControlPresent bool ConstrainedIntraPred bool RedundantPicCntPresent bool Transform8x8Mode bool ScalingMatrixPresent bool ScalingListPresent uint32 ScalingList [6*16 + 6*64]int32 UseDefaultScalingMatrix [12]bool SecondChromaQpIndexOffset int32 }
PPSInfo holds Picture Parameter Set information referenced by slices.
type ParameterSets ¶
type ParameterSets struct {
// contains filtered or unexported fields
}
ParameterSets keep all current parsed and indexed parameter sets for quick access.
func NewParameterSets ¶
func NewParameterSets() *ParameterSets
NewParameterSets create an representation of indexed storage for sequence and picture parameter sets.
func (*ParameterSets) GetPPS ¶
func (s *ParameterSets) GetPPS(id uint32) (pps *PPSInfo, ok bool)
GetPPS looks up PPS by id among currently available parameter sets.
func (*ParameterSets) GetSPS ¶
func (s *ParameterSets) GetSPS(id uint32) (sps *SPSInfo, ok bool)
GetSPS looks up SPS by id among currently available parameter sets.
func (*ParameterSets) ParsePPS ¶
func (s *ParameterSets) ParsePPS(buf []byte) (err error)
ParsePPS parses Picture Parameter Set information from a given buffer and adds it to the indexed list of available sets. Buffer can be out-of-band, coming from sprop-parameter-sets property in SDP. It could also come in-band in a NAL with respective type.
func (*ParameterSets) ParseSPS ¶
func (s *ParameterSets) ParseSPS(buf []byte) (err error)
ParseSPS parses Sequence Parameter Set information from a given buffer and adds it to the indexed list of available sets. Buffer can be out-of-band, coming from sprop-parameter-sets property in SDP. It could also come in-band in a NAL with respective type.
func (*ParameterSets) ParseSprop ¶
func (s *ParameterSets) ParseSprop(buf []byte) (err error)
ParseSprop analyzes value from SDP sprop parameter sets where first byte is a NAL header. To simplify code we do not fully queue and process NAL.
type SPSInfo ¶
type SPSInfo struct { ProfileIdc byte ConstraintSet byte LevelIdc byte SpsID uint32 ChromaFormatIdc uint32 SeparateColorPlane bool BitDepthLuma uint32 BitDepthChroma uint32 ZeroTransformBypass bool ScalingMatrixPresent bool ScalingListPresent uint32 ScalingList [6*16 + 6*64]int32 UseDefaultScalingMatrix [12]bool Log2MaxFrameNum uint32 PicOrderCntType uint32 Log2MaxPicOrderCnt uint32 DeltaPicOrderAlways0 bool OffsetForNonRefPic int32 OffsetForTopToBottomField int32 NumRefFramesInPicOrderCntCycle uint32 MaxNumRefFrames uint32 GapsInFrameNumValueAllowed bool PicWidthInMbsMinus1 uint32 PicHeightInMapUnitsMinus1 uint32 FrameMbsOnly uint32 MbAdaptiveFrameField bool Direct8x8Inference bool FrameCropping bool FrameCropLeftOffset uint32 FrameCropRightOffset uint32 FrameCropTopOffset uint32 FrameCropBottomOffset uint32 VuiParametersPresent bool Width uint32 Height uint32 }
SPSInfo holds Sequence Parameter Set information parsed from out-of-band or in-band data in the stream. Most of the information here is unused but parsed anyway. VUI parameters are no parsed at all.