• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavcodec/mpegaudio_tablegen.h

Go to the documentation of this file.
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 MPEGAUDIO_TABLEGEN_H
00024 #define MPEGAUDIO_TABLEGEN_H
00025 
00026 #include <stdint.h>
00027 // do not use libavutil/mathematics.h since this is compiled both
00028 // for the host and the target and config.h is only valid for the target
00029 #include <math.h>
00030 
00031 #define TABLE_4_3_SIZE (8191 + 16)*4
00032 #if CONFIG_HARDCODED_TABLES
00033 #define mpegaudio_tableinit()
00034 #include "libavcodec/mpegaudio_tables.h"
00035 #else
00036 static int8_t   table_4_3_exp[TABLE_4_3_SIZE];
00037 static uint32_t table_4_3_value[TABLE_4_3_SIZE];
00038 static uint32_t exp_table[512];
00039 static uint32_t expval_table[512][16];
00040 
00041 static void mpegaudio_tableinit(void)
00042 {
00043     int i, value, exponent;
00044     for (i = 1; i < TABLE_4_3_SIZE; i++) {
00045         double value = i / 4;
00046         double f, fm;
00047         int e, m;
00048         f  = value * cbrtf(value) * pow(2, (i & 3) * 0.25);
00049         fm = frexp(f, &e);
00050         m  = (uint32_t)(fm * (1LL << 31) + 0.5);
00051         e += FRAC_BITS - 31 + 5 - 100;
00052 
00053         /* normalized to FRAC_BITS */
00054         table_4_3_value[i] =  m;
00055         table_4_3_exp[i]   = -e;
00056     }
00057     for (exponent = 0; exponent < 512; exponent++) {
00058         for (value = 0; value < 16; value++) {
00059             double f = (double)value * cbrtf(value) * pow(2, (exponent - 400) * 0.25 + FRAC_BITS + 5);
00060             expval_table[exponent][value] = llrint(f);
00061         }
00062         exp_table[exponent] = expval_table[exponent][1];
00063     }
00064 }
00065 #endif /* CONFIG_HARDCODED_TABLES */
00066 
00067 #endif /* MPEGAUDIO_TABLEGEN_H */

Generated on Fri Sep 16 2011 17:17:40 for FFmpeg by  doxygen 1.7.1