1cabdff1aSopenharmony_ci/*
2cabdff1aSopenharmony_ci * AAC encoder data
3cabdff1aSopenharmony_ci * Copyright (c) 2015 Rostislav Pehlivanov ( atomnuker gmail com )
4cabdff1aSopenharmony_ci *
5cabdff1aSopenharmony_ci * This file is part of FFmpeg.
6cabdff1aSopenharmony_ci *
7cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or
8cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public
9cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either
10cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version.
11cabdff1aSopenharmony_ci *
12cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful,
13cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
14cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15cabdff1aSopenharmony_ci * Lesser General Public License for more details.
16cabdff1aSopenharmony_ci *
17cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public
18cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software
19cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20cabdff1aSopenharmony_ci */
21cabdff1aSopenharmony_ci
22cabdff1aSopenharmony_ci/**
23cabdff1aSopenharmony_ci * @file
24cabdff1aSopenharmony_ci * AAC encoder data
25cabdff1aSopenharmony_ci * @author Rostislav Pehlivanov ( atomnuker gmail com )
26cabdff1aSopenharmony_ci */
27cabdff1aSopenharmony_ci
28cabdff1aSopenharmony_ci#ifndef AVCODEC_AACENCTAB_H
29cabdff1aSopenharmony_ci#define AVCODEC_AACENCTAB_H
30cabdff1aSopenharmony_ci
31cabdff1aSopenharmony_ci#include "libavutil/channel_layout.h"
32cabdff1aSopenharmony_ci#include "aac.h"
33cabdff1aSopenharmony_ci
34cabdff1aSopenharmony_ci/** Total number of usable codebooks **/
35cabdff1aSopenharmony_ci#define CB_TOT 12
36cabdff1aSopenharmony_ci
37cabdff1aSopenharmony_ci/** Total number of codebooks, including special ones **/
38cabdff1aSopenharmony_ci#define CB_TOT_ALL 15
39cabdff1aSopenharmony_ci
40cabdff1aSopenharmony_ci#define AAC_MAX_CHANNELS 16
41cabdff1aSopenharmony_ci
42cabdff1aSopenharmony_ciextern const uint8_t *const ff_aac_swb_size_1024[];
43cabdff1aSopenharmony_ciextern const int      ff_aac_swb_size_1024_len;
44cabdff1aSopenharmony_ciextern const uint8_t *const ff_aac_swb_size_128[];
45cabdff1aSopenharmony_ciextern const int      ff_aac_swb_size_128_len;
46cabdff1aSopenharmony_ci
47cabdff1aSopenharmony_ci/* Supported layouts without using a PCE */
48cabdff1aSopenharmony_cistatic const AVChannelLayout aac_normal_chan_layouts[7] = {
49cabdff1aSopenharmony_ci    AV_CHANNEL_LAYOUT_MONO,
50cabdff1aSopenharmony_ci    AV_CHANNEL_LAYOUT_STEREO,
51cabdff1aSopenharmony_ci    AV_CHANNEL_LAYOUT_SURROUND,
52cabdff1aSopenharmony_ci    AV_CHANNEL_LAYOUT_4POINT0,
53cabdff1aSopenharmony_ci    AV_CHANNEL_LAYOUT_5POINT0_BACK,
54cabdff1aSopenharmony_ci    AV_CHANNEL_LAYOUT_5POINT1_BACK,
55cabdff1aSopenharmony_ci    AV_CHANNEL_LAYOUT_7POINT1,
56cabdff1aSopenharmony_ci};
57cabdff1aSopenharmony_ci
58cabdff1aSopenharmony_ci/** default channel configurations */
59cabdff1aSopenharmony_cistatic const uint8_t aac_chan_configs[AAC_MAX_CHANNELS][6] = {
60cabdff1aSopenharmony_ci    {1, TYPE_SCE},                                         // 1 channel  - single channel element
61cabdff1aSopenharmony_ci    {1, TYPE_CPE},                                         // 2 channels - channel pair
62cabdff1aSopenharmony_ci    {2, TYPE_SCE, TYPE_CPE},                               // 3 channels - center + stereo
63cabdff1aSopenharmony_ci    {3, TYPE_SCE, TYPE_CPE, TYPE_SCE},                     // 4 channels - front center + stereo + back center
64cabdff1aSopenharmony_ci    {3, TYPE_SCE, TYPE_CPE, TYPE_CPE},                     // 5 channels - front center + stereo + back stereo
65cabdff1aSopenharmony_ci    {4, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_LFE},           // 6 channels - front center + stereo + back stereo + LFE
66cabdff1aSopenharmony_ci    {0},                                                   // 7 channels - invalid without PCE
67cabdff1aSopenharmony_ci    {5, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_CPE, TYPE_LFE}, // 8 channels - front center + front stereo + side stereo + back stereo + LFE
68cabdff1aSopenharmony_ci};
69cabdff1aSopenharmony_ci
70cabdff1aSopenharmony_ci/**
71cabdff1aSopenharmony_ci * Table to remap channels from libavcodec's default order to AAC order.
72cabdff1aSopenharmony_ci */
73cabdff1aSopenharmony_cistatic const uint8_t aac_chan_maps[AAC_MAX_CHANNELS][AAC_MAX_CHANNELS] = {
74cabdff1aSopenharmony_ci    { 0 },
75cabdff1aSopenharmony_ci    { 0, 1 },
76cabdff1aSopenharmony_ci    { 2, 0, 1 },
77cabdff1aSopenharmony_ci    { 2, 0, 1, 3 },
78cabdff1aSopenharmony_ci    { 2, 0, 1, 3, 4 },
79cabdff1aSopenharmony_ci    { 2, 0, 1, 4, 5, 3 },
80cabdff1aSopenharmony_ci    { 0 },
81cabdff1aSopenharmony_ci    { 2, 0, 1, 6, 7, 4, 5, 3 },
82cabdff1aSopenharmony_ci};
83cabdff1aSopenharmony_ci
84cabdff1aSopenharmony_ci/** bits needed to code codebook run value for long windows */
85cabdff1aSopenharmony_cistatic const uint8_t run_value_bits_long[64] = {
86cabdff1aSopenharmony_ci     5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,
87cabdff1aSopenharmony_ci     5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5, 10,
88cabdff1aSopenharmony_ci    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
89cabdff1aSopenharmony_ci    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 15
90cabdff1aSopenharmony_ci};
91cabdff1aSopenharmony_ci
92cabdff1aSopenharmony_ci/** bits needed to code codebook run value for short windows */
93cabdff1aSopenharmony_cistatic const uint8_t run_value_bits_short[16] = {
94cabdff1aSopenharmony_ci    3, 3, 3, 3, 3, 3, 3, 6, 6, 6, 6, 6, 6, 6, 6, 9
95cabdff1aSopenharmony_ci};
96cabdff1aSopenharmony_ci
97cabdff1aSopenharmony_ci/* TNS starting SFBs for long and short windows */
98cabdff1aSopenharmony_cistatic const uint8_t tns_min_sfb_short[16] = {
99cabdff1aSopenharmony_ci    2, 2, 2, 3, 3, 4, 6, 6, 8, 10, 10, 12, 12, 12, 12, 12
100cabdff1aSopenharmony_ci};
101cabdff1aSopenharmony_ci
102cabdff1aSopenharmony_cistatic const uint8_t tns_min_sfb_long[16] = {
103cabdff1aSopenharmony_ci    12, 13, 15, 16, 17, 20, 25, 26, 24, 28, 30, 31, 31, 31, 31, 31
104cabdff1aSopenharmony_ci};
105cabdff1aSopenharmony_ci
106cabdff1aSopenharmony_cistatic const uint8_t * const tns_min_sfb[2] = {
107cabdff1aSopenharmony_ci    tns_min_sfb_long, tns_min_sfb_short
108cabdff1aSopenharmony_ci};
109cabdff1aSopenharmony_ci
110cabdff1aSopenharmony_cistatic const uint8_t * const run_value_bits[2] = {
111cabdff1aSopenharmony_ci    run_value_bits_long, run_value_bits_short
112cabdff1aSopenharmony_ci};
113cabdff1aSopenharmony_ci
114cabdff1aSopenharmony_ci/** Map to convert values from BandCodingPath index to a codebook index **/
115cabdff1aSopenharmony_cistatic 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};
116cabdff1aSopenharmony_ci/** Inverse map to convert from codebooks to BandCodingPath indices **/
117cabdff1aSopenharmony_cistatic 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};
118cabdff1aSopenharmony_ci
119cabdff1aSopenharmony_cistatic const uint8_t aac_cb_range [12] = {0, 3, 3, 3, 3, 9, 9, 8, 8, 13, 13, 17};
120cabdff1aSopenharmony_cistatic const uint8_t aac_cb_maxval[12] = {0, 1, 1, 2, 2, 4, 4, 7, 7, 12, 12, 16};
121cabdff1aSopenharmony_ci
122cabdff1aSopenharmony_cistatic const unsigned char aac_maxval_cb[] = {
123cabdff1aSopenharmony_ci    0, 1, 3, 5, 5, 7, 7, 7, 9, 9, 9, 9, 9, 11
124cabdff1aSopenharmony_ci};
125cabdff1aSopenharmony_ci
126cabdff1aSopenharmony_cistatic const int aacenc_profiles[] = {
127cabdff1aSopenharmony_ci    FF_PROFILE_AAC_MAIN,
128cabdff1aSopenharmony_ci    FF_PROFILE_AAC_LOW,
129cabdff1aSopenharmony_ci    FF_PROFILE_AAC_LTP,
130cabdff1aSopenharmony_ci    FF_PROFILE_MPEG2_AAC_LOW,
131cabdff1aSopenharmony_ci};
132cabdff1aSopenharmony_ci
133cabdff1aSopenharmony_ci#endif /* AVCODEC_AACENCTAB_H */
134