diff options
Diffstat (limited to 'libavcodec/aacenc.c')
-rw-r--r-- | libavcodec/aacenc.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index d5021a4..95523ca 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -2,20 +2,20 @@ * AAC encoder * Copyright (C) 2008 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -135,6 +135,15 @@ static const uint8_t aac_chan_configs[6][5] = { {4, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_LFE}, // 6 channels - front center + stereo + back stereo + LFE }; +static const uint8_t channel_maps[][AAC_MAX_CHANNELS] = { + { 0 }, + { 0, 1 }, + { 2, 0, 1 }, + { 2, 0, 1, 3 }, + { 2, 0, 1, 3, 4 }, + { 2, 0, 1, 4, 5, 3 }, +}; + /** * Make AAC audio config object. * @see 1.6.2.1 "Syntax - AudioSpecificConfig" @@ -502,15 +511,24 @@ static int aac_encode_frame(AVCodecContext *avctx, return 0; if (data) { if (!s->psypp) { - memcpy(s->samples + 1024 * avctx->channels, data, - 1024 * avctx->channels * sizeof(s->samples[0])); + if (avctx->channels <= 2) { + memcpy(s->samples + 1024 * avctx->channels, data, + 1024 * avctx->channels * sizeof(s->samples[0])); + } else { + for (i = 0; i < 1024; i++) + for (ch = 0; ch < avctx->channels; ch++) + s->samples[(i + 1024) * avctx->channels + ch] = + ((int16_t*)data)[i * avctx->channels + + channel_maps[avctx->channels-1][ch]]; + } } else { start_ch = 0; samples2 = s->samples + 1024 * avctx->channels; for (i = 0; i < s->chan_map[0]; i++) { tag = s->chan_map[i+1]; chans = tag == TYPE_CPE ? 2 : 1; - ff_psy_preprocess(s->psypp, (uint16_t*)data + start_ch, + ff_psy_preprocess(s->psypp, + (uint16_t*)data + channel_maps[avctx->channels-1][start_ch], samples2 + start_ch, start_ch, chans); start_ch += chans; } |