Coverage Report

Created: 2026-06-10 06:19

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vorbis/lib/scales.h
Line
Count
Source
1
/********************************************************************
2
 *                                                                  *
3
 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
4
 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
5
 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6
 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
7
 *                                                                  *
8
 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009             *
9
 * by the Xiph.Org Foundation https://xiph.org/                     *
10
 *                                                                  *
11
 ********************************************************************
12
13
 function: linear scale -> dB, Bark and Mel scales
14
15
 ********************************************************************/
16
17
#ifndef _V_SCALES_H_
18
#define _V_SCALES_H_
19
20
#include <math.h>
21
#include "os.h"
22
23
#ifdef _MSC_VER
24
/* MS Visual Studio doesn't have C99 inline keyword. */
25
#define inline __inline
26
#endif
27
28
/* 20log10(x) */
29
#define VORBIS_IEEE_FLOAT32 1
30
#ifdef VORBIS_IEEE_FLOAT32
31
32
176k
static inline float unitnorm(float x){
33
176k
  union {
34
176k
    ogg_uint32_t i;
35
176k
    float f;
36
176k
  } ix;
37
176k
  ix.f = x;
38
176k
  ix.i = (ix.i & 0x80000000U) | (0x3f800000U);
39
176k
  return ix.f;
40
176k
}
Unexecuted instantiation: envelope.c:unitnorm
Unexecuted instantiation: lpc.c:unitnorm
Unexecuted instantiation: analysis.c:unitnorm
psy.c:unitnorm
Line
Count
Source
32
176k
static inline float unitnorm(float x){
33
176k
  union {
34
176k
    ogg_uint32_t i;
35
176k
    float f;
36
176k
  } ix;
37
176k
  ix.f = x;
38
176k
  ix.i = (ix.i & 0x80000000U) | (0x3f800000U);
39
176k
  return ix.f;
40
176k
}
Unexecuted instantiation: codebook.c:unitnorm
Unexecuted instantiation: sharedbook.c:unitnorm
Unexecuted instantiation: floor1.c:unitnorm
Unexecuted instantiation: floor0.c:unitnorm
Unexecuted instantiation: mapping0.c:unitnorm
Unexecuted instantiation: lsp.c:unitnorm
41
42
/* Segher was off (too high) by ~ .3 decibel.  Center the conversion correctly. */
43
72.4M
static inline float todB(const float *x){
44
72.4M
  union {
45
72.4M
    ogg_uint32_t i;
46
72.4M
    float f;
47
72.4M
  } ix;
48
72.4M
  ix.f = *x;
49
72.4M
  ix.i = ix.i&0x7fffffff;
50
72.4M
  return (float)(ix.i * 7.17711438e-7f -764.6161886f);
51
72.4M
}
envelope.c:todB
Line
Count
Source
43
29.4M
static inline float todB(const float *x){
44
29.4M
  union {
45
29.4M
    ogg_uint32_t i;
46
29.4M
    float f;
47
29.4M
  } ix;
48
29.4M
  ix.f = *x;
49
29.4M
  ix.i = ix.i&0x7fffffff;
50
29.4M
  return (float)(ix.i * 7.17711438e-7f -764.6161886f);
51
29.4M
}
Unexecuted instantiation: lpc.c:todB
Unexecuted instantiation: analysis.c:todB
Unexecuted instantiation: psy.c:todB
Unexecuted instantiation: codebook.c:todB
Unexecuted instantiation: sharedbook.c:todB
Unexecuted instantiation: floor1.c:todB
Unexecuted instantiation: floor0.c:todB
mapping0.c:todB
Line
Count
Source
43
43.0M
static inline float todB(const float *x){
44
43.0M
  union {
45
43.0M
    ogg_uint32_t i;
46
43.0M
    float f;
47
43.0M
  } ix;
48
43.0M
  ix.f = *x;
49
43.0M
  ix.i = ix.i&0x7fffffff;
50
43.0M
  return (float)(ix.i * 7.17711438e-7f -764.6161886f);
51
43.0M
}
Unexecuted instantiation: lsp.c:todB
52
53
#define todB_nn(x) todB(x)
54
55
#else
56
57
static float unitnorm(float x){
58
  if(x<0)return(-1.f);
59
  return(1.f);
60
}
61
62
#define todB(x)   (*(x)==0?-400.f:log(*(x)**(x))*4.34294480f)
63
#define todB_nn(x)   (*(x)==0.f?-400.f:log(*(x))*8.6858896f)
64
65
#endif
66
67
12.8M
#define fromdB(x) (exp((x)*.11512925f))
68
69
/* The bark scale equations are approximations, since the original
70
   table was somewhat hand rolled.  The below are chosen to have the
71
   best possible fit to the rolled tables, thus their somewhat odd
72
   appearance (these are more accurate and over a longer range than
73
   the oft-quoted bark equations found in the texts I have).  The
74
   approximations are valid from 0 - 30kHz (nyquist) or so.
75
76
   all f in Hz, z in Bark */
77
78
20.7M
#define toBARK(n)   (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n))
79
#define fromBARK(z) (102.f*(z)-2.f*pow(z,2.f)+.4f*pow(z,3.f)+pow(1.46f,z)-1.f)
80
#define toMEL(n)    (log(1.f+(n)*.001f)*1442.695f)
81
#define fromMEL(m)  (1000.f*exp((m)/1442.695f)-1000.f)
82
83
/* Frequency to octave.  We arbitrarily declare 63.5 Hz to be octave
84
   0.0 */
85
86
8.71M
#define toOC(n)     (log(n)*1.442695f-5.965784f)
87
374M
#define fromOC(o)   (exp(((o)+5.965784f)*.693147f))
88
89
#endif