hevc

package
v0.21.2-0...-6e41e77 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package hevc - parsing of HEVC(H.265) NAL unit headers, slice headers, VPS, SPS, and PPS.

Index

Constants

View Source
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)
	// 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)
)

Variables

View Source
var ErrLengthSize = errors.New("Can only handle 4byte NALU length size")

Functions

func CodecString

func CodecString(sampleEntry string, sps *SPS) string

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

func ContainsNaluType(sample []byte, specificNalType NaluType) bool

ContainsNaluType - is specific NaluType present in sample

func GetParameterSets

func GetParameterSets(sample []byte) (vps, sps, pps [][]byte)

GetParameterSets - get (multiple) VPS, SPS, and PPS from a sample

func HasParameterSets

func HasParameterSets(b []byte) bool

HasParameterSets - Check if HEVC VPS, SPS and PPS are present

func IsRAPSample

func IsRAPSample(sample []byte) bool

IsRAPSample - is Random Access Sample (NALU 16-23)

Types

type ConformanceWindow

type ConformanceWindow struct {
	LeftOffset   uint32
	RightOffset  uint32
	TopOffset    uint32
	BottomOffset uint32
}

type HEVCDecConfRec

type HEVCDecConfRec 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
}

HEVCDecConfRec - 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 bool) (HEVCDecConfRec, error)

CreateHEVCDecConfRec - extract information from vps, sps, pps and fill HEVCDecConfRec with that

func DecodeHEVCDecConfRec

func DecodeHEVCDecConfRec(r io.Reader) (HEVCDecConfRec, error)

DecodeHEVCDecConfRec - decode an HEVCDecConfRec

func (*HEVCDecConfRec) Encode

func (h *HEVCDecConfRec) Encode(w io.Writer) error

Encode - write an HEVCDecConfRec to w

func (*HEVCDecConfRec) GetNalusForType

func (h *HEVCDecConfRec) GetNalusForType(naluType NaluType) [][]byte

GetNalusForType - get all nalus for a specific naluType

func (*HEVCDecConfRec) Size

func (h *HEVCDecConfRec) Size() uint64

type NaluArray

type NaluArray struct {
	Nalus [][]byte
	// contains filtered or unexported fields
}

NaluArray - HEVC NALU array including complete bit and type

func NewNaluArray

func NewNaluArray(complete bool, naluType NaluType, nalus [][]byte) *NaluArray

NewNaluArray - create an HEVC NaluArray

func (*NaluArray) Complete

func (n *NaluArray) Complete() byte

Complete - return 0x1 if complete

func (*NaluArray) NaluType

func (n *NaluArray) NaluType() NaluType

NaluType - return NaluType for NaluArray

type NaluType

type NaluType uint16

NaluType - HEVC nal type according to ISO/IEC 23008-2 Table 7.1

func FindNaluTypes

func FindNaluTypes(sample []byte) []NaluType

FindNaluTypes - find list of nalu types in sample

func GetNaluType

func GetNaluType(naluHeaderStart byte) NaluType

Get NaluType from first byte of NALU Header

func (NaluType) String

func (n NaluType) String() string

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
}

ISO/IEC 23008-2 Section 7.3.3

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
	NumShortTermRefPicSets               byte
	LongTermRefPicsPresentFlag           bool
	SpsTemporalMvpEnabledFlag            bool
	StrongIntraSmoothingEnabledFlag      bool
	VUIParametersPresentFlag             bool
}

SPS - HEVC SPS parameters ISO/IEC 23008-2 Sec. 7.3.2.2

func ParseSPSNALUnit

func ParseSPSNALUnit(data []byte) (*SPS, error)

ParseSPSNALUnit - Parse HEVC SPS NAL unit starting with NAL unit header

func (*SPS) ImageSize

func (s *SPS) ImageSize() (width, height uint32)

ImageSize - calculated width and height using ConformanceWindow

type SubLayerOrderingInfo

type SubLayerOrderingInfo struct {
	MaxDecPicBufferingMinus1 byte
	MaxNumReorderPics        byte
	MaxLatencyIncreasePlus1  byte
}

Jump to

Keyboard shortcuts

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