21 #include "../ogg/ogg.h"
22 #include "../vorbis/codec.h"
59 for(j=last;j<
this;j++){
134 for(i=0;i<quantvals;i++)
151 memset(s,0,
sizeof(*s));
160 if(s->
entries==-1)
goto _eofout;
175 if(num==-1)
goto _eofout;
184 if(num==-1)
goto _eofout;
198 if(num==-1)
goto _eofout;
199 for(j=0;j<num && i<s->
entries;j++,i++)
237 for(i=0;i<quantvals;i++)
240 if(quantvals&&s->
quantlist[quantvals-1]==-1)
goto _eofout;
279 int best=
_best(book,a,1);
302 x= ((x>>16)&0x0000ffff) | ((x<<16)&0xffff0000);
303 x= ((x>> 8)&0x00ff00ff) | ((x<< 8)&0xff00ff00);
304 x= ((x>> 4)&0x0f0f0f0f) | ((x<< 4)&0xf0f0f0f0);
305 x= ((x>> 2)&0x33333333) | ((x<< 2)&0xcccccccc);
306 return((x>> 1)&0x55555555) | ((x<< 1)&0xaaaaaaaa);
316 if(entry&0x80000000UL){
317 lo=(entry>>15)&0x7fff;
330 while(lok<0 && read>1)
376 return(packed_entry);
381 int step=n/book->
dim;
382 long *entry = alloca(
sizeof(*entry)*step);
383 float **
t = alloca(
sizeof(*t)*step);
386 for (i = 0; i < step; i++) {
388 if(entry[i]==-1)
return(-1);
391 for(i=0,o=0;i<book->
dim;i++,o+=step)
404 if(entry==-1)
return(-1);
406 for (j=0;j<book->
dim;)
412 if(entry==-1)
return(-1);
415 switch((
int)book->
dim){
446 if(entry==-1)
return(-1);
448 for (j=0;j<book->
dim;)
459 for(i=offset/ch;i<(offset+
n)/ch;){
461 if(entry==-1)
return(-1);
464 for (j=0;j<book->
dim;j++){
484 #include "vorbis/book/lsp20_0.vqh"
485 #include "vorbis/book/res0a_13.vqh"
488 float test1[TESTSIZE]={
540 float test3[TESTSIZE]={
541 0,1,-2,3,4,-5,6,7,8,9,
542 8,-2,7,-1,4,6,8,3,1,-9,
543 10,11,12,13,14,15,26,17,18,19,
544 30,-25,-30,-1,-5,-32,4,3,-2,0};
547 &_vq_book_res0a_13,
NULL};
548 float *testvec[]={test1,test3};
556 fprintf(stderr,
"Testing codebook abstraction...:\n");
558 while(testlist[ptr]){
561 float *qv=alloca(
sizeof(*qv)*TESTSIZE);
562 float *iv=alloca(
sizeof(*iv)*TESTSIZE);
563 memcpy(qv,testvec[ptr],
sizeof(*qv)*TESTSIZE);
564 memset(iv,0,
sizeof(*iv)*TESTSIZE);
566 fprintf(stderr,
"\tpacking/coding %ld... ",ptr);
573 fprintf(stderr,
"Codebook size %ld bytes... ",
oggpack_bytes(&write));
574 for(
i=0;
i<TESTSIZE;
i+=c.
dim){
575 int best=
_best(&c,qv+
i,1);
580 fprintf(stderr,
"OK.\n");
581 fprintf(stderr,
"\tunpacking/decoding %ld... ",ptr);
586 fprintf(stderr,
"Error unpacking codebook.\n");
590 fprintf(stderr,
"Error initializing codebook.\n");
594 for(
i=0;
i<TESTSIZE;
i+=c.
dim)
596 fprintf(stderr,
"Error reading codebook test data (EOP).\n");
599 for(
i=0;
i<TESTSIZE;
i++)
600 if(fabs(qv[
i]-iv[
i])>.000001){
601 fprintf(stderr,
"read (%g) != written (%g) at position (%ld)\n",
606 fprintf(stderr,
"OK\n");
long vorbis_book_decodevs_add(codebook *book, float *a, oggpack_buffer *b, int n)
const static_codebook * c
long oggpack_look(oggpack_buffer *b, int bits)
int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b)
int vorbis_book_errorv(codebook *book, float *a)
void oggpack_write(oggpack_buffer *b, unsigned long value, int bits)
int vorbis_book_init_decode(codebook *dest, const static_codebook *source)
ogg_uint32_t * dec_firsttable
void oggpack_adv(oggpack_buffer *b, int bits)
long vorbis_book_decode(codebook *book, oggpack_buffer *b)
int vorbis_staticbook_pack(const static_codebook *c, oggpack_buffer *opb)
GLuint GLuint GLsizei count
void vorbis_book_clear(codebook *b)
int _best(codebook *book, float *a, int step)
long vorbis_book_decodev_add(codebook *book, float *a, oggpack_buffer *b, int n)
void oggpack_readinit(oggpack_buffer *b, unsigned char *buf, int bytes)
int _ilog(unsigned int v)
GLubyte GLubyte GLubyte a
int vorbis_book_init_encode(codebook *dest, const static_codebook *source)
int vorbis_staticbook_unpack(oggpack_buffer *opb, static_codebook *s)
long _book_maptype1_quantvals(const static_codebook *b)
void oggpack_writeinit(oggpack_buffer *b)
long oggpack_bytes(oggpack_buffer *b)
GLsizei const GLcharARB const GLint * length
void oggpack_reset(oggpack_buffer *b)
unsigned char * oggpack_get_buffer(oggpack_buffer *b)
STIN long decode_packed_entry_number(codebook *book, oggpack_buffer *b)
int vorbis_book_encodev(codebook *book, int best, float *a, oggpack_buffer *b)
long vorbis_book_decodevv_add(codebook *book, float **a, long offset, int ch, oggpack_buffer *b, int n)
long oggpack_read(oggpack_buffer *b, int bits)
long vorbis_book_decodev_set(codebook *book, float *a, oggpack_buffer *b, int n)
void vorbis_staticbook_clear(static_codebook *b)