Tuned out Dibrom's tone/noise masking bug. The problem was the
[platform/upstream/libvorbis.git] / lib / masking.h
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-2001             *
9  * by the XIPHOPHORUS Company http://www.xiph.org/                  *
10  *                                                                  *
11  ********************************************************************
12
13  function: masking curve data for psychoacoustics
14  last mod: $Id: masking.h,v 1.21 2001/12/22 09:40:39 xiphmont Exp $
15
16  ********************************************************************/
17
18 #ifndef _V_MASKING_H_
19 #define _V_MASKING_H_
20
21 static float ATH_Bark_dB_lspconservative[]={  
22    15,   15,   15,    15,    11,    10,     8,    7,    7,    7,
23     6,    2,    0,     0,    -3,    -5,    -6,   -6, -4.5f, 2.5f,
24    10,   15,   15,    15,    15,    15,   15};
25
26 /* The below masking curves are straight from the R. Ehmer
27    (J. Acoustical Society of America) papers ca 1958-59.  I modified
28    them slightly as Ehmer does not correct for the Absolute Threshold
29    of Hearing, and the low dB portions of the curves are thus highly
30    suspect. */
31
32 /* Let's all do the Trek thing and just call them 'Ehmer curves' ;-)
33    Note these are octaves, not Bark scale. */
34
35 #define EHMER_OFFSET 16
36 #define EHMER_MAX 56
37
38 static float tone_125_40dB_SL[EHMER_MAX]={
39   20,  20,  20,  20,  20,  20,  20,  20,   20, 20, 20, 20, 20, 20, 20, 20,  
40   20,  18,  16,  14,  12,  11,   9,   7,    5,  3,  2,  0, -2, -4, -6, -8,
41  -10, -12, -14, -16, -18, -20, -900, -900,  -900,-900,-900,-900,-900,-900,-900,-900,  
42 -900,-900,-900,-900,-900,-900,-900,-900};
43 static float tone_125_60dB_SL[EHMER_MAX]={
44   40,  40,  40,  40,  40,  40,  40,  40,   40, 40, 40, 40, 40, 40, 40, 40,  
45   40,  38,  36,  34,  32,  31,  29,  27,   25, 23, 22, 20, 18, 16, 14, 12,
46   10,   8,   6,   4,   2,   0,  -3,  -5,   -8,-10,-14,-17,-20,-900,-900,-900,  
47 -900,-900,-900,-900,-900,-900,-900,-900};
48 static float tone_125_80dB_SL[EHMER_MAX]={
49   60,  60,  60,  60,  60,  60,  60,  60,   60, 60, 60, 60, 60, 60, 60, 60,  
50   60,  58,  56,  54,  52,  51,  49,  47,   45, 43, 42, 40, 38, 36, 34, 32,
51   30,  28,  26,  24,  22,  20,  17,  15,   12, 10,  6,  3,  0, -4, -8,-12,  
52 -900,-900,-900,-900,-900,-900,-900,-900};
53 static float tone_125_100dB_SL[EHMER_MAX]={
54   78,  78,  78,  78,  78,  78,  78,  78,   78, 78, 78, 78, 78, 78, 78, 78,  
55   78,  77,  75,  74,  73,  72,  71,  70,   69, 68, 67, 65, 64, 63, 62, 60,
56   58,  57,  55,  54,  52,  50,  48,  46,   44, 42, 40, 38, 36, 34, 31, 29,  
57   27,  24,  22,  20,  18,  15,  13,  11};
58
59 static float tone_250_40dB_SL[EHMER_MAX]={
60 -900,-900,-900,-900,-900,-900,-900,-900,   -19, -13,  -7,  -1,   4,   9,  15,  20,
61   22,  23,  22,  19,  18,  18,  16,  13,     9,   7,   3,   1,  -1,  -3,  -6,  -8,
62  -10, -13, -16, -19,-900,-900,-900,-900,  -900,-900,-900,-900,-900,-900,-900,-900,
63 -900,-900,-900,-900,-900,-900,-900,-900};
64 static float tone_250_60dB_SL[EHMER_MAX]={
65 -900,-900,-900,-900,-900,-900,-900, -10,   -5,  1,  7, 13, 19, 25, 30, 33,  
66   36,  39,  38,  37,  38,  39,  39,  40,   38, 36, 35, 34, 33, 31, 29, 28,
67   28,  28,  25,  20,  14,  10,   5,   0,   -5,-10,-15,-20,-900,-900,-900,-900,  
68 -900,-900,-900,-900,-900,-900,-900,-900};
69 static float tone_250_80dB_SL[EHMER_MAX]={
70 -900,-900,-900,-900,-900,-900,-900, -10,   10, 17, 24, 30, 37, 41, 48, 49,  
71   50,  53,  54,  53,  53,  54,  55,  57,   57, 57, 58, 59, 60, 58, 57, 58,
72   59,  58,  57,  54,  52,  50,  49,  47,   46, 47, 46, 44, 43, 42, 41, 40,  
73   38,  32,  27,  22,  17,  11,   6,   0};
74 /* no data, just interpolated from 80 */
75 static float tone_250_100dB_SL[EHMER_MAX]={
76 -900,-900,-900,-900,-900,-900,-900, -10,   15, 25, 34, 40, 50, 56, 60, 70,  
77   70,  73,  74,  73,  73,  74,  75,  77,   77, 77, 78, 79, 80, 78, 77, 78,
78   79,  78,  77,  74,  72,  70,  69,  67,   66, 67, 66, 64, 63, 62, 61, 60,  
79   58,  52,  47,  42,  37,  31,  26,  20};
80
81 static float tone_500_40dB_SL[EHMER_MAX]={
82 -900,-900,-900,-900,-900,-900,-900,-900,  -900, -20, -14,  -8,  -2,   4,  10,  17,
83   23,  16,  12,   9,   6,   3,   0,  -3,    -7, -10, -13, -16, -20,-900,-900,-900,
84 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900,-900,-900,-900,-900,
85 -900,-900,-900,-900,-900,-900,-900,-900};
86 static float tone_500_60dB_SL[EHMER_MAX]={
87 -900,-900,-900,-900,-900,-900,-900,-900,   -18, -12,  -6,   0,   6,  13,  20,  30,
88   39,  34,  31,  29,  29,  27,  24,  21,    18,  16,  13,   8,   6,   3,   1,  -1,
89   -5,  -2,  -5,  -8, -12, -15, -18,-900,  -900,-900,-900,-900,-900,-900,-900,-900,
90 -900,-900,-900,-900,-900,-900,-900,-900};
91 static float tone_500_80dB_SL[EHMER_MAX]={
92 -900,-900,-900,-900,-900,-900,-900,-900, -900,-16,-10,  0, 10, 20, 32, 43,  
93   53,  52,  52,  50,  49,  50,  52,  55,   55, 54, 51, 49, 46, 44, 44, 42,
94   38,  34,  32,  29,  29,  28,  25,  23,   20, 16, 10,  7,  4,  2, -1, -4,  
95   -7, -10, -15, -20,-900,-900,-900,-900};
96 static float tone_500_100dB_SL[EHMER_MAX]={
97 -900,-900,-900,-900,-900,-900,-900, -10,   -7,  2, 10, 19, 27, 35, 55, 56,  
98   62,  61,  60,  58,  57,  57,  59,  63,   65, 66, 62, 60, 57, 57, 58, 58,
99   57,  56,  56,  56,  57,  57,  56,  57,   57, 54, 47, 41, 37, 28, 21, 16,  
100   10,   3,  -3,  -8, -13, -18,-900,-900};
101
102 static float tone_1000_40dB_SL[EHMER_MAX]={
103 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900, -20, -10,  0,   9,  20,
104   27,  20,  13,  14,  13,   5,  -1,  -6,   -11, -20,-900,-900,-900,-900,-900,-900,
105 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900,-900,-900,-900,-900,
106 -900,-900,-900,-900,-900,-900,-900,-900};
107 static float tone_1000_60dB_SL[EHMER_MAX]={
108 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-13,-3,  7,  17,  25,  37,
109   42,  33,  25,  25,  23,  18,  13,   9,     4, -1, -7,-13,-18, -23, -28, -33,
110 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900,-900,-900,-900,-900,
111 -900,-900,-900,-900,-900,-900,-900,-900};
112 static float tone_1000_80dB_SL[EHMER_MAX]={
113 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-14, -4,  6, 16, 27, 33, 50,  
114   59,  57,  47,  41,  40,  43,  47,  48,    47, 42, 39, 37, 37, 36, 35, 32,
115   30,  27,  21,  15,   5,  -2, -10, -18,  -900,-900,-900,-900,-900,-900,-900,-900,
116 -900,-900,-900,-900,-900,-900,-900,-900};
117 static float tone_1000_100dB_SL[EHMER_MAX]={
118 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-10,  0, 10, 23, 33, 45, 60,  
119   70,  72,  55,  49,  43,  40,  44,  54,    59, 58, 49, 43, 52, 57, 57, 58,
120   58,  54,  49,  47,  42,  39,  33,  28,    20, 15,  5,  0, -5,-15,-900,-900,  
121 -900,-900,-900,-900,-900,-900,-900,-900};
122
123 static float tone_2000_40dB_SL[EHMER_MAX]={
124 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900,-900,   5,  12,  20,
125   24,  14,   8,   0,  -5,-900,-900,-900,  -900,-900,-900,-900,-900,-900,-900,-900,
126 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900,-900,-900,-900,-900,
127 -900,-900,-900,-900,-900,-900,-900,-900};
128 static float tone_2000_60dB_SL[EHMER_MAX]={
129 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900,  -2,   8,  19,  31,
130   38,  30,  15,  15,  15,  13,   8,   5,    -2,-900,-900,-900,-900,-900,-900,-900,
131 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900,-900,-900,-900,-900,
132 -900,-900,-900,-900,-900,-900,-900,-900};
133 static float tone_2000_80dB_SL[EHMER_MAX]={
134 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900,   2,  10,  22,  38,
135   52,  51,  40,  30,  28,  30,  33,  37,    37,  35,  31,  26,  20,  15,  10,   5,
136    0,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900,-900,-900,-900,-900,
137 -900,-900,-900,-900,-900,-900,-900,-900};
138 static float tone_2000_100dB_SL[EHMER_MAX]={  
139 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900,   6,  20,  40,  55,
140   66,  60,  53,  40,  35,  31,  34,  42,    58,  48,  43,  45,  52,  57,  50,  42,
141   45,  45,  35,  25,  20,  11,   2,-900,  -900,-900,-900,-900,-900,-900,-900,-900,
142 -900,-900,-900,-900,-900,-900,-900,-900};
143
144 static float tone_4000_40dB_SL[EHMER_MAX]={
145 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900,-900,   2,   4,  18,
146   24,  10,   5,   0,  -5,-900,-900,-900,  -900,-900,-900,-900,-900,-900,-900,-900,
147 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900,-900,-900,-900,-900,
148 -900,-900,-900,-900,-900,-900,-900,-900};
149
150 static float tone_4000_60dB_SL[EHMER_MAX]={
151 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900,  -2,   2,   4,  20,
152   38,  30,  22,  15,  10,   5,   0, -10,  -900,-900,-900,-900,-900,-900,-900,-900,
153 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900,-900,-900,-900,-900,
154 -900,-900,-900,-900,-900,-900,-900,-900};
155
156 static float tone_4000_80dB_SL[EHMER_MAX]={
157 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900,   0,   4,  10,  35,
158   51,  49,  35,  35,  36,  36,  36,  31,    25,  20,  10,   0,-900,-900,-900,-900,
159 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900,-900,-900,-900,-900,
160 -900,-900,-900,-900,-900,-900,-900,-900};
161
162 static float tone_4000_100dB_SL[EHMER_MAX]={
163 -900,  -5,   1,   3,   5,   8,  10,  12,    14,  20,  26,  28,  32,  36,  41,  51,
164   61,  59,  45,  45,  48,  48,  40,  25,    40,  30,  18,   5,  0, -900,-900,-900,
165 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900,-900,-900,-900,-900,
166 -900,-900,-900,-900,-900,-900,-900,-900};
167
168
169 /* here the data collected by ehmer is clearly suspect as I have
170    several samples that provide counterexamples.  the data below is
171    derated from Ehmers original numbers */
172
173 static float tone_8000_40dB_SL[EHMER_MAX]={
174 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900, -10,   3,  10,  18,
175   26,  21,  14,   5,   0,  0,   0,    0,    20,  35,  55,  70,  70,  70,  70,  70,
176   70,  70,  70,  70,  70, 70,  70,   70,  -900,-900,-900,-900,-900,-900,-900,-900,
177 -900,-900,-900,-900,-900,-900,-900,-900};
178 static float tone_8000_60dB_SL[EHMER_MAX]={
179 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900, -10,  5,   12,  30,
180   43,  34,  22,  15,  10,   5,   0,   0,    20,  55,  70,  70,  70,  70,  70,  70,
181   70,  70,  70,  70,  70,  70,  70,  70,  -900,-900,-900,-900,-900,-900,-900,-900,
182   -900,-900,-900,-900,-900,-900,-900,-900};
183 static float tone_8000_80dB_SL[EHMER_MAX]={
184 -900,-900,-900,-900,-900,-900,-900, -10,    -1,   2,   6,  10,  13,  19,  25,  35,
185   63,  50,  35,  35,  36,  36,  36,  31,    40,  55,  70,  70,  70,  70,  70,  70,
186   70,  70,  70,  70,  70,  70,  70,  70,  -900,-900,-900,-900,-900,-900,-900,-900,
187  -900,-900,-900,-900,-900,-900,-900,-900};
188 static float tone_8000_100dB_SL[EHMER_MAX]={
189  -18, -12,  -7,  -3,   0,   2,   5,   8,    10,  14,  18,  20,  20,  22,  40,  40,
190   70,  50,  30,  30,  30,  30,  30,  32,    43,  55,  70,  70,  70,  70,  70,  70,
191   70,  70,  70,  70,  70,  70,  70,  70,  -900,-900,-900,-900,-900,-900,-900,-900,
192   -900,-900,-900,-900,-900,-900,-900,-900};
193
194 /* a complete guess, but reasonably conservative and borne out by some
195    empirical testing */
196
197 static float tone_16000_40dB_SL[EHMER_MAX]={
198 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900, -10,   3,  10,  18,
199   26,  35,  55,  70,  70,  70,  70,  70,   70,  70,  70,  70,  70, 70,  70,  70, 
200 -900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
201 -900,-900,-900,-900,-900,-900,-900,-900};
202 static float tone_16000_60dB_SL[EHMER_MAX]={
203 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900, -10,  5,   12,  30,
204   43,  55,  70,  70,  70,  70,  70,  70,    70,  70,  70,  70,  70,  70,  70,  70,
205 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900,-900,-900,-900,-900,
206   -900,-900,-900,-900,-900,-900,-900,-900};
207 static float tone_16000_80dB_SL[EHMER_MAX]={
208 -900,-900,-900,-900,-900,-900,-900, -10,    -1,   2,   6,  10,  13,  19,  25,  35,
209   63,  55,  70,  70,  70,  70,  70,  70,    70,  70,  70,  70,  70,  70,  70,  70,
210 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900,-900,-900,-900,-900,
211  -900,-900,-900,-900,-900,-900,-900,-900};
212 static float tone_16000_100dB_SL[EHMER_MAX]={
213  -18, -12,  -7,  -3,   0,   2,   5,   8,    10,  14,  18,  20,  20,  22,  40,  40,
214   70,  55,  70,  70,  70,  70,  70,  70,    70,  70,  70,  70,  70,  70,  70,  70,
215 -900,-900,-900,-900,-900,-900,-900,-900,  -900,-900,-900,-900,-900,-900,-900,-900,
216   -900,-900,-900,-900,-900,-900,-900,-900};
217
218 #endif