mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-18 16:41:14 +02:00
Update libvorbis to 1.3.3.
This commit is contained in:
@@ -5,13 +5,13 @@
|
||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
||||
* *
|
||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 *
|
||||
* 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: envelope.c,v 1.8 2008-02-02 15:53:52 richardash1981 Exp $
|
||||
function: PCM data envelope analysis
|
||||
last mod: $Id: envelope.c 16227 2009-07-08 06:58:46Z xiphmont $
|
||||
|
||||
********************************************************************/
|
||||
|
||||
@@ -67,7 +67,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 +88,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 +110,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;i<n;i++)
|
||||
vec[i]=data[i]*ve->mdct_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 +144,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 +158,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;j<VE_BANDS;j++){
|
||||
float acc=0.;
|
||||
@@ -168,27 +167,27 @@ static int _ve_amp(envelope_lookup *ve,
|
||||
/* accumulate amplitude */
|
||||
for(i=0;i<bands[j].end;i++)
|
||||
acc+=vec[i+bands[j].begin]*bands[j].window[i];
|
||||
|
||||
|
||||
acc*=bands[j].total;
|
||||
|
||||
/* convert amplitude to delta */
|
||||
{
|
||||
int p,this=filters[j].ampptr;
|
||||
float postmax,postmin,premax=-99999.f,premin=99999.f;
|
||||
|
||||
|
||||
p=this;
|
||||
p--;
|
||||
if(p<0)p+=VE_AMP;
|
||||
postmax=max(acc,filters[j].ampbuf[p]);
|
||||
postmin=min(acc,filters[j].ampbuf[p]);
|
||||
|
||||
|
||||
for(i=0;i<stretch;i++){
|
||||
p--;
|
||||
if(p<0)p+=VE_AMP;
|
||||
premax=max(premax,filters[j].ampbuf[p]);
|
||||
premin=min(premin,filters[j].ampbuf[p]);
|
||||
p--;
|
||||
if(p<0)p+=VE_AMP;
|
||||
premax=max(premax,filters[j].ampbuf[p]);
|
||||
premin=min(premin,filters[j].ampbuf[p]);
|
||||
}
|
||||
|
||||
|
||||
valmin=postmin-premin;
|
||||
valmax=postmax-premax;
|
||||
|
||||
@@ -205,7 +204,7 @@ static int _ve_amp(envelope_lookup *ve,
|
||||
}
|
||||
if(valmin<gi->postecho_thresh[j]-penalty)ret|=2;
|
||||
}
|
||||
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@@ -237,10 +236,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;i<ve->ch;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 +265,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(j<ve->current-(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);
|
||||
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;m<VE_BANDS;m++){
|
||||
char buf[80];
|
||||
sprintf(buf,"delL%d",m);
|
||||
for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[m].markers[l]*.1;
|
||||
_analysis_output_always(buf,seq,marker,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;m<VE_BANDS;m++){
|
||||
char buf[80];
|
||||
sprintf(buf,"delR%d",m);
|
||||
for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[m+VE_BANDS].markers[l]*.1;
|
||||
_analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift);
|
||||
}
|
||||
for(m=0;m<VE_BANDS;m++){
|
||||
char buf[80];
|
||||
sprintf(buf,"delL%d",m);
|
||||
for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[m].markers[l]*.1;
|
||||
_analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift);
|
||||
}
|
||||
|
||||
for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->mark[l]*.4;
|
||||
_analysis_output_always("mark",seq,marker,v->pcm_current,0,0,totalshift);
|
||||
|
||||
|
||||
seq++;
|
||||
|
||||
}
|
||||
for(m=0;m<VE_BANDS;m++){
|
||||
char buf[80];
|
||||
sprintf(buf,"delR%d",m);
|
||||
for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[m+VE_BANDS].markers[l]*.1;
|
||||
_analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift);
|
||||
}
|
||||
|
||||
for(l=0;l<last;l++)marker[l*ve->searchstep]=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 +355,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;i<VE_BANDS*e->ch;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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user