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
b86ed07d
Commit
b86ed07d
authored
17 years ago
by
Jean-Marc Valin
Browse files
Options
Downloads
Patches
Plain Diff
bit allocation wip (untested)
parent
137bf01a
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/rate.c
+41
-1
41 additions, 1 deletion
libcelt/rate.c
with
41 additions
and
1 deletion
libcelt/rate.c
+
41
−
1
View file @
b86ed07d
...
...
@@ -109,7 +109,8 @@ int compute_allocation(const CELTMode *m, int *pulses)
int
bits2pulses
(
int
bits
,
int
N
)
{
int
i
,
b
,
prev
;
/* FIXME: This is terribly inefficient */
/* FIXME: This is terribly inefficient. Do a bisection instead
but be careful about overflows */
prev
=
0
;
i
=
1
;
b
=
log2_frac64
(
ncwrs
(
N
,
i
),
0
);
...
...
@@ -124,6 +125,45 @@ int bits2pulses(int bits, int N)
return
i
;
}
int
vec_bits2pulses
(
int
*
bands
,
int
*
bits
,
int
*
pulses
,
int
len
,
int
B
)
{
int
i
;
int
sum
=
0
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
int
N
=
(
bands
[
i
+
1
]
-
bands
[
i
])
*
B
;
pulses
[
i
]
=
bits2pulses
(
bits
[
i
],
N
);
sum
+=
log2_frac64
(
ncwrs
(
N
,
pulses
[
i
]),
8
);
}
return
(
sum
+
255
)
>>
8
;
}
int
interp_bits2pulses
(
int
*
bands
,
int
*
bits1
,
int
*
bits2
,
int
total
,
int
*
pulses
,
int
len
,
int
B
)
{
int
i
;
/* FIXME: This too is terribly inefficient. We should do a bisection instead */
for
(
i
=
0
;
i
<
16
;
i
++
)
{
int
j
;
int
bits
[
len
];
for
(
j
=
0
;
j
<
len
;
j
++
)
bits
[
j
]
=
((
16
-
i
)
*
bits1
[
j
]
+
i
*
bits2
[
j
])
>>
4
;
if
(
vec_bits2pulses
(
bands
,
bits
,
pulses
,
len
,
B
)
>
total
)
break
;
}
if
(
i
==
0
)
return
-
1
;
else
{
int
j
;
int
bits
[
len
];
/* Get the previous one (that didn't bust). Should rewrite that anyway */
i
--
;
for
(
j
=
0
;
j
<
len
;
j
++
)
bits
[
j
]
=
((
16
-
i
)
*
bits1
[
j
]
+
i
*
bits2
[
j
])
>>
4
;
return
vec_bits2pulses
(
bands
,
bits
,
pulses
,
len
,
B
);
}
}
#if 0
int main()
{
...
...
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