Documentation ¶
Overview ¶
Package h264 contains utilities to work with the H264 codec.
Index ¶
- Constants
- func AVCCMarshal(nalus [][]byte) ([]byte, error)
- func AVCCUnmarshal(buf []byte) ([][]byte, error)
- func AnnexBMarshal(nalus [][]byte) ([]byte, error)
- func AnnexBUnmarshal(byts []byte) ([][]byte, error)
- func EmulationPreventionRemove(nalu []byte) []byte
- func IDRPresent(nalus [][]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 ( // MaxNALUSize is the maximum size of a NALU. // with a 250 Mbps H264 video, the maximum NALU size is 2.2MB MaxNALUSize = 3 * 1024 * 1024 // MaxNALUsPerGroup is the maximum number of NALUs per group. MaxNALUsPerGroup = 20 )
Variables ¶
This section is empty.
Functions ¶
func AVCCMarshal ¶
AVCCMarshal encodes NALUs into the AVCC stream format.
func AVCCUnmarshal ¶
AVCCUnmarshal decodes NALUs from the AVCC stream format.
func AnnexBMarshal ¶
AnnexBMarshal encodes NALUs into the Annex-B stream format.
func AnnexBUnmarshal ¶
AnnexBUnmarshal decodes NALUs from the Annex-B stream format.
func EmulationPreventionRemove ¶
EmulationPreventionRemove removes emulation prevention bytes from a NALU.
func IDRPresent ¶
IDRPresent check if there's an IDR inside provided NALUs.
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.
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 ChromeFormatIdc 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.
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.