AAC编码的几个配置参数

对AAC格式的音频处理时都涉及到一些参数配置,之前经常忘记,特此做个记录。

最好的方式当然是去认真读一下spec。

下面就直接结合ffmpeg中代码的实现来说:

const int avpriv_mpeg4audio_sample_rates[16] = {
    96000, 88200, 64000, 48000, 44100, 32000,
    24000, 22050, 16000, 12000, 11025, 8000, 7350
};


const uint8_t ff_mpeg4audio_channels[8] = {
    0, 1, 2, 3, 4, 5, 6, 8
};


enum AudioObjectType {
    AOT_NULL,
                               // Support?                Name
    AOT_AAC_MAIN,              ///< Y                       Main
    AOT_AAC_LC,                ///< Y                       Low Complexity
    AOT_AAC_SSR,               ///< N (code in SoC repo)    Scalable Sample Rate
    AOT_AAC_LTP,               ///< Y                       Long Term Prediction
    AOT_SBR,                   ///< Y                       Spectral Band Replication
    AOT_AAC_SCALABLE,          ///< N                       Scalable
    AOT_TWINVQ,                ///< N                       Twin Vector Quantizer
    AOT_CELP,                  ///< N                       Code Excited Linear Prediction
    AOT_HVXC,                  ///< N                       Harmonic Vector eXcitation Coding
    AOT_TTSI             = 12, ///< N                       Text-To-Speech Interface
    AOT_MAINSYNTH,             ///< N                       Main Synthesis
    AOT_WAVESYNTH,             ///< N                       Wavetable Synthesis


在ffmpeg处理时和Android MediaCodec中用到Decoder-specific information from ESDS

1 ffmpeg中对应ACodec的extradata

2 Android MediaCodec中对应CSD buffer #0


从ffmpegaac_adtstoasc_filter函数可以看出其含义

       init_put_bits(&pb, avctx->extradata, avctx->extradata_size);
        put_bits(&pb, 5, hdr.object_type);
        put_bits(&pb, 4, hdr.sampling_index);
        put_bits(&pb, 4, hdr.chan_config);
        put_bits(&pb, 1, 0); //frame length - 1024 samples
        put_bits(&pb, 1, 0); //does not depend on core coder
        put_bits(&pb, 1, 0); //is not extension

      一般是2个字节,

1 最高5位对应AudioObjectType,实际上aac profile类型

2   下面4位是index,采样率定义参照avpriv_mpeg4audio_sample_rates数组

3 下面4位是index chan_config定义声道数,参照ff_mpeg4audio_channels数组


举例:0x12 0x10

profile:AAC_LC

sample_rates:44100

channels:2


另外ADTS格式怎么转换成ESDS需要个数可以参考

avpriv_aac_parse_header函数

网上也有大量文章,实现怎么增加ADTS头的文章,再此就不详述了。

     

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值