1 /* 2 * @(#)MpaDecoder.java - MPA dec 3 * 4 * Copyright (c) 2003-2006 by dvb.matt, All Rights Reserved. 5 * 6 * This file is part of ProjectX, a free Java based demux utility. 7 * By the authors, ProjectX is intended for educational purposes only, 8 * as a non-commercial test project. 9 * 10 * The mostly part of audio decoding was derived from the MPEG/Audio 11 * Software Simulation Group's audio codec. 12 * 13 * simple resampling, amplifying and others added. 14 * now decoding MPEG Layer 1 + 2 15 * 16 * 17 * This program is free software; you can redistribute it and/or modify 18 * it under the terms of the GNU General Public License as published by 19 * the Free Software Foundation; either version 2 of the License, or 20 * (at your option) any later version. 21 * 22 * This program is distributed in the hope that it will be useful, 23 * but WITHOUT ANY WARRANTY; without even the implied warranty of 24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 * GNU General Public License for more details. 26 * 27 * You should have received a copy of the GNU General Public License 28 * along with this program; if not, write to the Free Software 29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 30 * 31 */ 32 33 package net.sourceforge.dvb.projectx.audio; 34 35 36 import java.io.RandomAccessFile; 37 import java.io.IOException; 38 import java.io.ByteArrayOutputStream; 39 40 import java.util.Arrays; 41 42 import net.sourceforge.dvb.projectx.parser.CommonParsing; 43 44 45 public class MpaDecoder extends Object { 46 47 static int ERROR_CODE = 0; 48 static int ERROR_CODE1 = 0; 49 50 // scalefactors 51 static final double table_b1[] = { 52 2.00000000000000, 1.58740105196820, 1.25992104989487, 1.00000000000000, 53 0.79370042498410, 0.62996052494744, 0.50000000000000, 0.39685026299205, 54 0.31498026247372, 0.25000000000000, 0.19842513149602, 0.15749013123686, 55 0.12500000000000, 0.09921256574801, 0.07874506561843, 0.06250000000000, 56 57 0.04960628287401, 0.03937253280921, 0.03125000000000, 0.02480314143700, 58 0.01968626640461, 0.01562500000000, 0.01240157071850, 0.00984313320230, 59 0.00781250000000, 0.00620078535925, 0.00492156660115, 0.00390625000000, 60 0.00310039267963, 0.00246078330058, 0.00195312500000, 0.00155019633981, 61 62 0.00123039165029, 0.00097656250000, 0.00077509816991, 0.00061519582514, 63 0.00048828125000, 0.00038754908495, 0.00030759791257, 0.00024414062500, 64 0.00019377454248, 0.00015379895629, 0.00012207031250, 0.00009688727124, 65 0.00007689947814, 0.00006103515625, 0.00004844363562, 0.00003844973907, 66 67 0.00003051757813, 0.00002422181781, 0.00001922486954, 0.00001525878906, 68 0.00001211090890, 0.00000961243477, 0.00000762939453, 0.00000605545445, 69 0.00000480621738, 0.00000381469727, 0.00000302772723, 0.00000240310869, 70 0.00000190734863, 0.00000151386361, 0.00000120155435, 1E-20 71 }; 72 73 // sblimit 27,30 74 static final int table_b2ab_nbal[] = { 75 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 76 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2 77 }; 78 79 // sblimit 8,12 80 static final int table_b2cd_nbal[] = { 81 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 82 }; 83 84 // sblimit 30 85 static final int table_MPG2_nbal[] = { 86 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 87 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ,2 ,2 88 }; 89 90 static final int table_b2_4a[] = { 91 0, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 92 //0, 1,_3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 changed due to grouping 93 }; 94 95 static final int table_b2_4b[] = { 96 0, 1, 2, 4, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17 97 //0, 1, 2,_3,_4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17 changed due to grouping 98 }; 99 100 static final int table_b2_4c[] = { 101 0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 102 //0, 1, 2,_4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 changed due to grouping 103 }; 104 105 static final int table_b2_3a[] = { 106 0, 1, 2, 4, 3, 5, 6, 17 107 //0, 1, 2,_3,_4, 5, 6, 17 changed due to grouping 108 }; 109 110 static final int table_b2_3b[] = { 111 0, 1, 2, 3, 5, 6, 7, 8 112 //0, 1, 2,_4, 5, 6, 7,_127 changed due to grouping 113 }; 114 115 static final int table_b2_2[] = { 116 0, 1, 2, 17 117 //0, 1, 2, 17 118 }; 119 120 static final int table_MPG2_a[] = { 121 //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 changed due to grouping 122 0, 1, 2, 4, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 123 }; 124 125 static final int table_MPG2_b[] = { 126 //0, 1, 2, 4, 5, 6, 7, 8 changed due to grouping 127 0, 1, 2, 3, 5, 6, 7, 8 128 }; 129 130 static final int table_MPG2_c[] = { 131 //0, 1, 2, 4 changed due to grouping 132 0, 1, 2, 3 133 }; 134 135 static final int table_MPG2[][] = { 136 table_MPG2_a, table_MPG2_a, table_MPG2_a, table_MPG2_a, 137 table_MPG2_b, table_MPG2_b, table_MPG2_b, table_MPG2_b, 138 table_MPG2_b, table_MPG2_b, table_MPG2_b, table_MPG2_c, 139 table_MPG2_c, table_MPG2_c, table_MPG2_c, table_MPG2_c, 140 table_MPG2_c, table_MPG2_c, table_MPG2_c, table_MPG2_c, 141 table_MPG2_c, table_MPG2_c, table_MPG2_c, table_MPG2_c, 142 table_MPG2_c, table_MPG2_c, table_MPG2_c, table_MPG2_c, 143 table_MPG2_c, table_MPG2_c 144 }; 145 146 //sblimit 27,30 147 static final int table_b2ab[][] = { 148 table_b2_4a, table_b2_4a, table_b2_4a, table_b2_4b, 149 table_b2_4b, table_b2_4b, table_b2_4b, table_b2_4b, 150 table_b2_4b, table_b2_4b, table_b2_4b, table_b2_3a, 151 table_b2_3a, table_b2_3a, table_b2_3a, table_b2_3a, 152 table_b2_3a, table_b2_3a, table_b2_3a, table_b2_3a, 153 table_b2_3a, table_b2_3a, table_b2_3a, table_b2_2, 154 table_b2_2, table_b2_2, table_b2_2, table_b2_2, 155 table_b2_2, table_b2_2, table_b2_2, table_b2_2 156 }; 157 158 //sblimit 8,12 159 static final int table_b2cd[][] = { 160 table_b2_4c, table_b2_4c, table_b2_3b, table_b2_3b, 161 table_b2_3b, table_b2_3b, table_b2_3b, table_b2_3b, 162 table_b2_3b, table_b2_3b, table_b2_3b, table_b2_3b 163 }; 164 165 //c,d,bits,step 166 static final double table_b4[][] = { 167 {0.0, 0.0, 0, 0}, 168 {1.0+1.0/3.0, 1.0/2.0, 5, 3}, 169 {1.0+3.0/5.0, 1.0/2.0, 7, 5}, 170 {1.0+7.0/9.0, 1.0/2.0, 10, 9}, 171 {1.0+1.0/7.0, 1.0/4.0, 3, 4}, 172 {1.0+1.0/15.0, 1.0/8.0, 4, 8}, 173 {1.0+1.0/31.0, 1.0/16.0, 5, 16}, 174 {1.0+1.0/63.0, 1.0/32.0, 6, 32}, 175 {1.0+1.0/127.0, 1.0/64.0, 7, 64}, 176 {1.0+1.0/255.0, 1.0/128.0, 8, 128}, 177 {1.0+1.0/511.0, 1.0/256.0, 9, 256}, 178 {1.0+1.0/1023.0, 1.0/512.0, 10, 512}, 179 {1.0+1.0/2047.0, 1.0/1024.0, 11, 1024}, 180 {1.0+1.0/4095.0, 1.0/2048.0, 12, 2048}, 181 {1.0+1.0/8191.0, 1.0/4096.0, 13, 4096}, 182 {1.0+1.0/16383.0, 1.0/8192.0, 14, 8192}, 183 {1.0+1.0/32767.0, 1.0/16384.0, 15, 16384}, 184 {1.0+1.0/65535.0, 1.0/32768.0, 16, 32768} 185 }; 186 187 static final double table_b3[] = { 188 0.000000000, -0.000015259, -0.000015259, -0.000015259, 189 -0.000015259, -0.000015259, -0.000015259, -0.000030518, 190 -0.000030518, -0.000030518, -0.000030518, -0.000045776, 191 -0.000045776, -0.000061035, -0.000061035, -0.000076294, /* 15 */ 192 193 -0.000076294, -0.000091553, -0.000106812, -0.000106812, 194 -0.000122070, -0.000137329, -0.000152588, -0.000167847, 195 -0.000198364, -0.000213623, -0.000244141, -0.000259399, 196 -0.000289917, -0.000320435, -0.000366211, -0.000396729, /* 31 */ 197 198 -0.000442505, -0.000473022, -0.000534058, -0.000579834, 199 -0.000625610, -0.000686646, -0.000747681, -0.000808716, 200 -0.000885010, -0.000961304, -0.001037598, -0.001113892, 201 -0.001205444, -0.001296997, -0.001388550, -0.001480103, /* 47 */ 202 203 -0.001586914, -0.001693726, -0.001785278, -0.001907349, 204 -0.002014160, -0.002120972, -0.002243042, -0.002349854, 205 -0.002456665, -0.002578735, -0.002685547, -0.002792358, 206 -0.002899170, -0.002990723, -0.003082275, -0.003173828, /* 63 */ 207 208 0.003250122, 0.003326416, 0.003387451, 0.003433228, 209 0.003463745, 0.003479004, 0.003479004, 0.003463745, 210 0.003417969, 0.003372192, 0.003280640, 0.003173828, 211 0.003051758, 0.002883911, 0.002700806, 0.002487183, /* 79 */ 212 213 0.002227783, 0.001937866, 0.001617432, 0.001266479, 214 0.000869751, 0.000442505, -0.000030518, -0.000549316, 215 -0.001098633, -0.001693726, -0.002334595, -0.003005981, 216 -0.003723145, -0.004486084, -0.005294800, -0.006118774, /* 95 */ 217 218 -0.007003784, -0.007919312, -0.008865356, -0.009841919, 219 -0.010848999, -0.011886597, -0.012939453, -0.014022827, 220 -0.015121460, -0.016235352, -0.017349243, -0.018463135, 221 -0.019577026, -0.020690918, -0.021789551, -0.022857666, /* 111 */ 222 223 -0.023910522, -0.024932861, -0.025909424, -0.026840210, 224 -0.027725220, -0.028533936, -0.029281616, -0.029937744, 225 -0.030532837, -0.031005859, -0.031387329, -0.031661987, 226 -0.031814575, -0.031845093, -0.031738281, -0.031478882, /* 127 */ 227 228 0.031082153, 0.030517578, 0.029785156, 0.028884888, 229 0.027801514, 0.026535034, 0.025085449, 0.023422241, 230 0.021575928, 0.019531250, 0.017257690, 0.014801025, 231 0.012115479, 0.009231567, 0.006134033, 0.002822876, /* 143 */ 232 233 -0.000686646, -0.004394531, -0.008316040, -0.012420654, 234 -0.016708374, -0.021179199, -0.025817871, -0.030609131, 235 -0.035552979, -0.040634155, -0.045837402, -0.051132202, 236 -0.056533813, -0.061996460, -0.067520142, -0.073059082, /* 159 */ 237 238 -0.078628540, -0.084182739, -0.089706421, -0.095169067, 239 -0.100540161, -0.105819702, -0.110946655, -0.115921021, 240 -0.120697021, -0.125259399, -0.129562378, -0.133590698, 241 -0.137298584, -0.140670776, -0.143676758, -0.146255493, /* 175 */ 242 243 -0.148422241, -0.150115967, -0.151306152, -0.151962280, 244 -0.152069092, -0.151596069, -0.150497437, -0.148773193, 245 -0.146362305, -0.143264771, -0.139450073, -0.134887695, 246 -0.129577637, -0.123474121, -0.116577148, -0.108856201, /* 191 */ 247 248 0.100311279, 0.090927124, 0.080688477, 0.069595337, 249 0.057617187, 0.044784546, 0.031082153, 0.016510010, 250 0.001068115, -0.015228271, -0.032379150, -0.050354004, 251 -0.069168091, -0.088775635, -0.109161377, -0.130310059, /* 207 */ 252 253 -0.152206421, -0.174789429, -0.198059082, -0.221984863, 254 -0.246505737, -0.271591187, -0.297210693, -0.323318481, 255 -0.349868774, -0.376800537, -0.404083252, -0.431655884, 256 -0.459472656, -0.487472534, -0.515609741, -0.543823242, /* 223 */ 257 258 -0.572036743, -0.600219727, -0.628295898, -0.656219482, 259 -0.683914185, -0.711318970, -0.738372803, -0.765029907, 260 -0.791213989, -0.816864014, -0.841949463, -0.866363525, 261 -0.890090942, -0.913055420, -0.935195923, -0.956481934, /* 239 */ 262 263 -0.976852417, -0.996246338, -1.014617920, -1.031936646, 264 -1.048156738, -1.063217163, -1.077117920, -1.089782715, 265 -1.101211548, -1.111373901, -1.120223999, -1.127746582, 266 -1.133926392, -1.138763428, -1.142211914, -1.144287109, /* 255 */ 267 268 1.144989014, 1.144287109, 1.142211914, 1.138763428, 269 1.133926392, 1.127746582, 1.120223999, 1.111373901, 270 1.101211548, 1.089782715, 1.077117920, 1.063217163, 271 1.048156738, 1.031936646, 1.014617920, 0.996246338, /* 271 */ 272 273 0.976852417, 0.956481934, 0.935195923, 0.913055420, 274 0.890090942, 0.866363525, 0.841949463, 0.816864014, 275 0.791213989, 0.765029907, 0.738372803, 0.711318970, 276 0.683914185, 0.656219482, 0.628295898, 0.600219727, /* 287 */ 277 278 0.572036743, 0.543823242, 0.515609741, 0.487472534, 279 0.459472656, 0.431655884, 0.404083252, 0.376800537, 280 0.349868774, 0.323318481, 0.297210693, 0.271591187, 281 0.246505737, 0.221984863, 0.198059082, 0.174789429, /* 304 */ 282 283 0.152206421, 0.130310059, 0.109161377, 0.088775635, 284 0.069168091, 0.050354004, 0.032379150, 0.015228271, 285 -0.001068115, -0.016510010, -0.031082153, -0.044784546, 286 -0.057617187, -0.069595337, -0.080688477, -0.090927124, /* 319 */ 287 288 0.100311279, 0.108856201, 0.116577148, 0.123474121, 289 0.129577637, 0.134887695, 0.139450073, 0.143264771, 290 0.146362305, 0.148773193, 0.150497437, 0.151596069, 291 0.152069092, 0.151962280, 0.151306152, 0.150115967, /* 335 */ 292 293 0.148422241, 0.146255493, 0.143676758, 0.140670776, 294 0.137298584, 0.133590698, 0.129562378, 0.125259399, 295 0.120697021, 0.115921021, 0.110946655, 0.105819702, 296 0.100540161, 0.095169067, 0.089706421, 0.084182739, /* 351 */ 297 298 0.078628540, 0.073059082, 0.067520142, 0.061996460, 299 0.056533813, 0.051132202, 0.045837402, 0.040634155, 300 0.035552979, 0.030609131, 0.025817871, 0.021179199, 301 0.016708374, 0.012420654, 0.008316040, 0.004394531, /* 367 */ 302 303 0.000686646, -0.002822876, -0.006134033, -0.009231567, 304 -0.012115479, -0.014801025, -0.017257690, -0.019531250, 305 -0.021575928, -0.023422241, -0.025085449, -0.026535034, 306 -0.027801514, -0.028884888, -0.029785156, -0.030517578, /* 383 */ 307 308 0.031082153, 0.031478882, 0.031738281, 0.031845093, 309 0.031814575, 0.031661987, 0.031387329, 0.031005859, 310 0.030532837, 0.029937744, 0.029281616, 0.028533936, 311 0.027725220, 0.026840210, 0.025909424, 0.024932861, /* 399 */ 312 313 0.023910522, 0.022857666, 0.021789551, 0.020690918, 314 0.019577026, 0.018463135, 0.017349243, 0.016235352, 315 0.015121460, 0.014022827, 0.012939453, 0.011886597, 316 0.010848999, 0.009841919, 0.008865356, 0.007919312, /* 415 */ 317 318 0.007003784, 0.006118774, 0.005294800, 0.004486084, 319 0.003723145, 0.003005981, 0.002334595, 0.001693726, 320 0.001098633, 0.000549316, 0.000030518, -0.000442505, 321 -0.000869751, -0.001266479, -0.001617432, -0.001937866, /* 431 */ 322 323 -0.002227783, -0.002487183, -0.002700806, -0.002883911, 324 -0.003051758, -0.003173828, -0.003280640, -0.003372192, 325 -0.003417969, -0.003463745, -0.003479004, -0.003479004, 326 -0.003463745, -0.003433228, -0.003387451, -0.003326416, /* 447 */ 327 328 0.003250122, 0.003173828, 0.003082275, 0.002990723, 329 0.002899170, 0.002792358, 0.002685547, 0.002578735, 330 0.002456665, 0.002349854, 0.002243042, 0.002120972, 331 0.002014160, 0.001907349, 0.001785278, 0.001693726, /* 463 */ 332 333 0.001586914, 0.001480103, 0.001388550, 0.001296997, 334 0.001205444, 0.001113892, 0.001037598, 0.000961304, 335 0.000885010, 0.000808716, 0.000747681, 0.000686646, 336 0.000625610, 0.000579834, 0.000534058, 0.000473022, /* 479 */ 337 338 0.000442505, 0.000396729, 0.000366211, 0.000320435, 339 0.000289917, 0.000259399, 0.000244141, 0.000213623, 340 0.000198364, 0.000167847, 0.000152588, 0.000137329, 341 0.000122070, 0.000106812, 0.000106812, 0.000091553, /* 495 */ 342 343 0.000076294, 0.000076294, 0.000061035, 0.000061035, 344 0.000045776, 0.000045776, 0.000030518, 0.000030518, 345 0.000030518, 0.000030518, 0.000015259, 0.000015259, 346 0.000015259, 0.000015259, 0.000015259, 0.000015259 /* 511 */ 347 }; 348 349 static final double table_Nik[][] = { 350 { 351 0.707106781186547573, -0.707106781186547462, -0.707106781186547684, 0.707106781186547351, 352 0.707106781186547684, -0.707106781186547906, -0.707106781186547129, 0.707106781186547795, 353 0.707106781186547240, -0.707106781186547795, -0.707106781186547351, 0.707106781186546352, 354 0.707106781186547462, -0.707106781186546352, -0.707106781186547573, 0.707106781186548683, 355 0.707106781186547573, -0.707106781186548683, -0.707106781186547684, 0.707106781186548572, 356 0.707106781186545241, -0.707106781186546018, -0.707106781186547906, 0.707106781186548350, 357 0.707106781186545463, -0.707106781186545796, -0.707106781186548017, 0.707106781186548239, 358 0.707106781186545574, -0.707106781186545574, -0.707106781186548239, 0.707106781186548017, 359 },{ 360 0.671558954847018330, -0.803207531480644832, -0.514102744193221772, 0.903989293123443449, 361 0.336889853392220051, -0.970031253194544085, -0.146730474455361665, 0.998795456205172405, 362 -0.049067674327417293, -0.989176509964780903, 0.242980179903262428, 0.941544065183020806, 363 -0.427555093430283195, -0.857728610000272562, 0.595699304492433690, 0.740951125354960216, 364 -0.740951125354958884, -0.595699304492432469, 0.857728610000271452, 0.427555093430285082, 365 -0.941544065183021361, -0.242980179903264426, 0.989176509964780570, 0.049067674327415829, 366 -0.998795456205172405, 0.146730474455359611, 0.970031253194543308, -0.336889853392220606, 367 -0.903989293123444004, 0.514102744193224659, 0.803207531480644166, -0.671558954847017664, 368 },{ 369 0.634393284163645488, -0.881921264348354939, -0.290284677254462442, 0.995184726672196929, 370 -0.098017140329560840, -0.956940335732208713, 0.471396736825997364, 0.773010453362736549, 371 -0.773010453362736993, -0.471396736825998308, 0.956940335732208935, 0.098017140329559285, 372 -0.995184726672197040, 0.290284677254462220, 0.881921264348354605, -0.634393284163644267, 373 -0.634393284163645932, 0.881921264348355272, 0.290284677254464329, -0.995184726672196818, 374 0.098017140329560631, 0.956940335732208602, -0.471396736825999529, -0.773010453362734995, 375 0.773010453362735106, 0.471396736825999307, -0.956940335732208602, -0.098017140329560382, 376 0.995184726672196818, -0.290284677254464552, -0.881921264348353495, 0.634393284163643378, 377 },{ 378 0.595699304492433357, -0.941544065183020806, -0.049067674327418029, 0.970031253194544085, 379 -0.514102744193221439, -0.671558954847018108, 0.903989293123443005, 0.146730474455361803, 380 -0.989176509964780903, 0.427555093430283306, 0.740951125354960105, -0.857728610000271674, 381 -0.242980179903263954, 0.998795456205172405, -0.336889853392221328, -0.803207531480645831, 382 0.803207531480644388, 0.336889853392220162, -0.998795456205172294, 0.242980179903265148, 383 0.857728610000272895, -0.740951125354960882, -0.427555093430282196, 0.989176509964780570, 384 -0.146730474455362997, -0.903989293123444004, 0.671558954847020440, 0.514102744193221883, 385 -0.970031253194543308, 0.049067674327419257, 0.941544065183021361, -0.595699304492435466, 386 },{ 387 0.555570233019602289, -0.980785280403230431, 0.195090322016128304, 0.831469612302545014, 388 -0.831469612302545125, -0.195090322016128026, 0.980785280403230320, -0.555570233019601512, 389 -0.555570233019602622, 0.980785280403230431, -0.195090322016128581, -0.831469612302544903, 390 0.831469612302545791, 0.195090322016126888, -0.980785280403230098, 0.555570233019601067, 391 0.555570233019600179, -0.980785280403230986, 0.195090322016131440, 0.831469612302547123, 392 -0.831469612302543459, -0.195090322016130968, 0.980785280403230875, -0.555570233019600512, 393 -0.555570233019603621, 0.980785280403230209, -0.195090322016127360, -0.831469612302545569, 394 0.831469612302545125, 0.195090322016128082, -0.980785280403230320, 0.555570233019602955, 395 },{ 396 0.514102744193221661, -0.998795456205172405, 0.427555093430282140, 0.595699304492433246, 397 -0.989176509964781014, 0.336889853392220218, 0.671558954847018219, -0.970031253194544085, 398 0.242980179903262428, 0.740951125354960105, -0.941544065183020251, 0.146730474455360332, 399 0.803207531480645720, -0.903989293123442783, 0.049067674327416683, 0.857728610000272784, 400 -0.857728610000273228, -0.049067674327419250, 0.903989293123442339, -0.803207531480644166, 401 -0.146730474455359361, 0.941544065183021139, -0.740951125354960771, -0.242980179903264926, 402 0.970031253194543419, -0.671558954847017664, -0.336889853392217609, 0.989176509964781125, 403 -0.595699304492435466, -0.427555093430282862, 0.998795456205172294, -0.514102744193227101, 404 },{ 405 0.471396736825997587, -0.995184726672196929, 0.634393284163645599, 0.290284677254462553, 406 -0.956940335732208713, 0.773010453362736993, 0.098017140329560812, -0.881921264348354383, 407 0.881921264348355494, -0.098017140329561242, -0.773010453362736771, 0.956940335732208824, 408 -0.290284677254462109, -0.634393284163645932, 0.995184726672196818, -0.471396736825999751, 409 -0.471396736825995866, 0.995184726672196707, -0.634393284163646598, -0.290284677254461276, 410 0.956940335732208602, -0.773010453362737326, -0.098017140329560382, 0.881921264348355050, 411 -0.881921264348354828, 0.098017140329559896, 0.773010453362737548, -0.956940335732208491, 412 0.290284677254460832, 0.634393284163647042, -0.995184726672197373, 0.471396736826001694, 413 },{ 414 0.427555093430282196, -0.970031253194543974, 0.803207531480645054, -0.049067674327418424, 415 -0.740951125354958662, 0.989176509964781014, -0.514102744193221217, -0.336889853392219552, 416 0.941544065183020806, -0.857728610000271674, 0.146730474455360332, 0.671558954847017331, 417 -0.998795456205172405, 0.595699304492433468, 0.242980179903260873, -0.903989293123443782, 418 0.903989293123444115, -0.242980179903261595, -0.595699304492432913, 0.998795456205172183, 419 -0.671558954847017886, -0.146730474455359611, 0.857728610000273117, -0.941544065183021028, 420 0.336889853392216942, 0.514102744193222105, -0.989176509964780570, 0.740951125354957996, 421 0.049067674327416808, -0.803207531480646719, 0.970031253194545751, -0.427555093430284638, 422 },{ 423 0.382683432365089837, -0.923879532511286850, 0.923879532511286850, -0.382683432365089893, 424 -0.382683432365090559, 0.923879532511286738, -0.923879532511287072, 0.382683432365089560, 425 0.382683432365090892, -0.923879532511286294, 0.923879532511286850, -0.382683432365089227, 426 -0.382683432365091225, 0.923879532511286405, -0.923879532511285406, 0.382683432365092169, 427 0.382683432365088283, -0.923879532511286516, 0.923879532511286627, -0.382683432365088505, 428 -0.382683432365091947, 0.923879532511288071, -0.923879532511287849, 0.382683432365091447, 429 0.382683432365089005, -0.923879532511286850, 0.923879532511286294, -0.382683432365094389, 430 -0.382683432365092613, 0.923879532511285628, -0.923879532511284851, 0.382683432365090781, 431 },{ 432 0.336889853392220051, -0.857728610000272118, 0.989176509964781014, -0.671558954847018885, 433 0.049067674327417418, 0.595699304492433468, -0.970031253194543863, 0.903989293123442894, 434 -0.427555093430283195, -0.242980179903263954, 0.803207531480645720, -0.998795456205172405, 435 0.740951125354958773, -0.146730474455363497, -0.514102744193224437, 0.941544065183021028, 436 -0.941544065183021250, 0.514102744193218775, 0.146730474455362997, -0.740951125354958440, 437 0.998795456205172183, -0.803207531480643944, 0.242980179903264454, 0.427555093430279587, 438 -0.903989293123444226, 0.970031253194544085, -0.595699304492435244, -0.049067674327413380, 439 0.671558954847013334, -0.989176509964781681, 0.857728610000270564, -0.336889853392219440, 440 },{ 441 0.290284677254462331, -0.773010453362736882, 0.995184726672196818, -0.881921264348354828, 442 0.471396736825997364, 0.098017140329560812, -0.634393284163645599, 0.956940335732209380, 443 -0.956940335732208935, 0.634393284163644378, -0.098017140329560992, -0.471396736825998752, 444 0.881921264348354716, -0.995184726672196818, 0.773010453362735217, -0.290284677254465051, 445 -0.290284677254461276, 0.773010453362737326, -0.995184726672197151, 0.881921264348356604, 446 -0.471396736825999085, -0.098017140329560631, 0.634393284163646820, -0.956940335732209824, 447 0.956940335732209490, -0.634393284163640381, 0.098017140329566488, 0.471396736825993867, 448 -0.881921264348353828, 0.995184726672196929, -0.773010453362736549, 0.290284677254460111, 449 },{ 450 0.242980179903263982, -0.671558954847018330, 0.941544065183020695, -0.989176509964781014, 451 0.803207531480644832, -0.427555093430281807, -0.049067674327418521, 0.514102744193220773, 452 -0.857728610000272562, 0.998795456205172405, -0.903989293123442783, 0.595699304492433468, 453 -0.146730474455363497, -0.336889853392216942, 0.740951125354960549, -0.970031253194544196, 454 0.970031253194544196, -0.740951125354960771, 0.336889853392217165, 0.146730474455363247, 455 -0.595699304492433357, 0.903989293123442672, -0.998795456205172516, 0.857728610000270897, 456 -0.514102744193227101, 0.049067674327418764, 0.427555093430286415, -0.803207531480642611, 457 0.989176509964781236, -0.941544065183023138, 0.671558954847019440, -0.242980179903259930, 458 },{ 459 0.195090322016128331, -0.555570233019602178, 0.831469612302545014, -0.980785280403230320, 460 0.980785280403230431, -0.831469612302545014, 0.555570233019601512, -0.195090322016128581, 461 -0.195090322016126777, 0.555570233019602844, -0.831469612302545014, 0.980785280403230098, 462 -0.980785280403230986, 0.831469612302545569, -0.555570233019600734, 0.195090322016131218, 463 0.195090322016127610, -0.555570233019603621, 0.831469612302543459, -0.980785280403230320, 464 0.980785280403230098, -0.831469612302547012, 0.555570233019602955, -0.195090322016126888, 465 -0.195090322016124973, 0.555570233019607285, -0.831469612302545902, 0.980785280403229764, 466 -0.980785280403229320, 0.831469612302544570, -0.555570233019605175, 0.195090322016122558, 467 },{ 468 0.146730474455361748, -0.427555093430282474, 0.671558954847018108, -0.857728610000272340, 469 0.970031253194543863, -0.998795456205172405, 0.941544065183020362, -0.803207531480644610, 470 0.595699304492433690, -0.336889853392221328, 0.049067674327416683, 0.242980179903260873, 471 -0.514102744193224437, 0.740951125354960549, -0.903989293123443893, 0.989176509964781014, 472 -0.989176509964781014, 0.903989293123443893, -0.740951125354960549, 0.514102744193224437, 473 -0.242980179903260873, -0.049067674327420228, 0.336889853392221328, -0.595699304492433690, 474 0.803207531480644610, -0.941544065183020362, 0.998795456205172294, -0.970031253194544751, 475 0.857728610000274116, -0.671558954847021994, 0.427555093430287303, -0.146730474455368354, 476 },{ 477 0.098017140329560548, -0.290284677254462442, 0.471396736825997975, -0.634393284163645377, 478 0.773010453362736549, -0.881921264348354383, 0.956940335732209380, -0.995184726672197040, 479 0.995184726672196818, -0.956940335732208824, 0.881921264348355272, -0.773010453362737548, 480 0.634393284163643934, -0.471396736825999529, 0.290284677254461498, -0.098017140329563809, 481 -0.098017140329560382, 0.290284677254465051, -0.471396736825996476, 0.634393284163646820, 482 -0.773010453362735439, 0.881921264348355272, -0.956940335732207825, 0.995184726672196818, 483 -0.995184726672196596, 0.956940335732207270, -0.881921264348357714, 0.773010453362738659, 484 -0.634393284163645266, 0.471396736825994755, -0.290284677254456336, 0.098017140329565516, 485 },{ 486 0.049067674327417904, -0.146730474455361443, 0.242980179903264232, -0.336889853392219329, 487 0.427555093430282807, -0.514102744193220662, 0.595699304492432247, -0.671558954847017220, 488 0.740951125354960216, -0.803207531480645831, 0.857728610000272784, -0.903989293123443782, 489 0.941544065183021028, -0.970031253194544196, 0.989176509964781014, -0.998795456205172405, 490 0.998795456205172405, -0.989176509964781014, 0.970031253194544085, -0.941544065183021028, 491 0.903989293123443671, -0.857728610000272562, 0.803207531480641390, -0.740951125354960105, 492 0.671558954847014444, -0.595699304492434911, 0.514102744193217442, -0.427555093430284194, 493 0.336889853392215777, -0.242980179903266591, 0.146730474455357668, -0.049067674327421214, 494 },{ 495 0.000000000000000061, -0.000000000000000184, 0.000000000000000306, -0.000000000000000429, 496 0.000000000000000551, 0.000000000000001103, -0.000000000000000980, 0.000000000000000858, 497 -0.000000000000000735, 0.000000000000000613, -0.000000000000000491, -0.000000000000003185, 498 -0.000000000000000246, -0.000000000000003430, -0.000000000000000001, 0.000000000000003431, 499 0.000000000000000244, 0.000000000000003186, 0.000000000000000489, 0.000000000000002941, 500 -0.000000000000006371, -0.000000000000004409, 0.000000000000000979, 0.000000000000002451, 501 -0.000000000000005881, -0.000000000000004899, 0.000000000000001469, 0.000000000000001961, 502 -0.000000000000005392, -0.000000000000005389, 0.000000000000001959, 0.000000000000001472, 503 },{ 504 -0.049067674327418008, 0.146730474455361942, -0.242980179903264509, 0.336889853392220218, 505 -0.427555093430281807, 0.514102744193222660, -0.595699304492433801, 0.671558954847018441, 506 -0.740951125354958884, 0.803207531480644388, -0.857728610000273228, 0.903989293123444115, 507 -0.941544065183021250, 0.970031253194544196, -0.989176509964781014, 0.998795456205172405, 508 -0.998795456205172405, 0.989176509964781125, -0.970031253194544307, 0.941544065183021361, 509 -0.903989293123441229, 0.857728610000269787, -0.803207531480642611, 0.740951125354956774, 510 -0.671558954847016221, 0.595699304492431358, -0.514102744193219996, 0.427555093430280642, 511 -0.336889853392218996, 0.242980179903263260, -0.146730474455361554, 0.049067674327418272, 512 },{ 513 -0.098017140329560645, 0.290284677254462054, -0.471396736825997476, 0.634393284163646043, 514 -0.773010453362736993, 0.881921264348355494, -0.956940335732208935, 0.995184726672196818, 515 -0.995184726672197040, 0.956940335732208491, -0.881921264348356493, 0.773010453362737104, 516 -0.634393284163643600, 0.471396736825999307, -0.290284677254461498, 0.098017140329564045, 517 0.098017140329559896, -0.290284677254464329, 0.471396736825995644, -0.634393284163640381, 518 0.773010453362738992, -0.881921264348354494, 0.956940335732207270, -0.995184726672197262, 519 0.995184726672196929, -0.956940335732210157, 0.881921264348352385, -0.773010453362736216, 520 0.634393284163647930, -0.471396736825991758, 0.290284677254460111, -0.098017140329562588, 521 },{ 522 -0.146730474455361859, 0.427555093430282140, -0.671558954847018885, 0.857728610000271896, 523 -0.970031253194544085, 0.998795456205172405, -0.941544065183020917, 0.803207531480645720, 524 -0.595699304492432469, 0.336889853392220162, -0.049067674327419250, -0.242980179903261595, 525 0.514102744193218775, -0.740951125354960771, 0.903989293123443893, -0.989176509964781014, 526 0.989176509964781125, -0.903989293123444226, 0.740951125354961215, -0.514102744193225436, 527 0.242980179903262289, 0.049067674327411423, -0.336889853392219440, 0.595699304492437687, 528 -0.803207531480643166, 0.941544065183021806, -0.998795456205172183, 0.970031253194543752, 529 -0.857728610000268565, 0.671558954847019440, -0.427555093430278033, 0.146730474455365439, 530 },{ 531 -0.195090322016128193, 0.555570233019601845, -0.831469612302545125, 0.980785280403230431, 532 -0.980785280403230320, 0.831469612302544792, -0.555570233019602733, 0.195090322016126888, 533 0.195090322016128220, -0.555570233019600956, 0.831469612302545569, -0.980785280403230986, 534 0.980785280403230875, -0.831469612302545458, 0.555570233019600734, -0.195090322016131440, 535 -0.195090322016127138, 0.555570233019602955, -0.831469612302542904, 0.980785280403230098, 536 -0.980785280403230431, 0.831469612302544014, -0.555570233019598736, 0.195090322016122086, 537 0.195090322016122558, -0.555570233019599069, 0.831469612302544348, -0.980785280403230542, 538 0.980785280403229986, -0.831469612302542682, 0.555570233019596627, -0.195090322016133605, 539 },{ 540 -0.242980179903263871, 0.671558954847018330, -0.941544065183021028, 0.989176509964780903, 541 -0.803207531480645498, 0.427555093430281419, 0.049067674327416926, -0.514102744193222327, 542 0.857728610000271452, -0.998795456205172294, 0.903989293123442339, -0.595699304492432913, 543 0.146730474455362997, 0.336889853392217165, -0.740951125354960549, 0.970031253194544085, 544 -0.970031253194544307, 0.740951125354961215, -0.336889853392218053, -0.146730474455362053, 545 0.595699304492432136, -0.903989293123441895, 0.998795456205172627, -0.857728610000275671, 546 0.514102744193216998, -0.049067674327414358, -0.427555093430283750, 0.803207531480644943, 547 -0.989176509964780681, 0.941544065183022028, -0.671558954847022327, 0.242980179903257071, 548 },{ 549 -0.290284677254462387, 0.773010453362737215, -0.995184726672196929, 0.881921264348355272, 550 -0.471396736825998308, -0.098017140329561242, 0.634393284163644378, -0.956940335732208824, 551 0.956940335732208491, -0.634393284163643378, 0.098017140329563560, 0.471396736825996254, 552 -0.881921264348354939, 0.995184726672196818, -0.773010453362735217, 0.290284677254465273, 553 0.290284677254460832, -0.773010453362736771, 0.995184726672196263, -0.881921264348353828, 554 0.471396736826000362, 0.098017140329566002, -0.634393284163645266, 0.956940335732207159, 555 -0.956940335732208158, 0.634393284163647930, -0.098017140329555261, -0.471396736825997364, 556 0.881921264348352163, -0.995184726672196596, 0.773010453362738992, -0.290284677254457280, 557 },{ 558 -0.336889853392220162, 0.857728610000272007, -0.989176509964781125, 0.671558954847018219, 559 -0.049067674327418521, -0.595699304492433801, 0.970031253194544418, -0.903989293123443671, 560 0.427555093430285082, 0.242980179903265148, -0.803207531480644166, 0.998795456205172183, 561 -0.740951125354958440, 0.146730474455363247, 0.514102744193224437, -0.941544065183021028, 562 0.941544065183021361, -0.514102744193225436, -0.146730474455362053, 0.740951125354962437, 563 -0.998795456205172183, 0.803207531480644943, -0.242980179903259458, -0.427555093430277588, 564 0.903989293123443116, -0.970031253194542975, 0.595699304492437687, 0.049067674327417300, 565 -0.671558954847021328, 0.989176509964780126, -0.857728610000272562, 0.336889853392216665, 566 },{ 567 -0.382683432365089726, 0.923879532511286850, -0.923879532511286738, 0.382683432365089060, 568 0.382683432365089560, -0.923879532511286960, 0.923879532511286294, -0.382683432365091225, 569 -0.382683432365089005, 0.923879532511286738, -0.923879532511286516, 0.382683432365088505, 570 0.382683432365091669, -0.923879532511287849, 0.923879532511285406, -0.382683432365092391, 571 -0.382683432365094389, 0.923879532511288959, -0.923879532511284296, 0.382683432365096221, 572 0.382683432365084009, -0.923879532511284629, 0.923879532511288626, -0.382683432365093501, 573 -0.382683432365086729, 0.923879532511285739, -0.923879532511287405, 0.382683432365090781, 574 0.382683432365089449, -0.923879532511286850, 0.923879532511286294, -0.382683432365088061, 575 },{ 576 -0.427555093430282251, 0.970031253194543974, -0.803207531480645387, 0.049067674327418397, 577 0.740951125354959106, -0.989176509964780903, 0.514102744193220995, 0.336889853392221217, 578 -0.941544065183021361, 0.857728610000272895, -0.146730474455359361, -0.671558954847017886, 579 0.998795456205172183, -0.595699304492433357, -0.242980179903260873, 0.903989293123443671, 580 -0.903989293123441229, 0.242980179903262289, 0.595699304492432136, -0.998795456205172183, 581 0.671558954847013667, 0.146730474455364940, -0.857728610000272118, 0.941544065183021806, 582 -0.336889853392225935, -0.514102744193225880, 0.989176509964781236, -0.740951125354960105, 583 -0.049067674327413380, 0.803207531480648718, -0.970031253194543197, 0.427555093430281974, 584 },{ 585 -0.471396736825997698, 0.995184726672196929, -0.634393284163645377, -0.290284677254462553, 586 0.956940335732208935, -0.773010453362736771, -0.098017140329560992, 0.881921264348355272, 587 -0.881921264348356493, 0.098017140329563560, 0.773010453362735106, -0.956940335732209713, 588 0.290284677254465051, 0.634393284163643378, -0.995184726672197151, 0.471396736825999918, 589 0.471396736826001694, -0.995184726672196596, 0.634393284163641824, 0.290284677254460111, 590 -0.956940335732210268, 0.773010453362738326, 0.098017140329565516, -0.881921264348354050, 591 0.881921264348352607, -0.098017140329562588, -0.773010453362740213, 0.956940335732209380, 592 -0.290284677254457280, -0.634393284163644156, 0.995184726672196374, -0.471396736825986540, 593 },{ 594 -0.514102744193221661, 0.998795456205172405, -0.427555093430282696, -0.595699304492434023, 595 0.989176509964780903, -0.336889853392219829, -0.671558954847018441, 0.970031253194544085, 596 -0.242980179903264426, -0.740951125354960882, 0.941544065183021139, -0.146730474455359611, 597 -0.803207531480643944, 0.903989293123442672, -0.049067674327420228, -0.857728610000272562, 598 0.857728610000269787, 0.049067674327411423, -0.903989293123441895, 0.803207531480644943, 599 0.146730474455364940, -0.941544065183023027, 0.740951125354962104, 0.242980179903262788, 600 -0.970031253194544529, 0.671558954847014444, 0.336889853392214833, -0.989176509964780681, 601 0.595699304492432469, 0.427555093430285971, -0.998795456205172738, 0.514102744193224548, 602 },{ 603 -0.555570233019602289, 0.980785280403230431, -0.195090322016128026, -0.831469612302545014, 604 0.831469612302544792, 0.195090322016128442, -0.980785280403230320, 0.555570233019600179, 605 0.555570233019603843, -0.980785280403230209, 0.195090322016127610, 0.831469612302545236, 606 -0.831469612302545569, -0.195090322016127138, 0.980785280403230098, -0.555570233019598292, 607 -0.555570233019605619, 0.980785280403229764, -0.195090322016125445, -0.831469612302546457, 608 0.831469612302544348, 0.195090322016129303, -0.980785280403230542, 0.555570233019602400, 609 0.555570233019601512, -0.980785280403230764, 0.195090322016130246, 0.831469612302543792, 610 -0.831469612302547012, -0.195090322016124473, 0.980785280403232318, -0.555570233019594628, 611 },{ 612 -0.595699304492433357, 0.941544065183020695, 0.049067674327417418, -0.970031253194544085, 613 0.514102744193220773, 0.671558954847018441, -0.903989293123443671, -0.146730474455363497, 614 0.989176509964780570, -0.427555093430282196, -0.740951125354960771, 0.857728610000273117, 615 0.242980179903264454, -0.998795456205172516, 0.336889853392221328, 0.803207531480641390, 616 -0.803207531480642611, -0.336889853392219440, 0.998795456205172627, -0.242980179903259458, 617 -0.857728610000272118, 0.740951125354962104, 0.427555093430286859, -0.989176509964780903, 618 0.146730474455365439, 0.903989293123445892, -0.671558954847017331, -0.514102744193219108, 619 0.970031253194542420, -0.049067674327415822, -0.941544065183024803, 0.595699304492438797, 620 },{ 621 -0.634393284163645377, 0.881921264348355050, 0.290284677254462664, -0.995184726672196818, 622 0.098017140329559285, 0.956940335732208824, -0.471396736825998752, -0.773010453362737548, 623 0.773010453362737104, 0.471396736825996254, -0.956940335732209713, -0.098017140329563560, 624 0.995184726672197040, -0.290284677254461998, -0.881921264348357936, 0.634393284163647153, 625 0.634393284163648263, -0.881921264348357270, -0.290284677254463386, 0.995184726672196263, 626 -0.098017140329562089, -0.956940335732210157, 0.471396736826001250, 0.773010453362738104, 627 -0.773010453362741212, -0.471396736825996920, 0.956940335732207381, 0.098017140329557217, 628 -0.995184726672197151, 0.290284677254468104, 0.881921264348361711, -0.634393284163641158, 629 },{ 630 -0.671558954847018441, 0.803207531480644721, 0.514102744193221328, -0.903989293123443449, 631 -0.336889853392221550, 0.970031253194543974, 0.146730474455360110, -0.998795456205172405, 632 0.049067674327415829, 0.989176509964780570, -0.242980179903264926, -0.941544065183021028, 633 0.427555093430279587, 0.857728610000270897, -0.595699304492433690, -0.740951125354960105, 634 0.740951125354956774, 0.595699304492437687, -0.857728610000275671, -0.427555093430277588, 635 0.941544065183021806, 0.242980179903262788, -0.989176509964780903, -0.049067674327420721, 636 0.998795456205172627, -0.146730474455355253, -0.970031253194542642, 0.336889853392223604, 637 0.903989293123448667, -0.514102744193233874, -0.803207531480637615, 0.671558954847025991, 638 },{ 639 -0.707106781186547462, 0.707106781186547684, 0.707106781186547795, -0.707106781186547351, 640 -0.707106781186546352, 0.707106781186547573, 0.707106781186548572, -0.707106781186547906, 641 -0.707106781186545796, 0.707106781186545574, 0.707106781186548017, -0.707106781186548350, 642 -0.707106781186545241, 0.707106781186546129, 0.707106781186542466, -0.707106781186543909, 643 -0.707106781186549793, 0.707106781186546685, 0.707106781186547018, -0.707106781186549460, 644 -0.707106781186544242, 0.707106781186552236, 0.707106781186551458, -0.707106781186544908, 645 -0.707106781186548683, 0.707106781186547684, 0.707106781186546018, -0.707106781186540467, 646 -0.707106781186543243, 0.707106781186543243, 0.707106781186540467, -0.707106781186546018, 647 },{ 648 -0.740951125354959217, 0.595699304492433246, 0.857728610000271896, -0.427555093430281308, 649 -0.941544065183020251, 0.242980179903264093, 0.989176509964781125, -0.049067674327419250, 650 -0.998795456205172405, -0.146730474455362997, 0.970031253194543419, 0.336889853392216942, 651 -0.903989293123444226, -0.514102744193227101, 0.803207531480644610, 0.671558954847014444, 652 -0.671558954847016221, -0.803207531480643166, 0.514102744193216998, 0.903989293123443116, 653 -0.336889853392225935, -0.970031253194544529, 0.146730474455365439, 0.998795456205172627, 654 0.049067674327416808, -0.989176509964782014, -0.242980179903265148, 0.941544065183017476, 655 0.427555093430285527, -0.857728610000273117, -0.595699304492427029, 0.740951125354968321, 656 },{ 657 -0.773010453362736993, 0.471396736825997975, 0.956940335732209046, -0.098017140329559174, 658 -0.995184726672197040, -0.290284677254462109, 0.881921264348354716, 0.634393284163643934, 659 -0.634393284163643600, -0.881921264348354939, 0.290284677254465051, 0.995184726672197040, 660 0.098017140329559660, -0.956940335732207825, -0.471396736825992146, 0.773010453362738104, 661 0.773010453362738659, -0.471396736826003859, -0.956940335732208158, 0.098017140329558675, 662 0.995184726672196263, 0.290284677254459167, -0.881921264348354494, -0.634393284163649818, 663 0.634393284163648707, 0.881921264348355161, -0.290284677254457779, -0.995184726672197817, 664 -0.098017140329574287, 0.956940335732211822, 0.471396736825992591, -0.773010453362737771, 665 },{ 666 -0.803207531480644832, 0.336889853392220051, 0.998795456205172405, 0.242980179903262428, 667 -0.857728610000272562, -0.740951125354958884, 0.427555093430285082, 0.989176509964780570, 668 0.146730474455359611, -0.903989293123444004, -0.671558954847017664, 0.514102744193222105, 669 0.970031253194544085, 0.049067674327418764, -0.941544065183020362, -0.595699304492434911, 670 0.595699304492431358, 0.941544065183021806, -0.049067674327414358, -0.970031253194542975, 671 -0.514102744193225880, 0.671558954847014444, 0.903989293123445892, -0.146730474455355253, 672 -0.989176509964782014, -0.427555093430276256, 0.740951125354963103, 0.857728610000276670, 673 -0.242980179903268478, -0.998795456205171850, -0.336889853392216720, 0.803207531480638170, 674 },{ 675 -0.831469612302545347, 0.195090322016127915, 0.980785280403230320, 0.555570233019601512, 676 -0.555570233019602733, -0.980785280403230320, -0.195090322016128082, 0.831469612302547123, 677 0.831469612302545458, -0.195090322016131218, -0.980785280403230320, -0.555570233019600179, 678 0.555570233019601178, 0.980785280403230098, 0.195090322016123030, -0.831469612302542127, 679 -0.831469612302546457, 0.195090322016129275, 0.980785280403231319, 0.555570233019607729, 680 -0.555570233019599513, -0.980785280403230431, -0.195090322016124973, 0.831469612302548899, 681 0.831469612302547567, -0.195090322016141293, -0.980785280403228099, -0.555570233019609283, 682 0.555570233019597848, 0.980785280403230875, 0.195090322016126888, -0.831469612302547900, 683 },{ 684 -0.857728610000272007, 0.049067674327418154, 0.903989293123443449, 0.803207531480644721, 685 -0.146730474455362164, -0.941544065183020917, -0.740951125354961104, 0.242980179903261123, 686 0.970031253194543308, 0.671558954847020440, -0.336889853392217609, -0.989176509964780570, 687 -0.595699304492435244, 0.427555093430286415, 0.998795456205172294, 0.514102744193217442, 688 -0.514102744193219996, -0.998795456205172183, -0.427555093430283750, 0.595699304492437687, 689 0.989176509964781236, 0.336889853392214833, -0.671558954847017331, -0.970031253194542642, 690 -0.242980179903265148, 0.740951125354963103, 0.941544065183021139, 0.146730474455369797, 691 -0.803207531480652825, -0.903989293123440674, -0.049067674327418764, 0.857728610000268121, 692 },{ 693 -0.881921264348354939, -0.098017140329560840, 0.773010453362736549, 0.956940335732208935, 694 0.290284677254462220, -0.634393284163645932, -0.995184726672196818, -0.471396736825999529, 695 0.471396736825999307, 0.995184726672196818, 0.634393284163643378, -0.290284677254461998, 696 -0.956940335732207825, -0.773010453362741212, 0.098017140329565017, 0.881921264348355605, 697 0.881921264348355827, 0.098017140329565516, -0.773010453362740879, -0.956940335732207936, 698 -0.290284677254462442, 0.634393284163643045, 0.995184726672197484, 0.471396736825993479, 699 -0.471396736825986540, -0.995184726672196707, -0.634393284163638049, 0.290284677254454948, 700 0.956940335732209824, 0.773010453362745875, -0.098017140329557703, -0.881921264348358935, 701 },{ 702 -0.903989293123443338, -0.242980179903264509, 0.595699304492433468, 0.998795456205172405, 703 0.671558954847018441, -0.146730474455362414, -0.857728610000271008, -0.941544065183021250, 704 -0.336889853392220606, 0.514102744193221883, 0.989176509964781125, 0.740951125354957996, 705 -0.049067674327413380, -0.803207531480642611, -0.970031253194544751, -0.427555093430284194, 706 0.427555093430280642, 0.970031253194543752, 0.803207531480644943, 0.049067674327417300, 707 -0.740951125354960105, -0.989176509964780681, -0.514102744193219108, 0.336889853392223604, 708 0.941544065183017476, 0.857728610000276670, 0.146730474455369797, -0.671558954847012890, 709 -0.998795456205172738, -0.595699304492438020, 0.242980179903258958, 0.903989293123441451, 710 },{ 711 -0.923879532511286738, -0.382683432365089893, 0.382683432365089060, 0.923879532511286183, 712 0.923879532511286850, 0.382683432365089116, -0.382683432365091447, -0.923879532511286516, 713 -0.923879532511287960, -0.382683432365088283, 0.382683432365089005, 0.923879532511285517, 714 0.923879532511288959, 0.382683432365090781, -0.382683432365093057, -0.923879532511284407, 715 -0.923879532511287294, -0.382683432365086729, 0.382683432365084009, 0.923879532511286183, 716 0.923879532511285628, 0.382683432365095777, -0.382683432365088061, -0.923879532511287849, 717 -0.923879532511289292, -0.382683432365078569, 0.382683432365092169, 0.923879532511284074, 718 0.923879532511282187, 0.382683432365087617, -0.382683432365083065, -0.923879532511291179, 719 },{ 720 -0.941544065183020806, -0.514102744193221439, 0.146730474455361803, 0.740951125354960105, 721 0.998795456205172405, 0.803207531480644388, 0.242980179903265148, -0.427555093430282196, 722 -0.903989293123444004, -0.970031253194543308, -0.595699304492435466, 0.049067674327416808, 723 0.671558954847013334, 0.989176509964781236, 0.857728610000274116, 0.336889853392215777, 724 -0.336889853392218996, -0.857728610000268565, -0.989176509964780681, -0.671558954847021328, 725 -0.049067674327413380, 0.595699304492432469, 0.970031253194542420, 0.903989293123448667, 726 0.427555093430285527, -0.242980179903268478, -0.803207531480652825, -0.998795456205172738, 727 -0.740951125354957774, -0.146730474455351367, 0.514102744193213668, 0.941544065183020473, 728 },{ 729 -0.956940335732208824, -0.634393284163644822, -0.098017140329561492, 0.471396736825998419, 730 0.881921264348354605, 0.995184726672196818, 0.773010453362735217, 0.290284677254461498, 731 -0.290284677254461498, -0.773010453362735217, -0.995184726672197151, -0.881921264348357936, 732 -0.471396736825992146, 0.098017140329565017, 0.634393284163647597, 0.956940335732209157, 733 0.956940335732209157, 0.634393284163647597, 0.098017140329565017, -0.471396736825992146, 734 -0.881921264348357936, -0.995184726672196485, -0.773010453362735217, -0.290284677254461498, 735 0.290284677254461498, 0.773010453362735217, 0.995184726672196485, 0.881921264348357936, 736 0.471396736826004692, -0.098017140329550875, -0.634393284163636606, -0.956940335732205050, 737 },{ 738 -0.970031253194543974, -0.740951125354959328, -0.336889853392220107, 0.146730474455362025, 739 0.595699304492432469, 0.903989293123443782, 0.998795456205172405, 0.857728610000271230, 740 0.514102744193224659, 0.049067674327419257, -0.427555093430282862, -0.803207531480646719, 741 -0.989176509964781681, -0.941544065183023138, -0.671558954847021994, -0.242980179903266591, 742 0.242980179903263260, 0.671558954847019440, 0.941544065183022028, 0.989176509964780126, 743 0.803207531480648718, 0.427555093430285971, -0.049067674327415822, -0.514102744193233874, 744 -0.857728610000273117, -0.998795456205171850, -0.903989293123440674, -0.595699304492438020, 745 -0.146730474455351367, 0.336889853392218552, 0.740951125354949891, 0.970031253194544640, 746 },{ 747 -0.980785280403230431, -0.831469612302545125, -0.555570233019601512, -0.195090322016128581, 748 0.195090322016126888, 0.555570233019600179, 0.831469612302547123, 0.980785280403230875, 749 0.980785280403230209, 0.831469612302545125, 0.555570233019602955, 0.195090322016130246, 750 -0.195090322016132162, -0.555570233019598736, -0.831469612302546235, -0.980785280403229209, 751 -0.980785280403230542, -0.831469612302542127, -0.555570233019604398, -0.195090322016124973, 752 0.195090322016123530, 0.555570233019603177, 0.831469612302541350, 0.980785280403230209, 753 0.980785280403229431, 0.831469612302539129, 0.555570233019611726, 0.195090322016133605, 754 -0.195090322016128803, -0.555570233019607618, -0.831469612302552230, -0.980785280403228543, 755 },{ 756 -0.989176509964781014, -0.903989293123443116, -0.740951125354959217, -0.514102744193222549, 757 -0.242980179903265509, 0.049067674327415579, 0.336889853392220384, 0.595699304492435910, 758 0.803207531480644166, 0.941544065183021361, 0.998795456205172294, 0.970031253194545751, 759 0.857728610000270564, 0.671558954847019440, 0.427555093430287303, 0.146730474455357668, 760 -0.146730474455361554, -0.427555093430278033, -0.671558954847022327, -0.857728610000272562, 761 -0.970031253194543197, -0.998795456205172738, -0.941544065183024803, -0.803207531480637615, 762 -0.595699304492427029, -0.336889853392216720, -0.049067674327418764, 0.242980179903258958, 763 0.514102744193213668, 0.740951125354949891, 0.903989293123447779, 0.989176509964781903, 764 },{ 765 -0.995184726672196929, -0.956940335732209046, -0.881921264348354716, -0.773010453362737882, 766 -0.634393284163644267, -0.471396736825999751, -0.290284677254465051, -0.098017140329563809, 767 0.098017140329564045, 0.290284677254465273, 0.471396736825999918, 0.634393284163647153, 768 0.773010453362738104, 0.881921264348355605, 0.956940335732209157, 0.995184726672196929, 769 0.995184726672196929, 0.956940335732208935, 0.881921264348355383, 0.773010453362737771, 770 0.634393284163646820, 0.471396736825999529, 0.290284677254451229, 0.098017140329563560, 771 -0.098017140329571359, -0.290284677254458723, -0.471396736826006413, -0.634393284163641824, 772 -0.773010453362742767, -0.881921264348352385, -0.956940335732211267, -0.995184726672196263, 773 },{ 774 -0.998795456205172405, -0.989176509964781014, -0.970031253194544085, -0.941544065183020251, 775 -0.903989293123442783, -0.857728610000273228, -0.803207531480644166, -0.740951125354960771, 776 -0.671558954847017664, -0.595699304492435466, -0.514102744193227101, -0.427555093430284638, 777 -0.336889853392219440, -0.242980179903259930, -0.146730474455368354, -0.049067674327421214, 778 0.049067674327418272, 0.146730474455365439, 0.242980179903257071, 0.336889853392216665, 779 0.427555093430281974, 0.514102744193224548, 0.595699304492438797, 0.671558954847025991, 780 0.740951125354968321, 0.803207531480638170, 0.857728610000268121, 0.903989293123441451, 781 0.941544065183020473, 0.970031253194544640, 0.989176509964781903, 0.998795456205172849, 782 },{ 783 -1.000000000000000000, -1.000000000000000000, -1.000000000000000000, -1.000000000000000000, 784 -1.000000000000000000, -1.000000000000000000, -1.000000000000000000, -1.000000000000000000, 785 -1.000000000000000000, -1.000000000000000000, -1.000000000000000000, -1.000000000000000000, 786 -1.000000000000000000, -1.000000000000000000, -1.000000000000000000, -1.000000000000000000, 787 -1.000000000000000000, -1.000000000000000000, -1.000000000000000000, -1.000000000000000000, 788 -1.000000000000000000, -1.000000000000000000, -1.000000000000000000, -1.000000000000000000, 789 -1.000000000000000000, -1.000000000000000000, -1.000000000000000000, -1.000000000000000000, 790 -1.000000000000000000, -1.000000000000000000, -1.000000000000000000, -1.000000000000000000, 791 },{ 792 -0.998795456205172405, -0.989176509964781125, -0.970031253194543863, -0.941544065183020917, 793 -0.903989293123443671, -0.857728610000271008, -0.803207531480646053, -0.740951125354958440, 794 -0.671558954847020773, -0.595699304492433468, -0.514102744193225436, -0.427555093430283306, 795 -0.336889853392218552, -0.242980179903259458, -0.146730474455368326, -0.049067674327421699, 796 0.049067674327417300, 0.146730474455363968, 0.242980179903268950, 0.336889853392214389, 797 0.427555093430279365, 0.514102744193233874, 0.595699304492435688, 0.671558954847012224, 798 0.740951125354964990, 0.803207531480643500, 0.857728610000265013, 0.903989293123444892, 799 0.941544065183018142, 0.970031253194546306, 0.989176509964780681, 0.998795456205171739, 800 },{ 801 -0.995184726672196929, -0.956940335732208713, -0.881921264348354383, -0.773010453362736771, 802 -0.634393284163645932, -0.471396736825995866, -0.290284677254461276, -0.098017140329560382, 803 0.098017140329559896, 0.290284677254460832, 0.471396736826001694, 0.634393284163648263, 804 0.773010453362738659, 0.881921264348355827, 0.956940335732209157, 0.995184726672196929, 805 0.995184726672196929, 0.956940335732209380, 0.881921264348356382, 0.773010453362739325, 806 0.634393284163638049, 0.471396736825989982, 0.290284677254454948, 0.098017140329553804, 807 -0.098017140329566488, -0.290284677254467161, -0.471396736826001250, -0.634393284163647930, 808 -0.773010453362738326, -0.881921264348355605, -0.956940335732208935, -0.995184726672196818, 809 },{ 810 -0.989176509964781014, -0.903989293123443338, -0.740951125354959994, -0.514102744193220884, 811 -0.242980179903264204, 0.049067674327419986, 0.336889853392217387, 0.595699304492432913, 812 0.803207531480645942, 0.941544065183019807, 0.998795456205172405, 0.970031253194545306, 813 0.857728610000270120, 0.671558954847019107, 0.427555093430287303, 0.146730474455358167, 814 -0.146730474455360582, -0.427555093430276700, -0.671558954847020884, -0.857728610000278668, 815 -0.970031253194542531, -0.998795456205172183, -0.941544065183016476, -0.803207531480648718, 816 -0.595699304492430914, -0.336889853392208394, -0.049067674327424635, 0.242980179903266591, 817 0.514102744193232208, 0.740951125354954443, 0.903989293123444448, 0.989176509964782680, 818 },{ 819 -0.980785280403230431, -0.831469612302545569, -0.555570233019602622, -0.195090322016126777, 820 0.195090322016128220, 0.555570233019603843, 0.831469612302545458, 0.980785280403230209, 821 0.980785280403230986, 0.831469612302543792, 0.555570233019607285, 0.195090322016128803, 822 -0.195090322016133133, -0.555570233019599069, -0.831469612302546235, -0.980785280403229098, 823 -0.980785280403230764, -0.831469612302542904, -0.555570233019606063, -0.195090322016141293, 824 0.195090322016134576, 0.555570233019600290, 0.831469612302539129, 0.980785280403232207, 825 0.980785280403230431, 0.831469612302550010, 0.555570233019592963, 0.195090322016125917, 826 -0.195090322016122086, -0.555570233019613391, -0.831469612302547900, -0.980785280403229653, 827 },{ 828 -0.970031253194543974, -0.740951125354958662, -0.336889853392219552, 0.146730474455360332, 829 0.595699304492433468, 0.903989293123444115, 0.998795456205172183, 0.857728610000273117, 830 0.514102744193222105, 0.049067674327416808, -0.427555093430284638, -0.803207531480647607, 831 -0.989176509964781903, -0.941544065183022916, -0.671558954847021994, -0.242980179903267063, 832 0.242980179903262289, 0.671558954847018441, 0.941544065183021361, 0.989176509964782569, 833 0.803207531480650494, 0.427555093430289079, -0.049067674327411916, -0.514102744193217887, 834 -0.857728610000270564, -0.998795456205172294, -0.903989293123443116, -0.595699304492431692, 835 -0.146730474455358167, 0.336889853392224992, 0.740951125354963658, 0.970031253194546084, 836 },{ 837 -0.956940335732208824, -0.634393284163645377, -0.098017140329559174, 0.471396736825996920, 838 0.881921264348355272, 0.995184726672196707, 0.773010453362737326, 0.290284677254465051, 839 -0.290284677254464329, -0.773010453362736771, -0.995184726672196596, -0.881921264348357270, 840 -0.471396736826003859, 0.098017140329565516, 0.634393284163647597, 0.956940335732208935, 841 0.956940335732209380, 0.634393284163648707, 0.098017140329566974, -0.471396736825989982, 842 -0.881921264348356604, -0.995184726672198150, -0.773010453362737771, -0.290284677254452117, 843 0.290284677254456835, 0.773010453362740879, 0.995184726672195930, 0.881921264348354272, 844 0.471396736825985707, -0.098017140329557703, -0.634393284163652482, -0.956940335732206715, 845 },{ 846 -0.941544065183020806, -0.514102744193221994, 0.146730474455360582, 0.740951125354958884, 847 0.998795456205172405, 0.803207531480643944, 0.242980179903261345, -0.427555093430278921, 848 -0.903989293123442228, -0.970031253194544418, -0.595699304492428139, 0.049067674327418279, 849 0.671558954847014000, 0.989176509964781236, 0.857728610000274116, 0.336889853392216221, 850 -0.336889853392218053, -0.857728610000275116, -0.989176509964781014, -0.671558954847023104, 851 -0.049067674327430505, 0.595699304492441128, 0.970031253194544862, 0.903989293123444448, 852 0.427555093430289968, -0.242980179903277027, -0.803207531480649273, -0.998795456205172294, 853 -0.740951125354962437, -0.146730474455372711, 0.514102744193231320, 0.941544065183022472, 854 },{ 855 -0.923879532511286850, -0.382683432365090559, 0.382683432365089560, 0.923879532511286850, 856 0.923879532511286405, 0.382683432365088283, -0.382683432365088505, -0.923879532511287849, 857 -0.923879532511286850, -0.382683432365092613, 0.382683432365090781, 0.923879532511288737, 858 0.923879532511288626, 0.382683432365090337, -0.382683432365093057, -0.923879532511284296, 859 -0.923879532511287627, -0.382683432365088061, 0.382683432365082177, 0.923879532511285184, 860 0.923879532511286738, 0.382683432365085785, -0.382683432365097609, -0.923879532511291623, 861 -0.923879532511291179, -0.382683432365096665, 0.382683432365086729, 0.923879532511287072, 862 0.923879532511284851, 0.382683432365081289, -0.382683432365102105, -0.923879532511282631, 863 },{ 864 -0.903989293123443227, -0.242980179903263482, 0.595699304492433912, 0.998795456205172405, 865 0.671558954847017442, -0.146730474455363247, -0.857728610000273006, -0.941544065183020029, 866 -0.336889853392217831, 0.514102744193217887, 0.989176509964780348, 0.740951125354961770, 867 -0.049067674327414358, -0.803207531480642944, -0.970031253194544751, -0.427555093430284638, 868 0.427555093430279809, 0.970031253194543419, 0.803207531480637615, 0.049067674327419743, 869 -0.740951125354967655, -0.989176509964781125, -0.514102744193210337, 0.336889853392219440, 870 0.941544065183025469, 0.857728610000272118, 0.146730474455375598, -0.671558954847018774, 871 -0.998795456205173071, -0.595699304492432469, 0.242980179903251381, 0.903989293123444004, 872 },{ 873 -0.881921264348355050, -0.098017140329560687, 0.773010453362737993, 0.956940335732208380, 874 0.290284677254464329, -0.634393284163646598, -0.995184726672197151, -0.471396736825996476, 875 0.471396736825995644, 0.995184726672196263, 0.634393284163641824, -0.290284677254463386, 876 -0.956940335732208158, -0.773010453362740879, 0.098017140329565017, 0.881921264348355383, 877 0.881921264348356382, 0.098017140329566974, -0.773010453362739658, -0.956940335732208713, 878 -0.290284677254465273, 0.634393284163640381, 0.995184726672197928, 0.471396736826009854, 879 -0.471396736826007301, -0.995184726672197595, -0.634393284163642601, 0.290284677254462442, 880 0.956940335732207825, 0.773010453362741434, -0.098017140329549904, -0.881921264348361711, 881 },{ 882 -0.857728610000272118, 0.049067674327417418, 0.903989293123442894, 0.803207531480645720, 883 -0.146730474455363497, -0.941544065183021250, -0.740951125354958440, 0.242980179903264454, 884 0.970031253194544085, 0.671558954847013334, -0.336889853392219440, -0.989176509964781903, 885 -0.595699304492434467, 0.427555093430286859, 0.998795456205172294, 0.514102744193217887, 886 -0.514102744193219108, -0.998795456205172960, -0.427555093430285527, 0.595699304492435688, 887 0.989176509964779571, 0.336889853392231431, -0.671558954847014444, -0.970031253194543641, 888 -0.242980179903256127, 0.740951125354949891, 0.941544065183023138, 0.146730474455362025, 889 -0.803207531480648718, -0.903989293123437676, -0.049067674327426591, 0.857728610000271119, 890 },{ 891 -0.831469612302545236, 0.195090322016128942, 0.980785280403230431, 0.555570233019602844, 892 -0.555570233019600956, -0.980785280403230209, -0.195090322016131218, 0.831469612302545125, 893 0.831469612302543792, -0.195090322016133605, -0.980785280403229320, -0.555570233019604842, 894 0.555570233019601956, 0.980785280403229986, 0.195090322016123030, -0.831469612302541905, 895 -0.831469612302547012, 0.195090322016127860, 0.980785280403228099, 0.555570233019597848, 896 -0.555570233019597071, -0.980785280403228321, -0.195090322016128803, 0.831469612302538574, 897 0.831469612302542460, -0.195090322016122086, -0.980785280403232540, -0.555570233019602733, 898 0.555570233019592186, 0.980785280403229431, 0.195090322016134576, -0.831469612302551120, 899 },{ 900 -0.803207531480644943, 0.336889853392220218, 0.998795456205172405, 0.242980179903264093, 901 -0.857728610000273228, -0.740951125354958329, 0.427555093430282196, 0.989176509964781125, 902 0.146730474455356696, -0.903989293123445004, -0.671558954847016221, 0.514102744193223327, 903 0.970031253194543752, 0.049067674327418272, -0.941544065183020362, -0.595699304492435244, 904 0.595699304492430581, 0.941544065183017476, -0.049067674327426598, -0.970031253194545862, 905 -0.514102744193216221, 0.671558954847022438, 0.903989293123441451, -0.146730474455364940, 906 -0.989176509964781236, -0.427555093430281086, 0.740951125354959106, 0.857728610000272562, 907 -0.242980179903261817, -0.998795456205172183, -0.336889853392224048, 0.803207531480641723, 908 },{ 909 -0.773010453362736882, 0.471396736825997364, 0.956940335732209380, -0.098017140329560992, 910 -0.995184726672196818, -0.290284677254461276, 0.881921264348356604, 0.634393284163646820, 911 -0.634393284163640381, -0.881921264348353828, 0.290284677254460111, 0.995184726672196263, 912 0.098017140329558675, -0.956940335732207936, -0.471396736825992146, 0.773010453362737771, 913 0.773010453362739325, -0.471396736825989982, -0.956940335732208713, 0.098017140329570387, 914 0.995184726672195930, 0.290284677254462442, -0.881921264348359379, -0.634393284163653259, 915 0.634393284163644933, 0.881921264348351053, -0.290284677254452117, -0.995184726672197040, 916 -0.098017140329552832, 0.956940335732205605, 0.471396736825999529, -0.773010453362741545, 917 },{ 918 -0.740951125354959106, 0.595699304492432691, 0.857728610000272451, -0.427555093430282973, 919 -0.941544065183019807, 0.242980179903264926, 0.989176509964781125, -0.049067674327415586, 920 -0.998795456205172183, -0.146730474455360582, 0.970031253194545529, 0.336889853392222216, 921 -0.903989293123444670, -0.514102744193226657, 0.803207531480644610, 0.671558954847014777, 922 -0.671558954847015444, -0.803207531480644055, 0.514102744193215333, 0.903989293123438120, 923 -0.336889853392223160, -0.970031253194545306, 0.146730474455375626, 0.998795456205172183, 924 0.049067674327421699, -0.989176509964779127, -0.242980179903257071, 0.941544065183020140, 925 0.427555093430291744, -0.857728610000276670, -0.595699304492433357, 0.740951125354953222, 926 } 927 }; 928 929 //0: 48000 to 32000, 1: 48000 to 44100 930 static final float Resample[][] = { 931 { 932 -1, 0, 0.5f // write pcm, save act pcm, save act pcm before recalc to new pcm 933 },{ 934 -1, 0, 935 0.088435374f, 0.17687075f, 0.26530612f, 0.3537415f, 0.44217688f, 0.53061223f, 0.61904764f, 0.707483f, 0.79591835f, 0.88435376f, 0.9727891f, 0, 936 0.06122449f, 0.14965986f, 0.23809524f, 0.3265306f, 0.414966f, 0.50340134f, 0.59183675f, 0.6802721f, 0.76870745f, 0.85714287f, 0.9455782f, 0, 937 0.034013607f, 0.12244898f, 0.21088435f, 0.2993197f, 0.3877551f, 0.47619048f, 0.56462586f, 0.6530612f, 0.7414966f, 0.829932f, 0.9183673f, 0, 938 0.006802721f, 0.0952381f, 0.18367347f, 0.27210885f, 0.3605442f, 0.4489796f, 0.53741497f, 0.6258503f, 0.71428573f, 0.8027211f, 0.89115644f, 0.97959185f, 0, 939 0.06802721f, 0.15646258f, 0.24489796f, 0.33333334f, 0.4217687f, 0.5102041f, 0.5986394f, 0.68707484f, 0.7755102f, 0.8639456f, 0.95238096f, 0, 940 0.040816326f, 0.1292517f, 0.21768707f, 0.30612245f, 0.39455783f, 0.4829932f, 0.5714286f, 0.65986395f, 0.7482993f, 0.8367347f, 0.92517006f, 0, 941 0.013605442f, 0.10204082f, 0.1904762f, 0.27891156f, 0.36734694f, 0.45578232f, 0.5442177f, 0.63265306f, 0.7210884f, 0.8095238f, 0.8979592f, 0.9863946f, 0, 942 0.07482993f, 0.1632653f, 0.25170067f, 0.34013605f, 0.42857143f, 0.5170068f, 0.60544217f, 0.6938776f, 0.7823129f, 0.8707483f, 0.9591837f, 0, 943 0.04761905f, 0.13605443f, 0.2244898f, 0.31292516f, 0.40136054f, 0.48979592f, 0.5782313f, 0.6666667f, 0.75510204f, 0.8435374f, 0.9319728f, 0, 944 0.020408163f, 0.108843535f, 0.19727892f, 0.2857143f, 0.37414965f, 0.46258503f, 0.5510204f, 0.6394558f, 0.72789115f, 0.81632656f, 0.9047619f, 0.99319726f, 0, 945 0.08163265f, 0.17006803f, 0.2585034f, 0.3469388f, 0.43537414f, 0.52380955f, 0.6122449f, 0.70068026f, 0.78911567f, 0.877551f, 0.9659864f, 0, 946 0.054421768f, 0.14285715f, 0.23129252f, 0.3197279f, 0.40816328f, 0.49659863f, 0.585034f, 0.67346936f, 0.7619048f, 0.8503401f, 0.93877554f, 0, 947 0.027210884f, 0.11564626f, 0.20408164f, 0.292517f, 0.3809524f, 0.46938777f, 0.5578231f, 0.64625853f, 0.7346939f, 0.82312924f, 0.91156465f 948 } 949 }; 950 951 //0: 48000 to 32000, 1: 48000 to 44100 952 static final int Resample_frequency[][] = { 953 { 2, 3 }, 954 { 147, 160 } 955 }; 956 957 public static byte RIFF[] = { 958 0x52, 0x49, 0x46, 0x46, //RIFF 959 0, 0, 0, 0, //32-bit filesize-8 960 0x57, 0x41, 0x56, 0x45, //WAVE 961 0x66, 0x6d, 0x74, 0x20, //fmt chunk 962 0, 0, 0, 0, //chunk size 963 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 964 0x64, 0x61, 0x74, 0x61, //data chunk 965 0, 0, 0, 0 //chunk size 966 }; 967 968 //DM07022004 081.6 int16 new 969 public static byte AIFF[] = { 970 0x46, 0x4F, 0x52, 0x4D, //FORM 971 0, 0, 0, 0, //32-bit filesize-8 972 0x41, 0x49, 0x46, 0x46, //AIFF 973 0x43, 0x4F, 0x4D, 0x4D, //COMM chunk 974 0, 0, 0, 0x12, //chunk size 975 0, 0, // number of channels 976 0, 0, 0, 0, // number of samples 977 0, 0, // bits per sample 978 0, 0, 0, 0, // sample rate + ? 979 0, 0, 0, 0, 0, 0, 980 0x53, 0x53, 0x4E, 0x44, //SSND chunk 981 0, 0, 0, 0 //chunk size 982 }; 983 984 985 static class HEADER { 986 987 int ID; 988 int layer; 989 int protection_bit; 990 int bitrate_index; 991 int sampling_frequency; 992 int new_sampling_frequency = 0; //DM30122003 081.6 int10 add 993 int padding_bit; 994 int private_bit; 995 int mode; 996 int mode_extension; 997 int copyright; 998 int original; 999 int channel; 1000 int newchannel = 0; //DM30122003 081.6 int10 changed 1001 int bound; 1002 int emphasis; 1003 int sblimit; 1004 int framesize; 1005 int bits_per_sample; 1006 HEADER()1007 public HEADER() { 1008 return; 1009 1010 } 1011 } 1012 1013 static class WORK { 1014 1015 double area[] = new double[2048]; 1016 int offset; 1017 WORK()1018 public WORK() { 1019 return; 1020 } 1021 } 1022 1023 1024 private static byte[] buf; 1025 private static boolean[] Bits; 1026 private static int BitPos = 0; 1027 private static int BufferPos = 0; 1028 private static int resample = 0; 1029 private static int Frame = 0; 1030 1031 private static HEADER head = new HEADER(); 1032 private static WORK work = new WORK(); 1033 private static ByteArrayOutputStream out1 = new ByteArrayOutputStream(); 1034 private static ByteArrayOutputStream out2 = new ByteArrayOutputStream(); 1035 private static double saveS[] = new double[2]; //DM14052004 081.7 int02 changed 1036 1037 public static boolean PRESCAN = false; 1038 1039 private static int LEFT_RIGHT = 0; 1040 public static boolean MOTOROLA = false; 1041 public static boolean DOWNSAMPLE = false; 1042 public static boolean DOWNMIX = false; 1043 public static boolean WAVE = true; 1044 public static boolean MONO = false; 1045 public static boolean RESET = false; 1046 public static boolean NORMALIZE = false; 1047 1048 1049 public static boolean LEVELSCAN = false; 1050 1051 public static double MULTIPLY = 1; //DM10042004 081.7 int01 changed 1052 public static int MAX_VALUE = 32767; //DM10042004 081.7 int01 add 1053 1054 check_sync()1055 public static int check_sync() 1056 { 1057 if ((0xFF & buf[BufferPos]) != 0xFF || (0xF0 & buf[BufferPos + 1]) != 0xF0) 1058 return 0; 1059 1060 return 1; 1061 } 1062 1063 /*** 1064 public static void loadbits(int size) { 1065 BitPos = BufferPos<<3; 1066 BufferPos += size; 1067 } 1068 1069 public static int getbits(int N) { 1070 int Pos, Val; 1071 Pos = BitPos>>>3; 1072 Val = (0xFF&buf[Pos])<<24 | 1073 (0xFF&buf[Pos+1])<<16 | 1074 (0xFF&buf[Pos+2])<<8 | 1075 (0xFF&buf[Pos+3]); 1076 Val <<= BitPos & 7; 1077 Val >>>= 32-N; 1078 BitPos += N; 1079 return Val; 1080 } 1081 ***/ 1082 loadbits(int size)1083 public static void loadbits(int size) 1084 { 1085 Bits = new boolean[size*8]; 1086 BitPos = 0; 1087 1088 for (int a=0; a < size; a++) 1089 for (int b=0; b < 8; b++) 1090 if (((0x80>>>b) & buf[BufferPos + a]) != 0) 1091 Bits[(a * 8) + b] = true; 1092 1093 BufferPos += size; 1094 } 1095 1096 //DM10062004 081.7 int04 fixed getbits(int N)1097 public static int getbits(int N) 1098 { 1099 int Val=0; 1100 1101 for (int a = 0; a < N && BitPos + a < Bits.length; a++) 1102 if (Bits[BitPos + a]) 1103 Val |= 1<<(N - 1 - a); 1104 1105 BitPos += N; 1106 return Val; 1107 } 1108 1109 //DM10062004 081.7 int04 fixed showbits(int N)1110 public static int showbits(int N) 1111 { 1112 int Val=0; 1113 1114 for (int a = 0; a < N && BitPos + a < Bits.length; a++) 1115 if (Bits[BitPos + a]) 1116 Val |= 1<<(N-1-a); 1117 1118 return Val; 1119 } 1120 flushbits(int N)1121 public static void flushbits(int N) 1122 { 1123 BitPos += N; 1124 } 1125 flushBuffer(int N)1126 public static void flushBuffer(int N) 1127 { 1128 BufferPos += N; 1129 } 1130 1131 /** 1132 * 1133 */ intel_ByteOrder(short value)1134 private static byte[] intel_ByteOrder(short value) 1135 { 1136 byte b[] = new byte[2]; 1137 1138 if (!MOTOROLA) 1139 { 1140 b[0] = (byte)(value & 0xFF); 1141 b[1] = (byte)(value>>>8 & 0xFF); 1142 } 1143 1144 else 1145 { 1146 b[0] = (byte)(value>>>8 & 0xFF); 1147 b[1] = (byte)(value & 0xFF); 1148 } 1149 1150 return b; 1151 } 1152 1153 /** 1154 * 1155 */ writeSample(ByteArrayOutputStream baos, short value)1156 private static void writeSample(ByteArrayOutputStream baos, short value) throws IOException 1157 { 1158 if (PRESCAN) 1159 return; 1160 1161 baos.write(intel_ByteOrder(value)); 1162 } 1163 1164 //DM30122003 081.6 int10 changed & moved+ 1165 final static int bitrate[][][] = { 1166 { 1167 {-1,8000,16000,24000,32000,40000,48000,56000,64000, 1168 80000,96000,112000,128000,144000,160000,0 }, //MPG-2, L3 1169 {-1,8000,16000,24000,32000,40000,48000,56000,64000,80000, //MPG-2, L2 1170 96000,112000,128000,144000,160000,0 }, 1171 {-1,32000,48000,56000,64000,80000,96000,112000,128000, //MPG-2, L1 1172 144000,160000,176000,192000,224000,256000,0 } 1173 },{ 1174 {-1,32000,40000,48000,56000,64000,80000,96000, 1175 112000,128000,160000,192000,224000,256000,320000, 0 }, //MPG-1, L3 1176 {-1, 32000, 48000, 56000, 64000, 80000, 96000, 112000, //MPG-1, L2 1177 128000, 160000, 192000, 224000, 256000, 320000, 384000, 0 }, 1178 {-1,32000,64000,96000,128000,160000,192000,224000, //MPG-1, L1 1179 256000,288000,320000,352000,384000,416000,448000,0 } 1180 },{ 1181 {-1, 6000, 8000, 10000, 12000, 16000, 20000, 24000, //MPG-2.5, L3?? 1182 28000, 320000, 40000, 48000, 56000, 64000, 80000, 0 }, 1183 {-1, 6000, 8000, 10000, 12000, 16000, 20000, 24000, //MPG-2.5, L2 1184 28000, 320000, 40000, 48000, 56000, 64000, 80000, 0 }, 1185 {-1, 8000, 12000, 16000, 20000, 24000, 32000, 40000, //MPG-2.5, L1 1186 48000, 560000, 64000, 80000, 96000, 112000, 128000, 0 } 1187 } 1188 }; 1189 1190 1191 final static int frequency[][] = { 1192 { 22050,24000,16000,0 }, //MPG-2 1193 { 44100,48000,32000,0 }, //MPG-1 1194 { 11025,12000,8000,0 } //MPG-2.5 1195 }; 1196 //DM30122003 081.6 int10 moved- 1197 parse_header()1198 public static int parse_header() { 1199 1200 int channel_bitrate; 1201 int newfrequency=0; 1202 int sblimit = 32; 1203 1204 head.ID = 1 & buf[BufferPos + 1]>>>3; 1205 head.emphasis = 3 & buf[BufferPos + 3]; 1206 1207 if (head.ID == 1 && head.emphasis == 2) 1208 head.ID = 2; 1209 1210 if ( (head.layer = 3 & buf[BufferPos + 1]>>>1) < 1) //DM30122003 081.6 int10 changed 1211 return -3; 1212 1213 head.protection_bit = (1 & buf[BufferPos + 1]) ^ 1; 1214 1215 if ( (head.bitrate_index = bitrate[head.ID][head.layer - 1][0xF & buf[BufferPos + 2]>>>4]) < 1) //DM30122003 081.6 int10 changed 1216 return -4; 1217 1218 if ( (newfrequency = frequency[head.ID][3 & buf[BufferPos + 2]>>>2]) == 0) 1219 return -5; 1220 1221 head.sampling_frequency = newfrequency; 1222 head.padding_bit = 1 & buf[BufferPos + 2]>>>1; 1223 head.private_bit = 1 & buf[BufferPos + 2]; 1224 1225 head.mode = 3 & buf[BufferPos + 3]>>>6; 1226 head.mode_extension = 3 & buf[BufferPos + 3]>>>4;; 1227 1228 if (head.mode == 0) 1229 head.mode_extension = 0; 1230 1231 switch(head.mode) 1232 { 1233 case 0: /* stereo */ 1234 case 2: /* dual channel */ 1235 head.channel = 2; 1236 head.bound = sblimit; 1237 break; 1238 1239 case 1: /* intensity stereo */ 1240 head.channel = 2; 1241 head.bound = (head.mode_extension + 1) << 2; 1242 break; 1243 1244 case 3: /* monaural */ 1245 head.channel = 1; 1246 head.bound = sblimit; 1247 break; 1248 } 1249 1250 head.copyright = 1 & buf[BufferPos + 3]>>>3; 1251 head.original = 1 & buf[BufferPos + 3]>>>2; 1252 1253 if (head.ID == 1 && head.layer == 2) 1254 { // MPEG-1 1255 if (head.channel == 2) 1256 { 1257 channel_bitrate = head.bitrate_index / 2; 1258 1259 if (channel_bitrate < 32000) 1260 return -6; /* unsupported bitrate */ 1261 } 1262 else 1263 { 1264 channel_bitrate = head.bitrate_index; 1265 1266 if(channel_bitrate > 192000) 1267 return -7; /* unsupported bitrate */ 1268 } 1269 1270 if (channel_bitrate < 56000) 1271 { 1272 if (head.sampling_frequency == 32000) 1273 head.sblimit = 12; 1274 else 1275 head.sblimit = 8; 1276 } 1277 else if (channel_bitrate < 96000) 1278 head.sblimit = 27; 1279 1280 else 1281 { 1282 if (head.sampling_frequency == 48000) 1283 head.sblimit = 27; 1284 else 1285 head.sblimit = 30; 1286 } 1287 1288 if (head.bound > head.sblimit) 1289 head.bound = head.sblimit; 1290 } 1291 else if (head.layer == 2) 1292 { // MPEG-2 1293 head.sblimit = 30; 1294 } 1295 1296 head.bits_per_sample = 16; 1297 1298 flushBuffer(4); 1299 1300 if(head.protection_bit > 0) 1301 flushBuffer(2); 1302 1303 if (head.layer==2) 1304 { 1305 if (head.bound > head.sblimit) 1306 head.bound = head.sblimit; 1307 1308 head.framesize = 144 * head.bitrate_index / head.sampling_frequency + head.padding_bit; 1309 1310 return 2; 1311 } 1312 else if (head.layer == 1) 1313 { //DM30122003 081.6 int10 new 1314 if (head.bound > head.sblimit) 1315 head.bound = head.sblimit; 1316 1317 head.framesize = 144 * head.bitrate_index / head.sampling_frequency + head.padding_bit; 1318 1319 return 1; 1320 } 1321 else 1322 { 1323 head.sblimit = 32; 1324 head.framesize = (12 * head.bitrate_index / head.sampling_frequency + head.padding_bit) * 4; 1325 1326 return 3; 1327 } 1328 } 1329 1330 private static int[][] allocation = new int[32][2]; 1331 private static int[][] scfsi = new int[32][2]; 1332 private static int[][][] scalefactor = new int[32][2][3]; 1333 private static double[][][][] sample = new double[12][3][32][2]; 1334 1335 private static double[] U = new double[1024]; 1336 private static double[] W = new double[1024]; 1337 1338 private static int[][][] sample1 = new int[12][32][2]; 1339 private static double[][][] fraction = new double[12][32][2]; 1340 resetArraysLayer2()1341 private static void resetArraysLayer2() 1342 { 1343 resetArrays(); 1344 1345 for (int i = 0; i < sample.length; i++) 1346 for (int j = 0; j < sample[i].length; j++) 1347 for (int k = 0; k < sample[i][j].length; k++) 1348 Arrays.fill(sample[i][j][k], 0); 1349 } 1350 resetArraysLayer1()1351 private static void resetArraysLayer1() 1352 { 1353 resetArrays(); 1354 1355 for (int i = 0; i < sample1.length; i++) 1356 for (int j = 0; j < sample1[i].length; j++) 1357 Arrays.fill(sample1[i][j], 0); 1358 1359 for (int i = 0; i < fraction.length; i++) 1360 for (int j = 0; j < fraction[i].length; j++) 1361 Arrays.fill(fraction[i][j], 0); 1362 } 1363 resetArrays()1364 private static void resetArrays() 1365 { 1366 // Arrays.fill(U, 0); 1367 // Arrays.fill(W, 0); 1368 1369 // for (int i = 0; i < allocation.length; i++) 1370 // Arrays.fill(allocation[i], 0); 1371 1372 // for (int i = 0; i < scfsi.length; i++) 1373 // Arrays.fill(scfsi[i], 0); 1374 1375 // for (int i = 0; i < scalefactor.length; i++) 1376 // for (int j = 0; j < scalefactor[i].length; j++) 1377 // Arrays.fill(scalefactor[i][j], 0); 1378 } 1379 decode_layer2()1380 public static int decode_layer2() throws IOException 1381 { 1382 loadbits(head.framesize - 4 - (head.protection_bit * 2)); 1383 1384 int i,j,k,n,m; 1385 int step; 1386 int bits; 1387 int o1,o2; 1388 int code; 1389 int sb,ch,gr; 1390 1391 resetArraysLayer2(); 1392 1393 short[] pcm = new short[2]; 1394 double[] s = new double[2]; 1395 int[] ss = new int[2]; 1396 1397 final int[] table_nbal; 1398 final int[][] table_alloc; 1399 1400 if (head.ID == 1) 1401 { 1402 if (head.sblimit > 20) 1403 { 1404 table_nbal = table_b2ab_nbal; 1405 table_alloc = table_b2ab; 1406 } 1407 else 1408 { 1409 table_nbal = table_b2cd_nbal; 1410 table_alloc = table_b2cd; 1411 } 1412 } 1413 else 1414 { 1415 table_nbal = table_MPG2_nbal; 1416 table_alloc = table_MPG2; 1417 } 1418 1419 /* read allocation */ 1420 for (sb = 0; sb < head.bound; sb++) 1421 for (ch = 0; ch < head.channel; ch++) 1422 allocation[sb][ch] = table_alloc[sb][getbits(table_nbal[sb])]; 1423 1424 for (sb = head.bound; sb < head.sblimit; sb++) 1425 allocation[sb][0] = allocation[sb][1] = table_alloc[sb][getbits(table_nbal[sb])]; 1426 1427 /* read scalefactor selection information */ 1428 for (sb = 0; sb < head.sblimit; sb++) 1429 for (ch = 0; ch < head.channel; ch++) 1430 if (allocation[sb][ch] > 0) 1431 scfsi[sb][ch] = getbits(2); 1432 1433 /* read scalefactor */ 1434 for (sb = 0; sb < head.sblimit; sb++) 1435 { 1436 for (ch = 0; ch < head.channel; ch++) 1437 if (allocation[sb][ch] > 0) 1438 { 1439 scalefactor[sb][ch][0] = getbits(6); 1440 1441 switch(scfsi[sb][ch]) 1442 { 1443 case 0: 1444 scalefactor[sb][ch][1] = getbits(6); 1445 scalefactor[sb][ch][2] = getbits(6); 1446 break; 1447 1448 case 1: 1449 scalefactor[sb][ch][1] = scalefactor[sb][ch][0]; 1450 scalefactor[sb][ch][2] = getbits(6); 1451 break; 1452 1453 case 2: 1454 scalefactor[sb][ch][2] = scalefactor[sb][ch][1] = scalefactor[sb][ch][0]; 1455 break; 1456 1457 case 3: 1458 scalefactor[sb][ch][2] = scalefactor[sb][ch][1] = getbits(6); 1459 break; 1460 } 1461 } 1462 } 1463 1464 /* read sample and requantize and normalize */ 1465 for (gr = 0; gr < 12; gr++) 1466 { 1467 for (sb = 0; sb < head.bound; sb++) 1468 { 1469 for (ch = 0; ch < head.channel; ch++) 1470 { 1471 n = allocation[sb][ch]; 1472 1473 if (n == 0) 1474 {} // samples are already zero 1475 1476 else if (n < 4) 1477 { 1478 bits = (int) table_b4[n][2]; //bits 1479 step = (int) table_b4[n][3]; //step 1480 code = getbits(bits); 1481 1482 for ( i = 0; i <3 ; i++) 1483 { 1484 m = code % step; 1485 m -= (step-1); 1486 sample[gr][i][sb][ch] = m; 1487 sample[gr][i][sb][ch] /= (step-1); 1488 sample[gr][i][sb][ch] += table_b4[n][1]; // d 1489 sample[gr][i][sb][ch] *= table_b4[n][0]; // c 1490 sample[gr][i][sb][ch] *= table_b1[scalefactor[sb][ch][gr>>>2]]; 1491 code /= step; 1492 } 1493 } 1494 else 1495 { 1496 bits = (int) table_b4[n][2]; //bits 1497 step = (int) table_b4[n][3]; //step 1498 1499 for (i = 0; i < 3; i++) 1500 { 1501 m = getbits(bits); 1502 m -= step; 1503 sample[gr][i][sb][ch] = m; 1504 sample[gr][i][sb][ch] /= step; 1505 sample[gr][i][sb][ch] += table_b4[n][1]; // d 1506 sample[gr][i][sb][ch] *= table_b4[n][0]; // c 1507 sample[gr][i][sb][ch] *= table_b1[scalefactor[sb][ch][gr>>>2]]; 1508 } 1509 } 1510 } 1511 } 1512 1513 for (sb = head.bound; sb < head.sblimit; sb++) 1514 { 1515 n = allocation[sb][0]; 1516 1517 if (n == 0) 1518 {} // samples are already zero 1519 1520 else if (n < 4) 1521 { 1522 bits = (int) table_b4[n][2]; //bits 1523 step = (int) table_b4[n][3]; //step 1524 code = getbits(bits); 1525 1526 for (i = 0; i < 3; i++) 1527 { 1528 m = code % step; 1529 m -= (step-1); 1530 sample[gr][i][sb][0] = m; 1531 sample[gr][i][sb][0] /= (step - 1); 1532 sample[gr][i][sb][0] += table_b4[n][1]; // d 1533 sample[gr][i][sb][0] *= table_b4[n][0]; // c 1534 sample[gr][i][sb][1] = sample[gr][i][sb][0]; 1535 sample[gr][i][sb][0] *= table_b1[scalefactor[sb][0][gr>>>2]]; 1536 sample[gr][i][sb][1] *= table_b1[scalefactor[sb][1][gr>>>2]]; 1537 code /= step; 1538 } 1539 } 1540 else 1541 { 1542 bits = (int) table_b4[n][2]; //bits 1543 step = (int) table_b4[n][3]; //step 1544 1545 for (i = 0; i < 3; i++) 1546 { 1547 m = getbits(bits); 1548 m -= step; 1549 sample[gr][i][sb][0] = m; 1550 sample[gr][i][sb][0] /= step; 1551 sample[gr][i][sb][0] += table_b4[n][1]; // d 1552 sample[gr][i][sb][0] *= table_b4[n][0]; // c 1553 sample[gr][i][sb][1] = sample[gr][i][sb][0]; 1554 sample[gr][i][sb][0] *= table_b1[scalefactor[sb][0][gr>>>2]]; 1555 sample[gr][i][sb][1] *= table_b1[scalefactor[sb][1][gr>>>2]]; 1556 } 1557 } 1558 } 1559 1560 /** downmix */ 1561 if (DOWNMIX && head.channel == 2) 1562 { //12,3,32,2 1563 for (sb = 0; sb < 32; sb++) 1564 for (i = 0; i < 3; i++) 1565 sample[gr][i][sb][0] = (sample[gr][i][sb][0] + sample[gr][i][sb][1]) * 0.5f; 1566 } 1567 } 1568 1569 // 1570 if (LEVELSCAN) 1571 { 1572 getFrameLevel(sample); 1573 return 4; 1574 } 1575 // 1576 /** downmix */ 1577 if (DOWNMIX && head.channel == 2) 1578 head.newchannel = 1; 1579 1580 else 1581 head.newchannel = 2; 1582 1583 int channel = head.channel; 1584 int last_resample = resample; 1585 1586 writeLoop: 1587 while (true) 1588 { 1589 out1.reset(); 1590 out2.reset(); 1591 1592 resample = last_resample; 1593 1594 // subband synthesis 1595 for (gr = 0; gr < 12; gr++) 1596 { 1597 for (m = 0; m < 3; m++) 1598 { 1599 // shifting 1600 work.offset -= 128; 1601 work.offset &= 0x7FF; 1602 1603 // matrixing 1604 for (i = 0; i < 64; i++) 1605 { 1606 j = work.offset + i * 2; 1607 1608 for (ch = 0; ch < head.channel; ch++) 1609 { 1610 work.area[j + ch] = table_Nik[i][0] * sample[gr][m][0][ch]; 1611 1612 for (k = 1; k < head.sblimit; k++) 1613 work.area[j + ch] += table_Nik[i][k] * sample[gr][m][k][ch]; 1614 } 1615 } 1616 1617 // build vector U 1618 for (i = 0; i < 8; i++) 1619 { 1620 j = work.offset + i * 256; 1621 1622 o1 = j & 0x7FF; 1623 o2 = (j + 192) & 0x7FF; 1624 1625 for (k = 0; k < 32; k++) 1626 { 1627 j = (i * 64 + k) * 2; 1628 n = o1 + k * 2; 1629 1630 U[j] = work.area[n]; 1631 U[j + 1] = work.area[n + 1]; 1632 1633 j = (i * 64 + 32 + k) * 2; 1634 n = o2 + k * 2; 1635 1636 U[j] = work.area[n]; 1637 U[j + 1] = work.area[n + 1]; 1638 } 1639 } 1640 1641 // window 1642 for (i = 0; i < 512; i++) 1643 { 1644 j = i * 2; 1645 1646 W[j] = U[j] * table_b3[i]; 1647 W[j + 1] = U[j + 1] * table_b3[i]; 1648 } 1649 1650 // calc sample 1651 for (i = 0; i < 32; i++) 1652 { 1653 j = i * 2; 1654 1655 s[0] = W[j]; 1656 s[1] = W[j + 1]; 1657 1658 for(k = 1; k < 16; k++) 1659 { 1660 j = (32 * k + i) * 2; 1661 1662 s[0] += W[j]; 1663 s[1] += W[j + 1]; 1664 } 1665 1666 s[0] *= 32768; 1667 s[1] *= 32768; 1668 1669 if (resample == Resample[LEFT_RIGHT>>>3 & 1].length) 1670 resample = 0; 1671 1672 if (head.sampling_frequency == 48000 && (LEFT_RIGHT & 0xC) != 0) //resample 1673 { 1674 double interpolator = Resample[LEFT_RIGHT>>>3 & 1][resample]; 1675 1676 if (interpolator == -1) 1677 resample++; 1678 1679 if (interpolator == 0) 1680 { 1681 resample++; 1682 System.arraycopy(s, 0, saveS, 0, 2); 1683 continue; 1684 } 1685 else if (interpolator > 0) 1686 { 1687 resample++; 1688 double saveS2[] = new double[2]; 1689 System.arraycopy(s, 0, saveS2, 0, 2); 1690 s[0] = interpolator * s[0] + (1 - interpolator) * saveS[0]; 1691 s[1] = interpolator * s[1] + (1 - interpolator) * saveS[1]; 1692 System.arraycopy(saveS2, 0, saveS, 0, 2); 1693 } 1694 } 1695 1696 ss[0] = (int)(s[0] * MULTIPLY); 1697 ss[1] = (int)(s[1] * MULTIPLY); 1698 1699 if (ss[0] > MAX_VALUE) 1700 { 1701 if (NORMALIZE) 1702 MULTIPLY = 1.0 * MAX_VALUE / s[0]; 1703 1704 pcm[0] = (short)MAX_VALUE; 1705 } 1706 1707 else if (ss[0] < -(MAX_VALUE + 1)) 1708 { 1709 if (NORMALIZE) 1710 MULTIPLY = Math.abs(1.0 * -(MAX_VALUE + 1) / s[0]); 1711 1712 pcm[0] = (short)(-(MAX_VALUE + 1)); 1713 } 1714 1715 else 1716 { 1717 pcm[0] = (short)ss[0]; 1718 } 1719 1720 if (ss[1] > MAX_VALUE) 1721 { 1722 if (NORMALIZE) 1723 MULTIPLY = 1.0 * MAX_VALUE / s[1]; 1724 1725 pcm[1] = (short)MAX_VALUE; 1726 } 1727 1728 else if (ss[1] < -(MAX_VALUE + 1)) 1729 { 1730 if (NORMALIZE) 1731 MULTIPLY = Math.abs(1.0 * -(MAX_VALUE + 1) / s[1]); 1732 1733 pcm[1] = (short)(-(MAX_VALUE + 1)); 1734 } 1735 1736 else 1737 { 1738 pcm[1] = (short)ss[1]; 1739 } 1740 1741 if ((LEFT_RIGHT & 1) != 1) // exchange r<->l 1742 writeSample(out1, pcm[0]); 1743 1744 else 1745 writeSample(out1, pcm[1]); 1746 1747 if (!MONO) 1748 { 1749 if (head.channel == 1) 1750 { 1751 if ((LEFT_RIGHT & 1) != 1) 1752 writeSample(out1, pcm[0]); 1753 1754 else 1755 writeSample(out1, pcm[1]); 1756 1757 channel = 2; 1758 } 1759 1760 else 1761 { 1762 if ((LEFT_RIGHT & 1) != 1) 1763 writeSample(out1, pcm[1]); 1764 1765 else 1766 writeSample(out1, pcm[0]); 1767 } 1768 } 1769 1770 else 1771 { 1772 channel = 1; 1773 writeSample(out2, pcm[1]); 1774 } 1775 1776 if (DOWNSAMPLE) 1777 i++; 1778 } 1779 } 1780 } 1781 1782 break; 1783 } 1784 1785 head.newchannel = channel; 1786 1787 return 1; 1788 } 1789 1790 decode_layer1()1791 public static int decode_layer1() throws IOException 1792 { 1793 out1.reset(); 1794 out2.reset(); 1795 1796 loadbits(head.framesize - 4 - (head.protection_bit * 2)); 1797 1798 resetArraysLayer1(); 1799 1800 int i,k,n,gr; 1801 int o1,o2; 1802 1803 int sb,ch; 1804 1805 short[] pcm = new short[2]; 1806 double s[] = new double[2]; 1807 int ss[] = new int[2]; 1808 1809 /* read allocation */ 1810 for (sb = 0; sb < head.bound; sb++) 1811 for (ch = 0; ch < head.channel; ch++) 1812 allocation[sb][ch] = getbits(4); 1813 1814 for (sb = head.bound; sb < head.sblimit; sb++) 1815 allocation[sb][0] = allocation[sb][1] = getbits(4); 1816 1817 /* read scalefactor */ 1818 for (sb = 0; sb < head.sblimit; sb++) 1819 for (ch = 0; ch < head.channel; ch++) 1820 { 1821 if(allocation[sb][ch] > 0) 1822 scalefactor[sb][ch][0] = getbits(6); 1823 } 1824 1825 1826 // lay1 s = (s' + 2^(-nb+1) ) * 2^nb / (2^nb-1) , lay2 s = s' * c + d 1827 // read 1 sample of each allocated subband per channel, then continue with next sample for each sb , -> do this ever for 12samples per frame 1828 1829 /* read sample and requantize and normalize */ 1830 for (gr = 0; gr < 12;gr++) 1831 { 1832 for (sb = 0; sb < head.bound; sb++) 1833 { 1834 for (ch = 0; ch < head.channel; ch++) 1835 { 1836 if ( (n = allocation[sb][ch]) > 0) 1837 { // samples of interest 1838 sample1[gr][sb][ch] = getbits(++n); //read sample (read alloc +1 bit mehr = sample) 1839 1840 if (((sample1[gr][sb][ch]>>n-1) & 1) != 1) 1841 fraction[gr][sb][ch] = -1.0; 1842 1843 fraction[gr][sb][ch] += (double)(sample1[gr][sb][ch] & ((1<<n - 1) - 1)) / (double) (1L<<n-1); 1844 fraction[gr][sb][ch] = (double)(fraction[gr][sb][ch] + 1.0 / (double)(1L<<n - 1)) * (double) (1L<<n) / (double) ((1L<<n) - 1); 1845 fraction[gr][sb][ch] *= table_b1[scalefactor[sb][ch][0]]; 1846 } 1847 } 1848 } 1849 1850 for (sb = head.bound; sb < head.sblimit; sb++) 1851 { 1852 if ( (n = allocation[sb][0]) > 0) 1853 { // samples of interest 1854 sample1[gr][sb][0] = getbits(++n); //read sample 1855 1856 if (((sample1[gr][sb][0]>>n-1) &1) != 1) 1857 fraction[gr][sb][0] = -1.0; 1858 1859 fraction[gr][sb][0] += (double)(sample1[gr][sb][0] & ((1<<n - 1) - 1)) / (double) (1L<<n - 1); 1860 1861 fraction[gr][sb][1] = fraction[gr][sb][0] = (double)(fraction[gr][sb][0] + 1.0 / (double)(1L<<n - 1)) * (double) (1L<<n) / (double) ((1L<<n) - 1); 1862 fraction[gr][sb][0] *= table_b1[scalefactor[sb][0][0]]; 1863 fraction[gr][sb][1] *= table_b1[scalefactor[sb][1][0]]; 1864 } 1865 } 1866 1867 /** downmix */ 1868 if (DOWNMIX && head.channel == 2) 1869 { //12,32,2 1870 for (sb = 0; sb < head.sblimit; sb++) 1871 fraction[gr][sb][0] = (fraction[gr][sb][0] + fraction[gr][sb][1]) * 0.5f; 1872 } 1873 } 1874 1875 // 1876 if (LEVELSCAN) 1877 { 1878 getFrameLevel(sample1); 1879 return 4; 1880 } 1881 // 1882 /** downmix */ 1883 if (DOWNMIX && head.channel == 2) 1884 head.newchannel = 1; 1885 else 1886 head.newchannel = 2; 1887 1888 int channel = head.channel; 1889 1890 /* subband synthesis */ 1891 for (gr = 0; gr < 12; gr++) 1892 { 1893 /* shifting */ 1894 work.offset -= 128; 1895 work.offset &= 2047; 1896 1897 /* matrixing */ 1898 for (i = 0; i < 64; i++) 1899 { 1900 for (ch = 0; ch < head.channel; ch++) 1901 { 1902 work.area[work.offset + i * 2 + ch] = table_Nik[i][0] * fraction[gr][0][ch]; 1903 1904 for (k = 1; k < head.sblimit; k++) 1905 work.area[work.offset + i * 2 + ch] += table_Nik[i][k] * fraction[gr][k][ch]; 1906 } 1907 } 1908 1909 /* build vector U */ 1910 for (i = 0; i < 8; i++) 1911 { 1912 o1 = (work.offset + i * 256) & 2047; 1913 o2 = (work.offset + i * 256 + 192) & 2047; 1914 1915 for (k = 0; k < 32; k++) 1916 { 1917 U[(i * 64 + k) * 2 + 0] = work.area[o1 + k * 2 + 0]; 1918 U[(i * 64 + k) * 2 + 1] = work.area[o1 + k * 2 + 1]; 1919 U[(i * 64 + 32 + k) * 2 + 0] = work.area[o2 + k * 2 + 0]; 1920 U[(i * 64 + 32 + k) * 2 + 1] = work.area[o2 + k * 2 + 1]; 1921 } 1922 } 1923 1924 /* window */ 1925 for (i = 0; i < 512; i++) 1926 { 1927 W[i * 2 + 0] = U[i * 2 + 0] * table_b3[i]; 1928 W[i * 2 + 1] = U[i * 2 + 1] * table_b3[i]; 1929 } 1930 1931 /* calc sample */ 1932 for (i = 0; i < 32; i++) 1933 { 1934 s[0] = W[i * 2 + 0]; 1935 s[1] = W[i * 2 + 1]; 1936 1937 for (k = 1; k < 16; k++) 1938 { 1939 s[0] += W[(32 * k + i) * 2 + 0]; 1940 s[1] += W[(32 * k + i) * 2 + 1]; 1941 } 1942 1943 //DM10042004 081.7 int01 changed+ 1944 s[0] *= 32768; 1945 s[1] *= 32768; 1946 1947 //DM14052004 081.7 int02 changed++ 1948 if (resample == Resample[LEFT_RIGHT>>>3 & 1].length) 1949 resample=0; 1950 1951 if (head.sampling_frequency == 48000 && (LEFT_RIGHT & 0xC) != 0) //resample 1952 { 1953 double interpolator = Resample[LEFT_RIGHT>>>3 & 1][resample]; 1954 1955 if (interpolator == -1) 1956 resample++; 1957 1958 if (interpolator == 0) 1959 { 1960 resample++; 1961 System.arraycopy(s, 0, saveS, 0, 2); 1962 continue; 1963 } 1964 else if (interpolator > 0) 1965 { 1966 resample++; 1967 double saveS2[] = new double[2]; 1968 System.arraycopy(s, 0, saveS2, 0, 2); 1969 s[0] = interpolator * s[0] + (1 - interpolator) * saveS[0]; 1970 s[1] = interpolator * s[1] + (1 - interpolator) * saveS[1]; 1971 System.arraycopy(saveS2, 0, saveS, 0, 2); 1972 } 1973 } 1974 //DM14052004 081.7 int02 changed++ 1975 1976 ss[0] = (int)(s[0] * MULTIPLY); 1977 ss[1] = (int)(s[1] * MULTIPLY); 1978 1979 if(ss[0] > MAX_VALUE) 1980 { 1981 if (NORMALIZE) 1982 MULTIPLY = 1.0 * MAX_VALUE / s[0]; 1983 1984 pcm[0] = (short)MAX_VALUE; 1985 } 1986 else if(ss[0] < -(MAX_VALUE+1)) 1987 { 1988 if (NORMALIZE) 1989 MULTIPLY = Math.abs(1.0 * -(MAX_VALUE + 1) / s[0]); 1990 1991 pcm[0] = (short)(-(MAX_VALUE+1)); 1992 } 1993 else 1994 { 1995 pcm[0] = (short)ss[0]; 1996 } 1997 1998 if(ss[1] > MAX_VALUE) 1999 { 2000 if (NORMALIZE) 2001 MULTIPLY = 1.0 * MAX_VALUE / s[1]; 2002 2003 pcm[1] = (short)MAX_VALUE; 2004 } 2005 else if(ss[1] < -(MAX_VALUE+1)) 2006 { 2007 if (NORMALIZE) 2008 MULTIPLY = Math.abs(1.0 * -(MAX_VALUE+1) / s[1]); 2009 2010 pcm[1] = (short)(-(MAX_VALUE+1)); 2011 } 2012 else 2013 { 2014 pcm[1] = (short)ss[1]; 2015 } 2016 //DM10042004 081.7 int01 changed- 2017 2018 if ((LEFT_RIGHT & 1) != 1) 2019 writeSample(out1, pcm[0]); 2020 2021 else 2022 writeSample(out1, pcm[1]); 2023 2024 if (!MONO) 2025 { 2026 if (head.channel==1) 2027 { 2028 if ((LEFT_RIGHT & 1) != 1) 2029 writeSample(out1, pcm[0]); 2030 2031 else 2032 writeSample(out1, pcm[1]); 2033 2034 channel = 2; 2035 } 2036 else 2037 { 2038 if ((LEFT_RIGHT & 1) != 1) 2039 writeSample(out1, pcm[1]); 2040 2041 else 2042 writeSample(out1, pcm[0]); 2043 } 2044 } 2045 else 2046 channel = 1; 2047 2048 if (DOWNSAMPLE) 2049 i++; 2050 } 2051 } 2052 2053 head.newchannel = channel; 2054 2055 return 1; 2056 } 2057 2058 /** 2059 * 2060 */ init_work(int resample_type)2061 public static void init_work(int resample_type) 2062 { 2063 Arrays.fill(work.area, 0.0); 2064 work.offset = 0; 2065 resample = 0; 2066 Frame = 0; 2067 BufferPos = 0; 2068 saveS = new double[2]; 2069 LEFT_RIGHT = resample_type<<2; 2070 } 2071 2072 /** 2073 * 2074 */ littleEndian(int data, int flag)2075 private static int littleEndian(int data, int flag) 2076 { 2077 if (MOTOROLA) 2078 return data; 2079 2080 if (flag == 4) 2081 return ( (0xFF & data>>>24) | (0xFF & data>>>16)<<8 | (0xFF & data>>>8)<<16 | (0xFF & data)<<24 ); 2082 2083 else 2084 return ( (0xFF & data>>>8) | (0xFF & data)<<8 ); 2085 } 2086 2087 /** 2088 * 2089 */ fillAiff(String file, long playtime, boolean fade, int fade_millis)2090 public static void fillAiff(String file, long playtime, boolean fade, int fade_millis) throws IOException 2091 { 2092 //always MSB 2093 RandomAccessFile aiff = new RandomAccessFile(file,"rw"); 2094 2095 int len = (int)(aiff.length() - 8); 2096 2097 if (DOWNSAMPLE) 2098 head.sampling_frequency /= 2; 2099 2100 else if ((LEFT_RIGHT & 0xC) != 0 && head.sampling_frequency == 48000) 2101 head.sampling_frequency = (head.sampling_frequency * Resample_frequency[LEFT_RIGHT>>>3 & 1][0]) / Resample_frequency[LEFT_RIGHT>>>3 & 1][1]; 2102 2103 aiff.seek(4); 2104 aiff.writeInt(len); //data+chunksize 2105 2106 aiff.seek(16); 2107 aiff.writeInt(0x12); //chunk length 2108 aiff.writeShort((short)head.newchannel); //channels 2109 aiff.writeInt((int)(head.sampling_frequency * playtime / 1000.0)); //playtime 2110 aiff.writeShort((short)head.bits_per_sample); //bits_per_sample 2111 aiff.write(ConvertToIeeeExtended((double)head.sampling_frequency)); //sample_freq 2112 2113 aiff.seek(42); 2114 aiff.writeInt(len - 38); //chunk size sample data 2115 2116 if (fade) 2117 { 2118 fadeIn(aiff, fade_millis, 46, len - 38); 2119 fadeOut(aiff, fade_millis, 46, len - 38); 2120 } 2121 2122 aiff.close(); 2123 } 2124 2125 /** 2126 * 2127 */ deleteAiff(String file)2128 public static void deleteAiff(String file) throws IOException 2129 { 2130 RandomAccessFile aiff = new RandomAccessFile(file,"rw"); 2131 2132 aiff.seek(0); 2133 aiff.write(new byte[46]); 2134 2135 aiff.close(); 2136 } 2137 2138 /* 2139 * C O N V E R T T O I E E E E X T E N D E D 2140 * 2141 * Copyright (C) 1988-1991 Apple Computer, Inc. 2142 * All rights reserved. 2143 * 2144 * Machine-independent I/O routines for IEEE floating-point numbers. 2145 * 2146 * here: 80-bit floating point value of sample_rate in AIFF files 2147 * 2148 * simple Java adaption by dvb.matt 2004/02/07 2149 * no deep tests.. 2150 */ FloatToUnsigned(double f)2151 private static long FloatToUnsigned(double f) 2152 { 2153 return ((long)(((long)(f - 2147483648.0)) + 2147483647L) + 1); 2154 } 2155 2156 /** 2157 * 2158 */ ConvertToIeeeExtended(double num)2159 private static byte[] ConvertToIeeeExtended(double num) 2160 { 2161 byte bytes[] = new byte[10]; 2162 int sign; 2163 int expon=0; 2164 double fMant = 0.0, fsMant; 2165 long hiMant, loMant; 2166 2167 if (num < 0) 2168 { 2169 sign = 0x8000; 2170 num *= -1; 2171 } 2172 else 2173 sign = 0; 2174 2175 if (num == 0) 2176 { 2177 expon = 0; 2178 hiMant = 0; 2179 loMant = 0; 2180 } 2181 2182 else 2183 { 2184 for (int a = 1; a < 32; a++) 2185 if ((num /= 2) < 1.0) 2186 { 2187 expon = a; 2188 fMant = num; 2189 break; 2190 } 2191 2192 if ((expon > 16384) || !(fMant < 1)) 2193 { /* Infinity or NaN */ 2194 expon = sign | 0x7FFF; 2195 hiMant = 0; 2196 loMant = 0; /* infinity */ 2197 } 2198 2199 else 2200 { /* Finite */ 2201 expon += 16382; 2202 2203 if (expon < 0) 2204 { /* denormalized */ 2205 fMant *= (1L<<expon); 2206 expon = 0; 2207 } 2208 2209 expon |= sign; 2210 fMant *= (1L<<32); 2211 fsMant = Math.floor(fMant); 2212 hiMant = FloatToUnsigned(fsMant); 2213 fMant = (fMant - fsMant) * (1L<<32); 2214 fsMant = Math.floor(fMant); 2215 loMant = FloatToUnsigned(fsMant); 2216 } 2217 } 2218 2219 bytes[0] = (byte)(expon >> 8); 2220 bytes[1] = (byte)expon; 2221 bytes[2] = (byte)(hiMant >> 24); 2222 bytes[3] = (byte)(hiMant >> 16); 2223 bytes[4] = (byte)(hiMant >> 8); 2224 bytes[5] = (byte)hiMant; 2225 bytes[6] = (byte)(loMant >> 24); 2226 bytes[7] = (byte)(loMant >> 16); 2227 bytes[8] = (byte)(loMant >> 8); 2228 bytes[9] = (byte)loMant; 2229 2230 return bytes; 2231 } 2232 2233 /** 2234 * 2235 */ fillRIFF(String file, boolean fade, int fade_millis)2236 public static void fillRIFF(String file, boolean fade, int fade_millis) throws IOException 2237 { 2238 RandomAccessFile riff = new RandomAccessFile(file, "rw"); 2239 2240 int len = (int)riff.length() - 8; 2241 2242 if (DOWNSAMPLE) 2243 head.sampling_frequency /= 2; 2244 2245 else if ((LEFT_RIGHT & 0xC) != 0 && head.sampling_frequency == 48000) 2246 head.sampling_frequency = (head.sampling_frequency * Resample_frequency[LEFT_RIGHT>>>3 & 1][0]) / Resample_frequency[LEFT_RIGHT>>>3 & 1][1]; 2247 2248 if (MOTOROLA) 2249 { 2250 riff.seek(3); 2251 riff.write('X'); //RIFX nonIntel 2252 } 2253 2254 riff.seek(4); 2255 riff.writeInt(littleEndian(len, 4)); //data+chunksize 2256 2257 riff.seek(16); 2258 riff.writeInt(littleEndian(0x10, 4)); //chunk length 2259 riff.writeShort(littleEndian(1, 2)); //pcm 2260 riff.writeShort((short)littleEndian(head.newchannel, 2)); //channels 2261 riff.writeInt(littleEndian(head.sampling_frequency, 4)); //sample_freq 2262 riff.writeInt(littleEndian(head.sampling_frequency * head.newchannel * head.bits_per_sample / 8, 4)); //byterate 2263 riff.writeShort((short)littleEndian(head.newchannel * head.bits_per_sample / 8, 2)); //blockalign 2264 riff.writeShort((short)littleEndian(head.bits_per_sample, 2)); //bits_per_sample 2265 2266 riff.seek(40); 2267 riff.writeInt(littleEndian(len - 36, 4)); //data-size 2268 2269 if (fade) 2270 { 2271 fadeIn(riff, fade_millis, 44, len - 36); 2272 fadeOut(riff, fade_millis, 44, len - 36); 2273 } 2274 2275 riff.close(); 2276 } 2277 2278 /** 2279 * 2280 */ deleteRIFF(String file)2281 public static void deleteRIFF(String file) throws IOException 2282 { 2283 RandomAccessFile riff = new RandomAccessFile(file, "rw"); 2284 2285 riff.seek(0); 2286 riff.write(new byte[44]); 2287 2288 riff.close(); 2289 } 2290 2291 private final static int SamplesPerFrame[] = { 0, 1152, 1152, 384 }; //u,L3,L2,L1 2292 2293 /** 2294 * 2295 */ silentSamples(int new_sampling_frequency)2296 public static void silentSamples(int new_sampling_frequency) throws IOException 2297 { 2298 if (DOWNSAMPLE) 2299 new_sampling_frequency /= 2; 2300 2301 else if ((LEFT_RIGHT & 0xC) != 0) 2302 new_sampling_frequency = (new_sampling_frequency * Resample_frequency[LEFT_RIGHT>>>3 &1][0])/Resample_frequency[LEFT_RIGHT>>>3 &1][1]; 2303 2304 int silent_samples = head.newchannel * (head.bits_per_sample / 8) * (int)Math.abs((1.0 * SamplesPerFrame[head.layer] * new_sampling_frequency) / head.sampling_frequency); 2305 byte samples[] = new byte[silent_samples]; 2306 2307 out1.reset(); 2308 out2.reset(); 2309 2310 out1.write(samples); 2311 out2.write(samples); 2312 } 2313 2314 /** 2315 * 2316 */ decodeArray(byte[] data)2317 public static byte[] decodeArray(byte[] data) 2318 { 2319 buf = data; 2320 BufferPos = 0; 2321 ERROR_CODE = ERROR_CODE1 = 0; 2322 2323 double last_Multiply = MULTIPLY; 2324 2325 if ( (ERROR_CODE1 = check_sync()) == 0) 2326 return new byte[0]; 2327 2328 if ( (ERROR_CODE1 = parse_header()) < 1) 2329 return new byte[0]; 2330 2331 if (head.new_sampling_frequency == 0) 2332 head.new_sampling_frequency = head.sampling_frequency; 2333 2334 if (head.newchannel == 0) 2335 head.newchannel = DOWNMIX ? 1 : 2; 2336 2337 try { 2338 switch (ERROR_CODE1) 2339 { 2340 case 1: 2341 silentSamples(head.new_sampling_frequency); 2342 break; 2343 2344 case 2: 2345 ERROR_CODE = decode_layer2(); 2346 break; 2347 2348 case 3: 2349 ERROR_CODE = decode_layer1(); 2350 } 2351 2352 } catch (Exception e) { 2353 2354 } 2355 2356 if (ERROR_CODE == 1) 2357 head.new_sampling_frequency = head.sampling_frequency; 2358 2359 if (last_Multiply != MULTIPLY) 2360 CommonParsing.setAudioProcessingFlags(CommonParsing.getAudioProcessingFlags() | 0x1000CL); 2361 2362 return out1.toByteArray(); 2363 } 2364 2365 /** 2366 * 2367 */ get2ndArray()2368 public static byte[] get2ndArray() 2369 { 2370 return out2.toByteArray(); 2371 } 2372 2373 /** 2374 * 2375 */ fadeIn(RandomAccessFile pcm_file, int fade_millis, long seek_position, int datachunk_length)2376 private static void fadeIn(RandomAccessFile pcm_file, int fade_millis, long seek_position, int datachunk_length) throws IOException 2377 { 2378 fade(pcm_file, fade_millis, seek_position, datachunk_length, 1); 2379 } 2380 2381 /** 2382 * 2383 */ fadeOut(RandomAccessFile pcm_file, int fade_millis, long seek_position, int datachunk_length)2384 private static void fadeOut(RandomAccessFile pcm_file, int fade_millis, long seek_position, int datachunk_length) throws IOException 2385 { 2386 fade(pcm_file, fade_millis, seek_position, datachunk_length, 2); 2387 } 2388 2389 /** 2390 * 2391 */ fade(RandomAccessFile pcm_file, int fade_millis, long seek_position, int datachunk_length, int fade_mode)2392 private static void fade(RandomAccessFile pcm_file, int fade_millis, long seek_position, int datachunk_length, int fade_mode) throws IOException 2393 { 2394 int millis = (fade_millis < 0 || fade_millis > 5000) ? 2000 : fade_millis; 2395 int load = head.newchannel * (int)((1L * millis * head.sampling_frequency * head.bits_per_sample) / 8000); 2396 int bytes_per_sample = head.bits_per_sample / 8; 2397 2398 if (load > datachunk_length) 2399 load = datachunk_length; 2400 2401 double amp = 1.0; 2402 2403 byte[] array = new byte[load]; 2404 2405 if (fade_mode == 2) 2406 seek_position = seek_position + datachunk_length - load; 2407 2408 pcm_file.seek(seek_position); 2409 pcm_file.readFully(array); 2410 2411 for (int i = 0; i < load; ) 2412 { 2413 amp = (1.0 * (fade_mode == 2 ? (load - i) : i)) / load; 2414 2415 for (int ch = 0, _sample; ch < head.newchannel; ch++) 2416 { 2417 _sample = (0xFF & array[i])<<8 | (0xFF & array[i + 1]); 2418 _sample = littleEndian(_sample, 2); 2419 _sample = (0x8000 & _sample) != 0 ? (0xFFFF0000 | _sample) : _sample; 2420 _sample = (int) (amp * _sample); 2421 _sample = littleEndian(_sample, 2); 2422 2423 array[i] = (byte) (0xFF & _sample>>8); 2424 array[i + 1] = (byte) (0xFF & _sample); 2425 2426 i += bytes_per_sample; 2427 } 2428 } 2429 2430 pcm_file.seek(seek_position); 2431 pcm_file.write(array); 2432 } 2433 2434 /** 2435 * 2436 */ getFrameLevel(double[][][][] _sample)2437 private static void getFrameLevel(double[][][][] _sample) 2438 { 2439 double[] sample_level = new double[2]; 2440 2441 for (int gr = 0; gr < 12; gr++) 2442 for (int sb = 0; sb < 32; sb++) 2443 for (int i = 0; i < 3; i++) 2444 for(int ch = 0; ch < 2; ch++) 2445 if (Math.abs(_sample[gr][i][sb][ch]) > sample_level[ch]) 2446 sample_level[ch] = Math.abs(_sample[gr][i][sb][ch]); 2447 2448 out1.reset(); 2449 out1.write((byte) (sample_level[0] * 100.0)); 2450 out1.write((byte) (sample_level[1] * 100.0)); 2451 } 2452 2453 /** 2454 * 2455 */ getFrameLevel(int[][][] _sample)2456 private static void getFrameLevel(int[][][] _sample) 2457 { 2458 int[] sample_level = new int[2]; 2459 2460 for (int gr = 0; gr < 12; gr++) 2461 for (int sb = 0; sb < 32; sb++) 2462 for(int ch = 0; ch < 2; ch++) 2463 if (Math.abs(_sample[gr][sb][ch]) > sample_level[ch]) 2464 sample_level[ch] = Math.abs(_sample[gr][sb][ch]); 2465 2466 out1.reset(); 2467 out1.write((byte) (sample_level[0] * 100.0)); 2468 out1.write((byte) (sample_level[1] * 100.0)); 2469 } 2470 2471 } 2472 2473