00001 /* 00002 * Header file for hardcoded mpegaudiodec tables 00003 * 00004 * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> 00005 * 00006 * This file is part of FFmpeg. 00007 * 00008 * FFmpeg is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2.1 of the License, or (at your option) any later version. 00012 * 00013 * FFmpeg is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with FFmpeg; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 */ 00022 00023 #ifndef AVCODEC_MPEGAUDIO_TABLEGEN_H 00024 #define AVCODEC_MPEGAUDIO_TABLEGEN_H 00025 00026 #include <stdint.h> 00027 #include <math.h> 00028 00029 #define TABLE_4_3_SIZE (8191 + 16)*4 00030 #if CONFIG_HARDCODED_TABLES 00031 #define mpegaudio_tableinit() 00032 #include "libavcodec/mpegaudio_tables.h" 00033 #else 00034 static int8_t table_4_3_exp[TABLE_4_3_SIZE]; 00035 static uint32_t table_4_3_value[TABLE_4_3_SIZE]; 00036 static uint32_t exp_table_fixed[512]; 00037 static uint32_t expval_table_fixed[512][16]; 00038 static float exp_table_float[512]; 00039 static float expval_table_float[512][16]; 00040 00041 #define FRAC_BITS 23 00042 #define IMDCT_SCALAR 1.759 00043 00044 static void mpegaudio_tableinit(void) 00045 { 00046 int i, value, exponent; 00047 for (i = 1; i < TABLE_4_3_SIZE; i++) { 00048 double value = i / 4; 00049 double f, fm; 00050 int e, m; 00051 f = value / IMDCT_SCALAR * cbrtf(value) * pow(2, (i & 3) * 0.25); 00052 fm = frexp(f, &e); 00053 m = (uint32_t)(fm * (1LL << 31) + 0.5); 00054 e += FRAC_BITS - 31 + 5 - 100; 00055 00056 /* normalized to FRAC_BITS */ 00057 table_4_3_value[i] = m; 00058 table_4_3_exp[i] = -e; 00059 } 00060 for (exponent = 0; exponent < 512; exponent++) { 00061 for (value = 0; value < 16; value++) { 00062 double f = (double)value * cbrtf(value) * pow(2, (exponent - 400) * 0.25 + FRAC_BITS + 5) / IMDCT_SCALAR; 00063 expval_table_fixed[exponent][value] = llrint(f); 00064 expval_table_float[exponent][value] = f; 00065 } 00066 exp_table_fixed[exponent] = expval_table_fixed[exponent][1]; 00067 exp_table_float[exponent] = expval_table_float[exponent][1]; 00068 } 00069 } 00070 #endif /* CONFIG_HARDCODED_TABLES */ 00071 00072 #endif /* AVCODEC_MPEGAUDIO_TABLEGEN_H */