Revision e29af818

View differences:

libavcodec/Makefile
660 660

  
661 661
ifdef CONFIG_HARDCODED_TABLES
662 662
$(SUBDIR)aacdec.o: $(SUBDIR)cbrt_tables.h
663
$(SUBDIR)aactab.o: $(SUBDIR)aac_tables.h
663 664
$(SUBDIR)dv.o: $(SUBDIR)dv_tables.h
664 665
$(SUBDIR)mdct.o: $(SUBDIR)mdct_tables.h
665 666
$(SUBDIR)mpegaudiodec.o: $(SUBDIR)mpegaudio_tables.h
libavcodec/aac_tablegen.c
1
/*
2
 * Generate a header file for hardcoded AAC tables
3
 *
4
 * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
5
 *
6
 * This file is part of FFmpeg.
7
 *
8
 * FFmpeg is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11
 * version 2.1 of the License, or (at your option) any later version.
12
 *
13
 * FFmpeg is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public
19
 * License along with FFmpeg; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
 */
22

  
23
#include <stdlib.h>
24
#define CONFIG_HARDCODED_TABLES 0
25
#include "aac_tablegen.h"
26
#include "tableprint.h"
27

  
28
int main(void)
29
{
30
    ff_aac_tableinit();
31

  
32
    write_fileheader();
33

  
34
    printf("const float ff_aac_pow2sf_tab[428] = {\n");
35
    write_float_array(ff_aac_pow2sf_tab, 428);
36
    printf("};\n");
37

  
38
    return 0;
39
}
libavcodec/aac_tablegen.h
1
/*
2
 * Header file for hardcoded AAC tables
3
 *
4
 * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
5
 *
6
 * This file is part of FFmpeg.
7
 *
8
 * FFmpeg is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11
 * version 2.1 of the License, or (at your option) any later version.
12
 *
13
 * FFmpeg is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public
19
 * License along with FFmpeg; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
 */
22

  
23
#ifndef AAC_TABLEGEN_H
24
#define AAC_TABLEGEN_H
25

  
26
#include "aac_tablegen_decl.h"
27

  
28
#if CONFIG_HARDCODED_TABLES
29
#include "libavcodec/aac_tables.h"
30
#else
31
#include "../libavutil/mathematics.h"
32
float ff_aac_pow2sf_tab[428];
33

  
34
void ff_aac_tableinit(void)
35
{
36
    int i;
37
    for (i = 0; i < 428; i++)
38
        ff_aac_pow2sf_tab[i] = pow(2, (i - 200) / 4.);
39
}
40
#endif /* CONFIG_HARDCODED_TABLES */
41

  
42
#endif /* AAC_TABLEGEN_H */
libavcodec/aac_tablegen_decl.h
1
/*
2
 * Header file for hardcoded AAC tables
3
 *
4
 * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
5
 *
6
 * This file is part of FFmpeg.
7
 *
8
 * FFmpeg is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11
 * version 2.1 of the License, or (at your option) any later version.
12
 *
13
 * FFmpeg is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public
19
 * License along with FFmpeg; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
 */
22

  
23
#ifndef AAC_TABLEGEN_INIT_H
24
#define AAC_TABLEGEN_INIT_H
25

  
26
#if CONFIG_HARDCODED_TABLES
27
#define ff_aac_tableinit()
28
extern const float ff_aac_pow2sf_tab[428];
29
#else
30
void ff_aac_tableinit(void);
31
extern       float ff_aac_pow2sf_tab[428];
32
#endif /* CONFIG_HARDCODED_TABLES */
33

  
34
#endif /* AAC_TABLEGEN_INIT_H */
libavcodec/aacdec.c
537 537
static av_cold int aac_decode_init(AVCodecContext *avctx)
538 538
{
539 539
    AACContext *ac = avctx->priv_data;
540
    int i;
541 540

  
542 541
    ac->avctx = avctx;
543 542
    ac->m4ac.sample_rate = avctx->sample_rate;
......
581 580
        ac->sf_offset = 60;
582 581
    }
583 582

  
584
#if !CONFIG_HARDCODED_TABLES
585
    for (i = 0; i < 428; i++)
586
        ff_aac_pow2sf_tab[i] = pow(2, (i - 200) / 4.);
587
#endif /* CONFIG_HARDCODED_TABLES */
583
    ff_aac_tableinit();
588 584

  
589 585
    INIT_VLC_STATIC(&vlc_scalefactors,7,FF_ARRAY_ELEMS(ff_aac_scalefactor_code),
590 586
                    ff_aac_scalefactor_bits, sizeof(ff_aac_scalefactor_bits[0]), sizeof(ff_aac_scalefactor_bits[0]),
libavcodec/aacenc.c
204 204
    s->coder = &ff_aac_coders[2];
205 205

  
206 206
    s->lambda = avctx->global_quality ? avctx->global_quality : 120;
207
#if !CONFIG_HARDCODED_TABLES
208
    for (i = 0; i < 428; i++)
209
        ff_aac_pow2sf_tab[i] = pow(2, (i - 200)/4.);
210
#endif /* CONFIG_HARDCODED_TABLES */
207

  
208
    ff_aac_tableinit();
211 209

  
212 210
    if (avctx->channels > 5)
213 211
        av_log(avctx, AV_LOG_ERROR, "This encoder does not yet enforce the restrictions on LFEs. "
libavcodec/aactab.c
29 29

  
30 30
#include "libavutil/mem.h"
31 31
#include "aac.h"
32
#include "aac_tablegen.h"
32 33

  
33 34
#include <stdint.h>
34 35

  
......
1204 1205
    9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14
1205 1206
};
1206 1207
// @}
1207

  
1208

  
1209
#if CONFIG_HARDCODED_TABLES
1210

  
1211
/**
1212
 * Table of pow(2, (i - 200)/4.) used for different purposes depending on the
1213
 * range of indices to the table:
1214
 * [ 0, 255] scale factor decoding when using C dsp.float_to_int16
1215
 * [60, 315] scale factor decoding when using SIMD dsp.float_to_int16
1216
 * [45, 300] intensity stereo position decoding mapped in reverse order i.e. 0->300, 1->299, ..., 254->46, 255->45
1217
 */
1218
const float ff_aac_pow2sf_tab[428] = {
1219
    8.88178420e-16, 1.05622810e-15, 1.25607397e-15, 1.49373210e-15,
1220
    1.77635684e-15, 2.11245619e-15, 2.51214793e-15, 2.98746420e-15,
1221
    3.55271368e-15, 4.22491238e-15, 5.02429587e-15, 5.97492839e-15,
1222
    7.10542736e-15, 8.44982477e-15, 1.00485917e-14, 1.19498568e-14,
1223
    1.42108547e-14, 1.68996495e-14, 2.00971835e-14, 2.38997136e-14,
1224
    2.84217094e-14, 3.37992991e-14, 4.01943669e-14, 4.77994272e-14,
1225
    5.68434189e-14, 6.75985982e-14, 8.03887339e-14, 9.55988543e-14,
1226
    1.13686838e-13, 1.35197196e-13, 1.60777468e-13, 1.91197709e-13,
1227
    2.27373675e-13, 2.70394393e-13, 3.21554936e-13, 3.82395417e-13,
1228
    4.54747351e-13, 5.40788785e-13, 6.43109871e-13, 7.64790834e-13,
1229
    9.09494702e-13, 1.08157757e-12, 1.28621974e-12, 1.52958167e-12,
1230
    1.81898940e-12, 2.16315514e-12, 2.57243948e-12, 3.05916334e-12,
1231
    3.63797881e-12, 4.32631028e-12, 5.14487897e-12, 6.11832668e-12,
1232
    7.27595761e-12, 8.65262056e-12, 1.02897579e-11, 1.22366534e-11,
1233
    1.45519152e-11, 1.73052411e-11, 2.05795159e-11, 2.44733067e-11,
1234
    2.91038305e-11, 3.46104823e-11, 4.11590317e-11, 4.89466134e-11,
1235
    5.82076609e-11, 6.92209645e-11, 8.23180635e-11, 9.78932268e-11,
1236
    1.16415322e-10, 1.38441929e-10, 1.64636127e-10, 1.95786454e-10,
1237
    2.32830644e-10, 2.76883858e-10, 3.29272254e-10, 3.91572907e-10,
1238
    4.65661287e-10, 5.53767716e-10, 6.58544508e-10, 7.83145814e-10,
1239
    9.31322575e-10, 1.10753543e-09, 1.31708902e-09, 1.56629163e-09,
1240
    1.86264515e-09, 2.21507086e-09, 2.63417803e-09, 3.13258326e-09,
1241
    3.72529030e-09, 4.43014173e-09, 5.26835606e-09, 6.26516652e-09,
1242
    7.45058060e-09, 8.86028346e-09, 1.05367121e-08, 1.25303330e-08,
1243
    1.49011612e-08, 1.77205669e-08, 2.10734243e-08, 2.50606661e-08,
1244
    2.98023224e-08, 3.54411338e-08, 4.21468485e-08, 5.01213321e-08,
1245
    5.96046448e-08, 7.08822677e-08, 8.42936970e-08, 1.00242664e-07,
1246
    1.19209290e-07, 1.41764535e-07, 1.68587394e-07, 2.00485328e-07,
1247
    2.38418579e-07, 2.83529071e-07, 3.37174788e-07, 4.00970657e-07,
1248
    4.76837158e-07, 5.67058141e-07, 6.74349576e-07, 8.01941314e-07,
1249
    9.53674316e-07, 1.13411628e-06, 1.34869915e-06, 1.60388263e-06,
1250
    1.90734863e-06, 2.26823256e-06, 2.69739830e-06, 3.20776526e-06,
1251
    3.81469727e-06, 4.53646513e-06, 5.39479661e-06, 6.41553051e-06,
1252
    7.62939453e-06, 9.07293026e-06, 1.07895932e-05, 1.28310610e-05,
1253
    1.52587891e-05, 1.81458605e-05, 2.15791864e-05, 2.56621220e-05,
1254
    3.05175781e-05, 3.62917210e-05, 4.31583729e-05, 5.13242441e-05,
1255
    6.10351562e-05, 7.25834421e-05, 8.63167458e-05, 1.02648488e-04,
1256
    1.22070312e-04, 1.45166884e-04, 1.72633492e-04, 2.05296976e-04,
1257
    2.44140625e-04, 2.90333768e-04, 3.45266983e-04, 4.10593953e-04,
1258
    4.88281250e-04, 5.80667537e-04, 6.90533966e-04, 8.21187906e-04,
1259
    9.76562500e-04, 1.16133507e-03, 1.38106793e-03, 1.64237581e-03,
1260
    1.95312500e-03, 2.32267015e-03, 2.76213586e-03, 3.28475162e-03,
1261
    3.90625000e-03, 4.64534029e-03, 5.52427173e-03, 6.56950324e-03,
1262
    7.81250000e-03, 9.29068059e-03, 1.10485435e-02, 1.31390065e-02,
1263
    1.56250000e-02, 1.85813612e-02, 2.20970869e-02, 2.62780130e-02,
1264
    3.12500000e-02, 3.71627223e-02, 4.41941738e-02, 5.25560260e-02,
1265
    6.25000000e-02, 7.43254447e-02, 8.83883476e-02, 1.05112052e-01,
1266
    1.25000000e-01, 1.48650889e-01, 1.76776695e-01, 2.10224104e-01,
1267
    2.50000000e-01, 2.97301779e-01, 3.53553391e-01, 4.20448208e-01,
1268
    5.00000000e-01, 5.94603558e-01, 7.07106781e-01, 8.40896415e-01,
1269
    1.00000000e+00, 1.18920712e+00, 1.41421356e+00, 1.68179283e+00,
1270
    2.00000000e+00, 2.37841423e+00, 2.82842712e+00, 3.36358566e+00,
1271
    4.00000000e+00, 4.75682846e+00, 5.65685425e+00, 6.72717132e+00,
1272
    8.00000000e+00, 9.51365692e+00, 1.13137085e+01, 1.34543426e+01,
1273
    1.60000000e+01, 1.90273138e+01, 2.26274170e+01, 2.69086853e+01,
1274
    3.20000000e+01, 3.80546277e+01, 4.52548340e+01, 5.38173706e+01,
1275
    6.40000000e+01, 7.61092554e+01, 9.05096680e+01, 1.07634741e+02,
1276
    1.28000000e+02, 1.52218511e+02, 1.81019336e+02, 2.15269482e+02,
1277
    2.56000000e+02, 3.04437021e+02, 3.62038672e+02, 4.30538965e+02,
1278
    5.12000000e+02, 6.08874043e+02, 7.24077344e+02, 8.61077929e+02,
1279
    1.02400000e+03, 1.21774809e+03, 1.44815469e+03, 1.72215586e+03,
1280
    2.04800000e+03, 2.43549617e+03, 2.89630938e+03, 3.44431172e+03,
1281
    4.09600000e+03, 4.87099234e+03, 5.79261875e+03, 6.88862343e+03,
1282
    8.19200000e+03, 9.74198469e+03, 1.15852375e+04, 1.37772469e+04,
1283
    1.63840000e+04, 1.94839694e+04, 2.31704750e+04, 2.75544937e+04,
1284
    3.27680000e+04, 3.89679387e+04, 4.63409500e+04, 5.51089875e+04,
1285
    6.55360000e+04, 7.79358775e+04, 9.26819000e+04, 1.10217975e+05,
1286
    1.31072000e+05, 1.55871755e+05, 1.85363800e+05, 2.20435950e+05,
1287
    2.62144000e+05, 3.11743510e+05, 3.70727600e+05, 4.40871900e+05,
1288
    5.24288000e+05, 6.23487020e+05, 7.41455200e+05, 8.81743800e+05,
1289
    1.04857600e+06, 1.24697404e+06, 1.48291040e+06, 1.76348760e+06,
1290
    2.09715200e+06, 2.49394808e+06, 2.96582080e+06, 3.52697520e+06,
1291
    4.19430400e+06, 4.98789616e+06, 5.93164160e+06, 7.05395040e+06,
1292
    8.38860800e+06, 9.97579232e+06, 1.18632832e+07, 1.41079008e+07,
1293
    1.67772160e+07, 1.99515846e+07, 2.37265664e+07, 2.82158016e+07,
1294
    3.35544320e+07, 3.99031693e+07, 4.74531328e+07, 5.64316032e+07,
1295
    6.71088640e+07, 7.98063385e+07, 9.49062656e+07, 1.12863206e+08,
1296
    1.34217728e+08, 1.59612677e+08, 1.89812531e+08, 2.25726413e+08,
1297
    2.68435456e+08, 3.19225354e+08, 3.79625062e+08, 4.51452825e+08,
1298
    5.36870912e+08, 6.38450708e+08, 7.59250125e+08, 9.02905651e+08,
1299
    1.07374182e+09, 1.27690142e+09, 1.51850025e+09, 1.80581130e+09,
1300
    2.14748365e+09, 2.55380283e+09, 3.03700050e+09, 3.61162260e+09,
1301
    4.29496730e+09, 5.10760567e+09, 6.07400100e+09, 7.22324521e+09,
1302
    8.58993459e+09, 1.02152113e+10, 1.21480020e+10, 1.44464904e+10,
1303
    1.71798692e+10, 2.04304227e+10, 2.42960040e+10, 2.88929808e+10,
1304
    3.43597384e+10, 4.08608453e+10, 4.85920080e+10, 5.77859616e+10,
1305
    6.87194767e+10, 8.17216907e+10, 9.71840160e+10, 1.15571923e+11,
1306
    1.37438953e+11, 1.63443381e+11, 1.94368032e+11, 2.31143847e+11,
1307
    2.74877907e+11, 3.26886763e+11, 3.88736064e+11, 4.62287693e+11,
1308
    5.49755814e+11, 6.53773525e+11, 7.77472128e+11, 9.24575386e+11,
1309
    1.09951163e+12, 1.30754705e+12, 1.55494426e+12, 1.84915077e+12,
1310
    2.19902326e+12, 2.61509410e+12, 3.10988851e+12, 3.69830155e+12,
1311
    4.39804651e+12, 5.23018820e+12, 6.21977702e+12, 7.39660309e+12,
1312
    8.79609302e+12, 1.04603764e+13, 1.24395540e+13, 1.47932062e+13,
1313
    1.75921860e+13, 2.09207528e+13, 2.48791081e+13, 2.95864124e+13,
1314
    3.51843721e+13, 4.18415056e+13, 4.97582162e+13, 5.91728247e+13,
1315
    7.03687442e+13, 8.36830112e+13, 9.95164324e+13, 1.18345649e+14,
1316
    1.40737488e+14, 1.67366022e+14, 1.99032865e+14, 2.36691299e+14,
1317
    2.81474977e+14, 3.34732045e+14, 3.98065730e+14, 4.73382598e+14,
1318
    5.62949953e+14, 6.69464090e+14, 7.96131459e+14, 9.46765196e+14,
1319
    1.12589991e+15, 1.33892818e+15, 1.59226292e+15, 1.89353039e+15,
1320
    2.25179981e+15, 2.67785636e+15, 3.18452584e+15, 3.78706078e+15,
1321
    4.50359963e+15, 5.35571272e+15, 6.36905167e+15, 7.57412156e+15,
1322
    9.00719925e+15, 1.07114254e+16, 1.27381033e+16, 1.51482431e+16,
1323
    1.80143985e+16, 2.14228509e+16, 2.54762067e+16, 3.02964863e+16,
1324
    3.60287970e+16, 4.28457018e+16, 5.09524134e+16, 6.05929725e+16,
1325
    7.20575940e+16, 8.56914035e+16, 1.01904827e+17, 1.21185945e+17,
1326
};
1327

  
1328
#else
1329

  
1330
float ff_aac_pow2sf_tab[428];
1331

  
1332
#endif /* CONFIG_HARDCODED_TABLES */
libavcodec/aactab.h
32 32

  
33 33
#include "libavutil/mem.h"
34 34
#include "aac.h"
35
#include "aac_tablegen_decl.h"
35 36

  
36 37
#include <stdint.h>
37 38

  
......
73 74
extern const uint8_t ff_tns_max_bands_1024[13];
74 75
extern const uint8_t ff_tns_max_bands_128 [13];
75 76

  
76
#if CONFIG_HARDCODED_TABLES
77
extern const float ff_aac_pow2sf_tab[428];
78
#else
79
extern       float ff_aac_pow2sf_tab[428];
80
#endif /* CONFIG_HARDCODED_TABLES */
81

  
82 77
#endif /* AVCODEC_AACTAB_H */

Also available in: Unified diff