codec

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VERSION_RESERVED = 0
	VERSION_MPEG_1   = 1
	VERSION_MPEG_2   = 2
	VERSION_MPEG_2_5 = 3
)
View Source
const (
	LAYER_RESERVED = 0
	LAYER_1        = 1
	LAYER_2        = 2
	LAYER_3        = 3
)
View Source
const (
	LEFT_CHANNEL  = 0
	RIGHT_CHANNEL = 1
)

Variables

View Source
var (
	/// 10ms,20ms,40ms,60ms, samplerate 48000
	//  sample num per millisecond
	//  48000 / 1000ms * 10 = 480 ...
	SLKOpusSampleSize    [4]int = [4]int{480, 960, 1920, 2880}
	HybridOpusSampleSize [4]int = [4]int{480, 960}
	CELTOpusSampleSize   [4]int = [4]int{120, 210, 480, 960}
)
View Source
var AAC_Sampling_Idx [13]int = [13]int{96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350}
View Source
var BitMask [8]byte = [8]byte{0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF}
View Source
var BitRateTable [2][3][16]int = [2][3][16]int{
	{
		{0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, -1},
		{0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 380, -1},
		{0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -1},
	},
	{
		{0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, -1},
		{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, -1},
		{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, -1},
	},
}

ffmpeg mpegaudiotabs.h ff_mpa_bitrate_tab

View Source
var SampleRateTable [3][4]int = [3][4]int{
	{44100, 48000, 32000, 0},
	{22050, 24000, 16000, 0},
	{11025, 12000, 8000, 0},
}

Functions

func AACSampleIdxToSample

func AACSampleIdxToSample(idx int) int

func CalcCrc32

func CalcCrc32(crc uint32, buffer []byte) uint32

func CodecString

func CodecString(codecid CodecID) string

func ConvertAnnexBToAVCC

func ConvertAnnexBToAVCC(annexb []byte) []byte

func CovertAVCCToAnnexB

func CovertAVCCToAnnexB(avcc []byte)

func CovertExtradata

func CovertExtradata(extraData []byte) ([][]byte, [][]byte)

func CovertRbspToSodb

func CovertRbspToSodb(rbsp []byte) []byte

func CreateH264AVCCExtradata

func CreateH264AVCCExtradata(spss [][]byte, ppss [][]byte) ([]byte, error)

func FindSyncword

func FindSyncword(aac []byte, offset int) int

func GetH264FirstMbInSlice

func GetH264FirstMbInSlice(nalu []byte) uint64

func GetH264Resolution

func GetH264Resolution(sps []byte) (width uint32, height uint32)

https://stackoverflow.com/questions/12018535/get-the-width-height-of-the-video-from-h-264-nalu int Width = ((pic_width_in_mbs_minus1 +1)*16) - frame_crop_right_offset *2 - frame_crop_left_offset *2; int Height = ((2 - frame_mbs_only_flag)* (pic_height_in_map_units_minus1 +1) * 16) - (frame_crop_bottom_offset* 2) - (frame_crop_top_offset* 2);

func GetH265FirstMbInSlice

func GetH265FirstMbInSlice(nalu []byte) uint64

func GetH265PPSId

func GetH265PPSId(pps []byte) uint64

func GetH265PPSIdWithStartCode

func GetH265PPSIdWithStartCode(pps []byte) uint64

func GetH265Resolution

func GetH265Resolution(sps []byte) (width uint32, height uint32)

func GetH265SPSId

func GetH265SPSId(sps []byte) uint64

func GetH265SPSIdWithStartCode

func GetH265SPSIdWithStartCode(sps []byte) uint64

func GetPPSId

func GetPPSId(pps []byte) uint64

func GetPPSIdWithStartCode

func GetPPSIdWithStartCode(pps []byte) uint64

func GetSPSId

func GetSPSId(sps []byte) uint64

func GetSPSIdWithStartCode

func GetSPSIdWithStartCode(sps []byte) uint64

func GetVPSId

func GetVPSId(vps []byte) uint8

func GetVPSIdWithStartCode

func GetVPSIdWithStartCode(vps []byte) uint8

func IsH264IDRFrame

func IsH264IDRFrame(h264 []byte) bool

func IsH264VCLNaluType

func IsH264VCLNaluType(nal_type H264_NAL_TYPE) bool

func IsH265IDRFrame

func IsH265IDRFrame(h265 []byte) bool

func IsH265VCLNaluType

func IsH265VCLNaluType(nal_type H265_NAL_TYPE) bool

func Max

func Max(x, y int) int

func Min

func Min(x, y int) int

func OpusPacketDuration

func OpusPacketDuration(packet []byte) uint64

func SampleToAACSampleIndex

func SampleToAACSampleIndex(sampling int) int

func ShowPacketHexdump

func ShowPacketHexdump(data []byte)

func SplitAACFrame

func SplitAACFrame(frames []byte, onFrame func(aac []byte))

func SplitFrame

func SplitFrame(frames []byte, onFrame func(nalu []byte) bool)

func SplitFrameWithStartCode

func SplitFrameWithStartCode(frames []byte, onFrame func(nalu []byte) bool)

func SplitMp3Frames

func SplitMp3Frames(data []byte, onFrame func(head *MP3FrameHead, frame []byte)) error

func WriteDefaultOpusExtraData

func WriteDefaultOpusExtraData() []byte

Types

type AAC_PROFILE

type AAC_PROFILE int
const (
	MAIN AAC_PROFILE = iota
	LC
	SSR
)

type AAC_SAMPLING_FREQUENCY

type AAC_SAMPLING_FREQUENCY int
const (
	AAC_SAMPLE_96000 AAC_SAMPLING_FREQUENCY = iota
	AAC_SAMPLE_88200
	AAC_SAMPLE_64000
	AAC_SAMPLE_48000
	AAC_SAMPLE_44100
	AAC_SAMPLE_32000
	AAC_SAMPLE_24000
	AAC_SAMPLE_22050
	AAC_SAMPLE_16000
	AAC_SAMPLE_12000
	AAC_SAMPLE_11025
	AAC_SAMPLE_8000
	AAC_SAMPLE_7350
)

type ADTS_Fix_Header

type ADTS_Fix_Header struct {
	ID                       uint8
	Layer                    uint8
	Protection_absent        uint8
	Profile                  uint8
	Sampling_frequency_index uint8
	Private_bit              uint8
	Channel_configuration    uint8
	Originalorcopy           uint8
	Home                     uint8
}

type ADTS_Frame_Header

type ADTS_Frame_Header struct {
	Fix_Header      ADTS_Fix_Header
	Variable_Header ADTS_Variable_Header
}

func ConvertASCToADTS

func ConvertASCToADTS(asc []byte, aacbytes int) (*ADTS_Frame_Header, error)

func NewAdtsFrameHeader

func NewAdtsFrameHeader() *ADTS_Frame_Header

func (*ADTS_Frame_Header) Decode

func (frame *ADTS_Frame_Header) Decode(aac []byte)

func (*ADTS_Frame_Header) Encode

func (frame *ADTS_Frame_Header) Encode() []byte

type ADTS_Variable_Header

type ADTS_Variable_Header struct {
	Copyright_identification_bit uint8

	Frame_length                       uint16
	Adts_buffer_fullness               uint16
	Number_of_raw_data_blocks_in_frame uint8
	// contains filtered or unexported fields
}

type AudioSpecificConfiguration

type AudioSpecificConfiguration struct {
	Audio_object_type        uint8
	Sample_freq_index        uint8
	Channel_configuration    uint8
	GA_framelength_flag      uint8
	GA_depends_on_core_coder uint8
	GA_extension_flag        uint8
}

func ConvertADTSToASC

func ConvertADTSToASC(frame []byte) (*AudioSpecificConfiguration, error)

func NewAudioSpecificConfiguration

func NewAudioSpecificConfiguration() *AudioSpecificConfiguration

func (*AudioSpecificConfiguration) Decode

func (asc *AudioSpecificConfiguration) Decode(buf []byte) error

func (*AudioSpecificConfiguration) Encode

func (asc *AudioSpecificConfiguration) Encode() []byte

type BitStream

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

func NewBitStream

func NewBitStream(buf []byte) *BitStream

func (*BitStream) Bits

func (bs *BitStream) Bits() []byte

func (*BitStream) ByteOffset

func (bs *BitStream) ByteOffset() int

func (*BitStream) DistanceFromMarkDot

func (bs *BitStream) DistanceFromMarkDot() int

func (*BitStream) EOS

func (bs *BitStream) EOS() bool

func (*BitStream) GetBit

func (bs *BitStream) GetBit() uint8

func (*BitStream) GetBits

func (bs *BitStream) GetBits(n int) uint64

n <= 64

func (*BitStream) GetBytes

func (bs *BitStream) GetBytes(n int) []byte

func (*BitStream) Markdot

func (bs *BitStream) Markdot()

func (*BitStream) NextBits

func (bs *BitStream) NextBits(n int) uint64

func (*BitStream) ReadSE

func (bs *BitStream) ReadSE() int64

有符号哥伦布熵编码

func (*BitStream) ReadUE

func (bs *BitStream) ReadUE() uint64

无符号哥伦布熵编码

func (*BitStream) RemainBits

func (bs *BitStream) RemainBits() int

func (*BitStream) RemainBytes

func (bs *BitStream) RemainBytes() int

func (*BitStream) RemainData

func (bs *BitStream) RemainData() []byte

func (*BitStream) SkipBits

func (bs *BitStream) SkipBits(n int)

func (*BitStream) Uint16

func (bs *BitStream) Uint16(n int) uint16

func (*BitStream) Uint32

func (bs *BitStream) Uint32(n int) uint32

func (*BitStream) Uint8

func (bs *BitStream) Uint8(n int) uint8

func (*BitStream) UnRead

func (bs *BitStream) UnRead(n int)

type BitStreamWriter

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

func NewBitStreamWriter

func NewBitStreamWriter(n int) *BitStreamWriter

func (*BitStreamWriter) BitOffset

func (bsw *BitStreamWriter) BitOffset() int

func (*BitStreamWriter) Bits

func (bsw *BitStreamWriter) Bits() []byte

func (*BitStreamWriter) ByteOffset

func (bsw *BitStreamWriter) ByteOffset() int

func (*BitStreamWriter) DistanceFromMarkDot

func (bsw *BitStreamWriter) DistanceFromMarkDot() int

func (*BitStreamWriter) FillRemainData

func (bsw *BitStreamWriter) FillRemainData(v byte)

用v 填充剩余字节

func (*BitStreamWriter) Markdot

func (bsw *BitStreamWriter) Markdot()

func (*BitStreamWriter) PutByte

func (bsw *BitStreamWriter) PutByte(v byte)

func (*BitStreamWriter) PutBytes

func (bsw *BitStreamWriter) PutBytes(v []byte)

func (*BitStreamWriter) PutRepetValue

func (bsw *BitStreamWriter) PutRepetValue(v byte, n int)

func (*BitStreamWriter) PutUint16

func (bsw *BitStreamWriter) PutUint16(v uint16, n int)

func (*BitStreamWriter) PutUint32

func (bsw *BitStreamWriter) PutUint32(v uint32, n int)

func (*BitStreamWriter) PutUint64

func (bsw *BitStreamWriter) PutUint64(v uint64, n int)

func (*BitStreamWriter) PutUint8

func (bsw *BitStreamWriter) PutUint8(v uint8, n int)

func (*BitStreamWriter) Reset

func (bsw *BitStreamWriter) Reset()

func (*BitStreamWriter) SetByte

func (bsw *BitStreamWriter) SetByte(v byte, where int)

func (*BitStreamWriter) SetUint16

func (bsw *BitStreamWriter) SetUint16(v uint16, where int)

type ChannelMap

type ChannelMap struct {
	StreamIdx  int
	ChannelIdx int
	Silence    bool
	Copy       bool
	CopyFrom   int
}

type ChannelOrder

type ChannelOrder func(channels int, idx int) int

type CodecID

type CodecID int
const (
	CODECID_VIDEO_H264 CodecID = iota
	CODECID_VIDEO_H265
	CODECID_VIDEO_VP8

	CODECID_AUDIO_AAC CodecID = iota + 98
	CODECID_AUDIO_G711A
	CODECID_AUDIO_G711U
	CODECID_AUDIO_OPUS
	CODECID_AUDIO_MP3

	CODECID_UNRECOGNIZED = 999
)

type H264NaluHdr

type H264NaluHdr struct {
	Forbidden_zero_bit uint8
	Nal_ref_idc        uint8
	Nal_unit_type      uint8
}

func (*H264NaluHdr) Decode

func (hdr *H264NaluHdr) Decode(bs *BitStream)

type H264_NAL_TYPE

type H264_NAL_TYPE int
const (
	H264_NAL_RESERVED H264_NAL_TYPE = iota
	H264_NAL_P_SLICE
	H264_NAL_SLICE_A
	H264_NAL_SLICE_B
	H264_NAL_SLICE_C
	H264_NAL_I_SLICE
	H264_NAL_SEI
	H264_NAL_SPS
	H264_NAL_PPS
	H264_NAL_AUD
)

func H264NaluType

func H264NaluType(h264 []byte) H264_NAL_TYPE

func H264NaluTypeWithoutStartCode

func H264NaluTypeWithoutStartCode(h264 []byte) H264_NAL_TYPE

type H265NaluHdr

type H265NaluHdr struct {
	Forbidden_zero_bit    uint8
	Nal_unit_type         uint8
	Nuh_layer_id          uint8
	Nuh_temporal_id_plus1 uint8
}

func (*H265NaluHdr) Decode

func (hdr *H265NaluHdr) Decode(bs *BitStream)

type H265RawPPS

type H265RawPPS struct {
	Pps_pic_parameter_set_id                 uint64
	Pps_seq_parameter_set_id                 uint64
	Dependent_slice_segments_enabled_flag    uint8
	Output_flag_present_flag                 uint8
	Num_extra_slice_header_bits              uint8
	Sign_data_hiding_enabled_flag            uint8
	Cabac_init_present_flag                  uint8
	Num_ref_idx_l0_default_active_minus1     uint64
	Num_ref_idx_l1_default_active_minus1     uint64
	Init_qp_minus26                          int64
	Constrained_intra_pred_flag              uint8
	Transform_skip_enabled_flag              uint8
	Cu_qp_delta_enabled_flag                 uint8
	Diff_cu_qp_delta_depth                   uint64
	Pps_cb_qp_offset                         int64
	Pps_cr_qp_offset                         int64
	Pps_slice_chroma_qp_offsets_present_flag uint8
	Weighted_pred_flag                       uint8
	Weighted_bipred_flag                     uint8
	Transquant_bypass_enabled_flag           uint8
	Tiles_enabled_flag                       uint8
	Entropy_coding_sync_enabled_flag         uint8
}

func (*H265RawPPS) Decode

func (pps *H265RawPPS) Decode(nalu []byte)

nalu without startcode

type H265RawSPS

type H265RawSPS struct {
	Sps_video_parameter_set_id               uint8
	Sps_max_sub_layers_minus1                uint8
	Sps_temporal_id_nesting_flag             uint8
	Ptl                                      ProfileTierLevel
	Sps_seq_parameter_set_id                 uint64
	Chroma_format_idc                        uint64
	Pic_width_in_luma_samples                uint64
	Pic_height_in_luma_samples               uint64
	Conformance_window_flag                  uint8
	Conf_win_left_offset                     uint64
	Conf_win_right_offset                    uint64
	Conf_win_top_offset                      uint64
	Conf_win_bottom_offset                   uint64
	Bit_depth_luma_minus8                    uint64
	Bit_depth_chroma_minus8                  uint64
	Log2_max_pic_order_cnt_lsb_minus4        uint64
	Sps_sub_layer_ordering_info_present_flag uint8
	Vui_parameters_present_flag              uint8
	Vui                                      VUI_Parameters
}

func (*H265RawSPS) Decode

func (sps *H265RawSPS) Decode(nalu []byte)

nalu without startcode

type H265_NAL_TYPE

type H265_NAL_TYPE int
const (
	H265_NAL_Slice_TRAIL_N H265_NAL_TYPE = iota
	H265_NAL_LICE_TRAIL_R
	H265_NAL_SLICE_TSA_N
	H265_NAL_SLICE_TSA_R
	H265_NAL_SLICE_STSA_N
	H265_NAL_SLICE_STSA_R
	H265_NAL_SLICE_RADL_N
	H265_NAL_SLICE_RADL_R
	H265_NAL_SLICE_RASL_N
	H265_NAL_SLICE_RASL_R

	//IDR
	H265_NAL_SLICE_BLA_W_LP H265_NAL_TYPE = iota + 6
	H265_NAL_SLICE_BLA_W_RADL
	H265_NAL_SLICE_BLA_N_LP
	H265_NAL_SLICE_IDR_W_RADL
	H265_NAL_SLICE_IDR_N_LP
	H265_NAL_SLICE_CRA

	//vps pps sps
	H265_NAL_VPS H265_NAL_TYPE = iota + 16
	H265_NAL_SPS
	H265_NAL_PPS
	H265_NAL_AUD

	//SEI
	H265_NAL_SEI H265_NAL_TYPE = iota + 19
	H265_NAL_SEI_SUFFIX
)

func H265NaluType

func H265NaluType(h265 []byte) H265_NAL_TYPE

func H265NaluTypeWithoutStartCode

func H265NaluTypeWithoutStartCode(h265 []byte) H265_NAL_TYPE

type HEVCRecordConfiguration

type HEVCRecordConfiguration struct {
	ConfigurationVersion                uint8
	General_profile_space               uint8
	General_tier_flag                   uint8
	General_profile_idc                 uint8
	General_profile_compatibility_flags uint32
	General_constraint_indicator_flags  uint64
	General_level_idc                   uint8
	Min_spatial_segmentation_idc        uint16
	ParallelismType                     uint8
	ChromaFormat                        uint8
	BitDepthLumaMinus8                  uint8
	BitDepthChromaMinus8                uint8
	AvgFrameRate                        uint16
	ConstantFrameRate                   uint8
	NumTemporalLayers                   uint8
	TemporalIdNested                    uint8
	LengthSizeMinusOne                  uint8
	NumOfArrays                         uint8
	Arrays                              []*HVCCNALUnitArray
}

func NewHEVCRecordConfiguration

func NewHEVCRecordConfiguration() *HEVCRecordConfiguration

func (*HEVCRecordConfiguration) Decode

func (hvcc *HEVCRecordConfiguration) Decode(hevc []byte)

func (*HEVCRecordConfiguration) Encode

func (hvcc *HEVCRecordConfiguration) Encode() ([]byte, error)

func (*HEVCRecordConfiguration) ToNalus

func (hvcc *HEVCRecordConfiguration) ToNalus() (nalus []byte)

func (*HEVCRecordConfiguration) UpdatePPS

func (hvcc *HEVCRecordConfiguration) UpdatePPS(pps []byte)

func (*HEVCRecordConfiguration) UpdateSPS

func (hvcc *HEVCRecordConfiguration) UpdateSPS(sps []byte)

func (*HEVCRecordConfiguration) UpdateVPS

func (hvcc *HEVCRecordConfiguration) UpdateVPS(vps []byte)

type HVCCNALUnitArray

type HVCCNALUnitArray struct {
	Array_completeness uint8
	NAL_unit_type      uint8
	NumNalus           uint16
	NalUnits           []*NalUnit
}

type ID3V2

type ID3V2 struct {
	Ver      uint8
	Revision uint8
	Flag     uint8
	Size     uint32
}

type MP3FrameHead

type MP3FrameHead struct {
	Version         uint8
	Layer           uint8
	Protecttion     uint8
	BitrateIndex    uint8
	SampleRateIndex uint8
	Padding         uint8
	Private         uint8
	Mode            uint8
	ModeExtension   uint8
	Copyright       uint8
	Original        uint8
	Emphasis        uint8
	SampleSize      int
	FrameSize       int
}

func DecodeMp3Head

func DecodeMp3Head(data []byte) (*MP3FrameHead, error)

func (*MP3FrameHead) GetBitRate

func (mp3 *MP3FrameHead) GetBitRate() int

func (*MP3FrameHead) GetChannelCount

func (mp3 *MP3FrameHead) GetChannelCount() int

func (*MP3FrameHead) GetSampleRate

func (mp3 *MP3FrameHead) GetSampleRate() int

type NalUnit

type NalUnit struct {
	NalUnitLength uint16
	Nalu          []byte
}

type OpusContext

type OpusContext struct {
	Preskip           int
	SampleRate        int
	ChannelCount      int
	StreamCount       int
	StereoStreamCount int
	OutputGain        uint16
	MapType           uint8
	Channel           []byte
	ChannelMaps       []ChannelMap
}

func (*OpusContext) ParseExtranData

func (ctx *OpusContext) ParseExtranData(extraData []byte) error
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
                                               +-+-+-+-+-+-+-+-+
                                               | Stream Count  |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Coupled Count | Channel Mapping... : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func (*OpusContext) WriteOpusExtraData

func (ctx *OpusContext) WriteOpusExtraData() []byte

type OpusPacket

type OpusPacket struct {
	Code       int
	Config     int
	Stereo     int
	Vbr        int
	FrameCount int
	FrameLen   []uint16
	Frame      []byte
	Duration   uint64
}

ffmpeg opus.h OpusPacket

func DecodeOpusPacket

func DecodeOpusPacket(packet []byte) *OpusPacket

type PPS

type PPS struct {
	Pic_parameter_set_id                         uint64
	Seq_parameter_set_id                         uint64
	Entropy_coding_mode_flag                     uint8
	Bottom_field_pic_order_in_frame_present_flag uint8
	Num_slice_groups_minus1                      uint64
}

func (*PPS) Decode

func (pps *PPS) Decode(bs *BitStream)

type ProfileTierLevel

type ProfileTierLevel struct {
	General_profile_space              uint8
	General_tier_flag                  uint8
	General_profile_idc                uint8
	General_profile_compatibility_flag uint32
	General_constraint_indicator_flag  uint64
	General_level_idc                  uint8
	Sub_layer_profile_present_flag     [8]uint8
	Sub_layer_level_present_flag       [8]uint8
}

func Profile_tier_level

func Profile_tier_level(profilePresentFlag uint8, maxNumSubLayersMinus1 uint8, bs *BitStream) ProfileTierLevel

ffmpeg hevc.c static void hvcc_parse_ptl(GetBitContext *gb,HEVCDecoderConfigurationRecord *hvcc,unsigned int max_sub_layers_minus1)

type SEI

type SEI struct {
	PayloadType uint16
	PayloadSize uint16
	Sei_payload SEIReaderWriter
}

func (*SEI) Decode

func (sei *SEI) Decode(bs *BitStream)

func (*SEI) Encode

func (sei *SEI) Encode(bsw *BitStreamWriter) []byte

type SEIReaderWriter

type SEIReaderWriter interface {
	Read(size uint16, bs *BitStream)
	Write(bsw *BitStreamWriter)
}

type SPS

type SPS struct {
	Profile_idc                          uint8
	Constraint_set0_flag                 uint8
	Constraint_set1_flag                 uint8
	Constraint_set2_flag                 uint8
	Constraint_set3_flag                 uint8
	Constraint_set4_flag                 uint8
	Constraint_set5_flag                 uint8
	Reserved_zero_2bits                  uint8
	Level_idc                            uint8
	Seq_parameter_set_id                 uint64
	Chroma_format_idc                    uint64
	Separate_colour_plane_flag           uint8
	Bit_depth_luma_minus8                uint64
	Bit_depth_chroma_minus8              uint64
	Log2_max_frame_num_minus4            uint64
	Pic_order_cnt_type                   uint64
	Max_num_ref_frames                   uint64
	Gaps_in_frame_num_value_allowed_flag uint8
	Pic_width_in_mbs_minus1              uint64
	Pic_height_in_map_units_minus1       uint64
	Frame_mbs_only_flag                  uint8
	Direct_8x8_inference_flag            uint8
	Frame_cropping_flag                  uint8
	Frame_crop_left_offset               uint64
	Frame_crop_right_offset              uint64
	Frame_crop_top_offset                uint64
	Frame_crop_bottom_offset             uint64
	Vui_parameters_present_flag          uint8
}

func (*SPS) Decode

func (sps *SPS) Decode(bs *BitStream)

type START_CODE_TYPE

type START_CODE_TYPE int
const (
	START_CODE_3 START_CODE_TYPE = 3
	START_CODE_4 START_CODE_TYPE = 4
)

func FindStartCode

func FindStartCode(nalu []byte, offset int) (int, START_CODE_TYPE)

type SliceHeader

type SliceHeader struct {
	First_mb_in_slice    uint64
	Slice_type           uint64
	Pic_parameter_set_id uint64
	Frame_num            uint64
}

func (*SliceHeader) Decode

func (sh *SliceHeader) Decode(bs *BitStream)

调用方根据sps中的log2_max_frame_num_minus4的值来解析Frame_num

type UserDataUnregistered

type UserDataUnregistered struct {
	UUID     []byte
	UserData []byte
}

func (*UserDataUnregistered) Read

func (udu *UserDataUnregistered) Read(size uint16, bs *BitStream)

func (*UserDataUnregistered) Write

func (udu *UserDataUnregistered) Write(bsw *BitStreamWriter)

type VPS

type VPS struct {
	Vps_video_parameter_set_id               uint8
	Vps_base_layer_internal_flag             uint8
	Vps_base_layer_available_flag            uint8
	Vps_max_layers_minus1                    uint8
	Vps_max_sub_layers_minus1                uint8
	Vps_temporal_id_nesting_flag             uint8
	Vps_reserved_0xffff_16bits               uint16
	Ptl                                      ProfileTierLevel
	Vps_sub_layer_ordering_info_present_flag uint8
	Vps_max_dec_pic_buffering_minus1         [8]uint64
	Vps_max_num_reorder_pics                 [8]uint64
	Vps_max_latency_increase_plus1           [8]uint64
	Vps_max_layer_id                         uint8
	Vps_num_layer_sets_minus1                uint64
	Layer_id_included_flag                   [][]uint8
	Vps_timing_info_present_flag             uint8
	TimeInfo                                 VPSTimeInfo
}

func (*VPS) Decode

func (vps *VPS) Decode(nalu []byte)

nalu without startcode

type VPSTimeInfo

type VPSTimeInfo struct {
	Vps_num_units_in_tick               uint32
	Vps_time_scale                      uint32
	Vps_poc_proportional_to_timing_flag uint8
	Vps_num_ticks_poc_diff_one_minus1   uint64
	Vps_num_hrd_parameters              uint64
	Hrd_layer_set_idx                   []uint64
	Cprms_present_flag                  []uint8
}

func ParserVPSTimeinfo

func ParserVPSTimeinfo(bs *BitStream) VPSTimeInfo

type VUI_Parameters

type VUI_Parameters struct {
	Aspect_ratio_info_present_flag          uint8
	Overscan_info_present_flag              uint8
	Chroma_loc_info_present_flag            uint8
	Neutral_chroma_indication_flag          uint8
	Field_seq_flag                          uint8
	Frame_field_info_present_flag           uint8
	Default_display_window_flag             uint8
	Vui_timing_info_present_flag            uint8
	Vui_num_units_in_tick                   uint32
	Vui_time_scale                          uint32
	Vui_poc_proportional_to_timing_flag     uint8
	Vui_hrd_parameters_present_flag         uint8
	Bitstream_restriction_flag              uint8
	Tiles_fixed_structure_flag              uint8
	Motion_vectors_over_pic_boundaries_flag uint8
	Restricted_ref_pic_lists_flag           uint8
	Min_spatial_segmentation_idc            uint64
	Max_bytes_per_pic_denom                 uint64
	Max_bits_per_min_cu_denom               uint64
	Log2_max_mv_length_horizontal           uint64
	Log2_max_mv_length_vertical             uint64
}

func (*VUI_Parameters) Decode

func (vui *VUI_Parameters) Decode(bs *BitStream, max_sub_layers_minus1 uint8)

Jump to

Keyboard shortcuts

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