44 return(
getval(in,begin,n,group,max));
53 "huffbuild <input>.vqd <begin,n,group>|<lorange-hirange> [noguard]\n"
54 " where begin,n,group is first scalar, \n"
55 " number of scalars of each in line,\n"
56 " number of scalars in a group\n"
57 "eg: huffbuild reslongaux.vqd 0,1024,4\n"
58 "produces reslongaux.vqh\n\n");
62 int main(
int argc,
char *argv[]){
65 int i,
j,
k,begin,
n,subn,guard=1;
76 strrchr(base,
'.')[0]=
'\0';
79 char *pos=strchr(argv[2],
',');
80 char *dpos=strchr(argv[2],
'-');
92 pos=strchr(pos+1,
',');
98 fprintf(stderr,
"n must be divisible by group\n");
105 file=fopen(infile,
"r");
107 fprintf(stderr,
"Could not open file %s\n",infile);
111 fprintf(stderr,
" making untrained books.\n");
120 if(v>maxval)maxval=
v;
122 if(!(i++&0xff))
spinnit(
"loading... ",i);
129 long vals=pow(maxval,subn);
133 for(j=loval;j<vals;j++)hist[j]=guard;
139 long val=
getval(file,begin,n,subn,maxval);
140 if(val==-1 || val>=vals)
break;
142 if(!(i--&0xff))
spinnit(
"loading... ",i*subn);
148 fprintf(stderr,
"Building tree for %ld entries\n",vals);
153 char *
buffer=alloca(strlen(base)+5);
155 strcat(buffer,
".vqh");
156 file=fopen(buffer,
"w");
158 fprintf(stderr,
"Could not open file %s\n",buffer);
165 fprintf(file,
"static const long _huff_lengthlist_%s[] = {\n",base);
168 for(k=0;k<16 && j<vals;k++,j++)
169 fprintf(file,
"%2ld,",lengths[j]);
172 fprintf(file,
"};\n\n");
175 fprintf(file,
"static const static_codebook _huff_book_%s = {\n",base);
176 fprintf(file,
"\t%d, %ld,\n",subn,vals);
177 fprintf(file,
"\t(long *)_huff_lengthlist_%s,\n",base);
178 fprintf(file,
"\t0, 0, 0, 0, 0,\n");
179 fprintf(file,
"\tNULL,\n");
181 fprintf(file,
"\t0\n};\n\n");
184 fprintf(stderr,
"Done. \n\n");
GLuint const GLfloat * val
void reset_next_value(void)
int main(int argc, char **argv)
char * strdup(const char *inStr)
GLsizei const GLchar const GLint * lengths
void build_tree_from_lengths0(int vals, long *hist, long *lengths)
EGLContext EGLenum EGLClientBuffer buffer
int get_next_ivalue(FILE *in, long *ivalue)
void spinnit(char *s, int n)
static int getval(FILE *in, int begin, int n, int group, int max)
int get_line_value(FILE *in, float *value)
int get_next_value(FILE *in, float *value)
GLsizeiptr const GLvoid GLenum usage