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 00043 static void mpegaudio_tableinit(void) 00044 { 00045 int i, value, exponent; 00046 for (i = 1; i < TABLE_4_3_SIZE; i++) { 00047 double value = i / 4; 00048 double f, fm; 00049 int e, m; 00050 f = value * cbrtf(value) * pow(2, (i & 3) * 0.25); 00051 fm = frexp(f, &e); 00052 m = (uint32_t)(fm * (1LL << 31) + 0.5); 00053 e += FRAC_BITS - 31 + 5 - 100; 00054 00055 /* normalized to FRAC_BITS */ 00056 table_4_3_value[i] = m; 00057 table_4_3_exp[i] = -e; 00058 } 00059 for (exponent = 0; exponent < 512; exponent++) { 00060 for (value = 0; value < 16; value++) { 00061 double f = (double)value * cbrtf(value) * pow(2, (exponent - 400) * 0.25 + FRAC_BITS + 5); 00062 expval_table_fixed[exponent][value] = llrint(f); 00063 expval_table_float[exponent][value] = f; 00064 } 00065 exp_table_fixed[exponent] = expval_table_fixed[exponent][1]; 00066 exp_table_float[exponent] = expval_table_float[exponent][1]; 00067 } 00068 } 00069 #endif /* CONFIG_HARDCODED_TABLES */ 00070 00071 #endif /* AVCODEC_MPEGAUDIO_TABLEGEN_H */