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
- func EncoderVersion() string
- func GetInfoModule(module C.FDK_MODULE_ID) *C.LIB_INFO
- func GetInfoModules() []C.LIB_INFO
- func GetModules() (result []moduleInformation)
- func NewEncoderError(code int) error
- func ToolsVersion() string
- type AacDecoder
- func (v *AacDecoder) AacNumChannels() int
- func (v *AacDecoder) AacSampleRate() int
- func (v *AacDecoder) AacSamplesPerFrame() int
- func (v *AacDecoder) AudioObjectType() int
- func (v *AacDecoder) Bitrate() int
- func (v *AacDecoder) ChannelConfig() int
- func (v *AacDecoder) Close() error
- func (v *AacDecoder) Decode() (pcm []byte, err error)
- func (v *AacDecoder) ExtensionAudioObjectType() int
- func (v *AacDecoder) ExtensionSamplingRate() int
- func (v *AacDecoder) Fill(input []byte) (n int, err error)
- func (v *AacDecoder) FrameSize() int
- func (v *AacDecoder) InitAdts() (err error)
- func (v *AacDecoder) InitRaw(asc []byte) (err error)
- func (v *AacDecoder) NumBadAccessUnits() int
- func (v *AacDecoder) NumBadBytes() int
- func (v *AacDecoder) NumChannels() int
- func (v *AacDecoder) NumLostAccessUnits() int
- func (v *AacDecoder) NumTotalAccessUnits() int
- func (v *AacDecoder) NumTotalBytes() int
- func (v *AacDecoder) Profile() int
- func (v *AacDecoder) SampleBits() int
- func (v *AacDecoder) SampleRate() int
- type AacEncoder
- func (v *AacEncoder) Channels() int
- func (v *AacEncoder) Close() error
- func (v *AacEncoder) Encode(pcm []byte) (aac []byte, err error)
- func (v *AacEncoder) Flush() (aac []byte, err error)
- func (v *AacEncoder) FrameSize() int
- func (v *AacEncoder) InitHE(channels, sampleRate, bitrateBps, muxingMode, afterburner int) (err error)
- func (v *AacEncoder) InitHEv2(channels, sampleRate, bitrateBps, muxingMode, afterburner int) (err error)
- func (v *AacEncoder) InitLc(channels, sampleRate, bitrateBps, muxingMode, afterburner int) (err error)
- func (v *AacEncoder) NbBytesPerFrame() int
- type EncoderError
Constants ¶
const ( MuxingModeRAW = 0 MuxingModeADIF = 1 MuxingModeADTS = 2 )
const ( ModuleNone = C.FDK_NONE ModuleFdkTools = C.FDK_TOOLS ModuleFdkAACENC = C.FDK_AACENC )
Variables ¶
This section is empty.
Functions ¶
func EncoderVersion ¶
func EncoderVersion() string
func GetInfoModule ¶
func GetInfoModule(module C.FDK_MODULE_ID) *C.LIB_INFO
func GetInfoModules ¶
func GetModules ¶
func GetModules() (result []moduleInformation)
func NewEncoderError ¶
func ToolsVersion ¶
func ToolsVersion() string
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() (pcm []byte, err error)
Decode one audio frame, previously filled by Fill @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) Fill ¶
func (v *AacDecoder) Fill(input []byte) (n int, err error)
Fill the buffer of decoder then decode. @remark we always expect all input are consumed by decoder.
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
}
AacEncoder 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
Channels 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
FrameSize Get the frame size of encoder.
func (*AacEncoder) InitHE ¶
func (v *AacEncoder) InitHE(channels, sampleRate, bitrateBps, muxingMode, afterburner int) (err error)
InitHE Initialize the encoder in HE 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) InitHEv2 ¶
func (v *AacEncoder) InitHEv2(channels, sampleRate, bitrateBps, muxingMode, afterburner int) (err error)
InitHEv2 Initialize the encoder in HEv2 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) InitLc ¶
func (v *AacEncoder) InitLc(channels, sampleRate, bitrateBps, muxingMode, afterburner int) (err error)
InitLc 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
NbBytesPerFrame Get the number of bytes per a aac frame.
type EncoderError ¶
type EncoderError struct {
Code int
}
func (*EncoderError) Error ¶
func (e *EncoderError) Error() string