Delete mathematics.cpp/h

This commit is contained in:
Henrik Rydgård 2024-05-01 11:56:24 +02:00
parent 50bb07a6f5
commit c6502155ab
16 changed files with 65 additions and 203 deletions

View File

@ -395,7 +395,6 @@
<ClInclude Include="..\ext\at3_standalone\float_dsp.h" />
<ClInclude Include="..\ext\at3_standalone\get_bits.h" />
<ClInclude Include="..\ext\at3_standalone\intreadwrite.h" />
<ClInclude Include="..\ext\at3_standalone\mathematics.h" />
<ClInclude Include="..\ext\at3_standalone\mem.h" />
<ClInclude Include="..\ext\at3_standalone\sinewin.h" />
<ClInclude Include="..\ext\basis_universal\basisu.h" />
@ -606,7 +605,6 @@
<ClCompile Include="..\ext\at3_standalone\compat.cpp" />
<ClCompile Include="..\ext\at3_standalone\fft.cpp" />
<ClCompile Include="..\ext\at3_standalone\float_dsp.cpp" />
<ClCompile Include="..\ext\at3_standalone\mathematics.cpp" />
<ClCompile Include="..\ext\at3_standalone\mem.cpp" />
<ClCompile Include="..\ext\at3_standalone\sinewin.cpp" />
<ClCompile Include="..\ext\basis_universal\basisu_transcoder.cpp" />

View File

@ -551,9 +551,6 @@
<ClInclude Include="..\ext\at3_standalone\intreadwrite.h">
<Filter>ext\at3_standalone</Filter>
</ClInclude>
<ClInclude Include="..\ext\at3_standalone\mathematics.h">
<Filter>ext\at3_standalone</Filter>
</ClInclude>
<ClInclude Include="..\ext\at3_standalone\at3_decoders.h">
<Filter>ext\at3_standalone</Filter>
</ClInclude>
@ -1044,9 +1041,6 @@
<ClCompile Include="..\ext\at3_standalone\atrac.cpp">
<Filter>ext\at3_standalone</Filter>
</ClCompile>
<ClCompile Include="..\ext\at3_standalone\mathematics.cpp">
<Filter>ext\at3_standalone</Filter>
</ClCompile>
<ClCompile Include="..\ext\at3_standalone\fft.cpp">
<Filter>ext\at3_standalone</Filter>
</ClCompile>

View File

@ -251,7 +251,6 @@
<ClInclude Include="..\..\ext\at3_standalone\float_dsp.h" />
<ClInclude Include="..\..\ext\at3_standalone\get_bits.h" />
<ClInclude Include="..\..\ext\at3_standalone\intreadwrite.h" />
<ClInclude Include="..\..\ext\at3_standalone\mathematics.h" />
<ClInclude Include="..\..\ext\at3_standalone\mem.h" />
<ClInclude Include="..\..\ext\at3_standalone\sinewin.h" />
<ClInclude Include="..\..\ext\basis_universal\basisu.h" />
@ -404,7 +403,6 @@
<ClCompile Include="..\..\ext\at3_standalone\fft.cpp" />
<ClCompile Include="..\..\ext\at3_standalone\float_dsp.cpp" />
<ClCompile Include="..\..\ext\at3_standalone\get_bits.cpp" />
<ClCompile Include="..\..\ext\at3_standalone\mathematics.cpp" />
<ClCompile Include="..\..\ext\at3_standalone\mem.cpp" />
<ClCompile Include="..\..\ext\at3_standalone\sinewin.cpp" />
<ClCompile Include="..\..\ext\basis_universal\basisu_transcoder.cpp" />
@ -456,4 +454,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -492,9 +492,6 @@
<ClCompile Include="..\..\ext\at3_standalone\get_bits.cpp">
<Filter>ext\at3_standalone</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\at3_standalone\mathematics.cpp">
<Filter>ext\at3_standalone</Filter>
</ClCompile>
<ClCompile Include="..\..\ext\at3_standalone\mem.cpp">
<Filter>ext\at3_standalone</Filter>
</ClCompile>
@ -949,9 +946,6 @@
<ClInclude Include="..\..\ext\at3_standalone\intreadwrite.h">
<Filter>ext\at3_standalone</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\at3_standalone\mathematics.h">
<Filter>ext\at3_standalone</Filter>
</ClInclude>
<ClInclude Include="..\..\ext\at3_standalone\mem.h">
<Filter>ext\at3_standalone</Filter>
</ClInclude>
@ -1006,4 +1000,4 @@
<Filter>ext\at3_standalone</Filter>
</Text>
</ItemGroup>
</Project>
</Project>

View File

@ -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

View File

@ -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
)

View File

@ -28,7 +28,6 @@
#include <string.h>
#include <stdlib.h>
#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.
*

View File

@ -41,6 +41,7 @@
#endif
#define _USE_MATH_DEFINES
#include <math.h>
#include <string.h>

View File

@ -29,8 +29,10 @@
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#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;j<np;j++)
s->tmp_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 <stdlib.h>
#include <string.h>
#include "mathematics.h"
#include "fft.h"
#include "mem.h"

View File

@ -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];
}

View File

@ -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

View File

@ -33,7 +33,6 @@
#include "compat.h"
#include "mem.h"
#include "mathematics.h"
#include "get_bits.h"
static const uint8_t ff_reverse[256] = {

View File

@ -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:

View File

@ -1,57 +0,0 @@
/*
* Copyright (c) 2005-2012 Michael Niedermayer <michaelni@gmx.at>
*
* 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 <stdint.h>
#include <limits.h>
#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;
}

View File

@ -1,78 +0,0 @@
/*
* copyright (c) 2005-2012 Michael Niedermayer <michaelni@gmx.at>
*
* 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 <stdint.h>
#include <math.h>
#include <limits.h>
#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);
}

View File

@ -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