internal

package
v0.0.0-...-908b5a9 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2019 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExtendedSAR = 255
)

Variables

This section is empty.

Functions

func ScanNalu

func ScanNalu(data []byte, atEOF bool) (advance int, token []byte, err error)

ScanNalu split func for bufio to split nalu in bit stream

Types

type BitStream

type BitStream struct {
	// contains filtered or unexported fields
}

BitStream H264 bit stream, contains nalu

func NewBitStream

func NewBitStream(src io.Reader) *BitStream

NewBitStream return a new BitStream read from src

func (*BitStream) NextNalu

func (bs *BitStream) NextNalu() (*Nalu, error)

NextNalu read next nalu from src stream

type FrameCrop

type FrameCrop struct {
	LeftOffset   uint
	RightOffset  uint
	TopOffset    uint
	BottomOffset uint
}

type H264Decoder

type H264Decoder struct {
	// contains filtered or unexported fields
}

H264Decoder decoder of h264 codec

func NewH264DecoderWithFile

func NewH264DecoderWithFile(filePath string) (*H264Decoder, error)

func (*H264Decoder) InitWithFile

func (hd *H264Decoder) InitWithFile(filePath string) error

func (*H264Decoder) NextFrame

func (hd *H264Decoder) NextFrame() (image.Image, error)

type HrdParameters

type HrdParameters struct {
	CpbCntMinus1                       uint
	BitRateScale                       uint8
	CpbSizeScale                       uint8
	BitRateValueMinus1                 []uint
	CpbSizeValueMinus1                 []uint
	CbrFlag                            []bool
	InitialCpbRemovalDelayLengthMinus1 uint8
	CpbRemovalDelayLengthMinus1        uint8
	DpbOutputDelayLengthMinus1         uint8
	TimeOffsetLengths                  uint8
}

type Nalu

type Nalu struct {
	// contains filtered or unexported fields
}

Nalu of h264 codec

func NewNalu

func NewNalu() *Nalu

NewNalu create new Nalu

func (*Nalu) Load

func (nl *Nalu) Load(data []byte) error

Load load bit from data, add parse nalu fields

func (*Nalu) RbspSize

func (nl *Nalu) RbspSize() int

RbspSize return nalu rbr bytes count

func (*Nalu) Type

func (nl *Nalu) Type() NaluType

Type return nalu type

type NaluType

type NaluType uint8

NaluType of h264 codec

const (
	NaluUnspecified NaluType = 0
	// Coded slice of a non-IDR picture
	NaluSlice NaluType = 1
	// Coded slice data partition A
	NaluSliceDpa NaluType = 2
	// Coded slice data partition B
	NaluSliceDpb NaluType = 3
	// Coded slice data partition C
	NaluSliceDpc NaluType = 4
	// Coded slice of an IDR picture
	NaluSliceIdr NaluType = 5
	// Supplemental enhancement information (SEI)
	NaluSei NaluType = 6
	// Sequence parameter set
	NaluSps NaluType = 7
	// Picture parameter set
	NaluPps NaluType = 8
	// Access unit delimiter
	NaluAud NaluType = 9
	// End of sequence
	NaluEoseq NaluType = 10
	// End of stream
	NaluEostream NaluType = 11
	// Filler data
	NaluFiller NaluType = 12
)

ITU-T Rec. H.264 (05/2003) page 48 Table 7-1 – NAL unit type codes

func (NaluType) String

func (nt NaluType) String() string

type PPS

type PPS struct {
	Id                                    uint `json:"id"`
	SeqParameterSetId                     uint `json:"seq_parameter_set_id"`
	EntropyCodingModeFlag                 bool `json:"entropy_coding_mode_flag"`
	BottomFieldPicOrderInFramePresentFlag bool `json:"bottom_field_pic_order_in_frame_present_flag"`

	NumSliceGroupsMinus1          uint   `json:"num_slice_groups_minus_1"`
	SliceGroupMapType             uint   `json:"slice_group_map_type"`
	RunLengthMinus1               []uint `json:"run_length_minus_1"`
	TopLeft                       []uint `json:"top_left"`
	BottomRight                   []uint `json:"bottom_right"`
	SliceGroupChangeDirectionFlag bool   `json:"slice_group_change_direction_flag"`
	SliceGroupChangeRateMinus1    uint   `json:"slice_group_change_rate_minus_1"`
	PicSizeInMapUnitsMinus1       uint   `json:"pic_size_in_map_units_minus_1"`
	SliceGroupId                  []uint `json:"slice_group_id"`

	NumRefIdxL0DefaultActiveMinus1     uint  `json:"num_ref_idx_l_0_default_active_minus_1"`
	NumRefIdxL1DefaultActiveMinus1     uint  `json:"num_ref_idx_l_1_default_active_minus_1"`
	WeightedPredFlag                   bool  `json:"weighted_pred_flag"`
	WeightedBipredIdc                  uint8 `json:"weighted_bipred_idc"`
	PicInitQpMinus26                   int   `json:"pic_init_qp_minus_26"`
	PicInitQsMinus26                   int   `json:"pic_init_qs_minus_26"`
	ChromaQpIndexOffset                int   `json:"chroma_qp_index_offset"`
	DeblockingFilterControlPresentFlag bool  `json:"deblocking_filter_control_present_flag"`
	ConstrainedIntraPredFlag           bool  `json:"constrained_intra_pred_flag"`
	RedundantPicCntPresentFlag         bool  `json:"redundant_pic_cnt_present_flag"`

	Transform8X8ModeFlag        bool   `json:"transform_8_x_8_mode_flag"`
	PicScalingMatrixPresentFlag bool   `json:"pic_scaling_matrix_present_flag"`
	PicScalingListPresentFlag   []bool `json:"pic_scaling_list_present_flag"`
	SecondChromaQpIndexOffset   int    `json:"second_chroma_qp_index_offset"`
	// contains filtered or unexported fields
}

h264 picture parameters set T-REC-H.264-201402-S!!PDF-E.pdf 7.3.2.2 Picture parameter set RBSP syntax

func ParsePpsFromRBSP

func ParsePpsFromRBSP(rbsp []byte) (*PPS, error)

func (*PPS) Load

func (pps *PPS) Load(rbsp []byte) error

func (*PPS) String

func (pps *PPS) String() string

type SPS

type SPS struct {
	ProfileIdc         uint8
	ConstraintSet0Flag bool
	ConstraintSet1Flag bool
	ConstraintSet2Flag bool
	ConstraintSet3Flag bool
	ConstraintSet4Flag bool
	ConstraintSet5Flag bool

	LevelIdc uint8

	Id uint

	ChromaFormatIdc                 uint
	SeparateColourPlaneFlag         bool
	BitDepthLumaMinus8              uint
	BitDepthChromaMinus8            uint
	QpprimeYZeroTransformBypassFlag bool
	SeqScalingMatrixPresentFlag     bool
	SeqScalingListPresentFlag       []bool

	Log2MaxFrameNumMinus4          uint
	PicOrderCntType                uint
	Log2MaxPicOrderCntLsbMinus4L   uint
	DeltaPicOrderAlwaysZeroFlag    bool
	OffsetForNonRefPic             int
	OffsetForTopToBottomField      int
	NumRefFramesInPicOrderCntCycle uint
	OffsetForRefFrame              []int
	NumRefFrames                   uint

	GapsInFrameNumValueAllowedFlag bool
	PicWidthInMbsMinus1            uint
	PicHeightInMapUnitsMinus1      uint
	FrameMbsOnlyFlag               bool
	MbAdaptiveFrameFieldFlag       bool
	Direct8X8InferenceFlag         bool
	FrameCroppingFlag              bool
	FrameCrop                      FrameCrop
	VuiParametersPresentFlag       bool
	VuiParams                      VuiParameters
	// contains filtered or unexported fields
}

h264 sequence parameters set T-REC-H.264-201402-S!!PDF-E.pdf 7.3.2.1.1 Sequence parameter set data syntax

func ParseSpsFromRBSP

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

func (*SPS) Load

func (sps *SPS) Load(rbsp []byte) error

ITU-T Recommendation H.264(200305)

func (*SPS) String

func (sps *SPS) String() string

type VuiParameters

type VuiParameters struct {
	AspectRatioInfoPresentFlag bool
	AspectRatioIdc             uint8
	SarWidth                   uint16
	SarHeight                  uint16

	OverscanInfoPresentFlag      bool
	OverscanAppropriateFlag      bool
	VideoSignalTypePresentFlag   bool
	VideoFormat                  uint8
	VideoFullRangeFlag           bool
	ColourDescriptionPresentFlag bool
	ColourPrimaries              uint8
	TransferCharacteristics      uint8
	MatrixCoefficients           uint8

	ChromaLocInfoPresentFlag       bool
	ChromaSampleLocTypeTopField    uint
	ChromaSampleLocTypeBottomField uint

	TimingInfoPresentFlag bool
	NumUnitsInTick        uint32
	TimeScale             uint32
	FixedFrameRateFlag    bool

	NalHrdParametersPresentFlag bool
	VclHrdParametersPresentFlag bool
	HrdParameters               HrdParameters
	LowDelayHrdFlag             bool

	PicStructPresentFlag               bool
	BitstreamRestrictionFlag           bool
	MotionVectorsOverPicBoundariesFlag bool
	MaxBytesPerPicDenom                uint
	MaxBitsPerMbDenom                  uint
	Log2MaxMvLengthHorizontal          uint
	Log2MaxMvLengthVertical            uint
	MaxNumReorderFrames                uint
	MaxDecFrameBuffering               uint
}

T-REC-H.264-201402-S!!PDF-E.pdf Annex E.1.1 VUI parameters syntax

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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