Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Mark Harris
Opus
Commits
234969c9
Commit
234969c9
authored
Oct 17, 2009
by
Jean-Marc Valin
Browse files
Removed the _t from all the celt*_t types to avoid clashing with POSIX
parent
8b2ff0da
Changes
27
Hide whitespace changes
Inline
Side-by-side
libcelt/arch.h
View file @
234969c9
...
...
@@ -71,14 +71,13 @@
#ifdef FIXED_POINT
typedef
celt_int16
celt_word16
_t
;
typedef
celt_int32
celt_word32
_t
;
typedef
celt_int16
celt_word16
;
typedef
celt_int32
celt_word32
;
typedef
celt_word32_t
celt_sig_t
;
typedef
celt_word16_t
celt_norm_t
;
typedef
celt_word32_t
celt_ener_t
;
typedef
celt_word16_t
celt_pgain_t
;
typedef
celt_word32_t
celt_mask_t
;
typedef
celt_word32
celt_sig
;
typedef
celt_word16
celt_norm
;
typedef
celt_word32
celt_ener
;
typedef
celt_word32
celt_mask
;
#define Q15ONE 32767
#define Q30ONE 1073741823
...
...
@@ -102,9 +101,9 @@ typedef celt_word32_t celt_mask_t;
#define EPSILON 1
#define VERY_SMALL 0
#define VERY_LARGE32 ((celt_word32
_t
)2147483647)
#define VERY_LARGE16 ((celt_word16
_t
)32767)
#define Q15_ONE ((celt_word16
_t
)32767)
#define VERY_LARGE32 ((celt_word32)2147483647)
#define VERY_LARGE16 ((celt_word16)32767)
#define Q15_ONE ((celt_word16)32767)
#define Q15_ONE_1 (1.f/32768.f)
#define SCALEIN(a) (a)
...
...
@@ -133,14 +132,14 @@ typedef celt_word32_t celt_mask_t;
#else
/* FIXED_POINT */
typedef
float
celt_word16
_t
;
typedef
float
celt_word32
_t
;
typedef
float
celt_word16
;
typedef
float
celt_word32
;
typedef
float
celt_sig
_t
;
typedef
float
celt_norm
_t
;
typedef
float
celt_ener
_t
;
typedef
float
celt_pgain
_t
;
typedef
float
celt_mask
_t
;
typedef
float
celt_sig
;
typedef
float
celt_norm
;
typedef
float
celt_ener
;
typedef
float
celt_pgain
;
typedef
float
celt_mask
;
#define Q15ONE 1.0f
#define Q30ONE 1.0f
...
...
@@ -159,8 +158,8 @@ typedef float celt_mask_t;
#define VERY_SMALL 1e-15f
#define VERY_LARGE32 1e15f
#define VERY_LARGE16 1e15f
#define Q15_ONE ((celt_word16
_t
)1.f)
#define Q15_ONE_1 ((celt_word16
_t
)1.f)
#define Q15_ONE ((celt_word16)1.f)
#define Q15_ONE_1 ((celt_word16)1.f)
#define QCONST16(x,bits) (x)
#define QCONST32(x,bits) (x)
...
...
@@ -192,8 +191,8 @@ typedef float celt_mask_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) ((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_16(a,b) ((celt_word32)(a)*(celt_word32)(b))
#define MAC16_16(c,a,b) ((c)+(celt_word32)(a)*(celt_word32)(b))
#define MULT16_32_Q11(a,b) ((a)*(b))
#define MULT16_32_Q13(a,b) ((a)*(b))
...
...
@@ -218,10 +217,10 @@ typedef float celt_mask_t;
#define MULT16_16_P13(a,b) ((a)*(b))
#define MULT16_16_P14(a,b) ((a)*(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))
#define DIV32_16(a,b) (((celt_word32)(a))/(celt_word16)(b))
#define PDIV32_16(a,b) (((celt_word32)(a))/(celt_word16)(b))
#define DIV32(a,b) (((celt_word32)(a))/(celt_word32)(b))
#define PDIV32(a,b) (((celt_word32)(a))/(celt_word32)(b))
#define SCALEIN(a) ((a)*CELT_SIG_SCALE)
#define SCALEOUT(a) ((a)*(1/CELT_SIG_SCALE))
...
...
libcelt/bands.c
View file @
234969c9
...
...
@@ -48,7 +48,7 @@
#ifdef FIXED_POINT
/* Compute the amplitude (sqrt energy) in each of the bands */
void
compute_band_energies
(
const
CELTMode
*
m
,
const
celt_sig
_t
*
X
,
celt_ener
_t
*
bank
,
int
_C
)
void
compute_band_energies
(
const
CELTMode
*
m
,
const
celt_sig
*
X
,
celt_ener
*
bank
,
int
_C
)
{
int
i
,
c
,
N
;
const
celt_int16
*
eBands
=
m
->
eBands
;
...
...
@@ -59,8 +59,8 @@ void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t *
for
(
i
=
0
;
i
<
m
->
nbEBands
;
i
++
)
{
int
j
;
celt_word32
_t
maxval
=
0
;
celt_word32
_t
sum
=
0
;
celt_word32
maxval
=
0
;
celt_word32
sum
=
0
;
j
=
eBands
[
i
];
do
{
maxval
=
MAX32
(
maxval
,
X
[
j
+
c
*
N
]);
...
...
@@ -87,7 +87,7 @@ void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t *
}
/* Normalise each band such that the energy is one. */
void
normalise_bands
(
const
CELTMode
*
m
,
const
celt_sig
_t
*
restrict
freq
,
celt_norm
_t
*
restrict
X
,
const
celt_ener
_t
*
bank
,
int
_C
)
void
normalise_bands
(
const
CELTMode
*
m
,
const
celt_sig
*
restrict
freq
,
celt_norm
*
restrict
X
,
const
celt_ener
*
bank
,
int
_C
)
{
int
i
,
c
,
N
;
const
celt_int16
*
eBands
=
m
->
eBands
;
...
...
@@ -96,9 +96,9 @@ void normalise_bands(const CELTMode *m, const celt_sig_t * restrict freq, celt_n
for
(
c
=
0
;
c
<
C
;
c
++
)
{
i
=
0
;
do
{
celt_word16
_t
g
;
celt_word16
g
;
int
j
,
shift
;
celt_word16
_t
E
;
celt_word16
E
;
shift
=
celt_zlog2
(
bank
[
i
+
c
*
m
->
nbEBands
])
-
13
;
E
=
VSHR32
(
bank
[
i
+
c
*
m
->
nbEBands
],
shift
);
g
=
EXTRACT16
(
celt_rcp
(
SHL32
(
E
,
3
)));
...
...
@@ -111,7 +111,7 @@ void normalise_bands(const CELTMode *m, const celt_sig_t * restrict freq, celt_n
#else
/* FIXED_POINT */
/* Compute the amplitude (sqrt energy) in each of the bands */
void
compute_band_energies
(
const
CELTMode
*
m
,
const
celt_sig
_t
*
X
,
celt_ener
_t
*
bank
,
int
_C
)
void
compute_band_energies
(
const
CELTMode
*
m
,
const
celt_sig
*
X
,
celt_ener
*
bank
,
int
_C
)
{
int
i
,
c
,
N
;
const
celt_int16
*
eBands
=
m
->
eBands
;
...
...
@@ -122,7 +122,7 @@ void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t *
for
(
i
=
0
;
i
<
m
->
nbEBands
;
i
++
)
{
int
j
;
celt_word32
_t
sum
=
1e-10
;
celt_word32
sum
=
1e-10
;
for
(
j
=
eBands
[
i
];
j
<
eBands
[
i
+
1
];
j
++
)
sum
+=
X
[
j
+
c
*
N
]
*
X
[
j
+
c
*
N
];
bank
[
i
+
c
*
m
->
nbEBands
]
=
sqrt
(
sum
);
...
...
@@ -133,7 +133,7 @@ void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t *
}
#ifdef EXP_PSY
void
compute_noise_energies
(
const
CELTMode
*
m
,
const
celt_sig
_t
*
X
,
const
celt_word16
_t
*
tonality
,
celt_ener
_t
*
bank
,
int
_C
)
void
compute_noise_energies
(
const
CELTMode
*
m
,
const
celt_sig
*
X
,
const
celt_word16
*
tonality
,
celt_ener
*
bank
,
int
_C
)
{
int
i
,
c
,
N
;
const
celt_int16
*
eBands
=
m
->
eBands
;
...
...
@@ -144,7 +144,7 @@ void compute_noise_energies(const CELTMode *m, const celt_sig_t *X, const celt_w
for
(
i
=
0
;
i
<
m
->
nbEBands
;
i
++
)
{
int
j
;
celt_word32
_t
sum
=
1e-10
;
celt_word32
sum
=
1e-10
;
for
(
j
=
eBands
[
i
];
j
<
eBands
[
i
+
1
];
j
++
)
sum
+=
X
[
j
*
C
+
c
]
*
X
[
j
+
c
*
N
]
*
tonality
[
j
];
bank
[
i
+
c
*
m
->
nbEBands
]
=
sqrt
(
sum
);
...
...
@@ -156,7 +156,7 @@ void compute_noise_energies(const CELTMode *m, const celt_sig_t *X, const celt_w
#endif
/* Normalise each band such that the energy is one. */
void
normalise_bands
(
const
CELTMode
*
m
,
const
celt_sig
_t
*
restrict
freq
,
celt_norm
_t
*
restrict
X
,
const
celt_ener
_t
*
bank
,
int
_C
)
void
normalise_bands
(
const
CELTMode
*
m
,
const
celt_sig
*
restrict
freq
,
celt_norm
*
restrict
X
,
const
celt_ener
*
bank
,
int
_C
)
{
int
i
,
c
,
N
;
const
celt_int16
*
eBands
=
m
->
eBands
;
...
...
@@ -167,7 +167,7 @@ void normalise_bands(const CELTMode *m, const celt_sig_t * restrict freq, celt_n
for
(
i
=
0
;
i
<
m
->
nbEBands
;
i
++
)
{
int
j
;
celt_word16
_t
g
=
1
.
f
/
(
1e-10
+
bank
[
i
+
c
*
m
->
nbEBands
]);
celt_word16
g
=
1
.
f
/
(
1e-10
+
bank
[
i
+
c
*
m
->
nbEBands
]);
for
(
j
=
eBands
[
i
];
j
<
eBands
[
i
+
1
];
j
++
)
X
[
j
+
c
*
N
]
=
freq
[
j
+
c
*
N
]
*
g
;
}
...
...
@@ -176,7 +176,7 @@ void normalise_bands(const CELTMode *m, const celt_sig_t * restrict freq, celt_n
#endif
/* FIXED_POINT */
void
renormalise_bands
(
const
CELTMode
*
m
,
celt_norm
_t
*
restrict
X
,
int
_C
)
void
renormalise_bands
(
const
CELTMode
*
m
,
celt_norm
*
restrict
X
,
int
_C
)
{
int
i
,
c
;
const
celt_int16
*
eBands
=
m
->
eBands
;
...
...
@@ -190,7 +190,7 @@ void renormalise_bands(const CELTMode *m, celt_norm_t * restrict X, int _C)
}
/* De-normalise the energy to produce the synthesis from the unit-energy bands */
void
denormalise_bands
(
const
CELTMode
*
m
,
const
celt_norm
_t
*
restrict
X
,
celt_sig
_t
*
restrict
freq
,
const
celt_ener
_t
*
bank
,
int
_C
)
void
denormalise_bands
(
const
CELTMode
*
m
,
const
celt_norm
*
restrict
X
,
celt_sig
*
restrict
freq
,
const
celt_ener
*
bank
,
int
_C
)
{
int
i
,
c
,
N
;
const
celt_int16
*
eBands
=
m
->
eBands
;
...
...
@@ -203,7 +203,7 @@ void denormalise_bands(const CELTMode *m, const celt_norm_t * restrict X, celt_s
for
(
i
=
0
;
i
<
m
->
nbEBands
;
i
++
)
{
int
j
;
celt_word32
_t
g
=
SHR32
(
bank
[
i
+
c
*
m
->
nbEBands
],
1
);
celt_word32
g
=
SHR32
(
bank
[
i
+
c
*
m
->
nbEBands
],
1
);
j
=
eBands
[
i
];
do
{
freq
[
j
+
c
*
N
]
=
SHL32
(
MULT16_32_Q15
(
X
[
j
+
c
*
N
],
g
),
2
);
}
while
(
++
j
<
eBands
[
i
+
1
]);
...
...
@@ -213,18 +213,18 @@ void denormalise_bands(const CELTMode *m, const celt_norm_t * restrict X, celt_s
}
}
int
compute_pitch_gain
(
const
CELTMode
*
m
,
const
celt_sig
_t
*
X
,
const
celt_sig
_t
*
P
,
int
norm_rate
,
int
*
gain_id
,
int
_C
,
celt_word16
_t
*
gain_prod
)
int
compute_pitch_gain
(
const
CELTMode
*
m
,
const
celt_sig
*
X
,
const
celt_sig
*
P
,
int
norm_rate
,
int
*
gain_id
,
int
_C
,
celt_word16
*
gain_prod
)
{
int
j
,
c
;
celt_word16
_t
g
;
celt_word16
_t
delta
;
celt_word16
g
;
celt_word16
delta
;
const
int
C
=
CHANNELS
(
_C
);
celt_word32
_t
Sxy
=
0
,
Sxx
=
0
,
Syy
=
0
;
celt_word32
Sxy
=
0
,
Sxx
=
0
,
Syy
=
0
;
int
len
=
m
->
pitchEnd
;
const
int
N
=
FRAMESIZE
(
m
);
#ifdef FIXED_POINT
int
shift
=
0
;
celt_word32
_t
maxabs
=
0
;
celt_word32
maxabs
=
0
;
for
(
c
=
0
;
c
<
C
;
c
++
)
{
...
...
@@ -241,10 +241,10 @@ int compute_pitch_gain(const CELTMode *m, const celt_sig_t *X, const celt_sig_t
delta
=
PDIV32_16
(
Q15ONE
,
len
);
for
(
c
=
0
;
c
<
C
;
c
++
)
{
celt_word16
_t
gg
=
Q15ONE
;
celt_word16
gg
=
Q15ONE
;
for
(
j
=
0
;
j
<
len
;
j
++
)
{
celt_word16
_t
Xj
,
Pj
;
celt_word16
Xj
,
Pj
;
Xj
=
EXTRACT16
(
SHR32
(
X
[
j
+
c
*
N
],
shift
));
Pj
=
MULT16_16_P15
(
gg
,
EXTRACT16
(
SHR32
(
P
[
j
+
c
*
N
],
shift
)));
Sxy
=
MAC16_16
(
Sxy
,
Xj
,
Pj
);
...
...
@@ -255,8 +255,8 @@ int compute_pitch_gain(const CELTMode *m, const celt_sig_t *X, const celt_sig_t
}
#ifdef FIXED_POINT
{
celt_word32
_t
num
,
den
;
celt_word16
_t
fact
;
celt_word32
num
,
den
;
celt_word16
fact
;
fact
=
MULT16_16
(
QCONST16
(.
04
,
14
),
norm_rate
);
if
(
fact
<
QCONST16
(
1
.,
14
))
fact
=
QCONST16
(
1
.,
14
);
...
...
@@ -304,11 +304,11 @@ int compute_pitch_gain(const CELTMode *m, const celt_sig_t *X, const celt_sig_t
}
}
void
apply_pitch
(
const
CELTMode
*
m
,
celt_sig
_t
*
X
,
const
celt_sig
_t
*
P
,
int
gain_id
,
int
pred
,
int
_C
)
void
apply_pitch
(
const
CELTMode
*
m
,
celt_sig
*
X
,
const
celt_sig
*
P
,
int
gain_id
,
int
pred
,
int
_C
)
{
int
j
,
c
,
N
;
celt_word16
_t
gain
;
celt_word16
_t
delta
;
celt_word16
gain
;
celt_word16
delta
;
const
int
C
=
CHANNELS
(
_C
);
int
len
=
m
->
pitchEnd
;
...
...
@@ -321,7 +321,7 @@ void apply_pitch(const CELTMode *m, celt_sig_t *X, const celt_sig_t *P, int gain
delta
=
-
delta
;
for
(
c
=
0
;
c
<
C
;
c
++
)
{
celt_word16
_t
gg
=
gain
;
celt_word16
gg
=
gain
;
for
(
j
=
0
;
j
<
len
;
j
++
)
{
X
[
j
+
c
*
N
]
+=
SHL32
(
MULT16_32_Q15
(
gg
,
P
[
j
+
c
*
N
]),
1
);
...
...
@@ -332,20 +332,20 @@ void apply_pitch(const CELTMode *m, celt_sig_t *X, const celt_sig_t *P, int gain
#ifndef DISABLE_STEREO
static
void
stereo_band_mix
(
const
CELTMode
*
m
,
celt_norm
_t
*
X
,
celt_norm
_t
*
Y
,
const
celt_ener
_t
*
bank
,
int
stereo_mode
,
int
bandID
,
int
dir
)
static
void
stereo_band_mix
(
const
CELTMode
*
m
,
celt_norm
*
X
,
celt_norm
*
Y
,
const
celt_ener
*
bank
,
int
stereo_mode
,
int
bandID
,
int
dir
)
{
int
i
=
bandID
;
const
celt_int16
*
eBands
=
m
->
eBands
;
int
j
;
celt_word16
_t
a1
,
a2
;
celt_word16
a1
,
a2
;
if
(
stereo_mode
==
0
)
{
/* Do mid-side when not doing intensity stereo */
a1
=
QCONST16
(.
70711
f
,
14
);
a2
=
dir
*
QCONST16
(.
70711
f
,
14
);
}
else
{
celt_word16
_t
left
,
right
;
celt_word16
_t
norm
;
celt_word16
left
,
right
;
celt_word16
norm
;
#ifdef FIXED_POINT
int
shift
=
celt_zlog2
(
MAX32
(
bank
[
i
],
bank
[
i
+
m
->
nbEBands
]))
-
13
;
#endif
...
...
@@ -357,7 +357,7 @@ static void stereo_band_mix(const CELTMode *m, celt_norm_t *X, celt_norm_t *Y, c
}
for
(
j
=
0
;
j
<
eBands
[
i
+
1
]
-
eBands
[
i
];
j
++
)
{
celt_norm
_t
r
,
l
;
celt_norm
r
,
l
;
l
=
X
[
j
];
r
=
Y
[
j
];
X
[
j
]
=
MULT16_16_Q14
(
a1
,
l
)
+
MULT16_16_Q14
(
a2
,
r
);
...
...
@@ -368,11 +368,11 @@ static void stereo_band_mix(const CELTMode *m, celt_norm_t *X, celt_norm_t *Y, c
#endif
/* DISABLE_STEREO */
int
folding_decision
(
const
CELTMode
*
m
,
celt_norm
_t
*
X
,
celt_word16
_t
*
average
,
int
*
last_decision
,
int
_C
)
int
folding_decision
(
const
CELTMode
*
m
,
celt_norm
*
X
,
celt_word16
*
average
,
int
*
last_decision
,
int
_C
)
{
int
i
,
c
,
N0
;
int
NR
=
0
;
celt_word32
_t
ratio
=
EPSILON
;
celt_word32
ratio
=
EPSILON
;
const
int
C
=
CHANNELS
(
_C
);
const
celt_int16
*
restrict
eBands
=
m
->
eBands
;
...
...
@@ -384,9 +384,9 @@ int folding_decision(const CELTMode *m, celt_norm_t *X, celt_word16_t *average,
{
int
j
,
N
;
int
max_i
=
0
;
celt_word16
_t
max_val
=
EPSILON
;
celt_word32
_t
floor_ener
=
EPSILON
;
celt_norm
_t
*
restrict
x
=
X
+
eBands
[
i
]
+
c
*
N0
;
celt_word16
max_val
=
EPSILON
;
celt_word32
floor_ener
=
EPSILON
;
celt_norm
*
restrict
x
=
X
+
eBands
[
i
]
+
c
*
N0
;
N
=
eBands
[
i
+
1
]
-
eBands
[
i
];
for
(
j
=
0
;
j
<
N
;
j
++
)
{
...
...
@@ -416,8 +416,8 @@ int folding_decision(const CELTMode *m, celt_norm_t *X, celt_word16_t *average,
#endif
if
(
N
>
7
)
{
celt_word16
_t
r
;
celt_word16
_t
den
=
celt_sqrt
(
floor_ener
);
celt_word16
r
;
celt_word16
den
=
celt_sqrt
(
floor_ener
);
den
=
MAX32
(
QCONST16
(.
02
,
15
),
den
);
r
=
DIV32_16
(
SHL32
(
EXTEND32
(
max_val
),
8
),
den
);
ratio
=
ADD32
(
ratio
,
EXTEND32
(
r
));
...
...
@@ -439,17 +439,17 @@ int folding_decision(const CELTMode *m, celt_norm_t *X, celt_word16_t *average,
}
/* Quantisation of the residual */
void
quant_bands
(
const
CELTMode
*
m
,
celt_norm
_t
*
restrict
X
,
const
celt_ener
_t
*
bandE
,
int
*
pulses
,
int
shortBlocks
,
int
fold
,
int
total_bits
,
int
encode
,
void
*
enc_dec
)
void
quant_bands
(
const
CELTMode
*
m
,
celt_norm
*
restrict
X
,
const
celt_ener
*
bandE
,
int
*
pulses
,
int
shortBlocks
,
int
fold
,
int
total_bits
,
int
encode
,
void
*
enc_dec
)
{
int
i
,
j
,
remaining_bits
,
balance
;
const
celt_int16
*
restrict
eBands
=
m
->
eBands
;
celt_norm
_t
*
restrict
norm
;
VARDECL
(
celt_norm
_t
,
_norm
);
celt_norm
*
restrict
norm
;
VARDECL
(
celt_norm
,
_norm
);
int
B
;
SAVE_STACK
;
B
=
shortBlocks
?
m
->
nbShortMdcts
:
1
;
ALLOC
(
_norm
,
eBands
[
m
->
nbEBands
+
1
],
celt_norm
_t
);
ALLOC
(
_norm
,
eBands
[
m
->
nbEBands
+
1
],
celt_norm
);
norm
=
_norm
;
balance
=
0
;
...
...
@@ -458,7 +458,7 @@ void quant_bands(const CELTMode *m, celt_norm_t * restrict X, const celt_ener_t
int
tell
;
int
N
;
int
q
;
celt_word16
_t
n
;
celt_word16
n
;
const
celt_int16
*
const
*
BPbits
;
int
curr_balance
,
curr_bits
;
...
...
@@ -509,18 +509,18 @@ void quant_bands(const CELTMode *m, celt_norm_t * restrict X, const celt_ener_t
#ifndef DISABLE_STEREO
void
quant_bands_stereo
(
const
CELTMode
*
m
,
celt_norm
_t
*
_X
,
const
celt_ener
_t
*
bandE
,
int
*
pulses
,
int
shortBlocks
,
int
fold
,
int
total_bits
,
ec_enc
*
enc
)
void
quant_bands_stereo
(
const
CELTMode
*
m
,
celt_norm
*
_X
,
const
celt_ener
*
bandE
,
int
*
pulses
,
int
shortBlocks
,
int
fold
,
int
total_bits
,
ec_enc
*
enc
)
{
int
i
,
j
,
remaining_bits
,
balance
;
const
celt_int16
*
restrict
eBands
=
m
->
eBands
;
celt_norm
_t
*
restrict
norm
;
VARDECL
(
celt_norm
_t
,
_norm
);
celt_norm
*
restrict
norm
;
VARDECL
(
celt_norm
,
_norm
);
int
B
;
celt_word16
_t
mid
,
side
;
celt_word16
mid
,
side
;
SAVE_STACK
;
B
=
shortBlocks
?
m
->
nbShortMdcts
:
1
;
ALLOC
(
_norm
,
eBands
[
m
->
nbEBands
+
1
],
celt_norm
_t
);
ALLOC
(
_norm
,
eBands
[
m
->
nbEBands
+
1
],
celt_norm
);
norm
=
_norm
;
balance
=
0
;
...
...
@@ -529,7 +529,7 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t *b
int
c
;
int
tell
;
int
q1
,
q2
;
celt_word16
_t
n
;
celt_word16
n
;
const
celt_int16
*
const
*
BPbits
;
int
b
,
qb
;
int
N
;
...
...
@@ -537,7 +537,7 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t *b
int
imid
,
iside
,
itheta
;
int
mbits
,
sbits
,
delta
;
int
qalloc
;
celt_norm
_t
*
restrict
X
,
*
restrict
Y
;
celt_norm
*
restrict
X
,
*
restrict
Y
;
X
=
_X
+
eBands
[
i
];
Y
=
X
+
eBands
[
m
->
nbEBands
+
1
];
...
...
@@ -605,8 +605,8 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t *b
{
int
c2
;
int
sign
=
1
;
celt_norm
_t
v
[
2
],
w
[
2
];
celt_norm
_t
*
x2
,
*
y2
;
celt_norm
v
[
2
],
w
[
2
];
celt_norm
*
x2
,
*
y2
;
mbits
=
b
-
qalloc
;
sbits
=
0
;
if
(
itheta
!=
0
&&
itheta
!=
16384
)
...
...
@@ -740,18 +740,18 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t *b
#ifndef DISABLE_STEREO
void
unquant_bands_stereo
(
const
CELTMode
*
m
,
celt_norm
_t
*
_X
,
const
celt_ener
_t
*
bandE
,
int
*
pulses
,
int
shortBlocks
,
int
fold
,
int
total_bits
,
ec_dec
*
dec
)
void
unquant_bands_stereo
(
const
CELTMode
*
m
,
celt_norm
*
_X
,
const
celt_ener
*
bandE
,
int
*
pulses
,
int
shortBlocks
,
int
fold
,
int
total_bits
,
ec_dec
*
dec
)
{
int
i
,
j
,
remaining_bits
,
balance
;
const
celt_int16
*
restrict
eBands
=
m
->
eBands
;
celt_norm
_t
*
restrict
norm
;
VARDECL
(
celt_norm
_t
,
_norm
);
celt_norm
*
restrict
norm
;
VARDECL
(
celt_norm
,
_norm
);
int
B
;
celt_word16
_t
mid
,
side
;
celt_word16
mid
,
side
;
SAVE_STACK
;
B
=
shortBlocks
?
m
->
nbShortMdcts
:
1
;
ALLOC
(
_norm
,
eBands
[
m
->
nbEBands
+
1
],
celt_norm
_t
);
ALLOC
(
_norm
,
eBands
[
m
->
nbEBands
+
1
],
celt_norm
);
norm
=
_norm
;
balance
=
0
;
...
...
@@ -760,7 +760,7 @@ void unquant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t
int
c
;
int
tell
;
int
q1
,
q2
;
celt_word16
_t
n
;
celt_word16
n
;
const
celt_int16
*
const
*
BPbits
;
int
b
,
qb
;
int
N
;
...
...
@@ -768,7 +768,7 @@ void unquant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t
int
imid
,
iside
,
itheta
;
int
mbits
,
sbits
,
delta
;
int
qalloc
;
celt_norm
_t
*
restrict
X
,
*
restrict
Y
;
celt_norm
*
restrict
X
,
*
restrict
Y
;
X
=
_X
+
eBands
[
i
];
Y
=
X
+
eBands
[
m
->
nbEBands
+
1
];
...
...
@@ -825,8 +825,8 @@ void unquant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t
{
int
c2
;
int
sign
=
1
;
celt_norm
_t
v
[
2
],
w
[
2
];
celt_norm
_t
*
x2
,
*
y2
;
celt_norm
v
[
2
],
w
[
2
];
celt_norm
*
x2
,
*
y2
;
mbits
=
b
-
qalloc
;
sbits
=
0
;
if
(
itheta
!=
0
&&
itheta
!=
16384
)
...
...
libcelt/bands.h
View file @
234969c9
...
...
@@ -45,9 +45,9 @@
* @param X Spectrum
* @param bands Square root of the energy for each band (returned)
*/
void
compute_band_energies
(
const
CELTMode
*
m
,
const
celt_sig
_t
*
X
,
celt_ener
_t
*
bands
,
int
_C
);
void
compute_band_energies
(
const
CELTMode
*
m
,
const
celt_sig
*
X
,
celt_ener
*
bands
,
int
_C
);
/*void compute_noise_energies(const CELTMode *m, const celt_sig
_t
*X, const celt_word16
_t
*tonality, celt_ener
_t
*bank);*/
/*void compute_noise_energies(const CELTMode *m, const celt_sig *X, const celt_word16 *tonality, celt_ener *bank);*/
/** Normalise each band of X such that the energy in each band is
equal to 1
...
...
@@ -55,16 +55,16 @@ void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t *
* @param X Spectrum (returned normalised)
* @param bands Square root of the energy for each band
*/
void
normalise_bands
(
const
CELTMode
*
m
,
const
celt_sig
_t
*
restrict
freq
,
celt_norm
_t
*
restrict
X
,
const
celt_ener
_t
*
bands
,
int
_C
);
void
normalise_bands
(
const
CELTMode
*
m
,
const
celt_sig
*
restrict
freq
,
celt_norm
*
restrict
X
,
const
celt_ener
*
bands
,
int
_C
);
void
renormalise_bands
(
const
CELTMode
*
m
,
celt_norm
_t
*
restrict
X
,
int
_C
);
void
renormalise_bands
(
const
CELTMode
*
m
,
celt_norm
*
restrict
X
,
int
_C
);
/** Denormalise each band of X to restore full amplitude
* @param m Mode data
* @param X Spectrum (returned de-normalised)
* @param bands Square root of the energy for each band
*/
void
denormalise_bands
(
const
CELTMode
*
m
,
const
celt_norm
_t
*
restrict
X
,
celt_sig
_t
*
restrict
freq
,
const
celt_ener
_t
*
bands
,
int
_C
);
void
denormalise_bands
(
const
CELTMode
*
m
,
const
celt_norm
*
restrict
X
,
celt_sig
*
restrict
freq
,
const
celt_ener
*
bands
,
int
_C
);
/** Compute the pitch predictor gain for each pitch band
* @param m Mode data
...
...
@@ -73,11 +73,11 @@ void denormalise_bands(const CELTMode *m, const celt_norm_t * restrict X, celt_s
* @param gains Gain computed for each pitch band (returned)
* @param bank Square root of the energy for each band
*/
int
compute_pitch_gain
(
const
CELTMode
*
m
,
const
celt_sig
_t
*
X
,
const
celt_sig
_t
*
P
,
int
norm_rate
,
int
*
gain_id
,
int
_C
,
celt_word16
_t
*
gain_prod
);
int
compute_pitch_gain
(
const
CELTMode
*
m
,
const
celt_sig
*
X
,
const
celt_sig
*
P
,
int
norm_rate
,
int
*
gain_id
,
int
_C
,
celt_word16
*
gain_prod
);
void
apply_pitch
(
const
CELTMode
*
m
,
celt_sig
_t
*
X
,
const
celt_sig
_t
*
P
,
int
gain_id
,
int
pred
,
int
_C
);
void
apply_pitch
(
const
CELTMode
*
m
,
celt_sig
*
X
,
const
celt_sig
*
P
,
int
gain_id
,
int
pred
,
int
_C
);
int
folding_decision
(
const
CELTMode
*
m
,
celt_norm
_t
*
X
,
celt_word16
_t
*
average
,
int
*
last_decision
,
int
_C
);
int
folding_decision
(
const
CELTMode
*
m
,
celt_norm
*
X
,
celt_word16
*
average
,
int
*
last_decision
,
int
_C
);
/** Quantisation/encoding of the residual spectrum
* @param m Mode data
...
...
@@ -85,9 +85,9 @@ int folding_decision(const CELTMode *m, celt_norm_t *X, celt_word16_t *average,
* @param total_bits Total number of bits that can be used for the frame (including the ones already spent)
* @param enc Entropy encoder
*/
void
quant_bands
(
const
CELTMode
*
m
,
celt_norm
_t
*
restrict
X
,
const
celt_ener
_t
*
bandE
,
int
*
pulses
,
int
time_domain
,
int
fold
,
int
total_bits
,
int
encode
,
void
*
enc_dec
);
void
quant_bands
(
const
CELTMode
*
m
,
celt_norm
*
restrict
X
,
const
celt_ener
*
bandE
,
int
*
pulses
,
int
time_domain
,
int
fold
,
int
total_bits
,
int
encode
,
void
*
enc_dec
);
void
quant_bands_stereo
(
const
CELTMode
*
m
,
celt_norm
_t
*
restrict
X
,
const
celt_ener
_t
*
bandE
,
int
*
pulses
,
int
time_domain
,
int
fold
,
int
total_bits
,
ec_enc
*
enc
);
void
quant_bands_stereo
(
const
CELTMode
*
m
,
celt_norm
*
restrict
X
,
const
celt_ener
*
bandE
,
int
*
pulses
,
int
time_domain
,
int
fold
,
int
total_bits
,
ec_enc
*
enc
);
/** Decoding of the residual spectrum
* @param m Mode data
...
...
@@ -95,10 +95,10 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t * restrict X, const celt_
* @param total_bits Total number of bits that can be used for the frame (including the ones already spent)
* @param dec Entropy decoder
*/
void
unquant_bands
(
const
CELTMode
*
m
,
celt_norm
_t
*
restrict
X
,
const
celt_ener
_t
*
bandE
,
int
*
pulses
,
int
time_domain
,
int
fold
,
int
total_bits
,
ec_dec
*
dec
);
void
unquant_bands
(
const
CELTMode
*
m
,
celt_norm
*
restrict
X
,
const
celt_ener
*
bandE
,
int
*
pulses
,
int
time_domain
,
int
fold
,
int
total_bits
,
ec_dec
*
dec
);
void
unquant_bands_stereo
(
const
CELTMode
*
m
,
celt_norm
_t
*
restrict
X
,
const
celt_ener
_t
*
bandE
,
int
*
pulses
,
int
time_domain
,
int
fold
,
int
total_bits
,
ec_dec
*
dec
);
void
unquant_bands_stereo
(
const
CELTMode
*
m
,
celt_norm
*
restrict
X
,
const
celt_ener
*
bandE
,
int
*
pulses
,
int
time_domain
,
int
fold
,
int
total_bits
,
ec_dec
*
dec
);
void
stereo_decision
(
const
CELTMode
*
m
,
celt_norm
_t
*
restrict
X
,
int
*
stereo_mode
,
int
len
);
void
stereo_decision
(
const
CELTMode
*
m
,
celt_norm
*
restrict
X
,
int
*
stereo_mode
,
int
len
);
#endif
/* BANDS_H */
libcelt/celt.c
View file @
234969c9
...
...
@@ -54,10 +54,10 @@
#include
"float_cast.h"
#include
<stdarg.h>
static
const
celt_word16
_t
preemph
=
QCONST16
(
0
.
8
f
,
15
);
static
const
celt_word16
preemph
=
QCONST16
(
0
.
8
f
,
15
);
#ifdef FIXED_POINT
static
const
celt_word16
_t
transientWindow
[
16
]
=
{
static
const
celt_word16
transientWindow
[
16
]
=
{
279
,
1106
,
2454
,
4276
,
6510
,
9081
,
11900
,
14872
,
17896
,
20868
,
23687
,
26258
,
28492
,
30314
,
31662
,
32489
};
#else
...
...
@@ -88,20 +88,20 @@ struct CELTEncoder {
int
pitch_available
;
/* Amount of pitch buffer available */
int
force_intra
;
int
delayedIntra
;
celt_word16
_t
tonal_average
;
celt_word16
tonal_average
;
int
fold_decision
;
celt_word16
_t
gain_prod
;
celt_word16
gain_prod
;
int
VBR_rate
;
/* Target number of 16th bits per frame */
celt_word16
_t
*
restrict
preemph_memE
;
celt_sig
_t
*
restrict
preemph_memD
;
celt_word16
*
restrict
preemph_memE
;
celt_sig
*
restrict
preemph_memD
;
celt_sig
_t
*
in_mem
;
celt_sig
_t
*
out_mem
;
celt_sig
*
in_mem
;
celt_sig
*
out_mem
;
celt_word16
_t
*
oldBandE
;
celt_word16
*
oldBandE
;
#ifdef EXP_PSY
celt_word16
_t
*
psy_mem
;
celt_word16
*
psy_mem
;
struct
PsyDecay
psy
;
#endif
};
...
...
@@ -167,16 +167,16 @@ CELTEncoder *celt_encoder_create(const CELTMode *mode, int channels, int *error)
st
->
tonal_average
=
QCONST16
(
1
.,
8
);
st
->
fold_decision
=
1
;
st
->
in_mem
=
celt_alloc
(
st
->
overlap
*
C
*
sizeof
(
celt_sig
_t
));
st
->
out_mem
=
celt_alloc
((
MAX_PERIOD
+
st
->
overlap
)
*
C
*
sizeof
(
celt_sig
_t
));
st
->
in_mem
=
celt_alloc
(
st
->
overlap
*
C
*
sizeof
(
celt_sig
));
st
->
out_mem
=
celt_alloc
((
MAX_PERIOD
+
st
->
overlap
)
*
C
*
sizeof
(
celt_sig
));
st
->
oldBandE
=
(
celt_word16
_t
*
)
celt_alloc
(
C
*
mode
->
nbEBands
*
sizeof
(
celt_word16
_t
));
st
->
oldBandE
=
(
celt_word16
*
)
celt_alloc
(
C
*
mode
->
nbEBands
*
sizeof
(
celt_word16
));
st
->
preemph_memE
=
(
celt_word16
_t
*
)
celt_alloc
(
C
*
sizeof
(
celt_word16
_t
));
st
->
preemph_memD
=
(
celt_sig
_t
*
)
celt_alloc
(
C
*
sizeof
(
celt_sig
_t
));
st
->
preemph_memE
=
(
celt_word16
*
)
celt_alloc
(
C
*
sizeof
(
celt_word16
));
st
->
preemph_memD
=
(
celt_sig
*
)
celt_alloc
(
C
*
sizeof
(
celt_sig
));
#ifdef EXP_PSY
st
->
psy_mem
=
celt_alloc
(
MAX_PERIOD
*
sizeof
(
celt_word16
_t
));