Documentation ¶
Overview ¶
Package hevc - parsing of HEVC(H.265) NAL unit headers, slice headers, VPS, SPS, and PPS.
Index ¶
- Constants
- Variables
- func CodecString(sampleEntry string, sps *SPS) string
- func ContainsNaluType(sample []byte, specificNaluType NaluType) bool
- func ExtractNalusOfTypeFromByteStream(nType NaluType, data []byte, stopAtVideo bool) [][]byte
- func GetParameterSets(sample []byte) (vps, sps, pps [][]byte)
- func GetParameterSetsFromByteStream(data []byte) (vpss [][]byte, spss [][]byte, ppss [][]byte)
- func HasParameterSets(b []byte) bool
- func IsIDRSample(sample []byte) bool
- func IsRAPSample(sample []byte) bool
- type BitstreamRestrictions
- type ColourMappingTable
- type ConformanceWindow
- type D3Extension
- type DecConfRec
- type DeltaDlt
- type DepthLayer
- type HrdParameters
- type LongTermRPS
- type MultilayerExtension
- type NaluArray
- type NaluType
- type Octant
- type PPS
- type PredWeightTable
- type ProfileTierLevel
- type RangeExtension
- type RefLocOffset
- type RefPicListsModification
- type SPS
- type SPS3dExtension
- type SPSMultilayerExtension
- type SPSRangeExtension
- type SPSSccExtension
- type SccExtension
- type ShortTermRPS
- type SliceHeader
- type SliceType
- type SubLayerHrd
- type SubLayerHrdParameters
- type SubLayerOrderingInfo
- type VUIParameters
- type WeightingFactors
Constants ¶
const ( NALU_TRAIL_N = NaluType(0) NALU_TRAIL_R = NaluType(1) NALU_TSA_N = NaluType(2) NALU_TSA_R = NaluType(3) NALU_STSA_N = NaluType(4) NALU_STSA_R = NaluType(5) NALU_RADL_N = NaluType(6) NALU_RADL_R = NaluType(7) NALU_RASL_N = NaluType(8) NALU_RASL_R = NaluType(9) // BLA_W_LP and the following types are Random Access NALU_BLA_W_LP = NaluType(16) NALU_BLA_W_RADL = NaluType(17) NALU_BLA_N_LP = NaluType(18) NALU_IDR_W_RADL = NaluType(19) NALU_IDR_N_LP = NaluType(20) NALU_CRA = NaluType(21) // Reserved IRAP VCL NAL unit types NALU_IRAP_VCL22 = NaluType(22) NALU_IRAP_VCL23 = NaluType(23) // NALU_VPS - VideoParameterSet NAL Unit NALU_VPS = NaluType(32) // NALU_SPS - SequenceParameterSet NAL Unit NALU_SPS = NaluType(33) // NALU_PPS - PictureParameterSet NAL Unit NALU_PPS = NaluType(34) // NALU_AUD - AccessUnitDelimiter NAL Unit NALU_AUD = NaluType(35) //NALU_EOS - End of Sequence NAL Unit NALU_EOS = NaluType(36) //NALU_EOB - End of Bitstream NAL Unit NALU_EOB = NaluType(37) //NALU_FD - Filler data NAL Unit NALU_FD = NaluType(38) //NALU_SEI_PREFIX - Prefix SEI NAL Unit NALU_SEI_PREFIX = NaluType(39) //NALU_SEI_SUFFIX - Suffix SEI NAL Unit NALU_SEI_SUFFIX = NaluType(40) )
HEVC NALU types
const ( SLICE_B = SliceType(0) SLICE_P = SliceType(1) SLICE_I = SliceType(2) )
HEVC slice types
Variables ¶
var (
ErrLengthSize = errors.New("can only handle 4byte NALU length size")
)
HEVC errors
var (
ErrNotPPS = errors.New("Not an PPS NAL unit")
)
HEVC PPS errors
Functions ¶
func CodecString ¶
CodecString - sub-parameter for MIME type "codecs" parameter like hev1.1.6.L93.B0 where hev1 is sampleEntry. Defined in ISO/IEC 14496-15 2017 Annex E.
func ContainsNaluType ¶
ContainsNaluType - is specific NaluType present in sample
func ExtractNalusOfTypeFromByteStream ¶
ExtractNalusOfTypeFromByteStream returns all HEVC nalus of wanted type from bytestream. If stopAtVideo, the stream is not scanned beyond the first video NAL unit.
func GetParameterSets ¶
GetParameterSets - get (multiple) VPS, SPS, and PPS from a sample
func GetParameterSetsFromByteStream ¶
GetParameterSetsFromByteStream gets SPS and PPS nalus from bytestream
func HasParameterSets ¶
HasParameterSets - Check if HEVC VPS, SPS and PPS are present
func IsRAPSample ¶
IsRAPSample - is Random Access picture (NALU 16-23)
Types ¶
type BitstreamRestrictions ¶
type BitstreamRestrictions struct { TilesFixedStructureFlag bool MVOverPicBoundariesFlag bool RestrictedRefsPicsListsFlag bool MinSpatialSegmentationIDC uint MaxBytesPerPicDenom uint MaxBitsPerMinCuDenom uint Log2MaxMvLengthHorizontal uint Log2MaxMvLengthVertical uint }
BitstreamRestrictrictions - optional information
type ColourMappingTable ¶ added in v0.35.0
type ColourMappingTable struct { NumCmRefLayersMinus1 uint8 RefLayerId []uint8 OctantDepth uint8 YPartNumLog2 uint8 LumaBitDepthCmInputMinus8 uint ChromaBitDepthCmInputMinus8 uint LumaBitDepthCmOutputMinus8 uint ChromaBitDepthCmOutputMinus8 uint ResQuantBits uint8 DeltaFlcBitsMinus1 uint8 AdaptThresholdUDelta int AdaptThresholdVDelta int Octants map[string][4]Octant }
type ConformanceWindow ¶
type ConformanceWindow struct { LeftOffset uint32 RightOffset uint32 TopOffset uint32 BottomOffset uint32 }
ConformanceWindow according to ISO/IEC 23008-2
type D3Extension ¶ added in v0.35.0
type D3Extension struct { DltsPresentFlag bool NumDepthLayersMinus1 uint8 BitDepthForDepthLayersMinus8 uint8 DepthLayers []DepthLayer }
D3Extension represent PPS 3D extension
type DecConfRec ¶
type DecConfRec struct { ConfigurationVersion byte GeneralProfileSpace byte GeneralTierFlag bool GeneralProfileIDC byte GeneralProfileCompatibilityFlags uint32 GeneralConstraintIndicatorFlags uint64 GeneralLevelIDC byte MinSpatialSegmentationIDC uint16 ParallellismType byte ChromaFormatIDC byte BitDepthLumaMinus8 byte BitDepthChromaMinus8 byte AvgFrameRate uint16 ConstantFrameRate byte NumTemporalLayers byte TemporalIDNested byte LengthSizeMinusOne byte NaluArrays []NaluArray }
DecConfRec - HEVCDecoderConfigurationRecord Specified in ISO/IEC 14496-15 4't ed 2017 Sec. 8.3.3
func CreateHEVCDecConfRec ¶
func CreateHEVCDecConfRec(vpsNalus, spsNalus, ppsNalus [][]byte, vpsComplete, spsComplete, ppsComplete, includePS bool) (DecConfRec, error)
CreateHEVCDecConfRec - extract information from sps and insert vps, sps, pps if includePS set
func DecodeHEVCDecConfRec ¶
func DecodeHEVCDecConfRec(data []byte) (DecConfRec, error)
DecodeHEVCDecConfRec - decode an HEVCDecConfRec
func (*DecConfRec) AddNaluArrays ¶
func (h *DecConfRec) AddNaluArrays(na []NaluArray)
AddNaluArrays appends new nalus to HEVCDecConfRec.
func (*DecConfRec) EncodeSW ¶
func (h *DecConfRec) EncodeSW(sw bits.SliceWriter) error
EncodeSW- write an HEVCDecConfRec to sw
func (*DecConfRec) GetNalusForType ¶
func (h *DecConfRec) GetNalusForType(naluType NaluType) [][]byte
GetNalusForType - get all nalus for a specific naluType
type DepthLayer ¶ added in v0.35.0
type HrdParameters ¶ added in v0.36.0
type HrdParameters struct { NalHrdParametersPresentFlag bool VclHrdParametersPresentFlag bool SubPicHrdParamsPresentFlag bool TickDivisorMinus2 uint8 DuCpbRemovalDelayIncrementLengthMinus1 uint8 SubPicCpbParamsInPicTimingSeiFlag bool DpbOutputDelayDuLengthMinus1 uint8 BitRateScale uint8 CpbSizeScale uint8 CpbSizeDuScale uint8 InitialCpbRemovalDelayLengthMinus1 uint8 AuCpbRemovalDelayLengthMinus1 uint8 DpbOutputDelayLengthMinus1 uint8 SubLayerHrd []SubLayerHrd }
type LongTermRPS ¶ added in v0.35.0
type MultilayerExtension ¶ added in v0.35.0
type MultilayerExtension struct { PocResetInfoPresentFlag bool InferScalingListFlag bool ScalingListRefLayerId uint8 NumRefLocOffsets uint RefLocOffsetLayerIds []uint8 RefLocOffsets map[uint8]RefLocOffset ColourMappingEnabledFlag bool ColourMappingTable *ColourMappingTable }
type NaluArray ¶
type NaluArray struct { Nalus [][]byte // contains filtered or unexported fields }
NaluArray - HEVC NALU array including complete bit and type
func NewNaluArray ¶
NewNaluArray - create an HEVC NaluArray
type NaluType ¶
type NaluType uint16
NaluType - HEVC nal type according to ISO/IEC 23008-2 Table 7.1
func FindNaluTypes ¶
FindNaluTypes - find list of nalu types in sample
func FindNaluTypesUpToFirstVideoNalu ¶
FindNaluTypesUpToFirstVideoNalu - all nalu types up to first video nalu
func GetNaluType ¶
GetNaluType - extract NALU type from first byte of NALU Header
type PPS ¶ added in v0.35.0
type PPS struct { PicParameterSetID uint32 SeqParameterSetID uint32 DependentSliceSegmentsEnabledFlag bool OutputFlagPresentFlag bool NumExtraSliceHeaderBits uint8 SignDataHidingEnabledFlag bool CabacInitPresentFlag bool NumRefIdxL0DefaultActiveMinus1 uint8 NumRefIdxL1DefaultActiveMinus1 uint8 InitQpMinus26 int8 ConstrainedIntraPredFlag bool TransformSkipEnabledFlag bool CuQpDeltaEnabledFlag bool DiffCuQpDeltaDepth uint CbQpOffset int8 CrQpOffset int8 SliceChromaQpOffsetsPresentFlag bool WeightedPredFlag bool WeightedBipredFlag bool TransquantBypassEnabledFlag bool TilesEnabledFlag bool EntropyCodingSyncEnabledFlag bool NumTileColumnsMinus1 uint NumTileRowsMinus1 uint UniformSpacingFlag bool ColumnWidthMinus1 []uint RowHeightMinus1 []uint LoopFilterAcrossTilesEnabledFlag bool LoopFilterAcrossSlicesEnabledFlag bool DeblockingFilterControlPresentFlag bool DeblockingFilterOverrideEnabledFlag bool DeblockingFilterDisabledFlag bool BetaOffsetDiv2 int8 TcOffsetDiv2 int8 ScalingListDataPresentFlag bool ListsModificationPresentFlag bool Log2ParallelMergeLevelMinus2 uint SliceSegmentHeaderExtensionPresentFlag bool ExtensionPresentFlag bool RangeExtensionFlag bool RangeExtension *RangeExtension MultilayerExtensionFlag bool MultilayerExtension *MultilayerExtension // PPS 3D extension D3ExtensionFlag bool D3Extension *D3Extension SccExtensionFlag bool SccExtension *SccExtension Extension4bits uint8 ExtensionDataFlag []bool }
PPS - Picture Parameter Set
type PredWeightTable ¶ added in v0.35.0
type PredWeightTable struct { LumaLog2WeightDenom uint8 DeltaChromaLog2WeightDenom int8 WeightsL0 []WeightingFactors WeightsL1 []WeightingFactors }
type ProfileTierLevel ¶
type ProfileTierLevel struct { GeneralProfileSpace byte GeneralTierFlag bool GeneralProfileIDC byte GeneralProfileCompatibilityFlags uint32 GeneralConstraintIndicatorFlags uint64 // 48 bits GeneralProgressiveSourceFlag bool GeneralInterlacedSourceFlag bool GeneralNonPackedConstraintFlag bool GeneralFrameOnlyConstraintFlag bool // 43 + 1 bits of info GeneralLevelIDC byte }
ProfileTierLevel according to ISO/IEC 23008-2 Section 7.3.3
type RangeExtension ¶ added in v0.35.0
type RangeExtension struct { Log2MaxTransformSkipBlockSizeMinus2 uint CrossComponentPredictionEnabledFlag bool ChromaQpOffsetListEnabledFlag bool DiffCuChromaQpOffsetDepth uint ChromaQpOffsetListLenMinus1 uint CbQpOffsetList []int8 CrQpOffsetList []int8 Log2SaoOffsetScaleLuma uint Log2SaoOffsetScaleChroma uint }
type RefLocOffset ¶ added in v0.35.0
type RefLocOffset struct { ScaledRefLayerOffsetPresentFlag bool ScaledRefLayerLeftOffset int16 ScaledRefLayerTopOffset int16 ScaledRefLayerRightOffset int16 ScaledRefLayerBottomOffset int16 RefRegionOffsetPresentFlag bool RefRegionLeftOffset int16 RefRegionTopOffset int16 RefRegionRightOffset int16 RefRegionBottomOffset int16 ResamplePhaseSetPresentFlag bool PhaseHorLuma uint8 PhaseVerLuma uint8 PhaseHorChromaPlus8 uint8 PhaseVerChromaPlus8 uint8 }
type RefPicListsModification ¶ added in v0.35.0
type SPS ¶
type SPS struct { VpsID byte MaxSubLayersMinus1 byte TemporalIDNestingFlag bool ProfileTierLevel ProfileTierLevel SpsID byte ChromaFormatIDC byte SeparateColourPlaneFlag bool ConformanceWindowFlag bool PicWidthInLumaSamples uint32 PicHeightInLumaSamples uint32 ConformanceWindow ConformanceWindow BitDepthLumaMinus8 byte BitDepthChromaMinus8 byte Log2MaxPicOrderCntLsbMinus4 byte SubLayerOrderingInfoPresentFlag bool SubLayeringOrderingInfos []SubLayerOrderingInfo Log2MinLumaCodingBlockSizeMinus3 byte Log2DiffMaxMinLumaCodingBlockSize byte Log2MinLumaTransformBlockSizeMinus2 byte Log2DiffMaxMinLumaTransformBlockSize byte MaxTransformHierarchyDepthInter byte MaxTransformHierarchyDepthIntra byte ScalingListEnabledFlag bool ScalingListDataPresentFlag bool AmpEnabledFlag bool SampleAdaptiveOffsetEnabledFlag bool PCMEnabledFlag bool PcmSampleBitDepthLumaMinus1 byte PcmSampleBitDepthChromaMinus1 byte Log2MinPcmLumaCodingBlockSize uint16 Log2DiffMaxMinPcmLumaCodingBlockSize uint16 PcmLoopFilterDisabledFlag bool NumShortTermRefPicSets byte ShortTermRefPicSets []ShortTermRPS LongTermRefPicsPresentFlag bool NumLongTermRefPics uint8 LongTermRefPicSets []LongTermRPS SpsTemporalMvpEnabledFlag bool StrongIntraSmoothingEnabledFlag bool VUIParametersPresentFlag bool VUI *VUIParameters ExtensionPresentFlag bool Extension4bits uint8 RangeExtensionFlag bool RangeExtension *SPSRangeExtension MultilayerExtensionFlag bool MultilayerExtension *SPSMultilayerExtension // SPS 3D extension D3ExtensionFlag bool D3Extension *SPS3dExtension SccExtensionFlag bool SccExtension *SPSSccExtension ExtensionDataFlag []bool }
SPS - HEVC SPS parameters ISO/IEC 23008-2 Sec. 7.3.2.2
func ParseSPSNALUnit ¶
ParseSPSNALUnit parses SPS NAL unit starting with NAL unit header
type SPS3dExtension ¶ added in v0.35.0
type SPS3dExtension struct { IvDiMcEnabledFlag0 bool IvMvScalEnabledFlag0 bool Og2IvmcSubPbSizeMinus3 uint IvResPredEnabledFlag bool DepthRefEnabledFlag bool VspMcEnabledFlag bool DbbpEnabledFlag bool IvDiMcEnabledFlag1 bool IvMvScalEnabledFlag1 bool TexMcEnabledFlag bool Log2TexmcSubPbSizeMinus3 uint IntraContourEnabledFlag bool IntraDcOnlyWedgeEnabledFlag bool CqtCuPartPredEnabledFlag bool InterDcOnlyEnabledFlag bool SkipIntraEnabledFlag bool }
type SPSMultilayerExtension ¶ added in v0.35.0
type SPSMultilayerExtension struct {
InterViewMvVertConstraintFlag bool
}
type SPSRangeExtension ¶ added in v0.35.0
type SPSRangeExtension struct { TransformSkipRotationEnabledFlag bool TransformSkipContextEnabledFlag bool ImplicitRdpcmEnabledFlag bool ExplicitRdpcmEnabledFlag bool ExtendedPrecisionProcessingFlag bool IntraSmoothingDisabledFlag bool HighPrecisionOffsetsEnabledFlag bool PersistentRiceAdaptationEnabledFlag bool CabacBypassAlignmentEnabledFlag bool }
type SPSSccExtension ¶ added in v0.35.0
type SPSSccExtension struct { CurrPicRefEnabledFlag bool PaletteModeEnabledFlag bool PaletteMaxSize uint DeltaPaletteMaxPredictorSize uint PalettePredictorInitializersPresentFlag bool NumPalettePredictorInitializersMinus1 uint PalettePredictorInitializer [][]uint MotionVectorResolutionControlIdc uint8 IntraBoundaryFilteringDisabledFlag bool }
type SccExtension ¶ added in v0.35.0
type SccExtension struct { CurrPicRefEnabledFlag bool ResidualAdaptiveColourTransformEnabledFlag bool SliceActQpOffsetsPresentFlag bool ActYQpOffsetPlus5 int ActCbQpOffsetPlus5 int ActCrQpOffsetPlus3 int PalettePredictorInitializersPresentFlag bool NumPalettePredictorInitializers uint MonochromePaletteFlag bool LumaBitDepthEntryMinus8 uint ChromaBitDepthEntryMinus8 uint PalettePredictorInitializer [][]uint }
type ShortTermRPS ¶
type ShortTermRPS struct { // Delta Picture Order Count DeltaPocS0 []uint32 DeltaPocS1 []uint32 UsedByCurrPicS0 []bool UsedByCurrPicS1 []bool NumNegativePics byte NumPositivePics byte NumDeltaPocs byte }
ShortTermRPS - Short term Reference Picture Set
type SliceHeader ¶ added in v0.35.0
type SliceHeader struct { SliceType SliceType FirstSliceSegmentInPicFlag bool NoOutputOfPriorPicsFlag bool PicParameterSetId uint32 DependentSliceSegmentFlag bool SegmentAddress uint PicOutputFlag bool ColourPlaneId uint8 PicOrderCntLsb uint16 ShortTermRefPicSetSpsFlag bool ShortTermRefPicSet ShortTermRPS ShortTermRefPicSetIdx byte NumLongTermSps uint8 NumLongTermPics uint LongTermRefPicSets []LongTermRPS TemporalMvpEnabledFlag bool SaoLumaFlag bool SaoChromaFlag bool NumRefIdxActiveOverrideFlag bool NumRefIdxL0ActiveMinus1 uint8 NumRefIdxL1ActiveMinus1 uint8 RefPicListsModification *RefPicListsModification MvdL1ZeroFlag bool CabacInitFlag bool CollocatedFromL0Flag bool CollocatedRefIdx uint8 PredWeightTable *PredWeightTable FiveMinusMaxNumMergeCand uint8 UseIntegerMvFlag bool QpDelta int CbQpOffset int8 CrQpOffset int8 ActYQpOffset int8 ActCbQpOffset int8 ActCrQpOffset int8 CuChromaQpOffsetEnabledFlag bool DeblockingFilterOverrideFlag bool DeblockingFilterDisabledFlag bool BetaOffsetDiv2 int8 TcOffsetDiv2 int8 LoopFilterAcrossSlicesEnabledFlag bool NumEntryPointOffsets uint OffsetLenMinus1 uint8 EntryPointOffsetMinus1 []uint32 SegmentHeaderExtensionLength uint16 SegmentHeaderExtensionDataByte []byte Size uint32 }
func ParseSliceHeader ¶ added in v0.35.0
type SubLayerHrd ¶ added in v0.36.0
type SubLayerHrd struct { FixedPicRateGeneralFlag bool FixedPicRateWithinCvsFlag bool ElementalDurationInTcMinus1 uint16 LowDelayHrdFlag bool CpbCntMinus1 uint8 NalHrdParameters []SubLayerHrdParameters VclHrdParameters []SubLayerHrdParameters }
type SubLayerHrdParameters ¶ added in v0.36.0
type SubLayerOrderingInfo ¶
type SubLayerOrderingInfo struct { MaxDecPicBufferingMinus1 byte MaxNumReorderPics byte MaxLatencyIncreasePlus1 byte }
SubLayerOrderingInfo according to ISO/IEC 23008-2
type VUIParameters ¶
type VUIParameters struct { SampleAspectRatioWidth uint SampleAspectRatioHeight uint OverscanInfoPresentFlag bool OverscanAppropriateFlag bool VideoSignalTypePresentFlag bool VideoFormat byte VideoFullRangeFlag bool ColourDescriptionFlag bool ColourPrimaries byte TransferCharacteristics byte MatrixCoefficients byte ChromaLocInfoPresentFlag bool ChromaSampleLocTypeTopField uint ChromaSampleLocTypeBottomField uint NeutralChromaIndicationFlag bool FieldSeqFlag bool FrameFieldInfoPresentFlag bool DefaultDisplayWindowFlag bool DefDispWinLeftOffset uint DefDispWinRightOffset uint DefDispWinTopOffset uint DefDispWinBottomOffset uint TimingInfoPresentFlag bool NumUnitsInTick uint TimeScale uint PocProportionalToTimingFlag bool NumTicksPocDiffOneMinus1 uint HrdParametersPresentFlag bool HrdParameters *HrdParameters BitstreamRestrictionFlag bool BitstreamResctrictions *BitstreamRestrictions }
VUIParameters - Visual Usability Information as defined in Section E.2
type WeightingFactors ¶ added in v0.35.0
type WeightingFactors struct { LumaWeightFlag bool ChromaWeightFlag bool DeltaLumaWeight int8 LumaOffset int DeltaChromaWeight [2]int8 DeltaChromaOffset [2]int }
WeightingFactors fields described in specification 7.4.7.3 (Weighted prediction parameters semantics)