Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Mark Harris
Opus
Commits
b86ed07d
Commit
b86ed07d
authored
Jan 15, 2008
by
Jean-Marc Valin
Browse files
bit allocation wip (untested)
parent
137bf01a
Changes
1
Hide whitespace changes
Inline
Side-by-side
libcelt/rate.c
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()
{
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment