avc

package
v0.19.4 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NALUTypeSlice    uint8 = 1
	NALUTypeIDRSlice uint8 = 5
	NALUTypeSEI      uint8 = 6
	NALUTypeSPS      uint8 = 7
	NALUTypePPS      uint8 = 8
	NALUTypeAUD      uint8 = 9 // Access Unit Delimiter
)
View Source
const (
	SliceTypeP  uint8 = 0
	SliceTypeB  uint8 = 1
	SliceTypeI  uint8 = 2
	SliceTypeSP uint8 = 3
	SliceTypeSI uint8 = 4
)

Variables

View Source
var (
	NALUStartCode3 = []byte{0x0, 0x0, 0x1}
	NALUStartCode4 = []byte{0x0, 0x0, 0x0, 0x1}
)
View Source
var ErrAVC = errors.New("lal.avc: fxxk")
View Source
var NALUTypeMapping = map[uint8]string{
	1: "SLICE",
	5: "IDR",
	6: "SEI",
	7: "SPS",
	8: "PPS",
	9: "AUD",
}
View Source
var SliceTypeMapping = map[uint8]string{
	0: "P",
	1: "B",
	2: "I",
	3: "SP",
	4: "SI",
	5: "P",
	6: "B",
	7: "I",
	8: "SP",
	9: "SI",
}

Functions

func BuildSeqHeaderFromSPSPPS

func BuildSeqHeaderFromSPSPPS(sps, pps []byte) ([]byte, error)

返回的内存块为新申请的独立内存块

func CaptureAVCC2AnnexB

func CaptureAVCC2AnnexB(w io.Writer, payload []byte) error

AVCC -> AnnexB

@param <payload> rtmp message的payload部分或者flv tag的payload部分

注意,包含了头部2字节类型以及3字节的cts

func ParseNALUType

func ParseNALUType(v uint8) uint8

func ParseNALUTypeReadable

func ParseNALUTypeReadable(v uint8) string

func ParseSPS

func ParseSPS(payload []byte, ctx *Context) error

func ParseSPSPPSFromSeqHeader

func ParseSPSPPSFromSeqHeader(payload []byte) (sps, pps []byte, err error)

从AVCC格式的Seq Header中得到SPS和PPS内存块

@param <payload> rtmp message的payload部分或者flv tag的payload部分

注意,包含了头部2字节类型以及3字节的cts

@return 注意,返回的sps,pps内存块指向的是传入参数<payload>内存块的内存

func ParseSliceType

func ParseSliceType(nalu []byte) (uint8, error)

func ParseSliceTypeReadable

func ParseSliceTypeReadable(nalu []byte) (string, error)

func SPSPPSSeqHeader2AnnexB

func SPSPPSSeqHeader2AnnexB(payload []byte) ([]byte, error)

AVCC Seq Header -> AnnexB 注意,返回的内存块为独立的内存块,不依赖指向传输参数<payload>内存块

func TryParsePPS

func TryParsePPS(payload []byte) error

尝试解析PPS所有字段,实验中,请勿直接使用该函数

func TryParseSeqHeader

func TryParseSeqHeader(payload []byte) error

尝试解析SeqHeader所有字段,实验中,请勿直接使用该函数

@param <payload> rtmp message的payload部分或者flv tag的payload部分

注意,包含了头部2字节类型以及3字节的cts

Types

type Context

type Context struct {
	Profile uint8
	Level   uint8
	Width   uint32
	Height  uint32
}

type DecoderConfigurationRecord

type DecoderConfigurationRecord struct {
	ConfigurationVersion uint8
	AVCProfileIndication uint8
	ProfileCompatibility uint8
	AVCLevelIndication   uint8
	LengthSizeMinusOne   uint8
	NumOfSPS             uint8
	SPSLength            uint16
	NumOfPPS             uint8
	PPSLength            uint16
}

H.264-AVC-ISO_IEC_14496-15.pdf 5.2.4 Decoder configuration information

type SPS

type SPS struct {
	ProfileIdc                     uint8
	ConstraintSet0Flag             uint8
	ConstraintSet1Flag             uint8
	ConstraintSet2Flag             uint8
	LevelIdc                       uint8
	SPSId                          uint32
	ChromaFormatIdc                uint32
	ResidualColorTransformFlag     uint8
	BitDepthLuma                   uint32
	BitDepthChroma                 uint32
	TransFormBypass                uint8
	Log2MaxFrameNumMinus4          uint32
	PicOrderCntType                uint32
	Log2MaxPicOrderCntLsb          uint32
	NumRefFrames                   uint32 // num_ref_frames
	GapsInFrameNumValueAllowedFlag uint8  // gaps_in_frame_num_value_allowed_flag
	PicWidthInMbsMinusOne          uint32 // pic_width_in_mbs_minus1
	PicHeightInMapUnitsMinusOne    uint32 // pic_height_in_map_units_minus1
	FrameMbsOnlyFlag               uint8  // frame_mbs_only_flag
	MbAdaptiveFrameFieldFlag       uint8  // mb_adaptive_frame_field_flag
	Direct8X8InferenceFlag         uint8  // direct_8x8_inference_flag
	FrameCroppingFlag              uint8  // frame_cropping_flag
	FrameCropLeftOffset            uint32 // frame_crop_left_offset
	FrameCropRightOffset           uint32 // frame_crop_right_offset
	FrameCropTopOffset             uint32 // frame_crop_top_offset
	FrameCropBottomOffset          uint32 // frame_crop_bottom_offset
}

ISO-14496-10.pdf 7.3.2.1 Sequence parameter set RBSP syntax 7.4.2.1 Sequence parameter set RBSP semantics

Jump to

Keyboard shortcuts

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