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
bb57fe44
Commit
bb57fe44
authored
Dec 07, 2007
by
Jean-Marc Valin
Browse files
Most of the Laplace encoding works, except that ec_decode() is still not giving
me what I expect
parent
468c5395
Changes
1
Hide whitespace changes
Inline
Side-by-side
libentcode/laplace.c
View file @
bb57fe44
...
...
@@ -65,12 +65,12 @@ void ec_laplace_encode(ec_enc *enc, int value, int decay)
int
ec_laplace_decode
(
ec_dec
*
dec
,
int
decay
)
{
int
val
;
int
val
=
0
;
int
fl
,
fh
,
fs
,
ft
,
fm
;
ft
=
ec_laplace_get_total
(
decay
);
fm
=
ec_decode
(
dec
,
ft
);
printf
(
"
dec
: %d/%d
\n
"
,
fm
,
ft
);
printf
(
"
fm
: %d/%d
\n
"
,
fm
,
ft
);
fl
=
0
;
fs
=
1
<<
15
;
fh
=
fs
;
...
...
@@ -81,14 +81,25 @@ int ec_laplace_decode(ec_dec *dec, int decay)
fh
+=
fs
*
2
;
val
++
;
}
if
(
fm
>=
fl
+
fs
)
val
=
-
val
;
if
(
fl
<
0
)
{
if
(
fm
>=
fl
+
fs
)
{
val
=
-
val
;
fl
+=
fs
;
}
else
{
fh
-=
fs
;
}
}
printf
(
"fl/fh: %d/%d
\n
"
,
fl
,
fh
);
ec_dec_update
(
dec
,
fl
,
fh
,
ft
);
return
val
;
}
#if
0
#if
1
int
main
()
{
int
val
;
ec_enc
enc
;
ec_dec
dec
;
ec_byte_buffer
buf
;
...
...
@@ -105,7 +116,13 @@ int main()
ec_byte_readinit
(
&
buf
,
ec_byte_get_buffer
(
&
buf
),
ec_byte_bytes
(
&
buf
));
ec_dec_init
(
&
dec
,
&
buf
);
ec_laplace_decode(&dec, 10000);
val
=
ec_laplace_decode
(
&
dec
,
10000
);
printf
(
"dec: %d
\n
"
,
val
);
val
=
ec_laplace_decode
(
&
dec
,
12000
);
printf
(
"dec: %d
\n
"
,
val
);
val
=
ec_laplace_decode
(
&
dec
,
9000
);
printf
(
"dec: %d
\n
"
,
val
);
ec_byte_writeclear
(
&
buf
);
return
0
;
...
...
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