diff --git a/libavcodec/Makefile b/libavcodec/Makefile index aaf9ceb4f97327bfae392c4e9ebf2d62b4c7ea00..fa70216c9c176a56886a11bb32958f2014aeeafc 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -27,7 +27,7 @@ OBJS = allcodecs.o \ OBJS-$(CONFIG_AANDCT) += aandcttab.o OBJS-$(CONFIG_AC3DSP) += ac3dsp.o OBJS-$(CONFIG_ENCODERS) += faandct.o jfdctfst.o jfdctint.o -OBJS-$(CONFIG_DCT) += dct.o +OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o OBJS-$(CONFIG_DWT) += dwt.o OBJS-$(CONFIG_DXVA2) += dxva2.o FFT-OBJS-$(CONFIG_HARDCODED_TABLES) += cos_tables.o cos_fixed_tables.o diff --git a/libavcodec/dct.c b/libavcodec/dct.c index caa6bdb4b4b407e3b1003519e5926b4bdd6144c8..5c63af30a1a536347ab1f4f81711645441ce9bd9 100644 --- a/libavcodec/dct.c +++ b/libavcodec/dct.c @@ -30,9 +30,7 @@ #include #include "libavutil/mathematics.h" #include "dct.h" - -#define DCT32_FLOAT -#include "dct32.c" +#include "dct32.h" /* sin((M_PI * x / (2*n)) */ #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) } } - s->dct32 = dct32; + s->dct32 = ff_dct32_float; if (HAVE_MMX) ff_dct_init_mmx(s); return 0; diff --git a/libavcodec/dct32.c b/libavcodec/dct32.c index ae99d889965d79126b9a03204c10d706675d99f8..272e0dbf955bd9e0bca40f07ad1b35eebd8b4bf0 100644 --- a/libavcodec/dct32.c +++ b/libavcodec/dct32.c @@ -19,10 +19,19 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifdef DCT32_FLOAT +#include "dct32.h" +#include "mathops.h" + +#if DCT32_FLOAT +# define dct32 ff_dct32_float # define FIXHR(x) ((float)(x)) # define MULH3(x, y, s) ((s)*(y)*(x)) # define INTFLOAT float +#else +# define dct32 ff_dct32_fixed +# define FIXHR(a) ((int)((a) * (1LL<<32) + 0.5)) +# define MULH3(x, y, s) MULH((s)*(x), y) +# define INTFLOAT int #endif @@ -103,7 +112,7 @@ #define ADD(a, b) val##a += val##b /* DCT32 without 1/sqrt(2) coef zero scaling. */ -static void dct32(INTFLOAT *out, const INTFLOAT *tab) +void dct32(INTFLOAT *out, const INTFLOAT *tab) { INTFLOAT tmp0, tmp1; diff --git a/libavcodec/dct32.h b/libavcodec/dct32.h new file mode 100644 index 0000000000000000000000000000000000000000..110338d25c5e4295fd61e760f76efb3aa52fea7b --- /dev/null +++ b/libavcodec/dct32.h @@ -0,0 +1,25 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_DCT32_H +#define AVCODEC_DCT32_H + +void ff_dct32_float(float *dst, const float *src); +void ff_dct32_fixed(int *dst, const int *src); + +#endif diff --git a/libavcodec/dct32_fixed.c b/libavcodec/dct32_fixed.c new file mode 100644 index 0000000000000000000000000000000000000000..7eb9dc1a532cf134e181f1bc4afc579dfafb31ea --- /dev/null +++ b/libavcodec/dct32_fixed.c @@ -0,0 +1,20 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#define DCT32_FLOAT 0 +#include "dct32.c" diff --git a/libavcodec/dct32_float.c b/libavcodec/dct32_float.c new file mode 100644 index 0000000000000000000000000000000000000000..727ec3caca1c9ba07430420d7599378b889380da --- /dev/null +++ b/libavcodec/dct32_float.c @@ -0,0 +1,20 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#define DCT32_FLOAT 1 +#include "dct32.c" diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c index 8c42e09666750c69cd6ac4d0a735293dab82363c..35e217ea3e111218379e464be595b555de6e6275 100644 --- a/libavcodec/mpegaudiodec.c +++ b/libavcodec/mpegaudiodec.c @@ -29,6 +29,7 @@ #include "get_bits.h" #include "dsputil.h" #include "mathops.h" +#include "dct32.h" /* * TODO: @@ -68,12 +69,6 @@ #include "mpegaudiodata.h" #include "mpegaudiodectab.h" -#if CONFIG_FLOAT -# include "fft.h" -#else -# include "dct32.c" -#endif - static void compute_antialias(MPADecodeContext *s, GranuleDef *g); static void apply_window_mp3_c(MPA_INT *synth_buf, MPA_INT *window, 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, offset = *synth_buf_offset; synth_buf = synth_buf_ptr + offset; - dct32(synth_buf, sb_samples); + ff_dct32_fixed(synth_buf, sb_samples); apply_window_mp3_c(synth_buf, window, dither_state, samples, incr); offset = (offset - 32) & 511;