yading@10: /* yading@10: * Header file for hardcoded mpegaudiodec tables yading@10: * yading@10: * Copyright (c) 2009 Reimar Döffinger yading@10: * yading@10: * This file is part of FFmpeg. yading@10: * yading@10: * FFmpeg is free software; you can redistribute it and/or yading@10: * modify it under the terms of the GNU Lesser General Public yading@10: * License as published by the Free Software Foundation; either yading@10: * version 2.1 of the License, or (at your option) any later version. yading@10: * yading@10: * FFmpeg is distributed in the hope that it will be useful, yading@10: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@10: * Lesser General Public License for more details. yading@10: * yading@10: * You should have received a copy of the GNU Lesser General Public yading@10: * License along with FFmpeg; if not, write to the Free Software yading@10: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@10: */ yading@10: yading@10: #ifndef AVCODEC_MPEGAUDIO_TABLEGEN_H yading@10: #define AVCODEC_MPEGAUDIO_TABLEGEN_H yading@10: yading@10: #include yading@10: #include yading@10: yading@10: #define TABLE_4_3_SIZE (8191 + 16)*4 yading@10: #if CONFIG_HARDCODED_TABLES yading@10: #define mpegaudio_tableinit() yading@10: #include "libavcodec/mpegaudio_tables.h" yading@10: #else yading@10: static int8_t table_4_3_exp[TABLE_4_3_SIZE]; yading@10: static uint32_t table_4_3_value[TABLE_4_3_SIZE]; yading@10: static uint32_t exp_table_fixed[512]; yading@10: static uint32_t expval_table_fixed[512][16]; yading@10: static float exp_table_float[512]; yading@10: static float expval_table_float[512][16]; yading@10: yading@10: #define FRAC_BITS 23 yading@10: #define IMDCT_SCALAR 1.759 yading@10: yading@10: static void mpegaudio_tableinit(void) yading@10: { yading@10: int i, value, exponent; yading@10: for (i = 1; i < TABLE_4_3_SIZE; i++) { yading@10: double value = i / 4; yading@10: double f, fm; yading@10: int e, m; yading@10: f = value / IMDCT_SCALAR * cbrtf(value) * pow(2, (i & 3) * 0.25); yading@10: fm = frexp(f, &e); yading@10: m = (uint32_t)(fm * (1LL << 31) + 0.5); yading@10: e += FRAC_BITS - 31 + 5 - 100; yading@10: yading@10: /* normalized to FRAC_BITS */ yading@10: table_4_3_value[i] = m; yading@10: table_4_3_exp[i] = -e; yading@10: } yading@10: for (exponent = 0; exponent < 512; exponent++) { yading@10: for (value = 0; value < 16; value++) { yading@10: double f = (double)value * cbrtf(value) * pow(2, (exponent - 400) * 0.25 + FRAC_BITS + 5) / IMDCT_SCALAR; yading@10: expval_table_fixed[exponent][value] = llrint(f); yading@10: expval_table_float[exponent][value] = f; yading@10: } yading@10: exp_table_fixed[exponent] = expval_table_fixed[exponent][1]; yading@10: exp_table_float[exponent] = expval_table_float[exponent][1]; yading@10: } yading@10: } yading@10: #endif /* CONFIG_HARDCODED_TABLES */ yading@10: yading@10: #endif /* AVCODEC_MPEGAUDIO_TABLEGEN_H */