Index: libavformat/nsf_data.h =================================================================== --- libavformat/nsf_data.h (リビジョン 0) +++ libavformat/nsf_data.h (リビジョン 0) @@ -0,0 +1,4672 @@ +/* + * NSF(NES Sound Format) demuxer + * Copyright (c) 2001-2002 Mitsutaka Okazaki + * Copyright (c) 2004 Xodnizel + * Copyright (c) 2007 Nazo + * + * This file is part of FFmpeg. + * + * FFmpeg is av_free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the av_free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg 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 FFmpeg; if not, write to the av_free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#define NCOEFFS 484 +#define SQ2NCOEFFS 1024 + +static int32_t SQ2C44100NTSC[SQ2NCOEFFS/2]={ +116, +9, +9, +10, +10, +10, +10, +10, +10, +10, +10, +9, +9, +8, +8, +7, +6, +5, +4, +3, +2, +1, +0, +-1, +-2, +-4, +-5, +-7, +-9, +-10, +-12, +-14, +-16, +-18, +-20, +-22, +-24, +-25, +-27, +-29, +-31, +-33, +-34, +-36, +-37, +-39, +-40, +-41, +-42, +-43, +-44, +-44, +-44, +-45, +-45, +-44, +-44, +-43, +-42, +-41, +-40, +-39, +-37, +-35, +-33, +-30, +-28, +-25, +-22, +-18, +-15, +-11, +-7, +-3, +0, +4, +9, +13, +18, +22, +27, +32, +36, +41, +46, +50, +55, +59, +64, +68, +72, +76, +79, +82, +85, +88, +91, +93, +94, +96, +97, +97, +97, +97, +96, +95, +93, +91, +88, +85, +81, +77, +73, +68, +62, +56, +50, +43, +36, +28, +20, +12, +4, +-4, +-13, +-22, +-32, +-41, +-51, +-60, +-70, +-79, +-89, +-98, +-107, +-116, +-125, +-133, +-141, +-148, +-155, +-162, +-168, +-173, +-178, +-182, +-186, +-188, +-190, +-192, +-192, +-191, +-190, +-188, +-185, +-181, +-176, +-170, +-163, +-156, +-147, +-138, +-128, +-117, +-105, +-93, +-79, +-66, +-51, +-36, +-20, +-4, +11, +28, +45, +63, +80, +98, +115, +133, +150, +167, +183, +200, +215, +231, +245, +259, +272, +284, +295, +305, +314, +322, +328, +334, +338, +340, +341, +341, +339, +336, +331, +324, +316, +307, +296, +283, +269, +253, +236, +218, +198, +176, +154, +131, +106, +80, +54, +26, +-1, +-29, +-58, +-88, +-117, +-147, +-177, +-207, +-236, +-265, +-294, +-321, +-348, +-374, +-399, +-423, +-445, +-466, +-486, +-503, +-519, +-533, +-545, +-554, +-562, +-567, +-570, +-570, +-568, +-564, +-557, +-547, +-535, +-520, +-503, +-483, +-461, +-436, +-409, +-379, +-347, +-314, +-278, +-240, +-200, +-159, +-117, +-72, +-27, +18, +65, +113, +161, +210, +258, +306, +354, +402, +448, +494, +538, +581, +622, +661, +698, +733, +765, +795, +822, +846, +866, +883, +897, +907, +914, +916, +915, +910, +901, +887, +870, +848, +823, +793, +759, +722, +680, +635, +587, +534, +479, +420, +359, +295, +228, +159, +88, +15, +-58, +-134, +-210, +-287, +-364, +-441, +-518, +-593, +-668, +-741, +-813, +-882, +-949, +-1013, +-1074, +-1131, +-1185, +-1235, +-1280, +-1321, +-1357, +-1387, +-1412, +-1432, +-1446, +-1454, +-1456, +-1451, +-1440, +-1423, +-1400, +-1370, +-1333, +-1290, +-1241, +-1185, +-1123, +-1055, +-981, +-901, +-816, +-726, +-631, +-531, +-427, +-319, +-208, +-93, +24, +143, +265, +388, +511, +635, +759, +882, +1004, +1124, +1242, +1357, +1468, +1575, +1678, +1776, +1868, +1955, +2034, +2107, +2172, +2229, +2278, +2318, +2349, +2370, +2382, +2384, +2376, +2357, +2327, +2287, +2237, +2175, +2103, +2020, +1926, +1822, +1708, +1583, +1449, +1306, +1153, +992, +822, +645, +461, +270, +74, +-127, +-333, +-543, +-757, +-972, +-1189, +-1406, +-1623, +-1839, +-2052, +-2263, +-2469, +-2670, +-2866, +-3055, +-3235, +-3407, +-3569, +-3721, +-3861, +-3988, +-4102, +-4201, +-4286, +-4355, +-4407, +-4441, +-4458, +-4456, +-4434, +-4393, +-4331, +-4249, +-4145, +-4020, +-3873, +-3704, +-3512, +-3299, +-3063, +-2806, +-2526, +-2224, +-1900, +-1556, +-1190, +-804, +-398, +27, +471, +933, +1412, +1908, +2419, +2945, +3484, +4036, +4599, +5172, +5754, +6344, +6940, +7541, +8146, +8754, +9363, +9971, +10578, +11182, +11781, +12374, +12959, +13536, +14103, +14658, +15199, +15727, +16239, +16734, +17211, +17669, +18106, +18521, +18914, +19283, +19627, +19946, +20239, +20505, +20743, +20952, +21133, +21284, +21405, +21497, +21558, +21588, +}; + +static int32_t SQ2C48000NTSC[SQ2NCOEFFS/2]= +{ +-115, +-12, +-13, +-14, +-14, +-14, +-15, +-15, +-15, +-15, +-15, +-15, +-15, +-15, +-14, +-14, +-13, +-12, +-11, +-10, +-9, +-8, +-7, +-5, +-3, +-2, +0, +1, +3, +5, +7, +10, +12, +14, +17, +19, +22, +24, +26, +29, +31, +33, +35, +37, +39, +41, +42, +44, +45, +46, +47, +48, +48, +48, +48, +48, +47, +47, +45, +44, +42, +40, +38, +35, +33, +30, +26, +23, +19, +15, +10, +6, +1, +-3, +-8, +-13, +-18, +-23, +-28, +-33, +-39, +-44, +-49, +-54, +-59, +-63, +-68, +-72, +-76, +-80, +-83, +-86, +-88, +-91, +-92, +-94, +-94, +-95, +-94, +-93, +-92, +-90, +-88, +-85, +-81, +-77, +-73, +-67, +-62, +-55, +-49, +-42, +-34, +-26, +-18, +-9, +0, +9, +18, +28, +38, +48, +57, +67, +77, +87, +96, +106, +114, +123, +131, +139, +146, +152, +158, +163, +168, +171, +174, +176, +177, +177, +177, +175, +172, +168, +164, +158, +151, +143, +135, +125, +115, +103, +91, +78, +65, +50, +35, +20, +3, +-12, +-29, +-46, +-63, +-80, +-98, +-115, +-132, +-148, +-165, +-180, +-196, +-210, +-224, +-237, +-248, +-259, +-269, +-277, +-285, +-290, +-295, +-298, +-299, +-299, +-297, +-294, +-289, +-282, +-274, +-264, +-252, +-239, +-224, +-208, +-190, +-171, +-151, +-129, +-106, +-82, +-57, +-31, +-5, +22, +49, +77, +105, +134, +162, +190, +217, +244, +270, +295, +320, +343, +365, +385, +404, +421, +436, +449, +460, +469, +475, +479, +481, +480, +477, +471, +462, +451, +437, +421, +402, +380, +357, +330, +302, +271, +238, +203, +167, +129, +89, +48, +6, +-35, +-79, +-123, +-167, +-211, +-255, +-298, +-341, +-383, +-423, +-462, +-500, +-535, +-569, +-600, +-628, +-654, +-677, +-697, +-713, +-726, +-735, +-741, +-743, +-741, +-735, +-725, +-711, +-693, +-671, +-645, +-616, +-582, +-545, +-504, +-459, +-412, +-361, +-307, +-251, +-192, +-132, +-69, +-5, +60, +126, +193, +260, +328, +394, +460, +525, +588, +650, +709, +765, +819, +869, +916, +958, +997, +1031, +1060, +1084, +1103, +1116, +1124, +1126, +1123, +1113, +1097, +1075, +1047, +1013, +973, +928, +876, +819, +756, +689, +616, +539, +457, +372, +283, +190, +95, +-1, +-100, +-201, +-302, +-404, +-506, +-607, +-706, +-804, +-900, +-993, +-1082, +-1167, +-1248, +-1324, +-1395, +-1459, +-1517, +-1569, +-1613, +-1649, +-1678, +-1698, +-1710, +-1713, +-1707, +-1692, +-1667, +-1634, +-1591, +-1539, +-1478, +-1408, +-1329, +-1242, +-1146, +-1043, +-931, +-813, +-688, +-556, +-419, +-277, +-131, +19, +172, +328, +485, +643, +801, +958, +1113, +1266, +1416, +1561, +1702, +1836, +1964, +2085, +2197, +2300, +2393, +2476, +2548, +2608, +2656, +2690, +2712, +2720, +2713, +2692, +2657, +2607, +2542, +2462, +2367, +2257, +2133, +1994, +1842, +1676, +1497, +1305, +1102, +888, +663, +430, +187, +-61, +-317, +-579, +-844, +-1113, +-1383, +-1653, +-1922, +-2189, +-2452, +-2709, +-2960, +-3203, +-3437, +-3659, +-3869, +-4065, +-4245, +-4409, +-4556, +-4682, +-4789, +-4873, +-4935, +-4973, +-4986, +-4972, +-4933, +-4865, +-4770, +-4646, +-4492, +-4309, +-4096, +-3853, +-3579, +-3276, +-2942, +-2578, +-2185, +-1763, +-1313, +-835, +-330, +200, +755, +1335, +1937, +2560, +3203, +3864, +4543, +5236, +5942, +6660, +7387, +8122, +8863, +9608, +10354, +11099, +11842, +12580, +13311, +14033, +14745, +15443, +16125, +16791, +17436, +18061, +18663, +19239, +19789, +20310, +20801, +21261, +21687, +22079, +22435, +22755, +23037, +23281, +23485, +23649, +23772, +23854, +23896, +}; + +static int32_t SQ2C96000NTSC[SQ2NCOEFFS/2]= +{ +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +0, +0, +0, +0, +0, +0, +-1, +-1, +-2, +-2, +-2, +-3, +-3, +-3, +-3, +-3, +-3, +-3, +-3, +-3, +-2, +-2, +-1, +-1, +0, +0, +1, +2, +3, +4, +4, +5, +6, +6, +7, +7, +7, +7, +7, +7, +6, +6, +5, +4, +2, +1, +0, +-1, +-3, +-5, +-6, +-8, +-10, +-11, +-12, +-13, +-14, +-14, +-14, +-14, +-14, +-13, +-11, +-10, +-8, +-6, +-3, +0, +1, +4, +7, +10, +13, +16, +18, +21, +22, +24, +25, +25, +25, +24, +23, +21, +18, +15, +12, +8, +3, +-1, +-6, +-11, +-16, +-20, +-25, +-29, +-33, +-36, +-39, +-41, +-42, +-42, +-41, +-39, +-36, +-32, +-27, +-22, +-15, +-8, +-1, +6, +14, +22, +30, +37, +44, +51, +56, +60, +64, +65, +66, +65, +62, +58, +53, +46, +38, +28, +18, +6, +-4, +-17, +-29, +-41, +-53, +-64, +-74, +-83, +-90, +-95, +-99, +-100, +-100, +-97, +-91, +-84, +-74, +-62, +-49, +-33, +-17, +0, +18, +36, +55, +72, +89, +104, +118, +129, +138, +144, +148, +148, +144, +138, +128, +114, +98, +79, +58, +34, +9, +-16, +-42, +-69, +-95, +-120, +-143, +-163, +-181, +-195, +-205, +-211, +-212, +-209, +-201, +-188, +-171, +-149, +-124, +-94, +-62, +-27, +8, +46, +84, +121, +156, +189, +219, +245, +267, +283, +294, +298, +295, +287, +271, +249, +221, +187, +148, +104, +57, +7, +-44, +-96, +-148, +-198, +-245, +-288, +-326, +-358, +-382, +-400, +-408, +-408, +-399, +-381, +-354, +-318, +-274, +-223, +-165, +-102, +-35, +34, +105, +175, +244, +309, +370, +424, +470, +507, +533, +549, +553, +545, +524, +492, +447, +392, +326, +252, +169, +81, +-10, +-105, +-200, +-293, +-383, +-466, +-541, +-606, +-660, +-700, +-726, +-737, +-732, +-710, +-672, +-619, +-550, +-467, +-372, +-266, +-152, +-31, +93, +219, +344, +464, +577, +680, +771, +847, +907, +948, +970, +970, +949, +907, +843, +760, +657, +537, +403, +256, +99, +-62, +-228, +-392, +-552, +-704, +-845, +-970, +-1077, +-1164, +-1226, +-1264, +-1274, +-1257, +-1211, +-1138, +-1038, +-912, +-763, +-593, +-407, +-206, +3, +219, +435, +647, +851, +1040, +1212, +1361, +1484, +1578, +1639, +1666, +1656, +1610, +1528, +1409, +1257, +1073, +860, +623, +367, +95, +-184, +-468, +-749, +-1020, +-1277, +-1512, +-1719, +-1894, +-2033, +-2130, +-2182, +-2188, +-2146, +-2056, +-1918, +-1734, +-1507, +-1240, +-939, +-610, +-257, +109, +484, +859, +1225, +1574, +1898, +2190, +2441, +2646, +2798, +2893, +2926, +2897, +2802, +2643, +2421, +2140, +1803, +1416, +986, +522, +32, +-472, +-983, +-1487, +-1974, +-2433, +-2853, +-3223, +-3534, +-3777, +-3944, +-4030, +-4029, +-3940, +-3760, +-3492, +-3137, +-2701, +-2189, +-1611, +-977, +-298, +411, +1139, +1868, +2584, +3270, +3910, +4489, +4991, +5404, +5713, +5909, +5982, +5926, +5735, +5409, +4948, +4356, +3639, +2808, +1873, +851, +-241, +-1385, +-2559, +-3738, +-4899, +-6016, +-7064, +-8015, +-8845, +-9529, +-10043, +-10366, +-10479, +-10363, +-10006, +-9397, +-8529, +-7398, +-6005, +-4355, +-2456, +-320, +2033, +4587, +7316, +10193, +13188, +16268, +19400, +22548, +25673, +28740, +31710, +34547, +37216, +39683, +41916, +43887, +45570, +46943, +47990, +48695, +49050, +}; + +static int32_t SQ2C44100PAL[SQ2NCOEFFS/2]= +{ +-116, +-8, +-8, +-8, +-8, +-8, +-8, +-8, +-8, +-7, +-7, +-6, +-5, +-5, +-4, +-3, +-2, +-1, +0, +1, +2, +4, +5, +7, +9, +10, +12, +14, +16, +18, +19, +21, +23, +25, +27, +28, +30, +32, +33, +34, +36, +37, +38, +38, +39, +40, +40, +40, +40, +39, +39, +38, +37, +36, +34, +33, +31, +29, +26, +24, +21, +18, +14, +11, +7, +4, +0, +-3, +-8, +-12, +-16, +-21, +-25, +-29, +-34, +-38, +-43, +-47, +-51, +-55, +-59, +-62, +-66, +-69, +-72, +-75, +-77, +-79, +-80, +-81, +-82, +-83, +-83, +-82, +-81, +-80, +-78, +-75, +-72, +-69, +-65, +-61, +-56, +-51, +-45, +-39, +-33, +-26, +-19, +-11, +-4, +3, +12, +20, +29, +37, +46, +55, +64, +72, +81, +89, +97, +105, +112, +119, +126, +132, +138, +143, +147, +151, +154, +156, +158, +159, +159, +158, +157, +154, +151, +146, +141, +135, +128, +121, +112, +103, +93, +82, +70, +58, +45, +31, +17, +3, +-11, +-26, +-41, +-57, +-72, +-88, +-104, +-119, +-134, +-149, +-163, +-177, +-191, +-203, +-215, +-226, +-236, +-246, +-254, +-261, +-267, +-271, +-274, +-276, +-277, +-276, +-274, +-270, +-264, +-258, +-249, +-240, +-228, +-216, +-201, +-186, +-169, +-151, +-132, +-111, +-90, +-68, +-44, +-20, +3, +28, +54, +80, +106, +132, +158, +184, +209, +234, +258, +281, +304, +325, +345, +364, +381, +397, +411, +423, +433, +441, +447, +451, +453, +452, +449, +444, +436, +426, +413, +399, +381, +362, +340, +316, +289, +261, +231, +199, +165, +130, +93, +55, +16, +-23, +-63, +-104, +-145, +-187, +-228, +-269, +-310, +-349, +-388, +-425, +-461, +-495, +-528, +-558, +-586, +-612, +-635, +-655, +-673, +-687, +-698, +-705, +-709, +-710, +-707, +-700, +-690, +-675, +-657, +-636, +-610, +-581, +-549, +-513, +-473, +-431, +-385, +-336, +-285, +-232, +-176, +-118, +-59, +1, +64, +127, +190, +254, +318, +381, +444, +505, +566, +624, +680, +734, +786, +834, +879, +920, +957, +990, +1019, +1043, +1062, +1076, +1085, +1088, +1086, +1079, +1065, +1046, +1022, +991, +955, +913, +866, +814, +756, +693, +626, +554, +478, +398, +314, +228, +138, +46, +-47, +-143, +-240, +-337, +-435, +-532, +-628, +-723, +-817, +-907, +-995, +-1080, +-1161, +-1237, +-1309, +-1375, +-1436, +-1490, +-1538, +-1579, +-1612, +-1639, +-1657, +-1667, +-1669, +-1662, +-1647, +-1623, +-1590, +-1548, +-1498, +-1439, +-1372, +-1296, +-1212, +-1120, +-1020, +-913, +-800, +-680, +-553, +-422, +-286, +-145, +0, +146, +296, +447, +599, +752, +904, +1054, +1203, +1348, +1490, +1627, +1759, +1885, +2004, +2115, +2218, +2312, +2396, +2470, +2533, +2584, +2623, +2650, +2664, +2665, +2652, +2625, +2584, +2529, +2460, +2376, +2278, +2167, +2041, +1902, +1750, +1585, +1407, +1218, +1018, +808, +588, +359, +123, +-120, +-369, +-623, +-881, +-1142, +-1403, +-1665, +-1926, +-2184, +-2439, +-2688, +-2931, +-3166, +-3392, +-3607, +-3810, +-4000, +-4176, +-4335, +-4478, +-4602, +-4706, +-4790, +-4852, +-4891, +-4906, +-4897, +-4862, +-4801, +-4713, +-4598, +-4454, +-4283, +-4082, +-3853, +-3595, +-3308, +-2992, +-2647, +-2274, +-1873, +-1445, +-990, +-509, +-3, +527, +1081, +1657, +2254, +2870, +3505, +4156, +4823, +5504, +6196, +6898, +7609, +8326, +9048, +9773, +10498, +11222, +11943, +12658, +13366, +14065, +14753, +15427, +16086, +16728, +17351, +17953, +18533, +19088, +19616, +20118, +20590, +21032, +21441, +21818, +22160, +22467, +22738, +22971, +23167, +23324, +23443, +23522, +23561, +}; + +static int32_t SQ2C48000PAL[SQ2NCOEFFS/2]= +{ +113, +14, +15, +15, +16, +16, +17, +17, +18, +18, +18, +18, +18, +17, +17, +16, +16, +15, +14, +12, +11, +10, +8, +6, +4, +2, +0, +-1, +-3, +-6, +-8, +-11, +-13, +-16, +-18, +-21, +-24, +-26, +-29, +-31, +-33, +-35, +-37, +-39, +-41, +-42, +-44, +-45, +-46, +-46, +-47, +-47, +-46, +-46, +-45, +-44, +-42, +-40, +-38, +-36, +-33, +-30, +-26, +-23, +-19, +-15, +-10, +-6, +-1, +3, +8, +13, +19, +24, +29, +35, +40, +45, +50, +55, +60, +64, +68, +72, +75, +79, +81, +83, +85, +86, +87, +87, +87, +86, +84, +82, +79, +76, +72, +67, +62, +56, +50, +43, +36, +28, +20, +11, +2, +-6, +-15, +-25, +-34, +-44, +-54, +-63, +-73, +-82, +-91, +-100, +-109, +-117, +-124, +-131, +-137, +-142, +-147, +-151, +-154, +-156, +-158, +-158, +-157, +-156, +-153, +-149, +-145, +-139, +-132, +-124, +-115, +-105, +-95, +-83, +-71, +-58, +-44, +-29, +-14, +0, +16, +32, +48, +65, +81, +98, +114, +129, +145, +159, +174, +187, +199, +211, +221, +231, +239, +246, +251, +255, +257, +258, +257, +255, +251, +245, +237, +228, +217, +205, +191, +175, +158, +140, +120, +99, +77, +54, +30, +6, +-19, +-44, +-70, +-96, +-123, +-148, +-174, +-199, +-223, +-247, +-269, +-291, +-311, +-329, +-346, +-361, +-374, +-385, +-393, +-400, +-404, +-406, +-405, +-401, +-395, +-387, +-376, +-362, +-346, +-327, +-306, +-282, +-256, +-228, +-198, +-166, +-133, +-98, +-61, +-23, +14, +53, +93, +133, +173, +212, +251, +290, +327, +363, +397, +430, +461, +489, +515, +538, +558, +575, +589, +600, +607, +610, +609, +605, +597, +585, +569, +549, +526, +498, +467, +432, +395, +353, +309, +262, +213, +161, +107, +51, +-5, +-63, +-122, +-181, +-240, +-299, +-357, +-414, +-469, +-523, +-575, +-623, +-669, +-712, +-751, +-786, +-817, +-843, +-865, +-881, +-893, +-899, +-899, +-894, +-884, +-867, +-845, +-817, +-784, +-745, +-701, +-651, +-597, +-537, +-474, +-406, +-334, +-259, +-181, +-100, +-17, +67, +152, +239, +325, +412, +497, +581, +663, +742, +818, +890, +959, +1022, +1081, +1133, +1180, +1220, +1254, +1280, +1299, +1310, +1313, +1308, +1295, +1273, +1243, +1205, +1159, +1104, +1042, +972, +894, +809, +718, +621, +517, +409, +296, +179, +58, +-64, +-190, +-316, +-443, +-570, +-696, +-820, +-941, +-1059, +-1173, +-1281, +-1384, +-1480, +-1569, +-1649, +-1722, +-1785, +-1838, +-1881, +-1912, +-1933, +-1942, +-1939, +-1924, +-1897, +-1858, +-1806, +-1741, +-1665, +-1576, +-1476, +-1365, +-1243, +-1110, +-968, +-816, +-657, +-490, +-316, +-136, +47, +235, +426, +619, +811, +1003, +1193, +1380, +1563, +1740, +1910, +2072, +2225, +2368, +2499, +2618, +2723, +2814, +2889, +2949, +2991, +3016, +3022, +3010, +2979, +2929, +2859, +2769, +2660, +2531, +2384, +2217, +2032, +1830, +1611, +1376, +1126, +862, +585, +297, +0, +-307, +-621, +-940, +-1262, +-1586, +-1910, +-2232, +-2550, +-2862, +-3165, +-3459, +-3740, +-4007, +-4258, +-4491, +-4703, +-4893, +-5059, +-5200, +-5313, +-5396, +-5449, +-5470, +-5457, +-5409, +-5326, +-5206, +-5048, +-4853, +-4618, +-4345, +-4032, +-3681, +-3290, +-2861, +-2393, +-1888, +-1347, +-769, +-158, +486, +1162, +1868, +2602, +3362, +4146, +4952, +5777, +6619, +7475, +8342, +9219, +10102, +10988, +11874, +12757, +13635, +14504, +15361, +16204, +17029, +17833, +18615, +19370, +20096, +20790, +21451, +22075, +22660, +23205, +23707, +24164, +24574, +24937, +25250, +25513, +25725, +25884, +25991, +26044, +}; + +static int32_t SQ2C96000PAL[SQ2NCOEFFS/2]= +{ +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +-1, +-1, +-1, +-1, +-1, +0, +0, +0, +0, +0, +0, +0, +0, +0, +1, +1, +1, +1, +2, +2, +2, +2, +2, +2, +2, +2, +2, +1, +1, +0, +0, +0, +0, +-1, +-1, +-2, +-3, +-3, +-4, +-4, +-5, +-5, +-5, +-5, +-5, +-5, +-4, +-4, +-3, +-2, +-1, +0, +0, +1, +2, +4, +5, +6, +7, +8, +9, +10, +10, +10, +10, +10, +9, +8, +7, +6, +4, +2, +0, +-1, +-4, +-6, +-8, +-11, +-13, +-15, +-16, +-18, +-19, +-19, +-19, +-19, +-18, +-17, +-15, +-13, +-10, +-6, +-3, +0, +4, +8, +12, +17, +20, +24, +27, +30, +32, +33, +34, +34, +33, +31, +28, +25, +20, +15, +9, +3, +-3, +-10, +-17, +-24, +-31, +-37, +-43, +-48, +-52, +-55, +-57, +-57, +-56, +-54, +-50, +-45, +-38, +-30, +-21, +-11, +0, +10, +21, +33, +44, +55, +64, +73, +80, +86, +90, +92, +91, +88, +84, +76, +67, +56, +42, +27, +11, +-5, +-23, +-41, +-59, +-76, +-92, +-106, +-119, +-129, +-136, +-141, +-142, +-140, +-134, +-125, +-112, +-96, +-77, +-56, +-32, +-6, +19, +47, +74, +100, +125, +149, +169, +186, +199, +208, +213, +212, +206, +195, +179, +158, +132, +102, +68, +32, +-6, +-46, +-86, +-126, +-164, +-200, +-232, +-259, +-282, +-298, +-308, +-311, +-307, +-294, +-275, +-248, +-214, +-173, +-128, +-77, +-23, +33, +91, +149, +205, +258, +307, +350, +386, +415, +434, +443, +442, +431, +408, +375, +332, +280, +219, +151, +76, +-1, +-82, +-164, +-245, +-322, +-394, +-459, +-515, +-561, +-595, +-615, +-622, +-613, +-590, +-552, +-499, +-433, +-354, +-264, +-165, +-59, +51, +164, +277, +387, +490, +586, +670, +741, +797, +835, +854, +853, +832, +790, +729, +647, +548, +433, +304, +163, +15, +-138, +-293, +-445, +-592, +-729, +-852, +-959, +-1046, +-1111, +-1151, +-1165, +-1151, +-1110, +-1040, +-944, +-822, +-677, +-512, +-329, +-133, +71, +280, +489, +693, +886, +1063, +1220, +1353, +1458, +1530, +1569, +1571, +1535, +1462, +1352, +1206, +1027, +818, +584, +328, +57, +-222, +-505, +-785, +-1054, +-1306, +-1534, +-1733, +-1896, +-2019, +-2097, +-2128, +-2108, +-2038, +-1917, +-1747, +-1529, +-1269, +-970, +-639, +-283, +90, +474, +857, +1233, +1590, +1921, +2216, +2467, +2667, +2810, +2890, +2904, +2849, +2724, +2530, +2270, +1946, +1566, +1135, +664, +160, +-363, +-895, +-1425, +-1938, +-2423, +-2866, +-3256, +-3582, +-3834, +-4003, +-4082, +-4067, +-3953, +-3741, +-3431, +-3028, +-2537, +-1967, +-1328, +-632, +106, +871, +1646, +2413, +3154, +3849, +4482, +5034, +5489, +5833, +6051, +6134, +6074, +5864, +5504, +4994, +4339, +3546, +2628, +1599, +477, +-716, +-1958, +-3223, +-4482, +-5708, +-6869, +-7936, +-8878, +-9666, +-10273, +-10671, +-10839, +-10755, +-10402, +-9767, +-8843, +-7623, +-6110, +-4308, +-2228, +114, +2701, +5505, +8499, +11650, +14923, +18277, +21673, +25068, +28417, +31678, +34807, +37762, +40502, +42991, +45192, +47076, +48617, +49792, +50584, +50983, +}; + +/* 96000hz filter could probably be improved. */ + +/* +Parks-McClellan FIR Filter Design + +Filter type: Low pass +Passband: 0 - 0.016761904 +Order: 483 +Passband ripple: 0.01 dB +Transition band: 0.01005714 +Stopband attenuation: 103.0 dB + +Coefficients: +*/ +static int32_t C96000NTSC[NCOEFFS/2]= +{ +/*0*/ 65536*16* -5.9950991853042605E-6 +/*1*/, 65536*16* -3.0394382502604395E-6 +/*2*/, 65536*16* -3.728403434239284E-6 +/*3*/, 65536*16* -4.460351826790638E-6 +/*4*/, 65536*16* -5.2164320385801135E-6 +/*5*/, 65536*16* -5.9787071016806234E-6 +/*6*/, 65536*16* -6.716463411023574E-6 +/*7*/, 65536*16* -7.408551386580002E-6 +/*8*/, 65536*16* -8.023491429829738E-6 +/*9*/, 65536*16* -8.531232892238868E-6 +/*10*/, 65536*16* -8.878741512154837E-6 +/*11*/, 65536*16* -9.046773382992595E-6 +/*12*/, 65536*16* -8.993971214348702E-6 +/*13*/, 65536*16* -8.66944931521744E-6 +/*14*/, 65536*16* -8.049348524459474E-6 +/*15*/, 65536*16* -7.083238646482467E-6 +/*16*/, 65536*16* -5.746762349938464E-6 +/*17*/, 65536*16* -4.005753681691657E-6 +/*18*/, 65536*16* -1.838018035195733E-6 +/*19*/, 65536*16* 7.763983938828864E-7 +/*20*/, 65536*16* 3.842232025916005E-6 +/*21*/, 65536*16* 7.361161707034959E-6 +/*22*/, 65536*16* 1.1325948767988128E-5 +/*23*/, 65536*16* 1.5711486406341978E-5 +/*24*/, 65536*16* 2.0488201424957098E-5 +/*25*/, 65536*16* 2.5608402660083142E-5 +/*26*/, 65536*16* 3.101231858515874E-5 +/*27*/, 65536*16* 3.6630654060842745E-5 +/*28*/, 65536*16* 4.2375439803123404E-5 +/*29*/, 65536*16* 4.815060832963289E-5 +/*30*/, 65536*16* 5.384626411548906E-5 +/*31*/, 65536*16* 5.934549587237094E-5 +/*32*/, 65536*16* 6.451785679907682E-5 +/*33*/, 65536*16* 6.923065879553487E-5 +/*34*/, 65536*16* 7.334304650233838E-5 +/*35*/, 65536*16* 7.671308820252635E-5 +/*36*/, 65536*16* 7.920112989696133E-5 +/*37*/, 65536*16* 8.066793124218096E-5 +/*38*/, 65536*16* 8.098382483962539E-5 +/*39*/, 65536*16* 8.002921154479775E-5 +/*40*/, 65536*16* 7.769789869215064E-5 +/*41*/, 65536*16* 7.390152475899438E-5 +/*42*/, 65536*16* 6.857231550142758E-5 +/*43*/, 65536*16* 6.16673817460573E-5 +/*44*/, 65536*16* 5.3169767940001464E-5 +/*45*/, 65536*16* 4.309495398773014E-5 +/*46*/, 65536*16* 3.148737405995964E-5 +/*47*/, 65536*16* 1.8428415219696232E-5 +/*48*/, 65536*16* 4.0337781533928895E-6 +/*49*/, 65536*16* -1.154525373085283E-5 +/*50*/, 65536*16* -2.8120750949316567E-5 +/*51*/, 65536*16* -4.5470242422149815E-5 +/*52*/, 65536*16* -6.333736379615692E-5 +/*53*/, 65536*16* -8.143489509942166E-5 +/*54*/, 65536*16* -9.94475640226242E-5 +/*55*/, 65536*16* -1.1703729468742291E-4 +/*56*/, 65536*16* -1.3384679191408508E-4 +/*57*/, 65536*16* -1.4950548598267213E-4 +/*58*/, 65536*16* -1.6363792959068823E-4 +/*59*/, 65536*16* -1.7586732627086947E-4 +/*60*/, 65536*16* -1.858264971517669E-4 +/*61*/, 65536*16* -1.9316312487547242E-4 +/*62*/, 65536*16* -1.975494021862538E-4 +/*63*/, 65536*16* -1.9868977868165154E-4 +/*64*/, 65536*16* -1.963293865814053E-4 +/*65*/, 65536*16* -1.9026146175876417E-4 +/*66*/, 65536*16* -1.803352078962109E-4 +/*67*/, 65536*16* -1.66463443436789E-4 +/*68*/, 65536*16* -1.4862710934868261E-4 +/*69*/, 65536*16* -1.2688200452566298E-4 +/*70*/, 65536*16* -1.0136212853169677E-4 +/*71*/, 65536*16* -7.228199463954364E-5 +/*72*/, 65536*16* -3.9939461621236575E-5 +/*73*/, 65536*16* -4.7134932934724E-6 +/*74*/, 65536*16* 3.2936215273699675E-5 +/*75*/, 65536*16* 7.247384833064696E-5 +/*76*/, 65536*16* 1.1329187082792405E-4 +/*77*/, 65536*16* 1.5471948843725746E-4 +/*78*/, 65536*16* 1.9603027714808286E-4 +/*79*/, 65536*16* 2.364532958813608E-4 +/*80*/, 65536*16* 2.751853212246927E-4 +/*81*/, 65536*16* 3.114033208188799E-4 +/*82*/, 65536*16* 3.442804841775461E-4 +/*83*/, 65536*16* 3.7300098840546946E-4 +/*84*/, 65536*16* 3.967764136715296E-4 +/*85*/, 65536*16* 4.148631617351676E-4 +/*86*/, 65536*16* 4.265789297533608E-4 +/*87*/, 65536*16* 4.3132002526188114E-4 +/*88*/, 65536*16* 4.2857701618443636E-4 +/*89*/, 65536*16* 4.179510914969621E-4 +/*90*/, 65536*16* 3.991670037587729E-4 +/*91*/, 65536*16* 3.720870989970653E-4 +/*92*/, 65536*16* 3.367209236003282E-4 +/*93*/, 65536*16* 2.932338231303312E-4 +/*94*/, 65536*16* 2.419533571940393E-4 +/*95*/, 65536*16* 1.8337169647749448E-4 +/*96*/, 65536*16* 1.1814612711310299E-4 +/*97*/, 65536*16* 4.709567952563025E-5 +/*98*/, 65536*16* -2.880519351052945E-5 +/*99*/, 65536*16* -1.08436462295612E-4 +/*100*/, 65536*16* -1.905455293630124E-4 +/*101*/, 65536*16* -2.7376362665015007E-4 +/*102*/, 65536*16* -3.566259161939277E-4 +/*103*/, 65536*16* -4.375928024937683E-4 +/*104*/, 65536*16* -5.150762555847844E-4 +/*105*/, 65536*16* -5.874662774920191E-4 +/*106*/, 65536*16* -6.531605887419429E-4 +/*107*/, 65536*16* -7.105951946653638E-4 +/*108*/, 65536*16* -7.582757639600853E-4 +/*109*/, 65536*16* -7.948096207059845E-4 +/*110*/, 65536*16* -8.189373133065186E-4 +/*111*/, 65536*16* -8.295634640890689E-4 +/*112*/, 65536*16* -8.257854455404298E-4 +/*113*/, 65536*16* -8.069208861135825E-4 +/*114*/, 65536*16* -7.725316214556066E-4 +/*115*/, 65536*16* -7.224442067331338E-4 +/*116*/, 65536*16* -6.567673177902021E-4 +/*117*/, 65536*16* -5.759031970767677E-4 +/*118*/, 65536*16* -4.8055576975832975E-4 +/*119*/, 65536*16* -3.7173219275304865E-4 +/*120*/, 65536*16* -2.507394811359122E-4 +/*121*/, 65536*16* -1.191747608775131E-4 +/*122*/, 65536*16* 2.1089774143064154E-5 +/*123*/, 65536*16* 1.6792832047168277E-4 +/*124*/, 65536*16* 3.189887341095747E-4 +/*125*/, 65536*16* 4.7172479984555337E-4 +/*126*/, 65536*16* 6.234346495766704E-4 +/*127*/, 65536*16* 7.713029674040095E-4 +/*128*/, 65536*16* 9.124478381058291E-4 +/*129*/, 65536*16* 0.0010439713492973299 +/*130*/, 65536*16* 0.0011630121060354824 +/*131*/, 65536*16* 0.0012668003330792172 +/*132*/, 65536*16* 0.0013527131638668246 +/*133*/, 65536*16* 0.0014183305230994348 +/*134*/, 65536*16* 0.0014614889365474647 +/*135*/, 65536*16* 0.0014803340336415063 +/*136*/, 65536*16* 0.0014733688575452508 +/*137*/, 65536*16* 0.001439498243826639 +/*138*/, 65536*16* 0.0013780680098511918 +/*139*/, 65536*16* 0.0012888970057146566 +/*140*/, 65536*16* 0.0011723026532406624 +/*141*/, 65536*16* 0.0010291180003947405 +/*142*/, 65536*16* 8.607001658653358E-4 +/*143*/, 65536*16* 6.689295599970792E-4 +/*144*/, 65536*16* 4.5619928199453885E-4 +/*145*/, 65536*16* 2.253948582736753E-4 +/*146*/, 65536*16* -2.0136349562764177E-5 +/*147*/, 65536*16* -2.766248035657636E-4 +/*148*/, 65536*16* -5.399290507797791E-4 +/*149*/, 65536*16* -8.055939397996815E-4 +/*150*/, 65536*16* -0.0010689177291287714 +/*151*/, 65536*16* -0.0013250265370767429 +/*152*/, 65536*16* -0.0015689549600474482 +/*153*/, 65536*16* -0.0017957322527663085 +/*154*/, 65536*16* -0.002000472024117418 +/*155*/, 65536*16* -0.0021784645223266222 +/*156*/, 65536*16* -0.0023252695222818146 +/*157*/, 65536*16* -0.0024368087083972345 +/*158*/, 65536*16* -0.002509455241851095 +/*159*/, 65536*16* -0.0025401189567937766 +/*160*/, 65536*16* -0.0025263261450844377 +/*161*/, 65536*16* -0.0024662908754217406 +/*162*/, 65536*16* -0.002358977944127433 +/*163*/, 65536*16* -0.002204154401342649 +/*164*/, 65536*16* -0.002002429343138771 +/*165*/, 65536*16* -0.0017552803385372808 +/*166*/, 65536*16* -0.0014650656045065488 +/*167*/, 65536*16* -0.001135021049166992 +/*168*/, 65536*16* -7.692415547098649E-4 +/*169*/, 65536*16* -3.7264671522013244E-4 +/*170*/, 65536*16* 4.906989195928291E-5 +/*171*/, 65536*16* 4.895067103339711E-4 +/*172*/, 65536*16* 9.416355837269647E-4 +/*173*/, 65536*16* 0.001397897684142057 +/*174*/, 65536*16* 0.0018503121614766558 +/*175*/, 65536*16* 0.002290597319733804 +/*176*/, 65536*16* 0.0027103015920374113 +/*177*/, 65536*16* 0.0031009433327120863 +/*178*/, 65536*16* 0.0034541565687980116 +/*179*/, 65536*16* 0.0037618412630103333 +/*180*/, 65536*16* 0.004016315066649496 +/*181*/, 65536*16* 0.004210464374744574 +/*182*/, 65536*16* 0.004337892288164658 +/*183*/, 65536*16* 0.004393060165490985 +/*184*/, 65536*16* 0.004371421226297046 +/*185*/, 65536*16* 0.004269542847715132 +/*186*/, 65536*16* 0.00408521543517564 +/*187*/, 65536*16* 0.0038175457430583526 +/*188*/, 65536*16* 0.00346703221076496 +/*189*/, 65536*16* 0.0030356209846777236 +/*190*/, 65536*16* 0.002526740400739804 +/*191*/, 65536*16* 0.0019453134428630866 +/*192*/, 65536*16* 0.0012977462825954304 +/*193*/, 65536*16* 5.918933555500828E-4 +/*194*/, 65536*16* -1.6300197379338156E-4 +/*195*/, 65536*16* -9.563908629597664E-4 +/*196*/, 65536*16* -0.0017765255338228524 +/*197*/, 65536*16* -0.0026105886000394158 +/*198*/, 65536*16* -0.003444843158936217 +/*199*/, 65536*16* -0.004264802433556331 +/*200*/, 65536*16* -0.00505541655658742 +/*201*/, 65536*16* -0.005801274223045036 +/*202*/, 65536*16* -0.0064868164183708756 +/*203*/, 65536*16* -0.007096559102022994 +/*204*/, 65536*16* -0.007615322236172286 +/*205*/, 65536*16* -0.008028460796606074 +/*206*/, 65536*16* -0.008322095341268461 +/*207*/, 65536*16* -0.008483337773170242 +/*208*/, 65536*16* -0.008500509194641638 +/*209*/, 65536*16* -0.008363346317351387 +/*210*/, 65536*16* -0.008063192746297233 +/*211*/, 65536*16* -0.007593172286363423 +/*212*/, 65536*16* -0.0069483408893122045 +/*213*/, 65536*16* -0.006125814985695579 +/*214*/, 65536*16* -0.005124873148956596 +/*215*/, 65536*16* -0.003947029569132915 +/*216*/, 65536*16* -0.002596077508306772 +/*217*/, 65536*16* -0.0010781012650798818 +/*218*/, 65536*16* 5.985434770618447E-4 +/*219*/, 65536*16* 0.0024232820773754 +/*220*/, 65536*16* 0.004383405101533075 +/*221*/, 65536*16* 0.006464184070028333 +/*222*/, 65536*16* 0.008649017282842432 +/*223*/, 65536*16* 0.010919604285452066 +/*224*/, 65536*16* 0.013256146772932903 +/*225*/, 65536*16* 0.015637573164024095 +/*226*/, 65536*16* 0.018041784432073237 +/*227*/, 65536*16* 0.020445917198990023 +/*228*/, 65536*16* 0.022826621253151515 +/*229*/, 65536*16* 0.025160347111354456 +/*230*/, 65536*16* 0.02742363969736895 +/*231*/, 65536*16* 0.02959343430076011 +/*232*/, 65536*16* 0.03164735012116834 +/*233*/, 65536*16* 0.03356397767681876 +/*234*/, 65536*16* 0.035323155364389396 +/*235*/, 65536*16* 0.03690623176571385 +/*236*/, 65536*16* 0.03829630932788767 +/*237*/, 65536*16* 0.03947846623700253 +/*238*/, 65536*16* 0.040439953107911 +/*239*/, 65536*16* 0.0411703612762271 +/*240*/, 65536*16* 0.04166176091370756 +/*241*/, 65536*16* 0.041908806136461134 +}; + +/* +Parks-McClellan FIR Filter Design + +Filter type: Low pass +Passband: 0 - 0.01804395 +Order: 483 +Passband ripple: 0.01 dB +Transition band: 0.0108263 +Stopband attenuation: 114.0 dB + +Coefficients: +*/ + +static int32_t C96000PAL[NCOEFFS/2]= +{ +/*0*/ 65536*16* 3.850781559466991E-7 +/*1*/, 65536*16* -1.280019401722687E-6 +/*2*/, 65536*16* -1.3004583488088965E-6 +/*3*/, 65536*16* -1.7523167437749452E-6 +/*4*/, 65536*16* -2.410249470764872E-6 +/*5*/, 65536*16* -3.2346426554155092E-6 +/*6*/, 65536*16* -4.227271662321092E-6 +/*7*/, 65536*16* -5.3971678027414914E-6 +/*8*/, 65536*16* -6.753444785567694E-6 +/*9*/, 65536*16* -8.302128790766257E-6 +/*10*/, 65536*16* -1.0045896006160685E-5 +/*11*/, 65536*16* -1.1982368218542129E-5 +/*12*/, 65536*16* -1.4104296519058353E-5 +/*13*/, 65536*16* -1.6397945806910793E-5 +/*14*/, 65536*16* -1.8843550708827064E-5 +/*15*/, 65536*16* -2.1413952016264175E-5 +/*16*/, 65536*16* -2.407540699773165E-5 +/*17*/, 65536*16* -2.6786418491045868E-5 +/*18*/, 65536*16* -2.949883620881563E-5 +/*19*/, 65536*16* -3.215685693993941E-5 +/*20*/, 65536*16* -3.4698621200866915E-5 +/*21*/, 65536*16* -3.7055635055088747E-5 +/*22*/, 65536*16* -3.915516367387583E-5 +/*23*/, 65536*16* -4.092005046973106E-5 +/*24*/, 65536*16* -4.227173792151256E-5 +/*25*/, 65536*16* -4.313002076491602E-5 +/*26*/, 65536*16* -4.3416606424857764E-5 +/*27*/, 65536*16* -4.3054793786740716E-5 +/*28*/, 65536*16* -4.1974462257106624E-5 +/*29*/, 65536*16* -4.011236719136458E-5 +/*30*/, 65536*16* -3.7415159397597796E-5 +/*31*/, 65536*16* -3.3846213818414235E-5 +/*32*/, 65536*16* -2.9372757531099172E-5 +/*33*/, 65536*16* -2.3989695934591954E-5 +/*34*/, 65536*16* -1.7705989252101064E-5 +/*35*/, 65536*16* -1.0551320217411096E-5 +/*36*/, 65536*16* -2.5775325043216536E-6 +/*37*/, 65536*16* 6.139645766572715E-6 +/*38*/, 65536*16* 1.5501423038008354E-5 +/*39*/, 65536*16* 2.5384753820737575E-5 +/*40*/, 65536*16* 3.5643398684518664E-5 +/*41*/, 65536*16* 4.6108393091574726E-5 +/*42*/, 65536*16* 5.659011526249589E-5 +/*43*/, 65536*16* 6.68803323899828E-5 +/*44*/, 65536*16* 7.675537622878941E-5 +/*45*/, 65536*16* 8.597960059720824E-5 +/*46*/, 65536*16* 9.430960279897814E-5 +/*47*/, 65536*16* 1.0149893801465577E-4 +/*48*/, 65536*16* 1.0730328189856642E-4 +/*49*/, 65536*16* 1.1148622997923174E-4 +/*50*/, 65536*16* 1.1382511217545132E-4 +/*51*/, 65536*16* 1.141174295909343E-4 +/*52*/, 65536*16* 1.1218671460549208E-4 +/*53*/, 65536*16* 1.078890398041802E-4 +/*54*/, 65536*16* 1.0111839925160891E-4 +/*55*/, 65536*16* 9.181292532691402E-5 +/*56*/, 65536*16* 7.995923739813694E-5 +/*57*/, 65536*16* 6.559772591687974E-5 +/*58*/, 65536*16* 4.882471526869663E-5 +/*59*/, 65536*16* 2.9795861807919456E-5 +/*60*/, 65536*16* 8.727003235393024E-6 +/*61*/, 65536*16* -1.4106777294769694E-5 +/*62*/, 65536*16* -3.836880959229582E-5 +/*63*/, 65536*16* -6.366921149307032E-5 +/*64*/, 65536*16* -8.956481187350594E-5 +/*65*/, 65536*16* -1.1556632861786434E-4 +/*66*/, 65536*16* -1.411455941949306E-4 +/*67*/, 65536*16* -1.657445386231986E-4 +/*68*/, 65536*16* -1.8878427001863077E-4 +/*69*/, 65536*16* -2.0967688285495866E-4 +/*70*/, 65536*16* -2.2783715638612827E-4 +/*71*/, 65536*16* -2.4269587549180196E-4 +/*72*/, 65536*16* -2.5371305459897316E-4 +/*73*/, 65536*16* -2.603919787720978E-4 +/*74*/, 65536*16* -2.6229284265917287E-4 +/*75*/, 65536*16* -2.59046413963889E-4 +/*76*/, 65536*16* -2.503668396740634E-4 +/*77*/, 65536*16* -2.3606367328604213E-4 +/*78*/, 65536*16* -2.160524966650091E-4 +/*79*/, 65536*16* -1.903639226156617E-4 +/*80*/, 65536*16* -1.59150691014015E-4 +/*81*/, 65536*16* -1.2269241610349266E-4 +/*82*/, 65536*16* -8.139812226735764E-5 +/*83*/, 65536*16* -3.5805772732231955E-5 +/*84*/, 65536*16* 1.3420603339835859E-5 +/*85*/, 65536*16* 6.549742374431074E-5 +/*86*/, 65536*16* 1.1953033076822495E-4 +/*87*/, 65536*16* 1.745269622757623E-4 +/*88*/, 65536*16* 2.2941123586808386E-4 +/*89*/, 65536*16* 2.830419125977025E-4 +/*90*/, 65536*16* 3.3423267917052983E-4 +/*91*/, 65536*16* 3.81774499172079E-4 +/*92*/, 65536*16* 4.244616654237554E-4 +/*93*/, 65536*16* 4.611154134679936E-4 +/*94*/, 65536*16* 4.906128810250551E-4 +/*95*/, 65536*16* 5.119138315653597E-4 +/*96*/, 65536*16* 5.240878477917174E-4 +/*97*/, 65536*16* 5.263406012974186E-4 +/*98*/, 65536*16* 5.180395272684202E-4 +/*99*/, 65536*16* 4.987363674123535E-4 +/*100*/, 65536*16* 4.681879119879578E-4 +/*101*/, 65536*16* 4.263728836819278E-4 +/*102*/, 65536*16* 3.735054898141368E-4 +/*103*/, 65536*16* 3.1004425441119956E-4 +/*104*/, 65536*16* 2.3669640454159868E-4 +/*105*/, 65536*16* 1.5441686754990788E-4 +/*106*/, 65536*16* 6.440207419421148E-5 +/*107*/, 65536*16* -3.192198333335273E-5 +/*108*/, 65536*16* -1.3291717686663037E-4 +/*109*/, 65536*16* -2.3675627296534203E-4 +/*110*/, 65536*16* -3.414512496033162E-4 +/*111*/, 65536*16* -4.4488659997924806E-4 +/*112*/, 65536*16* -5.44857304239037E-4 +/*113*/, 65536*16* -6.391106241040588E-4 +/*114*/, 65536*16* -7.253914361418537E-4 +/*115*/, 65536*16* -8.0148962040363E-4 +/*116*/, 65536*16* -8.652895191393541E-4 +/*117*/, 65536*16* -9.148193159968953E-4 +/*118*/, 65536*16* -9.483009583169883E-4 +/*119*/, 65536*16* -9.64197392644944E-4 +/*120*/, 65536*16* -9.612579850877552E-4 +/*121*/, 65536*16* -9.385600118624972E-4 +/*122*/, 65536*16* -8.955444281498081E-4 +/*123*/, 65536*16* -8.320477398703453E-4 +/*124*/, 65536*16* -7.483247067952744E-4 +/*125*/, 65536*16* -6.450648142040654E-4 +/*126*/, 65536*16* -5.234000259248345E-4 +/*127*/, 65536*16* -3.8490357943433983E-4 +/*128*/, 65536*16* -2.3157879639504726E-4 +/*129*/, 65536*16* -6.583909529283622E-5 +/*130*/, 65536*16* 1.0952239530879758E-4 +/*131*/, 65536*16* 2.9137227027685464E-4 +/*132*/, 65536*16* 4.76285797012954E-4 +/*133*/, 65536*16* 6.606041066674581E-4 +/*134*/, 65536*16* 8.404993785845289E-4 +/*135*/, 65536*16* 0.0010120465600366754 +/*136*/, 65536*16* 0.00117130077980147 +/*137*/, 65536*16* 0.0013143787565297594 +/*138*/, 65536*16* 0.0014375429397231808 +/*139*/, 65536*16* 0.0015372865339524395 +/*140*/, 65536*16* 0.0016104178085955662 +/*141*/, 65536*16* 0.0016541417860661317 +/*142*/, 65536*16* 0.0016661374441763997 +/*143*/, 65536*16* 0.0016446287155235182 +/*144*/, 65536*16* 0.0015884472759871292 +/*145*/, 65536*16* 0.0014970858621845143 +/*146*/, 65536*16* 0.0013707399310406382 +/*147*/, 65536*16* 0.0012103371052757787 +/*148*/, 65536*16* 0.0010175519857289184 +/*149*/, 65536*16* 7.94807053668863E-4 +/*150*/, 65536*16* 5.452573395422002E-4 +/*151*/, 65536*16* 2.727594075846488E-4 +/*152*/, 65536*16* -1.8175144027827955E-5 +/*153*/, 65536*16* -3.2244298920455907E-4 +/*154*/, 65536*16* -6.344261333752713E-4 +/*155*/, 65536*16* -9.480839637356165E-4 +/*156*/, 65536*16* -0.001257058056943197 +/*157*/, 65536*16* -0.001554788246611654 +/*158*/, 65536*16* -0.001834637661184569 +/*159*/, 65536*16* -0.0020900256934556468 +/*160*/, 65536*16* -0.0023145651572872143 +/*161*/, 65536*16* -0.0025022020560114683 +/*162*/, 65536*16* -0.002647354498854991 +/*163*/, 65536*16* -0.002745048447695108 +/*164*/, 65536*16* -0.0027910469441460657 +/*165*/, 65536*16* -0.002781970255972488 +/*166*/, 65536*16* -0.0027154038464012363 +/*167*/, 65536*16* -0.002589991713387623 +/*168*/, 65536*16* -0.0024055123883779776 +/*169*/, 65536*16* -0.0021629354924022053 +/*170*/, 65536*16* -0.0018644567566629092 +/*171*/, 65536*16* -0.0015135100031795994 +/*172*/, 65536*16* -0.0011147548631940517 +/*173*/, 65536*16* -6.740394224166433E-4 +/*174*/, 65536*16* -1.9833762845333352E-4 +/*175*/, 65536*16* 3.043386309556266E-4 +/*176*/, 65536*16* 8.250516255359581E-4 +/*177*/, 65536*16* 0.0013540734762851313 +/*178*/, 65536*16* 0.0018810427835111666 +/*179*/, 65536*16* 0.002395141352428365 +/*180*/, 65536*16* 0.002885286937512414 +/*181*/, 65536*16* 0.0033403397957704442 +/*182*/, 65536*16* 0.003749319662913449 +/*183*/, 65536*16* 0.00410162844368435 +/*184*/, 65536*16* 0.00438727601255591 +/*185*/, 65536*16* 0.004597103692808949 +/*186*/, 65536*16* 0.004723001540295747 +/*187*/, 65536*16* 0.004758115147888017 +/*188*/, 65536*16* 0.0046970379302800494 +/*189*/, 65536*16* 0.0045359837766146575 +/*190*/, 65536*16* 0.004272937350956345 +/*191*/, 65536*16* 0.003907777448988567 +/*192*/, 65536*16* 0.0034423707924944227 +/*193*/, 65536*16* 0.0028806330094231125 +/*194*/, 65536*16* 0.0022285548928660825 +/*195*/, 65536*16* 0.0014941919971143964 +/*196*/, 65536*16* 6.876167025638233E-4 +/*197*/, 65536*16* -1.7916781098860902E-4 +/*198*/, 65536*16* -0.001092351250031068 +/*199*/, 65536*16* -0.002036476651580642 +/*200*/, 65536*16* -0.002994635788760751 +/*201*/, 65536*16* -0.003948697212655613 +/*202*/, 65536*16* -0.004879563858611486 +/*203*/, 65536*16* -0.005767456511229176 +/*204*/, 65536*16* -0.006592218979894068 +/*205*/, 65536*16* -0.007333640031607341 +/*206*/, 65536*16* -0.007971787269457032 +/*207*/, 65536*16* -0.008487346947516187 +/*208*/, 65536*16* -0.008861964740105959 +/*209*/, 65536*16* -0.009078580419089913 +/*210*/, 65536*16* -0.009121751784315056 +/*211*/, 65536*16* -0.008977961157199062 +/*212*/, 65536*16* -0.008635898786325313 +/*213*/, 65536*16* -0.008086718339557295 +/*214*/, 65536*16* -0.007324258683042848 +/*215*/, 65536*16* -0.0063452279676933475 +/*216*/, 65536*16* -0.005149346015761238 +/*217*/, 65536*16* -0.0037394415039958702 +/*218*/, 65536*16* -0.0021215012056140783 +/*219*/, 65536*16* -3.046703636518387E-4 +/*220*/, 65536*16* 0.0016987979320526618 +/*221*/, 65536*16* 0.0038736435001752246 +/*222*/, 65536*16* 0.006201749792159754 +/*223*/, 65536*16* 0.00866234250983842 +/*224*/, 65536*16* 0.011232233932071251 +/*225*/, 65536*16* 0.013886109426908738 +/*226*/, 65536*16* 0.016596852190097027 +/*227*/, 65536*16* 0.01933590131308301 +/*228*/, 65536*16* 0.022073637826085922 +/*229*/, 65536*16* 0.024779792715016697 +/*230*/, 65536*16* 0.027423870545765342 +/*231*/, 65536*16* 0.029975581949125456 +/*232*/, 65536*16* 0.03240527801144671 +/*233*/, 65536*16* 0.034684379593278115 +/*234*/, 65536*16* 0.03678579448103684 +/*235*/, 65536*16* 0.03868431571442653 +/*236*/, 65536*16* 0.04035699420925718 +/*237*/, 65536*16* 0.041783479941480954 +/*238*/, 65536*16* 0.04294632536294341 +/*239*/, 65536*16* 0.043831247006285705 +/*240*/, 65536*16* 0.044427339714649856 +/*241*/, 65536*16* 0.04472724072106236 +}; + +/* +Parks-McClellan FIR Filter Design + +Filter type: Low pass +Passband: 0 - 0.0077845 +Order: 483 +Passband ripple: 0.1 dB +Transition band: 0.005625 +Stopband attenuation: 60.0 dB +*/ +static int32_t C48000NTSC[NCOEFFS/2]= +{ +/*0*/ 65536*16* -1.2211019733097893E-4 +/*1*/ , 65536*16* 5.374660789759626E-4 +/*2*/ , 65536*16* 1.9882723274804067E-4 +/*3*/ , 65536*16* 1.3631041618360223E-4 +/*4*/ , 65536*16* 1.3153691128499229E-4 +/*5*/ , 65536*16* 1.3886281724158703E-4 +/*6*/ , 65536*16* 1.4887278966773673E-4 +/*7*/ , 65536*16* 1.5943890243162037E-4 +/*8*/ , 65536*16* 1.7020639605259616E-4 +/*9*/ , 65536*16* 1.809192079749018E-4 +/*10*/ , 65536*16* 1.9162093203709557E-4 +/*11*/ , 65536*16* 2.02127312351196E-4 +/*12*/ , 65536*16* 2.1249848894399555E-4 +/*13*/ , 65536*16* 2.2254095363111247E-4 +/*14*/ , 65536*16* 2.323202963851337E-4 +/*15*/ , 65536*16* 2.4163344759163413E-4 +/*16*/ , 65536*16* 2.505472122265602E-4 +/*17*/ , 65536*16* 2.5885306226458603E-4 +/*18*/ , 65536*16* 2.6660828860384193E-4 +/*19*/ , 65536*16* 2.736061193417779E-4 +/*20*/ , 65536*16* 2.79907587492226E-4 +/*21*/ , 65536*16* 2.852884076207648E-4 +/*22*/ , 65536*16* 2.898305905338908E-4 +/*23*/ , 65536*16* 2.93305922863925E-4 +/*24*/ , 65536*16* 2.958004341042564E-4 +/*25*/ , 65536*16* 2.9706939623100196E-4 +/*26*/ , 65536*16* 2.972508466837626E-4 +/*27*/ , 65536*16* 2.960684730022295E-4 +/*28*/ , 65536*16* 2.937123123731801E-4 +/*29*/ , 65536*16* 2.898634667442807E-4 +/*30*/ , 65536*16* 2.8478700978604426E-4 +/*31*/ , 65536*16* 2.7808505097364714E-4 +/*32*/ , 65536*16* 2.7016032300539216E-4 +/*33*/ , 65536*16* 2.6042025835357706E-4 +/*34*/ , 65536*16* 2.496053090718662E-4 +/*35*/ , 65536*16* 2.3660011363209167E-4 +/*36*/ , 65536*16* 2.228827056917728E-4 +/*37*/ , 65536*16* 2.0662381151599093E-4 +/*38*/ , 65536*16* 1.8946729340692708E-4 +/*39*/ , 65536*16* 1.707894290302382E-4 +/*40*/ , 65536*16* 1.4964075656329285E-4 +/*41*/ , 65536*16* 1.2806315562352013E-4 +/*42*/ , 65536*16* 1.0470129333132878E-4 +/*43*/ , 65536*16* 7.952742687952367E-5 +/*44*/ , 65536*16* 5.3080519892589936E-5 +/*45*/ , 65536*16* 2.5960680465529317E-5 +/*46*/ , 65536*16* -2.5651586484338896E-6 +/*47*/ , 65536*16* -3.248840068536756E-5 +/*48*/ , 65536*16* -6.374045088088799E-5 +/*49*/ , 65536*16* -9.575401529845337E-5 +/*50*/ , 65536*16* -1.2853435644071695E-4 +/*51*/ , 65536*16* -1.6188456243132127E-4 +/*52*/ , 65536*16* -1.9591394048834482E-4 +/*53*/ , 65536*16* -2.3037663947407175E-4 +/*54*/ , 65536*16* -2.6523734278928246E-4 +/*55*/ , 65536*16* -3.0020331327926296E-4 +/*56*/ , 65536*16* -3.352268879856044E-4 +/*57*/ , 65536*16* -3.700260022275662E-4 +/*58*/ , 65536*16* -4.045571559416333E-4 +/*59*/ , 65536*16* -4.38534577720557E-4 +/*60*/ , 65536*16* -4.718927645081437E-4 +/*61*/ , 65536*16* -5.043317033789757E-4 +/*62*/ , 65536*16* -5.357994753678582E-4 +/*63*/ , 65536*16* -5.659671580788766E-4 +/*64*/ , 65536*16* -5.947897013020397E-4 +/*65*/ , 65536*16* -6.219384666963997E-4 +/*66*/ , 65536*16* -6.473787936195385E-4 +/*67*/ , 65536*16* -6.707514595741775E-4 +/*68*/ , 65536*16* -6.920680579893526E-4 +/*69*/ , 65536*16* -7.109402066802999E-4 +/*70*/ , 65536*16* -7.274298271538291E-4 +/*71*/ , 65536*16* -7.411375648954899E-4 +/*72*/ , 65536*16* -7.520788343347275E-4 +/*73*/ , 65536*16* -7.600510659768832E-4 +/*74*/ , 65536*16* -7.647430899316486E-4 +/*75*/ , 65536*16* -7.664294191482773E-4 +/*76*/ , 65536*16* -7.644147173692687E-4 +/*77*/ , 65536*16* -7.590920613362674E-4 +/*78*/ , 65536*16* -7.501459543641885E-4 +/*79*/ , 65536*16* -7.373621082253133E-4 +/*80*/ , 65536*16* -7.208964561671388E-4 +/*81*/ , 65536*16* -7.006901755632023E-4 +/*82*/ , 65536*16* -6.764591748580997E-4 +/*83*/ , 65536*16* -6.483697284795448E-4 +/*84*/ , 65536*16* -6.164929718400197E-4 +/*85*/ , 65536*16* -5.806918766677904E-4 +/*86*/ , 65536*16* -5.409344735839229E-4 +/*87*/ , 65536*16* -4.97405373620265E-4 +/*88*/ , 65536*16* -4.502086002815554E-4 +/*89*/ , 65536*16* -3.9932330033988294E-4 +/*90*/ , 65536*16* -3.448028565721092E-4 +/*91*/ , 65536*16* -2.8685420307046736E-4 +/*92*/ , 65536*16* -2.256958038579715E-4 +/*93*/ , 65536*16* -1.615040528190604E-4 +/*94*/ , 65536*16* -9.438524808984473E-5 +/*95*/ , 65536*16* -2.4519303584370608E-5 +/*96*/ , 65536*16* 4.786961616483501E-5 +/*97*/ , 65536*16* 1.2248011782462745E-4 +/*98*/ , 65536*16* 1.990534978611127E-4 +/*99*/ , 65536*16* 2.7728245405517893E-4 +/*100*/ , 65536*16* 3.5690342407690407E-4 +/*101*/ , 65536*16* 4.376002679601721E-4 +/*102*/ , 65536*16* 5.19047629492113E-4 +/*103*/ , 65536*16* 6.008846564336277E-4 +/*104*/ , 65536*16* 6.827617063818499E-4 +/*105*/ , 65536*16* 7.643160551093983E-4 +/*106*/ , 65536*16* 8.451272011819538E-4 +/*107*/ , 65536*16* 9.248890776355356E-4 +/*108*/ , 65536*16* 0.001003072355955673 +/*109*/ , 65536*16* 0.0010794672777372975 +/*110*/ , 65536*16* 0.0011534276232606116 +/*111*/ , 65536*16* 0.0012247823207262698 +/*112*/ , 65536*16* 0.0012929541324917778 +/*113*/ , 65536*16* 0.001357585199795128 +/*114*/ , 65536*16* 0.001418338397346014 +/*115*/ , 65536*16* 0.0014746734285279383 +/*116*/ , 65536*16* 0.0015262884930771822 +/*117*/ , 65536*16* 0.0015728226550844923 +/*118*/ , 65536*16* 0.00161379655898045 +/*119*/ , 65536*16* 0.001648915948444658 +/*120*/ , 65536*16* 0.0016778840108713717 +/*121*/ , 65536*16* 0.0017002560629258679 +/*122*/ , 65536*16* 0.0017157641984855009 +/*123*/ , 65536*16* 0.0017241805985007432 +/*124*/ , 65536*16* 0.001725182645995729 +/*125*/ , 65536*16* 0.0017184841648036691 +/*126*/ , 65536*16* 0.0017039216808435336 +/*127*/ , 65536*16* 0.001681334520841587 +/*128*/ , 65536*16* 0.0016504918660173195 +/*129*/ , 65536*16* 0.0016112687597971862 +/*130*/ , 65536*16* 0.0015636063248128528 +/*131*/ , 65536*16* 0.0015074624593932396 +/*132*/ , 65536*16* 0.0014427699009003175 +/*133*/ , 65536*16* 0.001369527394628539 +/*134*/ , 65536*16* 0.0012878043567412672 +/*135*/ , 65536*16* 0.0011977101442406943 +/*136*/ , 65536*16* 0.0010993686954177168 +/*137*/ , 65536*16* 9.928872878864818E-4 +/*138*/ , 65536*16* 8.784941174786496E-4 +/*139*/ , 65536*16* 7.564288883294911E-4 +/*140*/ , 65536*16* 6.270372159510238E-4 +/*141*/ , 65536*16* 4.905983779660314E-4 +/*142*/ , 65536*16* 3.4754116793679786E-4 +/*143*/ , 65536*16* 1.9816162887093084E-4 +/*144*/ , 65536*16* 4.300342678121075E-5 +/*145*/ , 65536*16* -1.1751370467978956E-4 +/*146*/ , 65536*16* -2.8280605795854083E-4 +/*147*/ , 65536*16* -4.523173545514795E-4 +/*148*/ , 65536*16* -6.255041797790695E-4 +/*149*/ , 65536*16* -8.016355996557292E-4 +/*150*/ , 65536*16* -9.801573426762404E-4 +/*151*/ , 65536*16* -0.0011602954820678437 +/*152*/ , 65536*16* -0.001341343986206184 +/*153*/ , 65536*16* -0.001522571621631356 +/*154*/ , 65536*16* -0.001703172768158951 +/*155*/ , 65536*16* -0.0018823360844618293 +/*156*/ , 65536*16* -0.00205930337901632 +/*157*/ , 65536*16* -0.0022331579230920632 +/*158*/ , 65536*16* -0.002403069015327 +/*159*/ , 65536*16* -0.0025682175666884455 +/*160*/ , 65536*16* -0.002727682820990084 +/*161*/ , 65536*16* -0.002880584481539458 +/*162*/ , 65536*16* -0.003026077683940661 +/*163*/ , 65536*16* -0.00316326704154516 +/*164*/ , 65536*16* -0.003291235176827385 +/*165*/ , 65536*16* -0.0034091436232751705 +/*166*/ , 65536*16* -0.0035161624262765347 +/*167*/ , 65536*16* -0.00361139707788214 +/*168*/ , 65536*16* -0.0036940241232429707 +/*169*/ , 65536*16* -0.003763249197925811 +/*170*/ , 65536*16* -0.0038183138554794805 +/*171*/ , 65536*16* -0.003858413648517434 +/*172*/ , 65536*16* -0.0038828565696081884 +/*173*/ , 65536*16* -0.0038909308779192654 +/*174*/ , 65536*16* -0.0038820231307916493 +/*175*/ , 65536*16* -0.0038554750792844325 +/*176*/ , 65536*16* -0.003810737282493679 +/*177*/ , 65536*16* -0.003747262375484652 +/*178*/ , 65536*16* -0.0036646285078894706 +/*179*/ , 65536*16* -0.0035623728689170597 +/*180*/ , 65536*16* -0.0034401218523635543 +/*181*/ , 65536*16* -0.003297594128579178 +/*182*/ , 65536*16* -0.0031344918897463427 +/*183*/ , 65536*16* -0.0029506999116335536 +/*184*/ , 65536*16* -0.002746012743503227 +/*185*/ , 65536*16* -0.0025204082871514897 +/*186*/ , 65536*16* -0.0022738407863853822 +/*187*/ , 65536*16* -0.0020063873037173175 +/*188*/ , 65536*16* -0.0017182175415557032 +/*189*/ , 65536*16* -0.0014095092681882975 +/*190*/ , 65536*16* -0.0010805220633352567 +/*191*/ , 65536*16* -7.316077716348434E-4 +/*192*/ , 65536*16* -3.631468249678417E-4 +/*193*/ , 65536*16* 2.438177178474359E-5 +/*194*/ , 65536*16* 4.3040711526763105E-4 +/*195*/ , 65536*16* 8.543758511240976E-4 +/*196*/ , 65536*16* 0.0012955688715509065 +/*197*/ , 65536*16* 0.0017532574138845757 +/*198*/ , 65536*16* 0.0022266720975588176 +/*199*/ , 65536*16* 0.0027149312534676365 +/*200*/ , 65536*16* 0.003217102703811305 +/*201*/ , 65536*16* 0.0037322302087511496 +/*202*/ , 65536*16* 0.004259307964559864 +/*203*/ , 65536*16* 0.004797205731205993 +/*204*/ , 65536*16* 0.00534482556712745 +/*205*/ , 65536*16* 0.00590099232932727 +/*206*/ , 65536*16* 0.0064644836497811 +/*207*/ , 65536*16* 0.007034017389280477 +/*208*/ , 65536*16* 0.007608353016621833 +/*209*/ , 65536*16* 0.008186157965561618 +/*210*/ , 65536*16* 0.008766068964147668 +/*211*/ , 65536*16* 0.009346716260147759 +/*212*/ , 65536*16* 0.009926718862388615 +/*213*/ , 65536*16* 0.010504681043184161 +/*214*/ , 65536*16* 0.01107917387309342 +/*215*/ , 65536*16* 0.011648797102049465 +/*216*/ , 65536*16* 0.012212089485935572 +/*217*/ , 65536*16* 0.012767702033610684 +/*218*/ , 65536*16* 0.01331416222058608 +/*219*/ , 65536*16* 0.013850107485964188 +/*220*/ , 65536*16* 0.01437415626494087 +/*221*/ , 65536*16* 0.01488494484218882 +/*222*/ , 65536*16* 0.015381157046388828 +/*223*/ , 65536*16* 0.015861470914555698 +/*224*/ , 65536*16* 0.016324639468324405 +/*225*/ , 65536*16* 0.01676942738258265 +/*226*/ , 65536*16* 0.017194657140859698 +/*227*/ , 65536*16* 0.01759919326505855 +/*228*/ , 65536*16* 0.01798195744932672 +/*229*/ , 65536*16* 0.018341882104229386 +/*230*/ , 65536*16* 0.018678046774501487 +/*231*/ , 65536*16* 0.018989525183852277 +/*232*/ , 65536*16* 0.019275463483745325 +/*233*/ , 65536*16* 0.019535099985330217 +/*234*/ , 65536*16* 0.019767681230128092 +/*235*/ , 65536*16* 0.019972616359274192 +/*236*/ , 65536*16* 0.02014933369102741 +/*237*/ , 65536*16* 0.020297350637687013 +/*238*/ , 65536*16* 0.020416241350314838 +/*239*/ , 65536*16* 0.020505719050281913 +/*240*/ , 65536*16* 0.020565502954380747 +/*241*/ , 65536*16* 0.02059542406883178 +}; + + +/* 44100 NTSC + +Parks-McClellan FIR Filter Design + +Filter type: Low pass +Passband: 0 - 0.006695 +Order: 483 +Passband ripple: 0.2 dB +Transition band: 0.005625 +Stopband attenuation: 66.4 dB + +Coefficients: +*/ + +static int32_t C44100NTSC[NCOEFFS/2]= +{ +/*0*/ 65536 *16 * 2.7250584077004043E-4 +/*1*/, 65536 *16 * -5.6651407794062126E-5 +/*2*/, 65536 *16 * -5.387595203270082E-5 +/*3*/, 65536 *16 * -5.3104114528112036E-5 +/*4*/, 65536 *16 * -5.3927905431407917E-5 +/*5*/, 65536 *16 * -5.624810531844495E-5 +/*6*/, 65536 *16 * -5.9753966587005594E-5 +/*7*/, 65536 *16 * -6.443298022976466E-5 +/*8*/, 65536 *16 * -7.002861393823279E-5 +/*9*/, 65536 *16 * -7.658937335809571E-5 +/*10*/, 65536 *16 * -8.388337472693157E-5 +/*11*/, 65536 *16 * -9.20081628039712E-5 +/*12*/, 65536 *16 * -1.007311169050114E-4 +/*13*/, 65536 *16 * -1.1019992230503533E-4 +/*14*/, 65536 *16 * -1.2014773803429516E-4 +/*15*/, 65536 *16 * -1.3080398984366903E-4 +/*16*/, 65536 *16 * -1.4175865072457003E-4 +/*17*/, 65536 *16 * -1.536527853404198E-4 +/*18*/, 65536 *16 * -1.6517054562524376E-4 +/*19*/, 65536 *16 * -1.7797585116596963E-4 +/*20*/, 65536 *16 * -1.909845496405445E-4 +/*21*/, 65536 *16 * -2.0389566936141008E-4 +/*22*/, 65536 *16 * -2.1726846302640957E-4 +/*23*/, 65536 *16 * -2.310008165840215E-4 +/*24*/, 65536 *16 * -2.4506881863360544E-4 +/*25*/, 65536 *16 * -2.5926465655995895E-4 +/*26*/, 65536 *16 * -2.735381275272462E-4 +/*27*/, 65536 *16 * -2.878190904612406E-4 +/*28*/, 65536 *16 * -3.0209388781875723E-4 +/*29*/, 65536 *16 * -3.163448868528516E-4 +/*30*/, 65536 *16 * -3.30514980542584E-4 +/*31*/, 65536 *16 * -3.4458721564408845E-4 +/*32*/, 65536 *16 * -3.5843761692424506E-4 +/*33*/, 65536 *16 * -3.720823326733447E-4 +/*34*/, 65536 *16 * -3.8529611278848583E-4 +/*35*/, 65536 *16 * -3.982435971141635E-4 +/*36*/, 65536 *16 * -4.1054225307421383E-4 +/*37*/, 65536 *16 * -4.223385042208698E-4 +/*38*/, 65536 *16 * -4.3363210365443626E-4 +/*39*/, 65536 *16 * -4.440451096331875E-4 +/*40*/, 65536 *16 * -4.537334227294333E-4 +/*41*/, 65536 *16 * -4.6260960194346025E-4 +/*42*/, 65536 *16 * -4.706224417116799E-4 +/*43*/, 65536 *16 * -4.776010427698281E-4 +/*44*/, 65536 *16 * -4.8350610346281614E-4 +/*45*/, 65536 *16 * -4.8826489934975626E-4 +/*46*/, 65536 *16 * -4.918511387810396E-4 +/*47*/, 65536 *16 * -4.941839548845786E-4 +/*48*/, 65536 *16 * -4.95186572618022E-4 +/*49*/, 65536 *16 * -4.947817087436606E-4 +/*50*/, 65536 *16 * -4.928828353341973E-4 +/*51*/, 65536 *16 * -4.894676199661217E-4 +/*52*/, 65536 *16 * -4.8443244774343773E-4 +/*53*/, 65536 *16 * -4.778002134883142E-4 +/*54*/, 65536 *16 * -4.694896704084311E-4 +/*55*/, 65536 *16 * -4.593928438902496E-4 +/*56*/, 65536 *16 * -4.4763586771533415E-4 +/*57*/, 65536 *16 * -4.3399559196764174E-4 +/*58*/, 65536 *16 * -4.185187519793231E-4 +/*59*/, 65536 *16 * -4.0118338859945383E-4 +/*60*/, 65536 *16 * -3.820043675631783E-4 +/*61*/, 65536 *16 * -3.6090543967085524E-4 +/*62*/, 65536 *16 * -3.379128204177913E-4 +/*63*/, 65536 *16 * -3.130247503897743E-4 +/*64*/, 65536 *16 * -2.8628759491904673E-4 +/*65*/, 65536 *16 * -2.5769205396918157E-4 +/*66*/, 65536 *16 * -2.2726228845123853E-4 +/*67*/, 65536 *16 * -1.9501222414998665E-4 +/*68*/, 65536 *16 * -1.609903786128509E-4 +/*69*/, 65536 *16 * -1.2525258280646142E-4 +/*70*/, 65536 *16 * -8.786088130641809E-5 +/*71*/, 65536 *16 * -4.885883411475722E-5 +/*72*/, 65536 *16 * -8.373566315346232E-6 +/*73*/, 65536 *16 * 3.362843819360238E-5 +/*74*/, 65536 *16 * 7.69302822233031E-5 +/*75*/, 65536 *16 * 1.2151249228835434E-4 +/*76*/, 65536 *16 * 1.6724878315058612E-4 +/*77*/, 65536 *16 * 2.1402171363813576E-4 +/*78*/, 65536 *16 * 2.6167305946436103E-4 +/*79*/, 65536 *16 * 3.10122854445744E-4 +/*80*/, 65536 *16 * 3.5921866691687363E-4 +/*81*/, 65536 *16 * 4.0882826181233784E-4 +/*82*/, 65536 *16 * 4.5876834733749337E-4 +/*83*/, 65536 *16 * 5.089048509923103E-4 +/*84*/, 65536 *16 * 5.590621717784201E-4 +/*85*/, 65536 *16 * 6.090870406928206E-4 +/*86*/, 65536 *16 * 6.587768488216395E-4 +/*87*/, 65536 *16 * 7.079653533691067E-4 +/*88*/, 65536 *16 * 7.56434905175643E-4 +/*89*/, 65536 *16 * 8.040537989021466E-4 +/*90*/, 65536 *16 * 8.505576158388297E-4 +/*91*/, 65536 *16 * 8.958345533585908E-4 +/*92*/, 65536 *16 * 9.396170235698547E-4 +/*93*/, 65536 *16 * 9.817197600520506E-4 +/*94*/, 65536 *16 * 0.0010219440113723856 +/*95*/, 65536 *16 * 0.0010600976395277468 +/*96*/, 65536 *16 * 0.0010959465933076378 +/*97*/, 65536 *16 * 0.0011293213059753442 +/*98*/, 65536 *16 * 0.001160012212002378 +/*99*/, 65536 *16 * 0.0011878334518393636 +/*100*/, 65536 *16 * 0.0012125633172564833 +/*101*/, 65536 *16 * 0.0012340340153475305 +/*102*/, 65536 *16 * 0.0012520523486154733 +/*103*/, 65536 *16 * 0.001266464375255462 +/*104*/, 65536 *16 * 0.001277070934117742 +/*105*/, 65536 *16 * 0.0012837351142488396 +/*106*/, 65536 *16 * 0.0012862625405968798 +/*107*/, 65536 *16 * 0.0012845614834936406 +/*108*/, 65536 *16 * 0.0012784420593778636 +/*109*/, 65536 *16 * 0.0012678178114382621 +/*110*/, 65536 *16 * 0.0012525556826375537 +/*111*/, 65536 *16 * 0.0012325473943852084 +/*112*/, 65536 *16 * 0.0012077126268838676 +/*113*/, 65536 *16 * 0.0011779966448355029 +/*114*/, 65536 *16 * 0.0011433146771737655 +/*115*/, 65536 *16 * 0.0011036347058885887 +/*116*/, 65536 *16 * 0.0010589202139950945 +/*117*/, 65536 *16 * 0.0010091683044254098 +/*118*/, 65536 *16 * 9.543624468571229E-4 +/*119*/, 65536 *16 * 8.945398819399117E-4 +/*120*/, 65536 *16 * 8.297313883125644E-4 +/*121*/, 65536 *16 * 7.600155199968718E-4 +/*122*/, 65536 *16 * 6.854405952299358E-4 +/*123*/, 65536 *16 * 6.061236114458317E-4 +/*124*/, 65536 *16 * 5.221478191516476E-4 +/*125*/, 65536 *16 * 4.336813620599164E-4 +/*126*/, 65536 *16 * 3.408549526515998E-4 +/*127*/, 65536 *16 * 2.438450825114285E-4 +/*128*/, 65536 *16 * 1.428494911857926E-4 +/*129*/, 65536 *16 * 3.8067640594361634E-5 +/*130*/, 65536 *16 * -7.027035111775681E-5 +/*131*/, 65536 *16 * -1.818984143827126E-4 +/*132*/, 65536 *16 * -2.9656343184630157E-4 +/*133*/, 65536 *16 * -4.1397802421901906E-4 +/*134*/, 65536 *16 * -5.33838500742085E-4 +/*135*/, 65536 *16 * -6.558110253978588E-4 +/*136*/, 65536 *16 * -7.795655816897978E-4 +/*137*/, 65536 *16 * -9.047371821667003E-4 +/*138*/, 65536 *16 * -0.001030961345825847 +/*139*/, 65536 *16 * -0.0011578367988084777 +/*140*/, 65536 *16 * -0.0012849810572319298 +/*141*/, 65536 *16 * -0.0014119662266064482 +/*142*/, 65536 *16 * -0.0015383759515758101 +/*143*/, 65536 *16 * -0.001663756794188296 +/*144*/, 65536 *16 * -0.0017876541594460456 +/*145*/, 65536 *16 * -0.001909621722046808 +/*146*/, 65536 *16 * -0.0020291786719378088 +/*147*/, 65536 *16 * -0.002145855089743562 +/*148*/, 65536 *16 * -0.002259171910476534 +/*149*/, 65536 *16 * -0.0023686314802222655 +/*150*/, 65536 *16 * -0.002473745572697707 +/*151*/, 65536 *16 * -0.0025740277587192853 +/*152*/, 65536 *16 * -0.0026689831666099955 +/*153*/, 65536 *16 * -0.0027581124255643377 +/*154*/, 65536 *16 * -0.0028409282136656177 +/*155*/, 65536 *16 * -0.0029169432593640367 +/*156*/, 65536 *16 * -0.002985680612410139 +/*157*/, 65536 *16 * -0.003046658228485494 +/*158*/, 65536 *16 * -0.003099414222252269 +/*159*/, 65536 *16 * -0.0031434902530511595 +/*160*/, 65536 *16 * -0.003178436798255356 +/*161*/, 65536 *16 * -0.0032038260756887147 +/*162*/, 65536 *16 * -0.003219225355080285 +/*163*/, 65536 *16 * -0.0032242502222488744 +/*164*/, 65536 *16 * -0.003218506103318342 +/*165*/, 65536 *16 * -0.003201625222636992 +/*166*/, 65536 *16 * -0.003173259488065382 +/*167*/, 65536 *16 * -0.0031330803817718332 +/*168*/, 65536 *16 * -0.0030807779128908526 +/*169*/, 65536 *16 * -0.0030160821637947783 +/*170*/, 65536 *16 * -0.0029387362752889335 +/*171*/, 65536 *16 * -0.002848510131379585 +/*172*/, 65536 *16 * -0.0027451998188029363 +/*173*/, 65536 *16 * -0.00262863682904045 +/*174*/, 65536 *16 * -0.0024986780420415064 +/*175*/, 65536 *16 * -0.0023552114528323513 +/*176*/, 65536 *16 * -0.0021981491527779964 +/*177*/, 65536 *16 * -0.0020274504745732714 +/*178*/, 65536 *16 * -0.0018430877753141852 +/*179*/, 65536 *16 * -0.0016450910502005863 +/*180*/, 65536 *16 * -0.0014334955802048866 +/*181*/, 65536 *16 * -0.0012083983821827642 +/*182*/, 65536 *16 * -9.699135443572468E-4 +/*183*/, 65536 *16 * -7.181935207475589E-4 +/*184*/, 65536 *16 * -4.534224887286362E-4 +/*185*/, 65536 *16 * -1.758311300125605E-4 +/*186*/, 65536 *16 * 1.1433027008948132E-4 +/*187*/, 65536 *16 * 4.1675921199616097E-4 +/*188*/, 65536 *16 * 7.311320710094336E-4 +/*189*/, 65536 *16 * 0.0010570872458505827 +/*190*/, 65536 *16 * 0.0013942372682560795 +/*191*/, 65536 *16 * 0.001742148094642797 +/*192*/, 65536 *16 * 0.002100362793433286 +/*193*/, 65536 *16 * 0.0024683818857210646 +/*194*/, 65536 *16 * 0.002845695057494279 +/*195*/, 65536 *16 * 0.0032317385772924275 +/*196*/, 65536 *16 * 0.0036259433326630884 +/*197*/, 65536 *16 * 0.0040276894120370626 +/*198*/, 65536 *16 * 0.004436353627556968 +/*199*/, 65536 *16 * 0.004851271439526238 +/*200*/, 65536 *16 * 0.005271762758295799 +/*201*/, 65536 *16 * 0.005697120565601845 +/*202*/, 65536 *16 * 0.006126626859240469 +/*203*/, 65536 *16 * 0.006559527746778011 +/*204*/, 65536 *16 * 0.0069950693344747504 +/*205*/, 65536 *16 * 0.007432470090915211 +/*206*/, 65536 *16 * 0.007870944336430185 +/*207*/, 65536 *16 * 0.008309688701943495 +/*208*/, 65536 *16 * 0.008747898549370043 +/*209*/, 65536 *16 * 0.009184747205291654 +/*210*/, 65536 *16 * 0.009619414724898365 +/*211*/, 65536 *16 * 0.010051063453485451 +/*212*/, 65536 *16 * 0.010478876316671397 +/*213*/, 65536 *16 * 0.010902016899039163 +/*214*/, 65536 *16 * 0.011319665474466693 +/*215*/, 65536 *16 * 0.011730992134403782 +/*216*/, 65536 *16 * 0.012135186113163639 +/*217*/, 65536 *16 * 0.01253143889871197 +/*218*/, 65536 *16 * 0.012918956981226547 +/*219*/, 65536 *16 * 0.013296952886747157 +/*220*/, 65536 *16 * 0.013664665893392403 +/*221*/, 65536 *16 * 0.014021339353548561 +/*222*/, 65536 *16 * 0.014366244972764902 +/*223*/, 65536 *16 * 0.014698670942210527 +/*224*/, 65536 *16 * 0.015017930945351435 +/*225*/, 65536 *16 * 0.015323359168800435 +/*226*/, 65536 *16 * 0.015614322198635518 +/*227*/, 65536 *16 * 0.015890204972590742 +/*228*/, 65536 *16 * 0.016150433344740527 +/*229*/, 65536 *16 * 0.01639445378257351 +/*230*/, 65536 *16 * 0.016621758349582072 +/*231*/, 65536 *16 * 0.01683186471138077 +/*232*/, 65536 *16 * 0.01702432745775747 +/*233*/, 65536 *16 * 0.017198732908190056 +/*234*/, 65536 *16 * 0.017354710361561963 +/*235*/, 65536 *16 * 0.017491928210652433 +/*236*/, 65536 *16 * 0.017610096156964024 +/*237*/, 65536 *16 * 0.017708958417438553 +/*238*/, 65536 *16 * 0.017788304726419644 +/*239*/, 65536 *16 * 0.01784796484627723 +/*240*/, 65536 *16 * 0.017887808513528385 +/*241*/, 65536 *16 * 0.01790775243433271 +}; + +/* 48000 PAL +Parks-McClellan FIR Filter Design + +Filter type: Low pass +Passband: 0 - 0.008810 +Order: 483 +Passband ripple: 0.133 dB +Transition band: 0.005625 +Stopband attenuation: 63.0 dB + +Coefficients: +*/ +static int32_t C48000PAL[NCOEFFS/2]= +{ +/*0*/ 65536 *16 * -4.8720337170268194E-4 +/*1*/, 65536 *16 * 7.629902642634879E-7 +/*2*/, 65536 *16 * 2.1378369687164975E-6 +/*3*/, 65536 *16 * 4.2506426520122444E-6 +/*4*/, 65536 *16 * 7.369889860416342E-6 +/*5*/, 65536 *16 * 1.1216062943011637E-5 +/*6*/, 65536 *16 * 1.6073843505677063E-5 +/*7*/, 65536 *16 * 2.1633099120040373E-5 +/*8*/, 65536 *16 * 2.8206508485377597E-5 +/*9*/, 65536 *16 * 3.543629776593455E-5 +/*10*/, 65536 *16 * 4.368764327716006E-5 +/*11*/, 65536 *16 * 5.2518982409171E-5 +/*12*/, 65536 *16 * 6.239757141317561E-5 +/*13*/, 65536 *16 * 7.27096511997309E-5 +/*14*/, 65536 *16 * 8.417180660805913E-5 +/*15*/, 65536 *16 * 9.556951705928003E-5 +/*16*/, 65536 *16 * 1.0902571193097876E-4 +/*17*/, 65536 *16 * 1.227237340685471E-4 +/*18*/, 65536 *16 * 1.3608963828565135E-4 +/*19*/, 65536 *16 * 1.5074291732163737E-4 +/*20*/, 65536 *16 * 1.654957671774518E-4 +/*21*/, 65536 *16 * 1.8094544537755017E-4 +/*22*/, 65536 *16 * 1.9650254639058925E-4 +/*23*/, 65536 *16 * 2.124977005396817E-4 +/*24*/, 65536 *16 * 2.2850169154416925E-4 +/*25*/, 65536 *16 * 2.447269340662641E-4 +/*26*/, 65536 *16 * 2.60813097374866E-4 +/*27*/, 65536 *16 * 2.769089011403406E-4 +/*28*/, 65536 *16 * 2.926838284872595E-4 +/*29*/, 65536 *16 * 3.082587328683191E-4 +/*30*/, 65536 *16 * 3.233018169377691E-4 +/*31*/, 65536 *16 * 3.379664790017549E-4 +/*32*/, 65536 *16 * 3.520147829064225E-4 +/*33*/, 65536 *16 * 3.6489502104188965E-4 +/*34*/, 65536 *16 * 3.771837837785839E-4 +/*35*/, 65536 *16 * 3.8841744550992556E-4 +/*36*/, 65536 *16 * 3.985152578693797E-4 +/*37*/, 65536 *16 * 4.0737410559796126E-4 +/*38*/, 65536 *16 * 4.1485052511765913E-4 +/*39*/, 65536 *16 * 4.2087321591616255E-4 +/*40*/, 65536 *16 * 4.252880030529943E-4 +/*41*/, 65536 *16 * 4.2804175098790727E-4 +/*42*/, 65536 *16 * 4.289792011350111E-4 +/*43*/, 65536 *16 * 4.280677040429387E-4 +/*44*/, 65536 *16 * 4.251526022872329E-4 +/*45*/, 65536 *16 * 4.202312572840644E-4 +/*46*/, 65536 *16 * 4.1313629237647344E-4 +/*47*/, 65536 *16 * 4.0393669855985745E-4 +/*48*/, 65536 *16 * 3.9229544134295797E-4 +/*49*/, 65536 *16 * 3.785081882385653E-4 +/*50*/, 65536 *16 * 3.624387298611128E-4 +/*51*/, 65536 *16 * 3.439609793120755E-4 +/*52*/, 65536 *16 * 3.2317107312926493E-4 +/*53*/, 65536 *16 * 3.0001522643985015E-4 +/*54*/, 65536 *16 * 2.7456037312211196E-4 +/*55*/, 65536 *16 * 2.468022375847908E-4 +/*56*/, 65536 *16 * 2.1682011116032351E-4 +/*57*/, 65536 *16 * 1.846463359087917E-4 +/*58*/, 65536 *16 * 1.5038519581308458E-4 +/*59*/, 65536 *16 * 1.1409999503195986E-4 +/*60*/, 65536 *16 * 7.592602477010921E-5 +/*61*/, 65536 *16 * 3.594949037485983E-5 +/*62*/, 65536 *16 * -5.654205953473915E-6 +/*63*/, 65536 *16 * -4.8796158887641113E-5 +/*64*/, 65536 *16 * -9.324450907374415E-5 +/*65*/, 65536 *16 * -1.3875102646747199E-4 +/*66*/, 65536 *16 * -1.853099936736042E-4 +/*67*/, 65536 *16 * -2.3256519878196182E-4 +/*68*/, 65536 *16 * -2.803629983423417E-4 +/*69*/, 65536 *16 * -3.284299717573991E-4 +/*70*/, 65536 *16 * -3.7655572805983734E-4 +/*71*/, 65536 *16 * -4.244648731259925E-4 +/*72*/, 65536 *16 * -4.7191652130487173E-4 +/*73*/, 65536 *16 * -5.18626812434502E-4 +/*74*/, 65536 *16 * -5.64334322901072E-4 +/*75*/, 65536 *16 * -6.087503654593899E-4 +/*76*/, 65536 *16 * -6.515995849807032E-4 +/*77*/, 65536 *16 * -6.925935510204477E-4 +/*78*/, 65536 *16 * -7.314432865833455E-4 +/*79*/, 65536 *16 * -7.678735923848921E-4 +/*80*/, 65536 *16 * -8.015359919770463E-4 +/*81*/, 65536 *16 * -8.322768680565776E-4 +/*82*/, 65536 *16 * -8.597539203190856E-4 +/*83*/, 65536 *16 * -8.836879776280238E-4 +/*84*/, 65536 *16 * -9.038629010388075E-4 +/*85*/, 65536 *16 * -9.200080217158554E-4 +/*86*/, 65536 *16 * -9.319235257639778E-4 +/*87*/, 65536 *16 * -9.393690949611698E-4 +/*88*/, 65536 *16 * -9.421725179420662E-4 +/*89*/, 65536 *16 * -9.401299048871544E-4 +/*90*/, 65536 *16 * -9.33106896645869E-4 +/*91*/, 65536 *16 * -9.209400636174311E-4 +/*92*/, 65536 *16 * -9.035401279622776E-4 +/*93*/, 65536 *16 * -8.807854817776823E-4 +/*94*/, 65536 *16 * -8.526430615286829E-4 +/*95*/, 65536 *16 * -8.190296190822509E-4 +/*96*/, 65536 *16 * -7.799980167439345E-4 +/*97*/, 65536 *16 * -7.355478199155667E-4 +/*98*/, 65536 *16 * -6.8567697874281E-4 +/*99*/, 65536 *16 * -6.305240657493408E-4 +/*100*/, 65536 *16 * -5.701694385732142E-4 +/*101*/, 65536 *16 * -5.047740591296687E-4 +/*102*/, 65536 *16 * -4.344980221283718E-4 +/*103*/, 65536 *16 * -3.595556715693896E-4 +/*104*/, 65536 *16 * -2.8017864491759883E-4 +/*105*/, 65536 *16 * -1.9664106446578853E-4 +/*106*/, 65536 *16 * -1.0924056590418239E-4 +/*107*/, 65536 *16 * -1.831009861307028E-5 +/*108*/, 65536 *16 * 7.579029921420169E-5 +/*109*/, 65536 *16 * 1.726696848384902E-4 +/*110*/, 65536 *16 * 2.719067221880469E-4 +/*111*/, 65536 *16 * 3.7305728261123155E-4 +/*112*/, 65536 *16 * 4.7562651195605295E-4 +/*113*/, 65536 *16 * 5.791888527128953E-4 +/*114*/, 65536 *16 * 6.831673135667645E-4 +/*115*/, 65536 *16 * 7.870493762901182E-4 +/*116*/, 65536 *16 * 8.902822670362451E-4 +/*117*/, 65536 *16 * 9.923024258505538E-4 +/*118*/, 65536 *16 * 0.0010925350458368308 +/*119*/, 65536 *16 * 0.0011903898503065698 +/*120*/, 65536 *16 * 0.0012852771482304163 +/*121*/, 65536 *16 * 0.0013765956662458894 +/*122*/, 65536 *16 * 0.001463753120426749 +/*123*/, 65536 *16 * 0.001546148019165285 +/*124*/, 65536 *16 * 0.0016231971391851225 +/*125*/, 65536 *16 * 0.0016943089588603764 +/*126*/, 65536 *16 * 0.0017589264521182184 +/*127*/, 65536 *16 * 0.001816477825843157 +/*128*/, 65536 *16 * 0.001866465750234791 +/*129*/, 65536 *16 * 0.001908351881851273 +/*130*/, 65536 *16 * 0.0019416355874888774 +/*131*/, 65536 *16 * 0.0019658912100497094 +/*132*/, 65536 *16 * 0.0019806705540431754 +/*133*/, 65536 *16 * 0.001985602463070219 +/*134*/, 65536 *16 * 0.0019803173347810094 +/*135*/, 65536 *16 * 0.001964518487218229 +/*136*/, 65536 *16 * 0.00193792749109128 +/*137*/, 65536 *16 * 0.0019003361153152295 +/*138*/, 65536 *16 * 0.0018515636696845045 +/*139*/, 65536 *16 * 0.0017915008584460717 +/*140*/, 65536 *16 * 0.0017200735452676211 +/*141*/, 65536 *16 * 0.0016372830430278298 +/*142*/, 65536 *16 * 0.0015431709906056357 +/*143*/, 65536 *16 * 0.0014378573929982352 +/*144*/, 65536 *16 * 0.0013215084987890104 +/*145*/, 65536 *16 * 0.001194328283068528 +/*146*/, 65536 *16 * 0.0010566468386934231 +/*147*/, 65536 *16 * 9.088002025373218E-4 +/*148*/, 65536 *16 * 7.512135584215806E-4 +/*149*/, 65536 *16 * 5.843621536328689E-4 +/*150*/, 65536 *16 * 4.087894375795271E-4 +/*151*/, 65536 *16 * 2.2510227575334467E-4 +/*152*/, 65536 *16 * 3.396239791846655E-5 +/*153*/, 65536 *16 * -1.6390294871759475E-4 +/*154*/, 65536 *16 * -3.6771789280231503E-4 +/*155*/, 65536 *16 * -5.766405458635558E-4 +/*156*/, 65536 *16 * -7.897872933737203E-4 +/*157*/, 65536 *16 * -0.001006209757480115 +/*158*/, 65536 *16 * -0.0012249304977170316 +/*159*/, 65536 *16 * -0.0014449054341312839 +/*160*/, 65536 *16 * -0.0016650898600315796 +/*161*/, 65536 *16 * -0.001884343774622382 +/*162*/, 65536 *16 * -0.0021015342465919864 +/*163*/, 65536 *16 * -0.0023154975831354337 +/*164*/, 65536 *16 * -0.0025250324219407566 +/*165*/, 65536 *16 * -0.0027289312457094736 +/*166*/, 65536 *16 * -0.0029259546931934967 +/*167*/, 65536 *16 * -0.003114871201398419 +/*168*/, 65536 *16 * -0.003294430723892981 +/*169*/, 65536 *16 * -0.003463396424710959 +/*170*/, 65536 *16 * -0.003620525188769811 +/*171*/, 65536 *16 * -0.0037645967189351955 +/*172*/, 65536 *16 * -0.003894396916361478 +/*173*/, 65536 *16 * -0.00400874728567525 +/*174*/, 65536 *16 * -0.004106485394068385 +/*175*/, 65536 *16 * -0.004186497692846864 +/*176*/, 65536 *16 * -0.004247692032125654 +/*177*/, 65536 *16 * -0.004289020763525844 +/*178*/, 65536 *16 * -0.0043095197889136795 +/*179*/, 65536 *16 * -0.004308238489219152 +/*180*/, 65536 *16 * -0.004284317631022625 +/*181*/, 65536 *16 * -0.0042369380515990835 +/*182*/, 65536 *16 * -0.004165372803509635 +/*183*/, 65536 *16 * -0.004068956516951112 +/*184*/, 65536 *16 * -0.003947110543306579 +/*185*/, 65536 *16 * -0.003799332887739826 +/*186*/, 65536 *16 * -0.0036252122359255057 +/*187*/, 65536 *16 * -0.0034244255727248728 +/*188*/, 65536 *16 * -0.0031967441992062605 +/*189*/, 65536 *16 * -0.0029420359603045624 +/*190*/, 65536 *16 * -0.002660262473612329 +/*191*/, 65536 *16 * -0.0023514913391939015 +/*192*/, 65536 *16 * -0.002015874218170038 +/*193*/, 65536 *16 * -0.0016537021922741356 +/*194*/, 65536 *16 * -0.0012653326032471951 +/*195*/, 65536 *16 * -8.512425489658283E-4 +/*196*/, 65536 *16 * -4.12008134196091E-4 +/*197*/, 65536 *16 * 5.169160678832697E-5 +/*198*/, 65536 *16 * 5.3906734093252E-4 +/*199*/, 65536 *16 * 0.0010492444783799305 +/*200*/, 65536 *16 * 0.0015812369440962736 +/*201*/, 65536 *16 * 0.002133975437656693 +/*202*/, 65536 *16 * 0.002706284295633396 +/*203*/, 65536 *16 * 0.003296910987472264 +/*204*/, 65536 *16 * 0.0039045040922850343 +/*205*/, 65536 *16 * 0.004527645156076457 +/*206*/, 65536 *16 * 0.005164822580527953 +/*207*/, 65536 *16 * 0.00581446977998051 +/*208*/, 65536 *16 * 0.00647492818678252 +/*209*/, 65536 *16 * 0.007144495527005753 +/*210*/, 65536 *16 * 0.007821417135435386 +/*211*/, 65536 *16 * 0.008503870707064397 +/*212*/, 65536 *16 * 0.00919000676302643 +/*213*/, 65536 *16 * 0.009877917856582038 +/*214*/, 65536 *16 * 0.010565689475867907 +/*215*/, 65536 *16 * 0.011251366750588049 +/*216*/, 65536 *16 * 0.01193298816023733 +/*217*/, 65536 *16 * 0.012608574497468706 +/*218*/, 65536 *16 * 0.013276151008399953 +/*219*/, 65536 *16 * 0.013933744269275995 +/*220*/, 65536 *16 * 0.014579397589755912 +/*221*/, 65536 *16 * 0.015211171751139368 +/*222*/, 65536 *16 * 0.015827155422328678 +/*223*/, 65536 *16 * 0.01642547256780349 +/*224*/, 65536 *16 * 0.01700428326907068 +/*225*/, 65536 *16 * 0.017561819587529177 +/*226*/, 65536 *16 * 0.018096338432718698 +/*227*/, 65536 *16 * 0.018606183762999433 +/*228*/, 65536 *16 * 0.019089749497960648 +/*229*/, 65536 *16 * 0.019545523698532997 +/*230*/, 65536 *16 * 0.019972069058400564 +/*231*/, 65536 *16 * 0.02036803110561515 +/*232*/, 65536 *16 * 0.020732154475618856 +/*233*/, 65536 *16 * 0.021063275458886234 +/*234*/, 65536 *16 * 0.021360340738775345 +/*235*/, 65536 *16 * 0.02162239534537267 +/*236*/, 65536 *16 * 0.021848603142668337 +/*237*/, 65536 *16 * 0.02203823092181804 +/*238*/, 65536 *16 * 0.022190674411724294 +/*239*/, 65536 *16 * 0.022305434241445123 +/*240*/, 65536 *16 * 0.022382153728111424 +/*241*/, 65536 *16 * 0.022420574751016616 +}; + +/* 44100 PAL +Parks-McClellan FIR Filter Design + +Filter type: Low pass +Passband: 0 - 0.0076373 +Order: 483 +Passband ripple: 0.1 dB +Transition band: 0.005625 +Stopband attenuation: 60.5 dB + +Coefficients: +*/ +static int32_t C44100PAL[NCOEFFS/2]= +{ +/*0*/ 65536 *16 * 5.793783958720019E-4 +/*1*/, 65536 *16 * 1.0571291666629312E-4 +/*2*/, 65536 *16 * 1.1459085882755871E-4 +/*3*/, 65536 *16 * 1.2371675029136968E-4 +/*4*/, 65536 *16 * 1.3275170325031607E-4 +/*5*/, 65536 *16 * 1.4207721167879995E-4 +/*6*/, 65536 *16 * 1.5130497600100568E-4 +/*7*/, 65536 *16 * 1.6077227873948047E-4 +/*8*/, 65536 *16 * 1.6990814771316866E-4 +/*9*/, 65536 *16 * 1.79005024990367E-4 +/*10*/, 65536 *16 * 1.8739246068939436E-4 +/*11*/, 65536 *16 * 1.9572039600801667E-4 +/*12*/, 65536 *16 * 2.0352846914404956E-4 +/*13*/, 65536 *16 * 2.1201116607443127E-4 +/*14*/, 65536 *16 * 2.188838839136502E-4 +/*15*/, 65536 *16 * 2.2495686284733203E-4 +/*16*/, 65536 *16 * 2.3149812422937834E-4 +/*17*/, 65536 *16 * 2.363635497444841E-4 +/*18*/, 65536 *16 * 2.410054979130104E-4 +/*19*/, 65536 *16 * 2.445286108284421E-4 +/*20*/, 65536 *16 * 2.474675828550653E-4 +/*21*/, 65536 *16 * 2.4934815214903343E-4 +/*22*/, 65536 *16 * 2.50372333906785E-4 +/*23*/, 65536 *16 * 2.501665763315339E-4 +/*24*/, 65536 *16 * 2.488750795254978E-4 +/*25*/, 65536 *16 * 2.4640153199411455E-4 +/*26*/, 65536 *16 * 2.428720291968876E-4 +/*27*/, 65536 *16 * 2.3801309032826844E-4 +/*28*/, 65536 *16 * 2.3160240772113682E-4 +/*29*/, 65536 *16 * 2.2423402291517938E-4 +/*30*/, 65536 *16 * 2.152856501527123E-4 +/*31*/, 65536 *16 * 2.0488674543318888E-4 +/*32*/, 65536 *16 * 1.9317919544163198E-4 +/*33*/, 65536 *16 * 1.7994016398005858E-4 +/*34*/, 65536 *16 * 1.6541109383681028E-4 +/*35*/, 65536 *16 * 1.4938382649739635E-4 +/*36*/, 65536 *16 * 1.3200975730094075E-4 +/*37*/, 65536 *16 * 1.1313240842725184E-4 +/*38*/, 65536 *16 * 9.296992728984174E-5 +/*39*/, 65536 *16 * 7.143010735440594E-5 +/*40*/, 65536 *16 * 4.8632764324109725E-5 +/*41*/, 65536 *16 * 2.443073549738759E-5 +/*42*/, 65536 *16 * -8.284349612349981E-7 +/*43*/, 65536 *16 * -2.7227387247375577E-5 +/*44*/, 65536 *16 * -5.4818038895146106E-5 +/*45*/, 65536 *16 * -8.330005435111118E-5 +/*46*/, 65536 *16 * -1.1275737974091186E-4 +/*47*/, 65536 *16 * -1.4298620796919756E-4 +/*48*/, 65536 *16 * -1.7390785487074508E-4 +/*49*/, 65536 *16 * -2.054308580401118E-4 +/*50*/, 65536 *16 * -2.37415521983132E-4 +/*51*/, 65536 *16 * -2.697456782629617E-4 +/*52*/, 65536 *16 * -3.022375619849705E-4 +/*53*/, 65536 *16 * -3.348339660959209E-4 +/*54*/, 65536 *16 * -3.673583086741243E-4 +/*55*/, 65536 *16 * -3.996554197363865E-4 +/*56*/, 65536 *16 * -4.3147108191834185E-4 +/*57*/, 65536 *16 * -4.6285023012872966E-4 +/*58*/, 65536 *16 * -4.934440989261961E-4 +/*59*/, 65536 *16 * -5.231720978150925E-4 +/*60*/, 65536 *16 * -5.518656107257292E-4 +/*61*/, 65536 *16 * -5.793049560550073E-4 +/*62*/, 65536 *16 * -6.053792205725333E-4 +/*63*/, 65536 *16 * -6.298765704841736E-4 +/*64*/, 65536 *16 * -6.526402738994988E-4 +/*65*/, 65536 *16 * -6.734722964365358E-4 +/*66*/, 65536 *16 * -6.922485843472661E-4 +/*67*/, 65536 *16 * -7.088111930758961E-4 +/*68*/, 65536 *16 * -7.229789042068006E-4 +/*69*/, 65536 *16 * -7.34572975483669E-4 +/*70*/, 65536 *16 * -7.435049180176613E-4 +/*71*/, 65536 *16 * -7.496258178311876E-4 +/*72*/, 65536 *16 * -7.527294926570751E-4 +/*73*/, 65536 *16 * -7.528075552986548E-4 +/*74*/, 65536 *16 * -7.496410435428715E-4 +/*75*/, 65536 *16 * -7.432054606042111E-4 +/*76*/, 65536 *16 * -7.33375741493331E-4 +/*77*/, 65536 *16 * -7.200753858529672E-4 +/*78*/, 65536 *16 * -7.03226653737734E-4 +/*79*/, 65536 *16 * -6.827921676621563E-4 +/*80*/, 65536 *16 * -6.58752773848678E-4 +/*81*/, 65536 *16 * -6.31061807229375E-4 +/*82*/, 65536 *16 * -5.997124150992168E-4 +/*83*/, 65536 *16 * -5.647352645065657E-4 +/*84*/, 65536 *16 * -5.261799041455252E-4 +/*85*/, 65536 *16 * -4.8402880277824417E-4 +/*86*/, 65536 *16 * -4.3840329475572E-4 +/*87*/, 65536 *16 * -3.893672279202991E-4 +/*88*/, 65536 *16 * -3.37002579326518E-4 +/*89*/, 65536 *16 * -2.8148278838384204E-4 +/*90*/, 65536 *16 * -2.2288467365854118E-4 +/*91*/, 65536 *16 * -1.6140368454103024E-4 +/*92*/, 65536 *16 * -9.718648150744015E-5 +/*93*/, 65536 *16 * -3.046343268277719E-5 +/*94*/, 65536 *16 * 3.859234051837562E-5 +/*95*/, 65536 *16 * 1.0974328274324426E-4 +/*96*/, 65536 *16 * 1.8273974279995372E-4 +/*97*/, 65536 *16 * 2.5730055402762935E-4 +/*98*/, 65536 *16 * 3.3318458939353874E-4 +/*99*/, 65536 *16 * 4.100891270013777E-4 +/*100*/, 65536 *16 * 4.876860015464126E-4 +/*101*/, 65536 *16 * 5.657011755504638E-4 +/*102*/, 65536 *16 * 6.437547403393535E-4 +/*103*/, 65536 *16 * 7.215350856659516E-4 +/*104*/, 65536 *16 * 7.986901321007353E-4 +/*105*/, 65536 *16 * 8.748424228508639E-4 +/*106*/, 65536 *16 * 9.496338070297501E-4 +/*107*/, 65536 *16 * 0.0010226804298925178 +/*108*/, 65536 *16 * 0.001093633836878271 +/*109*/, 65536 *16 * 0.0011620773771650913 +/*110*/, 65536 *16 * 0.001227641045409496 +/*111*/, 65536 *16 * 0.0012899374110895208 +/*112*/, 65536 *16 * 0.001348607725415767 +/*113*/, 65536 *16 * 0.001403236086962171 +/*114*/, 65536 *16 * 0.0014534904370406968 +/*115*/, 65536 *16 * 0.0014989864777827345 +/*116*/, 65536 *16 * 0.0015393672007052272 +/*117*/, 65536 *16 * 0.0015743174329729173 +/*118*/, 65536 *16 * 0.0016034756800234508 +/*119*/, 65536 *16 * 0.0016265420570988364 +/*120*/, 65536 *16 * 0.0016432110467175217 +/*121*/, 65536 *16 * 0.0016532197970121178 +/*122*/, 65536 *16 * 0.0016562968359550962 +/*123*/, 65536 *16 * 0.0016521969919585549 +/*124*/, 65536 *16 * 0.001640721606064916 +/*125*/, 65536 *16 * 0.001621678045313759 +/*126*/, 65536 *16 * 0.0015948992297934834 +/*127*/, 65536 *16 * 0.0015602457924787695 +/*128*/, 65536 *16 * 0.0015176354451292787 +/*129*/, 65536 *16 * 0.0014669598890367775 +/*130*/, 65536 *16 * 0.001408218899058892 +/*131*/, 65536 *16 * 0.001341376545671481 +/*132*/, 65536 *16 * 0.0012664621369705463 +/*133*/, 65536 *16 * 0.0011835425953369801 +/*134*/, 65536 *16 * 0.0010927146027981068 +/*135*/, 65536 *16 * 9.941150953832762E-4 +/*136*/, 65536 *16 * 8.878982163088053E-4 +/*137*/, 65536 *16 * 7.742911468907501E-4 +/*138*/, 65536 *16 * 6.535350381595103E-4 +/*139*/, 65536 *16 * 5.259114487251054E-4 +/*140*/, 65536 *16 * 3.9173611703422796E-4 +/*141*/, 65536 *16 * 2.513813444320677E-4 +/*142*/, 65536 *16 * 1.0522988594595334E-4 +/*143*/, 65536 *16 * -4.627799877161863E-5 +/*144*/, 65536 *16 * -2.0266153878465397E-4 +/*145*/, 65536 *16 * -3.6344539072942917E-4 +/*146*/, 65536 *16 * -5.28061484912101E-4 +/*147*/, 65536 *16 * -6.959549845043866E-4 +/*148*/, 65536 *16 * -8.665108935058429E-4 +/*149*/, 65536 *16 * -0.0010391137133997624 +/*150*/, 65536 *16 * -0.001213088248571412 +/*151*/, 65536 *16 * -0.0013877438142645866 +/*152*/, 65536 *16 * -0.0015623746142961936 +/*153*/, 65536 *16 * -0.001736242850147973 +/*154*/, 65536 *16 * -0.0019085899496564314 +/*155*/, 65536 *16 * -0.002078639823528187 +/*156*/, 65536 *16 * -0.0022456104279907118 +/*157*/, 65536 *16 * -0.002408678368623706 +/*158*/, 65536 *16 * -0.002567052121352872 +/*159*/, 65536 *16 * -0.0027198956481072887 +/*160*/, 65536 *16 * -0.0028663750213148488 +/*161*/, 65536 *16 * -0.0030056713494924794 +/*162*/, 65536 *16 * -0.0031369487365098063 +/*163*/, 65536 *16 * -0.0032593909953083865 +/*164*/, 65536 *16 * -0.0033721594370116153 +/*165*/, 65536 *16 * -0.0034744643621211356 +/*166*/, 65536 *16 * -0.0035654990231207963 +/*167*/, 65536 *16 * -0.003644488024347632 +/*168*/, 65536 *16 * -0.0037106644342197828 +/*169*/, 65536 *16 * -0.0037632989436418352 +/*170*/, 65536 *16 * -0.00380166827783197 +/*171*/, 65536 *16 * -0.0038250950477227447 +/*172*/, 65536 *16 * -0.0038329329853570827 +/*173*/, 65536 *16 * -0.0038245430145814447 +/*174*/, 65536 *16 * -0.0037993625516763766 +/*175*/, 65536 *16 * -0.003756842883124589 +/*176*/, 65536 *16 * -0.0036964913119694686 +/*177*/, 65536 *16 * -0.0036178458358447655 +/*178*/, 65536 *16 * -0.00352050628243193 +/*179*/, 65536 *16 * -0.003404123578517079 +/*180*/, 65536 *16 * -0.003268383375473133 +/*181*/, 65536 *16 * -0.0031130454148921446 +/*182*/, 65536 *16 * -0.002937909773123352 +/*183*/, 65536 *16 * -0.0027428475146560275 +/*184*/, 65536 *16 * -0.0025277729297779944 +/*185*/, 65536 *16 * -0.0022926869206439508 +/*186*/, 65536 *16 * -0.0020376141174133374 +/*187*/, 65536 *16 * -0.0017626719756025908 +/*188*/, 65536 *16 * -0.0014680351622130402 +/*189*/, 65536 *16 * -0.0011539297872750212 +/*190*/, 65536 *16 * -8.206567501069872E-4 +/*191*/, 65536 *16 * -4.685710694984321E-4 +/*192*/, 65536 *16 * -9.811116382477182E-5 +/*193*/, 65536 *16 * 2.902488429495873E-4 +/*194*/, 65536 *16 * 6.959516881166062E-4 +/*195*/, 65536 *16 * 0.0011183883405789612 +/*196*/, 65536 *16 * 0.0015568865209671754 +/*197*/, 65536 *16 * 0.0020107155705137744 +/*198*/, 65536 *16 * 0.002479084293281152 +/*199*/, 65536 *16 * 0.002961149037985776 +/*200*/, 65536 *16 * 0.0034560223628435746 +/*201*/, 65536 *16 * 0.0039627343373741354 +/*202*/, 65536 *16 * 0.0044803036416812955 +/*203*/, 65536 *16 * 0.005007678185806692 +/*204*/, 65536 *16 * 0.00554377521563058 +/*205*/, 65536 *16 * 0.006087456836491167 +/*206*/, 65536 *16 * 0.006637561024809676 +/*207*/, 65536 *16 * 0.007192890398414245 +/*208*/, 65536 *16 * 0.0077522050201042055 +/*209*/, 65536 *16 * 0.008314254820045306 +/*210*/, 65536 *16 * 0.008877749982246051 +/*211*/, 65536 *16 * 0.009441393781470539 +/*212*/, 65536 *16 * 0.010003862886118781 +/*213*/, 65536 *16 * 0.01056383933598836 +/*214*/, 65536 *16 * 0.011119972235266088 +/*215*/, 65536 *16 * 0.011670924253482212 +/*216*/, 65536 *16 * 0.012215363764388693 +/*217*/, 65536 *16 * 0.012751945584822125 +/*218*/, 65536 *16 * 0.013279348664168343 +/*219*/, 65536 *16 * 0.013796251849197938 +/*220*/, 65536 *16 * 0.0143013718962506 +/*221*/, 65536 *16 * 0.014793420656675483 +/*222*/, 65536 *16 * 0.015271157641252524 +/*223*/, 65536 *16 * 0.015733358657288442 +/*224*/, 65536 *16 * 0.016178837288118402 +/*225*/, 65536 *16 * 0.016606446422463023 +/*226*/, 65536 *16 * 0.01701507865820779 +/*227*/, 65536 *16 * 0.017403671672970734 +/*228*/, 65536 *16 * 0.01777119975394863 +/*229*/, 65536 *16 * 0.018116717572056962 +/*230*/, 65536 *16 * 0.01843930362202181 +/*231*/, 65536 *16 * 0.01873811058717855 +/*232*/, 65536 *16 * 0.01901234584784063 +/*233*/, 65536 *16 * 0.019261287195027194 +/*234*/, 65536 *16 * 0.019484271195397335 +/*235*/, 65536 *16 * 0.0196806998422779 +/*236*/, 65536 *16 * 0.019850058102456474 +/*237*/, 65536 *16 * 0.019991882444368586 +/*238*/, 65536 *16 * 0.0201058042761605 +/*239*/, 65536 *16 * 0.02019151207246131 +/*240*/, 65536 *16 * 0.02024878178965319 +/*241*/, 65536 *16 * 0.020277449712345474 +}; Index: libavformat/Makefile =================================================================== --- libavformat/Makefile (リビジョン 8451) +++ libavformat/Makefile (作業コピー) @@ -77,6 +77,7 @@ OBJS-$(CONFIG_MPJPEG_MUXER) += mpjpeg.o OBJS-$(CONFIG_MTV_DEMUXER) += mtv.o OBJS-$(CONFIG_MXF_DEMUXER) += mxf.o +OBJS-$(CONFIG_NSF_DEMUXER) += nsf.o OBJS-$(CONFIG_NSV_DEMUXER) += nsvdec.o riff.o OBJS-$(CONFIG_NUV_DEMUXER) += nuv.o riff.o OBJS-$(CONFIG_OGG_DEMUXER) += ogg2.o \ Index: libavformat/nsf.c =================================================================== --- libavformat/nsf.c (リビジョン 0) +++ libavformat/nsf.c (リビジョン 0) @@ -0,0 +1,4467 @@ +/* + * NSF(NES Sound Format) demuxer + * Copyright (c) 2001-2002 Mitsutaka Okazaki + * Copyright (c) 2004 Xodnizel + * Copyright (c) 2007 Nazo + * + * This file is part of FFmpeg. + * + * FFmpeg is av_free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the av_free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg 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 FFmpeg; if not, write to the av_free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include "avformat.h" +#include +#include +#include +#include + +#include "nsf.h" + +static DECLFW(BRAML) +{ + ((uint8_t *)private)[A&0x7FF]=V; +} + +static DECLFR(ARAML) +{ + return ((uint8_t *)private)[A&0x7FF]; +} + +static DECLFW(NSF_write); +static DECLFR(NSF_read); + +static const uint8_t NSFROM[0x30+6]= +{ + /* 0x00 - NMI */ + 0x8D,0xF4,0x3F, /* Stop play routine NMIs. */ + 0xA2,0xFF,0x9A, /* Initialize the stack pointer. */ + 0xAD,0xF0,0x3F, /* See if we need to init. */ + 0xF0,0x09, /* If 0, go to play routine playing. */ + + 0xAD,0xF1,0x3F, /* Confirm and load A */ + 0xAE,0xF3,0x3F, /* Load X with PAL/NTSC byte */ + + 0x20,0x00,0x00, /* JSR to init routine */ + + 0xA9,0x00, + 0xAA, + 0xA8, + 0x20,0x00,0x00, /* JSR to play routine */ + 0x8D,0xF5,0x3F, /* Start play routine NMIs. */ + 0x90,0xFE, /* Loopie time. */ + + /* 0x20 */ + 0x8D,0xF3,0x3F, /* Init init NMIs */ + 0x18, + 0x90,0xFE /* Loopie time. */ +}; + +static DECLFR(NSFROMRead) +{ + return ((uint8_t *)private)[A-0x3800]; +} + +void FESTAI_Close(FESTALON *festa) +{ + if(festa->apu) FCEUSND_Kill(festa->apu); + + if(festa->cart) FESTAC_Kill(festa->cart); + + if(festa->NSFDATA) av_free(festa->NSFDATA); + + if(festa->ExWRAM) av_free(festa->ExWRAM); + + if(festa->NSFROM) av_free(festa->NSFROM); + + av_free(festa); +} + +static inline void BANKSET(FESTALON *fe, uint32_t A, uint32_t bank) +{ + bank&=fe->NSFMaxBank; + if(fe->NSFHeader.SoundChip&4) + memcpy(fe->ExWRAM+(A-0x6000),fe->NSFDATA+(bank<<12),4096); + else + setprg4(fe->cart,A,bank); +} + +static uint32_t uppow2(uint32_t n) +{ + int x; + + for(x=31;x>=0;x--) + if(n&(1<NSFHeader,buf,0x80); + buf+=0x80; + if(memcmp(fe->NSFHeader.ID,"NESM\x1a",5)) + return 0; + fe->NSFHeader.SongName[31]=fe->NSFHeader.Artist[31]=fe->NSFHeader.Copyright[31]=0; + + fe->LoadAddr=fe->NSFHeader.LoadAddressLow; + fe->LoadAddr|=fe->NSFHeader.LoadAddressHigh<<8; + + if(fe->LoadAddr<0x6000) + return 0; + + fe->InitAddr=fe->NSFHeader.InitAddressLow; + fe->InitAddr|=fe->NSFHeader.InitAddressHigh<<8; + + fe->PlayAddr=fe->NSFHeader.PlayAddressLow; + fe->PlayAddr|=fe->NSFHeader.PlayAddressHigh<<8; + + fe->NSFSize=size-0x80; + + fe->NSFMaxBank=((fe->NSFSize+(fe->LoadAddr&0xfff)+4095)/4096); + fe->NSFMaxBank=uppow2(fe->NSFMaxBank); + + if(!(fe->NSFDATA=(uint8_t *)av_malloc(fe->NSFMaxBank*4096))){ + FESTAI_Close(fe); + return 0; + } + memset(fe->NSFDATA,0x00,fe->NSFMaxBank*4096); + memcpy(fe->NSFDATA+(fe->LoadAddr&0xfff),buf,fe->NSFSize); + + fe->NSFMaxBank--; + + fe->BSon=0; + for(x=0;x<8;x++) + fe->BSon|=fe->NSFHeader.BankSwitch[x]; + + fe->NSFROM=av_malloc(sizeof(NSFROM)); + memcpy(fe->NSFROM,NSFROM,sizeof(NSFROM)); + + for(x=0;;x++){ + if(fe->NSFROM[x]==0x20){ + fe->NSFROM[x+1]=fe->InitAddr&0xFF; + fe->NSFROM[x+2]=fe->InitAddr>>8; + fe->NSFROM[x+8]=fe->PlayAddr&0xFF; + fe->NSFROM[x+9]=fe->PlayAddr>>8; + break; + } + } + + if(fe->NSFHeader.VideoSystem==0) + fe->PAL=0; + else if(fe->NSFHeader.VideoSystem==1) + fe->PAL=1; + + if(fe->NSFHeader.SoundChip&4) + fe->ExWRAM=av_malloc(32768+8192); + else + fe->ExWRAM=av_malloc(8192); + + if(!(fe->X=X6502_Init(fe->RAM,fe->PAL,fe))){ + FESTAI_Close(fe); + return 0; + } + + if(!(fe->apu=FCEUSND_Init(fe->X, rate, quality))){ + FESTAI_Close(fe); + return 0; + } + + X6502_Power(fe->X); + FCEUSND_Power(fe->apu); + + SetReadHandler(fe->X,0x0000,0x1FFF,ARAML,fe->RAM); + SetWriteHandler(fe->X,0x0000,0x1FFF,BRAML,fe->RAM); + + NSF_init(fe); + return fe; +} + +static DECLFR(NSFVectorRead) +{ + FESTALON *fe=private; + if(((fe->NSFNMIFlags&1) && fe->SongReload) || (fe->NSFNMIFlags&2) || fe->doreset){ + if(A==0xFFFA) return 0x00; + else if(A==0xFFFB) return 0x38; + else if(A==0xFFFC) return 0x20; + else if(A==0xFFFD) {fe->doreset=0;return 0x38;} + return DB; + }else + return CartBR(fe->cart,A,DB); +} + +/* EXPSOUND structure is set by NSF*_Init(), NESAPU structure is already set when these + functions are called. +*/ + +int NSFVRC6_Init(EXPSOUND *, NESAPU *); +int NSFVRC7_Init(EXPSOUND *, NESAPU *); +int NSFAY_Init(EXPSOUND *, NESAPU *); +int NSFMMC5_Init(EXPSOUND *, NESAPU *); +int NSFN106_Init(EXPSOUND *, NESAPU *); +int NSFFDS_Init(EXPSOUND *, NESAPU *); + +static void NSF_init(FESTALON *fe) +{ + NESCART *ca; + + fe->doreset=1; + + fe->cart=ca=FESTAC_Init(); + + if(fe->NSFHeader.SoundChip&4){ + FESTAC_SetupPRG(ca,0,fe->ExWRAM,32768+8192,1); + setprg32(ca,0x6000,0); + setprg8(ca,0xE000,4); + memset(fe->ExWRAM,0x00,32768+8192); + SetWriteHandler(fe->X,0x6000,0xDFFF,CartBW,ca); + SetReadHandler(fe->X,0x6000,0xFFFF,CartBR,ca); + }else{ + memset(fe->ExWRAM,0x00,8192); + SetReadHandler(fe->X,0x6000,0x7FFF,CartBR,ca); + SetWriteHandler(fe->X,0x6000,0x7FFF,CartBW,ca); + + FESTAC_SetupPRG(ca,0,fe->NSFDATA,((fe->NSFMaxBank+1)*4096),0); + FESTAC_SetupPRG(ca,1,fe->ExWRAM,8192,1); + + setprg8r(ca,1,0x6000,0); + SetReadHandler(fe->X,0x8000,0xFFFF,CartBR,ca); + } + + if(fe->BSon){ + int32_t x; + for(x=0;x<8;x++){ + if(fe->NSFHeader.SoundChip&4 && x>=6) + BANKSET(fe,0x6000+(x-6)*4096,fe->NSFHeader.BankSwitch[x]); + BANKSET(fe,0x8000+x*4096,fe->NSFHeader.BankSwitch[x]); + } + }else{ + int32_t x; + for(x=(fe->LoadAddr&0xF000);x<0x10000;x+=0x1000) + BANKSET(fe, x,((x-(fe->LoadAddr&0x7000))>>12)); + } + + SetReadHandler(fe->X,0xFFFA,0xFFFD,NSFVectorRead,fe); + + SetWriteHandler(fe->X,0x2000,0x3ffF,0,0); + SetReadHandler(fe->X,0x2000,0x37FF,0,0); + SetReadHandler(fe->X,0x3836,0x3FFF,0,0); + SetReadHandler(fe->X,0x3800,0x3835,NSFROMRead,fe->NSFROM); + + SetWriteHandler(fe->X,0x5ff6,0x5fff,NSF_write,fe); + + SetWriteHandler(fe->X,0x3ff0,0x3fff,NSF_write,fe); + SetReadHandler(fe->X,0x3ff0,0x3fff,NSF_read,fe); + + + /* We don't support expansion sound chips in PAL mode. + It would be EL BUTTO PAINO to do so, and probably slow, since + it would require having two resamplers going at once(on some chips; Festalon + takes advantage of the fact that chips like the VRC7 are run at a clock speed + "compatible" with the NES' CPU clock speed, as far as resampling is concerned). + */ + + if(!fe->PAL){ + int (*EXPInit[6])(EXPSOUND *, NESAPU *) = + {NSFVRC6_Init,NSFVRC7_Init,NSFFDS_Init,NSFMMC5_Init,NSFN106_Init,NSFAY_Init}; + int x; + + for(x=0;x<6;x++) + if(fe->NSFHeader.SoundChip&(1<apu) ) /** FIXME? Error out? */ + FCEUSND_AddExp(fe->apu,ep); + } + } + + fe->CurrentSong=fe->NSFHeader.StartingSong; + fe->SongReload=0xFF; + fe->NSFNMIFlags=0; +} + +static DECLFW(NSF_write) +{ + FESTALON *fe=private; + + if(A >= 0x5ff6 && A<= 0x5FFF){ /* Bank-switching */ + if(A <= 0x5ff7 && !(fe->NSFHeader.SoundChip&4))return; /* Only valid in FDS mode */ + if(!fe->BSon) return; + A&=0xF; + BANKSET(fe, (A*4096),V); + }else + switch(A){ + case 0x3FF3:fe->NSFNMIFlags|=1;break; + case 0x3FF4:fe->NSFNMIFlags&=~2;break; + case 0x3FF5:fe->NSFNMIFlags|=2;break; + } +} + +static DECLFR(NSF_read) +{ + FESTALON *fe=private; + int x; + + switch(A){ + case 0x3ff0:x=fe->SongReload; + fe->SongReload=0; + return x; + case 0x3ff1: + memset(fe->RAM,0x00,0x800); + + X6502_DMW(fe->X,0x4015,0x00); + + for(x=0;x<0x14;x++) + X6502_DMW(fe->X,0x4000+x,0); + X6502_DMW(fe->X,0x4015,0xF); + + if(fe->NSFHeader.SoundChip&4){ + X6502_DMW(fe->X,0x4017,0xC0); /* FDS BIOS writes $C0 */ + X6502_DMW(fe->X,0x4089,0x80); + X6502_DMW(fe->X,0x408A,0xE8); + }else{ + memset(fe->ExWRAM,0x00,8192); + X6502_DMW(fe->X,0x4017,0xC0); + X6502_DMW(fe->X,0x4017,0xC0); + X6502_DMW(fe->X,0x4017,0x40); + } + + if(fe->BSon){ + for(x=0;x<8;x++) + BANKSET(fe, 0x8000+x*4096,fe->NSFHeader.BankSwitch[x]); + } + return fe->CurrentSong-1; + case 0x3FF3:return fe->PAL; + } + return 0; +} + +int FESTAI_NSFControl(FESTALON *fe, int z, int o) +{ + if(o) + fe->CurrentSong=z; + else + fe->CurrentSong+=z; + + if(fe->CurrentSong<1) fe->CurrentSong=1; + else if(fe->CurrentSong>fe->NSFHeader.TotalSongs) + fe->CurrentSong=fe->NSFHeader.TotalSongs; + + fe->SongReload=0xFF; + + return fe->CurrentSong; +} + +int32_t *FESTAI_Emulate(FESTALON *fe, int *Count) +{ + if(fe->PAL) + X6502_Run(fe->X, 312*(256+85)-fe->doodoo); + else + X6502_Run(fe->X, 262*(256+85)-fe->doodoo); + fe->doodoo^=1; + + if(((fe->NSFNMIFlags&1) && fe->SongReload) || (fe->NSFNMIFlags&2)) + TriggerNMI(fe->X); + + *Count=FCEUSND_FlushEmulate(fe->apu); + return fe->apu->WaveFinal; +} + +void FESTAI_SetLowpass(FESTALON *fe, int l) +{ + fe->FSettings.lowpass=l; +} + +void FESTAI_Disable(FESTALON *fe, int t) +{ + FCEUSND_Disable(fe->apu, t); +} + + +static void SexyFilter(FESTAFILT *ff, int32_t *in, int32_t *out, int32_t count) +{ + int32_t mul1,mul2,vmul; + + mul1=(94<<16)/ff->rate; + mul2=(24<<16)/ff->rate; + vmul=(ff->SoundVolume<<16)*3/4/4/100; + + while(count){ + int64_t ino=(int64_t)*in*vmul; + ff->acc1+=((ino-ff->acc1)*mul1)>>16; + ff->acc2+=((ino-ff->acc1-ff->acc2)*mul2)>>16; + //printf("%d ",*in); + *in=0; + { + int32_t t=(ff->acc1-ino+ff->acc2)>>16; + //if(t>32767 || t<-32768) printf("Flow: %d\n",t); + if(t>32767) t=32767; + if(t<-32768) t=-32768; + *out=t; + } + in++; + out++; + count--; + } +} + +/* Returns number of samples written to out. */ +/* leftover is set to the number of samples that need to be copied + from the end of in to the beginning of in. +*/ + +/* This filtering code assumes that almost all input values stay below 32767. + Do not adjust the volume in the wlookup tables and the expansion sound + code to be higher, or you *might* overflow the FIR code. +*/ + +int32_t FESTAFILT_Do(FESTAFILT *ff, int32_t *in, int32_t *out, uint32_t inlen, int32_t *leftover) +{ + uint32_t x; + uint32_t max; + int32_t *outsave=out; + int32_t count=0; + + max=(inlen-1)<<16; + + if(ff->soundq==2) + for(x=ff->mrindex;xmrratio){ + int32_t acc=0,acc2=0; + unsigned int c; + int32_t *S,*D; + + for(c=SQ2NCOEFFS,S=&in[(x>>16)-SQ2NCOEFFS],D=ff->sq2coeffs;c;c--,D++){ + acc+=(S[c]**D)>>6; + acc2+=(S[1+c]**D)>>6; + } + + acc=((int64_t)acc*(65536-(x&65535))+(int64_t)acc2*(x&65535))>>(16+11); + *out=acc; + out++; + count++; + }else + for(x=ff->mrindex;xmrratio){ + int32_t acc=0,acc2=0; + unsigned int c; + int32_t *S,*D; + + for(c=NCOEFFS,S=&in[(x>>16)-NCOEFFS],D=ff->coeffs;c;c--,D++){ + acc+=(S[c]**D)>>6; + acc2+=(S[1+c]**D)>>6; + } + + acc=((int64_t)acc*(65536-(x&65535))+(int64_t)acc2*(x&65535))>>(16+11); + *out=acc; + out++; + count++; + } + ff->mrindex=x-max; + + if(ff->soundq==2){ + ff->mrindex+=SQ2NCOEFFS*65536; + *leftover=SQ2NCOEFFS+1; + }else{ + ff->mrindex+=NCOEFFS*65536; + *leftover=NCOEFFS+1; + } + + SexyFilter(ff,outsave,outsave,count); + return count; +} + +FESTAFILT * FESTAFILT_Init(int32_t rate, int PAL, int soundq) +{ + int32_t *tabs[6]={C44100NTSC,C44100PAL,C48000NTSC,C48000PAL,C96000NTSC, + C96000PAL}; + int32_t *sq2tabs[6]={SQ2C44100NTSC,SQ2C44100PAL,SQ2C48000NTSC,SQ2C48000PAL, + SQ2C96000NTSC,SQ2C96000PAL}; + + int32_t *tmp; + int32_t x; + uint32_t nco; + FESTAFILT *ff; + + if(!(ff=av_malloc(sizeof(FESTAFILT)))) + return 0; + + memset(ff,0,sizeof(FESTAFILT)); + + ff->soundq=soundq; + + if(soundq==2) + nco=SQ2NCOEFFS; + else + nco=NCOEFFS; + + ff->mrindex=(nco+1)<<16; + ff->mrratio=(PAL?(int64_t)(PAL_CPU*65536):(int64_t)(NTSC_CPU*65536))/rate; + + if(soundq==2) + tmp=sq2tabs[(PAL?1:0)|(rate==48000?2:0)|(rate==96000?4:0)]; + else + tmp=tabs[(PAL?1:0)|(rate==48000?2:0)|(rate==96000?4:0)]; + + if(soundq==2) + for(x=0;x>1;x++) + ff->sq2coeffs[x]=ff->sq2coeffs[SQ2NCOEFFS-1-x]=tmp[x]; + else + for(x=0;x>1;x++) + ff->coeffs[x]=ff->coeffs[NCOEFFS-1-x]=tmp[x]; + ff->rate=rate; + return ff; +} + + +/* 16 are (sort of) reserved for UNIF/iNES and 16 to map other stuff. */ + +static inline void setpageptr(NESCART *ca, int s, uint32_t A, uint8_t *p, int ram) +{ + uint32_t AB=A>>11; + int x; + + if(p) + for(x=(s>>1)-1;x>=0;x--){ + ca->PRGIsRAM[AB+x]=ram; + ca->Page[AB+x]=p-A; + } + else + for(x=(s>>1)-1;x>=0;x--){ + ca->PRGIsRAM[AB+x]=0; + ca->Page[AB+x]=0; + } +} + +static uint8_t nothing[8192]; + +void FESTAC_Kill(NESCART *ca) +{ + av_free(ca); +} + +NESCART *FESTAC_Init(void) +{ + int x; + NESCART *ca; + + if(!(ca=av_malloc(sizeof(NESCART)))) + return 0; + + memset(ca,0,sizeof(NESCART)); + + for(x=0;x<32;x++){ + ca->Page[x]=nothing-x*2048; + ca->PRGptr[x]=0; + ca->PRGsize[x]=0; + } + return ca; +} + +void FESTAC_SetupPRG(NESCART *ca, int chip, uint8_t *p, uint32_t size, int ram) +{ + ca->PRGptr[chip]=p; + ca->PRGsize[chip]=size; + + ca->PRGmask2[chip]=(size>>11)-1; + ca->PRGmask4[chip]=(size>>12)-1; + ca->PRGmask8[chip]=(size>>13)-1; + ca->PRGmask16[chip]=(size>>14)-1; + ca->PRGmask32[chip]=(size>>15)-1; + + ca->PRGram[chip]=ram?1:0; +} + +DECLFR(CartBR) +{ + NESCART *ca=private; + + return ca->Page[A>>11][A]; +} + +DECLFW(CartBW) +{ + NESCART *ca=private; + + if(ca->PRGIsRAM[A>>11] && ca->Page[A>>11]) + ca->Page[A>>11][A]=V; +} + +DECLFR(CartBROB) +{ + NESCART *ca=private; + + if(!ca->Page[A>>11]) return DB; + return ca->Page[A>>11][A]; +} + +void FASTAPASS(3) setprg2r(NESCART *ca, int r, unsigned int A, unsigned int V) +{ + V&=ca->PRGmask2[r]; + + setpageptr(ca,2,A,ca->PRGptr[r]?(&ca->PRGptr[r][V<<11]):0,ca->PRGram[r]); +} + +void FASTAPASS(2) setprg2(NESCART *ca, uint32_t A, uint32_t V) +{ + setprg2r(ca,0,A,V); +} + +void FASTAPASS(3) setprg4r(NESCART *ca, int r, unsigned int A, unsigned int V) +{ + V&=ca->PRGmask4[r]; + setpageptr(ca,4,A,ca->PRGptr[r]?(&ca->PRGptr[r][V<<12]):0,ca->PRGram[r]); +} + +void FASTAPASS(2) setprg4(NESCART *ca, uint32_t A, uint32_t V) +{ + setprg4r(ca,0,A,V); +} + +void FASTAPASS(3) setprg8r(NESCART *ca, int r, unsigned int A, unsigned int V) +{ + if(ca->PRGsize[r]>=8192){ + V&=ca->PRGmask8[r]; + setpageptr(ca,8,A,ca->PRGptr[r]?(&ca->PRGptr[r][V<<13]):0,ca->PRGram[r]); + }else{ + uint32_t VA=V<<2; + int x; + for(x=0;x<4;x++) + setpageptr(ca,2,A+(x<<11),ca->PRGptr[r]?(&ca->PRGptr[r][((VA+x)&ca->PRGmask2[r])<<11]):0,ca->PRGram[r]); + } +} + +void FASTAPASS(2) setprg8(NESCART *ca, uint32_t A, uint32_t V) +{ + setprg8r(ca,0,A,V); +} + +void FASTAPASS(3) setprg16r(NESCART *ca, int r, unsigned int A, unsigned int V) +{ + if(ca->PRGsize[r]>=16384){ + V&=ca->PRGmask16[r]; + setpageptr(ca,16,A,ca->PRGptr[r]?(&ca->PRGptr[r][V<<14]):0,ca->PRGram[r]); + }else{ + uint32_t VA=V<<3; + int x; + + for(x=0;x<8;x++) + setpageptr(ca,2,A+(x<<11),ca->PRGptr[r]?(&ca->PRGptr[r][((VA+x)&ca->PRGmask2[r])<<11]):0,ca->PRGram[r]); + } +} + +void FASTAPASS(2) setprg16(NESCART *ca, uint32_t A, uint32_t V) +{ + setprg16r(ca,0,A,V); +} + +void FASTAPASS(3) setprg32r(NESCART *ca, int r,unsigned int A, unsigned int V) +{ + if(ca->PRGsize[r]>=32768){ + V&=ca->PRGmask32[r]; + setpageptr(ca,32,A,ca->PRGptr[r]?(&ca->PRGptr[r][V<<15]):0,ca->PRGram[r]); + }else{ + uint32_t VA=V<<4; + int x; + + for(x=0;x<16;x++) + setpageptr(ca,2,A+(x<<11),ca->PRGptr[r]?(&ca->PRGptr[r][((VA+x)&ca->PRGmask2[r])<<11]):0,ca->PRGram[r]); + } +} + +void FASTAPASS(2) setprg32(NESCART *ca, uint32_t A, uint32_t V) +{ + setprg32r(ca,0,A,V); +} + + +static const int RectDuties[4]={1,2,4,6}; + +static const uint8_t lengthtable[0x20]= +{ + 0x5*2,0x7f*2,0xA*2,0x1*2,0x14*2,0x2*2,0x28*2,0x3*2,0x50*2,0x4*2,0x1E*2,0x5*2,0x7*2,0x6*2,0x0E*2,0x7*2, + 0x6*2,0x08*2,0xC*2,0x9*2,0x18*2,0xa*2,0x30*2,0xb*2,0x60*2,0xc*2,0x24*2,0xd*2,0x8*2,0xe*2,0x10*2,0xf*2 +}; + +static const uint32_t NoiseFreqTable[0x10]= +{ + 2,4,8,0x10,0x20,0x30,0x40,0x50,0x65,0x7f,0xbe,0xfe,0x17d,0x1fc,0x3f9,0x7f2 +}; + +static const uint32_t NTSCDMCTable[0x10]= +{ + 428,380,340,320,286,254,226,214, + 190,160,142,128,106, 84 ,72,54 +}; + +static const uint32_t PALDMCTable[0x10]= +{ + 397, 353, 315, 297, 265, 235, 209, 198, + 176, 148, 131, 118, 98, 78, 66, 50, +}; + +static void DoPCM(NESAPU *apu); +static void DoSQ1(NESAPU *apu); +static void DoSQ2(NESAPU *apu); +static void DoTriangle(NESAPU *apu); +static void DoNoise(NESAPU *apu); + +static void LoadDMCPeriod(NESAPU *apu, uint8_t V) +{ + if(apu->X->PAL) + apu->DMCPeriod=PALDMCTable[V]; + else + apu->DMCPeriod=NTSCDMCTable[V]; +} + +static void PrepDPCM(NESAPU *apu) +{ + apu->DMCAddress=0x4000+(apu->DMCAddressLatch<<6); + apu->DMCSize=(apu->DMCSizeLatch<<4)+1; +} + +/* Instantaneous? Maybe the new freq value is being calculated all of the time... */ + +static int FASTAPASS(2) CheckFreq(uint32_t cf, uint8_t sr) +{ + uint32_t mod; + if(!(sr&0x8)){ + mod=cf>>(sr&7); + if((mod+cf)&0x800) + return 0; + } + return 1; +} + +static void SQReload(NESAPU *apu, int x, uint8_t V) +{ + if(apu->EnabledChannels&(1<lengthcount[x]=lengthtable[(V>>3)&0x1f]; + } + + apu->sweepon[x]=apu->PSG[(x<<2)|1]&0x80; + apu->curfreq[x]=apu->PSG[(x<<2)|0x2]|((V&7)<<8); + apu->SweepCount[x]=((apu->PSG[(x<<2)|0x1]>>4)&7)+1; + + apu->RectDutyCount[x]=7; + apu->EnvUnits[x].reloaddec=1; +} + +static DECLFW(Write_PSG) +{ + NESAPU *apu=private; + + A&=0x1F; + switch(A){ + case 0x0:DoSQ1(apu); + apu->EnvUnits[0].Mode=(V&0x30)>>4; + apu->EnvUnits[0].Speed=(V&0xF); + break; + case 0x1: + apu->sweepon[0]=V&0x80; + break; + case 0x2: + DoSQ1(apu); + apu->curfreq[0]&=0xFF00; + apu->curfreq[0]|=V; + break; + case 0x3: + SQReload(apu,0,V); + break; + case 0x4: + DoSQ2(apu); + apu->EnvUnits[1].Mode=(V&0x30)>>4; + apu->EnvUnits[1].Speed=(V&0xF); + break; + case 0x5: + apu->sweepon[1]=V&0x80; + break; + case 0x6:DoSQ2(apu); + apu->curfreq[1]&=0xFF00; + apu->curfreq[1]|=V; + break; + case 0x7: + SQReload(apu,1,V); + break; + case 0xa:DoTriangle(apu); + break; + case 0xb: + DoTriangle(apu); + if(apu->EnabledChannels&0x4) + apu->lengthcount[2]=lengthtable[(V>>3)&0x1f]; + apu->TriMode=1; // Load mode + break; + case 0xC:DoNoise(apu); + apu->EnvUnits[2].Mode=(V&0x30)>>4; + apu->EnvUnits[2].Speed=(V&0xF); + break; + case 0xE:DoNoise(apu); + break; + case 0xF: + DoNoise(apu); + if(apu->EnabledChannels&0x8) + apu->lengthcount[3]=lengthtable[(V>>3)&0x1f]; + apu->EnvUnits[2].reloaddec=1; + break; + case 0x10:DoPCM(apu); + LoadDMCPeriod(apu,V&0xF); + + if(apu->SIRQStat&0x80){ + if(!(V&0x80)){ + X6502_IRQEnd(apu->X,FCEU_IQDPCM); + apu->SIRQStat&=~0x80; + }else + X6502_IRQBegin(apu->X,FCEU_IQDPCM); + } + break; + } + apu->PSG[A]=V; +} + +static DECLFW(Write_DMCRegs) +{ + NESAPU *apu=private; + A&=0xF; + + switch(A){ + case 0x00:DoPCM(apu); + LoadDMCPeriod(apu,V&0xF); + + if(apu->SIRQStat&0x80){ + if(!(V&0x80)){ + X6502_IRQEnd(apu->X,FCEU_IQDPCM); + apu->SIRQStat&=~0x80; + }else X6502_IRQBegin(apu->X,FCEU_IQDPCM); + } + apu->DMCFormat=V; + break; + case 0x01:DoPCM(apu); + apu->RawDALatch=V&0x7F; + break; + case 0x02:apu->DMCAddressLatch=V;break; + case 0x03:apu->DMCSizeLatch=V;break; + } +} + +static DECLFW(StatusWrite) +{ + NESAPU *apu=private; + int x; + + DoSQ1(apu); + DoSQ2(apu); + DoTriangle(apu); + DoNoise(apu); + DoPCM(apu); + for(x=0;x<4;x++) + if(!(V&(1<lengthcount[x]=0; /* Force length counters to 0. */ + + if(V&0x10){ + if(!apu->DMCSize) + PrepDPCM(apu); + }else{ + apu->DMCSize=0; + } + apu->SIRQStat&=~0x80; + X6502_IRQEnd(apu->X,FCEU_IQDPCM); + apu->EnabledChannels=V&0x1F; +} + +static DECLFR(StatusRead) +{ + NESAPU *apu=private; + int x; + uint8_t ret; + + ret=apu->SIRQStat; + + for(x=0;x<4;x++) ret|=apu->lengthcount[x]?(1<DMCSize) ret|=0x10; + + apu->SIRQStat&=~0x40; + X6502_IRQEnd(apu->X,FCEU_IQFCOUNT); + + return ret; +} + +static void FASTAPASS(2) FrameSoundStuff(NESAPU *apu, int V) +{ + int P; + + DoSQ1(apu); + DoSQ2(apu); + DoNoise(apu); + DoTriangle(apu); + + if(!(V&1)){ /* Envelope decay, linear counter, length counter, freq sweep */ + if(!(apu->PSG[8]&0x80)) + if(apu->lengthcount[2]>0) + apu->lengthcount[2]--; + + if(!(apu->PSG[0xC]&0x20)) /* Make sure loop flag is not set. */ + if(apu->lengthcount[3]>0) + apu->lengthcount[3]--; + + for(P=0;P<2;P++){ + if(!(apu->PSG[P<<2]&0x20)) /* Make sure loop flag is not set. */ + if(apu->lengthcount[P]>0) + apu->lengthcount[P]--; + + /* Frequency Sweep Code Here */ + /* xxxx 0000 */ + /* xxxx = hz. 120/(x+1)*/ + if(apu->sweepon[P]){ + int32_t mod=0; + + if(apu->SweepCount[P]>0) apu->SweepCount[P]--; + if(apu->SweepCount[P]<=0){ + apu->SweepCount[P]=((apu->PSG[(P<<2)+0x1]>>4)&7)+1; //+1; + if(apu->PSG[(P<<2)+0x1]&0x8){ + mod-=(P^1)+((apu->curfreq[P])>>(apu->PSG[(P<<2)+0x1]&7)); + if(apu->curfreq[P] && (apu->PSG[(P<<2)+0x1]&7)/* && sweepon[P]&0x80*/){ + apu->curfreq[P]+=mod; + } + }else{ + mod=apu->curfreq[P]>>(apu->PSG[(P<<2)+0x1]&7); + if((mod+apu->curfreq[P])&0x800){ + apu->sweepon[P]=0; + apu->curfreq[P]=0; + }else{ + if(apu->curfreq[P] && (apu->PSG[(P<<2)+0x1]&7)/* && sweepon[P]&0x80*/){ + apu->curfreq[P]+=mod; + } + } + } + } + }else{ /* Sweeping is disabled: */ + //curfreq[P]&=0xFF00; + //curfreq[P]|=apu->PSG[(P<<2)|0x2]; //|((apu->PSG[(P<<2)|3]&7)<<8); + } + } + } + + /* Now do envelope decay + linear counter. */ + + if(apu->TriMode) // In load mode? + apu->TriCount=apu->PSG[0x8]&0x7F; + else if(apu->TriCount) + apu->TriCount--; + + if(!(apu->PSG[0x8]&0x80)) + apu->TriMode=0; + + for(P=0;P<3;P++){ + if(apu->EnvUnits[P].reloaddec){ + apu->EnvUnits[P].decvolume=0xF; + apu->EnvUnits[P].DecCountTo1=apu->EnvUnits[P].Speed+1; + apu->EnvUnits[P].reloaddec=0; + continue; + } + + if(apu->EnvUnits[P].DecCountTo1>0) apu->EnvUnits[P].DecCountTo1--; + if(apu->EnvUnits[P].DecCountTo1==0){ + apu->EnvUnits[P].DecCountTo1=apu->EnvUnits[P].Speed+1; + if(apu->EnvUnits[P].decvolume || (apu->EnvUnits[P].Mode&0x2)){ + apu->EnvUnits[P].decvolume--; + apu->EnvUnits[P].decvolume&=0xF; + } + } + } +} + +void FrameSoundUpdate(NESAPU *apu) +{ + // Linear counter: Bit 0-6 of $4008 + // Length counter: Bit 4-7 of $4003, $4007, $400b, $400f + + if(!apu->fcnt && !(apu->IRQFrameMode&0x3)){ + apu->SIRQStat|=0x40; + X6502_IRQBegin(apu->X,FCEU_IQFCOUNT); + } + + if(apu->fcnt==3){ + if(apu->IRQFrameMode&0x2) + apu->fhcnt+=apu->fhinc; + } + FrameSoundStuff(apu, apu->fcnt); + apu->fcnt=(apu->fcnt+1)&3; +} + + +static inline void tester(NESAPU *apu) +{ + if(apu->DMCBitCount==0){ + if(!apu->DMCHaveDMA) + apu->DMCHaveSample=0; + else{ + apu->DMCHaveSample=1; + apu->DMCShift=apu->DMCDMABuf; + apu->DMCHaveDMA=0; + } + } +} + +static inline void DMCDMA(NESAPU *apu) +{ + if(apu->DMCSize && !apu->DMCHaveDMA){ + X6502_DMR(apu->X,0x8000+apu->DMCAddress); + X6502_DMR(apu->X,0x8000+apu->DMCAddress); + X6502_DMR(apu->X,0x8000+apu->DMCAddress); + apu->DMCDMABuf=X6502_DMR(apu->X,0x8000+apu->DMCAddress); + apu->DMCHaveDMA=1; + apu->DMCAddress=(apu->DMCAddress+1)&0x7fff; + apu->DMCSize--; + if(!apu->DMCSize){ + if(apu->DMCFormat&0x40) + PrepDPCM(apu); + else{ + apu->SIRQStat|=0x80; + if(apu->DMCFormat&0x80) + X6502_IRQBegin(apu->X,FCEU_IQDPCM); + } + } + } +} + +void FASTAPASS(2) FCEU_SoundCPUHook(void *private, int cycles) +{ + NESAPU *apu=((FESTALON *)private)->apu; + + apu->fhcnt-=cycles*48; + if(apu->fhcnt<=0){ + FrameSoundUpdate(apu); + apu->fhcnt+=apu->fhinc; + } + + DMCDMA(apu); + apu->DMCacc-=cycles; + + while(apu->DMCacc<=0){ + if(apu->DMCHaveSample){ + uint8_t bah=apu->RawDALatch; + int t=((apu->DMCShift&1)<<2)-2; + + /* Unbelievably ugly hack */ + apu->X->timestamp+=apu->DMCacc; + DoPCM(apu); + apu->X->timestamp-=apu->DMCacc; + apu->RawDALatch+=t; + if(apu->RawDALatch&0x80) + apu->RawDALatch=bah; + } + + apu->DMCacc+=apu->DMCPeriod; + apu->DMCBitCount=(apu->DMCBitCount+1)&7; + apu->DMCShift>>=1; + tester(apu); + } +} + +void DoPCM(NESAPU *apu) +{ + int32_t V; + + if(!(apu->disabled&0x10)) + for(V=apu->ChannelBC[4];VX->timestamp;V++) + apu->WaveHi[V]+=apu->RawDALatch<<16; + + apu->ChannelBC[4]=apu->X->timestamp; +} + +/* This has the correct phase. Don't mess with it. */ +static inline void DoSQ(NESAPU *apu, int x) +{ + int32_t V; + int32_t amp; + int32_t rthresh; + int32_t *D; + int32_t currdc; + int32_t cf; + int32_t rc; + + if(apu->disabled&(1<curfreq[x]<8 || apu->curfreq[x]>0x7ff) + goto endit; + if(!CheckFreq(apu->curfreq[x],apu->PSG[(x<<2)|0x1])) + goto endit; + if(!apu->lengthcount[x]) + goto endit; + + if(apu->EnvUnits[x].Mode&0x1) + amp=apu->EnvUnits[x].Speed; + else + amp=apu->EnvUnits[x].decvolume; +// printf("%d\n",amp); + amp<<=24; + + rthresh=RectDuties[(apu->PSG[(x<<2)]&0xC0)>>6]; + + D=&apu->WaveHi[apu->ChannelBC[x]]; + V=apu->X->timestamp-apu->ChannelBC[x]; + + currdc=apu->RectDutyCount[x]; + cf=(apu->curfreq[x]+1)*2; + rc=apu->wlcount[x]; + + while(V>0){ + if(currdcRectDutyCount[x]=currdc; + apu->wlcount[x]=rc; + + endit: + apu->ChannelBC[x]=apu->X->timestamp; +} + +static void DoSQ1(NESAPU *apu) +{ + DoSQ(apu, 0); +} + +static void DoSQ2(NESAPU *apu) +{ + DoSQ(apu, 1); +} + +static void DoTriangle(NESAPU *apu) +{ + int32_t V; + int32_t tcout; + + tcout=(apu->tristep&0xF); + if(!(apu->tristep&0x10)) tcout^=0xF; + tcout=tcout*3; //(tcout<<1); + + if(apu->disabled&4){ + apu->ChannelBC[2]=apu->X->timestamp; + return; + } + + if(!apu->lengthcount[2] || !apu->TriCount){/* Counter is halted, but we still need to output. */ + for(V=apu->ChannelBC[2];VX->timestamp;V++) + apu->WaveHi[V]+=tcout<<16; + }else + for(V=apu->ChannelBC[2];VX->timestamp;V++){ + apu->WaveHi[V]+=tcout<<16; + apu->wlcount[2]--; + if(!apu->wlcount[2]){ + apu->wlcount[2]=(apu->PSG[0xa]|((apu->PSG[0xb]&7)<<8))+1; + apu->tristep++; + tcout=(apu->tristep&0xF); + if(!(apu->tristep&0x10)) tcout^=0xF; + tcout=tcout*3; //(tcout<<1); + } + } + + apu->ChannelBC[2]=apu->X->timestamp; +} + +static void DoNoise(NESAPU *apu) +{ + int32_t V; + int32_t outo; + uint32_t amptab[2]; + + if(apu->EnvUnits[2].Mode&0x1) + amptab[0]=apu->EnvUnits[2].Speed; + else + amptab[0]=apu->EnvUnits[2].decvolume; + + amptab[0]<<=16; + amptab[1]=0; + + amptab[0]<<=1; + + if(apu->disabled&8){ + apu->ChannelBC[3]=apu->X->timestamp; + return; + } + + outo=amptab[apu->nreg&1]; //(nreg>>0xe)&1]; + + if(!apu->lengthcount[3]){ + outo=amptab[0]=0; + } + + if(apu->PSG[0xE]&0x80) // "short" noise + for(V=apu->ChannelBC[3];VX->timestamp;V++){ + apu->WaveHi[V]+=outo; + apu->wlcount[3]--; + if(!apu->wlcount[3]){ + uint8_t feedback; + apu->wlcount[3]=NoiseFreqTable[apu->PSG[0xE]&0xF]<<1; + feedback=((apu->nreg>>8)&1)^((apu->nreg>>14)&1); + apu->nreg=(apu->nreg<<1)+feedback; + apu->nreg&=0x7fff; + outo=amptab[(apu->nreg>>0xe)&1]; + } + } + else + for(V=apu->ChannelBC[3];VX->timestamp;V++){ + apu->WaveHi[V]+=outo; + apu->wlcount[3]--; + if(!apu->wlcount[3]){ + uint8_t feedback; + apu->wlcount[3]=NoiseFreqTable[apu->PSG[0xE]&0xF]<<1; + feedback=((apu->nreg>>13)&1)^((apu->nreg>>14)&1); + apu->nreg=(apu->nreg<<1)+feedback; + apu->nreg&=0x7fff; + outo=amptab[(apu->nreg>>0xe)&1]; + } + } + apu->ChannelBC[3]=apu->X->timestamp; +} + +static DECLFW(Write_IRQFM) +{ + NESAPU *apu=private; + + V=(V&0xC0)>>6; + apu->fcnt=0; + if(V&0x2) + FrameSoundUpdate(apu); + apu->fcnt=1; + apu->fhcnt=apu->fhinc; + X6502_IRQEnd(apu->X,FCEU_IQFCOUNT); + apu->SIRQStat&=~0x40; + apu->IRQFrameMode=V; +} + +int FCEUSND_FlushEmulate(NESAPU *apu) +{ + int x; + int32_t end,left; + + if(!apu->X->timestamp) + return 0; + + DoSQ1(apu); + DoSQ2(apu); + DoTriangle(apu); + DoNoise(apu); + DoPCM(apu); + + { + int32_t *tmpo=&apu->WaveHi[apu->lastpoo]; + + for(x=0;xexpcount;x++) + if(apu->exp[x]->HiFill) apu->exp[x]->HiFill(apu->exp[x]->private); + + /* + if(0) //FSettings.lowpass) + for(x=apu->X->timestamp- apu->lastpoo;x;x--){ + static uint32_t acc=0; + uint32_t b=*tmpo; + + b=(b&65535)+apu->wlookup2[(b>>16)&255]+apu->wlookup1[b>>24]; + acc+=(int32_t)((b<<6)-acc)>>6; + *tmpo=acc>>6; //acc; + tmpo++; + } + else + */ + + for(x=apu->X->timestamp- apu->lastpoo;x;x--){ + uint32_t b=*tmpo; + + *tmpo=(b&65535)+apu->wlookup2[(b>>16)&255]+apu->wlookup1[b>>24]; + tmpo++; + } + + end=FESTAFILT_Do(apu->ff, apu->WaveHi,apu->WaveFinal,apu->X->timestamp,&left); + + memmove(apu->WaveHi,apu->WaveHi+apu->X->timestamp-left,left*sizeof(uint32_t)); + memset(apu->WaveHi+left,0,sizeof(apu->WaveHi)-left*sizeof(uint32_t)); + + for(x=0;xexpcount;x++) + if(apu->exp[x]->HiFill) apu->exp[x]->HiSync(apu->exp[x]->private,left); + for(x=0;x<5;x++) + apu->ChannelBC[x]=left; + } + + apu->X->timestampbase+=apu->X->timestamp; + apu->X->timestamp=left; + apu->X->timestampbase-=apu->X->timestamp; + apu->lastpoo=apu->X->timestamp; + apu->inbuf=end; + + return end; +} + +/** FIXME: Find out what sound registers get reset on reset. I know $4001/$4005 don't, +due to that whole MegaMan 2 Game Genie thing. +*/ +void FCEUSND_Reset(NESAPU *apu) +{ + int x; + + apu->IRQFrameMode=0x0; + apu->fhcnt=apu->fhinc; + apu->fcnt=0; + + apu->nreg=1; + for(x=0;x<2;x++){ + apu->wlcount[x]=2048; + apu->sweepon[x]=0; + apu->curfreq[x]=0; + } + apu->wlcount[2]=1; //2048; + apu->wlcount[3]=2048; + apu->DMCHaveDMA=apu->DMCHaveSample=0; + apu->SIRQStat=0x00; + + apu->RawDALatch=0x00; + apu->TriCount=0; + apu->TriMode=0; + apu->tristep=0; + apu->EnabledChannels=0; + for(x=0;x<4;x++) + apu->lengthcount[x]=0; + + apu->DMCAddressLatch=0; + apu->DMCSizeLatch=0; + apu->DMCFormat=0; + apu->DMCAddress=0; + apu->DMCSize=0; + apu->DMCShift=0; +} +void FCEUSND_Power(NESAPU *apu) +{ + int x; + + SetWriteHandler(apu->X,0x4000,0x400F,Write_PSG,apu); + SetWriteHandler(apu->X,0x4010,0x4013,Write_DMCRegs,apu); + SetWriteHandler(apu->X,0x4017,0x4017,Write_IRQFM,apu); + + SetWriteHandler(apu->X,0x4015,0x4015,StatusWrite,apu); + SetReadHandler(apu->X,0x4015,0x4015,StatusRead,apu); + + memset(apu->PSG,0x00,sizeof(apu->PSG)); + FCEUSND_Reset(apu); + + memset(apu->WaveHi,0,sizeof(apu->WaveHi)); + memset(&apu->EnvUnits,0,sizeof(apu->EnvUnits)); + + for(x=0;x<5;x++) + apu->ChannelBC[x]=0; + apu->lastpoo=0; + LoadDMCPeriod(apu, apu->DMCFormat&0xF); +} + + +void FCEUSND_Kill(NESAPU *apu) +{ + int x; + + for(x=0;xexpcount;x++){ + if(apu->exp[x]->Kill) apu->exp[x]->Kill(apu->exp[x]->private); + av_free(apu->exp[x]); + } + av_free(apu); +} + + +NESAPU *FCEUSND_Init(X6502 *X, uint32_t rate, int quality) +{ + NESAPU *apu; + int x; + + if(!(apu=av_malloc(sizeof(NESAPU)))) + return 0; + + memset(apu,0,sizeof(NESAPU)); + + apu->X=X; + + apu->fhinc=X->PAL?16626:14915; // *2 CPU clock rate + apu->fhinc*=24; + + apu->wlookup1[0]=0; + for(x=1;x<32;x++) + apu->wlookup1[x]=(double)16*16*16*4*95.52/((double)8128/(double)x+100); + + apu->wlookup2[0]=0; + for(x=1;x<203;x++) + apu->wlookup2[x]=(double)16*16*16*4*163.67/((double)24329/(double)x+100); + + apu->ff = FESTAFILT_Init(rate, X->PAL, quality); + + LoadDMCPeriod(apu, apu->DMCFormat&0xF); + return apu; +} + +void FCEUSND_Disable(NESAPU *apu, int d) +{ + int x; + + apu->disabled=d&0x1F; + + for(x=0;xexpcount;x++) + if(apu->exp[x]->Disable) apu->exp[x]->Disable(apu->exp[x]->private, d >> 5); +} + +void FCEUSND_AddExp(NESAPU *apu, EXPSOUND *exp) +{ + if(apu->expcount < 16) + apu->exp[apu->expcount++]=exp; +} + +void FESTAI_SetVolume(FESTALON *fe, uint32_t volume) +{ + fe->apu->ff->SoundVolume=volume; +} + +static DECLFW(BNull) +{ + +} + +static DECLFR(ANull) +{ + return DB; +} + +void SetReadHandler(X6502 *X, int32_t start, int32_t end, readfunc func, void *private) +{ + int32_t x; + + if(!func) + func=ANull; + for(x=end;x>=start;x--){ + X->ARead[x]=func; + X->AReadPrivate[x]=private; + } +} + +void SetWriteHandler(X6502 *X, int32_t start, int32_t end, writefunc func, void *private) +{ + int32_t x; + + if(!func) + func=BNull; + + for(x=end;x>=start;x--){ + X->BWrite[x]=func; + X->BWritePrivate[x]=private; + } +} + +//void FP_FASTAPASS(1) (*MapIRQHook)(int a); + +#define _PC X->PC +#define _A X->A +#define _X X->X +#define _Y X->Y +#define _S X->S +#define _P X->P +#define _PI X->mooPI +#define _DB X->DB +#define _count X->count +#define _tcount X->tcount +#define _IRQlow X->IRQlow +#define _jammed X->jammed +#define _timestamp X->timestamp + +#define ADDCYC(x) \ +{ \ + int __x=x; \ + _tcount+=__x; \ + _count-=__x*48; \ + _timestamp+=__x; \ +} + +static inline uint8_t RdMem(X6502 *X, unsigned int A) +{ + return _DB=X->ARead[A](X->AReadPrivate[A],A,_DB); +} + +static inline void WrMem(X6502 *X, unsigned int A, uint8_t V) +{ + X->BWrite[A](X->BWritePrivate[A],A,V); +} + +static inline uint8_t RdRAM(X6502 *X, unsigned int A) +{ + return _DB=X->RAM[A]; +} + +static inline void WrRAM(X6502 *X, unsigned int A, uint8_t V) +{ + X->RAM[A]=V; +} + +uint8_t FASTAPASS(1) X6502_DMR(X6502 *X, uint32_t A) +{ + ADDCYC(1); + return _DB=X->ARead[A](X->AReadPrivate[A],A,_DB); +} + +void FASTAPASS(2) X6502_DMW(X6502 *X, uint32_t A, uint8_t V) +{ + ADDCYC(1); + X->BWrite[A](X->BWritePrivate[A],A,V); +} + +#define PUSH(V) \ +{ \ + uint8_t VTMP=V; \ + WrRAM(X,0x100+_S,VTMP); \ + _S--; \ +} + +#define POP() RdRAM(X,0x100+(++_S)) + +static const uint8_t ZNTable[256]= +{ + Z_FLAG, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG, + N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG, + N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG, + N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG, + N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG, + N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG, + N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG, + N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG,N_FLAG +}; + +/* Some of these operations will only make sense if you know what the flag + constants are. */ + +#define X_ZN(zort) _P&=~(Z_FLAG|N_FLAG);_P|=ZNTable[zort] +#define X_ZNT(zort) _P|=ZNTable[zort] + +#define JR(cond); \ +{ \ + if(cond) \ + { \ + uint32_t tmp; \ + int8_t disp; \ + disp=RdMem(X,_PC); \ + _PC++; \ + ADDCYC(1); \ + tmp=_PC; \ + _PC+=disp; \ + if((tmp^_PC)&0x100) \ + ADDCYC(1); \ + } \ + else _PC++; \ +} + +#define LDA _A=x;X_ZN(_A) +#define LDX _X=x;X_ZN(_X) +#define LDY _Y=x;X_ZN(_Y) + +/* All of the freaky arithmetic operations. */ +#define AND _A&=x;X_ZN(_A) +#define BIT _P&=~(Z_FLAG|V_FLAG|N_FLAG);_P|=ZNTable[x&_A]&Z_FLAG;_P|=x&(V_FLAG|N_FLAG) +#define EOR _A^=x;X_ZN(_A) +#define ORA _A|=x;X_ZN(_A) + +#define ADC { \ + uint32_t l=_A+x+(_P&1); \ + _P&=~(Z_FLAG|C_FLAG|N_FLAG|V_FLAG); \ + _P|=((((_A^x)&0x80)^0x80) & ((_A^l)&0x80))>>1; \ + _P|=(l>>8)&C_FLAG; \ + _A=l; \ + X_ZNT(_A); \ + } + +#define SBC { \ + uint32_t l=_A-x-((_P&1)^1); \ + _P&=~(Z_FLAG|C_FLAG|N_FLAG|V_FLAG); \ +