X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lib%2Fenvelope.c;h=da752375428500a1d2f5cbd940d4fe94a5d728c1;hb=679433ebb8287744a9801f847b7a105dbc2a0404;hp=fb82f357f2213eddf9e47442fb3eba7a5d4c738c;hpb=30dacdee96e7a592aa4e683ed07076b7ca610dde;p=platform%2Fupstream%2Flibvorbis.git diff --git a/lib/envelope.c b/lib/envelope.c index fb82f35..da75237 100644 --- a/lib/envelope.c +++ b/lib/envelope.c @@ -5,13 +5,12 @@ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * by the XIPHOPHORUS Company http://www.xiph.org/ * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * + * by the Xiph.Org Foundation http://www.xiph.org/ * * * ******************************************************************** - function: PCM data envelope analysis - last mod: $Id$ + function: PCM data envelope analysis ********************************************************************/ @@ -67,7 +66,7 @@ void _ve_envelope_init(envelope_lookup *e,vorbis_info *vi){ } e->band[j].total=1./e->band[j].total; } - + e->filter=_ogg_calloc(VE_BANDS*ch,sizeof(*e->filter)); e->mark=_ogg_calloc(e->storage,sizeof(*e->mark)); @@ -88,11 +87,10 @@ void _ve_envelope_clear(envelope_lookup *e){ that works better and isn't patented. */ static int _ve_amp(envelope_lookup *ve, - vorbis_info_psy_global *gi, - float *data, - envelope_band *bands, - envelope_filter_state *filters, - long pos){ + vorbis_info_psy_global *gi, + float *data, + envelope_band *bands, + envelope_filter_state *filters){ long n=ve->winlength; int ret=0; long i,j; @@ -111,15 +109,15 @@ static int _ve_amp(envelope_lookup *ve, float penalty=gi->stretch_penalty-(ve->stretch/2-VE_MINSTRETCH); if(penalty<0.f)penalty=0.f; if(penalty>gi->stretch_penalty)penalty=gi->stretch_penalty; - + /*_analysis_output_always("lpcm",seq2,data,n,0,0, totalshift+pos*ve->searchstep);*/ - + /* window and transform */ for(i=0;imdct_win[i]; mdct_forward(&ve->mdct,vec,vec); - + /*_analysis_output_always("mdct",seq2,vec,n/2,0,1,0); */ /* near-DC spreading function; this has nothing to do with @@ -145,7 +143,7 @@ static int _ve_amp(envelope_lookup *ve, if(filters->nearptr>=VE_NEARDC)filters->nearptr=0; decay=todB(&decay)*.5-15.f; } - + /* perform spreading and limiting, also smooth the spectrum. yes, the MDCT results in all real coefficients, but it still *behaves* like real/imaginary pairs */ @@ -159,7 +157,7 @@ static int _ve_amp(envelope_lookup *ve, } /*_analysis_output_always("spread",seq2++,vec,n/4,0,0,0);*/ - + /* perform preecho/postecho triggering by band */ for(j=0;jpostecho_thresh[j]-penalty)ret|=2; } - + return(ret); } @@ -237,10 +235,10 @@ long _ve_envelope_search(vorbis_dsp_state *v){ ve->stretch++; if(ve->stretch>VE_MAXSTRETCH*2) ve->stretch=VE_MAXSTRETCH*2; - + for(i=0;ich;i++){ float *pcm=v->pcm[i]+ve->searchstep*(j); - ret|=_ve_amp(ve,gi,pcm,ve->band,ve->filter+i*VE_BANDS,j); + ret|=_ve_amp(ve,gi,pcm,ve->band,ve->filter+i*VE_BANDS); } ve->mark[j+VE_POST]=0; @@ -266,65 +264,65 @@ long _ve_envelope_search(vorbis_dsp_state *v){ ci->blocksizes[v->W]/4+ ci->blocksizes[1]/2+ ci->blocksizes[0]/4; - + j=ve->cursor; - + while(jcurrent-(ve->searchstep)){/* account for postecho working back one window */ if(j>=testW)return(1); - + ve->cursor=j; if(ve->mark[j/ve->searchstep]){ - if(j>centerW){ + if(j>centerW){ #if 0 - if(j>ve->curmark){ - float *marker=alloca(v->pcm_current*sizeof(*marker)); - int l,m; - memset(marker,0,sizeof(*marker)*v->pcm_current); - fprintf(stderr,"mark! seq=%d, cursor:%fs time:%fs\n", - seq, - (totalshift+ve->cursor)/44100., - (totalshift+j)/44100.); - _analysis_output_always("pcmL",seq,v->pcm[0],v->pcm_current,0,0,totalshift); - _analysis_output_always("pcmR",seq,v->pcm[1],v->pcm_current,0,0,totalshift); - - _analysis_output_always("markL",seq,v->pcm[0],j,0,0,totalshift); - _analysis_output_always("markR",seq,v->pcm[1],j,0,0,totalshift); - - for(m=0;msearchstep]=ve->filter[m].markers[l]*.1; - _analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift); - } - - for(m=0;msearchstep]=ve->filter[m+VE_BANDS].markers[l]*.1; - _analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift); - } - - for(l=0;lsearchstep]=ve->mark[l]*.4; - _analysis_output_always("mark",seq,marker,v->pcm_current,0,0,totalshift); - - - seq++; - - } + if(j>ve->curmark){ + float *marker=alloca(v->pcm_current*sizeof(*marker)); + int l,m; + memset(marker,0,sizeof(*marker)*v->pcm_current); + fprintf(stderr,"mark! seq=%d, cursor:%fs time:%fs\n", + seq, + (totalshift+ve->cursor)/44100., + (totalshift+j)/44100.); + _analysis_output_always("pcmL",seq,v->pcm[0],v->pcm_current,0,0,totalshift); + _analysis_output_always("pcmR",seq,v->pcm[1],v->pcm_current,0,0,totalshift); + + _analysis_output_always("markL",seq,v->pcm[0],j,0,0,totalshift); + _analysis_output_always("markR",seq,v->pcm[1],j,0,0,totalshift); + + for(m=0;msearchstep]=ve->filter[m].markers[l]*.1; + _analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift); + } + + for(m=0;msearchstep]=ve->filter[m+VE_BANDS].markers[l]*.1; + _analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift); + } + + for(l=0;lsearchstep]=ve->mark[l]*.4; + _analysis_output_always("mark",seq,marker,v->pcm_current,0,0,totalshift); + + + seq++; + + } #endif - ve->curmark=j; - if(j>=testW)return(1); - return(0); - } + ve->curmark=j; + if(j>=testW)return(1); + return(0); + } } j+=ve->searchstep; } } - + return(-1); } @@ -356,27 +354,21 @@ int _ve_envelope_mark(vorbis_dsp_state *v){ void _ve_envelope_shift(envelope_lookup *e,long shift){ int smallsize=e->current/e->searchstep+VE_POST; /* adjust for placing marks - ahead of ve->current */ + ahead of ve->current */ int smallshift=shift/e->searchstep; memmove(e->mark,e->mark+smallshift,(smallsize-smallshift)*sizeof(*e->mark)); - + #if 0 for(i=0;ich;i++) memmove(e->filter[i].markers, - e->filter[i].markers+smallshift, - (1024-smallshift)*sizeof(*(*e->filter).markers)); + e->filter[i].markers+smallshift, + (1024-smallshift)*sizeof(*(*e->filter).markers)); totalshift+=shift; -#endif +#endif e->current-=shift; if(e->curmark>=0) e->curmark-=shift; e->cursor-=shift; } - - - - - -