Documentation ¶
Overview ¶
Package h264 contains utilities to work with the H264 codec.
Index ¶
- Constants
- func AVCCMarshal(au [][]byte) ([]byte, error)
- func AVCCUnmarshal(buf []byte) ([][]byte, error)
- func AnnexBMarshal(au [][]byte) ([]byte, error)
- func AnnexBUnmarshal(byts []byte) ([][]byte, error)
- func EmulationPreventionRemove(nalu []byte) []byte
- func IDRPresent(au [][]byte) bool
- type DTSExtractor
- type NALUType
- type SPS
- type SPS_BitstreamRestriction
- type SPS_FrameCropping
- type SPS_HRD
- type SPS_TimingInfo
- type SPS_VUI
Constants ¶
const ( // MaxAccessUnitSize is the maximum size of an access unit. // With a 50 Mbps 2160p60 H264 video, the maximum size does not seem to exceed 8 MiB. MaxAccessUnitSize = 8 * 1024 * 1024 // MaxNALUsPerAccessUnit is the maximum number of NALUs per access unit. MaxNALUsPerAccessUnit = 21 )
Variables ¶
This section is empty.
Functions ¶
func AVCCMarshal ¶
AVCCMarshal encodes an access unit into the AVCC stream format. Specification: ?
func AVCCUnmarshal ¶
AVCCUnmarshal decodes an access unit from the AVCC stream format. Specification: ?
func AnnexBMarshal ¶
AnnexBMarshal encodes an access unit into the Annex-B stream format. Specification: ITU-T Rec. H.264, Annex B
func AnnexBUnmarshal ¶
AnnexBUnmarshal decodes an access unit from the Annex-B stream format. Specification: ITU-T Rec. H.264, Annex B
func EmulationPreventionRemove ¶
EmulationPreventionRemove removes emulation prevention bytes from a NALU. Specification: ITU-T Rec. H.264, 7.4.1 NAL unit semantics
func IDRPresent ¶
IDRPresent check whether there's an IDR inside the access unit.
Types ¶
type DTSExtractor ¶
type DTSExtractor struct {
// contains filtered or unexported fields
}
DTSExtractor allows to extract DTS from PTS.
func NewDTSExtractor ¶
func NewDTSExtractor() *DTSExtractor
NewDTSExtractor allocates a DTSExtractor.
type NALUType ¶
type NALUType uint8
NALUType is the type of a NALU. Specification: ITU-T Rec. H.264, Table 7-1
const ( NALUTypeNonIDR NALUType = 1 NALUTypeDataPartitionA NALUType = 2 NALUTypeDataPartitionB NALUType = 3 NALUTypeDataPartitionC NALUType = 4 NALUTypeIDR NALUType = 5 NALUTypeSEI NALUType = 6 NALUTypeSPS NALUType = 7 NALUTypePPS NALUType = 8 NALUTypeAccessUnitDelimiter NALUType = 9 NALUTypeEndOfSequence NALUType = 10 NALUTypeEndOfStream NALUType = 11 NALUTypeFillerData NALUType = 12 NALUTypeSPSExtension NALUType = 13 NALUTypePrefix NALUType = 14 NALUTypeSubsetSPS NALUType = 15 NALUTypeReserved16 NALUType = 16 NALUTypeReserved17 NALUType = 17 NALUTypeReserved18 NALUType = 18 NALUTypeSliceLayerWithoutPartitioning NALUType = 19 NALUTypeSliceExtension NALUType = 20 NALUTypeSliceExtensionDepth NALUType = 21 NALUTypeReserved22 NALUType = 22 NALUTypeReserved23 NALUType = 23 // additional NALU types for RTP/H264 NALUTypeSTAPA NALUType = 24 NALUTypeSTAPB NALUType = 25 NALUTypeMTAP16 NALUType = 26 NALUTypeMTAP24 NALUType = 27 NALUTypeFUA NALUType = 28 NALUTypeFUB NALUType = 29 )
NALU types.
type SPS ¶
type SPS struct { ProfileIdc uint8 ConstraintSet0Flag bool ConstraintSet1Flag bool ConstraintSet2Flag bool ConstraintSet3Flag bool ConstraintSet4Flag bool ConstraintSet5Flag bool LevelIdc uint8 ID uint32 // only for selected ProfileIdcs ChromaFormatIdc uint32 SeparateColourPlaneFlag bool BitDepthLumaMinus8 uint32 BitDepthChromaMinus8 uint32 QpprimeYZeroTransformBypassFlag bool // seqScalingListPresentFlag == true ScalingList4x4 [][]int32 UseDefaultScalingMatrix4x4Flag []bool ScalingList8x8 [][]int32 UseDefaultScalingMatrix8x8Flag []bool Log2MaxFrameNumMinus4 uint32 PicOrderCntType uint32 // PicOrderCntType == 0 Log2MaxPicOrderCntLsbMinus4 uint32 // PicOrderCntType == 1 DeltaPicOrderAlwaysZeroFlag bool OffsetForNonRefPic int32 OffsetForTopToBottomField int32 OffsetForRefFrames []int32 MaxNumRefFrames uint32 GapsInFrameNumValueAllowedFlag bool PicWidthInMbsMinus1 uint32 PicHeightInMapUnitsMinus1 uint32 FrameMbsOnlyFlag bool // FrameMbsOnlyFlag == false MbAdaptiveFrameFieldFlag bool Direct8x8InferenceFlag bool FrameCropping *SPS_FrameCropping VUI *SPS_VUI }
SPS is a H264 sequence parameter set. Specification: ITU-T Rec. H.264, 7.3.2.1.1
type SPS_BitstreamRestriction ¶
type SPS_BitstreamRestriction struct { MotionVectorsOverPicBoundariesFlag bool MaxBytesPerPicDenom uint32 MaxBitsPerMbDenom uint32 Log2MaxMvLengthHorizontal uint32 Log2MaxMvLengthVertical uint32 MaxNumReorderFrames uint32 MaxDecFrameBuffering uint32 }
SPS_BitstreamRestriction are bitstream restriction infos.
type SPS_FrameCropping ¶
type SPS_FrameCropping struct { LeftOffset uint32 RightOffset uint32 TopOffset uint32 BottomOffset uint32 }
SPS_FrameCropping is the frame cropping part of a SPS.
type SPS_HRD ¶
type SPS_HRD struct { CpbCntMinus1 uint32 BitRateScale uint8 CpbSizeScale uint8 BitRateValueMinus1 []uint32 CpbSizeValueMinus1 []uint32 CbrFlag []bool InitialCpbRemovalDelayLengthMinus1 uint8 CpbRemovalDelayLengthMinus1 uint8 DpbOutputDelayLengthMinus1 uint8 TimeOffsetLength uint8 }
SPS_HRD is a hypotetical reference decoder.
type SPS_TimingInfo ¶
SPS_TimingInfo is a timing info.
type SPS_VUI ¶
type SPS_VUI struct { AspectRatioInfoPresentFlag bool // AspectRatioInfoPresentFlag == true AspectRatioIdc uint8 SarWidth uint16 SarHeight uint16 OverscanInfoPresentFlag bool // OverscanInfoPresentFlag == true OverscanAppropriateFlag bool VideoSignalTypePresentFlag bool // VideoSignalTypePresentFlag == true VideoFormat uint8 VideoFullRangeFlag bool ColourDescriptionPresentFlag bool // ColourDescriptionPresentFlag == true ColourPrimaries uint8 TransferCharacteristics uint8 MatrixCoefficients uint8 ChromaLocInfoPresentFlag bool // ChromaLocInfoPresentFlag == true ChromaSampleLocTypeTopField uint32 ChromaSampleLocTypeBottomField uint32 TimingInfo *SPS_TimingInfo NalHRD *SPS_HRD VclHRD *SPS_HRD LowDelayHrdFlag bool PicStructPresentFlag bool BitstreamRestriction *SPS_BitstreamRestriction }
SPS_VUI is a video usability information.