Skip to content
GitLab
Menu
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
ccea9ce9
Commit
ccea9ce9
authored
Feb 18, 2008
by
Jean-Marc Valin
Browse files
Two-pass algorithm for filling the remaining bits. Still not perfect, but close
enough.
parent
17683ebe
Changes
2
Hide whitespace changes
Inline
Side-by-side
libcelt/celt.c
View file @
ccea9ce9
...
...
@@ -361,7 +361,7 @@ int celt_encode(CELTEncoder *st, celt_int16_t *pcm, unsigned char *compressed, i
}
}
if
(
ec_enc_tell
(
&
st
->
enc
,
0
)
<
nbCompressedBytes
*
8
-
16
)
if
(
ec_enc_tell
(
&
st
->
enc
,
0
)
<
nbCompressedBytes
*
8
-
7
)
celt_warning_int
(
"many unused bits: "
,
nbCompressedBytes
*
8
-
ec_enc_tell
(
&
st
->
enc
,
0
));
//printf ("%d\n", ec_enc_tell(&st->enc, 0)-8*nbCompressedBytes);
/* Finishing the stream with a 0101... pattern so that the decoder can check is everything's right */
...
...
libcelt/rate.c
View file @
ccea9ce9
...
...
@@ -221,13 +221,15 @@ int interp_bits2pulses(const struct alloc_data *alloc, int *bits1, int *bits2, i
for
(
j
=
0
;
j
<
len
;
j
++
)
bits
[
j
]
=
((
1
<<
BITRES
)
-
lo
)
*
bits1
[
j
]
+
lo
*
bits2
[
j
];
out
=
vec_bits2pulses
(
alloc
,
bands
,
bits
,
pulses
,
len
);
/* Do some refinement to use up all bits */
/* Do some refinement to use up all bits. In the first pass, we can only add pulses to
bands that are under their allocated budget. In the second pass, anything goes */
int
firstpass
=
1
;
while
(
1
)
{
int
incremented
=
0
;
for
(
j
=
0
;
j
<
len
;
j
++
)
{
if
(
alloc
->
bits
[
j
][
pulses
[
j
]]
<
bits
[
j
]
&&
pulses
[
j
]
<
MAX_PULSES
-
1
)
if
(
(
!
firstpass
||
alloc
->
bits
[
j
][
pulses
[
j
]]
<
bits
[
j
]
)
&&
pulses
[
j
]
<
MAX_PULSES
-
1
)
{
if
(
out
+
alloc
->
bits
[
j
][
pulses
[
j
]
+
1
]
-
alloc
->
bits
[
j
][
pulses
[
j
]]
<=
total
<<
BITRES
)
{
...
...
@@ -239,7 +241,12 @@ int interp_bits2pulses(const struct alloc_data *alloc, int *bits1, int *bits2, i
}
}
if
(
!
incremented
)
break
;
{
if
(
firstpass
)
firstpass
=
0
;
else
break
;
}
}
return
(
out
+
BITROUND
)
>>
BITRES
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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