Browse code

dct: build dct32 as separate object files

This builds the float and fixed-point versions of dct32 separately
instead of #including the file in dct.c and mpegaudiodec.c.

Signed-off-by: Mans Rullgard <mans@mansr.com>

Mans Rullgard authored on 2011/05/17 19:48:28
Showing 7 changed files
... ...
@@ -27,7 +27,7 @@ OBJS = allcodecs.o                                                      \
27 27
 OBJS-$(CONFIG_AANDCT)                  += aandcttab.o
28 28
 OBJS-$(CONFIG_AC3DSP)                  += ac3dsp.o
29 29
 OBJS-$(CONFIG_ENCODERS)                += faandct.o jfdctfst.o jfdctint.o
30
-OBJS-$(CONFIG_DCT)                     += dct.o
30
+OBJS-$(CONFIG_DCT)                     += dct.o dct32_fixed.o dct32_float.o
31 31
 OBJS-$(CONFIG_DWT)                     += dwt.o
32 32
 OBJS-$(CONFIG_DXVA2)                   += dxva2.o
33 33
 FFT-OBJS-$(CONFIG_HARDCODED_TABLES)    += cos_tables.o cos_fixed_tables.o
... ...
@@ -30,9 +30,7 @@
30 30
 #include <math.h>
31 31
 #include "libavutil/mathematics.h"
32 32
 #include "dct.h"
33
-
34
-#define DCT32_FLOAT
35
-#include "dct32.c"
33
+#include "dct32.h"
36 34
 
37 35
 /* sin((M_PI * x / (2*n)) */
38 36
 #define SIN(s,n,x) (s->costab[(n) - (x)])
... ...
@@ -210,7 +208,7 @@ av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse)
210 210
         }
211 211
     }
212 212
 
213
-    s->dct32 = dct32;
213
+    s->dct32 = ff_dct32_float;
214 214
     if (HAVE_MMX)     ff_dct_init_mmx(s);
215 215
 
216 216
     return 0;
... ...
@@ -19,10 +19,19 @@
19 19
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 20
  */
21 21
 
22
-#ifdef DCT32_FLOAT
22
+#include "dct32.h"
23
+#include "mathops.h"
24
+
25
+#if DCT32_FLOAT
26
+#   define dct32 ff_dct32_float
23 27
 #   define FIXHR(x)       ((float)(x))
24 28
 #   define MULH3(x, y, s) ((s)*(y)*(x))
25 29
 #   define INTFLOAT float
30
+#else
31
+#   define dct32 ff_dct32_fixed
32
+#   define FIXHR(a)       ((int)((a) * (1LL<<32) + 0.5))
33
+#   define MULH3(x, y, s) MULH((s)*(x), y)
34
+#   define INTFLOAT int
26 35
 #endif
27 36
 
28 37
 
... ...
@@ -103,7 +112,7 @@
103 103
 #define ADD(a, b) val##a += val##b
104 104
 
105 105
 /* DCT32 without 1/sqrt(2) coef zero scaling. */
106
-static void dct32(INTFLOAT *out, const INTFLOAT *tab)
106
+void dct32(INTFLOAT *out, const INTFLOAT *tab)
107 107
 {
108 108
     INTFLOAT tmp0, tmp1;
109 109
 
110 110
new file mode 100644
... ...
@@ -0,0 +1,25 @@
0
+/*
1
+ * This file is part of Libav.
2
+ *
3
+ * Libav is free software; you can redistribute it and/or
4
+ * modify it under the terms of the GNU Lesser General Public
5
+ * License as published by the Free Software Foundation; either
6
+ * version 2.1 of the License, or (at your option) any later version.
7
+ *
8
+ * Libav is distributed in the hope that it will be useful,
9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
+ * Lesser General Public License for more details.
12
+ *
13
+ * You should have received a copy of the GNU Lesser General Public
14
+ * License along with Libav; if not, write to the Free Software
15
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+ */
17
+
18
+#ifndef AVCODEC_DCT32_H
19
+#define AVCODEC_DCT32_H
20
+
21
+void ff_dct32_float(float *dst, const float *src);
22
+void ff_dct32_fixed(int *dst, const int *src);
23
+
24
+#endif
0 25
new file mode 100644
... ...
@@ -0,0 +1,20 @@
0
+/*
1
+ * This file is part of Libav.
2
+ *
3
+ * Libav is free software; you can redistribute it and/or
4
+ * modify it under the terms of the GNU Lesser General Public
5
+ * License as published by the Free Software Foundation; either
6
+ * version 2.1 of the License, or (at your option) any later version.
7
+ *
8
+ * Libav is distributed in the hope that it will be useful,
9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
+ * Lesser General Public License for more details.
12
+ *
13
+ * You should have received a copy of the GNU Lesser General Public
14
+ * License along with Libav; if not, write to the Free Software
15
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+ */
17
+
18
+#define DCT32_FLOAT 0
19
+#include "dct32.c"
0 20
new file mode 100644
... ...
@@ -0,0 +1,20 @@
0
+/*
1
+ * This file is part of Libav.
2
+ *
3
+ * Libav is free software; you can redistribute it and/or
4
+ * modify it under the terms of the GNU Lesser General Public
5
+ * License as published by the Free Software Foundation; either
6
+ * version 2.1 of the License, or (at your option) any later version.
7
+ *
8
+ * Libav is distributed in the hope that it will be useful,
9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
+ * Lesser General Public License for more details.
12
+ *
13
+ * You should have received a copy of the GNU Lesser General Public
14
+ * License along with Libav; if not, write to the Free Software
15
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+ */
17
+
18
+#define DCT32_FLOAT 1
19
+#include "dct32.c"
... ...
@@ -29,6 +29,7 @@
29 29
 #include "get_bits.h"
30 30
 #include "dsputil.h"
31 31
 #include "mathops.h"
32
+#include "dct32.h"
32 33
 
33 34
 /*
34 35
  * TODO:
... ...
@@ -68,12 +69,6 @@
68 68
 #include "mpegaudiodata.h"
69 69
 #include "mpegaudiodectab.h"
70 70
 
71
-#if CONFIG_FLOAT
72
-#    include "fft.h"
73
-#else
74
-#    include "dct32.c"
75
-#endif
76
-
77 71
 static void compute_antialias(MPADecodeContext *s, GranuleDef *g);
78 72
 static void apply_window_mp3_c(MPA_INT *synth_buf, MPA_INT *window,
79 73
                                int *dither_state, OUT_INT *samples, int incr);
... ...
@@ -637,7 +632,7 @@ void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
637 637
     offset = *synth_buf_offset;
638 638
     synth_buf = synth_buf_ptr + offset;
639 639
 
640
-    dct32(synth_buf, sb_samples);
640
+    ff_dct32_fixed(synth_buf, sb_samples);
641 641
     apply_window_mp3_c(synth_buf, window, dither_state, samples, incr);
642 642
 
643 643
     offset = (offset - 32) & 511;