From eaf29d90e892dde843bad47ea5f579abf6bda8d5 Mon Sep 17 00:00:00 2001 From: Monty Date: Sun, 13 Feb 2000 10:23:51 +0000 Subject: Fixed bug reading codebooks with very large auxiliary encoding structs svn path=/trunk/vorbis/; revision=259 --- vq/bookutil.c | 35 ++++++++++++++++++++++++++++++----- vq/vqsplit.c | 26 +++++++++----------------- 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/vq/bookutil.c b/vq/bookutil.c index d22742eb..c4de2c0f 100644 --- a/vq/bookutil.c +++ b/vq/bookutil.c @@ -12,7 +12,7 @@ ******************************************************************** function: utility functions for loading .vqh and .vqd files - last mod: $Id: bookutil.c,v 1.8 2000/02/07 19:39:44 xiphmont Exp $ + last mod: $Id: bookutil.c,v 1.9 2000/02/13 10:23:50 xiphmont Exp $ ********************************************************************/ @@ -103,7 +103,8 @@ int get_line_value(FILE *in,double *value){ return(-1); }else{ value_line_buff=next; - while(*value_line_buff>32)value_line_buff++; + while(*value_line_buff>44)value_line_buff++; + if(*value_line_buff==44)value_line_buff++; return(0); } } @@ -297,12 +298,36 @@ codebook *codebook_load(char *filename){ return(b); } +static double _dist(int el,double *a, double *b){ + int i; + double acc=0.; + for(i=0;ic; encode_aux *t=c->encode_tree; int ptr=0,k; + + /*{ + brute force + double this,best=_dist(c->dim,val,b->valuelist); + int i; + for(i=1;ientries;i++){ + this=_dist(c->dim,val,b->valuelist+i*c->dim); + if(thisdim*sizeof(double)); - + while(1){ double C=0.; double *p=b->valuelist+t->p[ptr]; @@ -313,10 +338,10 @@ int codebook_entry(codebook *b,double *val){ C-=(p[k]+q[k])*n[k]; } C/=2.; - + for(k=0;kdim;k++) C+=n[k]*val[k]; - + if(C>0.) /* in A */ ptr= -t->ptr0[ptr]; else /* in B */ diff --git a/vq/vqsplit.c b/vq/vqsplit.c index a3409cf3..bf4e8c4b 100644 --- a/vq/vqsplit.c +++ b/vq/vqsplit.c @@ -12,7 +12,7 @@ ******************************************************************** function: build a VQ codebook and the encoding decision 'tree' - last mod: $Id: vqsplit.c,v 1.14 2000/01/28 09:05:21 xiphmont Exp $ + last mod: $Id: vqsplit.c,v 1.15 2000/02/13 10:23:51 xiphmont Exp $ ********************************************************************/ @@ -371,18 +371,14 @@ int lp_split(vqgen *v,codebook *b, static int _node_eq(encode_aux *v, long a, long b){ long Aptr0=v->ptr0[a]; long Aptr1=v->ptr1[a]; - long Ap =v->p[a]; - long Aq =v->q[a]; long Bptr0=v->ptr0[b]; long Bptr1=v->ptr1[b]; - long Bp =v->p[b]; - long Bq =v->q[b]; /* the possibility of choosing the same p and q, but switched, can;t happen because we always look for the best p/q in the same search order and the search is stable */ - if(Aptr0==Bptr0 && Aptr1==Bptr1 && Ap==Bp && Aq==Bq) + if(Aptr0==Bptr0 && Aptr1==Bptr1) return(1); return(0); @@ -428,10 +424,8 @@ void vqsp_book(vqgen *v, codebook *b, long *quantlist){ /* The tree is likely big and redundant. Pare and reroute branches */ { int changedflag=1; - long *unique_entries=alloca(t->aux*sizeof(long)); while(changedflag){ - int nodes=0; changedflag=0; fprintf(stderr,"\t..."); @@ -442,19 +436,16 @@ void vqsp_book(vqgen *v, codebook *b, long *quantlist){ int k; /* check list of unique decisions */ - for(j=0;jaux;k++){ - if(t->ptr0[k]==-i)t->ptr0[k]=-unique_entries[j]; - if(t->ptr1[k]==-i)t->ptr1[k]=-unique_entries[j]; + if(t->ptr0[k]==-i)t->ptr0[k]=-j; + if(t->ptr1[k]==-i)t->ptr1[k]=-j; } /* Now, we need to fill in the hole from this redundant @@ -471,7 +462,8 @@ void vqsp_book(vqgen *v, codebook *b, long *quantlist){ } /* hole plugged */ - } + }else + i++; } fprintf(stderr," %ld remaining\n",t->aux); -- cgit v1.2.1