Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Mark Harris
Opus
Commits
9a0bba18
Commit
9a0bba18
authored
Feb 20, 2008
by
Jean-Marc Valin
Browse files
Everything should now compile with a C89 compiler.
parent
0bb05bc5
Changes
11
Hide whitespace changes
Inline
Side-by-side
libcelt/pitch.c
View file @
9a0bba18
...
...
@@ -32,6 +32,7 @@
void
find_spectral_pitch
(
kiss_fftr_cfg
fft
,
struct
PsyDecay
*
decay
,
float
*
x
,
float
*
y
,
int
lag
,
int
len
,
int
C
,
int
*
pitch
)
{
int
c
,
i
;
float
max_corr
;
VARDECL
(
float
*
xx
);
VARDECL
(
float
*
yy
);
VARDECL
(
float
*
X
);
...
...
@@ -62,19 +63,19 @@ void find_spectral_pitch(kiss_fftr_cfg fft, struct PsyDecay *decay, float *x, fl
for
(
i
=
1
;
i
<
C
*
n2
;
i
++
)
{
float
n
;
float
n
,
tmp
;
/*n = 1.f/(1e1+sqrt(sqrt((X[2*i-1]*X[2*i-1] + X[2*i ]*X[2*i ])*(Y[2*i-1]*Y[2*i-1] + Y[2*i ]*Y[2*i ]))));*/
/*n = 1;*/
n
=
1
.
f
/
sqrt
(
1
+
curve
[
i
]);
/*n = 1.f/(1+curve[i]);*/
float
tmp
=
X
[
2
*
i
];
tmp
=
X
[
2
*
i
];
X
[
2
*
i
]
=
(
X
[
2
*
i
]
*
Y
[
2
*
i
]
+
X
[
2
*
i
+
1
]
*
Y
[
2
*
i
+
1
])
*
n
;
X
[
2
*
i
+
1
]
=
(
-
X
[
2
*
i
+
1
]
*
Y
[
2
*
i
]
+
tmp
*
Y
[
2
*
i
+
1
])
*
n
;
}
X
[
0
]
=
X
[
1
]
=
0
;
kiss_fftri
(
fft
,
X
,
xx
);
float
max_corr
=-
1e10
;
max_corr
=-
1e10
;
*
pitch
=
0
;
for
(
i
=
0
;
i
<
lag
-
len
;
i
++
)
{
...
...
libcelt/quant_bands.c
View file @
9a0bba18
...
...
@@ -37,6 +37,7 @@
#include "laplace.h"
#include <math.h>
#include "os_support.h"
#include "arch.h"
const
float
eMeans
[
24
]
=
{
45
.
f
,
-
8
.
f
,
-
12
.
f
,
-
2
.
5
f
,
1
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
,
0
.
f
};
...
...
@@ -49,9 +50,11 @@ static void quant_energy_mono(const CELTMode *m, float *eBands, float *oldEBands
int
bits
;
float
prev
=
0
;
float
coef
=
m
->
ePredCoef
;
float
error
[
m
->
nbEBands
]
;
VARDECL
(
float
*
error
)
;
/* The .7 is a heuristic */
float
beta
=
.
7
*
coef
;
ALLOC
(
error
,
m
->
nbEBands
,
float
);
bits
=
ec_enc_tell
(
enc
,
0
);
for
(
i
=
0
;
i
<
m
->
nbEBands
;
i
++
)
{
...
...
@@ -172,10 +175,11 @@ void quant_energy(const CELTMode *m, float *eBands, float *oldEBands, int budget
#if 1
{
int
c
;
VARDECL
(
float
*
E
);
ALLOC
(
E
,
m
->
nbEBands
,
float
);
for
(
c
=
0
;
c
<
C
;
c
++
)
{
int
i
;
float
E
[
m
->
nbEBands
];
for
(
i
=
0
;
i
<
m
->
nbEBands
;
i
++
)
E
[
i
]
=
eBands
[
C
*
i
+
c
];
quant_energy_mono
(
m
,
E
,
oldEBands
+
c
*
m
->
nbEBands
,
budget
/
C
,
enc
);
...
...
@@ -230,10 +234,11 @@ void unquant_energy(const CELTMode *m, float *eBands, float *oldEBands, int budg
unquant_energy_mono
(
m
,
eBands
,
oldEBands
,
budget
,
dec
);
else
{
int
c
;
VARDECL
(
float
*
E
);
ALLOC
(
E
,
m
->
nbEBands
,
float
);
for
(
c
=
0
;
c
<
C
;
c
++
)
{
int
i
;
float
E
[
m
->
nbEBands
];
unquant_energy_mono
(
m
,
E
,
oldEBands
+
c
*
m
->
nbEBands
,
budget
/
C
,
dec
);
for
(
i
=
0
;
i
<
m
->
nbEBands
;
i
++
)
eBands
[
C
*
i
+
c
]
=
E
[
i
];
...
...
libcelt/rate.c
View file @
9a0bba18
...
...
@@ -247,8 +247,8 @@ int compute_allocation(const CELTMode *m, int *offsets, int total, int *pulses)
VARDECL
(
int
*
bits2
);
len
=
m
->
nbEBands
;
ALLOC
(
bits1
,
len
,
floa
t
);
ALLOC
(
bits2
,
len
,
floa
t
);
ALLOC
(
bits1
,
len
,
in
t
);
ALLOC
(
bits2
,
len
,
in
t
);
lo
=
0
;
hi
=
m
->
nbAllocVectors
-
1
;
while
(
hi
-
lo
!=
1
)
...
...
libcelt/stack_alloc.h
View file @
9a0bba18
...
...
@@ -107,8 +107,9 @@
#define VARDECL(var) var
#define ALLOC(var, size, type) var = alloca(sizeof(type)*(size))
#else
#define VARDECL(var) var
#define ALLOC(var, size, type) var = PUSH(stack, size, type)
/*#define VARDECL(var) var
#define ALLOC(var, size, type) var = PUSH(stack, size, type)*/
#error scratchpad not yet supported, you need to define either VAR_ARRAYS or USE_ALLOCA
#endif
...
...
libcelt/vq.c
View file @
9a0bba18
...
...
@@ -37,6 +37,7 @@
#include <stdlib.h>
#include "cwrs.h"
#include "vq.h"
#include "arch.h"
/* Enable this or define your own implementation if you want to speed up the
VQ search (used in inner loop only) */
...
...
@@ -74,31 +75,48 @@ struct NBest {
void
alg_quant
(
float
*
x
,
float
*
W
,
int
N
,
int
K
,
float
*
p
,
float
alpha
,
ec_enc
*
enc
)
{
int
L
=
3
;
float
_y
[
L
][
N
];
int
_iy
[
L
][
N
];
float
_ny
[
L
][
N
];
int
_iny
[
L
][
N
];
float
*
(
ny
[
L
]),
*
(
y
[
L
]);
int
*
(
iny
[
L
]),
*
(
iy
[
L
]);
VARDECL
(
float
*
_y
);
VARDECL
(
float
*
_ny
);
VARDECL
(
int
*
_iy
);
VARDECL
(
int
*
_iny
);
VARDECL
(
float
**
y
);
VARDECL
(
float
**
ny
);
VARDECL
(
int
**
iy
);
VARDECL
(
int
**
iny
);
int
i
,
j
,
k
,
m
;
int
pulsesLeft
;
float
xy
[
L
]
;
float
yy
[
L
]
;
float
yp
[
L
]
;
struct
NBest
_nbest
[
L
]
;
struct
NBest
*
(
nbest
[
L
]
);
VARDECL
(
float
*
xy
)
;
VARDECL
(
float
*
yy
)
;
VARDECL
(
float
*
yp
)
;
VARDECL
(
struct
NBest
*
_nbest
)
;
VARDECL
(
struct
NBest
*
*
nbest
);
float
Rpp
=
0
,
Rxp
=
0
;
int
maxL
=
1
;
ALLOC
(
_y
,
L
*
N
,
float
);
ALLOC
(
_ny
,
L
*
N
,
float
);
ALLOC
(
_iy
,
L
*
N
,
int
);
ALLOC
(
_iny
,
L
*
N
,
int
);
ALLOC
(
y
,
L
*
N
,
float
*
);
ALLOC
(
ny
,
L
*
N
,
float
*
);
ALLOC
(
iy
,
L
*
N
,
int
*
);
ALLOC
(
iny
,
L
*
N
,
int
*
);
ALLOC
(
xy
,
L
,
float
);
ALLOC
(
yy
,
L
,
float
);
ALLOC
(
yp
,
L
,
float
);
ALLOC
(
_nbest
,
L
,
struct
NBest
);
ALLOC
(
nbest
,
L
,
struct
NBest
*
);
for
(
m
=
0
;
m
<
L
;
m
++
)
nbest
[
m
]
=
&
_nbest
[
m
];
for
(
m
=
0
;
m
<
L
;
m
++
)
{
ny
[
m
]
=
_ny
[
m
];
iny
[
m
]
=
_iny
[
m
];
y
[
m
]
=
_y
[
m
];
iy
[
m
]
=
_iy
[
m
];
ny
[
m
]
=
&
_ny
[
m
*
N
];
iny
[
m
]
=
&
_iny
[
m
*
N
];
y
[
m
]
=
&
_y
[
m
*
N
];
iy
[
m
]
=
&
_iy
[
m
*
N
];
}
for
(
j
=
0
;
j
<
N
;
j
++
)
...
...
@@ -146,15 +164,16 @@ void alg_quant(float *x, float *W, int N, int K, float *p, float alpha, ec_enc *
/*if (x[j]>0) sign=1; else sign=-1;*/
for
(
sign
=-
1
;
sign
<=
1
;
sign
+=
2
)
{
/* All pulses at one location must have the same sign. */
if
(
iy
[
m
][
j
]
*
sign
<
0
)
continue
;
/*fprintf (stderr, "%d/%d %d/%d %d/%d\n", i, K, m, L2, j, N);*/
float
tmp_xy
,
tmp_yy
,
tmp_yp
;
float
score
;
float
g
;
float
s
=
sign
*
pulsesAtOnce
;
/* All pulses at one location must have the same sign. */
if
(
iy
[
m
][
j
]
*
sign
<
0
)
continue
;
/* Updating the sums of the new pulse(s) */
tmp_xy
=
xy
[
m
]
+
s
*
x
[
j
]
-
alpha
*
s
*
p
[
j
]
*
Rxp
;
tmp_yy
=
yy
[
m
]
+
2
.
f
*
s
*
y
[
m
][
j
]
+
s
*
s
+
s
*
s
*
alpha
*
alpha
*
p
[
j
]
*
p
[
j
]
*
Rpp
-
2
.
f
*
alpha
*
s
*
p
[
j
]
*
yp
[
m
]
-
2
.
f
*
s
*
s
*
alpha
*
p
[
j
]
*
p
[
j
];
...
...
@@ -290,10 +309,13 @@ void alg_quant(float *x, float *W, int N, int K, float *p, float alpha, ec_enc *
void
alg_unquant
(
float
*
x
,
int
N
,
int
K
,
float
*
p
,
float
alpha
,
ec_dec
*
dec
)
{
int
i
;
int
iy
[
N
];
float
y
[
N
];
float
Rpp
=
0
,
Ryp
=
0
,
Ryy
=
0
;
float
g
;
VARDECL
(
int
*
iy
);
VARDECL
(
float
*
y
);
ALLOC
(
iy
,
N
,
int
);
ALLOC
(
y
,
N
,
float
);
decode_pulses
(
iy
,
N
,
K
,
dec
);
...
...
@@ -333,6 +355,7 @@ void intra_prediction(float *x, float *W, int N, int K, float *Y, float *P, int
float
s
=
1
;
int
sign
;
float
E
;
float
pred_gain
;
int
max_pos
=
N0
-
N
/
B
;
if
(
max_pos
>
32
)
max_pos
=
32
;
...
...
@@ -367,7 +390,6 @@ void intra_prediction(float *x, float *W, int N, int K, float *Y, float *P, int
ec_enc_uint
(
enc
,
best
/
B
,
max_pos
);
/*printf ("%d %f\n", best, best_score);*/
float
pred_gain
;
if
(
K
>
10
)
pred_gain
=
pg
[
10
];
else
...
...
@@ -401,6 +423,7 @@ void intra_unquant(float *x, int N, int K, float *Y, float *P, int B, int N0, ec
float
s
;
int
best
;
float
E
;
float
pred_gain
;
int
max_pos
=
N0
-
N
/
B
;
if
(
max_pos
>
32
)
max_pos
=
32
;
...
...
@@ -414,7 +437,6 @@ void intra_unquant(float *x, int N, int K, float *Y, float *P, int B, int N0, ec
best
=
B
*
ec_dec_uint
(
dec
,
max_pos
);
/*printf ("%d %d ", sign, best);*/
float
pred_gain
;
if
(
K
>
10
)
pred_gain
=
pg
[
10
];
else
...
...
tests/cwrs32-test.c
View file @
9a0bba18
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include "cwrs.h"
...
...
tests/cwrs64-test.c
View file @
9a0bba18
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include "cwrs.h"
#define NMAX (32)
...
...
tests/dft-test.c
View file @
9a0bba18
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include "kiss_fft.h"
...
...
tests/ectest.c
View file @
9a0bba18
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
...
...
tests/real-fft-test.c
View file @
9a0bba18
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "kiss_fftr.h"
#include "_kiss_fft_guts.h"
#include <sys/times.h>
...
...
tests/type-test.c
View file @
9a0bba18
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "celt_types.h"
#include <stdio.h>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment