From c08be4485b9e15461578527f568219459db2036c Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Wed, 17 Jun 2009 23:23:46 -0400 Subject: 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 --- tests/ectest.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'tests') 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 #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 []\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>(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