44 #define VQ_FEXP_BIAS 768
55 exp=
floor(log(val)/log(2.
f)+.001);
56 mant=rint(ldexp(val,(
VQ_FMAN-1)-exp));
59 return(sign|exp|mant);
63 double mant=val&0x1fffff;
64 int sign=val&0x80000000;
65 long exp =(val&0x7fe00000L)>>
VQ_FMAN;
77 memset(marker,0,
sizeof(marker));
90 if(length<32 && (entry>>length)){
100 for(j=length;j>0;j--){
107 marker[
j]=marker[j-1]<<1;
118 for(j=length+1;j<33;j++)
119 if((marker[j]>>1) == entry){
121 marker[
j]=marker[j-1]<<1;
125 if(sparsecount==0)count++;
133 if(sparsecount != 1){
135 if(marker[i] & (0xffffffffUL>>(32-i))){
143 for(i=0,count=0;i<
n;i++){
175 for(i=0;i<b->
dim;i++){
217 if((sparsemap && b->
lengthlist[j]) || !sparsemap){
220 for(k=0;k<b->
dim;k++){
221 int index= (j/indexdiv)%quantvals;
223 val=
fabs(val)*delta+mindel+last;
238 if((sparsemap && b->
lengthlist[j]) || !sparsemap){
241 for(k=0;k<b->
dim;k++){
243 val=
fabs(val)*delta+mindel+last;
300 x= ((x>>16)&0x0000ffffUL) | ((x<<16)&0xffff0000UL);
301 x= ((x>> 8)&0x00ff00ffUL) | ((x<< 8)&0xff00ff00UL);
302 x= ((x>> 4)&0x0f0f0f0fUL) | ((x<< 4)&0xf0f0f0f0UL);
303 x= ((x>> 2)&0x33333333UL) | ((x<< 2)&0xccccccccUL);
304 return((x>> 1)&0x55555555UL) | ((x<< 1)&0xaaaaaaaaUL);
343 if(codes==
NULL)
goto err_out;
352 sortindex=alloca(n*
sizeof(*sortindex));
356 int position=codep[
i]-codes;
357 sortindex[position]=
i;
404 while((lo+1)<n && c->
codelist[lo+1]<=word)lo++;
411 unsigned long loval=
lo;
412 unsigned long hival=n-
hi;
414 if(loval>0x7fff)loval=0x7fff;
415 if(hival>0x7fff)hival=0x7fff;
417 0x80000000UL | (loval<<15) | hival;
462 static long full_quantlist1[]={0,1,2,3, 4,5,6,7, 8,3,6,1};
463 static long partial_quantlist1[]={0,7,2};
474 static float *test1_result=
NULL;
481 -533200896,1611661312,4,0,
485 static float test2_result[]={-3,-2,-1,0, 1,2,3,4, 5,0,3,-2};
492 -533200896,1611661312,4,1,
496 static float test3_result[]={-3,-5,-6,-6, 1,3,6,10, 5,5,8,6};
503 -533200896,1611661312,4,0,
507 static float test4_result[]={-3,-3,-3, 4,-3,-3, -1,-3,-3,
508 -3, 4,-3, 4, 4,-3, -1, 4,-3,
509 -3,-1,-3, 4,-1,-3, -1,-1,-3,
510 -3,-3, 4, 4,-3, 4, -1,-3, 4,
511 -3, 4, 4, 4, 4, 4, -1, 4, 4,
512 -3,-1, 4, 4,-1, 4, -1,-1, 4,
513 -3,-3,-1, 4,-3,-1, -1,-3,-1,
514 -3, 4,-1, 4, 4,-1, -1, 4,-1,
515 -3,-1,-1, 4,-1,-1, -1,-1,-1};
522 -533200896,1611661312,4,1,
526 static float test5_result[]={-3,-6,-9, 4, 1,-2, -1,-4,-7,
527 -3, 1,-2, 4, 8, 5, -1, 3, 0,
528 -3,-4,-7, 4, 3, 0, -1,-2,-5,
529 -3,-6,-2, 4, 1, 5, -1,-4, 0,
530 -3, 1, 5, 4, 8,12, -1, 3, 7,
531 -3,-4, 0, 4, 3, 7, -1,-2, 2,
532 -3,-6,-7, 4, 1, 0, -1,-4,-5,
533 -3, 1, 0, 4, 8, 7, -1, 3, 2,
534 -3,-4,-5, 4, 3, 2, -1,-2,-3};
542 fprintf(stderr,
"_book_unquantize incorrectly returned NULL\n");
547 if(
fabs(out[i]-comp[i])>.0001){
548 fprintf(stderr,
"disagreement in unquantized and reference data:\n"
549 "position %d, %g != %g\n",i,out[i],comp[i]);
555 fprintf(stderr,
"_book_unquantize returned a value array: \n"
556 " correct result should have been NULL\n");
564 fprintf(stderr,
"Dequant test 1... ");
565 run_test(&test1,test1_result);
566 fprintf(stderr,
"OK\nDequant test 2... ");
567 run_test(&test2,test2_result);
568 fprintf(stderr,
"OK\nDequant test 3... ");
569 run_test(&test3,test3_result);
570 fprintf(stderr,
"OK\nDequant test 4... ");
571 run_test(&test4,test4_result);
572 fprintf(stderr,
"OK\nDequant test 5... ");
573 run_test(&test5,test5_result);
574 fprintf(stderr,
"OK\n\n");
GLuint const GLfloat * val
long vorbis_book_codeword(codebook *book, int entry)
void vorbis_staticbook_destroy(static_codebook *b)
int main(int argc, char **argv)
const static_codebook * c
static ogg_uint32_t bitreverse(ogg_uint32_t x)
long vorbis_book_codelen(codebook *book, int entry)
ogg_uint32_t * dec_firsttable
GLboolean GLboolean GLboolean GLboolean a
static int comp(const void *a, const void *b)
int vorbis_book_init_decode(codebook *dest, const static_codebook *source)
ogg_uint32_t * _make_words(long *l, long n, long sparsecount)
void vorbis_book_clear(codebook *b)
float * _book_unquantize(const static_codebook *b, int n, int *map)
float _float32_unpack(long val)
long _float32_pack(float val)
int _ilog(unsigned int v)
static int sort32a(const void *a, const void *b)
unsigned int ogg_uint32_t
int vorbis_book_init_encode(codebook *dest, const static_codebook *source)
long _book_maptype1_quantvals(const static_codebook *b)
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLdouble GLdouble GLdouble r
GLdouble GLdouble GLdouble b
void qsort(void *base, size_t nmemb, size_t size, int(*compare)(const void *, const void *))