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
81a82957
Commit
81a82957
authored
17 years ago
by
Jean-Marc Valin
Browse files
Options
Downloads
Patches
Plain Diff
Some work trying to generate the modes on the fly
parent
6da36c04
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libcelt/modes.c
+70
-0
70 additions, 0 deletions
libcelt/modes.c
libcelt/modes.h
+1
-0
1 addition, 0 deletions
libcelt/modes.h
with
71 additions
and
0 deletions
libcelt/modes.c
+
70
−
0
View file @
81a82957
...
...
@@ -30,6 +30,7 @@
*/
#include
"modes.h"
#include
"os_support.h"
#define NBANDS 18
#define PBANDS 8
...
...
@@ -211,3 +212,72 @@ int celt_mode_info(const CELTMode *mode, int request, celt_int32_t *value)
return
CELT_OK
;
}
#define MIN_BINS 4
#define BARK_BANDS 25
const
celt_int16_t
bark_freq
[
26
]
=
{
0
,
101
,
200
,
301
,
405
,
516
,
635
,
766
,
912
,
1077
,
1263
,
1476
,
1720
,
2003
,
2333
,
2721
,
3184
,
3742
,
4428
,
5285
,
6376
,
7791
,
9662
,
12181
,
15624
,
20397
};
static
int
*
compute_ebands
(
int
Fs
,
int
frame_size
,
int
*
nbEBands
)
{
int
*
eBands
;
int
i
,
res
,
min_width
,
lin
,
low
,
high
;
res
=
(
Fs
+
frame_size
)
/
(
2
*
frame_size
);
min_width
=
MIN_BINS
*
res
;
//printf ("min_width = %d\n", min_width);
/* Find where the linear part ends (i.e. where the spacing is more than min_width */
for
(
lin
=
0
;
lin
<
BARK_BANDS
;
lin
++
)
if
(
bark_freq
[
lin
+
1
]
-
bark_freq
[
lin
]
>=
min_width
)
break
;
//printf ("lin = %d (%d Hz)\n", lin, bark_freq[lin]);
low
=
((
bark_freq
[
lin
]
/
res
)
+
(
MIN_BINS
-
1
))
/
MIN_BINS
;
high
=
BARK_BANDS
-
lin
;
*
nbEBands
=
low
+
high
;
eBands
=
celt_alloc
(
sizeof
(
int
)
*
(
*
nbEBands
+
2
));
/* Linear spacing (min_width) */
for
(
i
=
0
;
i
<
low
;
i
++
)
eBands
[
i
]
=
MIN_BINS
*
i
;
/* Spacing follows critical bands */
for
(
i
=
0
;
i
<
high
;
i
++
)
eBands
[
i
+
low
]
=
bark_freq
[
lin
+
i
]
/
res
;
/* Enforce the minimum spacing at the boundary */
for
(
i
=
0
;
i
<*
nbEBands
;
i
++
)
if
(
eBands
[
i
]
<
MIN_BINS
*
i
)
eBands
[
i
]
=
MIN_BINS
*
i
;
eBands
[
*
nbEBands
]
=
bark_freq
[
BARK_BANDS
]
/
res
;
eBands
[
*
nbEBands
+
1
]
=
frame_size
;
if
(
eBands
[
*
nbEBands
]
>
eBands
[
*
nbEBands
+
1
])
eBands
[
*
nbEBands
]
=
eBands
[
*
nbEBands
+
1
];
for
(
i
=
0
;
i
<*
nbEBands
+
2
;
i
++
)
printf
(
"%d "
,
eBands
[
i
]);
printf
(
"
\n
"
);
return
eBands
;
}
CELTMode
*
celt_mode_create
(
int
Fs
,
int
channels
,
int
frame_size
,
int
overlap
)
{
int
i
,
res
,
min_width
,
lin
,
low
,
high
;
CELTMode
*
mode
;
mode
=
celt_alloc
(
sizeof
(
CELTMode
));
mode
->
overlap
=
overlap
;
mode
->
mdctSize
=
frame_size
;
mode
->
nbMdctBlocks
=
1
;
mode
->
nbChannels
=
channels
;
mode
->
eBands
=
compute_ebands
(
Fs
,
frame_size
,
&
mode
->
nbEBands
);
printf
(
"%d bands
\n
"
,
mode
->
nbEBands
);
}
/*
int main()
{
celt_mode_create(32000, 1, 256, 128);
}
*/
This diff is collapsed.
Click to expand it.
libcelt/modes.h
+
1
−
0
View file @
81a82957
...
...
@@ -32,6 +32,7 @@
#ifndef MODES_H
#define MODES_H
#include
"celt_types.h"
#include
"celt.h"
struct
CELTMode
{
...
...
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