fdkaac

package
v0.0.0-...-2f6b0a5 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

The aac decoder, to decode the encoded aac frame to PCM samples.

The aac encoder, to encode the PCM samples to aac frame.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AacDecoder

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

func NewAacDecoder

func NewAacDecoder() *AacDecoder

func (*AacDecoder) AacNumChannels

func (v *AacDecoder) AacNumChannels() int

The number of audio channels after AAC core processing (before PS or MPS processing).

CAUTION: This are not the final number of output channels!

@remark Decoder internal members.

func (*AacDecoder) AacSampleRate

func (v *AacDecoder) AacSampleRate() int

sampling rate in Hz without SBR (from configuration info). @remark Decoder internal members.

func (*AacDecoder) AacSamplesPerFrame

func (v *AacDecoder) AacSamplesPerFrame() int

Samples per frame for the AAC core (from ASC).

1024 or 960 for AAC-LC
512 or 480 for AAC-LD and AAC-ELD

@remark Decoder internal members.

func (*AacDecoder) AudioObjectType

func (v *AacDecoder) AudioObjectType() int

Audio Object Type (from ASC): is set to the appropriate value for MPEG-2 bitstreams (e. g. 2 for AAC-LC). @remark Decoder internal members.

func (*AacDecoder) Bitrate

func (v *AacDecoder) Bitrate() int

Instantaneous bit rate. @remark Decoder internal members.

func (*AacDecoder) ChannelConfig

func (v *AacDecoder) ChannelConfig() int

Channel configuration (0: PCE defined, 1: mono, 2: stereo, ... @remark Decoder internal members.

func (*AacDecoder) Close

func (v *AacDecoder) Close() error

De-allocate all resources of an AAC decoder instance.

func (*AacDecoder) Decode

func (v *AacDecoder) Decode(frame []byte) (pcm []byte, err error)

Decode one audio frame. @param the frame contains encoded aac frame, optional can be nil. @eturn when pcm is nil, should fill more bytes and decode again.

func (*AacDecoder) ExtensionAudioObjectType

func (v *AacDecoder) ExtensionAudioObjectType() int

Extension Audio Object Type (from ASC) @remark Decoder internal members.

func (*AacDecoder) ExtensionSamplingRate

func (v *AacDecoder) ExtensionSamplingRate() int

Extension sampling rate in Hz (from ASC) @remark Decoder internal members.

func (*AacDecoder) FrameSize

func (v *AacDecoder) FrameSize() int

The frame size of the decoded PCM audio signal.

1024 or 960 for AAC-LC
2048 or 1920 for HE-AAC (v2)
512 or 480 for AAC-LD and AAC-ELD

@remark The only really relevant ones for the user.

func (*AacDecoder) InitAdts

func (v *AacDecoder) InitAdts() (err error)

Open the decoder in ADTS mode without ASC, we never know the stream info util got the first frame, because the codec info is insert at begin of each frame. @remark The frame to Decode() is muxed in ADTS format.

func (*AacDecoder) InitRaw

func (v *AacDecoder) InitRaw(asc []byte) (err error)

Open the decoder in RAW mode with ASC. For example, the FLV audio payload is a SequenceHeader(ASC) or RAW AAC data, user can init the decoder with ASC and decode the raw data. @remark user should never get the info util decode one frame.

func (*AacDecoder) NumBadAccessUnits

func (v *AacDecoder) NumBadAccessUnits() int

This is the number of total access units that were considered with errors from numTotalBytes. @remark Statistics.

func (*AacDecoder) NumBadBytes

func (v *AacDecoder) NumBadBytes() int

This is the number of total bytes that were considered with errors from numTotalBytes. @remark Statistics.

func (*AacDecoder) NumChannels

func (v *AacDecoder) NumChannels() int

The number of output audio channels in the decoded and interleaved PCM audio signal. @remark The only really relevant ones for the user.

func (*AacDecoder) NumLostAccessUnits

func (v *AacDecoder) NumLostAccessUnits() int

This integer will reflect the estimated amount of lost access units in case aacDecoder_DecodeFrame() returns AAC_DEC_TRANSPORT_SYNC_ERROR. It will be < 0 if the estimation failed. @remark Statistics.

func (*AacDecoder) NumTotalAccessUnits

func (v *AacDecoder) NumTotalAccessUnits() int

This is the number of total access units that have passed through the decoder. @remark Statistics.

func (*AacDecoder) NumTotalBytes

func (v *AacDecoder) NumTotalBytes() int

This is the number of total bytes that have passed through the decoder. @remark Statistics.

func (*AacDecoder) Profile

func (v *AacDecoder) Profile() int

MPEG-2 profile (from file header) (-1: not applicable (e. g. MPEG-4)). @remark Decoder internal members.

func (*AacDecoder) SampleBits

func (v *AacDecoder) SampleBits() int

The bits of a sample, the fdk aac always use 16bits sample.

func (*AacDecoder) SampleRate

func (v *AacDecoder) SampleRate() int

The samplerate in Hz of the fully decoded PCM audio signal (after SBR processing). @remark The only really relevant ones for the user.

type AacEncoder

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

The AAC encoder, input is PCM samples, output AAC frame in ADTS.

func NewAacEncoder

func NewAacEncoder() *AacEncoder

func (*AacEncoder) Channels

func (v *AacEncoder) Channels() int

Get the channels of encoder.

func (*AacEncoder) Close

func (v *AacEncoder) Close() error

func (*AacEncoder) Encode

func (v *AacEncoder) Encode(pcm []byte) (aac []byte, err error)

Encode the pcm to aac, pcm must contains bytes for one aac frame,

that is the bytes must be NbBytesPerFrame().

@remark fdkaac always use 16bits pcm, so the bits of pcm always 16. @remark user should resample the pcm to fit the encoder, so the channels of pcm equals to encoder's. @remark user should resample the pcm to fit the encoder, so the sampleRate of pcm equals to encoder's. @return when aac is nil, encoded completed(the Flush() return nil also),

because we will flush the encoder automatically to got the last frames.

func (*AacEncoder) Flush

func (v *AacEncoder) Flush() (aac []byte, err error)

Flush the encoder to get the cached aac frames. @return when aac is nil, flush ok, should never flush anymore.

func (*AacEncoder) FrameSize

func (v *AacEncoder) FrameSize() int

Get the frame size of encoder.

func (*AacEncoder) InitLc

func (v *AacEncoder) InitLc(channels, sampleRate, bitrateBps int) (err error)

Initialize the encoder in LC profile. @remark the encoder use sampleRate and channels, user should resample the PCM to fit it,

that is, the channels and sampleRate of PCM should always equals to encoder's.

@remark for the fdkaac always use 16bits sample, so the bits of pcm always 16,

which must be: [SHORT PCM] [SHORT PCM] ... ...

func (*AacEncoder) NbBytesPerFrame

func (v *AacEncoder) NbBytesPerFrame() int

Get the number of bytes per a aac frame.

Jump to

Keyboard shortcuts

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