Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
Vorbis
Vorbis
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Xiph.Org
  • VorbisVorbis
  • Issues
  • #1920

Closed
Open
Created Jan 03, 2013 by Aniket B@aniketmb

todB () function correction

In the mapping0_forward () function in the file mapping0.c file, while converting fft values to dB scale, a local maximum calculations are performed. In the first iteration, the max value is initialized to fft[0] (magnitude of signal) while in later on iterations, the maximum value is initialized to magnitude^2. In dB conversion of these values, a constant is subtracted in the todB () function. However, in the first iteration the constant is subtracted from the magnitude value, while in the further iterations the value is subtracted from magnitude^2.

logfft[0]=scale_dB+todB(pcm)  + .345; /* + .345 is a hack; the
                                 original todB estimation used on
                                 IEEE 754 compliant machines had a
                                 bug that returned dB values about
                                 a third of a decibel too high.
                                 The bug was harmless because
                                 tunings implicitly took that into
                                 account.  However, fixing the bug
                                 in the estimator requires
                                 changing all the tunings as well.
                                 For now, it's easier to sync
                                 things back up here, and
                                 recalibrate the tunings in the
                                 next major model upgrade. */
local_ampmax[i]=logfft[0];
for(j=1;j<n-1;j+=2){
  float temp=pcm[j]*pcm[j]+pcm[j+1]*pcm[j+1]; //magnitude square calculation
  temp=logfft[(j+1)>>1]=scale_dB+.5f*todB(&temp)  + .345; /* +
                                 .345 is a hack; the original todB
                                 estimation used on IEEE 754
                                 compliant machines had a bug that
                                 returned dB values about a third
                                 of a decibel too high.  The bug
                                 was harmless because tunings
                                 implicitly took that into
                                 account.  However, fixing the bug
                                 in the estimator requires
                                 changing all the tunings as well.
                                 For now, it's easier to sync
                                 things back up here, and
                                 recalibrate the tunings in the
                                 next major model upgrade. */
  if(temp>local_ampmax[i])local_ampmax[i]=temp;
}

if(local_ampmax[i]>0.f)local_ampmax[i]=0.f;
if(local_ampmax[i]>global_ampmax)global_ampmax=local_ampmax[i];

//todB () function definition. static inline float todB(const float *x){ union { ogg_uint32_t i; float f; } ix; ix.f = *x; ix.i = ix.i&0x7fffffff; return (float)(ix.i * 7.17711438e-7f -764.6161886f); //764.6161886 is subtracted from fft[0] as well as amp^2. //The constant subtraction is not consistent over the max calculations }

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None