Ignore:
Timestamp:
10/07/06 02:49:28 (18 years ago)
Author:
r2d
Message:
  • fixed a LOT of bugs
  • fixed a bug that took me 2 days to find :)
  • remember to ALWAYS use -Wall with a C compiler (C++ is great !!!)
  • files can be played, but are not bit identical with the 1.15w encoder (the last digits of floats are not the same) - must be fixed.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • mppenc/branches/r2d/libmpcpsy/psy_tab.c

    r65 r71  
    4747const float iw_short [PART_SHORT] = { 1.f, 1.f, 1.f, 1.f, 1.f/2, 1.f/2, 1.f/2, 1.f/2, 1.f/3, 1.f/3, 1.f/4, 1.f/6, 1.f/7, 1.f/8, 1.f/11, 1.f/13, 1.f/17, 1.f/25, 1.f/29 };
    4848
     49float  MinVal   [PART_LONG];               // contains minimum tonality soffsets
     50float  Loudness [PART_LONG];               // weighting factors for loudness calculation
     51float  SPRD     [PART_LONG] [PART_LONG];   // tabulated spreading function
     52float  O_MAX;
     53float  O_MIN;
     54float  FAC1;
     55float  FAC2;                               // constants for offset calculation
     56float  partLtq  [PART_LONG];               // threshold in quiet (partitions)
     57float  invLtq   [PART_LONG];               // inverse threshold in quiet (partitions, long)
     58float  fftLtq   [512];                     // threshold in quiet (FFT)
    4959
    5060static float
     
    165175        tmp       = mind ( tmp, Ltq_max );              // Limit ATH
    166176        tmp      += Ltq_offset - 23;                    // Add chosen Offset
    167         m->fftLtq[n] = absLtq[n] = POW10 ( 0.1 * tmp);     // conversion into power
     177        fftLtq[n] = absLtq[n] = POW10 ( 0.1 * tmp);     // conversion into power
    168178    }
    169179
     
    174184            erg = minf (erg, absLtq[k]);
    175185
    176                 m->partLtq[n] = erg;               // threshold in quiet
    177                 m->invLtq [n] = 1.f / m->partLtq[n];  // Inverse
     186                partLtq[n] = erg;               // threshold in quiet
     187                invLtq [n] = 1.f / partLtq[n];  // Inverse
    178188    }
    179189}
     
    219229        tmp          = LOG10 (midfreq) - 3.5f;                                  // dB(A)
    220230        tmp          = -10 * tmp * tmp + 3 - midfreq/3000;
    221                 m->Loudness [n] = POW10 ( 0.1 * tmp );                                     // conversion into power
     231                Loudness [n] = POW10 ( 0.1 * tmp );                                     // conversion into power
    222232    }
    223233}
     
    286296    for ( n = 0; n < PART_LONG; n++ ) {
    287297                tmp        = Bass ( (wl [n] + wh [n]) / 2048. * m->SampleFreq, m->TMN, m->NMT, bass );
    288                 m->MinVal [n] = POW10 ( -0.1 * tmp );                      // conversion into power
     298                MinVal [n] = POW10 ( -0.1 * tmp );                      // conversion into power
    289299    }
    290300
    291301    // calculation of the constants for "tonality offset"
    292         m->O_MAX = POW10 ( -0.1 * m->TMN );
    293         m->O_MIN = POW10 ( -0.1 * m->NMT );
    294         m->FAC1  = POW10 ( -0.1 * (m->NMT - (m->TMN - m->NMT) * 0.229) ) ;
    295         m->FAC2  = (m->TMN - m->NMT) * (0.99011159 * 0.1);
     302        O_MAX = POW10 ( -0.1 * m->TMN );
     303        O_MIN = POW10 ( -0.1 * m->NMT );
     304        FAC1  = POW10 ( -0.1 * (m->NMT - (m->TMN - m->NMT) * 0.229) ) ;
     305        FAC2  = (m->TMN - m->NMT) * (0.99011159 * 0.1);
    296306}
    297307
     
    333343
    334344            // calculate coefficient
    335                         m->SPRD[i][j] = POW10 ( -0.1 * (tmpy+tmpz) );  // [Source] [Target]
     345                        SPRD[i][j] = POW10 ( -0.1 * (tmpy+tmpz) );  // [Source] [Target]
    336346        }
    337347    }
     
    341351        float  norm = 0.f;
    342352        for ( j = 0; j < PART_LONG; j++ )               // j is masking Partition
    343                         norm += m->SPRD [j] [i];
     353                        norm += SPRD [j] [i];
    344354        for ( j = 0; j < PART_LONG; j++ )               // j is masking Partition
    345                         m->SPRD [j] [i] /= norm;
     355                        SPRD [j] [i] /= norm;
    346356    }
    347357}
Note: See TracChangeset for help on using the changeset viewer.