Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/celt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJean-Marc Valin <jean-marc.valin@usherbrooke.ca>2009-06-18 07:23:46 +0400
committerJean-Marc Valin <jean-marc.valin@usherbrooke.ca>2009-07-23 15:33:24 +0400
commitc08be4485b9e15461578527f568219459db2036c (patch)
treef58cb17580811634247c9683edabd92da9a205d7 /tests
parent8d940a664e14952f3541b6587e367064d9f321bd (diff)
Implemented "raw bits"
Making it so all the information encoded directly with ec_enc_bits() gets stored at the end of the stream, without going through the range coder. This should be both faster and reduce the effects of bit errors. Conflicts: tests/ectest.c
Diffstat (limited to 'tests')
-rw-r--r--tests/ectest.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/ectest.c b/tests/ectest.c
index e861dfb..397a29e 100644
--- a/tests/ectest.c
+++ b/tests/ectest.c
@@ -11,6 +11,7 @@
#include "entcode.h"
#include "entenc.h"
#include "entdec.h"
+#include <string.h>
#include "../libcelt/rangeenc.c"
#include "../libcelt/rangedec.c"
@@ -21,6 +22,8 @@
#ifndef M_LOG2E
# define M_LOG2E 1.4426950408889634074
#endif
+#define DATA_SIZE 10000000
+#define DATA_SIZE2 10000
int main(int _argc,char **_argv){
ec_byte_buffer buf;
@@ -38,7 +41,7 @@ int main(int _argc,char **_argv){
unsigned int seed;
ret=0;
entropy=0;
-
+ unsigned char *ptr;
if (_argc > 2) {
fprintf(stderr, "Usage: %s [<seed>]\n", _argv[0]);
return 1;
@@ -48,7 +51,8 @@ int main(int _argc,char **_argv){
else
seed = (time(NULL) ^ (getpid()%(1<<16) << 16));
/*Testing encoding of raw bit values.*/
- ec_byte_writeinit(&buf);
+ ptr = malloc(DATA_SIZE);
+ ec_byte_writeinit_buffer(&buf, ptr, DATA_SIZE);
ec_enc_init(&enc,&buf);
for(ft=2;ft<1024;ft++){
for(i=0;i<ft;i++){
@@ -76,7 +80,7 @@ int main(int _argc,char **_argv){
"Encoded %0.2lf bits of entropy to %0.2lf bits (%0.3lf%% wasted).\n",
entropy,ldexp(nbits,-4),100*(nbits-ldexp(entropy,4))/nbits);
fprintf(stderr,"Packed to %li bytes.\n",(long)(buf.ptr-buf.buf));
- ec_byte_readinit(&buf,ec_byte_get_buffer(&buf),ec_byte_bytes(&buf));
+ ec_byte_readinit(&buf,ptr,DATA_SIZE);
ec_dec_init(&dec,&buf);
for(ft=2;ft<1024;ft++){
for(i=0;i<ft;i++){
@@ -114,7 +118,7 @@ int main(int _argc,char **_argv){
ft=rand()/((RAND_MAX>>(rand()%11))+1)+10;
sz=rand()/((RAND_MAX>>(rand()%9))+1);
data=(unsigned *)malloc(sz*sizeof(*data));
- ec_byte_writeinit(&buf);
+ ec_byte_writeinit_buffer(&buf, ptr, DATA_SIZE2);
ec_enc_init(&enc,&buf);
zeros = rand()%13==0;
for(j=0;j<sz;j++){
@@ -136,7 +140,7 @@ int main(int _argc,char **_argv){
ret=-1;
}
tell_bits -= 8*ec_byte_bytes(&buf);
- ec_byte_readinit(&buf,ec_byte_get_buffer(&buf),ec_byte_bytes(&buf));
+ ec_byte_readinit(&buf,ptr,DATA_SIZE2);
ec_dec_init(&dec,&buf);
for(j=0;j<sz;j++){
sym=ec_dec_uint(&dec,ft);
@@ -150,5 +154,6 @@ int main(int _argc,char **_argv){
ec_byte_writeclear(&buf);
free(data);
}
+ free(ptr);
return ret;
}