#include "audio_frame_queue.h"
#include "internal.h"
#include "libavutil/audioconvert.h"
+#include "libavutil/common.h"
/* libfaac has an encoder delay of 1024 samples */
return 0;
}
+static const int channel_maps[][6] = {
+ { 2, 0, 1 }, //< C L R
+ { 2, 0, 1, 3 }, //< C L R Cs
+ { 2, 0, 1, 3, 4 }, //< C L R Ls Rs
+ { 2, 0, 1, 4, 5, 3 }, //< C L R Ls Rs LFE
+};
+
static av_cold int Faac_encode_init(AVCodecContext *avctx)
{
FaacAudioContext *s = avctx->priv_data;
}
faac_cfg->outputFormat = 1;
faac_cfg->inputFormat = FAAC_INPUT_16BIT;
+ if (avctx->channels > 2)
+ memcpy(faac_cfg->channel_map, channel_maps[avctx->channels-3],
+ avctx->channels * sizeof(int));
avctx->frame_size = samples_input / avctx->channels;
AVCodec ff_libfaac_encoder = {
.name = "libfaac",
.type = AVMEDIA_TYPE_AUDIO,
- .id = CODEC_ID_AAC,
+ .id = AV_CODEC_ID_AAC,
.priv_data_size = sizeof(FaacAudioContext),
.init = Faac_encode_init,
.encode2 = Faac_encode_frame,
.capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY,
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16,
AV_SAMPLE_FMT_NONE },
- .long_name = NULL_IF_CONFIG_SMALL("libfaac AAC (Advanced Audio Codec)"),
+ .long_name = NULL_IF_CONFIG_SMALL("libfaac AAC (Advanced Audio Coding)"),
.profiles = NULL_IF_CONFIG_SMALL(profiles),
.channel_layouts = faac_channel_layouts,
};