Documentation
¶
Index ¶
- Constants
- Variables
- func AACSampleIdxToSample(idx int) int
- func CalcCrc32(crc uint32, buffer []byte) uint32
- func CodecString(codecid CodecID) string
- func ConvertAnnexBToAVCC(annexb []byte) []byte
- func CovertAVCCToAnnexB(avcc []byte)
- func CovertExtradata(extraData []byte) ([][]byte, [][]byte)
- func CovertRbspToSodb(rbsp []byte) []byte
- func CreateH264AVCCExtradata(spss [][]byte, ppss [][]byte) ([]byte, error)
- func FindSyncword(aac []byte, offset int) int
- func GetH264FirstMbInSlice(nalu []byte) uint64
- func GetH264Resolution(sps []byte) (width uint32, height uint32)
- func GetH265FirstMbInSlice(nalu []byte) uint64
- func GetH265PPSId(pps []byte) uint64
- func GetH265PPSIdWithStartCode(pps []byte) uint64
- func GetH265Resolution(sps []byte) (width uint32, height uint32)
- func GetH265SPSId(sps []byte) uint64
- func GetH265SPSIdWithStartCode(sps []byte) uint64
- func GetPPSId(pps []byte) uint64
- func GetPPSIdWithStartCode(pps []byte) uint64
- func GetSPSId(sps []byte) uint64
- func GetSPSIdWithStartCode(sps []byte) uint64
- func GetVPSId(vps []byte) uint8
- func GetVPSIdWithStartCode(vps []byte) uint8
- func IsH264IDRFrame(h264 []byte) bool
- func IsH264VCLNaluType(nal_type H264_NAL_TYPE) bool
- func IsH265IDRFrame(h265 []byte) bool
- func IsH265VCLNaluType(nal_type H265_NAL_TYPE) bool
- func Max(x, y int) int
- func Min(x, y int) int
- func OpusPacketDuration(packet []byte) uint64
- func SampleToAACSampleIndex(sampling int) int
- func ShowPacketHexdump(data []byte)
- func SplitAACFrame(frames []byte, onFrame func(aac []byte))
- func SplitFrame(frames []byte, onFrame func(nalu []byte) bool)
- func SplitFrameWithStartCode(frames []byte, onFrame func(nalu []byte) bool)
- func SplitMp3Frames(data []byte, onFrame func(head *MP3FrameHead, frame []byte)) error
- func WriteDefaultOpusExtraData() []byte
- type AAC_PROFILE
- type AAC_SAMPLING_FREQUENCY
- type ADTS_Fix_Header
- type ADTS_Frame_Header
- type ADTS_Variable_Header
- type AudioSpecificConfiguration
- type BitStream
- func (bs *BitStream) Bits() []byte
- func (bs *BitStream) ByteOffset() int
- func (bs *BitStream) DistanceFromMarkDot() int
- func (bs *BitStream) EOS() bool
- func (bs *BitStream) GetBit() uint8
- func (bs *BitStream) GetBits(n int) uint64
- func (bs *BitStream) GetBytes(n int) []byte
- func (bs *BitStream) Markdot()
- func (bs *BitStream) NextBits(n int) uint64
- func (bs *BitStream) ReadSE() int64
- func (bs *BitStream) ReadUE() uint64
- func (bs *BitStream) RemainBits() int
- func (bs *BitStream) RemainBytes() int
- func (bs *BitStream) RemainData() []byte
- func (bs *BitStream) SkipBits(n int)
- func (bs *BitStream) Uint8(n int) uint8
- func (bs *BitStream) Uint16(n int) uint16
- func (bs *BitStream) Uint32(n int) uint32
- func (bs *BitStream) UnRead(n int)
- type BitStreamWriter
- func (bsw *BitStreamWriter) BitOffset() int
- func (bsw *BitStreamWriter) Bits() []byte
- func (bsw *BitStreamWriter) ByteOffset() int
- func (bsw *BitStreamWriter) DistanceFromMarkDot() int
- func (bsw *BitStreamWriter) FillRemainData(v byte)
- func (bsw *BitStreamWriter) Markdot()
- func (bsw *BitStreamWriter) PutByte(v byte)
- func (bsw *BitStreamWriter) PutBytes(v []byte)
- func (bsw *BitStreamWriter) PutRepetValue(v byte, n int)
- func (bsw *BitStreamWriter) PutUint8(v uint8, n int)
- func (bsw *BitStreamWriter) PutUint16(v uint16, n int)
- func (bsw *BitStreamWriter) PutUint32(v uint32, n int)
- func (bsw *BitStreamWriter) PutUint64(v uint64, n int)
- func (bsw *BitStreamWriter) Reset()
- func (bsw *BitStreamWriter) SetByte(v byte, where int)
- func (bsw *BitStreamWriter) SetUint16(v uint16, where int)
- type ChannelMap
- type ChannelOrder
- type CodecID
- type H264NaluHdr
- type H264_NAL_TYPE
- type H265NaluHdr
- type H265RawPPS
- type H265RawSPS
- type H265_NAL_TYPE
- type HEVCRecordConfiguration
- func (hvcc *HEVCRecordConfiguration) Decode(hevc []byte)
- func (hvcc *HEVCRecordConfiguration) Encode() ([]byte, error)
- func (hvcc *HEVCRecordConfiguration) ToNalus() (nalus []byte)
- func (hvcc *HEVCRecordConfiguration) UpdatePPS(pps []byte)
- func (hvcc *HEVCRecordConfiguration) UpdateSPS(sps []byte)
- func (hvcc *HEVCRecordConfiguration) UpdateVPS(vps []byte)
- type HVCCNALUnitArray
- type ID3V2
- type MP3FrameHead
- type NalUnit
- type OpusContext
- type OpusPacket
- type PPS
- type ProfileTierLevel
- type SEI
- type SEIReaderWriter
- type SPS
- type START_CODE_TYPE
- type SliceHeader
- type UserDataUnregistered
- type VPS
- type VPSTimeInfo
- type VUI_Parameters
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 CodecString ¶
func ConvertAnnexBToAVCC ¶
func CovertAVCCToAnnexB ¶
func CovertAVCCToAnnexB(avcc []byte)
func CovertExtradata ¶
func CovertRbspToSodb ¶
func CreateH264AVCCExtradata ¶
func FindSyncword ¶
func GetH264FirstMbInSlice ¶
func GetH264Resolution ¶
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 GetH265PPSId ¶
func GetH265Resolution ¶
func GetH265SPSId ¶
func GetPPSIdWithStartCode ¶
func GetSPSIdWithStartCode ¶
func GetVPSIdWithStartCode ¶
func IsH264IDRFrame ¶
func IsH264VCLNaluType ¶
func IsH264VCLNaluType(nal_type H264_NAL_TYPE) bool
func IsH265IDRFrame ¶
func IsH265VCLNaluType ¶
func IsH265VCLNaluType(nal_type H265_NAL_TYPE) bool
func OpusPacketDuration ¶
func SampleToAACSampleIndex ¶
func ShowPacketHexdump ¶
func ShowPacketHexdump(data []byte)
func SplitAACFrame ¶
func SplitFrame ¶
func SplitFrameWithStartCode ¶
func SplitMp3Frames ¶
func SplitMp3Frames(data []byte, onFrame func(head *MP3FrameHead, frame []byte)) error
func WriteDefaultOpusExtraData ¶
func WriteDefaultOpusExtraData() []byte
Types ¶
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_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 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 (*BitStream) ByteOffset ¶
func (*BitStream) DistanceFromMarkDot ¶
func (*BitStream) RemainBits ¶
func (*BitStream) RemainBytes ¶
func (*BitStream) RemainData ¶
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) PutUint8 ¶
func (bsw *BitStreamWriter) PutUint8(v uint8, 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) 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 ChannelOrder ¶
type H264NaluHdr ¶
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
}
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