[FFmpeg-cvslog] r20233 - trunk/libavcodec/mpegaudiodec.c
Reimar Döffinger
Reimar.Doeffinger
Thu Oct 15 11:23:13 CEST 2009
On Thu, Oct 15, 2009 at 10:59:31AM +0200, Reimar D?ffinger wrote:
> On Thu, Oct 15, 2009 at 09:57:18AM +0100, M?ns Rullg?rd wrote:
> > reimar <subversion at mplayerhq.hu> writes:
> >
> > > Author: reimar
> > > Date: Thu Oct 15 08:59:23 2009
> > > New Revision: 20233
> > >
> > > Log:
> > > Use cbrtf and exp2f instead of pow to calculate tables for MPEG
> > > audio decoding. This hopefully is fast enough so that it is
> > > reasonable to use the same formula directly instead of the table for
> > > CONFIG_SMALL.
> >
> > This broke AVR32, DOS, and a couple of BSDs. They seem to be missing
> > one or more of those functions.
>
> only exp2f seems to be missing on all of those. Opinions/suggestions?
Besides just reverting, I can also offer this patch
-------------- next part --------------
Index: libavcodec/mpegaudiodec.c
===================================================================
--- libavcodec/mpegaudiodec.c (revision 20233)
+++ libavcodec/mpegaudiodec.c (working copy)
@@ -27,6 +27,7 @@
#include "avcodec.h"
#include "get_bits.h"
#include "dsputil.h"
+#include "libavutil/mathematics.h"
/*
* TODO:
@@ -94,6 +95,7 @@
static uint16_t band_index_long[9][23];
/* XXX: free when all decoders are closed */
#define TABLE_4_3_SIZE (8191 + 16)*4
+static const double pow_2_025[4] = {1, 1.18920711500272106671, M_SQRT2, 1.68179283050742908604};
static int8_t table_4_3_exp[TABLE_4_3_SIZE];
static uint32_t table_4_3_value[TABLE_4_3_SIZE];
static uint32_t exp_table[512];
@@ -411,7 +413,7 @@
double value = i/4;
double f, fm;
int e, m;
- f = value * cbrtf(value) * exp2f((i&3)*0.25);
+ f = value * cbrtf(value) * pow_2_025[i&3];
fm = frexp(f, &e);
m = (uint32_t)(fm*(1LL<<31) + 0.5);
e+= FRAC_BITS - 31 + 5 - 100;
@@ -423,7 +425,7 @@
for(i=0; i<512*16; i++){
double value = i & 15;
int exponent= (i>>4);
- double f= value * cbrtf(value) * exp2f((exponent-400)*0.25 + FRAC_BITS + 5);
+ double f= value * cbrtf(value) * pow(2, (exponent-400)*0.25 + FRAC_BITS + 5);
expval_table[exponent][i&15]= llrint(f);
if((i&15)==1)
exp_table[exponent]= llrint(f);
Index: libavutil/mathematics.h
===================================================================
--- libavutil/mathematics.h (revision 20231)
+++ libavutil/mathematics.h (working copy)
@@ -38,6 +38,9 @@
#ifndef M_PI
#define M_PI 3.14159265358979323846 /* pi */
#endif
+#ifndef M_SQRT2
+#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
+#endif
#ifndef M_SQRT1_2
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
#endif
More information about the ffmpeg-cvslog
mailing list