diff options
author | Monty <xiphmont@xiph.org> | 2000-11-04 06:43:56 +0000 |
---|---|---|
committer | Monty <xiphmont@xiph.org> | 2000-11-04 06:43:56 +0000 |
commit | 167c853de8389c27eac144eab2af96c66f916508 (patch) | |
tree | 5cace70f907a335a2f3d16b94681b54560cfdd00 | |
parent | 7344a1c20fb4acfb8f2de692d55a0b4fec7bcc59 (diff) | |
download | libvorbis-git-167c853de8389c27eac144eab2af96c66f916508.tar.gz |
trade out malloc, calloc, realloc for redefinable hooks _ogg_malloc,
_ogg_calloc, _ogg_realloc.
svn path=/branches/branch_beta3/vorbis/; revision=972
-rw-r--r-- | debian/README.examples | 11 | ||||
-rw-r--r-- | include/vorbis/codec.h | 4 | ||||
-rw-r--r-- | lib/block.c | 48 | ||||
-rw-r--r-- | lib/codebook.c | 8 | ||||
-rw-r--r-- | lib/envelope.c | 12 | ||||
-rw-r--r-- | lib/floor0.c | 12 | ||||
-rw-r--r-- | lib/iir.c | 13 | ||||
-rw-r--r-- | lib/info.c | 46 | ||||
-rw-r--r-- | lib/mapping0.c | 26 | ||||
-rw-r--r-- | lib/mdct.c | 6 | ||||
-rw-r--r-- | lib/misc.c | 14 | ||||
-rw-r--r-- | lib/misc.h | 16 | ||||
-rw-r--r-- | lib/os.h | 4 | ||||
-rw-r--r-- | lib/psy.c | 24 | ||||
-rw-r--r-- | lib/psytune.c | 22 | ||||
-rw-r--r-- | lib/res0.c | 16 | ||||
-rw-r--r-- | lib/sharedbook.c | 16 | ||||
-rw-r--r-- | lib/smallft.c | 6 | ||||
-rw-r--r-- | lib/vorbisenc.c | 6 | ||||
-rw-r--r-- | lib/vorbisfile.c | 18 | ||||
-rw-r--r-- | lib/window.c | 4 | ||||
-rw-r--r-- | mac/compat/strdup.c | 1 | ||||
-rw-r--r-- | vq/bookutil.c | 44 | ||||
-rw-r--r-- | vq/build.c | 8 | ||||
-rw-r--r-- | vq/huffbuild.c | 6 | ||||
-rw-r--r-- | vq/latticebuild.c | 12 | ||||
-rw-r--r-- | vq/latticehint.c | 32 | ||||
-rw-r--r-- | vq/latticepare.c | 42 | ||||
-rw-r--r-- | vq/latticetune.c | 6 | ||||
-rw-r--r-- | vq/lspdata.c | 4 | ||||
-rw-r--r-- | vq/metrics.c | 22 | ||||
-rw-r--r-- | vq/residuedata.c | 4 | ||||
-rw-r--r-- | vq/residuesplit.c | 10 | ||||
-rw-r--r-- | vq/run.c | 10 | ||||
-rw-r--r-- | vq/vqgen.c | 22 | ||||
-rw-r--r-- | vq/vqsplit.c | 52 |
36 files changed, 310 insertions, 297 deletions
diff --git a/debian/README.examples b/debian/README.examples new file mode 100644 index 00000000..3bf63010 --- /dev/null +++ b/debian/README.examples @@ -0,0 +1,11 @@ +Example tools using vorbis. + +The examples/ directory contains some example source files to build tools +using the vorbis codec. The Makefile is only included to show how they are +compiled. It contains relative references to the libraries in the source +tree, so it will *not* work without being edited first. + +The misc.h included in chaining_example and seeking_test just allows the +use of a debugging _ogg_malloc. (defined in misc.c) It is safe to comment out. + + -- Michael Beattie <mjb@debian.org>, Mon, 26 Jun 2000 18:59:56 +1200 diff --git a/include/vorbis/codec.h b/include/vorbis/codec.h index d70b69ef..9b7f6f7e 100644 --- a/include/vorbis/codec.h +++ b/include/vorbis/codec.h @@ -12,7 +12,7 @@ ******************************************************************** function: libvorbis codec headers - last mod: $Id: codec.h,v 1.32.2.4 2000/11/04 06:21:40 xiphmont Exp $ + last mod: $Id: codec.h,v 1.32.2.5 2000/11/04 06:43:48 xiphmont Exp $ ********************************************************************/ @@ -102,7 +102,7 @@ typedef struct vorbis_block{ ogg_int64_t sequence; vorbis_dsp_state *vd; /* For read-only access of configuration */ - /* local storage to avoid remallocing; it's up to the mapping to + /* local storage to avoid re_ogg_mallocing; it's up to the mapping to structure it */ void *localstore; long localtop; diff --git a/lib/block.c b/lib/block.c index db1a4ab2..347e1424 100644 --- a/lib/block.c +++ b/lib/block.c @@ -12,7 +12,7 @@ ******************************************************************** function: PCM data vector blocking, windowing and dis/reassembly - last mod: $Id: block.c,v 1.39.2.4 2000/11/04 06:21:42 xiphmont Exp $ + last mod: $Id: block.c,v 1.39.2.5 2000/11/04 06:43:49 xiphmont Exp $ Handle windowing, overlap-add, etc of the PCM vectors. This is made more amusing by Vorbis' current two allowed block sizes. @@ -105,9 +105,9 @@ int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb){ void *_vorbis_block_alloc(vorbis_block *vb,long bytes){ bytes=(bytes+(WORD_ALIGN-1)) & ~(WORD_ALIGN-1); if(bytes+vb->localtop>vb->localalloc){ - /* can't just realloc... there are outstanding pointers */ + /* can't just _ogg_realloc... there are outstanding pointers */ if(vb->localstore){ - struct alloc_chain *link=malloc(sizeof(struct alloc_chain)); + struct alloc_chain *link=_ogg_malloc(sizeof(struct alloc_chain)); vb->totaluse+=vb->localtop; link->next=vb->reap; link->ptr=vb->localstore; @@ -115,7 +115,7 @@ void *_vorbis_block_alloc(vorbis_block *vb,long bytes){ } /* highly conservative */ vb->localalloc=bytes; - vb->localstore=malloc(vb->localalloc); + vb->localstore=_ogg_malloc(vb->localalloc); vb->localtop=0; } { @@ -138,7 +138,7 @@ void _vorbis_block_ripcord(vorbis_block *vb){ } /* consolidate storage */ if(vb->totaluse){ - vb->localstore=realloc(vb->localstore,vb->totaluse+vb->localalloc); + vb->localstore=_ogg_realloc(vb->localstore,vb->totaluse+vb->localalloc); vb->localalloc+=vb->totaluse; vb->totaluse=0; } @@ -169,29 +169,29 @@ static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){ backend_lookup_state *b=NULL; memset(v,0,sizeof(vorbis_dsp_state)); - b=v->backend_state=calloc(1,sizeof(backend_lookup_state)); + b=v->backend_state=_ogg_calloc(1,sizeof(backend_lookup_state)); v->vi=vi; b->modebits=ilog2(ci->modes); - b->transform[0]=calloc(VI_TRANSFORMB,sizeof(vorbis_look_transform *)); - b->transform[1]=calloc(VI_TRANSFORMB,sizeof(vorbis_look_transform *)); + b->transform[0]=_ogg_calloc(VI_TRANSFORMB,sizeof(vorbis_look_transform *)); + b->transform[1]=_ogg_calloc(VI_TRANSFORMB,sizeof(vorbis_look_transform *)); /* MDCT is tranform 0 */ - b->transform[0][0]=calloc(1,sizeof(mdct_lookup)); - b->transform[1][0]=calloc(1,sizeof(mdct_lookup)); + b->transform[0][0]=_ogg_calloc(1,sizeof(mdct_lookup)); + b->transform[1][0]=_ogg_calloc(1,sizeof(mdct_lookup)); mdct_init(b->transform[0][0],ci->blocksizes[0]); mdct_init(b->transform[1][0],ci->blocksizes[1]); - b->window[0][0][0]=calloc(VI_WINDOWB,sizeof(float *)); + b->window[0][0][0]=_ogg_calloc(VI_WINDOWB,sizeof(float *)); b->window[0][0][1]=b->window[0][0][0]; b->window[0][1][0]=b->window[0][0][0]; b->window[0][1][1]=b->window[0][0][0]; - b->window[1][0][0]=calloc(VI_WINDOWB,sizeof(float *)); - b->window[1][0][1]=calloc(VI_WINDOWB,sizeof(float *)); - b->window[1][1][0]=calloc(VI_WINDOWB,sizeof(float *)); - b->window[1][1][1]=calloc(VI_WINDOWB,sizeof(float *)); + b->window[1][0][0]=_ogg_calloc(VI_WINDOWB,sizeof(float *)); + b->window[1][0][1]=_ogg_calloc(VI_WINDOWB,sizeof(float *)); + b->window[1][1][0]=_ogg_calloc(VI_WINDOWB,sizeof(float *)); + b->window[1][1][1]=_ogg_calloc(VI_WINDOWB,sizeof(float *)); for(i=0;i<VI_WINDOWB;i++){ b->window[0][0][0][i]= @@ -208,13 +208,13 @@ static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){ if(encp){ /* encode/decode differ here */ /* finish the codebooks */ - b->fullbooks=calloc(ci->books,sizeof(codebook)); + b->fullbooks=_ogg_calloc(ci->books,sizeof(codebook)); for(i=0;i<ci->books;i++) vorbis_book_init_encode(b->fullbooks+i,ci->book_param[i]); v->analysisp=1; }else{ /* finish the codebooks */ - b->fullbooks=calloc(ci->books,sizeof(codebook)); + b->fullbooks=_ogg_calloc(ci->books,sizeof(codebook)); for(i=0;i<ci->books;i++) vorbis_book_init_decode(b->fullbooks+i,ci->book_param[i]); } @@ -225,12 +225,12 @@ static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){ v->pcm_storage=8192; /* we'll assume later that we have a minimum of twice the blocksize of accumulated samples in analysis */ - v->pcm=malloc(vi->channels*sizeof(float *)); - v->pcmret=malloc(vi->channels*sizeof(float *)); + v->pcm=_ogg_malloc(vi->channels*sizeof(float *)); + v->pcmret=_ogg_malloc(vi->channels*sizeof(float *)); { int i; for(i=0;i<vi->channels;i++) - v->pcm[i]=calloc(v->pcm_storage,sizeof(float)); + v->pcm[i]=_ogg_calloc(v->pcm_storage,sizeof(float)); } /* all 1 (large block) or 0 (small block) */ @@ -244,7 +244,7 @@ static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){ v->pcm_current=v->centerW; /* initialize all the mapping/backend lookups */ - b->mode=calloc(ci->modes,sizeof(vorbis_look_mapping *)); + b->mode=_ogg_calloc(ci->modes,sizeof(vorbis_look_mapping *)); for(i=0;i<ci->modes;i++){ int mapnum=ci->mode_param[i]->mapping; int maptype=ci->map_type[mapnum]; @@ -263,7 +263,7 @@ int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi){ b=v->backend_state; /* Initialize the envelope state storage */ - b->ve=calloc(1,sizeof(envelope_lookup)); + b->ve=_ogg_calloc(1,sizeof(envelope_lookup)); _ve_envelope_init(b->ve,vi); return(0); @@ -359,7 +359,7 @@ float **vorbis_analysis_buffer(vorbis_dsp_state *v, int vals){ v->pcm_storage=v->pcm_current+vals*2; for(i=0;i<vi->channels;i++){ - v->pcm[i]=realloc(v->pcm[i],v->pcm_storage*sizeof(float)); + v->pcm[i]=_ogg_realloc(v->pcm[i],v->pcm_storage*sizeof(float)); } } @@ -663,7 +663,7 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ v->pcm_storage=endW+ci->blocksizes[1]; for(i=0;i<vi->channels;i++) - v->pcm[i]=realloc(v->pcm[i],v->pcm_storage*sizeof(float)); + v->pcm[i]=_ogg_realloc(v->pcm[i],v->pcm_storage*sizeof(float)); } /* overlap/add PCM */ diff --git a/lib/codebook.c b/lib/codebook.c index 376d6cc8..5aaab413 100644 --- a/lib/codebook.c +++ b/lib/codebook.c @@ -12,7 +12,7 @@ ******************************************************************** function: basic codebook pack/unpack/code/decode operations - last mod: $Id: codebook.c,v 1.18.2.3 2000/11/04 06:21:42 xiphmont Exp $ + last mod: $Id: codebook.c,v 1.18.2.4 2000/11/04 06:43:49 xiphmont Exp $ ********************************************************************/ @@ -162,7 +162,7 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){ switch(oggpack_read(opb,1)){ case 0: /* unordered */ - s->lengthlist=malloc(sizeof(long)*s->entries); + s->lengthlist=_ogg_malloc(sizeof(long)*s->entries); /* allocated but unused entries? */ if(oggpack_read(opb,1)){ @@ -190,7 +190,7 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){ /* ordered */ { long length=oggpack_read(opb,5)+1; - s->lengthlist=malloc(sizeof(long)*s->entries); + s->lengthlist=_ogg_malloc(sizeof(long)*s->entries); for(i=0;i<s->entries;){ long num=oggpack_read(opb,_ilog(s->entries-i)); @@ -232,7 +232,7 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){ } /* quantized values */ - s->quantlist=malloc(sizeof(float)*quantvals); + s->quantlist=_ogg_malloc(sizeof(float)*quantvals); for(i=0;i<quantvals;i++) s->quantlist[i]=oggpack_read(opb,s->q_quant); diff --git a/lib/envelope.c b/lib/envelope.c index f00a7d4a..720f9c4f 100644 --- a/lib/envelope.c +++ b/lib/envelope.c @@ -12,7 +12,7 @@ ******************************************************************** function: PCM data envelope analysis and manipulation - last mod: $Id: envelope.c,v 1.23.2.2 2000/11/04 06:21:43 xiphmont Exp $ + last mod: $Id: envelope.c,v 1.23.2.3 2000/11/04 06:43:49 xiphmont Exp $ Preecho calculation. @@ -79,18 +79,18 @@ void _ve_envelope_init(envelope_lookup *e,vorbis_info *vi){ int i; e->winlength=window; e->minenergy=fromdB(ci->preecho_minenergy); - e->iir=calloc(ch,sizeof(IIR_state)); - e->filtered=calloc(ch,sizeof(float *)); + e->iir=_ogg_calloc(ch,sizeof(IIR_state)); + e->filtered=_ogg_calloc(ch,sizeof(float *)); e->ch=ch; e->storage=128; for(i=0;i<ch;i++){ IIR_init(e->iir+i,cheb_highpass_stages,cheb_highpass_gain, cheb_highpass_A,cheb_highpass_B); - e->filtered[i]=calloc(e->storage,sizeof(float)); + e->filtered[i]=_ogg_calloc(e->storage,sizeof(float)); } drft_init(&e->drft,window); - e->window=malloc(e->winlength*sizeof(float)); + e->window=_ogg_malloc(e->winlength*sizeof(float)); /* We just use a straight sin(x) window for this */ for(i=0;i<e->winlength;i++) e->window[i]=sin((i+.5)/e->winlength*M_PI); @@ -166,7 +166,7 @@ long _ve_envelope_search(vorbis_dsp_state *v,long searchpoint){ if(v->pcm_storage>ve->storage){ ve->storage=v->pcm_storage; for(i=0;i<ve->ch;i++) - ve->filtered[i]=realloc(ve->filtered[i],ve->storage*sizeof(float)); + ve->filtered[i]=_ogg_realloc(ve->filtered[i],ve->storage*sizeof(float)); } /* catch up the highpass to match the pcm */ diff --git a/lib/floor0.c b/lib/floor0.c index e4eef463..553b8961 100644 --- a/lib/floor0.c +++ b/lib/floor0.c @@ -12,7 +12,7 @@ ******************************************************************** function: floor backend 0 implementation - last mod: $Id: floor0.c,v 1.25.2.2 2000/11/04 06:21:44 xiphmont Exp $ + last mod: $Id: floor0.c,v 1.25.2.3 2000/11/04 06:43:49 xiphmont Exp $ ********************************************************************/ @@ -72,7 +72,7 @@ static long _f0_fit(codebook *book, static vorbis_info_floor *floor0_copy_info (vorbis_info_floor *i){ vorbis_info_floor0 *info=(vorbis_info_floor0 *)i; - vorbis_info_floor0 *ret=malloc(sizeof(vorbis_info_floor0)); + vorbis_info_floor0 *ret=_ogg_malloc(sizeof(vorbis_info_floor0)); memcpy(ret,info,sizeof(vorbis_info_floor0)); return(ret); } @@ -112,7 +112,7 @@ static vorbis_info_floor *floor0_unpack (vorbis_info *vi,oggpack_buffer *opb){ codec_setup_info *ci=vi->codec_setup; int j; - vorbis_info_floor0 *info=malloc(sizeof(vorbis_info_floor0)); + vorbis_info_floor0 *info=_ogg_malloc(sizeof(vorbis_info_floor0)); info->order=oggpack_read(opb,8); info->rate=oggpack_read(opb,16); info->barkmap=oggpack_read(opb,16); @@ -151,7 +151,7 @@ static vorbis_look_floor *floor0_look (vorbis_dsp_state *vd,vorbis_info_mode *mi vorbis_info *vi=vd->vi; codec_setup_info *ci=vi->codec_setup; vorbis_info_floor0 *info=(vorbis_info_floor0 *)i; - vorbis_look_floor0 *look=calloc(1,sizeof(vorbis_look_floor0)); + vorbis_look_floor0 *look=_ogg_calloc(1,sizeof(vorbis_look_floor0)); look->m=info->order; look->n=ci->blocksizes[mi->blockflag]/2; look->ln=info->barkmap; @@ -171,7 +171,7 @@ static vorbis_look_floor *floor0_look (vorbis_dsp_state *vd,vorbis_info_mode *mi the encoder may do what it wishes in filling them. They're necessary in some mapping combinations to keep the scale spacing accurate */ - look->linearmap=malloc((look->n+1)*sizeof(int)); + look->linearmap=_ogg_malloc((look->n+1)*sizeof(int)); for(j=0;j<look->n;j++){ int val=floor( toBARK((info->rate/2.)/look->n*j) *scale); /* bark numbers represent band edges */ @@ -180,7 +180,7 @@ static vorbis_look_floor *floor0_look (vorbis_dsp_state *vd,vorbis_info_mode *mi } look->linearmap[j]=-1; - look->lsp_look=malloc(look->ln*sizeof(float)); + look->lsp_look=_ogg_malloc(look->ln*sizeof(float)); for(j=0;j<look->ln;j++) look->lsp_look[j]=2*cos(M_PI/look->ln*j); @@ -12,13 +12,14 @@ ******************************************************************** function: Direct Form I, II IIR filters, plus some specializations - last mod: $Id: iir.c,v 1.2.2.1 2000/11/04 06:21:44 xiphmont Exp $ + last mod: $Id: iir.c,v 1.2.2.2 2000/11/04 06:43:50 xiphmont Exp $ ********************************************************************/ /* LPC is actually a degenerate case of form I/II filters, but we need both */ +#include <ogg/ogg.h> #include <stdlib.h> #include <string.h> #include <math.h> @@ -28,10 +29,10 @@ void IIR_init(IIR_state *s,int stages,float gain, float *A, float *B){ memset(s,0,sizeof(IIR_state)); s->stages=stages; s->gain=gain; - s->coeff_A=malloc(stages*sizeof(float)); - s->coeff_B=malloc((stages+1)*sizeof(float)); - s->z_A=calloc(stages*2,sizeof(float)); - s->z_B=calloc(stages*2,sizeof(float)); + s->coeff_A=_ogg_malloc(stages*sizeof(float)); + s->coeff_B=_ogg_malloc((stages+1)*sizeof(float)); + s->z_A=_ogg_calloc(stages*2,sizeof(float)); + s->z_B=_ogg_calloc(stages*2,sizeof(float)); memcpy(s->coeff_A,A,stages*sizeof(float)); memcpy(s->coeff_B,B,(stages+1)*sizeof(float)); @@ -267,7 +268,7 @@ int main(){ /* run the pregenerated Chebyshev filter, then our own distillation through the generic and specialized code */ - float *work=malloc(128*sizeof(float)); + float *work=_ogg_malloc(128*sizeof(float)); IIR_state iir; int i; @@ -12,7 +12,7 @@ ******************************************************************** function: maintain the info structure, info <-> header packets - last mod: $Id: info.c,v 1.31.2.4 2000/11/04 06:21:44 xiphmont Exp $ + last mod: $Id: info.c,v 1.31.2.5 2000/11/04 06:43:50 xiphmont Exp $ ********************************************************************/ @@ -60,9 +60,9 @@ void vorbis_comment_init(vorbis_comment *vc){ } void vorbis_comment_add(vorbis_comment *vc,char *comment){ - vc->user_comments=realloc(vc->user_comments, + vc->user_comments=_ogg_realloc(vc->user_comments, (vc->comments+2)*sizeof(char *)); - vc->comment_lengths=realloc(vc->comment_lengths, + vc->comment_lengths=_ogg_realloc(vc->comment_lengths, (vc->comments+2)*sizeof(int)); vc->user_comments[vc->comments]=strdup(comment); vc->comment_lengths[vc->comments]=strlen(comment); @@ -141,7 +141,7 @@ void vorbis_comment_clear(vorbis_comment *vc){ /* used by synthesis, which has a full, alloced vi */ void vorbis_info_init(vorbis_info *vi){ memset(vi,0,sizeof(vorbis_info)); - vi->codec_setup=calloc(1,sizeof(codec_setup_info)); + vi->codec_setup=_ogg_calloc(1,sizeof(codec_setup_info)); } void vorbis_info_clear(vorbis_info *vi){ @@ -217,18 +217,18 @@ static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){ int i; int vendorlen=oggpack_read(opb,32); if(vendorlen<0)goto err_out; - vc->vendor=calloc(vendorlen+1,1); + vc->vendor=_ogg_calloc(vendorlen+1,1); _v_readstring(opb,vc->vendor,vendorlen); vc->comments=oggpack_read(opb,32); if(vc->comments<0)goto err_out; - vc->user_comments=calloc(vc->comments+1,sizeof(char **)); - vc->comment_lengths=calloc(vc->comments+1, sizeof(int)); + vc->user_comments=_ogg_calloc(vc->comments+1,sizeof(char **)); + vc->comment_lengths=_ogg_calloc(vc->comments+1, sizeof(int)); for(i=0;i<vc->comments;i++){ int len=oggpack_read(opb,32); if(len<0)goto err_out; vc->comment_lengths[i]=len; - vc->user_comments[i]=calloc(len+1,1); + vc->user_comments[i]=_ogg_calloc(len+1,1); _v_readstring(opb,vc->user_comments[i],len); } if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */ @@ -248,16 +248,16 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){ /* codebooks */ ci->books=oggpack_read(opb,8)+1; - /*ci->book_param=calloc(ci->books,sizeof(static_codebook *));*/ + /*ci->book_param=_ogg_calloc(ci->books,sizeof(static_codebook *));*/ for(i=0;i<ci->books;i++){ - ci->book_param[i]=calloc(1,sizeof(static_codebook)); + ci->book_param[i]=_ogg_calloc(1,sizeof(static_codebook)); if(vorbis_staticbook_unpack(opb,ci->book_param[i]))goto err_out; } /* time backend settings */ ci->times=oggpack_read(opb,6)+1; - /*ci->time_type=malloc(ci->times*sizeof(int));*/ - /*ci->time_param=calloc(ci->times,sizeof(void *));*/ + /*ci->time_type=_ogg_malloc(ci->times*sizeof(int));*/ + /*ci->time_param=_ogg_calloc(ci->times,sizeof(void *));*/ for(i=0;i<ci->times;i++){ ci->time_type[i]=oggpack_read(opb,16); if(ci->time_type[i]<0 || ci->time_type[i]>=VI_TIMEB)goto err_out; @@ -267,8 +267,8 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){ /* floor backend settings */ ci->floors=oggpack_read(opb,6)+1; - /*ci->floor_type=malloc(ci->floors*sizeof(int));*/ - /*ci->floor_param=calloc(ci->floors,sizeof(void *));*/ + /*ci->floor_type=_ogg_malloc(ci->floors*sizeof(int));*/ + /*ci->floor_param=_ogg_calloc(ci->floors,sizeof(void *));*/ for(i=0;i<ci->floors;i++){ ci->floor_type[i]=oggpack_read(opb,16); if(ci->floor_type[i]<0 || ci->floor_type[i]>=VI_FLOORB)goto err_out; @@ -278,8 +278,8 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){ /* residue backend settings */ ci->residues=oggpack_read(opb,6)+1; - /*ci->residue_type=malloc(ci->residues*sizeof(int));*/ - /*ci->residue_param=calloc(ci->residues,sizeof(void *));*/ + /*ci->residue_type=_ogg_malloc(ci->residues*sizeof(int));*/ + /*ci->residue_param=_ogg_calloc(ci->residues,sizeof(void *));*/ for(i=0;i<ci->residues;i++){ ci->residue_type[i]=oggpack_read(opb,16); if(ci->residue_type[i]<0 || ci->residue_type[i]>=VI_RESB)goto err_out; @@ -289,8 +289,8 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){ /* map backend settings */ ci->maps=oggpack_read(opb,6)+1; - /*ci->map_type=malloc(ci->maps*sizeof(int));*/ - /*ci->map_param=calloc(ci->maps,sizeof(void *));*/ + /*ci->map_type=_ogg_malloc(ci->maps*sizeof(int));*/ + /*ci->map_param=_ogg_calloc(ci->maps,sizeof(void *));*/ for(i=0;i<ci->maps;i++){ ci->map_type[i]=oggpack_read(opb,16); if(ci->map_type[i]<0 || ci->map_type[i]>=VI_MAPB)goto err_out; @@ -300,9 +300,9 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){ /* mode settings */ ci->modes=oggpack_read(opb,6)+1; - /*vi->mode_param=calloc(vi->modes,sizeof(void *));*/ + /*vi->mode_param=_ogg_calloc(vi->modes,sizeof(void *));*/ for(i=0;i<ci->modes;i++){ - ci->mode_param[i]=calloc(1,sizeof(vorbis_info_mode)); + ci->mode_param[i]=_ogg_calloc(1,sizeof(vorbis_info_mode)); ci->mode_param[i]->blockflag=oggpack_read(opb,1); ci->mode_param[i]->windowtype=oggpack_read(opb,16); ci->mode_param[i]->transformtype=oggpack_read(opb,16); @@ -516,7 +516,7 @@ int vorbis_analysis_headerout(vorbis_dsp_state *v, /* build the packet */ if(b->header)free(b->header); - b->header=malloc(oggpack_bytes(&opb)); + b->header=_ogg_malloc(oggpack_bytes(&opb)); memcpy(b->header,opb.buffer,oggpack_bytes(&opb)); op->packet=b->header; op->bytes=oggpack_bytes(&opb); @@ -530,7 +530,7 @@ int vorbis_analysis_headerout(vorbis_dsp_state *v, if(_vorbis_pack_comment(&opb,vc))goto err_out; if(b->header1)free(b->header1); - b->header1=malloc(oggpack_bytes(&opb)); + b->header1=_ogg_malloc(oggpack_bytes(&opb)); memcpy(b->header1,opb.buffer,oggpack_bytes(&opb)); op_comm->packet=b->header1; op_comm->bytes=oggpack_bytes(&opb); @@ -544,7 +544,7 @@ int vorbis_analysis_headerout(vorbis_dsp_state *v, if(_vorbis_pack_books(&opb,vi))goto err_out; if(b->header2)free(b->header2); - b->header2=malloc(oggpack_bytes(&opb)); + b->header2=_ogg_malloc(oggpack_bytes(&opb)); memcpy(b->header2,opb.buffer,oggpack_bytes(&opb)); op_code->packet=b->header2; op_code->bytes=oggpack_bytes(&opb); diff --git a/lib/mapping0.c b/lib/mapping0.c index 5860f2aa..c007ee63 100644 --- a/lib/mapping0.c +++ b/lib/mapping0.c @@ -12,7 +12,7 @@ ******************************************************************** function: channel mapping 0 implementation - last mod: $Id: mapping0.c,v 1.16.2.2 2000/11/04 06:21:44 xiphmont Exp $ + last mod: $Id: mapping0.c,v 1.16.2.3 2000/11/04 06:43:50 xiphmont Exp $ ********************************************************************/ @@ -58,7 +58,7 @@ typedef struct { static vorbis_info_mapping *mapping0_copy_info(vorbis_info_mapping *vm){ vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)vm; - vorbis_info_mapping0 *ret=malloc(sizeof(vorbis_info_mapping0)); + vorbis_info_mapping0 *ret=_ogg_malloc(sizeof(vorbis_info_mapping0)); memcpy(ret,info,sizeof(vorbis_info_mapping0)); return(ret); } @@ -105,19 +105,19 @@ static vorbis_look_mapping *mapping0_look(vorbis_dsp_state *vd,vorbis_info_mode int i; vorbis_info *vi=vd->vi; codec_setup_info *ci=vi->codec_setup; - vorbis_look_mapping0 *look=calloc(1,sizeof(vorbis_look_mapping0)); + vorbis_look_mapping0 *look=_ogg_calloc(1,sizeof(vorbis_look_mapping0)); vorbis_info_mapping0 *info=look->map=(vorbis_info_mapping0 *)m; look->mode=vm; - look->time_look=calloc(info->submaps,sizeof(vorbis_look_time *)); - look->floor_look=calloc(info->submaps,sizeof(vorbis_look_floor *)); + look->time_look=_ogg_calloc(info->submaps,sizeof(vorbis_look_time *)); + look->floor_look=_ogg_calloc(info->submaps,sizeof(vorbis_look_floor *)); - look->residue_look=calloc(info->submaps,sizeof(vorbis_look_residue *)); - if(ci->psys)look->psy_look=calloc(info->submaps,sizeof(vorbis_look_psy)); + look->residue_look=_ogg_calloc(info->submaps,sizeof(vorbis_look_residue *)); + if(ci->psys)look->psy_look=_ogg_calloc(info->submaps,sizeof(vorbis_look_psy)); - look->time_func=calloc(info->submaps,sizeof(vorbis_func_time *)); - look->floor_func=calloc(info->submaps,sizeof(vorbis_func_floor *)); - look->residue_func=calloc(info->submaps,sizeof(vorbis_func_residue *)); + look->time_func=_ogg_calloc(info->submaps,sizeof(vorbis_func_time *)); + look->floor_func=_ogg_calloc(info->submaps,sizeof(vorbis_func_floor *)); + look->residue_func=_ogg_calloc(info->submaps,sizeof(vorbis_func_residue *)); for(i=0;i<info->submaps;i++){ int timenum=info->timesubmap[i]; @@ -143,9 +143,9 @@ static vorbis_look_mapping *mapping0_look(vorbis_dsp_state *vd,vorbis_info_mode look->ch=vi->channels; if(ci->psys){ - look->decay=calloc(vi->channels,sizeof(float *)); + look->decay=_ogg_calloc(vi->channels,sizeof(float *)); for(i=0;i<vi->channels;i++) - look->decay[i]=calloc(ci->blocksizes[vm->blockflag]/2,sizeof(float)); + look->decay[i]=_ogg_calloc(ci->blocksizes[vm->blockflag]/2,sizeof(float)); } return(look); @@ -171,7 +171,7 @@ static void mapping0_pack(vorbis_info *vi,vorbis_info_mapping *vm,oggpack_buffer /* also responsible for range checking */ static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb){ int i; - vorbis_info_mapping0 *info=calloc(1,sizeof(vorbis_info_mapping0)); + vorbis_info_mapping0 *info=_ogg_calloc(1,sizeof(vorbis_info_mapping0)); codec_setup_info *ci=vi->codec_setup; memset(info,0,sizeof(vorbis_info_mapping0)); @@ -13,7 +13,7 @@ function: normalized modified discrete cosine transform power of two length transform only [16 <= n ] - last mod: $Id: mdct.c,v 1.17.2.4 2000/11/04 06:21:45 xiphmont Exp $ + last mod: $Id: mdct.c,v 1.17.2.5 2000/11/04 06:43:50 xiphmont Exp $ Algorithm adapted from _The use of multirate filter banks for coding of high quality digital audio_, by T. Sporer, K. Brandenburg and @@ -45,8 +45,8 @@ some window function algebra. */ void mdct_init(mdct_lookup *lookup,int n){ - int *bitrev=malloc(sizeof(int)*(n/4)); - float *trig=malloc(sizeof(float)*(n+n/4)); + int *bitrev=_ogg_malloc(sizeof(int)*(n/4)); + float *trig=_ogg_malloc(sizeof(float)*(n+n/4)); float *AE=trig; float *AO=trig+1; float *BE=AE+n/2; @@ -42,11 +42,11 @@ static void *_insert(void *ptr,char *file,long line){ if(pinsert>=palloced){ palloced+=64; if(pointers){ - pointers=(void **)realloc(pointers,sizeof(void **)*palloced); - insertlist=(long *)realloc(insertlist,sizeof(long *)*palloced); + pointers=(void **)_ogg_realloc(pointers,sizeof(void **)*palloced); + insertlist=(long *)_ogg_realloc(insertlist,sizeof(long *)*palloced); }else{ - pointers=(void **)malloc(sizeof(void **)*palloced); - insertlist=(long *)malloc(sizeof(long *)*palloced); + pointers=(void **)_ogg_malloc(sizeof(void **)*palloced); + insertlist=(long *)_ogg_malloc(sizeof(long *)*palloced); } } @@ -84,14 +84,14 @@ void _VDBG_dump(void){ pthread_mutex_unlock(&memlock); } -extern void *_VDBG_malloc(void *ptr,long bytes,char *file,long line){ +extern void *_VDBG__ogg_malloc(void *ptr,long bytes,char *file,long line){ bytes+=HEAD_ALIGN; if(ptr){ ptr-=HEAD_ALIGN; _ripremove(ptr); - ptr=realloc(ptr,bytes); + ptr=_ogg_realloc(ptr,bytes); }else{ - ptr=malloc(bytes); + ptr=_ogg_malloc(bytes); memset(ptr,0,bytes); } return _insert(ptr,file,line); @@ -12,7 +12,7 @@ ******************************************************************** function: miscellaneous prototypes - last mod: $Id: misc.h,v 1.5.2.1 2000/11/04 06:21:45 xiphmont Exp $ + last mod: $Id: misc.h,v 1.5.2.2 2000/11/04 06:43:50 xiphmont Exp $ ********************************************************************/ @@ -25,18 +25,18 @@ extern void _vorbis_block_ripcord(vorbis_block *vb); extern void _analysis_output(char *base,int i,float *v,int n,int bark,int dB); #ifdef DEBUG_LEAKS -extern void *_VDBG_malloc(void *ptr,long bytes,char *file,long line); +extern void *_VDBG__ogg_malloc(void *ptr,long bytes,char *file,long line); extern void _VDBG_free(void *ptr,char *file,long line); #ifndef MISC_C -#undef malloc -#undef calloc -#undef realloc +#undef _ogg_malloc +#undef _ogg_calloc +#undef _ogg_realloc #undef free -#define malloc(x) _VDBG_malloc(NULL,(x),__FILE__,__LINE__) -#define calloc(x,y) _VDBG_malloc(NULL,(x)*(y),__FILE__,__LINE__) -#define realloc(x,y) _VDBG_malloc((x),(y),__FILE__,__LINE__) +#define _ogg_malloc(x) _VDBG__ogg_malloc(NULL,(x),__FILE__,__LINE__) +#define _ogg_calloc(x,y) _VDBG__ogg_malloc(NULL,(x)*(y),__FILE__,__LINE__) +#define _ogg_realloc(x,y) _VDBG__ogg_malloc((x),(y),__FILE__,__LINE__) #define free(x) _VDBG_free((x),__FILE__,__LINE__) #endif #endif @@ -14,7 +14,7 @@ ******************************************************************** function: #ifdef jail to whip a few platforms into the UNIX ideal. - last mod: $Id: os.h,v 1.10.2.3 2000/11/04 06:21:45 xiphmont Exp $ + last mod: $Id: os.h,v 1.10.2.4 2000/11/04 06:43:50 xiphmont Exp $ ********************************************************************/ @@ -30,7 +30,7 @@ #ifndef __GNUC__ #ifdef _WIN32 -# include <malloc.h> +# include <_ogg_malloc.h> # define rint(x) (floor((x)+0.5)) #endif #endif @@ -12,7 +12,7 @@ ******************************************************************** function: psychoacoustics not including preecho - last mod: $Id: psy.c,v 1.29.2.2 2000/11/04 06:21:45 xiphmont Exp $ + last mod: $Id: psy.c,v 1.29.2.3 2000/11/04 06:43:50 xiphmont Exp $ ********************************************************************/ @@ -42,7 +42,7 @@ void _vi_psy_free(vorbis_info_psy *i){ } vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i){ - vorbis_info_psy *ret=malloc(sizeof(vorbis_info_psy)); + vorbis_info_psy *ret=_ogg_malloc(sizeof(vorbis_info_psy)); memcpy(ret,i,sizeof(vorbis_info_psy)); return(ret); } @@ -178,9 +178,9 @@ static void setup_curve(float **c, void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,int n,long rate){ long i,j; memset(p,0,sizeof(vorbis_look_psy)); - p->ath=malloc(n*sizeof(float)); - p->octave=malloc(n*sizeof(int)); - p->bark=malloc(n*sizeof(float)); + p->ath=_ogg_malloc(n*sizeof(float)); + p->octave=_ogg_malloc(n*sizeof(int)); + p->bark=_ogg_malloc(n*sizeof(float)); p->vi=vi; p->n=n; @@ -199,18 +199,18 @@ void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,int n,long rate){ p->octave[i]=oc; } - p->tonecurves=malloc(P_BANDS*sizeof(float **)); - p->noiseatt=malloc(P_BANDS*sizeof(float **)); - p->peakatt=malloc(P_BANDS*sizeof(float *)); + p->tonecurves=_ogg_malloc(P_BANDS*sizeof(float **)); + p->noiseatt=_ogg_malloc(P_BANDS*sizeof(float **)); + p->peakatt=_ogg_malloc(P_BANDS*sizeof(float *)); for(i=0;i<P_BANDS;i++){ - p->tonecurves[i]=malloc(P_LEVELS*sizeof(float *)); - p->noiseatt[i]=malloc(P_LEVELS*sizeof(float)); - p->peakatt[i]=malloc(P_LEVELS*sizeof(float)); + p->tonecurves[i]=_ogg_malloc(P_LEVELS*sizeof(float *)); + p->noiseatt[i]=_ogg_malloc(P_LEVELS*sizeof(float)); + p->peakatt[i]=_ogg_malloc(P_LEVELS*sizeof(float)); } for(i=0;i<P_BANDS;i++) for(j=0;j<P_LEVELS;j++){ - p->tonecurves[i][j]=malloc(EHMER_MAX*sizeof(float)); + p->tonecurves[i][j]=_ogg_malloc(EHMER_MAX*sizeof(float)); } /* OK, yeah, this was a silly way to do it */ diff --git a/lib/psytune.c b/lib/psytune.c index f9946eef..dd87c0c8 100644 --- a/lib/psytune.c +++ b/lib/psytune.c @@ -13,7 +13,7 @@ function: simple utility that runs audio through the psychoacoustics without encoding - last mod: $Id: psytune.c,v 1.7.2.1 2000/11/04 06:21:45 xiphmont Exp $ + last mod: $Id: psytune.c,v 1.7.2.2 2000/11/04 06:43:50 xiphmont Exp $ ********************************************************************/ @@ -163,7 +163,7 @@ static void floorinit(vorbis_look_floor0 *look,int n,int m,int ln){ scale=look->ln/toBARK(22050.); - look->linearmap=malloc(look->n*sizeof(int)); + look->linearmap=_ogg_malloc(look->n*sizeof(int)); for(j=0;j<look->n;j++){ int val=floor( toBARK(22050./n*j) *scale); if(val>look->ln)val=look->ln; @@ -230,15 +230,15 @@ int main(int argc,char *argv[]){ argv++; } - pcm[0]=malloc(framesize*sizeof(float)); - pcm[1]=malloc(framesize*sizeof(float)); - out[0]=calloc(framesize/2,sizeof(float)); - out[1]=calloc(framesize/2,sizeof(float)); - decay[0]=calloc(framesize/2,sizeof(float)); - decay[1]=calloc(framesize/2,sizeof(float)); - floor=malloc(framesize*sizeof(float)); - lpc=malloc(order*sizeof(float)); - buffer=malloc(framesize*4); + pcm[0]=_ogg_malloc(framesize*sizeof(float)); + pcm[1]=_ogg_malloc(framesize*sizeof(float)); + out[0]=_ogg_calloc(framesize/2,sizeof(float)); + out[1]=_ogg_calloc(framesize/2,sizeof(float)); + decay[0]=_ogg_calloc(framesize/2,sizeof(float)); + decay[1]=_ogg_calloc(framesize/2,sizeof(float)); + floor=_ogg_malloc(framesize*sizeof(float)); + lpc=_ogg_malloc(order*sizeof(float)); + buffer=_ogg_malloc(framesize*4); buffer2=buffer+framesize*2; window=_vorbis_window(0,framesize,framesize/2,framesize/2); mdct_init(&m_look,framesize); @@ -12,7 +12,7 @@ ******************************************************************** function: residue backend 0 implementation - last mod: $Id: res0.c,v 1.18.2.2 2000/11/04 06:21:45 xiphmont Exp $ + last mod: $Id: res0.c,v 1.18.2.3 2000/11/04 06:43:50 xiphmont Exp $ ********************************************************************/ @@ -47,7 +47,7 @@ typedef struct { vorbis_info_residue *res0_copy_info(vorbis_info_residue *vr){ vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr; - vorbis_info_residue0 *ret=malloc(sizeof(vorbis_info_residue0)); + vorbis_info_residue0 *ret=_ogg_malloc(sizeof(vorbis_info_residue0)); memcpy(ret,info,sizeof(vorbis_info_residue0)); return(ret); } @@ -96,7 +96,7 @@ void res0_pack(vorbis_info_residue *vr,oggpack_buffer *opb){ /* vorbis_info is for range checking */ vorbis_info_residue *res0_unpack(vorbis_info *vi,oggpack_buffer *opb){ int j,acc=0; - vorbis_info_residue0 *info=calloc(1,sizeof(vorbis_info_residue0)); + vorbis_info_residue0 *info=_ogg_calloc(1,sizeof(vorbis_info_residue0)); codec_setup_info *ci=vi->codec_setup; info->begin=oggpack_read(opb,24); @@ -127,7 +127,7 @@ vorbis_info_residue *res0_unpack(vorbis_info *vi,oggpack_buffer *opb){ vorbis_look_residue *res0_look (vorbis_dsp_state *vd,vorbis_info_mode *vm, vorbis_info_residue *vr){ vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr; - vorbis_look_residue0 *look=calloc(1,sizeof(vorbis_look_residue0)); + vorbis_look_residue0 *look=_ogg_calloc(1,sizeof(vorbis_look_residue0)); backend_lookup_state *be=vd->backend_state; int j,k,acc=0; @@ -139,23 +139,23 @@ vorbis_look_residue *res0_look (vorbis_dsp_state *vd,vorbis_info_mode *vm, look->phrasebook=be->fullbooks+info->groupbook; dim=look->phrasebook->dim; - look->partbooks=calloc(look->parts,sizeof(codebook **)); + look->partbooks=_ogg_calloc(look->parts,sizeof(codebook **)); for(j=0;j<look->parts;j++){ int stages=info->secondstages[j]; if(stages){ - look->partbooks[j]=malloc(stages*sizeof(codebook *)); + look->partbooks[j]=_ogg_malloc(stages*sizeof(codebook *)); for(k=0;k<stages;k++) look->partbooks[j][k]=be->fullbooks+info->booklist[acc++]; } } look->partvals=rint(pow(look->parts,dim)); - look->decodemap=malloc(look->partvals*sizeof(int *)); + look->decodemap=_ogg_malloc(look->partvals*sizeof(int *)); for(j=0;j<look->partvals;j++){ long val=j; long mult=look->partvals/look->parts; - look->decodemap[j]=malloc(dim*sizeof(int)); + look->decodemap[j]=_ogg_malloc(dim*sizeof(int)); for(k=0;k<dim;k++){ long deco=val/mult; val-=deco*mult; diff --git a/lib/sharedbook.c b/lib/sharedbook.c index 8b5752c2..d155a161 100644 --- a/lib/sharedbook.c +++ b/lib/sharedbook.c @@ -12,7 +12,7 @@ ******************************************************************** function: basic shared codebook operations - last mod: $Id: sharedbook.c,v 1.9.2.2 2000/11/04 06:21:45 xiphmont Exp $ + last mod: $Id: sharedbook.c,v 1.9.2.3 2000/11/04 06:43:50 xiphmont Exp $ ********************************************************************/ @@ -73,7 +73,7 @@ float _float32_unpack(long val){ long *_make_words(long *l,long n){ long i,j; long marker[33]; - long *r=malloc(n*sizeof(long)); + long *r=_ogg_malloc(n*sizeof(long)); memset(marker,0,sizeof(marker)); for(i=0;i<n;i++){ @@ -142,9 +142,9 @@ long *_make_words(long *l,long n){ decode_aux *_make_decode_tree(codebook *c){ const static_codebook *s=c->c; long top=0,i,j,n; - decode_aux *t=malloc(sizeof(decode_aux)); - long *ptr0=t->ptr0=calloc(c->entries*2,sizeof(long)); - long *ptr1=t->ptr1=calloc(c->entries*2,sizeof(long)); + decode_aux *t=_ogg_malloc(sizeof(decode_aux)); + long *ptr0=t->ptr0=_ogg_calloc(c->entries*2,sizeof(long)); + long *ptr1=t->ptr1=_ogg_calloc(c->entries*2,sizeof(long)); long *codelist=_make_words(s->lengthlist,s->entries); if(codelist==NULL)return(NULL); @@ -176,8 +176,8 @@ decode_aux *_make_decode_tree(codebook *c){ t->tabn = _ilog(c->entries)-4; /* this is magic */ if(t->tabn<5)t->tabn=5; n = 1<<t->tabn; - t->tab = malloc(n*sizeof(long)); - t->tabl = malloc(n*sizeof(int)); + t->tab = _ogg_malloc(n*sizeof(long)); + t->tabl = _ogg_malloc(n*sizeof(int)); for (i = 0; i < n; i++) { long p = 0; for (j = 0; j < t->tabn && (p > 0 || j == 0); j++) { @@ -236,7 +236,7 @@ float *_book_unquantize(const static_codebook *b){ int quantvals; float mindel=_float32_unpack(b->q_min); float delta=_float32_unpack(b->q_delta); - float *r=calloc(b->entries*b->dim,sizeof(float)); + float *r=_ogg_calloc(b->entries*b->dim,sizeof(float)); /* maptype 1 and 2 both use a quantized value vector, but different sizes */ diff --git a/lib/smallft.c b/lib/smallft.c index d003f538..b33775d3 100644 --- a/lib/smallft.c +++ b/lib/smallft.c @@ -12,7 +12,7 @@ ******************************************************************** function: *unnormalized* fft transform - last mod: $Id: smallft.c,v 1.9.2.1 2000/11/04 06:21:46 xiphmont Exp $ + last mod: $Id: smallft.c,v 1.9.2.2 2000/11/04 06:43:51 xiphmont Exp $ ********************************************************************/ @@ -1241,8 +1241,8 @@ void drft_backward(drft_lookup *l,float *data){ void drft_init(drft_lookup *l,int n){ l->n=n; - l->trigcache=calloc(3*n,sizeof(float)); - l->splitcache=calloc(32,sizeof(int)); + l->trigcache=_ogg_calloc(3*n,sizeof(float)); + l->splitcache=_ogg_calloc(32,sizeof(int)); fdrffti(n, l->trigcache, l->splitcache); } diff --git a/lib/vorbisenc.c b/lib/vorbisenc.c index 5afac064..cf845d2e 100644 --- a/lib/vorbisenc.c +++ b/lib/vorbisenc.c @@ -12,7 +12,7 @@ ******************************************************************** function: simple programmatic interface for encoder mode setup - last mod: $Id: vorbisenc.c,v 1.1.2.2 2000/11/04 06:21:46 xiphmont Exp $ + last mod: $Id: vorbisenc.c,v 1.1.2.3 2000/11/04 06:43:51 xiphmont Exp $ ********************************************************************/ @@ -70,7 +70,7 @@ static void codec_setup_partialcopy(codec_setup_info *ci, /* mode settings */ for(i=0;i<ci->modes;i++){ - ci->mode_param[i]=calloc(1,sizeof(vorbis_info_mode)); + ci->mode_param[i]=_ogg_calloc(1,sizeof(vorbis_info_mode)); ci->mode_param[i]->blockflag=cs->mode_param[i]->blockflag; ci->mode_param[i]->windowtype=cs->mode_param[i]->windowtype; ci->mode_param[i]->transformtype=cs->mode_param[i]->transformtype; @@ -140,7 +140,7 @@ int vorbis_encode_init(vorbis_info *vi, ((vorbis_info_floor0 *)(ci->floor_param[i]))->rate=rate; /* adjust for channels; all our mappings use submap zero now */ - /* yeah, OK, calloc did this for us. But it's a reminder/placeholder */ + /* yeah, OK, _ogg_calloc did this for us. But it's a reminder/placeholder */ for(i=0;i<ci->maps;i++) for(j=0;j<channels;j++) ((vorbis_info_mapping0 *)ci->map_param[i])->chmuxlist[j]=0; diff --git a/lib/vorbisfile.c b/lib/vorbisfile.c index ce6e3924..1a1af709 100644 --- a/lib/vorbisfile.c +++ b/lib/vorbisfile.c @@ -12,7 +12,7 @@ ******************************************************************** function: stdio-based convenience library for opening/seeking/decoding - last mod: $Id: vorbisfile.c,v 1.30.2.4 2000/11/04 06:21:46 xiphmont Exp $ + last mod: $Id: vorbisfile.c,v 1.30.2.5 2000/11/04 06:43:51 xiphmont Exp $ ********************************************************************/ @@ -194,7 +194,7 @@ static int _bisect_forward_serialno(OggVorbis_File *vf, if(searched>=end || ret<0){ vf->links=m+1; - vf->offsets=malloc((m+2)*sizeof(ogg_int64_t)); + vf->offsets=_ogg_malloc((m+2)*sizeof(ogg_int64_t)); vf->offsets[m+1]=searched; }else{ ret=_bisect_forward_serialno(vf,next,vf->offset, @@ -275,11 +275,11 @@ static void _prefetch_all_headers(OggVorbis_File *vf,vorbis_info *first_i, ogg_page og; int i,ret; - vf->vi=calloc(vf->links,sizeof(vorbis_info)); - vf->vc=calloc(vf->links,sizeof(vorbis_info)); - vf->dataoffsets=malloc(vf->links*sizeof(ogg_int64_t)); - vf->pcmlengths=malloc(vf->links*sizeof(ogg_int64_t)); - vf->serialnos=malloc(vf->links*sizeof(long)); + vf->vi=_ogg_calloc(vf->links,sizeof(vorbis_info)); + vf->vc=_ogg_calloc(vf->links,sizeof(vorbis_info)); + vf->dataoffsets=_ogg_malloc(vf->links*sizeof(ogg_int64_t)); + vf->pcmlengths=_ogg_malloc(vf->links*sizeof(ogg_int64_t)); + vf->serialnos=_ogg_malloc(vf->links*sizeof(long)); for(i=0;i<vf->links;i++){ if(first_i && first_c && i==0){ @@ -393,8 +393,8 @@ static int _open_nonseekable(OggVorbis_File *vf){ int ret; /* we cannot seek. Set up a 'single' (current) logical bitstream entry */ vf->links=1; - vf->vi=calloc(vf->links,sizeof(vorbis_info)); - vf->vc=calloc(vf->links,sizeof(vorbis_info)); + vf->vi=_ogg_calloc(vf->links,sizeof(vorbis_info)); + vf->vc=_ogg_calloc(vf->links,sizeof(vorbis_info)); /* Try to fetch the headers, maintaining all the storage */ if((ret=_fetch_headers(vf,vf->vi,vf->vc,&vf->current_serialno,NULL))<0) diff --git a/lib/window.c b/lib/window.c index 79014cd6..26bb9be1 100644 --- a/lib/window.c +++ b/lib/window.c @@ -12,7 +12,7 @@ ******************************************************************** function: window functions - last mod: $Id: window.c,v 1.8.2.1 2000/11/04 06:21:46 xiphmont Exp $ + last mod: $Id: window.c,v 1.8.2.2 2000/11/04 06:43:51 xiphmont Exp $ ********************************************************************/ @@ -22,7 +22,7 @@ #include "misc.h" float *_vorbis_window(int type, int window,int left,int right){ - float *ret=calloc(window,sizeof(float)); + float *ret=_ogg_calloc(window,sizeof(float)); switch(type){ case 0: diff --git a/mac/compat/strdup.c b/mac/compat/strdup.c new file mode 100644 index 00000000..536f746f --- /dev/null +++ b/mac/compat/strdup.c @@ -0,0 +1 @@ +#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
char *strdup(const char *inStr)
{
char *outStr = NULL;
if (inStr == NULL) {
return NULL;
}
outStr = _ogg_malloc(strlen(inStr) + 1);
if (outStr != NULL) {
strcpy(outStr, inStr);
}
return outStr;
}
\ No newline at end of file diff --git a/vq/bookutil.c b/vq/bookutil.c index 913b6001..9a784934 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.17.2.4 2000/11/04 06:22:09 xiphmont Exp $ + last mod: $Id: bookutil.c,v 1.17.2.5 2000/11/04 06:43:55 xiphmont Exp $ ********************************************************************/ @@ -40,10 +40,10 @@ char *get_line(FILE *in){ if(sofar+1>=lbufsize){ if(!lbufsize){ lbufsize=1024; - linebuffer=malloc(lbufsize); + linebuffer=_ogg_malloc(lbufsize); }else{ lbufsize*=2; - linebuffer=realloc(linebuffer,lbufsize); + linebuffer=_ogg_realloc(linebuffer,lbufsize); } } { @@ -178,8 +178,8 @@ char *find_seek_to(FILE *in,char *s){ header-ness will break this routine */ codebook *codebook_load(char *filename){ - codebook *b=calloc(1,sizeof(codebook)); - static_codebook *c=(static_codebook *)(b->c=calloc(1,sizeof(static_codebook))); + codebook *b=_ogg_calloc(1,sizeof(codebook)); + static_codebook *c=(static_codebook *)(b->c=_ogg_calloc(1,sizeof(static_codebook))); encode_aux_nearestmatch *a=NULL; encode_aux_threshmatch *t=NULL; encode_aux_pigeonhole *p=NULL; @@ -215,7 +215,7 @@ codebook *codebook_load(char *filename){ /* find the auxiliary encode struct[s] (if any) */ if(find_seek_to(in,"static encode_aux_nearestmatch _vq_aux")){ /* how big? */ - c->nearest_tree=a=calloc(1,sizeof(encode_aux_nearestmatch)); + c->nearest_tree=a=_ogg_calloc(1,sizeof(encode_aux_nearestmatch)); line=get_line(in); line=get_line(in); line=get_line(in); @@ -229,7 +229,7 @@ codebook *codebook_load(char *filename){ /* load ptr0 */ find_seek_to(in,"static long _vq_ptr0"); reset_next_value(); - a->ptr0=malloc(sizeof(long)*a->aux); + a->ptr0=_ogg_malloc(sizeof(long)*a->aux); for(i=0;i<a->aux;i++) if(get_next_ivalue(in,a->ptr0+i)){ fprintf(stderr,"out of data while reading codebook %s\n",filename); @@ -239,7 +239,7 @@ codebook *codebook_load(char *filename){ /* load ptr1 */ find_seek_to(in,"static long _vq_ptr1"); reset_next_value(); - a->ptr1=malloc(sizeof(long)*a->aux); + a->ptr1=_ogg_malloc(sizeof(long)*a->aux); for(i=0;i<a->aux;i++) if(get_next_ivalue(in,a->ptr1+i)){ fprintf(stderr,"out of data while reading codebook %s\n",filename); @@ -250,7 +250,7 @@ codebook *codebook_load(char *filename){ /* load p */ find_seek_to(in,"static long _vq_p_"); reset_next_value(); - a->p=malloc(sizeof(long)*a->aux); + a->p=_ogg_malloc(sizeof(long)*a->aux); for(i=0;i<a->aux;i++) if(get_next_ivalue(in,a->p+i)){ fprintf(stderr,"out of data while reading codebook %s\n",filename); @@ -260,7 +260,7 @@ codebook *codebook_load(char *filename){ /* load q */ find_seek_to(in,"static long _vq_q_"); reset_next_value(); - a->q=malloc(sizeof(long)*a->aux); + a->q=_ogg_malloc(sizeof(long)*a->aux); for(i=0;i<a->aux;i++) if(get_next_ivalue(in,a->q+i)){ fprintf(stderr,"out of data while reading codebook %s\n",filename); @@ -270,7 +270,7 @@ codebook *codebook_load(char *filename){ if(find_seek_to(in,"static encode_aux_threshmatch _vq_aux")){ /* how big? */ - c->thresh_tree=t=calloc(1,sizeof(encode_aux_threshmatch)); + c->thresh_tree=t=_ogg_calloc(1,sizeof(encode_aux_threshmatch)); line=get_line(in); line=get_line(in); line=get_line(in); @@ -286,7 +286,7 @@ codebook *codebook_load(char *filename){ /* load quantthresh */ find_seek_to(in,"static float _vq_quantthresh_"); reset_next_value(); - t->quantthresh=malloc(sizeof(float)*t->threshvals); + t->quantthresh=_ogg_malloc(sizeof(float)*t->threshvals); for(i=0;i<t->threshvals-1;i++) if(get_next_value(in,t->quantthresh+i)){ fprintf(stderr,"out of data 1 while reading codebook %s\n",filename); @@ -295,7 +295,7 @@ codebook *codebook_load(char *filename){ /* load quantmap */ find_seek_to(in,"static long _vq_quantmap_"); reset_next_value(); - t->quantmap=malloc(sizeof(long)*t->threshvals); + t->quantmap=_ogg_malloc(sizeof(long)*t->threshvals); for(i=0;i<t->threshvals;i++) if(get_next_ivalue(in,t->quantmap+i)){ fprintf(stderr,"out of data 2 while reading codebook %s\n",filename); @@ -306,7 +306,7 @@ codebook *codebook_load(char *filename){ if(find_seek_to(in,"static encode_aux_pigeonhole _vq_aux")){ int pigeons=1,i; /* how big? */ - c->pigeon_tree=p=calloc(1,sizeof(encode_aux_pigeonhole)); + c->pigeon_tree=p=_ogg_calloc(1,sizeof(encode_aux_pigeonhole)); line=get_line(in); if(sscanf(line,"%f, %f, %d, %d",&(p->min),&(p->del), &(p->mapentries),&(p->quantvals))!=4){ @@ -322,7 +322,7 @@ codebook *codebook_load(char *filename){ /* load pigeonmap */ find_seek_to(in,"static long _vq_pigeonmap_"); reset_next_value(); - p->pigeonmap=malloc(sizeof(long)*p->mapentries); + p->pigeonmap=_ogg_malloc(sizeof(long)*p->mapentries); for(i=0;i<p->mapentries;i++) if(get_next_ivalue(in,p->pigeonmap+i)){ fprintf(stderr,"out of data (pigeonmap) while reading codebook %s\n",filename); @@ -331,7 +331,7 @@ codebook *codebook_load(char *filename){ /* load fitlist */ find_seek_to(in,"static long _vq_fitlist_"); reset_next_value(); - p->fitlist=malloc(sizeof(long)*p->fittotal); + p->fitlist=_ogg_malloc(sizeof(long)*p->fittotal); for(i=0;i<p->fittotal;i++) if(get_next_ivalue(in,p->fitlist+i)){ fprintf(stderr,"out of data (fitlist) while reading codebook %s\n",filename); @@ -341,7 +341,7 @@ codebook *codebook_load(char *filename){ find_seek_to(in,"static long _vq_fitmap_"); reset_next_value(); for(i=0;i<c->dim;i++)pigeons*=p->quantvals; - p->fitmap=malloc(sizeof(long)*pigeons); + p->fitmap=_ogg_malloc(sizeof(long)*pigeons); for(i=0;i<pigeons;i++) if(get_next_ivalue(in,p->fitmap+i)){ fprintf(stderr,"out of data (fitmap) while reading codebook %s\n",filename); @@ -351,7 +351,7 @@ codebook *codebook_load(char *filename){ /* load fitlength */ find_seek_to(in,"static long _vq_fitlength_"); reset_next_value(); - p->fitlength=malloc(sizeof(long)*pigeons); + p->fitlength=_ogg_malloc(sizeof(long)*pigeons); for(i=0;i<pigeons;i++) if(get_next_ivalue(in,p->fitlength+i)){ fprintf(stderr,"out of data (fitlength) while reading codebook %s\n",filename); @@ -374,7 +374,7 @@ codebook *codebook_load(char *filename){ /* load the quantized entries */ find_seek_to(in,"static long _vq_quantlist_"); reset_next_value(); - c->quantlist=malloc(sizeof(long)*quant_to_read); + c->quantlist=_ogg_malloc(sizeof(long)*quant_to_read); for(i=0;i<quant_to_read;i++) if(get_next_ivalue(in,c->quantlist+i)){ fprintf(stderr,"out of data while reading codebook %s\n",filename); @@ -384,7 +384,7 @@ codebook *codebook_load(char *filename){ /* load the lengthlist */ find_seek_to(in,"static long _vq_lengthlist"); reset_next_value(); - c->lengthlist=malloc(sizeof(long)*c->entries); + c->lengthlist=_ogg_malloc(sizeof(long)*c->entries); for(i=0;i<c->entries;i++) if(get_next_ivalue(in,c->lengthlist+i)){ fprintf(stderr,"out of data while reading codebook %s\n",filename); @@ -433,7 +433,7 @@ void spinnit(char *s,int n){ void build_tree_from_lengths(int vals, long *hist, long *lengths){ int i,j; - long *membership=malloc(vals*sizeof(long)); + long *membership=_ogg_malloc(vals*sizeof(long)); long *histsave=alloca(vals*sizeof(long)); memcpy(histsave,hist,vals*sizeof(long)); @@ -506,7 +506,7 @@ void build_tree_from_lengths0(int vals, long *hist, long *lengths){ the lengths after the build */ int upper=0,i; - long *lengthlist=calloc(vals,sizeof(long)); + long *lengthlist=_ogg_calloc(vals,sizeof(long)); long *newhist=alloca(vals*sizeof(long)); for(i=0;i<vals;i++) @@ -12,7 +12,7 @@ ******************************************************************** function: utility main for building codebooks from training sets - last mod: $Id: build.c,v 1.15.2.2 2000/11/04 06:22:10 xiphmont Exp $ + last mod: $Id: build.c,v 1.15.2.3 2000/11/04 06:43:55 xiphmont Exp $ ********************************************************************/ @@ -41,10 +41,10 @@ static char *rline(FILE *in,FILE *out){ if(sofar>=lbufsize){ if(!lbufsize){ lbufsize=1024; - linebuffer=malloc(lbufsize); + linebuffer=_ogg_malloc(lbufsize); }else{ lbufsize*=2; - linebuffer=realloc(linebuffer,lbufsize); + linebuffer=_ogg_realloc(linebuffer,lbufsize); } } { @@ -147,7 +147,7 @@ int main(int argc,char *argv[]){ /* save quant data; we don't want to requantize later as our method is currently imperfect wrt repeated application */ i=0; - quantlist=malloc(sizeof(long)*v.elements*v.entries); + quantlist=_ogg_malloc(sizeof(long)*v.elements*v.entries); for(j=0;j<entries;j++){ float a; for(k=0;k<dim;k++){ diff --git a/vq/huffbuild.c b/vq/huffbuild.c index efc96e88..13c0faa4 100644 --- a/vq/huffbuild.c +++ b/vq/huffbuild.c @@ -12,7 +12,7 @@ ******************************************************************** function: hufftree builder - last mod: $Id: huffbuild.c,v 1.5.2.4 2000/11/04 06:22:10 xiphmont Exp $ + last mod: $Id: huffbuild.c,v 1.5.2.5 2000/11/04 06:43:55 xiphmont Exp $ ********************************************************************/ @@ -112,8 +112,8 @@ int main(int argc, char *argv[]){ { long vals=pow(maxval,subn); - long *hist=malloc(vals*sizeof(long)); - long *lengths=malloc(vals*sizeof(long)); + long *hist=_ogg_malloc(vals*sizeof(long)); + long *lengths=_ogg_malloc(vals*sizeof(long)); for(j=0;j<vals;j++)hist[j]=guard; diff --git a/vq/latticebuild.c b/vq/latticebuild.c index 7d4b9eef..146d6ee0 100644 --- a/vq/latticebuild.c +++ b/vq/latticebuild.c @@ -12,7 +12,7 @@ ******************************************************************** function: utility main for building codebooks from lattice descriptions - last mod: $Id: latticebuild.c,v 1.6.2.1 2000/11/04 06:22:10 xiphmont Exp $ + last mod: $Id: latticebuild.c,v 1.6.2.2 2000/11/04 06:43:55 xiphmont Exp $ ********************************************************************/ @@ -77,7 +77,7 @@ int main(int argc,char *argv[]){ { char *ptr; - char *filename=calloc(strlen(argv[1])+4,1); + char *filename=_ogg_calloc(strlen(argv[1])+4,1); strcpy(filename,argv[1]); in=fopen(filename,"r"); @@ -107,13 +107,13 @@ int main(int argc,char *argv[]){ entries=pow(quantvals,dim); c.dim=dim; c.entries=entries; - c.lengthlist=malloc(entries*sizeof(long)); + c.lengthlist=_ogg_malloc(entries*sizeof(long)); c.maptype=1; c.q_sequencep=sequencep; - c.quantlist=calloc(quantvals,sizeof(long)); + c.quantlist=_ogg_calloc(quantvals,sizeof(long)); - quantlist=malloc(sizeof(long)*c.dim*c.entries); - hits=malloc(c.entries*sizeof(long)); + quantlist=_ogg_malloc(sizeof(long)*c.dim*c.entries); + hits=_ogg_malloc(c.entries*sizeof(long)); for(j=0;j<entries;j++)hits[j]=1; for(j=0;j<entries;j++)c.lengthlist[j]=1; diff --git a/vq/latticehint.c b/vq/latticehint.c index 9dc1feff..c45bd4cd 100644 --- a/vq/latticehint.c +++ b/vq/latticehint.c @@ -12,7 +12,7 @@ ******************************************************************** function: utility main for building thresh/pigeonhole encode hints - last mod: $Id: latticehint.c,v 1.3.2.1 2000/11/04 06:22:10 xiphmont Exp $ + last mod: $Id: latticehint.c,v 1.3.2.2 2000/11/04 06:43:55 xiphmont Exp $ ********************************************************************/ @@ -58,10 +58,10 @@ static int addtosearch(int entry,long **tempstack,long *tempcount,int add){ if(ptr){ while(i--) if(*ptr++==add)return(0); - tempstack[entry]=realloc(tempstack[entry], + tempstack[entry]=_ogg_realloc(tempstack[entry], (tempcount[entry]+1)*sizeof(long)); }else{ - tempstack[entry]=malloc(sizeof(long)); + tempstack[entry]=_ogg_malloc(sizeof(long)); } tempstack[entry][tempcount[entry]++]=add; @@ -166,14 +166,14 @@ int main(int argc,char *argv[]){ /* yes. Discard any preexisting threshhold hint */ long quantvals=_book_maptype1_quantvals(c); long **quantsort=alloca(quantvals*sizeof(long *)); - encode_aux_threshmatch *t=calloc(1,sizeof(encode_aux_threshmatch)); + encode_aux_threshmatch *t=_ogg_calloc(1,sizeof(encode_aux_threshmatch)); c->thresh_tree=t; fprintf(stderr,"Adding threshold hint to %s...\n",name); /* simplest possible threshold hint only */ - t->quantthresh=calloc(quantvals-1,sizeof(float)); - t->quantmap=calloc(quantvals,sizeof(int)); + t->quantthresh=_ogg_calloc(quantvals-1,sizeof(float)); + t->quantmap=_ogg_calloc(quantvals,sizeof(int)); t->threshvals=quantvals; t->quantvals=quantvals; @@ -212,7 +212,7 @@ int main(int argc,char *argv[]){ long quantvals=_book_maptype1_quantvals(c); int changep=1,factor; - encode_aux_pigeonhole *p=calloc(1,sizeof(encode_aux_pigeonhole)); + encode_aux_pigeonhole *p=_ogg_calloc(1,sizeof(encode_aux_pigeonhole)); c->pigeon_tree=p; fprintf(stderr,"Adding pigeonhole hint to %s...\n",name); @@ -237,7 +237,7 @@ int main(int argc,char *argv[]){ for(i=0;i<quantvals;i++)if(max<c->quantlist[i])max=c->quantlist[i]; p->mapentries=max; } - p->pigeonmap=malloc(p->mapentries*sizeof(long)); + p->pigeonmap=_ogg_malloc(p->mapentries*sizeof(long)); p->quantvals=(quantvals+factor-1)/factor; /* pigeonhole roughly on the boundaries of the quantvals; the @@ -274,11 +274,11 @@ int main(int argc,char *argv[]){ subpigeons=1; for(i=0;i<dim;i++)subpigeons*=p->mapentries; for(i=0;i<dim;i++)pigeons*=p->quantvals; - temptrack=calloc(dim,sizeof(long)); - tempmin=calloc(dim,sizeof(float)); - tempmax=calloc(dim,sizeof(float)); - tempstack=calloc(pigeons,sizeof(long *)); - tempcount=calloc(pigeons,sizeof(long)); + temptrack=_ogg_calloc(dim,sizeof(long)); + tempmin=_ogg_calloc(dim,sizeof(float)); + tempmax=_ogg_calloc(dim,sizeof(float)); + tempstack=_ogg_calloc(pigeons,sizeof(long *)); + tempcount=_ogg_calloc(pigeons,sizeof(long)); while(1){ float errorpost=-1; @@ -338,7 +338,7 @@ int main(int argc,char *argv[]){ /* pare the list of shortlists; merge contained and similar lists together */ - p->fitmap=malloc(pigeons*sizeof(long)); + p->fitmap=_ogg_malloc(pigeons*sizeof(long)); for(i=0;i<pigeons;i++)p->fitmap[i]=-1; while(changep){ char buffer[80]; @@ -388,8 +388,8 @@ int main(int argc,char *argv[]){ p->fittotal=totalstack; - p->fitlist=malloc((totalstack+1)*sizeof(long)); - p->fitlength=malloc(pigeons*sizeof(long)); + p->fitlist=_ogg_malloc((totalstack+1)*sizeof(long)); + p->fitlength=_ogg_malloc(pigeons*sizeof(long)); { long usage=0; for(i=0;i<pigeons;i++){ diff --git a/vq/latticepare.c b/vq/latticepare.c index 915cce33..a445db1d 100644 --- a/vq/latticepare.c +++ b/vq/latticepare.c @@ -12,7 +12,7 @@ ******************************************************************** function: utility for paring low hit count cells from lattice codebook - last mod: $Id: latticepare.c,v 1.5.2.1 2000/11/04 06:22:10 xiphmont Exp $ + last mod: $Id: latticepare.c,v 1.5.2.2 2000/11/04 06:43:55 xiphmont Exp $ ********************************************************************/ @@ -248,7 +248,7 @@ int main(int argc,char *argv[]){ if((lines&0xff)==0)spinnit("counting samples...",lines*cols); line=setup_line(in); } - pointlist=malloc((cols*lines+entries*dim)*sizeof(float)); + pointlist=_ogg_malloc((cols*lines+entries*dim)*sizeof(float)); rewind(in); line=setup_line(in); @@ -312,15 +312,15 @@ int main(int argc,char *argv[]){ long indexedpoints=0; long *entryindex; long *reventry; - long *membership=malloc(points*sizeof(long)); - long *firsthead=malloc(entries*sizeof(long)); - long *secondary=malloc(points*sizeof(long)); - long *secondhead=malloc(entries*sizeof(long)); - - long *cellcount=calloc(entries,sizeof(long)); - long *cellcount2=calloc(entries,sizeof(long)); - float *cellerror=calloc(entries,sizeof(float)); - float *cellerrormax=calloc(entries,sizeof(float)); + long *membership=_ogg_malloc(points*sizeof(long)); + long *firsthead=_ogg_malloc(entries*sizeof(long)); + long *secondary=_ogg_malloc(points*sizeof(long)); + long *secondhead=_ogg_malloc(entries*sizeof(long)); + + long *cellcount=_ogg_calloc(entries,sizeof(long)); + long *cellcount2=_ogg_calloc(entries,sizeof(long)); + float *cellerror=_ogg_calloc(entries,sizeof(float)); + float *cellerrormax=_ogg_calloc(entries,sizeof(float)); long cellsleft=entries; for(i=0;i<points;i++)membership[i]=-1; for(i=0;i<entries;i++)firsthead[i]=-1; @@ -355,7 +355,7 @@ int main(int argc,char *argv[]){ /* which cells are most heavily populated? Protect as many from dispersal as the user has requested */ { - long **countindex=calloc(entries,sizeof(long *)); + long **countindex=_ogg_calloc(entries,sizeof(long *)); for(i=0;i<entries;i++)countindex[i]=cellcount+i; qsort(countindex,entries,sizeof(long *),longsort); for(i=0;i<protect;i++){ @@ -491,7 +491,7 @@ int main(int argc,char *argv[]){ free(cellerrormax); free(secondary); - pointindex=malloc(points*sizeof(long)); + pointindex=_ogg_malloc(points*sizeof(long)); /* make a point index of fall-through points */ for(i=0;i<points;i++){ int best=_best(b,pointlist+i*dim,1); @@ -501,7 +501,7 @@ int main(int argc,char *argv[]){ } /* make an entry index */ - entryindex=malloc(entries*sizeof(long)); + entryindex=_ogg_malloc(entries*sizeof(long)); target=0; for(i=0;i<entries;i++){ if(b->c->lengthlist[i]>0) @@ -509,17 +509,17 @@ int main(int argc,char *argv[]){ } /* make working space for a reverse entry index */ - reventry=malloc(entries*sizeof(long)); + reventry=_ogg_malloc(entries*sizeof(long)); /* do the split */ nt=b->c->nearest_tree= - calloc(1,sizeof(encode_aux_nearestmatch)); + _ogg_calloc(1,sizeof(encode_aux_nearestmatch)); nt->alloc=4096; - nt->ptr0=malloc(sizeof(long)*nt->alloc); - nt->ptr1=malloc(sizeof(long)*nt->alloc); - nt->p=malloc(sizeof(long)*nt->alloc); - nt->q=malloc(sizeof(long)*nt->alloc); + nt->ptr0=_ogg_malloc(sizeof(long)*nt->alloc); + nt->ptr1=_ogg_malloc(sizeof(long)*nt->alloc); + nt->p=_ogg_malloc(sizeof(long)*nt->alloc); + nt->q=_ogg_malloc(sizeof(long)*nt->alloc); nt->aux=0; fprintf(stderr,"Leaves added: %d \n", @@ -558,7 +558,7 @@ int main(int argc,char *argv[]){ the lengths after the build */ { int upper=0; - long *lengthlist=calloc(entries,sizeof(long)); + long *lengthlist=_ogg_calloc(entries,sizeof(long)); for(i=0;i<entries;i++){ if(b->c->lengthlist[i]>0) entryindex[upper++]=entryindex[i]; diff --git a/vq/latticetune.c b/vq/latticetune.c index d260dd5a..e368ae1a 100644 --- a/vq/latticetune.c +++ b/vq/latticetune.c @@ -13,7 +13,7 @@ function: utility main for setting entropy encoding parameters for lattice codebooks - last mod: $Id: latticetune.c,v 1.3.2.1 2000/11/04 06:22:10 xiphmont Exp $ + last mod: $Id: latticetune.c,v 1.3.2.2 2000/11/04 06:43:55 xiphmont Exp $ ********************************************************************/ @@ -80,8 +80,8 @@ int main(int argc,char *argv[]){ entries=b->entries; dim=b->dim; - hits=malloc(entries*sizeof(long)); - lengths=calloc(entries,sizeof(long)); + hits=_ogg_malloc(entries*sizeof(long)); + lengths=_ogg_calloc(entries,sizeof(long)); for(j=0;j<entries;j++)hits[j]=guard; in=fopen(argv[2],"r"); diff --git a/vq/lspdata.c b/vq/lspdata.c index 669bbee3..89d696cc 100644 --- a/vq/lspdata.c +++ b/vq/lspdata.c @@ -12,7 +12,7 @@ ******************************************************************** function: metrics and quantization code for LSP VQ codebooks - last mod: $Id: lspdata.c,v 1.13.2.2 2000/11/04 06:22:10 xiphmont Exp $ + last mod: $Id: lspdata.c,v 1.13.2.3 2000/11/04 06:43:55 xiphmont Exp $ ********************************************************************/ @@ -153,6 +153,6 @@ void vqext_preprocess(vqgen *v){ } } - weight=malloc(sizeof(float)*v->elements); + weight=_ogg_malloc(sizeof(float)*v->elements); } diff --git a/vq/metrics.c b/vq/metrics.c index 974fcf57..1190f5c1 100644 --- a/vq/metrics.c +++ b/vq/metrics.c @@ -12,7 +12,7 @@ ******************************************************************** function: function calls to collect codebook metrics - last mod: $Id: metrics.c,v 1.9.2.1 2000/11/04 06:22:10 xiphmont Exp $ + last mod: $Id: metrics.c,v 1.9.2.2 2000/11/04 06:43:55 xiphmont Exp $ ********************************************************************/ @@ -63,11 +63,11 @@ void process_preprocess(codebook **bs,char *basename){ while(bs[books])books++; if(books){ - histogram=calloc(books,sizeof(float *)); - histogram_error=calloc(books,sizeof(float *)); - histogram_errorsq=calloc(books,sizeof(float *)); - histogram_hi=calloc(books,sizeof(float *)); - histogram_lo=calloc(books,sizeof(float *)); + histogram=_ogg_calloc(books,sizeof(float *)); + histogram_error=_ogg_calloc(books,sizeof(float *)); + histogram_errorsq=_ogg_calloc(books,sizeof(float *)); + histogram_hi=_ogg_calloc(books,sizeof(float *)); + histogram_lo=_ogg_calloc(books,sizeof(float *)); }else{ fprintf(stderr,"Specify at least one codebook\n"); exit(1); @@ -75,11 +75,11 @@ void process_preprocess(codebook **bs,char *basename){ for(i=0;i<books;i++){ codebook *b=bs[i]; - histogram[i]=calloc(b->entries,sizeof(float)); - histogram_error[i]=calloc(b->entries*b->dim,sizeof(float)); - histogram_errorsq[i]=calloc(b->entries*b->dim,sizeof(float)); - histogram_hi[i]=calloc(b->entries*b->dim,sizeof(float)); - histogram_lo[i]=calloc(b->entries*b->dim,sizeof(float)); + histogram[i]=_ogg_calloc(b->entries,sizeof(float)); + histogram_error[i]=_ogg_calloc(b->entries*b->dim,sizeof(float)); + histogram_errorsq[i]=_ogg_calloc(b->entries*b->dim,sizeof(float)); + histogram_hi[i]=_ogg_calloc(b->entries*b->dim,sizeof(float)); + histogram_lo[i]=_ogg_calloc(b->entries*b->dim,sizeof(float)); } } diff --git a/vq/residuedata.c b/vq/residuedata.c index 71849217..b8a4703e 100644 --- a/vq/residuedata.c +++ b/vq/residuedata.c @@ -12,7 +12,7 @@ ******************************************************************** function: metrics and quantization code for residue VQ codebooks - last mod: $Id: residuedata.c,v 1.4.2.1 2000/11/04 06:22:10 xiphmont Exp $ + last mod: $Id: residuedata.c,v 1.4.2.2 2000/11/04 06:43:55 xiphmont Exp $ ********************************************************************/ @@ -154,7 +154,7 @@ void vqext_preprocess(vqgen *v){ } } vqext_quantize(v,&q); - quant_save=malloc(sizeof(float)*v->elements*v->entries); + quant_save=_ogg_malloc(sizeof(float)*v->elements*v->entries); memcpy(quant_save,_now(v,0),sizeof(float)*v->elements*v->entries); vqgen_unquantize(v,&q); diff --git a/vq/residuesplit.c b/vq/residuesplit.c index aa7c55b8..3aced800 100644 --- a/vq/residuesplit.c +++ b/vq/residuesplit.c @@ -12,7 +12,7 @@ ******************************************************************** function: residue backend 0 partitioner/classifier - last mod: $Id: residuesplit.c,v 1.5.2.1 2000/11/04 06:22:10 xiphmont Exp $ + last mod: $Id: residuesplit.c,v 1.5.2.2 2000/11/04 06:43:56 xiphmont Exp $ ********************************************************************/ @@ -162,9 +162,9 @@ int main(int argc, char *argv[]){ /* how many parts?... */ parts=argc-3; - ebound=malloc(sizeof(float)*parts); - mbound=malloc(sizeof(float)*parts); - subgrp=malloc(sizeof(int)*parts); + ebound=_ogg_malloc(sizeof(float)*parts); + mbound=_ogg_malloc(sizeof(float)*parts); + subgrp=_ogg_malloc(sizeof(int)*parts); for(i=0;i<parts-1;i++){ char *pos=strchr(argv[4+i],','); @@ -217,7 +217,7 @@ int main(int argc, char *argv[]){ } } - vec=malloc(sizeof(float)*n); + vec=_ogg_malloc(sizeof(float)*n); /* get the input line by line and process it */ while(!feof(res)){ if(getline(res,vec,begin,n)) @@ -12,7 +12,7 @@ ******************************************************************** function: utility main for loading and operating on codebooks - last mod: $Id: run.c,v 1.11.2.1 2000/11/04 06:22:10 xiphmont Exp $ + last mod: $Id: run.c,v 1.11.2.2 2000/11/04 06:43:56 xiphmont Exp $ ********************************************************************/ @@ -44,8 +44,8 @@ extern void process_usage(void); int main(int argc,char *argv[]){ char *basename; - codebook **b=calloc(1,sizeof(codebook *)); - int *addmul=calloc(1,sizeof(int)); + codebook **b=_ogg_calloc(1,sizeof(codebook *)); + int *addmul=_ogg_calloc(1,sizeof(int)); int books=0; int input=0; int interleave=0; @@ -115,9 +115,9 @@ int main(int argc,char *argv[]){ dot=strrchr(basename,'.'); if(dot)*dot='\0'; - b=realloc(b,sizeof(codebook *)*(books+2)); + b=_ogg_realloc(b,sizeof(codebook *)*(books+2)); b[books]=codebook_load(name); - addmul=realloc(addmul,sizeof(int)*(books+1)); + addmul=_ogg_realloc(addmul,sizeof(int)*(books+1)); addmul[books++]=multp; b[books]=NULL; } @@ -12,7 +12,7 @@ ******************************************************************** function: train a VQ codebook - last mod: $Id: vqgen.c,v 1.34.2.1 2000/11/04 06:22:11 xiphmont Exp $ + last mod: $Id: vqgen.c,v 1.34.2.2 2000/11/04 06:43:56 xiphmont Exp $ ********************************************************************/ @@ -250,13 +250,13 @@ void vqgen_init(vqgen *v,int elements,int aux,int entries,float mindist, v->aux=aux; v->mindist=mindist; v->allocated=32768; - v->pointlist=malloc(v->allocated*(v->elements+v->aux)*sizeof(float)); + v->pointlist=_ogg_malloc(v->allocated*(v->elements+v->aux)*sizeof(float)); v->entries=entries; - v->entrylist=malloc(v->entries*v->elements*sizeof(float)); - v->assigned=malloc(v->entries*sizeof(long)); - v->bias=calloc(v->entries,sizeof(float)); - v->max=calloc(v->entries,sizeof(float)); + v->entrylist=_ogg_malloc(v->entries*v->elements*sizeof(float)); + v->assigned=_ogg_malloc(v->entries*sizeof(long)); + v->bias=_ogg_calloc(v->entries,sizeof(float)); + v->max=_ogg_calloc(v->entries,sizeof(float)); if(metric) v->metric_func=metric; else @@ -279,7 +279,7 @@ void vqgen_addpoint(vqgen *v, float *p,float *a){ if(v->points>=v->allocated){ v->allocated*=2; - v->pointlist=realloc(v->pointlist,v->allocated*(v->elements+v->aux)* + v->pointlist=_ogg_realloc(v->pointlist,v->allocated*(v->elements+v->aux)* sizeof(float)); } @@ -371,10 +371,10 @@ float vqgen_iterate(vqgen *v,int biasp){ fdesired=(float)v->points/v->entries; desired=fdesired; desired2=desired*2; - new=malloc(sizeof(float)*v->entries*v->elements); - new2=malloc(sizeof(float)*v->entries*v->elements); - nearcount=malloc(v->entries*sizeof(long)); - nearbias=malloc(v->entries*desired2*sizeof(float)); + new=_ogg_malloc(sizeof(float)*v->entries*v->elements); + new2=_ogg_malloc(sizeof(float)*v->entries*v->elements); + nearcount=_ogg_malloc(v->entries*sizeof(long)); + nearbias=_ogg_malloc(v->entries*desired2*sizeof(float)); /* fill in nearest points for entry biasing */ /*memset(v->bias,0,sizeof(float)*v->entries);*/ diff --git a/vq/vqsplit.c b/vq/vqsplit.c index 9e345423..00e33d6a 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.20.2.1 2000/11/04 06:22:11 xiphmont Exp $ + last mod: $Id: vqsplit.c,v 1.20.2.2 2000/11/04 06:43:56 xiphmont Exp $ ********************************************************************/ @@ -98,8 +98,8 @@ int vqsp_count(float *entrylist,float *pointlist,int dim, long *temppointsB=NULL; if(splitp){ - temppointsA=malloc(points*sizeof(long)); - temppointsB=malloc(points*sizeof(long)); + temppointsA=_ogg_malloc(points*sizeof(long)); + temppointsB=_ogg_malloc(points*sizeof(long)); } memset(entryA,0,sizeof(long)*entries); @@ -174,8 +174,8 @@ int lp_split(float *pointlist,long totalpoints, int dim=b->dim; float *entrylist=b->valuelist; long ret; - long *entryA=calloc(entries,sizeof(long)); - long *entryB=calloc(entries,sizeof(long)); + long *entryA=_ogg_calloc(entries,sizeof(long)); + long *entryB=_ogg_calloc(entries,sizeof(long)); long entriesA=0; long entriesB=0; long entriesC=0; @@ -320,10 +320,10 @@ int lp_split(float *pointlist,long totalpoints, long thisaux=t->aux++; if(t->aux>=t->alloc){ t->alloc*=2; - t->ptr0=realloc(t->ptr0,sizeof(long)*t->alloc); - t->ptr1=realloc(t->ptr1,sizeof(long)*t->alloc); - t->p=realloc(t->p,sizeof(long)*t->alloc); - t->q=realloc(t->q,sizeof(long)*t->alloc); + t->ptr0=_ogg_realloc(t->ptr0,sizeof(long)*t->alloc); + t->ptr1=_ogg_realloc(t->ptr1,sizeof(long)*t->alloc); + t->p=_ogg_realloc(t->p,sizeof(long)*t->alloc); + t->q=_ogg_realloc(t->q,sizeof(long)*t->alloc); } t->p[thisaux]=besti; @@ -378,7 +378,7 @@ void vqsp_book(vqgen *v, codebook *b, long *quantlist){ memset(b,0,sizeof(codebook)); memset(c,0,sizeof(static_codebook)); b->c=c; - t=c->nearest_tree=calloc(1,sizeof(encode_aux_nearestmatch)); + t=c->nearest_tree=_ogg_calloc(1,sizeof(encode_aux_nearestmatch)); c->maptype=2; /* make sure there are no duplicate entries and that every @@ -400,7 +400,7 @@ void vqsp_book(vqgen *v, codebook *b, long *quantlist){ } { - v->assigned=calloc(v->entries,sizeof(long)); + v->assigned=_ogg_calloc(v->entries,sizeof(long)); for(i=0;i<v->points;i++){ float *ppt=_point(v,i); float firstmetric=_Ndist(v->elements,_now(v,0),ppt); @@ -436,24 +436,24 @@ void vqsp_book(vqgen *v, codebook *b, long *quantlist){ fprintf(stderr,"Building a book with %ld unique entries...\n",v->entries); { - long *entryindex=malloc(v->entries*sizeof(long *)); - long *pointindex=malloc(v->points*sizeof(long)); - long *membership=malloc(v->points*sizeof(long)); - long *reventry=malloc(v->entries*sizeof(long)); + long *entryindex=_ogg_malloc(v->entries*sizeof(long *)); + long *pointindex=_ogg_malloc(v->points*sizeof(long)); + long *membership=_ogg_malloc(v->points*sizeof(long)); + long *reventry=_ogg_malloc(v->entries*sizeof(long)); long pointssofar=0; for(i=0;i<v->entries;i++)entryindex[i]=i; for(i=0;i<v->points;i++)pointindex[i]=i; t->alloc=4096; - t->ptr0=malloc(sizeof(long)*t->alloc); - t->ptr1=malloc(sizeof(long)*t->alloc); - t->p=malloc(sizeof(long)*t->alloc); - t->q=malloc(sizeof(long)*t->alloc); + t->ptr0=_ogg_malloc(sizeof(long)*t->alloc); + t->ptr1=_ogg_malloc(sizeof(long)*t->alloc); + t->p=_ogg_malloc(sizeof(long)*t->alloc); + t->q=_ogg_malloc(sizeof(long)*t->alloc); t->aux=0; c->dim=v->elements; c->entries=v->entries; - c->lengthlist=calloc(c->entries,sizeof(long)); + c->lengthlist=_ogg_calloc(c->entries,sizeof(long)); b->valuelist=v->entrylist; /* temporary; replaced later */ b->dim=c->dim; b->entries=c->entries; @@ -546,7 +546,7 @@ void vqsp_book(vqgen *v, codebook *b, long *quantlist){ /* run all training points through the decision tree to get a final probability count */ { - long *probability=malloc(c->entries*sizeof(long)); + long *probability=_ogg_malloc(c->entries*sizeof(long)); for(i=0;i<c->entries;i++)probability[i]=1; /* trivial guard */ b->dim=c->dim; @@ -573,8 +573,8 @@ void vqsp_book(vqgen *v, codebook *b, long *quantlist){ assignment and packing to do it now) */ { long *wordlen=c->lengthlist; - long *index=malloc(c->entries*sizeof(long)); - long *revindex=malloc(c->entries*sizeof(long)); + long *index=_ogg_malloc(c->entries*sizeof(long)); + long *revindex=_ogg_malloc(c->entries*sizeof(long)); int k; for(i=0;i<c->entries;i++)index[i]=i; isortvals=c->lengthlist; @@ -594,9 +594,9 @@ void vqsp_book(vqgen *v, codebook *b, long *quantlist){ free(revindex); /* map lengthlist and vallist with index */ - c->lengthlist=calloc(c->entries,sizeof(long)); - b->valuelist=malloc(sizeof(float)*c->entries*c->dim); - c->quantlist=malloc(sizeof(long)*c->entries*c->dim); + c->lengthlist=_ogg_calloc(c->entries,sizeof(long)); + b->valuelist=_ogg_malloc(sizeof(float)*c->entries*c->dim); + c->quantlist=_ogg_malloc(sizeof(long)*c->entries*c->dim); for(i=0;i<c->entries;i++){ long e=index[i]; for(k=0;k<c->dim;k++){ |