/*1* AAC encoder data2* Copyright (c) 2015 Rostislav Pehlivanov ( atomnuker gmail com )3*4* This file is part of FFmpeg.5*6* FFmpeg is free software; you can redistribute it and/or7* modify it under the terms of the GNU Lesser General Public8* License as published by the Free Software Foundation; either9* version 2.1 of the License, or (at your option) any later version.10*11* FFmpeg is distributed in the hope that it will be useful,12* but WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU14* Lesser General Public License for more details.15*16* You should have received a copy of the GNU Lesser General Public17* License along with FFmpeg; if not, write to the Free Software18* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA19*/2021/**22* @file23* AAC encoder data24* @author Rostislav Pehlivanov ( atomnuker gmail com )25*/2627#ifndef AVCODEC_AACENCTAB_H28#define AVCODEC_AACENCTAB_H2930#include "aac.h"3132/** Total number of usable codebooks **/33#define CB_TOT 123435/** Total number of codebooks, including special ones **/36#define CB_TOT_ALL 153738#define AAC_MAX_CHANNELS 83940extern const uint8_t *ff_aac_swb_size_1024[];41extern const int ff_aac_swb_size_1024_len;42extern const uint8_t *ff_aac_swb_size_128[];43extern const int ff_aac_swb_size_128_len;4445/** default channel configurations */46static const uint8_t aac_chan_configs[AAC_MAX_CHANNELS][6] = {47{1, TYPE_SCE}, // 1 channel - single channel element48{1, TYPE_CPE}, // 2 channels - channel pair49{2, TYPE_SCE, TYPE_CPE}, // 3 channels - center + stereo50{3, TYPE_SCE, TYPE_CPE, TYPE_SCE}, // 4 channels - front center + stereo + back center51{3, TYPE_SCE, TYPE_CPE, TYPE_CPE}, // 5 channels - front center + stereo + back stereo52{4, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_LFE}, // 6 channels - front center + stereo + back stereo + LFE53{0}, // 7 channels - invalid without PCE54{5, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_CPE, TYPE_LFE}, // 8 channels - front center + front stereo + side stereo + back stereo + LFE55};5657/**58* Table to remap channels from libavcodec's default order to AAC order.59*/60static const uint8_t aac_chan_maps[AAC_MAX_CHANNELS][AAC_MAX_CHANNELS] = {61{ 0 },62{ 0, 1 },63{ 2, 0, 1 },64{ 2, 0, 1, 3 },65{ 2, 0, 1, 3, 4 },66{ 2, 0, 1, 4, 5, 3 },67{ 0 },68{ 2, 0, 1, 6, 7, 4, 5, 3 },69};7071/* duplicated from avpriv_mpeg4audio_sample_rates to avoid shared build72* failures */73static const int mpeg4audio_sample_rates[16] = {7496000, 88200, 64000, 48000, 44100, 32000,7524000, 22050, 16000, 12000, 11025, 8000, 735076};7778/** bits needed to code codebook run value for long windows */79static const uint8_t run_value_bits_long[64] = {805, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,815, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10,8210, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,8310, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1584};8586/** bits needed to code codebook run value for short windows */87static const uint8_t run_value_bits_short[16] = {883, 3, 3, 3, 3, 3, 3, 6, 6, 6, 6, 6, 6, 6, 6, 989};9091/* TNS starting SFBs for long and short windows */92static const uint8_t tns_min_sfb_short[16] = {932, 2, 2, 3, 3, 4, 6, 6, 8, 10, 10, 12, 12, 12, 12, 1294};9596static const uint8_t tns_min_sfb_long[16] = {9712, 13, 15, 16, 17, 20, 25, 26, 24, 28, 30, 31, 31, 31, 31, 3198};99100static const uint8_t * const tns_min_sfb[2] = {101tns_min_sfb_long, tns_min_sfb_short102};103104static const uint8_t * const run_value_bits[2] = {105run_value_bits_long, run_value_bits_short106};107108/** Map to convert values from BandCodingPath index to a codebook index **/109static const uint8_t aac_cb_out_map[CB_TOT_ALL] = {0,1,2,3,4,5,6,7,8,9,10,11,13,14,15};110/** Inverse map to convert from codebooks to BandCodingPath indices **/111static const uint8_t aac_cb_in_map[CB_TOT_ALL+1] = {0,1,2,3,4,5,6,7,8,9,10,11,0,12,13,14};112113static const uint8_t aac_cb_range [12] = {0, 3, 3, 3, 3, 9, 9, 8, 8, 13, 13, 17};114static const uint8_t aac_cb_maxval[12] = {0, 1, 1, 2, 2, 4, 4, 7, 7, 12, 12, 16};115116static const unsigned char aac_maxval_cb[] = {1170, 1, 3, 5, 5, 7, 7, 7, 9, 9, 9, 9, 9, 11118};119120static const int aacenc_profiles[] = {121FF_PROFILE_AAC_MAIN,122FF_PROFILE_AAC_LOW,123FF_PROFILE_AAC_LTP,124FF_PROFILE_MPEG2_AAC_LOW,125};126127#endif /* AVCODEC_AACENCTAB_H */128129130