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
789fc141
Commit
789fc141
authored
Oct 23, 2009
by
Jean-Marc Valin
Browse files
Removing unused code in the entropy coder
parent
954fb110
Changes
5
Hide whitespace changes
Inline
Side-by-side
libcelt/entcode.h
View file @
789fc141
...
...
@@ -57,7 +57,6 @@ struct ec_byte_buffer{
unsigned
char
*
ptr
;
unsigned
char
*
end_ptr
;
long
storage
;
int
resizable
;
};
/*Encoding functions.*/
...
...
libcelt/entdec.c
View file @
789fc141
...
...
@@ -44,13 +44,6 @@ void ec_byte_readinit(ec_byte_buffer *_b,unsigned char *_buf,long _bytes){
_b
->
end_ptr
=
_b
->
buf
+
_bytes
-
1
;
}
int
ec_byte_look1
(
ec_byte_buffer
*
_b
){
ptrdiff_t
endbyte
;
endbyte
=
_b
->
ptr
-
_b
->
buf
;
if
(
endbyte
>=
_b
->
storage
)
return
-
1
;
else
return
_b
->
ptr
[
0
];
}
unsigned
char
ec_byte_look_at_end
(
ec_byte_buffer
*
_b
){
if
(
_b
->
end_ptr
<
_b
->
buf
)
{
...
...
@@ -59,38 +52,10 @@ unsigned char ec_byte_look_at_end(ec_byte_buffer *_b){
return
*
(
_b
->
end_ptr
--
);
}
int
ec_byte_look4
(
ec_byte_buffer
*
_b
,
ec_uint32
*
_val
){
ptrdiff_t
endbyte
;
endbyte
=
_b
->
ptr
-
_b
->
buf
;
if
(
endbyte
+
4
>
_b
->
storage
){
if
(
endbyte
<
_b
->
storage
){
*
_val
=
_b
->
ptr
[
0
];
endbyte
++
;
if
(
endbyte
<
_b
->
storage
){
*
_val
|=
(
ec_uint32
)
_b
->
ptr
[
1
]
<<
8
;
endbyte
++
;
if
(
endbyte
<
_b
->
storage
)
*
_val
|=
(
ec_uint32
)
_b
->
ptr
[
2
]
<<
16
;
}
}
return
-
1
;
}
else
{
*
_val
=
_b
->
ptr
[
0
];
*
_val
|=
(
ec_uint32
)
_b
->
ptr
[
1
]
<<
8
;
*
_val
|=
(
ec_uint32
)
_b
->
ptr
[
2
]
<<
16
;
*
_val
|=
(
ec_uint32
)
_b
->
ptr
[
3
]
<<
24
;
}
return
0
;
}
void
ec_byte_adv1
(
ec_byte_buffer
*
_b
){
_b
->
ptr
++
;
}
void
ec_byte_adv4
(
ec_byte_buffer
*
_b
){
_b
->
ptr
+=
4
;
}
int
ec_byte_read1
(
ec_byte_buffer
*
_b
){
ptrdiff_t
endbyte
;
endbyte
=
_b
->
ptr
-
_b
->
buf
;
...
...
@@ -98,29 +63,6 @@ int ec_byte_read1(ec_byte_buffer *_b){
else
return
*
(
_b
->
ptr
++
);
}
int
ec_byte_read4
(
ec_byte_buffer
*
_b
,
ec_uint32
*
_val
){
unsigned
char
*
end
;
end
=
_b
->
buf
+
_b
->
storage
;
if
(
_b
->
ptr
+
4
>
end
){
if
(
_b
->
ptr
<
end
){
*
_val
=*
(
_b
->
ptr
++
);
if
(
_b
->
ptr
<
end
){
*
_val
|=
(
ec_uint32
)
*
(
_b
->
ptr
++
)
<<
8
;
if
(
_b
->
ptr
<
end
)
*
_val
|=
(
ec_uint32
)
*
(
_b
->
ptr
++
)
<<
16
;
}
}
return
-
1
;
}
else
{
*
_val
=
(
*
_b
->
ptr
++
);
*
_val
|=
(
ec_uint32
)
*
(
_b
->
ptr
++
)
<<
8
;
*
_val
|=
(
ec_uint32
)
*
(
_b
->
ptr
++
)
<<
16
;
*
_val
|=
(
ec_uint32
)
*
(
_b
->
ptr
++
)
<<
24
;
}
return
0
;
}
ec_uint32
ec_dec_bits
(
ec_dec
*
_this
,
int
_ftb
){
ec_uint32
t
;
...
...
libcelt/entenc.c
View file @
789fc141
...
...
@@ -44,20 +44,11 @@ void ec_byte_writeinit_buffer(ec_byte_buffer *_b, unsigned char *_buf, long _siz
_b
->
ptr
=
_b
->
buf
=
_buf
;
_b
->
end_ptr
=
_b
->
buf
+
_size
-
1
;
_b
->
storage
=
_size
;
_b
->
resizable
=
0
;
}
void
ec_byte_shrink
(
ec_byte_buffer
*
_b
,
long
_size
){
_b
->
end_ptr
=
_b
->
buf
+
_size
-
1
;
_b
->
storage
=
_size
;
_b
->
resizable
=
0
;
}
void
ec_byte_writeinit
(
ec_byte_buffer
*
_b
){
_b
->
ptr
=
_b
->
buf
=
celt_alloc
(
EC_BUFFER_INCREMENT
*
sizeof
(
char
));
_b
->
storage
=
EC_BUFFER_INCREMENT
;
_b
->
end_ptr
=
_b
->
buf
;
_b
->
resizable
=
1
;
}
void
ec_byte_writetrunc
(
ec_byte_buffer
*
_b
,
long
_bytes
){
...
...
@@ -68,13 +59,7 @@ void ec_byte_write1(ec_byte_buffer *_b,unsigned _value){
ptrdiff_t
endbyte
;
endbyte
=
_b
->
ptr
-
_b
->
buf
;
if
(
endbyte
>=
_b
->
storage
){
if
(
_b
->
resizable
){
_b
->
buf
=
celt_realloc
(
_b
->
buf
,(
_b
->
storage
+
EC_BUFFER_INCREMENT
)
*
sizeof
(
char
));
_b
->
storage
+=
EC_BUFFER_INCREMENT
;
_b
->
ptr
=
_b
->
buf
+
endbyte
;
}
else
{
celt_fatal
(
"range encoder overflow
\n
"
);
}
celt_fatal
(
"range encoder overflow
\n
"
);
}
*
(
_b
->
ptr
++
)
=
(
unsigned
char
)
_value
;
}
...
...
@@ -87,49 +72,6 @@ void ec_byte_write_at_end(ec_byte_buffer *_b,unsigned _value){
*
(
_b
->
end_ptr
--
)
=
(
unsigned
char
)
_value
;
}
void
ec_byte_write4
(
ec_byte_buffer
*
_b
,
ec_uint32
_value
){
ptrdiff_t
endbyte
;
endbyte
=
_b
->
ptr
-
_b
->
buf
;
if
(
endbyte
+
4
>
_b
->
storage
){
if
(
_b
->
resizable
){
_b
->
buf
=
celt_realloc
(
_b
->
buf
,(
_b
->
storage
+
EC_BUFFER_INCREMENT
)
*
sizeof
(
char
));
_b
->
storage
+=
EC_BUFFER_INCREMENT
;
_b
->
ptr
=
_b
->
buf
+
endbyte
;
}
else
{
celt_fatal
(
"range encoder overflow
\n
"
);
}
}
*
(
_b
->
ptr
++
)
=
(
unsigned
char
)
_value
;
_value
>>=
8
;
*
(
_b
->
ptr
++
)
=
(
unsigned
char
)
_value
;
_value
>>=
8
;
*
(
_b
->
ptr
++
)
=
(
unsigned
char
)
_value
;
_value
>>=
8
;
*
(
_b
->
ptr
++
)
=
(
unsigned
char
)
_value
;
}
void
ec_byte_writecopy
(
ec_byte_buffer
*
_b
,
void
*
_source
,
long
_bytes
){
ptrdiff_t
endbyte
;
endbyte
=
_b
->
ptr
-
_b
->
buf
;
if
(
endbyte
+
_bytes
>
_b
->
storage
){
if
(
_b
->
resizable
){
_b
->
storage
=
endbyte
+
_bytes
+
EC_BUFFER_INCREMENT
;
_b
->
buf
=
celt_realloc
(
_b
->
buf
,
_b
->
storage
*
sizeof
(
char
));
_b
->
ptr
=
_b
->
buf
+
endbyte
;
}
else
{
celt_fatal
(
"range encoder overflow
\n
"
);
}
}
memmove
(
_b
->
ptr
,
_source
,
_bytes
);
_b
->
ptr
+=
_bytes
;
}
void
ec_byte_writeclear
(
ec_byte_buffer
*
_b
){
if
(
_b
->
resizable
)
celt_free
(
_b
->
buf
);
}
void
ec_enc_bits
(
ec_enc
*
_this
,
ec_uint32
_fl
,
int
_ftb
){
unsigned
fl
;
...
...
tests/ectest.c
View file @
789fc141
...
...
@@ -105,7 +105,6 @@ int main(int _argc,char **_argv){
ldexp
(
nbits2
,
-
4
),
ldexp
(
nbits
,
-
4
));
ret
=-
1
;
}
ec_byte_writeclear
(
&
buf
);
srand
(
seed
);
fprintf
(
stderr
,
"Testing random streams... Random seed: %u (%.4X)
\n
"
,
seed
,
rand
()
%
65536
);
for
(
i
=
0
;
i
<
409600
;
i
++
){
...
...
@@ -149,7 +148,6 @@ int main(int _argc,char **_argv){
ret
=-
1
;
}
}
ec_byte_writeclear
(
&
buf
);
free
(
data
);
}
free
(
ptr
);
...
...
tests/laplace-test.c
View file @
789fc141
...
...
@@ -15,6 +15,7 @@
#include
"../libcelt/entcode.c"
#include
"../libcelt/laplace.c"
#define DATA_SIZE 40000
int
main
(
void
)
{
...
...
@@ -23,9 +24,12 @@ int main(void)
ec_enc
enc
;
ec_dec
dec
;
ec_byte_buffer
buf
;
unsigned
char
*
ptr
;
int
val
[
10000
],
decay
[
10000
];
ALLOC_STACK
;
ec_byte_writeinit
(
&
buf
);
ptr
=
malloc
(
DATA_SIZE
);
ec_byte_writeinit_buffer
(
&
buf
,
ptr
,
DATA_SIZE
);
//ec_byte_writeinit(&buf);
ec_enc_init
(
&
enc
,
&
buf
);
val
[
0
]
=
3
;
decay
[
0
]
=
6000
;
...
...
@@ -54,6 +58,5 @@ int main(void)
}
}
ec_byte_writeclear
(
&
buf
);
return
ret
;
}
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