* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
- * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
- * by the Xiph.Org Foundation http://www.xiph.org/ *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2014 *
+ * by the Xiph.Org Foundation https://xiph.org/ *
* *
********************************************************************
function: hufftree builder
- last mod: $Id$
********************************************************************/
static void usage(){
fprintf(stderr,
- "usage:\n"
+ "usage:\n"
"huffbuild <input>.vqd <begin,n,group>|<lorange-hirange> [noguard]\n"
" where begin,n,group is first scalar, \n"
" number of scalars of each in line,\n"
long v;
if(get_next_ivalue(file,&v))break;
if(v>maxval)maxval=v;
-
+
if(!(i++&0xff))spinnit("loading... ",i);
}
rewind(file);
long vals=pow(maxval,subn);
long *hist=_ogg_calloc(vals,sizeof(long));
long *lengths=_ogg_calloc(vals,sizeof(long));
-
+
for(j=loval;j<vals;j++)hist[j]=guard;
-
+
if(file){
reset_next_value();
i/=subn;
}
fclose(file);
}
-
+
/* we have the probabilities, build the tree */
fprintf(stderr,"Building tree for %ld entries\n",vals);
build_tree_from_lengths0(vals,hist,lengths);
exit(1);
}
}
-
+
/* first, the static vectors, then the book structure to tie it together. */
/* lengthlist */
- fprintf(file,"static const long _huff_lengthlist_%s[] = {\n",base);
+ fprintf(file,"static const char _huff_lengthlist_%s[] = {\n",base);
for(j=0;j<vals;){
fprintf(file,"\t");
for(k=0;k<16 && j<vals;k++,j++)
fprintf(file,"\n");
}
fprintf(file,"};\n\n");
-
+
/* the toplevel book */
fprintf(file,"static const static_codebook _huff_book_%s = {\n",base);
fprintf(file,"\t%d, %ld,\n",subn,vals);
- fprintf(file,"\t(long *)_huff_lengthlist_%s,\n",base);
+ fprintf(file,"\t(char *)_huff_lengthlist_%s,\n",base);
fprintf(file,"\t0, 0, 0, 0, 0,\n");
fprintf(file,"\tNULL,\n");
fprintf(file,"\t0\n};\n\n");
-
+
fclose(file);
fprintf(stderr,"Done. \n\n");
}