Newer
Older
urbanLifeline_YanAn / patches / lamejs+1.2.1.patch
@zhangqy zhangqy on 3 Oct 39 KB first commit
  1. diff --git a/node_modules/lamejs/src/js/BitStream.js b/node_modules/lamejs/src/js/BitStream.js
  2. index dd9d69f..1a9822e 100644
  3. --- a/node_modules/lamejs/src/js/BitStream.js
  4. +++ b/node_modules/lamejs/src/js/BitStream.js
  5. @@ -30,6 +30,7 @@ BitStream.NEQ = function (a, b) {
  6. };
  7. function BitStream() {
  8. + var Lame = require('./Lame.js');
  9. var self = this;
  10. var CRC16_POLYNOMIAL = 0x8005;
  11. @@ -788,7 +789,7 @@ function BitStream() {
  12. /* find the gain and scale change required for no clipping */
  13. if (gfc.findPeakSample) {
  14. gfc.noclipGainChange = Math.ceil(Math
  15. - .log10(gfc.PeakSample / 32767.0) * 20.0 * 10.0) | 0;
  16. + .log10(gfc.PeakSample / 32767.0) * 20.0 * 10.0) | 0;
  17. /* round up */
  18. if (gfc.noclipGainChange > 0) {
  19. @@ -808,7 +809,7 @@ function BitStream() {
  20. gfc.noclipScale = -1;
  21. }
  22. } else
  23. - /* no clipping */
  24. + /* no clipping */
  25. gfc.noclipScale = -1;
  26. }
  27. };
  28. @@ -992,8 +993,8 @@ function BitStream() {
  29. if (gfc.findReplayGain)
  30. if (ga.AnalyzeSamples(gfc.rgdata, pcm_buf[0], 0,
  31. - pcm_buf[1], 0, samples_out,
  32. - gfc.channels_out) == GainAnalysis.GAIN_ANALYSIS_ERROR)
  33. + pcm_buf[1], 0, samples_out,
  34. + gfc.channels_out) == GainAnalysis.GAIN_ANALYSIS_ERROR)
  35. return -6;
  36. }
  37. diff --git a/node_modules/lamejs/src/js/Encoder.js b/node_modules/lamejs/src/js/Encoder.js
  38. index 4fea74e..ad109ae 100644
  39. --- a/node_modules/lamejs/src/js/Encoder.js
  40. +++ b/node_modules/lamejs/src/js/Encoder.js
  41. @@ -103,13 +103,13 @@ Encoder.MPG_MD_MS_LR = 2;
  42. Encoder.MPG_MD_MS_I = 3;
  43. Encoder.fircoef = [-0.0207887 * 5, -0.0378413 * 5,
  44. - -0.0432472 * 5, -0.031183 * 5, 7.79609e-18 * 5, 0.0467745 * 5,
  45. - 0.10091 * 5, 0.151365 * 5, 0.187098 * 5];
  46. +-0.0432472 * 5, -0.031183 * 5, 7.79609e-18 * 5, 0.0467745 * 5,
  47. +0.10091 * 5, 0.151365 * 5, 0.187098 * 5];
  48. function Encoder() {
  49. var NewMDCT = require('./NewMDCT.js');
  50. var III_psy_ratio = require('./III_psy_ratio.js');
  51. -
  52. + var MPEGMode = require('./MPEGMode.js');
  53. var FFTOFFSET = Encoder.FFTOFFSET;
  54. var MPG_MD_MS_LR = Encoder.MPG_MD_MS_LR;
  55. //BitStream bs;
  56. @@ -161,7 +161,7 @@ function Encoder() {
  57. *
  58. * modifies some values in gfp.internal_flags.ATH (gfc.ATH)
  59. */
  60. -//private void adjust_ATH(final LameInternalFlags gfc) {
  61. + //private void adjust_ATH(final LameInternalFlags gfc) {
  62. function adjust_ATH(gfc) {
  63. var gr2_max, max_pow;
  64. @@ -412,7 +412,7 @@ function Encoder() {
  65. var pe = [[0., 0.], [0., 0.]];
  66. var pe_MS = [[0., 0.], [0., 0.]];
  67. -//float[][] pe_use;
  68. + //float[][] pe_use;
  69. var pe_use;
  70. var ch, gr;
  71. @@ -644,7 +644,7 @@ function Encoder() {
  72. var j;
  73. for (j = 0; j < FFTOFFSET; j++)
  74. gfc.pinfo.pcmdata[ch][j] = gfc.pinfo.pcmdata[ch][j
  75. - + gfp.framesize];
  76. + + gfp.framesize];
  77. for (j = FFTOFFSET; j < 1600; j++) {
  78. gfc.pinfo.pcmdata[ch][j] = inbuf[ch][j - FFTOFFSET];
  79. }
  80. diff --git a/node_modules/lamejs/src/js/Lame.js b/node_modules/lamejs/src/js/Lame.js
  81. index d2dc7c0..7fc31a6 100644
  82. --- a/node_modules/lamejs/src/js/Lame.js
  83. +++ b/node_modules/lamejs/src/js/Lame.js
  84. @@ -26,6 +26,7 @@ var Tables = require('./Tables.js');
  85. var Encoder = require('./Encoder.js');
  86. function Lame() {
  87. + var MPEGMode = require('./MPEGMode.js');
  88. var self = this;
  89. var LAME_MAXALBUMART = (128 * 1024);
  90. @@ -414,7 +415,7 @@ function Lame() {
  91. for (var i = 2; i <= 14; i++) {
  92. if (Tables.bitrate_table[version][i] > 0) {
  93. if (Math.abs(Tables.bitrate_table[version][i] - bRate) < Math
  94. - .abs(bitrate - bRate))
  95. + .abs(bitrate - bRate))
  96. bitrate = Tables.bitrate_table[version][i];
  97. }
  98. }
  99. @@ -453,14 +454,14 @@ function Lame() {
  100. * </PRE>
  101. */
  102. var freq_map = [new BandPass(8, 2000),
  103. - new BandPass(16, 3700), new BandPass(24, 3900),
  104. - new BandPass(32, 5500), new BandPass(40, 7000),
  105. - new BandPass(48, 7500), new BandPass(56, 10000),
  106. - new BandPass(64, 11000), new BandPass(80, 13500),
  107. - new BandPass(96, 15100), new BandPass(112, 15600),
  108. - new BandPass(128, 17000), new BandPass(160, 17500),
  109. - new BandPass(192, 18600), new BandPass(224, 19400),
  110. - new BandPass(256, 19700), new BandPass(320, 20500)];
  111. + new BandPass(16, 3700), new BandPass(24, 3900),
  112. + new BandPass(32, 5500), new BandPass(40, 7000),
  113. + new BandPass(48, 7500), new BandPass(56, 10000),
  114. + new BandPass(64, 11000), new BandPass(80, 13500),
  115. + new BandPass(96, 15100), new BandPass(112, 15600),
  116. + new BandPass(128, 17000), new BandPass(160, 17500),
  117. + new BandPass(192, 18600), new BandPass(224, 19400),
  118. + new BandPass(256, 19700), new BandPass(320, 20500)];
  119. var table_index = self.nearestBitrateFullIndex(bitrate);
  120. lh.lowerlimit = freq_map[table_index].lowpass;
  121. @@ -839,42 +840,42 @@ function Lame() {
  122. switch (gfp.VBR) {
  123. case VbrMode.vbr_off:
  124. - {
  125. - var lh = new LowPassHighPass();
  126. - optimum_bandwidth(lh, gfp.brate);
  127. - lowpass = lh.lowerlimit;
  128. - break;
  129. - }
  130. + {
  131. + var lh = new LowPassHighPass();
  132. + optimum_bandwidth(lh, gfp.brate);
  133. + lowpass = lh.lowerlimit;
  134. + break;
  135. + }
  136. case VbrMode.vbr_abr:
  137. - {
  138. - var lh = new LowPassHighPass();
  139. - optimum_bandwidth(lh, gfp.VBR_mean_bitrate_kbps);
  140. - lowpass = lh.lowerlimit;
  141. - break;
  142. - }
  143. + {
  144. + var lh = new LowPassHighPass();
  145. + optimum_bandwidth(lh, gfp.VBR_mean_bitrate_kbps);
  146. + lowpass = lh.lowerlimit;
  147. + break;
  148. + }
  149. case VbrMode.vbr_rh:
  150. - {
  151. - var x = [19500, 19000, 18600, 18000, 17500, 16000,
  152. - 15600, 14900, 12500, 10000, 3950];
  153. - if (0 <= gfp.VBR_q && gfp.VBR_q <= 9) {
  154. - var a = x[gfp.VBR_q], b = x[gfp.VBR_q + 1], m = gfp.VBR_q_frac;
  155. - lowpass = linear_int(a, b, m);
  156. - } else {
  157. - lowpass = 19500;
  158. + {
  159. + var x = [19500, 19000, 18600, 18000, 17500, 16000,
  160. + 15600, 14900, 12500, 10000, 3950];
  161. + if (0 <= gfp.VBR_q && gfp.VBR_q <= 9) {
  162. + var a = x[gfp.VBR_q], b = x[gfp.VBR_q + 1], m = gfp.VBR_q_frac;
  163. + lowpass = linear_int(a, b, m);
  164. + } else {
  165. + lowpass = 19500;
  166. + }
  167. + break;
  168. }
  169. - break;
  170. - }
  171. default:
  172. - {
  173. - var x = [19500, 19000, 18500, 18000, 17500, 16500,
  174. - 15500, 14500, 12500, 9500, 3950];
  175. - if (0 <= gfp.VBR_q && gfp.VBR_q <= 9) {
  176. - var a = x[gfp.VBR_q], b = x[gfp.VBR_q + 1], m = gfp.VBR_q_frac;
  177. - lowpass = linear_int(a, b, m);
  178. - } else {
  179. - lowpass = 19500;
  180. + {
  181. + var x = [19500, 19000, 18500, 18000, 17500, 16500,
  182. + 15500, 14500, 12500, 9500, 3950];
  183. + if (0 <= gfp.VBR_q && gfp.VBR_q <= 9) {
  184. + var a = x[gfp.VBR_q], b = x[gfp.VBR_q + 1], m = gfp.VBR_q_frac;
  185. + lowpass = linear_int(a, b, m);
  186. + } else {
  187. + lowpass = 19500;
  188. + }
  189. }
  190. - }
  191. }
  192. if (gfp.mode == MPEGMode.MONO
  193. && (gfp.VBR == VbrMode.vbr_off || gfp.VBR == VbrMode.vbr_abr))
  194. @@ -975,12 +976,12 @@ function Lame() {
  195. case VbrMode.vbr_mt:
  196. case VbrMode.vbr_rh:
  197. case VbrMode.vbr_mtrh:
  198. - {
  199. - /* numbers are a bit strange, but they determine the lowpass value */
  200. - var cmp = [5.7, 6.5, 7.3, 8.2, 10, 11.9, 13, 14,
  201. - 15, 16.5];
  202. - gfp.compression_ratio = cmp[gfp.VBR_q];
  203. - }
  204. + {
  205. + /* numbers are a bit strange, but they determine the lowpass value */
  206. + var cmp = [5.7, 6.5, 7.3, 8.2, 10, 11.9, 13, 14,
  207. + 15, 16.5];
  208. + gfp.compression_ratio = cmp[gfp.VBR_q];
  209. + }
  210. break;
  211. case VbrMode.vbr_abr:
  212. gfp.compression_ratio = gfp.out_samplerate * 16 * gfc.channels_out
  213. @@ -1007,7 +1008,7 @@ function Lame() {
  214. if (gfp.highpasswidth >= 0)
  215. gfc.highpass2 = 2. * (gfp.highpassfreq + gfp.highpasswidth);
  216. else
  217. - /* 0% above on default */
  218. + /* 0% above on default */
  219. gfc.highpass2 = (1 + 0.00) * 2. * gfp.highpassfreq;
  220. gfc.highpass1 /= gfp.out_samplerate;
  221. @@ -1102,7 +1103,7 @@ function Lame() {
  222. if (gfp.version == 1) /* MPEG 1 */
  223. gfc.sideinfo_len = (gfc.channels_out == 1) ? 4 + 17 : 4 + 32;
  224. else
  225. - /* MPEG 2 */
  226. + /* MPEG 2 */
  227. gfc.sideinfo_len = (gfc.channels_out == 1) ? 4 + 9 : 4 + 17;
  228. if (gfp.error_protection)
  229. @@ -1130,103 +1131,103 @@ function Lame() {
  230. gfp.VBR = VbrMode.vbr_mtrh;
  231. //$FALL-THROUGH$
  232. case VbrMode.vbr_mtrh:
  233. - {
  234. - if (gfp.useTemporal == null) {
  235. - gfp.useTemporal = false;
  236. - /* off by default for this VBR mode */
  237. - }
  238. -
  239. - p.apply_preset(gfp, 500 - (gfp.VBR_q * 10), 0);
  240. - /**
  241. - * <PRE>
  242. - * The newer VBR code supports only a limited
  243. - * subset of quality levels:
  244. - * 9-5=5 are the same, uses x^3/4 quantization
  245. - * 4-0=0 are the same 5 plus best huffman divide code
  246. - * </PRE>
  247. - */
  248. - if (gfp.quality < 0)
  249. - gfp.quality = LAME_DEFAULT_QUALITY;
  250. - if (gfp.quality < 5)
  251. - gfp.quality = 0;
  252. - if (gfp.quality > 5)
  253. - gfp.quality = 5;
  254. -
  255. - gfc.PSY.mask_adjust = gfp.maskingadjust;
  256. - gfc.PSY.mask_adjust_short = gfp.maskingadjust_short;
  257. -
  258. - /*
  259. - * sfb21 extra only with MPEG-1 at higher sampling rates
  260. - */
  261. - if (gfp.experimentalY)
  262. - gfc.sfb21_extra = false;
  263. - else
  264. - gfc.sfb21_extra = (gfp.out_samplerate > 44000);
  265. + {
  266. + if (gfp.useTemporal == null) {
  267. + gfp.useTemporal = false;
  268. + /* off by default for this VBR mode */
  269. + }
  270. - gfc.iteration_loop = new VBRNewIterationLoop(qu);
  271. - break;
  272. + p.apply_preset(gfp, 500 - (gfp.VBR_q * 10), 0);
  273. + /**
  274. + * <PRE>
  275. + * The newer VBR code supports only a limited
  276. + * subset of quality levels:
  277. + * 9-5=5 are the same, uses x^3/4 quantization
  278. + * 4-0=0 are the same 5 plus best huffman divide code
  279. + * </PRE>
  280. + */
  281. + if (gfp.quality < 0)
  282. + gfp.quality = LAME_DEFAULT_QUALITY;
  283. + if (gfp.quality < 5)
  284. + gfp.quality = 0;
  285. + if (gfp.quality > 5)
  286. + gfp.quality = 5;
  287. +
  288. + gfc.PSY.mask_adjust = gfp.maskingadjust;
  289. + gfc.PSY.mask_adjust_short = gfp.maskingadjust_short;
  290. +
  291. + /*
  292. + * sfb21 extra only with MPEG-1 at higher sampling rates
  293. + */
  294. + if (gfp.experimentalY)
  295. + gfc.sfb21_extra = false;
  296. + else
  297. + gfc.sfb21_extra = (gfp.out_samplerate > 44000);
  298. +
  299. + gfc.iteration_loop = new VBRNewIterationLoop(qu);
  300. + break;
  301. - }
  302. + }
  303. case VbrMode.vbr_rh:
  304. - {
  305. + {
  306. - p.apply_preset(gfp, 500 - (gfp.VBR_q * 10), 0);
  307. + p.apply_preset(gfp, 500 - (gfp.VBR_q * 10), 0);
  308. - gfc.PSY.mask_adjust = gfp.maskingadjust;
  309. - gfc.PSY.mask_adjust_short = gfp.maskingadjust_short;
  310. + gfc.PSY.mask_adjust = gfp.maskingadjust;
  311. + gfc.PSY.mask_adjust_short = gfp.maskingadjust_short;
  312. - /*
  313. - * sfb21 extra only with MPEG-1 at higher sampling rates
  314. - */
  315. - if (gfp.experimentalY)
  316. - gfc.sfb21_extra = false;
  317. - else
  318. - gfc.sfb21_extra = (gfp.out_samplerate > 44000);
  319. + /*
  320. + * sfb21 extra only with MPEG-1 at higher sampling rates
  321. + */
  322. + if (gfp.experimentalY)
  323. + gfc.sfb21_extra = false;
  324. + else
  325. + gfc.sfb21_extra = (gfp.out_samplerate > 44000);
  326. - /*
  327. - * VBR needs at least the output of GPSYCHO, so we have to garantee
  328. - * that by setting a minimum quality level, actually level 6 does
  329. - * it. down to level 6
  330. - */
  331. - if (gfp.quality > 6)
  332. - gfp.quality = 6;
  333. + /*
  334. + * VBR needs at least the output of GPSYCHO, so we have to garantee
  335. + * that by setting a minimum quality level, actually level 6 does
  336. + * it. down to level 6
  337. + */
  338. + if (gfp.quality > 6)
  339. + gfp.quality = 6;
  340. - if (gfp.quality < 0)
  341. - gfp.quality = LAME_DEFAULT_QUALITY;
  342. + if (gfp.quality < 0)
  343. + gfp.quality = LAME_DEFAULT_QUALITY;
  344. - gfc.iteration_loop = new VBROldIterationLoop(qu);
  345. - break;
  346. - }
  347. + gfc.iteration_loop = new VBROldIterationLoop(qu);
  348. + break;
  349. + }
  350. default: /* cbr/abr */
  351. - {
  352. - var vbrmode;
  353. + {
  354. + var vbrmode;
  355. - /*
  356. - * no sfb21 extra with CBR code
  357. - */
  358. - gfc.sfb21_extra = false;
  359. + /*
  360. + * no sfb21 extra with CBR code
  361. + */
  362. + gfc.sfb21_extra = false;
  363. - if (gfp.quality < 0)
  364. - gfp.quality = LAME_DEFAULT_QUALITY;
  365. + if (gfp.quality < 0)
  366. + gfp.quality = LAME_DEFAULT_QUALITY;
  367. - vbrmode = gfp.VBR;
  368. - if (vbrmode == VbrMode.vbr_off)
  369. - gfp.VBR_mean_bitrate_kbps = gfp.brate;
  370. - /* second, set parameters depending on bitrate */
  371. - p.apply_preset(gfp, gfp.VBR_mean_bitrate_kbps, 0);
  372. - gfp.VBR = vbrmode;
  373. + vbrmode = gfp.VBR;
  374. + if (vbrmode == VbrMode.vbr_off)
  375. + gfp.VBR_mean_bitrate_kbps = gfp.brate;
  376. + /* second, set parameters depending on bitrate */
  377. + p.apply_preset(gfp, gfp.VBR_mean_bitrate_kbps, 0);
  378. + gfp.VBR = vbrmode;
  379. - gfc.PSY.mask_adjust = gfp.maskingadjust;
  380. - gfc.PSY.mask_adjust_short = gfp.maskingadjust_short;
  381. + gfc.PSY.mask_adjust = gfp.maskingadjust;
  382. + gfc.PSY.mask_adjust_short = gfp.maskingadjust_short;
  383. - if (vbrmode == VbrMode.vbr_off) {
  384. - gfc.iteration_loop = new CBRNewIterationLoop(qu);
  385. - } else {
  386. - gfc.iteration_loop = new ABRIterationLoop(qu);
  387. + if (vbrmode == VbrMode.vbr_off) {
  388. + gfc.iteration_loop = new CBRNewIterationLoop(qu);
  389. + } else {
  390. + gfc.iteration_loop = new ABRIterationLoop(qu);
  391. + }
  392. + break;
  393. }
  394. - break;
  395. - }
  396. }
  397. assert(gfp.scale >= 0);
  398. /* initialize default values common for all modes */
  399. @@ -1577,7 +1578,7 @@ function Lame() {
  400. /* Downsample to Mono if 2 channels in and 1 channel out */
  401. if (gfp.num_channels == 2 && gfc.channels_out == 1) {
  402. for (i = 0; i < nsamples; ++i) {
  403. - in_buffer[0][i] = 0.5 * ( in_buffer[0][i] + in_buffer[1][i]);
  404. + in_buffer[0][i] = 0.5 * (in_buffer[0][i] + in_buffer[1][i]);
  405. in_buffer[1][i] = 0.0;
  406. }
  407. }
  408. @@ -1608,7 +1609,7 @@ function Lame() {
  409. /* compute ReplayGain of resampled input if requested */
  410. if (gfc.findReplayGain && !gfc.decode_on_the_fly)
  411. if (ga.AnalyzeSamples(gfc.rgdata, mfbuf[0], gfc.mf_size,
  412. - mfbuf[1], gfc.mf_size, n_out, gfc.channels_out) == GainAnalysis.GAIN_ANALYSIS_ERROR)
  413. + mfbuf[1], gfc.mf_size, n_out, gfc.channels_out) == GainAnalysis.GAIN_ANALYSIS_ERROR)
  414. return -6;
  415. /* update in_buffer counters */
  416. @@ -1786,13 +1787,13 @@ function Lame() {
  417. joff = 0 | Math.floor((offset * 2 * bpc) + bpc + .5);
  418. var xvalue = 0.;
  419. for (i = 0; i <= filter_l; ++i) {
  420. - /* force integer index */
  421. + /* force integer index */
  422. var j2 = 0 | (i + j - filter_l / 2);
  423. var y;
  424. assert(j2 < len);
  425. assert(j2 + BLACKSIZE >= 0);
  426. y = (j2 < 0) ? inbuf_old[BLACKSIZE + j2] : inbuf[in_bufferPos
  427. - + j2];
  428. + + j2];
  429. xvalue += y * gfc.blackfilt[joff][i];
  430. }
  431. outbuf[outbufPos + k] = xvalue;
  432. @@ -1815,7 +1816,7 @@ function Lame() {
  433. if (num_used.num_used >= BLACKSIZE) {
  434. for (i = 0; i < BLACKSIZE; i++)
  435. inbuf_old[i] = inbuf[in_bufferPos + num_used.num_used + i
  436. - - BLACKSIZE];
  437. + - BLACKSIZE];
  438. } else {
  439. /* shift in num_used.num_used samples into inbuf_old */
  440. var n_shift = BLACKSIZE - num_used.num_used;
  441. diff --git a/node_modules/lamejs/src/js/Presets.js b/node_modules/lamejs/src/js/Presets.js
  442. index a3de3c6..7789b4e 100644
  443. --- a/node_modules/lamejs/src/js/Presets.js
  444. +++ b/node_modules/lamejs/src/js/Presets.js
  445. @@ -15,11 +15,12 @@ var new_int_n = common.new_int_n;
  446. var assert = common.assert;
  447. function Presets() {
  448. + var Lame = require('./Lame.js');
  449. function VBRPresets(qual, comp, compS,
  450. - y, shThreshold, shThresholdS,
  451. - adj, adjShort, lower,
  452. - curve, sens, inter,
  453. - joint, mod, fix) {
  454. + y, shThreshold, shThresholdS,
  455. + adj, adjShort, lower,
  456. + curve, sens, inter,
  457. + joint, mod, fix) {
  458. this.vbr_q = qual;
  459. this.quant_comp = comp;
  460. this.quant_comp_s = compS;
  461. @@ -38,10 +39,10 @@ function Presets() {
  462. }
  463. function ABRPresets(kbps, comp, compS,
  464. - joint, fix, shThreshold,
  465. - shThresholdS, bass, sc,
  466. - mask, lower, curve,
  467. - interCh, sfScale) {
  468. + joint, fix, shThreshold,
  469. + shThresholdS, bass, sc,
  470. + mask, lower, curve,
  471. + interCh, sfScale) {
  472. this.quant_comp = comp;
  473. this.quant_comp_s = compS;
  474. this.safejoint = joint;
  475. @@ -356,59 +357,59 @@ function Presets() {
  476. return preset;
  477. }
  478. - this.apply_preset = function(gfp, preset, enforce) {
  479. + this.apply_preset = function (gfp, preset, enforce) {
  480. /* translate legacy presets */
  481. switch (preset) {
  482. case Lame.R3MIX:
  483. - {
  484. - preset = Lame.V3;
  485. - gfp.VBR = VbrMode.vbr_mtrh;
  486. - break;
  487. - }
  488. + {
  489. + preset = Lame.V3;
  490. + gfp.VBR = VbrMode.vbr_mtrh;
  491. + break;
  492. + }
  493. case Lame.MEDIUM:
  494. - {
  495. - preset = Lame.V4;
  496. - gfp.VBR = VbrMode.vbr_rh;
  497. - break;
  498. - }
  499. + {
  500. + preset = Lame.V4;
  501. + gfp.VBR = VbrMode.vbr_rh;
  502. + break;
  503. + }
  504. case Lame.MEDIUM_FAST:
  505. - {
  506. - preset = Lame.V4;
  507. - gfp.VBR = VbrMode.vbr_mtrh;
  508. - break;
  509. - }
  510. + {
  511. + preset = Lame.V4;
  512. + gfp.VBR = VbrMode.vbr_mtrh;
  513. + break;
  514. + }
  515. case Lame.STANDARD:
  516. - {
  517. - preset = Lame.V2;
  518. - gfp.VBR = VbrMode.vbr_rh;
  519. - break;
  520. - }
  521. + {
  522. + preset = Lame.V2;
  523. + gfp.VBR = VbrMode.vbr_rh;
  524. + break;
  525. + }
  526. case Lame.STANDARD_FAST:
  527. - {
  528. - preset = Lame.V2;
  529. - gfp.VBR = VbrMode.vbr_mtrh;
  530. - break;
  531. - }
  532. + {
  533. + preset = Lame.V2;
  534. + gfp.VBR = VbrMode.vbr_mtrh;
  535. + break;
  536. + }
  537. case Lame.EXTREME:
  538. - {
  539. - preset = Lame.V0;
  540. - gfp.VBR = VbrMode.vbr_rh;
  541. - break;
  542. - }
  543. + {
  544. + preset = Lame.V0;
  545. + gfp.VBR = VbrMode.vbr_rh;
  546. + break;
  547. + }
  548. case Lame.EXTREME_FAST:
  549. - {
  550. - preset = Lame.V0;
  551. - gfp.VBR = VbrMode.vbr_mtrh;
  552. - break;
  553. - }
  554. + {
  555. + preset = Lame.V0;
  556. + gfp.VBR = VbrMode.vbr_mtrh;
  557. + break;
  558. + }
  559. case Lame.INSANE:
  560. - {
  561. - preset = 320;
  562. - gfp.preset = preset;
  563. - apply_abr_preset(gfp, preset, enforce);
  564. - gfp.VBR = VbrMode.vbr_off;
  565. - return preset;
  566. - }
  567. + {
  568. + preset = 320;
  569. + gfp.preset = preset;
  570. + apply_abr_preset(gfp, preset, enforce);
  571. + gfp.VBR = VbrMode.vbr_off;
  572. + return preset;
  573. + }
  574. }
  575. gfp.preset = preset;
  576. diff --git a/node_modules/lamejs/src/js/PsyModel.js b/node_modules/lamejs/src/js/PsyModel.js
  577. index e440280..ee82fe2 100644
  578. --- a/node_modules/lamejs/src/js/PsyModel.js
  579. +++ b/node_modules/lamejs/src/js/PsyModel.js
  580. @@ -159,7 +159,7 @@ var FFT = require("./FFT.js");
  581. var Encoder = require("./Encoder.js");
  582. function PsyModel() {
  583. -
  584. + var MPEGMode = require('./MPEGMode.js');
  585. var fft = new FFT();
  586. var LOG10 = 2.30258509299404568402;
  587. @@ -289,9 +289,9 @@ function PsyModel() {
  588. fftenergy_s[b][0] *= fftenergy_s[b][0];
  589. for (var j = Encoder.BLKSIZE_s / 2 - 1; j >= 0; --j) {
  590. var re = (wsamp_s[wsamp_sPos + 0])[b][Encoder.BLKSIZE_s
  591. - / 2 - j];
  592. + / 2 - j];
  593. var im = (wsamp_s[wsamp_sPos + 0])[b][Encoder.BLKSIZE_s
  594. - / 2 + j];
  595. + / 2 + j];
  596. fftenergy_s[b][Encoder.BLKSIZE_s / 2 - j] = NON_LINEAR_SCALE_ENERGY((re
  597. * re + im * im) * 0.5);
  598. }
  599. @@ -376,26 +376,26 @@ function PsyModel() {
  600. }
  601. var table1 = [3.3246 * 3.3246,
  602. - 3.23837 * 3.23837, 3.15437 * 3.15437, 3.00412 * 3.00412,
  603. - 2.86103 * 2.86103, 2.65407 * 2.65407, 2.46209 * 2.46209,
  604. - 2.284 * 2.284, 2.11879 * 2.11879, 1.96552 * 1.96552,
  605. - 1.82335 * 1.82335, 1.69146 * 1.69146, 1.56911 * 1.56911,
  606. - 1.46658 * 1.46658, 1.37074 * 1.37074, 1.31036 * 1.31036,
  607. - 1.25264 * 1.25264, 1.20648 * 1.20648, 1.16203 * 1.16203,
  608. - 1.12765 * 1.12765, 1.09428 * 1.09428, 1.0659 * 1.0659,
  609. - 1.03826 * 1.03826, 1.01895 * 1.01895, 1];
  610. + 3.23837 * 3.23837, 3.15437 * 3.15437, 3.00412 * 3.00412,
  611. + 2.86103 * 2.86103, 2.65407 * 2.65407, 2.46209 * 2.46209,
  612. + 2.284 * 2.284, 2.11879 * 2.11879, 1.96552 * 1.96552,
  613. + 1.82335 * 1.82335, 1.69146 * 1.69146, 1.56911 * 1.56911,
  614. + 1.46658 * 1.46658, 1.37074 * 1.37074, 1.31036 * 1.31036,
  615. + 1.25264 * 1.25264, 1.20648 * 1.20648, 1.16203 * 1.16203,
  616. + 1.12765 * 1.12765, 1.09428 * 1.09428, 1.0659 * 1.0659,
  617. + 1.03826 * 1.03826, 1.01895 * 1.01895, 1];
  618. var table2 = [1.33352 * 1.33352,
  619. - 1.35879 * 1.35879, 1.38454 * 1.38454, 1.39497 * 1.39497,
  620. - 1.40548 * 1.40548, 1.3537 * 1.3537, 1.30382 * 1.30382,
  621. - 1.22321 * 1.22321, 1.14758 * 1.14758, 1];
  622. + 1.35879 * 1.35879, 1.38454 * 1.38454, 1.39497 * 1.39497,
  623. + 1.40548 * 1.40548, 1.3537 * 1.3537, 1.30382 * 1.30382,
  624. + 1.22321 * 1.22321, 1.14758 * 1.14758, 1];
  625. var table3 = [2.35364 * 2.35364,
  626. - 2.29259 * 2.29259, 2.23313 * 2.23313, 2.12675 * 2.12675,
  627. - 2.02545 * 2.02545, 1.87894 * 1.87894, 1.74303 * 1.74303,
  628. - 1.61695 * 1.61695, 1.49999 * 1.49999, 1.39148 * 1.39148,
  629. - 1.29083 * 1.29083, 1.19746 * 1.19746, 1.11084 * 1.11084,
  630. - 1.03826 * 1.03826];
  631. + 2.29259 * 2.29259, 2.23313 * 2.23313, 2.12675 * 2.12675,
  632. + 2.02545 * 2.02545, 1.87894 * 1.87894, 1.74303 * 1.74303,
  633. + 1.61695 * 1.61695, 1.49999 * 1.49999, 1.39148 * 1.39148,
  634. + 1.29083 * 1.29083, 1.19746 * 1.19746, 1.11084 * 1.11084,
  635. + 1.03826 * 1.03826];
  636. /**
  637. * addition of simultaneous masking Naoki Shibata 2000/7
  638. @@ -473,9 +473,9 @@ function PsyModel() {
  639. }
  640. var table2_ = [1.33352 * 1.33352,
  641. - 1.35879 * 1.35879, 1.38454 * 1.38454, 1.39497 * 1.39497,
  642. - 1.40548 * 1.40548, 1.3537 * 1.3537, 1.30382 * 1.30382,
  643. - 1.22321 * 1.22321, 1.14758 * 1.14758, 1];
  644. + 1.35879 * 1.35879, 1.38454 * 1.38454, 1.39497 * 1.39497,
  645. + 1.40548 * 1.40548, 1.3537 * 1.3537, 1.30382 * 1.30382,
  646. + 1.22321 * 1.22321, 1.14758 * 1.14758, 1];
  647. /**
  648. * addition of simultaneous masking Naoki Shibata 2000/7
  649. @@ -611,7 +611,7 @@ function PsyModel() {
  650. gfc.thm[3].l[sb] = Math.min(thmS, gfc.thm[3].l[sb]);
  651. }
  652. - athlower *= ( Encoder.BLKSIZE_s / Encoder.BLKSIZE);
  653. + athlower *= (Encoder.BLKSIZE_s / Encoder.BLKSIZE);
  654. for (var sb = 0; sb < Encoder.SBMAX_s; sb++) {
  655. for (var sblock = 0; sblock < 3; sblock++) {
  656. var thmLR, thmM, thmS, ath;
  657. @@ -785,9 +785,9 @@ function PsyModel() {
  658. var gfc = gfp.internal_flags;
  659. if (gfp.short_blocks == ShortBlock.short_block_coupled
  660. - /* force both channels to use the same block type */
  661. - /* this is necessary if the frame is to be encoded in ms_stereo. */
  662. - /* But even without ms_stereo, FhG does this */
  663. + /* force both channels to use the same block type */
  664. + /* this is necessary if the frame is to be encoded in ms_stereo. */
  665. + /* But even without ms_stereo, FhG does this */
  666. && !(uselongblock[0] != 0 && uselongblock[1] != 0))
  667. uselongblock[0] = uselongblock[1] = 0;
  668. @@ -960,7 +960,7 @@ function PsyModel() {
  669. a = 20.0
  670. * (m * 3.0 - a)
  671. / (a * (gfc.numlines_l[b - 1] + gfc.numlines_l[b]
  672. - + gfc.numlines_l[b + 1] - 1));
  673. + + gfc.numlines_l[b + 1] - 1));
  674. var k = 0 | a;
  675. if (k > last_tab_entry)
  676. k = last_tab_entry;
  677. @@ -1034,8 +1034,8 @@ function PsyModel() {
  678. numchn = 4;
  679. if (gfp.VBR == VbrMode.vbr_off)
  680. - pcfact = gfc.ResvMax == 0 ? 0 : ( gfc.ResvSize)
  681. - / gfc.ResvMax * 0.5;
  682. + pcfact = gfc.ResvMax == 0 ? 0 : (gfc.ResvSize)
  683. + / gfc.ResvMax * 0.5;
  684. else if (gfp.VBR == VbrMode.vbr_rh || gfp.VBR == VbrMode.vbr_mtrh
  685. || gfp.VBR == VbrMode.vbr_mt) {
  686. pcfact = 0.6;
  687. @@ -1060,10 +1060,10 @@ function PsyModel() {
  688. for (j = 0; j < ((NSFIRLEN - 1) / 2) - 1; j += 2) {
  689. sum1 += fircoef[j]
  690. * (firbuf[firbufPos + i + j] + firbuf[firbufPos + i
  691. - + NSFIRLEN - j]);
  692. + + NSFIRLEN - j]);
  693. sum2 += fircoef[j + 1]
  694. * (firbuf[firbufPos + i + j + 1] + firbuf[firbufPos
  695. - + i + NSFIRLEN - j - 1]);
  696. + + i + NSFIRLEN - j - 1]);
  697. }
  698. ns_hpfsmpl[chn][i] = sum1 + sum2;
  699. }
  700. @@ -1312,7 +1312,7 @@ function PsyModel() {
  701. thr[b] = NS_INTERP(
  702. Math.min(ecb, Math.min(rpelev
  703. * gfc.nb_1[chn][b], rpelev2
  704. - * gfc.nb_2[chn][b])), ecb, pcfact);
  705. + * gfc.nb_2[chn][b])), ecb, pcfact);
  706. gfc.nb_2[chn][b] = gfc.nb_1[chn][b];
  707. gfc.nb_1[chn][b] = ecb;
  708. @@ -1468,9 +1468,9 @@ function PsyModel() {
  709. }
  710. var fircoef_ = [-8.65163e-18 * 2,
  711. - -0.00851586 * 2, -6.74764e-18 * 2, 0.0209036 * 2,
  712. - -3.36639e-17 * 2, -0.0438162 * 2, -1.54175e-17 * 2,
  713. - 0.0931738 * 2, -5.52212e-17 * 2, -0.313819 * 2];
  714. + -0.00851586 * 2, -6.74764e-18 * 2, 0.0209036 * 2,
  715. + -3.36639e-17 * 2, -0.0438162 * 2, -1.54175e-17 * 2,
  716. + 0.0931738 * 2, -5.52212e-17 * 2, -0.313819 * 2];
  717. /**
  718. * Apply HPF of fs/4 to the input signal. This is used for attack detection
  719. @@ -1496,10 +1496,10 @@ function PsyModel() {
  720. for (var j = 0; j < ((NSFIRLEN - 1) / 2) - 1; j += 2) {
  721. sum1 += fircoef_[j]
  722. * (firbuf[firbufPos + i + j] + firbuf[firbufPos + i
  723. - + NSFIRLEN - j]);
  724. + + NSFIRLEN - j]);
  725. sum2 += fircoef_[j + 1]
  726. * (firbuf[firbufPos + i + j + 1] + firbuf[firbufPos
  727. - + i + NSFIRLEN - j - 1]);
  728. + + i + NSFIRLEN - j - 1]);
  729. }
  730. ns_hpfsmpl[chn][i] = sum1 + sum2;
  731. }
  732. @@ -1628,7 +1628,7 @@ function PsyModel() {
  733. if (gfc.nsPsy.lastAttacks[chn] == 3
  734. || (ns_attacks[chn][0] + ns_attacks[chn][1]
  735. - + ns_attacks[chn][2] + ns_attacks[chn][3]) != 0) {
  736. + + ns_attacks[chn][2] + ns_attacks[chn][3]) != 0) {
  737. ns_uselongblock = 0;
  738. if (ns_attacks[chn][1] != 0 && ns_attacks[chn][0] != 0) {
  739. @@ -1707,7 +1707,7 @@ function PsyModel() {
  740. a = 20.0
  741. * (m * 3.0 - a)
  742. / (a * (gfc.numlines_s[b - 1] + gfc.numlines_s[b]
  743. - + gfc.numlines_s[b + 1] - 1));
  744. + + gfc.numlines_s[b + 1] - 1));
  745. var k = 0 | a;
  746. if (k > last_tab_entry)
  747. k = last_tab_entry;
  748. @@ -1949,9 +1949,9 @@ function PsyModel() {
  749. var gfc = gfp.internal_flags;
  750. if (gfp.short_blocks == ShortBlock.short_block_coupled
  751. - /* force both channels to use the same block type */
  752. - /* this is necessary if the frame is to be encoded in ms_stereo. */
  753. - /* But even without ms_stereo, FhG does this */
  754. + /* force both channels to use the same block type */
  755. + /* this is necessary if the frame is to be encoded in ms_stereo. */
  756. + /* But even without ms_stereo, FhG does this */
  757. && !(uselongblock[0] != 0 && uselongblock[1] != 0))
  758. uselongblock[0] = uselongblock[1] = 0;
  759. @@ -2071,7 +2071,7 @@ function PsyModel() {
  760. /* block type */
  761. var ns_attacks = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0],
  762. - [0, 0, 0, 0]];
  763. + [0, 0, 0, 0]];
  764. var uselongblock = new_int(2);
  765. /* usual variables like loop indices, etc.. */
  766. @@ -2380,7 +2380,7 @@ function PsyModel() {
  767. b_frq[i] = sfreq * j;
  768. for (j2 = j; freq2bark(sfreq * j2) - bark1 < DELBARK
  769. - && j2 <= blksize / 2; j2++)
  770. + && j2 <= blksize / 2; j2++)
  771. ;
  772. numlines[i] = j2 - j;
  773. @@ -2432,7 +2432,7 @@ function PsyModel() {
  774. /* setup stereo demasking thresholds */
  775. /* formula reverse enginerred from plot in paper */
  776. arg = freq2bark(sfreq * scalepos[sfb] * deltafreq);
  777. - arg = ( Math.min(arg, 15.5) / 15.5);
  778. + arg = (Math.min(arg, 15.5) / 15.5);
  779. mld[sfb] = Math.pow(10.0,
  780. 1.25 * (1 - Math.cos(Math.PI * arg)) - 2.5);
  781. @@ -2602,7 +2602,7 @@ function PsyModel() {
  782. gfc.npart_l = init_numline(gfc.numlines_l, gfc.bo_l, gfc.bm_l, bval,
  783. bval_width, gfc.mld_l, gfc.PSY.bo_l_weight, sfreq,
  784. Encoder.BLKSIZE, gfc.scalefac_band.l, Encoder.BLKSIZE
  785. - / (2.0 * 576), Encoder.SBMAX_l);
  786. + / (2.0 * 576), Encoder.SBMAX_l);
  787. assert(gfc.npart_l < Encoder.CBANDS);
  788. /* compute the spreading function */
  789. for (i = 0; i < gfc.npart_l; i++) {
  790. @@ -2671,7 +2671,7 @@ function PsyModel() {
  791. gfc.npart_s = init_numline(gfc.numlines_s, gfc.bo_s, gfc.bm_s, bval,
  792. bval_width, gfc.mld_s, gfc.PSY.bo_s_weight, sfreq,
  793. Encoder.BLKSIZE_s, gfc.scalefac_band.s, Encoder.BLKSIZE_s
  794. - / (2.0 * 192), Encoder.SBMAX_s);
  795. + / (2.0 * 192), Encoder.SBMAX_s);
  796. assert(gfc.npart_s < Encoder.CBANDS);
  797. /* SNR formula. short block is normalized by SNR. is it still right ? */
  798. diff --git a/node_modules/lamejs/src/js/QuantizePVT.js b/node_modules/lamejs/src/js/QuantizePVT.js
  799. index ef69bef..2656fd9 100644
  800. --- a/node_modules/lamejs/src/js/QuantizePVT.js
  801. +++ b/node_modules/lamejs/src/js/QuantizePVT.js
  802. @@ -51,6 +51,7 @@ QuantizePVT.IXMAX_VAL = 8206;
  803. function QuantizePVT() {
  804. + var BitStream = require('./BitStream.js');
  805. var tak = null;
  806. var rv = null;
  807. var psy = null;
  808. @@ -137,67 +138,67 @@ function QuantizePVT() {
  809. this.sfBandIndex = [
  810. // Table B.2.b: 22.05 kHz
  811. new ScaleFac([0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464,
  812. - 522, 576],
  813. + 522, 576],
  814. [0, 4, 8, 12, 18, 24, 32, 42, 56, 74, 100, 132, 174, 192]
  815. , [0, 0, 0, 0, 0, 0, 0] // sfb21 pseudo sub bands
  816. , [0, 0, 0, 0, 0, 0, 0] // sfb12 pseudo sub bands
  817. ),
  818. /* Table B.2.c: 24 kHz */ /* docs: 332. mpg123(broken): 330 */
  819. new ScaleFac([0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 114, 136, 162, 194, 232, 278, 332, 394, 464,
  820. - 540, 576],
  821. + 540, 576],
  822. [0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 136, 180, 192]
  823. , [0, 0, 0, 0, 0, 0, 0] /* sfb21 pseudo sub bands */
  824. , [0, 0, 0, 0, 0, 0, 0] /* sfb12 pseudo sub bands */
  825. ),
  826. /* Table B.2.a: 16 kHz */
  827. new ScaleFac([0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464,
  828. - 522, 576],
  829. + 522, 576],
  830. [0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192]
  831. , [0, 0, 0, 0, 0, 0, 0] /* sfb21 pseudo sub bands */
  832. , [0, 0, 0, 0, 0, 0, 0] /* sfb12 pseudo sub bands */
  833. ),
  834. /* Table B.8.b: 44.1 kHz */
  835. new ScaleFac([0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 52, 62, 74, 90, 110, 134, 162, 196, 238, 288, 342, 418,
  836. - 576],
  837. + 576],
  838. [0, 4, 8, 12, 16, 22, 30, 40, 52, 66, 84, 106, 136, 192]
  839. , [0, 0, 0, 0, 0, 0, 0] /* sfb21 pseudo sub bands */
  840. , [0, 0, 0, 0, 0, 0, 0] /* sfb12 pseudo sub bands */
  841. ),
  842. /* Table B.8.c: 48 kHz */
  843. new ScaleFac([0, 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 60, 72, 88, 106, 128, 156, 190, 230, 276, 330, 384,
  844. - 576],
  845. + 576],
  846. [0, 4, 8, 12, 16, 22, 28, 38, 50, 64, 80, 100, 126, 192]
  847. , [0, 0, 0, 0, 0, 0, 0] /* sfb21 pseudo sub bands */
  848. , [0, 0, 0, 0, 0, 0, 0] /* sfb12 pseudo sub bands */
  849. ),
  850. /* Table B.8.a: 32 kHz */
  851. new ScaleFac([0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 54, 66, 82, 102, 126, 156, 194, 240, 296, 364, 448, 550,
  852. - 576],
  853. + 576],
  854. [0, 4, 8, 12, 16, 22, 30, 42, 58, 78, 104, 138, 180, 192]
  855. , [0, 0, 0, 0, 0, 0, 0] /* sfb21 pseudo sub bands */
  856. , [0, 0, 0, 0, 0, 0, 0] /* sfb12 pseudo sub bands */
  857. ),
  858. /* MPEG-2.5 11.025 kHz */
  859. new ScaleFac([0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464,
  860. - 522, 576],
  861. + 522, 576],
  862. [0 / 3, 12 / 3, 24 / 3, 36 / 3, 54 / 3, 78 / 3, 108 / 3, 144 / 3, 186 / 3, 240 / 3, 312 / 3,
  863. - 402 / 3, 522 / 3, 576 / 3]
  864. + 402 / 3, 522 / 3, 576 / 3]
  865. , [0, 0, 0, 0, 0, 0, 0] /* sfb21 pseudo sub bands */
  866. , [0, 0, 0, 0, 0, 0, 0] /* sfb12 pseudo sub bands */
  867. ),
  868. /* MPEG-2.5 12 kHz */
  869. new ScaleFac([0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464,
  870. - 522, 576],
  871. + 522, 576],
  872. [0 / 3, 12 / 3, 24 / 3, 36 / 3, 54 / 3, 78 / 3, 108 / 3, 144 / 3, 186 / 3, 240 / 3, 312 / 3,
  873. - 402 / 3, 522 / 3, 576 / 3]
  874. + 402 / 3, 522 / 3, 576 / 3]
  875. , [0, 0, 0, 0, 0, 0, 0] /* sfb21 pseudo sub bands */
  876. , [0, 0, 0, 0, 0, 0, 0] /* sfb12 pseudo sub bands */
  877. ),
  878. /* MPEG-2.5 8 kHz */
  879. new ScaleFac([0, 12, 24, 36, 48, 60, 72, 88, 108, 132, 160, 192, 232, 280, 336, 400, 476, 566, 568, 570,
  880. - 572, 574, 576],
  881. + 572, 574, 576],
  882. [0 / 3, 24 / 3, 48 / 3, 72 / 3, 108 / 3, 156 / 3, 216 / 3, 288 / 3, 372 / 3, 480 / 3, 486 / 3,
  883. - 492 / 3, 498 / 3, 576 / 3]
  884. + 492 / 3, 498 / 3, 576 / 3]
  885. , [0, 0, 0, 0, 0, 0, 0] /* sfb21 pseudo sub bands */
  886. , [0, 0, 0, 0, 0, 0, 0] /* sfb12 pseudo sub bands */
  887. )
  888. @@ -419,7 +420,7 @@ function QuantizePVT() {
  889. * bugfixes rh 8/01: often allocated more than the allowed 4095 bits
  890. */
  891. this.on_pe = function (gfp, pe,
  892. - targ_bits, mean_bits, gr, cbr) {
  893. + targ_bits, mean_bits, gr, cbr) {
  894. var gfc = gfp.internal_flags;
  895. var tbits = 0, bits;
  896. var add_bits = new_int(2);