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
c6ca4992
Commit
c6ca4992
authored
16 years ago
by
Jean-Marc Valin
Browse files
Options
Downloads
Patches
Plain Diff
Infrastructure work for a psy model
parent
13294b54
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
libcelt/celt.c
+28
-3
28 additions, 3 deletions
libcelt/celt.c
libcelt/psy.c
+2
-2
2 additions, 2 deletions
libcelt/psy.c
libcelt/psy.h
+1
-1
1 addition, 1 deletion
libcelt/psy.h
with
31 additions
and
6 deletions
libcelt/celt.c
+
28
−
3
View file @
c6ca4992
...
...
@@ -73,6 +73,10 @@ struct CELTEncoder {
celt_sig_t
*
out_mem
;
celt_word16_t
*
oldBandE
;
#ifdef EXP_PSY
celt_word16_t
*
psy_mem
;
struct
PsyDecay
psy
;
#endif
};
CELTEncoder
EXPORT
*
celt_encoder_create
(
const
CELTMode
*
mode
)
...
...
@@ -103,6 +107,11 @@ CELTEncoder EXPORT *celt_encoder_create(const CELTMode *mode)
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
));;
#ifdef EXP_PSY
st
->
psy_mem
=
celt_alloc
(
MAX_PERIOD
*
sizeof
(
celt_word16_t
));
psydecay_init
(
&
st
->
psy
,
MAX_PERIOD
/
2
,
st
->
mode
->
Fs
);
#endif
return
st
;
}
...
...
@@ -126,6 +135,11 @@ void EXPORT celt_encoder_destroy(CELTEncoder *st)
celt_free
(
st
->
preemph_memE
);
celt_free
(
st
->
preemph_memD
);
#ifdef EXP_PSY
celt_free
(
st
->
psy_mem
);
psydecay_clear
(
&
st
->
psy
);
#endif
celt_free
(
st
);
}
...
...
@@ -224,6 +238,9 @@ int EXPORT celt_encode(CELTEncoder * restrict st, celt_int16_t * restrict pcm, u
VARDECL
(
celt_ener_t
,
bandE
);
VARDECL
(
celt_pgain_t
,
gains
);
VARDECL
(
int
,
stereo_mode
);
#ifdef EXP_PSY
VARDECL
(
celt_word32_t
,
mask
);
#endif
const
int
C
=
CHANNELS
(
st
->
mode
);
SAVE_STACK
;
...
...
@@ -260,13 +277,21 @@ int EXPORT celt_encode(CELTEncoder * restrict st, celt_int16_t * restrict pcm, u
/* Compute MDCTs */
compute_mdcts
(
st
->
mode
,
st
->
mode
->
window
,
in
,
freq
);
#if 0 /* Mask disabled until it can be made to do something useful */
compute_mdct_masking(X, mask, B*C*N, st->Fs);
#ifdef EXP_PSY
CELT_MOVE
(
st
->
psy_mem
,
st
->
out_mem
+
N
,
MAX_PERIOD
+
st
->
overlap
-
N
);
for
(
i
=
0
;
i
<
N
;
i
++
)
st
->
psy_mem
[
MAX_PERIOD
+
st
->
overlap
-
N
+
i
]
=
in
[
C
*
(
st
->
overlap
+
i
)];
for
(
c
=
1
;
c
<
C
;
c
++
)
for
(
i
=
0
;
i
<
N
;
i
++
)
st
->
psy_mem
[
MAX_PERIOD
+
st
->
overlap
-
N
+
i
]
+=
in
[
C
*
(
st
->
overlap
+
i
)
+
c
];
ALLOC
(
mask
,
N
,
celt_sig_t
);
compute_mdct_masking
(
&
st
->
psy
,
freq
,
st
->
psy_mem
,
mask
,
C
*
N
);
/* Invert and stretch the mask to length of X
For some reason, I get better results by using the sqrt instead,
although there's no valid reason to. Must investigate further */
for (i=0;i<
B*
C*N;i++)
for
(
i
=
0
;
i
<
C
*
N
;
i
++
)
mask
[
i
]
=
1
/
(.
1
+
mask
[
i
]);
#endif
...
...
This diff is collapsed.
Click to expand it.
libcelt/psy.c
+
2
−
2
View file @
c6ca4992
...
...
@@ -143,8 +143,8 @@ void compute_masking(const struct PsyDecay *decay, celt_word16_t *X, celt_mask_t
spreading_func
(
decay
,
mask
,
N
);
}
#if
0
/* Not needed for now, but will be useful in the future */
void compute_mdct_masking(const struct PsyDecay *decay, celt_word32_t *X, celt_mask_t *mask, int len)
#if
def EXP_PSY
/* Not needed for now, but will be useful in the future */
void
compute_mdct_masking
(
const
struct
PsyDecay
*
decay
,
celt_word32_t
*
X
,
celt_word16_t
*
long_window
,
celt_mask_t
*
mask
,
int
len
)
{
int
i
;
VARDECL
(
float
,
psd
);
...
...
This diff is collapsed.
Click to expand it.
libcelt/psy.h
+
1
−
1
View file @
c6ca4992
...
...
@@ -48,6 +48,6 @@ void psydecay_clear(struct PsyDecay *decay);
void
compute_masking
(
const
struct
PsyDecay
*
decay
,
celt_word16_t
*
X
,
celt_mask_t
*
mask
,
int
len
);
/** Compute the masking curve for an input (MDCT) spectrum X */
void
compute_mdct_masking
(
const
struct
PsyDecay
*
decay
,
celt_word32_t
*
X
,
celt_mask_t
*
mask
,
int
len
);
void
compute_mdct_masking
(
const
struct
PsyDecay
*
decay
,
celt_word32_t
*
X
,
celt_word16_t
*
long_window
,
celt_mask_t
*
mask
,
int
len
);
#endif
/* PSY_H */
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