|
|
|
@ -128,7 +128,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) |
|
|
|
|
int aot = FF_PROFILE_AAC_LOW + 1; |
|
|
|
|
int sce = 0, cpe = 0; |
|
|
|
|
|
|
|
|
|
if ((err = aacEncOpen(&s->handle, 0, avctx->channels)) != AACENC_OK) { |
|
|
|
|
if ((err = aacEncOpen(&s->handle, 0, avctx->ch_layout.nb_channels)) != AACENC_OK) { |
|
|
|
|
av_log(avctx, AV_LOG_ERROR, "Unable to open the encoder: %s\n", |
|
|
|
|
aac_get_error(err)); |
|
|
|
|
goto error; |
|
|
|
@ -159,7 +159,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) |
|
|
|
|
goto error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch (avctx->channels) { |
|
|
|
|
switch (avctx->ch_layout.nb_channels) { |
|
|
|
|
case 1: mode = MODE_1; sce = 1; cpe = 0; break; |
|
|
|
|
case 2: |
|
|
|
|
#if FDKENC_VER_AT_LEAST(4, 0) // 4.0.0
|
|
|
|
@ -193,7 +193,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) |
|
|
|
|
case 8: |
|
|
|
|
sce = 2; |
|
|
|
|
cpe = 3; |
|
|
|
|
if (avctx->channel_layout == AV_CH_LAYOUT_7POINT1) { |
|
|
|
|
if (!av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1)) { |
|
|
|
|
mode = MODE_7_1_REAR_SURROUND; |
|
|
|
|
} else { |
|
|
|
|
// MODE_1_2_2_2_1 and MODE_7_1_FRONT_CENTER use the same channel layout
|
|
|
|
@ -203,7 +203,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) |
|
|
|
|
#endif |
|
|
|
|
default: |
|
|
|
|
av_log(avctx, AV_LOG_ERROR, |
|
|
|
|
"Unsupported number of channels %d\n", avctx->channels); |
|
|
|
|
"Unsupported number of channels %d\n", avctx->ch_layout.nb_channels); |
|
|
|
|
goto error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -375,9 +375,9 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, |
|
|
|
|
in_args.numInSamples = -1; |
|
|
|
|
} else { |
|
|
|
|
in_ptr = frame->data[0]; |
|
|
|
|
in_buffer_size = 2 * avctx->channels * frame->nb_samples; |
|
|
|
|
in_buffer_size = 2 * avctx->ch_layout.nb_channels * frame->nb_samples; |
|
|
|
|
|
|
|
|
|
in_args.numInSamples = avctx->channels * frame->nb_samples; |
|
|
|
|
in_args.numInSamples = avctx->ch_layout.nb_channels * frame->nb_samples; |
|
|
|
|
|
|
|
|
|
/* add current frame to the queue */ |
|
|
|
|
if ((ret = ff_af_queue_add(&s->afq, frame)) < 0) |
|
|
|
@ -392,7 +392,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, |
|
|
|
|
in_buf.bufElSizes = &in_buffer_element_size; |
|
|
|
|
|
|
|
|
|
/* The maximum packet size is 6144 bits aka 768 bytes per channel. */ |
|
|
|
|
ret = ff_alloc_packet(avctx, avpkt, FFMAX(8192, 768 * avctx->channels)); |
|
|
|
|
ret = ff_alloc_packet(avctx, avpkt, FFMAX(8192, 768 * avctx->ch_layout.nb_channels)); |
|
|
|
|
if (ret < 0) |
|
|
|
|
return ret; |
|
|
|
|
|
|
|
|
@ -440,6 +440,7 @@ static const AVCodecDefault aac_encode_defaults[] = { |
|
|
|
|
{ NULL } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
#if FF_API_OLD_CHANNEL_LAYOUT |
|
|
|
|
static const uint64_t aac_channel_layout[] = { |
|
|
|
|
AV_CH_LAYOUT_MONO, |
|
|
|
|
AV_CH_LAYOUT_STEREO, |
|
|
|
@ -453,6 +454,21 @@ static const uint64_t aac_channel_layout[] = { |
|
|
|
|
#endif |
|
|
|
|
0, |
|
|
|
|
}; |
|
|
|
|
#endif /* FF_API_OLD_CHANNEL_LAYOUT */ |
|
|
|
|
|
|
|
|
|
static const AVChannelLayout aac_ch_layouts[16] = { |
|
|
|
|
AV_CHANNEL_LAYOUT_MONO, |
|
|
|
|
AV_CHANNEL_LAYOUT_STEREO, |
|
|
|
|
AV_CHANNEL_LAYOUT_SURROUND, |
|
|
|
|
AV_CHANNEL_LAYOUT_4POINT0, |
|
|
|
|
AV_CHANNEL_LAYOUT_5POINT0_BACK, |
|
|
|
|
AV_CHANNEL_LAYOUT_5POINT1_BACK, |
|
|
|
|
#ifdef AACENCODER_LIB_VL0 |
|
|
|
|
AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK, |
|
|
|
|
AV_CHANNEL_LAYOUT_7POINT1, |
|
|
|
|
#endif |
|
|
|
|
{ 0 }, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static const int aac_sample_rates[] = { |
|
|
|
|
96000, 88200, 64000, 48000, 44100, 32000, |
|
|
|
@ -475,6 +491,9 @@ const AVCodec ff_libfdk_aac_encoder = { |
|
|
|
|
.defaults = aac_encode_defaults, |
|
|
|
|
.profiles = profiles, |
|
|
|
|
.supported_samplerates = aac_sample_rates, |
|
|
|
|
.channel_layouts = aac_channel_layout, |
|
|
|
|
.wrapper_name = "libfdk", |
|
|
|
|
#if FF_API_OLD_CHANNEL_LAYOUT |
|
|
|
|
.channel_layouts = aac_channel_layout, |
|
|
|
|
#endif |
|
|
|
|
.ch_layouts = aac_ch_layouts, |
|
|
|
|
}; |
|
|
|
|