X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=vq%2Fhuffbuild.c;h=50880f25ad5c93eebb2ae4222656c42f3cb0a3ad;hb=130e20f76254404157111598716617555d266acf;hp=28e106d479f851d5c655580c2e7050df904a14a0;hpb=7700f14246d914e1705fa2dfeea730e570078d78;p=platform%2Fupstream%2Flibvorbis.git
diff --git a/vq/huffbuild.c b/vq/huffbuild.c
index 28e106d..50880f2 100644
--- a/vq/huffbuild.c
+++ b/vq/huffbuild.c
@@ -5,13 +5,13 @@
* 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 XIPHOPHORUS Company http://www.xiph.org/ *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2014 *
+ * by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: hufftree builder
- last mod: $Id: huffbuild.c,v 1.10 2001/06/04 05:50:12 xiphmont Exp $
+ last mod: $Id$
********************************************************************/
@@ -49,13 +49,13 @@ static int getval(FILE *in,int begin,int n,int group,int max){
static void usage(){
fprintf(stderr,
- "usage:\n"
- "huffbuild .vqd | [noguard]\n"
- " where begin,n,group is first scalar, \n"
- " number of scalars of each in line,\n"
- " number of scalars in a group\n"
- "eg: huffbuild reslongaux.vqd 0,1024,4\n"
- "produces reslongaux.vqh\n\n");
+ "usage:\n"
+ "huffbuild .vqd | [noguard]\n"
+ " where begin,n,group is first scalar, \n"
+ " number of scalars of each in line,\n"
+ " number of scalars in a group\n"
+ "eg: huffbuild reslongaux.vqd 0,1024,4\n"
+ "produces reslongaux.vqh\n\n");
exit(1);
}
@@ -86,17 +86,17 @@ int main(int argc, char *argv[]){
}else{
begin=atoi(argv[2]);
if(!pos)
- usage();
+ usage();
else
- n=atoi(pos+1);
+ n=atoi(pos+1);
pos=strchr(pos+1,',');
if(!pos)
- usage();
+ usage();
else
- subn=atoi(pos+1);
+ subn=atoi(pos+1);
if(n/subn*subn != n){
- fprintf(stderr,"n must be divisible by group\n");
- exit(1);
+ fprintf(stderr,"n must be divisible by group\n");
+ exit(1);
}
}
}
@@ -127,8 +127,8 @@ int main(int argc, char *argv[]){
{
long vals=pow(maxval,subn);
- long *hist=_ogg_malloc(vals*sizeof(long));
- long *lengths=_ogg_malloc(vals*sizeof(long));
+ long *hist=_ogg_calloc(vals,sizeof(long));
+ long *lengths=_ogg_calloc(vals,sizeof(long));
for(j=loval;j=vals)break;
- hist[val]++;
- if(!(i--&0xff))spinnit("loading... ",i*subn);
+ long val=getval(file,begin,n,subn,maxval);
+ if(val==-1 || val>=vals)break;
+ hist[val]++;
+ if(!(i--&0xff))spinnit("loading... ",i*subn);
}
fclose(file);
}
@@ -155,54 +155,31 @@ int main(int argc, char *argv[]){
strcat(buffer,".vqh");
file=fopen(buffer,"w");
if(!file){
- fprintf(stderr,"Could not open file %s\n",buffer);
- exit(1);
+ fprintf(stderr,"Could not open file %s\n",buffer);
+ exit(1);
}
}
- fprintf(file,
- "/********************************************************************\n"
- " * *\n"
- " * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *\n"
- " * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *\n"
- " * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *\n"
- " * PLEASE READ THESE TERMS DISTRIBUTING. *\n"
- " * *\n"
- " * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-1999 *\n"
- " * by 1999 Monty and The XIPHOPHORUS Company *\n"
- " * http://www.xiph.org/ *\n"
- " * *\n"
- " ********************************************************************\n"
- "\n"
- " function: static codebook autogenerated by huff/huffbuld\n"
- "\n"
- " ********************************************************************/\n\n");
-
- fprintf(file,"#ifndef _V_%s_VQH_\n#define _V_%s_VQH_\n",base,base);
- fprintf(file,"#include \"codebook.h\"\n\n");
-
/* first, the static vectors, then the book structure to tie it together. */
/* lengthlist */
- fprintf(file,"static long _huff_lengthlist_%s[] = {\n",base);
+ fprintf(file,"static const char _huff_lengthlist_%s[] = {\n",base);
for(j=0;j