quartz: add implementations for AmpFactorToDB and DBToAmpFactor
Robert Reif
reif at earthlink.net
Tue Jan 2 08:36:20 CST 2007
-------------- next part --------------
diff -puN wine.cvs/dlls/quartz/db.c wine/dlls/quartz/db.c
--- wine.cvs/dlls/quartz/db.c 1969-12-31 19:00:00.000000000 -0500
+++ wine/dlls/quartz/db.c 2007-01-01 17:51:44.000000000 -0500
@@ -0,0 +1,204 @@
+/* DirectShow dB conversion functions
+ *
+ * Copyright 2007 Robert Reif
+ *
+ * This file contains the (internal) driver registration functions,
+ * driver enumeration APIs and DirectDraw creation functions.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "config.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(quartz);
+
+/* table was generated with the following code */
+
+#if 0
+#include <stdio.h>
+#include <math.h>
+
+int main(int argc, char * argv[])
+{
+ int i, amp, db;
+ char line[128];
+ char num[16];
+ line[0] = 0;
+ printf("static unsigned short table[964] = {\n");
+ for (i = 0; i < 964; i++)
+ {
+ db = -i * 10;
+ amp = pow(10.0, db / 2000.0) * 65536.0;
+ if (amp > 65535)
+ amp = 65535;
+ sprintf(num, "%5d, ", amp);
+ strcat(line, num);
+ if (i % 10 == 9) {
+ printf(" %s\n", line);
+ line[0] = 0;
+ }
+ }
+ printf(" %s\n", line);
+ printf("};\n");
+ return 0;
+}
+#endif
+
+static unsigned short table[964] = {
+ 65535, 64785, 64044, 63311, 62586, 61869, 61161, 60461, 59769, 59085,
+ 58409, 57740, 57079, 56426, 55780, 55141, 54510, 53886, 53269, 52659,
+ 52057, 51461, 50872, 50289, 49714, 49145, 48582, 48026, 47476, 46933,
+ 46395, 45864, 45339, 44820, 44307, 43800, 43299, 42803, 42313, 41829,
+ 41350, 40877, 40409, 39946, 39489, 39037, 38590, 38148, 37712, 37280,
+ 36853, 36431, 36014, 35602, 35194, 34792, 34393, 34000, 33610, 33226,
+ 32845, 32469, 32098, 31730, 31367, 31008, 30653, 30302, 29955, 29612,
+ 29273, 28938, 28607, 28280, 27956, 27636, 27319, 27007, 26698, 26392,
+ 26090, 25791, 25496, 25204, 24916, 24630, 24348, 24070, 23794, 23522,
+ 23253, 22986, 22723, 22463, 22206, 21952, 21701, 21452, 21207, 20964,
+ 20724, 20487, 20252, 20020, 19791, 19565, 19341, 19119, 18900, 18684,
+ 18470, 18259, 18050, 17843, 17639, 17437, 17237, 17040, 16845, 16652,
+ 16461, 16273, 16087, 15903, 15720, 15541, 15363, 15187, 15013, 14841,
+ 14671, 14503, 14337, 14173, 14011, 13850, 13692, 13535, 13380, 13227,
+ 13076, 12926, 12778, 12632, 12487, 12344, 12203, 12063, 11925, 11789,
+ 11654, 11520, 11388, 11258, 11129, 11002, 10876, 10751, 10628, 10507,
+ 10386, 10267, 10150, 10034, 9919, 9805, 9693, 9582, 9472, 9364,
+ 9257, 9151, 9046, 8942, 8840, 8739, 8639, 8540, 8442, 8346,
+ 8250, 8156, 8062, 7970, 7879, 7788, 7699, 7611, 7524, 7438,
+ 7353, 7269, 7185, 7103, 7022, 6941, 6862, 6783, 6706, 6629,
+ 6553, 6478, 6404, 6331, 6258, 6186, 6116, 6046, 5976, 5908,
+ 5840, 5774, 5707, 5642, 5578, 5514, 5451, 5388, 5326, 5265,
+ 5205, 5146, 5087, 5028, 4971, 4914, 4858, 4802, 4747, 4693,
+ 4639, 4586, 4533, 4482, 4430, 4380, 4329, 4280, 4231, 4182,
+ 4135, 4087, 4040, 3994, 3948, 3903, 3859, 3814, 3771, 3728,
+ 3685, 3643, 3601, 3560, 3519, 3479, 3439, 3400, 3361, 3322,
+ 3284, 3246, 3209, 3173, 3136, 3100, 3065, 3030, 2995, 2961,
+ 2927, 2893, 2860, 2828, 2795, 2763, 2731, 2700, 2669, 2639,
+ 2609, 2579, 2549, 2520, 2491, 2463, 2434, 2407, 2379, 2352,
+ 2325, 2298, 2272, 2246, 2220, 2195, 2170, 2145, 2120, 2096,
+ 2072, 2048, 2025, 2002, 1979, 1956, 1934, 1911, 1890, 1868,
+ 1847, 1825, 1805, 1784, 1763, 1743, 1723, 1704, 1684, 1665,
+ 1646, 1627, 1608, 1590, 1572, 1554, 1536, 1518, 1501, 1484,
+ 1467, 1450, 1433, 1417, 1401, 1385, 1369, 1353, 1338, 1322,
+ 1307, 1292, 1277, 1263, 1248, 1234, 1220, 1206, 1192, 1178,
+ 1165, 1152, 1138, 1125, 1112, 1100, 1087, 1075, 1062, 1050,
+ 1038, 1026, 1015, 1003, 991, 980, 969, 958, 947, 936,
+ 925, 915, 904, 894, 884, 873, 863, 854, 844, 834,
+ 825, 815, 806, 797, 787, 778, 769, 761, 752, 743,
+ 735, 726, 718, 710, 702, 694, 686, 678, 670, 662,
+ 655, 647, 640, 633, 625, 618, 611, 604, 597, 590,
+ 584, 577, 570, 564, 557, 551, 545, 538, 532, 526,
+ 520, 514, 508, 502, 497, 491, 485, 480, 474, 469,
+ 463, 458, 453, 448, 443, 438, 432, 428, 423, 418,
+ 413, 408, 404, 399, 394, 390, 385, 381, 377, 372,
+ 368, 364, 360, 356, 351, 347, 343, 340, 336, 332,
+ 328, 324, 320, 317, 313, 310, 306, 303, 299, 296,
+ 292, 289, 286, 282, 279, 276, 273, 270, 266, 263,
+ 260, 257, 254, 252, 249, 246, 243, 240, 237, 235,
+ 232, 229, 227, 224, 222, 219, 217, 214, 212, 209,
+ 207, 204, 202, 200, 197, 195, 193, 191, 189, 186,
+ 184, 182, 180, 178, 176, 174, 172, 170, 168, 166,
+ 164, 162, 160, 159, 157, 155, 153, 151, 150, 148,
+ 146, 145, 143, 141, 140, 138, 136, 135, 133, 132,
+ 130, 129, 127, 126, 124, 123, 122, 120, 119, 117,
+ 116, 115, 113, 112, 111, 110, 108, 107, 106, 105,
+ 103, 102, 101, 100, 99, 98, 96, 95, 94, 93,
+ 92, 91, 90, 89, 88, 87, 86, 85, 84, 83,
+ 82, 81, 80, 79, 78, 77, 76, 76, 75, 74,
+ 73, 72, 71, 71, 70, 69, 68, 67, 67, 66,
+ 65, 64, 64, 63, 62, 61, 61, 60, 59, 59,
+ 58, 57, 57, 56, 55, 55, 54, 53, 53, 52,
+ 52, 51, 50, 50, 49, 49, 48, 48, 47, 46,
+ 46, 45, 45, 44, 44, 43, 43, 42, 42, 41,
+ 41, 40, 40, 39, 39, 39, 38, 38, 37, 37,
+ 36, 36, 36, 35, 35, 34, 34, 34, 33, 33,
+ 32, 32, 32, 31, 31, 31, 30, 30, 29, 29,
+ 29, 28, 28, 28, 27, 27, 27, 27, 26, 26,
+ 26, 25, 25, 25, 24, 24, 24, 24, 23, 23,
+ 23, 22, 22, 22, 22, 21, 21, 21, 21, 20,
+ 20, 20, 20, 20, 19, 19, 19, 19, 18, 18,
+ 18, 18, 18, 17, 17, 17, 17, 17, 16, 16,
+ 16, 16, 16, 15, 15, 15, 15, 15, 15, 14,
+ 14, 14, 14, 14, 14, 13, 13, 13, 13, 13,
+ 13, 12, 12, 12, 12, 12, 12, 12, 11, 11,
+ 11, 11, 11, 11, 11, 11, 10, 10, 10, 10,
+ 10, 10, 10, 10, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 5, 5,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1,
+};
+
+LONG WINAPI AmpFactorToDB(LONG ampfactor)
+{
+ int step = (sizeof(table) / sizeof(table[0])) / 2;
+ int i = step;
+ TRACE("(%d)\n", ampfactor);
+
+ if (ampfactor < 0 || ampfactor > 65535)
+ return 0;
+
+ if (ampfactor == 0)
+ return -9640;
+
+ /* There are multiple entries with the same value and we want to find */
+ /* the highest index so do a binary search and then a linear search. */
+ while (i > 0 && i < 963)
+ {
+ if (ampfactor <= table[i] && ampfactor > table[i + 1])
+ return i * -10;
+
+ step /= 2;
+ if (step == 0) /* start linear search */
+ step = 1;
+
+ if (ampfactor > table[i])
+ i -= step;
+ else
+ i += step;
+ }
+
+ return i * -10;
+}
+
+LONG WINAPI DBToAmpFactor(LONG db)
+{
+ TRACE("(%d)\n", db);
+
+ if (db > 0)
+ return 65535;
+
+ if (db <= -9635)
+ return 0;
+
+ return table[-(db - 5) / 10];
+}
+
diff -puN wine.cvs/dlls/quartz/main.c wine/dlls/quartz/main.c
--- wine.cvs/dlls/quartz/main.c 2006-12-30 03:10:54.000000000 -0500
+++ wine/dlls/quartz/main.c 2006-12-30 03:14:20.000000000 -0500
@@ -254,21 +254,6 @@ const char * qzdebugstr_State(FILTER_STA
}
}
-LONG WINAPI AmpFactorToDB(LONG ampfactor)
-{
- FIXME("(%d) Stub!\n", ampfactor);
- return 0;
-}
-
-LONG WINAPI DBToAmpFactor(LONG db)
-{
- FIXME("(%d) Stub!\n", db);
- /* Avoid divide by zero (probably during range computation) in Windows Media Player 6.4 */
- if (db < -1000)
- return 0;
- return 100;
-}
-
/***********************************************************************
* AMGetErrorTextA (QUARTZ.@)
*/
--- wine.cvs/dlls/quartz/Makefile.in 2006-12-30 03:10:54.000000000 -0500
+++ wine/dlls/quartz/Makefile.in 2006-12-30 02:31:34.000000000 -0500
@@ -12,6 +12,7 @@ C_SRCS = \
avidec.c \
avisplit.c \
control.c \
+ db.c \
dsoundrender.c \
enumfilters.c \
enummedia.c \
More information about the wine-patches
mailing list