[vorbis-dev] Possible bug in psy.c

Martin Reinecke martin at MPA-Garching.MPG.DE
Thu Jul 6 02:33:50 PDT 2000



Monty wrote:
> 
> > Hi all,
> >
> > I'm quite new to Vorbis, so please excuse me if I'm writing complete
> > nonsense (and, if possible, tell me where I'm wrong).
> >
> > While searching for optimization possibilities in lib/psy.c, I found the following
> > piece of code in _vp_compute_mask():
> >
> >   if(p->vi->smoothp){
> >     /* compute power^.5 of three neighboring bins to smooth for peaks
> >        that get split twixt bins/peaks that nail the bin.  This evens
> >        out treatment as we're not doing additive masking any longer. */
> >     double acc=work[0]*work[0]+work[1]*work[1];
> >     double prev=work[0];
> >
> >     work[0]=sqrt(acc);
> >     for(i=1;i<n-1;i++){
> >       double this=work[i];
> >       acc+=work[i+1]*work[i+1];
> >       work[i]=sqrt(acc);
> >       acc-=prev*prev;
> >       prev=this;
> >     }
> >     work[n-1]=sqrt(acc);
> >   }
> >
> > If this is intended to be a simple smoothing operation, I would expect that
> > work[0] and work[n-1] must be divided by sqrt(2) and all other entries in work
> > must be divided by sqrt(3) in order to renormalize work[].
> 
> it computes 'sqrt(work[i-1]^2+work[i]^2+work[i+1]^2)' as intended.

No, it doesn't. The border values are
sqrt (work[0]^2 + work[1]^2) and sqrt (work[n-2]^2 + work[n-1]^2).
They are the sum of only two terms istead of three for all the others.
If all entries in work[] were equal before the smoothing, work[0]
and work[n-1] would be smaller than the rest afterwards. Is this intended?

Martin

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/



More information about the Vorbis-dev mailing list