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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Alexander Traud
Opus
Commits
bd82ca80
Commit
bd82ca80
authored
14 years ago
by
Jean-Marc Valin
Browse files
Options
Downloads
Patches
Plain Diff
Fixed-point version of frac_div32()
parent
456eab2e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libcelt/plc.c
+23
-4
23 additions, 4 deletions
libcelt/plc.c
with
23 additions
and
4 deletions
libcelt/plc.c
+
23
−
4
View file @
bd82ca80
...
...
@@ -4,9 +4,22 @@
#endif
#ifdef FIXED_POINT
#define frac_div(a,b) ((celt_word32)((32768*65535+32767)*(float)(a)/(b)))
static
celt_word32
frac_div32
(
celt_word32
a
,
celt_word32
b
)
{
celt_word32
rcp
,
result
,
rem
;
while
(
b
<
(
1
<<
30
))
{
a
=
SHL32
(
a
,
1
);
b
=
SHL32
(
b
,
1
);
}
rcp
=
PSHR32
(
celt_rcp
(
ROUND16
(
b
,
16
)),
2
);
result
=
SHL32
(
MULT16_32_Q15
(
rcp
,
a
),
1
);
rem
=
a
-
MULT32_32_Q31
(
result
,
b
);
result
+=
SHL32
(
MULT16_32_Q15
(
rcp
,
rem
),
1
);
return
result
;
}
#else
#define frac_div(a,b) ((float)(a)/(b))
#define frac_div
32
(a,b) ((float)(a)/(b))
#endif
...
...
@@ -36,7 +49,7 @@ int p
rr
+=
MULT32_32_Q31
(
lpc
[
j
],
ac
[
i
-
j
]);
rr
+=
SHR32
(
ac
[
i
+
1
],
3
);
//r = -RC_SCALING*1.*SHL32(rr,3)/(error+1e-15);
r
=
-
frac_div
(
SHL32
(
rr
,
3
),
error
);
r
=
-
frac_div
32
(
SHL32
(
rr
,
3
),
error
);
/* Update LPC coefficients and total error */
lpc
[
i
]
=
SHR32
(
r
,
3
);
for
(
j
=
0
;
j
<
(
i
+
1
)
>>
1
;
j
++
)
...
...
@@ -49,8 +62,14 @@ int p
}
error
=
error
-
MULT32_32_Q31
(
MULT32_32_Q31
(
r
,
r
),
error
);
if
(
error
<
.
00001
*
ac
[
0
])
/* Bail out once we get 30 dB gain */
#ifdef FIXED_POINT
if
(
error
<
SHR32
(
ac
[
0
],
10
))
break
;
#else
if
(
error
<
.
001
*
ac
[
0
])
break
;
#endif
}
}
#ifdef FIXED_POINT
...
...
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