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
fed97d58
Commit
fed97d58
authored
17 years ago
by
Jean-Marc Valin
Browse files
Options
Downloads
Patches
Plain Diff
optimisation: changed some for() loops to do-while() to give the compiler
a hint that there has to be at least one iteration.
parent
df7ab430
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/rate.c
+2
-1
2 additions, 1 deletion
libcelt/rate.c
libcelt/rate.h
+1
-1
1 addition, 1 deletion
libcelt/rate.h
libcelt/vq.c
+10
-7
10 additions, 7 deletions
libcelt/vq.c
with
13 additions
and
9 deletions
libcelt/rate.c
+
2
−
1
View file @
fed97d58
/* (C) 2007 Jean-Marc Valin, CSIRO
/* (C) 2007
-2008
Jean-Marc Valin, CSIRO
*/
/*
Redistribution and use in source and binary forms, with or without
...
...
@@ -165,6 +165,7 @@ static int bits2pulses(const CELTMode *m, int band, int bits)
for
(
i
=
0
;
i
<
LOG_MAX_PULSES
;
i
++
)
{
int
mid
=
(
lo
+
hi
)
>>
1
;
/* OPT: Make sure this is implemented with a conditional move */
if
(
m
->
bits
[
band
][
mid
]
>=
bits
)
hi
=
mid
;
else
...
...
This diff is collapsed.
Click to expand it.
libcelt/rate.h
+
1
−
1
View file @
fed97d58
/* (C) 2007 Jean-Marc Valin, CSIRO
/* (C) 2007
-2008
Jean-Marc Valin, CSIRO
*/
/*
Redistribution and use in source and binary forms, with or without
...
...
This diff is collapsed.
Click to expand it.
libcelt/vq.c
+
10
−
7
View file @
fed97d58
...
...
@@ -157,8 +157,9 @@ void alg_quant(celt_norm_t *X, celt_mask_t *W, int N, int K, const celt_norm_t *
/* Choose between fast and accurate strategy depending on where we are in the search */
if
(
pulsesLeft
>
1
)
{
for
(
j
=
0
;
j
<
N
;
j
++
)
{
/* OPT: This loop is very CPU-intensive */
j
=
0
;
do
{
celt_word32_t
num
;
celt_word16_t
den
;
/* Select sign based on X[j] alone */
...
...
@@ -173,13 +174,14 @@ void alg_quant(celt_norm_t *X, celt_mask_t *W, int N, int K, const celt_norm_t *
den
=
ROUND16
(
Ryy
,
14
);
/* The idea is to check for num/den >= best_num/best_den, but that way
we can do it without any division */
/* OPT: Make sure to use a conditional move here */
if
(
MULT16_32_Q15
(
best_den
,
num
)
>
MULT16_32_Q15
(
den
,
best_num
))
{
best_den
=
den
;
best_num
=
num
;
best_id
=
j
;
}
}
}
while
(
++
j
<
N
);
/* Promises we loop at least once */
}
else
{
for
(
j
=
0
;
j
<
N
;
j
++
)
{
...
...
@@ -275,17 +277,18 @@ void intra_prediction(celt_norm_t *x, celt_mask_t *W, int N, int K, celt_norm_t
celt_word32_t
xy
=
0
,
yy
=
0
;
celt_word32_t
num
;
celt_word16_t
den
;
/* If this doesn't generate a double-MAC on supported architectures,
/*
OPT:
If this doesn't generate a double-MAC
(
on supported architectures
)
,
complain to your compilor vendor */
for
(
j
=
0
;
j
<
N
;
j
++
)
{
j
=
0
;
do
{
xy
=
MAC16_16
(
xy
,
x
[
j
],
Y
[
i
+
N
-
j
-
1
]);
yy
=
MAC16_16
(
yy
,
Y
[
i
+
N
-
j
-
1
],
Y
[
i
+
N
-
j
-
1
]);
}
}
while
(
++
j
<
N
);
/* Promises we loop at least once */
/* Using xy^2/yy as the score but without having to do the division */
num
=
MULT16_16
(
ROUND16
(
xy
,
14
),
ROUND16
(
xy
,
14
));
den
=
ROUND16
(
yy
,
14
);
/* If you're really desperate for speed, just use xy as the score */
/* OPT: Make sure to use a conditional move here */
if
(
MULT16_32_Q15
(
best_den
,
num
)
>
MULT16_32_Q15
(
den
,
best_num
))
{
best_num
=
num
;
...
...
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