syntax

package
v1.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: BSD-2-Clause Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SEIPayloadTypeBufferingPeriod      = 0
	SEIPayloadTypePicTiming            = 1
	SEIPayloadTypeUserDataUnregistered = 5
	SEIPayloadTypeRecoveryPoint        = 6
)
View Source
const (
	ProfileBaseline = 66
	ProfileMain     = 77
	ProfileExtended = 88
	ProfileHigh     = 100
)
View Source
const (
	ChromaMonochrome = 0
	Chroma420        = 1
	Chroma422        = 2
	Chroma444        = 3
)
View Source
const ExtendedSAR = 255

Variables

View Source
var (
	ErrUnsupported   = errors.New("go264/syntax: unsupported bitstream feature")
	ErrInvalidValue  = errors.New("go264/syntax: syntax element out of range")
	ErrMissingSPS    = errors.New("go264/syntax: referenced SPS is absent")
	ErrMissingPPS    = errors.New("go264/syntax: referenced PPS is absent")
	ErrUnexpectedEnd = errors.New("go264/syntax: bitstream ended inside a syntax structure")
)

Functions

func ChromaQP

func ChromaQP(qpY, offset int) int

func ParseSliceHeader

func ParseSliceHeader(r *bits.Reader, unit nal.Header, sets ParameterSets) (*SliceHeader, *SPS, *PPS, error)

func WritePPS

func WritePPS(p *PPS, lookupSPS func(id uint32) *SPS) ([]byte, error)

func WriteSEI added in v1.2.0

func WriteSEI(messages []SEIMessage, activeSPS *SPS, lookupSPS func(id uint32) *SPS) ([]byte, error)

func WriteSPS

func WriteSPS(s *SPS) ([]byte, error)

func WriteSliceHeader

func WriteSliceHeader(w *bits.Writer, h *SliceHeader, sps *SPS, pps *PPS) error

Types

type HRD

type HRD struct {
	CPBCntMinus1                       uint32
	BitRateScale                       uint8
	CPBSizeScale                       uint8
	BitRateValueMinus1                 []uint32
	CPBSizeValueMinus1                 []uint32
	CBRFlag                            []bool
	InitialCPBRemovalDelayLengthMinus1 uint8
	CPBRemovalDelayLengthMinus1        uint8
	DPBOutputDelayLengthMinus1         uint8
	TimeOffsetLength                   uint8
}

type MMCO

type MMCO struct {
	Op                        uint32
	DifferenceOfPicNumsMinus1 uint32
	LongTermPicNum            uint32
	LongTermFrameIdx          uint32
	MaxLongTermFrameIdxPlus1  uint32
}

type PPS

type PPS struct {
	ID                                uint32
	SPSID                             uint32
	CABAC                             bool
	BottomFieldPicOrderInFramePresent bool
	NumSliceGroupsMinus1              uint32

	NumRefIdxL0DefaultActiveMinus1 uint32
	NumRefIdxL1DefaultActiveMinus1 uint32
	WeightedPred                   bool
	WeightedBipredIDC              uint32
	PicInitQPMinus26               int32
	PicInitQSMinus26               int32
	ChromaQPIndexOffset            int32
	DeblockingFilterControlPresent bool
	ConstrainedIntraPred           bool
	RedundantPicCntPresent         bool

	HasExtension              bool
	Transform8x8Mode          bool
	PicScalingMatrixPresent   bool
	ScalingList4x4            [6][16]uint8
	ScalingList8x8            [6][64]uint8
	ScalingList4x4Present     [6]bool
	ScalingList8x8Present     [6]bool
	UseDefaultScaling4x4      [6]bool
	UseDefaultScaling8x8      [6]bool
	SecondChromaQPIndexOffset int32
}

func ParsePPS

func ParsePPS(rbsp []byte, lookupSPS func(id uint32) *SPS) (*PPS, error)

func (*PPS) ResolvedScalingLists added in v1.2.0

func (p *PPS) ResolvedScalingLists(sps *SPS) (list4x4 [6][16]uint8, list8x8 [6][64]uint8)

func (*PPS) SliceQPY

func (p *PPS) SliceQPY(sliceQPDelta int32) int

type ParameterSets

type ParameterSets interface {
	SPS(id uint32) *SPS
	PPS(id uint32) *PPS
}

type PredWeightTable

type PredWeightTable struct {
	LumaLog2WeightDenom   uint32
	ChromaLog2WeightDenom uint32
	L0                    []WeightEntry
	L1                    []WeightEntry
}

type RefPicListModification

type RefPicListModification struct {
	IDC   uint32
	Value uint32
}

type SEIBufferingPeriod added in v1.2.0

type SEIBufferingPeriod struct {
	SeqParameterSetID uint32
	NalHRD            []SEIInitialCPBDelay
	VclHRD            []SEIInitialCPBDelay
}

type SEIClockTimestamp added in v1.2.0

type SEIClockTimestamp struct {
	Present        bool
	CTType         uint8
	NuitFieldBased bool
	CountingType   uint8
	FullTimestamp  bool
	Discontinuity  bool
	CntDropped     bool
	NFrames        uint8
	SecondsFlag    bool
	Seconds        uint8
	MinutesFlag    bool
	Minutes        uint8
	HoursFlag      bool
	Hours          uint8
	TimeOffset     int32
}

type SEIInitialCPBDelay added in v1.2.0

type SEIInitialCPBDelay struct {
	InitialCPBRemovalDelay       uint32
	InitialCPBRemovalDelayOffset uint32
}

type SEIMessage added in v1.2.0

type SEIMessage struct {
	PayloadType uint32
	Opaque      []byte

	RecoveryPoint        *SEIRecoveryPoint
	BufferingPeriod      *SEIBufferingPeriod
	PicTiming            *SEIPicTiming
	UserDataUnregistered *SEIUserDataUnregistered
}

func ParseSEI added in v1.2.0

func ParseSEI(rbsp []byte, activeSPS *SPS, lookupSPS func(id uint32) *SPS) ([]SEIMessage, error)

type SEIPicTiming added in v1.2.0

type SEIPicTiming struct {
	CPBRemovalDelay uint32
	DPBOutputDelay  uint32
	PicStruct       uint8
	ClockTimestamps []SEIClockTimestamp
}

type SEIRecoveryPoint added in v1.2.0

type SEIRecoveryPoint struct {
	RecoveryFrameCnt      uint32
	ExactMatch            bool
	BrokenLink            bool
	ChangingSliceGroupIDC uint8
}

type SEIUserDataUnregistered added in v1.2.0

type SEIUserDataUnregistered struct {
	UUID [16]byte
	Data []byte
}

type SPS

type SPS struct {
	ProfileIDC                  uint8
	ConstraintSet               uint8
	LevelIDC                    uint8
	ID                          uint32
	ChromaFormatIDC             uint32
	SeparateColourPlane         bool
	BitDepthLumaMinus8          uint32
	BitDepthChromaMinus8        uint32
	QpprimeYZeroTransformBypass bool
	SeqScalingMatrixPresent     bool
	ScalingList4x4              [6][16]uint8
	ScalingList8x8              [6][64]uint8
	ScalingList4x4Present       [6]bool
	ScalingList8x8Present       [6]bool
	UseDefaultScaling4x4        [6]bool
	UseDefaultScaling8x8        [6]bool

	Log2MaxFrameNumMinus4       uint32
	PicOrderCntType             uint32
	Log2MaxPicOrderCntLsbMinus4 uint32
	DeltaPicOrderAlwaysZero     bool
	OffsetForNonRefPic          int32
	OffsetForTopToBottomField   int32
	OffsetForRefFrame           []int32

	MaxNumRefFrames            uint32
	GapsInFrameNumValueAllowed bool
	PicWidthInMbsMinus1        uint32
	PicHeightInMapUnitsMinus1  uint32
	FrameMbsOnly               bool
	MBAdaptiveFrameField       bool
	Direct8x8Inference         bool
	FrameCropping              bool
	FrameCropLeftOffset        uint32
	FrameCropRightOffset       uint32
	FrameCropTopOffset         uint32
	FrameCropBottomOffset      uint32
	VUIPresent                 bool
	VUI                        VUI
}

func ParseSPS

func ParseSPS(rbsp []byte) (*SPS, error)

func (*SPS) ChromaArrayType

func (s *SPS) ChromaArrayType() uint32

func (*SPS) CroppedHeight

func (s *SPS) CroppedHeight() int

func (*SPS) CroppedWidth

func (s *SPS) CroppedWidth() int

func (*SPS) FrameHeightInMbs

func (s *SPS) FrameHeightInMbs() int

func (*SPS) Height

func (s *SPS) Height() int

func (*SPS) IsLevel1b added in v1.6.0

func (s *SPS) IsLevel1b() bool

func (*SPS) MaxDpbFrames added in v1.1.0

func (s *SPS) MaxDpbFrames() int

func (*SPS) MaxFrameNum

func (s *SPS) MaxFrameNum() uint32

func (*SPS) MaxNumReorder added in v1.1.0

func (s *SPS) MaxNumReorder() int

func (*SPS) MaxPicOrderCntLsb

func (s *SPS) MaxPicOrderCntLsb() uint32

func (*SPS) PicHeightInMapUnits

func (s *SPS) PicHeightInMapUnits() int

func (*SPS) PicWidthInMbs

func (s *SPS) PicWidthInMbs() int

func (*SPS) ResolvedScalingLists added in v1.2.0

func (s *SPS) ResolvedScalingLists() (list4x4 [6][16]uint8, list8x8 [6][64]uint8)

func (*SPS) RestrictBitstream added in v1.11.1

func (s *SPS) RestrictBitstream(reorder int)

func (*SPS) ScalingListsPresent added in v1.2.0

func (s *SPS) ScalingListsPresent() bool

func (*SPS) Width

func (s *SPS) Width() int

type SliceHeader

type SliceHeader struct {
	FirstMBInSlice uint32
	SliceType      SliceType
	PPSID          uint32
	ColourPlaneID  uint32
	FrameNum       uint32

	FieldPic    bool
	BottomField bool

	IDRPicID uint32

	PicOrderCntLsb         uint32
	DeltaPicOrderCntBottom int32
	DeltaPicOrderCnt       [2]int32

	RedundantPicCnt uint32

	DirectSpatialMvPred bool

	NumRefIdxActiveOverride bool
	NumRefIdxL0ActiveMinus1 uint32
	NumRefIdxL1ActiveMinus1 uint32

	RefPicListModificationL0 []RefPicListModification
	RefPicListModificationL1 []RefPicListModification
	ModificationL0Present    bool
	ModificationL1Present    bool

	PredWeight PredWeightTable

	NoOutputOfPriorPics   bool
	LongTermReference     bool
	AdaptiveRefPicMarking bool
	MMCOs                 []MMCO

	CABACInitIDC uint32

	SliceQPDelta int32
	SPForSwitch  bool
	SliceQSDelta int32

	DisableDeblockingFilterIDC uint32
	SliceAlphaC0OffsetDiv2     int32
	SliceBetaOffsetDiv2        int32

	IDR       bool
	NalRefIDC uint8
}

func (*SliceHeader) MbaffFrame

func (h *SliceHeader) MbaffFrame(s *SPS) bool

func (*SliceHeader) NumRefIdxL0Active

func (h *SliceHeader) NumRefIdxL0Active(p *PPS) int

func (*SliceHeader) NumRefIdxL1Active

func (h *SliceHeader) NumRefIdxL1Active(p *PPS) int

func (*SliceHeader) QPY

func (h *SliceHeader) QPY(p *PPS) int

type SliceType

type SliceType uint8
const (
	SliceP  SliceType = 0
	SliceB  SliceType = 1
	SliceI  SliceType = 2
	SliceSP SliceType = 3
	SliceSI SliceType = 4
)

func (SliceType) AllSlicesSameType

func (t SliceType) AllSlicesSameType() bool

func (SliceType) Base

func (t SliceType) Base() SliceType

func (SliceType) IsB

func (t SliceType) IsB() bool

func (SliceType) IsI

func (t SliceType) IsI() bool

func (SliceType) IsP

func (t SliceType) IsP() bool

func (SliceType) IsSI

func (t SliceType) IsSI() bool

func (SliceType) IsSP

func (t SliceType) IsSP() bool

func (SliceType) String

func (t SliceType) String() string

type VUI

type VUI struct {
	AspectRatioInfoPresent bool
	AspectRatioIDC         uint8
	SarWidth               uint16
	SarHeight              uint16

	OverscanInfoPresent bool
	OverscanAppropriate bool

	VideoSignalTypePresent  bool
	VideoFormat             uint8
	VideoFullRange          bool
	ColourDescPresent       bool
	ColourPrimaries         uint8
	TransferCharacteristics uint8
	MatrixCoefficients      uint8

	ChromaLocInfoPresent      bool
	ChromaSampleLocTypeTop    uint32
	ChromaSampleLocTypeBottom uint32

	TimingInfoPresent bool
	NumUnitsInTick    uint32
	TimeScale         uint32
	FixedFrameRate    bool

	NalHRDPresent bool
	NalHRD        HRD
	VclHRDPresent bool
	VclHRD        HRD
	LowDelayHRD   bool

	PicStructPresent bool

	BitstreamRestriction         bool
	MotionVectorsOverPicBoundary bool
	MaxBytesPerPicDenom          uint32
	MaxBitsPerMBDenom            uint32
	Log2MaxMvLengthHorizontal    uint32
	Log2MaxMvLengthVertical      uint32
	MaxNumReorderFrames          uint32
	MaxDecFrameBuffering         uint32
}

type WeightEntry

type WeightEntry struct {
	LumaWeightFlag   bool
	LumaWeight       int32
	LumaOffset       int32
	ChromaWeightFlag bool
	ChromaWeight     [2]int32
	ChromaOffset     [2]int32
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL