diff --git a/Common/Common.vcxproj b/Common/Common.vcxproj index 17e2d3ab13..8745044801 100644 --- a/Common/Common.vcxproj +++ b/Common/Common.vcxproj @@ -395,7 +395,6 @@ - @@ -606,7 +605,6 @@ - diff --git a/Common/Common.vcxproj.filters b/Common/Common.vcxproj.filters index 2940bc7f88..50f2086669 100644 --- a/Common/Common.vcxproj.filters +++ b/Common/Common.vcxproj.filters @@ -551,9 +551,6 @@ ext\at3_standalone - - ext\at3_standalone - ext\at3_standalone @@ -1044,9 +1041,6 @@ ext\at3_standalone - - ext\at3_standalone - ext\at3_standalone diff --git a/UWP/CommonUWP/CommonUWP.vcxproj b/UWP/CommonUWP/CommonUWP.vcxproj index fcaeb8cc3f..4939854018 100644 --- a/UWP/CommonUWP/CommonUWP.vcxproj +++ b/UWP/CommonUWP/CommonUWP.vcxproj @@ -251,7 +251,6 @@ - @@ -404,7 +403,6 @@ - @@ -456,4 +454,4 @@ - \ No newline at end of file + diff --git a/UWP/CommonUWP/CommonUWP.vcxproj.filters b/UWP/CommonUWP/CommonUWP.vcxproj.filters index 0855ecae23..bea74ab0cc 100644 --- a/UWP/CommonUWP/CommonUWP.vcxproj.filters +++ b/UWP/CommonUWP/CommonUWP.vcxproj.filters @@ -492,9 +492,6 @@ ext\at3_standalone - - ext\at3_standalone - ext\at3_standalone @@ -949,9 +946,6 @@ ext\at3_standalone - - ext\at3_standalone - ext\at3_standalone @@ -1006,4 +1000,4 @@ ext\at3_standalone - \ No newline at end of file + diff --git a/android/jni/Android.mk b/android/jni/Android.mk index cfc31293e8..f6ddf4100e 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -122,7 +122,6 @@ AT3_STANDALONE_FILES := \ ${SRC}/ext/at3_standalone/compat.cpp \ ${SRC}/ext/at3_standalone/fft.cpp \ ${SRC}/ext/at3_standalone/float_dsp.cpp \ - ${SRC}/ext/at3_standalone/mathematics.cpp \ ${SRC}/ext/at3_standalone/mem.cpp \ ${SRC}/ext/at3_standalone/sinewin.cpp diff --git a/ext/at3_standalone/CMakeLists.txt b/ext/at3_standalone/CMakeLists.txt index 8c5ab175e2..e9c5452b13 100644 --- a/ext/at3_standalone/CMakeLists.txt +++ b/ext/at3_standalone/CMakeLists.txt @@ -15,7 +15,6 @@ set(ALL_SOURCE_FILES ${SRC_DIR}/compat.cpp ${SRC_DIR}/fft.cpp ${SRC_DIR}/float_dsp.cpp - ${SRC_DIR}/mathematics.cpp ${SRC_DIR}/mem.cpp ${SRC_DIR}/sinewin.cpp ) diff --git a/ext/at3_standalone/atrac3plus.cpp b/ext/at3_standalone/atrac3plus.cpp index d5add102c8..01a5fbe801 100644 --- a/ext/at3_standalone/atrac3plus.cpp +++ b/ext/at3_standalone/atrac3plus.cpp @@ -28,7 +28,6 @@ #include #include -#include "mathematics.h" #include "get_bits.h" #include "atrac3plus.h" #include "atrac3plus_data.h" @@ -41,6 +40,34 @@ static VLC spec_vlc_tabs[112]; static VLC gain_vlc_tabs[11]; static VLC tone_vlc_tabs[7]; +static const uint8_t ff_logg2_tab[256] = { + 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 +}; + +// todo: Replace with clz type instructions. +int av_log2(unsigned int v) +{ + int n = 0; + if (v & 0xffff0000) { + v >>= 16; + n += 16; + } + if (v & 0xff00) { + v >>= 8; + n += 8; + } + n += ff_logg2_tab[v]; + + return n; +} + /** * Generate canonical VLC table from given descriptor. * @@ -788,6 +815,16 @@ static int decode_code_table_indexes(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, return 0; } +/** + * Clear high bits from an unsigned integer starting with specific bit position + * @param a value to clip + * @param p bit position to clip at + * @return clipped value + */ +inline unsigned av_mod_uintp2(unsigned a, unsigned p) { + return a & ((1 << p) - 1); +} + /** * Decode huffman-coded spectral lines for a given quant unit. * diff --git a/ext/at3_standalone/atrac3plusdsp.cpp b/ext/at3_standalone/atrac3plusdsp.cpp index 004515819c..d7bbd0b792 100644 --- a/ext/at3_standalone/atrac3plusdsp.cpp +++ b/ext/at3_standalone/atrac3plusdsp.cpp @@ -41,6 +41,7 @@ #endif +#define _USE_MATH_DEFINES #include #include diff --git a/ext/at3_standalone/fft.cpp b/ext/at3_standalone/fft.cpp index 2201901c32..fa07c7844a 100644 --- a/ext/at3_standalone/fft.cpp +++ b/ext/at3_standalone/fft.cpp @@ -29,8 +29,10 @@ #include #include +#define _USE_MATH_DEFINES +#include + #include "mem.h" -#include "mathematics.h" #include "fft.h" #define sqrthalf (float)M_SQRT1_2 @@ -70,7 +72,6 @@ static FFTSample * const av_cos_tabs[] = { av_cos_65536, }; -void fft_permute(FFTContext *s, FFTComplex *z); void fft_calc(FFTContext *s, FFTComplex *z); static int split_radix_permutation(int i, int n, int inverse) @@ -146,17 +147,6 @@ int ff_fft_init(FFTContext *s, int nbits, int inverse) return -1; } -void fft_permute(FFTContext *s, FFTComplex *z) -{ - int j, np; - const uint16_t *revtab = s->revtab; - np = 1 << s->nbits; - /* TODO: handle split-radix permute in a more optimal way, probably in-place */ - for(j=0;jtmp_buf[revtab[j]] = z[j]; - memcpy(z, s->tmp_buf, np * sizeof(FFTComplex)); -} - void ff_fft_end(FFTContext *s) { av_freep(&s->revtab); @@ -269,7 +259,6 @@ static void fft8(FFTComplex *z) TRANSFORM(z[1],z[3],z[5],z[7],sqrthalf,sqrthalf); } -#if !CONFIG_SMALL static void fft16(FFTComplex *z) { FFTDouble t1, t2, t3, t4, t5, t6; @@ -285,17 +274,12 @@ static void fft16(FFTComplex *z) TRANSFORM(z[1],z[5],z[9],z[13],cos_16_1,cos_16_3); TRANSFORM(z[3],z[7],z[11],z[15],cos_16_3,cos_16_1); } -#else -DECL_FFT(16,8,4) -#endif DECL_FFT(32,16,8) DECL_FFT(64,32,16) DECL_FFT(128,64,32) DECL_FFT(256,128,64) DECL_FFT(512,256,128) -#if !CONFIG_SMALL #define pass pass_big -#endif DECL_FFT(1024,512,256) static void (* const fft_dispatch[])(FFTComplex*) = { @@ -309,7 +293,6 @@ void fft_calc(FFTContext *s, FFTComplex *z) { #include #include -#include "mathematics.h" #include "fft.h" #include "mem.h" diff --git a/ext/at3_standalone/float_dsp.cpp b/ext/at3_standalone/float_dsp.cpp index 91e78e03e7..75dbdb6918 100644 --- a/ext/at3_standalone/float_dsp.cpp +++ b/ext/at3_standalone/float_dsp.cpp @@ -35,15 +35,9 @@ void vector_fmul_scalar(float *dst, const float *src, float mul, int len) { dst[i] = src[i] * mul; } -void vector_fmul_add(float *dst, const float *src0, const float *src1, const float *src2, int len) { - int i; - for (i = 0; i < len; i++) - dst[i] = src0[i] * src1[i] + src2[i]; -} - void vector_fmul_reverse(float *dst, const float *src0, const float *src1, int len) { int i; - src1 += len-1; + src1 += len - 1; for (i = 0; i < len; i++) dst[i] = src0[i] * src1[-i]; } diff --git a/ext/at3_standalone/float_dsp.h b/ext/at3_standalone/float_dsp.h index 9379c7a7d1..c379dd17ba 100644 --- a/ext/at3_standalone/float_dsp.h +++ b/ext/at3_standalone/float_dsp.h @@ -26,23 +26,6 @@ void vector_fmul(float *dst, const float *src0, const float *src1, int len); */ void vector_fmul_scalar(float *dst, const float *src, float mul, int len); -/** - * Calculate the entry wise product of two vectors of floats, add a third vector of - * floats and store the result in a vector of floats. - * - * @param dst output vector - * constraints: 32-byte aligned - * @param src0 first input vector - * constraints: 32-byte aligned - * @param src1 second input vector - * constraints: 32-byte aligned - * @param src2 third input vector - * constraints: 32-byte aligned - * @param len number of elements in the input - * constraints: multiple of 16 - */ -void vector_fmul_add(float *dst, const float *src0, const float *src1, const float *src2, int len); - /** * Calculate the entry wise product of two vectors of floats, and store the result * in a vector of floats. The second vector of floats is iterated over diff --git a/ext/at3_standalone/get_bits.cpp b/ext/at3_standalone/get_bits.cpp index d7a6da5226..02812a1601 100644 --- a/ext/at3_standalone/get_bits.cpp +++ b/ext/at3_standalone/get_bits.cpp @@ -33,7 +33,6 @@ #include "compat.h" #include "mem.h" -#include "mathematics.h" #include "get_bits.h" static const uint8_t ff_reverse[256] = { diff --git a/ext/at3_standalone/get_bits.h b/ext/at3_standalone/get_bits.h index 4cc1178889..9366026eea 100644 --- a/ext/at3_standalone/get_bits.h +++ b/ext/at3_standalone/get_bits.h @@ -24,7 +24,26 @@ #include "compat.h" #include "intreadwrite.h" -#include "mathematics.h" + +#ifndef NEG_SSR32 +# define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s))) +#endif + +#ifndef NEG_USR32 +# define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s))) +#endif + +static inline unsigned zero_extend(unsigned val, unsigned bits) +{ + return (val << ((8 * sizeof(int)) - bits)) >> ((8 * sizeof(int)) - bits); +} + +static inline int sign_extend(int val, unsigned bits) +{ + unsigned shift = 8 * sizeof(int) - bits; + union { unsigned u; int s; } v = { (unsigned)val << shift }; + return v.s >> shift; +} /* * Safe bitstream reading: diff --git a/ext/at3_standalone/mathematics.cpp b/ext/at3_standalone/mathematics.cpp deleted file mode 100644 index 44efb6f18b..0000000000 --- a/ext/at3_standalone/mathematics.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2005-2012 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg 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. - * - * FFmpeg 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 FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * miscellaneous math routines and tables - */ - -#include -#include - -#include "mathematics.h" -#include "compat.h" - -static const uint8_t ff_logg2_tab[256] = { - 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 -}; - -int av_log2(unsigned int v) -{ - int n = 0; - if (v & 0xffff0000) { - v >>= 16; - n += 16; - } - if (v & 0xff00) { - v >>= 8; - n += 8; - } - n += ff_logg2_tab[v]; - - return n; -} diff --git a/ext/at3_standalone/mathematics.h b/ext/at3_standalone/mathematics.h deleted file mode 100644 index 6a0ac4882d..0000000000 --- a/ext/at3_standalone/mathematics.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * copyright (c) 2005-2012 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg 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. - * - * FFmpeg 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 FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#pragma once - -#include -#include -#include - -#include "compat.h" - -int av_log2(unsigned int v); - -static inline int sign_extend(int val, unsigned bits) -{ - unsigned shift = 8 * sizeof(int) - bits; - union { unsigned u; int s; } v = { (unsigned)val << shift }; - return v.s >> shift; -} - -static inline unsigned zero_extend(unsigned val, unsigned bits) -{ - return (val << ((8 * sizeof(int)) - bits)) >> ((8 * sizeof(int)) - bits); -} - -#ifndef NEG_SSR32 -# define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s))) -#endif - -#ifndef NEG_USR32 -# define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s))) -#endif - -#ifndef M_LOG2_10 -#define M_LOG2_10 3.32192809488736234787 /* log_2 10 */ -#endif -#ifndef M_PHI -#define M_PHI 1.61803398874989484820 /* phi / golden ratio */ -#endif -#ifndef M_PI -#define M_PI 3.14159265358979323846 /* pi */ -#endif -#ifndef M_PI_2 -#define M_PI_2 1.57079632679489661923 /* pi/2 */ -#endif -#ifndef M_SQRT1_2 -#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ -#endif -#ifndef M_SQRT2 -#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ -#endif -/** - * Clear high bits from an unsigned integer starting with specific bit position - * @param a value to clip - * @param p bit position to clip at - * @return clipped value - */ -static inline unsigned av_mod_uintp2(unsigned a, unsigned p) -{ - return a & ((1 << p) - 1); -} diff --git a/libretro/Makefile.common b/libretro/Makefile.common index 47a886af34..7e6a998116 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -272,7 +272,6 @@ SOURCES_CXX += \ ${EXTDIR}/at3_standalone/compat.cpp \ ${EXTDIR}/at3_standalone/fft.cpp \ ${EXTDIR}/at3_standalone/float_dsp.cpp \ - ${EXTDIR}/at3_standalone/mathematics.cpp \ ${EXTDIR}/at3_standalone/mem.cpp \ ${EXTDIR}/at3_standalone/sinewin.cpp