Commit 238e4a02 authored by Segher Boessenkool's avatar Segher Boessenkool
Browse files

sizeof() cleanup. the occasional void * didn't make this easier.

two bugs in vorbisfile found and fixed.

svn path=/trunk/vorbis/; revision=2105
parent 84253f30
......@@ -11,7 +11,7 @@
********************************************************************
function: flexible, delayed bitpacking abstraction
last mod: $Id: bitbuffer.c,v 1.5 2001/02/26 03:50:41 xiphmont Exp $
last mod: $Id: bitbuffer.c,v 1.6 2001/10/02 00:14:30 segher Exp $
********************************************************************/
......@@ -27,16 +27,16 @@
*/
void bitbuf_init(vorbis_bitbuffer *vbb,vorbis_block *vb){
memset(vbb,0,sizeof(vorbis_bitbuffer));
memset(vbb,0,sizeof(*vbb));
vbb->vb=vb;
vbb->first=vbb->last=_vorbis_block_alloc(vb,sizeof(vorbis_bitbuffer_chain));
vbb->first=vbb->last=_vorbis_block_alloc(vb,sizeof(*vbb->first));
vbb->first->next=0; /* overengineering */
}
void bitbuf_write(vorbis_bitbuffer *vbb,unsigned long word,int length){
vorbis_block *vb=vbb->vb;
if(vbb->ptr>=_VBB_ALLOCSIZE){
vbb->last->next=_vorbis_block_alloc(vb,sizeof(vorbis_bitbuffer_chain));
vbb->last->next=_vorbis_block_alloc(vb,sizeof(*vbb->last->next));
vbb->last=vbb->last->next;
vbb->last->next=0; /* overengineering */
vbb->ptr=0;
......
......@@ -11,7 +11,7 @@
********************************************************************
function: PCM data vector blocking, windowing and dis/reassembly
last mod: $Id: block.c,v 1.49 2001/08/13 01:36:56 xiphmont Exp $
last mod: $Id: block.c,v 1.50 2001/10/02 00:14:30 segher Exp $
Handle windowing, overlap-add, etc of the PCM vectors. This is made
more amusing by Vorbis' current two allowed block sizes.
......@@ -89,7 +89,7 @@ static int ilog2(unsigned int v){
#endif
int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb){
memset(vb,0,sizeof(vorbis_block));
memset(vb,0,sizeof(*vb));
vb->vd=v;
vb->localalloc=0;
vb->localstore=NULL;
......@@ -107,7 +107,7 @@ void *_vorbis_block_alloc(vorbis_block *vb,long bytes){
if(bytes+vb->localtop>vb->localalloc){
/* can't just _ogg_realloc... there are outstanding pointers */
if(vb->localstore){
struct alloc_chain *link=_ogg_malloc(sizeof(struct alloc_chain));
struct alloc_chain *link=_ogg_malloc(sizeof(*link));
vb->totaluse+=vb->localtop;
link->next=vb->reap;
link->ptr=vb->localstore;
......@@ -132,7 +132,7 @@ void _vorbis_block_ripcord(vorbis_block *vb){
while(reap){
struct alloc_chain *next=reap->next;
_ogg_free(reap->ptr);
memset(reap,0,sizeof(struct alloc_chain));
memset(reap,0,sizeof(*reap));
_ogg_free(reap);
reap=next;
}
......@@ -156,7 +156,7 @@ int vorbis_block_clear(vorbis_block *vb){
if(vb->localstore)_ogg_free(vb->localstore);
if(vb->internal)_ogg_free(vb->internal);
memset(vb,0,sizeof(vorbis_block));
memset(vb,0,sizeof(*vb));
return(0);
}
......@@ -169,14 +169,14 @@ static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){
codec_setup_info *ci=vi->codec_setup;
backend_lookup_state *b=NULL;
memset(v,0,sizeof(vorbis_dsp_state));
b=v->backend_state=_ogg_calloc(1,sizeof(backend_lookup_state));
memset(v,0,sizeof(*v));
b=v->backend_state=_ogg_calloc(1,sizeof(*b));
v->vi=vi;
b->modebits=ilog2(ci->modes);
b->transform[0]=_ogg_calloc(VI_TRANSFORMB,sizeof(vorbis_look_transform *));
b->transform[1]=_ogg_calloc(VI_TRANSFORMB,sizeof(vorbis_look_transform *));
b->transform[0]=_ogg_calloc(VI_TRANSFORMB,sizeof(*b->transform[0]));
b->transform[1]=_ogg_calloc(VI_TRANSFORMB,sizeof(*b->transform[1]));
/* MDCT is tranform 0 */
......@@ -185,14 +185,14 @@ static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){
mdct_init(b->transform[0][0],ci->blocksizes[0]);
mdct_init(b->transform[1][0],ci->blocksizes[1]);
b->window[0][0][0]=_ogg_calloc(VI_WINDOWB,sizeof(float *));
b->window[0][0][0]=_ogg_calloc(VI_WINDOWB,sizeof(*b->window[0][0][0]));
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]=_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 *));
b->window[1][0][0]=_ogg_calloc(VI_WINDOWB,sizeof(*b->window[1][0][0]));
b->window[1][0][1]=_ogg_calloc(VI_WINDOWB,sizeof(*b->window[1][0][1]));
b->window[1][1][0]=_ogg_calloc(VI_WINDOWB,sizeof(*b->window[1][1][0]));
b->window[1][1][1]=_ogg_calloc(VI_WINDOWB,sizeof(*b->window[1][1][1]));
for(i=0;i<VI_WINDOWB;i++){
b->window[0][0][0][i]=
......@@ -209,13 +209,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=_ogg_calloc(ci->books,sizeof(codebook));
b->fullbooks=_ogg_calloc(ci->books,sizeof(*b->fullbooks));
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=_ogg_calloc(ci->books,sizeof(codebook));
b->fullbooks=_ogg_calloc(ci->books,sizeof(*b->fullbooks));
for(i=0;i<ci->books;i++)
vorbis_book_init_decode(b->fullbooks+i,ci->book_param[i]);
}
......@@ -226,12 +226,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=_ogg_malloc(vi->channels*sizeof(float *));
v->pcmret=_ogg_malloc(vi->channels*sizeof(float *));
v->pcm=_ogg_malloc(vi->channels*sizeof(*v->pcm));
v->pcmret=_ogg_malloc(vi->channels*sizeof(*v->pcmret));
{
int i;
for(i=0;i<vi->channels;i++)
v->pcm[i]=_ogg_calloc(v->pcm_storage,sizeof(float));
v->pcm[i]=_ogg_calloc(v->pcm_storage,sizeof(*v->pcm[i]));
}
/* all 1 (large block) or 0 (small block) */
......@@ -245,7 +245,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=_ogg_calloc(ci->modes,sizeof(vorbis_look_mapping *));
b->mode=_ogg_calloc(ci->modes,sizeof(*b->mode));
for(i=0;i<ci->modes;i++){
int mapnum=ci->mode_param[i]->mapping;
int maptype=ci->map_type[mapnum];
......@@ -265,7 +265,7 @@ int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi){
b->psy_g_look=_vp_global_look(vi);
/* Initialize the envelope state storage */
b->ve=_ogg_calloc(1,sizeof(envelope_lookup));
b->ve=_ogg_calloc(1,sizeof(*b->ve));
_ve_envelope_init(b->ve,vi);
return(0);
}
......@@ -340,7 +340,7 @@ void vorbis_dsp_clear(vorbis_dsp_state *v){
_ogg_free(b);
}
memset(v,0,sizeof(vorbis_dsp_state));
memset(v,0,sizeof(*v));
}
}
......@@ -361,7 +361,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]=_ogg_realloc(v->pcm[i],v->pcm_storage*sizeof(float));
v->pcm[i]=_ogg_realloc(v->pcm[i],v->pcm_storage*sizeof(*v->pcm[i]));
}
}
......@@ -374,8 +374,8 @@ float **vorbis_analysis_buffer(vorbis_dsp_state *v, int vals){
static void _preextrapolate_helper(vorbis_dsp_state *v){
int i;
int order=32;
float *lpc=alloca(order*sizeof(float));
float *work=alloca(v->pcm_current*sizeof(float));
float *lpc=alloca(order*sizeof(*lpc));
float *work=alloca(v->pcm_current*sizeof(*work));
long j;
v->preextrapolate=1;
......@@ -411,7 +411,7 @@ int vorbis_analysis_wrote(vorbis_dsp_state *v, int vals){
if(vals<=0){
int order=32;
int i;
float *lpc=alloca(order*sizeof(float));
float *lpc=alloca(order*sizeof(*lpc));
/* if it wasn't done earlier (very short sample) */
if(!v->preextrapolate)
......@@ -445,7 +445,7 @@ int vorbis_analysis_wrote(vorbis_dsp_state *v, int vals){
guarding the overlap, but bulletproof in case that
assumtion goes away). zeroes will do. */
memset(v->pcm[i]+v->eofflag,0,
(v->pcm_current-v->eofflag)*sizeof(float));
(v->pcm_current-v->eofflag)*sizeof(*v->pcm[i]));
}
}
......@@ -550,17 +550,17 @@ int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb){
g->ampmax=_vp_ampmax_decay(g->ampmax,v);
vbi->ampmax=g->ampmax;
vb->pcm=_vorbis_block_alloc(vb,sizeof(float *)*vi->channels);
vbi->pcmdelay=_vorbis_block_alloc(vb,sizeof(float *)*vi->channels);
vb->pcm=_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels);
vbi->pcmdelay=_vorbis_block_alloc(vb,sizeof(*vbi->pcmdelay)*vi->channels);
for(i=0;i<vi->channels;i++){
vbi->pcmdelay[i]=
_vorbis_block_alloc(vb,(vb->pcmend+beginW)*sizeof(float));
memcpy(vbi->pcmdelay[i],v->pcm[i],(vb->pcmend+beginW)*sizeof(float));
_vorbis_block_alloc(vb,(vb->pcmend+beginW)*sizeof(*vbi->pcmdelay[i]));
memcpy(vbi->pcmdelay[i],v->pcm[i],(vb->pcmend+beginW)*sizeof(*vbi->pcmdelay[i]));
vb->pcm[i]=vbi->pcmdelay[i]+beginW;
/* before we added the delay
vb->pcm[i]=_vorbis_block_alloc(vb,vb->pcmend*sizeof(float));
memcpy(vb->pcm[i],v->pcm[i]+beginW,ci->blocksizes[v->W]*sizeof(float));
vb->pcm[i]=_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i]));
memcpy(vb->pcm[i],v->pcm[i]+beginW,ci->blocksizes[v->W]*sizeof(*vb->pcm[i]));
*/
}
......@@ -590,7 +590,7 @@ int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb){
for(i=0;i<vi->channels;i++)
memmove(v->pcm[i],v->pcm[i]+movementW,
v->pcm_current*sizeof(float));
v->pcm_current*sizeof(*v->pcm[i]));
v->lW=v->W;
......@@ -658,7 +658,7 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
int i;
for(i=0;i<vi->channels;i++)
memmove(v->pcm[i],v->pcm[i]+shiftPCM,
v->pcm_current*sizeof(float));
v->pcm_current*sizeof(*v->pcm[i]));
}
}
......@@ -691,7 +691,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]=_ogg_realloc(v->pcm[i],v->pcm_storage*sizeof(float));
v->pcm[i]=_ogg_realloc(v->pcm[i],v->pcm_storage*sizeof(*v->pcm[i]));
}
/* overlap/add PCM */
......
......@@ -11,7 +11,7 @@
********************************************************************
function: basic codebook pack/unpack/code/decode operations
last mod: $Id: codebook.c,v 1.29 2001/08/13 11:33:39 xiphmont Exp $
last mod: $Id: codebook.c,v 1.30 2001/10/02 00:14:30 segher Exp $
********************************************************************/
......@@ -148,7 +148,7 @@ int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){
readies the codebook auxiliary structures for decode *************/
int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
long i,j;
memset(s,0,sizeof(static_codebook));
memset(s,0,sizeof(*s));
s->allocedp=1;
/* make sure alignment is correct */
......@@ -163,7 +163,7 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
switch(oggpack_read(opb,1)){
case 0:
/* unordered */
s->lengthlist=_ogg_malloc(sizeof(long)*s->entries);
s->lengthlist=_ogg_malloc(sizeof(*s->lengthlist)*s->entries);
/* allocated but unused entries? */
if(oggpack_read(opb,1)){
......@@ -191,7 +191,7 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
/* ordered */
{
long length=oggpack_read(opb,5)+1;
s->lengthlist=_ogg_malloc(sizeof(long)*s->entries);
s->lengthlist=_ogg_malloc(sizeof(*s->lengthlist)*s->entries);
for(i=0;i<s->entries;){
long num=oggpack_read(opb,_ilog(s->entries-i));
......@@ -233,7 +233,7 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
}
/* quantized values */
s->quantlist=_ogg_malloc(sizeof(long)*quantvals);
s->quantlist=_ogg_malloc(sizeof(*s->quantlist)*quantvals);
for(i=0;i<quantvals;i++)
s->quantlist[i]=oggpack_read(opb,s->q_quant);
......@@ -344,8 +344,8 @@ long vorbis_book_decode(codebook *book, oggpack_buffer *b){
/* returns 0 on OK or -1 on eof *************************************/
long vorbis_book_decodevs_add(codebook *book,float *a,oggpack_buffer *b,int n){
int step=n/book->dim;
long *entry = alloca(sizeof(long)*step);
float **t = alloca(sizeof(float *)*step);
long *entry = alloca(sizeof(*entry)*step);
float **t = alloca(sizeof(*t)*step);
int i,j,o;
for (i = 0; i < step; i++) {
......@@ -523,10 +523,10 @@ int main(){
while(testlist[ptr]){
codebook c;
static_codebook s;
float *qv=alloca(sizeof(float)*TESTSIZE);
float *iv=alloca(sizeof(float)*TESTSIZE);
memcpy(qv,testvec[ptr],sizeof(float)*TESTSIZE);
memset(iv,0,sizeof(float)*TESTSIZE);
float *qv=alloca(sizeof(*qv)*TESTSIZE);
float *iv=alloca(sizeof(*iv)*TESTSIZE);
memcpy(qv,testvec[ptr],sizeof(*qv)*TESTSIZE);
memset(iv,0,sizeof(*iv)*TESTSIZE);
fprintf(stderr,"\tpacking/coding %ld... ",ptr);
......
......@@ -11,7 +11,7 @@
********************************************************************
function: PCM data envelope analysis and manipulation
last mod: $Id: envelope.c,v 1.37 2001/08/13 01:36:56 xiphmont Exp $
last mod: $Id: envelope.c,v 1.38 2001/10/02 00:14:30 segher Exp $
Preecho calculation.
......@@ -88,8 +88,8 @@ void _ve_envelope_init(envelope_lookup *e,vorbis_info *vi){
int i;
e->winlength=window;
e->minenergy=fromdB(gi->preecho_minenergy);
e->iir=_ogg_calloc(ch*4,sizeof(IIR_state));
e->filtered=_ogg_calloc(ch*4,sizeof(float *));
e->iir=_ogg_calloc(ch*4,sizeof(*e->iir));
e->filtered=_ogg_calloc(ch*4,sizeof(*e->filtered));
e->ch=ch;
e->storage=128;
for(i=0;i<ch*4;i+=4){
......@@ -103,10 +103,10 @@ void _ve_envelope_init(envelope_lookup *e,vorbis_info *vi){
IIR_init(e->iir+i+3,cheb_bandpass_stages,cheb_bandpass1k_gain,
cheb_bandpass1k_A,cheb_bandpass_B);
e->filtered[i]=_ogg_calloc(e->storage,sizeof(float));
e->filtered[i+1]=_ogg_calloc(e->storage,sizeof(float));
e->filtered[i+2]=_ogg_calloc(e->storage,sizeof(float));
e->filtered[i+3]=_ogg_calloc(e->storage,sizeof(float));
e->filtered[i]=_ogg_calloc(e->storage,sizeof(*e->filtered[i]));
e->filtered[i+1]=_ogg_calloc(e->storage,sizeof(*e->filtered[i+1]));
e->filtered[i+2]=_ogg_calloc(e->storage,sizeof(*e->filtered[i+2]));
e->filtered[i+3]=_ogg_calloc(e->storage,sizeof(*e->filtered[i+3]));
}
}
......@@ -119,7 +119,7 @@ void _ve_envelope_clear(envelope_lookup *e){
}
_ogg_free(e->filtered);
_ogg_free(e->iir);
memset(e,0,sizeof(envelope_lookup));
memset(e,0,sizeof(*e));
}
/* straight threshhold based until we find something that works better
......@@ -159,7 +159,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*4;i++)
ve->filtered[i]=_ogg_realloc(ve->filtered[i],ve->storage*sizeof(float));
ve->filtered[i]=_ogg_realloc(ve->filtered[i],ve->storage*sizeof(*ve->filtered[i]));
}
/* catch up the highpass to match the pcm */
......@@ -228,7 +228,7 @@ void _ve_envelope_shift(envelope_lookup *e,long shift){
int i;
for(i=0;i<e->ch*4;i++)
memmove(e->filtered[i],e->filtered[i]+shift,(e->current-shift)*
sizeof(float));
sizeof(*e->filtered[i]));
e->current-=shift;
e->lastmark-=shift;
}
......
......@@ -11,7 +11,7 @@
********************************************************************
function: floor backend 0 implementation
last mod: $Id: floor0.c,v 1.45 2001/08/13 01:36:56 xiphmont Exp $
last mod: $Id: floor0.c,v 1.46 2001/10/02 00:14:30 segher Exp $
********************************************************************/
......@@ -63,7 +63,7 @@ static long _f0_fit(codebook *book,
lsp[i]=(orig[i+cursor]-base);
best=_best(book,lsp,1);
memcpy(lsp,book->valuelist+best*dim,dim*sizeof(float));
memcpy(lsp,book->valuelist+best*dim,dim*sizeof(*lsp));
for(i=0;i<dim;i++)
lsp[i]+=base;
return(best);
......@@ -73,21 +73,22 @@ 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=_ogg_malloc(sizeof(vorbis_info_floor0));
memcpy(ret,info,sizeof(vorbis_info_floor0));
vorbis_info_floor0 *ret=_ogg_malloc(sizeof(*ret));
memcpy(ret,info,sizeof(*ret));
return(ret);
}
static void floor0_free_info(vorbis_info_floor *i){
if(i){
memset(i,0,sizeof(vorbis_info_floor0));
_ogg_free(i);
vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
if(info){
memset(info,0,sizeof(*info));
_ogg_free(info);
}
}
static void floor0_free_look(vorbis_look_floor *i){
vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
if(i){
if(look){
/*fprintf(stderr,"floor 0 bit usage %f\n",
(float)look->bits/look->frames);*/
......@@ -95,7 +96,7 @@ static void floor0_free_look(vorbis_look_floor *i){
if(look->linearmap)_ogg_free(look->linearmap);
if(look->lsp_look)_ogg_free(look->lsp_look);
lpc_clear(&look->lpclook);
memset(look,0,sizeof(vorbis_look_floor0));
memset(look,0,sizeof(*look));
_ogg_free(look);
}
}
......@@ -117,7 +118,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=_ogg_malloc(sizeof(vorbis_info_floor0));
vorbis_info_floor0 *info=_ogg_malloc(sizeof(*info));
info->order=oggpack_read(opb,8);
info->rate=oggpack_read(opb,16);
info->barkmap=oggpack_read(opb,16);
......@@ -156,7 +157,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=_ogg_calloc(1,sizeof(vorbis_look_floor0));
vorbis_look_floor0 *look=_ogg_calloc(1,sizeof(*look));
look->m=info->order;
look->n=ci->blocksizes[mi->blockflag]/2;
look->ln=info->barkmap;
......@@ -176,7 +177,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=_ogg_malloc((look->n+1)*sizeof(int));
look->linearmap=_ogg_malloc((look->n+1)*sizeof(*look->linearmap));
for(j=0;j<look->n;j++){
int val=floor( toBARK((info->rate/2.f)/look->n*j)
*scale); /* bark numbers represent band edges */
......@@ -185,7 +186,7 @@ static vorbis_look_floor *floor0_look (vorbis_dsp_state *vd,vorbis_info_mode *mi
}
look->linearmap[j]=-1;
look->lsp_look=_ogg_malloc(look->ln*sizeof(float));
look->lsp_look=_ogg_malloc(look->ln*sizeof(*look->lsp_look));
for(j=0;j<look->ln;j++)
look->lsp_look[j]=2*cos(M_PI/look->ln*j);
......@@ -200,12 +201,12 @@ float _curve_to_lpc(float *curve,float *lpc,
/* map the input curve to a bark-scale curve for encoding */
int mapped=l->ln;
float *work=alloca(sizeof(float)*mapped);
float *work=alloca(sizeof(*work)*mapped);
int i,j,last=0;
int bark=0;
static int seq=0;
memset(work,0,sizeof(float)*mapped);
memset(work,0,sizeof(*work)*mapped);
/* Only the decode side is behavior-specced; for now in the encoder,
we select the maximum value of each band as representative (this
......@@ -323,7 +324,7 @@ static int floor0_forward(vorbis_block *vb,vorbis_look_floor *in,
look->frames++;
if(val){
float *lspwork=alloca(look->m*sizeof(float));
float *lspwork=alloca(look->m*sizeof(*lspwork));
/* the spec supports using one of a number of codebooks. Right
now, encode using this lib supports only one */
......@@ -404,8 +405,8 @@ static int floor0_forward(vorbis_block *vb,vorbis_look_floor *in,
fclose(of);
#endif
memset(codedflr,0,sizeof(float)*look->n);
memset(mdct,0,sizeof(float)*look->n);
memset(codedflr,0,sizeof(*codedflr)*look->n);
memset(mdct,0,sizeof(*mdct)*look->n);
return(val);
}
......@@ -424,7 +425,7 @@ static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){
backend_lookup_state *be=vb->vd->backend_state;
codebook *b=be->fullbooks+info->books[booknum];
float last=0.f;
float *lsp=_vorbis_block_alloc(vb,sizeof(float)*(look->m+1));
float *lsp=_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+1));
for(j=0;j<look->m;j+=b->dim)
if(vorbis_book_decodev_set(b,lsp+j,&vb->opb,b->dim)==-1)goto eop;
......@@ -455,7 +456,7 @@ static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i,
lsp,look->m,amp,info->ampdB);
return(1);
}
memset(out,0,sizeof(float)*look->n);
memset(out,0,sizeof(*out)*look->n);
return(0);
}
......
......@@ -11,7 +11,7 @@
********************************************************************
function: floor backend 1 implementation
last mod: $Id: floor1.c,v 1.15 2001/09/01 06:14:50 xiphmont Exp $
last mod: $Id: floor1.c,v 1.16 2001/10/02 00:14:31 segher Exp $
********************************************************************/
......@@ -68,28 +68,29 @@ typedef struct lsfit_acc{
static vorbis_info_floor *floor1_copy_info (vorbis_info_floor *i){
vorbis_info_floor1 *info=(vorbis_info_floor1 *)i;
vorbis_info_floor1 *ret=_ogg_malloc(sizeof(vorbis_info_floor1));
memcpy(ret,info,sizeof(vorbis_info_floor1));
vorbis_info_floor1 *ret=_ogg_malloc(sizeof(*ret));
memcpy(ret,info,sizeof(*ret));
return(ret);
}
static void floor1_free_info(vorbis_info_floor *i){
if(i){
memset(i,0,sizeof(vorbis_info_floor1));
_ogg_free(i);
vorbis_info_floor1 *info=(vorbis_info_floor1 *)i;
if(info){
memset(info,0,sizeof(*info));
_ogg_free(info);
}
}
static void floor1_free_look(vorbis_look_floor *i){
vorbis_look_floor1 *look=(vorbis_look_floor1 *)i;
if(i){
if(look){
/*fprintf(stderr,"floor 1 bit usage %f:%f (%f total)\n",
(float)look->phrasebits/look->frames,
(float)look->postbits/look->frames,
(float)(look->postbits+look->phrasebits)/look->frames);*/
memset(look,0,sizeof(vorbis_look_floor1));
free(i);
memset(look,0,sizeof(*look));
free(look);
}
}
......@@ -152,7 +153,7 @@ static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){
codec_setup_info *ci=vi->codec_setup;
int j,k,count=0,maxclass=-1,rangebits;
vorbis_info_floor1 *info=_ogg_calloc(1,sizeof(vorbis_info_floor1));
vorbis_info_floor1 *info=_ogg_calloc(1,sizeof(*info));
/* read partitions */
info->partitions=oggpack_read(opb,5); /* only 0 to 31 legal */
for(j=0;j<info->partitions;j++){
......@@ -207,7 +208,7 @@ static vorbis_look_floor *floor1_look(vorbis_dsp_state *vd,vorbis_info_mode *mi,
int *sortpointer[VIF_POSIT+2];
vorbis_info_floor1 *info=(vorbis_info_floor1 *)in;
vorbis_look_floor1 *look=_ogg_calloc(1,sizeof(vorbis_look_floor1));
vorbis_look_floor1 *look=_ogg_calloc(1,sizeof(*look));
int i,j,n=0;
look->vi=info;
......@@ -226,7 +227,7 @@ static vorbis_look_floor *floor1_look(vorbis_dsp_state *vd,vorbis_info_mode *mi,
/* also store a sorted position index */
for(i=0;i<n;i++)sortpointer[i]=info->postlist+i;
qsort(sortpointer,n,sizeof(int *),icomp);
qsort(sortpointer,n,sizeof(*sortpointer),icomp);
/* points from sort order back to range number */
for(i=0;i<n;i++)look->forward_index[i]=sortpointer[i]-info->postlist;
......@@ -426,7 +427,7 @@ static int accumulate_fit(const float *flr,const float *mdct,
long xa=0,ya=0,x2a=0,y2a=0,xya=0,na=0, xb=0,yb=0,x2b=0,y2b=0,xyb=0,nb=0;
memset(a,0,sizeof(lsfit_acc));
memset(a,0,sizeof(*a));
a->x0=x0;