> 
> So, is the ISO Doc buggy or Lame?
> The ISO doc states, to calculate the spreading function s(i,j) 
> for layer III one has to change the line
>       tmpx = 1.05*(bval[j]-bval[i]);
> into
>       if( j>=i ) tmpx = (bval[j]-bval[i])*3.0;
>       else       tmpx = (bval[j]-bval[i])*1.5;
>                               ^       ^
> but in Lame
>       if( j>=i ) tmpx = (bval[i]-bval[j])*3.0;
>       else       tmpx = (bval[i]-bval[j])*1.5;
>                               ^       ^
> we calculate -tmpx instead of tmpx!
> 
> And to be a bit more pessimistic, I would suggest
>       tmpx = (bval[j]-bval[i])*3.0;
> 
> 

Looks like another serious bug!

The full block of code looks like:

          //tempx = (bval_l[i] - bval_l[j])*1.05;
          if (j>=i) tempx = (bval_l[i] - bval_l[j])*3.0;
          else    tempx = (bval_l[i] - bval_l[j])*1.5;
          /*             if (j>=i) tempx = (bval_l[j] - bval_l[i])*3.0;
                         else    tempx = (bval_l[j] - bval_l[i])*1.5; */

          if(tempx>=0.5 && tempx<=2.5)
            {
              temp = tempx - 0.5;
              x = 8.0 * (temp*temp - 2.0 * temp);
            }
          else x = 0.0;
          tempx += 0.474;
          tempy = 15.811389 + 7.5*tempx - 17.5*sqrt(1.0+tempx*tempx);

          if (tempy <= -60.0) s3_l[i][j] = 0.0;
          else                s3_l[i][j] = exp( (x + tempy)*LN_TO_LOG10 );

But note that the ISO docs say to replace 'tmpy', not 'tmpx' which is
done here.  But replacing tmpy with the suggested value gives numbers
that dont make any sense.  I think this must be a bug in both the ISO
docs and the code.  Probably going back to the layer II formula 
    tempx = (bval_l[i] - bval_l[j])*1.05;
is the safest thing.

And what is the deal with 'x'?  It seems to be some kind of correction
term, which reduces the masking of frequencies between .5 and 2.5 barks
lower than the masking frequency.  (bval_l[i] = frequency of i'th partition band, in 
barks) 
I wonder if this should also be applied for the layer 3 model?

Taking a look of that Painter et al. article on psychoacoustics,
it looks like the spreading function should be 0 at j=i, and
have slope 25 db/bark for j<i, -10db/bark for j>i.  
But these values (25 and 10) dont seem to close to 3 and 1.5.  

I would suggest:

          if (j>=i) tempy = (bval_l[j] - bval_l[i])*(-10);
          else    tempy = (bval_l[j] - bval_l[i])*25;

          if (tempy <= -60.0) s3_l[i][j] = 0.0;
          else                s3_l[i][j] = exp( tempy*LN_TO_LOG10 ); 

but this will need a lot of testing.

One additional confusion: in the ISO doc, the meaning of i and j
seem to be reversed from the ISO code.  

Mark

--
MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )

Reply via email to