Commit abe043f0 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Moving everything to the same type abstraction (sort of).

parent 3d3bb685
......@@ -35,40 +35,8 @@
#ifndef ARCH_H
#define ARCH_H
/* A couple test to catch stupid option combinations */
#ifdef FIXED_POINT
#ifdef FLOATING_POINT
#error You cannot compile as floating point and fixed point at the same time
#endif
#ifdef _USE_SSE
#error SSE is only for floating-point
#endif
#if ((defined (ARM4_ASM)||defined (ARM4_ASM)) && defined(BFIN_ASM)) || (defined (ARM4_ASM)&&defined(ARM5E_ASM))
#error Make up your mind. What CPU do you have?
#endif
#ifdef VORBIS_PSYCHO
#error Vorbis-psy model currently not implemented in fixed-point
#endif
#else
/*#ifndef FLOATING_POINT
#error You now need to define either FIXED_POINT or FLOATING_POINT
#endif
#if defined (ARM4_ASM) || defined(ARM5E_ASM) || defined(BFIN_ASM)
#error I suppose you can have a [ARM4/ARM5E/Blackfin] that has float instructions?
#endif
#ifdef FIXED_POINT_DEBUG
#error "Don't you think enabling fixed-point is a good thing to do if you want to debug that?"
#endif*/
#endif
#include "celt_types.h"
typedef unsigned long long celt_uint64_t;
typedef int spx_int32_t;
typedef short spx_int16_t;
#define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */
#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */
......@@ -80,12 +48,8 @@ typedef short spx_int16_t;
#ifdef FIXED_POINT
typedef spx_int16_t spx_word16_t;
typedef spx_int32_t spx_word32_t;
typedef spx_word32_t spx_mem_t;
typedef spx_word16_t spx_coef_t;
typedef spx_word16_t spx_lsp_t;
typedef spx_word32_t spx_sig_t;
typedef celt_int16_t celt_word16_t;
typedef celt_int32_t celt_word32_t;
#define Q15ONE 32767
......@@ -102,9 +66,9 @@ typedef spx_word32_t spx_sig_t;
#define GAIN_SHIFT 6
#define VERY_SMALL 0
#define VERY_LARGE32 ((spx_word32_t)2147483647)
#define VERY_LARGE16 ((spx_word16_t)32767)
#define Q15_ONE ((spx_word16_t)32767)
#define VERY_LARGE32 ((celt_word32_t)2147483647)
#define VERY_LARGE16 ((celt_word16_t)32767)
#define Q15_ONE ((celt_word16_t)32767)
#ifdef FIXED_DEBUG
......@@ -126,12 +90,8 @@ typedef spx_word32_t spx_sig_t;
#else
typedef float spx_mem_t;
typedef float spx_coef_t;
typedef float spx_lsp_t;
typedef float spx_sig_t;
typedef float spx_word16_t;
typedef float spx_word32_t;
typedef float celt_word16_t;
typedef float celt_word32_t;
#define Q15ONE 1.0f
#define LPC_SCALING 1.f
......@@ -145,7 +105,7 @@ typedef float spx_word32_t;
#define VERY_SMALL 1e-15f
#define VERY_LARGE32 1e15f
#define VERY_LARGE16 1e15f
#define Q15_ONE ((spx_word16_t)1.f)
#define Q15_ONE ((celt_word16_t)1.f)
#define QCONST16(x,bits) (x)
#define QCONST32(x,bits) (x)
......@@ -174,8 +134,8 @@ typedef float spx_word32_t;
#define ADD32(a,b) ((a)+(b))
#define SUB32(a,b) ((a)-(b))
#define MULT16_16_16(a,b) ((a)*(b))
#define MULT16_16(a,b) ((spx_word32_t)(a)*(spx_word32_t)(b))
#define MAC16_16(c,a,b) ((c)+(spx_word32_t)(a)*(spx_word32_t)(b))
#define MULT16_16(a,b) ((celt_word32_t)(a)*(celt_word32_t)(b))
#define MAC16_16(c,a,b) ((c)+(celt_word32_t)(a)*(celt_word32_t)(b))
#define MULT16_32_Q11(a,b) ((a)*(b))
#define MULT16_32_Q13(a,b) ((a)*(b))
......@@ -197,10 +157,10 @@ typedef float spx_word32_t;
#define MULT16_16_P13(a,b) ((a)*(b))
#define MULT16_16_P14(a,b) ((a)*(b))
#define DIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b))
#define PDIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b))
#define DIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b))
#define PDIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b))
#define DIV32_16(a,b) (((celt_word32_t)(a))/(celt_word16_t)(b))
#define PDIV32_16(a,b) (((celt_word32_t)(a))/(celt_word16_t)(b))
#define DIV32(a,b) (((celt_word32_t)(a))/(celt_word32_t)(b))
#define PDIV32(a,b) (((celt_word32_t)(a))/(celt_word32_t)(b))
#endif
......@@ -223,9 +183,4 @@ typedef float spx_word32_t;
#ifdef FIXED_DEBUG
long long spx_mips=0;
#endif
#endif
......@@ -22,7 +22,7 @@
#ifndef _CELT_TYPES_H
#define _CELT_TYPES_H
/* Taken from Paul Hsieh's stdint.h */
/* Use the real stdint.h if it's there (taken from Paul Hsieh's pstdint.h) */
#if (defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) )
#include <stdint.h>
......@@ -30,7 +30,8 @@
typedef uint16_t celt_uint16_t;
typedef int32_t celt_int32_t;
typedef uint32_t celt_uint32_t;
typedef int64_t celt_int64_t;
typedef uint64_t celt_uint64_t;
#elif defined(_WIN32)
# if defined(__CYGWIN__)
......@@ -39,22 +40,30 @@
typedef _G_uint32_t celt_uint32_t;
typedef _G_int16_t celt_int16_t;
typedef _G_uint16_t celt_uint16_t;
typedef _G_int64_t celt_int64_t;
typedef _G_uint64_t celt_uint64_t;
# elif defined(__MINGW32__)
typedef short celt_int16_t;
typedef unsigned short celt_uint16_t;
typedef int celt_int32_t;
typedef unsigned int celt_uint32_t;
typedef long long celt_int64_t;
typedef unsigned long long celt_uint64_t;
# elif defined(__MWERKS__)
typedef int celt_int32_t;
typedef unsigned int celt_uint32_t;
typedef short celt_int16_t;
typedef unsigned short celt_uint16_t;
typedef long long celt_int64_t;
typedef unsigned long long celt_uint64_t;
# else
/* MSVC/Borland */
typedef __int32 celt_int32_t;
typedef unsigned __int32 celt_uint32_t;
typedef __int16 celt_int16_t;
typedef unsigned __int16 celt_uint16_t;
typedef __int64 celt_int64_t;
typedef unsigned __int64 celt_uint64_t;
# endif
#elif defined(__MACOS__)
......@@ -64,6 +73,8 @@
typedef UInt16 celt_uint16_t;
typedef SInt32 celt_int32_t;
typedef UInt32 celt_uint32_t;
typedef SInt64 celt_int64_t;
typedef UInt64 celt_uint64_t;
#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */
......@@ -72,6 +83,8 @@
typedef u_int16_t celt_uint16_t;
typedef int32_t celt_int32_t;
typedef u_int32_t celt_uint32_t;
typedef int64_t celt_int64_t;
typedef u_int64_t celt_uint64_t;
#elif defined(__BEOS__)
......@@ -81,6 +94,8 @@
typedef u_int16_t celt_uint16_t;
typedef int32_t celt_int32_t;
typedef u_int32_t celt_uint32_t;
typedef int64_t celt_int64_t;
typedef u_int64_t celt_uint64_t;
#elif defined (__EMX__)
......@@ -89,6 +104,8 @@
typedef unsigned short celt_uint16_t;
typedef int celt_int32_t;
typedef unsigned int celt_uint32_t;
typedef long long celt_int64_t;
typedef unsigned long long celt_uint64_t;
#elif defined (DJGPP)
......@@ -96,6 +113,8 @@
typedef short celt_int16_t;
typedef int celt_int32_t;
typedef unsigned int celt_uint32_t;
typedef long long celt_int64_t;
typedef unsigned long long celt_uint64_t;
#elif defined(R5900)
......@@ -103,6 +122,8 @@
typedef int celt_int32_t;
typedef unsigned celt_uint32_t;
typedef short celt_int16_t;
typedef long celt_int64_t;
typedef unsigned long celt_uint64_t;
#elif defined(__SYMBIAN32__)
......@@ -111,6 +132,8 @@
typedef unsigned short celt_uint16_t;
typedef signed int celt_int32_t;
typedef unsigned int celt_uint32_t;
typedef long long int celt_int64_t;
typedef unsigned long long int celt_uint64_t;
#elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)
......@@ -118,6 +141,8 @@
typedef unsigned short celt_uint16_t;
typedef long celt_int32_t;
typedef unsigned long celt_uint32_t;
typedef long long celt_int64_t;
typedef unsigned long long celt_uint64_t;
#elif defined(CONFIG_TI_C6X)
......@@ -125,6 +150,8 @@
typedef unsigned short celt_uint16_t;
typedef int celt_int32_t;
typedef unsigned int celt_uint32_t;
typedef long long int celt_int64_t;
typedef unsigned long long int celt_uint64_t;
#else
......@@ -133,6 +160,8 @@
typedef unsigned short celt_uint16_t;
typedef long celt_int32_t;
typedef unsigned long celt_uint32_t;
typedef long long celt_int64_t;
typedef unsigned long long celt_uint64_t;
#endif
......
......@@ -33,8 +33,8 @@
/*Returns the numer of ways of choosing _m elements from a set of size _n with
replacement when a sign bit is needed for each unique element.*/
#if 0
static unsigned ncwrs(int _n,int _m){
static unsigned c[32][32];
static celt_uint32_t ncwrs(int _n,int _m){
static celt_uint32_t c[32][32];
if(_n<0||_m<0)return 0;
if(!c[_n][_m]){
if(_m<=0)c[_n][_m]=1;
......@@ -43,10 +43,10 @@ static unsigned ncwrs(int _n,int _m){
return c[_n][_m];
}
#else
unsigned ncwrs(int _n,int _m){
unsigned ret;
unsigned f;
unsigned d;
celt_uint32_t ncwrs(int _n,int _m){
celt_uint32_t ret;
celt_uint32_t f;
celt_uint32_t d;
int i;
if(_n<0||_m<0)return 0;
if(_m==0)return 1;
......@@ -86,13 +86,13 @@ celt_uint64_t ncwrs64(int _n,int _m){
with associated sign bits.
_x: Returns the combination with elements sorted in ascending order.
_s: Returns the associated sign bits.*/
void cwrsi(int _n,int _m,unsigned _i,int *_x,int *_s){
void cwrsi(int _n,int _m,celt_uint32_t _i,int *_x,int *_s){
int j;
int k;
for(k=j=0;k<_m;k++){
unsigned pn;
unsigned p;
unsigned t;
celt_uint32_t pn;
celt_uint32_t p;
celt_uint32_t t;
p=ncwrs(_n-j,_m-k-1);
pn=ncwrs(_n-j-1,_m-k-1);
p+=pn;
......@@ -118,14 +118,14 @@ void cwrsi(int _n,int _m,unsigned _i,int *_x,int *_s){
of size _n with associated sign bits.
_x: The combination with elements sorted in ascending order.
_s: The associated sign bits.*/
unsigned icwrs(int _n,int _m,const int *_x,const int *_s){
unsigned i;
celt_uint32_t icwrs(int _n,int _m,const int *_x,const int *_s){
celt_uint32_t i;
int j;
int k;
i=0;
for(k=j=0;k<_m;k++){
unsigned pn;
unsigned p;
celt_uint32_t pn;
celt_uint32_t p;
p=ncwrs(_n-j,_m-k-1);
pn=ncwrs(_n-j-1,_m-k-1);
p+=pn;
......@@ -241,95 +241,3 @@ void pulse2comb(int _n,int _m,int *_x,int *_s,const int *_y){
}
}
#if 0
#include <stdio.h>
#define NMAX (10)
#define MMAX (9)
int main(int _argc,char **_argv){
int n;
for(n=0;n<=NMAX;n++){
int m;
for(m=0;m<=MMAX;m++){
unsigned nc;
unsigned i;
nc=ncwrs(n,m);
for(i=0;i<nc;i++){
int x[MMAX];
int s[MMAX];
int x2[MMAX];
int s2[MMAX];
int y[NMAX];
int j;
int k;
cwrsi(n,m,i,x,s);
printf("%6u of %u:",i,nc);
for(k=0;k<m;k++){
printf(" %c%i",k>0&&x[k]==x[k-1]?' ':s[k]?'-':'+',x[k]);
}
printf(" ->");
if(icwrs(n,m,x,s)!=i){
fprintf(stderr,"Combination-index mismatch.\n");
}
comb2pulse(n,m,y,x,s);
for(j=0;j<n;j++)printf(" %c%i",y[j]?y[j]<0?'-':'+':' ',abs(y[j]));
printf("\n");
pulse2comb(n,m,x2,s2,y);
for(k=0;k<m;k++)if(x[k]!=x2[k]||s[k]!=s2[k]){
fprintf(stderr,"Pulse-combination mismatch.\n");
break;
}
}
printf("\n");
}
}
return -1;
}
#endif
#if 0
#include <stdio.h>
#define NMAX (32)
#define MMAX (16)
int main(int _argc,char **_argv){
int n;
for(n=0;n<=NMAX;n+=3){
int m;
for(m=0;m<=MMAX;m++){
celt_uint64_t nc;
celt_uint64_t i;
nc=ncwrs64(n,m);
printf("%d/%d: %llu",n,m, nc);
for(i=0;i<nc;i+=100000){
int x[MMAX];
int s[MMAX];
int x2[MMAX];
int s2[MMAX];
int y[NMAX];
int j;
int k;
cwrsi64(n,m,i,x,s);
/*printf("%llu of %llu:",i,nc);
for(k=0;k<m;k++){
printf(" %c%i",k>0&&x[k]==x[k-1]?' ':s[k]?'-':'+',x[k]);
}
printf(" ->");*/
if(icwrs64(n,m,x,s)!=i){
fprintf(stderr,"Combination-index mismatch.\n");
}
comb2pulse(n,m,y,x,s);
/*for(j=0;j<n;j++)printf(" %c%i",y[j]?y[j]<0?'-':'+':' ',abs(y[j]));
printf("\n");*/
pulse2comb(n,m,x2,s2,y);
for(k=0;k<m;k++)if(x[k]!=x2[k]||s[k]!=s2[k]){
fprintf(stderr,"Pulse-combination mismatch.\n");
break;
}
}
printf("\n");
}
}
return 0;
}
#endif
......@@ -34,11 +34,11 @@
#include "arch.h"
unsigned ncwrs(int _n,int _m);
celt_uint32_t ncwrs(int _n,int _m);
void cwrsi(int _n,int _m,unsigned _i,int *_x,int *_s);
void cwrsi(int _n,int _m,celt_uint32_t _i,int *_x,int *_s);
unsigned icwrs(int _n,int _m,const int *_x,const int *_s);
celt_uint32_t icwrs(int _n,int _m,const int *_x,const int *_s);
void comb2pulse(int _n,int _m,int *_y,const int *_x,const int *_s);
......
#include "celt_types.h"
#if !defined(_entcode_H)
# define _entcode_H (1)
# include <limits.h>
......@@ -5,8 +7,8 @@
typedef unsigned ec_uint32;
typedef unsigned long long ec_uint64;
typedef celt_uint32_t ec_uint32;
typedef celt_uint64_t ec_uint64;
typedef struct ec_byte_buffer ec_byte_buffer;
......
......@@ -44,10 +44,10 @@ void *spx_fft_init(int size);
void spx_fft_destroy(void *table);
/** Forward (real to half-complex) transform */
void spx_fft(void *table, spx_word16_t *in, spx_word16_t *out);
void spx_fft(void *table, celt_word16_t *in, celt_word16_t *out);
/** Backward (half-complex to real) transform */
void spx_ifft(void *table, spx_word16_t *in, spx_word16_t *out);
void spx_ifft(void *table, celt_word16_t *in, celt_word16_t *out);
/** Forward (real to half-complex) transform of float data */
void spx_fft_float(void *table, float *in, float *out);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment