Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Opus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xiph.Org
Opus
Commits
9d35ccda
Commit
9d35ccda
authored
17 years ago
by
Jean-Marc Valin
Browse files
Options
Downloads
Patches
Plain Diff
Fixed stereo version of the pitch estimator
parent
bf94045f
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
libcelt/celt.c
+8
-2
8 additions, 2 deletions
libcelt/celt.c
libcelt/pitch.c
+21
-14
21 additions, 14 deletions
libcelt/pitch.c
libcelt/pitch.h
+1
-1
1 addition, 1 deletion
libcelt/pitch.h
libcelt/testcelt.c
+1
-1
1 addition, 1 deletion
libcelt/testcelt.c
with
31 additions
and
18 deletions
libcelt/celt.c
+
8
−
2
View file @
9d35ccda
...
...
@@ -88,7 +88,7 @@ CELTEncoder *celt_encoder_new(const CELTMode *mode)
ec_enc_init
(
&
st
->
enc
,
&
st
->
buf
);
mdct_init
(
&
st
->
mdct_lookup
,
2
*
N
);
st
->
fft
=
spx_fft_init
(
MAX_PERIOD
);
st
->
fft
=
spx_fft_init
(
MAX_PERIOD
*
C
);
st
->
window
=
celt_alloc
(
2
*
N
*
sizeof
(
float
));
st
->
in_mem
=
celt_alloc
(
N
*
C
*
sizeof
(
float
));
...
...
@@ -237,7 +237,7 @@ int celt_encode(CELTEncoder *st, short *pcm)
in
[
C
*
(
B
*
N
+
i
)
+
c
]
*=
st
->
window
[
N
+
i
];
}
}
find_spectral_pitch
(
st
->
fft
,
in
,
st
->
out_mem
,
MAX_PERIOD
,
(
B
+
1
)
*
N
,
&
pitch_index
);
find_spectral_pitch
(
st
->
fft
,
in
,
st
->
out_mem
,
MAX_PERIOD
,
(
B
+
1
)
*
N
,
C
,
&
pitch_index
);
ec_enc_uint
(
&
st
->
enc
,
pitch_index
,
MAX_PERIOD
-
(
B
+
1
)
*
N
);
/* Compute MDCTs of the pitch part */
...
...
@@ -314,6 +314,8 @@ int celt_encode(CELTEncoder *st, short *pcm)
{
float
tmp
=
st
->
out_mem
[
C
*
(
MAX_PERIOD
+
(
i
-
B
)
*
N
)
+
C
*
j
+
c
]
+
st
->
preemph
*
st
->
preemph_memD
[
c
];
st
->
preemph_memD
[
c
]
=
tmp
;
if
(
tmp
>
32767
)
tmp
=
32767
;
if
(
tmp
<
-
32767
)
tmp
=
-
32767
;
pcm
[
C
*
i
*
N
+
C
*
j
+
c
]
=
(
short
)
floor
(.
5
+
tmp
);
}
}
...
...
@@ -443,6 +445,8 @@ static void celt_decode_lost(CELTDecoder *st, short *pcm)
{
float
tmp
=
st
->
out_mem
[
C
*
(
MAX_PERIOD
+
(
i
-
B
)
*
N
)
+
C
*
j
+
c
]
+
st
->
preemph
*
st
->
preemph_memD
[
c
];
st
->
preemph_memD
[
c
]
=
tmp
;
if
(
tmp
>
32767
)
tmp
=
32767
;
if
(
tmp
<
-
32767
)
tmp
=
-
32767
;
pcm
[
C
*
i
*
N
+
C
*
j
+
c
]
=
(
short
)
floor
(.
5
+
tmp
);
}
}
...
...
@@ -520,6 +524,8 @@ int celt_decode(CELTDecoder *st, char *data, int len, short *pcm)
{
float
tmp
=
st
->
out_mem
[
C
*
(
MAX_PERIOD
+
(
i
-
B
)
*
N
)
+
C
*
j
+
c
]
+
st
->
preemph
*
st
->
preemph_memD
[
c
];
st
->
preemph_memD
[
c
]
=
tmp
;
if
(
tmp
>
32767
)
tmp
=
32767
;
if
(
tmp
<
-
32767
)
tmp
=
-
32767
;
pcm
[
C
*
i
*
N
+
C
*
j
+
c
]
=
(
short
)
floor
(.
5
+
tmp
);
}
}
...
...
This diff is collapsed.
Click to expand it.
libcelt/pitch.c
+
21
−
14
View file @
9d35ccda
...
...
@@ -27,27 +27,34 @@
#include
"pitch.h"
#include
"psy.h"
void
find_spectral_pitch
(
void
*
fft
,
float
*
x
,
float
*
y
,
int
lag
,
int
len
,
int
*
pitch
)
void
find_spectral_pitch
(
void
*
fft
,
float
*
x
,
float
*
y
,
int
lag
,
int
len
,
int
C
,
int
*
pitch
)
{
int
c
;
int
n2
=
lag
/
2
;
float
xx
[
lag
];
float
X
[
lag
];
float
Y
[
lag
];
float
curve
[
n2
];
float
xx
[
lag
*
C
];
float
yy
[
lag
*
C
];
float
X
[
lag
*
C
];
float
Y
[
lag
*
C
];
float
curve
[
n2
*
C
];
int
i
;
for
(
i
=
0
;
i
<
lag
;
i
++
)
for
(
i
=
0
;
i
<
C
*
lag
;
i
++
)
xx
[
i
]
=
0
;
for
(
i
=
0
;
i
<
len
;
i
++
)
xx
[
i
]
=
x
[
i
];
for
(
c
=
0
;
c
<
C
;
c
++
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
xx
[
c
*
lag
+
i
]
=
x
[
C
*
i
+
c
];
for
(
i
=
0
;
i
<
lag
;
i
++
)
yy
[
c
*
lag
+
i
]
=
y
[
C
*
i
+
c
];
}
spx_fft
(
fft
,
xx
,
X
);
spx_fft
(
fft
,
y
,
Y
);
spx_fft
(
fft
,
y
y
,
Y
);
compute_masking
(
X
,
curve
,
lag
,
44100
);
compute_masking
(
X
,
curve
,
lag
*
C
,
44100
);
X
[
0
]
=
0
;
for
(
i
=
1
;
i
<
lag
/
2
;
i
++
)
for
(
i
=
1
;
i
<
C
*
n
2
;
i
++
)
{
float
n
;
//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 ]))));
...
...
@@ -58,8 +65,8 @@ void find_spectral_pitch(void *fft, float *x, float *y, int lag, int len, int *p
X
[
2
*
i
-
1
]
=
(
X
[
2
*
i
-
1
]
*
Y
[
2
*
i
-
1
]
+
X
[
2
*
i
]
*
Y
[
2
*
i
])
*
n
;
X
[
2
*
i
]
=
(
-
X
[
2
*
i
]
*
Y
[
2
*
i
-
1
]
+
tmp
*
Y
[
2
*
i
])
*
n
;
}
X
[
lag
-
1
]
=
0
;
X
[
0
]
=
X
[
lag
-
1
]
=
0
;
X
[
C
*
lag
-
1
]
=
0
;
X
[
0
]
=
X
[
C
*
lag
-
1
]
=
0
;
spx_ifft
(
fft
,
X
,
xx
);
float
max_corr
=-
1e10
;
...
...
This diff is collapsed.
Click to expand it.
libcelt/pitch.h
+
1
−
1
View file @
9d35ccda
...
...
@@ -23,6 +23,6 @@
#ifndef _PITCH_H
#define _PITCH_H
void
find_spectral_pitch
(
void
*
fft
,
float
*
x
,
float
*
y
,
int
lag
,
int
len
,
int
*
pitch
);
void
find_spectral_pitch
(
void
*
fft
,
float
*
x
,
float
*
y
,
int
lag
,
int
len
,
int
C
,
int
*
pitch
);
#endif
This diff is collapsed.
Click to expand it.
libcelt/testcelt.c
+
1
−
1
View file @
9d35ccda
...
...
@@ -59,9 +59,9 @@ int main(int argc, char *argv[])
{
fread
(
in
,
sizeof
(
short
),
FRAME_SIZE
*
CHANNELS
,
fin
);
celt_encode
(
enc
,
in
);
#if 1
data
=
celt_encoder_get_bytes
(
enc
,
&
len
);
//printf ("%d\n", len);
#if 1
/* this is to simulate packet loss */
if
(
rand
()
%
100
==-
1
)
celt_decode
(
dec
,
NULL
,
len
,
in
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment