@sendbird/uikit-react 3.5.0-rc.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (936) hide show
  1. package/App.js +312 -235
  2. package/App.js.map +1 -1
  3. package/CHANGELOG.md +544 -0
  4. package/Channel/components/ChannelHeader.js +46 -41
  5. package/Channel/components/ChannelHeader.js.map +1 -1
  6. package/Channel/components/ChannelUI.js +104 -131
  7. package/Channel/components/ChannelUI.js.map +1 -1
  8. package/Channel/components/FileViewer.js +56 -52
  9. package/Channel/components/FileViewer.js.map +1 -1
  10. package/Channel/components/FrozenNotification.js +12 -7
  11. package/Channel/components/FrozenNotification.js.map +1 -1
  12. package/Channel/components/Message.js +240 -230
  13. package/Channel/components/Message.js.map +1 -1
  14. package/Channel/components/MessageInput.js +152 -129
  15. package/Channel/components/MessageInput.js.map +1 -1
  16. package/Channel/components/MessageList.js +260 -175
  17. package/Channel/components/MessageList.js.map +1 -1
  18. package/Channel/components/RemoveMessageModal.js +34 -30
  19. package/Channel/components/RemoveMessageModal.js.map +1 -1
  20. package/Channel/components/SuggestedMentionList.js +139 -193
  21. package/Channel/components/SuggestedMentionList.js.map +1 -1
  22. package/Channel/components/TypingIndicator.js +44 -61
  23. package/Channel/components/TypingIndicator.js.map +1 -1
  24. package/Channel/components/UnreadCount.js +18 -20
  25. package/Channel/components/UnreadCount.js.map +1 -1
  26. package/Channel/context.js +12 -19
  27. package/Channel/context.js.map +1 -1
  28. package/Channel.js +69 -44
  29. package/Channel.js.map +1 -1
  30. package/ChannelList/components/AddChannel.js +29 -30
  31. package/ChannelList/components/AddChannel.js.map +1 -1
  32. package/ChannelList/components/ChannelListHeader.js +32 -28
  33. package/ChannelList/components/ChannelListHeader.js.map +1 -1
  34. package/ChannelList/components/ChannelListUI.js +101 -142
  35. package/ChannelList/components/ChannelListUI.js.map +1 -1
  36. package/ChannelList/components/ChannelPreview.js +72 -82
  37. package/ChannelList/components/ChannelPreview.js.map +1 -1
  38. package/ChannelList/components/ChannelPreviewAction.js +36 -36
  39. package/ChannelList/components/ChannelPreviewAction.js.map +1 -1
  40. package/ChannelList/context.js +7 -8
  41. package/ChannelList/context.js.map +1 -1
  42. package/ChannelList.js +32 -31
  43. package/ChannelList.js.map +1 -1
  44. package/{ChannelListProvider-ade145a7.js → ChannelListProvider-4cf5c0f5.js} +233 -285
  45. package/ChannelListProvider-4cf5c0f5.js.map +1 -0
  46. package/{ChannelProvider-c9db10c0.js → ChannelProvider-6e8e99df.js} +659 -726
  47. package/ChannelProvider-6e8e99df.js.map +1 -0
  48. package/ChannelSettings/components/ChannelProfile.js +33 -46
  49. package/ChannelSettings/components/ChannelProfile.js.map +1 -1
  50. package/ChannelSettings/components/ChannelSettingsUI.js +45 -48
  51. package/ChannelSettings/components/ChannelSettingsUI.js.map +1 -1
  52. package/ChannelSettings/components/EditDetailsModal.js +47 -58
  53. package/ChannelSettings/components/EditDetailsModal.js.map +1 -1
  54. package/ChannelSettings/components/LeaveChannel.js +40 -46
  55. package/ChannelSettings/components/LeaveChannel.js.map +1 -1
  56. package/ChannelSettings/components/ModerationPanel.js +522 -605
  57. package/ChannelSettings/components/ModerationPanel.js.map +1 -1
  58. package/ChannelSettings/components/UserListItem.js +71 -72
  59. package/ChannelSettings/components/UserListItem.js.map +1 -1
  60. package/ChannelSettings/components/UserPanel.js +29 -32
  61. package/ChannelSettings/components/UserPanel.js.map +1 -1
  62. package/ChannelSettings/context.js +53 -57
  63. package/ChannelSettings/context.js.map +1 -1
  64. package/ChannelSettings.js +20 -20
  65. package/ChannelSettings.js.map +1 -1
  66. package/CreateChannel/components/CreateChannelUI.js +24 -24
  67. package/CreateChannel/components/CreateChannelUI.js.map +1 -1
  68. package/CreateChannel/components/InviteUsers.js +102 -124
  69. package/CreateChannel/components/InviteUsers.js.map +1 -1
  70. package/CreateChannel/components/SelectChannelType.js +41 -42
  71. package/CreateChannel/components/SelectChannelType.js.map +1 -1
  72. package/CreateChannel/context.js +4 -4
  73. package/CreateChannel.js +22 -21
  74. package/CreateChannel.js.map +1 -1
  75. package/CreateChannelProvider-34603fa5.js +44 -0
  76. package/CreateChannelProvider-34603fa5.js.map +1 -0
  77. package/CreateOpenChannel/components/CreateOpenChannelUI.js +33 -43
  78. package/CreateOpenChannel/components/CreateOpenChannelUI.js.map +1 -1
  79. package/CreateOpenChannel/context.js +33 -33
  80. package/CreateOpenChannel/context.js.map +1 -1
  81. package/CreateOpenChannel.js +18 -17
  82. package/CreateOpenChannel.js.map +1 -1
  83. package/EditUserProfile/components/EditUserProfileUI.js +12 -13
  84. package/EditUserProfile/components/EditUserProfileUI.js.map +1 -1
  85. package/EditUserProfile/context.js +0 -2
  86. package/EditUserProfile/context.js.map +1 -1
  87. package/EditUserProfile.js +18 -17
  88. package/EditUserProfile.js.map +1 -1
  89. package/LocalizationContext-04c0c9dc.js +20 -0
  90. package/{LocalizationContext-60894e38.js.map → LocalizationContext-04c0c9dc.js.map} +1 -1
  91. package/MediaQueryContext-ff9dca2b.js +87 -0
  92. package/MediaQueryContext-ff9dca2b.js.map +1 -0
  93. package/MemberList-9bf26111.js +403 -0
  94. package/MemberList-9bf26111.js.map +1 -0
  95. package/Message/context.js +31 -0
  96. package/Message/context.js.map +1 -0
  97. package/MessageSearch/components/MessageSearchUI.js +62 -71
  98. package/MessageSearch/components/MessageSearchUI.js.map +1 -1
  99. package/MessageSearch/context.js +201 -224
  100. package/MessageSearch/context.js.map +1 -1
  101. package/MessageSearch.js +46 -58
  102. package/MessageSearch.js.map +1 -1
  103. package/OpenChannel/components/FrozenChannelNotification.js +8 -6
  104. package/OpenChannel/components/FrozenChannelNotification.js.map +1 -1
  105. package/OpenChannel/components/OpenChannelHeader.js +27 -25
  106. package/OpenChannel/components/OpenChannelHeader.js.map +1 -1
  107. package/OpenChannel/components/OpenChannelInput.js +50 -35
  108. package/OpenChannel/components/OpenChannelInput.js.map +1 -1
  109. package/OpenChannel/components/OpenChannelMessage.js +174 -191
  110. package/OpenChannel/components/OpenChannelMessage.js.map +1 -1
  111. package/OpenChannel/components/OpenChannelMessageList.js +72 -92
  112. package/OpenChannel/components/OpenChannelMessageList.js.map +1 -1
  113. package/OpenChannel/components/OpenChannelUI.js +52 -49
  114. package/OpenChannel/components/OpenChannelUI.js.map +1 -1
  115. package/OpenChannel/context.js +8 -9
  116. package/OpenChannel/context.js.map +1 -1
  117. package/OpenChannel.js +36 -30
  118. package/OpenChannel.js.map +1 -1
  119. package/OpenChannelList/components/OpenChannelListUI.js +61 -76
  120. package/OpenChannelList/components/OpenChannelListUI.js.map +1 -1
  121. package/OpenChannelList/components/OpenChannelPreview.js +21 -22
  122. package/OpenChannelList/components/OpenChannelPreview.js.map +1 -1
  123. package/OpenChannelList/context.js +3 -4
  124. package/OpenChannelList/context.js.map +1 -1
  125. package/OpenChannelList.js +26 -24
  126. package/OpenChannelList.js.map +1 -1
  127. package/OpenChannelListProvider-d7372692.js +429 -0
  128. package/OpenChannelListProvider-d7372692.js.map +1 -0
  129. package/OpenChannelProvider-24cd68b9.js +1885 -0
  130. package/OpenChannelProvider-24cd68b9.js.map +1 -0
  131. package/OpenChannelSettings/components/EditDetailsModal.js +47 -56
  132. package/OpenChannelSettings/components/EditDetailsModal.js.map +1 -1
  133. package/OpenChannelSettings/components/OpenChannelProfile.js +26 -31
  134. package/OpenChannelSettings/components/OpenChannelProfile.js.map +1 -1
  135. package/OpenChannelSettings/components/OpenChannelSettingsUI.js +45 -43
  136. package/OpenChannelSettings/components/OpenChannelSettingsUI.js.map +1 -1
  137. package/OpenChannelSettings/components/OperatorUI.js +516 -586
  138. package/OpenChannelSettings/components/OperatorUI.js.map +1 -1
  139. package/OpenChannelSettings/components/ParticipantUI.js +15 -16
  140. package/OpenChannelSettings/components/ParticipantUI.js.map +1 -1
  141. package/OpenChannelSettings/context.js +56 -69
  142. package/OpenChannelSettings/context.js.map +1 -1
  143. package/OpenChannelSettings.js +19 -20
  144. package/OpenChannelSettings.js.map +1 -1
  145. package/README.md +62 -13
  146. package/RemoveMessageModal-94e2bf9e.js +36 -0
  147. package/RemoveMessageModal-94e2bf9e.js.map +1 -0
  148. package/SendbirdProvider.js +749 -408
  149. package/SendbirdProvider.js.map +1 -1
  150. package/Thread/components/ParentMessageInfo.js +238 -217
  151. package/Thread/components/ParentMessageInfo.js.map +1 -1
  152. package/Thread/components/ParentMessageInfoItem.js +112 -89
  153. package/Thread/components/ParentMessageInfoItem.js.map +1 -1
  154. package/Thread/components/ThreadHeader.js +22 -23
  155. package/Thread/components/ThreadHeader.js.map +1 -1
  156. package/Thread/components/ThreadList.js +108 -83
  157. package/Thread/components/ThreadList.js.map +1 -1
  158. package/Thread/components/ThreadListItem.js +306 -276
  159. package/Thread/components/ThreadListItem.js.map +1 -1
  160. package/Thread/components/ThreadMessageInput.js +146 -113
  161. package/Thread/components/ThreadMessageInput.js.map +1 -1
  162. package/Thread/components/ThreadUI.js +169 -138
  163. package/Thread/components/ThreadUI.js.map +1 -1
  164. package/Thread/context/types.js +9 -14
  165. package/Thread/context/types.js.map +1 -1
  166. package/Thread/context.js +8 -8
  167. package/Thread.js +87 -57
  168. package/Thread.js.map +1 -1
  169. package/ThreadProvider-203b94f3.js +1695 -0
  170. package/ThreadProvider-203b94f3.js.map +1 -0
  171. package/{UserProfileContext-33a26cc4.js → UserProfileContext-c776d522.js} +1 -4
  172. package/{UserProfileContext-33a26cc4.js.map → UserProfileContext-c776d522.js.map} +1 -1
  173. package/VoiceMessageInputWrapper-77d8f487.js +170 -0
  174. package/VoiceMessageInputWrapper-77d8f487.js.map +1 -0
  175. package/VoicePlayer/context.js +7 -0
  176. package/{NotificationChannel → VoicePlayer}/context.js.map +1 -1
  177. package/VoicePlayer/useVoicePlayer.js +84 -0
  178. package/VoicePlayer/useVoicePlayer.js.map +1 -0
  179. package/VoiceRecorder/context.js +156 -0
  180. package/VoiceRecorder/context.js.map +1 -0
  181. package/VoiceRecorder/useVoiceRecorder.js +121 -0
  182. package/VoiceRecorder/useVoiceRecorder.js.map +1 -0
  183. package/WebAudioUtils-62e6d3a7.js +123 -0
  184. package/WebAudioUtils-62e6d3a7.js.map +1 -0
  185. package/{_rollupPluginBabelHelpers-ed44209e.js → _rollupPluginBabelHelpers-fb0e05a4.js} +17 -11
  186. package/_rollupPluginBabelHelpers-fb0e05a4.js.map +1 -0
  187. package/actionTypes-1db5749d.js +8 -0
  188. package/actionTypes-1db5749d.js.map +1 -0
  189. package/cjs/App.js +312 -235
  190. package/cjs/App.js.map +1 -1
  191. package/cjs/Channel/components/ChannelHeader.js +46 -41
  192. package/cjs/Channel/components/ChannelHeader.js.map +1 -1
  193. package/cjs/Channel/components/ChannelUI.js +102 -129
  194. package/cjs/Channel/components/ChannelUI.js.map +1 -1
  195. package/cjs/Channel/components/FileViewer.js +56 -52
  196. package/cjs/Channel/components/FileViewer.js.map +1 -1
  197. package/cjs/Channel/components/FrozenNotification.js +12 -7
  198. package/cjs/Channel/components/FrozenNotification.js.map +1 -1
  199. package/cjs/Channel/components/Message.js +243 -233
  200. package/cjs/Channel/components/Message.js.map +1 -1
  201. package/cjs/Channel/components/MessageInput.js +151 -128
  202. package/cjs/Channel/components/MessageInput.js.map +1 -1
  203. package/cjs/Channel/components/MessageList.js +260 -175
  204. package/cjs/Channel/components/MessageList.js.map +1 -1
  205. package/cjs/Channel/components/RemoveMessageModal.js +34 -30
  206. package/cjs/Channel/components/RemoveMessageModal.js.map +1 -1
  207. package/cjs/Channel/components/SuggestedMentionList.js +139 -193
  208. package/cjs/Channel/components/SuggestedMentionList.js.map +1 -1
  209. package/cjs/Channel/components/TypingIndicator.js +44 -61
  210. package/cjs/Channel/components/TypingIndicator.js.map +1 -1
  211. package/cjs/Channel/components/UnreadCount.js +18 -20
  212. package/cjs/Channel/components/UnreadCount.js.map +1 -1
  213. package/cjs/Channel/context.js +12 -23
  214. package/cjs/Channel/context.js.map +1 -1
  215. package/cjs/Channel.js +69 -44
  216. package/cjs/Channel.js.map +1 -1
  217. package/cjs/ChannelList/components/AddChannel.js +29 -30
  218. package/cjs/ChannelList/components/AddChannel.js.map +1 -1
  219. package/cjs/ChannelList/components/ChannelListHeader.js +32 -28
  220. package/cjs/ChannelList/components/ChannelListHeader.js.map +1 -1
  221. package/cjs/ChannelList/components/ChannelListUI.js +100 -141
  222. package/cjs/ChannelList/components/ChannelListUI.js.map +1 -1
  223. package/cjs/ChannelList/components/ChannelPreview.js +72 -82
  224. package/cjs/ChannelList/components/ChannelPreview.js.map +1 -1
  225. package/cjs/ChannelList/components/ChannelPreviewAction.js +36 -36
  226. package/cjs/ChannelList/components/ChannelPreviewAction.js.map +1 -1
  227. package/cjs/ChannelList/context.js +7 -8
  228. package/cjs/ChannelList/context.js.map +1 -1
  229. package/cjs/ChannelList.js +32 -31
  230. package/cjs/ChannelList.js.map +1 -1
  231. package/cjs/{ChannelListProvider-65473831.js → ChannelListProvider-e0ce316a.js} +232 -284
  232. package/cjs/ChannelListProvider-e0ce316a.js.map +1 -0
  233. package/cjs/{ChannelProvider-1e08a7a9.js → ChannelProvider-0df75472.js} +657 -724
  234. package/cjs/ChannelProvider-0df75472.js.map +1 -0
  235. package/cjs/ChannelSettings/components/ChannelProfile.js +33 -46
  236. package/cjs/ChannelSettings/components/ChannelProfile.js.map +1 -1
  237. package/cjs/ChannelSettings/components/ChannelSettingsUI.js +45 -48
  238. package/cjs/ChannelSettings/components/ChannelSettingsUI.js.map +1 -1
  239. package/cjs/ChannelSettings/components/EditDetailsModal.js +47 -58
  240. package/cjs/ChannelSettings/components/EditDetailsModal.js.map +1 -1
  241. package/cjs/ChannelSettings/components/LeaveChannel.js +40 -46
  242. package/cjs/ChannelSettings/components/LeaveChannel.js.map +1 -1
  243. package/cjs/ChannelSettings/components/ModerationPanel.js +522 -605
  244. package/cjs/ChannelSettings/components/ModerationPanel.js.map +1 -1
  245. package/cjs/ChannelSettings/components/UserListItem.js +71 -72
  246. package/cjs/ChannelSettings/components/UserListItem.js.map +1 -1
  247. package/cjs/ChannelSettings/components/UserPanel.js +29 -32
  248. package/cjs/ChannelSettings/components/UserPanel.js.map +1 -1
  249. package/cjs/ChannelSettings/context.js +55 -59
  250. package/cjs/ChannelSettings/context.js.map +1 -1
  251. package/cjs/ChannelSettings.js +20 -20
  252. package/cjs/ChannelSettings.js.map +1 -1
  253. package/cjs/CreateChannel/components/CreateChannelUI.js +24 -24
  254. package/cjs/CreateChannel/components/CreateChannelUI.js.map +1 -1
  255. package/cjs/CreateChannel/components/InviteUsers.js +102 -124
  256. package/cjs/CreateChannel/components/InviteUsers.js.map +1 -1
  257. package/cjs/CreateChannel/components/SelectChannelType.js +41 -42
  258. package/cjs/CreateChannel/components/SelectChannelType.js.map +1 -1
  259. package/cjs/CreateChannel/context.js +4 -4
  260. package/cjs/CreateChannel.js +22 -21
  261. package/cjs/CreateChannel.js.map +1 -1
  262. package/cjs/CreateChannelProvider-c0fca0a5.js +52 -0
  263. package/cjs/CreateChannelProvider-c0fca0a5.js.map +1 -0
  264. package/cjs/CreateOpenChannel/components/CreateOpenChannelUI.js +33 -43
  265. package/cjs/CreateOpenChannel/components/CreateOpenChannelUI.js.map +1 -1
  266. package/cjs/CreateOpenChannel/context.js +33 -33
  267. package/cjs/CreateOpenChannel/context.js.map +1 -1
  268. package/cjs/CreateOpenChannel.js +18 -17
  269. package/cjs/CreateOpenChannel.js.map +1 -1
  270. package/cjs/EditUserProfile/components/EditUserProfileUI.js +12 -13
  271. package/cjs/EditUserProfile/components/EditUserProfileUI.js.map +1 -1
  272. package/cjs/EditUserProfile/context.js +0 -2
  273. package/cjs/EditUserProfile/context.js.map +1 -1
  274. package/cjs/EditUserProfile.js +18 -17
  275. package/cjs/EditUserProfile.js.map +1 -1
  276. package/cjs/{LocalizationContext-8780a64e.js → LocalizationContext-0e429c3d.js} +9 -11
  277. package/cjs/{LocalizationContext-8780a64e.js.map → LocalizationContext-0e429c3d.js.map} +1 -1
  278. package/cjs/MediaQueryContext-33fc3b17.js +94 -0
  279. package/cjs/MediaQueryContext-33fc3b17.js.map +1 -0
  280. package/cjs/MemberList-a45a51c4.js +409 -0
  281. package/cjs/MemberList-a45a51c4.js.map +1 -0
  282. package/cjs/Message/context.js +40 -0
  283. package/cjs/Message/context.js.map +1 -0
  284. package/cjs/MessageSearch/components/MessageSearchUI.js +61 -70
  285. package/cjs/MessageSearch/components/MessageSearchUI.js.map +1 -1
  286. package/cjs/MessageSearch/context.js +201 -224
  287. package/cjs/MessageSearch/context.js.map +1 -1
  288. package/cjs/MessageSearch.js +46 -58
  289. package/cjs/MessageSearch.js.map +1 -1
  290. package/cjs/OpenChannel/components/FrozenChannelNotification.js +8 -6
  291. package/cjs/OpenChannel/components/FrozenChannelNotification.js.map +1 -1
  292. package/cjs/OpenChannel/components/OpenChannelHeader.js +27 -25
  293. package/cjs/OpenChannel/components/OpenChannelHeader.js.map +1 -1
  294. package/cjs/OpenChannel/components/OpenChannelInput.js +50 -35
  295. package/cjs/OpenChannel/components/OpenChannelInput.js.map +1 -1
  296. package/cjs/OpenChannel/components/OpenChannelMessage.js +174 -191
  297. package/cjs/OpenChannel/components/OpenChannelMessage.js.map +1 -1
  298. package/cjs/OpenChannel/components/OpenChannelMessageList.js +72 -92
  299. package/cjs/OpenChannel/components/OpenChannelMessageList.js.map +1 -1
  300. package/cjs/OpenChannel/components/OpenChannelUI.js +52 -49
  301. package/cjs/OpenChannel/components/OpenChannelUI.js.map +1 -1
  302. package/cjs/OpenChannel/context.js +8 -9
  303. package/cjs/OpenChannel/context.js.map +1 -1
  304. package/cjs/OpenChannel.js +36 -30
  305. package/cjs/OpenChannel.js.map +1 -1
  306. package/cjs/OpenChannelList/components/OpenChannelListUI.js +61 -76
  307. package/cjs/OpenChannelList/components/OpenChannelListUI.js.map +1 -1
  308. package/cjs/OpenChannelList/components/OpenChannelPreview.js +21 -22
  309. package/cjs/OpenChannelList/components/OpenChannelPreview.js.map +1 -1
  310. package/cjs/OpenChannelList/context.js +3 -4
  311. package/cjs/OpenChannelList/context.js.map +1 -1
  312. package/cjs/OpenChannelList.js +26 -24
  313. package/cjs/OpenChannelList.js.map +1 -1
  314. package/cjs/OpenChannelListProvider-fc8b53ee.js +439 -0
  315. package/cjs/OpenChannelListProvider-fc8b53ee.js.map +1 -0
  316. package/cjs/OpenChannelProvider-217a8ac2.js +1894 -0
  317. package/cjs/OpenChannelProvider-217a8ac2.js.map +1 -0
  318. package/cjs/OpenChannelSettings/components/EditDetailsModal.js +47 -56
  319. package/cjs/OpenChannelSettings/components/EditDetailsModal.js.map +1 -1
  320. package/cjs/OpenChannelSettings/components/OpenChannelProfile.js +26 -31
  321. package/cjs/OpenChannelSettings/components/OpenChannelProfile.js.map +1 -1
  322. package/cjs/OpenChannelSettings/components/OpenChannelSettingsUI.js +45 -43
  323. package/cjs/OpenChannelSettings/components/OpenChannelSettingsUI.js.map +1 -1
  324. package/cjs/OpenChannelSettings/components/OperatorUI.js +516 -586
  325. package/cjs/OpenChannelSettings/components/OperatorUI.js.map +1 -1
  326. package/cjs/OpenChannelSettings/components/ParticipantUI.js +15 -16
  327. package/cjs/OpenChannelSettings/components/ParticipantUI.js.map +1 -1
  328. package/cjs/OpenChannelSettings/context.js +57 -70
  329. package/cjs/OpenChannelSettings/context.js.map +1 -1
  330. package/cjs/OpenChannelSettings.js +19 -20
  331. package/cjs/OpenChannelSettings.js.map +1 -1
  332. package/cjs/{RemoveMessageModal-0da4f94b.js → RemoveMessageModal-5903f232.js} +19 -14
  333. package/cjs/RemoveMessageModal-5903f232.js.map +1 -0
  334. package/cjs/SendbirdProvider.js +748 -408
  335. package/cjs/SendbirdProvider.js.map +1 -1
  336. package/cjs/Thread/components/ParentMessageInfo.js +237 -216
  337. package/cjs/Thread/components/ParentMessageInfo.js.map +1 -1
  338. package/cjs/Thread/components/ParentMessageInfoItem.js +111 -88
  339. package/cjs/Thread/components/ParentMessageInfoItem.js.map +1 -1
  340. package/cjs/Thread/components/ThreadHeader.js +22 -23
  341. package/cjs/Thread/components/ThreadHeader.js.map +1 -1
  342. package/cjs/Thread/components/ThreadList.js +108 -83
  343. package/cjs/Thread/components/ThreadList.js.map +1 -1
  344. package/cjs/Thread/components/ThreadListItem.js +305 -275
  345. package/cjs/Thread/components/ThreadListItem.js.map +1 -1
  346. package/cjs/Thread/components/ThreadMessageInput.js +146 -113
  347. package/cjs/Thread/components/ThreadMessageInput.js.map +1 -1
  348. package/cjs/Thread/components/ThreadUI.js +170 -139
  349. package/cjs/Thread/components/ThreadUI.js.map +1 -1
  350. package/cjs/Thread/context/types.js +13 -14
  351. package/cjs/Thread/context/types.js.map +1 -1
  352. package/cjs/Thread/context.js +8 -8
  353. package/cjs/Thread.js +87 -57
  354. package/cjs/Thread.js.map +1 -1
  355. package/cjs/ThreadProvider-8ee179c2.js +1704 -0
  356. package/cjs/ThreadProvider-8ee179c2.js.map +1 -0
  357. package/cjs/{UserProfileContext-0808e413.js → UserProfileContext-87580795.js} +1 -4
  358. package/cjs/{UserProfileContext-0808e413.js.map → UserProfileContext-87580795.js.map} +1 -1
  359. package/cjs/VoiceMessageInputWrapper-4fdc8ef1.js +176 -0
  360. package/cjs/VoiceMessageInputWrapper-4fdc8ef1.js.map +1 -0
  361. package/cjs/VoicePlayer/context.js +17 -0
  362. package/cjs/{NotificationChannel → VoicePlayer}/context.js.map +1 -1
  363. package/cjs/VoicePlayer/useVoicePlayer.js +88 -0
  364. package/cjs/VoicePlayer/useVoicePlayer.js.map +1 -0
  365. package/cjs/VoiceRecorder/context.js +166 -0
  366. package/cjs/VoiceRecorder/context.js.map +1 -0
  367. package/cjs/VoiceRecorder/useVoiceRecorder.js +126 -0
  368. package/cjs/VoiceRecorder/useVoiceRecorder.js.map +1 -0
  369. package/cjs/WebAudioUtils-e226789c.js +126 -0
  370. package/cjs/WebAudioUtils-e226789c.js.map +1 -0
  371. package/cjs/{_rollupPluginBabelHelpers-bd6baf0a.js → _rollupPluginBabelHelpers-c89f311a.js} +17 -10
  372. package/cjs/_rollupPluginBabelHelpers-c89f311a.js.map +1 -0
  373. package/cjs/actionTypes-0fa2943d.js +10 -0
  374. package/cjs/actionTypes-0fa2943d.js.map +1 -0
  375. package/cjs/{color-fdbe394d.js → color-bada0fc7.js} +13 -21
  376. package/cjs/color-bada0fc7.js.map +1 -0
  377. package/cjs/{compareIds-d0c02eca.js → compareIds-ccccfe86.js} +5 -6
  378. package/cjs/compareIds-ccccfe86.js.map +1 -0
  379. package/cjs/const-a85f3364.js +20 -0
  380. package/cjs/const-a85f3364.js.map +1 -0
  381. package/cjs/{const-8785e4ad.js → const-d8cece19.js} +4 -4
  382. package/cjs/const-d8cece19.js.map +1 -0
  383. package/cjs/consts-1c3020ad.js +6 -0
  384. package/cjs/consts-1c3020ad.js.map +1 -0
  385. package/cjs/consts-1d94dc61.js +6 -0
  386. package/cjs/consts-1d94dc61.js.map +1 -0
  387. package/cjs/consts-5e0f96b3.js +41 -0
  388. package/cjs/consts-5e0f96b3.js.map +1 -0
  389. package/cjs/consts-740f60b8.js +6 -0
  390. package/cjs/consts-740f60b8.js.map +1 -0
  391. package/cjs/{context-012aecd1.js → context-8e7e8457.js} +6 -5
  392. package/cjs/{context-012aecd1.js.map → context-8e7e8457.js.map} +1 -1
  393. package/cjs/dist/index.css +1682 -1229
  394. package/cjs/dist/index.css.map +1 -1
  395. package/cjs/handlers/OpenChannelHandler.js.map +1 -1
  396. package/cjs/handlers/SessionHandler.js.map +1 -1
  397. package/cjs/{index-48d85d8f.js → index-016f7106.js} +1 -1
  398. package/cjs/{index-48d85d8f.js.map → index-016f7106.js.map} +1 -1
  399. package/cjs/{index-e8544e24.js → index-1613ae03.js} +29 -37
  400. package/cjs/index-1613ae03.js.map +1 -0
  401. package/cjs/index-2be14d85.js +57 -0
  402. package/cjs/index-2be14d85.js.map +1 -0
  403. package/cjs/index-3b30939e.js +79 -0
  404. package/cjs/index-3b30939e.js.map +1 -0
  405. package/cjs/index-5231fde8.js +585 -0
  406. package/cjs/index-5231fde8.js.map +1 -0
  407. package/cjs/index-648c06ed.js +330 -0
  408. package/cjs/index-648c06ed.js.map +1 -0
  409. package/cjs/{index-bdd889a2.js → index-6cb0d040.js} +11 -25
  410. package/cjs/index-6cb0d040.js.map +1 -0
  411. package/cjs/{index-ebb542c3.js → index-71fdaa1b.js} +55 -63
  412. package/cjs/index-71fdaa1b.js.map +1 -0
  413. package/cjs/{index-abe135e6.js → index-7d125728.js} +2 -2
  414. package/cjs/{index-abe135e6.js.map → index-7d125728.js.map} +1 -1
  415. package/cjs/{index-e191d245.js → index-7f6bbe0c.js} +42 -51
  416. package/cjs/index-7f6bbe0c.js.map +1 -0
  417. package/cjs/{index-5ea12b7a.js → index-869e9a94.js} +2 -2
  418. package/cjs/{index-5ea12b7a.js.map → index-869e9a94.js.map} +1 -1
  419. package/cjs/index-89d81dad.js +456 -0
  420. package/cjs/index-89d81dad.js.map +1 -0
  421. package/cjs/{index-c13771a7.js → index-8affdde5.js} +57 -3
  422. package/cjs/index-8affdde5.js.map +1 -0
  423. package/cjs/index-99f16473.js +202 -0
  424. package/cjs/index-99f16473.js.map +1 -0
  425. package/cjs/index-c9d348b6.js +367 -0
  426. package/cjs/index-c9d348b6.js.map +1 -0
  427. package/cjs/index-e8c0080f.js +161 -0
  428. package/cjs/index-e8c0080f.js.map +1 -0
  429. package/cjs/{index-08d232f8.js → index-f570d25c.js} +1 -1
  430. package/cjs/index-f570d25c.js.map +1 -0
  431. package/cjs/index.js +84 -63
  432. package/cjs/index.js.map +1 -1
  433. package/cjs/index.module-0585715f.js +6 -0
  434. package/cjs/index.module-0585715f.js.map +1 -0
  435. package/cjs/lame.all.js +2541 -0
  436. package/cjs/lame.all.js.map +1 -0
  437. package/cjs/resolvedReplyType-67e78c63.js +32 -0
  438. package/cjs/resolvedReplyType-67e78c63.js.map +1 -0
  439. package/cjs/sendbirdSelectors.js +307 -417
  440. package/cjs/sendbirdSelectors.js.map +1 -1
  441. package/cjs/{stringSet-60660a99.js → stringSet-106da549.js} +112 -90
  442. package/cjs/stringSet-106da549.js.map +1 -0
  443. package/cjs/tokenize-2aa0f876.js +164 -0
  444. package/cjs/tokenize-2aa0f876.js.map +1 -0
  445. package/cjs/topics-b384e6b3.js +18 -0
  446. package/cjs/topics-b384e6b3.js.map +1 -0
  447. package/cjs/types-e0b77c8c.js +17 -0
  448. package/cjs/types-e0b77c8c.js.map +1 -0
  449. package/cjs/ui/Accordion.js +21 -24
  450. package/cjs/ui/Accordion.js.map +1 -1
  451. package/cjs/ui/AccordionGroup.js +10 -13
  452. package/cjs/ui/AccordionGroup.js.map +1 -1
  453. package/cjs/ui/AdminMessage.js +10 -13
  454. package/cjs/ui/AdminMessage.js.map +1 -1
  455. package/cjs/ui/Avatar.js +57 -79
  456. package/cjs/ui/Avatar.js.map +1 -1
  457. package/cjs/ui/Badge.js +16 -15
  458. package/cjs/ui/Badge.js.map +1 -1
  459. package/cjs/ui/BottomSheet.js +14 -12
  460. package/cjs/ui/BottomSheet.js.map +1 -1
  461. package/cjs/ui/Button.js +20 -35
  462. package/cjs/ui/Button.js.map +1 -1
  463. package/cjs/ui/ChannelAvatar.js +38 -41
  464. package/cjs/ui/ChannelAvatar.js.map +1 -1
  465. package/cjs/ui/Checkbox.js +11 -13
  466. package/cjs/ui/Checkbox.js.map +1 -1
  467. package/cjs/ui/ConnectionStatus.js +7 -5
  468. package/cjs/ui/ConnectionStatus.js.map +1 -1
  469. package/cjs/ui/ContextMenu.js +175 -199
  470. package/cjs/ui/ContextMenu.js.map +1 -1
  471. package/cjs/ui/DateSeparator.js +12 -14
  472. package/cjs/ui/DateSeparator.js.map +1 -1
  473. package/cjs/ui/EmojiReactions.js +299 -107
  474. package/cjs/ui/EmojiReactions.js.map +1 -1
  475. package/cjs/ui/FileMessageItemBody.js +22 -23
  476. package/cjs/ui/FileMessageItemBody.js.map +1 -1
  477. package/cjs/ui/FileViewer.js +36 -36
  478. package/cjs/ui/FileViewer.js.map +1 -1
  479. package/cjs/ui/Icon.js +447 -623
  480. package/cjs/ui/Icon.js.map +1 -1
  481. package/cjs/ui/IconButton.js +20 -31
  482. package/cjs/ui/IconButton.js.map +1 -1
  483. package/cjs/ui/ImageRenderer.js +34 -43
  484. package/cjs/ui/ImageRenderer.js.map +1 -1
  485. package/cjs/ui/Input.js +16 -16
  486. package/cjs/ui/Input.js.map +1 -1
  487. package/cjs/ui/Label.js +2 -2
  488. package/cjs/ui/LinkLabel.js +4 -3
  489. package/cjs/ui/LinkLabel.js.map +1 -1
  490. package/cjs/ui/Loader.js +10 -12
  491. package/cjs/ui/Loader.js.map +1 -1
  492. package/cjs/ui/MentionLabel.js +58 -65
  493. package/cjs/ui/MentionLabel.js.map +1 -1
  494. package/cjs/ui/MentionUserLabel.js +12 -10
  495. package/cjs/ui/MentionUserLabel.js.map +1 -1
  496. package/cjs/ui/MessageContent.js +212 -548
  497. package/cjs/ui/MessageContent.js.map +1 -1
  498. package/cjs/ui/MessageInput.js +392 -119
  499. package/cjs/ui/MessageInput.js.map +1 -1
  500. package/cjs/ui/MessageItemMenu.js +83 -83
  501. package/cjs/ui/MessageItemMenu.js.map +1 -1
  502. package/cjs/ui/MessageItemReactionMenu.js +58 -62
  503. package/cjs/ui/MessageItemReactionMenu.js.map +1 -1
  504. package/cjs/ui/MessageSearchFileItem.js +56 -51
  505. package/cjs/ui/MessageSearchFileItem.js.map +1 -1
  506. package/cjs/ui/MessageSearchItem.js +42 -41
  507. package/cjs/ui/MessageSearchItem.js.map +1 -1
  508. package/cjs/ui/MessageStatus.js +10 -11
  509. package/cjs/ui/MessageStatus.js.map +1 -1
  510. package/cjs/ui/Modal.js +52 -46
  511. package/cjs/ui/Modal.js.map +1 -1
  512. package/cjs/ui/MutedAvatarOverlay.js +10 -10
  513. package/cjs/ui/MutedAvatarOverlay.js.map +1 -1
  514. package/cjs/ui/OGMessageItemBody.js +67 -63
  515. package/cjs/ui/OGMessageItemBody.js.map +1 -1
  516. package/cjs/ui/OpenChannelAdminMessage.js +8 -7
  517. package/cjs/ui/OpenChannelAdminMessage.js.map +1 -1
  518. package/cjs/ui/OpenChannelAvatar.js +18 -17
  519. package/cjs/ui/OpenChannelAvatar.js.map +1 -1
  520. package/cjs/ui/OpenchannelConversationHeader.js +17 -13
  521. package/cjs/ui/OpenchannelConversationHeader.js.map +1 -1
  522. package/cjs/ui/OpenchannelFileMessage.js +140 -151
  523. package/cjs/ui/OpenchannelFileMessage.js.map +1 -1
  524. package/cjs/ui/OpenchannelOGMessage.js +204 -233
  525. package/cjs/ui/OpenchannelOGMessage.js.map +1 -1
  526. package/cjs/ui/OpenchannelThumbnailMessage.js +215 -222
  527. package/cjs/ui/OpenchannelThumbnailMessage.js.map +1 -1
  528. package/cjs/ui/OpenchannelUserMessage.js +168 -178
  529. package/cjs/ui/OpenchannelUserMessage.js.map +1 -1
  530. package/cjs/ui/PlaceHolder.js +5 -6
  531. package/cjs/ui/PlaceHolder.js.map +1 -1
  532. package/cjs/ui/PlaybackTime.js +35 -0
  533. package/cjs/ui/PlaybackTime.js.map +1 -0
  534. package/cjs/ui/ProgressBar.js +40 -0
  535. package/cjs/ui/ProgressBar.js.map +1 -0
  536. package/cjs/ui/QuoteMessage.js +50 -44
  537. package/cjs/ui/QuoteMessage.js.map +1 -1
  538. package/cjs/ui/QuoteMessageInput.js +31 -29
  539. package/cjs/ui/QuoteMessageInput.js.map +1 -1
  540. package/cjs/ui/ReactionBadge.js +13 -21
  541. package/cjs/ui/ReactionBadge.js.map +1 -1
  542. package/cjs/ui/ReactionButton.js +30 -27
  543. package/cjs/ui/ReactionButton.js.map +1 -1
  544. package/cjs/ui/SortByRow.js +14 -18
  545. package/cjs/ui/SortByRow.js.map +1 -1
  546. package/cjs/ui/TextButton.js +13 -21
  547. package/cjs/ui/TextButton.js.map +1 -1
  548. package/cjs/ui/TextMessageItemBody.js +41 -48
  549. package/cjs/ui/TextMessageItemBody.js.map +1 -1
  550. package/cjs/ui/ThreadReplies.js +25 -22
  551. package/cjs/ui/ThreadReplies.js.map +1 -1
  552. package/cjs/ui/ThumbnailMessageItemBody.js +36 -45
  553. package/cjs/ui/ThumbnailMessageItemBody.js.map +1 -1
  554. package/cjs/ui/Toggle.js +202 -0
  555. package/cjs/ui/Toggle.js.map +1 -0
  556. package/cjs/ui/Tooltip.js +8 -9
  557. package/cjs/ui/Tooltip.js.map +1 -1
  558. package/cjs/ui/TooltipWrapper.js +17 -20
  559. package/cjs/ui/TooltipWrapper.js.map +1 -1
  560. package/cjs/ui/UnknownMessageItemBody.js +21 -22
  561. package/cjs/ui/UnknownMessageItemBody.js.map +1 -1
  562. package/cjs/ui/UserListItem.js +76 -76
  563. package/cjs/ui/UserListItem.js.map +1 -1
  564. package/cjs/ui/UserProfile.js +31 -29
  565. package/cjs/ui/UserProfile.js.map +1 -1
  566. package/cjs/ui/VoiceMessageItemBody.js +119 -0
  567. package/cjs/ui/VoiceMessageItemBody.js.map +1 -0
  568. package/cjs/ui/VoiceMessgeInput.js +22 -0
  569. package/cjs/ui/VoiceMessgeInput.js.map +1 -0
  570. package/cjs/ui/Word.js +31 -39
  571. package/cjs/ui/Word.js.map +1 -1
  572. package/cjs/useDirtyGetMentions-b8ca5675.js +77 -0
  573. package/cjs/useDirtyGetMentions-b8ca5675.js.map +1 -0
  574. package/cjs/useLongPress-8037894e.js +87 -0
  575. package/cjs/useLongPress-8037894e.js.map +1 -0
  576. package/cjs/useSendbirdStateContext.js +2 -3
  577. package/cjs/useSendbirdStateContext.js.map +1 -1
  578. package/cjs/utils/message/getOutgoingMessageState.js +16 -21
  579. package/cjs/utils/message/getOutgoingMessageState.js.map +1 -1
  580. package/cjs/utils/message/isVoiceMessage.js +12 -0
  581. package/cjs/utils/message/isVoiceMessage.js.map +1 -0
  582. package/cjs/{utils-ba58eacf.js → utils-01ff5332.js} +3 -7
  583. package/cjs/{utils-ba58eacf.js.map → utils-01ff5332.js.map} +1 -1
  584. package/cjs/utils-2edcddc8.js +35 -0
  585. package/cjs/utils-2edcddc8.js.map +1 -0
  586. package/cjs/utils-5ac3db44.js +31 -0
  587. package/cjs/utils-5ac3db44.js.map +1 -0
  588. package/cjs/{utils-708aa730.js → utils-ad7b5b82.js} +1 -1
  589. package/cjs/{utils-708aa730.js.map → utils-ad7b5b82.js.map} +1 -1
  590. package/cjs/uuid-12b01f73.js +15 -0
  591. package/cjs/{uuid-a9006ea2.js.map → uuid-12b01f73.js.map} +1 -1
  592. package/cjs/withSendbird.js +5 -6
  593. package/cjs/withSendbird.js.map +1 -1
  594. package/{color-c39702d1.js → color-347926b6.js} +5 -14
  595. package/{color-c39702d1.js.map → color-347926b6.js.map} +1 -1
  596. package/{compareIds-063e5503.js → compareIds-3a43c11b.js} +5 -6
  597. package/compareIds-3a43c11b.js.map +1 -0
  598. package/const-18dba7a4.js +13 -0
  599. package/const-18dba7a4.js.map +1 -0
  600. package/{const-1510a671.js → const-c608f749.js} +4 -4
  601. package/const-c608f749.js.map +1 -0
  602. package/consts-6bca01c7.js +4 -0
  603. package/consts-6bca01c7.js.map +1 -0
  604. package/consts-7a169a0f.js +4 -0
  605. package/consts-7a169a0f.js.map +1 -0
  606. package/consts-c1baf70a.js +27 -0
  607. package/consts-c1baf70a.js.map +1 -0
  608. package/consts-fb4d475a.js +4 -0
  609. package/consts-fb4d475a.js.map +1 -0
  610. package/context-786ef1a2.js +13 -0
  611. package/{context-d5dc28c9.js.map → context-786ef1a2.js.map} +1 -1
  612. package/dist/index.css +1682 -1229
  613. package/dist/index.css.map +1 -1
  614. package/handlers/OpenChannelHandler.js.map +1 -1
  615. package/handlers/SessionHandler.js.map +1 -1
  616. package/{index-7c1f570b.js → index-06b854f7.js} +55 -63
  617. package/index-06b854f7.js.map +1 -0
  618. package/index-2673effb.js +360 -0
  619. package/index-2673effb.js.map +1 -0
  620. package/{index-5e776774.js → index-319984d0.js} +1 -1
  621. package/{index-5e776774.js.map → index-319984d0.js.map} +1 -1
  622. package/{index-eadca08d.js → index-4455855e.js} +2 -2
  623. package/{index-eadca08d.js.map → index-4455855e.js.map} +1 -1
  624. package/index-6663ce18.js +450 -0
  625. package/index-6663ce18.js.map +1 -0
  626. package/{index-b19486f5.js → index-6c252d25.js} +2 -2
  627. package/{index-b19486f5.js.map → index-6c252d25.js.map} +1 -1
  628. package/index-71a20863.js +320 -0
  629. package/index-71a20863.js.map +1 -0
  630. package/index-7d71b26c.js +154 -0
  631. package/index-7d71b26c.js.map +1 -0
  632. package/{index-d81c515b.js → index-9a4e0846.js} +1 -1
  633. package/index-9a4e0846.js.map +1 -0
  634. package/{index-fd15e3b0.js → index-9cd77b08.js} +29 -37
  635. package/index-9cd77b08.js.map +1 -0
  636. package/index-c149ea48.js +187 -0
  637. package/index-c149ea48.js.map +1 -0
  638. package/index-cf3939c6.js +76 -0
  639. package/index-cf3939c6.js.map +1 -0
  640. package/index-cf859f03.js +540 -0
  641. package/index-cf859f03.js.map +1 -0
  642. package/{index-95ac9232.js → index-e33f7f55.js} +11 -25
  643. package/index-e33f7f55.js.map +1 -0
  644. package/{index-b8de16d6.js → index-eabd1e7e.js} +39 -48
  645. package/index-eabd1e7e.js.map +1 -0
  646. package/index-ebb62af1.js +51 -0
  647. package/index-ebb62af1.js.map +1 -0
  648. package/{index-0fd24497.js → index-edf844f0.js} +57 -4
  649. package/index-edf844f0.js.map +1 -0
  650. package/index.d.ts +176 -124
  651. package/index.js +84 -63
  652. package/index.js.map +1 -1
  653. package/index.module-6b7ed635.js +4 -0
  654. package/index.module-6b7ed635.js.map +1 -0
  655. package/lame.all.js +2537 -0
  656. package/lame.all.js.map +1 -0
  657. package/package.json +62 -41
  658. package/resolvedReplyType-8776d777.js +29 -0
  659. package/resolvedReplyType-8776d777.js.map +1 -0
  660. package/sendbirdSelectors.js +307 -417
  661. package/sendbirdSelectors.js.map +1 -1
  662. package/{stringSet-7ace5726.js → stringSet-e0ee1265.js} +112 -90
  663. package/stringSet-e0ee1265.js.map +1 -0
  664. package/tokenize-1b053c86.js +159 -0
  665. package/tokenize-1b053c86.js.map +1 -0
  666. package/topics-70f569e9.js +16 -0
  667. package/topics-70f569e9.js.map +1 -0
  668. package/types-77bbdda6.js +15 -0
  669. package/types-77bbdda6.js.map +1 -0
  670. package/ui/Accordion.js +21 -24
  671. package/ui/Accordion.js.map +1 -1
  672. package/ui/AccordionGroup.js +10 -13
  673. package/ui/AccordionGroup.js.map +1 -1
  674. package/ui/AdminMessage.js +10 -13
  675. package/ui/AdminMessage.js.map +1 -1
  676. package/ui/Avatar.js +57 -79
  677. package/ui/Avatar.js.map +1 -1
  678. package/ui/Badge.js +16 -15
  679. package/ui/Badge.js.map +1 -1
  680. package/ui/BottomSheet.js +14 -12
  681. package/ui/BottomSheet.js.map +1 -1
  682. package/ui/Button.js +20 -35
  683. package/ui/Button.js.map +1 -1
  684. package/ui/ChannelAvatar.js +38 -41
  685. package/ui/ChannelAvatar.js.map +1 -1
  686. package/ui/Checkbox.js +11 -13
  687. package/ui/Checkbox.js.map +1 -1
  688. package/ui/ConnectionStatus.js +7 -5
  689. package/ui/ConnectionStatus.js.map +1 -1
  690. package/ui/ContextMenu.js +176 -200
  691. package/ui/ContextMenu.js.map +1 -1
  692. package/ui/DateSeparator.js +12 -14
  693. package/ui/DateSeparator.js.map +1 -1
  694. package/ui/EmojiReactions.js +300 -108
  695. package/ui/EmojiReactions.js.map +1 -1
  696. package/ui/FileMessageItemBody.js +22 -23
  697. package/ui/FileMessageItemBody.js.map +1 -1
  698. package/ui/FileViewer.js +36 -36
  699. package/ui/FileViewer.js.map +1 -1
  700. package/ui/Icon.js +448 -622
  701. package/ui/Icon.js.map +1 -1
  702. package/ui/IconButton.js +20 -31
  703. package/ui/IconButton.js.map +1 -1
  704. package/ui/ImageRenderer.js +34 -43
  705. package/ui/ImageRenderer.js.map +1 -1
  706. package/ui/Input.js +16 -16
  707. package/ui/Input.js.map +1 -1
  708. package/ui/Label.js +2 -2
  709. package/ui/LinkLabel.js +4 -3
  710. package/ui/LinkLabel.js.map +1 -1
  711. package/ui/Loader.js +10 -12
  712. package/ui/Loader.js.map +1 -1
  713. package/ui/MentionLabel.js +58 -65
  714. package/ui/MentionLabel.js.map +1 -1
  715. package/ui/MentionUserLabel.js +12 -10
  716. package/ui/MentionUserLabel.js.map +1 -1
  717. package/ui/MessageContent.js +215 -551
  718. package/ui/MessageContent.js.map +1 -1
  719. package/ui/MessageInput.js +392 -120
  720. package/ui/MessageInput.js.map +1 -1
  721. package/ui/MessageItemMenu.js +83 -83
  722. package/ui/MessageItemMenu.js.map +1 -1
  723. package/ui/MessageItemReactionMenu.js +58 -62
  724. package/ui/MessageItemReactionMenu.js.map +1 -1
  725. package/ui/MessageSearchFileItem.js +55 -50
  726. package/ui/MessageSearchFileItem.js.map +1 -1
  727. package/ui/MessageSearchItem.js +41 -40
  728. package/ui/MessageSearchItem.js.map +1 -1
  729. package/ui/MessageStatus.js +10 -11
  730. package/ui/MessageStatus.js.map +1 -1
  731. package/ui/Modal.js +52 -46
  732. package/ui/Modal.js.map +1 -1
  733. package/ui/MutedAvatarOverlay.js +10 -10
  734. package/ui/MutedAvatarOverlay.js.map +1 -1
  735. package/ui/OGMessageItemBody.js +68 -64
  736. package/ui/OGMessageItemBody.js.map +1 -1
  737. package/ui/OpenChannelAdminMessage.js +8 -7
  738. package/ui/OpenChannelAdminMessage.js.map +1 -1
  739. package/ui/OpenChannelAvatar.js +18 -17
  740. package/ui/OpenChannelAvatar.js.map +1 -1
  741. package/ui/OpenchannelConversationHeader.js +17 -13
  742. package/ui/OpenchannelConversationHeader.js.map +1 -1
  743. package/ui/OpenchannelFileMessage.js +140 -151
  744. package/ui/OpenchannelFileMessage.js.map +1 -1
  745. package/ui/OpenchannelOGMessage.js +204 -233
  746. package/ui/OpenchannelOGMessage.js.map +1 -1
  747. package/ui/OpenchannelThumbnailMessage.js +215 -222
  748. package/ui/OpenchannelThumbnailMessage.js.map +1 -1
  749. package/ui/OpenchannelUserMessage.js +168 -178
  750. package/ui/OpenchannelUserMessage.js.map +1 -1
  751. package/ui/PlaceHolder.js +5 -6
  752. package/ui/PlaceHolder.js.map +1 -1
  753. package/ui/PlaybackTime.js +26 -0
  754. package/ui/PlaybackTime.js.map +1 -0
  755. package/ui/ProgressBar.js +30 -0
  756. package/ui/ProgressBar.js.map +1 -0
  757. package/ui/QuoteMessage.js +50 -44
  758. package/ui/QuoteMessage.js.map +1 -1
  759. package/ui/QuoteMessageInput.js +31 -29
  760. package/ui/QuoteMessageInput.js.map +1 -1
  761. package/ui/ReactionBadge.js +13 -21
  762. package/ui/ReactionBadge.js.map +1 -1
  763. package/ui/ReactionButton.js +30 -27
  764. package/ui/ReactionButton.js.map +1 -1
  765. package/ui/SortByRow.js +14 -18
  766. package/ui/SortByRow.js.map +1 -1
  767. package/ui/TextButton.js +13 -21
  768. package/ui/TextButton.js.map +1 -1
  769. package/ui/TextMessageItemBody.js +41 -48
  770. package/ui/TextMessageItemBody.js.map +1 -1
  771. package/ui/ThreadReplies.js +25 -22
  772. package/ui/ThreadReplies.js.map +1 -1
  773. package/ui/ThumbnailMessageItemBody.js +36 -45
  774. package/ui/ThumbnailMessageItemBody.js.map +1 -1
  775. package/ui/Toggle.js +191 -0
  776. package/ui/Toggle.js.map +1 -0
  777. package/ui/Tooltip.js +8 -9
  778. package/ui/Tooltip.js.map +1 -1
  779. package/ui/TooltipWrapper.js +17 -20
  780. package/ui/TooltipWrapper.js.map +1 -1
  781. package/ui/UnknownMessageItemBody.js +21 -22
  782. package/ui/UnknownMessageItemBody.js.map +1 -1
  783. package/ui/UserListItem.js +76 -76
  784. package/ui/UserListItem.js.map +1 -1
  785. package/ui/UserProfile.js +31 -29
  786. package/ui/UserProfile.js.map +1 -1
  787. package/ui/VoiceMessageItemBody.js +110 -0
  788. package/ui/VoiceMessageItemBody.js.map +1 -0
  789. package/ui/VoiceMessgeInput.js +14 -0
  790. package/ui/VoiceMessgeInput.js.map +1 -0
  791. package/ui/Word.js +31 -39
  792. package/ui/Word.js.map +1 -1
  793. package/useDirtyGetMentions-f00f1f94.js +75 -0
  794. package/useDirtyGetMentions-f00f1f94.js.map +1 -0
  795. package/useLongPress-1ab49410.js +85 -0
  796. package/useLongPress-1ab49410.js.map +1 -0
  797. package/useSendbirdStateContext.js +2 -3
  798. package/useSendbirdStateContext.js.map +1 -1
  799. package/utils/message/getOutgoingMessageState.js +9 -15
  800. package/utils/message/getOutgoingMessageState.js.map +1 -1
  801. package/utils/message/isVoiceMessage.js +8 -0
  802. package/utils/message/isVoiceMessage.js.map +1 -0
  803. package/{utils-30c326f7.js → utils-56cb7de5.js} +1 -1
  804. package/{utils-30c326f7.js.map → utils-56cb7de5.js.map} +1 -1
  805. package/utils-77f7e8b2.js +29 -0
  806. package/utils-77f7e8b2.js.map +1 -0
  807. package/{utils-ded73fa5.js → utils-7f3d0d8c.js} +3 -7
  808. package/{utils-ded73fa5.js.map → utils-7f3d0d8c.js.map} +1 -1
  809. package/utils-af9b1c06.js +31 -0
  810. package/utils-af9b1c06.js.map +1 -0
  811. package/uuid-92d22300.js +13 -0
  812. package/{uuid-968941a0.js.map → uuid-92d22300.js.map} +1 -1
  813. package/withSendbird.js +5 -6
  814. package/withSendbird.js.map +1 -1
  815. package/ChannelListProvider-ade145a7.js.map +0 -1
  816. package/ChannelProvider-c9db10c0.js.map +0 -1
  817. package/CreateChannelProvider-be2dfe96.js +0 -55
  818. package/CreateChannelProvider-be2dfe96.js.map +0 -1
  819. package/LocalizationContext-60894e38.js +0 -22
  820. package/MediaQueryContext-bcf72e28.js +0 -90
  821. package/MediaQueryContext-bcf72e28.js.map +0 -1
  822. package/MemberList-ce1fd162.js +0 -435
  823. package/MemberList-ce1fd162.js.map +0 -1
  824. package/NotificationChannel/components/NotificationChannelUI.js +0 -119
  825. package/NotificationChannel/components/NotificationChannelUI.js.map +0 -1
  826. package/NotificationChannel/components/NotificationList.js +0 -111
  827. package/NotificationChannel/components/NotificationList.js.map +0 -1
  828. package/NotificationChannel/components/NotificationMessageWrap.js +0 -136
  829. package/NotificationChannel/components/NotificationMessageWrap.js.map +0 -1
  830. package/NotificationChannel/context.js +0 -12
  831. package/NotificationChannel.js +0 -58
  832. package/NotificationChannel.js.map +0 -1
  833. package/NotificationChannelProvider-2cb7ca21.js +0 -535
  834. package/NotificationChannelProvider-2cb7ca21.js.map +0 -1
  835. package/OpenChannelListProvider-0bdafda1.js +0 -434
  836. package/OpenChannelListProvider-0bdafda1.js.map +0 -1
  837. package/OpenChannelProvider-a72c6fb7.js +0 -2000
  838. package/OpenChannelProvider-a72c6fb7.js.map +0 -1
  839. package/RemoveMessageModal-b025d4a7.js +0 -31
  840. package/RemoveMessageModal-b025d4a7.js.map +0 -1
  841. package/ThreadProvider-de5a7889.js +0 -1644
  842. package/ThreadProvider-de5a7889.js.map +0 -1
  843. package/_rollupPluginBabelHelpers-ed44209e.js.map +0 -1
  844. package/actionTypes-aa58fd27.js +0 -6
  845. package/actionTypes-aa58fd27.js.map +0 -1
  846. package/cjs/ChannelListProvider-65473831.js.map +0 -1
  847. package/cjs/ChannelProvider-1e08a7a9.js.map +0 -1
  848. package/cjs/CreateChannelProvider-cbf490c6.js +0 -62
  849. package/cjs/CreateChannelProvider-cbf490c6.js.map +0 -1
  850. package/cjs/MediaQueryContext-e455934a.js +0 -97
  851. package/cjs/MediaQueryContext-e455934a.js.map +0 -1
  852. package/cjs/MemberList-aee91fce.js +0 -441
  853. package/cjs/MemberList-aee91fce.js.map +0 -1
  854. package/cjs/NotificationChannel/components/NotificationChannelUI.js +0 -125
  855. package/cjs/NotificationChannel/components/NotificationChannelUI.js.map +0 -1
  856. package/cjs/NotificationChannel/components/NotificationList.js +0 -117
  857. package/cjs/NotificationChannel/components/NotificationList.js.map +0 -1
  858. package/cjs/NotificationChannel/components/NotificationMessageWrap.js +0 -142
  859. package/cjs/NotificationChannel/components/NotificationMessageWrap.js.map +0 -1
  860. package/cjs/NotificationChannel/context.js +0 -21
  861. package/cjs/NotificationChannel.js +0 -64
  862. package/cjs/NotificationChannel.js.map +0 -1
  863. package/cjs/NotificationChannelProvider-4cc9575f.js +0 -543
  864. package/cjs/NotificationChannelProvider-4cc9575f.js.map +0 -1
  865. package/cjs/OpenChannelListProvider-4aab4391.js +0 -443
  866. package/cjs/OpenChannelListProvider-4aab4391.js.map +0 -1
  867. package/cjs/OpenChannelProvider-a763b71c.js +0 -2009
  868. package/cjs/OpenChannelProvider-a763b71c.js.map +0 -1
  869. package/cjs/RemoveMessageModal-0da4f94b.js.map +0 -1
  870. package/cjs/ThreadProvider-51be09a5.js +0 -1653
  871. package/cjs/ThreadProvider-51be09a5.js.map +0 -1
  872. package/cjs/_rollupPluginBabelHelpers-bd6baf0a.js.map +0 -1
  873. package/cjs/actionTypes-561bdde9.js +0 -10
  874. package/cjs/actionTypes-561bdde9.js.map +0 -1
  875. package/cjs/color-fdbe394d.js.map +0 -1
  876. package/cjs/compareIds-d0c02eca.js.map +0 -1
  877. package/cjs/const-8785e4ad.js.map +0 -1
  878. package/cjs/const-beb25e10.js +0 -20
  879. package/cjs/const-beb25e10.js.map +0 -1
  880. package/cjs/index-08d232f8.js.map +0 -1
  881. package/cjs/index-8a4b2f10.js +0 -59
  882. package/cjs/index-8a4b2f10.js.map +0 -1
  883. package/cjs/index-8c350889.js +0 -194
  884. package/cjs/index-8c350889.js.map +0 -1
  885. package/cjs/index-b3371ef2.js +0 -701
  886. package/cjs/index-b3371ef2.js.map +0 -1
  887. package/cjs/index-bdd889a2.js.map +0 -1
  888. package/cjs/index-c13771a7.js.map +0 -1
  889. package/cjs/index-e191d245.js.map +0 -1
  890. package/cjs/index-e8544e24.js.map +0 -1
  891. package/cjs/index-ebb542c3.js.map +0 -1
  892. package/cjs/index-f032bd2c.js +0 -360
  893. package/cjs/index-f032bd2c.js.map +0 -1
  894. package/cjs/stringSet-60660a99.js.map +0 -1
  895. package/cjs/topics-f3f74edc.js +0 -22
  896. package/cjs/topics-f3f74edc.js.map +0 -1
  897. package/cjs/tslib.es6-5a7eb30d.js +0 -110
  898. package/cjs/tslib.es6-5a7eb30d.js.map +0 -1
  899. package/cjs/useLongPress-e7140087.js +0 -118
  900. package/cjs/useLongPress-e7140087.js.map +0 -1
  901. package/cjs/utils-693dd952.js +0 -38
  902. package/cjs/utils-693dd952.js.map +0 -1
  903. package/cjs/utils-b6001dd4.js +0 -32
  904. package/cjs/utils-b6001dd4.js.map +0 -1
  905. package/cjs/uuid-a9006ea2.js +0 -19
  906. package/compareIds-063e5503.js.map +0 -1
  907. package/const-14919575.js +0 -14
  908. package/const-14919575.js.map +0 -1
  909. package/const-1510a671.js.map +0 -1
  910. package/context-d5dc28c9.js +0 -12
  911. package/index-0fd24497.js.map +0 -1
  912. package/index-2561104e.js +0 -179
  913. package/index-2561104e.js.map +0 -1
  914. package/index-54843058.js +0 -57
  915. package/index-54843058.js.map +0 -1
  916. package/index-58e5d82d.js +0 -662
  917. package/index-58e5d82d.js.map +0 -1
  918. package/index-7c1f570b.js.map +0 -1
  919. package/index-95ac9232.js.map +0 -1
  920. package/index-b8de16d6.js.map +0 -1
  921. package/index-d07faed8.js +0 -353
  922. package/index-d07faed8.js.map +0 -1
  923. package/index-d81c515b.js.map +0 -1
  924. package/index-fd15e3b0.js.map +0 -1
  925. package/stringSet-7ace5726.js.map +0 -1
  926. package/topics-d390daf6.js +0 -13
  927. package/topics-d390daf6.js.map +0 -1
  928. package/tslib.es6-d9fa3716.js +0 -104
  929. package/tslib.es6-d9fa3716.js.map +0 -1
  930. package/useLongPress-7d9a5f67.js +0 -116
  931. package/useLongPress-7d9a5f67.js.map +0 -1
  932. package/utils-40ce4da5.js +0 -34
  933. package/utils-40ce4da5.js.map +0 -1
  934. package/utils-d485030c.js +0 -30
  935. package/utils-d485030c.js.map +0 -1
  936. package/uuid-968941a0.js +0 -17
package/lame.all.js ADDED
@@ -0,0 +1,2537 @@
1
+ function $parcel$export(e,n,v,s){Object.defineProperty(e,n,{get:v,set:s,enumerable:true,configurable:true});}var $parcel$global=typeof globalThis!=='undefined'?globalThis:typeof self!=='undefined'?self:typeof window!=='undefined'?window:typeof global!=='undefined'?global:{};var $parcel$modules={};var $parcel$inits={};var parcelRequire=$parcel$global["parcelRequire3f09"];if(parcelRequire==null){parcelRequire=function(id){if(id in $parcel$modules){return $parcel$modules[id].exports;}if(id in $parcel$inits){var init=$parcel$inits[id];delete $parcel$inits[id];var module={id:id,exports:{}};$parcel$modules[id]=module;init.call(module.exports,module,module.exports);return module.exports;}var err=new Error("Cannot find module '"+id+"'");err.code='MODULE_NOT_FOUND';throw err;};parcelRequire.register=function register(id,init){$parcel$inits[id]=init;};$parcel$global["parcelRequire3f09"]=parcelRequire;}parcelRequire.register("kk1yk",function(module,exports){var $3YDN3=parcelRequire("3YDN3");var $ecb6e13812bdc08b$var$System=$3YDN3.System;var $ecb6e13812bdc08b$var$VbrMode=$3YDN3.VbrMode;$3YDN3.Float;var $ecb6e13812bdc08b$var$ShortBlock=$3YDN3.ShortBlock;$3YDN3.Util;$3YDN3.Arrays;$3YDN3.new_array_n;$3YDN3.new_byte;$3YDN3.new_double;var $ecb6e13812bdc08b$var$new_float=$3YDN3.new_float;$3YDN3.new_float_n;$3YDN3.new_int;var $ecb6e13812bdc08b$var$new_int_n=$3YDN3.new_int_n;var $ecb6e13812bdc08b$var$new_short_n=$3YDN3.new_short_n;var $ecb6e13812bdc08b$var$assert=$3YDN3.assert;var $d2VP0=parcelRequire("d2VP0");var $5HJeD=parcelRequire("5HJeD");var $4SDnr=parcelRequire("4SDnr");var $cU3Yf=parcelRequire("cU3Yf");var $2qGTD=parcelRequire("2qGTD");var $e32wu=parcelRequire("e32wu");var $ctaQC=parcelRequire("ctaQC");var $dQDcS=parcelRequire("dQDcS");var $cPNKB=parcelRequire("cPNKB");function $ecb6e13812bdc08b$var$Lame(){var MPEGMode=parcelRequire("jL6I1");var self=this;var LAME_MAXALBUMART=131072;$ecb6e13812bdc08b$var$Lame.V9=410;$ecb6e13812bdc08b$var$Lame.V8=420;$ecb6e13812bdc08b$var$Lame.V7=430;$ecb6e13812bdc08b$var$Lame.V6=440;$ecb6e13812bdc08b$var$Lame.V5=450;$ecb6e13812bdc08b$var$Lame.V4=460;$ecb6e13812bdc08b$var$Lame.V3=470;$ecb6e13812bdc08b$var$Lame.V2=480;$ecb6e13812bdc08b$var$Lame.V1=490;$ecb6e13812bdc08b$var$Lame.V0=500;/* still there for compatibility */$ecb6e13812bdc08b$var$Lame.R3MIX=1000;$ecb6e13812bdc08b$var$Lame.STANDARD=1001;$ecb6e13812bdc08b$var$Lame.EXTREME=1002;$ecb6e13812bdc08b$var$Lame.INSANE=1003;$ecb6e13812bdc08b$var$Lame.STANDARD_FAST=1004;$ecb6e13812bdc08b$var$Lame.EXTREME_FAST=1005;$ecb6e13812bdc08b$var$Lame.MEDIUM=1006;$ecb6e13812bdc08b$var$Lame.MEDIUM_FAST=1007;/**
2
+ * maximum size of mp3buffer needed if you encode at most 1152 samples for
3
+ * each call to lame_encode_buffer. see lame_encode_buffer() below
4
+ * (LAME_MAXMP3BUFFER is now obsolete)
5
+ */var LAME_MAXMP3BUFFER=16384+LAME_MAXALBUMART;$ecb6e13812bdc08b$var$Lame.LAME_MAXMP3BUFFER=LAME_MAXMP3BUFFER;var ga;var bs;var p;var qupvt;var qu;var psy=new $d2VP0();var vbr;var id3;var mpglib;this.enc=new $cPNKB();this.setModules=function(_ga,_bs,_p,_qupvt,_qu,_vbr,_ver,_id3,_mpglib){ga=_ga;bs=_bs;p=_p;qupvt=_qupvt;qu=_qu;vbr=_vbr;id3=_id3;mpglib=_mpglib;this.enc.setModules(bs,psy,qupvt,vbr);};/**
6
+ * PSY Model related stuff
7
+ */function PSY(){/**
8
+ * The dbQ stuff.
9
+ */this.mask_adjust=0.;/**
10
+ * The dbQ stuff.
11
+ */this.mask_adjust_short=0.;/* at transition from one scalefactor band to next */ /**
12
+ * Band weight long scalefactor bands.
13
+ */this.bo_l_weight=$ecb6e13812bdc08b$var$new_float($cPNKB.SBMAX_l);/**
14
+ * Band weight short scalefactor bands.
15
+ */this.bo_s_weight=$ecb6e13812bdc08b$var$new_float($cPNKB.SBMAX_s);}function LowPassHighPass(){this.lowerlimit=0.;}function BandPass(bitrate,lPass){this.lowpass=lPass;}var LAME_ID=0xFFF88E3B;function lame_init_old(gfp){var gfc;gfp.class_id=LAME_ID;gfc=gfp.internal_flags=new $4SDnr();/* Global flags. set defaults here for non-zero values */ /* see lame.h for description */ /*
16
+ * set integer values to -1 to mean that LAME will compute the best
17
+ * value, UNLESS the calling program as set it (and the value is no
18
+ * longer -1)
19
+ */gfp.mode=MPEGMode.NOT_SET;gfp.original=1;gfp.in_samplerate=44100;gfp.num_channels=2;gfp.num_samples=-1;gfp.bWriteVbrTag=true;gfp.quality=-1;gfp.short_blocks=null;gfc.subblock_gain=-1;gfp.lowpassfreq=0;gfp.highpassfreq=0;gfp.lowpasswidth=-1;gfp.highpasswidth=-1;gfp.VBR=$ecb6e13812bdc08b$var$VbrMode.vbr_off;gfp.VBR_q=4;gfp.ATHcurve=-1;gfp.VBR_mean_bitrate_kbps=128;gfp.VBR_min_bitrate_kbps=0;gfp.VBR_max_bitrate_kbps=0;gfp.VBR_hard_min=0;gfc.VBR_min_bitrate=1;/* not 0 ????? */gfc.VBR_max_bitrate=13;/* not 14 ????? */gfp.quant_comp=-1;gfp.quant_comp_short=-1;gfp.msfix=-1;gfc.resample_ratio=1;gfc.OldValue[0]=180;gfc.OldValue[1]=180;gfc.CurrentStep[0]=4;gfc.CurrentStep[1]=4;gfc.masking_lower=1;gfc.nsPsy.attackthre=-1;gfc.nsPsy.attackthre_s=-1;gfp.scale=-1;gfp.athaa_type=-1;gfp.ATHtype=-1;/* default = -1 = set in lame_init_params */gfp.athaa_loudapprox=-1;/* 1 = flat loudness approx. (total energy) */ /* 2 = equal loudness curve */gfp.athaa_sensitivity=0.0;/* no offset */gfp.useTemporal=null;gfp.interChRatio=-1;/*
20
+ * The reason for int mf_samples_to_encode = ENCDELAY + POSTDELAY;
21
+ * ENCDELAY = internal encoder delay. And then we have to add
22
+ * POSTDELAY=288 because of the 50% MDCT overlap. A 576 MDCT granule
23
+ * decodes to 1152 samples. To synthesize the 576 samples centered under
24
+ * this granule we need the previous granule for the first 288 samples
25
+ * (no problem), and the next granule for the next 288 samples (not
26
+ * possible if this is last granule). So we need to pad with 288 samples
27
+ * to make sure we can encode the 576 samples we are interested in.
28
+ */gfc.mf_samples_to_encode=$cPNKB.ENCDELAY+$cPNKB.POSTDELAY;gfp.encoder_padding=0;gfc.mf_size=$cPNKB.ENCDELAY-$cPNKB.MDCTDELAY;/*
29
+ * we pad input with this many 0's
30
+ */gfp.findReplayGain=false;gfp.decode_on_the_fly=false;gfc.decode_on_the_fly=false;gfc.findReplayGain=false;gfc.findPeakSample=false;gfc.RadioGain=0;gfc.AudiophileGain=0;gfc.noclipGainChange=0;gfc.noclipScale=-1;gfp.preset=0;gfp.write_id3tag_automatic=true;return 0;}this.lame_init=function(){var gfp=new $5HJeD();lame_init_old(gfp);gfp.lame_allocated_gfp=1;return gfp;};function filter_coef(x){if(x>1.0)return 0.0;if(x<=0.0)return 1.0;return Math.cos(Math.PI/2*x);}this.nearestBitrateFullIndex=function(bitrate){/* borrowed from DM abr presets */var full_bitrate_table=[8,16,24,32,40,48,56,64,80,96,112,128,160,192,224,256,320];var lower_range=0,lower_range_kbps=0,upper_range=0,upper_range_kbps=0;/* We assume specified bitrate will be 320kbps */upper_range_kbps=full_bitrate_table[16];upper_range=16;lower_range_kbps=full_bitrate_table[16];lower_range=16;/*
31
+ * Determine which significant bitrates the value specified falls
32
+ * between, if loop ends without breaking then we were correct above
33
+ * that the value was 320
34
+ */for(var b=0;b<16;b++)if(Math.max(bitrate,full_bitrate_table[b+1])!=bitrate){upper_range_kbps=full_bitrate_table[b+1];upper_range=b+1;lower_range_kbps=full_bitrate_table[b];lower_range=b;break;/* We found upper range */}/* Determine which range the value specified is closer to */if(upper_range_kbps-bitrate>bitrate-lower_range_kbps)return lower_range;return upper_range;};function optimum_samplefreq(lowpassfreq,input_samplefreq){/*
35
+ * Rules:
36
+ *
37
+ * - if possible, sfb21 should NOT be used
38
+ */var suggested_samplefreq=44100;if(input_samplefreq>=48000)suggested_samplefreq=48000;else if(input_samplefreq>=44100)suggested_samplefreq=44100;else if(input_samplefreq>=32000)suggested_samplefreq=32000;else if(input_samplefreq>=24000)suggested_samplefreq=24000;else if(input_samplefreq>=22050)suggested_samplefreq=22050;else if(input_samplefreq>=16000)suggested_samplefreq=16000;else if(input_samplefreq>=12000)suggested_samplefreq=12000;else if(input_samplefreq>=11025)suggested_samplefreq=11025;else if(input_samplefreq>=8000)suggested_samplefreq=8000;if(lowpassfreq==-1)return suggested_samplefreq;if(lowpassfreq<=15960)suggested_samplefreq=44100;if(lowpassfreq<=15250)suggested_samplefreq=32000;if(lowpassfreq<=11220)suggested_samplefreq=24000;if(lowpassfreq<=9970)suggested_samplefreq=22050;if(lowpassfreq<=7230)suggested_samplefreq=16000;if(lowpassfreq<=5420)suggested_samplefreq=12000;if(lowpassfreq<=4510)suggested_samplefreq=11025;if(lowpassfreq<=3970)suggested_samplefreq=8000;if(input_samplefreq<suggested_samplefreq){/*
39
+ * choose a valid MPEG sample frequency above the input sample
40
+ * frequency to avoid SFB21/12 bitrate bloat rh 061115
41
+ */if(input_samplefreq>44100)return 48000;if(input_samplefreq>32000)return 44100;if(input_samplefreq>24000)return 32000;if(input_samplefreq>22050)return 24000;if(input_samplefreq>16000)return 22050;if(input_samplefreq>12000)return 16000;if(input_samplefreq>11025)return 12000;if(input_samplefreq>8000)return 11025;return 8000;}return suggested_samplefreq;}/**
42
+ * convert samp freq in Hz to index
43
+ */function SmpFrqIndex(sample_freq,gpf){switch(sample_freq){case 44100:gpf.version=1;return 0;case 48000:gpf.version=1;return 1;case 32000:gpf.version=1;return 2;case 22050:gpf.version=0;return 0;case 24000:gpf.version=0;return 1;case 16000:gpf.version=0;return 2;case 11025:gpf.version=0;return 0;case 12000:gpf.version=0;return 1;case 8000:gpf.version=0;return 2;default:gpf.version=0;return -1;}}/**
44
+ * @param bRate
45
+ * legal rates from 8 to 320
46
+ */function FindNearestBitrate(bRate,version,samplerate){/* MPEG-1 or MPEG-2 LSF */if(samplerate<16000)version=2;var bitrate=$dQDcS.bitrate_table[version][1];for(var i=2;i<=14;i++){if($dQDcS.bitrate_table[version][i]>0){if(Math.abs($dQDcS.bitrate_table[version][i]-bRate)<Math.abs(bitrate-bRate))bitrate=$dQDcS.bitrate_table[version][i];}}return bitrate;}/**
47
+ * @param bRate
48
+ * legal rates from 32 to 448 kbps
49
+ * @param version
50
+ * MPEG-1 or MPEG-2/2.5 LSF
51
+ */function BitrateIndex(bRate,version,samplerate){/* convert bitrate in kbps to index */if(samplerate<16000)version=2;for(var i=0;i<=14;i++)if($dQDcS.bitrate_table[version][i]>0){if($dQDcS.bitrate_table[version][i]==bRate)return i;}return -1;}function optimum_bandwidth(lh,bitrate){/**
52
+ * <PRE>
53
+ * Input:
54
+ * bitrate total bitrate in kbps
55
+ *
56
+ * Output:
57
+ * lowerlimit: best lowpass frequency limit for input filter in Hz
58
+ * upperlimit: best highpass frequency limit for input filter in Hz
59
+ * </PRE>
60
+ */var freq_map=[new BandPass(8,2000),new BandPass(16,3700),new BandPass(24,3900),new BandPass(32,5500),new BandPass(40,7000),new BandPass(48,7500),new BandPass(56,10000),new BandPass(64,11000),new BandPass(80,13500),new BandPass(96,15100),new BandPass(112,15600),new BandPass(128,17000),new BandPass(160,17500),new BandPass(192,18600),new BandPass(224,19400),new BandPass(256,19700),new BandPass(320,20500)];var table_index=self.nearestBitrateFullIndex(bitrate);lh.lowerlimit=freq_map[table_index].lowpass;}function lame_init_params_ppflt(gfp){var gfc=gfp.internal_flags;/***************************************************************/ /* compute info needed for polyphase filter (filter type==0, default) */ /***************************************************************/var lowpass_band=32;var highpass_band=-1;if(gfc.lowpass1>0){var minband=999;for(var band=0;band<=31;band++){var freq=band/31.0;/* this band and above will be zeroed: */if(freq>=gfc.lowpass2)lowpass_band=Math.min(lowpass_band,band);if(gfc.lowpass1<freq&&freq<gfc.lowpass2)minband=Math.min(minband,band);}/*
61
+ * compute the *actual* transition band implemented by the polyphase
62
+ * filter
63
+ */if(minband==999)gfc.lowpass1=(lowpass_band-.75)/31.0;else gfc.lowpass1=(minband-.75)/31.0;gfc.lowpass2=lowpass_band/31.0;}/*
64
+ * make sure highpass filter is within 90% of what the effective
65
+ * highpass frequency will be
66
+ */if(gfc.highpass2>0){if(gfc.highpass2<.9*(.75/31.0)){gfc.highpass1=0;gfc.highpass2=0;$ecb6e13812bdc08b$var$System.err.println("Warning: highpass filter disabled. highpass frequency too small\n");}}if(gfc.highpass2>0){var maxband=-1;for(var band=0;band<=31;band++){var freq=band/31.0;/* this band and below will be zereod */if(freq<=gfc.highpass1)highpass_band=Math.max(highpass_band,band);if(gfc.highpass1<freq&&freq<gfc.highpass2)maxband=Math.max(maxband,band);}/*
67
+ * compute the *actual* transition band implemented by the polyphase
68
+ * filter
69
+ */gfc.highpass1=highpass_band/31.0;if(maxband==-1)gfc.highpass2=(highpass_band+.75)/31.0;else gfc.highpass2=(maxband+.75)/31.0;}for(var band=0;band<32;band++){var fc1,fc2;var freq=band/31.0;if(gfc.highpass2>gfc.highpass1)fc1=filter_coef((gfc.highpass2-freq)/(gfc.highpass2-gfc.highpass1+1e-20));else fc1=1.0;if(gfc.lowpass2>gfc.lowpass1)fc2=filter_coef((freq-gfc.lowpass1)/(gfc.lowpass2-gfc.lowpass1+1e-20));else fc2=1.0;gfc.amp_filter[band]=fc1*fc2;}}function lame_init_qval(gfp){var gfc=gfp.internal_flags;switch(gfp.quality){default:case 9:/* no psymodel, no noise shaping */gfc.psymodel=0;gfc.noise_shaping=0;gfc.noise_shaping_amp=0;gfc.noise_shaping_stop=0;gfc.use_best_huffman=0;gfc.full_outer_loop=0;break;case 8:gfp.quality=7;//$FALL-THROUGH$
70
+ case 7:/*
71
+ * use psymodel (for short block and m/s switching), but no noise
72
+ * shapping
73
+ */gfc.psymodel=1;gfc.noise_shaping=0;gfc.noise_shaping_amp=0;gfc.noise_shaping_stop=0;gfc.use_best_huffman=0;gfc.full_outer_loop=0;break;case 6:gfc.psymodel=1;if(gfc.noise_shaping==0)gfc.noise_shaping=1;gfc.noise_shaping_amp=0;gfc.noise_shaping_stop=0;if(gfc.subblock_gain==-1)gfc.subblock_gain=1;gfc.use_best_huffman=0;gfc.full_outer_loop=0;break;case 5:gfc.psymodel=1;if(gfc.noise_shaping==0)gfc.noise_shaping=1;gfc.noise_shaping_amp=0;gfc.noise_shaping_stop=0;if(gfc.subblock_gain==-1)gfc.subblock_gain=1;gfc.use_best_huffman=0;gfc.full_outer_loop=0;break;case 4:gfc.psymodel=1;if(gfc.noise_shaping==0)gfc.noise_shaping=1;gfc.noise_shaping_amp=0;gfc.noise_shaping_stop=0;if(gfc.subblock_gain==-1)gfc.subblock_gain=1;gfc.use_best_huffman=1;gfc.full_outer_loop=0;break;case 3:gfc.psymodel=1;if(gfc.noise_shaping==0)gfc.noise_shaping=1;gfc.noise_shaping_amp=1;gfc.noise_shaping_stop=1;if(gfc.subblock_gain==-1)gfc.subblock_gain=1;gfc.use_best_huffman=1;gfc.full_outer_loop=0;break;case 2:gfc.psymodel=1;if(gfc.noise_shaping==0)gfc.noise_shaping=1;if(gfc.substep_shaping==0)gfc.substep_shaping=2;gfc.noise_shaping_amp=1;gfc.noise_shaping_stop=1;if(gfc.subblock_gain==-1)gfc.subblock_gain=1;gfc.use_best_huffman=1;/* inner loop */gfc.full_outer_loop=0;break;case 1:gfc.psymodel=1;if(gfc.noise_shaping==0)gfc.noise_shaping=1;if(gfc.substep_shaping==0)gfc.substep_shaping=2;gfc.noise_shaping_amp=2;gfc.noise_shaping_stop=1;if(gfc.subblock_gain==-1)gfc.subblock_gain=1;gfc.use_best_huffman=1;gfc.full_outer_loop=0;break;case 0:gfc.psymodel=1;if(gfc.noise_shaping==0)gfc.noise_shaping=1;if(gfc.substep_shaping==0)gfc.substep_shaping=2;gfc.noise_shaping_amp=2;gfc.noise_shaping_stop=1;if(gfc.subblock_gain==-1)gfc.subblock_gain=1;gfc.use_best_huffman=1;/*
74
+ * type 2 disabled because of it slowness, in favor of full outer
75
+ * loop search
76
+ */gfc.full_outer_loop=0;break;}}function lame_init_bitstream(gfp){var gfc=gfp.internal_flags;gfp.frameNum=0;if(gfp.write_id3tag_automatic)id3.id3tag_write_v2(gfp);/* initialize histogram data optionally used by frontend */gfc.bitrate_stereoMode_Hist=$ecb6e13812bdc08b$var$new_int_n([16,5]);gfc.bitrate_blockType_Hist=$ecb6e13812bdc08b$var$new_int_n([16,6]);gfc.PeakSample=0.0;/* Write initial VBR Header to bitstream and init VBR data */if(gfp.bWriteVbrTag)vbr.InitVbrTag(gfp);}/********************************************************************
77
+ * initialize internal params based on data in gf (globalflags struct filled
78
+ * in by calling program)
79
+ *
80
+ * OUTLINE:
81
+ *
82
+ * We first have some complex code to determine bitrate, output samplerate
83
+ * and mode. It is complicated by the fact that we allow the user to set
84
+ * some or all of these parameters, and need to determine best possible
85
+ * values for the rest of them:
86
+ *
87
+ * 1. set some CPU related flags 2. check if we are mono.mono, stereo.mono
88
+ * or stereo.stereo 3. compute bitrate and output samplerate: user may have
89
+ * set compression ratio user may have set a bitrate user may have set a
90
+ * output samplerate 4. set some options which depend on output samplerate
91
+ * 5. compute the actual compression ratio 6. set mode based on compression
92
+ * ratio
93
+ *
94
+ * The remaining code is much simpler - it just sets options based on the
95
+ * mode & compression ratio:
96
+ *
97
+ * set allow_diff_short based on mode select lowpass filter based on
98
+ * compression ratio & mode set the bitrate index, and min/max bitrates for
99
+ * VBR modes disable VBR tag if it is not appropriate initialize the
100
+ * bitstream initialize scalefac_band data set sideinfo_len (based on
101
+ * channels, CRC, out_samplerate) write an id3v2 tag into the bitstream
102
+ * write VBR tag into the bitstream set mpeg1/2 flag estimate the number of
103
+ * frames (based on a lot of data)
104
+ *
105
+ * now we set more flags: nspsytune: see code VBR modes see code CBR/ABR see
106
+ * code
107
+ *
108
+ * Finally, we set the algorithm flags based on the gfp.quality value
109
+ * lame_init_qval(gfp);
110
+ *
111
+ ********************************************************************/this.lame_init_params=function(gfp){var gfc=gfp.internal_flags;gfc.Class_ID=0;if(gfc.ATH==null)gfc.ATH=new $cU3Yf();if(gfc.PSY==null)gfc.PSY=new PSY();if(gfc.rgdata==null)gfc.rgdata=new $2qGTD();gfc.channels_in=gfp.num_channels;if(gfc.channels_in==1)gfp.mode=MPEGMode.MONO;gfc.channels_out=gfp.mode==MPEGMode.MONO?1:2;gfc.mode_ext=$cPNKB.MPG_MD_MS_LR;if(gfp.mode==MPEGMode.MONO)gfp.force_ms=false;/*
112
+ * don't allow forced mid/side stereo for mono output
113
+ */if(gfp.VBR==$ecb6e13812bdc08b$var$VbrMode.vbr_off&&gfp.VBR_mean_bitrate_kbps!=128&&gfp.brate==0)gfp.brate=gfp.VBR_mean_bitrate_kbps;if(gfp.VBR==$ecb6e13812bdc08b$var$VbrMode.vbr_off||gfp.VBR==$ecb6e13812bdc08b$var$VbrMode.vbr_mtrh||gfp.VBR==$ecb6e13812bdc08b$var$VbrMode.vbr_mt);else gfp.free_format=false;if(gfp.VBR==$ecb6e13812bdc08b$var$VbrMode.vbr_off&&gfp.brate==0)/* no bitrate or compression ratio specified, use 11.025 */{if($ctaQC.EQ(gfp.compression_ratio,0))gfp.compression_ratio=11.025;}/* find bitrate if user specify a compression ratio */if(gfp.VBR==$ecb6e13812bdc08b$var$VbrMode.vbr_off&&gfp.compression_ratio>0){if(gfp.out_samplerate==0)gfp.out_samplerate=map2MP3Frequency(int(0.97*gfp.in_samplerate));/*
114
+ * round up with a margin of 3 %
115
+ */ /*
116
+ * choose a bitrate for the output samplerate which achieves
117
+ * specified compression ratio
118
+ */gfp.brate=0|gfp.out_samplerate*16*gfc.channels_out/(1.e3*gfp.compression_ratio);/* we need the version for the bitrate table look up */gfc.samplerate_index=SmpFrqIndex(gfp.out_samplerate,gfp);if(!gfp.free_format)/*
119
+ * for non Free Format find the nearest allowed
120
+ * bitrate
121
+ */gfp.brate=FindNearestBitrate(gfp.brate,gfp.version,gfp.out_samplerate);}if(gfp.out_samplerate!=0){if(gfp.out_samplerate<16000){gfp.VBR_mean_bitrate_kbps=Math.max(gfp.VBR_mean_bitrate_kbps,8);gfp.VBR_mean_bitrate_kbps=Math.min(gfp.VBR_mean_bitrate_kbps,64);}else if(gfp.out_samplerate<32000){gfp.VBR_mean_bitrate_kbps=Math.max(gfp.VBR_mean_bitrate_kbps,8);gfp.VBR_mean_bitrate_kbps=Math.min(gfp.VBR_mean_bitrate_kbps,160);}else {gfp.VBR_mean_bitrate_kbps=Math.max(gfp.VBR_mean_bitrate_kbps,32);gfp.VBR_mean_bitrate_kbps=Math.min(gfp.VBR_mean_bitrate_kbps,320);}}/****************************************************************/ /* if a filter has not been enabled, see if we should add one: */ /****************************************************************/if(gfp.lowpassfreq==0){var lowpass=16000.;switch(gfp.VBR){case $ecb6e13812bdc08b$var$VbrMode.vbr_off:var lh=new LowPassHighPass();optimum_bandwidth(lh,gfp.brate);lowpass=lh.lowerlimit;break;case $ecb6e13812bdc08b$var$VbrMode.vbr_abr:var lh=new LowPassHighPass();optimum_bandwidth(lh,gfp.VBR_mean_bitrate_kbps);lowpass=lh.lowerlimit;break;case $ecb6e13812bdc08b$var$VbrMode.vbr_rh:var x=[19500,19000,18600,18000,17500,16000,15600,14900,12500,10000,3950];if(0<=gfp.VBR_q&&gfp.VBR_q<=9){var a=x[gfp.VBR_q],b=x[gfp.VBR_q+1],m=gfp.VBR_q_frac;lowpass=linear_int(a,b,m);}else lowpass=19500;break;default:var x=[19500,19000,18500,18000,17500,16500,15500,14500,12500,9500,3950];if(0<=gfp.VBR_q&&gfp.VBR_q<=9){var a=x[gfp.VBR_q],b=x[gfp.VBR_q+1],m=gfp.VBR_q_frac;lowpass=linear_int(a,b,m);}else lowpass=19500;}if(gfp.mode==MPEGMode.MONO&&(gfp.VBR==$ecb6e13812bdc08b$var$VbrMode.vbr_off||gfp.VBR==$ecb6e13812bdc08b$var$VbrMode.vbr_abr))lowpass*=1.5;gfp.lowpassfreq=lowpass|0;}if(gfp.out_samplerate==0){if(2*gfp.lowpassfreq>gfp.in_samplerate)gfp.lowpassfreq=gfp.in_samplerate/2;gfp.out_samplerate=optimum_samplefreq(gfp.lowpassfreq|0,gfp.in_samplerate);}gfp.lowpassfreq=Math.min(20500,gfp.lowpassfreq);gfp.lowpassfreq=Math.min(gfp.out_samplerate/2,gfp.lowpassfreq);if(gfp.VBR==$ecb6e13812bdc08b$var$VbrMode.vbr_off)gfp.compression_ratio=gfp.out_samplerate*16*gfc.channels_out/(1.e3*gfp.brate);if(gfp.VBR==$ecb6e13812bdc08b$var$VbrMode.vbr_abr)gfp.compression_ratio=gfp.out_samplerate*16*gfc.channels_out/(1.e3*gfp.VBR_mean_bitrate_kbps);/*
122
+ * do not compute ReplayGain values and do not find the peak sample if
123
+ * we can't store them
124
+ */if(!gfp.bWriteVbrTag){gfp.findReplayGain=false;gfp.decode_on_the_fly=false;gfc.findPeakSample=false;}gfc.findReplayGain=gfp.findReplayGain;gfc.decode_on_the_fly=gfp.decode_on_the_fly;if(gfc.decode_on_the_fly)gfc.findPeakSample=true;if(gfc.findReplayGain){if(ga.InitGainAnalysis(gfc.rgdata,gfp.out_samplerate)==GainAnalysis.INIT_GAIN_ANALYSIS_ERROR){gfp.internal_flags=null;return -6;}}if(gfc.decode_on_the_fly&&!gfp.decode_only){if(gfc.hip!=null)mpglib.hip_decode_exit(gfc.hip);gfc.hip=mpglib.hip_decode_init();}gfc.mode_gr=gfp.out_samplerate<=24000?1:2;/*
125
+ * Number of granules per frame
126
+ */gfp.framesize=576*gfc.mode_gr;gfp.encoder_delay=$cPNKB.ENCDELAY;gfc.resample_ratio=gfp.in_samplerate/gfp.out_samplerate;/**
127
+ * <PRE>
128
+ * sample freq bitrate compression ratio
129
+ * [kHz] [kbps/channel] for 16 bit input
130
+ * 44.1 56 12.6
131
+ * 44.1 64 11.025
132
+ * 44.1 80 8.82
133
+ * 22.05 24 14.7
134
+ * 22.05 32 11.025
135
+ * 22.05 40 8.82
136
+ * 16 16 16.0
137
+ * 16 24 10.667
138
+ * </PRE>
139
+ */ /**
140
+ * <PRE>
141
+ * For VBR, take a guess at the compression_ratio.
142
+ * For example:
143
+ *
144
+ * VBR_q compression like
145
+ * - 4.4 320 kbps/44 kHz
146
+ * 0...1 5.5 256 kbps/44 kHz
147
+ * 2 7.3 192 kbps/44 kHz
148
+ * 4 8.8 160 kbps/44 kHz
149
+ * 6 11 128 kbps/44 kHz
150
+ * 9 14.7 96 kbps
151
+ *
152
+ * for lower bitrates, downsample with --resample
153
+ * </PRE>
154
+ */switch(gfp.VBR){case $ecb6e13812bdc08b$var$VbrMode.vbr_mt:case $ecb6e13812bdc08b$var$VbrMode.vbr_rh:case $ecb6e13812bdc08b$var$VbrMode.vbr_mtrh:/* numbers are a bit strange, but they determine the lowpass value */var cmp=[5.7,6.5,7.3,8.2,10,11.9,13,14,15,16.5];gfp.compression_ratio=cmp[gfp.VBR_q];break;case $ecb6e13812bdc08b$var$VbrMode.vbr_abr:gfp.compression_ratio=gfp.out_samplerate*16*gfc.channels_out/(1.e3*gfp.VBR_mean_bitrate_kbps);break;default:gfp.compression_ratio=gfp.out_samplerate*16*gfc.channels_out/(1.e3*gfp.brate);break;}/*
155
+ * mode = -1 (not set by user) or mode = MONO (because of only 1 input
156
+ * channel). If mode has not been set, then select J-STEREO
157
+ */if(gfp.mode==MPEGMode.NOT_SET)gfp.mode=MPEGMode.JOINT_STEREO;/* apply user driven high pass filter */if(gfp.highpassfreq>0){gfc.highpass1=2.*gfp.highpassfreq;if(gfp.highpasswidth>=0)gfc.highpass2=2.*(gfp.highpassfreq+gfp.highpasswidth);else/* 0% above on default */gfc.highpass2=2*gfp.highpassfreq;gfc.highpass1/=gfp.out_samplerate;gfc.highpass2/=gfp.out_samplerate;}else {gfc.highpass1=0;gfc.highpass2=0;}/* apply user driven low pass filter */if(gfp.lowpassfreq>0){gfc.lowpass2=2.*gfp.lowpassfreq;if(gfp.lowpasswidth>=0){gfc.lowpass1=2.*(gfp.lowpassfreq-gfp.lowpasswidth);if(gfc.lowpass1<0)/* has to be >= 0 */gfc.lowpass1=0;}else gfc.lowpass1=2*gfp.lowpassfreq;gfc.lowpass1/=gfp.out_samplerate;gfc.lowpass2/=gfp.out_samplerate;}else {gfc.lowpass1=0;gfc.lowpass2=0;}/**********************************************************************/ /* compute info needed for polyphase filter (filter type==0, default) */ /**********************************************************************/lame_init_params_ppflt(gfp);/*******************************************************
158
+ * samplerate and bitrate index
159
+ *******************************************************/gfc.samplerate_index=SmpFrqIndex(gfp.out_samplerate,gfp);if(gfc.samplerate_index<0){gfp.internal_flags=null;return -1;}if(gfp.VBR==$ecb6e13812bdc08b$var$VbrMode.vbr_off){if(gfp.free_format)gfc.bitrate_index=0;else {gfp.brate=FindNearestBitrate(gfp.brate,gfp.version,gfp.out_samplerate);gfc.bitrate_index=BitrateIndex(gfp.brate,gfp.version,gfp.out_samplerate);if(gfc.bitrate_index<=0){gfp.internal_flags=null;return -1;}}}else gfc.bitrate_index=1;/* for CBR, we will write an "info" tag. */if(gfp.analysis)gfp.bWriteVbrTag=false;/* some file options not allowed if output is: not specified or stdout */if(gfc.pinfo!=null)gfp.bWriteVbrTag=false;/* disable Xing VBR tag */bs.init_bit_stream_w(gfc);var j=gfc.samplerate_index+3*gfp.version+6*(gfp.out_samplerate<16000?1:0);for(var i=0;i<$cPNKB.SBMAX_l+1;i++)gfc.scalefac_band.l[i]=qupvt.sfBandIndex[j].l[i];for(var i=0;i<$cPNKB.PSFB21+1;i++){var size=(gfc.scalefac_band.l[22]-gfc.scalefac_band.l[21])/$cPNKB.PSFB21;var start=gfc.scalefac_band.l[21]+i*size;gfc.scalefac_band.psfb21[i]=start;}gfc.scalefac_band.psfb21[$cPNKB.PSFB21]=576;for(var i=0;i<$cPNKB.SBMAX_s+1;i++)gfc.scalefac_band.s[i]=qupvt.sfBandIndex[j].s[i];for(var i=0;i<$cPNKB.PSFB12+1;i++){var size=(gfc.scalefac_band.s[13]-gfc.scalefac_band.s[12])/$cPNKB.PSFB12;var start=gfc.scalefac_band.s[12]+i*size;gfc.scalefac_band.psfb12[i]=start;}gfc.scalefac_band.psfb12[$cPNKB.PSFB12]=192;/* determine the mean bitrate for main data */if(gfp.version==1)/* MPEG 1 */gfc.sideinfo_len=gfc.channels_out==1?21:36;else/* MPEG 2 */gfc.sideinfo_len=gfc.channels_out==1?13:21;if(gfp.error_protection)gfc.sideinfo_len+=2;lame_init_bitstream(gfp);gfc.Class_ID=LAME_ID;var k;for(k=0;k<19;k++)gfc.nsPsy.pefirbuf[k]=700*gfc.mode_gr*gfc.channels_out;if(gfp.ATHtype==-1)gfp.ATHtype=4;$ecb6e13812bdc08b$var$assert(gfp.VBR_q<=9);$ecb6e13812bdc08b$var$assert(gfp.VBR_q>=0);switch(gfp.VBR){case $ecb6e13812bdc08b$var$VbrMode.vbr_mt:gfp.VBR=$ecb6e13812bdc08b$var$VbrMode.vbr_mtrh;//$FALL-THROUGH$
160
+ case $ecb6e13812bdc08b$var$VbrMode.vbr_mtrh:if(gfp.useTemporal==null)gfp.useTemporal=false;p.apply_preset(gfp,500-gfp.VBR_q*10,0);/**
161
+ * <PRE>
162
+ * The newer VBR code supports only a limited
163
+ * subset of quality levels:
164
+ * 9-5=5 are the same, uses x^3/4 quantization
165
+ * 4-0=0 are the same 5 plus best huffman divide code
166
+ * </PRE>
167
+ */if(gfp.quality<0)gfp.quality=LAME_DEFAULT_QUALITY;if(gfp.quality<5)gfp.quality=0;if(gfp.quality>5)gfp.quality=5;gfc.PSY.mask_adjust=gfp.maskingadjust;gfc.PSY.mask_adjust_short=gfp.maskingadjust_short;/*
168
+ * sfb21 extra only with MPEG-1 at higher sampling rates
169
+ */if(gfp.experimentalY)gfc.sfb21_extra=false;else gfc.sfb21_extra=gfp.out_samplerate>44000;gfc.iteration_loop=new VBRNewIterationLoop(qu);break;case $ecb6e13812bdc08b$var$VbrMode.vbr_rh:p.apply_preset(gfp,500-gfp.VBR_q*10,0);gfc.PSY.mask_adjust=gfp.maskingadjust;gfc.PSY.mask_adjust_short=gfp.maskingadjust_short;/*
170
+ * sfb21 extra only with MPEG-1 at higher sampling rates
171
+ */if(gfp.experimentalY)gfc.sfb21_extra=false;else gfc.sfb21_extra=gfp.out_samplerate>44000;/*
172
+ * VBR needs at least the output of GPSYCHO, so we have to garantee
173
+ * that by setting a minimum quality level, actually level 6 does
174
+ * it. down to level 6
175
+ */if(gfp.quality>6)gfp.quality=6;if(gfp.quality<0)gfp.quality=LAME_DEFAULT_QUALITY;gfc.iteration_loop=new VBROldIterationLoop(qu);break;default:var vbrmode;/*
176
+ * no sfb21 extra with CBR code
177
+ */gfc.sfb21_extra=false;if(gfp.quality<0)gfp.quality=LAME_DEFAULT_QUALITY;vbrmode=gfp.VBR;if(vbrmode==$ecb6e13812bdc08b$var$VbrMode.vbr_off)gfp.VBR_mean_bitrate_kbps=gfp.brate;/* second, set parameters depending on bitrate */p.apply_preset(gfp,gfp.VBR_mean_bitrate_kbps,0);gfp.VBR=vbrmode;gfc.PSY.mask_adjust=gfp.maskingadjust;gfc.PSY.mask_adjust_short=gfp.maskingadjust_short;if(vbrmode==$ecb6e13812bdc08b$var$VbrMode.vbr_off)gfc.iteration_loop=new $e32wu(qu);else gfc.iteration_loop=new ABRIterationLoop(qu);break;}$ecb6e13812bdc08b$var$assert(gfp.scale>=0);/* initialize default values common for all modes */if(gfp.VBR!=$ecb6e13812bdc08b$var$VbrMode.vbr_off){/* if the user didn't specify VBR_max_bitrate: */gfc.VBR_min_bitrate=1;/*
178
+ * default: allow 8 kbps (MPEG-2) or 32 kbps (MPEG-1)
179
+ */gfc.VBR_max_bitrate=14;/*
180
+ * default: allow 160 kbps (MPEG-2) or 320 kbps (MPEG-1)
181
+ */if(gfp.out_samplerate<16000)gfc.VBR_max_bitrate=8;/* default: allow 64 kbps (MPEG-2.5) */if(gfp.VBR_min_bitrate_kbps!=0){gfp.VBR_min_bitrate_kbps=FindNearestBitrate(gfp.VBR_min_bitrate_kbps,gfp.version,gfp.out_samplerate);gfc.VBR_min_bitrate=BitrateIndex(gfp.VBR_min_bitrate_kbps,gfp.version,gfp.out_samplerate);if(gfc.VBR_min_bitrate<0)return -1;}if(gfp.VBR_max_bitrate_kbps!=0){gfp.VBR_max_bitrate_kbps=FindNearestBitrate(gfp.VBR_max_bitrate_kbps,gfp.version,gfp.out_samplerate);gfc.VBR_max_bitrate=BitrateIndex(gfp.VBR_max_bitrate_kbps,gfp.version,gfp.out_samplerate);if(gfc.VBR_max_bitrate<0)return -1;}gfp.VBR_min_bitrate_kbps=$dQDcS.bitrate_table[gfp.version][gfc.VBR_min_bitrate];gfp.VBR_max_bitrate_kbps=$dQDcS.bitrate_table[gfp.version][gfc.VBR_max_bitrate];gfp.VBR_mean_bitrate_kbps=Math.min($dQDcS.bitrate_table[gfp.version][gfc.VBR_max_bitrate],gfp.VBR_mean_bitrate_kbps);gfp.VBR_mean_bitrate_kbps=Math.max($dQDcS.bitrate_table[gfp.version][gfc.VBR_min_bitrate],gfp.VBR_mean_bitrate_kbps);}/* just another daily changing developer switch */if(gfp.tune){gfc.PSY.mask_adjust+=gfp.tune_value_a;gfc.PSY.mask_adjust_short+=gfp.tune_value_a;}/* initialize internal qval settings */lame_init_qval(gfp);$ecb6e13812bdc08b$var$assert(gfp.scale>=0);/*
182
+ * automatic ATH adjustment on
183
+ */if(gfp.athaa_type<0)gfc.ATH.useAdjust=3;else gfc.ATH.useAdjust=gfp.athaa_type;/* initialize internal adaptive ATH settings -jd */gfc.ATH.aaSensitivityP=Math.pow(10.0,gfp.athaa_sensitivity/-10);if(gfp.short_blocks==null)gfp.short_blocks=$ecb6e13812bdc08b$var$ShortBlock.short_block_allowed;/*
184
+ * Note Jan/2003: Many hardware decoders cannot handle short blocks in
185
+ * regular stereo mode unless they are coupled (same type in both
186
+ * channels) it is a rare event (1 frame per min. or so) that LAME would
187
+ * use uncoupled short blocks, so lets turn them off until we decide how
188
+ * to handle this. No other encoders allow uncoupled short blocks, even
189
+ * though it is in the standard.
190
+ */ /*
191
+ * rh 20040217: coupling makes no sense for mono and dual-mono streams
192
+ */if(gfp.short_blocks==$ecb6e13812bdc08b$var$ShortBlock.short_block_allowed&&(gfp.mode==MPEGMode.JOINT_STEREO||gfp.mode==MPEGMode.STEREO))gfp.short_blocks=$ecb6e13812bdc08b$var$ShortBlock.short_block_coupled;if(gfp.quant_comp<0)gfp.quant_comp=1;if(gfp.quant_comp_short<0)gfp.quant_comp_short=0;if(gfp.msfix<0)gfp.msfix=0;/* select psychoacoustic model */gfp.exp_nspsytune=gfp.exp_nspsytune|1;if(gfp.internal_flags.nsPsy.attackthre<0)gfp.internal_flags.nsPsy.attackthre=$d2VP0.NSATTACKTHRE;if(gfp.internal_flags.nsPsy.attackthre_s<0)gfp.internal_flags.nsPsy.attackthre_s=$d2VP0.NSATTACKTHRE_S;$ecb6e13812bdc08b$var$assert(gfp.scale>=0);if(gfp.scale<0)gfp.scale=1;if(gfp.ATHtype<0)gfp.ATHtype=4;if(gfp.ATHcurve<0)gfp.ATHcurve=4;if(gfp.athaa_loudapprox<0)gfp.athaa_loudapprox=2;if(gfp.interChRatio<0)gfp.interChRatio=0;if(gfp.useTemporal==null)gfp.useTemporal=true;/* on by default */ /*
193
+ * padding method as described in
194
+ * "MPEG-Layer3 / Bitstream Syntax and Decoding" by Martin Sieler, Ralph
195
+ * Sperschneider
196
+ *
197
+ * note: there is no padding for the very first frame
198
+ *
199
+ * Robert Hegemann 2000-06-22
200
+ */gfc.slot_lag=gfc.frac_SpF=0;if(gfp.VBR==$ecb6e13812bdc08b$var$VbrMode.vbr_off)gfc.slot_lag=gfc.frac_SpF=(gfp.version+1)*72000*gfp.brate%gfp.out_samplerate|0;qupvt.iteration_init(gfp);psy.psymodel_init(gfp);$ecb6e13812bdc08b$var$assert(gfp.scale>=0);return 0;};function update_inbuffer_size(gfc,nsamples){if(gfc.in_buffer_0==null||gfc.in_buffer_nsamples<nsamples){gfc.in_buffer_0=$ecb6e13812bdc08b$var$new_float(nsamples);gfc.in_buffer_1=$ecb6e13812bdc08b$var$new_float(nsamples);gfc.in_buffer_nsamples=nsamples;}}this.lame_encode_flush=function(gfp,mp3buffer,mp3bufferPos,mp3buffer_size){var gfc=gfp.internal_flags;var buffer=$ecb6e13812bdc08b$var$new_short_n([2,1152]);var imp3=0,mp3count,mp3buffer_size_remaining;/*
201
+ * we always add POSTDELAY=288 padding to make sure granule with real
202
+ * data can be complety decoded (because of 50% overlap with next
203
+ * granule
204
+ */var end_padding;var frames_left;var samples_to_encode=gfc.mf_samples_to_encode-$cPNKB.POSTDELAY;var mf_needed=calcNeeded(gfp);/* Was flush already called? */if(gfc.mf_samples_to_encode<1)return 0;mp3count=0;if(gfp.in_samplerate!=gfp.out_samplerate)/*
205
+ * delay due to resampling; needs to be fixed, if resampling code
206
+ * gets changed
207
+ */samples_to_encode+=16.*gfp.out_samplerate/gfp.in_samplerate;end_padding=gfp.framesize-samples_to_encode%gfp.framesize;if(end_padding<576)end_padding+=gfp.framesize;gfp.encoder_padding=end_padding;frames_left=(samples_to_encode+end_padding)/gfp.framesize;/*
208
+ * send in a frame of 0 padding until all internal sample buffers are
209
+ * flushed
210
+ */while(frames_left>0&&imp3>=0){var bunch=mf_needed-gfc.mf_size;var frame_num=gfp.frameNum;bunch*=gfp.in_samplerate;bunch/=gfp.out_samplerate;if(bunch>1152)bunch=1152;if(bunch<1)bunch=1;mp3buffer_size_remaining=mp3buffer_size-mp3count;/* if user specifed buffer size = 0, dont check size */if(mp3buffer_size==0)mp3buffer_size_remaining=0;imp3=this.lame_encode_buffer(gfp,buffer[0],buffer[1],bunch,mp3buffer,mp3bufferPos,mp3buffer_size_remaining);mp3bufferPos+=imp3;mp3count+=imp3;frames_left-=frame_num!=gfp.frameNum?1:0;}/*
211
+ * Set gfc.mf_samples_to_encode to 0, so we may detect and break loops
212
+ * calling it more than once in a row.
213
+ */gfc.mf_samples_to_encode=0;if(imp3<0)/* some type of fatal error */return imp3;mp3buffer_size_remaining=mp3buffer_size-mp3count;/* if user specifed buffer size = 0, dont check size */if(mp3buffer_size==0)mp3buffer_size_remaining=0;/* mp3 related stuff. bit buffer might still contain some mp3 data */bs.flush_bitstream(gfp);imp3=bs.copy_buffer(gfc,mp3buffer,mp3bufferPos,mp3buffer_size_remaining,1);if(imp3<0)/* some type of fatal error */return imp3;mp3bufferPos+=imp3;mp3count+=imp3;mp3buffer_size_remaining=mp3buffer_size-mp3count;/* if user specifed buffer size = 0, dont check size */if(mp3buffer_size==0)mp3buffer_size_remaining=0;if(gfp.write_id3tag_automatic){/* write a id3 tag to the bitstream */id3.id3tag_write_v1(gfp);imp3=bs.copy_buffer(gfc,mp3buffer,mp3bufferPos,mp3buffer_size_remaining,0);if(imp3<0)return imp3;mp3count+=imp3;}return mp3count;};this.lame_encode_buffer=function(gfp,buffer_l,buffer_r,nsamples,mp3buf,mp3bufPos,mp3buf_size){var gfc=gfp.internal_flags;var in_buffer=[null,null];if(gfc.Class_ID!=LAME_ID)return -3;if(nsamples==0)return 0;update_inbuffer_size(gfc,nsamples);in_buffer[0]=gfc.in_buffer_0;in_buffer[1]=gfc.in_buffer_1;/* make a copy of input buffer, changing type to sample_t */for(var i=0;i<nsamples;i++){in_buffer[0][i]=buffer_l[i];if(gfc.channels_in>1)in_buffer[1][i]=buffer_r[i];}return lame_encode_buffer_sample(gfp,in_buffer[0],in_buffer[1],nsamples,mp3buf,mp3bufPos,mp3buf_size);};function calcNeeded(gfp){var mf_needed=$cPNKB.BLKSIZE+gfp.framesize-$cPNKB.FFTOFFSET;/*
214
+ * amount needed for FFT
215
+ */mf_needed=Math.max(mf_needed,512+gfp.framesize-32);$ecb6e13812bdc08b$var$assert($4SDnr.MFSIZE>=mf_needed);return mf_needed;}function lame_encode_buffer_sample(gfp,buffer_l,buffer_r,nsamples,mp3buf,mp3bufPos,mp3buf_size){var gfc=gfp.internal_flags;var mp3size=0,ret,i,ch,mf_needed;var mp3out;var mfbuf=[null,null];var in_buffer=[null,null];if(gfc.Class_ID!=LAME_ID)return -3;if(nsamples==0)return 0;/* copy out any tags that may have been written into bitstream */mp3out=bs.copy_buffer(gfc,mp3buf,mp3bufPos,mp3buf_size,0);if(mp3out<0)return mp3out;/* not enough buffer space */mp3bufPos+=mp3out;mp3size+=mp3out;in_buffer[0]=buffer_l;in_buffer[1]=buffer_r;/* Apply user defined re-scaling */ /* user selected scaling of the samples */if($ctaQC.NEQ(gfp.scale,0)&&$ctaQC.NEQ(gfp.scale,1.0))for(i=0;i<nsamples;++i){in_buffer[0][i]*=gfp.scale;if(gfc.channels_out==2)in_buffer[1][i]*=gfp.scale;}/* user selected scaling of the channel 0 (left) samples */if($ctaQC.NEQ(gfp.scale_left,0)&&$ctaQC.NEQ(gfp.scale_left,1.0))for(i=0;i<nsamples;++i)in_buffer[0][i]*=gfp.scale_left;/* user selected scaling of the channel 1 (right) samples */if($ctaQC.NEQ(gfp.scale_right,0)&&$ctaQC.NEQ(gfp.scale_right,1.0))for(i=0;i<nsamples;++i)in_buffer[1][i]*=gfp.scale_right;/* Downsample to Mono if 2 channels in and 1 channel out */if(gfp.num_channels==2&&gfc.channels_out==1)for(i=0;i<nsamples;++i){in_buffer[0][i]=0.5*(in_buffer[0][i]+in_buffer[1][i]);in_buffer[1][i]=0.0;}mf_needed=calcNeeded(gfp);mfbuf[0]=gfc.mfbuf[0];mfbuf[1]=gfc.mfbuf[1];var in_bufferPos=0;while(nsamples>0){var in_buffer_ptr=[null,null];var n_in=0;/* number of input samples processed with fill_buffer */var n_out=0;/* number of samples output with fill_buffer */ /* n_in <> n_out if we are resampling */in_buffer_ptr[0]=in_buffer[0];in_buffer_ptr[1]=in_buffer[1];/* copy in new samples into mfbuf, with resampling */var inOut=new InOut();fill_buffer(gfp,mfbuf,in_buffer_ptr,in_bufferPos,nsamples,inOut);n_in=inOut.n_in;n_out=inOut.n_out;/* compute ReplayGain of resampled input if requested */if(gfc.findReplayGain&&!gfc.decode_on_the_fly){if(ga.AnalyzeSamples(gfc.rgdata,mfbuf[0],gfc.mf_size,mfbuf[1],gfc.mf_size,n_out,gfc.channels_out)==GainAnalysis.GAIN_ANALYSIS_ERROR)return -6;}/* update in_buffer counters */nsamples-=n_in;in_bufferPos+=n_in;gfc.channels_out;// in_bufferPos += n_in;
216
+ /* update mfbuf[] counters */gfc.mf_size+=n_out;$ecb6e13812bdc08b$var$assert(gfc.mf_size<=$4SDnr.MFSIZE);/*
217
+ * lame_encode_flush may have set gfc.mf_sample_to_encode to 0 so we
218
+ * have to reinitialize it here when that happened.
219
+ */if(gfc.mf_samples_to_encode<1)gfc.mf_samples_to_encode=$cPNKB.ENCDELAY+$cPNKB.POSTDELAY;gfc.mf_samples_to_encode+=n_out;if(gfc.mf_size>=mf_needed){/* encode the frame. */ /* mp3buf = pointer to current location in buffer */ /* mp3buf_size = size of original mp3 output buffer */ /* = 0 if we should not worry about the */ /* buffer size because calling program is */ /* to lazy to compute it */ /* mp3size = size of data written to buffer so far */ /* mp3buf_size-mp3size = amount of space avalable */var buf_size=mp3buf_size-mp3size;if(mp3buf_size==0)buf_size=0;ret=lame_encode_frame(gfp,mfbuf[0],mfbuf[1],mp3buf,mp3bufPos,buf_size);if(ret<0)return ret;mp3bufPos+=ret;mp3size+=ret;/* shift out old samples */gfc.mf_size-=gfp.framesize;gfc.mf_samples_to_encode-=gfp.framesize;for(ch=0;ch<gfc.channels_out;ch++)for(i=0;i<gfc.mf_size;i++)mfbuf[ch][i]=mfbuf[ch][i+gfp.framesize];}}$ecb6e13812bdc08b$var$assert(nsamples==0);return mp3size;}function lame_encode_frame(gfp,inbuf_l,inbuf_r,mp3buf,mp3bufPos,mp3buf_size){var ret=self.enc.lame_encode_mp3_frame(gfp,inbuf_l,inbuf_r,mp3buf,mp3bufPos,mp3buf_size);gfp.frameNum++;return ret;}function InOut(){this.n_in=0;this.n_out=0;}function NumUsed(){this.num_used=0;}/**
220
+ * Greatest common divisor.
221
+ * <p>
222
+ * Joint work of Euclid and M. Hendry
223
+ */function gcd(i,j){return j!=0?gcd(j,i%j):i;}/**
224
+ * Resampling via FIR filter, blackman window.
225
+ */function blackman(x,fcn,l){/*
226
+ * This algorithm from: SIGNAL PROCESSING ALGORITHMS IN FORTRAN AND C
227
+ * S.D. Stearns and R.A. David, Prentice-Hall, 1992
228
+ */var wcn=Math.PI*fcn;x/=l;if(x<0)x=0;if(x>1)x=1;var x2=x-.5;var bkwn=0.42-0.5*Math.cos(2*x*Math.PI)+0.08*Math.cos(4*x*Math.PI);if(Math.abs(x2)<1e-9)return wcn/Math.PI;else return bkwn*Math.sin(l*wcn*x2)/(Math.PI*l*x2);}function fill_buffer_resample(gfp,outbuf,outbufPos,desired_len,inbuf,in_bufferPos,len,num_used,ch){var gfc=gfp.internal_flags;var i,j=0,k;/* number of convolution functions to pre-compute */var bpc=gfp.out_samplerate/gcd(gfp.out_samplerate,gfp.in_samplerate);if(bpc>$4SDnr.BPC)bpc=$4SDnr.BPC;var intratio=Math.abs(gfc.resample_ratio-Math.floor(.5+gfc.resample_ratio))<.0001?1:0;var fcn=1.00/gfc.resample_ratio;if(fcn>1.00)fcn=1.00;var filter_l=31;if(0==filter_l%2)--filter_l;/* must be odd */filter_l+=intratio;/* unless resample_ratio=int, it must be even */var BLACKSIZE=filter_l+1;/* size of data needed for FIR */if(gfc.fill_buffer_resample_init==0){gfc.inbuf_old[0]=$ecb6e13812bdc08b$var$new_float(BLACKSIZE);gfc.inbuf_old[1]=$ecb6e13812bdc08b$var$new_float(BLACKSIZE);for(i=0;i<=2*bpc;++i)gfc.blackfilt[i]=$ecb6e13812bdc08b$var$new_float(BLACKSIZE);gfc.itime[0]=0;gfc.itime[1]=0;/* precompute blackman filter coefficients */for(j=0;j<=2*bpc;j++){var sum=0.;var offset=(j-bpc)/(2.*bpc);for(i=0;i<=filter_l;i++)sum+=gfc.blackfilt[j][i]=blackman(i-offset,fcn,filter_l);for(i=0;i<=filter_l;i++)gfc.blackfilt[j][i]/=sum;}gfc.fill_buffer_resample_init=1;}var inbuf_old=gfc.inbuf_old[ch];/* time of j'th element in inbuf = itime + j/ifreq; */ /* time of k'th element in outbuf = j/ofreq */for(k=0;k<desired_len;k++){var time0;var joff;time0=k*gfc.resample_ratio;/* time of k'th output sample */j=0|Math.floor(time0-gfc.itime[ch]);/* check if we need more input data */if(filter_l+j-filter_l/2>=len)break;/* blackman filter. by default, window centered at j+.5(filter_l%2) */ /* but we want a window centered at time0. */var offset=time0-gfc.itime[ch]-(j+.5*(filter_l%2));$ecb6e13812bdc08b$var$assert(Math.abs(offset)<=.501);/* find the closest precomputed window for this offset: */joff=0|Math.floor(offset*2*bpc+bpc+.5);var xvalue=0.;for(i=0;i<=filter_l;++i){/* force integer index */var j2=0|i+j-filter_l/2;var y;$ecb6e13812bdc08b$var$assert(j2<len);$ecb6e13812bdc08b$var$assert(j2+BLACKSIZE>=0);y=j2<0?inbuf_old[BLACKSIZE+j2]:inbuf[in_bufferPos+j2];xvalue+=y*gfc.blackfilt[joff][i];}outbuf[outbufPos+k]=xvalue;}/* k = number of samples added to outbuf */ /* last k sample used data from [j-filter_l/2,j+filter_l-filter_l/2] */ /* how many samples of input data were used: */num_used.num_used=Math.min(len,filter_l+j-filter_l/2);/*
229
+ * adjust our input time counter. Incriment by the number of samples
230
+ * used, then normalize so that next output sample is at time 0, next
231
+ * input buffer is at time itime[ch]
232
+ */gfc.itime[ch]+=num_used.num_used-k*gfc.resample_ratio;/* save the last BLACKSIZE samples into the inbuf_old buffer */if(num_used.num_used>=BLACKSIZE)for(i=0;i<BLACKSIZE;i++)inbuf_old[i]=inbuf[in_bufferPos+num_used.num_used+i-BLACKSIZE];else {/* shift in num_used.num_used samples into inbuf_old */var n_shift=BLACKSIZE-num_used.num_used;/*
233
+ * number of samples to
234
+ * shift
235
+ */ /*
236
+ * shift n_shift samples by num_used.num_used, to make room for the
237
+ * num_used new samples
238
+ */for(i=0;i<n_shift;++i)inbuf_old[i]=inbuf_old[i+num_used.num_used];/* shift in the num_used.num_used samples */for(j=0;i<BLACKSIZE;++i,++j)inbuf_old[i]=inbuf[in_bufferPos+j];$ecb6e13812bdc08b$var$assert(j==num_used.num_used);}return k;/* return the number samples created at the new samplerate */}function fill_buffer(gfp,mfbuf,in_buffer,in_bufferPos,nsamples,io){var gfc=gfp.internal_flags;/* copy in new samples into mfbuf, with resampling if necessary */if(gfc.resample_ratio<.9999||gfc.resample_ratio>1.0001)for(var ch=0;ch<gfc.channels_out;ch++){var numUsed=new NumUsed();io.n_out=fill_buffer_resample(gfp,mfbuf[ch],gfc.mf_size,gfp.framesize,in_buffer[ch],in_bufferPos,nsamples,numUsed,ch);io.n_in=numUsed.num_used;}else {io.n_out=Math.min(gfp.framesize,nsamples);io.n_in=io.n_out;for(var i=0;i<io.n_out;++i){mfbuf[0][gfc.mf_size+i]=in_buffer[0][in_bufferPos+i];if(gfc.channels_out==2)mfbuf[1][gfc.mf_size+i]=in_buffer[1][in_bufferPos+i];}}}}module.exports=$ecb6e13812bdc08b$var$Lame;});parcelRequire.register("3YDN3",function(module,exports){function $2e55d7364d01815c$var$new_byte(count){return new Int8Array(count);}function $2e55d7364d01815c$var$new_short(count){return new Int16Array(count);}function $2e55d7364d01815c$var$new_int(count){return new Int32Array(count);}function $2e55d7364d01815c$var$new_float(count){return new Float32Array(count);}function $2e55d7364d01815c$var$new_double(count){return new Float64Array(count);}function $2e55d7364d01815c$var$new_float_n(args){if(args.length==1)return $2e55d7364d01815c$var$new_float(args[0]);var sz=args[0];args=args.slice(1);var A=[];for(var i=0;i<sz;i++)A.push($2e55d7364d01815c$var$new_float_n(args));return A;}function $2e55d7364d01815c$var$new_int_n(args){if(args.length==1)return $2e55d7364d01815c$var$new_int(args[0]);var sz=args[0];args=args.slice(1);var A=[];for(var i=0;i<sz;i++)A.push($2e55d7364d01815c$var$new_int_n(args));return A;}function $2e55d7364d01815c$var$new_short_n(args){if(args.length==1)return $2e55d7364d01815c$var$new_short(args[0]);var sz=args[0];args=args.slice(1);var A=[];for(var i=0;i<sz;i++)A.push($2e55d7364d01815c$var$new_short_n(args));return A;}function $2e55d7364d01815c$var$new_array_n(args){if(args.length==1)return new Array(args[0]);var sz=args[0];args=args.slice(1);var A=[];for(var i=0;i<sz;i++)A.push($2e55d7364d01815c$var$new_array_n(args));return A;}var $2e55d7364d01815c$var$Arrays={};$2e55d7364d01815c$var$Arrays.fill=function(a,fromIndex,toIndex,val){if(arguments.length==2)for(var i=0;i<a.length;i++)a[i]=arguments[1];else for(var i=fromIndex;i<toIndex;i++)a[i]=val;};var $2e55d7364d01815c$var$System={};$2e55d7364d01815c$var$System.arraycopy=function(src,srcPos,dest,destPos,length){var srcEnd=srcPos+length;while(srcPos<srcEnd)dest[destPos++]=src[srcPos++];};$2e55d7364d01815c$var$System.out={};$2e55d7364d01815c$var$System.out.println=function(message){console.log(message);};$2e55d7364d01815c$var$System.out.printf=function(){console.log.apply(console,arguments);};var $2e55d7364d01815c$var$Util={};$2e55d7364d01815c$var$Util.SQRT2=1.41421356237309504880;$2e55d7364d01815c$var$Util.FAST_LOG10=function(x){return Math.log10(x);};$2e55d7364d01815c$var$Util.FAST_LOG10_X=function(x,y){return Math.log10(x)*y;};function $2e55d7364d01815c$var$ShortBlock(ordinal){this.ordinal=ordinal;}/**
239
+ * LAME may use them, even different block types for L/R.
240
+ */$2e55d7364d01815c$var$ShortBlock.short_block_allowed=new $2e55d7364d01815c$var$ShortBlock(0);/**
241
+ * LAME may use them, but always same block types in L/R.
242
+ */$2e55d7364d01815c$var$ShortBlock.short_block_coupled=new $2e55d7364d01815c$var$ShortBlock(1);/**
243
+ * LAME will not use short blocks, long blocks only.
244
+ */$2e55d7364d01815c$var$ShortBlock.short_block_dispensed=new $2e55d7364d01815c$var$ShortBlock(2);/**
245
+ * LAME will not use long blocks, short blocks only.
246
+ */$2e55d7364d01815c$var$ShortBlock.short_block_forced=new $2e55d7364d01815c$var$ShortBlock(3);var $2e55d7364d01815c$var$Float={};$2e55d7364d01815c$var$Float.MAX_VALUE=3.4028235e+38;function $2e55d7364d01815c$var$VbrMode(ordinal){this.ordinal=ordinal;}$2e55d7364d01815c$var$VbrMode.vbr_off=new $2e55d7364d01815c$var$VbrMode(0);$2e55d7364d01815c$var$VbrMode.vbr_mt=new $2e55d7364d01815c$var$VbrMode(1);$2e55d7364d01815c$var$VbrMode.vbr_rh=new $2e55d7364d01815c$var$VbrMode(2);$2e55d7364d01815c$var$VbrMode.vbr_abr=new $2e55d7364d01815c$var$VbrMode(3);$2e55d7364d01815c$var$VbrMode.vbr_mtrh=new $2e55d7364d01815c$var$VbrMode(4);$2e55d7364d01815c$var$VbrMode.vbr_default=$2e55d7364d01815c$var$VbrMode.vbr_mtrh;var $2e55d7364d01815c$var$assert=function(x){//console.assert(x);
247
+ };module.exports={"System":$2e55d7364d01815c$var$System,"VbrMode":$2e55d7364d01815c$var$VbrMode,"Float":$2e55d7364d01815c$var$Float,"ShortBlock":$2e55d7364d01815c$var$ShortBlock,"Util":$2e55d7364d01815c$var$Util,"Arrays":$2e55d7364d01815c$var$Arrays,"new_array_n":$2e55d7364d01815c$var$new_array_n,"new_byte":$2e55d7364d01815c$var$new_byte,"new_double":$2e55d7364d01815c$var$new_double,"new_float":$2e55d7364d01815c$var$new_float,"new_float_n":$2e55d7364d01815c$var$new_float_n,"new_int":$2e55d7364d01815c$var$new_int,"new_int_n":$2e55d7364d01815c$var$new_int_n,"new_short":$2e55d7364d01815c$var$new_short,"new_short_n":$2e55d7364d01815c$var$new_short_n,"assert":$2e55d7364d01815c$var$assert};});parcelRequire.register("d2VP0",function(module,exports){/*
248
+ * psymodel.c
249
+ *
250
+ * Copyright (c) 1999-2000 Mark Taylor
251
+ * Copyright (c) 2001-2002 Naoki Shibata
252
+ * Copyright (c) 2000-2003 Takehiro Tominaga
253
+ * Copyright (c) 2000-2008 Robert Hegemann
254
+ * Copyright (c) 2000-2005 Gabriel Bouvigne
255
+ * Copyright (c) 2000-2005 Alexander Leidinger
256
+ *
257
+ * This library is free software; you can redistribute it and/or
258
+ * modify it under the terms of the GNU Lesser General Public
259
+ * License as published by the Free Software Foundation; either
260
+ * version 2 of the License, or (at your option) any later version.
261
+ *
262
+ * This library is distributed in the hope that it will be useful,
263
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
264
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
265
+ * Library General Public License for more details.
266
+ *
267
+ * You should have received a copy of the GNU Lesser General Public
268
+ * License along with this library; if not, write to the
269
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
270
+ * Boston, MA 02111-1307, USA.
271
+ */ /* $Id: PsyModel.java,v 1.27 2011/05/24 20:48:06 kenchis Exp $ */ /*
272
+ PSYCHO ACOUSTICS
273
+
274
+
275
+ This routine computes the psycho acoustics, delayed by one granule.
276
+
277
+ Input: buffer of PCM data (1024 samples).
278
+
279
+ This window should be centered over the 576 sample granule window.
280
+ The routine will compute the psycho acoustics for
281
+ this granule, but return the psycho acoustics computed
282
+ for the *previous* granule. This is because the block
283
+ type of the previous granule can only be determined
284
+ after we have computed the psycho acoustics for the following
285
+ granule.
286
+
287
+ Output: maskings and energies for each scalefactor band.
288
+ block type, PE, and some correlation measures.
289
+ The PE is used by CBR modes to determine if extra bits
290
+ from the bit reservoir should be used. The correlation
291
+ measures are used to determine mid/side or regular stereo.
292
+ */ /*
293
+ Notation:
294
+
295
+ barks: a non-linear frequency scale. Mapping from frequency to
296
+ barks is given by freq2bark()
297
+
298
+ scalefactor bands: The spectrum (frequencies) are broken into
299
+ SBMAX "scalefactor bands". Thes bands
300
+ are determined by the MPEG ISO spec. In
301
+ the noise shaping/quantization code, we allocate
302
+ bits among the partition bands to achieve the
303
+ best possible quality
304
+
305
+ partition bands: The spectrum is also broken into about
306
+ 64 "partition bands". Each partition
307
+ band is about .34 barks wide. There are about 2-5
308
+ partition bands for each scalefactor band.
309
+
310
+ LAME computes all psycho acoustic information for each partition
311
+ band. Then at the end of the computations, this information
312
+ is mapped to scalefactor bands. The energy in each scalefactor
313
+ band is taken as the sum of the energy in all partition bands
314
+ which overlap the scalefactor band. The maskings can be computed
315
+ in the same way (and thus represent the average masking in that band)
316
+ or by taking the minmum value multiplied by the number of
317
+ partition bands used (which represents a minimum masking in that band).
318
+ */ /*
319
+ The general outline is as follows:
320
+
321
+ 1. compute the energy in each partition band
322
+ 2. compute the tonality in each partition band
323
+ 3. compute the strength of each partion band "masker"
324
+ 4. compute the masking (via the spreading function applied to each masker)
325
+ 5. Modifications for mid/side masking.
326
+
327
+ Each partition band is considiered a "masker". The strength
328
+ of the i'th masker in band j is given by:
329
+
330
+ s3(bark(i)-bark(j))*strength(i)
331
+
332
+ The strength of the masker is a function of the energy and tonality.
333
+ The more tonal, the less masking. LAME uses a simple linear formula
334
+ (controlled by NMT and TMN) which says the strength is given by the
335
+ energy divided by a linear function of the tonality.
336
+ */ /*
337
+ s3() is the "spreading function". It is given by a formula
338
+ determined via listening tests.
339
+
340
+ The total masking in the j'th partition band is the sum over
341
+ all maskings i. It is thus given by the convolution of
342
+ the strength with s3(), the "spreading function."
343
+
344
+ masking(j) = sum_over_i s3(i-j)*strength(i) = s3 o strength
345
+
346
+ where "o" = convolution operator. s3 is given by a formula determined
347
+ via listening tests. It is normalized so that s3 o 1 = 1.
348
+
349
+ Note: instead of a simple convolution, LAME also has the
350
+ option of using "additive masking"
351
+
352
+ The most critical part is step 2, computing the tonality of each
353
+ partition band. LAME has two tonality estimators. The first
354
+ is based on the ISO spec, and measures how predictiable the
355
+ signal is over time. The more predictable, the more tonal.
356
+ The second measure is based on looking at the spectrum of
357
+ a single granule. The more peaky the spectrum, the more
358
+ tonal. By most indications, the latter approach is better.
359
+
360
+ Finally, in step 5, the maskings for the mid and side
361
+ channel are possibly increased. Under certain circumstances,
362
+ noise in the mid & side channels is assumed to also
363
+ be masked by strong maskers in the L or R channels.
364
+
365
+
366
+ Other data computed by the psy-model:
367
+
368
+ ms_ratio side-channel / mid-channel masking ratio (for previous granule)
369
+ ms_ratio_next side-channel / mid-channel masking ratio for this granule
370
+
371
+ percep_entropy[2] L and R values (prev granule) of PE - A measure of how
372
+ much pre-echo is in the previous granule
373
+ percep_entropy_MS[2] mid and side channel values (prev granule) of percep_entropy
374
+ energy[4] L,R,M,S energy in each channel, prev granule
375
+ blocktype_d[2] block type to use for previous granule
376
+ */ //package mp3;
377
+ //import java.util.Arrays;
378
+ var $3YDN3=parcelRequire("3YDN3");$3YDN3.System;var $97f850779472263e$var$VbrMode=$3YDN3.VbrMode;var $97f850779472263e$var$Float=$3YDN3.Float;var $97f850779472263e$var$ShortBlock=$3YDN3.ShortBlock;var $97f850779472263e$var$Util=$3YDN3.Util;var $97f850779472263e$var$Arrays=$3YDN3.Arrays;$3YDN3.new_array_n;$3YDN3.new_byte;$3YDN3.new_double;var $97f850779472263e$var$new_float=$3YDN3.new_float;var $97f850779472263e$var$new_float_n=$3YDN3.new_float_n;var $97f850779472263e$var$new_int=$3YDN3.new_int;$3YDN3.new_int_n;var $97f850779472263e$var$assert=$3YDN3.assert;var $2g11P=parcelRequire("2g11P");var $cPNKB=parcelRequire("cPNKB");function $97f850779472263e$var$PsyModel(){var MPEGMode=parcelRequire("jL6I1");var fft=new $2g11P();var LOG10=2.30258509299404568402;var rpelev=2;var rpelev2=16;var rpelev_s=2;var rpelev2_s=16;/* size of each partition band, in barks: */var DELBARK=.34;/* tuned for output level (sensitive to energy scale) */var VO_SCALE=1./217621504/($cPNKB.BLKSIZE/2);var temporalmask_sustain_sec=0.01;var NS_PREECHO_ATT0=0.8;var NS_PREECHO_ATT1=0.6;var NS_PREECHO_ATT2=0.3;var NS_MSFIX=3.5;var NSFIRLEN=21;/* size of each partition band, in barks: */var LN_TO_LOG10=0.2302585093;function NON_LINEAR_SCALE_ENERGY(x){return x;}/**
379
+ * <PRE>
380
+ * L3psycho_anal. Compute psycho acoustics.
381
+ *
382
+ * Data returned to the calling program must be delayed by one
383
+ * granule.
384
+ *
385
+ * This is done in two places.
386
+ * If we do not need to know the blocktype, the copying
387
+ * can be done here at the top of the program: we copy the data for
388
+ * the last granule (computed during the last call) before it is
389
+ * overwritten with the new data. It looks like this:
390
+ *
391
+ * 0. static psymodel_data
392
+ * 1. calling_program_data = psymodel_data
393
+ * 2. compute psymodel_data
394
+ *
395
+ * For data which needs to know the blocktype, the copying must be
396
+ * done at the end of this loop, and the old values must be saved:
397
+ *
398
+ * 0. static psymodel_data_old
399
+ * 1. compute psymodel_data
400
+ * 2. compute possible block type of this granule
401
+ * 3. compute final block type of previous granule based on #2.
402
+ * 4. calling_program_data = psymodel_data_old
403
+ * 5. psymodel_data_old = psymodel_data
404
+ * psycho_loudness_approx
405
+ * jd - 2001 mar 12
406
+ * in: energy - BLKSIZE/2 elements of frequency magnitudes ^ 2
407
+ * gfp - uses out_samplerate, ATHtype (also needed for ATHformula)
408
+ * returns: loudness^2 approximation, a positive value roughly tuned for a value
409
+ * of 1.0 for signals near clipping.
410
+ * notes: When calibrated, feeding this function binary white noise at sample
411
+ * values +32767 or -32768 should return values that approach 3.
412
+ * ATHformula is used to approximate an equal loudness curve.
413
+ * future: Data indicates that the shape of the equal loudness curve varies
414
+ * with intensity. This function might be improved by using an equal
415
+ * loudness curve shaped for typical playback levels (instead of the
416
+ * ATH, that is shaped for the threshold). A flexible realization might
417
+ * simply bend the existing ATH curve to achieve the desired shape.
418
+ * However, the potential gain may not be enough to justify an effort.
419
+ * </PRE>
420
+ */function psycho_loudness_approx(energy,gfc){var loudness_power=0.0;/* apply weights to power in freq. bands */for(var i=0;i<$cPNKB.BLKSIZE/2;++i)loudness_power+=energy[i]*gfc.ATH.eql_w[i];loudness_power*=VO_SCALE;return loudness_power;}function compute_ffts(gfp,fftenergy,fftenergy_s,wsamp_l,wsamp_lPos,wsamp_s,wsamp_sPos,gr_out,chn,buffer,bufPos){var gfc=gfp.internal_flags;if(chn<2){fft.fft_long(gfc,wsamp_l[wsamp_lPos],chn,buffer,bufPos);fft.fft_short(gfc,wsamp_s[wsamp_sPos],chn,buffer,bufPos);}else if(chn==2){for(var j=$cPNKB.BLKSIZE-1;j>=0;--j){var l=wsamp_l[wsamp_lPos+0][j];var r=wsamp_l[wsamp_lPos+1][j];wsamp_l[wsamp_lPos+0][j]=(l+r)*$97f850779472263e$var$Util.SQRT2*0.5;wsamp_l[wsamp_lPos+1][j]=(l-r)*$97f850779472263e$var$Util.SQRT2*0.5;}for(var b=2;b>=0;--b)for(var j=$cPNKB.BLKSIZE_s-1;j>=0;--j){var l=wsamp_s[wsamp_sPos+0][b][j];var r=wsamp_s[wsamp_sPos+1][b][j];wsamp_s[wsamp_sPos+0][b][j]=(l+r)*$97f850779472263e$var$Util.SQRT2*0.5;wsamp_s[wsamp_sPos+1][b][j]=(l-r)*$97f850779472263e$var$Util.SQRT2*0.5;}}/*********************************************************************
421
+ * compute energies
422
+ *********************************************************************/fftenergy[0]=NON_LINEAR_SCALE_ENERGY(wsamp_l[wsamp_lPos+0][0]);fftenergy[0]*=fftenergy[0];for(var j=$cPNKB.BLKSIZE/2-1;j>=0;--j){var re=wsamp_l[wsamp_lPos+0][$cPNKB.BLKSIZE/2-j];var im=wsamp_l[wsamp_lPos+0][$cPNKB.BLKSIZE/2+j];fftenergy[$cPNKB.BLKSIZE/2-j]=NON_LINEAR_SCALE_ENERGY((re*re+im*im)*0.5);}for(var b=2;b>=0;--b){fftenergy_s[b][0]=wsamp_s[wsamp_sPos+0][b][0];fftenergy_s[b][0]*=fftenergy_s[b][0];for(var j=$cPNKB.BLKSIZE_s/2-1;j>=0;--j){var re=wsamp_s[wsamp_sPos+0][b][$cPNKB.BLKSIZE_s/2-j];var im=wsamp_s[wsamp_sPos+0][b][$cPNKB.BLKSIZE_s/2+j];fftenergy_s[b][$cPNKB.BLKSIZE_s/2-j]=NON_LINEAR_SCALE_ENERGY((re*re+im*im)*0.5);}}var totalenergy=0.0;for(var j=11;j<$cPNKB.HBLKSIZE;j++)totalenergy+=fftenergy[j];gfc.tot_ener[chn]=totalenergy;if(gfp.analysis){for(var j=0;j<$cPNKB.HBLKSIZE;j++){gfc.pinfo.energy[gr_out][chn][j]=gfc.pinfo.energy_save[chn][j];gfc.pinfo.energy_save[chn][j]=fftenergy[j];}gfc.pinfo.pe[gr_out][chn]=gfc.pe[chn];}/*********************************************************************
423
+ * compute loudness approximation (used for ATH auto-level adjustment)
424
+ *********************************************************************/if(gfp.athaa_loudapprox==2&&chn<2){// no loudness for mid/side ch
425
+ gfc.loudness_sq[gr_out][chn]=gfc.loudness_sq_save[chn];gfc.loudness_sq_save[chn]=psycho_loudness_approx(fftenergy,gfc);}}/* mask_add optimization */ /* init the limit values used to avoid computing log in mask_add when it is not necessary */ /**
426
+ * <PRE>
427
+ * For example, with i = 10*log10(m2/m1)/10*16 (= log10(m2/m1)*16)
428
+ *
429
+ * abs(i)>8 is equivalent (as i is an integer) to
430
+ * abs(i)>=9
431
+ * i>=9 || i<=-9
432
+ * equivalent to (as i is the biggest integer smaller than log10(m2/m1)*16
433
+ * or the smallest integer bigger than log10(m2/m1)*16 depending on the sign of log10(m2/m1)*16)
434
+ * log10(m2/m1)>=9/16 || log10(m2/m1)<=-9/16
435
+ * exp10 is strictly increasing thus this is equivalent to
436
+ * m2/m1 >= 10^(9/16) || m2/m1<=10^(-9/16) which are comparisons to constants
437
+ * </PRE>
438
+ */ /**
439
+ * as in if(i>8)
440
+ */var I1LIMIT=8;/**
441
+ * as in if(i>24) . changed 23
442
+ */var I2LIMIT=23;/**
443
+ * as in if(m<15)
444
+ */var MLIMIT=15;var ma_max_i1;var ma_max_i2;var ma_max_m;/**
445
+ * This is the masking table:<BR>
446
+ * According to tonality, values are going from 0dB (TMN) to 9.3dB (NMT).<BR>
447
+ * After additive masking computation, 8dB are added, so final values are
448
+ * going from 8dB to 17.3dB
449
+ *
450
+ * pow(10, -0.0..-0.6)
451
+ */var tab=[1.0,0.79433,0.63096,0.63096,0.63096,0.63096,0.63096,0.25119,0.11749];function init_mask_add_max_values(){ma_max_i1=Math.pow(10,(I1LIMIT+1)/16.0);ma_max_i2=Math.pow(10,(I2LIMIT+1)/16.0);ma_max_m=Math.pow(10,MLIMIT/10.0);}var table1=[3.3246*3.3246,3.23837*3.23837,9.9500500969,9.0247369744,8.1854926609,7.0440875649,2.46209*2.46209,2.284*2.284,4.4892710641,1.96552*1.96552,1.82335*1.82335,1.69146*1.69146,2.4621061921,2.1508568964,1.37074*1.37074,1.31036*1.31036,1.5691069696,1.4555939904,1.16203*1.16203,1.2715945225,1.09428*1.09428,1.0659*1.0659,1.0779838276,1.0382591025,1];var table2=[1.7782755904,1.35879*1.35879,1.38454*1.38454,1.39497*1.39497,1.40548*1.40548,1.3537*1.3537,1.6999465924,1.22321*1.22321,1.3169398564,1];var table3=[5.5396212496,2.29259*2.29259,4.9868695969,2.12675*2.12675,2.02545*2.02545,1.87894*1.87894,1.74303*1.74303,1.61695*1.61695,2.2499700001,1.39148*1.39148,1.29083*1.29083,1.19746*1.19746,1.2339655056,1.0779838276];/**
452
+ * addition of simultaneous masking Naoki Shibata 2000/7
453
+ */function mask_add(m1,m2,kk,b,gfc,shortblock){var ratio;if(m2>m1){if(m2<m1*ma_max_i2)ratio=m2/m1;else return m1+m2;}else {if(m1>=m2*ma_max_i2)return m1+m2;ratio=m1/m2;}/* Should always be true, just checking */$97f850779472263e$var$assert(m1>=0);$97f850779472263e$var$assert(m2>=0);m1+=m2;//if (((long)(b + 3) & 0xffffffff) <= 3 + 3) {
454
+ if(b+3<=6){/* approximately, 1 bark = 3 partitions */ /* 65% of the cases */ /* originally 'if(i > 8)' */if(ratio>=ma_max_i1)/* 43% of the total */return m1;/* 22% of the total */var i=0|$97f850779472263e$var$Util.FAST_LOG10_X(ratio,16.0);return m1*table2[i];}/**
455
+ * <PRE>
456
+ * m<15 equ log10((m1+m2)/gfc.ATH.cb[k])<1.5
457
+ * equ (m1+m2)/gfc.ATH.cb[k]<10^1.5
458
+ * equ (m1+m2)<10^1.5 * gfc.ATH.cb[k]
459
+ * </PRE>
460
+ */var i=0|$97f850779472263e$var$Util.FAST_LOG10_X(ratio,16.0);if(shortblock!=0)m2=gfc.ATH.cb_s[kk]*gfc.ATH.adjust;else m2=gfc.ATH.cb_l[kk]*gfc.ATH.adjust;$97f850779472263e$var$assert(m2>=0);if(m1<ma_max_m*m2){/* 3% of the total */ /* Originally if (m > 0) { */if(m1>m2){var f,r;f=1.0;if(i<=13)f=table3[i];r=$97f850779472263e$var$Util.FAST_LOG10_X(m1/m2,10.0/15.0);return m1*((table1[i]-f)*r+f);}if(i>13)return m1;return m1*table3[i];}/* 10% of total */return m1*table1[i];}var table2_=[1.7782755904,1.35879*1.35879,1.38454*1.38454,1.39497*1.39497,1.40548*1.40548,1.3537*1.3537,1.6999465924,1.22321*1.22321,1.3169398564,1];/**
461
+ * addition of simultaneous masking Naoki Shibata 2000/7
462
+ */function vbrpsy_mask_add(m1,m2,b){var ratio;if(m1<0)m1=0;if(m2<0)m2=0;if(m1<=0)return m2;if(m2<=0)return m1;if(m2>m1)ratio=m2/m1;else ratio=m1/m2;if(-2<=b&&b<=2){/* approximately, 1 bark = 3 partitions */ /* originally 'if(i > 8)' */if(ratio>=ma_max_i1)return m1+m2;else {var i=0|$97f850779472263e$var$Util.FAST_LOG10_X(ratio,16.0);return (m1+m2)*table2_[i];}}if(ratio<ma_max_i2)return m1+m2;if(m1<m2)m1=m2;return m1;}/**
463
+ * compute interchannel masking effects
464
+ */function calc_interchannel_masking(gfp,ratio){var gfc=gfp.internal_flags;if(gfc.channels_out>1){for(var sb=0;sb<$cPNKB.SBMAX_l;sb++){var l=gfc.thm[0].l[sb];var r=gfc.thm[1].l[sb];gfc.thm[0].l[sb]+=r*ratio;gfc.thm[1].l[sb]+=l*ratio;}for(var sb=0;sb<$cPNKB.SBMAX_s;sb++)for(var sblock=0;sblock<3;sblock++){var l=gfc.thm[0].s[sb][sblock];var r=gfc.thm[1].s[sb][sblock];gfc.thm[0].s[sb][sblock]+=r*ratio;gfc.thm[1].s[sb][sblock]+=l*ratio;}}}/**
465
+ * compute M/S thresholds from Johnston & Ferreira 1992 ICASSP paper
466
+ */function msfix1(gfc){for(var sb=0;sb<$cPNKB.SBMAX_l;sb++){/* use this fix if L & R masking differs by 2db or less */ /* if db = 10*log10(x2/x1) < 2 */ /* if (x2 < 1.58*x1) { */if(gfc.thm[0].l[sb]>1.58*gfc.thm[1].l[sb]||gfc.thm[1].l[sb]>1.58*gfc.thm[0].l[sb])continue;var mld=gfc.mld_l[sb]*gfc.en[3].l[sb];var rmid=Math.max(gfc.thm[2].l[sb],Math.min(gfc.thm[3].l[sb],mld));mld=gfc.mld_l[sb]*gfc.en[2].l[sb];var rside=Math.max(gfc.thm[3].l[sb],Math.min(gfc.thm[2].l[sb],mld));gfc.thm[2].l[sb]=rmid;gfc.thm[3].l[sb]=rside;}for(var sb=0;sb<$cPNKB.SBMAX_s;sb++)for(var sblock=0;sblock<3;sblock++){if(gfc.thm[0].s[sb][sblock]>1.58*gfc.thm[1].s[sb][sblock]||gfc.thm[1].s[sb][sblock]>1.58*gfc.thm[0].s[sb][sblock])continue;var mld=gfc.mld_s[sb]*gfc.en[3].s[sb][sblock];var rmid=Math.max(gfc.thm[2].s[sb][sblock],Math.min(gfc.thm[3].s[sb][sblock],mld));mld=gfc.mld_s[sb]*gfc.en[2].s[sb][sblock];var rside=Math.max(gfc.thm[3].s[sb][sblock],Math.min(gfc.thm[2].s[sb][sblock],mld));gfc.thm[2].s[sb][sblock]=rmid;gfc.thm[3].s[sb][sblock]=rside;}}/**
467
+ * Adjust M/S maskings if user set "msfix"
468
+ *
469
+ * Naoki Shibata 2000
470
+ */function ns_msfix(gfc,msfix,athadjust){var msfix2=msfix;var athlower=Math.pow(10,athadjust);msfix*=2.0;msfix2*=2.0;for(var sb=0;sb<$cPNKB.SBMAX_l;sb++){var thmLR,thmM,thmS,ath;ath=gfc.ATH.cb_l[gfc.bm_l[sb]]*athlower;thmLR=Math.min(Math.max(gfc.thm[0].l[sb],ath),Math.max(gfc.thm[1].l[sb],ath));thmM=Math.max(gfc.thm[2].l[sb],ath);thmS=Math.max(gfc.thm[3].l[sb],ath);if(thmLR*msfix<thmM+thmS){var f=thmLR*msfix2/(thmM+thmS);thmM*=f;thmS*=f;$97f850779472263e$var$assert(thmM+thmS>0);}gfc.thm[2].l[sb]=Math.min(thmM,gfc.thm[2].l[sb]);gfc.thm[3].l[sb]=Math.min(thmS,gfc.thm[3].l[sb]);}athlower*=$cPNKB.BLKSIZE_s/$cPNKB.BLKSIZE;for(var sb=0;sb<$cPNKB.SBMAX_s;sb++)for(var sblock=0;sblock<3;sblock++){var thmLR,thmM,thmS,ath;ath=gfc.ATH.cb_s[gfc.bm_s[sb]]*athlower;thmLR=Math.min(Math.max(gfc.thm[0].s[sb][sblock],ath),Math.max(gfc.thm[1].s[sb][sblock],ath));thmM=Math.max(gfc.thm[2].s[sb][sblock],ath);thmS=Math.max(gfc.thm[3].s[sb][sblock],ath);if(thmLR*msfix<thmM+thmS){var f=thmLR*msfix/(thmM+thmS);thmM*=f;thmS*=f;$97f850779472263e$var$assert(thmM+thmS>0);}gfc.thm[2].s[sb][sblock]=Math.min(gfc.thm[2].s[sb][sblock],thmM);gfc.thm[3].s[sb][sblock]=Math.min(gfc.thm[3].s[sb][sblock],thmS);}}/**
471
+ * short block threshold calculation (part 2)
472
+ *
473
+ * partition band bo_s[sfb] is at the transition from scalefactor band sfb
474
+ * to the next one sfb+1; enn and thmm have to be split between them
475
+ */function convert_partition2scalefac_s(gfc,eb,thr,chn,sblock){var sb,b;var enn=0.0;var thmm=0.0;for(sb=b=0;sb<$cPNKB.SBMAX_s;++b,++sb){var bo_s_sb=gfc.bo_s[sb];var npart_s=gfc.npart_s;var b_lim=bo_s_sb<npart_s?bo_s_sb:npart_s;while(b<b_lim){$97f850779472263e$var$assert(eb[b]>=0);// iff failed, it may indicate some index error elsewhere
476
+ $97f850779472263e$var$assert(thr[b]>=0);enn+=eb[b];thmm+=thr[b];b++;}gfc.en[chn].s[sb][sblock]=enn;gfc.thm[chn].s[sb][sblock]=thmm;if(b>=npart_s){++sb;break;}$97f850779472263e$var$assert(eb[b]>=0);// iff failed, it may indicate some index error elsewhere
477
+ $97f850779472263e$var$assert(thr[b]>=0);/* at transition sfb . sfb+1 */var w_curr=gfc.PSY.bo_s_weight[sb];var w_next=1.0-w_curr;enn=w_curr*eb[b];thmm=w_curr*thr[b];gfc.en[chn].s[sb][sblock]+=enn;gfc.thm[chn].s[sb][sblock]+=thmm;enn=w_next*eb[b];thmm=w_next*thr[b];}/* zero initialize the rest */for(;sb<$cPNKB.SBMAX_s;++sb){gfc.en[chn].s[sb][sblock]=0;gfc.thm[chn].s[sb][sblock]=0;}}/**
478
+ * longblock threshold calculation (part 2)
479
+ */function convert_partition2scalefac_l(gfc,eb,thr,chn){var sb,b;var enn=0.0;var thmm=0.0;for(sb=b=0;sb<$cPNKB.SBMAX_l;++b,++sb){var bo_l_sb=gfc.bo_l[sb];var npart_l=gfc.npart_l;var b_lim=bo_l_sb<npart_l?bo_l_sb:npart_l;while(b<b_lim){$97f850779472263e$var$assert(eb[b]>=0);// iff failed, it may indicate some index error elsewhere
480
+ $97f850779472263e$var$assert(thr[b]>=0);enn+=eb[b];thmm+=thr[b];b++;}gfc.en[chn].l[sb]=enn;gfc.thm[chn].l[sb]=thmm;if(b>=npart_l){++sb;break;}$97f850779472263e$var$assert(eb[b]>=0);$97f850779472263e$var$assert(thr[b]>=0);/* at transition sfb . sfb+1 */var w_curr=gfc.PSY.bo_l_weight[sb];var w_next=1.0-w_curr;enn=w_curr*eb[b];thmm=w_curr*thr[b];gfc.en[chn].l[sb]+=enn;gfc.thm[chn].l[sb]+=thmm;enn=w_next*eb[b];thmm=w_next*thr[b];}/* zero initialize the rest */for(;sb<$cPNKB.SBMAX_l;++sb){gfc.en[chn].l[sb]=0;gfc.thm[chn].l[sb]=0;}}function compute_masking_s(gfp,fftenergy_s,eb,thr,chn,sblock){var gfc=gfp.internal_flags;var j,b;for(b=j=0;b<gfc.npart_s;++b){var ebb=0;var n=gfc.numlines_s[b];for(var i=0;i<n;++i,++j){var el=fftenergy_s[sblock][j];ebb+=el;}eb[b]=ebb;}$97f850779472263e$var$assert(b==gfc.npart_s);$97f850779472263e$var$assert(j==129);for(j=b=0;b<gfc.npart_s;b++){var kk=gfc.s3ind_s[b][0];var ecb=gfc.s3_ss[j++]*eb[kk];++kk;while(kk<=gfc.s3ind_s[b][1]){ecb+=gfc.s3_ss[j]*eb[kk];++j;++kk;}var x=rpelev_s*gfc.nb_s1[chn][b];thr[b]=Math.min(ecb,x);if(gfc.blocktype_old[chn&1]==$cPNKB.SHORT_TYPE){/* limit calculated threshold by even older granule */var x=rpelev2_s*gfc.nb_s2[chn][b];var y=thr[b];thr[b]=Math.min(x,y);}gfc.nb_s2[chn][b]=gfc.nb_s1[chn][b];gfc.nb_s1[chn][b]=ecb;$97f850779472263e$var$assert(thr[b]>=0);}for(;b<=$cPNKB.CBANDS;++b){eb[b]=0;thr[b]=0;}}function block_type_set(gfp,uselongblock,blocktype_d,blocktype){var gfc=gfp.internal_flags;if(gfp.short_blocks==$97f850779472263e$var$ShortBlock.short_block_coupled&&!(uselongblock[0]!=0&&uselongblock[1]!=0))uselongblock[0]=uselongblock[1]=0;/*
481
+ * update the blocktype of the previous granule, since it depends on
482
+ * what happend in this granule
483
+ */for(var chn=0;chn<gfc.channels_out;chn++){blocktype[chn]=$cPNKB.NORM_TYPE;/* disable short blocks */if(gfp.short_blocks==$97f850779472263e$var$ShortBlock.short_block_dispensed)uselongblock[chn]=1;if(gfp.short_blocks==$97f850779472263e$var$ShortBlock.short_block_forced)uselongblock[chn]=0;if(uselongblock[chn]!=0){/* no attack : use long blocks */$97f850779472263e$var$assert(gfc.blocktype_old[chn]!=$cPNKB.START_TYPE);if(gfc.blocktype_old[chn]==$cPNKB.SHORT_TYPE)blocktype[chn]=$cPNKB.STOP_TYPE;}else {/* attack : use short blocks */blocktype[chn]=$cPNKB.SHORT_TYPE;if(gfc.blocktype_old[chn]==$cPNKB.NORM_TYPE)gfc.blocktype_old[chn]=$cPNKB.START_TYPE;if(gfc.blocktype_old[chn]==$cPNKB.STOP_TYPE)gfc.blocktype_old[chn]=$cPNKB.SHORT_TYPE;}blocktype_d[chn]=gfc.blocktype_old[chn];// value returned to calling program
484
+ gfc.blocktype_old[chn]=blocktype[chn];// save for next call to l3psy_anal
485
+ }}function NS_INTERP(x,y,r){/* was pow((x),(r))*pow((y),1-(r)) */if(r>=1.0)/* 99.7% of the time */return x;if(r<=0.0)return y;if(y>0.0)/* rest of the time */return Math.pow(x/y,r)*y;/* never happens */return 0.0;}/**
486
+ * these values are tuned only for 44.1kHz...
487
+ */var regcoef_s=[11.8,13.6,17.2,32,46.5,51.3,57.5,67.1,71.5,84.6,97.6,130];function pecalc_s(mr,masking_lower){var pe_s=309.07;for(var sb=0;sb<$cPNKB.SBMAX_s-1;sb++)for(var sblock=0;sblock<3;sblock++){var thm=mr.thm.s[sb][sblock];$97f850779472263e$var$assert(sb<regcoef_s.length);if(thm>0.0){var x=thm*masking_lower;var en=mr.en.s[sb][sblock];if(en>x){if(en>x*1e10)pe_s+=regcoef_s[sb]*(10.0*LOG10);else {$97f850779472263e$var$assert(x>0);pe_s+=regcoef_s[sb]*$97f850779472263e$var$Util.FAST_LOG10(en/x);}}}}return pe_s;}/**
488
+ * these values are tuned only for 44.1kHz...
489
+ */var regcoef_l=[6.8,5.8,5.8,6.4,6.5,9.9,12.1,14.4,15,18.9,21.6,26.9,34.2,40.2,46.8,56.5,60.7,73.9,85.7,93.4,126.1];function pecalc_l(mr,masking_lower){var pe_l=281.0575;for(var sb=0;sb<$cPNKB.SBMAX_l-1;sb++){var thm=mr.thm.l[sb];$97f850779472263e$var$assert(sb<regcoef_l.length);if(thm>0.0){var x=thm*masking_lower;var en=mr.en.l[sb];if(en>x){if(en>x*1e10)pe_l+=regcoef_l[sb]*(10.0*LOG10);else {$97f850779472263e$var$assert(x>0);pe_l+=regcoef_l[sb]*$97f850779472263e$var$Util.FAST_LOG10(en/x);}}}}return pe_l;}function calc_energy(gfc,fftenergy,eb,max,avg){var b,j;for(b=j=0;b<gfc.npart_l;++b){var ebb=0,m=0;var i;for(i=0;i<gfc.numlines_l[b];++i,++j){var el=fftenergy[j];$97f850779472263e$var$assert(el>=0);ebb+=el;if(m<el)m=el;}eb[b]=ebb;max[b]=m;avg[b]=ebb*gfc.rnumlines_l[b];$97f850779472263e$var$assert(gfc.rnumlines_l[b]>=0);$97f850779472263e$var$assert(ebb>=0);$97f850779472263e$var$assert(eb[b]>=0);$97f850779472263e$var$assert(max[b]>=0);$97f850779472263e$var$assert(avg[b]>=0);}}function calc_mask_index_l(gfc,max,avg,mask_idx){var last_tab_entry=tab.length-1;var b=0;var a=avg[b]+avg[b+1];$97f850779472263e$var$assert(a>=0);if(a>0.0){var m=max[b];if(m<max[b+1])m=max[b+1];$97f850779472263e$var$assert(gfc.numlines_l[b]+gfc.numlines_l[b+1]-1>0);a=20.0*(m*2.0-a)/(a*(gfc.numlines_l[b]+gfc.numlines_l[b+1]-1));var k=0|a;if(k>last_tab_entry)k=last_tab_entry;mask_idx[b]=k;}else mask_idx[b]=0;for(b=1;b<gfc.npart_l-1;b++){a=avg[b-1]+avg[b]+avg[b+1];$97f850779472263e$var$assert(a>=0);if(a>0.0){var m=max[b-1];if(m<max[b])m=max[b];if(m<max[b+1])m=max[b+1];$97f850779472263e$var$assert(gfc.numlines_l[b-1]+gfc.numlines_l[b]+gfc.numlines_l[b+1]-1>0);a=20.0*(m*3.0-a)/(a*(gfc.numlines_l[b-1]+gfc.numlines_l[b]+gfc.numlines_l[b+1]-1));var k=0|a;if(k>last_tab_entry)k=last_tab_entry;mask_idx[b]=k;}else mask_idx[b]=0;}$97f850779472263e$var$assert(b>0);$97f850779472263e$var$assert(b==gfc.npart_l-1);a=avg[b-1]+avg[b];$97f850779472263e$var$assert(a>=0);if(a>0.0){var m=max[b-1];if(m<max[b])m=max[b];$97f850779472263e$var$assert(gfc.numlines_l[b-1]+gfc.numlines_l[b]-1>0);a=20.0*(m*2.0-a)/(a*(gfc.numlines_l[b-1]+gfc.numlines_l[b]-1));var k=0|a;if(k>last_tab_entry)k=last_tab_entry;mask_idx[b]=k;}else mask_idx[b]=0;$97f850779472263e$var$assert(b==gfc.npart_l-1);}var fircoef=[-0.00000000000000000865163*2,-0.01703172,-0.00000000000000000674764*2,0.0418072,-0.0000000000000000336639*2,-0.0876324,-0.0000000000000000154175*2,0.1863476,-0.0000000000000000552212*2,-0.627638];this.L3psycho_anal_ns=function(gfp,buffer,bufPos,gr_out,masking_ratio,masking_MS_ratio,percep_entropy,percep_MS_entropy,energy,blocktype_d){/*
490
+ * to get a good cache performance, one has to think about the sequence,
491
+ * in which the variables are used.
492
+ */var gfc=gfp.internal_flags;/* fft and energy calculation */var wsamp_L=$97f850779472263e$var$new_float_n([2,$cPNKB.BLKSIZE]);var wsamp_S=$97f850779472263e$var$new_float_n([2,3,$cPNKB.BLKSIZE_s]);/* convolution */var eb_l=$97f850779472263e$var$new_float($cPNKB.CBANDS+1);var eb_s=$97f850779472263e$var$new_float($cPNKB.CBANDS+1);var thr=$97f850779472263e$var$new_float($cPNKB.CBANDS+2);/* block type */var blocktype=$97f850779472263e$var$new_int(2),uselongblock=$97f850779472263e$var$new_int(2);/* usual variables like loop indices, etc.. */var numchn,chn;var b,i,j,k;var sb,sblock;/* variables used for --nspsytune */var ns_hpfsmpl=$97f850779472263e$var$new_float_n([2,576]);var pcfact;var mask_idx_l=$97f850779472263e$var$new_int($cPNKB.CBANDS+2),mask_idx_s=$97f850779472263e$var$new_int($cPNKB.CBANDS+2);$97f850779472263e$var$Arrays.fill(mask_idx_s,0);numchn=gfc.channels_out;/* chn=2 and 3 = Mid and Side channels */if(gfp.mode==MPEGMode.JOINT_STEREO)numchn=4;if(gfp.VBR==$97f850779472263e$var$VbrMode.vbr_off)pcfact=gfc.ResvMax==0?0:gfc.ResvSize/gfc.ResvMax*0.5;else if(gfp.VBR==$97f850779472263e$var$VbrMode.vbr_rh||gfp.VBR==$97f850779472263e$var$VbrMode.vbr_mtrh||gfp.VBR==$97f850779472263e$var$VbrMode.vbr_mt)pcfact=0.6;else pcfact=1.0;/**********************************************************************
493
+ * Apply HPF of fs/4 to the input signal. This is used for attack
494
+ * detection / handling.
495
+ **********************************************************************/ /* Don't copy the input buffer into a temporary buffer */ /* unroll the loop 2 times */for(chn=0;chn<gfc.channels_out;chn++){/* apply high pass filter of fs/4 */var firbuf1=buffer[chn];var firbufPos=bufPos+576-350-NSFIRLEN+192;$97f850779472263e$var$assert(fircoef.length==(NSFIRLEN-1)/2);for(i=0;i<576;i++){var sum1,sum2;sum1=firbuf1[firbufPos+i+10];sum2=0.0;for(j=0;j<(NSFIRLEN-1)/2-1;j+=2){sum1+=fircoef[j]*(firbuf1[firbufPos+i+j]+firbuf1[firbufPos+i+NSFIRLEN-j]);sum2+=fircoef[j+1]*(firbuf1[firbufPos+i+j+1]+firbuf1[firbufPos+i+NSFIRLEN-j-1]);}ns_hpfsmpl[chn][i]=sum1+sum2;}masking_ratio[gr_out][chn].en.assign(gfc.en[chn]);masking_ratio[gr_out][chn].thm.assign(gfc.thm[chn]);if(numchn>2){/* MS maskings */ /* percep_MS_entropy [chn-2] = gfc . pe [chn]; */masking_MS_ratio[gr_out][chn].en.assign(gfc.en[chn+2]);masking_MS_ratio[gr_out][chn].thm.assign(gfc.thm[chn+2]);}}for(chn=0;chn<numchn;chn++){var wsamp_l;var wsamp_s;var en_subshort=$97f850779472263e$var$new_float(12);var en_short=[0,0,0,0];var attack_intensity=$97f850779472263e$var$new_float(12);var ns_uselongblock=1;var attackThreshold;var max=$97f850779472263e$var$new_float($cPNKB.CBANDS),avg=$97f850779472263e$var$new_float($cPNKB.CBANDS);var ns_attacks=[0,0,0,0];var fftenergy=$97f850779472263e$var$new_float($cPNKB.HBLKSIZE);var fftenergy_s=$97f850779472263e$var$new_float_n([3,$cPNKB.HBLKSIZE_s]);/*
496
+ * rh 20040301: the following loops do access one off the limits so
497
+ * I increase the array dimensions by one and initialize the
498
+ * accessed values to zero
499
+ */$97f850779472263e$var$assert(gfc.npart_s<=$cPNKB.CBANDS);$97f850779472263e$var$assert(gfc.npart_l<=$cPNKB.CBANDS);/***************************************************************
500
+ * determine the block type (window type)
501
+ ***************************************************************/ /* calculate energies of each sub-shortblocks */for(i=0;i<3;i++){en_subshort[i]=gfc.nsPsy.last_en_subshort[chn][i+6];$97f850779472263e$var$assert(gfc.nsPsy.last_en_subshort[chn][i+4]>0);attack_intensity[i]=en_subshort[i]/gfc.nsPsy.last_en_subshort[chn][i+4];en_short[0]+=en_subshort[i];}if(chn==2)for(i=0;i<576;i++){var l,r;l=ns_hpfsmpl[0][i];r=ns_hpfsmpl[1][i];ns_hpfsmpl[0][i]=l+r;ns_hpfsmpl[1][i]=l-r;}var pf=ns_hpfsmpl[chn&1];var pfPos=0;for(i=0;i<9;i++){var pfe=pfPos+64;var p=1.;for(;pfPos<pfe;pfPos++)if(p<Math.abs(pf[pfPos]))p=Math.abs(pf[pfPos]);gfc.nsPsy.last_en_subshort[chn][i]=en_subshort[i+3]=p;en_short[1+i/3]+=p;if(p>en_subshort[i+3-2]){$97f850779472263e$var$assert(en_subshort[i+3-2]>0);p=p/en_subshort[i+3-2];}else if(en_subshort[i+3-2]>p*10.0){$97f850779472263e$var$assert(p>0);p=en_subshort[i+3-2]/(p*10.0);}else p=0.0;attack_intensity[i+3]=p;}if(gfp.analysis){var x=attack_intensity[0];for(i=1;i<12;i++)if(x<attack_intensity[i])x=attack_intensity[i];gfc.pinfo.ers[gr_out][chn]=gfc.pinfo.ers_save[chn];gfc.pinfo.ers_save[chn]=x;}/* compare energies between sub-shortblocks */attackThreshold=chn==3?gfc.nsPsy.attackthre_s:gfc.nsPsy.attackthre;for(i=0;i<12;i++)if(0==ns_attacks[i/3]&&attack_intensity[i]>attackThreshold)ns_attacks[i/3]=i%3+1;/*
502
+ * should have energy change between short blocks, in order to avoid
503
+ * periodic signals
504
+ */for(i=1;i<4;i++){var ratio;if(en_short[i-1]>en_short[i]){$97f850779472263e$var$assert(en_short[i]>0);ratio=en_short[i-1]/en_short[i];}else {$97f850779472263e$var$assert(en_short[i-1]>0);ratio=en_short[i]/en_short[i-1];}if(ratio<1.7){ns_attacks[i]=0;if(i==1)ns_attacks[0]=0;}}if(ns_attacks[0]!=0&&gfc.nsPsy.lastAttacks[chn]!=0)ns_attacks[0]=0;if(gfc.nsPsy.lastAttacks[chn]==3||ns_attacks[0]+ns_attacks[1]+ns_attacks[2]+ns_attacks[3]!=0){ns_uselongblock=0;if(ns_attacks[1]!=0&&ns_attacks[0]!=0)ns_attacks[1]=0;if(ns_attacks[2]!=0&&ns_attacks[1]!=0)ns_attacks[2]=0;if(ns_attacks[3]!=0&&ns_attacks[2]!=0)ns_attacks[3]=0;}if(chn<2)uselongblock[chn]=ns_uselongblock;else if(ns_uselongblock==0)uselongblock[0]=uselongblock[1]=0;/*
505
+ * there is a one granule delay. Copy maskings computed last call
506
+ * into masking_ratio to return to calling program.
507
+ */energy[chn]=gfc.tot_ener[chn];/*********************************************************************
508
+ * compute FFTs
509
+ *********************************************************************/wsamp_s=wsamp_S;wsamp_l=wsamp_L;compute_ffts(gfp,fftenergy,fftenergy_s,wsamp_l,chn&1,wsamp_s,chn&1,gr_out,chn,buffer,bufPos);/*********************************************************************
510
+ * Calculate the energy and the tonality of each partition.
511
+ *********************************************************************/calc_energy(gfc,fftenergy,eb_l,max,avg);calc_mask_index_l(gfc,max,avg,mask_idx_l);/* compute masking thresholds for short blocks */for(sblock=0;sblock<3;sblock++){var enn,thmm;compute_masking_s(gfp,fftenergy_s,eb_s,thr,chn,sblock);convert_partition2scalefac_s(gfc,eb_s,thr,chn,sblock);/**** short block pre-echo control ****/for(sb=0;sb<$cPNKB.SBMAX_s;sb++){thmm=gfc.thm[chn].s[sb][sblock];thmm*=NS_PREECHO_ATT0;if(ns_attacks[sblock]>=2||ns_attacks[sblock+1]==1){var idx=sblock!=0?sblock-1:2;var p=NS_INTERP(gfc.thm[chn].s[sb][idx],thmm,NS_PREECHO_ATT1*pcfact);thmm=Math.min(thmm,p);}if(ns_attacks[sblock]==1){var idx=sblock!=0?sblock-1:2;var p=NS_INTERP(gfc.thm[chn].s[sb][idx],thmm,NS_PREECHO_ATT2*pcfact);thmm=Math.min(thmm,p);}else if(sblock!=0&&ns_attacks[sblock-1]==3||sblock==0&&gfc.nsPsy.lastAttacks[chn]==3){var idx=sblock!=2?sblock+1:0;var p=NS_INTERP(gfc.thm[chn].s[sb][idx],thmm,NS_PREECHO_ATT2*pcfact);thmm=Math.min(thmm,p);}/* pulse like signal detection for fatboy.wav and so on */enn=en_subshort[sblock*3+3]+en_subshort[sblock*3+4]+en_subshort[sblock*3+5];if(en_subshort[sblock*3+5]*6<enn){thmm*=0.5;if(en_subshort[sblock*3+4]*6<enn)thmm*=0.5;}gfc.thm[chn].s[sb][sblock]=thmm;}}gfc.nsPsy.lastAttacks[chn]=ns_attacks[2];/*********************************************************************
512
+ * convolve the partitioned energy and unpredictability with the
513
+ * spreading function, s3_l[b][k]
514
+ ********************************************************************/k=0;for(b=0;b<gfc.npart_l;b++){/*
515
+ * convolve the partitioned energy with the spreading
516
+ * function
517
+ */var kk=gfc.s3ind[b][0];var eb2=eb_l[kk]*tab[mask_idx_l[kk]];var ecb=gfc.s3_ll[k++]*eb2;while(++kk<=gfc.s3ind[b][1]){eb2=eb_l[kk]*tab[mask_idx_l[kk]];ecb=mask_add(ecb,gfc.s3_ll[k++]*eb2,kk,kk-b,gfc,0);}ecb*=0.158489319246111;/* pow(10,-0.8) */ /**** long block pre-echo control ****/ /**
518
+ * <PRE>
519
+ * dont use long block pre-echo control if previous granule was
520
+ * a short block. This is to avoid the situation:
521
+ * frame0: quiet (very low masking)
522
+ * frame1: surge (triggers short blocks)
523
+ * frame2: regular frame. looks like pre-echo when compared to
524
+ * frame0, but all pre-echo was in frame1.
525
+ * </PRE>
526
+ */ /*
527
+ * chn=0,1 L and R channels
528
+ *
529
+ * chn=2,3 S and M channels.
530
+ */if(gfc.blocktype_old[chn&1]==$cPNKB.SHORT_TYPE)thr[b]=ecb;else thr[b]=NS_INTERP(Math.min(ecb,Math.min(rpelev*gfc.nb_1[chn][b],rpelev2*gfc.nb_2[chn][b])),ecb,pcfact);gfc.nb_2[chn][b]=gfc.nb_1[chn][b];gfc.nb_1[chn][b]=ecb;}for(;b<=$cPNKB.CBANDS;++b){eb_l[b]=0;thr[b]=0;}/* compute masking thresholds for long blocks */convert_partition2scalefac_l(gfc,eb_l,thr,chn);}/* end loop over chn */if(gfp.mode==MPEGMode.STEREO||gfp.mode==MPEGMode.JOINT_STEREO){if(gfp.interChRatio>0.0)calc_interchannel_masking(gfp,gfp.interChRatio);}if(gfp.mode==MPEGMode.JOINT_STEREO){var msfix;msfix1(gfc);msfix=gfp.msfix;if(Math.abs(msfix)>0.0)ns_msfix(gfc,msfix,gfp.ATHlower*gfc.ATH.adjust);}/***************************************************************
531
+ * determine final block type
532
+ ***************************************************************/block_type_set(gfp,uselongblock,blocktype_d,blocktype);/*********************************************************************
533
+ * compute the value of PE to return ... no delay and advance
534
+ *********************************************************************/for(chn=0;chn<numchn;chn++){var ppe;var ppePos=0;var type;var mr;if(chn>1){ppe=percep_MS_entropy;ppePos=-2;type=$cPNKB.NORM_TYPE;if(blocktype_d[0]==$cPNKB.SHORT_TYPE||blocktype_d[1]==$cPNKB.SHORT_TYPE)type=$cPNKB.SHORT_TYPE;mr=masking_MS_ratio[gr_out][chn-2];}else {ppe=percep_entropy;ppePos=0;type=blocktype_d[chn];mr=masking_ratio[gr_out][chn];}if(type==$cPNKB.SHORT_TYPE)ppe[ppePos+chn]=pecalc_s(mr,gfc.masking_lower);else ppe[ppePos+chn]=pecalc_l(mr,gfc.masking_lower);if(gfp.analysis)gfc.pinfo.pe[gr_out][chn]=ppe[ppePos+chn];}return 0;};function vbrpsy_compute_fft_l(gfp,buffer,bufPos,chn,gr_out,fftenergy,wsamp_l,wsamp_lPos){var gfc=gfp.internal_flags;if(chn<2)fft.fft_long(gfc,wsamp_l[wsamp_lPos],chn,buffer,bufPos);else if(chn==2)/* FFT data for mid and side channel is derived from L & R */for(var j=$cPNKB.BLKSIZE-1;j>=0;--j){var l=wsamp_l[wsamp_lPos+0][j];var r=wsamp_l[wsamp_lPos+1][j];wsamp_l[wsamp_lPos+0][j]=(l+r)*$97f850779472263e$var$Util.SQRT2*0.5;wsamp_l[wsamp_lPos+1][j]=(l-r)*$97f850779472263e$var$Util.SQRT2*0.5;}/*********************************************************************
535
+ * compute energies
536
+ *********************************************************************/fftenergy[0]=NON_LINEAR_SCALE_ENERGY(wsamp_l[wsamp_lPos+0][0]);fftenergy[0]*=fftenergy[0];for(var j=$cPNKB.BLKSIZE/2-1;j>=0;--j){var re=wsamp_l[wsamp_lPos+0][$cPNKB.BLKSIZE/2-j];var im=wsamp_l[wsamp_lPos+0][$cPNKB.BLKSIZE/2+j];fftenergy[$cPNKB.BLKSIZE/2-j]=NON_LINEAR_SCALE_ENERGY((re*re+im*im)*0.5);}var totalenergy=0.0;for(var j=11;j<$cPNKB.HBLKSIZE;j++)totalenergy+=fftenergy[j];gfc.tot_ener[chn]=totalenergy;if(gfp.analysis){for(var j=0;j<$cPNKB.HBLKSIZE;j++){gfc.pinfo.energy[gr_out][chn][j]=gfc.pinfo.energy_save[chn][j];gfc.pinfo.energy_save[chn][j]=fftenergy[j];}gfc.pinfo.pe[gr_out][chn]=gfc.pe[chn];}}function vbrpsy_compute_fft_s(gfp,buffer,bufPos,chn,sblock,fftenergy_s,wsamp_s,wsamp_sPos){var gfc=gfp.internal_flags;if(sblock==0&&chn<2)fft.fft_short(gfc,wsamp_s[wsamp_sPos],chn,buffer,bufPos);if(chn==2)/* FFT data for mid and side channel is derived from L & R */for(var j=$cPNKB.BLKSIZE_s-1;j>=0;--j){var l=wsamp_s[wsamp_sPos+0][sblock][j];var r=wsamp_s[wsamp_sPos+1][sblock][j];wsamp_s[wsamp_sPos+0][sblock][j]=(l+r)*$97f850779472263e$var$Util.SQRT2*0.5;wsamp_s[wsamp_sPos+1][sblock][j]=(l-r)*$97f850779472263e$var$Util.SQRT2*0.5;}/*********************************************************************
537
+ * compute energies
538
+ *********************************************************************/fftenergy_s[sblock][0]=wsamp_s[wsamp_sPos+0][sblock][0];fftenergy_s[sblock][0]*=fftenergy_s[sblock][0];for(var j=$cPNKB.BLKSIZE_s/2-1;j>=0;--j){var re=wsamp_s[wsamp_sPos+0][sblock][$cPNKB.BLKSIZE_s/2-j];var im=wsamp_s[wsamp_sPos+0][sblock][$cPNKB.BLKSIZE_s/2+j];fftenergy_s[sblock][$cPNKB.BLKSIZE_s/2-j]=NON_LINEAR_SCALE_ENERGY((re*re+im*im)*0.5);}}/**
539
+ * compute loudness approximation (used for ATH auto-level adjustment)
540
+ */function vbrpsy_compute_loudness_approximation_l(gfp,gr_out,chn,fftenergy){var gfc=gfp.internal_flags;if(gfp.athaa_loudapprox==2&&chn<2){// no loudness for mid/side ch
541
+ gfc.loudness_sq[gr_out][chn]=gfc.loudness_sq_save[chn];gfc.loudness_sq_save[chn]=psycho_loudness_approx(fftenergy,gfc);}}var fircoef_=[-0.00000000000000000865163*2,-0.01703172,-0.00000000000000000674764*2,0.0418072,-0.0000000000000000336639*2,-0.0876324,-0.0000000000000000154175*2,0.1863476,-0.0000000000000000552212*2,-0.627638];/**
542
+ * Apply HPF of fs/4 to the input signal. This is used for attack detection
543
+ * / handling.
544
+ */function vbrpsy_attack_detection(gfp,buffer,bufPos,gr_out,masking_ratio,masking_MS_ratio,energy,sub_short_factor,ns_attacks,uselongblock){var ns_hpfsmpl=$97f850779472263e$var$new_float_n([2,576]);var gfc=gfp.internal_flags;var n_chn_out=gfc.channels_out;/* chn=2 and 3 = Mid and Side channels */var n_chn_psy=gfp.mode==MPEGMode.JOINT_STEREO?4:n_chn_out;/* Don't copy the input buffer into a temporary buffer */ /* unroll the loop 2 times */for(var chn=0;chn<n_chn_out;chn++){/* apply high pass filter of fs/4 */firbuf=buffer[chn];var firbufPos=bufPos+576-350-NSFIRLEN+192;$97f850779472263e$var$assert(fircoef_.length==(NSFIRLEN-1)/2);for(var i=0;i<576;i++){var sum1,sum2;sum1=firbuf[firbufPos+i+10];sum2=0.0;for(var j=0;j<(NSFIRLEN-1)/2-1;j+=2){sum1+=fircoef_[j]*(firbuf[firbufPos+i+j]+firbuf[firbufPos+i+NSFIRLEN-j]);sum2+=fircoef_[j+1]*(firbuf[firbufPos+i+j+1]+firbuf[firbufPos+i+NSFIRLEN-j-1]);}ns_hpfsmpl[chn][i]=sum1+sum2;}masking_ratio[gr_out][chn].en.assign(gfc.en[chn]);masking_ratio[gr_out][chn].thm.assign(gfc.thm[chn]);if(n_chn_psy>2){/* MS maskings */ /* percep_MS_entropy [chn-2] = gfc . pe [chn]; */masking_MS_ratio[gr_out][chn].en.assign(gfc.en[chn+2]);masking_MS_ratio[gr_out][chn].thm.assign(gfc.thm[chn+2]);}}for(var chn=0;chn<n_chn_psy;chn++){var attack_intensity=$97f850779472263e$var$new_float(12);var en_subshort=$97f850779472263e$var$new_float(12);var en_short=[0,0,0,0];var pf=ns_hpfsmpl[chn&1];var pfPos=0;var attackThreshold=chn==3?gfc.nsPsy.attackthre_s:gfc.nsPsy.attackthre;var ns_uselongblock=1;if(chn==2)for(var i=0,j=576;j>0;++i,--j){var l=ns_hpfsmpl[0][i];var r=ns_hpfsmpl[1][i];ns_hpfsmpl[0][i]=l+r;ns_hpfsmpl[1][i]=l-r;}/***************************************************************
545
+ * determine the block type (window type)
546
+ ***************************************************************/ /* calculate energies of each sub-shortblocks */for(var i=0;i<3;i++){en_subshort[i]=gfc.nsPsy.last_en_subshort[chn][i+6];$97f850779472263e$var$assert(gfc.nsPsy.last_en_subshort[chn][i+4]>0);attack_intensity[i]=en_subshort[i]/gfc.nsPsy.last_en_subshort[chn][i+4];en_short[0]+=en_subshort[i];}for(var i=0;i<9;i++){var pfe=pfPos+64;var p=1.;for(;pfPos<pfe;pfPos++)if(p<Math.abs(pf[pfPos]))p=Math.abs(pf[pfPos]);gfc.nsPsy.last_en_subshort[chn][i]=en_subshort[i+3]=p;en_short[1+i/3]+=p;if(p>en_subshort[i+3-2]){$97f850779472263e$var$assert(en_subshort[i+3-2]>0);p=p/en_subshort[i+3-2];}else if(en_subshort[i+3-2]>p*10.0){$97f850779472263e$var$assert(p>0);p=en_subshort[i+3-2]/(p*10.0);}else p=0.0;attack_intensity[i+3]=p;}/* pulse like signal detection for fatboy.wav and so on */for(var i=0;i<3;++i){var enn=en_subshort[i*3+3]+en_subshort[i*3+4]+en_subshort[i*3+5];var factor=1.;if(en_subshort[i*3+5]*6<enn){factor*=0.5;if(en_subshort[i*3+4]*6<enn)factor*=0.5;}sub_short_factor[chn][i]=factor;}if(gfp.analysis){var x=attack_intensity[0];for(var i=1;i<12;i++)if(x<attack_intensity[i])x=attack_intensity[i];gfc.pinfo.ers[gr_out][chn]=gfc.pinfo.ers_save[chn];gfc.pinfo.ers_save[chn]=x;}/* compare energies between sub-shortblocks */for(var i=0;i<12;i++)if(0==ns_attacks[chn][i/3]&&attack_intensity[i]>attackThreshold)ns_attacks[chn][i/3]=i%3+1;/*
547
+ * should have energy change between short blocks, in order to avoid
548
+ * periodic signals
549
+ */ /* Good samples to show the effect are Trumpet test songs */ /*
550
+ * GB: tuned (1) to avoid too many short blocks for test sample
551
+ * TRUMPET
552
+ */ /*
553
+ * RH: tuned (2) to let enough short blocks through for test sample
554
+ * FSOL and SNAPS
555
+ */for(var i=1;i<4;i++){var u=en_short[i-1];var v=en_short[i];var m=Math.max(u,v);if(m<40000){if(u<1.7*v&&v<1.7*u){if(i==1&&ns_attacks[chn][0]<=ns_attacks[chn][i])ns_attacks[chn][0]=0;ns_attacks[chn][i]=0;}}}if(ns_attacks[chn][0]<=gfc.nsPsy.lastAttacks[chn])ns_attacks[chn][0]=0;if(gfc.nsPsy.lastAttacks[chn]==3||ns_attacks[chn][0]+ns_attacks[chn][1]+ns_attacks[chn][2]+ns_attacks[chn][3]!=0){ns_uselongblock=0;if(ns_attacks[chn][1]!=0&&ns_attacks[chn][0]!=0)ns_attacks[chn][1]=0;if(ns_attacks[chn][2]!=0&&ns_attacks[chn][1]!=0)ns_attacks[chn][2]=0;if(ns_attacks[chn][3]!=0&&ns_attacks[chn][2]!=0)ns_attacks[chn][3]=0;}if(chn<2)uselongblock[chn]=ns_uselongblock;else if(ns_uselongblock==0)uselongblock[0]=uselongblock[1]=0;/*
556
+ * there is a one granule delay. Copy maskings computed last call
557
+ * into masking_ratio to return to calling program.
558
+ */energy[chn]=gfc.tot_ener[chn];}}function vbrpsy_skip_masking_s(gfc,chn,sblock){if(sblock==0)for(var b=0;b<gfc.npart_s;b++){gfc.nb_s2[chn][b]=gfc.nb_s1[chn][b];gfc.nb_s1[chn][b]=0;}}function vbrpsy_skip_masking_l(gfc,chn){for(var b=0;b<gfc.npart_l;b++){gfc.nb_2[chn][b]=gfc.nb_1[chn][b];gfc.nb_1[chn][b]=0;}}function psyvbr_calc_mask_index_s(gfc,max,avg,mask_idx){var last_tab_entry=tab.length-1;var b=0;var a=avg[b]+avg[b+1];$97f850779472263e$var$assert(a>=0);if(a>0.0){var m=max[b];if(m<max[b+1])m=max[b+1];$97f850779472263e$var$assert(gfc.numlines_s[b]+gfc.numlines_s[b+1]-1>0);a=20.0*(m*2.0-a)/(a*(gfc.numlines_s[b]+gfc.numlines_s[b+1]-1));var k=0|a;if(k>last_tab_entry)k=last_tab_entry;mask_idx[b]=k;}else mask_idx[b]=0;for(b=1;b<gfc.npart_s-1;b++){a=avg[b-1]+avg[b]+avg[b+1];$97f850779472263e$var$assert(b+1<gfc.npart_s);$97f850779472263e$var$assert(a>=0);if(a>0.0){var m=max[b-1];if(m<max[b])m=max[b];if(m<max[b+1])m=max[b+1];$97f850779472263e$var$assert(gfc.numlines_s[b-1]+gfc.numlines_s[b]+gfc.numlines_s[b+1]-1>0);a=20.0*(m*3.0-a)/(a*(gfc.numlines_s[b-1]+gfc.numlines_s[b]+gfc.numlines_s[b+1]-1));var k=0|a;if(k>last_tab_entry)k=last_tab_entry;mask_idx[b]=k;}else mask_idx[b]=0;}$97f850779472263e$var$assert(b>0);$97f850779472263e$var$assert(b==gfc.npart_s-1);a=avg[b-1]+avg[b];$97f850779472263e$var$assert(a>=0);if(a>0.0){var m=max[b-1];if(m<max[b])m=max[b];$97f850779472263e$var$assert(gfc.numlines_s[b-1]+gfc.numlines_s[b]-1>0);a=20.0*(m*2.0-a)/(a*(gfc.numlines_s[b-1]+gfc.numlines_s[b]-1));var k=0|a;if(k>last_tab_entry)k=last_tab_entry;mask_idx[b]=k;}else mask_idx[b]=0;$97f850779472263e$var$assert(b==gfc.npart_s-1);}function vbrpsy_compute_masking_s(gfp,fftenergy_s,eb,thr,chn,sblock){var gfc=gfp.internal_flags;var max=new float[$cPNKB.CBANDS](),avg=$97f850779472263e$var$new_float($cPNKB.CBANDS);var i,j,b;var mask_idx_s=new int[$cPNKB.CBANDS]();for(b=j=0;b<gfc.npart_s;++b){var ebb=0,m=0;var n=gfc.numlines_s[b];for(i=0;i<n;++i,++j){var el=fftenergy_s[sblock][j];ebb+=el;if(m<el)m=el;}eb[b]=ebb;$97f850779472263e$var$assert(ebb>=0);max[b]=m;$97f850779472263e$var$assert(n>0);avg[b]=ebb/n;$97f850779472263e$var$assert(avg[b]>=0);}$97f850779472263e$var$assert(b==gfc.npart_s);$97f850779472263e$var$assert(j==129);for(;b<$cPNKB.CBANDS;++b){max[b]=0;avg[b]=0;}psyvbr_calc_mask_index_s(gfc,max,avg,mask_idx_s);for(j=b=0;b<gfc.npart_s;b++){var kk=gfc.s3ind_s[b][0];var last=gfc.s3ind_s[b][1];var dd,dd_n;var x,ecb,avg_mask;dd=mask_idx_s[kk];dd_n=1;ecb=gfc.s3_ss[j]*eb[kk]*tab[mask_idx_s[kk]];++j;++kk;while(kk<=last){dd+=mask_idx_s[kk];dd_n+=1;x=gfc.s3_ss[j]*eb[kk]*tab[mask_idx_s[kk]];ecb=vbrpsy_mask_add(ecb,x,kk-b);++j;++kk;}dd=(1+2*dd)/(2*dd_n);avg_mask=tab[dd]*0.5;ecb*=avg_mask;thr[b]=ecb;gfc.nb_s2[chn][b]=gfc.nb_s1[chn][b];gfc.nb_s1[chn][b]=ecb;/*
559
+ * if THR exceeds EB, the quantization routines will take the
560
+ * difference from other bands. in case of strong tonal samples
561
+ * (tonaltest.wav) this leads to heavy distortions. that's why
562
+ * we limit THR here.
563
+ */x=max[b];x*=gfc.minval_s[b];x*=avg_mask;if(thr[b]>x)thr[b]=x;if(gfc.masking_lower>1)thr[b]*=gfc.masking_lower;if(thr[b]>eb[b])thr[b]=eb[b];if(gfc.masking_lower<1)thr[b]*=gfc.masking_lower;$97f850779472263e$var$assert(thr[b]>=0);}for(;b<$cPNKB.CBANDS;++b){eb[b]=0;thr[b]=0;}}function vbrpsy_compute_masking_l(gfc,fftenergy,eb_l,thr,chn){var max=$97f850779472263e$var$new_float($cPNKB.CBANDS),avg=$97f850779472263e$var$new_float($cPNKB.CBANDS);var mask_idx_l=$97f850779472263e$var$new_int($cPNKB.CBANDS+2);var b;/*********************************************************************
564
+ * Calculate the energy and the tonality of each partition.
565
+ *********************************************************************/calc_energy(gfc,fftenergy,eb_l,max,avg);calc_mask_index_l(gfc,max,avg,mask_idx_l);/*********************************************************************
566
+ * convolve the partitioned energy and unpredictability with the
567
+ * spreading function, s3_l[b][k]
568
+ ********************************************************************/var k=0;for(b=0;b<gfc.npart_l;b++){var x,ecb,avg_mask,t;/* convolve the partitioned energy with the spreading function */var kk=gfc.s3ind[b][0];var last=gfc.s3ind[b][1];var dd=0,dd_n=0;dd=mask_idx_l[kk];dd_n+=1;ecb=gfc.s3_ll[k]*eb_l[kk]*tab[mask_idx_l[kk]];++k;++kk;while(kk<=last){dd+=mask_idx_l[kk];dd_n+=1;x=gfc.s3_ll[k]*eb_l[kk]*tab[mask_idx_l[kk]];t=vbrpsy_mask_add(ecb,x,kk-b);ecb=t;++k;++kk;}dd=(1+2*dd)/(2*dd_n);avg_mask=tab[dd]*0.5;ecb*=avg_mask;/**** long block pre-echo control ****/ /**
569
+ * <PRE>
570
+ * dont use long block pre-echo control if previous granule was
571
+ * a short block. This is to avoid the situation:
572
+ * frame0: quiet (very low masking)
573
+ * frame1: surge (triggers short blocks)
574
+ * frame2: regular frame. looks like pre-echo when compared to
575
+ * frame0, but all pre-echo was in frame1.
576
+ * </PRE>
577
+ */ /*
578
+ * chn=0,1 L and R channels chn=2,3 S and M channels.
579
+ */if(gfc.blocktype_old[chn&0x01]==$cPNKB.SHORT_TYPE){var ecb_limit=rpelev*gfc.nb_1[chn][b];if(ecb_limit>0)thr[b]=Math.min(ecb,ecb_limit);else/**
580
+ * <PRE>
581
+ * Robert 071209:
582
+ * Because we don't calculate long block psy when we know a granule
583
+ * should be of short blocks, we don't have any clue how the granule
584
+ * before would have looked like as a long block. So we have to guess
585
+ * a little bit for this END_TYPE block.
586
+ * Most of the time we get away with this sloppyness. (fingers crossed :)
587
+ * The speed increase is worth it.
588
+ * </PRE>
589
+ */thr[b]=Math.min(ecb,eb_l[b]*NS_PREECHO_ATT2);}else {var ecb_limit_2=rpelev2*gfc.nb_2[chn][b];var ecb_limit_1=rpelev*gfc.nb_1[chn][b];var ecb_limit;if(ecb_limit_2<=0)ecb_limit_2=ecb;if(ecb_limit_1<=0)ecb_limit_1=ecb;if(gfc.blocktype_old[chn&0x01]==$cPNKB.NORM_TYPE)ecb_limit=Math.min(ecb_limit_1,ecb_limit_2);else ecb_limit=ecb_limit_1;thr[b]=Math.min(ecb,ecb_limit);}gfc.nb_2[chn][b]=gfc.nb_1[chn][b];gfc.nb_1[chn][b]=ecb;/*
590
+ * if THR exceeds EB, the quantization routines will take the
591
+ * difference from other bands. in case of strong tonal samples
592
+ * (tonaltest.wav) this leads to heavy distortions. that's why
593
+ * we limit THR here.
594
+ */x=max[b];x*=gfc.minval_l[b];x*=avg_mask;if(thr[b]>x)thr[b]=x;if(gfc.masking_lower>1)thr[b]*=gfc.masking_lower;if(thr[b]>eb_l[b])thr[b]=eb_l[b];if(gfc.masking_lower<1)thr[b]*=gfc.masking_lower;$97f850779472263e$var$assert(thr[b]>=0);}for(;b<$cPNKB.CBANDS;++b){eb_l[b]=0;thr[b]=0;}}function vbrpsy_compute_block_type(gfp,uselongblock){var gfc=gfp.internal_flags;if(gfp.short_blocks==$97f850779472263e$var$ShortBlock.short_block_coupled&&!(uselongblock[0]!=0&&uselongblock[1]!=0))uselongblock[0]=uselongblock[1]=0;for(var chn=0;chn<gfc.channels_out;chn++){/* disable short blocks */if(gfp.short_blocks==$97f850779472263e$var$ShortBlock.short_block_dispensed)uselongblock[chn]=1;if(gfp.short_blocks==$97f850779472263e$var$ShortBlock.short_block_forced)uselongblock[chn]=0;}}function vbrpsy_apply_block_type(gfp,uselongblock,blocktype_d){var gfc=gfp.internal_flags;/*
595
+ * update the blocktype of the previous granule, since it depends on
596
+ * what happend in this granule
597
+ */for(var chn=0;chn<gfc.channels_out;chn++){var blocktype=$cPNKB.NORM_TYPE;/* disable short blocks */if(uselongblock[chn]!=0){/* no attack : use long blocks */$97f850779472263e$var$assert(gfc.blocktype_old[chn]!=$cPNKB.START_TYPE);if(gfc.blocktype_old[chn]==$cPNKB.SHORT_TYPE)blocktype=$cPNKB.STOP_TYPE;}else {/* attack : use short blocks */blocktype=$cPNKB.SHORT_TYPE;if(gfc.blocktype_old[chn]==$cPNKB.NORM_TYPE)gfc.blocktype_old[chn]=$cPNKB.START_TYPE;if(gfc.blocktype_old[chn]==$cPNKB.STOP_TYPE)gfc.blocktype_old[chn]=$cPNKB.SHORT_TYPE;}blocktype_d[chn]=gfc.blocktype_old[chn];// value returned to calling program
598
+ gfc.blocktype_old[chn]=blocktype;// save for next call to l3psy_anal
599
+ }}/**
600
+ * compute M/S thresholds from Johnston & Ferreira 1992 ICASSP paper
601
+ */function vbrpsy_compute_MS_thresholds(eb,thr,cb_mld,ath_cb,athadjust,msfix,n){var msfix2=msfix*2;var athlower=msfix>0?Math.pow(10,athadjust):1;var rside,rmid;for(var b=0;b<n;++b){var ebM=eb[2][b];var ebS=eb[3][b];var thmL=thr[0][b];var thmR=thr[1][b];var thmM=thr[2][b];var thmS=thr[3][b];/* use this fix if L & R masking differs by 2db or less */if(thmL<=1.58*thmR&&thmR<=1.58*thmL){var mld_m=cb_mld[b]*ebS;var mld_s=cb_mld[b]*ebM;rmid=Math.max(thmM,Math.min(thmS,mld_m));rside=Math.max(thmS,Math.min(thmM,mld_s));}else {rmid=thmM;rside=thmS;}if(msfix>0){/***************************************************************/ /* Adjust M/S maskings if user set "msfix" */ /***************************************************************/ /* Naoki Shibata 2000 */var thmLR,thmMS;var ath=ath_cb[b]*athlower;thmLR=Math.min(Math.max(thmL,ath),Math.max(thmR,ath));thmM=Math.max(rmid,ath);thmS=Math.max(rside,ath);thmMS=thmM+thmS;if(thmMS>0&&thmLR*msfix2<thmMS){var f=thmLR*msfix2/thmMS;thmM*=f;thmS*=f;$97f850779472263e$var$assert(thmMS>0);}rmid=Math.min(thmM,rmid);rside=Math.min(thmS,rside);}if(rmid>ebM)rmid=ebM;if(rside>ebS)rside=ebS;thr[2][b]=rmid;thr[3][b]=rside;}}this.L3psycho_anal_vbr=function(gfp,buffer,bufPos,gr_out,masking_ratio,masking_MS_ratio,percep_entropy,percep_MS_entropy,energy,blocktype_d){var gfc=gfp.internal_flags;/* fft and energy calculation */var wsamp_l;var wsamp_s;var fftenergy=$97f850779472263e$var$new_float($cPNKB.HBLKSIZE);var fftenergy_s=$97f850779472263e$var$new_float_n([3,$cPNKB.HBLKSIZE_s]);var wsamp_L=$97f850779472263e$var$new_float_n([2,$cPNKB.BLKSIZE]);var wsamp_S=$97f850779472263e$var$new_float_n([2,3,$cPNKB.BLKSIZE_s]);var eb=$97f850779472263e$var$new_float_n([4,$cPNKB.CBANDS]),thr=$97f850779472263e$var$new_float_n([4,$cPNKB.CBANDS]);var sub_short_factor=$97f850779472263e$var$new_float_n([4,3]);var pcfact=0.6;/* block type */var ns_attacks=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]];var uselongblock=$97f850779472263e$var$new_int(2);/* usual variables like loop indices, etc.. */ /* chn=2 and 3 = Mid and Side channels */var n_chn_psy=gfp.mode==MPEGMode.JOINT_STEREO?4:gfc.channels_out;vbrpsy_attack_detection(gfp,buffer,bufPos,gr_out,masking_ratio,masking_MS_ratio,energy,sub_short_factor,ns_attacks,uselongblock);vbrpsy_compute_block_type(gfp,uselongblock);for(var chn=0;chn<n_chn_psy;chn++){var ch01=chn&0x01;wsamp_l=wsamp_L;vbrpsy_compute_fft_l(gfp,buffer,bufPos,chn,gr_out,fftenergy,wsamp_l,ch01);vbrpsy_compute_loudness_approximation_l(gfp,gr_out,chn,fftenergy);if(uselongblock[ch01]!=0)vbrpsy_compute_masking_l(gfc,fftenergy,eb[chn],thr[chn],chn);else vbrpsy_skip_masking_l(gfc,chn);}if(uselongblock[0]+uselongblock[1]==2)/* M/S channel */{if(gfp.mode==MPEGMode.JOINT_STEREO)vbrpsy_compute_MS_thresholds(eb,thr,gfc.mld_cb_l,gfc.ATH.cb_l,gfp.ATHlower*gfc.ATH.adjust,gfp.msfix,gfc.npart_l);}/* TODO: apply adaptive ATH masking here ?? */for(var chn=0;chn<n_chn_psy;chn++){var ch01=chn&0x01;if(uselongblock[ch01]!=0)convert_partition2scalefac_l(gfc,eb[chn],thr[chn],chn);}for(var sblock=0;sblock<3;sblock++){for(var chn=0;chn<n_chn_psy;++chn){var ch01=chn&0x01;if(uselongblock[ch01]!=0)vbrpsy_skip_masking_s(gfc,chn,sblock);else {/* compute masking thresholds for short blocks */wsamp_s=wsamp_S;vbrpsy_compute_fft_s(gfp,buffer,bufPos,chn,sblock,fftenergy_s,wsamp_s,ch01);vbrpsy_compute_masking_s(gfp,fftenergy_s,eb[chn],thr[chn],chn,sblock);}}if(uselongblock[0]+uselongblock[1]==0)/* M/S channel */{if(gfp.mode==MPEGMode.JOINT_STEREO)vbrpsy_compute_MS_thresholds(eb,thr,gfc.mld_cb_s,gfc.ATH.cb_s,gfp.ATHlower*gfc.ATH.adjust,gfp.msfix,gfc.npart_s);}/* TODO: apply adaptive ATH masking here ?? */for(var chn=0;chn<n_chn_psy;++chn){var ch01=chn&0x01;if(0==uselongblock[ch01])convert_partition2scalefac_s(gfc,eb[chn],thr[chn],chn,sblock);}}/**** short block pre-echo control ****/for(var chn=0;chn<n_chn_psy;chn++){var ch01=chn&0x01;if(uselongblock[ch01]!=0)continue;for(var sb=0;sb<$cPNKB.SBMAX_s;sb++){var new_thmm=$97f850779472263e$var$new_float(3);for(var sblock=0;sblock<3;sblock++){var thmm=gfc.thm[chn].s[sb][sblock];thmm*=NS_PREECHO_ATT0;if(ns_attacks[chn][sblock]>=2||ns_attacks[chn][sblock+1]==1){var idx=sblock!=0?sblock-1:2;var p=NS_INTERP(gfc.thm[chn].s[sb][idx],thmm,NS_PREECHO_ATT1*pcfact);thmm=Math.min(thmm,p);}else if(ns_attacks[chn][sblock]==1){var idx=sblock!=0?sblock-1:2;var p=NS_INTERP(gfc.thm[chn].s[sb][idx],thmm,NS_PREECHO_ATT2*pcfact);thmm=Math.min(thmm,p);}else if(sblock!=0&&ns_attacks[chn][sblock-1]==3||sblock==0&&gfc.nsPsy.lastAttacks[chn]==3){var idx=sblock!=2?sblock+1:0;var p=NS_INTERP(gfc.thm[chn].s[sb][idx],thmm,NS_PREECHO_ATT2*pcfact);thmm=Math.min(thmm,p);}/* pulse like signal detection for fatboy.wav and so on */thmm*=sub_short_factor[chn][sblock];new_thmm[sblock]=thmm;}for(var sblock=0;sblock<3;sblock++)gfc.thm[chn].s[sb][sblock]=new_thmm[sblock];}}for(var chn=0;chn<n_chn_psy;chn++)gfc.nsPsy.lastAttacks[chn]=ns_attacks[chn][2];/***************************************************************
602
+ * determine final block type
603
+ ***************************************************************/vbrpsy_apply_block_type(gfp,uselongblock,blocktype_d);/*********************************************************************
604
+ * compute the value of PE to return ... no delay and advance
605
+ *********************************************************************/for(var chn=0;chn<n_chn_psy;chn++){var ppe;var ppePos;var type;var mr;if(chn>1){ppe=percep_MS_entropy;ppePos=-2;type=$cPNKB.NORM_TYPE;if(blocktype_d[0]==$cPNKB.SHORT_TYPE||blocktype_d[1]==$cPNKB.SHORT_TYPE)type=$cPNKB.SHORT_TYPE;mr=masking_MS_ratio[gr_out][chn-2];}else {ppe=percep_entropy;ppePos=0;type=blocktype_d[chn];mr=masking_ratio[gr_out][chn];}if(type==$cPNKB.SHORT_TYPE)ppe[ppePos+chn]=pecalc_s(mr,gfc.masking_lower);else ppe[ppePos+chn]=pecalc_l(mr,gfc.masking_lower);if(gfp.analysis)gfc.pinfo.pe[gr_out][chn]=ppe[ppePos+chn];}return 0;};function s3_func_x(bark,hf_slope){var tempx=bark,tempy;if(tempx>=0)tempy=-tempx*27;else tempy=tempx*hf_slope;if(tempy<=-72)return 0;return Math.exp(tempy*LN_TO_LOG10);}function norm_s3_func_x(hf_slope){var lim_a=0,lim_b=0;var x=0,l,h;for(x=0;s3_func_x(x,hf_slope)>1e-20;x-=1);l=x;h=0;while(Math.abs(h-l)>1e-12){x=(h+l)/2;if(s3_func_x(x,hf_slope)>0)h=x;else l=x;}lim_a=l;var x=0,l,h;for(x=0;s3_func_x(x,hf_slope)>1e-20;x+=1);l=0;h=x;while(Math.abs(h-l)>1e-12){x=(h+l)/2;if(s3_func_x(x,hf_slope)>0)l=x;else h=x;}lim_b=h;var sum=0;var m=1000;var i;for(i=0;i<=m;++i){var x=lim_a+i*(lim_b-lim_a)/m;var y=s3_func_x(x,hf_slope);sum+=y;}var norm=(m+1)/(sum*(lim_b-lim_a));/* printf( "norm = %lf\n",norm); */return norm;}/**
606
+ * The spreading function. Values returned in units of energy
607
+ */function s3_func(bark){var tempx,x,tempy,temp;tempx=bark;if(tempx>=0)tempx*=3;else tempx*=1.5;if(tempx>=0.5&&tempx<=2.5){temp=tempx-0.5;x=8.0*(temp*temp-2.0*temp);}else x=0.0;tempx+=0.474;tempy=15.811389+7.5*tempx-17.5*Math.sqrt(1.0+tempx*tempx);if(tempy<=-60)return 0.0;tempx=Math.exp((x+tempy)*LN_TO_LOG10);/**
608
+ * <PRE>
609
+ * Normalization. The spreading function should be normalized so that:
610
+ * +inf
611
+ * /
612
+ * | s3 [ bark ] d(bark) = 1
613
+ * /
614
+ * -inf
615
+ * </PRE>
616
+ */tempx/=.6609193;return tempx;}/**
617
+ * see for example "Zwicker: Psychoakustik, 1982; ISBN 3-540-11401-7
618
+ */function freq2bark(freq){/* input: freq in hz output: barks */if(freq<0)freq=0;freq=freq*0.001;return 13.0*Math.atan(.76*freq)+3.5*Math.atan(freq*freq/56.25);}function init_numline(numlines,bo,bm,bval,bval_width,mld,bo_w,sfreq,blksize,scalepos,deltafreq,sbmax){var b_frq=$97f850779472263e$var$new_float($cPNKB.CBANDS+1);var sample_freq_frac=sfreq/(sbmax>15?1152:384);var partition=$97f850779472263e$var$new_int($cPNKB.HBLKSIZE);var i;sfreq/=blksize;var j=0;var ni=0;/* compute numlines, the number of spectral lines in each partition band */ /* each partition band should be about DELBARK wide. */for(i=0;i<$cPNKB.CBANDS;i++){var bark1;var j2;bark1=freq2bark(sfreq*j);b_frq[i]=sfreq*j;for(j2=j;freq2bark(sfreq*j2)-bark1<DELBARK&&j2<=blksize/2;j2++);numlines[i]=j2-j;ni=i+1;while(j<j2){$97f850779472263e$var$assert(j<$cPNKB.HBLKSIZE);partition[j++]=i;}if(j>blksize/2){j=blksize/2;++i;break;}}$97f850779472263e$var$assert(i<$cPNKB.CBANDS);b_frq[i]=sfreq*j;for(var sfb=0;sfb<sbmax;sfb++){var i1,i2,start,end;var arg;start=scalepos[sfb];end=scalepos[sfb+1];i1=0|Math.floor(.5+deltafreq*(start-.5));if(i1<0)i1=0;i2=0|Math.floor(.5+deltafreq*(end-.5));if(i2>blksize/2)i2=blksize/2;bm[sfb]=(partition[i1]+partition[i2])/2;bo[sfb]=partition[i2];var f_tmp=sample_freq_frac*end;/*
619
+ * calculate how much of this band belongs to current scalefactor
620
+ * band
621
+ */bo_w[sfb]=(f_tmp-b_frq[bo[sfb]])/(b_frq[bo[sfb]+1]-b_frq[bo[sfb]]);if(bo_w[sfb]<0)bo_w[sfb]=0;else if(bo_w[sfb]>1)bo_w[sfb]=1;/* setup stereo demasking thresholds */ /* formula reverse enginerred from plot in paper */arg=freq2bark(sfreq*scalepos[sfb]*deltafreq);arg=Math.min(arg,15.5)/15.5;mld[sfb]=Math.pow(10.0,1.25*(1-Math.cos(Math.PI*arg))-2.5);}/* compute bark values of each critical band */j=0;for(var k=0;k<ni;k++){var w=numlines[k];var bark1,bark2;bark1=freq2bark(sfreq*j);bark2=freq2bark(sfreq*(j+w-1));bval[k]=.5*(bark1+bark2);bark1=freq2bark(sfreq*(j-.5));bark2=freq2bark(sfreq*(j+w-.5));bval_width[k]=bark2-bark1;j+=w;}return ni;}function init_s3_values(s3ind,npart,bval,bval_width,norm,use_old_s3){var s3=$97f850779472263e$var$new_float_n([$cPNKB.CBANDS,$cPNKB.CBANDS]);/*
622
+ * The s3 array is not linear in the bark scale.
623
+ *
624
+ * bval[x] should be used to get the bark value.
625
+ */var j;var numberOfNoneZero=0;/**
626
+ * <PRE>
627
+ * s[i][j], the value of the spreading function,
628
+ * centered at band j (masker), for band i (maskee)
629
+ *
630
+ * i.e.: sum over j to spread into signal barkval=i
631
+ * NOTE: i and j are used opposite as in the ISO docs
632
+ * </PRE>
633
+ */if(use_old_s3){for(var i=0;i<npart;i++)for(j=0;j<npart;j++){var v=s3_func(bval[i]-bval[j])*bval_width[j];s3[i][j]=v*norm[i];}}else for(j=0;j<npart;j++){var hf_slope=15+Math.min(21/bval[j],12);var s3_x_norm=norm_s3_func_x(hf_slope);for(var i=0;i<npart;i++){var v=s3_x_norm*s3_func_x(bval[i]-bval[j],hf_slope)*bval_width[j];s3[i][j]=v*norm[i];}}for(var i=0;i<npart;i++){for(j=0;j<npart;j++){if(s3[i][j]>0.0)break;}s3ind[i][0]=j;for(j=npart-1;j>0;j--){if(s3[i][j]>0.0)break;}s3ind[i][1]=j;numberOfNoneZero+=s3ind[i][1]-s3ind[i][0]+1;}var p=$97f850779472263e$var$new_float(numberOfNoneZero);var k=0;for(var i=0;i<npart;i++)for(j=s3ind[i][0];j<=s3ind[i][1];j++)p[k++]=s3[i][j];return p;}function stereo_demask(f){/* setup stereo demasking thresholds */ /* formula reverse enginerred from plot in paper */var arg=freq2bark(f);arg=Math.min(arg,15.5)/15.5;return Math.pow(10.0,1.25*(1-Math.cos(Math.PI*arg))-2.5);}/**
634
+ * NOTE: the bitrate reduction from the inter-channel masking effect is low
635
+ * compared to the chance of getting annyoing artefacts. L3psycho_anal_vbr
636
+ * does not use this feature. (Robert 071216)
637
+ */this.psymodel_init=function(gfp){var gfc=gfp.internal_flags;var i;var useOldS3=true;var bvl_a=13,bvl_b=24;var snr_l_a=0,snr_l_b=0;var snr_s_a=-8.25,snr_s_b=-4.5;var bval=$97f850779472263e$var$new_float($cPNKB.CBANDS);var bval_width=$97f850779472263e$var$new_float($cPNKB.CBANDS);var norm=$97f850779472263e$var$new_float($cPNKB.CBANDS);var sfreq=gfp.out_samplerate;switch(gfp.experimentalZ){default:case 0:useOldS3=true;break;case 1:useOldS3=gfp.VBR==$97f850779472263e$var$VbrMode.vbr_mtrh||gfp.VBR==$97f850779472263e$var$VbrMode.vbr_mt?false:true;break;case 2:useOldS3=false;break;case 3:bvl_a=8;snr_l_a=-1.75;snr_l_b=-0.0125;snr_s_a=-8.25;snr_s_b=-2.25;break;}gfc.ms_ener_ratio_old=.25;gfc.blocktype_old[0]=gfc.blocktype_old[1]=$cPNKB.NORM_TYPE;// the vbr header is long blocks
638
+ for(i=0;i<4;++i){for(var j=0;j<$cPNKB.CBANDS;++j){gfc.nb_1[i][j]=1e20;gfc.nb_2[i][j]=1e20;gfc.nb_s1[i][j]=gfc.nb_s2[i][j]=1.0;}for(var sb=0;sb<$cPNKB.SBMAX_l;sb++){gfc.en[i].l[sb]=1e20;gfc.thm[i].l[sb]=1e20;}for(var j=0;j<3;++j){for(var sb=0;sb<$cPNKB.SBMAX_s;sb++){gfc.en[i].s[sb][j]=1e20;gfc.thm[i].s[sb][j]=1e20;}gfc.nsPsy.lastAttacks[i]=0;}for(var j=0;j<9;j++)gfc.nsPsy.last_en_subshort[i][j]=10.;}/* init. for loudness approx. -jd 2001 mar 27 */gfc.loudness_sq_save[0]=gfc.loudness_sq_save[1]=0.0;/*************************************************************************
639
+ * now compute the psychoacoustic model specific constants
640
+ ************************************************************************/ /* compute numlines, bo, bm, bval, bval_width, mld */gfc.npart_l=init_numline(gfc.numlines_l,gfc.bo_l,gfc.bm_l,bval,bval_width,gfc.mld_l,gfc.PSY.bo_l_weight,sfreq,$cPNKB.BLKSIZE,gfc.scalefac_band.l,$cPNKB.BLKSIZE/1152,$cPNKB.SBMAX_l);$97f850779472263e$var$assert(gfc.npart_l<$cPNKB.CBANDS);/* compute the spreading function */for(i=0;i<gfc.npart_l;i++){var snr=snr_l_a;if(bval[i]>=bvl_a)snr=snr_l_b*(bval[i]-bvl_a)/(bvl_b-bvl_a)+snr_l_a*(bvl_b-bval[i])/(bvl_b-bvl_a);norm[i]=Math.pow(10.0,snr/10.0);if(gfc.numlines_l[i]>0)gfc.rnumlines_l[i]=1.0/gfc.numlines_l[i];else gfc.rnumlines_l[i]=0;}gfc.s3_ll=init_s3_values(gfc.s3ind,gfc.npart_l,bval,bval_width,norm,useOldS3);/* compute long block specific values, ATH and MINVAL */var j=0;for(i=0;i<gfc.npart_l;i++){var x;/* ATH */x=$97f850779472263e$var$Float.MAX_VALUE;for(var k=0;k<gfc.numlines_l[i];k++,j++){var freq=sfreq*j/(1000.0*$cPNKB.BLKSIZE);var level;/*
641
+ * ATH below 100 Hz constant, not further climbing
642
+ */level=this.ATHformula(freq*1000,gfp)-20;// scale to FFT units; returned value is in dB
643
+ level=Math.pow(10.,0.1*level);// convert from dB . energy
644
+ level*=gfc.numlines_l[i];if(x>level)x=level;}gfc.ATH.cb_l[i]=x;/*
645
+ * MINVAL. For low freq, the strength of the masking is limited by
646
+ * minval this is an ISO MPEG1 thing, dont know if it is really
647
+ * needed
648
+ */ /*
649
+ * FIXME: it does work to reduce low-freq problems in S53-Wind-Sax
650
+ * and lead-voice samples, but introduces some 3 kbps bit bloat too.
651
+ * TODO: Further refinement of the shape of this hack.
652
+ */x=-20+bval[i]*20/10;if(x>6)x=100;if(x<-15)x=-15;x-=8.;gfc.minval_l[i]=Math.pow(10.0,x/10.)*gfc.numlines_l[i];}/************************************************************************
653
+ * do the same things for short blocks
654
+ ************************************************************************/gfc.npart_s=init_numline(gfc.numlines_s,gfc.bo_s,gfc.bm_s,bval,bval_width,gfc.mld_s,gfc.PSY.bo_s_weight,sfreq,$cPNKB.BLKSIZE_s,gfc.scalefac_band.s,$cPNKB.BLKSIZE_s/384,$cPNKB.SBMAX_s);$97f850779472263e$var$assert(gfc.npart_s<$cPNKB.CBANDS);/* SNR formula. short block is normalized by SNR. is it still right ? */j=0;for(i=0;i<gfc.npart_s;i++){var x;var snr=snr_s_a;if(bval[i]>=bvl_a)snr=snr_s_b*(bval[i]-bvl_a)/(bvl_b-bvl_a)+snr_s_a*(bvl_b-bval[i])/(bvl_b-bvl_a);norm[i]=Math.pow(10.0,snr/10.0);/* ATH */x=$97f850779472263e$var$Float.MAX_VALUE;for(var k=0;k<gfc.numlines_s[i];k++,j++){var freq=sfreq*j/(1000.0*$cPNKB.BLKSIZE_s);var level;/* freq = Min(.1,freq); */ /*
655
+ * ATH below 100 Hz constant, not
656
+ * further climbing
657
+ */level=this.ATHformula(freq*1000,gfp)-20;// scale to FFT units; returned value is in dB
658
+ level=Math.pow(10.,0.1*level);// convert from dB . energy
659
+ level*=gfc.numlines_s[i];if(x>level)x=level;}gfc.ATH.cb_s[i]=x;/*
660
+ * MINVAL. For low freq, the strength of the masking is limited by
661
+ * minval this is an ISO MPEG1 thing, dont know if it is really
662
+ * needed
663
+ */x=-7+bval[i]*7.0/12.0;if(bval[i]>12)x*=1+Math.log(1+x)*3.1;if(bval[i]<12)x*=1+Math.log(1-x)*2.3;if(x<-15)x=-15;x-=8;gfc.minval_s[i]=Math.pow(10.0,x/10)*gfc.numlines_s[i];}gfc.s3_ss=init_s3_values(gfc.s3ind_s,gfc.npart_s,bval,bval_width,norm,useOldS3);init_mask_add_max_values();fft.init_fft(gfc);/* setup temporal masking */gfc.decay=Math.exp(-1*LOG10/(temporalmask_sustain_sec*sfreq/192.0));var msfix;msfix=NS_MSFIX;if((gfp.exp_nspsytune&2)!=0)msfix=1.0;if(Math.abs(gfp.msfix)>0.0)msfix=gfp.msfix;gfp.msfix=msfix;/*
664
+ * spread only from npart_l bands. Normally, we use the spreading
665
+ * function to convolve from npart_l down to npart_l bands
666
+ */for(var b=0;b<gfc.npart_l;b++)if(gfc.s3ind[b][1]>gfc.npart_l-1)gfc.s3ind[b][1]=gfc.npart_l-1;/*
667
+ * prepare for ATH auto adjustment: we want to decrease the ATH by 12 dB
668
+ * per second
669
+ */var frame_duration=576.*gfc.mode_gr/sfreq;gfc.ATH.decay=Math.pow(10.,-1.2*frame_duration);gfc.ATH.adjust=0.01;/* minimum, for leading low loudness */gfc.ATH.adjustLimit=1.0;/* on lead, allow adjust up to maximum */$97f850779472263e$var$assert(gfc.bo_l[$cPNKB.SBMAX_l-1]<=gfc.npart_l);$97f850779472263e$var$assert(gfc.bo_s[$cPNKB.SBMAX_s-1]<=gfc.npart_s);if(gfp.ATHtype!=-1){/* compute equal loudness weights (eql_w) */var freq;var freq_inc=gfp.out_samplerate/$cPNKB.BLKSIZE;var eql_balance=0.0;freq=0.0;for(i=0;i<$cPNKB.BLKSIZE/2;++i){/* convert ATH dB to relative power (not dB) */ /* to determine eql_w */freq+=freq_inc;gfc.ATH.eql_w[i]=1./Math.pow(10,this.ATHformula(freq,gfp)/10);eql_balance+=gfc.ATH.eql_w[i];}eql_balance=1.0/eql_balance;for(i=$cPNKB.BLKSIZE/2;--i>=0;)gfc.ATH.eql_w[i]*=eql_balance;}for(var b=j=0;b<gfc.npart_s;++b)for(i=0;i<gfc.numlines_s[b];++i)++j;$97f850779472263e$var$assert(j==129);for(var b=j=0;b<gfc.npart_l;++b)for(i=0;i<gfc.numlines_l[b];++i)++j;$97f850779472263e$var$assert(j==513);j=0;for(i=0;i<gfc.npart_l;i++){var freq=sfreq*(j+gfc.numlines_l[i]/2)/(1.0*$cPNKB.BLKSIZE);gfc.mld_cb_l[i]=stereo_demask(freq);j+=gfc.numlines_l[i];}for(;i<$cPNKB.CBANDS;++i)gfc.mld_cb_l[i]=1;j=0;for(i=0;i<gfc.npart_s;i++){var freq=sfreq*(j+gfc.numlines_s[i]/2)/(1.0*$cPNKB.BLKSIZE_s);gfc.mld_cb_s[i]=stereo_demask(freq);j+=gfc.numlines_s[i];}for(;i<$cPNKB.CBANDS;++i)gfc.mld_cb_s[i]=1;return 0;};/**
670
+ * Those ATH formulas are returning their minimum value for input = -1
671
+ */function ATHformula_GB(f,value){/**
672
+ * <PRE>
673
+ * from Painter & Spanias
674
+ * modified by Gabriel Bouvigne to better fit the reality
675
+ * ath = 3.640 * pow(f,-0.8)
676
+ * - 6.800 * exp(-0.6*pow(f-3.4,2.0))
677
+ * + 6.000 * exp(-0.15*pow(f-8.7,2.0))
678
+ * + 0.6* 0.001 * pow(f,4.0);
679
+ *
680
+ *
681
+ * In the past LAME was using the Painter &Spanias formula.
682
+ * But we had some recurrent problems with HF content.
683
+ * We measured real ATH values, and found the older formula
684
+ * to be inaccurate in the higher part. So we made this new
685
+ * formula and this solved most of HF problematic test cases.
686
+ * The tradeoff is that in VBR mode it increases a lot the
687
+ * bitrate.
688
+ * </PRE>
689
+ */ /*
690
+ * This curve can be adjusted according to the VBR scale: it adjusts
691
+ * from something close to Painter & Spanias on V9 up to Bouvigne's
692
+ * formula for V0. This way the VBR bitrate is more balanced according
693
+ * to the -V value.
694
+ */ // the following Hack allows to ask for the lowest value
695
+ if(f<-0.3)f=3410;// convert to khz
696
+ f/=1000;f=Math.max(0.1,f);var ath=3.640*Math.pow(f,-0.8)-6.800*Math.exp(-0.6*Math.pow(f-3.4,2.0))+6.000*Math.exp(-0.15*Math.pow(f-8.7,2.0))+(0.6+0.04*value)*0.001*Math.pow(f,4.0);return ath;}this.ATHformula=function(f,gfp){var ath;switch(gfp.ATHtype){case 0:ath=ATHformula_GB(f,9);break;case 1:// over sensitive, should probably be removed
697
+ ath=ATHformula_GB(f,-1);break;case 2:ath=ATHformula_GB(f,0);break;case 3:// modification of GB formula by Roel
698
+ ath=ATHformula_GB(f,1)+6;break;case 4:ath=ATHformula_GB(f,gfp.ATHcurve);break;default:ath=ATHformula_GB(f,0);break;}return ath;};}module.exports=$97f850779472263e$var$PsyModel;});parcelRequire.register("2g11P",function(module,exports){var $3YDN3=parcelRequire("3YDN3");$3YDN3.System;$3YDN3.VbrMode;$3YDN3.Float;$3YDN3.ShortBlock;var $1a4ddf9b01454eb6$var$Util=$3YDN3.Util;$3YDN3.Arrays;$3YDN3.new_array_n;$3YDN3.new_byte;$3YDN3.new_double;var $1a4ddf9b01454eb6$var$new_float=$3YDN3.new_float;$3YDN3.new_float_n;$3YDN3.new_int;$3YDN3.new_int_n;$3YDN3.assert;var $cPNKB=parcelRequire("cPNKB");function $1a4ddf9b01454eb6$var$FFT(){var window=$1a4ddf9b01454eb6$var$new_float($cPNKB.BLKSIZE);var window_s=$1a4ddf9b01454eb6$var$new_float($cPNKB.BLKSIZE_s/2);var costab=[9.238795325112867e-01,3.826834323650898e-01,9.951847266721969e-01,9.801714032956060e-02,9.996988186962042e-01,2.454122852291229e-02,9.999811752826011e-01,6.135884649154475e-03];function fht(fz,fzPos,n){var tri=0;var k4;var fi;var gi;n<<=1;/* to get BLKSIZE, because of 3DNow! ASM routine */var fn=fzPos+n;k4=4;do{var s1,c1;var i,k1,k2,k3,kx;kx=k4>>1;k1=k4;k2=k4<<1;k3=k2+k1;k4=k2<<1;fi=fzPos;gi=fi+kx;do{var f0,f1,f2,f3;f1=fz[fi+0]-fz[fi+k1];f0=fz[fi+0]+fz[fi+k1];f3=fz[fi+k2]-fz[fi+k3];f2=fz[fi+k2]+fz[fi+k3];fz[fi+k2]=f0-f2;fz[fi+0]=f0+f2;fz[fi+k3]=f1-f3;fz[fi+k1]=f1+f3;f1=fz[gi+0]-fz[gi+k1];f0=fz[gi+0]+fz[gi+k1];f3=$1a4ddf9b01454eb6$var$Util.SQRT2*fz[gi+k3];f2=$1a4ddf9b01454eb6$var$Util.SQRT2*fz[gi+k2];fz[gi+k2]=f0-f2;fz[gi+0]=f0+f2;fz[gi+k3]=f1-f3;fz[gi+k1]=f1+f3;gi+=k4;fi+=k4;}while(fi<fn);c1=costab[tri+0];s1=costab[tri+1];for(i=1;i<kx;i++){var c2,s2;c2=1-2*s1*s1;s2=2*s1*c1;fi=fzPos+i;gi=fzPos+k1-i;do{var a,b,g0,f0,f1,g1,f2,g2,f3,g3;b=s2*fz[fi+k1]-c2*fz[gi+k1];a=c2*fz[fi+k1]+s2*fz[gi+k1];f1=fz[fi+0]-a;f0=fz[fi+0]+a;g1=fz[gi+0]-b;g0=fz[gi+0]+b;b=s2*fz[fi+k3]-c2*fz[gi+k3];a=c2*fz[fi+k3]+s2*fz[gi+k3];f3=fz[fi+k2]-a;f2=fz[fi+k2]+a;g3=fz[gi+k2]-b;g2=fz[gi+k2]+b;b=s1*f2-c1*g3;a=c1*f2+s1*g3;fz[fi+k2]=f0-a;fz[fi+0]=f0+a;fz[gi+k3]=g1-b;fz[gi+k1]=g1+b;b=c1*g2-s1*f3;a=s1*g2+c1*f3;fz[gi+k2]=g0-a;fz[gi+0]=g0+a;fz[fi+k3]=f1-b;fz[fi+k1]=f1+b;gi+=k4;fi+=k4;}while(fi<fn);c2=c1;c1=c2*costab[tri+0]-s1*costab[tri+1];s1=c2*costab[tri+1]+s1*costab[tri+0];}tri+=2;}while(k4<n);}var rv_tbl=[0x00,0x80,0x40,0xc0,0x20,0xa0,0x60,0xe0,0x10,0x90,0x50,0xd0,0x30,0xb0,0x70,0xf0,0x08,0x88,0x48,0xc8,0x28,0xa8,0x68,0xe8,0x18,0x98,0x58,0xd8,0x38,0xb8,0x78,0xf8,0x04,0x84,0x44,0xc4,0x24,0xa4,0x64,0xe4,0x14,0x94,0x54,0xd4,0x34,0xb4,0x74,0xf4,0x0c,0x8c,0x4c,0xcc,0x2c,0xac,0x6c,0xec,0x1c,0x9c,0x5c,0xdc,0x3c,0xbc,0x7c,0xfc,0x02,0x82,0x42,0xc2,0x22,0xa2,0x62,0xe2,0x12,0x92,0x52,0xd2,0x32,0xb2,0x72,0xf2,0x0a,0x8a,0x4a,0xca,0x2a,0xaa,0x6a,0xea,0x1a,0x9a,0x5a,0xda,0x3a,0xba,0x7a,0xfa,0x06,0x86,0x46,0xc6,0x26,0xa6,0x66,0xe6,0x16,0x96,0x56,0xd6,0x36,0xb6,0x76,0xf6,0x0e,0x8e,0x4e,0xce,0x2e,0xae,0x6e,0xee,0x1e,0x9e,0x5e,0xde,0x3e,0xbe,0x7e,0xfe];this.fft_short=function(gfc,x_real,chn,buffer,bufPos){for(var b=0;b<3;b++){var x=$cPNKB.BLKSIZE_s/2;var k=0xffff&192*(b+1);var j=$cPNKB.BLKSIZE_s/8-1;do{var f0,f1,f2,f3,w;var i=rv_tbl[j<<2]&0xff;f0=window_s[i]*buffer[chn][bufPos+i+k];w=window_s[0x7f-i]*buffer[chn][bufPos+i+k+0x80];f1=f0-w;f0=f0+w;f2=window_s[i+0x40]*buffer[chn][bufPos+i+k+0x40];w=window_s[0x3f-i]*buffer[chn][bufPos+i+k+0xc0];f3=f2-w;f2=f2+w;x-=4;x_real[b][x+0]=f0+f2;x_real[b][x+2]=f0-f2;x_real[b][x+1]=f1+f3;x_real[b][x+3]=f1-f3;f0=window_s[i+0x01]*buffer[chn][bufPos+i+k+0x01];w=window_s[0x7e-i]*buffer[chn][bufPos+i+k+0x81];f1=f0-w;f0=f0+w;f2=window_s[i+0x41]*buffer[chn][bufPos+i+k+0x41];w=window_s[0x3e-i]*buffer[chn][bufPos+i+k+0xc1];f3=f2-w;f2=f2+w;x_real[b][x+$cPNKB.BLKSIZE_s/2+0]=f0+f2;x_real[b][x+$cPNKB.BLKSIZE_s/2+2]=f0-f2;x_real[b][x+$cPNKB.BLKSIZE_s/2+1]=f1+f3;x_real[b][x+$cPNKB.BLKSIZE_s/2+3]=f1-f3;}while(--j>=0);fht(x_real[b],x,$cPNKB.BLKSIZE_s/2);/* BLKSIZE_s/2 because of 3DNow! ASM routine */ /* BLKSIZE/2 because of 3DNow! ASM routine */}};this.fft_long=function(gfc,y,chn,buffer,bufPos){var jj=$cPNKB.BLKSIZE/8-1;var x=$cPNKB.BLKSIZE/2;do{var f0,f1,f2,f3,w;var i=rv_tbl[jj]&0xff;f0=window[i]*buffer[chn][bufPos+i];w=window[i+0x200]*buffer[chn][bufPos+i+0x200];f1=f0-w;f0=f0+w;f2=window[i+0x100]*buffer[chn][bufPos+i+0x100];w=window[i+0x300]*buffer[chn][bufPos+i+0x300];f3=f2-w;f2=f2+w;x-=4;y[x+0]=f0+f2;y[x+2]=f0-f2;y[x+1]=f1+f3;y[x+3]=f1-f3;f0=window[i+0x001]*buffer[chn][bufPos+i+0x001];w=window[i+0x201]*buffer[chn][bufPos+i+0x201];f1=f0-w;f0=f0+w;f2=window[i+0x101]*buffer[chn][bufPos+i+0x101];w=window[i+0x301]*buffer[chn][bufPos+i+0x301];f3=f2-w;f2=f2+w;y[x+$cPNKB.BLKSIZE/2+0]=f0+f2;y[x+$cPNKB.BLKSIZE/2+2]=f0-f2;y[x+$cPNKB.BLKSIZE/2+1]=f1+f3;y[x+$cPNKB.BLKSIZE/2+3]=f1-f3;}while(--jj>=0);fht(y,x,$cPNKB.BLKSIZE/2);/* BLKSIZE/2 because of 3DNow! ASM routine */};this.init_fft=function(gfc){/* The type of window used here will make no real difference, but */ /*
699
+ * in the interest of merging nspsytune stuff - switch to blackman
700
+ * window
701
+ */for(var i=0;i<$cPNKB.BLKSIZE;i++)/* blackman window */window[i]=0.42-0.5*Math.cos(2*Math.PI*(i+.5)/$cPNKB.BLKSIZE)+0.08*Math.cos(4*Math.PI*(i+.5)/$cPNKB.BLKSIZE);for(var i=0;i<$cPNKB.BLKSIZE_s/2;i++)window_s[i]=0.5*(1.0-Math.cos(2.0*Math.PI*(i+0.5)/$cPNKB.BLKSIZE_s));};}module.exports=$1a4ddf9b01454eb6$var$FFT;});parcelRequire.register("cPNKB",function(module,exports){var $3YDN3=parcelRequire("3YDN3");var $9580d6e047027232$var$System=$3YDN3.System;var $9580d6e047027232$var$VbrMode=$3YDN3.VbrMode;$3YDN3.Float;$3YDN3.ShortBlock;$3YDN3.Util;$3YDN3.Arrays;var $9580d6e047027232$var$new_array_n=$3YDN3.new_array_n;$3YDN3.new_byte;$3YDN3.new_double;var $9580d6e047027232$var$new_float=$3YDN3.new_float;var $9580d6e047027232$var$new_float_n=$3YDN3.new_float_n;var $9580d6e047027232$var$new_int=$3YDN3.new_int;$3YDN3.new_int_n;var $9580d6e047027232$var$assert=$3YDN3.assert;/**
702
+ * ENCDELAY The encoder delay.
703
+ *
704
+ * Minimum allowed is MDCTDELAY (see below)
705
+ *
706
+ * The first 96 samples will be attenuated, so using a value less than 96
707
+ * will result in corrupt data for the first 96-ENCDELAY samples.
708
+ *
709
+ * suggested: 576 set to 1160 to sync with FhG.
710
+ */$9580d6e047027232$var$Encoder.ENCDELAY=576;/**
711
+ * make sure there is at least one complete frame after the last frame
712
+ * containing real data
713
+ *
714
+ * Using a value of 288 would be sufficient for a a very sophisticated
715
+ * decoder that can decode granule-by-granule instead of frame by frame. But
716
+ * lets not assume this, and assume the decoder will not decode frame N
717
+ * unless it also has data for frame N+1
718
+ */$9580d6e047027232$var$Encoder.POSTDELAY=1152;/**
719
+ * delay of the MDCT used in mdct.c original ISO routines had a delay of
720
+ * 528! Takehiro's routines:
721
+ */$9580d6e047027232$var$Encoder.MDCTDELAY=48;$9580d6e047027232$var$Encoder.FFTOFFSET=224+$9580d6e047027232$var$Encoder.MDCTDELAY;/**
722
+ * Most decoders, including the one we use, have a delay of 528 samples.
723
+ */$9580d6e047027232$var$Encoder.DECDELAY=528;/**
724
+ * number of subbands
725
+ */$9580d6e047027232$var$Encoder.SBLIMIT=32;/**
726
+ * parition bands bands
727
+ */$9580d6e047027232$var$Encoder.CBANDS=64;/**
728
+ * number of critical bands/scale factor bands where masking is computed
729
+ */$9580d6e047027232$var$Encoder.SBPSY_l=21;$9580d6e047027232$var$Encoder.SBPSY_s=12;/**
730
+ * total number of scalefactor bands encoded
731
+ */$9580d6e047027232$var$Encoder.SBMAX_l=22;$9580d6e047027232$var$Encoder.SBMAX_s=13;$9580d6e047027232$var$Encoder.PSFB21=6;$9580d6e047027232$var$Encoder.PSFB12=6;/**
732
+ * FFT sizes
733
+ */$9580d6e047027232$var$Encoder.BLKSIZE=1024;$9580d6e047027232$var$Encoder.HBLKSIZE=$9580d6e047027232$var$Encoder.BLKSIZE/2+1;$9580d6e047027232$var$Encoder.BLKSIZE_s=256;$9580d6e047027232$var$Encoder.HBLKSIZE_s=$9580d6e047027232$var$Encoder.BLKSIZE_s/2+1;$9580d6e047027232$var$Encoder.NORM_TYPE=0;$9580d6e047027232$var$Encoder.START_TYPE=1;$9580d6e047027232$var$Encoder.SHORT_TYPE=2;$9580d6e047027232$var$Encoder.STOP_TYPE=3;/**
734
+ * <PRE>
735
+ * Mode Extention:
736
+ * When we are in stereo mode, there are 4 possible methods to store these
737
+ * two channels. The stereo modes -m? are using a subset of them.
738
+ *
739
+ * -ms: MPG_MD_LR_LR
740
+ * -mj: MPG_MD_LR_LR and MPG_MD_MS_LR
741
+ * -mf: MPG_MD_MS_LR
742
+ * -mi: all
743
+ * </PRE>
744
+ */$9580d6e047027232$var$Encoder.MPG_MD_LR_LR=0;$9580d6e047027232$var$Encoder.MPG_MD_LR_I=1;$9580d6e047027232$var$Encoder.MPG_MD_MS_LR=2;$9580d6e047027232$var$Encoder.MPG_MD_MS_I=3;$9580d6e047027232$var$Encoder.fircoef=[-0.1039435,-0.1892065,-0.0432472*5,-0.155915,7.79609e-18*5,0.0467745*5,0.50455,0.756825,0.187098*5];function $9580d6e047027232$var$Encoder(){var NewMDCT=parcelRequire("drj3v");var III_psy_ratio=parcelRequire("hvy40");var MPEGMode=parcelRequire("jL6I1");var FFTOFFSET=$9580d6e047027232$var$Encoder.FFTOFFSET;var MPG_MD_MS_LR=$9580d6e047027232$var$Encoder.MPG_MD_MS_LR;//BitStream bs;
745
+ //PsyModel psy;
746
+ //VBRTag vbr;
747
+ //QuantizePVT qupvt;
748
+ var bs=null;this.psy=null;var psy=null;var vbr=null;var qupvt=null;//public final void setModules(BitStream bs, PsyModel psy, QuantizePVT qupvt,
749
+ // VBRTag vbr) {
750
+ this.setModules=function(_bs,_psy,_qupvt,_vbr){bs=_bs;this.psy=_psy;psy=_psy;vbr=_vbr;qupvt=_qupvt;};var newMDCT=new NewMDCT();/***********************************************************************
751
+ *
752
+ * encoder and decoder delays
753
+ *
754
+ ***********************************************************************/ /**
755
+ * <PRE>
756
+ * layer III enc->dec delay: 1056 (1057?) (observed)
757
+ * layer II enc->dec delay: 480 (481?) (observed)
758
+ *
759
+ * polyphase 256-16 (dec or enc) = 240
760
+ * mdct 256+32 (9*32) (dec or enc) = 288
761
+ * total: 512+16
762
+ *
763
+ * My guess is that delay of polyphase filterbank is actualy 240.5
764
+ * (there are technical reasons for this, see postings in mp3encoder).
765
+ * So total Encode+Decode delay = ENCDELAY + 528 + 1
766
+ * </PRE>
767
+ */ /**
768
+ * auto-adjust of ATH, useful for low volume Gabriel Bouvigne 3 feb 2001
769
+ *
770
+ * modifies some values in gfp.internal_flags.ATH (gfc.ATH)
771
+ */ //private void adjust_ATH(final LameInternalFlags gfc) {
772
+ function adjust_ATH(gfc){var gr2_max,max_pow;if(gfc.ATH.useAdjust==0){gfc.ATH.adjust=1.0;/* no adjustment */return;}/* jd - 2001 mar 12, 27, jun 30 */ /* loudness based on equal loudness curve; */ /* use granule with maximum combined loudness */max_pow=gfc.loudness_sq[0][0];gr2_max=gfc.loudness_sq[1][0];if(gfc.channels_out==2){max_pow+=gfc.loudness_sq[0][1];gr2_max+=gfc.loudness_sq[1][1];}else {max_pow+=max_pow;gr2_max+=gr2_max;}if(gfc.mode_gr==2)max_pow=Math.max(max_pow,gr2_max);max_pow*=0.5;/* max_pow approaches 1.0 for full band noise */ /* jd - 2001 mar 31, jun 30 */ /* user tuning of ATH adjustment region */max_pow*=gfc.ATH.aaSensitivityP;/*
773
+ * adjust ATH depending on range of maximum value
774
+ */ /* jd - 2001 feb27, mar12,20, jun30, jul22 */ /* continuous curves based on approximation */ /* to GB's original values. */ /* For an increase in approximate loudness, */ /* set ATH adjust to adjust_limit immediately */ /* after a delay of one frame. */ /* For a loudness decrease, reduce ATH adjust */ /* towards adjust_limit gradually. */ /* max_pow is a loudness squared or a power. */if(max_pow>0.03125){if(gfc.ATH.adjust>=1.0)gfc.ATH.adjust=1.0;else/* preceding frame has lower ATH adjust; */ /* ascend only to the preceding adjust_limit */ /* in case there is leading low volume */if(gfc.ATH.adjust<gfc.ATH.adjustLimit)gfc.ATH.adjust=gfc.ATH.adjustLimit;gfc.ATH.adjustLimit=1.0;}else {/* about 32 dB maximum adjust (0.000625) */var adj_lim_new=31.98*max_pow+0.000625;if(gfc.ATH.adjust>=adj_lim_new){gfc.ATH.adjust*=adj_lim_new*0.075+0.925;if(gfc.ATH.adjust<adj_lim_new)gfc.ATH.adjust=adj_lim_new;}else {if(gfc.ATH.adjustLimit>=adj_lim_new)gfc.ATH.adjust=adj_lim_new;else/* preceding frame has lower ATH adjust; */ /* ascend only to the preceding adjust_limit */if(gfc.ATH.adjust<gfc.ATH.adjustLimit)gfc.ATH.adjust=gfc.ATH.adjustLimit;}gfc.ATH.adjustLimit=adj_lim_new;}}/**
775
+ * <PRE>
776
+ * some simple statistics
777
+ *
778
+ * bitrate index 0: free bitrate . not allowed in VBR mode
779
+ * : bitrates, kbps depending on MPEG version
780
+ * bitrate index 15: forbidden
781
+ *
782
+ * mode_ext:
783
+ * 0: LR
784
+ * 1: LR-i
785
+ * 2: MS
786
+ * 3: MS-i
787
+ * </PRE>
788
+ */function updateStats(gfc){var gr,ch;$9580d6e047027232$var$assert(0<=gfc.bitrate_index&&gfc.bitrate_index<16);$9580d6e047027232$var$assert(0<=gfc.mode_ext&&gfc.mode_ext<4);/* count bitrate indices */gfc.bitrate_stereoMode_Hist[gfc.bitrate_index][4]++;gfc.bitrate_stereoMode_Hist[15][4]++;/* count 'em for every mode extension in case of 2 channel encoding */if(gfc.channels_out==2){gfc.bitrate_stereoMode_Hist[gfc.bitrate_index][gfc.mode_ext]++;gfc.bitrate_stereoMode_Hist[15][gfc.mode_ext]++;}for(gr=0;gr<gfc.mode_gr;++gr)for(ch=0;ch<gfc.channels_out;++ch){var bt=gfc.l3_side.tt[gr][ch].block_type|0;if(gfc.l3_side.tt[gr][ch].mixed_block_flag!=0)bt=4;gfc.bitrate_blockType_Hist[gfc.bitrate_index][bt]++;gfc.bitrate_blockType_Hist[gfc.bitrate_index][5]++;gfc.bitrate_blockType_Hist[15][bt]++;gfc.bitrate_blockType_Hist[15][5]++;}}function lame_encode_frame_init(gfp,inbuf){var gfc=gfp.internal_flags;var ch,gr;if(gfc.lame_encode_frame_init==0){/* prime the MDCT/polyphase filterbank with a short block */var i,j;var primebuff0=$9580d6e047027232$var$new_float(2014);var primebuff1=$9580d6e047027232$var$new_float(2014);gfc.lame_encode_frame_init=1;for(i=0,j=0;i<286+576*(1+gfc.mode_gr);++i)if(i<576*gfc.mode_gr){primebuff0[i]=0;if(gfc.channels_out==2)primebuff1[i]=0;}else {primebuff0[i]=inbuf[0][j];if(gfc.channels_out==2)primebuff1[i]=inbuf[1][j];++j;}/* polyphase filtering / mdct */for(gr=0;gr<gfc.mode_gr;gr++)for(ch=0;ch<gfc.channels_out;ch++)gfc.l3_side.tt[gr][ch].block_type=$9580d6e047027232$var$Encoder.SHORT_TYPE;newMDCT.mdct_sub48(gfc,primebuff0,primebuff1);/* check FFT will not use a negative starting offset */$9580d6e047027232$var$assert(576>=$9580d6e047027232$var$Encoder.FFTOFFSET);/* check if we have enough data for FFT */$9580d6e047027232$var$assert(gfc.mf_size>=$9580d6e047027232$var$Encoder.BLKSIZE+gfp.framesize-$9580d6e047027232$var$Encoder.FFTOFFSET);/* check if we have enough data for polyphase filterbank */$9580d6e047027232$var$assert(gfc.mf_size>=512+gfp.framesize-32);}}/**
789
+ * <PRE>
790
+ * encodeframe() Layer 3
791
+ *
792
+ * encode a single frame
793
+ *
794
+ *
795
+ * lame_encode_frame()
796
+ *
797
+ *
798
+ * gr 0 gr 1
799
+ * inbuf: |--------------|--------------|--------------|
800
+ *
801
+ *
802
+ * Polyphase (18 windows, each shifted 32)
803
+ * gr 0:
804
+ * window1 <----512---.
805
+ * window18 <----512---.
806
+ *
807
+ * gr 1:
808
+ * window1 <----512---.
809
+ * window18 <----512---.
810
+ *
811
+ *
812
+ *
813
+ * MDCT output: |--------------|--------------|--------------|
814
+ *
815
+ * FFT's <---------1024---------.
816
+ * <---------1024-------.
817
+ *
818
+ *
819
+ *
820
+ * inbuf = buffer of PCM data size=MP3 framesize
821
+ * encoder acts on inbuf[ch][0], but output is delayed by MDCTDELAY
822
+ * so the MDCT coefficints are from inbuf[ch][-MDCTDELAY]
823
+ *
824
+ * psy-model FFT has a 1 granule delay, so we feed it data for the
825
+ * next granule.
826
+ * FFT is centered over granule: 224+576+224
827
+ * So FFT starts at: 576-224-MDCTDELAY
828
+ *
829
+ * MPEG2: FFT ends at: BLKSIZE+576-224-MDCTDELAY (1328)
830
+ * MPEG1: FFT ends at: BLKSIZE+2*576-224-MDCTDELAY (1904)
831
+ *
832
+ * MPEG2: polyphase first window: [0..511]
833
+ * 18th window: [544..1055] (1056)
834
+ * MPEG1: 36th window: [1120..1631] (1632)
835
+ * data needed: 512+framesize-32
836
+ *
837
+ * A close look newmdct.c shows that the polyphase filterbank
838
+ * only uses data from [0..510] for each window. Perhaps because the window
839
+ * used by the filterbank is zero for the last point, so Takehiro's
840
+ * code doesn't bother to compute with it.
841
+ *
842
+ * FFT starts at 576-224-MDCTDELAY (304) = 576-FFTOFFSET
843
+ *
844
+ * </PRE>
845
+ */this.lame_encode_mp3_frame=function(gfp,inbuf_l,inbuf_r,mp3buf,mp3bufPos,mp3buf_size){var mp3count;var masking_LR=$9580d6e047027232$var$new_array_n([2,2]);/*
846
+ * LR masking &
847
+ * energy
848
+ */masking_LR[0][0]=new III_psy_ratio();masking_LR[0][1]=new III_psy_ratio();masking_LR[1][0]=new III_psy_ratio();masking_LR[1][1]=new III_psy_ratio();var masking_MS=$9580d6e047027232$var$new_array_n([2,2]);/* MS masking & energy */masking_MS[0][0]=new III_psy_ratio();masking_MS[0][1]=new III_psy_ratio();masking_MS[1][0]=new III_psy_ratio();masking_MS[1][1]=new III_psy_ratio();//III_psy_ratio masking[][];
849
+ var masking;/* pointer to selected maskings */var inbuf=[null,null];var gfc=gfp.internal_flags;var tot_ener=$9580d6e047027232$var$new_float_n([2,4]);var ms_ener_ratio=[.5,.5];var pe=[[0.,0.],[0.,0.]];var pe_MS=[[0.,0.],[0.,0.]];//float[][] pe_use;
850
+ var pe_use;var ch,gr;inbuf[0]=inbuf_l;inbuf[1]=inbuf_r;if(gfc.lame_encode_frame_init==0)/* first run? */lame_encode_frame_init(gfp,inbuf);/********************** padding *****************************/ /**
851
+ * <PRE>
852
+ * padding method as described in
853
+ * "MPEG-Layer3 / Bitstream Syntax and Decoding"
854
+ * by Martin Sieler, Ralph Sperschneider
855
+ *
856
+ * note: there is no padding for the very first frame
857
+ *
858
+ * Robert Hegemann 2000-06-22
859
+ * </PRE>
860
+ */gfc.padding=0;if((gfc.slot_lag-=gfc.frac_SpF)<0){gfc.slot_lag+=gfp.out_samplerate;gfc.padding=1;}/****************************************
861
+ * Stage 1: psychoacoustic model *
862
+ ****************************************/if(gfc.psymodel!=0){/*
863
+ * psychoacoustic model psy model has a 1 granule (576) delay that
864
+ * we must compensate for (mt 6/99).
865
+ */var ret;var bufp=[null,null];/* address of beginning of left & right granule */var bufpPos=0;/* address of beginning of left & right granule */var blocktype=$9580d6e047027232$var$new_int(2);for(gr=0;gr<gfc.mode_gr;gr++){for(ch=0;ch<gfc.channels_out;ch++){bufp[ch]=inbuf[ch];bufpPos=576+gr*576-$9580d6e047027232$var$Encoder.FFTOFFSET;}if(gfp.VBR==$9580d6e047027232$var$VbrMode.vbr_mtrh||gfp.VBR==$9580d6e047027232$var$VbrMode.vbr_mt)ret=psy.L3psycho_anal_vbr(gfp,bufp,bufpPos,gr,masking_LR,masking_MS,pe[gr],pe_MS[gr],tot_ener[gr],blocktype);else ret=psy.L3psycho_anal_ns(gfp,bufp,bufpPos,gr,masking_LR,masking_MS,pe[gr],pe_MS[gr],tot_ener[gr],blocktype);if(ret!=0)return -4;if(gfp.mode==MPEGMode.JOINT_STEREO){ms_ener_ratio[gr]=tot_ener[gr][2]+tot_ener[gr][3];if(ms_ener_ratio[gr]>0)ms_ener_ratio[gr]=tot_ener[gr][3]/ms_ener_ratio[gr];}/* block type flags */for(ch=0;ch<gfc.channels_out;ch++){var cod_info=gfc.l3_side.tt[gr][ch];cod_info.block_type=blocktype[ch];cod_info.mixed_block_flag=0;}}}else {/* no psy model */for(gr=0;gr<gfc.mode_gr;gr++)for(ch=0;ch<gfc.channels_out;ch++){gfc.l3_side.tt[gr][ch].block_type=$9580d6e047027232$var$Encoder.NORM_TYPE;gfc.l3_side.tt[gr][ch].mixed_block_flag=0;pe_MS[gr][ch]=pe[gr][ch]=700;}}/* auto-adjust of ATH, useful for low volume */adjust_ATH(gfc);/****************************************
866
+ * Stage 2: MDCT *
867
+ ****************************************/ /* polyphase filtering / mdct */newMDCT.mdct_sub48(gfc,inbuf[0],inbuf[1]);/****************************************
868
+ * Stage 3: MS/LR decision *
869
+ ****************************************/ /* Here will be selected MS or LR coding of the 2 stereo channels */gfc.mode_ext=$9580d6e047027232$var$Encoder.MPG_MD_LR_LR;if(gfp.force_ms)gfc.mode_ext=$9580d6e047027232$var$Encoder.MPG_MD_MS_LR;else if(gfp.mode==MPEGMode.JOINT_STEREO){/*
870
+ * ms_ratio = is scaled, for historical reasons, to look like a
871
+ * ratio of side_channel / total. 0 = signal is 100% mono .5 = L & R
872
+ * uncorrelated
873
+ */ /**
874
+ * <PRE>
875
+ * [0] and [1] are the results for the two granules in MPEG-1,
876
+ * in MPEG-2 it's only a faked averaging of the same value
877
+ * _prev is the value of the last granule of the previous frame
878
+ * _next is the value of the first granule of the next frame
879
+ * </PRE>
880
+ */var sum_pe_MS=0.;var sum_pe_LR=0.;for(gr=0;gr<gfc.mode_gr;gr++)for(ch=0;ch<gfc.channels_out;ch++){sum_pe_MS+=pe_MS[gr][ch];sum_pe_LR+=pe[gr][ch];}/* based on PE: M/S coding would not use much more bits than L/R */if(sum_pe_MS<=1.00*sum_pe_LR){var gi0=gfc.l3_side.tt[0];var gi1=gfc.l3_side.tt[gfc.mode_gr-1];if(gi0[0].block_type==gi0[1].block_type&&gi1[0].block_type==gi1[1].block_type)gfc.mode_ext=$9580d6e047027232$var$Encoder.MPG_MD_MS_LR;}}/* bit and noise allocation */if(gfc.mode_ext==MPG_MD_MS_LR){masking=masking_MS;/* use MS masking */pe_use=pe_MS;}else {masking=masking_LR;/* use LR masking */pe_use=pe;}/* copy data for MP3 frame analyzer */if(gfp.analysis&&gfc.pinfo!=null){for(gr=0;gr<gfc.mode_gr;gr++)for(ch=0;ch<gfc.channels_out;ch++){gfc.pinfo.ms_ratio[gr]=gfc.ms_ratio[gr];gfc.pinfo.ms_ener_ratio[gr]=ms_ener_ratio[gr];gfc.pinfo.blocktype[gr][ch]=gfc.l3_side.tt[gr][ch].block_type;gfc.pinfo.pe[gr][ch]=pe_use[gr][ch];$9580d6e047027232$var$System.arraycopy(gfc.l3_side.tt[gr][ch].xr,0,gfc.pinfo.xr[gr][ch],0,576);/*
881
+ * in psymodel, LR and MS data was stored in pinfo. switch
882
+ * to MS data:
883
+ */if(gfc.mode_ext==MPG_MD_MS_LR){gfc.pinfo.ers[gr][ch]=gfc.pinfo.ers[gr][ch+2];$9580d6e047027232$var$System.arraycopy(gfc.pinfo.energy[gr][ch+2],0,gfc.pinfo.energy[gr][ch],0,gfc.pinfo.energy[gr][ch].length);}}}/****************************************
884
+ * Stage 4: quantization loop *
885
+ ****************************************/if(gfp.VBR==$9580d6e047027232$var$VbrMode.vbr_off||gfp.VBR==$9580d6e047027232$var$VbrMode.vbr_abr){var i;var f;for(i=0;i<18;i++)gfc.nsPsy.pefirbuf[i]=gfc.nsPsy.pefirbuf[i+1];f=0.0;for(gr=0;gr<gfc.mode_gr;gr++)for(ch=0;ch<gfc.channels_out;ch++)f+=pe_use[gr][ch];gfc.nsPsy.pefirbuf[18]=f;f=gfc.nsPsy.pefirbuf[9];for(i=0;i<9;i++)f+=(gfc.nsPsy.pefirbuf[i]+gfc.nsPsy.pefirbuf[18-i])*$9580d6e047027232$var$Encoder.fircoef[i];f=3350*gfc.mode_gr*gfc.channels_out/f;for(gr=0;gr<gfc.mode_gr;gr++)for(ch=0;ch<gfc.channels_out;ch++)pe_use[gr][ch]*=f;}gfc.iteration_loop.iteration_loop(gfp,pe_use,ms_ener_ratio,masking);/****************************************
886
+ * Stage 5: bitstream formatting *
887
+ ****************************************/ /* write the frame to the bitstream */bs.format_bitstream(gfp);/* copy mp3 bit buffer into array */mp3count=bs.copy_buffer(gfc,mp3buf,mp3bufPos,mp3buf_size,1);if(gfp.bWriteVbrTag)vbr.addVbrFrame(gfp);if(gfp.analysis&&gfc.pinfo!=null){for(ch=0;ch<gfc.channels_out;ch++){var j;for(j=0;j<FFTOFFSET;j++)gfc.pinfo.pcmdata[ch][j]=gfc.pinfo.pcmdata[ch][j+gfp.framesize];for(j=FFTOFFSET;j<1600;j++)gfc.pinfo.pcmdata[ch][j]=inbuf[ch][j-FFTOFFSET];}qupvt.set_frame_pinfo(gfp,masking);}updateStats(gfc);return mp3count;};}module.exports=$9580d6e047027232$var$Encoder;});parcelRequire.register("drj3v",function(module,exports){/*
888
+ * MP3 window subband -> subband filtering -> mdct routine
889
+ *
890
+ * Copyright (c) 1999-2000 Takehiro Tominaga
891
+ *
892
+ *
893
+ * This library is free software; you can redistribute it and/or
894
+ * modify it under the terms of the GNU Lesser General Public
895
+ * License as published by the Free Software Foundation; either
896
+ * version 2 of the License, or (at your option) any later version.
897
+ *
898
+ * This library is distributed in the hope that it will be useful,
899
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
900
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
901
+ * Library General Public License for more details.
902
+ *
903
+ * You should have received a copy of the GNU Library General Public
904
+ * License along with this library; if not, write to the
905
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
906
+ * Boston, MA 02111-1307, USA.
907
+ */ /*
908
+ * Special Thanks to Patrick De Smet for your advices.
909
+ */ /* $Id: NewMDCT.java,v 1.11 2011/05/24 20:48:06 kenchis Exp $ */ //package mp3;
910
+ //import java.util.Arrays;
911
+ var $3YDN3=parcelRequire("3YDN3");var $9c8c9409243421ca$var$System=$3YDN3.System;$3YDN3.VbrMode;$3YDN3.Float;$3YDN3.ShortBlock;var $9c8c9409243421ca$var$Util=$3YDN3.Util;var $9c8c9409243421ca$var$Arrays=$3YDN3.Arrays;$3YDN3.new_array_n;$3YDN3.new_byte;$3YDN3.new_double;var $9c8c9409243421ca$var$new_float=$3YDN3.new_float;$3YDN3.new_float_n;$3YDN3.new_int;$3YDN3.new_int_n;$3YDN3.assert;var $cPNKB=parcelRequire("cPNKB");function $9c8c9409243421ca$var$NewMDCT(){var enwindow=[-0.1482523854003001,32.308141959636465,296.40344946382766,883.1344870032432,11113.947376231741,1057.2713659324597,305.7402417275812,30.825928907280012,/* 15 */3.8533188138216365,59.42900443849514,709.5899960123345,5281.91112291017,-5829.66483675846,-817.6293103748613,-76.91656988279972,-4.594269939176596,9.063471690191471e-01,1.960342806591213e-01,-0.15466694054279598,34.324387823855965,301.8067566458425,817.599602898885,11573.795901679885,1181.2520595540152,321.59731579894424,31.232021761053772,/* 14 */3.7107095756221318,53.650946155329365,684.167428119626,5224.56624370173,-6366.391851890084,-908.9766368219582,-89.83068876699639,-5.411397422890401,8.206787908286602e-01,3.901806440322567e-01,-0.16070888947830023,36.147034243915876,304.11815768187864,732.7429163887613,11989.60988270091,1300.012278487897,335.28490093152146,31.48816102859945,/* 13 */3.373875931311736,47.232241542899175,652.7371796173471,5132.414255594984,-6909.087078780055,-1001.9990371107289,-103.62185754286375,-6.104916304710272,7.416505462720353e-01,5.805693545089249e-01,-0.16636367662261495,37.751650073343995,303.01103387567713,627.9747488785183,12358.763425278165,1412.2779918482834,346.7496836825721,31.598286663170416,/* 12 */3.1598635433980946,40.57878626349686,616.1671130880391,5007.833007176154,-7454.040671756168,-1095.7960341867115,-118.24411666465777,-6.818469345853504,6.681786379192989e-01,7.653668647301797e-01,-0.1716176790982088,39.11551877123304,298.3413246578966,503.5259106886539,12679.589408408976,1516.5821921214542,355.9850766329023,31.395241710249053,/* 11 */2.9164211881972335,33.79716964664243,574.8943997801362,4853.234992253242,-7997.57021486075,-1189.7624067269965,-133.6444792601766,-7.7202770609839915,5.993769336819237e-01,9.427934736519954e-01,-0.17645823955292173,40.21879108166477,289.9982036694474,359.3226160751053,12950.259102786438,1612.1013903507662,362.85067106591504,31.045922092242872,/* 10 */2.822222032597987,26.988862316190684,529.8996541764288,4671.371946949588,-8535.899136645805,-1282.5898586244496,-149.58553632943463,-8.643494270763135,5.345111359507916e-01,1.111140466039205e+00,-0.36174739330527045,41.04429910497807,277.5463268268618,195.6386023135583,13169.43812144731,1697.6433561479398,367.40983966190305,30.557037410382826,/* 9 */2.531473372857427,20.070154905927314,481.50208566532336,4464.970341588308,-9065.36882077239,-1373.62841526722,-166.1660487028118,-9.58289321133207,4.729647758913199e-01,1.268786568327291e+00,-0.36970682634889585,41.393213350082036,261.2935935556502,12.935476055240873,13336.131683328815,1772.508612059496,369.76534388639965,29.751323653701338,2.4023193045459172,13.304795348228817,430.5615775526625,4237.0568611071185,-9581.931701634761,-1461.6913552409758,-183.12733958476446,-10.718010163869403,4.1421356237309504879e-01,/* tan(PI/8) */1.414213562373095e+00,-0.37677560326535325,41.619486213528496,241.05423794991074,-187.94665032361226,13450.063605744153,1836.153896465782,369.4908799925761,29.001847876923147,/* 7 */2.0714759319987186,6.779591200894186,377.7767837205709,3990.386575512536,-10081.709459700915,-1545.947424837898,-200.3762958015653,-11.864482073055006,3.578057213145241e-01,1.546020906725474e+00,-0.3829366947518991,41.1516456456653,216.47684307105183,-406.1569483347166,13511.136535077321,1887.8076599260432,367.3025214564151,28.136213436723654,/* 6 */1.913880671464418,0.3829366947518991,323.85365704338597,3728.1472257487526,-10561.233882199509,-1625.2025997821418,-217.62525175416,-13.015432208941645,3.033466836073424e-01,1.662939224605090e+00,-0.5822628872992417,40.35639251440489,188.20071124269245,-640.2706748618148,13519.21490106562,1927.6022433578062,362.8197642637487,26.968821921868447,/* 5 */1.7463817695935329,-5.62650678237171,269.3016715297017,3453.386536448852,-11016.145278780888,-1698.6569643425091,-234.7658734267683,-14.16351421663124,2.504869601913055e-01,1.763842528696710e+00,-0.5887180101749253,39.23429103868072,155.76096234403798,-889.2492977967378,13475.470561874661,1955.0535223723712,356.4450994756727,25.894952980042156,/* 4 */1.5695032905781554,-11.181939564328772,214.80884394039484,3169.1640829158237,-11443.321309975563,-1765.1588461316153,-251.68908574481912,-15.49755935939164,1.989123673796580e-01,1.847759065022573e+00,-0.7912582233652842,37.39369355329111,119.699486012458,-1151.0956593239027,13380.446257078214,1970.3952110853447,348.01959814116185,24.731487364283044,/* 3 */1.3850130831637748,-16.421408865300393,161.05030052864092,2878.3322807850063,-11838.991423510031,-1823.985884688674,-268.2854986386903,-16.81724543849939,1.483359875383474e-01,1.913880671464418e+00,-0.7960642926861912,35.2322109610459,80.01928065061526,-1424.0212633405113,13235.794061869668,1973.804052543835,337.9908651258184,23.289159354463873,1.3934255946442087,-21.099669467133474,108.48348407242611,2583.700758091299,-12199.726194855148,-1874.2780658979746,-284.2467154529415,-18.11369784385905,9.849140335716425e-02,1.961570560806461e+00,-0.998795456205172,32.56307803611191,36.958364584370486,-1706.075448829146,13043.287458812016,1965.3831106103316,326.43182772364605,22.175018750622293,1.198638339011324,-25.371248002043963,57.53505923036915,2288.41886619975,-12522.674544337233,-1914.8400385312243,-299.26241273417224,-19.37805630698734,4.912684976946725e-02,1.990369453344394e+00,3.5780907e-02*$9c8c9409243421ca$var$Util.SQRT2*0.5/2.384e-06,1.7876148e-02*$9c8c9409243421ca$var$Util.SQRT2*0.5/2.384e-06,3.134727e-03*$9c8c9409243421ca$var$Util.SQRT2*0.5/2.384e-06,2.457142e-03*$9c8c9409243421ca$var$Util.SQRT2*0.5/2.384e-06,9.71317e-04*$9c8c9409243421ca$var$Util.SQRT2*0.5/2.384e-06,2.18868e-04*$9c8c9409243421ca$var$Util.SQRT2*0.5/2.384e-06,1.01566e-04*$9c8c9409243421ca$var$Util.SQRT2*0.5/2.384e-06,1.3828e-05*$9c8c9409243421ca$var$Util.SQRT2*0.5/2.384e-06,12804.797818791945,1945.5515939597317,313.4244966442953,20.801593959731544,1995.1556208053692,9.000838926174497,-29.20218120805369];var NS=12;var NL=36;var win=[[2.382191739347913e-13,6.423305872147834e-13,9.400849094049688e-13,1.122435026096556e-12,1.183840321267481e-12,1.122435026096556e-12,9.400849094049690e-13,6.423305872147839e-13,2.382191739347918e-13,5.456116108943412e-12,4.878985199565852e-12,4.240448995017367e-12,3.559909094758252e-12,2.858043359288075e-12,2.156177623817898e-12,1.475637723558783e-12,8.371015190102974e-13,2.599706096327376e-13,-0.000000000005456116108943412,-0.000000000004878985199565852,-0.000000000004240448995017367,-0.000000000003559909094758252,-0.000000000002858043359288076,-0.000000000002156177623817898,-0.000000000001475637723558783,-0.0000000000008371015190102975,-0.0000000000002599706096327376,-0.0000000000002382191739347923,-0.0000000000006423305872147843,-0.0000000000009400849094049696,-0.000000000001122435026096556,-0.000000000001183840321267481,-0.000000000001122435026096556,-0.0000000000009400849094049694,-0.000000000000642330587214784,-0.0000000000002382191739347918],[2.382191739347913e-13,6.423305872147834e-13,9.400849094049688e-13,1.122435026096556e-12,1.183840321267481e-12,1.122435026096556e-12,9.400849094049688e-13,6.423305872147841e-13,2.382191739347918e-13,5.456116108943413e-12,4.878985199565852e-12,4.240448995017367e-12,3.559909094758253e-12,2.858043359288075e-12,2.156177623817898e-12,1.475637723558782e-12,8.371015190102975e-13,2.599706096327376e-13,-0.000000000005461314069809755,-0.000000000004921085770524055,-0.000000000004343405037091838,-0.000000000003732668368707687,-0.000000000003093523840190885,-0.000000000002430835727329465,-0.000000000001734679010007751,-0.000000000000974825365660928,-0.0000000000002797435120168326,0.000000000000000e+00,0.000000000000000e+00,0.000000000000000e+00,0.000000000000000e+00,0.000000000000000e+00,0.000000000000000e+00,-0.0000000000002283748241799531,-0.0000000000004037858874020686,-0.0000000000002146547464825323],[1.316524975873958e-01,/* win[SHORT_TYPE] */4.142135623730950e-01,7.673269879789602e-01,1.091308501069271e+00,/* tantab_l */1.303225372841206e+00,1.569685577117490e+00,1.920982126971166e+00,2.414213562373094e+00,3.171594802363212e+00,4.510708503662055e+00,7.595754112725146e+00,2.290376554843115e+01,0.98480775301220802032,/* cx */0.64278760968653936292,0.34202014332566882393,0.93969262078590842791,-0.1736481776669303,-0.7660444431189779,0.86602540378443870761,0.500000000000000e+00,-0.5144957554275265,/* ca */-0.4717319685649723,-0.3133774542039019,-0.1819131996109812,-0.09457419252642064,-0.04096558288530405,-0.01419856857247115,-0.003699974673760037,8.574929257125442e-01,/* cs */8.817419973177052e-01,9.496286491027329e-01,9.833145924917901e-01,9.955178160675857e-01,9.991605581781475e-01,9.998991952444470e-01,9.999931550702802e-01],[0.000000000000000e+00,0.000000000000000e+00,0.000000000000000e+00,0.000000000000000e+00,0.000000000000000e+00,0.000000000000000e+00,2.283748241799531e-13,4.037858874020686e-13,2.146547464825323e-13,5.461314069809755e-12,4.921085770524055e-12,4.343405037091838e-12,3.732668368707687e-12,3.093523840190885e-12,2.430835727329466e-12,1.734679010007751e-12,9.748253656609281e-13,2.797435120168326e-13,-0.000000000005456116108943413,-0.000000000004878985199565852,-0.000000000004240448995017367,-0.000000000003559909094758253,-0.000000000002858043359288075,-0.000000000002156177623817898,-0.000000000001475637723558782,-0.0000000000008371015190102975,-0.0000000000002599706096327376,-0.0000000000002382191739347913,-0.0000000000006423305872147834,-0.0000000000009400849094049688,-0.000000000001122435026096556,-0.000000000001183840321267481,-0.000000000001122435026096556,-0.0000000000009400849094049688,-0.0000000000006423305872147841,-0.0000000000002382191739347918]];var tantab_l=win[$cPNKB.SHORT_TYPE];var cx=win[$cPNKB.SHORT_TYPE];var ca=win[$cPNKB.SHORT_TYPE];var cs=win[$cPNKB.SHORT_TYPE];/**
912
+ * new IDCT routine written by Takehiro TOMINAGA
913
+ *
914
+ * PURPOSE: Overlapping window on PCM samples<BR>
915
+ *
916
+ * SEMANTICS:<BR>
917
+ * 32 16-bit pcm samples are scaled to fractional 2's complement and
918
+ * concatenated to the end of the window buffer #x#. The updated window
919
+ * buffer #x# is then windowed by the analysis window #c# to produce the
920
+ * windowed sample #z#
921
+ */var order=[0,1,16,17,8,9,24,25,4,5,20,21,12,13,28,29,2,3,18,19,10,11,26,27,6,7,22,23,14,15,30,31];/**
922
+ * returns sum_j=0^31 a[j]*cos(PI*j*(k+1/2)/32), 0<=k<32
923
+ */function window_subband(x1,x1Pos,a){var wp=10;var x2=x1Pos+238-14-286;for(var i=-15;i<0;i++){var w,s,t;w=enwindow[wp+-10];s=x1[x2+-224]*w;t=x1[x1Pos+224]*w;w=enwindow[wp+-9];s+=x1[x2+-160]*w;t+=x1[x1Pos+160]*w;w=enwindow[wp+-8];s+=x1[x2+-96]*w;t+=x1[x1Pos+96]*w;w=enwindow[wp+-7];s+=x1[x2+-32]*w;t+=x1[x1Pos+32]*w;w=enwindow[wp+-6];s+=x1[x2+32]*w;t+=x1[x1Pos+-32]*w;w=enwindow[wp+-5];s+=x1[x2+96]*w;t+=x1[x1Pos+-96]*w;w=enwindow[wp+-4];s+=x1[x2+160]*w;t+=x1[x1Pos+-160]*w;w=enwindow[wp+-3];s+=x1[x2+224]*w;t+=x1[x1Pos+-224]*w;w=enwindow[wp+-2];s+=x1[x1Pos+-256]*w;t-=x1[x2+256]*w;w=enwindow[wp+-1];s+=x1[x1Pos+-192]*w;t-=x1[x2+192]*w;w=enwindow[wp+0];s+=x1[x1Pos+-128]*w;t-=x1[x2+128]*w;w=enwindow[wp+1];s+=x1[x1Pos+-64]*w;t-=x1[x2+64]*w;w=enwindow[wp+2];s+=x1[x1Pos+0]*w;t-=x1[x2+0]*w;w=enwindow[wp+3];s+=x1[x1Pos+64]*w;t-=x1[x2+-64]*w;w=enwindow[wp+4];s+=x1[x1Pos+128]*w;t-=x1[x2+-128]*w;w=enwindow[wp+5];s+=x1[x1Pos+192]*w;t-=x1[x2+-192]*w;/*
924
+ * this multiplyer could be removed, but it needs more 256 FLOAT
925
+ * data. thinking about the data cache performance, I think we
926
+ * should not use such a huge table. tt 2000/Oct/25
927
+ */s*=enwindow[wp+6];w=t-s;a[30+i*2]=t+s;a[31+i*2]=enwindow[wp+7]*w;wp+=18;x1Pos--;x2++;}var s,t,u,v;t=x1[x1Pos+-16]*enwindow[wp+-10];s=x1[x1Pos+-32]*enwindow[wp+-2];t+=(x1[x1Pos+-48]-x1[x1Pos+16])*enwindow[wp+-9];s+=x1[x1Pos+-96]*enwindow[wp+-1];t+=(x1[x1Pos+-80]+x1[x1Pos+48])*enwindow[wp+-8];s+=x1[x1Pos+-160]*enwindow[wp+0];t+=(x1[x1Pos+-112]-x1[x1Pos+80])*enwindow[wp+-7];s+=x1[x1Pos+-224]*enwindow[wp+1];t+=(x1[x1Pos+-144]+x1[x1Pos+112])*enwindow[wp+-6];s-=x1[x1Pos+32]*enwindow[wp+2];t+=(x1[x1Pos+-176]-x1[x1Pos+144])*enwindow[wp+-5];s-=x1[x1Pos+96]*enwindow[wp+3];t+=(x1[x1Pos+-208]+x1[x1Pos+176])*enwindow[wp+-4];s-=x1[x1Pos+160]*enwindow[wp+4];t+=(x1[x1Pos+-240]-x1[x1Pos+208])*enwindow[wp+-3];s-=x1[x1Pos+224];u=s-t;v=s+t;t=a[14];s=a[15]-t;a[31]=v+t;/* A0 */a[30]=u+s;/* A1 */a[15]=u-s;/* A2 */a[14]=v-t;/* A3 */var xr;xr=a[28]-a[0];a[0]+=a[28];a[28]=xr*enwindow[wp+-36+7];xr=a[29]-a[1];a[1]+=a[29];a[29]=xr*enwindow[wp+-36+7];xr=a[26]-a[2];a[2]+=a[26];a[26]=xr*enwindow[wp+-72+7];xr=a[27]-a[3];a[3]+=a[27];a[27]=xr*enwindow[wp+-72+7];xr=a[24]-a[4];a[4]+=a[24];a[24]=xr*enwindow[wp+-108+7];xr=a[25]-a[5];a[5]+=a[25];a[25]=xr*enwindow[wp+-108+7];xr=a[22]-a[6];a[6]+=a[22];a[22]=xr*$9c8c9409243421ca$var$Util.SQRT2;xr=a[23]-a[7];a[7]+=a[23];a[23]=xr*$9c8c9409243421ca$var$Util.SQRT2-a[7];a[7]-=a[6];a[22]-=a[7];a[23]-=a[22];xr=a[6];a[6]=a[31]-xr;a[31]=a[31]+xr;xr=a[7];a[7]=a[30]-xr;a[30]=a[30]+xr;xr=a[22];a[22]=a[15]-xr;a[15]=a[15]+xr;xr=a[23];a[23]=a[14]-xr;a[14]=a[14]+xr;xr=a[20]-a[8];a[8]+=a[20];a[20]=xr*enwindow[wp+-180+7];xr=a[21]-a[9];a[9]+=a[21];a[21]=xr*enwindow[wp+-180+7];xr=a[18]-a[10];a[10]+=a[18];a[18]=xr*enwindow[wp+-216+7];xr=a[19]-a[11];a[11]+=a[19];a[19]=xr*enwindow[wp+-216+7];xr=a[16]-a[12];a[12]+=a[16];a[16]=xr*enwindow[wp+-252+7];xr=a[17]-a[13];a[13]+=a[17];a[17]=xr*enwindow[wp+-252+7];xr=-a[20]+a[24];a[20]+=a[24];a[24]=xr*enwindow[wp+-216+7];xr=-a[21]+a[25];a[21]+=a[25];a[25]=xr*enwindow[wp+-216+7];xr=a[4]-a[8];a[4]+=a[8];a[8]=xr*enwindow[wp+-216+7];xr=a[5]-a[9];a[5]+=a[9];a[9]=xr*enwindow[wp+-216+7];xr=a[0]-a[12];a[0]+=a[12];a[12]=xr*enwindow[wp+-72+7];xr=a[1]-a[13];a[1]+=a[13];a[13]=xr*enwindow[wp+-72+7];xr=a[16]-a[28];a[16]+=a[28];a[28]=xr*enwindow[wp+-72+7];xr=-a[17]+a[29];a[17]+=a[29];a[29]=xr*enwindow[wp+-72+7];xr=$9c8c9409243421ca$var$Util.SQRT2*(a[2]-a[10]);a[2]+=a[10];a[10]=xr;xr=$9c8c9409243421ca$var$Util.SQRT2*(a[3]-a[11]);a[3]+=a[11];a[11]=xr;xr=$9c8c9409243421ca$var$Util.SQRT2*(-a[18]+a[26]);a[18]+=a[26];a[26]=xr-a[18];xr=$9c8c9409243421ca$var$Util.SQRT2*(-a[19]+a[27]);a[19]+=a[27];a[27]=xr-a[19];xr=a[2];a[19]-=a[3];a[3]-=xr;a[2]=a[31]-xr;a[31]+=xr;xr=a[3];a[11]-=a[19];a[18]-=xr;a[3]=a[30]-xr;a[30]+=xr;xr=a[18];a[27]-=a[11];a[19]-=xr;a[18]=a[15]-xr;a[15]+=xr;xr=a[19];a[10]-=xr;a[19]=a[14]-xr;a[14]+=xr;xr=a[10];a[11]-=xr;a[10]=a[23]-xr;a[23]+=xr;xr=a[11];a[26]-=xr;a[11]=a[22]-xr;a[22]+=xr;xr=a[26];a[27]-=xr;a[26]=a[7]-xr;a[7]+=xr;xr=a[27];a[27]=a[6]-xr;a[6]+=xr;xr=$9c8c9409243421ca$var$Util.SQRT2*(a[0]-a[4]);a[0]+=a[4];a[4]=xr;xr=$9c8c9409243421ca$var$Util.SQRT2*(a[1]-a[5]);a[1]+=a[5];a[5]=xr;xr=$9c8c9409243421ca$var$Util.SQRT2*(a[16]-a[20]);a[16]+=a[20];a[20]=xr;xr=$9c8c9409243421ca$var$Util.SQRT2*(a[17]-a[21]);a[17]+=a[21];a[21]=xr;xr=-$9c8c9409243421ca$var$Util.SQRT2*(a[8]-a[12]);a[8]+=a[12];a[12]=xr-a[8];xr=-$9c8c9409243421ca$var$Util.SQRT2*(a[9]-a[13]);a[9]+=a[13];a[13]=xr-a[9];xr=-$9c8c9409243421ca$var$Util.SQRT2*(a[25]-a[29]);a[25]+=a[29];a[29]=xr-a[25];xr=-$9c8c9409243421ca$var$Util.SQRT2*(a[24]+a[28]);a[24]-=a[28];a[28]=xr-a[24];xr=a[24]-a[16];a[24]=xr;xr=a[20]-xr;a[20]=xr;xr=a[28]-xr;a[28]=xr;xr=a[25]-a[17];a[25]=xr;xr=a[21]-xr;a[21]=xr;xr=a[29]-xr;a[29]=xr;xr=a[17]-a[1];a[17]=xr;xr=a[9]-xr;a[9]=xr;xr=a[25]-xr;a[25]=xr;xr=a[5]-xr;a[5]=xr;xr=a[21]-xr;a[21]=xr;xr=a[13]-xr;a[13]=xr;xr=a[29]-xr;a[29]=xr;xr=a[1]-a[0];a[1]=xr;xr=a[16]-xr;a[16]=xr;xr=a[17]-xr;a[17]=xr;xr=a[8]-xr;a[8]=xr;xr=a[9]-xr;a[9]=xr;xr=a[24]-xr;a[24]=xr;xr=a[25]-xr;a[25]=xr;xr=a[4]-xr;a[4]=xr;xr=a[5]-xr;a[5]=xr;xr=a[20]-xr;a[20]=xr;xr=a[21]-xr;a[21]=xr;xr=a[12]-xr;a[12]=xr;xr=a[13]-xr;a[13]=xr;xr=a[28]-xr;a[28]=xr;xr=a[29]-xr;a[29]=xr;xr=a[0];a[0]+=a[31];a[31]-=xr;xr=a[1];a[1]+=a[30];a[30]-=xr;xr=a[16];a[16]+=a[15];a[15]-=xr;xr=a[17];a[17]+=a[14];a[14]-=xr;xr=a[8];a[8]+=a[23];a[23]-=xr;xr=a[9];a[9]+=a[22];a[22]-=xr;xr=a[24];a[24]+=a[7];a[7]-=xr;xr=a[25];a[25]+=a[6];a[6]-=xr;xr=a[4];a[4]+=a[27];a[27]-=xr;xr=a[5];a[5]+=a[26];a[26]-=xr;xr=a[20];a[20]+=a[11];a[11]-=xr;xr=a[21];a[21]+=a[10];a[10]-=xr;xr=a[12];a[12]+=a[19];a[19]-=xr;xr=a[13];a[13]+=a[18];a[18]-=xr;xr=a[28];a[28]+=a[3];a[3]-=xr;xr=a[29];a[29]+=a[2];a[2]-=xr;}/**
928
+ * Function: Calculation of the MDCT In the case of long blocks (type 0,1,3)
929
+ * there are 36 coefficents in the time domain and 18 in the frequency
930
+ * domain.<BR>
931
+ * In the case of short blocks (type 2) there are 3 transformations with
932
+ * short length. This leads to 12 coefficents in the time and 6 in the
933
+ * frequency domain. In this case the results are stored side by side in the
934
+ * vector out[].
935
+ *
936
+ * New layer3
937
+ */function mdct_short(inout,inoutPos){for(var l=0;l<3;l++){var tc0,tc1,tc2,ts0,ts1,ts2;ts0=inout[inoutPos+6]*win[$cPNKB.SHORT_TYPE][0]-inout[inoutPos+15];tc0=inout[inoutPos+0]*win[$cPNKB.SHORT_TYPE][2]-inout[inoutPos+9];tc1=ts0+tc0;tc2=ts0-tc0;ts0=inout[inoutPos+15]*win[$cPNKB.SHORT_TYPE][0]+inout[inoutPos+6];tc0=inout[inoutPos+9]*win[$cPNKB.SHORT_TYPE][2]+inout[inoutPos+0];ts1=ts0+tc0;ts2=-ts0+tc0;tc0=(inout[inoutPos+3]*win[$cPNKB.SHORT_TYPE][1]-inout[inoutPos+12])*2.069978111953089e-11;/*
938
+ * tritab_s [ 1 ]
939
+ */ts0=(inout[inoutPos+12]*win[$cPNKB.SHORT_TYPE][1]+inout[inoutPos+3])*2.069978111953089e-11;/*
940
+ * tritab_s [ 1 ]
941
+ */inout[inoutPos+0]=tc1*1.907525191737280e-11+tc0;/*
942
+ * tritab_s[ 2 ]
943
+ */inout[inoutPos+15]=-ts1*1.907525191737280e-11+ts0;/*
944
+ * tritab_s[0 ]
945
+ */tc2=tc2*0.000000000016519652744032674;/*
946
+ * tritab_s[ 2]
947
+ */ts1=ts1*0.5*1.907525191737281e-11+ts0;inout[inoutPos+3]=tc2-ts1;inout[inoutPos+6]=tc2+ts1;tc1=tc1*0.5*1.907525191737281e-11-tc0;ts2=ts2*0.000000000016519652744032674;/*
948
+ * tritab_s[ 0]
949
+ */inout[inoutPos+9]=tc1+ts2;inout[inoutPos+12]=tc1-ts2;inoutPos++;}}function mdct_long(out,outPos,_in){var ct,st;var tc1,tc2,tc3,tc4,ts5,ts6,ts7,ts8;/* 1,2, 5,6, 9,10, 13,14, 17 */tc1=_in[17]-_in[9];tc3=_in[15]-_in[11];tc4=_in[14]-_in[12];ts5=_in[0]+_in[8];ts6=_in[1]+_in[7];ts7=_in[2]+_in[6];ts8=_in[3]+_in[5];out[outPos+17]=ts5+ts7-ts8-(ts6-_in[4]);st=(ts5+ts7-ts8)*cx[19]+(ts6-_in[4]);ct=(tc1-tc3-tc4)*cx[18];out[outPos+5]=ct+st;out[outPos+6]=ct-st;tc2=(_in[16]-_in[10])*cx[18];ts6=ts6*cx[19]+_in[4];ct=tc1*cx[12]+tc2+tc3*cx[13]+tc4*cx[14];st=-ts5*cx[16]+ts6-ts7*cx[17]+ts8*cx[15];out[outPos+1]=ct+st;out[outPos+2]=ct-st;ct=tc1*cx[13]-tc2-tc3*cx[14]+tc4*cx[12];st=-ts5*cx[17]+ts6-ts7*cx[15]+ts8*cx[16];out[outPos+9]=ct+st;out[outPos+10]=ct-st;ct=tc1*cx[14]-tc2+tc3*cx[12]-tc4*cx[13];st=ts5*cx[15]-ts6+ts7*cx[16]-ts8*cx[17];out[outPos+13]=ct+st;out[outPos+14]=ct-st;var ts1,ts2,ts3,ts4,tc5,tc6,tc7,tc8;ts1=_in[8]-_in[0];ts3=_in[6]-_in[2];ts4=_in[5]-_in[3];tc5=_in[17]+_in[9];tc6=_in[16]+_in[10];tc7=_in[15]+_in[11];tc8=_in[14]+_in[12];out[outPos+0]=tc5+tc7+tc8+(tc6+_in[13]);ct=(tc5+tc7+tc8)*cx[19]-(tc6+_in[13]);st=(ts1-ts3+ts4)*cx[18];out[outPos+11]=ct+st;out[outPos+12]=ct-st;ts2=(_in[7]-_in[1])*cx[18];tc6=_in[13]-tc6*cx[19];ct=tc5*cx[15]-tc6+tc7*cx[16]+tc8*cx[17];st=ts1*cx[14]+ts2+ts3*cx[12]+ts4*cx[13];out[outPos+3]=ct+st;out[outPos+4]=ct-st;ct=-tc5*cx[17]+tc6-tc7*cx[15]-tc8*cx[16];st=ts1*cx[13]+ts2-ts3*cx[14]-ts4*cx[12];out[outPos+7]=ct+st;out[outPos+8]=ct-st;ct=-tc5*cx[16]+tc6-tc7*cx[17]-tc8*cx[15];st=ts1*cx[12]-ts2+ts3*cx[13]-ts4*cx[14];out[outPos+15]=ct+st;out[outPos+16]=ct-st;}this.mdct_sub48=function(gfc,w0,w1){var wk=w0;var wkPos=286;/* thinking cache performance, ch->gr loop is better than gr->ch loop */for(var ch=0;ch<gfc.channels_out;ch++){for(var gr=0;gr<gfc.mode_gr;gr++){var band;var gi=gfc.l3_side.tt[gr][ch];var mdct_enc=gi.xr;var mdct_encPos=0;var samp=gfc.sb_sample[ch][1-gr];var sampPos=0;for(var k=0;k<9;k++){window_subband(wk,wkPos,samp[sampPos]);window_subband(wk,wkPos+32,samp[sampPos+1]);sampPos+=2;wkPos+=64;/*
950
+ * Compensate for inversion in the analysis filter
951
+ */for(band=1;band<32;band+=2)samp[sampPos-1][band]*=-1;}/*
952
+ * Perform imdct of 18 previous subband samples + 18 current
953
+ * subband samples
954
+ */for(band=0;band<32;band++,mdct_encPos+=18){var type=gi.block_type;var band0=gfc.sb_sample[ch][gr];var band1=gfc.sb_sample[ch][1-gr];if(gi.mixed_block_flag!=0&&band<2)type=0;if(gfc.amp_filter[band]<1e-12)$9c8c9409243421ca$var$Arrays.fill(mdct_enc,mdct_encPos+0,mdct_encPos+18,0);else {if(gfc.amp_filter[band]<1.0)for(var k=0;k<18;k++)band1[k][order[band]]*=gfc.amp_filter[band];if(type==$cPNKB.SHORT_TYPE){for(var k=-NS/4;k<0;k++){var w=win[$cPNKB.SHORT_TYPE][k+3];mdct_enc[mdct_encPos+k*3+9]=band0[9+k][order[band]]*w-band0[8-k][order[band]];mdct_enc[mdct_encPos+k*3+18]=band0[14-k][order[band]]*w+band0[15+k][order[band]];mdct_enc[mdct_encPos+k*3+10]=band0[15+k][order[band]]*w-band0[14-k][order[band]];mdct_enc[mdct_encPos+k*3+19]=band1[2-k][order[band]]*w+band1[3+k][order[band]];mdct_enc[mdct_encPos+k*3+11]=band1[3+k][order[band]]*w-band1[2-k][order[band]];mdct_enc[mdct_encPos+k*3+20]=band1[8-k][order[band]]*w+band1[9+k][order[band]];}mdct_short(mdct_enc,mdct_encPos);}else {var work=$9c8c9409243421ca$var$new_float(18);for(var k=-NL/4;k<0;k++){var a,b;a=win[type][k+27]*band1[k+9][order[band]]+win[type][k+36]*band1[8-k][order[band]];b=win[type][k+9]*band0[k+9][order[band]]-win[type][k+18]*band0[8-k][order[band]];work[k+9]=a-b*tantab_l[3+k+9];work[k+18]=a*tantab_l[3+k+9]+b;}mdct_long(mdct_enc,mdct_encPos,work);}}/*
955
+ * Perform aliasing reduction butterfly
956
+ */if(type!=$cPNKB.SHORT_TYPE&&band!=0)for(var k=7;k>=0;--k){var bu,bd;bu=mdct_enc[mdct_encPos+k]*ca[20+k]+mdct_enc[mdct_encPos+-1-k]*cs[28+k];bd=mdct_enc[mdct_encPos+k]*cs[28+k]-mdct_enc[mdct_encPos+-1-k]*ca[20+k];mdct_enc[mdct_encPos+-1-k]=bu;mdct_enc[mdct_encPos+k]=bd;}}}wk=w1;wkPos=286;if(gfc.mode_gr==1)for(var i=0;i<18;i++)$9c8c9409243421ca$var$System.arraycopy(gfc.sb_sample[ch][1][i],0,gfc.sb_sample[ch][0][i],0,32);}};}module.exports=$9c8c9409243421ca$var$NewMDCT;});parcelRequire.register("hvy40",function(module,exports){//package mp3;
957
+ var $51XxS=parcelRequire("51XxS");function $cbefc13b27188c2b$var$III_psy_ratio(){this.thm=new $51XxS();this.en=new $51XxS();}module.exports=$cbefc13b27188c2b$var$III_psy_ratio;});parcelRequire.register("51XxS",function(module,exports){var $cPNKB=parcelRequire("cPNKB");var $3YDN3=parcelRequire("3YDN3");var $3a9b3c3a1c7d1011$var$System=$3YDN3.System;$3YDN3.VbrMode;$3YDN3.Float;$3YDN3.ShortBlock;$3YDN3.Util;$3YDN3.Arrays;$3YDN3.new_array_n;$3YDN3.new_byte;$3YDN3.new_double;var $3a9b3c3a1c7d1011$var$new_float=$3YDN3.new_float;var $3a9b3c3a1c7d1011$var$new_float_n=$3YDN3.new_float_n;$3YDN3.new_int;$3YDN3.new_int_n;$3YDN3.assert;function $3a9b3c3a1c7d1011$var$III_psy_xmin(){this.l=$3a9b3c3a1c7d1011$var$new_float($cPNKB.SBMAX_l);this.s=$3a9b3c3a1c7d1011$var$new_float_n([$cPNKB.SBMAX_s,3]);var self=this;this.assign=function(iii_psy_xmin){$3a9b3c3a1c7d1011$var$System.arraycopy(iii_psy_xmin.l,0,self.l,0,$cPNKB.SBMAX_l);for(var i=0;i<$cPNKB.SBMAX_s;i++)for(var j=0;j<3;j++)self.s[i][j]=iii_psy_xmin.s[i][j];};}module.exports=$3a9b3c3a1c7d1011$var$III_psy_xmin;});parcelRequire.register("jL6I1",function(module,exports){//package mp3;
958
+ /* MPEG modes */function $e6279c632d7fdac0$var$MPEGMode(ordinal){var _ordinal=ordinal;this.ordinal=function(){return _ordinal;};}$e6279c632d7fdac0$var$MPEGMode.STEREO=new $e6279c632d7fdac0$var$MPEGMode(0);$e6279c632d7fdac0$var$MPEGMode.JOINT_STEREO=new $e6279c632d7fdac0$var$MPEGMode(1);$e6279c632d7fdac0$var$MPEGMode.DUAL_CHANNEL=new $e6279c632d7fdac0$var$MPEGMode(2);$e6279c632d7fdac0$var$MPEGMode.MONO=new $e6279c632d7fdac0$var$MPEGMode(3);$e6279c632d7fdac0$var$MPEGMode.NOT_SET=new $e6279c632d7fdac0$var$MPEGMode(4);module.exports=$e6279c632d7fdac0$var$MPEGMode;});parcelRequire.register("5HJeD",function(module,exports){var $jL6I1=parcelRequire("jL6I1");function $42740ea95db3cb8e$var$LameGlobalFlags(){this.class_id=0;/* input description */ /**
959
+ * number of samples. default=-1
960
+ */this.num_samples=0;/**
961
+ * input number of channels. default=2
962
+ */this.num_channels=0;/**
963
+ * input_samp_rate in Hz. default=44.1 kHz
964
+ */this.in_samplerate=0;/**
965
+ * output_samp_rate. default: LAME picks best value at least not used for
966
+ * MP3 decoding: Remember 44.1 kHz MP3s and AC97
967
+ */this.out_samplerate=0;/**
968
+ * scale input by this amount before encoding at least not used for MP3
969
+ * decoding
970
+ */this.scale=0.;/**
971
+ * scale input of channel 0 (left) by this amount before encoding
972
+ */this.scale_left=0.;/**
973
+ * scale input of channel 1 (right) by this amount before encoding
974
+ */this.scale_right=0.;/* general control params */ /**
975
+ * collect data for a MP3 frame analyzer?
976
+ */this.analysis=false;/**
977
+ * add Xing VBR tag?
978
+ */this.bWriteVbrTag=false;/**
979
+ * use lame/mpglib to convert mp3 to wav
980
+ */this.decode_only=false;/**
981
+ * quality setting 0=best, 9=worst default=5
982
+ */this.quality=0;/**
983
+ * see enum default = LAME picks best value
984
+ */this.mode=$jL6I1.STEREO;/**
985
+ * force M/S mode. requires mode=1
986
+ */this.force_ms=false;/**
987
+ * use free format? default=0
988
+ */this.free_format=false;/**
989
+ * find the RG value? default=0
990
+ */this.findReplayGain=false;/**
991
+ * decode on the fly? default=0
992
+ */this.decode_on_the_fly=false;/**
993
+ * 1 (default) writes ID3 tags, 0 not
994
+ */this.write_id3tag_automatic=false;/*
995
+ * set either brate>0 or compression_ratio>0, LAME will compute the value of
996
+ * the variable not set. Default is compression_ratio = 11.025
997
+ */ /**
998
+ * bitrate
999
+ */this.brate=0;/**
1000
+ * sizeof(wav file)/sizeof(mp3 file)
1001
+ */this.compression_ratio=0.;/* frame params */ /**
1002
+ * mark as copyright. default=0
1003
+ */this.copyright=0;/**
1004
+ * mark as original. default=1
1005
+ */this.original=0;/**
1006
+ * the MP3 'private extension' bit. Meaningless
1007
+ */this.extension=0;/**
1008
+ * Input PCM is emphased PCM (for instance from one of the rarely emphased
1009
+ * CDs), it is STRONGLY not recommended to use this, because psycho does not
1010
+ * take it into account, and last but not least many decoders don't care
1011
+ * about these bits
1012
+ */this.emphasis=0;/**
1013
+ * use 2 bytes per frame for a CRC checksum. default=0
1014
+ */this.error_protection=0;/**
1015
+ * enforce ISO spec as much as possible
1016
+ */this.strict_ISO=false;/**
1017
+ * use bit reservoir?
1018
+ */this.disable_reservoir=false;/* quantization/noise shaping */this.quant_comp=0;this.quant_comp_short=0;this.experimentalY=false;this.experimentalZ=0;this.exp_nspsytune=0;this.preset=0;/* VBR control */this.VBR=null;/**
1019
+ * Range [0,...,1[
1020
+ */this.VBR_q_frac=0.;/**
1021
+ * Range [0,...,9]
1022
+ */this.VBR_q=0;this.VBR_mean_bitrate_kbps=0;this.VBR_min_bitrate_kbps=0;this.VBR_max_bitrate_kbps=0;/**
1023
+ * strictly enforce VBR_min_bitrate normaly, it will be violated for analog
1024
+ * silence
1025
+ */this.VBR_hard_min=0;/* resampling and filtering */ /**
1026
+ * freq in Hz. 0=lame choses. -1=no filter
1027
+ */this.lowpassfreq=0;/**
1028
+ * freq in Hz. 0=lame choses. -1=no filter
1029
+ */this.highpassfreq=0;/**
1030
+ * freq width of filter, in Hz (default=15%)
1031
+ */this.lowpasswidth=0;/**
1032
+ * freq width of filter, in Hz (default=15%)
1033
+ */this.highpasswidth=0;/*
1034
+ * psycho acoustics and other arguments which you should not change unless
1035
+ * you know what you are doing
1036
+ */this.maskingadjust=0.;this.maskingadjust_short=0.;/**
1037
+ * only use ATH
1038
+ */this.ATHonly=false;/**
1039
+ * only use ATH for short blocks
1040
+ */this.ATHshort=false;/**
1041
+ * disable ATH
1042
+ */this.noATH=false;/**
1043
+ * select ATH formula
1044
+ */this.ATHtype=0;/**
1045
+ * change ATH formula 4 shape
1046
+ */this.ATHcurve=0.;/**
1047
+ * lower ATH by this many db
1048
+ */this.ATHlower=0.;/**
1049
+ * select ATH auto-adjust scheme
1050
+ */this.athaa_type=0;/**
1051
+ * select ATH auto-adjust loudness calc
1052
+ */this.athaa_loudapprox=0;/**
1053
+ * dB, tune active region of auto-level
1054
+ */this.athaa_sensitivity=0.;this.short_blocks=null;/**
1055
+ * use temporal masking effect
1056
+ */this.useTemporal=false;this.interChRatio=0.;/**
1057
+ * Naoki's adjustment of Mid/Side maskings
1058
+ */this.msfix=0.;/**
1059
+ * 0 off, 1 on
1060
+ */this.tune=false;/**
1061
+ * used to pass values for debugging and stuff
1062
+ */this.tune_value_a=0.;/************************************************************************/ /* internal variables, do not set... */ /* provided because they may be of use to calling application */ /************************************************************************/ /**
1063
+ * 0=MPEG-2/2.5 1=MPEG-1
1064
+ */this.version=0;this.encoder_delay=0;/**
1065
+ * number of samples of padding appended to input
1066
+ */this.encoder_padding=0;this.framesize=0;/**
1067
+ * number of frames encoded
1068
+ */this.frameNum=0;/**
1069
+ * is this struct owned by calling program or lame?
1070
+ */this.lame_allocated_gfp=0;/**************************************************************************/ /* more internal variables are stored in this structure: */ /**************************************************************************/this.internal_flags=null;}module.exports=$42740ea95db3cb8e$var$LameGlobalFlags;});parcelRequire.register("4SDnr",function(module,exports){var $3YDN3=parcelRequire("3YDN3");$3YDN3.System;$3YDN3.VbrMode;$3YDN3.Float;$3YDN3.ShortBlock;$3YDN3.Util;$3YDN3.Arrays;$3YDN3.new_array_n;var $38dac00579cf6ffc$var$new_byte=$3YDN3.new_byte;var $38dac00579cf6ffc$var$new_double=$3YDN3.new_double;var $38dac00579cf6ffc$var$new_float=$3YDN3.new_float;var $38dac00579cf6ffc$var$new_float_n=$3YDN3.new_float_n;var $38dac00579cf6ffc$var$new_int=$3YDN3.new_int;var $38dac00579cf6ffc$var$new_int_n=$3YDN3.new_int_n;$3YDN3.assert;var $eWXBy=parcelRequire("eWXBy");var $7imnH=parcelRequire("7imnH");var $7yzUB=parcelRequire("7yzUB");var $jTmCQ=parcelRequire("jTmCQ");var $51XxS=parcelRequire("51XxS");var $cPNKB=parcelRequire("cPNKB");var $arIi9=parcelRequire("arIi9");$38dac00579cf6ffc$var$LameInternalFlags.MFSIZE=3456+$cPNKB.ENCDELAY-$cPNKB.MDCTDELAY;$38dac00579cf6ffc$var$LameInternalFlags.MAX_HEADER_BUF=256;$38dac00579cf6ffc$var$LameInternalFlags.MAX_BITS_PER_CHANNEL=4095;$38dac00579cf6ffc$var$LameInternalFlags.MAX_BITS_PER_GRANULE=7680;$38dac00579cf6ffc$var$LameInternalFlags.BPC=320;function $38dac00579cf6ffc$var$LameInternalFlags(){var MAX_HEADER_LEN=40;/********************************************************************
1071
+ * internal variables NOT set by calling program, and should not be *
1072
+ * modified by the calling program *
1073
+ ********************************************************************/ /**
1074
+ * Some remarks to the Class_ID field: The Class ID is an Identifier for a
1075
+ * pointer to this struct. It is very unlikely that a pointer to
1076
+ * lame_global_flags has the same 32 bits in it's structure (large and other
1077
+ * special properties, for instance prime).
1078
+ *
1079
+ * To test that the structure is right and initialized, use: if ( gfc .
1080
+ * Class_ID == LAME_ID ) ... Other remark: If you set a flag to 0 for uninit
1081
+ * data and 1 for init data, the right test should be "if (flag == 1)" and
1082
+ * NOT "if (flag)". Unintended modification of this element will be
1083
+ * otherwise misinterpreted as an init.
1084
+ */this.Class_ID=0;this.lame_encode_frame_init=0;this.iteration_init_init=0;this.fill_buffer_resample_init=0;//public float mfbuf[][] = new float[2][MFSIZE];
1085
+ this.mfbuf=$38dac00579cf6ffc$var$new_float_n([2,$38dac00579cf6ffc$var$LameInternalFlags.MFSIZE]);/**
1086
+ * granules per frame
1087
+ */this.mode_gr=0;/**
1088
+ * number of channels in the input data stream (PCM or decoded PCM)
1089
+ */this.channels_in=0;/**
1090
+ * number of channels in the output data stream (not used for decoding)
1091
+ */this.channels_out=0;/**
1092
+ * input_samp_rate/output_samp_rate
1093
+ */ //public double resample_ratio;
1094
+ this.resample_ratio=0.;this.mf_samples_to_encode=0;this.mf_size=0;/**
1095
+ * min bitrate index
1096
+ */this.VBR_min_bitrate=0;/**
1097
+ * max bitrate index
1098
+ */this.VBR_max_bitrate=0;this.bitrate_index=0;this.samplerate_index=0;this.mode_ext=0;/* lowpass and highpass filter control */ /**
1099
+ * normalized frequency bounds of passband
1100
+ */this.lowpass1=0.;this.lowpass2=0.;/**
1101
+ * normalized frequency bounds of passband
1102
+ */this.highpass1=0.;this.highpass2=0.;/**
1103
+ * 0 = none 1 = ISO AAC model 2 = allow scalefac_select=1
1104
+ */this.noise_shaping=0;/**
1105
+ * 0 = ISO model: amplify all distorted bands<BR>
1106
+ * 1 = amplify within 50% of max (on db scale)<BR>
1107
+ * 2 = amplify only most distorted band<BR>
1108
+ * 3 = method 1 and refine with method 2<BR>
1109
+ */this.noise_shaping_amp=0;/**
1110
+ * 0 = no substep<BR>
1111
+ * 1 = use substep shaping at last step(VBR only)<BR>
1112
+ * (not implemented yet)<BR>
1113
+ * 2 = use substep inside loop<BR>
1114
+ * 3 = use substep inside loop and last step<BR>
1115
+ */this.substep_shaping=0;/**
1116
+ * 1 = gpsycho. 0 = none
1117
+ */this.psymodel=0;/**
1118
+ * 0 = stop at over=0, all scalefacs amplified or<BR>
1119
+ * a scalefac has reached max value<BR>
1120
+ * 1 = stop when all scalefacs amplified or a scalefac has reached max value<BR>
1121
+ * 2 = stop when all scalefacs amplified
1122
+ */this.noise_shaping_stop=0;/**
1123
+ * 0 = no, 1 = yes
1124
+ */this.subblock_gain=0;/**
1125
+ * 0 = no. 1=outside loop 2=inside loop(slow)
1126
+ */this.use_best_huffman=0;/**
1127
+ * 0 = stop early after 0 distortion found. 1 = full search
1128
+ */this.full_outer_loop=0;//public IIISideInfo l3_side = new IIISideInfo();
1129
+ this.l3_side=new $eWXBy();this.ms_ratio=$38dac00579cf6ffc$var$new_float(2);/* used for padding */ /**
1130
+ * padding for the current frame?
1131
+ */this.padding=0;this.frac_SpF=0;this.slot_lag=0;/**
1132
+ * optional ID3 tags
1133
+ */ //public ID3TagSpec tag_spec;
1134
+ this.tag_spec=null;this.nMusicCRC=0;/* variables used by Quantize */ //public int OldValue[] = new int[2];
1135
+ this.OldValue=$38dac00579cf6ffc$var$new_int(2);//public int CurrentStep[] = new int[2];
1136
+ this.CurrentStep=$38dac00579cf6ffc$var$new_int(2);this.masking_lower=0.;//public int bv_scf[] = new int[576];
1137
+ this.bv_scf=$38dac00579cf6ffc$var$new_int(576);//public int pseudohalf[] = new int[L3Side.SFBMAX];
1138
+ this.pseudohalf=$38dac00579cf6ffc$var$new_int($arIi9.SFBMAX);/**
1139
+ * will be set in lame_init_params
1140
+ */this.sfb21_extra=false;/* BPC = maximum number of filter convolution windows to precompute */ //public float[][] inbuf_old = new float[2][];
1141
+ this.inbuf_old=new Array(2);//public float[][] blackfilt = new float[2 * BPC + 1][];
1142
+ this.blackfilt=new Array(2*$38dac00579cf6ffc$var$LameInternalFlags.BPC+1);//public double itime[] = new double[2];
1143
+ this.itime=$38dac00579cf6ffc$var$new_double(2);this.sideinfo_len=0;/* variables for newmdct.c */ //public float sb_sample[][][][] = new float[2][2][18][Encoder.SBLIMIT];
1144
+ this.sb_sample=$38dac00579cf6ffc$var$new_float_n([2,2,18,$cPNKB.SBLIMIT]);this.amp_filter=$38dac00579cf6ffc$var$new_float(32);/* variables for BitStream */ /**
1145
+ * <PRE>
1146
+ * mpeg1: buffer=511 bytes smallest frame: 96-38(sideinfo)=58
1147
+ * max number of frames in reservoir: 8
1148
+ * mpeg2: buffer=255 bytes. smallest frame: 24-23bytes=1
1149
+ * with VBR, if you are encoding all silence, it is possible to
1150
+ * have 8kbs/24khz frames with 1byte of data each, which means we need
1151
+ * to buffer up to 255 headers!
1152
+ * </PRE>
1153
+ */ /**
1154
+ * also, max_header_buf has to be a power of two
1155
+ */ /**
1156
+ * max size of header is 38
1157
+ */function Header(){this.write_timing=0;this.ptr=0;//public byte buf[] = new byte[MAX_HEADER_LEN];
1158
+ this.buf=$38dac00579cf6ffc$var$new_byte(MAX_HEADER_LEN);}this.header=new Array($38dac00579cf6ffc$var$LameInternalFlags.MAX_HEADER_BUF);this.h_ptr=0;this.w_ptr=0;this.ancillary_flag=0;/* variables for Reservoir */ /**
1159
+ * in bits
1160
+ */this.ResvSize=0;/**
1161
+ * in bits
1162
+ */this.ResvMax=0;//public ScaleFac scalefac_band = new ScaleFac();
1163
+ this.scalefac_band=new $7imnH();/* daa from PsyModel */ /* The static variables "r", "phi_sav", "new", "old" and "oldest" have */ /* to be remembered for the unpredictability measure. For "r" and */ /* "phi_sav", the first index from the left is the channel select and */ /* the second index is the "age" of the data. */this.minval_l=$38dac00579cf6ffc$var$new_float($cPNKB.CBANDS);this.minval_s=$38dac00579cf6ffc$var$new_float($cPNKB.CBANDS);this.nb_1=$38dac00579cf6ffc$var$new_float_n([4,$cPNKB.CBANDS]);this.nb_2=$38dac00579cf6ffc$var$new_float_n([4,$cPNKB.CBANDS]);this.nb_s1=$38dac00579cf6ffc$var$new_float_n([4,$cPNKB.CBANDS]);this.nb_s2=$38dac00579cf6ffc$var$new_float_n([4,$cPNKB.CBANDS]);this.s3_ss=null;this.s3_ll=null;this.decay=0.;//public III_psy_xmin[] thm = new III_psy_xmin[4];
1164
+ //public III_psy_xmin[] en = new III_psy_xmin[4];
1165
+ this.thm=new Array(4);this.en=new Array(4);/**
1166
+ * fft and energy calculation
1167
+ */this.tot_ener=$38dac00579cf6ffc$var$new_float(4);/* loudness calculation (for adaptive threshold of hearing) */ /**
1168
+ * loudness^2 approx. per granule and channel
1169
+ */this.loudness_sq=$38dac00579cf6ffc$var$new_float_n([2,2]);/**
1170
+ * account for granule delay of L3psycho_anal
1171
+ */this.loudness_sq_save=$38dac00579cf6ffc$var$new_float(2);/**
1172
+ * Scale Factor Bands
1173
+ */this.mld_l=$38dac00579cf6ffc$var$new_float($cPNKB.SBMAX_l);this.mld_s=$38dac00579cf6ffc$var$new_float($cPNKB.SBMAX_s);this.bm_l=$38dac00579cf6ffc$var$new_int($cPNKB.SBMAX_l);this.bo_l=$38dac00579cf6ffc$var$new_int($cPNKB.SBMAX_l);this.bm_s=$38dac00579cf6ffc$var$new_int($cPNKB.SBMAX_s);this.bo_s=$38dac00579cf6ffc$var$new_int($cPNKB.SBMAX_s);this.npart_l=0;this.npart_s=0;this.s3ind=$38dac00579cf6ffc$var$new_int_n([$cPNKB.CBANDS,2]);this.s3ind_s=$38dac00579cf6ffc$var$new_int_n([$cPNKB.CBANDS,2]);this.numlines_s=$38dac00579cf6ffc$var$new_int($cPNKB.CBANDS);this.numlines_l=$38dac00579cf6ffc$var$new_int($cPNKB.CBANDS);this.rnumlines_l=$38dac00579cf6ffc$var$new_float($cPNKB.CBANDS);this.mld_cb_l=$38dac00579cf6ffc$var$new_float($cPNKB.CBANDS);this.mld_cb_s=$38dac00579cf6ffc$var$new_float($cPNKB.CBANDS);this.numlines_s_num1=0;this.numlines_l_num1=0;/* ratios */this.pe=$38dac00579cf6ffc$var$new_float(4);this.ms_ratio_s_old=0.;this.ms_ratio_l_old=0.;this.ms_ener_ratio_old=0.;/**
1174
+ * block type
1175
+ */this.blocktype_old=$38dac00579cf6ffc$var$new_int(2);/**
1176
+ * variables used for --nspsytune
1177
+ */this.nsPsy=new $7yzUB();/**
1178
+ * used for Xing VBR header
1179
+ */this.VBR_seek_table=new $jTmCQ();/**
1180
+ * all ATH related stuff
1181
+ */ //public ATH ATH;
1182
+ this.ATH=null;this.PSY=null;this.nogap_total=0;this.nogap_current=0;/* ReplayGain */this.decode_on_the_fly=true;this.findReplayGain=true;this.findPeakSample=true;this.PeakSample=0.;this.RadioGain=0;this.AudiophileGain=0;//public ReplayGain rgdata;
1183
+ this.rgdata=null;/**
1184
+ * gain change required for preventing clipping
1185
+ */this.noclipGainChange=0;/**
1186
+ * user-specified scale factor required for preventing clipping
1187
+ */this.noclipScale=0.;/* simple statistics */this.bitrate_stereoMode_Hist=$38dac00579cf6ffc$var$new_int_n([16,5]);/**
1188
+ * norm/start/short/stop/mixed(short)/sum
1189
+ */this.bitrate_blockType_Hist=$38dac00579cf6ffc$var$new_int_n([16,6]);//public PlottingData pinfo;
1190
+ //public MPGLib.mpstr_tag hip;
1191
+ this.pinfo=null;this.hip=null;this.in_buffer_nsamples=0;//public float[] in_buffer_0;
1192
+ //public float[] in_buffer_1;
1193
+ this.in_buffer_0=null;this.in_buffer_1=null;//public IIterationLoop iteration_loop;
1194
+ this.iteration_loop=null;for(var i=0;i<this.en.length;i++)this.en[i]=new $51XxS();for(var i=0;i<this.thm.length;i++)this.thm[i]=new $51XxS();for(var i=0;i<this.header.length;i++)this.header[i]=new Header();}module.exports=$38dac00579cf6ffc$var$LameInternalFlags;});parcelRequire.register("eWXBy",function(module,exports){var $3YDN3=parcelRequire("3YDN3");$3YDN3.System;$3YDN3.VbrMode;$3YDN3.Float;$3YDN3.ShortBlock;$3YDN3.Util;$3YDN3.Arrays;$3YDN3.new_array_n;$3YDN3.new_byte;$3YDN3.new_double;$3YDN3.new_float;$3YDN3.new_float_n;var $ae24b7bb56fee1da$var$new_int=$3YDN3.new_int;$3YDN3.new_int_n;$3YDN3.assert;var $7weBo=parcelRequire("7weBo");function $ae24b7bb56fee1da$var$IIISideInfo(){this.tt=[[null,null],[null,null]];this.main_data_begin=0;this.private_bits=0;this.resvDrain_pre=0;this.resvDrain_post=0;this.scfsi=[$ae24b7bb56fee1da$var$new_int(4),$ae24b7bb56fee1da$var$new_int(4)];for(var gr=0;gr<2;gr++)for(var ch=0;ch<2;ch++)this.tt[gr][ch]=new $7weBo();}module.exports=$ae24b7bb56fee1da$var$IIISideInfo;});parcelRequire.register("7weBo",function(module,exports){//package mp3;
1195
+ var $3YDN3=parcelRequire("3YDN3");$3YDN3.System;$3YDN3.VbrMode;$3YDN3.Float;$3YDN3.ShortBlock;$3YDN3.Util;$3YDN3.Arrays;$3YDN3.new_array_n;$3YDN3.new_byte;$3YDN3.new_double;var $5796d93ba9162632$var$new_float=$3YDN3.new_float;$3YDN3.new_float_n;var $5796d93ba9162632$var$new_int=$3YDN3.new_int;$3YDN3.new_int_n;$3YDN3.assert;var $arIi9=parcelRequire("arIi9");function $5796d93ba9162632$var$GrInfo(){//float xr[] = new float[576];
1196
+ this.xr=$5796d93ba9162632$var$new_float(576);//int l3_enc[] = new int[576];
1197
+ this.l3_enc=$5796d93ba9162632$var$new_int(576);//int scalefac[] = new int[L3Side.SFBMAX];
1198
+ this.scalefac=$5796d93ba9162632$var$new_int($arIi9.SFBMAX);this.xrpow_max=0.;this.part2_3_length=0;this.big_values=0;this.count1=0;this.global_gain=0;this.scalefac_compress=0;this.block_type=0;this.mixed_block_flag=0;this.table_select=$5796d93ba9162632$var$new_int(3);this.subblock_gain=$5796d93ba9162632$var$new_int(4);this.region0_count=0;this.region1_count=0;this.preflag=0;this.scalefac_scale=0;this.count1table_select=0;this.part2_length=0;this.sfb_lmax=0;this.sfb_smin=0;this.psy_lmax=0;this.sfbmax=0;this.psymax=0;this.sfbdivide=0;this.width=$5796d93ba9162632$var$new_int($arIi9.SFBMAX);this.window=$5796d93ba9162632$var$new_int($arIi9.SFBMAX);this.count1bits=0;/**
1199
+ * added for LSF
1200
+ */this.sfb_partition_table=null;this.slen=$5796d93ba9162632$var$new_int(4);this.max_nonzero_coeff=0;var self=this;function clone_int(array){return new Int32Array(array);}function clone_float(array){return new Float32Array(array);}this.assign=function(other){self.xr=clone_float(other.xr);//.slice(0); //clone();
1201
+ self.l3_enc=clone_int(other.l3_enc);//.slice(0); //clone();
1202
+ self.scalefac=clone_int(other.scalefac);//.slice(0); //clone();
1203
+ self.xrpow_max=other.xrpow_max;self.part2_3_length=other.part2_3_length;self.big_values=other.big_values;self.count1=other.count1;self.global_gain=other.global_gain;self.scalefac_compress=other.scalefac_compress;self.block_type=other.block_type;self.mixed_block_flag=other.mixed_block_flag;self.table_select=clone_int(other.table_select);//.slice(0); //clone();
1204
+ self.subblock_gain=clone_int(other.subblock_gain);//.slice(0); //.clone();
1205
+ self.region0_count=other.region0_count;self.region1_count=other.region1_count;self.preflag=other.preflag;self.scalefac_scale=other.scalefac_scale;self.count1table_select=other.count1table_select;self.part2_length=other.part2_length;self.sfb_lmax=other.sfb_lmax;self.sfb_smin=other.sfb_smin;self.psy_lmax=other.psy_lmax;self.sfbmax=other.sfbmax;self.psymax=other.psymax;self.sfbdivide=other.sfbdivide;self.width=clone_int(other.width);//.slice(0); //.clone();
1206
+ self.window=clone_int(other.window);//.slice(0); //.clone();
1207
+ self.count1bits=other.count1bits;self.sfb_partition_table=other.sfb_partition_table.slice(0);//.clone();
1208
+ self.slen=clone_int(other.slen);//.slice(0); //.clone();
1209
+ self.max_nonzero_coeff=other.max_nonzero_coeff;};}module.exports=$5796d93ba9162632$var$GrInfo;});parcelRequire.register("arIi9",function(module,exports){var $cPNKB=parcelRequire("cPNKB");var $79aec86e829b6e82$var$L3Side={};/**
1210
+ * max scalefactor band, max(SBMAX_l, SBMAX_s*3, (SBMAX_s-3)*3+8)
1211
+ */$79aec86e829b6e82$var$L3Side.SFBMAX=$cPNKB.SBMAX_s*3;module.exports=$79aec86e829b6e82$var$L3Side;});parcelRequire.register("7imnH",function(module,exports){//package mp3;
1212
+ /**
1213
+ * Layer III side information.
1214
+ *
1215
+ * @author Ken
1216
+ *
1217
+ */var $3YDN3=parcelRequire("3YDN3");var $54fb93475471cb87$var$System=$3YDN3.System;$3YDN3.VbrMode;$3YDN3.Float;$3YDN3.ShortBlock;$3YDN3.Util;$3YDN3.Arrays;$3YDN3.new_array_n;$3YDN3.new_byte;$3YDN3.new_double;$3YDN3.new_float;$3YDN3.new_float_n;var $54fb93475471cb87$var$new_int=$3YDN3.new_int;$3YDN3.new_int_n;$3YDN3.assert;var $cPNKB=parcelRequire("cPNKB");function $54fb93475471cb87$var$ScaleFac(arrL,arrS,arr21,arr12){this.l=$54fb93475471cb87$var$new_int(1+$cPNKB.SBMAX_l);this.s=$54fb93475471cb87$var$new_int(1+$cPNKB.SBMAX_s);this.psfb21=$54fb93475471cb87$var$new_int(1+$cPNKB.PSFB21);this.psfb12=$54fb93475471cb87$var$new_int(1+$cPNKB.PSFB12);var l=this.l;var s=this.s;if(arguments.length==4){//public ScaleFac(final int[] arrL, final int[] arrS, final int[] arr21,
1218
+ // final int[] arr12) {
1219
+ this.arrL=arguments[0];this.arrS=arguments[1];this.arr21=arguments[2];this.arr12=arguments[3];$54fb93475471cb87$var$System.arraycopy(this.arrL,0,l,0,Math.min(this.arrL.length,this.l.length));$54fb93475471cb87$var$System.arraycopy(this.arrS,0,s,0,Math.min(this.arrS.length,this.s.length));$54fb93475471cb87$var$System.arraycopy(this.arr21,0,this.psfb21,0,Math.min(this.arr21.length,this.psfb21.length));$54fb93475471cb87$var$System.arraycopy(this.arr12,0,this.psfb12,0,Math.min(this.arr12.length,this.psfb12.length));}}module.exports=$54fb93475471cb87$var$ScaleFac;});parcelRequire.register("7yzUB",function(module,exports){var $3YDN3=parcelRequire("3YDN3");$3YDN3.System;$3YDN3.VbrMode;$3YDN3.Float;$3YDN3.ShortBlock;$3YDN3.Util;$3YDN3.Arrays;$3YDN3.new_array_n;$3YDN3.new_byte;$3YDN3.new_double;var $580790bdd94a8b57$var$new_float=$3YDN3.new_float;var $580790bdd94a8b57$var$new_float_n=$3YDN3.new_float_n;var $580790bdd94a8b57$var$new_int=$3YDN3.new_int;$3YDN3.new_int_n;$3YDN3.assert;var $cPNKB=parcelRequire("cPNKB");//package mp3;
1220
+ /**
1221
+ * Variables used for --nspsytune
1222
+ *
1223
+ * @author Ken
1224
+ *
1225
+ */function $580790bdd94a8b57$var$NsPsy(){this.last_en_subshort=$580790bdd94a8b57$var$new_float_n([4,9]);this.lastAttacks=$580790bdd94a8b57$var$new_int(4);this.pefirbuf=$580790bdd94a8b57$var$new_float(19);this.longfact=$580790bdd94a8b57$var$new_float($cPNKB.SBMAX_l);this.shortfact=$580790bdd94a8b57$var$new_float($cPNKB.SBMAX_s);/**
1226
+ * short block tuning
1227
+ */this.attackthre=0.;this.attackthre_s=0.;}module.exports=$580790bdd94a8b57$var$NsPsy;});parcelRequire.register("jTmCQ",function(module,exports){//package mp3;
1228
+ function $e7b4b455db8db26b$var$VBRSeekInfo(){/**
1229
+ * What we have seen so far.
1230
+ */this.sum=0;/**
1231
+ * How many frames we have seen in this chunk.
1232
+ */this.seen=0;/**
1233
+ * How many frames we want to collect into one chunk.
1234
+ */this.want=0;/**
1235
+ * Actual position in our bag.
1236
+ */this.pos=0;/**
1237
+ * Size of our bag.
1238
+ */this.size=0;/**
1239
+ * Pointer to our bag.
1240
+ */this.bag=null;this.nVbrNumFrames=0;this.nBytesWritten=0;/* VBR tag data */this.TotalFrameSize=0;}module.exports=$e7b4b455db8db26b$var$VBRSeekInfo;});parcelRequire.register("cU3Yf",function(module,exports){var $3YDN3=parcelRequire("3YDN3");$3YDN3.System;$3YDN3.VbrMode;$3YDN3.Float;$3YDN3.ShortBlock;$3YDN3.Util;$3YDN3.Arrays;$3YDN3.new_array_n;$3YDN3.new_byte;$3YDN3.new_double;var $964dcb8066029e00$var$new_float=$3YDN3.new_float;$3YDN3.new_float_n;$3YDN3.new_int;$3YDN3.new_int_n;$3YDN3.assert;var $cPNKB=parcelRequire("cPNKB");/**
1241
+ * ATH related stuff, if something new ATH related has to be added, please plug
1242
+ * it here into the ATH.
1243
+ */function $964dcb8066029e00$var$ATH(){/**
1244
+ * Method for the auto adjustment.
1245
+ */this.useAdjust=0;/**
1246
+ * factor for tuning the (sample power) point below which adaptive threshold
1247
+ * of hearing adjustment occurs
1248
+ */this.aaSensitivityP=0.;/**
1249
+ * Lowering based on peak volume, 1 = no lowering.
1250
+ */this.adjust=0.;/**
1251
+ * Limit for dynamic ATH adjust.
1252
+ */this.adjustLimit=0.;/**
1253
+ * Determined to lower x dB each second.
1254
+ */this.decay=0.;/**
1255
+ * Lowest ATH value.
1256
+ */this.floor=0.;/**
1257
+ * ATH for sfbs in long blocks.
1258
+ */this.l=$964dcb8066029e00$var$new_float($cPNKB.SBMAX_l);/**
1259
+ * ATH for sfbs in short blocks.
1260
+ */this.s=$964dcb8066029e00$var$new_float($cPNKB.SBMAX_s);/**
1261
+ * ATH for partitioned sfb21 in long blocks.
1262
+ */this.psfb21=$964dcb8066029e00$var$new_float($cPNKB.PSFB21);/**
1263
+ * ATH for partitioned sfb12 in short blocks.
1264
+ */this.psfb12=$964dcb8066029e00$var$new_float($cPNKB.PSFB12);/**
1265
+ * ATH for long block convolution bands.
1266
+ */this.cb_l=$964dcb8066029e00$var$new_float($cPNKB.CBANDS);/**
1267
+ * ATH for short block convolution bands.
1268
+ */this.cb_s=$964dcb8066029e00$var$new_float($cPNKB.CBANDS);/**
1269
+ * Equal loudness weights (based on ATH).
1270
+ */this.eql_w=$964dcb8066029e00$var$new_float($cPNKB.BLKSIZE/2);}module.exports=$964dcb8066029e00$var$ATH;});parcelRequire.register("2qGTD",function(module,exports){var $3YDN3=parcelRequire("3YDN3");$3YDN3.System;$3YDN3.VbrMode;$3YDN3.Float;$3YDN3.ShortBlock;$3YDN3.Util;$3YDN3.Arrays;$3YDN3.new_array_n;$3YDN3.new_byte;$3YDN3.new_double;var $1c4f48cc96a3a753$var$new_float=$3YDN3.new_float;$3YDN3.new_float_n;var $1c4f48cc96a3a753$var$new_int=$3YDN3.new_int;$3YDN3.new_int_n;$3YDN3.assert;var $b8dhq=parcelRequire("b8dhq");function $1c4f48cc96a3a753$var$ReplayGain(){this.linprebuf=$1c4f48cc96a3a753$var$new_float($b8dhq.MAX_ORDER*2);/**
1271
+ * left input samples, with pre-buffer
1272
+ */this.linpre=0;this.lstepbuf=$1c4f48cc96a3a753$var$new_float($b8dhq.MAX_SAMPLES_PER_WINDOW+$b8dhq.MAX_ORDER);/**
1273
+ * left "first step" (i.e. post first filter) samples
1274
+ */this.lstep=0;this.loutbuf=$1c4f48cc96a3a753$var$new_float($b8dhq.MAX_SAMPLES_PER_WINDOW+$b8dhq.MAX_ORDER);/**
1275
+ * left "out" (i.e. post second filter) samples
1276
+ */this.lout=0;this.rinprebuf=$1c4f48cc96a3a753$var$new_float($b8dhq.MAX_ORDER*2);/**
1277
+ * right input samples ...
1278
+ */this.rinpre=0;this.rstepbuf=$1c4f48cc96a3a753$var$new_float($b8dhq.MAX_SAMPLES_PER_WINDOW+$b8dhq.MAX_ORDER);this.rstep=0;this.routbuf=$1c4f48cc96a3a753$var$new_float($b8dhq.MAX_SAMPLES_PER_WINDOW+$b8dhq.MAX_ORDER);this.rout=0;/**
1279
+ * number of samples required to reach number of milliseconds required
1280
+ * for RMS window
1281
+ */this.sampleWindow=0;this.totsamp=0;this.lsum=0.;this.rsum=0.;this.freqindex=0;this.first=0;this.A=$1c4f48cc96a3a753$var$new_int(0|$b8dhq.STEPS_per_dB*$b8dhq.MAX_dB);this.B=$1c4f48cc96a3a753$var$new_int(0|$b8dhq.STEPS_per_dB*$b8dhq.MAX_dB);}module.exports=$1c4f48cc96a3a753$var$ReplayGain;});parcelRequire.register("b8dhq",function(module,exports){/*
1282
+ * ReplayGainAnalysis - analyzes input samples and give the recommended dB change
1283
+ * Copyright (C) 2001 David Robinson and Glen Sawyer
1284
+ * Improvements and optimizations added by Frank Klemm, and by Marcel Muller
1285
+ *
1286
+ * This library is free software; you can redistribute it and/or
1287
+ * modify it under the terms of the GNU Lesser General Public
1288
+ * License as published by the Free Software Foundation; either
1289
+ * version 2.1 of the License, or (at your option) any later version.
1290
+ *
1291
+ * This library is distributed in the hope that it will be useful,
1292
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1293
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1294
+ * Lesser General Public License for more details.
1295
+ *
1296
+ * You should have received a copy of the GNU Lesser General Public
1297
+ * License along with this library; if not, write to the Free Software
1298
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1299
+ *
1300
+ * concept and filter values by David Robinson (David@Robinson.org)
1301
+ * -- blame him if you think the idea is flawed
1302
+ * original coding by Glen Sawyer (mp3gain@hotmail.com)
1303
+ * -- blame him if you think this runs too slowly, or the coding is otherwise flawed
1304
+ *
1305
+ * lots of code improvements by Frank Klemm ( http://www.uni-jena.de/~pfk/mpp/ )
1306
+ * -- credit him for all the _good_ programming ;)
1307
+ *
1308
+ *
1309
+ * For an explanation of the concepts and the basic algorithms involved, go to:
1310
+ * http://www.replaygain.org/
1311
+ */ /*
1312
+ * Here's the deal. Call
1313
+ *
1314
+ * InitGainAnalysis ( long samplefreq );
1315
+ *
1316
+ * to initialize everything. Call
1317
+ *
1318
+ * AnalyzeSamples ( var Float_t* left_samples,
1319
+ * var Float_t* right_samples,
1320
+ * size_t num_samples,
1321
+ * int num_channels );
1322
+ *
1323
+ * as many times as you want, with as many or as few samples as you want.
1324
+ * If mono, pass the sample buffer in through left_samples, leave
1325
+ * right_samples NULL, and make sure num_channels = 1.
1326
+ *
1327
+ * GetTitleGain()
1328
+ *
1329
+ * will return the recommended dB level change for all samples analyzed
1330
+ * SINCE THE LAST TIME you called GetTitleGain() OR InitGainAnalysis().
1331
+ *
1332
+ * GetAlbumGain()
1333
+ *
1334
+ * will return the recommended dB level change for all samples analyzed
1335
+ * since InitGainAnalysis() was called and finalized with GetTitleGain().
1336
+ *
1337
+ * Pseudo-code to process an album:
1338
+ *
1339
+ * Float_t l_samples [4096];
1340
+ * Float_t r_samples [4096];
1341
+ * size_t num_samples;
1342
+ * unsigned int num_songs;
1343
+ * unsigned int i;
1344
+ *
1345
+ * InitGainAnalysis ( 44100 );
1346
+ * for ( i = 1; i <= num_songs; i++ ) {
1347
+ * while ( ( num_samples = getSongSamples ( song[i], left_samples, right_samples ) ) > 0 )
1348
+ * AnalyzeSamples ( left_samples, right_samples, num_samples, 2 );
1349
+ * fprintf ("Recommended dB change for song %2d: %+6.2 dB\n", i, GetTitleGain() );
1350
+ * }
1351
+ * fprintf ("Recommended dB change for whole album: %+6.2 dB\n", GetAlbumGain() );
1352
+ */ /*
1353
+ * So here's the main source of potential code confusion:
1354
+ *
1355
+ * The filters applied to the incoming samples are IIR filters,
1356
+ * meaning they rely on up to <filter order> number of previous samples
1357
+ * AND up to <filter order> number of previous filtered samples.
1358
+ *
1359
+ * I set up the AnalyzeSamples routine to minimize memory usage and interface
1360
+ * complexity. The speed isn't compromised too much (I don't think), but the
1361
+ * internal complexity is higher than it should be for such a relatively
1362
+ * simple routine.
1363
+ *
1364
+ * Optimization/clarity suggestions are welcome.
1365
+ */var $3YDN3=parcelRequire("3YDN3");var $81aabe360221f821$var$System=$3YDN3.System;$3YDN3.VbrMode;$3YDN3.Float;$3YDN3.ShortBlock;$3YDN3.Util;var $81aabe360221f821$var$Arrays=$3YDN3.Arrays;$3YDN3.new_array_n;$3YDN3.new_byte;$3YDN3.new_double;$3YDN3.new_float;$3YDN3.new_float_n;$3YDN3.new_int;$3YDN3.new_int_n;$3YDN3.assert;/**
1366
+ * Table entries per dB
1367
+ */$81aabe360221f821$var$GainAnalysis.STEPS_per_dB=100.;/**
1368
+ * Table entries for 0...MAX_dB (normal max. values are 70...80 dB)
1369
+ */$81aabe360221f821$var$GainAnalysis.MAX_dB=120.;$81aabe360221f821$var$GainAnalysis.GAIN_NOT_ENOUGH_SAMPLES=-24601;$81aabe360221f821$var$GainAnalysis.GAIN_ANALYSIS_ERROR=0;$81aabe360221f821$var$GainAnalysis.GAIN_ANALYSIS_OK=1;$81aabe360221f821$var$GainAnalysis.INIT_GAIN_ANALYSIS_ERROR=0;$81aabe360221f821$var$GainAnalysis.INIT_GAIN_ANALYSIS_OK=1;$81aabe360221f821$var$GainAnalysis.YULE_ORDER=10;$81aabe360221f821$var$GainAnalysis.MAX_ORDER=$81aabe360221f821$var$GainAnalysis.YULE_ORDER;$81aabe360221f821$var$GainAnalysis.MAX_SAMP_FREQ=48000;$81aabe360221f821$var$GainAnalysis.RMS_WINDOW_TIME_NUMERATOR=1;$81aabe360221f821$var$GainAnalysis.RMS_WINDOW_TIME_DENOMINATOR=20;$81aabe360221f821$var$GainAnalysis.MAX_SAMPLES_PER_WINDOW=$81aabe360221f821$var$GainAnalysis.MAX_SAMP_FREQ*$81aabe360221f821$var$GainAnalysis.RMS_WINDOW_TIME_NUMERATOR/$81aabe360221f821$var$GainAnalysis.RMS_WINDOW_TIME_DENOMINATOR+1;function $81aabe360221f821$var$GainAnalysis(){/**
1370
+ * calibration value for 89dB
1371
+ */var PINK_REF=64.82;$81aabe360221f821$var$GainAnalysis.YULE_ORDER;/**
1372
+ * percentile which is louder than the proposed level
1373
+ */var RMS_PERCENTILE=0.95;/**
1374
+ * maximum allowed sample frequency [Hz]
1375
+ */$81aabe360221f821$var$GainAnalysis.MAX_SAMP_FREQ;var RMS_WINDOW_TIME_NUMERATOR=$81aabe360221f821$var$GainAnalysis.RMS_WINDOW_TIME_NUMERATOR;/**
1376
+ * numerator / denominator = time slice size [s]
1377
+ */var RMS_WINDOW_TIME_DENOMINATOR=$81aabe360221f821$var$GainAnalysis.RMS_WINDOW_TIME_DENOMINATOR;/**
1378
+ * max. Samples per Time slice
1379
+ */$81aabe360221f821$var$GainAnalysis.MAX_SAMPLES_PER_WINDOW;var ABYule=[[0.03857599435200,-3.84664617118067,-0.02160367184185,7.81501653005538,-0.00123395316851,-11.34170355132042,-0.00009291677959,13.05504219327545,-0.01655260341619,-12.28759895145294,0.02161526843274,9.48293806319790,-0.02074045215285,-5.87257861775999,0.00594298065125,2.75465861874613,0.00306428023191,-0.86984376593551,0.00012025322027,0.13919314567432,0.00288463683916],[0.05418656406430,-3.47845948550071,-0.02911007808948,6.36317777566148,-0.00848709379851,-8.54751527471874,-0.00851165645469,9.47693607801280,-0.00834990904936,-8.81498681370155,0.02245293253339,6.85401540936998,-0.02596338512915,-4.39470996079559,0.01624864962975,2.19611684890774,-0.00240879051584,-0.75104302451432,0.00674613682247,0.13149317958808,-0.00187763777362],[0.15457299681924,-2.37898834973084,-0.09331049056315,2.84868151156327,-0.06247880153653,-2.64577170229825,0.02163541888798,2.23697657451713,-0.05588393329856,-1.67148153367602,0.04781476674921,1.00595954808547,0.00222312597743,-0.45953458054983,0.03174092540049,0.16378164858596,-0.01390589421898,-0.05032077717131,0.00651420667831,0.02347897407020,-0.00881362733839],[0.30296907319327,-1.61273165137247,-0.22613988682123,1.07977492259970,-0.08587323730772,-0.2565625775407,0.03282930172664,-0.1627671912044,-0.00915702933434,-0.22638893773906,-0.02364141202522,0.39120800788284,-0.00584456039913,-0.22138138954925,0.06276101321749,0.04500235387352,-0.00000828086748,0.02005851806501,0.00205861885564,0.00302439095741,-0.02950134983287],[0.33642304856132,-1.49858979367799,-0.2557224142557,0.87350271418188,-0.11828570177555,0.12205022308084,0.11921148675203,-0.80774944671438,-0.07834489609479,0.47854794562326,-0.0046997791438,-0.12453458140019,-0.0058950022444,-0.04067510197014,0.05724228140351,0.08333755284107,0.00832043980773,-0.04237348025746,-0.0163538138454,0.02977207319925,-0.0176017656815],[0.44915256608450,-0.62820619233671,-0.14351757464547,0.29661783706366,-0.22784394429749,-0.372563729424,-0.01419140100551,0.00213767857124,0.04078262797139,-0.42029820170918,-0.12398163381748,0.22199650564824,0.04097565135648,0.00613424350682,0.10478503600251,0.06747620744683,-0.01863887810927,0.05784820375801,-0.03193428438915,0.03222754072173,0.00541907748707],[0.56619470757641,-1.04800335126349,-0.75464456939302,0.29156311971249,0.16242137742230,-0.26806001042947,0.16744243493672,0.00819999645858,-0.18901604199609,0.45054734505008,0.30931782841830,-0.33032403314006,-0.27562961986224,0.06739368333110,0.00647310677246,-0.04784254229033,0.08647503780351,0.01639907836189,-0.0378898455484,0.01807364323573,-0.00588215443421],[0.58100494960553,-0.51035327095184,-0.53174909058578,-0.31863563325245,-0.14289799034253,-0.20256413484477,0.17520704835522,0.14728154134330,0.02377945217615,0.38952639978999,0.15558449135573,-0.23313271880868,-0.25344790059353,-0.05246019024463,0.01628462406333,-0.02505961724053,0.06920467763959,0.02442357316099,-0.03721611395801,0.01818801111503,-0.00749618797172],[0.53648789255105,-0.2504987195602,-0.42163034350696,-0.43193942311114,-0.00275953611929,-0.03424681017675,0.04267842219415,-0.04678328784242,-0.10214864179676,0.26408300200955,0.14590772289388,0.15113130533216,-0.02459864859345,-0.17556493366449,-0.11202315195388,-0.18823009262115,-0.04060034127,0.05477720428674,0.04788665548180,0.04704409688120,-0.02217936801134]];var ABButter=[[0.98621192462708,-1.97223372919527,-1.97242384925416,0.97261396931306,0.98621192462708],[0.98500175787242,-1.96977855582618,-1.97000351574484,0.97022847566350,0.98500175787242],[0.97938932735214,-1.95835380975398,-1.95877865470428,0.95920349965459,0.97938932735214],[0.97531843204928,-1.95002759149878,-1.95063686409857,0.95124613669835,0.97531843204928],[0.97316523498161,-1.94561023566527,-1.94633046996323,0.94705070426118,0.97316523498161],[0.96454515552826,-1.92783286977036,-1.92909031105652,0.93034775234268,0.96454515552826],[0.96009142950541,-1.91858953033784,-1.92018285901082,0.92177618768381,0.96009142950541],[0.95856916599601,-1.9154210807478,-1.91713833199203,0.91885558323625,0.95856916599601],[0.94597685600279,-1.88903307939452,-1.89195371200558,0.89487434461664,0.94597685600279]];/**
1380
+ * When calling this procedure, make sure that ip[-order] and op[-order]
1381
+ * point to real data
1382
+ */ //private void filterYule(final float[] input, int inputPos, float[] output,
1383
+ //int outputPos, int nSamples, final float[] kernel) {
1384
+ function filterYule(input,inputPos,output,outputPos,nSamples,kernel){while(nSamples--!=0){/* 1e-10 is a hack to avoid slowdown because of denormals */output[outputPos]=1e-10+input[inputPos+0]*kernel[0]-output[outputPos-1]*kernel[1]+input[inputPos-1]*kernel[2]-output[outputPos-2]*kernel[3]+input[inputPos-2]*kernel[4]-output[outputPos-3]*kernel[5]+input[inputPos-3]*kernel[6]-output[outputPos-4]*kernel[7]+input[inputPos-4]*kernel[8]-output[outputPos-5]*kernel[9]+input[inputPos-5]*kernel[10]-output[outputPos-6]*kernel[11]+input[inputPos-6]*kernel[12]-output[outputPos-7]*kernel[13]+input[inputPos-7]*kernel[14]-output[outputPos-8]*kernel[15]+input[inputPos-8]*kernel[16]-output[outputPos-9]*kernel[17]+input[inputPos-9]*kernel[18]-output[outputPos-10]*kernel[19]+input[inputPos-10]*kernel[20];++outputPos;++inputPos;}}//private void filterButter(final float[] input, int inputPos,
1385
+ // float[] output, int outputPos, int nSamples, final float[] kernel) {
1386
+ function filterButter(input,inputPos,output,outputPos,nSamples,kernel){while(nSamples--!=0){output[outputPos]=input[inputPos+0]*kernel[0]-output[outputPos-1]*kernel[1]+input[inputPos-1]*kernel[2]-output[outputPos-2]*kernel[3]+input[inputPos-2]*kernel[4];++outputPos;++inputPos;}}/**
1387
+ * @return INIT_GAIN_ANALYSIS_OK if successful, INIT_GAIN_ANALYSIS_ERROR if
1388
+ * not
1389
+ */function ResetSampleFrequency(rgData,samplefreq){/* zero out initial values */for(var i=0;i<MAX_ORDER;i++)rgData.linprebuf[i]=rgData.lstepbuf[i]=rgData.loutbuf[i]=rgData.rinprebuf[i]=rgData.rstepbuf[i]=rgData.routbuf[i]=0.;switch(0|samplefreq){case 48000:rgData.reqindex=0;break;case 44100:rgData.reqindex=1;break;case 32000:rgData.reqindex=2;break;case 24000:rgData.reqindex=3;break;case 22050:rgData.reqindex=4;break;case 16000:rgData.reqindex=5;break;case 12000:rgData.reqindex=6;break;case 11025:rgData.reqindex=7;break;case 8000:rgData.reqindex=8;break;default:return INIT_GAIN_ANALYSIS_ERROR;}rgData.sampleWindow=0|(samplefreq*RMS_WINDOW_TIME_NUMERATOR+RMS_WINDOW_TIME_DENOMINATOR-1)/RMS_WINDOW_TIME_DENOMINATOR;rgData.lsum=0.;rgData.rsum=0.;rgData.totsamp=0;$81aabe360221f821$var$Arrays.ill(rgData.A,0);return INIT_GAIN_ANALYSIS_OK;}this.InitGainAnalysis=function(rgData,samplefreq){if(ResetSampleFrequency(rgData,samplefreq)!=INIT_GAIN_ANALYSIS_OK)return INIT_GAIN_ANALYSIS_ERROR;rgData.linpre=MAX_ORDER;rgData.rinpre=MAX_ORDER;rgData.lstep=MAX_ORDER;rgData.rstep=MAX_ORDER;rgData.lout=MAX_ORDER;rgData.rout=MAX_ORDER;$81aabe360221f821$var$Arrays.fill(rgData.B,0);return INIT_GAIN_ANALYSIS_OK;};/**
1390
+ * square
1391
+ */function fsqr(d){return d*d;}this.AnalyzeSamples=function(rgData,left_samples,left_samplesPos,right_samples,right_samplesPos,num_samples,num_channels){var curleft;var curleftBase;var curright;var currightBase;var batchsamples;var cursamples;var cursamplepos;if(num_samples==0)return GAIN_ANALYSIS_OK;cursamplepos=0;batchsamples=num_samples;switch(num_channels){case 1:right_samples=left_samples;right_samplesPos=left_samplesPos;break;case 2:break;default:return GAIN_ANALYSIS_ERROR;}if(num_samples<MAX_ORDER){$81aabe360221f821$var$System.arraycopy(left_samples,left_samplesPos,rgData.linprebuf,MAX_ORDER,num_samples);$81aabe360221f821$var$System.arraycopy(right_samples,right_samplesPos,rgData.rinprebuf,MAX_ORDER,num_samples);}else {$81aabe360221f821$var$System.arraycopy(left_samples,left_samplesPos,rgData.linprebuf,MAX_ORDER,MAX_ORDER);$81aabe360221f821$var$System.arraycopy(right_samples,right_samplesPos,rgData.rinprebuf,MAX_ORDER,MAX_ORDER);}while(batchsamples>0){cursamples=batchsamples>rgData.sampleWindow-rgData.totsamp?rgData.sampleWindow-rgData.totsamp:batchsamples;if(cursamplepos<MAX_ORDER){curleft=rgData.linpre+cursamplepos;curleftBase=rgData.linprebuf;curright=rgData.rinpre+cursamplepos;currightBase=rgData.rinprebuf;if(cursamples>MAX_ORDER-cursamplepos)cursamples=MAX_ORDER-cursamplepos;}else {curleft=left_samplesPos+cursamplepos;curleftBase=left_samples;curright=right_samplesPos+cursamplepos;currightBase=right_samples;}filterYule(curleftBase,curleft,rgData.lstepbuf,rgData.lstep+rgData.totsamp,cursamples,ABYule[rgData.reqindex]);filterYule(currightBase,curright,rgData.rstepbuf,rgData.rstep+rgData.totsamp,cursamples,ABYule[rgData.reqindex]);filterButter(rgData.lstepbuf,rgData.lstep+rgData.totsamp,rgData.loutbuf,rgData.lout+rgData.totsamp,cursamples,ABButter[rgData.reqindex]);filterButter(rgData.rstepbuf,rgData.rstep+rgData.totsamp,rgData.routbuf,rgData.rout+rgData.totsamp,cursamples,ABButter[rgData.reqindex]);curleft=rgData.lout+rgData.totsamp;/* Get the squared values */curleftBase=rgData.loutbuf;curright=rgData.rout+rgData.totsamp;currightBase=rgData.routbuf;var i=cursamples%8;while(i--!=0){rgData.lsum+=fsqr(curleftBase[curleft++]);rgData.rsum+=fsqr(currightBase[curright++]);}i=cursamples/8;while(i--!=0){rgData.lsum+=fsqr(curleftBase[curleft+0])+fsqr(curleftBase[curleft+1])+fsqr(curleftBase[curleft+2])+fsqr(curleftBase[curleft+3])+fsqr(curleftBase[curleft+4])+fsqr(curleftBase[curleft+5])+fsqr(curleftBase[curleft+6])+fsqr(curleftBase[curleft+7]);curleft+=8;rgData.rsum+=fsqr(currightBase[curright+0])+fsqr(currightBase[curright+1])+fsqr(currightBase[curright+2])+fsqr(currightBase[curright+3])+fsqr(currightBase[curright+4])+fsqr(currightBase[curright+5])+fsqr(currightBase[curright+6])+fsqr(currightBase[curright+7]);curright+=8;}batchsamples-=cursamples;cursamplepos+=cursamples;rgData.totsamp+=cursamples;if(rgData.totsamp==rgData.sampleWindow){/* Get the Root Mean Square (RMS) for this set of samples */var val=$81aabe360221f821$var$GainAnalysis.STEPS_per_dB*10.*Math.log10((rgData.lsum+rgData.rsum)/rgData.totsamp*0.5+1.e-37);var ival=val<=0?0:0|val;if(ival>=rgData.A.length)ival=rgData.A.length-1;rgData.A[ival]++;rgData.lsum=rgData.rsum=0.;$81aabe360221f821$var$System.arraycopy(rgData.loutbuf,rgData.totsamp,rgData.loutbuf,0,MAX_ORDER);$81aabe360221f821$var$System.arraycopy(rgData.routbuf,rgData.totsamp,rgData.routbuf,0,MAX_ORDER);$81aabe360221f821$var$System.arraycopy(rgData.lstepbuf,rgData.totsamp,rgData.lstepbuf,0,MAX_ORDER);$81aabe360221f821$var$System.arraycopy(rgData.rstepbuf,rgData.totsamp,rgData.rstepbuf,0,MAX_ORDER);rgData.totsamp=0;}if(rgData.totsamp>rgData.sampleWindow)/*
1392
+ * somehow I really screwed up: Error in programming! Contact
1393
+ * author about totsamp > sampleWindow
1394
+ */return GAIN_ANALYSIS_ERROR;}if(num_samples<MAX_ORDER){$81aabe360221f821$var$System.arraycopy(rgData.linprebuf,num_samples,rgData.linprebuf,0,MAX_ORDER-num_samples);$81aabe360221f821$var$System.arraycopy(rgData.rinprebuf,num_samples,rgData.rinprebuf,0,MAX_ORDER-num_samples);$81aabe360221f821$var$System.arraycopy(left_samples,left_samplesPos,rgData.linprebuf,MAX_ORDER-num_samples,num_samples);$81aabe360221f821$var$System.arraycopy(right_samples,right_samplesPos,rgData.rinprebuf,MAX_ORDER-num_samples,num_samples);}else {$81aabe360221f821$var$System.arraycopy(left_samples,left_samplesPos+num_samples-MAX_ORDER,rgData.linprebuf,0,MAX_ORDER);$81aabe360221f821$var$System.arraycopy(right_samples,right_samplesPos+num_samples-MAX_ORDER,rgData.rinprebuf,0,MAX_ORDER);}return GAIN_ANALYSIS_OK;};function analyzeResult(Array,len){var i;var elems=0;for(i=0;i<len;i++)elems+=Array[i];if(elems==0)return GAIN_NOT_ENOUGH_SAMPLES;var upper=0|Math.ceil(elems*(1.-RMS_PERCENTILE));for(i=len;i-->0;){if((upper-=Array[i])<=0)break;}//return (float) ((float) PINK_REF - (float) i / (float) STEPS_per_dB);
1395
+ return PINK_REF-i/$81aabe360221f821$var$GainAnalysis.STEPS_per_dB;}this.GetTitleGain=function(rgData){var retval=analyzeResult(rgData.A,rgData.A.length);for(var i=0;i<rgData.A.length;i++){rgData.B[i]+=rgData.A[i];rgData.A[i]=0;}for(var i=0;i<MAX_ORDER;i++)rgData.linprebuf[i]=rgData.lstepbuf[i]=rgData.loutbuf[i]=rgData.rinprebuf[i]=rgData.rstepbuf[i]=rgData.routbuf[i]=0.;rgData.totsamp=0;rgData.lsum=rgData.rsum=0.;return retval;};}module.exports=$81aabe360221f821$var$GainAnalysis;});parcelRequire.register("e32wu",function(module,exports){var $3YDN3=parcelRequire("3YDN3");$3YDN3.System;$3YDN3.VbrMode;$3YDN3.Float;$3YDN3.ShortBlock;$3YDN3.Util;$3YDN3.Arrays;$3YDN3.new_array_n;$3YDN3.new_byte;$3YDN3.new_double;var $a3a34d831b8c1682$var$new_float=$3YDN3.new_float;$3YDN3.new_float_n;var $a3a34d831b8c1682$var$new_int=$3YDN3.new_int;$3YDN3.new_int_n;var $a3a34d831b8c1682$var$assert=$3YDN3.assert;var $lL4Le=parcelRequire("lL4Le");var $cPNKB=parcelRequire("cPNKB");var $arIi9=parcelRequire("arIi9");var $4SDnr=parcelRequire("4SDnr");function $a3a34d831b8c1682$var$CBRNewIterationLoop(_quantize){var quantize=_quantize;this.quantize=quantize;this.iteration_loop=function(gfp,pe,ms_ener_ratio,ratio){var gfc=gfp.internal_flags;var l3_xmin=$a3a34d831b8c1682$var$new_float($arIi9.SFBMAX);var xrpow=$a3a34d831b8c1682$var$new_float(576);var targ_bits=$a3a34d831b8c1682$var$new_int(2);var mean_bits=0,max_bits;var l3_side=gfc.l3_side;var mb=new $lL4Le(mean_bits);this.quantize.rv.ResvFrameBegin(gfp,mb);mean_bits=mb.bits;/* quantize! */for(var gr=0;gr<gfc.mode_gr;gr++){/*
1396
+ * calculate needed bits
1397
+ */max_bits=this.quantize.qupvt.on_pe(gfp,pe,targ_bits,mean_bits,gr,gr);if(gfc.mode_ext==$cPNKB.MPG_MD_MS_LR){this.quantize.ms_convert(gfc.l3_side,gr);this.quantize.qupvt.reduce_side(targ_bits,ms_ener_ratio[gr],mean_bits,max_bits);}for(var ch=0;ch<gfc.channels_out;ch++){var adjust,masking_lower_db;var cod_info=l3_side.tt[gr][ch];if(cod_info.block_type!=$cPNKB.SHORT_TYPE){// NORM, START or STOP type
1398
+ adjust=0;masking_lower_db=gfc.PSY.mask_adjust-adjust;}else {adjust=0;masking_lower_db=gfc.PSY.mask_adjust_short-adjust;}gfc.masking_lower=Math.pow(10.0,masking_lower_db*0.1);/*
1399
+ * init_outer_loop sets up cod_info, scalefac and xrpow
1400
+ */this.quantize.init_outer_loop(gfc,cod_info);if(this.quantize.init_xrpow(gfc,cod_info,xrpow)){/*
1401
+ * xr contains energy we will have to encode calculate the
1402
+ * masking abilities find some good quantization in
1403
+ * outer_loop
1404
+ */this.quantize.qupvt.calc_xmin(gfp,ratio[gr][ch],cod_info,l3_xmin);this.quantize.outer_loop(gfp,cod_info,l3_xmin,xrpow,ch,targ_bits[ch]);}this.quantize.iteration_finish_one(gfc,gr,ch);$a3a34d831b8c1682$var$assert(cod_info.part2_3_length<=$4SDnr.MAX_BITS_PER_CHANNEL);$a3a34d831b8c1682$var$assert(cod_info.part2_3_length<=targ_bits[ch]);}/* for ch */}/* for gr */this.quantize.rv.ResvFrameEnd(gfc,mean_bits);};}module.exports=$a3a34d831b8c1682$var$CBRNewIterationLoop;});parcelRequire.register("lL4Le",function(module,exports){function $fd71ae23813c0974$var$MeanBits(meanBits){this.bits=meanBits;}module.exports=$fd71ae23813c0974$var$MeanBits;});parcelRequire.register("ctaQC",function(module,exports){var $3YDN3=parcelRequire("3YDN3");var $91409b9649b00300$var$System=$3YDN3.System;$3YDN3.VbrMode;$3YDN3.Float;$3YDN3.ShortBlock;$3YDN3.Util;var $91409b9649b00300$var$Arrays=$3YDN3.Arrays;$3YDN3.new_array_n;var $91409b9649b00300$var$new_byte=$3YDN3.new_byte;$3YDN3.new_double;$3YDN3.new_float;var $91409b9649b00300$var$new_float_n=$3YDN3.new_float_n;var $91409b9649b00300$var$new_int=$3YDN3.new_int;$3YDN3.new_int_n;var $91409b9649b00300$var$assert=$3YDN3.assert;var $65Sx2=parcelRequire("65Sx2");var $dQDcS=parcelRequire("dQDcS");var $cPNKB=parcelRequire("cPNKB");var $4SDnr=parcelRequire("4SDnr");$91409b9649b00300$var$BitStream.EQ=function(a,b){return Math.abs(a)>Math.abs(b)?Math.abs(a-b)<=Math.abs(a)*1e-6:Math.abs(a-b)<=Math.abs(b)*1e-6;};$91409b9649b00300$var$BitStream.NEQ=function(a,b){return !$91409b9649b00300$var$BitStream.EQ(a,b);};function $91409b9649b00300$var$BitStream(){var Lame=parcelRequire("kk1yk");var self=this;var CRC16_POLYNOMIAL=0x8005;/*
1405
+ * we work with ints, so when doing bit manipulation, we limit ourselves to
1406
+ * MAX_LENGTH-2 just to be on the safe side
1407
+ */var MAX_LENGTH=32;//GainAnalysis ga;
1408
+ //MPGLib mpg;
1409
+ //Version ver;
1410
+ //VBRTag vbr;
1411
+ var ga=null;var mpg=null;var ver=null;var vbr=null;//public final void setModules(GainAnalysis ga, MPGLib mpg, Version ver,
1412
+ // VBRTag vbr) {
1413
+ this.setModules=function(_ga,_mpg,_ver,_vbr){ga=_ga;mpg=_mpg;ver=_ver;vbr=_vbr;};/**
1414
+ * Bit stream buffer.
1415
+ */ //private byte[] buf;
1416
+ var buf=null;/**
1417
+ * Bit counter of bit stream.
1418
+ */var totbit=0;/**
1419
+ * Pointer to top byte in buffer.
1420
+ */var bufByteIdx=0;/**
1421
+ * Pointer to top bit of top byte in buffer.
1422
+ */var bufBitIdx=0;/**
1423
+ * compute bitsperframe and mean_bits for a layer III frame
1424
+ */this.getframebits=function(gfp){var gfc=gfp.internal_flags;var bit_rate;/* get bitrate in kbps [?] */if(gfc.bitrate_index!=0)bit_rate=$dQDcS.bitrate_table[gfp.version][gfc.bitrate_index];else bit_rate=gfp.brate;$91409b9649b00300$var$assert(8<=bit_rate&&bit_rate<=640);/* main encoding routine toggles padding on and off */ /* one Layer3 Slot consists of 8 bits */var bytes=0|(gfp.version+1)*72000*bit_rate/gfp.out_samplerate+gfc.padding;return 8*bytes;};function putheader_bits(gfc){$91409b9649b00300$var$System.arraycopy(gfc.header[gfc.w_ptr].buf,0,buf,bufByteIdx,gfc.sideinfo_len);bufByteIdx+=gfc.sideinfo_len;totbit+=gfc.sideinfo_len*8;gfc.w_ptr=gfc.w_ptr+1&$4SDnr.MAX_HEADER_BUF-1;}/**
1425
+ * write j bits into the bit stream
1426
+ */function putbits2(gfc,val,j){$91409b9649b00300$var$assert(j<MAX_LENGTH-2);while(j>0){var k;if(bufBitIdx==0){bufBitIdx=8;bufByteIdx++;$91409b9649b00300$var$assert(bufByteIdx<Lame.LAME_MAXMP3BUFFER);$91409b9649b00300$var$assert(gfc.header[gfc.w_ptr].write_timing>=totbit);if(gfc.header[gfc.w_ptr].write_timing==totbit)putheader_bits(gfc);buf[bufByteIdx]=0;}k=Math.min(j,bufBitIdx);j-=k;bufBitIdx-=k;$91409b9649b00300$var$assert(j<MAX_LENGTH);/* 32 too large on 32 bit machines */$91409b9649b00300$var$assert(bufBitIdx<MAX_LENGTH);buf[bufByteIdx]|=val>>j<<bufBitIdx;totbit+=k;}}/**
1427
+ * write j bits into the bit stream, ignoring frame headers
1428
+ */function putbits_noheaders(gfc,val,j){$91409b9649b00300$var$assert(j<MAX_LENGTH-2);while(j>0){var k;if(bufBitIdx==0){bufBitIdx=8;bufByteIdx++;$91409b9649b00300$var$assert(bufByteIdx<Lame.LAME_MAXMP3BUFFER);buf[bufByteIdx]=0;}k=Math.min(j,bufBitIdx);j-=k;bufBitIdx-=k;$91409b9649b00300$var$assert(j<MAX_LENGTH);/* 32 too large on 32 bit machines */$91409b9649b00300$var$assert(bufBitIdx<MAX_LENGTH);buf[bufByteIdx]|=val>>j<<bufBitIdx;totbit+=k;}}/**
1429
+ * Some combinations of bitrate, Fs, and stereo make it impossible to stuff
1430
+ * out a frame using just main_data, due to the limited number of bits to
1431
+ * indicate main_data_length. In these situations, we put stuffing bits into
1432
+ * the ancillary data...
1433
+ */function drain_into_ancillary(gfp,remainingBits){var gfc=gfp.internal_flags;var i;$91409b9649b00300$var$assert(remainingBits>=0);if(remainingBits>=8){putbits2(gfc,0x4c,8);remainingBits-=8;}if(remainingBits>=8){putbits2(gfc,0x41,8);remainingBits-=8;}if(remainingBits>=8){putbits2(gfc,0x4d,8);remainingBits-=8;}if(remainingBits>=8){putbits2(gfc,0x45,8);remainingBits-=8;}if(remainingBits>=32){var version=ver.getLameShortVersion();if(remainingBits>=32)for(i=0;i<version.length&&remainingBits>=8;++i){remainingBits-=8;putbits2(gfc,version.charAt(i),8);}}for(;remainingBits>=1;remainingBits-=1){putbits2(gfc,gfc.ancillary_flag,1);gfc.ancillary_flag^=!gfp.disable_reservoir?1:0;}$91409b9649b00300$var$assert(remainingBits==0);}/**
1434
+ * write N bits into the header
1435
+ */function writeheader(gfc,val,j){var ptr=gfc.header[gfc.h_ptr].ptr;while(j>0){var k=Math.min(j,8-(ptr&7));j-=k;$91409b9649b00300$var$assert(j<MAX_LENGTH);/* >> 32 too large for 32 bit machines */gfc.header[gfc.h_ptr].buf[ptr>>3]|=val>>j<<8-(ptr&7)-k;ptr+=k;}gfc.header[gfc.h_ptr].ptr=ptr;}function CRC_update(value,crc){value<<=8;for(var i=0;i<8;i++){value<<=1;crc<<=1;if(((crc^value)&0x10000)!=0)crc^=CRC16_POLYNOMIAL;}return crc;}this.CRC_writeheader=function(gfc,header){var crc=0xffff;/* (jo) init crc16 for error_protection */crc=CRC_update(header[2]&0xff,crc);crc=CRC_update(header[3]&0xff,crc);for(var i=6;i<gfc.sideinfo_len;i++)crc=CRC_update(header[i]&0xff,crc);header[4]=byte(crc>>8);header[5]=byte(crc&255);};function encodeSideInfo2(gfp,bitsPerFrame){var gfc=gfp.internal_flags;var l3_side;var gr,ch;l3_side=gfc.l3_side;gfc.header[gfc.h_ptr].ptr=0;$91409b9649b00300$var$Arrays.fill(gfc.header[gfc.h_ptr].buf,0,gfc.sideinfo_len,0);if(gfp.out_samplerate<16000)writeheader(gfc,0xffe,12);else writeheader(gfc,0xfff,12);writeheader(gfc,gfp.version,1);writeheader(gfc,1,2);writeheader(gfc,!gfp.error_protection?1:0,1);writeheader(gfc,gfc.bitrate_index,4);writeheader(gfc,gfc.samplerate_index,2);writeheader(gfc,gfc.padding,1);writeheader(gfc,gfp.extension,1);writeheader(gfc,gfp.mode.ordinal(),2);writeheader(gfc,gfc.mode_ext,2);writeheader(gfc,gfp.copyright,1);writeheader(gfc,gfp.original,1);writeheader(gfc,gfp.emphasis,2);if(gfp.error_protection)writeheader(gfc,0,16);if(gfp.version==1){/* MPEG1 */$91409b9649b00300$var$assert(l3_side.main_data_begin>=0);writeheader(gfc,l3_side.main_data_begin,9);if(gfc.channels_out==2)writeheader(gfc,l3_side.private_bits,3);else writeheader(gfc,l3_side.private_bits,5);for(ch=0;ch<gfc.channels_out;ch++){var band;for(band=0;band<4;band++)writeheader(gfc,l3_side.scfsi[ch][band],1);}for(gr=0;gr<2;gr++)for(ch=0;ch<gfc.channels_out;ch++){var gi=l3_side.tt[gr][ch];writeheader(gfc,gi.part2_3_length+gi.part2_length,12);writeheader(gfc,gi.big_values/2,9);writeheader(gfc,gi.global_gain,8);writeheader(gfc,gi.scalefac_compress,4);if(gi.block_type!=$cPNKB.NORM_TYPE){writeheader(gfc,1,1);/* window_switching_flag */writeheader(gfc,gi.block_type,2);writeheader(gfc,gi.mixed_block_flag,1);if(gi.table_select[0]==14)gi.table_select[0]=16;writeheader(gfc,gi.table_select[0],5);if(gi.table_select[1]==14)gi.table_select[1]=16;writeheader(gfc,gi.table_select[1],5);writeheader(gfc,gi.subblock_gain[0],3);writeheader(gfc,gi.subblock_gain[1],3);writeheader(gfc,gi.subblock_gain[2],3);}else {writeheader(gfc,0,1);/* window_switching_flag */if(gi.table_select[0]==14)gi.table_select[0]=16;writeheader(gfc,gi.table_select[0],5);if(gi.table_select[1]==14)gi.table_select[1]=16;writeheader(gfc,gi.table_select[1],5);if(gi.table_select[2]==14)gi.table_select[2]=16;writeheader(gfc,gi.table_select[2],5);$91409b9649b00300$var$assert(0<=gi.region0_count&&gi.region0_count<16);$91409b9649b00300$var$assert(0<=gi.region1_count&&gi.region1_count<8);writeheader(gfc,gi.region0_count,4);writeheader(gfc,gi.region1_count,3);}writeheader(gfc,gi.preflag,1);writeheader(gfc,gi.scalefac_scale,1);writeheader(gfc,gi.count1table_select,1);}}else {/* MPEG2 */$91409b9649b00300$var$assert(l3_side.main_data_begin>=0);writeheader(gfc,l3_side.main_data_begin,8);writeheader(gfc,l3_side.private_bits,gfc.channels_out);gr=0;for(ch=0;ch<gfc.channels_out;ch++){var gi=l3_side.tt[gr][ch];writeheader(gfc,gi.part2_3_length+gi.part2_length,12);writeheader(gfc,gi.big_values/2,9);writeheader(gfc,gi.global_gain,8);writeheader(gfc,gi.scalefac_compress,9);if(gi.block_type!=$cPNKB.NORM_TYPE){writeheader(gfc,1,1);/* window_switching_flag */writeheader(gfc,gi.block_type,2);writeheader(gfc,gi.mixed_block_flag,1);if(gi.table_select[0]==14)gi.table_select[0]=16;writeheader(gfc,gi.table_select[0],5);if(gi.table_select[1]==14)gi.table_select[1]=16;writeheader(gfc,gi.table_select[1],5);writeheader(gfc,gi.subblock_gain[0],3);writeheader(gfc,gi.subblock_gain[1],3);writeheader(gfc,gi.subblock_gain[2],3);}else {writeheader(gfc,0,1);/* window_switching_flag */if(gi.table_select[0]==14)gi.table_select[0]=16;writeheader(gfc,gi.table_select[0],5);if(gi.table_select[1]==14)gi.table_select[1]=16;writeheader(gfc,gi.table_select[1],5);if(gi.table_select[2]==14)gi.table_select[2]=16;writeheader(gfc,gi.table_select[2],5);$91409b9649b00300$var$assert(0<=gi.region0_count&&gi.region0_count<16);$91409b9649b00300$var$assert(0<=gi.region1_count&&gi.region1_count<8);writeheader(gfc,gi.region0_count,4);writeheader(gfc,gi.region1_count,3);}writeheader(gfc,gi.scalefac_scale,1);writeheader(gfc,gi.count1table_select,1);}}if(gfp.error_protection)/* (jo) error_protection: add crc16 information to header */CRC_writeheader(gfc,gfc.header[gfc.h_ptr].buf);var old=gfc.h_ptr;$91409b9649b00300$var$assert(gfc.header[old].ptr==gfc.sideinfo_len*8);gfc.h_ptr=old+1&$4SDnr.MAX_HEADER_BUF-1;gfc.header[gfc.h_ptr].write_timing=gfc.header[old].write_timing+bitsPerFrame;if(gfc.h_ptr==gfc.w_ptr)/* yikes! we are out of header buffer space */$91409b9649b00300$var$System.err.println("Error: MAX_HEADER_BUF too small in bitstream.c \n");}function huffman_coder_count1(gfc,gi){/* Write count1 area */var h=$dQDcS.ht[gi.count1table_select+32];var i,bits=0;var ix=gi.big_values;var xr=gi.big_values;$91409b9649b00300$var$assert(gi.count1table_select<2);for(i=(gi.count1-gi.big_values)/4;i>0;--i){var huffbits=0;var p=0,v;v=gi.l3_enc[ix+0];if(v!=0){p+=8;if(gi.xr[xr+0]<0)huffbits++;$91409b9649b00300$var$assert(v<=1);}v=gi.l3_enc[ix+1];if(v!=0){p+=4;huffbits*=2;if(gi.xr[xr+1]<0)huffbits++;$91409b9649b00300$var$assert(v<=1);}v=gi.l3_enc[ix+2];if(v!=0){p+=2;huffbits*=2;if(gi.xr[xr+2]<0)huffbits++;$91409b9649b00300$var$assert(v<=1);}v=gi.l3_enc[ix+3];if(v!=0){p++;huffbits*=2;if(gi.xr[xr+3]<0)huffbits++;$91409b9649b00300$var$assert(v<=1);}ix+=4;xr+=4;putbits2(gfc,huffbits+h.table[p],h.hlen[p]);bits+=h.hlen[p];}return bits;}/**
1436
+ * Implements the pseudocode of page 98 of the IS
1437
+ */function Huffmancode(gfc,tableindex,start,end,gi){var h=$dQDcS.ht[tableindex];var bits=0;$91409b9649b00300$var$assert(tableindex<32);if(0==tableindex)return bits;for(var i=start;i<end;i+=2){var cbits=0;var xbits=0;var linbits=h.xlen;var xlen=h.xlen;var ext=0;var x1=gi.l3_enc[i];var x2=gi.l3_enc[i+1];if(x1!=0){if(gi.xr[i]<0)ext++;cbits--;}if(tableindex>15){/* use ESC-words */if(x1>14){var linbits_x1=x1-15;$91409b9649b00300$var$assert(linbits_x1<=h.linmax);ext|=linbits_x1<<1;xbits=linbits;x1=15;}if(x2>14){var linbits_x2=x2-15;$91409b9649b00300$var$assert(linbits_x2<=h.linmax);ext<<=linbits;ext|=linbits_x2;xbits+=linbits;x2=15;}xlen=16;}if(x2!=0){ext<<=1;if(gi.xr[i+1]<0)ext++;cbits--;}$91409b9649b00300$var$assert((x1|x2)<16);x1=x1*xlen+x2;xbits-=cbits;cbits+=h.hlen[x1];$91409b9649b00300$var$assert(cbits<=MAX_LENGTH);$91409b9649b00300$var$assert(xbits<=MAX_LENGTH);putbits2(gfc,h.table[x1],cbits);putbits2(gfc,ext,xbits);bits+=cbits+xbits;}return bits;}/**
1438
+ * Note the discussion of huffmancodebits() on pages 28 and 29 of the IS, as
1439
+ * well as the definitions of the side information on pages 26 and 27.
1440
+ */function ShortHuffmancodebits(gfc,gi){var region1Start=3*gfc.scalefac_band.s[3];if(region1Start>gi.big_values)region1Start=gi.big_values;/* short blocks do not have a region2 */var bits=Huffmancode(gfc,gi.table_select[0],0,region1Start,gi);bits+=Huffmancode(gfc,gi.table_select[1],region1Start,gi.big_values,gi);return bits;}function LongHuffmancodebits(gfc,gi){var bigvalues,bits;var region1Start,region2Start;bigvalues=gi.big_values;$91409b9649b00300$var$assert(0<=bigvalues&&bigvalues<=576);var i=gi.region0_count+1;$91409b9649b00300$var$assert(0<=i);$91409b9649b00300$var$assert(i<gfc.scalefac_band.l.length);region1Start=gfc.scalefac_band.l[i];i+=gi.region1_count+1;$91409b9649b00300$var$assert(0<=i);$91409b9649b00300$var$assert(i<gfc.scalefac_band.l.length);region2Start=gfc.scalefac_band.l[i];if(region1Start>bigvalues)region1Start=bigvalues;if(region2Start>bigvalues)region2Start=bigvalues;bits=Huffmancode(gfc,gi.table_select[0],0,region1Start,gi);bits+=Huffmancode(gfc,gi.table_select[1],region1Start,region2Start,gi);bits+=Huffmancode(gfc,gi.table_select[2],region2Start,bigvalues,gi);return bits;}function writeMainData(gfp){var gr,ch,sfb,data_bits,tot_bits=0;var gfc=gfp.internal_flags;var l3_side=gfc.l3_side;if(gfp.version==1){/* MPEG 1 */for(gr=0;gr<2;gr++)for(ch=0;ch<gfc.channels_out;ch++){var gi=l3_side.tt[gr][ch];var slen1=$65Sx2.slen1_tab[gi.scalefac_compress];var slen2=$65Sx2.slen2_tab[gi.scalefac_compress];data_bits=0;for(sfb=0;sfb<gi.sfbdivide;sfb++){if(gi.scalefac[sfb]==-1)continue;/* scfsi is used */putbits2(gfc,gi.scalefac[sfb],slen1);data_bits+=slen1;}for(;sfb<gi.sfbmax;sfb++){if(gi.scalefac[sfb]==-1)continue;/* scfsi is used */putbits2(gfc,gi.scalefac[sfb],slen2);data_bits+=slen2;}$91409b9649b00300$var$assert(data_bits==gi.part2_length);if(gi.block_type==$cPNKB.SHORT_TYPE)data_bits+=ShortHuffmancodebits(gfc,gi);else data_bits+=LongHuffmancodebits(gfc,gi);data_bits+=huffman_coder_count1(gfc,gi);/* does bitcount in quantize.c agree with actual bit count? */$91409b9649b00300$var$assert(data_bits==gi.part2_3_length+gi.part2_length);tot_bits+=data_bits;}/* for gr */}else {/* MPEG 2 */gr=0;for(ch=0;ch<gfc.channels_out;ch++){var gi=l3_side.tt[gr][ch];var i,sfb_partition,scale_bits=0;$91409b9649b00300$var$assert(gi.sfb_partition_table!=null);data_bits=0;sfb=0;sfb_partition=0;if(gi.block_type==$cPNKB.SHORT_TYPE){for(;sfb_partition<4;sfb_partition++){var sfbs=gi.sfb_partition_table[sfb_partition]/3;var slen=gi.slen[sfb_partition];for(i=0;i<sfbs;i++,sfb++){putbits2(gfc,Math.max(gi.scalefac[sfb*3+0],0),slen);putbits2(gfc,Math.max(gi.scalefac[sfb*3+1],0),slen);putbits2(gfc,Math.max(gi.scalefac[sfb*3+2],0),slen);scale_bits+=3*slen;}}data_bits+=ShortHuffmancodebits(gfc,gi);}else {for(;sfb_partition<4;sfb_partition++){var sfbs=gi.sfb_partition_table[sfb_partition];var slen=gi.slen[sfb_partition];for(i=0;i<sfbs;i++,sfb++){putbits2(gfc,Math.max(gi.scalefac[sfb],0),slen);scale_bits+=slen;}}data_bits+=LongHuffmancodebits(gfc,gi);}data_bits+=huffman_coder_count1(gfc,gi);/* does bitcount in quantize.c agree with actual bit count? */$91409b9649b00300$var$assert(data_bits==gi.part2_3_length);$91409b9649b00300$var$assert(scale_bits==gi.part2_length);tot_bits+=scale_bits+data_bits;}/* for ch */}/* for gf */return tot_bits;}/* main_data */function TotalBytes(){this.total=0;}/*
1441
+ * compute the number of bits required to flush all mp3 frames currently in
1442
+ * the buffer. This should be the same as the reservoir size. Only call this
1443
+ * routine between frames - i.e. only after all headers and data have been
1444
+ * added to the buffer by format_bitstream().
1445
+ *
1446
+ * Also compute total_bits_output = size of mp3 buffer (including frame
1447
+ * headers which may not have yet been send to the mp3 buffer) + number of
1448
+ * bits needed to flush all mp3 frames.
1449
+ *
1450
+ * total_bytes_output is the size of the mp3 output buffer if
1451
+ * lame_encode_flush_nogap() was called right now.
1452
+ */function compute_flushbits(gfp,total_bytes_output){var gfc=gfp.internal_flags;var flushbits,remaining_headers;var bitsPerFrame;var last_ptr,first_ptr;first_ptr=gfc.w_ptr;/* first header to add to bitstream */last_ptr=gfc.h_ptr-1;/* last header to add to bitstream */if(last_ptr==-1)last_ptr=$4SDnr.MAX_HEADER_BUF-1;/* add this many bits to bitstream so we can flush all headers */flushbits=gfc.header[last_ptr].write_timing-totbit;total_bytes_output.total=flushbits;if(flushbits>=0){/* if flushbits >= 0, some headers have not yet been written */ /* reduce flushbits by the size of the headers */remaining_headers=1+last_ptr-first_ptr;if(last_ptr<first_ptr)remaining_headers=1+last_ptr-first_ptr+$4SDnr.MAX_HEADER_BUF;flushbits-=remaining_headers*8*gfc.sideinfo_len;}/*
1453
+ * finally, add some bits so that the last frame is complete these bits
1454
+ * are not necessary to decode the last frame, but some decoders will
1455
+ * ignore last frame if these bits are missing
1456
+ */bitsPerFrame=self.getframebits(gfp);flushbits+=bitsPerFrame;total_bytes_output.total+=bitsPerFrame;/* round up: */if(total_bytes_output.total%8!=0)total_bytes_output.total=1+total_bytes_output.total/8;else total_bytes_output.total=total_bytes_output.total/8;total_bytes_output.total+=bufByteIdx+1;if(flushbits<0)$91409b9649b00300$var$System.err.println("strange error flushing buffer ... \n");return flushbits;}this.flush_bitstream=function(gfp){var gfc=gfp.internal_flags;var l3_side;var flushbits;var last_ptr=gfc.h_ptr-1;/* last header to add to bitstream */if(last_ptr==-1)last_ptr=$4SDnr.MAX_HEADER_BUF-1;l3_side=gfc.l3_side;if((flushbits=compute_flushbits(gfp,new TotalBytes()))<0)return;drain_into_ancillary(gfp,flushbits);/* check that the 100% of the last frame has been written to bitstream */$91409b9649b00300$var$assert(gfc.header[last_ptr].write_timing+this.getframebits(gfp)==totbit);/*
1457
+ * we have padded out all frames with ancillary data, which is the same
1458
+ * as filling the bitreservoir with ancillary data, so :
1459
+ */gfc.ResvSize=0;l3_side.main_data_begin=0;/* save the ReplayGain value */if(gfc.findReplayGain){var RadioGain=ga.GetTitleGain(gfc.rgdata);$91409b9649b00300$var$assert(NEQ(RadioGain,GainAnalysis.GAIN_NOT_ENOUGH_SAMPLES));gfc.RadioGain=Math.floor(RadioGain*10.0+0.5)|0;/* round to nearest */}/* find the gain and scale change required for no clipping */if(gfc.findPeakSample){gfc.noclipGainChange=Math.ceil(Math.log10(gfc.PeakSample/32767.0)*200)|0;/* round up */if(gfc.noclipGainChange>0){/* clipping occurs */if(EQ(gfp.scale,1.0)||EQ(gfp.scale,0.0))gfc.noclipScale=Math.floor(32767.0/gfc.PeakSample*100.0)/100.0;else/*
1460
+ * the user specified his own scaling factor. We could
1461
+ * suggest the scaling factor of
1462
+ * (32767.0/gfp.PeakSample)*(gfp.scale) but it's usually
1463
+ * very inaccurate. So we'd rather not advice him on the
1464
+ * scaling factor.
1465
+ */gfc.noclipScale=-1;}else/* no clipping */gfc.noclipScale=-1;}};this.add_dummy_byte=function(gfp,val,n){var gfc=gfp.internal_flags;var i;while(n-->0){putbits_noheaders(gfc,val,8);for(i=0;i<$4SDnr.MAX_HEADER_BUF;++i)gfc.header[i].write_timing+=8;}};/**
1466
+ * This is called after a frame of audio has been quantized and coded. It
1467
+ * will write the encoded audio to the bitstream. Note that from a layer3
1468
+ * encoder's perspective the bit stream is primarily a series of main_data()
1469
+ * blocks, with header and side information inserted at the proper locations
1470
+ * to maintain framing. (See Figure A.7 in the IS).
1471
+ */this.format_bitstream=function(gfp){var gfc=gfp.internal_flags;var l3_side;l3_side=gfc.l3_side;var bitsPerFrame=this.getframebits(gfp);drain_into_ancillary(gfp,l3_side.resvDrain_pre);encodeSideInfo2(gfp,bitsPerFrame);var bits=8*gfc.sideinfo_len;bits+=writeMainData(gfp);drain_into_ancillary(gfp,l3_side.resvDrain_post);bits+=l3_side.resvDrain_post;l3_side.main_data_begin+=(bitsPerFrame-bits)/8;/*
1472
+ * compare number of bits needed to clear all buffered mp3 frames with
1473
+ * what we think the resvsize is:
1474
+ */if(compute_flushbits(gfp,new TotalBytes())!=gfc.ResvSize)$91409b9649b00300$var$System.err.println("Internal buffer inconsistency. flushbits <> ResvSize");/*
1475
+ * compare main_data_begin for the next frame with what we think the
1476
+ * resvsize is:
1477
+ */if(l3_side.main_data_begin*8!=gfc.ResvSize){$91409b9649b00300$var$System.err.printf("bit reservoir error: \nl3_side.main_data_begin: %d \nResvoir size: %d \nresv drain (post) %d \nresv drain (pre) %d \nheader and sideinfo: %d \ndata bits: %d \ntotal bits: %d (remainder: %d) \nbitsperframe: %d \n",8*l3_side.main_data_begin,gfc.ResvSize,l3_side.resvDrain_post,l3_side.resvDrain_pre,8*gfc.sideinfo_len,bits-l3_side.resvDrain_post-8*gfc.sideinfo_len,bits,bits%8,bitsPerFrame);$91409b9649b00300$var$System.err.println("This is a fatal error. It has several possible causes:");$91409b9649b00300$var$System.err.println("90%% LAME compiled with buggy version of gcc using advanced optimizations");$91409b9649b00300$var$System.err.println(" 9%% Your system is overclocked");$91409b9649b00300$var$System.err.println(" 1%% bug in LAME encoding library");gfc.ResvSize=l3_side.main_data_begin*8;}//;
1478
+ $91409b9649b00300$var$assert(totbit%8==0);if(totbit>1000000000){/*
1479
+ * to avoid totbit overflow, (at 8h encoding at 128kbs) lets reset
1480
+ * bit counter
1481
+ */var i;for(i=0;i<$4SDnr.MAX_HEADER_BUF;++i)gfc.header[i].write_timing-=totbit;totbit=0;}return 0;};/**
1482
+ * <PRE>
1483
+ * copy data out of the internal MP3 bit buffer into a user supplied
1484
+ * unsigned char buffer.
1485
+ *
1486
+ * mp3data=0 indicates data in buffer is an id3tags and VBR tags
1487
+ * mp3data=1 data is real mp3 frame data.
1488
+ * </PRE>
1489
+ */this.copy_buffer=function(gfc,buffer,bufferPos,size,mp3data){var minimum=bufByteIdx+1;if(minimum<=0)return 0;if(size!=0&&minimum>size)/* buffer is too small */return -1;$91409b9649b00300$var$System.arraycopy(buf,0,buffer,bufferPos,minimum);bufByteIdx=-1;bufBitIdx=0;if(mp3data!=0){var crc=$91409b9649b00300$var$new_int(1);crc[0]=gfc.nMusicCRC;vbr.updateMusicCRC(crc,buffer,bufferPos,minimum);gfc.nMusicCRC=crc[0];/**
1490
+ * sum number of bytes belonging to the mp3 stream this info will be
1491
+ * written into the Xing/LAME header for seeking
1492
+ */if(minimum>0)gfc.VBR_seek_table.nBytesWritten+=minimum;if(gfc.decode_on_the_fly){var pcm_buf=$91409b9649b00300$var$new_float_n([2,1152]);var mp3_in=minimum;var samples_out=-1;var i;/* re-synthesis to pcm. Repeat until we get a samples_out=0 */while(samples_out!=0){samples_out=mpg.hip_decode1_unclipped(gfc.hip,buffer,bufferPos,mp3_in,pcm_buf[0],pcm_buf[1]);/*
1493
+ * samples_out = 0: need more data to decode samples_out =
1494
+ * -1: error. Lets assume 0 pcm output samples_out = number
1495
+ * of samples output
1496
+ */ /*
1497
+ * set the lenght of the mp3 input buffer to zero, so that
1498
+ * in the next iteration of the loop we will be querying
1499
+ * mpglib about buffered data
1500
+ */mp3_in=0;if(samples_out==-1)/*
1501
+ * error decoding. Not fatal, but might screw up the
1502
+ * ReplayGain tag. What should we do? Ignore for now
1503
+ */samples_out=0;if(samples_out>0){/* process the PCM data */ /*
1504
+ * this should not be possible, and indicates we have
1505
+ * overflown the pcm_buf buffer
1506
+ */$91409b9649b00300$var$assert(samples_out<=1152);if(gfc.findPeakSample){for(i=0;i<samples_out;i++){if(pcm_buf[0][i]>gfc.PeakSample)gfc.PeakSample=pcm_buf[0][i];else if(-pcm_buf[0][i]>gfc.PeakSample)gfc.PeakSample=-pcm_buf[0][i];}if(gfc.channels_out>1)for(i=0;i<samples_out;i++){if(pcm_buf[1][i]>gfc.PeakSample)gfc.PeakSample=pcm_buf[1][i];else if(-pcm_buf[1][i]>gfc.PeakSample)gfc.PeakSample=-pcm_buf[1][i];}}if(gfc.findReplayGain){if(ga.AnalyzeSamples(gfc.rgdata,pcm_buf[0],0,pcm_buf[1],0,samples_out,gfc.channels_out)==GainAnalysis.GAIN_ANALYSIS_ERROR)return -6;}}/* if (samples_out>0) */}/* while (samples_out!=0) */}/* if (gfc.decode_on_the_fly) */}/* if (mp3data) */return minimum;};this.init_bit_stream_w=function(gfc){buf=$91409b9649b00300$var$new_byte(Lame.LAME_MAXMP3BUFFER);gfc.h_ptr=gfc.w_ptr=0;gfc.header[gfc.h_ptr].write_timing=0;bufByteIdx=-1;bufBitIdx=0;totbit=0;};// From machine.h
1507
+ }module.exports=$91409b9649b00300$var$BitStream;});parcelRequire.register("65Sx2",function(module,exports){/*
1508
+ * MP3 huffman table selecting and bit counting
1509
+ *
1510
+ * Copyright (c) 1999-2005 Takehiro TOMINAGA
1511
+ * Copyright (c) 2002-2005 Gabriel Bouvigne
1512
+ *
1513
+ * This library is free software; you can redistribute it and/or
1514
+ * modify it under the terms of the GNU Lesser General Public
1515
+ * License as published by the Free Software Foundation; either
1516
+ * version 2 of the License, or (at your option) any later version.
1517
+ *
1518
+ * This library is distributed in the hope that it will be useful,
1519
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1520
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1521
+ * Library General Public License for more details.
1522
+ *
1523
+ * You should have received a copy of the GNU Lesser General Public
1524
+ * License along with this library; if not, write to the
1525
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1526
+ * Boston, MA 02111-1307, USA.
1527
+ */ /* $Id: Takehiro.java,v 1.26 2011/05/24 20:48:06 kenchis Exp $ */ //package mp3;
1528
+ //import java.util.Arrays;
1529
+ var $3YDN3=parcelRequire("3YDN3");var $46fd82963609949b$var$System=$3YDN3.System;$3YDN3.VbrMode;$3YDN3.Float;$3YDN3.ShortBlock;$3YDN3.Util;var $46fd82963609949b$var$Arrays=$3YDN3.Arrays;$3YDN3.new_array_n;$3YDN3.new_byte;$3YDN3.new_double;$3YDN3.new_float;$3YDN3.new_float_n;var $46fd82963609949b$var$new_int=$3YDN3.new_int;$3YDN3.new_int_n;var $46fd82963609949b$var$assert=$3YDN3.assert;var $cPNKB=parcelRequire("cPNKB");var $dQDcS=parcelRequire("dQDcS");var $7weBo=parcelRequire("7weBo");var $84mea=parcelRequire("84mea");function $46fd82963609949b$var$Takehiro(){var qupvt=null;this.qupvt=null;this.setModules=function(_qupvt){this.qupvt=_qupvt;qupvt=_qupvt;};function Bits(b){this.bits=0|b;}var subdv_table=[[0,0],/* 0 bands */[0,0],/* 1 bands */[0,0],/* 2 bands */[0,0],/* 3 bands */[0,0],/* 4 bands */[0,1],/* 5 bands */[1,1],/* 6 bands */[1,1],/* 7 bands */[1,2],/* 8 bands */[2,2],/* 9 bands */[2,3],/* 10 bands */[2,3],/* 11 bands */[3,4],/* 12 bands */[3,4],/* 13 bands */[3,4],/* 14 bands */[4,5],/* 15 bands */[4,5],/* 16 bands */[4,6],/* 17 bands */[5,6],/* 18 bands */[5,6],/* 19 bands */[5,7],/* 20 bands */[6,7],/* 21 bands */[6,7]];/**
1530
+ * nonlinear quantization of xr More accurate formula than the ISO formula.
1531
+ * Takes into account the fact that we are quantizing xr . ix, but we want
1532
+ * ix^4/3 to be as close as possible to x^4/3. (taking the nearest int would
1533
+ * mean ix is as close as possible to xr, which is different.)
1534
+ *
1535
+ * From Segher Boessenkool <segher@eastsite.nl> 11/1999
1536
+ *
1537
+ * 09/2000: ASM code removed in favor of IEEE754 hack by Takehiro Tominaga.
1538
+ * If you need the ASM code, check CVS circa Aug 2000.
1539
+ *
1540
+ * 01/2004: Optimizations by Gabriel Bouvigne
1541
+ */function quantize_lines_xrpow_01(l,istep,xr,xrPos,ix,ixPos){var compareval0=0.5946/istep;$46fd82963609949b$var$assert(l>0);l=l>>1;while(l--!=0){ix[ixPos++]=compareval0>xr[xrPos++]?0:1;ix[ixPos++]=compareval0>xr[xrPos++]?0:1;}}/**
1542
+ * XRPOW_FTOI is a macro to convert floats to ints.<BR>
1543
+ * if XRPOW_FTOI(x) = nearest_int(x), then QUANTFAC(x)=adj43asm[x]<BR>
1544
+ * ROUNDFAC= -0.0946<BR>
1545
+ *
1546
+ * if XRPOW_FTOI(x) = floor(x), then QUANTFAC(x)=asj43[x]<BR>
1547
+ * ROUNDFAC=0.4054<BR>
1548
+ *
1549
+ * Note: using floor() or 0| is extremely slow. On machines where the
1550
+ * TAKEHIRO_IEEE754_HACK code above does not work, it is worthwile to write
1551
+ * some ASM for XRPOW_FTOI().
1552
+ */function quantize_lines_xrpow(l,istep,xr,xrPos,ix,ixPos){$46fd82963609949b$var$assert(l>0);l=l>>1;var remaining=l%2;l=l>>1;while(l--!=0){var x0,x1,x2,x3;var rx0,rx1,rx2,rx3;x0=xr[xrPos++]*istep;x1=xr[xrPos++]*istep;rx0=0|x0;x2=xr[xrPos++]*istep;rx1=0|x1;x3=xr[xrPos++]*istep;rx2=0|x2;x0+=qupvt.adj43[rx0];rx3=0|x3;x1+=qupvt.adj43[rx1];ix[ixPos++]=0|x0;x2+=qupvt.adj43[rx2];ix[ixPos++]=0|x1;x3+=qupvt.adj43[rx3];ix[ixPos++]=0|x2;ix[ixPos++]=0|x3;}if(remaining!=0){var x0,x1;var rx0,rx1;x0=xr[xrPos++]*istep;x1=xr[xrPos++]*istep;rx0=0|x0;rx1=0|x1;x0+=qupvt.adj43[rx0];x1+=qupvt.adj43[rx1];ix[ixPos++]=0|x0;ix[ixPos++]=0|x1;}}/**
1553
+ * Quantization function This function will select which lines to quantize
1554
+ * and call the proper quantization function
1555
+ */function quantize_xrpow(xp,pi,istep,codInfo,prevNoise){/* quantize on xr^(3/4) instead of xr */var sfb;var sfbmax;var j=0;var prev_data_use;var accumulate=0;var accumulate01=0;var xpPos=0;var iData=pi;var iDataPos=0;var acc_iData=iData;var acc_iDataPos=0;var acc_xp=xp;var acc_xpPos=0;/*
1556
+ * Reusing previously computed data does not seems to work if global
1557
+ * gain is changed. Finding why it behaves this way would allow to use a
1558
+ * cache of previously computed values (let's 10 cached values per sfb)
1559
+ * that would probably provide a noticeable speedup
1560
+ */prev_data_use=prevNoise!=null&&codInfo.global_gain==prevNoise.global_gain;if(codInfo.block_type==$cPNKB.SHORT_TYPE)sfbmax=38;else sfbmax=21;for(sfb=0;sfb<=sfbmax;sfb++){var step=-1;if(prev_data_use||codInfo.block_type==$cPNKB.NORM_TYPE)step=codInfo.global_gain-(codInfo.scalefac[sfb]+(codInfo.preflag!=0?qupvt.pretab[sfb]:0)<<codInfo.scalefac_scale+1)-codInfo.subblock_gain[codInfo.window[sfb]]*8;$46fd82963609949b$var$assert(codInfo.width[sfb]>=0);if(prev_data_use&&prevNoise.step[sfb]==step){/*
1561
+ * do not recompute this part, but compute accumulated lines
1562
+ */if(accumulate!=0){quantize_lines_xrpow(accumulate,istep,acc_xp,acc_xpPos,acc_iData,acc_iDataPos);accumulate=0;}if(accumulate01!=0){quantize_lines_xrpow_01(accumulate01,istep,acc_xp,acc_xpPos,acc_iData,acc_iDataPos);accumulate01=0;}}else {var l=codInfo.width[sfb];if(j+codInfo.width[sfb]>codInfo.max_nonzero_coeff){/* do not compute upper zero part */var usefullsize;usefullsize=codInfo.max_nonzero_coeff-j+1;$46fd82963609949b$var$Arrays.fill(pi,codInfo.max_nonzero_coeff,576,0);l=usefullsize;if(l<0)l=0;/* no need to compute higher sfb values */sfb=sfbmax+1;}/* accumulate lines to quantize */if(0==accumulate&&0==accumulate01){acc_iData=iData;acc_iDataPos=iDataPos;acc_xp=xp;acc_xpPos=xpPos;}if(prevNoise!=null&&prevNoise.sfb_count1>0&&sfb>=prevNoise.sfb_count1&&prevNoise.step[sfb]>0&&step>=prevNoise.step[sfb]){if(accumulate!=0){quantize_lines_xrpow(accumulate,istep,acc_xp,acc_xpPos,acc_iData,acc_iDataPos);accumulate=0;acc_iData=iData;acc_iDataPos=iDataPos;acc_xp=xp;acc_xpPos=xpPos;}accumulate01+=l;}else {if(accumulate01!=0){quantize_lines_xrpow_01(accumulate01,istep,acc_xp,acc_xpPos,acc_iData,acc_iDataPos);accumulate01=0;acc_iData=iData;acc_iDataPos=iDataPos;acc_xp=xp;acc_xpPos=xpPos;}accumulate+=l;}if(l<=0){/*
1563
+ * rh: 20040215 may happen due to "prev_data_use"
1564
+ * optimization
1565
+ */if(accumulate01!=0){quantize_lines_xrpow_01(accumulate01,istep,acc_xp,acc_xpPos,acc_iData,acc_iDataPos);accumulate01=0;}if(accumulate!=0){quantize_lines_xrpow(accumulate,istep,acc_xp,acc_xpPos,acc_iData,acc_iDataPos);accumulate=0;}break;/* ends for-loop */}}if(sfb<=sfbmax){iDataPos+=codInfo.width[sfb];xpPos+=codInfo.width[sfb];j+=codInfo.width[sfb];}}if(accumulate!=0){quantize_lines_xrpow(accumulate,istep,acc_xp,acc_xpPos,acc_iData,acc_iDataPos);accumulate=0;}if(accumulate01!=0){quantize_lines_xrpow_01(accumulate01,istep,acc_xp,acc_xpPos,acc_iData,acc_iDataPos);accumulate01=0;}}/**
1566
+ * ix_max
1567
+ */function ix_max(ix,ixPos,endPos){var max1=0,max2=0;do{var x1=ix[ixPos++];var x2=ix[ixPos++];if(max1<x1)max1=x1;if(max2<x2)max2=x2;}while(ixPos<endPos);if(max1<max2)max1=max2;return max1;}function count_bit_ESC(ix,ixPos,end,t1,t2,s){/* ESC-table is used */var linbits=$dQDcS.ht[t1].xlen*65536+$dQDcS.ht[t2].xlen;var sum=0,sum2;do{var x=ix[ixPos++];var y=ix[ixPos++];if(x!=0){if(x>14){x=15;sum+=linbits;}x*=16;}if(y!=0){if(y>14){y=15;sum+=linbits;}x+=y;}sum+=$dQDcS.largetbl[x];}while(ixPos<end);sum2=sum&0xffff;sum>>=16;if(sum>sum2){sum=sum2;t1=t2;}s.bits+=sum;return t1;}function count_bit_noESC(ix,ixPos,end,s){/* No ESC-words */var sum1=0;var hlen1=$dQDcS.ht[1].hlen;do{var x=ix[ixPos+0]*2+ix[ixPos+1];ixPos+=2;sum1+=hlen1[x];}while(ixPos<end);s.bits+=sum1;return 1;}function count_bit_noESC_from2(ix,ixPos,end,t1,s){/* No ESC-words */var sum=0,sum2;var xlen=$dQDcS.ht[t1].xlen;var hlen;if(t1==2)hlen=$dQDcS.table23;else hlen=$dQDcS.table56;do{var x=ix[ixPos+0]*xlen+ix[ixPos+1];ixPos+=2;sum+=hlen[x];}while(ixPos<end);sum2=sum&0xffff;sum>>=16;if(sum>sum2){sum=sum2;t1++;}s.bits+=sum;return t1;}function count_bit_noESC_from3(ix,ixPos,end,t1,s){/* No ESC-words */var sum1=0;var sum2=0;var sum3=0;var xlen=$dQDcS.ht[t1].xlen;var hlen1=$dQDcS.ht[t1].hlen;var hlen2=$dQDcS.ht[t1+1].hlen;var hlen3=$dQDcS.ht[t1+2].hlen;do{var x=ix[ixPos+0]*xlen+ix[ixPos+1];ixPos+=2;sum1+=hlen1[x];sum2+=hlen2[x];sum3+=hlen3[x];}while(ixPos<end);var t=t1;if(sum1>sum2){sum1=sum2;t++;}if(sum1>sum3){sum1=sum3;t=t1+2;}s.bits+=sum1;return t;}/*************************************************************************/ /* choose table */ /*************************************************************************/var huf_tbl_noESC=[1,2,5,7,7,10,10,13,13,13,13,13,13,13,13];/**
1568
+ * Choose the Huffman table that will encode ix[begin..end] with the fewest
1569
+ * bits.
1570
+ *
1571
+ * Note: This code contains knowledge about the sizes and characteristics of
1572
+ * the Huffman tables as defined in the IS (Table B.7), and will not work
1573
+ * with any arbitrary tables.
1574
+ */function choose_table(ix,ixPos,endPos,s){var max=ix_max(ix,ixPos,endPos);switch(max){case 0:return max;case 1:return count_bit_noESC(ix,ixPos,endPos,s);case 2:case 3:return count_bit_noESC_from2(ix,ixPos,endPos,huf_tbl_noESC[max-1],s);case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:return count_bit_noESC_from3(ix,ixPos,endPos,huf_tbl_noESC[max-1],s);default:/* try tables with linbits */if(max>$84mea.IXMAX_VAL){s.bits=$84mea.LARGE_BITS;return -1;}max-=15;var choice2;for(choice2=24;choice2<32;choice2++){if($dQDcS.ht[choice2].linmax>=max)break;}var choice;for(choice=choice2-8;choice<24;choice++){if($dQDcS.ht[choice].linmax>=max)break;}return count_bit_ESC(ix,ixPos,endPos,choice,choice2,s);}}/**
1575
+ * count_bit
1576
+ */this.noquant_count_bits=function(gfc,gi,prev_noise){var ix=gi.l3_enc;var i=Math.min(576,gi.max_nonzero_coeff+2>>1<<1);if(prev_noise!=null)prev_noise.sfb_count1=0;/* Determine count1 region */for(;i>1;i-=2)if((ix[i-1]|ix[i-2])!=0)break;gi.count1=i;/* Determines the number of bits to encode the quadruples. */var a1=0;var a2=0;for(;i>3;i-=4){var p;/* hack to check if all values <= 1 */ //throw "TODO: HACK if ((((long) ix[i - 1] | (long) ix[i - 2] | (long) ix[i - 3] | (long) ix[i - 4]) & 0xffffffffL) > 1L "
1577
+ //if (true) {
1578
+ if(((ix[i-1]|ix[i-2]|ix[i-3]|ix[i-4])&0x7fffffff)>1)break;p=((ix[i-4]*2+ix[i-3])*2+ix[i-2])*2+ix[i-1];a1+=$dQDcS.t32l[p];a2+=$dQDcS.t33l[p];}var bits=a1;gi.count1table_select=0;if(a1>a2){bits=a2;gi.count1table_select=1;}gi.count1bits=bits;gi.big_values=i;if(i==0)return bits;if(gi.block_type==$cPNKB.SHORT_TYPE){a1=3*gfc.scalefac_band.s[3];if(a1>gi.big_values)a1=gi.big_values;a2=gi.big_values;}else if(gi.block_type==$cPNKB.NORM_TYPE){$46fd82963609949b$var$assert(i<=576);/* bv_scf has 576 entries (0..575) */a1=gi.region0_count=gfc.bv_scf[i-2];a2=gi.region1_count=gfc.bv_scf[i-1];$46fd82963609949b$var$assert(a1+a2+2<$cPNKB.SBPSY_l);a2=gfc.scalefac_band.l[a1+a2+2];a1=gfc.scalefac_band.l[a1+1];if(a2<i){var bi=new Bits(bits);gi.table_select[2]=choose_table(ix,a2,i,bi);bits=bi.bits;}}else {gi.region0_count=7;/* gi.region1_count = SBPSY_l - 7 - 1; */gi.region1_count=$cPNKB.SBMAX_l-1-7-1;a1=gfc.scalefac_band.l[8];a2=i;if(a1>a2)a1=a2;}/* have to allow for the case when bigvalues < region0 < region1 */ /* (and region0, region1 are ignored) */a1=Math.min(a1,i);a2=Math.min(a2,i);$46fd82963609949b$var$assert(a1>=0);$46fd82963609949b$var$assert(a2>=0);/* Count the number of bits necessary to code the bigvalues region. */if(0<a1){var bi=new Bits(bits);gi.table_select[0]=choose_table(ix,0,a1,bi);bits=bi.bits;}if(a1<a2){var bi=new Bits(bits);gi.table_select[1]=choose_table(ix,a1,a2,bi);bits=bi.bits;}if(gfc.use_best_huffman==2){gi.part2_3_length=bits;best_huffman_divide(gfc,gi);bits=gi.part2_3_length;}if(prev_noise!=null){if(gi.block_type==$cPNKB.NORM_TYPE){var sfb=0;while(gfc.scalefac_band.l[sfb]<gi.big_values)sfb++;prev_noise.sfb_count1=sfb;}}return bits;};this.count_bits=function(gfc,xr,gi,prev_noise){var ix=gi.l3_enc;/* since quantize_xrpow uses table lookup, we need to check this first: */var w=$84mea.IXMAX_VAL/qupvt.IPOW20(gi.global_gain);if(gi.xrpow_max>w)return $84mea.LARGE_BITS;quantize_xrpow(xr,ix,qupvt.IPOW20(gi.global_gain),gi,prev_noise);if((gfc.substep_shaping&2)!=0){var j=0;/* 0.634521682242439 = 0.5946*2**(.5*0.1875) */var gain=gi.global_gain+gi.scalefac_scale;var roundfac=0.634521682242439/qupvt.IPOW20(gain);for(var sfb=0;sfb<gi.sfbmax;sfb++){var width=gi.width[sfb];$46fd82963609949b$var$assert(width>=0);if(0==gfc.pseudohalf[sfb])j+=width;else {var k;for(k=j,j+=width;k<j;++k)ix[k]=xr[k]>=roundfac?ix[k]:0;}}}return this.noquant_count_bits(gfc,gi,prev_noise);};/**
1579
+ * re-calculate the best scalefac_compress using scfsi the saved bits are
1580
+ * kept in the bit reservoir.
1581
+ */function recalc_divide_init(gfc,cod_info,ix,r01_bits,r01_div,r0_tbl,r1_tbl){var bigv=cod_info.big_values;for(var r0=0;r0<=22;r0++)r01_bits[r0]=$84mea.LARGE_BITS;for(var r0=0;r0<16;r0++){var a1=gfc.scalefac_band.l[r0+1];if(a1>=bigv)break;var r0bits=0;var bi=new Bits(r0bits);var r0t=choose_table(ix,0,a1,bi);r0bits=bi.bits;for(var r1=0;r1<8;r1++){var a2=gfc.scalefac_band.l[r0+r1+2];if(a2>=bigv)break;var bits=r0bits;bi=new Bits(bits);var r1t=choose_table(ix,a1,a2,bi);bits=bi.bits;if(r01_bits[r0+r1]>bits){r01_bits[r0+r1]=bits;r01_div[r0+r1]=r0;r0_tbl[r0+r1]=r0t;r1_tbl[r0+r1]=r1t;}}}}function recalc_divide_sub(gfc,cod_info2,gi,ix,r01_bits,r01_div,r0_tbl,r1_tbl){var bigv=cod_info2.big_values;for(var r2=2;r2<$cPNKB.SBMAX_l+1;r2++){var a2=gfc.scalefac_band.l[r2];if(a2>=bigv)break;var bits=r01_bits[r2-2]+cod_info2.count1bits;if(gi.part2_3_length<=bits)break;var bi=new Bits(bits);var r2t=choose_table(ix,a2,bigv,bi);bits=bi.bits;if(gi.part2_3_length<=bits)continue;gi.assign(cod_info2);gi.part2_3_length=bits;gi.region0_count=r01_div[r2-2];gi.region1_count=r2-2-r01_div[r2-2];gi.table_select[0]=r0_tbl[r2-2];gi.table_select[1]=r1_tbl[r2-2];gi.table_select[2]=r2t;}}this.best_huffman_divide=function(gfc,gi){var cod_info2=new $7weBo();var ix=gi.l3_enc;var r01_bits=$46fd82963609949b$var$new_int(23);var r01_div=$46fd82963609949b$var$new_int(23);var r0_tbl=$46fd82963609949b$var$new_int(23);var r1_tbl=$46fd82963609949b$var$new_int(23);/* SHORT BLOCK stuff fails for MPEG2 */if(gi.block_type==$cPNKB.SHORT_TYPE&&gfc.mode_gr==1)return;cod_info2.assign(gi);if(gi.block_type==$cPNKB.NORM_TYPE){recalc_divide_init(gfc,gi,ix,r01_bits,r01_div,r0_tbl,r1_tbl);recalc_divide_sub(gfc,cod_info2,gi,ix,r01_bits,r01_div,r0_tbl,r1_tbl);}var i=cod_info2.big_values;if(i==0||(ix[i-2]|ix[i-1])>1)return;i=gi.count1+2;if(i>576)return;/* Determines the number of bits to encode the quadruples. */cod_info2.assign(gi);cod_info2.count1=i;var a1=0;var a2=0;$46fd82963609949b$var$assert(i<=576);for(;i>cod_info2.big_values;i-=4){var p=((ix[i-4]*2+ix[i-3])*2+ix[i-2])*2+ix[i-1];a1+=$dQDcS.t32l[p];a2+=$dQDcS.t33l[p];}cod_info2.big_values=i;cod_info2.count1table_select=0;if(a1>a2){a1=a2;cod_info2.count1table_select=1;}cod_info2.count1bits=a1;if(cod_info2.block_type==$cPNKB.NORM_TYPE)recalc_divide_sub(gfc,cod_info2,gi,ix,r01_bits,r01_div,r0_tbl,r1_tbl);else {/* Count the number of bits necessary to code the bigvalues region. */cod_info2.part2_3_length=a1;a1=gfc.scalefac_band.l[8];if(a1>i)a1=i;if(a1>0){var bi=new Bits(cod_info2.part2_3_length);cod_info2.table_select[0]=choose_table(ix,0,a1,bi);cod_info2.part2_3_length=bi.bits;}if(i>a1){var bi=new Bits(cod_info2.part2_3_length);cod_info2.table_select[1]=choose_table(ix,a1,i,bi);cod_info2.part2_3_length=bi.bits;}if(gi.part2_3_length>cod_info2.part2_3_length)gi.assign(cod_info2);}};var slen1_n=[1,1,1,1,8,2,2,2,4,4,4,8,8,8,16,16];var slen2_n=[1,2,4,8,1,2,4,8,2,4,8,2,4,8,4,8];var slen1_tab=[0,0,0,0,3,1,1,1,2,2,2,3,3,3,4,4];var slen2_tab=[0,1,2,3,0,1,2,3,1,2,3,1,2,3,2,3];$46fd82963609949b$var$Takehiro.slen1_tab=slen1_tab;$46fd82963609949b$var$Takehiro.slen2_tab=slen2_tab;function scfsi_calc(ch,l3_side){var sfb;var gi=l3_side.tt[1][ch];var g0=l3_side.tt[0][ch];for(var i=0;i<$dQDcS.scfsi_band.length-1;i++){for(sfb=$dQDcS.scfsi_band[i];sfb<$dQDcS.scfsi_band[i+1];sfb++){if(g0.scalefac[sfb]!=gi.scalefac[sfb]&&gi.scalefac[sfb]>=0)break;}if(sfb==$dQDcS.scfsi_band[i+1]){for(sfb=$dQDcS.scfsi_band[i];sfb<$dQDcS.scfsi_band[i+1];sfb++)gi.scalefac[sfb]=-1;l3_side.scfsi[ch][i]=1;}}var s1=0;var c1=0;for(sfb=0;sfb<11;sfb++){if(gi.scalefac[sfb]==-1)continue;c1++;if(s1<gi.scalefac[sfb])s1=gi.scalefac[sfb];}var s2=0;var c2=0;for(;sfb<$cPNKB.SBPSY_l;sfb++){if(gi.scalefac[sfb]==-1)continue;c2++;if(s2<gi.scalefac[sfb])s2=gi.scalefac[sfb];}for(var i=0;i<16;i++)if(s1<slen1_n[i]&&s2<slen2_n[i]){var c=slen1_tab[i]*c1+slen2_tab[i]*c2;if(gi.part2_length>c){gi.part2_length=c;gi.scalefac_compress=i;}}}/**
1582
+ * Find the optimal way to store the scalefactors. Only call this routine
1583
+ * after final scalefactors have been chosen and the channel/granule will
1584
+ * not be re-encoded.
1585
+ */this.best_scalefac_store=function(gfc,gr,ch,l3_side){/* use scalefac_scale if we can */var gi=l3_side.tt[gr][ch];var sfb,i,j,l;var recalc=0;/*
1586
+ * remove scalefacs from bands with ix=0. This idea comes from the AAC
1587
+ * ISO docs. added mt 3/00
1588
+ */ /* check if l3_enc=0 */j=0;for(sfb=0;sfb<gi.sfbmax;sfb++){var width=gi.width[sfb];$46fd82963609949b$var$assert(width>=0);j+=width;for(l=-width;l<0;l++){if(gi.l3_enc[l+j]!=0)break;}if(l==0)gi.scalefac[sfb]=recalc=-2;/* anything goes. */ /*
1589
+ * only best_scalefac_store and calc_scfsi know--and only they
1590
+ * should know--about the magic number -2.
1591
+ */}if(0==gi.scalefac_scale&&0==gi.preflag){var s=0;for(sfb=0;sfb<gi.sfbmax;sfb++)if(gi.scalefac[sfb]>0)s|=gi.scalefac[sfb];if(0==(s&1)&&s!=0){for(sfb=0;sfb<gi.sfbmax;sfb++)if(gi.scalefac[sfb]>0)gi.scalefac[sfb]>>=1;gi.scalefac_scale=recalc=1;}}if(0==gi.preflag&&gi.block_type!=$cPNKB.SHORT_TYPE&&gfc.mode_gr==2){for(sfb=11;sfb<$cPNKB.SBPSY_l;sfb++)if(gi.scalefac[sfb]<qupvt.pretab[sfb]&&gi.scalefac[sfb]!=-2)break;if(sfb==$cPNKB.SBPSY_l){for(sfb=11;sfb<$cPNKB.SBPSY_l;sfb++)if(gi.scalefac[sfb]>0)gi.scalefac[sfb]-=qupvt.pretab[sfb];gi.preflag=recalc=1;}}for(i=0;i<4;i++)l3_side.scfsi[ch][i]=0;if(gfc.mode_gr==2&&gr==1&&l3_side.tt[0][ch].block_type!=$cPNKB.SHORT_TYPE&&l3_side.tt[1][ch].block_type!=$cPNKB.SHORT_TYPE){scfsi_calc(ch,l3_side);recalc=0;}for(sfb=0;sfb<gi.sfbmax;sfb++)if(gi.scalefac[sfb]==-2)gi.scalefac[sfb]=0;if(recalc!=0){if(gfc.mode_gr==2)this.scale_bitcount(gi);else this.scale_bitcount_lsf(gfc,gi);}};function all_scalefactors_not_negative(scalefac,n){for(var i=0;i<n;++i){if(scalefac[i]<0)return false;}return true;}/**
1592
+ * number of bits used to encode scalefacs.
1593
+ *
1594
+ * 18*slen1_tab[i] + 18*slen2_tab[i]
1595
+ */var scale_short=[0,18,36,54,54,36,54,72,54,72,90,72,90,108,108,126];/**
1596
+ * number of bits used to encode scalefacs.
1597
+ *
1598
+ * 17*slen1_tab[i] + 18*slen2_tab[i]
1599
+ */var scale_mixed=[0,18,36,54,51,35,53,71,52,70,88,69,87,105,104,122];/**
1600
+ * number of bits used to encode scalefacs.
1601
+ *
1602
+ * 11*slen1_tab[i] + 10*slen2_tab[i]
1603
+ */var scale_long=[0,10,20,30,33,21,31,41,32,42,52,43,53,63,64,74];/**
1604
+ * Also calculates the number of bits necessary to code the scalefactors.
1605
+ */this.scale_bitcount=function(cod_info){var k,sfb,max_slen1=0,max_slen2=0;/* maximum values */var tab;var scalefac=cod_info.scalefac;$46fd82963609949b$var$assert(all_scalefactors_not_negative(scalefac,cod_info.sfbmax));if(cod_info.block_type==$cPNKB.SHORT_TYPE){tab=scale_short;if(cod_info.mixed_block_flag!=0)tab=scale_mixed;}else {tab=scale_long;if(0==cod_info.preflag){for(sfb=11;sfb<$cPNKB.SBPSY_l;sfb++)if(scalefac[sfb]<qupvt.pretab[sfb])break;if(sfb==$cPNKB.SBPSY_l){cod_info.preflag=1;for(sfb=11;sfb<$cPNKB.SBPSY_l;sfb++)scalefac[sfb]-=qupvt.pretab[sfb];}}}for(sfb=0;sfb<cod_info.sfbdivide;sfb++)if(max_slen1<scalefac[sfb])max_slen1=scalefac[sfb];for(;sfb<cod_info.sfbmax;sfb++)if(max_slen2<scalefac[sfb])max_slen2=scalefac[sfb];/*
1606
+ * from Takehiro TOMINAGA <tominaga@isoternet.org> 10/99 loop over *all*
1607
+ * posible values of scalefac_compress to find the one which uses the
1608
+ * smallest number of bits. ISO would stop at first valid index
1609
+ */cod_info.part2_length=$84mea.LARGE_BITS;for(k=0;k<16;k++)if(max_slen1<slen1_n[k]&&max_slen2<slen2_n[k]&&cod_info.part2_length>tab[k]){cod_info.part2_length=tab[k];cod_info.scalefac_compress=k;}return cod_info.part2_length==$84mea.LARGE_BITS;};/**
1610
+ * table of largest scalefactor values for MPEG2
1611
+ */var max_range_sfac_tab=[[15,15,7,7],[15,15,7,0],[7,3,0,0],[15,31,31,0],[7,7,7,0],[3,3,0,0]];/**
1612
+ * Also counts the number of bits to encode the scalefacs but for MPEG 2
1613
+ * Lower sampling frequencies (24, 22.05 and 16 kHz.)
1614
+ *
1615
+ * This is reverse-engineered from section 2.4.3.2 of the MPEG2 IS,
1616
+ * "Audio Decoding Layer III"
1617
+ */this.scale_bitcount_lsf=function(gfc,cod_info){var table_number,row_in_table,partition,nr_sfb,window;var over;var i,sfb;var max_sfac=$46fd82963609949b$var$new_int(4);//var partition_table;
1618
+ var scalefac=cod_info.scalefac;/*
1619
+ * Set partition table. Note that should try to use table one, but do
1620
+ * not yet...
1621
+ */if(cod_info.preflag!=0)table_number=2;else table_number=0;for(i=0;i<4;i++)max_sfac[i]=0;if(cod_info.block_type==$cPNKB.SHORT_TYPE){row_in_table=1;var partition_table=qupvt.nr_of_sfb_block[table_number][row_in_table];for(sfb=0,partition=0;partition<4;partition++){nr_sfb=partition_table[partition]/3;for(i=0;i<nr_sfb;i++,sfb++)for(window=0;window<3;window++)if(scalefac[sfb*3+window]>max_sfac[partition])max_sfac[partition]=scalefac[sfb*3+window];}}else {row_in_table=0;var partition_table=qupvt.nr_of_sfb_block[table_number][row_in_table];for(sfb=0,partition=0;partition<4;partition++){nr_sfb=partition_table[partition];for(i=0;i<nr_sfb;i++,sfb++)if(scalefac[sfb]>max_sfac[partition])max_sfac[partition]=scalefac[sfb];}}for(over=false,partition=0;partition<4;partition++)if(max_sfac[partition]>max_range_sfac_tab[table_number][partition])over=true;if(!over){var slen1,slen2,slen3,slen4;cod_info.sfb_partition_table=qupvt.nr_of_sfb_block[table_number][row_in_table];for(partition=0;partition<4;partition++)cod_info.slen[partition]=log2tab[max_sfac[partition]];/* set scalefac_compress */slen1=cod_info.slen[0];slen2=cod_info.slen[1];slen3=cod_info.slen[2];slen4=cod_info.slen[3];switch(table_number){case 0:cod_info.scalefac_compress=(slen1*5+slen2<<4)+(slen3<<2)+slen4;break;case 1:cod_info.scalefac_compress=400+(slen1*5+slen2<<2)+slen3;break;case 2:cod_info.scalefac_compress=500+slen1*3+slen2;break;default:$46fd82963609949b$var$System.err.printf("intensity stereo not implemented yet\n");break;}}if(!over){$46fd82963609949b$var$assert(cod_info.sfb_partition_table!=null);cod_info.part2_length=0;for(partition=0;partition<4;partition++)cod_info.part2_length+=cod_info.slen[partition]*cod_info.sfb_partition_table[partition];}return over;};/*
1622
+ * Since no bands have been over-amplified, we can set scalefac_compress and
1623
+ * slen[] for the formatter
1624
+ */var log2tab=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];this.huffman_init=function(gfc){for(var i=2;i<=576;i+=2){var scfb_anz=0,bv_index;while(gfc.scalefac_band.l[++scfb_anz]<i);bv_index=subdv_table[scfb_anz][0];// .region0_count
1625
+ while(gfc.scalefac_band.l[bv_index+1]>i)bv_index--;if(bv_index<0)/*
1626
+ * this is an indication that everything is going to be encoded
1627
+ * as region0: bigvalues < region0 < region1 so lets set
1628
+ * region0, region1 to some value larger than bigvalues
1629
+ */bv_index=subdv_table[scfb_anz][0];// .region0_count
1630
+ gfc.bv_scf[i-2]=bv_index;bv_index=subdv_table[scfb_anz][1];// .region1_count
1631
+ while(gfc.scalefac_band.l[bv_index+gfc.bv_scf[i-2]+2]>i)bv_index--;if(bv_index<0)bv_index=subdv_table[scfb_anz][1];// .region1_count
1632
+ gfc.bv_scf[i-1]=bv_index;}};}module.exports=$46fd82963609949b$var$Takehiro;});parcelRequire.register("dQDcS",function(module,exports){function $a14e8b54f947e3d4$var$HuffCodeTab(len,max,tab,hl){this.xlen=len;this.linmax=max;this.table=tab;this.hlen=hl;}var $a14e8b54f947e3d4$var$Tables={};$a14e8b54f947e3d4$var$Tables.t1HB=[1,1,1,0];$a14e8b54f947e3d4$var$Tables.t2HB=[1,2,1,3,1,1,3,2,0];$a14e8b54f947e3d4$var$Tables.t3HB=[3,2,1,1,1,1,3,2,0];$a14e8b54f947e3d4$var$Tables.t5HB=[1,2,6,5,3,1,4,4,7,5,7,1,6,1,1,0];$a14e8b54f947e3d4$var$Tables.t6HB=[7,3,5,1,6,2,3,2,5,4,4,1,3,3,2,0];$a14e8b54f947e3d4$var$Tables.t7HB=[1,2,10,19,16,10,3,3,7,10,5,3,11,4,13,17,8,4,12,11,18,15,11,2,7,6,9,14,3,1,6,4,5,3,2,0];$a14e8b54f947e3d4$var$Tables.t8HB=[3,4,6,18,12,5,5,1,2,16,9,3,7,3,5,14,7,3,19,17,15,13,10,4,13,5,8,11,5,1,12,4,4,1,1,0];$a14e8b54f947e3d4$var$Tables.t9HB=[7,5,9,14,15,7,6,4,5,5,6,7,7,6,8,8,8,5,15,6,9,10,5,1,11,7,9,6,4,1,14,4,6,2,6,0];$a14e8b54f947e3d4$var$Tables.t10HB=[1,2,10,23,35,30,12,17,3,3,8,12,18,21,12,7,11,9,15,21,32,40,19,6,14,13,22,34,46,23,18,7,20,19,33,47,27,22,9,3,31,22,41,26,21,20,5,3,14,13,10,11,16,6,5,1,9,8,7,8,4,4,2,0];$a14e8b54f947e3d4$var$Tables.t11HB=[3,4,10,24,34,33,21,15,5,3,4,10,32,17,11,10,11,7,13,18,30,31,20,5,25,11,19,59,27,18,12,5,35,33,31,58,30,16,7,5,28,26,32,19,17,15,8,14,14,12,9,13,14,9,4,1,11,4,6,6,6,3,2,0];$a14e8b54f947e3d4$var$Tables.t12HB=[9,6,16,33,41,39,38,26,7,5,6,9,23,16,26,11,17,7,11,14,21,30,10,7,17,10,15,12,18,28,14,5,32,13,22,19,18,16,9,5,40,17,31,29,17,13,4,2,27,12,11,15,10,7,4,1,27,12,8,12,6,3,1,0];$a14e8b54f947e3d4$var$Tables.t13HB=[1,5,14,21,34,51,46,71,42,52,68,52,67,44,43,19,3,4,12,19,31,26,44,33,31,24,32,24,31,35,22,14,15,13,23,36,59,49,77,65,29,40,30,40,27,33,42,16,22,20,37,61,56,79,73,64,43,76,56,37,26,31,25,14,35,16,60,57,97,75,114,91,54,73,55,41,48,53,23,24,58,27,50,96,76,70,93,84,77,58,79,29,74,49,41,17,47,45,78,74,115,94,90,79,69,83,71,50,59,38,36,15,72,34,56,95,92,85,91,90,86,73,77,65,51,44,43,42,43,20,30,44,55,78,72,87,78,61,46,54,37,30,20,16,53,25,41,37,44,59,54,81,66,76,57,54,37,18,39,11,35,33,31,57,42,82,72,80,47,58,55,21,22,26,38,22,53,25,23,38,70,60,51,36,55,26,34,23,27,14,9,7,34,32,28,39,49,75,30,52,48,40,52,28,18,17,9,5,45,21,34,64,56,50,49,45,31,19,12,15,10,7,6,3,48,23,20,39,36,35,53,21,16,23,13,10,6,1,4,2,16,15,17,27,25,20,29,11,17,12,16,8,1,1,0,1];$a14e8b54f947e3d4$var$Tables.t15HB=[7,12,18,53,47,76,124,108,89,123,108,119,107,81,122,63,13,5,16,27,46,36,61,51,42,70,52,83,65,41,59,36,19,17,15,24,41,34,59,48,40,64,50,78,62,80,56,33,29,28,25,43,39,63,55,93,76,59,93,72,54,75,50,29,52,22,42,40,67,57,95,79,72,57,89,69,49,66,46,27,77,37,35,66,58,52,91,74,62,48,79,63,90,62,40,38,125,32,60,56,50,92,78,65,55,87,71,51,73,51,70,30,109,53,49,94,88,75,66,122,91,73,56,42,64,44,21,25,90,43,41,77,73,63,56,92,77,66,47,67,48,53,36,20,71,34,67,60,58,49,88,76,67,106,71,54,38,39,23,15,109,53,51,47,90,82,58,57,48,72,57,41,23,27,62,9,86,42,40,37,70,64,52,43,70,55,42,25,29,18,11,11,118,68,30,55,50,46,74,65,49,39,24,16,22,13,14,7,91,44,39,38,34,63,52,45,31,52,28,19,14,8,9,3,123,60,58,53,47,43,32,22,37,24,17,12,15,10,2,1,71,37,34,30,28,20,17,26,21,16,10,6,8,6,2,0];$a14e8b54f947e3d4$var$Tables.t16HB=[1,5,14,44,74,63,110,93,172,149,138,242,225,195,376,17,3,4,12,20,35,62,53,47,83,75,68,119,201,107,207,9,15,13,23,38,67,58,103,90,161,72,127,117,110,209,206,16,45,21,39,69,64,114,99,87,158,140,252,212,199,387,365,26,75,36,68,65,115,101,179,164,155,264,246,226,395,382,362,9,66,30,59,56,102,185,173,265,142,253,232,400,388,378,445,16,111,54,52,100,184,178,160,133,257,244,228,217,385,366,715,10,98,48,91,88,165,157,148,261,248,407,397,372,380,889,884,8,85,84,81,159,156,143,260,249,427,401,392,383,727,713,708,7,154,76,73,141,131,256,245,426,406,394,384,735,359,710,352,11,139,129,67,125,247,233,229,219,393,743,737,720,885,882,439,4,243,120,118,115,227,223,396,746,742,736,721,712,706,223,436,6,202,224,222,218,216,389,386,381,364,888,443,707,440,437,1728,4,747,211,210,208,370,379,734,723,714,1735,883,877,876,3459,865,2,377,369,102,187,726,722,358,711,709,866,1734,871,3458,870,434,0,12,10,7,11,10,17,11,9,13,12,10,7,5,3,1,3];$a14e8b54f947e3d4$var$Tables.t24HB=[15,13,46,80,146,262,248,434,426,669,653,649,621,517,1032,88,14,12,21,38,71,130,122,216,209,198,327,345,319,297,279,42,47,22,41,74,68,128,120,221,207,194,182,340,315,295,541,18,81,39,75,70,134,125,116,220,204,190,178,325,311,293,271,16,147,72,69,135,127,118,112,210,200,188,352,323,306,285,540,14,263,66,129,126,119,114,214,202,192,180,341,317,301,281,262,12,249,123,121,117,113,215,206,195,185,347,330,308,291,272,520,10,435,115,111,109,211,203,196,187,353,332,313,298,283,531,381,17,427,212,208,205,201,193,186,177,169,320,303,286,268,514,377,16,335,199,197,191,189,181,174,333,321,305,289,275,521,379,371,11,668,184,183,179,175,344,331,314,304,290,277,530,383,373,366,10,652,346,171,168,164,318,309,299,287,276,263,513,375,368,362,6,648,322,316,312,307,302,292,284,269,261,512,376,370,364,359,4,620,300,296,294,288,282,273,266,515,380,374,369,365,361,357,2,1033,280,278,274,267,264,259,382,378,372,367,363,360,358,356,0,43,20,19,17,15,13,11,9,7,6,4,7,5,3,1,3];$a14e8b54f947e3d4$var$Tables.t32HB=[1,10,8,20,12,20,16,32,14,12,24,0,28,16,24,16];$a14e8b54f947e3d4$var$Tables.t33HB=[15,28,26,48,22,40,36,64,14,24,20,32,12,16,8,0];$a14e8b54f947e3d4$var$Tables.t1l=[1,4,3,5];$a14e8b54f947e3d4$var$Tables.t2l=[1,4,7,4,5,7,6,7,8];$a14e8b54f947e3d4$var$Tables.t3l=[2,3,7,4,4,7,6,7,8];$a14e8b54f947e3d4$var$Tables.t5l=[1,4,7,8,4,5,8,9,7,8,9,10,8,8,9,10];$a14e8b54f947e3d4$var$Tables.t6l=[3,4,6,8,4,4,6,7,5,6,7,8,7,7,8,9];$a14e8b54f947e3d4$var$Tables.t7l=[1,4,7,9,9,10,4,6,8,9,9,10,7,7,9,10,10,11,8,9,10,11,11,11,8,9,10,11,11,12,9,10,11,12,12,12];$a14e8b54f947e3d4$var$Tables.t8l=[2,4,7,9,9,10,4,4,6,10,10,10,7,6,8,10,10,11,9,10,10,11,11,12,9,9,10,11,12,12,10,10,11,11,13,13];$a14e8b54f947e3d4$var$Tables.t9l=[3,4,6,7,9,10,4,5,6,7,8,10,5,6,7,8,9,10,7,7,8,9,9,10,8,8,9,9,10,11,9,9,10,10,11,11];$a14e8b54f947e3d4$var$Tables.t10l=[1,4,7,9,10,10,10,11,4,6,8,9,10,11,10,10,7,8,9,10,11,12,11,11,8,9,10,11,12,12,11,12,9,10,11,12,12,12,12,12,10,11,12,12,13,13,12,13,9,10,11,12,12,12,13,13,10,10,11,12,12,13,13,13];$a14e8b54f947e3d4$var$Tables.t11l=[2,4,6,8,9,10,9,10,4,5,6,8,10,10,9,10,6,7,8,9,10,11,10,10,8,8,9,11,10,12,10,11,9,10,10,11,11,12,11,12,9,10,11,12,12,13,12,13,9,9,9,10,11,12,12,12,9,9,10,11,12,12,12,12];$a14e8b54f947e3d4$var$Tables.t12l=[4,4,6,8,9,10,10,10,4,5,6,7,9,9,10,10,6,6,7,8,9,10,9,10,7,7,8,8,9,10,10,10,8,8,9,9,10,10,10,11,9,9,10,10,10,11,10,11,9,9,9,10,10,11,11,12,10,10,10,11,11,11,11,12];$a14e8b54f947e3d4$var$Tables.t13l=[1,5,7,8,9,10,10,11,10,11,12,12,13,13,14,14,4,6,8,9,10,10,11,11,11,11,12,12,13,14,14,14,7,8,9,10,11,11,12,12,11,12,12,13,13,14,15,15,8,9,10,11,11,12,12,12,12,13,13,13,13,14,15,15,9,9,11,11,12,12,13,13,12,13,13,14,14,15,15,16,10,10,11,12,12,12,13,13,13,13,14,13,15,15,16,16,10,11,12,12,13,13,13,13,13,14,14,14,15,15,16,16,11,11,12,13,13,13,14,14,14,14,15,15,15,16,18,18,10,10,11,12,12,13,13,14,14,14,14,15,15,16,17,17,11,11,12,12,13,13,13,15,14,15,15,16,16,16,18,17,11,12,12,13,13,14,14,15,14,15,16,15,16,17,18,19,12,12,12,13,14,14,14,14,15,15,15,16,17,17,17,18,12,13,13,14,14,15,14,15,16,16,17,17,17,18,18,18,13,13,14,15,15,15,16,16,16,16,16,17,18,17,18,18,14,14,14,15,15,15,17,16,16,19,17,17,17,19,18,18,13,14,15,16,16,16,17,16,17,17,18,18,21,20,21,18];$a14e8b54f947e3d4$var$Tables.t15l=[3,5,6,8,8,9,10,10,10,11,11,12,12,12,13,14,5,5,7,8,9,9,10,10,10,11,11,12,12,12,13,13,6,7,7,8,9,9,10,10,10,11,11,12,12,13,13,13,7,8,8,9,9,10,10,11,11,11,12,12,12,13,13,13,8,8,9,9,10,10,11,11,11,11,12,12,12,13,13,13,9,9,9,10,10,10,11,11,11,11,12,12,13,13,13,14,10,9,10,10,10,11,11,11,11,12,12,12,13,13,14,14,10,10,10,11,11,11,11,12,12,12,12,12,13,13,13,14,10,10,10,11,11,11,11,12,12,12,12,13,13,14,14,14,10,10,11,11,11,11,12,12,12,13,13,13,13,14,14,14,11,11,11,11,12,12,12,12,12,13,13,13,13,14,15,14,11,11,11,11,12,12,12,12,13,13,13,13,14,14,14,15,12,12,11,12,12,12,13,13,13,13,13,13,14,14,15,15,12,12,12,12,12,13,13,13,13,14,14,14,14,14,15,15,13,13,13,13,13,13,13,13,14,14,14,14,15,15,14,15,13,13,13,13,13,13,13,14,14,14,14,14,15,15,15,15];$a14e8b54f947e3d4$var$Tables.t16_5l=[1,5,7,9,10,10,11,11,12,12,12,13,13,13,14,11,4,6,8,9,10,11,11,11,12,12,12,13,14,13,14,11,7,8,9,10,11,11,12,12,13,12,13,13,13,14,14,12,9,9,10,11,11,12,12,12,13,13,14,14,14,15,15,13,10,10,11,11,12,12,13,13,13,14,14,14,15,15,15,12,10,10,11,11,12,13,13,14,13,14,14,15,15,15,16,13,11,11,11,12,13,13,13,13,14,14,14,14,15,15,16,13,11,11,12,12,13,13,13,14,14,15,15,15,15,17,17,13,11,12,12,13,13,13,14,14,15,15,15,15,16,16,16,13,12,12,12,13,13,14,14,15,15,15,15,16,15,16,15,14,12,13,12,13,14,14,14,14,15,16,16,16,17,17,16,13,13,13,13,13,14,14,15,16,16,16,16,16,16,15,16,14,13,14,14,14,14,15,15,15,15,17,16,16,16,16,18,14,15,14,14,14,15,15,16,16,16,18,17,17,17,19,17,14,14,15,13,14,16,16,15,16,16,17,18,17,19,17,16,14,11,11,11,12,12,13,13,13,14,14,14,14,14,14,14,12];$a14e8b54f947e3d4$var$Tables.t16l=[1,5,7,9,10,10,11,11,12,12,12,13,13,13,14,10,4,6,8,9,10,11,11,11,12,12,12,13,14,13,14,10,7,8,9,10,11,11,12,12,13,12,13,13,13,14,14,11,9,9,10,11,11,12,12,12,13,13,14,14,14,15,15,12,10,10,11,11,12,12,13,13,13,14,14,14,15,15,15,11,10,10,11,11,12,13,13,14,13,14,14,15,15,15,16,12,11,11,11,12,13,13,13,13,14,14,14,14,15,15,16,12,11,11,12,12,13,13,13,14,14,15,15,15,15,17,17,12,11,12,12,13,13,13,14,14,15,15,15,15,16,16,16,12,12,12,12,13,13,14,14,15,15,15,15,16,15,16,15,13,12,13,12,13,14,14,14,14,15,16,16,16,17,17,16,12,13,13,13,13,14,14,15,16,16,16,16,16,16,15,16,13,13,14,14,14,14,15,15,15,15,17,16,16,16,16,18,13,15,14,14,14,15,15,16,16,16,18,17,17,17,19,17,13,14,15,13,14,16,16,15,16,16,17,18,17,19,17,16,13,10,10,10,11,11,12,12,12,13,13,13,13,13,13,13,10];$a14e8b54f947e3d4$var$Tables.t24l=[4,5,7,8,9,10,10,11,11,12,12,12,12,12,13,10,5,6,7,8,9,10,10,11,11,11,12,12,12,12,12,10,7,7,8,9,9,10,10,11,11,11,11,12,12,12,13,9,8,8,9,9,10,10,10,11,11,11,11,12,12,12,12,9,9,9,9,10,10,10,10,11,11,11,12,12,12,12,13,9,10,9,10,10,10,10,11,11,11,11,12,12,12,12,12,9,10,10,10,10,10,11,11,11,11,12,12,12,12,12,13,9,11,10,10,10,11,11,11,11,12,12,12,12,12,13,13,10,11,11,11,11,11,11,11,11,11,12,12,12,12,13,13,10,11,11,11,11,11,11,11,12,12,12,12,12,13,13,13,10,12,11,11,11,11,12,12,12,12,12,12,13,13,13,13,10,12,12,11,11,11,12,12,12,12,12,12,13,13,13,13,10,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,10,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,10,13,12,12,12,12,12,12,13,13,13,13,13,13,13,13,10,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,6];$a14e8b54f947e3d4$var$Tables.t32l=[1,5,5,7,5,8,7,9,5,7,7,9,7,9,9,10];$a14e8b54f947e3d4$var$Tables.t33l=[4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8];$a14e8b54f947e3d4$var$Tables.ht=[/* xlen, linmax, table, hlen */new $a14e8b54f947e3d4$var$HuffCodeTab(0,0,null,null),new $a14e8b54f947e3d4$var$HuffCodeTab(2,0,$a14e8b54f947e3d4$var$Tables.t1HB,$a14e8b54f947e3d4$var$Tables.t1l),new $a14e8b54f947e3d4$var$HuffCodeTab(3,0,$a14e8b54f947e3d4$var$Tables.t2HB,$a14e8b54f947e3d4$var$Tables.t2l),new $a14e8b54f947e3d4$var$HuffCodeTab(3,0,$a14e8b54f947e3d4$var$Tables.t3HB,$a14e8b54f947e3d4$var$Tables.t3l),new $a14e8b54f947e3d4$var$HuffCodeTab(0,0,null,null),/* Apparently not used */new $a14e8b54f947e3d4$var$HuffCodeTab(4,0,$a14e8b54f947e3d4$var$Tables.t5HB,$a14e8b54f947e3d4$var$Tables.t5l),new $a14e8b54f947e3d4$var$HuffCodeTab(4,0,$a14e8b54f947e3d4$var$Tables.t6HB,$a14e8b54f947e3d4$var$Tables.t6l),new $a14e8b54f947e3d4$var$HuffCodeTab(6,0,$a14e8b54f947e3d4$var$Tables.t7HB,$a14e8b54f947e3d4$var$Tables.t7l),new $a14e8b54f947e3d4$var$HuffCodeTab(6,0,$a14e8b54f947e3d4$var$Tables.t8HB,$a14e8b54f947e3d4$var$Tables.t8l),new $a14e8b54f947e3d4$var$HuffCodeTab(6,0,$a14e8b54f947e3d4$var$Tables.t9HB,$a14e8b54f947e3d4$var$Tables.t9l),new $a14e8b54f947e3d4$var$HuffCodeTab(8,0,$a14e8b54f947e3d4$var$Tables.t10HB,$a14e8b54f947e3d4$var$Tables.t10l),new $a14e8b54f947e3d4$var$HuffCodeTab(8,0,$a14e8b54f947e3d4$var$Tables.t11HB,$a14e8b54f947e3d4$var$Tables.t11l),new $a14e8b54f947e3d4$var$HuffCodeTab(8,0,$a14e8b54f947e3d4$var$Tables.t12HB,$a14e8b54f947e3d4$var$Tables.t12l),new $a14e8b54f947e3d4$var$HuffCodeTab(16,0,$a14e8b54f947e3d4$var$Tables.t13HB,$a14e8b54f947e3d4$var$Tables.t13l),new $a14e8b54f947e3d4$var$HuffCodeTab(0,0,null,$a14e8b54f947e3d4$var$Tables.t16_5l),/* Apparently not used */new $a14e8b54f947e3d4$var$HuffCodeTab(16,0,$a14e8b54f947e3d4$var$Tables.t15HB,$a14e8b54f947e3d4$var$Tables.t15l),new $a14e8b54f947e3d4$var$HuffCodeTab(1,1,$a14e8b54f947e3d4$var$Tables.t16HB,$a14e8b54f947e3d4$var$Tables.t16l),new $a14e8b54f947e3d4$var$HuffCodeTab(2,3,$a14e8b54f947e3d4$var$Tables.t16HB,$a14e8b54f947e3d4$var$Tables.t16l),new $a14e8b54f947e3d4$var$HuffCodeTab(3,7,$a14e8b54f947e3d4$var$Tables.t16HB,$a14e8b54f947e3d4$var$Tables.t16l),new $a14e8b54f947e3d4$var$HuffCodeTab(4,15,$a14e8b54f947e3d4$var$Tables.t16HB,$a14e8b54f947e3d4$var$Tables.t16l),new $a14e8b54f947e3d4$var$HuffCodeTab(6,63,$a14e8b54f947e3d4$var$Tables.t16HB,$a14e8b54f947e3d4$var$Tables.t16l),new $a14e8b54f947e3d4$var$HuffCodeTab(8,255,$a14e8b54f947e3d4$var$Tables.t16HB,$a14e8b54f947e3d4$var$Tables.t16l),new $a14e8b54f947e3d4$var$HuffCodeTab(10,1023,$a14e8b54f947e3d4$var$Tables.t16HB,$a14e8b54f947e3d4$var$Tables.t16l),new $a14e8b54f947e3d4$var$HuffCodeTab(13,8191,$a14e8b54f947e3d4$var$Tables.t16HB,$a14e8b54f947e3d4$var$Tables.t16l),new $a14e8b54f947e3d4$var$HuffCodeTab(4,15,$a14e8b54f947e3d4$var$Tables.t24HB,$a14e8b54f947e3d4$var$Tables.t24l),new $a14e8b54f947e3d4$var$HuffCodeTab(5,31,$a14e8b54f947e3d4$var$Tables.t24HB,$a14e8b54f947e3d4$var$Tables.t24l),new $a14e8b54f947e3d4$var$HuffCodeTab(6,63,$a14e8b54f947e3d4$var$Tables.t24HB,$a14e8b54f947e3d4$var$Tables.t24l),new $a14e8b54f947e3d4$var$HuffCodeTab(7,127,$a14e8b54f947e3d4$var$Tables.t24HB,$a14e8b54f947e3d4$var$Tables.t24l),new $a14e8b54f947e3d4$var$HuffCodeTab(8,255,$a14e8b54f947e3d4$var$Tables.t24HB,$a14e8b54f947e3d4$var$Tables.t24l),new $a14e8b54f947e3d4$var$HuffCodeTab(9,511,$a14e8b54f947e3d4$var$Tables.t24HB,$a14e8b54f947e3d4$var$Tables.t24l),new $a14e8b54f947e3d4$var$HuffCodeTab(11,2047,$a14e8b54f947e3d4$var$Tables.t24HB,$a14e8b54f947e3d4$var$Tables.t24l),new $a14e8b54f947e3d4$var$HuffCodeTab(13,8191,$a14e8b54f947e3d4$var$Tables.t24HB,$a14e8b54f947e3d4$var$Tables.t24l),new $a14e8b54f947e3d4$var$HuffCodeTab(0,0,$a14e8b54f947e3d4$var$Tables.t32HB,$a14e8b54f947e3d4$var$Tables.t32l),new $a14e8b54f947e3d4$var$HuffCodeTab(0,0,$a14e8b54f947e3d4$var$Tables.t33HB,$a14e8b54f947e3d4$var$Tables.t33l)];/**
1633
+ * <CODE>
1634
+ * for (i = 0; i < 16*16; i++) [
1635
+ * largetbl[i] = ((ht[16].hlen[i]) << 16) + ht[24].hlen[i];
1636
+ * ]
1637
+ * </CODE>
1638
+ *
1639
+ */$a14e8b54f947e3d4$var$Tables.largetbl=[0x010004,0x050005,0x070007,0x090008,0x0a0009,0x0a000a,0x0b000a,0x0b000b,0x0c000b,0x0c000c,0x0c000c,0x0d000c,0x0d000c,0x0d000c,0x0e000d,0x0a000a,0x040005,0x060006,0x080007,0x090008,0x0a0009,0x0b000a,0x0b000a,0x0b000b,0x0c000b,0x0c000b,0x0c000c,0x0d000c,0x0e000c,0x0d000c,0x0e000c,0x0a000a,0x070007,0x080007,0x090008,0x0a0009,0x0b0009,0x0b000a,0x0c000a,0x0c000b,0x0d000b,0x0c000b,0x0d000b,0x0d000c,0x0d000c,0x0e000c,0x0e000d,0x0b0009,0x090008,0x090008,0x0a0009,0x0b0009,0x0b000a,0x0c000a,0x0c000a,0x0c000b,0x0d000b,0x0d000b,0x0e000b,0x0e000c,0x0e000c,0x0f000c,0x0f000c,0x0c0009,0x0a0009,0x0a0009,0x0b0009,0x0b000a,0x0c000a,0x0c000a,0x0d000a,0x0d000b,0x0d000b,0x0e000b,0x0e000c,0x0e000c,0x0f000c,0x0f000c,0x0f000d,0x0b0009,0x0a000a,0x0a0009,0x0b000a,0x0b000a,0x0c000a,0x0d000a,0x0d000b,0x0e000b,0x0d000b,0x0e000b,0x0e000c,0x0f000c,0x0f000c,0x0f000c,0x10000c,0x0c0009,0x0b000a,0x0b000a,0x0b000a,0x0c000a,0x0d000a,0x0d000b,0x0d000b,0x0d000b,0x0e000b,0x0e000c,0x0e000c,0x0e000c,0x0f000c,0x0f000c,0x10000d,0x0c0009,0x0b000b,0x0b000a,0x0c000a,0x0c000a,0x0d000b,0x0d000b,0x0d000b,0x0e000b,0x0e000c,0x0f000c,0x0f000c,0x0f000c,0x0f000c,0x11000d,0x11000d,0x0c000a,0x0b000b,0x0c000b,0x0c000b,0x0d000b,0x0d000b,0x0d000b,0x0e000b,0x0e000b,0x0f000b,0x0f000c,0x0f000c,0x0f000c,0x10000c,0x10000d,0x10000d,0x0c000a,0x0c000b,0x0c000b,0x0c000b,0x0d000b,0x0d000b,0x0e000b,0x0e000b,0x0f000c,0x0f000c,0x0f000c,0x0f000c,0x10000c,0x0f000d,0x10000d,0x0f000d,0x0d000a,0x0c000c,0x0d000b,0x0c000b,0x0d000b,0x0e000b,0x0e000c,0x0e000c,0x0e000c,0x0f000c,0x10000c,0x10000c,0x10000d,0x11000d,0x11000d,0x10000d,0x0c000a,0x0d000c,0x0d000c,0x0d000b,0x0d000b,0x0e000b,0x0e000c,0x0f000c,0x10000c,0x10000c,0x10000c,0x10000c,0x10000d,0x10000d,0x0f000d,0x10000d,0x0d000a,0x0d000c,0x0e000c,0x0e000c,0x0e000c,0x0e000c,0x0f000c,0x0f000c,0x0f000c,0x0f000c,0x11000c,0x10000d,0x10000d,0x10000d,0x10000d,0x12000d,0x0d000a,0x0f000c,0x0e000c,0x0e000c,0x0e000c,0x0f000c,0x0f000c,0x10000c,0x10000c,0x10000d,0x12000d,0x11000d,0x11000d,0x11000d,0x13000d,0x11000d,0x0d000a,0x0e000d,0x0f000c,0x0d000c,0x0e000c,0x10000c,0x10000c,0x0f000c,0x10000d,0x10000d,0x11000d,0x12000d,0x11000d,0x13000d,0x11000d,0x10000d,0x0d000a,0x0a0009,0x0a0009,0x0a0009,0x0b0009,0x0b0009,0x0c0009,0x0c0009,0x0c0009,0x0d0009,0x0d0009,0x0d0009,0x0d000a,0x0d000a,0x0d000a,0x0d000a,0x0a0006];/**
1640
+ * <CODE>
1641
+ * for (i = 0; i < 3*3; i++) [
1642
+ * table23[i] = ((ht[2].hlen[i]) << 16) + ht[3].hlen[i];
1643
+ * ]
1644
+ * </CODE>
1645
+ *
1646
+ */$a14e8b54f947e3d4$var$Tables.table23=[0x010002,0x040003,0x070007,0x040004,0x050004,0x070007,0x060006,0x070007,0x080008];/**
1647
+ * <CODE>
1648
+ * for (i = 0; i < 4*4; i++) [
1649
+ * table56[i] = ((ht[5].hlen[i]) << 16) + ht[6].hlen[i];
1650
+ * ]
1651
+ * </CODE>
1652
+ *
1653
+ */$a14e8b54f947e3d4$var$Tables.table56=[0x010003,0x040004,0x070006,0x080008,0x040004,0x050004,0x080006,0x090007,0x070005,0x080006,0x090007,0x0a0008,0x080007,0x080007,0x090008,0x0a0009];$a14e8b54f947e3d4$var$Tables.bitrate_table=[[0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,-1],/* MPEG 2 */[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],/* MPEG 1 */[0,8,16,24,32,40,48,56,64,-1,-1,-1,-1,-1,-1,-1]];/**
1654
+ * MPEG 2, MPEG 1, MPEG 2.5.
1655
+ */$a14e8b54f947e3d4$var$Tables.samplerate_table=[[22050,24000,16000,-1],[44100,48000,32000,-1],[11025,12000,8000,-1]];/**
1656
+ * This is the scfsi_band table from 2.4.2.7 of the IS.
1657
+ */$a14e8b54f947e3d4$var$Tables.scfsi_band=[0,6,11,16,21];module.exports=$a14e8b54f947e3d4$var$Tables;});parcelRequire.register("84mea",function(module,exports){/*
1658
+ * quantize_pvt source file
1659
+ *
1660
+ * Copyright (c) 1999-2002 Takehiro Tominaga
1661
+ * Copyright (c) 2000-2002 Robert Hegemann
1662
+ * Copyright (c) 2001 Naoki Shibata
1663
+ * Copyright (c) 2002-2005 Gabriel Bouvigne
1664
+ *
1665
+ * This library is free software; you can redistribute it and/or
1666
+ * modify it under the terms of the GNU Lesser General Public
1667
+ * License as published by the Free Software Foundation; either
1668
+ * version 2 of the License, or (at your option) any later version.
1669
+ *
1670
+ * This library is distributed in the hope that it will be useful,
1671
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1672
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1673
+ * Library General Public License for more details.
1674
+ *
1675
+ * You should have received a copy of the GNU Lesser General Public
1676
+ * License along with this library; if not, write to the
1677
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1678
+ * Boston, MA 02111-1307, USA.
1679
+ */ /* $Id: QuantizePVT.java,v 1.24 2011/05/24 20:48:06 kenchis Exp $ */var $7imnH=parcelRequire("7imnH");var $3YDN3=parcelRequire("3YDN3");$3YDN3.System;var $5dfff05939c3cc74$var$VbrMode=$3YDN3.VbrMode;var $5dfff05939c3cc74$var$Float=$3YDN3.Float;$3YDN3.ShortBlock;var $5dfff05939c3cc74$var$Util=$3YDN3.Util;$3YDN3.Arrays;$3YDN3.new_array_n;$3YDN3.new_byte;$3YDN3.new_double;var $5dfff05939c3cc74$var$new_float=$3YDN3.new_float;$3YDN3.new_float_n;var $5dfff05939c3cc74$var$new_int=$3YDN3.new_int;$3YDN3.new_int_n;var $5dfff05939c3cc74$var$assert=$3YDN3.assert;var $cPNKB=parcelRequire("cPNKB");var $lL4Le=parcelRequire("lL4Le");var $4SDnr=parcelRequire("4SDnr");$5dfff05939c3cc74$var$QuantizePVT.Q_MAX=257;$5dfff05939c3cc74$var$QuantizePVT.Q_MAX2=116;$5dfff05939c3cc74$var$QuantizePVT.LARGE_BITS=100000;$5dfff05939c3cc74$var$QuantizePVT.IXMAX_VAL=8206;function $5dfff05939c3cc74$var$QuantizePVT(){var BitStream=parcelRequire("ctaQC");var tak=null;var rv=null;var psy=null;this.setModules=function(_tk,_rv,_psy){tak=_tk;rv=_rv;psy=_psy;};function POW20(x){$5dfff05939c3cc74$var$assert(0<=x+$5dfff05939c3cc74$var$QuantizePVT.Q_MAX2&&x<$5dfff05939c3cc74$var$QuantizePVT.Q_MAX);return pow20[x+$5dfff05939c3cc74$var$QuantizePVT.Q_MAX2];}this.IPOW20=function(x){$5dfff05939c3cc74$var$assert(0<=x&&x<$5dfff05939c3cc74$var$QuantizePVT.Q_MAX);return ipow20[x];};/**
1680
+ * smallest such that 1.0+DBL_EPSILON != 1.0
1681
+ */var DBL_EPSILON=2.2204460492503131e-016;/**
1682
+ * ix always <= 8191+15. see count_bits()
1683
+ */var IXMAX_VAL=$5dfff05939c3cc74$var$QuantizePVT.IXMAX_VAL;var PRECALC_SIZE=IXMAX_VAL+2;var Q_MAX=$5dfff05939c3cc74$var$QuantizePVT.Q_MAX;/**
1684
+ * <CODE>
1685
+ * minimum possible number of
1686
+ * -cod_info.global_gain + ((scalefac[] + (cod_info.preflag ? pretab[sfb] : 0))
1687
+ * << (cod_info.scalefac_scale + 1)) + cod_info.subblock_gain[cod_info.window[sfb]] * 8;
1688
+ *
1689
+ * for long block, 0+((15+3)<<2) = 18*4 = 72
1690
+ * for short block, 0+(15<<2)+7*8 = 15*4+56 = 116
1691
+ * </CODE>
1692
+ */var Q_MAX2=$5dfff05939c3cc74$var$QuantizePVT.Q_MAX2;$5dfff05939c3cc74$var$QuantizePVT.LARGE_BITS;/**
1693
+ * Assuming dynamic range=96dB, this value should be 92
1694
+ */var NSATHSCALE=100;/**
1695
+ * The following table is used to implement the scalefactor partitioning for
1696
+ * MPEG2 as described in section 2.4.3.2 of the IS. The indexing corresponds
1697
+ * to the way the tables are presented in the IS:
1698
+ *
1699
+ * [table_number][row_in_table][column of nr_of_sfb]
1700
+ */this.nr_of_sfb_block=[[[6,5,5,5],[9,9,9,9],[6,9,9,9]],[[6,5,7,3],[9,9,12,6],[6,9,12,6]],[[11,10,0,0],[18,18,0,0],[15,18,0,0]],[[7,7,7,0],[12,12,12,0],[6,15,12,0]],[[6,6,6,3],[12,9,9,6],[6,12,9,6]],[[8,8,5,0],[15,12,9,0],[6,18,9,0]]];/**
1701
+ * Table B.6: layer3 preemphasis
1702
+ */var pretab=[0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,2,0];this.pretab=pretab;/**
1703
+ * Here are MPEG1 Table B.8 and MPEG2 Table B.1 -- Layer III scalefactor
1704
+ * bands. <BR>
1705
+ * Index into this using a method such as:<BR>
1706
+ * idx = fr_ps.header.sampling_frequency + (fr_ps.header.version * 3)
1707
+ */this.sfBandIndex=[// Table B.2.b: 22.05 kHz
1708
+ new $7imnH([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0,4,8,12,18,24,32,42,56,74,100,132,174,192],[0,0,0,0,0,0,0]// sfb21 pseudo sub bands
1709
+ ,[0,0,0,0,0,0,0]// sfb12 pseudo sub bands
1710
+ ),/* Table B.2.c: 24 kHz */ /* docs: 332. mpg123(broken): 330 */new $7imnH([0,6,12,18,24,30,36,44,54,66,80,96,114,136,162,194,232,278,332,394,464,540,576],[0,4,8,12,18,26,36,48,62,80,104,136,180,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),/* Table B.2.a: 16 kHz */new $7imnH([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0,4,8,12,18,26,36,48,62,80,104,134,174,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),/* Table B.8.b: 44.1 kHz */new $7imnH([0,4,8,12,16,20,24,30,36,44,52,62,74,90,110,134,162,196,238,288,342,418,576],[0,4,8,12,16,22,30,40,52,66,84,106,136,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),/* Table B.8.c: 48 kHz */new $7imnH([0,4,8,12,16,20,24,30,36,42,50,60,72,88,106,128,156,190,230,276,330,384,576],[0,4,8,12,16,22,28,38,50,64,80,100,126,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),/* Table B.8.a: 32 kHz */new $7imnH([0,4,8,12,16,20,24,30,36,44,54,66,82,102,126,156,194,240,296,364,448,550,576],[0,4,8,12,16,22,30,42,58,78,104,138,180,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),/* MPEG-2.5 11.025 kHz */new $7imnH([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0,4,8,12,18,26,36,48,62,80,104,134,174,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),/* MPEG-2.5 12 kHz */new $7imnH([0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576],[0,4,8,12,18,26,36,48,62,80,104,134,174,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]),/* MPEG-2.5 8 kHz */new $7imnH([0,12,24,36,48,60,72,88,108,132,160,192,232,280,336,400,476,566,568,570,572,574,576],[0,8,16,24,36,52,72,96,124,160,162,164,166,192],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0])];var pow20=$5dfff05939c3cc74$var$new_float(Q_MAX+Q_MAX2+1);var ipow20=$5dfff05939c3cc74$var$new_float(Q_MAX);var pow43=$5dfff05939c3cc74$var$new_float(PRECALC_SIZE);var adj43=$5dfff05939c3cc74$var$new_float(PRECALC_SIZE);this.adj43=adj43;/**
1711
+ * <PRE>
1712
+ * compute the ATH for each scalefactor band cd range: 0..96db
1713
+ *
1714
+ * Input: 3.3kHz signal 32767 amplitude (3.3kHz is where ATH is smallest =
1715
+ * -5db) longblocks: sfb=12 en0/bw=-11db max_en0 = 1.3db shortblocks: sfb=5
1716
+ * -9db 0db
1717
+ *
1718
+ * Input: 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 (repeated) longblocks: amp=1
1719
+ * sfb=12 en0/bw=-103 db max_en0 = -92db amp=32767 sfb=12 -12 db -1.4db
1720
+ *
1721
+ * Input: 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 (repeated) shortblocks: amp=1
1722
+ * sfb=5 en0/bw= -99 -86 amp=32767 sfb=5 -9 db 4db
1723
+ *
1724
+ *
1725
+ * MAX energy of largest wave at 3.3kHz = 1db AVE energy of largest wave at
1726
+ * 3.3kHz = -11db Let's take AVE: -11db = maximum signal in sfb=12. Dynamic
1727
+ * range of CD: 96db. Therefor energy of smallest audible wave in sfb=12 =
1728
+ * -11 - 96 = -107db = ATH at 3.3kHz.
1729
+ *
1730
+ * ATH formula for this wave: -5db. To adjust to LAME scaling, we need ATH =
1731
+ * ATH_formula - 103 (db) ATH = ATH * 2.5e-10 (ener)
1732
+ * </PRE>
1733
+ */function ATHmdct(gfp,f){var ath=psy.ATHformula(f,gfp);ath-=NSATHSCALE;/* modify the MDCT scaling for the ATH and convert to energy */ath=Math.pow(10.0,ath/10.0+gfp.ATHlower);return ath;}function compute_ath(gfp){var ATH_l=gfp.internal_flags.ATH.l;var ATH_psfb21=gfp.internal_flags.ATH.psfb21;var ATH_s=gfp.internal_flags.ATH.s;var ATH_psfb12=gfp.internal_flags.ATH.psfb12;var gfc=gfp.internal_flags;var samp_freq=gfp.out_samplerate;for(var sfb=0;sfb<$cPNKB.SBMAX_l;sfb++){var start=gfc.scalefac_band.l[sfb];var end=gfc.scalefac_band.l[sfb+1];ATH_l[sfb]=$5dfff05939c3cc74$var$Float.MAX_VALUE;for(var i=start;i<end;i++){var freq=i*samp_freq/1152;var ATH_f=ATHmdct(gfp,freq);/* freq in kHz */ATH_l[sfb]=Math.min(ATH_l[sfb],ATH_f);}}for(var sfb=0;sfb<$cPNKB.PSFB21;sfb++){var start=gfc.scalefac_band.psfb21[sfb];var end=gfc.scalefac_band.psfb21[sfb+1];ATH_psfb21[sfb]=$5dfff05939c3cc74$var$Float.MAX_VALUE;for(var i=start;i<end;i++){var freq=i*samp_freq/1152;var ATH_f=ATHmdct(gfp,freq);/* freq in kHz */ATH_psfb21[sfb]=Math.min(ATH_psfb21[sfb],ATH_f);}}for(var sfb=0;sfb<$cPNKB.SBMAX_s;sfb++){var start=gfc.scalefac_band.s[sfb];var end=gfc.scalefac_band.s[sfb+1];ATH_s[sfb]=$5dfff05939c3cc74$var$Float.MAX_VALUE;for(var i=start;i<end;i++){var freq=i*samp_freq/384;var ATH_f=ATHmdct(gfp,freq);/* freq in kHz */ATH_s[sfb]=Math.min(ATH_s[sfb],ATH_f);}ATH_s[sfb]*=gfc.scalefac_band.s[sfb+1]-gfc.scalefac_band.s[sfb];}for(var sfb=0;sfb<$cPNKB.PSFB12;sfb++){var start=gfc.scalefac_band.psfb12[sfb];var end=gfc.scalefac_band.psfb12[sfb+1];ATH_psfb12[sfb]=$5dfff05939c3cc74$var$Float.MAX_VALUE;for(var i=start;i<end;i++){var freq=i*samp_freq/384;var ATH_f=ATHmdct(gfp,freq);/* freq in kHz */ATH_psfb12[sfb]=Math.min(ATH_psfb12[sfb],ATH_f);}/* not sure about the following */ATH_psfb12[sfb]*=gfc.scalefac_band.s[13]-gfc.scalefac_band.s[12];}/*
1734
+ * no-ATH mode: reduce ATH to -200 dB
1735
+ */if(gfp.noATH){for(var sfb=0;sfb<$cPNKB.SBMAX_l;sfb++)ATH_l[sfb]=1E-20;for(var sfb=0;sfb<$cPNKB.PSFB21;sfb++)ATH_psfb21[sfb]=1E-20;for(var sfb=0;sfb<$cPNKB.SBMAX_s;sfb++)ATH_s[sfb]=1E-20;for(var sfb=0;sfb<$cPNKB.PSFB12;sfb++)ATH_psfb12[sfb]=1E-20;}/*
1736
+ * work in progress, don't rely on it too much
1737
+ */gfc.ATH.floor=10.*Math.log10(ATHmdct(gfp,-1));}/**
1738
+ * initialization for iteration_loop
1739
+ */this.iteration_init=function(gfp){var gfc=gfp.internal_flags;var l3_side=gfc.l3_side;var i;if(gfc.iteration_init_init==0){gfc.iteration_init_init=1;l3_side.main_data_begin=0;compute_ath(gfp);pow43[0]=0.0;for(i=1;i<PRECALC_SIZE;i++)pow43[i]=Math.pow(i,4.0/3.0);for(i=0;i<PRECALC_SIZE-1;i++)adj43[i]=i+1-Math.pow(0.5*(pow43[i]+pow43[i+1]),0.75);adj43[i]=0.5;for(i=0;i<Q_MAX;i++)ipow20[i]=Math.pow(2.0,(i-210)*-0.1875);for(i=0;i<=Q_MAX+Q_MAX2;i++)pow20[i]=Math.pow(2.0,(i-210-Q_MAX2)*0.25);tak.huffman_init(gfc);var bass,alto,treble,sfb21;i=gfp.exp_nspsytune>>2&63;if(i>=32)i-=64;bass=Math.pow(10,i/4.0/10.0);i=gfp.exp_nspsytune>>8&63;if(i>=32)i-=64;alto=Math.pow(10,i/4.0/10.0);i=gfp.exp_nspsytune>>14&63;if(i>=32)i-=64;treble=Math.pow(10,i/4.0/10.0);/*
1740
+ * to be compatible with Naoki's original code, the next 6 bits
1741
+ * define only the amount of changing treble for sfb21
1742
+ */i=gfp.exp_nspsytune>>20&63;if(i>=32)i-=64;sfb21=treble*Math.pow(10,i/4.0/10.0);for(i=0;i<$cPNKB.SBMAX_l;i++){var f;if(i<=6)f=bass;else if(i<=13)f=alto;else if(i<=20)f=treble;else f=sfb21;gfc.nsPsy.longfact[i]=f;}for(i=0;i<$cPNKB.SBMAX_s;i++){var f;if(i<=5)f=bass;else if(i<=10)f=alto;else if(i<=11)f=treble;else f=sfb21;gfc.nsPsy.shortfact[i]=f;}}};/**
1743
+ * allocate bits among 2 channels based on PE<BR>
1744
+ * mt 6/99<BR>
1745
+ * bugfixes rh 8/01: often allocated more than the allowed 4095 bits
1746
+ */this.on_pe=function(gfp,pe,targ_bits,mean_bits,gr,cbr){var gfc=gfp.internal_flags;var tbits=0,bits;var add_bits=$5dfff05939c3cc74$var$new_int(2);var ch;/* allocate targ_bits for granule */var mb=new $lL4Le(tbits);var extra_bits=rv.ResvMaxBits(gfp,mean_bits,mb,cbr);tbits=mb.bits;/* maximum allowed bits for this granule */var max_bits=tbits+extra_bits;if(max_bits>$4SDnr.MAX_BITS_PER_GRANULE)// hard limit per granule
1747
+ max_bits=$4SDnr.MAX_BITS_PER_GRANULE;for(bits=0,ch=0;ch<gfc.channels_out;++ch){/******************************************************************
1748
+ * allocate bits for each channel
1749
+ ******************************************************************/targ_bits[ch]=Math.min($4SDnr.MAX_BITS_PER_CHANNEL,tbits/gfc.channels_out);add_bits[ch]=0|targ_bits[ch]*pe[gr][ch]/700.0-targ_bits[ch];/* at most increase bits by 1.5*average */if(add_bits[ch]>mean_bits*3/4)add_bits[ch]=mean_bits*3/4;if(add_bits[ch]<0)add_bits[ch]=0;if(add_bits[ch]+targ_bits[ch]>$4SDnr.MAX_BITS_PER_CHANNEL)add_bits[ch]=Math.max(0,$4SDnr.MAX_BITS_PER_CHANNEL-targ_bits[ch]);bits+=add_bits[ch];}if(bits>extra_bits)for(ch=0;ch<gfc.channels_out;++ch)add_bits[ch]=extra_bits*add_bits[ch]/bits;for(ch=0;ch<gfc.channels_out;++ch){targ_bits[ch]+=add_bits[ch];extra_bits-=add_bits[ch];}for(bits=0,ch=0;ch<gfc.channels_out;++ch)bits+=targ_bits[ch];if(bits>$4SDnr.MAX_BITS_PER_GRANULE){var sum=0;for(ch=0;ch<gfc.channels_out;++ch){targ_bits[ch]*=$4SDnr.MAX_BITS_PER_GRANULE;targ_bits[ch]/=bits;sum+=targ_bits[ch];}$5dfff05939c3cc74$var$assert(sum<=$4SDnr.MAX_BITS_PER_GRANULE);}return max_bits;};this.reduce_side=function(targ_bits,ms_ener_ratio,mean_bits,max_bits){$5dfff05939c3cc74$var$assert(max_bits<=$4SDnr.MAX_BITS_PER_GRANULE);$5dfff05939c3cc74$var$assert(targ_bits[0]+targ_bits[1]<=$4SDnr.MAX_BITS_PER_GRANULE);/*
1750
+ * ms_ener_ratio = 0: allocate 66/33 mid/side fac=.33 ms_ener_ratio =.5:
1751
+ * allocate 50/50 mid/side fac= 0
1752
+ */ /* 75/25 split is fac=.5 */var fac=.33*(.5-ms_ener_ratio)/.5;if(fac<0)fac=0;if(fac>.5)fac=.5;/* number of bits to move from side channel to mid channel */ /* move_bits = fac*targ_bits[1]; */var move_bits=0|fac*.5*(targ_bits[0]+targ_bits[1]);if(move_bits>$4SDnr.MAX_BITS_PER_CHANNEL-targ_bits[0])move_bits=$4SDnr.MAX_BITS_PER_CHANNEL-targ_bits[0];if(move_bits<0)move_bits=0;if(targ_bits[1]>=125){/* dont reduce side channel below 125 bits */if(targ_bits[1]-move_bits>125){/* if mid channel already has 2x more than average, dont bother */ /* mean_bits = bits per granule (for both channels) */if(targ_bits[0]<mean_bits)targ_bits[0]+=move_bits;targ_bits[1]-=move_bits;}else {targ_bits[0]+=targ_bits[1]-125;targ_bits[1]=125;}}move_bits=targ_bits[0]+targ_bits[1];if(move_bits>max_bits){targ_bits[0]=max_bits*targ_bits[0]/move_bits;targ_bits[1]=max_bits*targ_bits[1]/move_bits;}$5dfff05939c3cc74$var$assert(targ_bits[0]<=$4SDnr.MAX_BITS_PER_CHANNEL);$5dfff05939c3cc74$var$assert(targ_bits[1]<=$4SDnr.MAX_BITS_PER_CHANNEL);$5dfff05939c3cc74$var$assert(targ_bits[0]+targ_bits[1]<=$4SDnr.MAX_BITS_PER_GRANULE);};/**
1753
+ * Robert Hegemann 2001-04-27:
1754
+ * this adjusts the ATH, keeping the original noise floor
1755
+ * affects the higher frequencies more than the lower ones
1756
+ */this.athAdjust=function(a,x,athFloor){/*
1757
+ * work in progress
1758
+ */var o=90.30873362;var p=94.82444863;var u=$5dfff05939c3cc74$var$Util.FAST_LOG10_X(x,10.0);var v=a*a;var w=0.0;u-=athFloor;/* undo scaling */if(v>1E-20)w=1.+$5dfff05939c3cc74$var$Util.FAST_LOG10_X(v,10.0/o);if(w<0)w=0.;u*=w;u+=athFloor+o-p;/* redo scaling */return Math.pow(10.,0.1*u);};/**
1759
+ * Calculate the allowed distortion for each scalefactor band, as determined
1760
+ * by the psychoacoustic model. xmin(sb) = ratio(sb) * en(sb) / bw(sb)
1761
+ *
1762
+ * returns number of sfb's with energy > ATH
1763
+ */this.calc_xmin=function(gfp,ratio,cod_info,pxmin){var pxminPos=0;var gfc=gfp.internal_flags;var gsfb,j=0,ath_over=0;var ATH=gfc.ATH;var xr=cod_info.xr;var enable_athaa_fix=gfp.VBR==$5dfff05939c3cc74$var$VbrMode.vbr_mtrh?1:0;var masking_lower=gfc.masking_lower;if(gfp.VBR==$5dfff05939c3cc74$var$VbrMode.vbr_mtrh||gfp.VBR==$5dfff05939c3cc74$var$VbrMode.vbr_mt)/* was already done in PSY-Model */masking_lower=1.0;for(gsfb=0;gsfb<cod_info.psy_lmax;gsfb++){var en0,xmin;var rh1,rh2;var width,l;if(gfp.VBR==$5dfff05939c3cc74$var$VbrMode.vbr_rh||gfp.VBR==$5dfff05939c3cc74$var$VbrMode.vbr_mtrh)xmin=athAdjust(ATH.adjust,ATH.l[gsfb],ATH.floor);else xmin=ATH.adjust*ATH.l[gsfb];width=cod_info.width[gsfb];rh1=xmin/width;rh2=DBL_EPSILON;l=width>>1;en0=0.0;do{var xa,xb;xa=xr[j]*xr[j];en0+=xa;rh2+=xa<rh1?xa:rh1;j++;xb=xr[j]*xr[j];en0+=xb;rh2+=xb<rh1?xb:rh1;j++;}while(--l>0);if(en0>xmin)ath_over++;if(gsfb==$cPNKB.SBPSY_l){var x=xmin*gfc.nsPsy.longfact[gsfb];if(rh2<x)rh2=x;}if(enable_athaa_fix!=0)xmin=rh2;if(!gfp.ATHonly){var e=ratio.en.l[gsfb];if(e>0.0){var x;x=en0*ratio.thm.l[gsfb]*masking_lower/e;if(enable_athaa_fix!=0)x*=gfc.nsPsy.longfact[gsfb];if(xmin<x)xmin=x;}}if(enable_athaa_fix!=0)pxmin[pxminPos++]=xmin;else pxmin[pxminPos++]=xmin*gfc.nsPsy.longfact[gsfb];}/* end of long block loop */ /* use this function to determine the highest non-zero coeff */var max_nonzero=575;if(cod_info.block_type!=$cPNKB.SHORT_TYPE){// NORM, START or STOP type, but not SHORT
1764
+ var k=576;while(k--!=0&&BitStream.EQ(xr[k],0))max_nonzero=k;}cod_info.max_nonzero_coeff=max_nonzero;for(var sfb=cod_info.sfb_smin;gsfb<cod_info.psymax;sfb++,gsfb+=3){var width,b;var tmpATH;if(gfp.VBR==$5dfff05939c3cc74$var$VbrMode.vbr_rh||gfp.VBR==$5dfff05939c3cc74$var$VbrMode.vbr_mtrh)tmpATH=athAdjust(ATH.adjust,ATH.s[sfb],ATH.floor);else tmpATH=ATH.adjust*ATH.s[sfb];width=cod_info.width[gsfb];for(b=0;b<3;b++){var en0=0.0,xmin;var rh1,rh2;var l=width>>1;rh1=tmpATH/width;rh2=DBL_EPSILON;do{var xa,xb;xa=xr[j]*xr[j];en0+=xa;rh2+=xa<rh1?xa:rh1;j++;xb=xr[j]*xr[j];en0+=xb;rh2+=xb<rh1?xb:rh1;j++;}while(--l>0);if(en0>tmpATH)ath_over++;if(sfb==$cPNKB.SBPSY_s){var x=tmpATH*gfc.nsPsy.shortfact[sfb];if(rh2<x)rh2=x;}if(enable_athaa_fix!=0)xmin=rh2;else xmin=tmpATH;if(!gfp.ATHonly&&!gfp.ATHshort){var e=ratio.en.s[sfb][b];if(e>0.0){var x;x=en0*ratio.thm.s[sfb][b]*masking_lower/e;if(enable_athaa_fix!=0)x*=gfc.nsPsy.shortfact[sfb];if(xmin<x)xmin=x;}}if(enable_athaa_fix!=0)pxmin[pxminPos++]=xmin;else pxmin[pxminPos++]=xmin*gfc.nsPsy.shortfact[sfb];}/* b */if(gfp.useTemporal){if(pxmin[pxminPos-3]>pxmin[pxminPos-3+1])pxmin[pxminPos-3+1]+=(pxmin[pxminPos-3]-pxmin[pxminPos-3+1])*gfc.decay;if(pxmin[pxminPos-3+1]>pxmin[pxminPos-3+2])pxmin[pxminPos-3+2]+=(pxmin[pxminPos-3+1]-pxmin[pxminPos-3+2])*gfc.decay;}}/* end of short block sfb loop */return ath_over;};function StartLine(j){this.s=j;}this.calc_noise_core=function(cod_info,startline,l,step){var noise=0;var j=startline.s;var ix=cod_info.l3_enc;if(j>cod_info.count1)while(l--!=0){var temp;temp=cod_info.xr[j];j++;noise+=temp*temp;temp=cod_info.xr[j];j++;noise+=temp*temp;}else if(j>cod_info.big_values){var ix01=$5dfff05939c3cc74$var$new_float(2);ix01[0]=0;ix01[1]=step;while(l--!=0){var temp;temp=Math.abs(cod_info.xr[j])-ix01[ix[j]];j++;noise+=temp*temp;temp=Math.abs(cod_info.xr[j])-ix01[ix[j]];j++;noise+=temp*temp;}}else while(l--!=0){var temp;temp=Math.abs(cod_info.xr[j])-pow43[ix[j]]*step;j++;noise+=temp*temp;temp=Math.abs(cod_info.xr[j])-pow43[ix[j]]*step;j++;noise+=temp*temp;}startline.s=j;return noise;};/**
1765
+ * <PRE>
1766
+ * -oo dB => -1.00
1767
+ * - 6 dB => -0.97
1768
+ * - 3 dB => -0.80
1769
+ * - 2 dB => -0.64
1770
+ * - 1 dB => -0.38
1771
+ * 0 dB => 0.00
1772
+ * + 1 dB => +0.49
1773
+ * + 2 dB => +1.06
1774
+ * + 3 dB => +1.68
1775
+ * + 6 dB => +3.69
1776
+ * +10 dB => +6.45
1777
+ * </PRE>
1778
+ */this.calc_noise=function(cod_info,l3_xmin,distort,res,prev_noise){var distortPos=0;var l3_xminPos=0;var sfb,l,over=0;var over_noise_db=0;/* 0 dB relative to masking */var tot_noise_db=0;/* -200 dB relative to masking */var max_noise=-20;var j=0;var scalefac=cod_info.scalefac;var scalefacPos=0;res.over_SSD=0;for(sfb=0;sfb<cod_info.psymax;sfb++){var s=cod_info.global_gain-(scalefac[scalefacPos++]+(cod_info.preflag!=0?pretab[sfb]:0)<<cod_info.scalefac_scale+1)-cod_info.subblock_gain[cod_info.window[sfb]]*8;var noise=0.0;if(prev_noise!=null&&prev_noise.step[sfb]==s){/* use previously computed values */noise=prev_noise.noise[sfb];j+=cod_info.width[sfb];distort[distortPos++]=noise/l3_xmin[l3_xminPos++];noise=prev_noise.noise_log[sfb];}else {var step=POW20(s);l=cod_info.width[sfb]>>1;if(j+cod_info.width[sfb]>cod_info.max_nonzero_coeff){var usefullsize;usefullsize=cod_info.max_nonzero_coeff-j+1;if(usefullsize>0)l=usefullsize>>1;else l=0;}var sl=new StartLine(j);noise=this.calc_noise_core(cod_info,sl,l,step);j=sl.s;if(prev_noise!=null){/* save noise values */prev_noise.step[sfb]=s;prev_noise.noise[sfb]=noise;}noise=distort[distortPos++]=noise/l3_xmin[l3_xminPos++];/* multiplying here is adding in dB, but can overflow */noise=$5dfff05939c3cc74$var$Util.FAST_LOG10(Math.max(noise,1E-20));if(prev_noise!=null)/* save noise values */prev_noise.noise_log[sfb]=noise;}if(prev_noise!=null)/* save noise values */prev_noise.global_gain=cod_info.global_gain;tot_noise_db+=noise;if(noise>0.0){var tmp;tmp=Math.max(0|noise*10+.5,1);res.over_SSD+=tmp*tmp;over++;/* multiplying here is adding in dB -but can overflow */ /* over_noise *= noise; */over_noise_db+=noise;}max_noise=Math.max(max_noise,noise);}res.over_count=over;res.tot_noise=tot_noise_db;res.over_noise=over_noise_db;res.max_noise=max_noise;return over;};/**
1779
+ * updates plotting data
1780
+ *
1781
+ * Mark Taylor 2000-??-??
1782
+ *
1783
+ * Robert Hegemann: moved noise/distortion calc into it
1784
+ */this.set_pinfo=function(gfp,cod_info,ratio,gr,ch){var gfc=gfp.internal_flags;var sfb,sfb2;var l;var en0,en1;var ifqstep=cod_info.scalefac_scale==0?.5:1.0;var scalefac=cod_info.scalefac;var l3_xmin=$5dfff05939c3cc74$var$new_float(L3Side.SFBMAX);var xfsf=$5dfff05939c3cc74$var$new_float(L3Side.SFBMAX);var noise=new CalcNoiseResult();calc_xmin(gfp,ratio,cod_info,l3_xmin);calc_noise(cod_info,l3_xmin,xfsf,noise,null);var j=0;sfb2=cod_info.sfb_lmax;if(cod_info.block_type!=$cPNKB.SHORT_TYPE&&0==cod_info.mixed_block_flag)sfb2=22;for(sfb=0;sfb<sfb2;sfb++){var start=gfc.scalefac_band.l[sfb];var end=gfc.scalefac_band.l[sfb+1];var bw=end-start;for(en0=0.0;j<end;j++)en0+=cod_info.xr[j]*cod_info.xr[j];en0/=bw;/* convert to MDCT units */ /* scaling so it shows up on FFT plot */en1=1e15;gfc.pinfo.en[gr][ch][sfb]=en1*en0;gfc.pinfo.xfsf[gr][ch][sfb]=en1*l3_xmin[sfb]*xfsf[sfb]/bw;if(ratio.en.l[sfb]>0&&!gfp.ATHonly)en0=en0/ratio.en.l[sfb];else en0=0.0;gfc.pinfo.thr[gr][ch][sfb]=en1*Math.max(en0*ratio.thm.l[sfb],gfc.ATH.l[sfb]);/* there is no scalefactor bands >= SBPSY_l */gfc.pinfo.LAMEsfb[gr][ch][sfb]=0;if(cod_info.preflag!=0&&sfb>=11)gfc.pinfo.LAMEsfb[gr][ch][sfb]=-ifqstep*pretab[sfb];if(sfb<$cPNKB.SBPSY_l){/* scfsi should be decoded by caller side */$5dfff05939c3cc74$var$assert(scalefac[sfb]>=0);gfc.pinfo.LAMEsfb[gr][ch][sfb]-=ifqstep*scalefac[sfb];}}/* for sfb */if(cod_info.block_type==$cPNKB.SHORT_TYPE){sfb2=sfb;for(sfb=cod_info.sfb_smin;sfb<$cPNKB.SBMAX_s;sfb++){var start=gfc.scalefac_band.s[sfb];var end=gfc.scalefac_band.s[sfb+1];var bw=end-start;for(var i=0;i<3;i++){for(en0=0.0,l=start;l<end;l++){en0+=cod_info.xr[j]*cod_info.xr[j];j++;}en0=Math.max(en0/bw,1e-20);/* convert to MDCT units */ /* scaling so it shows up on FFT plot */en1=1e15;gfc.pinfo.en_s[gr][ch][3*sfb+i]=en1*en0;gfc.pinfo.xfsf_s[gr][ch][3*sfb+i]=en1*l3_xmin[sfb2]*xfsf[sfb2]/bw;if(ratio.en.s[sfb][i]>0)en0=en0/ratio.en.s[sfb][i];else en0=0.0;if(gfp.ATHonly||gfp.ATHshort)en0=0;gfc.pinfo.thr_s[gr][ch][3*sfb+i]=en1*Math.max(en0*ratio.thm.s[sfb][i],gfc.ATH.s[sfb]);/* there is no scalefactor bands >= SBPSY_s */gfc.pinfo.LAMEsfb_s[gr][ch][3*sfb+i]=-2*cod_info.subblock_gain[i];if(sfb<$cPNKB.SBPSY_s)gfc.pinfo.LAMEsfb_s[gr][ch][3*sfb+i]-=ifqstep*scalefac[sfb2];sfb2++;}}}/* block type short */gfc.pinfo.LAMEqss[gr][ch]=cod_info.global_gain;gfc.pinfo.LAMEmainbits[gr][ch]=cod_info.part2_3_length+cod_info.part2_length;gfc.pinfo.LAMEsfbits[gr][ch]=cod_info.part2_length;gfc.pinfo.over[gr][ch]=noise.over_count;gfc.pinfo.max_noise[gr][ch]=noise.max_noise*10.0;gfc.pinfo.over_noise[gr][ch]=noise.over_noise*10.0;gfc.pinfo.tot_noise[gr][ch]=noise.tot_noise*10.0;gfc.pinfo.over_SSD[gr][ch]=noise.over_SSD;};}module.exports=$5dfff05939c3cc74$var$QuantizePVT;});var $dd7ee3788d91dcb8$exports={};$parcel$export($dd7ee3788d91dcb8$exports,"Mp3Encoder",()=>$dd7ee3788d91dcb8$export$9ca5d136ebf61cf2,v=>$dd7ee3788d91dcb8$export$9ca5d136ebf61cf2=v);$parcel$export($dd7ee3788d91dcb8$exports,"WavHeader",()=>$dd7ee3788d91dcb8$export$cb948f2d6837f136,v=>$dd7ee3788d91dcb8$export$cb948f2d6837f136=v);var $dd7ee3788d91dcb8$export$9ca5d136ebf61cf2;var $dd7ee3788d91dcb8$export$cb948f2d6837f136;var $3YDN3=parcelRequire("3YDN3");$3YDN3.System;$3YDN3.VbrMode;$3YDN3.Float;$3YDN3.ShortBlock;$3YDN3.Util;$3YDN3.Arrays;$3YDN3.new_array_n;var $dd7ee3788d91dcb8$var$new_byte=$3YDN3.new_byte;$3YDN3.new_double;$3YDN3.new_float;$3YDN3.new_float_n;$3YDN3.new_int;$3YDN3.new_int_n;var $dd7ee3788d91dcb8$var$assert=$3YDN3.assert;var $kk1yk=parcelRequire("kk1yk");var $7960aab77e945546$exports={};var $3YDN3=parcelRequire("3YDN3");$3YDN3.System;var $7960aab77e945546$var$VbrMode=$3YDN3.VbrMode;$3YDN3.Float;$3YDN3.ShortBlock;$3YDN3.Util;$3YDN3.Arrays;$3YDN3.new_array_n;$3YDN3.new_byte;$3YDN3.new_double;$3YDN3.new_float;$3YDN3.new_float_n;$3YDN3.new_int;$3YDN3.new_int_n;$3YDN3.assert;function $7960aab77e945546$var$Presets(){var Lame=parcelRequire("kk1yk");function VBRPresets(qual,comp,compS,y,shThreshold,shThresholdS,adj,adjShort,lower,curve,sens,inter,joint,mod,fix){this.vbr_q=qual;this.quant_comp=comp;this.quant_comp_s=compS;this.expY=y;this.st_lrm=shThreshold;this.st_s=shThresholdS;this.masking_adj=adj;this.masking_adj_short=adjShort;this.ath_lower=lower;this.ath_curve=curve;this.ath_sensitivity=sens;this.interch=inter;this.safejoint=joint;this.sfb21mod=mod;this.msfix=fix;}function ABRPresets(kbps,comp,compS,joint,fix,shThreshold,shThresholdS,bass,sc,mask,lower,curve,interCh,sfScale){this.quant_comp=comp;this.quant_comp_s=compS;this.safejoint=joint;this.nsmsfix=fix;this.st_lrm=shThreshold;this.st_s=shThresholdS;this.nsbass=bass;this.scale=sc;this.masking_adj=mask;this.ath_lower=lower;this.ath_curve=curve;this.interch=interCh;this.sfscale=sfScale;}var lame;this.setModules=function(_lame){lame=_lame;};/**
1785
+ * <PRE>
1786
+ * Switch mappings for VBR mode VBR_RH
1787
+ * vbr_q qcomp_l qcomp_s expY st_lrm st_s mask adj_l adj_s ath_lower ath_curve ath_sens interChR safejoint sfb21mod msfix
1788
+ * </PRE>
1789
+ */var vbr_old_switch_map=[new VBRPresets(0,9,9,0,5.20,125.0,-4.2,-6.3,4.8,1,0,0,2,21,0.97),new VBRPresets(1,9,9,0,5.30,125.0,-3.6,-5.6,4.5,1.5,0,0,2,21,1.35),new VBRPresets(2,9,9,0,5.60,125.0,-2.2,-3.5,2.8,2,0,0,2,21,1.49),new VBRPresets(3,9,9,1,5.80,130.0,-1.8,-2.8,2.6,3,-4,0,2,20,1.64),new VBRPresets(4,9,9,1,6.00,135.0,-0.7,-1.1,1.1,3.5,-8,0,2,0,1.79),new VBRPresets(5,9,9,1,6.40,140.0,0.5,0.4,-7.5,4,-12,0.0002,0,0,1.95),new VBRPresets(6,9,9,1,6.60,145.0,0.67,0.65,-14.7,6.5,-19,0.0004,0,0,2.30),new VBRPresets(7,9,9,1,6.60,145.0,0.8,0.75,-19.7,8,-22,0.0006,0,0,2.70),new VBRPresets(8,9,9,1,6.60,145.0,1.2,1.15,-27.5,10,-23,0.0007,0,0,0),new VBRPresets(9,9,9,1,6.60,145.0,1.6,1.6,-36,11,-25,0.0008,0,0,0),new VBRPresets(10,9,9,1,6.60,145.0,2.0,2.0,-36,12,-25,0.0008,0,0,0)];/**
1790
+ * <PRE>
1791
+ * vbr_q qcomp_l qcomp_s expY st_lrm st_s mask adj_l adj_s ath_lower ath_curve ath_sens interChR safejoint sfb21mod msfix
1792
+ * </PRE>
1793
+ */var vbr_psy_switch_map=[new VBRPresets(0,9,9,0,4.20,25.0,-7,-4,7.5,1,0,0,2,26,0.97),new VBRPresets(1,9,9,0,4.20,25.0,-5.6,-3.6,4.5,1.5,0,0,2,21,1.35),new VBRPresets(2,9,9,0,4.20,25.0,-4.4,-1.8,2,2,0,0,2,18,1.49),new VBRPresets(3,9,9,1,4.20,25.0,-3.4,-1.25,1.1,3,-4,0,2,15,1.64),new VBRPresets(4,9,9,1,4.20,25.0,-2.2,0.1,0,3.5,-8,0,2,0,1.79),new VBRPresets(5,9,9,1,4.20,25.0,-1,1.65,-7.7,4,-12,0.0002,0,0,1.95),new VBRPresets(6,9,9,1,4.20,25.0,-0,2.47,-7.7,6.5,-19,0.0004,0,0,2),new VBRPresets(7,9,9,1,4.20,25.0,0.5,2.0,-14.5,8,-22,0.0006,0,0,2),new VBRPresets(8,9,9,1,4.20,25.0,1.0,2.4,-22,10,-23,0.0007,0,0,2),new VBRPresets(9,9,9,1,4.20,25.0,1.5,2.95,-30,11,-25,0.0008,0,0,2),new VBRPresets(10,9,9,1,4.20,25.0,2.0,2.95,-36,12,-30,0.0008,0,0,2)];function apply_vbr_preset(gfp,a,enforce){var vbr_preset=gfp.VBR==$7960aab77e945546$var$VbrMode.vbr_rh?vbr_old_switch_map:vbr_psy_switch_map;var x=gfp.VBR_q_frac;var p=vbr_preset[a];var q=vbr_preset[a+1];var set=p;// NOOP(vbr_q);
1794
+ // NOOP(quant_comp);
1795
+ // NOOP(quant_comp_s);
1796
+ // NOOP(expY);
1797
+ p.st_lrm=p.st_lrm+x*(q.st_lrm-p.st_lrm);// LERP(st_lrm);
1798
+ p.st_s=p.st_s+x*(q.st_s-p.st_s);// LERP(st_s);
1799
+ p.masking_adj=p.masking_adj+x*(q.masking_adj-p.masking_adj);// LERP(masking_adj);
1800
+ p.masking_adj_short=p.masking_adj_short+x*(q.masking_adj_short-p.masking_adj_short);// LERP(masking_adj_short);
1801
+ p.ath_lower=p.ath_lower+x*(q.ath_lower-p.ath_lower);// LERP(ath_lower);
1802
+ p.ath_curve=p.ath_curve+x*(q.ath_curve-p.ath_curve);// LERP(ath_curve);
1803
+ p.ath_sensitivity=p.ath_sensitivity+x*(q.ath_sensitivity-p.ath_sensitivity);// LERP(ath_sensitivity);
1804
+ p.interch=p.interch+x*(q.interch-p.interch);// LERP(interch);
1805
+ // NOOP(safejoint);
1806
+ // NOOP(sfb21mod);
1807
+ p.msfix=p.msfix+x*(q.msfix-p.msfix);// LERP(msfix);
1808
+ lame_set_VBR_q(gfp,set.vbr_q);if(enforce!=0)gfp.quant_comp=set.quant_comp;else if(!(Math.abs(gfp.quant_comp- -1)>0))gfp.quant_comp=set.quant_comp;// SET_OPTION(quant_comp, set.quant_comp, -1);
1809
+ if(enforce!=0)gfp.quant_comp_short=set.quant_comp_s;else if(!(Math.abs(gfp.quant_comp_short- -1)>0))gfp.quant_comp_short=set.quant_comp_s;// SET_OPTION(quant_comp_short, set.quant_comp_s, -1);
1810
+ if(set.expY!=0)gfp.experimentalY=set.expY!=0;if(enforce!=0)gfp.internal_flags.nsPsy.attackthre=set.st_lrm;else if(!(Math.abs(gfp.internal_flags.nsPsy.attackthre- -1)>0))gfp.internal_flags.nsPsy.attackthre=set.st_lrm;// SET_OPTION(short_threshold_lrm, set.st_lrm, -1);
1811
+ if(enforce!=0)gfp.internal_flags.nsPsy.attackthre_s=set.st_s;else if(!(Math.abs(gfp.internal_flags.nsPsy.attackthre_s- -1)>0))gfp.internal_flags.nsPsy.attackthre_s=set.st_s;// SET_OPTION(short_threshold_s, set.st_s, -1);
1812
+ if(enforce!=0)gfp.maskingadjust=set.masking_adj;else if(!(Math.abs(gfp.maskingadjust-0)>0))gfp.maskingadjust=set.masking_adj;// SET_OPTION(maskingadjust, set.masking_adj, 0);
1813
+ if(enforce!=0)gfp.maskingadjust_short=set.masking_adj_short;else if(!(Math.abs(gfp.maskingadjust_short-0)>0))gfp.maskingadjust_short=set.masking_adj_short;// SET_OPTION(maskingadjust_short, set.masking_adj_short, 0);
1814
+ if(enforce!=0)gfp.ATHlower=-set.ath_lower/10.0;else if(!(Math.abs(-gfp.ATHlower*10.0-0)>0))gfp.ATHlower=-set.ath_lower/10.0;// SET_OPTION(ATHlower, set.ath_lower, 0);
1815
+ if(enforce!=0)gfp.ATHcurve=set.ath_curve;else if(!(Math.abs(gfp.ATHcurve- -1)>0))gfp.ATHcurve=set.ath_curve;// SET_OPTION(ATHcurve, set.ath_curve, -1);
1816
+ if(enforce!=0)gfp.athaa_sensitivity=set.ath_sensitivity;else if(!(Math.abs(gfp.athaa_sensitivity- -1)>0))gfp.athaa_sensitivity=set.ath_sensitivity;// SET_OPTION(athaa_sensitivity, set.ath_sensitivity, 0);
1817
+ if(set.interch>0){if(enforce!=0)gfp.interChRatio=set.interch;else if(!(Math.abs(gfp.interChRatio- -1)>0))gfp.interChRatio=set.interch;// SET_OPTION(interChRatio, set.interch, -1);
1818
+ }/* parameters for which there is no proper set/get interface */if(set.safejoint>0)gfp.exp_nspsytune=gfp.exp_nspsytune|set.safejoint;if(set.sfb21mod>0)gfp.exp_nspsytune=gfp.exp_nspsytune|set.sfb21mod<<20;if(enforce!=0)gfp.msfix=set.msfix;else if(!(Math.abs(gfp.msfix- -1)>0))gfp.msfix=set.msfix;// SET_OPTION(msfix, set.msfix, -1);
1819
+ if(enforce==0){gfp.VBR_q=a;gfp.VBR_q_frac=x;}}/**
1820
+ * <PRE>
1821
+ * Switch mappings for ABR mode
1822
+ *
1823
+ * kbps quant q_s safejoint nsmsfix st_lrm st_s ns-bass scale msk ath_lwr ath_curve interch , sfscale
1824
+ * </PRE>
1825
+ */var abr_switch_map=[new ABRPresets(8,9,9,0,0,6.60,145,0,0.95,0,-30,11,0.0012,1),/* 8, impossible to use in stereo */new ABRPresets(16,9,9,0,0,6.60,145,0,0.95,0,-25,11,0.0010,1),/* 16 */new ABRPresets(24,9,9,0,0,6.60,145,0,0.95,0,-20,11,0.0010,1),/* 24 */new ABRPresets(32,9,9,0,0,6.60,145,0,0.95,0,-15,11,0.0010,1),/* 32 */new ABRPresets(40,9,9,0,0,6.60,145,0,0.95,0,-10,11,0.0009,1),/* 40 */new ABRPresets(48,9,9,0,0,6.60,145,0,0.95,0,-10,11,0.0009,1),/* 48 */new ABRPresets(56,9,9,0,0,6.60,145,0,0.95,0,-6,11,0.0008,1),/* 56 */new ABRPresets(64,9,9,0,0,6.60,145,0,0.95,0,-2,11,0.0008,1),/* 64 */new ABRPresets(80,9,9,0,0,6.60,145,0,0.95,0,.0,8,0.0007,1),/* 80 */new ABRPresets(96,9,9,0,2.50,6.60,145,0,0.95,0,1.0,5.5,0.0006,1),/* 96 */new ABRPresets(112,9,9,0,2.25,6.60,145,0,0.95,0,2.0,4.5,0.0005,1),/* 112 */new ABRPresets(128,9,9,0,1.95,6.40,140,0,0.95,0,3.0,4,0.0002,1),/* 128 */new ABRPresets(160,9,9,1,1.79,6.00,135,0,0.95,-2,5.0,3.5,0,1),/* 160 */new ABRPresets(192,9,9,1,1.49,5.60,125,0,0.97,-4,7.0,3,0,0),/* 192 */new ABRPresets(224,9,9,1,1.25,5.20,125,0,0.98,-6,9.0,2,0,0),/* 224 */new ABRPresets(256,9,9,1,0.97,5.20,125,0,1.00,-8,10.0,1,0,0),/* 256 */new ABRPresets(320,9,9,1,0.90,5.20,125,0,1.00,-10,12.0,0,0,0)];function apply_abr_preset(gfp,preset,enforce){/* Variables for the ABR stuff */var actual_bitrate=preset;var r=lame.nearestBitrateFullIndex(preset);gfp.VBR=$7960aab77e945546$var$VbrMode.vbr_abr;gfp.VBR_mean_bitrate_kbps=actual_bitrate;gfp.VBR_mean_bitrate_kbps=Math.min(gfp.VBR_mean_bitrate_kbps,320);gfp.VBR_mean_bitrate_kbps=Math.max(gfp.VBR_mean_bitrate_kbps,8);gfp.brate=gfp.VBR_mean_bitrate_kbps;if(gfp.VBR_mean_bitrate_kbps>320)gfp.disable_reservoir=true;/* parameters for which there is no proper set/get interface */if(abr_switch_map[r].safejoint>0)gfp.exp_nspsytune=gfp.exp_nspsytune|2;/* safejoint */if(abr_switch_map[r].sfscale>0)gfp.internal_flags.noise_shaping=2;/* ns-bass tweaks */if(Math.abs(abr_switch_map[r].nsbass)>0){var k=int(abr_switch_map[r].nsbass*4);if(k<0)k+=64;gfp.exp_nspsytune=gfp.exp_nspsytune|k<<2;}if(enforce!=0)gfp.quant_comp=abr_switch_map[r].quant_comp;else if(!(Math.abs(gfp.quant_comp- -1)>0))gfp.quant_comp=abr_switch_map[r].quant_comp;// SET_OPTION(quant_comp, abr_switch_map[r].quant_comp, -1);
1826
+ if(enforce!=0)gfp.quant_comp_short=abr_switch_map[r].quant_comp_s;else if(!(Math.abs(gfp.quant_comp_short- -1)>0))gfp.quant_comp_short=abr_switch_map[r].quant_comp_s;// SET_OPTION(quant_comp_short, abr_switch_map[r].quant_comp_s, -1);
1827
+ if(enforce!=0)gfp.msfix=abr_switch_map[r].nsmsfix;else if(!(Math.abs(gfp.msfix- -1)>0))gfp.msfix=abr_switch_map[r].nsmsfix;// SET_OPTION(msfix, abr_switch_map[r].nsmsfix, -1);
1828
+ if(enforce!=0)gfp.internal_flags.nsPsy.attackthre=abr_switch_map[r].st_lrm;else if(!(Math.abs(gfp.internal_flags.nsPsy.attackthre- -1)>0))gfp.internal_flags.nsPsy.attackthre=abr_switch_map[r].st_lrm;// SET_OPTION(short_threshold_lrm, abr_switch_map[r].st_lrm, -1);
1829
+ if(enforce!=0)gfp.internal_flags.nsPsy.attackthre_s=abr_switch_map[r].st_s;else if(!(Math.abs(gfp.internal_flags.nsPsy.attackthre_s- -1)>0))gfp.internal_flags.nsPsy.attackthre_s=abr_switch_map[r].st_s;// SET_OPTION(short_threshold_s, abr_switch_map[r].st_s, -1);
1830
+ /*
1831
+ * ABR seems to have big problems with clipping, especially at low
1832
+ * bitrates
1833
+ */ /*
1834
+ * so we compensate for that here by using a scale value depending on
1835
+ * bitrate
1836
+ */if(enforce!=0)gfp.scale=abr_switch_map[r].scale;else if(!(Math.abs(gfp.scale- -1)>0))gfp.scale=abr_switch_map[r].scale;// SET_OPTION(scale, abr_switch_map[r].scale, -1);
1837
+ if(enforce!=0)gfp.maskingadjust=abr_switch_map[r].masking_adj;else if(!(Math.abs(gfp.maskingadjust-0)>0))gfp.maskingadjust=abr_switch_map[r].masking_adj;// SET_OPTION(maskingadjust, abr_switch_map[r].masking_adj, 0);
1838
+ if(abr_switch_map[r].masking_adj>0){if(enforce!=0)gfp.maskingadjust_short=abr_switch_map[r].masking_adj*.9;else if(!(Math.abs(gfp.maskingadjust_short-0)>0))gfp.maskingadjust_short=abr_switch_map[r].masking_adj*.9;// SET_OPTION(maskingadjust_short, abr_switch_map[r].masking_adj *
1839
+ // .9, 0);
1840
+ }else {if(enforce!=0)gfp.maskingadjust_short=abr_switch_map[r].masking_adj*1.1;else if(!(Math.abs(gfp.maskingadjust_short-0)>0))gfp.maskingadjust_short=abr_switch_map[r].masking_adj*1.1;// SET_OPTION(maskingadjust_short, abr_switch_map[r].masking_adj *
1841
+ // 1.1, 0);
1842
+ }if(enforce!=0)gfp.ATHlower=-abr_switch_map[r].ath_lower/10.;else if(!(Math.abs(-gfp.ATHlower*10.-0)>0))gfp.ATHlower=-abr_switch_map[r].ath_lower/10.;// SET_OPTION(ATHlower, abr_switch_map[r].ath_lower, 0);
1843
+ if(enforce!=0)gfp.ATHcurve=abr_switch_map[r].ath_curve;else if(!(Math.abs(gfp.ATHcurve- -1)>0))gfp.ATHcurve=abr_switch_map[r].ath_curve;// SET_OPTION(ATHcurve, abr_switch_map[r].ath_curve, -1);
1844
+ if(enforce!=0)gfp.interChRatio=abr_switch_map[r].interch;else if(!(Math.abs(gfp.interChRatio- -1)>0))gfp.interChRatio=abr_switch_map[r].interch;// SET_OPTION(interChRatio, abr_switch_map[r].interch, -1);
1845
+ return preset;}this.apply_preset=function(gfp,preset,enforce){/* translate legacy presets */switch(preset){case Lame.R3MIX:preset=Lame.V3;gfp.VBR=$7960aab77e945546$var$VbrMode.vbr_mtrh;break;case Lame.MEDIUM:preset=Lame.V4;gfp.VBR=$7960aab77e945546$var$VbrMode.vbr_rh;break;case Lame.MEDIUM_FAST:preset=Lame.V4;gfp.VBR=$7960aab77e945546$var$VbrMode.vbr_mtrh;break;case Lame.STANDARD:preset=Lame.V2;gfp.VBR=$7960aab77e945546$var$VbrMode.vbr_rh;break;case Lame.STANDARD_FAST:preset=Lame.V2;gfp.VBR=$7960aab77e945546$var$VbrMode.vbr_mtrh;break;case Lame.EXTREME:preset=Lame.V0;gfp.VBR=$7960aab77e945546$var$VbrMode.vbr_rh;break;case Lame.EXTREME_FAST:preset=Lame.V0;gfp.VBR=$7960aab77e945546$var$VbrMode.vbr_mtrh;break;case Lame.INSANE:preset=320;gfp.preset=preset;apply_abr_preset(gfp,preset,enforce);gfp.VBR=$7960aab77e945546$var$VbrMode.vbr_off;return preset;}gfp.preset=preset;switch(preset){case Lame.V9:apply_vbr_preset(gfp,9,enforce);return preset;case Lame.V8:apply_vbr_preset(gfp,8,enforce);return preset;case Lame.V7:apply_vbr_preset(gfp,7,enforce);return preset;case Lame.V6:apply_vbr_preset(gfp,6,enforce);return preset;case Lame.V5:apply_vbr_preset(gfp,5,enforce);return preset;case Lame.V4:apply_vbr_preset(gfp,4,enforce);return preset;case Lame.V3:apply_vbr_preset(gfp,3,enforce);return preset;case Lame.V2:apply_vbr_preset(gfp,2,enforce);return preset;case Lame.V1:apply_vbr_preset(gfp,1,enforce);return preset;case Lame.V0:apply_vbr_preset(gfp,0,enforce);return preset;}if(8<=preset&&preset<=320)return apply_abr_preset(gfp,preset,enforce);/* no corresponding preset found */gfp.preset=0;return preset;};// Rest from getset.c:
1846
+ /**
1847
+ * VBR quality level.<BR>
1848
+ * 0 = highest<BR>
1849
+ * 9 = lowest
1850
+ */function lame_set_VBR_q(gfp,VBR_q){var ret=0;if(0>VBR_q){/* Unknown VBR quality level! */ret=-1;VBR_q=0;}if(9<VBR_q){ret=-1;VBR_q=9;}gfp.VBR_q=VBR_q;gfp.VBR_q_frac=0;return ret;}}$7960aab77e945546$exports=$7960aab77e945546$var$Presets;var $b8dhq=parcelRequire("b8dhq");var $84mea=parcelRequire("84mea");var $df08f3a0d41b7a78$exports={};/*
1851
+ * MP3 quantization
1852
+ *
1853
+ * Copyright (c) 1999-2000 Mark Taylor
1854
+ * Copyright (c) 1999-2003 Takehiro Tominaga
1855
+ * Copyright (c) 2000-2007 Robert Hegemann
1856
+ * Copyright (c) 2001-2005 Gabriel Bouvigne
1857
+ *
1858
+ * This library is free software; you can redistribute it and/or
1859
+ * modify it under the terms of the GNU Lesser General Public
1860
+ * License as published by the Free Software Foundation; either
1861
+ * version 2 of the License, or (at your option) any later version.
1862
+ *
1863
+ * This library is distributed in the hope that it will be useful,
1864
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1865
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1866
+ * Library General Public License for more details.
1867
+ *
1868
+ * You should have received a copy of the GNU Lesser General Public
1869
+ * License along with this library; if not, write to the
1870
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1871
+ * Boston, MA 02111-1307, USA.
1872
+ */ /* $Id: Quantize.java,v 1.24 2011/05/24 20:48:06 kenchis Exp $ */ //package mp3;
1873
+ //import java.util.Arrays;
1874
+ var $3YDN3=parcelRequire("3YDN3");var $df08f3a0d41b7a78$var$System=$3YDN3.System;var $df08f3a0d41b7a78$var$VbrMode=$3YDN3.VbrMode;$3YDN3.Float;$3YDN3.ShortBlock;var $df08f3a0d41b7a78$var$Util=$3YDN3.Util;var $df08f3a0d41b7a78$var$Arrays=$3YDN3.Arrays;$3YDN3.new_array_n;$3YDN3.new_byte;$3YDN3.new_double;var $df08f3a0d41b7a78$var$new_float=$3YDN3.new_float;$3YDN3.new_float_n;$3YDN3.new_int;$3YDN3.new_int_n;var $df08f3a0d41b7a78$var$assert=$3YDN3.assert;var $225800021a714f05$exports={};function $225800021a714f05$var$VBRQuantize(){this.setModules=function(_qupvt,_tk){};//TODO
1875
+ }$225800021a714f05$exports=$225800021a714f05$var$VBRQuantize;var $3afa85f14aff627b$exports={};//package mp3;
1876
+ function $3afa85f14aff627b$var$CalcNoiseResult(){/**
1877
+ * sum of quantization noise > masking
1878
+ */this.over_noise=0.;/**
1879
+ * sum of all quantization noise
1880
+ */this.tot_noise=0.;/**
1881
+ * max quantization noise
1882
+ */this.max_noise=0.;/**
1883
+ * number of quantization noise > masking
1884
+ */this.over_count=0;/**
1885
+ * SSD-like cost of distorted bands
1886
+ */this.over_SSD=0;this.bits=0;}$3afa85f14aff627b$exports=$3afa85f14aff627b$var$CalcNoiseResult;var $4fc41bdea3aedc83$exports={};var $3YDN3=parcelRequire("3YDN3");var $4fc41bdea3aedc83$var$new_float=$3YDN3.new_float;var $4fc41bdea3aedc83$var$new_int=$3YDN3.new_int;$3YDN3.assert;function $4fc41bdea3aedc83$var$CalcNoiseData(){this.global_gain=0;this.sfb_count1=0;this.step=$4fc41bdea3aedc83$var$new_int(39);this.noise=$4fc41bdea3aedc83$var$new_float(39);this.noise_log=$4fc41bdea3aedc83$var$new_float(39);}$4fc41bdea3aedc83$exports=$4fc41bdea3aedc83$var$CalcNoiseData;var $cPNKB=parcelRequire("cPNKB");var $7weBo=parcelRequire("7weBo");var $arIi9=parcelRequire("arIi9");function $df08f3a0d41b7a78$var$Quantize(){var bs;this.rv=null;var rv;this.qupvt=null;var qupvt;var vbr=new $225800021a714f05$exports();var tk;this.setModules=function(_bs,_rv,_qupvt,_tk){bs=_bs;rv=_rv;this.rv=_rv;qupvt=_qupvt;this.qupvt=_qupvt;tk=_tk;vbr.setModules(qupvt,tk);};/**
1887
+ * convert from L/R <. Mid/Side
1888
+ */this.ms_convert=function(l3_side,gr){for(var i=0;i<576;++i){var l=l3_side.tt[gr][0].xr[i];var r=l3_side.tt[gr][1].xr[i];l3_side.tt[gr][0].xr[i]=(l+r)*($df08f3a0d41b7a78$var$Util.SQRT2*0.5);l3_side.tt[gr][1].xr[i]=(l-r)*($df08f3a0d41b7a78$var$Util.SQRT2*0.5);}};/**
1889
+ * mt 6/99
1890
+ *
1891
+ * initializes cod_info, scalefac and xrpow
1892
+ *
1893
+ * returns 0 if all energies in xr are zero, else 1
1894
+ */function init_xrpow_core(cod_info,xrpow,upper,sum){sum=0;for(var i=0;i<=upper;++i){var tmp=Math.abs(cod_info.xr[i]);sum+=tmp;xrpow[i]=Math.sqrt(tmp*Math.sqrt(tmp));if(xrpow[i]>cod_info.xrpow_max)cod_info.xrpow_max=xrpow[i];}return sum;}this.init_xrpow=function(gfc,cod_info,xrpow){var sum=0;var upper=0|cod_info.max_nonzero_coeff;$df08f3a0d41b7a78$var$assert(xrpow!=null);cod_info.xrpow_max=0;/*
1895
+ * check if there is some energy we have to quantize and calculate xrpow
1896
+ * matching our fresh scalefactors
1897
+ */$df08f3a0d41b7a78$var$assert(0<=upper&&upper<=575);$df08f3a0d41b7a78$var$Arrays.fill(xrpow,upper,576,0);sum=init_xrpow_core(cod_info,xrpow,upper,sum);/*
1898
+ * return 1 if we have something to quantize, else 0
1899
+ */if(sum>1E-20){var j=0;if((gfc.substep_shaping&2)!=0)j=1;for(var i=0;i<cod_info.psymax;i++)gfc.pseudohalf[i]=j;return true;}$df08f3a0d41b7a78$var$Arrays.fill(cod_info.l3_enc,0,576,0);return false;};/**
1900
+ * Gabriel Bouvigne feb/apr 2003<BR>
1901
+ * Analog silence detection in partitionned sfb21 or sfb12 for short blocks
1902
+ *
1903
+ * From top to bottom of sfb, changes to 0 coeffs which are below ath. It
1904
+ * stops on the first coeff higher than ath.
1905
+ */function psfb21_analogsilence(gfc,cod_info){var ath=gfc.ATH;var xr=cod_info.xr;if(cod_info.block_type!=$cPNKB.SHORT_TYPE){/* NORM, START or STOP type, but not SHORT blocks */var stop=false;for(var gsfb=$cPNKB.PSFB21-1;gsfb>=0&&!stop;gsfb--){var start=gfc.scalefac_band.psfb21[gsfb];var end=gfc.scalefac_band.psfb21[gsfb+1];var ath21=qupvt.athAdjust(ath.adjust,ath.psfb21[gsfb],ath.floor);if(gfc.nsPsy.longfact[21]>1e-12)ath21*=gfc.nsPsy.longfact[21];for(var j=end-1;j>=start;j--)if(Math.abs(xr[j])<ath21)xr[j]=0;else {stop=true;break;}}}else/* note: short blocks coeffs are reordered */for(var block=0;block<3;block++){var stop=false;for(var gsfb=$cPNKB.PSFB12-1;gsfb>=0&&!stop;gsfb--){var start=gfc.scalefac_band.s[12]*3+(gfc.scalefac_band.s[13]-gfc.scalefac_band.s[12])*block+(gfc.scalefac_band.psfb12[gsfb]-gfc.scalefac_band.psfb12[0]);var end=start+(gfc.scalefac_band.psfb12[gsfb+1]-gfc.scalefac_band.psfb12[gsfb]);var ath12=qupvt.athAdjust(ath.adjust,ath.psfb12[gsfb],ath.floor);if(gfc.nsPsy.shortfact[12]>1e-12)ath12*=gfc.nsPsy.shortfact[12];for(var j=end-1;j>=start;j--)if(Math.abs(xr[j])<ath12)xr[j]=0;else {stop=true;break;}}}}this.init_outer_loop=function(gfc,cod_info){/*
1906
+ * initialize fresh cod_info
1907
+ */cod_info.part2_3_length=0;cod_info.big_values=0;cod_info.count1=0;cod_info.global_gain=210;cod_info.scalefac_compress=0;/* mixed_block_flag, block_type was set in psymodel.c */cod_info.table_select[0]=0;cod_info.table_select[1]=0;cod_info.table_select[2]=0;cod_info.subblock_gain[0]=0;cod_info.subblock_gain[1]=0;cod_info.subblock_gain[2]=0;cod_info.subblock_gain[3]=0;/* this one is always 0 */cod_info.region0_count=0;cod_info.region1_count=0;cod_info.preflag=0;cod_info.scalefac_scale=0;cod_info.count1table_select=0;cod_info.part2_length=0;cod_info.sfb_lmax=$cPNKB.SBPSY_l;cod_info.sfb_smin=$cPNKB.SBPSY_s;cod_info.psy_lmax=gfc.sfb21_extra?$cPNKB.SBMAX_l:$cPNKB.SBPSY_l;cod_info.psymax=cod_info.psy_lmax;cod_info.sfbmax=cod_info.sfb_lmax;cod_info.sfbdivide=11;for(var sfb=0;sfb<$cPNKB.SBMAX_l;sfb++){cod_info.width[sfb]=gfc.scalefac_band.l[sfb+1]-gfc.scalefac_band.l[sfb];/* which is always 0. */cod_info.window[sfb]=3;}if(cod_info.block_type==$cPNKB.SHORT_TYPE){var ixwork=$df08f3a0d41b7a78$var$new_float(576);cod_info.sfb_smin=0;cod_info.sfb_lmax=0;if(cod_info.mixed_block_flag!=0){/*
1908
+ * MPEG-1: sfbs 0-7 long block, 3-12 short blocks MPEG-2(.5):
1909
+ * sfbs 0-5 long block, 3-12 short blocks
1910
+ */cod_info.sfb_smin=3;cod_info.sfb_lmax=gfc.mode_gr*2+4;}cod_info.psymax=cod_info.sfb_lmax+3*((gfc.sfb21_extra?$cPNKB.SBMAX_s:$cPNKB.SBPSY_s)-cod_info.sfb_smin);cod_info.sfbmax=cod_info.sfb_lmax+3*($cPNKB.SBPSY_s-cod_info.sfb_smin);cod_info.sfbdivide=cod_info.sfbmax-18;cod_info.psy_lmax=cod_info.sfb_lmax;/* re-order the short blocks, for more efficient encoding below */ /* By Takehiro TOMINAGA */ /*
1911
+ * Within each scalefactor band, data is given for successive time
1912
+ * windows, beginning with window 0 and ending with window 2. Within
1913
+ * each window, the quantized values are then arranged in order of
1914
+ * increasing frequency...
1915
+ */var ix=gfc.scalefac_band.l[cod_info.sfb_lmax];$df08f3a0d41b7a78$var$System.arraycopy(cod_info.xr,0,ixwork,0,576);for(var sfb=cod_info.sfb_smin;sfb<$cPNKB.SBMAX_s;sfb++){var start=gfc.scalefac_band.s[sfb];var end=gfc.scalefac_band.s[sfb+1];for(var window=0;window<3;window++)for(var l=start;l<end;l++)cod_info.xr[ix++]=ixwork[3*l+window];}var j=cod_info.sfb_lmax;for(var sfb=cod_info.sfb_smin;sfb<$cPNKB.SBMAX_s;sfb++){cod_info.width[j]=cod_info.width[j+1]=cod_info.width[j+2]=gfc.scalefac_band.s[sfb+1]-gfc.scalefac_band.s[sfb];cod_info.window[j]=0;cod_info.window[j+1]=1;cod_info.window[j+2]=2;j+=3;}}cod_info.count1bits=0;cod_info.sfb_partition_table=qupvt.nr_of_sfb_block[0][0];cod_info.slen[0]=0;cod_info.slen[1]=0;cod_info.slen[2]=0;cod_info.slen[3]=0;cod_info.max_nonzero_coeff=575;/*
1916
+ * fresh scalefactors are all zero
1917
+ */$df08f3a0d41b7a78$var$Arrays.fill(cod_info.scalefac,0);psfb21_analogsilence(gfc,cod_info);};function BinSearchDirection(ordinal){this.ordinal=ordinal;}BinSearchDirection.BINSEARCH_NONE=new BinSearchDirection(0);BinSearchDirection.BINSEARCH_UP=new BinSearchDirection(1);BinSearchDirection.BINSEARCH_DOWN=new BinSearchDirection(2);/**
1918
+ * author/date??
1919
+ *
1920
+ * binary step size search used by outer_loop to get a quantizer step size
1921
+ * to start with
1922
+ */function bin_search_StepSize(gfc,cod_info,desired_rate,ch,xrpow){var nBits;var CurrentStep=gfc.CurrentStep[ch];var flagGoneOver=false;var start=gfc.OldValue[ch];var Direction=BinSearchDirection.BINSEARCH_NONE;cod_info.global_gain=start;desired_rate-=cod_info.part2_length;$df08f3a0d41b7a78$var$assert(CurrentStep!=0);for(;;){var step;nBits=tk.count_bits(gfc,xrpow,cod_info,null);if(CurrentStep==1||nBits==desired_rate)break;/* nothing to adjust anymore */if(nBits>desired_rate){/* increase Quantize_StepSize */if(Direction==BinSearchDirection.BINSEARCH_DOWN)flagGoneOver=true;if(flagGoneOver)CurrentStep/=2;Direction=BinSearchDirection.BINSEARCH_UP;step=CurrentStep;}else {/* decrease Quantize_StepSize */if(Direction==BinSearchDirection.BINSEARCH_UP)flagGoneOver=true;if(flagGoneOver)CurrentStep/=2;Direction=BinSearchDirection.BINSEARCH_DOWN;step=-CurrentStep;}cod_info.global_gain+=step;if(cod_info.global_gain<0){cod_info.global_gain=0;flagGoneOver=true;}if(cod_info.global_gain>255){cod_info.global_gain=255;flagGoneOver=true;}}$df08f3a0d41b7a78$var$assert(cod_info.global_gain>=0);$df08f3a0d41b7a78$var$assert(cod_info.global_gain<256);while(nBits>desired_rate&&cod_info.global_gain<255){cod_info.global_gain++;nBits=tk.count_bits(gfc,xrpow,cod_info,null);}gfc.CurrentStep[ch]=start-cod_info.global_gain>=4?4:2;gfc.OldValue[ch]=cod_info.global_gain;cod_info.part2_3_length=nBits;return nBits;}this.trancate_smallspectrums=function(gfc,gi,l3_xmin,work){var distort=$df08f3a0d41b7a78$var$new_float($arIi9.SFBMAX);if(0==(gfc.substep_shaping&4)&&gi.block_type==$cPNKB.SHORT_TYPE||(gfc.substep_shaping&0x80)!=0)return;qupvt.calc_noise(gi,l3_xmin,distort,new $3afa85f14aff627b$exports(),null);for(var j=0;j<576;j++){var xr=0.0;if(gi.l3_enc[j]!=0)xr=Math.abs(gi.xr[j]);work[j]=xr;}var j=0;var sfb=8;if(gi.block_type==$cPNKB.SHORT_TYPE)sfb=6;do{var allowedNoise,trancateThreshold;var nsame,start;var width=gi.width[sfb];j+=width;if(distort[sfb]>=1.0)continue;$df08f3a0d41b7a78$var$Arrays.sort(work,j-width,width);if(BitStream.EQ(work[j-1],0.0))continue;/* all zero sfb */allowedNoise=(1.0-distort[sfb])*l3_xmin[sfb];trancateThreshold=0.0;start=0;do{var noise;for(nsame=1;start+nsame<width;nsame++)if(BitStream.NEQ(work[start+j-width],work[start+j+nsame-width]))break;noise=work[start+j-width]*work[start+j-width]*nsame;if(allowedNoise<noise){if(start!=0)trancateThreshold=work[start+j-width-1];break;}allowedNoise-=noise;start+=nsame;}while(start<width);if(BitStream.EQ(trancateThreshold,0.0))continue;do if(Math.abs(gi.xr[j-width])<=trancateThreshold)gi.l3_enc[j-width]=0;while(--width>0);}while(++sfb<gi.psymax);gi.part2_3_length=tk.noquant_count_bits(gfc,gi,null);};/**
1923
+ * author/date??
1924
+ *
1925
+ * Function: Returns zero if there is a scalefac which has not been
1926
+ * amplified. Otherwise it returns one.
1927
+ */function loop_break(cod_info){for(var sfb=0;sfb<cod_info.sfbmax;sfb++)if(cod_info.scalefac[sfb]+cod_info.subblock_gain[cod_info.window[sfb]]==0)return false;return true;}/* mt 5/99: Function: Improved calc_noise for a single channel */function penalties(noise){return $df08f3a0d41b7a78$var$Util.FAST_LOG10(0.368+0.632*noise*noise*noise);}/**
1928
+ * author/date??
1929
+ *
1930
+ * several different codes to decide which quantization is better
1931
+ */function get_klemm_noise(distort,gi){var klemm_noise=1E-37;for(var sfb=0;sfb<gi.psymax;sfb++)klemm_noise+=penalties(distort[sfb]);return Math.max(1e-20,klemm_noise);}function quant_compare(quant_comp,best,calc,gi,distort){/**
1932
+ * noise is given in decibels (dB) relative to masking thesholds.<BR>
1933
+ *
1934
+ * over_noise: ??? (the previous comment is fully wrong)<BR>
1935
+ * tot_noise: ??? (the previous comment is fully wrong)<BR>
1936
+ * max_noise: max quantization noise
1937
+ */var better;switch(quant_comp){default:case 9:if(best.over_count>0){/* there are distorted sfb */better=calc.over_SSD<=best.over_SSD;if(calc.over_SSD==best.over_SSD)better=calc.bits<best.bits;}else/* no distorted sfb */better=calc.max_noise<0&&calc.max_noise*10+calc.bits<=best.max_noise*10+best.bits;break;case 0:better=calc.over_count<best.over_count||calc.over_count==best.over_count&&calc.over_noise<best.over_noise||calc.over_count==best.over_count&&BitStream.EQ(calc.over_noise,best.over_noise)&&calc.tot_noise<best.tot_noise;break;case 8:calc.max_noise=get_klemm_noise(distort,gi);//$FALL-THROUGH$
1938
+ case 1:better=calc.max_noise<best.max_noise;break;case 2:better=calc.tot_noise<best.tot_noise;break;case 3:better=calc.tot_noise<best.tot_noise&&calc.max_noise<best.max_noise;break;case 4:better=calc.max_noise<=0.0&&best.max_noise>0.2||calc.max_noise<=0.0&&best.max_noise<0.0&&best.max_noise>calc.max_noise-0.2&&calc.tot_noise<best.tot_noise||calc.max_noise<=0.0&&best.max_noise>0.0&&best.max_noise>calc.max_noise-0.2&&calc.tot_noise<best.tot_noise+best.over_noise||calc.max_noise>0.0&&best.max_noise>-0.05&&best.max_noise>calc.max_noise-0.1&&calc.tot_noise+calc.over_noise<best.tot_noise+best.over_noise||calc.max_noise>0.0&&best.max_noise>-0.1&&best.max_noise>calc.max_noise-0.15&&calc.tot_noise+calc.over_noise+calc.over_noise<best.tot_noise+best.over_noise+best.over_noise;break;case 5:better=calc.over_noise<best.over_noise||BitStream.EQ(calc.over_noise,best.over_noise)&&calc.tot_noise<best.tot_noise;break;case 6:better=calc.over_noise<best.over_noise||BitStream.EQ(calc.over_noise,best.over_noise)&&(calc.max_noise<best.max_noise||BitStream.EQ(calc.max_noise,best.max_noise)&&calc.tot_noise<=best.tot_noise);break;case 7:better=calc.over_count<best.over_count||calc.over_noise<best.over_noise;break;}if(best.over_count==0)/*
1939
+ * If no distorted bands, only use this quantization if it is
1940
+ * better, and if it uses less bits. Unfortunately, part2_3_length
1941
+ * is sometimes a poor estimator of the final size at low bitrates.
1942
+ */better=better&&calc.bits<best.bits;return better;}/**
1943
+ * author/date??
1944
+ *
1945
+ * <PRE>
1946
+ * Amplify the scalefactor bands that violate the masking threshold.
1947
+ * See ISO 11172-3 Section C.1.5.4.3.5
1948
+ *
1949
+ * distort[] = noise/masking
1950
+ * distort[] > 1 ==> noise is not masked
1951
+ * distort[] < 1 ==> noise is masked
1952
+ * max_dist = maximum value of distort[]
1953
+ *
1954
+ * Three algorithms:
1955
+ * noise_shaping_amp
1956
+ * 0 Amplify all bands with distort[]>1.
1957
+ *
1958
+ * 1 Amplify all bands with distort[] >= max_dist^(.5);
1959
+ * ( 50% in the db scale)
1960
+ *
1961
+ * 2 Amplify first band with distort[] >= max_dist;
1962
+ *
1963
+ *
1964
+ * For algorithms 0 and 1, if max_dist < 1, then amplify all bands
1965
+ * with distort[] >= .95*max_dist. This is to make sure we always
1966
+ * amplify at least one band.
1967
+ * </PRE>
1968
+ */function amp_scalefac_bands(gfp,cod_info,distort,xrpow,bRefine){var gfc=gfp.internal_flags;var ifqstep34;if(cod_info.scalefac_scale==0)ifqstep34=1.29683955465100964055;else ifqstep34=1.68179283050742922612;/* compute maximum value of distort[] */var trigger=0;for(var sfb=0;sfb<cod_info.sfbmax;sfb++)if(trigger<distort[sfb])trigger=distort[sfb];var noise_shaping_amp=gfc.noise_shaping_amp;if(noise_shaping_amp==3){if(bRefine)noise_shaping_amp=2;else noise_shaping_amp=1;}switch(noise_shaping_amp){case 2:break;case 1:/* amplify bands within 50% of max (on db scale) */if(trigger>1.0)trigger=Math.pow(trigger,.5);else trigger*=.95;break;case 0:default:/* ISO algorithm. amplify all bands with distort>1 */if(trigger>1.0)trigger=1.0;else trigger*=.95;break;}var j=0;for(var sfb=0;sfb<cod_info.sfbmax;sfb++){var width=cod_info.width[sfb];var l;j+=width;if(distort[sfb]<trigger)continue;if((gfc.substep_shaping&2)!=0){gfc.pseudohalf[sfb]=0==gfc.pseudohalf[sfb]?1:0;if(0==gfc.pseudohalf[sfb]&&gfc.noise_shaping_amp==2)return;}cod_info.scalefac[sfb]++;for(l=-width;l<0;l++){xrpow[j+l]*=ifqstep34;if(xrpow[j+l]>cod_info.xrpow_max)cod_info.xrpow_max=xrpow[j+l];}if(gfc.noise_shaping_amp==2)return;}}/**
1969
+ * Takehiro Tominaga 2000-xx-xx
1970
+ *
1971
+ * turns on scalefac scale and adjusts scalefactors
1972
+ */function inc_scalefac_scale(cod_info,xrpow){var ifqstep34=1.29683955465100964055;var j=0;for(var sfb=0;sfb<cod_info.sfbmax;sfb++){var width=cod_info.width[sfb];var s=cod_info.scalefac[sfb];if(cod_info.preflag!=0)s+=qupvt.pretab[sfb];j+=width;if((s&1)!=0){s++;for(var l=-width;l<0;l++){xrpow[j+l]*=ifqstep34;if(xrpow[j+l]>cod_info.xrpow_max)cod_info.xrpow_max=xrpow[j+l];}}cod_info.scalefac[sfb]=s>>1;}cod_info.preflag=0;cod_info.scalefac_scale=1;}/**
1973
+ * Takehiro Tominaga 2000-xx-xx
1974
+ *
1975
+ * increases the subblock gain and adjusts scalefactors
1976
+ */function inc_subblock_gain(gfc,cod_info,xrpow){var sfb;var scalefac=cod_info.scalefac;/* subbloc_gain can't do anything in the long block region */for(sfb=0;sfb<cod_info.sfb_lmax;sfb++){if(scalefac[sfb]>=16)return true;}for(var window=0;window<3;window++){var s1=0;var s2=0;for(sfb=cod_info.sfb_lmax+window;sfb<cod_info.sfbdivide;sfb+=3)if(s1<scalefac[sfb])s1=scalefac[sfb];for(;sfb<cod_info.sfbmax;sfb+=3)if(s2<scalefac[sfb])s2=scalefac[sfb];if(s1<16&&s2<8)continue;if(cod_info.subblock_gain[window]>=7)return true;/*
1977
+ * even though there is no scalefactor for sfb12 subblock gain
1978
+ * affects upper frequencies too, that's why we have to go up to
1979
+ * SBMAX_s
1980
+ */cod_info.subblock_gain[window]++;var j=gfc.scalefac_band.l[cod_info.sfb_lmax];for(sfb=cod_info.sfb_lmax+window;sfb<cod_info.sfbmax;sfb+=3){var amp;var width=cod_info.width[sfb];var s=scalefac[sfb];$df08f3a0d41b7a78$var$assert(s>=0);s=s-(4>>cod_info.scalefac_scale);if(s>=0){scalefac[sfb]=s;j+=width*3;continue;}scalefac[sfb]=0;var gain=210+(s<<cod_info.scalefac_scale+1);amp=qupvt.IPOW20(gain);j+=width*(window+1);for(var l=-width;l<0;l++){xrpow[j+l]*=amp;if(xrpow[j+l]>cod_info.xrpow_max)cod_info.xrpow_max=xrpow[j+l];}j+=width*(3-window-1);}var amp=qupvt.IPOW20(202);j+=cod_info.width[sfb]*(window+1);for(var l=-cod_info.width[sfb];l<0;l++){xrpow[j+l]*=amp;if(xrpow[j+l]>cod_info.xrpow_max)cod_info.xrpow_max=xrpow[j+l];}}return false;}/**
1981
+ * <PRE>
1982
+ * Takehiro Tominaga /date??
1983
+ * Robert Hegemann 2000-09-06: made a function of it
1984
+ *
1985
+ * amplifies scalefactor bands,
1986
+ * - if all are already amplified returns 0
1987
+ * - if some bands are amplified too much:
1988
+ * * try to increase scalefac_scale
1989
+ * * if already scalefac_scale was set
1990
+ * try on short blocks to increase subblock gain
1991
+ * </PRE>
1992
+ */function balance_noise(gfp,cod_info,distort,xrpow,bRefine){var gfc=gfp.internal_flags;amp_scalefac_bands(gfp,cod_info,distort,xrpow,bRefine);/*
1993
+ * check to make sure we have not amplified too much loop_break returns
1994
+ * 0 if there is an unamplified scalefac scale_bitcount returns 0 if no
1995
+ * scalefactors are too large
1996
+ */var status=loop_break(cod_info);if(status)return false;/* all bands amplified */ /*
1997
+ * not all scalefactors have been amplified. so these scalefacs are
1998
+ * possibly valid. encode them:
1999
+ */if(gfc.mode_gr==2)status=tk.scale_bitcount(cod_info);else status=tk.scale_bitcount_lsf(gfc,cod_info);if(!status)return true;/* amplified some bands not exceeding limits */ /*
2000
+ * some scalefactors are too large. lets try setting scalefac_scale=1
2001
+ */if(gfc.noise_shaping>1){$df08f3a0d41b7a78$var$Arrays.fill(gfc.pseudohalf,0);if(0==cod_info.scalefac_scale){inc_scalefac_scale(cod_info,xrpow);status=false;}else if(cod_info.block_type==$cPNKB.SHORT_TYPE&&gfc.subblock_gain>0)status=inc_subblock_gain(gfc,cod_info,xrpow)||loop_break(cod_info);}if(!status){if(gfc.mode_gr==2)status=tk.scale_bitcount(cod_info);else status=tk.scale_bitcount_lsf(gfc,cod_info);}return !status;}/**
2002
+ * <PRE>
2003
+ * Function: The outer iteration loop controls the masking conditions
2004
+ * of all scalefactorbands. It computes the best scalefac and
2005
+ * global gain. This module calls the inner iteration loop
2006
+ *
2007
+ * mt 5/99 completely rewritten to allow for bit reservoir control,
2008
+ * mid/side channels with L/R or mid/side masking thresholds,
2009
+ * and chooses best quantization instead of last quantization when
2010
+ * no distortion free quantization can be found.
2011
+ *
2012
+ * added VBR support mt 5/99
2013
+ *
2014
+ * some code shuffle rh 9/00
2015
+ * </PRE>
2016
+ *
2017
+ * @param l3_xmin
2018
+ * allowed distortion
2019
+ * @param xrpow
2020
+ * coloured magnitudes of spectral
2021
+ * @param targ_bits
2022
+ * maximum allowed bits
2023
+ */this.outer_loop=function(gfp,cod_info,l3_xmin,xrpow,ch,targ_bits){var gfc=gfp.internal_flags;var cod_info_w=new $7weBo();var save_xrpow=$df08f3a0d41b7a78$var$new_float(576);var distort=$df08f3a0d41b7a78$var$new_float($arIi9.SFBMAX);var best_noise_info=new $3afa85f14aff627b$exports();var better;var prev_noise=new $4fc41bdea3aedc83$exports();var best_part2_3_length=9999999;var bEndOfSearch=false;var bRefine=false;var best_ggain_pass1=0;bin_search_StepSize(gfc,cod_info,targ_bits,ch,xrpow);if(0==gfc.noise_shaping)/* fast mode, no noise shaping, we are ready */return 100;/* default noise_info.over_count */ /* compute the distortion in this quantization */ /* coefficients and thresholds both l/r (or both mid/side) */qupvt.calc_noise(cod_info,l3_xmin,distort,best_noise_info,prev_noise);best_noise_info.bits=cod_info.part2_3_length;cod_info_w.assign(cod_info);var age=0;$df08f3a0d41b7a78$var$System.arraycopy(xrpow,0,save_xrpow,0,576);while(!bEndOfSearch){/* BEGIN MAIN LOOP */do{var noise_info=new $3afa85f14aff627b$exports();var search_limit;var maxggain=255;/*
2024
+ * When quantization with no distorted bands is found, allow up
2025
+ * to X new unsuccesful tries in serial. This gives us more
2026
+ * possibilities for different quant_compare modes. Much more
2027
+ * than 3 makes not a big difference, it is only slower.
2028
+ */if((gfc.substep_shaping&2)!=0)search_limit=20;else search_limit=3;/*
2029
+ * Check if the last scalefactor band is distorted. in VBR mode
2030
+ * we can't get rid of the distortion, so quit now and VBR mode
2031
+ * will try again with more bits. (makes a 10% speed increase,
2032
+ * the files I tested were binary identical, 2000/05/20 Robert
2033
+ * Hegemann) distort[] > 1 means noise > allowed noise
2034
+ */if(gfc.sfb21_extra){if(distort[cod_info_w.sfbmax]>1.0)break;if(cod_info_w.block_type==$cPNKB.SHORT_TYPE&&(distort[cod_info_w.sfbmax+1]>1.0||distort[cod_info_w.sfbmax+2]>1.0))break;}/* try a new scalefactor conbination on cod_info_w */if(!balance_noise(gfp,cod_info_w,distort,xrpow,bRefine))break;if(cod_info_w.scalefac_scale!=0)maxggain=254;/*
2035
+ * inner_loop starts with the initial quantization step computed
2036
+ * above and slowly increases until the bits < huff_bits. Thus
2037
+ * it is important not to start with too large of an inital
2038
+ * quantization step. Too small is ok, but inner_loop will take
2039
+ * longer
2040
+ */var huff_bits=targ_bits-cod_info_w.part2_length;if(huff_bits<=0)break;/*
2041
+ * increase quantizer stepsize until needed bits are below
2042
+ * maximum
2043
+ */while((cod_info_w.part2_3_length=tk.count_bits(gfc,xrpow,cod_info_w,prev_noise))>huff_bits&&cod_info_w.global_gain<=maxggain)cod_info_w.global_gain++;if(cod_info_w.global_gain>maxggain)break;if(best_noise_info.over_count==0){while((cod_info_w.part2_3_length=tk.count_bits(gfc,xrpow,cod_info_w,prev_noise))>best_part2_3_length&&cod_info_w.global_gain<=maxggain)cod_info_w.global_gain++;if(cod_info_w.global_gain>maxggain)break;}/* compute the distortion in this quantization */qupvt.calc_noise(cod_info_w,l3_xmin,distort,noise_info,prev_noise);noise_info.bits=cod_info_w.part2_3_length;/*
2044
+ * check if this quantization is better than our saved
2045
+ * quantization
2046
+ */if(cod_info.block_type!=$cPNKB.SHORT_TYPE)// NORM, START or STOP type
2047
+ better=gfp.quant_comp;else better=gfp.quant_comp_short;better=quant_compare(better,best_noise_info,noise_info,cod_info_w,distort)?1:0;/* save data so we can restore this quantization later */if(better!=0){best_part2_3_length=cod_info.part2_3_length;best_noise_info=noise_info;cod_info.assign(cod_info_w);age=0;/* save data so we can restore this quantization later */ /* store for later reuse */$df08f3a0d41b7a78$var$System.arraycopy(xrpow,0,save_xrpow,0,576);}else/* early stop? */if(gfc.full_outer_loop==0){if(++age>search_limit&&best_noise_info.over_count==0)break;if(gfc.noise_shaping_amp==3&&bRefine&&age>30)break;if(gfc.noise_shaping_amp==3&&bRefine&&cod_info_w.global_gain-best_ggain_pass1>15)break;}}while(cod_info_w.global_gain+cod_info_w.scalefac_scale<255);if(gfc.noise_shaping_amp==3){if(!bRefine){/* refine search */cod_info_w.assign(cod_info);$df08f3a0d41b7a78$var$System.arraycopy(save_xrpow,0,xrpow,0,576);age=0;best_ggain_pass1=cod_info_w.global_gain;bRefine=true;}else/* search already refined, stop */bEndOfSearch=true;}else bEndOfSearch=true;}$df08f3a0d41b7a78$var$assert(cod_info.global_gain+cod_info.scalefac_scale<=255);/*
2048
+ * finish up
2049
+ */if(gfp.VBR==$df08f3a0d41b7a78$var$VbrMode.vbr_rh||gfp.VBR==$df08f3a0d41b7a78$var$VbrMode.vbr_mtrh)/* restore for reuse on next try */$df08f3a0d41b7a78$var$System.arraycopy(save_xrpow,0,xrpow,0,576);else if((gfc.substep_shaping&1)!=0)trancate_smallspectrums(gfc,cod_info,l3_xmin,xrpow);return best_noise_info.over_count;};/**
2050
+ * Robert Hegemann 2000-09-06
2051
+ *
2052
+ * update reservoir status after FINAL quantization/bitrate
2053
+ */this.iteration_finish_one=function(gfc,gr,ch){var l3_side=gfc.l3_side;var cod_info=l3_side.tt[gr][ch];/*
2054
+ * try some better scalefac storage
2055
+ */tk.best_scalefac_store(gfc,gr,ch,l3_side);/*
2056
+ * best huffman_divide may save some bits too
2057
+ */if(gfc.use_best_huffman==1)tk.best_huffman_divide(gfc,cod_info);/*
2058
+ * update reservoir status after FINAL quantization/bitrate
2059
+ */rv.ResvAdjust(gfc,cod_info);};/**
2060
+ *
2061
+ * 2000-09-04 Robert Hegemann
2062
+ *
2063
+ * @param l3_xmin
2064
+ * allowed distortion of the scalefactor
2065
+ * @param xrpow
2066
+ * coloured magnitudes of spectral values
2067
+ */this.VBR_encode_granule=function(gfp,cod_info,l3_xmin,xrpow,ch,min_bits,max_bits){var gfc=gfp.internal_flags;var bst_cod_info=new $7weBo();var bst_xrpow=$df08f3a0d41b7a78$var$new_float(576);var Max_bits=max_bits;var real_bits=max_bits+1;var this_bits=(max_bits+min_bits)/2;var dbits,over,found=0;var sfb21_extra=gfc.sfb21_extra;$df08f3a0d41b7a78$var$assert(Max_bits<=LameInternalFlags.MAX_BITS_PER_CHANNEL);$df08f3a0d41b7a78$var$Arrays.fill(bst_cod_info.l3_enc,0);/*
2068
+ * search within round about 40 bits of optimal
2069
+ */do{$df08f3a0d41b7a78$var$assert(this_bits>=min_bits);$df08f3a0d41b7a78$var$assert(this_bits<=max_bits);$df08f3a0d41b7a78$var$assert(min_bits<=max_bits);if(this_bits>Max_bits-42)gfc.sfb21_extra=false;else gfc.sfb21_extra=sfb21_extra;over=outer_loop(gfp,cod_info,l3_xmin,xrpow,ch,this_bits);/*
2070
+ * is quantization as good as we are looking for ? in this case: is
2071
+ * no scalefactor band distorted?
2072
+ */if(over<=0){found=1;/*
2073
+ * now we know it can be done with "real_bits" and maybe we can
2074
+ * skip some iterations
2075
+ */real_bits=cod_info.part2_3_length;/*
2076
+ * store best quantization so far
2077
+ */bst_cod_info.assign(cod_info);$df08f3a0d41b7a78$var$System.arraycopy(xrpow,0,bst_xrpow,0,576);/*
2078
+ * try with fewer bits
2079
+ */max_bits=real_bits-32;dbits=max_bits-min_bits;this_bits=(max_bits+min_bits)/2;}else {/*
2080
+ * try with more bits
2081
+ */min_bits=this_bits+32;dbits=max_bits-min_bits;this_bits=(max_bits+min_bits)/2;if(found!=0){found=2;/*
2082
+ * start again with best quantization so far
2083
+ */cod_info.assign(bst_cod_info);$df08f3a0d41b7a78$var$System.arraycopy(bst_xrpow,0,xrpow,0,576);}}}while(dbits>12);gfc.sfb21_extra=sfb21_extra;/*
2084
+ * found=0 => nothing found, use last one found=1 => we just found the
2085
+ * best and left the loop found=2 => we restored a good one and have now
2086
+ * l3_enc to restore too
2087
+ */if(found==2)$df08f3a0d41b7a78$var$System.arraycopy(bst_cod_info.l3_enc,0,cod_info.l3_enc,0,576);$df08f3a0d41b7a78$var$assert(cod_info.part2_3_length<=Max_bits);};/**
2088
+ * Robert Hegemann 2000-09-05
2089
+ *
2090
+ * calculates * how many bits are available for analog silent granules * how
2091
+ * many bits to use for the lowest allowed bitrate * how many bits each
2092
+ * bitrate would provide
2093
+ */this.get_framebits=function(gfp,frameBits){var gfc=gfp.internal_flags;/*
2094
+ * always use at least this many bits per granule per channel unless we
2095
+ * detect analog silence, see below
2096
+ */gfc.bitrate_index=gfc.VBR_min_bitrate;var bitsPerFrame=bs.getframebits(gfp);/*
2097
+ * bits for analog silence
2098
+ */gfc.bitrate_index=1;bitsPerFrame=bs.getframebits(gfp);for(var i=1;i<=gfc.VBR_max_bitrate;i++){gfc.bitrate_index=i;var mb=new MeanBits(bitsPerFrame);frameBits[i]=rv.ResvFrameBegin(gfp,mb);bitsPerFrame=mb.bits;}};/* RH: this one needs to be overhauled sometime */ /**
2099
+ * <PRE>
2100
+ * 2000-09-04 Robert Hegemann
2101
+ *
2102
+ * * converts LR to MS coding when necessary
2103
+ * * calculates allowed/adjusted quantization noise amounts
2104
+ * * detects analog silent frames
2105
+ *
2106
+ * some remarks:
2107
+ * - lower masking depending on Quality setting
2108
+ * - quality control together with adjusted ATH MDCT scaling
2109
+ * on lower quality setting allocate more noise from
2110
+ * ATH masking, and on higher quality setting allocate
2111
+ * less noise from ATH masking.
2112
+ * - experiments show that going more than 2dB over GPSYCHO's
2113
+ * limits ends up in very annoying artefacts
2114
+ * </PRE>
2115
+ */this.VBR_old_prepare=function(gfp,pe,ms_ener_ratio,ratio,l3_xmin,frameBits,min_bits,max_bits,bands){var gfc=gfp.internal_flags;var masking_lower_db,adjust=0.0;var analog_silence=1;var bits=0;gfc.bitrate_index=gfc.VBR_max_bitrate;var avg=rv.ResvFrameBegin(gfp,new MeanBits(0))/gfc.mode_gr;get_framebits(gfp,frameBits);for(var gr=0;gr<gfc.mode_gr;gr++){var mxb=qupvt.on_pe(gfp,pe,max_bits[gr],avg,gr,0);if(gfc.mode_ext==$cPNKB.MPG_MD_MS_LR){ms_convert(gfc.l3_side,gr);qupvt.reduce_side(max_bits[gr],ms_ener_ratio[gr],avg,mxb);}for(var ch=0;ch<gfc.channels_out;++ch){var cod_info=gfc.l3_side.tt[gr][ch];if(cod_info.block_type!=$cPNKB.SHORT_TYPE){// NORM, START or STOP type
2116
+ adjust=1.28/(1+Math.exp(3.5-pe[gr][ch]/300.))-0.05;masking_lower_db=gfc.PSY.mask_adjust-adjust;}else {adjust=2.56/(1+Math.exp(3.5-pe[gr][ch]/300.))-0.14;masking_lower_db=gfc.PSY.mask_adjust_short-adjust;}gfc.masking_lower=Math.pow(10.0,masking_lower_db*0.1);init_outer_loop(gfc,cod_info);bands[gr][ch]=qupvt.calc_xmin(gfp,ratio[gr][ch],cod_info,l3_xmin[gr][ch]);if(bands[gr][ch]!=0)analog_silence=0;min_bits[gr][ch]=126;bits+=max_bits[gr][ch];}}for(var gr=0;gr<gfc.mode_gr;gr++)for(var ch=0;ch<gfc.channels_out;ch++){if(bits>frameBits[gfc.VBR_max_bitrate]){max_bits[gr][ch]*=frameBits[gfc.VBR_max_bitrate];max_bits[gr][ch]/=bits;}if(min_bits[gr][ch]>max_bits[gr][ch])min_bits[gr][ch]=max_bits[gr][ch];}/* for gr */return analog_silence;};this.bitpressure_strategy=function(gfc,l3_xmin,min_bits,max_bits){for(var gr=0;gr<gfc.mode_gr;gr++)for(var ch=0;ch<gfc.channels_out;ch++){var gi=gfc.l3_side.tt[gr][ch];var pxmin=l3_xmin[gr][ch];var pxminPos=0;for(var sfb=0;sfb<gi.psy_lmax;sfb++)pxmin[pxminPos++]*=1.+.029*sfb*sfb/$cPNKB.SBMAX_l/$cPNKB.SBMAX_l;if(gi.block_type==$cPNKB.SHORT_TYPE)for(var sfb=gi.sfb_smin;sfb<$cPNKB.SBMAX_s;sfb++){pxmin[pxminPos++]*=1.+.029*sfb*sfb/$cPNKB.SBMAX_s/$cPNKB.SBMAX_s;pxmin[pxminPos++]*=1.+.029*sfb*sfb/$cPNKB.SBMAX_s/$cPNKB.SBMAX_s;pxmin[pxminPos++]*=1.+.029*sfb*sfb/$cPNKB.SBMAX_s/$cPNKB.SBMAX_s;}max_bits[gr][ch]=0|Math.max(min_bits[gr][ch],0.9*max_bits[gr][ch]);}};this.VBR_new_prepare=function(gfp,pe,ratio,l3_xmin,frameBits,max_bits){var gfc=gfp.internal_flags;var analog_silence=1;var avg=0,bits=0;var maximum_framebits;if(!gfp.free_format){gfc.bitrate_index=gfc.VBR_max_bitrate;var mb=new MeanBits(avg);rv.ResvFrameBegin(gfp,mb);avg=mb.bits;get_framebits(gfp,frameBits);maximum_framebits=frameBits[gfc.VBR_max_bitrate];}else {gfc.bitrate_index=0;var mb=new MeanBits(avg);maximum_framebits=rv.ResvFrameBegin(gfp,mb);avg=mb.bits;frameBits[0]=maximum_framebits;}for(var gr=0;gr<gfc.mode_gr;gr++){qupvt.on_pe(gfp,pe,max_bits[gr],avg,gr,0);if(gfc.mode_ext==$cPNKB.MPG_MD_MS_LR)ms_convert(gfc.l3_side,gr);for(var ch=0;ch<gfc.channels_out;++ch){var cod_info=gfc.l3_side.tt[gr][ch];gfc.masking_lower=Math.pow(10.0,gfc.PSY.mask_adjust*0.1);init_outer_loop(gfc,cod_info);if(0!=qupvt.calc_xmin(gfp,ratio[gr][ch],cod_info,l3_xmin[gr][ch]))analog_silence=0;bits+=max_bits[gr][ch];}}for(var gr=0;gr<gfc.mode_gr;gr++){for(var ch=0;ch<gfc.channels_out;ch++)if(bits>maximum_framebits){max_bits[gr][ch]*=maximum_framebits;max_bits[gr][ch]/=bits;}/* for ch */}/* for gr */return analog_silence;};/**
2117
+ * calculates target bits for ABR encoding
2118
+ *
2119
+ * mt 2000/05/31
2120
+ */this.calc_target_bits=function(gfp,pe,ms_ener_ratio,targ_bits,analog_silence_bits,max_frame_bits){var gfc=gfp.internal_flags;var l3_side=gfc.l3_side;var res_factor;var gr,ch,totbits,mean_bits=0;gfc.bitrate_index=gfc.VBR_max_bitrate;var mb=new MeanBits(mean_bits);max_frame_bits[0]=rv.ResvFrameBegin(gfp,mb);mean_bits=mb.bits;gfc.bitrate_index=1;mean_bits=bs.getframebits(gfp)-gfc.sideinfo_len*8;analog_silence_bits[0]=mean_bits/(gfc.mode_gr*gfc.channels_out);mean_bits=gfp.VBR_mean_bitrate_kbps*gfp.framesize*1000;if((gfc.substep_shaping&1)!=0)mean_bits*=1.09;mean_bits/=gfp.out_samplerate;mean_bits-=gfc.sideinfo_len*8;mean_bits/=gfc.mode_gr*gfc.channels_out;/**
2121
+ * <PRE>
2122
+ * res_factor is the percentage of the target bitrate that should
2123
+ * be used on average. the remaining bits are added to the
2124
+ * bitreservoir and used for difficult to encode frames.
2125
+ *
2126
+ * Since we are tracking the average bitrate, we should adjust
2127
+ * res_factor "on the fly", increasing it if the average bitrate
2128
+ * is greater than the requested bitrate, and decreasing it
2129
+ * otherwise. Reasonable ranges are from .9 to 1.0
2130
+ *
2131
+ * Until we get the above suggestion working, we use the following
2132
+ * tuning:
2133
+ * compression ratio res_factor
2134
+ * 5.5 (256kbps) 1.0 no need for bitreservoir
2135
+ * 11 (128kbps) .93 7% held for reservoir
2136
+ *
2137
+ * with linear interpolation for other values.
2138
+ * </PRE>
2139
+ */res_factor=.93+.07*(11.0-gfp.compression_ratio)/5.5;if(res_factor<.90)res_factor=.90;if(res_factor>1.00)res_factor=1.00;for(gr=0;gr<gfc.mode_gr;gr++){var sum=0;for(ch=0;ch<gfc.channels_out;ch++){targ_bits[gr][ch]=int(res_factor*mean_bits);if(pe[gr][ch]>700){var add_bits=int((pe[gr][ch]-700)/1.4);var cod_info=l3_side.tt[gr][ch];targ_bits[gr][ch]=int(res_factor*mean_bits);/* short blocks use a little extra, no matter what the pe */if(cod_info.block_type==$cPNKB.SHORT_TYPE){if(add_bits<mean_bits/2)add_bits=mean_bits/2;}/* at most increase bits by 1.5*average */if(add_bits>mean_bits*3/2)add_bits=mean_bits*3/2;else if(add_bits<0)add_bits=0;targ_bits[gr][ch]+=add_bits;}if(targ_bits[gr][ch]>LameInternalFlags.MAX_BITS_PER_CHANNEL)targ_bits[gr][ch]=LameInternalFlags.MAX_BITS_PER_CHANNEL;sum+=targ_bits[gr][ch];}/* for ch */if(sum>LameInternalFlags.MAX_BITS_PER_GRANULE)for(ch=0;ch<gfc.channels_out;++ch){targ_bits[gr][ch]*=LameInternalFlags.MAX_BITS_PER_GRANULE;targ_bits[gr][ch]/=sum;}}/* for gr */if(gfc.mode_ext==$cPNKB.MPG_MD_MS_LR)for(gr=0;gr<gfc.mode_gr;gr++)qupvt.reduce_side(targ_bits[gr],ms_ener_ratio[gr],mean_bits*gfc.channels_out,LameInternalFlags.MAX_BITS_PER_GRANULE);/*
2140
+ * sum target bits
2141
+ */totbits=0;for(gr=0;gr<gfc.mode_gr;gr++)for(ch=0;ch<gfc.channels_out;ch++){if(targ_bits[gr][ch]>LameInternalFlags.MAX_BITS_PER_CHANNEL)targ_bits[gr][ch]=LameInternalFlags.MAX_BITS_PER_CHANNEL;totbits+=targ_bits[gr][ch];}/*
2142
+ * repartion target bits if needed
2143
+ */if(totbits>max_frame_bits[0]){for(gr=0;gr<gfc.mode_gr;gr++)for(ch=0;ch<gfc.channels_out;ch++){targ_bits[gr][ch]*=max_frame_bits[0];targ_bits[gr][ch]/=totbits;}}};}$df08f3a0d41b7a78$exports=$df08f3a0d41b7a78$var$Quantize;var $65Sx2=parcelRequire("65Sx2");var $b5a7ab7c590f5d1e$exports={};/*
2144
+ * bit reservoir source file
2145
+ *
2146
+ * Copyright (c) 1999-2000 Mark Taylor
2147
+ *
2148
+ * This library is free software; you can redistribute it and/or
2149
+ * modify it under the terms of the GNU Lesser General Public
2150
+ * License as published by the Free Software Foundation; either
2151
+ * version 2 of the License, or (at your option) any later version.
2152
+ *
2153
+ * This library is distributed in the hope that it will be useful,
2154
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2155
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2156
+ * Library General Public License for more details.
2157
+ *
2158
+ * You should have received a copy of the GNU Lesser General Public
2159
+ * License along with this library; if not, write to the
2160
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
2161
+ * Boston, MA 02111-1307, USA.
2162
+ */ /* $Id: Reservoir.java,v 1.9 2011/05/24 20:48:06 kenchis Exp $ */ //package mp3;
2163
+ /**
2164
+ * ResvFrameBegin:<BR>
2165
+ * Called (repeatedly) at the beginning of a frame. Updates the maximum size of
2166
+ * the reservoir, and checks to make sure main_data_begin was set properly by
2167
+ * the formatter<BR>
2168
+ * Background information:
2169
+ *
2170
+ * This is the original text from the ISO standard. Because of sooo many bugs
2171
+ * and irritations correcting comments are added in brackets []. A '^W' means
2172
+ * you should remove the last word.
2173
+ *
2174
+ * <PRE>
2175
+ * 1. The following rule can be used to calculate the maximum
2176
+ * number of bits used for one granule [^W frame]:<BR>
2177
+ * At the highest possible bitrate of Layer III (320 kbps
2178
+ * per stereo signal [^W^W^W], 48 kHz) the frames must be of
2179
+ * [^W^W^W are designed to have] constant length, i.e.
2180
+ * one buffer [^W^W the frame] length is:<BR>
2181
+ *
2182
+ * 320 kbps * 1152/48 kHz = 7680 bit = 960 byte
2183
+ *
2184
+ * This value is used as the maximum buffer per channel [^W^W] at
2185
+ * lower bitrates [than 320 kbps]. At 64 kbps mono or 128 kbps
2186
+ * stereo the main granule length is 64 kbps * 576/48 kHz = 768 bit
2187
+ * [per granule and channel] at 48 kHz sampling frequency.
2188
+ * This means that there is a maximum deviation (short time buffer
2189
+ * [= reservoir]) of 7680 - 2*2*768 = 4608 bits is allowed at 64 kbps.
2190
+ * The actual deviation is equal to the number of bytes [with the
2191
+ * meaning of octets] denoted by the main_data_end offset pointer.
2192
+ * The actual maximum deviation is (2^9-1)*8 bit = 4088 bits
2193
+ * [for MPEG-1 and (2^8-1)*8 bit for MPEG-2, both are hard limits].
2194
+ * ... The xchange of buffer bits between the left and right channel
2195
+ * is allowed without restrictions [exception: dual channel].
2196
+ * Because of the [constructed] constraint on the buffer size
2197
+ * main_data_end is always set to 0 in the case of bit_rate_index==14,
2198
+ * i.e. data rate 320 kbps per stereo signal [^W^W^W]. In this case
2199
+ * all data are allocated between adjacent header [^W sync] words
2200
+ * [, i.e. there is no buffering at all].
2201
+ * </PRE>
2202
+ */var $3YDN3=parcelRequire("3YDN3");var $b5a7ab7c590f5d1e$var$assert=$3YDN3.assert;function $b5a7ab7c590f5d1e$var$Reservoir(){var bs;this.setModules=function(_bs){bs=_bs;};this.ResvFrameBegin=function(gfp,mean_bits){var gfc=gfp.internal_flags;var maxmp3buf;var l3_side=gfc.l3_side;var frameLength=bs.getframebits(gfp);mean_bits.bits=(frameLength-gfc.sideinfo_len*8)/gfc.mode_gr;/**
2203
+ * <PRE>
2204
+ * Meaning of the variables:
2205
+ * resvLimit: (0, 8, ..., 8*255 (MPEG-2), 8*511 (MPEG-1))
2206
+ * Number of bits can be stored in previous frame(s) due to
2207
+ * counter size constaints
2208
+ * maxmp3buf: ( ??? ... 8*1951 (MPEG-1 and 2), 8*2047 (MPEG-2.5))
2209
+ * Number of bits allowed to encode one frame (you can take 8*511 bit
2210
+ * from the bit reservoir and at most 8*1440 bit from the current
2211
+ * frame (320 kbps, 32 kHz), so 8*1951 bit is the largest possible
2212
+ * value for MPEG-1 and -2)
2213
+ *
2214
+ * maximum allowed granule/channel size times 4 = 8*2047 bits.,
2215
+ * so this is the absolute maximum supported by the format.
2216
+ *
2217
+ *
2218
+ * fullFrameBits: maximum number of bits available for encoding
2219
+ * the current frame.
2220
+ *
2221
+ * mean_bits: target number of bits per granule.
2222
+ *
2223
+ * frameLength:
2224
+ *
2225
+ * gfc.ResvMax: maximum allowed reservoir
2226
+ *
2227
+ * gfc.ResvSize: current reservoir size
2228
+ *
2229
+ * l3_side.resvDrain_pre:
2230
+ * ancillary data to be added to previous frame:
2231
+ * (only usefull in VBR modes if it is possible to have
2232
+ * maxmp3buf < fullFrameBits)). Currently disabled,
2233
+ * see #define NEW_DRAIN
2234
+ * 2010-02-13: RH now enabled, it seems to be needed for CBR too,
2235
+ * as there exists one example, where the FhG decoder
2236
+ * can't decode a -b320 CBR file anymore.
2237
+ *
2238
+ * l3_side.resvDrain_post:
2239
+ * ancillary data to be added to this frame:
2240
+ *
2241
+ * </PRE>
2242
+ */ /* main_data_begin has 9 bits in MPEG-1, 8 bits MPEG-2 */var resvLimit=2048*gfc.mode_gr-8;/*
2243
+ * maximum allowed frame size. dont use more than this number of bits,
2244
+ * even if the frame has the space for them:
2245
+ */if(gfp.brate>320)/* in freeformat the buffer is constant */maxmp3buf=8*int(gfp.brate*1000/(gfp.out_samplerate/1152)/8+.5);else {/*
2246
+ * all mp3 decoders should have enough buffer to handle this value:
2247
+ * size of a 320kbps 32kHz frame
2248
+ */maxmp3buf=11520;/*
2249
+ * Bouvigne suggests this more lax interpretation of the ISO doc
2250
+ * instead of using 8*960.
2251
+ */if(gfp.strict_ISO)maxmp3buf=8*int(320000/(gfp.out_samplerate/1152)/8+.5);}gfc.ResvMax=maxmp3buf-frameLength;if(gfc.ResvMax>resvLimit)gfc.ResvMax=resvLimit;if(gfc.ResvMax<0||gfp.disable_reservoir)gfc.ResvMax=0;var fullFrameBits=mean_bits.bits*gfc.mode_gr+Math.min(gfc.ResvSize,gfc.ResvMax);if(fullFrameBits>maxmp3buf)fullFrameBits=maxmp3buf;$b5a7ab7c590f5d1e$var$assert(0==gfc.ResvMax%8);$b5a7ab7c590f5d1e$var$assert(gfc.ResvMax>=0);l3_side.resvDrain_pre=0;// frame analyzer code
2252
+ if(gfc.pinfo!=null){/*
2253
+ * expected bits per channel per granule [is this also right for
2254
+ * mono/stereo, MPEG-1/2 ?]
2255
+ */gfc.pinfo.mean_bits=mean_bits.bits/2;gfc.pinfo.resvsize=gfc.ResvSize;}return fullFrameBits;};/**
2256
+ * returns targ_bits: target number of bits to use for 1 granule<BR>
2257
+ * extra_bits: amount extra available from reservoir<BR>
2258
+ * Mark Taylor 4/99
2259
+ */this.ResvMaxBits=function(gfp,mean_bits,targ_bits,cbr){var gfc=gfp.internal_flags;var add_bits;var ResvSize=gfc.ResvSize,ResvMax=gfc.ResvMax;/* compensate the saved bits used in the 1st granule */if(cbr!=0)ResvSize+=mean_bits;if((gfc.substep_shaping&1)!=0)ResvMax*=0.9;targ_bits.bits=mean_bits;/* extra bits if the reservoir is almost full */if(ResvSize*10>ResvMax*9){add_bits=ResvSize-ResvMax*9/10;targ_bits.bits+=add_bits;gfc.substep_shaping|=0x80;}else {add_bits=0;gfc.substep_shaping&=0x7f;/*
2260
+ * build up reservoir. this builds the reservoir a little slower
2261
+ * than FhG. It could simple be mean_bits/15, but this was rigged to
2262
+ * always produce 100 (the old value) at 128kbs
2263
+ */if(!gfp.disable_reservoir&&0==(gfc.substep_shaping&1))targ_bits.bits-=.1*mean_bits;}/* amount from the reservoir we are allowed to use. ISO says 6/10 */var extra_bits=ResvSize<gfc.ResvMax*6/10?ResvSize:gfc.ResvMax*6/10;extra_bits-=add_bits;if(extra_bits<0)extra_bits=0;return extra_bits;};/**
2264
+ * Called after a granule's bit allocation. Readjusts the size of the
2265
+ * reservoir to reflect the granule's usage.
2266
+ */this.ResvAdjust=function(gfc,gi){gfc.ResvSize-=gi.part2_3_length+gi.part2_length;};/**
2267
+ * Called after all granules in a frame have been allocated. Makes sure that
2268
+ * the reservoir size is within limits, possibly by adding stuffing bits.
2269
+ */this.ResvFrameEnd=function(gfc,mean_bits){var over_bits;var l3_side=gfc.l3_side;gfc.ResvSize+=mean_bits*gfc.mode_gr;var stuffingBits=0;l3_side.resvDrain_post=0;l3_side.resvDrain_pre=0;/* we must be byte aligned */if((over_bits=gfc.ResvSize%8)!=0)stuffingBits+=over_bits;over_bits=gfc.ResvSize-stuffingBits-gfc.ResvMax;if(over_bits>0){$b5a7ab7c590f5d1e$var$assert(0==over_bits%8);$b5a7ab7c590f5d1e$var$assert(over_bits>=0);stuffingBits+=over_bits;}var mdb_bytes=Math.min(l3_side.main_data_begin*8,stuffingBits)/8;l3_side.resvDrain_pre+=8*mdb_bytes;stuffingBits-=8*mdb_bytes;gfc.ResvSize-=8*mdb_bytes;l3_side.main_data_begin-=mdb_bytes;/* drain the rest into this frames ancillary data */l3_side.resvDrain_post+=stuffingBits;gfc.ResvSize-=stuffingBits;};}$b5a7ab7c590f5d1e$exports=$b5a7ab7c590f5d1e$var$Reservoir;var $jL6I1=parcelRequire("jL6I1");var $ctaQC=parcelRequire("ctaQC");parcelRequire("cPNKB");var $34609aeb1df0c2af$exports={};function $34609aeb1df0c2af$var$Version(){/**
2270
+ * URL for the LAME website.
2271
+ */var LAME_URL="http://www.mp3dev.org/";/**
2272
+ * Major version number.
2273
+ */var LAME_MAJOR_VERSION=3;/**
2274
+ * Minor version number.
2275
+ */var LAME_MINOR_VERSION=98;/**
2276
+ * Patch level.
2277
+ */var LAME_PATCH_VERSION=4;/**
2278
+ * Major version number.
2279
+ */var PSY_MAJOR_VERSION=0;/**
2280
+ * Minor version number.
2281
+ */var PSY_MINOR_VERSION=93;/**
2282
+ * A string which describes the version of LAME.
2283
+ *
2284
+ * @return string which describes the version of LAME
2285
+ */this.getLameVersion=function(){// primary to write screen reports
2286
+ return LAME_MAJOR_VERSION+"."+LAME_MINOR_VERSION+"."+LAME_PATCH_VERSION;};/**
2287
+ * The short version of the LAME version string.
2288
+ *
2289
+ * @return short version of the LAME version string
2290
+ */this.getLameShortVersion=function(){// Adding date and time to version string makes it harder for output
2291
+ // validation
2292
+ return LAME_MAJOR_VERSION+"."+LAME_MINOR_VERSION+"."+LAME_PATCH_VERSION;};/**
2293
+ * The shortest version of the LAME version string.
2294
+ *
2295
+ * @return shortest version of the LAME version string
2296
+ */this.getLameVeryShortVersion=function(){// Adding date and time to version string makes it harder for output
2297
+ return "LAME"+LAME_MAJOR_VERSION+"."+LAME_MINOR_VERSION+"r";};/**
2298
+ * String which describes the version of GPSYCHO
2299
+ *
2300
+ * @return string which describes the version of GPSYCHO
2301
+ */this.getPsyVersion=function(){return PSY_MAJOR_VERSION+"."+PSY_MINOR_VERSION;};/**
2302
+ * String which is a URL for the LAME website.
2303
+ *
2304
+ * @return string which is a URL for the LAME website
2305
+ */this.getLameUrl=function(){return LAME_URL;};/**
2306
+ * Quite useless for a java version, however we are compatible ;-)
2307
+ *
2308
+ * @return "32bits"
2309
+ */this.getLameOsBitness=function(){return "32bits";};}$34609aeb1df0c2af$exports=$34609aeb1df0c2af$var$Version;var $e674985ea62d27cf$exports={};var $3YDN3=parcelRequire("3YDN3");var $e674985ea62d27cf$var$System=$3YDN3.System;var $e674985ea62d27cf$var$VbrMode=$3YDN3.VbrMode;$3YDN3.Float;var $e674985ea62d27cf$var$ShortBlock=$3YDN3.ShortBlock;$3YDN3.Util;var $e674985ea62d27cf$var$Arrays=$3YDN3.Arrays;$3YDN3.new_array_n;var $e674985ea62d27cf$var$new_byte=$3YDN3.new_byte;$3YDN3.new_double;$3YDN3.new_float;$3YDN3.new_float_n;$3YDN3.new_int;$3YDN3.new_int_n;var $e674985ea62d27cf$var$assert=$3YDN3.assert;/**
2310
+ * A Vbr header may be present in the ancillary data field of the first frame of
2311
+ * an mp3 bitstream<BR>
2312
+ * The Vbr header (optionally) contains
2313
+ * <UL>
2314
+ * <LI>frames total number of audio frames in the bitstream
2315
+ * <LI>bytes total number of bytes in the bitstream
2316
+ * <LI>toc table of contents
2317
+ * </UL>
2318
+ *
2319
+ * toc (table of contents) gives seek points for random access.<BR>
2320
+ * The ith entry determines the seek point for i-percent duration.<BR>
2321
+ * seek point in bytes = (toc[i]/256.0) * total_bitstream_bytes<BR>
2322
+ * e.g. half duration seek point = (toc[50]/256.0) * total_bitstream_bytes
2323
+ */$e674985ea62d27cf$var$VBRTag.NUMTOCENTRIES=100;$e674985ea62d27cf$var$VBRTag.MAXFRAMESIZE=2880;function $e674985ea62d27cf$var$VBRTag(){var lame;var bs;var v;this.setModules=function(_lame,_bs,_v){lame=_lame;bs=_bs;v=_v;};var FRAMES_FLAG=0x0001;var BYTES_FLAG=0x0002;var TOC_FLAG=0x0004;var VBR_SCALE_FLAG=0x0008;var NUMTOCENTRIES=$e674985ea62d27cf$var$VBRTag.NUMTOCENTRIES;/**
2324
+ * (0xB40) the max freeformat 640 32kHz framesize.
2325
+ */var MAXFRAMESIZE=$e674985ea62d27cf$var$VBRTag.MAXFRAMESIZE;/**
2326
+ * <PRE>
2327
+ * 4 bytes for Header Tag
2328
+ * 4 bytes for Header Flags
2329
+ * 100 bytes for entry (toc)
2330
+ * 4 bytes for frame size
2331
+ * 4 bytes for stream size
2332
+ * 4 bytes for VBR scale. a VBR quality indicator: 0=best 100=worst
2333
+ * 20 bytes for LAME tag. for example, "LAME3.12 (beta 6)"
2334
+ * ___________
2335
+ * 140 bytes
2336
+ * </PRE>
2337
+ */var VBRHEADERSIZE=NUMTOCENTRIES+4+4+4+4+4;var LAMEHEADERSIZE=VBRHEADERSIZE+9+1+1+8+1+1+3+1+1+2+4+2+2;/**
2338
+ * The size of the Xing header MPEG-1, bit rate in kbps.
2339
+ */var XING_BITRATE1=128;/**
2340
+ * The size of the Xing header MPEG-2, bit rate in kbps.
2341
+ */var XING_BITRATE2=64;/**
2342
+ * The size of the Xing header MPEG-2.5, bit rate in kbps.
2343
+ */var XING_BITRATE25=32;/**
2344
+ * ISO-8859-1 charset for byte to string operations.
2345
+ */var ISO_8859_1=null;//Charset.forName("ISO-8859-1");
2346
+ /**
2347
+ * VBR header magic string.
2348
+ */var VBRTag0="Xing";/**
2349
+ * VBR header magic string (VBR == VBRMode.vbr_off).
2350
+ */var VBRTag1="Info";/**
2351
+ * Lookup table for fast CRC-16 computation. Uses the polynomial
2352
+ * x^16+x^15+x^2+1
2353
+ */var crc16Lookup=[0x0000,0xC0C1,0xC181,0x0140,0xC301,0x03C0,0x0280,0xC241,0xC601,0x06C0,0x0780,0xC741,0x0500,0xC5C1,0xC481,0x0440,0xCC01,0x0CC0,0x0D80,0xCD41,0x0F00,0xCFC1,0xCE81,0x0E40,0x0A00,0xCAC1,0xCB81,0x0B40,0xC901,0x09C0,0x0880,0xC841,0xD801,0x18C0,0x1980,0xD941,0x1B00,0xDBC1,0xDA81,0x1A40,0x1E00,0xDEC1,0xDF81,0x1F40,0xDD01,0x1DC0,0x1C80,0xDC41,0x1400,0xD4C1,0xD581,0x1540,0xD701,0x17C0,0x1680,0xD641,0xD201,0x12C0,0x1380,0xD341,0x1100,0xD1C1,0xD081,0x1040,0xF001,0x30C0,0x3180,0xF141,0x3300,0xF3C1,0xF281,0x3240,0x3600,0xF6C1,0xF781,0x3740,0xF501,0x35C0,0x3480,0xF441,0x3C00,0xFCC1,0xFD81,0x3D40,0xFF01,0x3FC0,0x3E80,0xFE41,0xFA01,0x3AC0,0x3B80,0xFB41,0x3900,0xF9C1,0xF881,0x3840,0x2800,0xE8C1,0xE981,0x2940,0xEB01,0x2BC0,0x2A80,0xEA41,0xEE01,0x2EC0,0x2F80,0xEF41,0x2D00,0xEDC1,0xEC81,0x2C40,0xE401,0x24C0,0x2580,0xE541,0x2700,0xE7C1,0xE681,0x2640,0x2200,0xE2C1,0xE381,0x2340,0xE101,0x21C0,0x2080,0xE041,0xA001,0x60C0,0x6180,0xA141,0x6300,0xA3C1,0xA281,0x6240,0x6600,0xA6C1,0xA781,0x6740,0xA501,0x65C0,0x6480,0xA441,0x6C00,0xACC1,0xAD81,0x6D40,0xAF01,0x6FC0,0x6E80,0xAE41,0xAA01,0x6AC0,0x6B80,0xAB41,0x6900,0xA9C1,0xA881,0x6840,0x7800,0xB8C1,0xB981,0x7940,0xBB01,0x7BC0,0x7A80,0xBA41,0xBE01,0x7EC0,0x7F80,0xBF41,0x7D00,0xBDC1,0xBC81,0x7C40,0xB401,0x74C0,0x7580,0xB541,0x7700,0xB7C1,0xB681,0x7640,0x7200,0xB2C1,0xB381,0x7340,0xB101,0x71C0,0x7080,0xB041,0x5000,0x90C1,0x9181,0x5140,0x9301,0x53C0,0x5280,0x9241,0x9601,0x56C0,0x5780,0x9741,0x5500,0x95C1,0x9481,0x5440,0x9C01,0x5CC0,0x5D80,0x9D41,0x5F00,0x9FC1,0x9E81,0x5E40,0x5A00,0x9AC1,0x9B81,0x5B40,0x9901,0x59C0,0x5880,0x9841,0x8801,0x48C0,0x4980,0x8941,0x4B00,0x8BC1,0x8A81,0x4A40,0x4E00,0x8EC1,0x8F81,0x4F40,0x8D01,0x4DC0,0x4C80,0x8C41,0x4400,0x84C1,0x8581,0x4540,0x8701,0x47C0,0x4680,0x8641,0x8201,0x42C0,0x4380,0x8341,0x4100,0x81C1,0x8081,0x4040];/***********************************************************************
2354
+ * Robert Hegemann 2001-01-17
2355
+ ***********************************************************************/function addVbr(v,bitrate){v.nVbrNumFrames++;v.sum+=bitrate;v.seen++;if(v.seen<v.want)return;if(v.pos<v.size){v.bag[v.pos]=v.sum;v.pos++;v.seen=0;}if(v.pos==v.size){for(var i=1;i<v.size;i+=2)v.bag[i/2]=v.bag[i];v.want*=2;v.pos/=2;}}function xingSeekTable(v,t){if(v.pos<=0)return;for(var i=1;i<NUMTOCENTRIES;++i){var j=i/NUMTOCENTRIES,act,sum;var indx=0|Math.floor(j*v.pos);if(indx>v.pos-1)indx=v.pos-1;act=v.bag[indx];sum=v.sum;var seek_point=0|256.*act/sum;if(seek_point>255)seek_point=255;t[i]=0xff&seek_point;}}/**
2356
+ * Add VBR entry, used to fill the VBR TOC entries.
2357
+ *
2358
+ * @param gfp
2359
+ * global flags
2360
+ */this.addVbrFrame=function(gfp){var gfc=gfp.internal_flags;var kbps=Tables.bitrate_table[gfp.version][gfc.bitrate_index];$e674985ea62d27cf$var$assert(gfc.VBR_seek_table.bag!=null);addVbr(gfc.VBR_seek_table,kbps);};/**
2361
+ * Read big endian integer (4-bytes) from header.
2362
+ *
2363
+ * @param buf
2364
+ * header containing the integer
2365
+ * @param bufPos
2366
+ * offset into the header
2367
+ * @return extracted integer
2368
+ */function extractInteger(buf,bufPos){var x=buf[bufPos+0]&0xff;x<<=8;x|=buf[bufPos+1]&0xff;x<<=8;x|=buf[bufPos+2]&0xff;x<<=8;x|=buf[bufPos+3]&0xff;return x;}/**
2369
+ * Write big endian integer (4-bytes) in the header.
2370
+ *
2371
+ * @param buf
2372
+ * header to write the integer into
2373
+ * @param bufPos
2374
+ * offset into the header
2375
+ * @param value
2376
+ * integer value to write
2377
+ */function createInteger(buf,bufPos,value){buf[bufPos+0]=0xff&(value>>24&0xff);buf[bufPos+1]=0xff&(value>>16&0xff);buf[bufPos+2]=0xff&(value>>8&0xff);buf[bufPos+3]=0xff&(value&0xff);}/**
2378
+ * Write big endian short (2-bytes) in the header.
2379
+ *
2380
+ * @param buf
2381
+ * header to write the integer into
2382
+ * @param bufPos
2383
+ * offset into the header
2384
+ * @param value
2385
+ * integer value to write
2386
+ */function createShort(buf,bufPos,value){buf[bufPos+0]=0xff&(value>>8&0xff);buf[bufPos+1]=0xff&(value&0xff);}/**
2387
+ * Check for magic strings (Xing/Info).
2388
+ *
2389
+ * @param buf
2390
+ * header to check
2391
+ * @param bufPos
2392
+ * header offset to check
2393
+ * @return magic string found
2394
+ */function isVbrTag(buf,bufPos){return new String(buf,bufPos,VBRTag0.length(),ISO_8859_1).equals(VBRTag0)||new String(buf,bufPos,VBRTag1.length(),ISO_8859_1).equals(VBRTag1);}function shiftInBitsValue(x,n,v){return 0xff&(x<<n|v&~(-1<<n));}/**
2395
+ * Construct the MP3 header using the settings of the global flags.
2396
+ *
2397
+ * <img src="1000px-Mp3filestructure.svg.png">
2398
+ *
2399
+ * @param gfp
2400
+ * global flags
2401
+ * @param buffer
2402
+ * header
2403
+ */function setLameTagFrameHeader(gfp,buffer){var gfc=gfp.internal_flags;// MP3 Sync Word
2404
+ buffer[0]=shiftInBitsValue(buffer[0],8,0xff);buffer[1]=shiftInBitsValue(buffer[1],3,7);buffer[1]=shiftInBitsValue(buffer[1],1,gfp.out_samplerate<16000?0:1);// Version
2405
+ buffer[1]=shiftInBitsValue(buffer[1],1,gfp.version);// 01 == Layer 3
2406
+ buffer[1]=shiftInBitsValue(buffer[1],2,1);// Error protection
2407
+ buffer[1]=shiftInBitsValue(buffer[1],1,!gfp.error_protection?1:0);// Bit rate
2408
+ buffer[2]=shiftInBitsValue(buffer[2],4,gfc.bitrate_index);// Frequency
2409
+ buffer[2]=shiftInBitsValue(buffer[2],2,gfc.samplerate_index);// Pad. Bit
2410
+ buffer[2]=shiftInBitsValue(buffer[2],1,0);// Priv. Bit
2411
+ buffer[2]=shiftInBitsValue(buffer[2],1,gfp.extension);// Mode
2412
+ buffer[3]=shiftInBitsValue(buffer[3],2,gfp.mode.ordinal());// Mode extension (Used with Joint Stereo)
2413
+ buffer[3]=shiftInBitsValue(buffer[3],2,gfc.mode_ext);// Copy
2414
+ buffer[3]=shiftInBitsValue(buffer[3],1,gfp.copyright);// Original
2415
+ buffer[3]=shiftInBitsValue(buffer[3],1,gfp.original);// Emphasis
2416
+ buffer[3]=shiftInBitsValue(buffer[3],2,gfp.emphasis);/* the default VBR header. 48 kbps layer III, no padding, no crc */ /* but sampling freq, mode and copyright/copy protection taken */ /* from first valid frame */buffer[0]=0xff;var abyte=0xff&(buffer[1]&0xf1);var bitrate;if(1==gfp.version)bitrate=XING_BITRATE1;else if(gfp.out_samplerate<16000)bitrate=XING_BITRATE25;else bitrate=XING_BITRATE2;if(gfp.VBR==$e674985ea62d27cf$var$VbrMode.vbr_off)bitrate=gfp.brate;var bbyte;if(gfp.free_format)bbyte=0x00;else bbyte=0xff&16*lame.BitrateIndex(bitrate,gfp.version,gfp.out_samplerate);/*
2417
+ * Use as much of the info from the real frames in the Xing header:
2418
+ * samplerate, channels, crc, etc...
2419
+ */if(gfp.version==1){/* MPEG1 */buffer[1]=0xff&(abyte|0x0a);/* was 0x0b; */abyte=0xff&(buffer[2]&0x0d);/* AF keep also private bit */buffer[2]=0xff&(bbyte|abyte);/* 64kbs MPEG1 frame */}else {/* MPEG2 */buffer[1]=0xff&(abyte|0x02);/* was 0x03; */abyte=0xff&(buffer[2]&0x0d);/* AF keep also private bit */buffer[2]=0xff&(bbyte|abyte);/* 64kbs MPEG2 frame */}}/**
2420
+ * Get VBR tag information
2421
+ *
2422
+ * @param buf
2423
+ * header to analyze
2424
+ * @param bufPos
2425
+ * offset into the header
2426
+ * @return VBR tag data
2427
+ */this.getVbrTag=function(buf){var pTagData=new VBRTagData();var bufPos=0;/* get Vbr header data */pTagData.flags=0;/* get selected MPEG header data */var hId=buf[bufPos+1]>>3&1;var hSrIndex=buf[bufPos+2]>>2&3;var hMode=buf[bufPos+3]>>6&3;var hBitrate=buf[bufPos+2]>>4&0xf;hBitrate=Tables.bitrate_table[hId][hBitrate];/* check for FFE syncword */if(buf[bufPos+1]>>4==0xE)pTagData.samprate=Tables.samplerate_table[2][hSrIndex];else pTagData.samprate=Tables.samplerate_table[hId][hSrIndex];/* determine offset of header */if(hId!=0){/* mpeg1 */if(hMode!=3)bufPos+=36;else bufPos+=21;}else/* mpeg2 */if(hMode!=3)bufPos+=21;else bufPos+=13;if(!isVbrTag(buf,bufPos))return null;bufPos+=4;pTagData.hId=hId;/* get flags */var head_flags=pTagData.flags=extractInteger(buf,bufPos);bufPos+=4;if((head_flags&FRAMES_FLAG)!=0){pTagData.frames=extractInteger(buf,bufPos);bufPos+=4;}if((head_flags&BYTES_FLAG)!=0){pTagData.bytes=extractInteger(buf,bufPos);bufPos+=4;}if((head_flags&TOC_FLAG)!=0){if(pTagData.toc!=null)for(var i=0;i<NUMTOCENTRIES;i++)pTagData.toc[i]=buf[bufPos+i];bufPos+=NUMTOCENTRIES;}pTagData.vbrScale=-1;if((head_flags&VBR_SCALE_FLAG)!=0){pTagData.vbrScale=extractInteger(buf,bufPos);bufPos+=4;}pTagData.headersize=(hId+1)*72000*hBitrate/pTagData.samprate;bufPos+=21;var encDelay=buf[bufPos+0]<<4;encDelay+=buf[bufPos+1]>>4;var encPadding=(buf[bufPos+1]&0x0F)<<8;encPadding+=buf[bufPos+2]&0xff;/* check for reasonable values (this may be an old Xing header, */ /* not a INFO tag) */if(encDelay<0||encDelay>3000)encDelay=-1;if(encPadding<0||encPadding>3000)encPadding=-1;pTagData.encDelay=encDelay;pTagData.encPadding=encPadding;/* success */return pTagData;};/**
2428
+ * Initializes the header
2429
+ *
2430
+ * @param gfp
2431
+ * global flags
2432
+ */this.InitVbrTag=function(gfp){var gfc=gfp.internal_flags;/**
2433
+ * <PRE>
2434
+ * Xing VBR pretends to be a 48kbs layer III frame. (at 44.1kHz).
2435
+ * (at 48kHz they use 56kbs since 48kbs frame not big enough for
2436
+ * table of contents)
2437
+ * let's always embed Xing header inside a 64kbs layer III frame.
2438
+ * this gives us enough room for a LAME version string too.
2439
+ * size determined by sampling frequency (MPEG1)
2440
+ * 32kHz: 216 bytes@48kbs 288bytes@ 64kbs
2441
+ * 44.1kHz: 156 bytes 208bytes@64kbs (+1 if padding = 1)
2442
+ * 48kHz: 144 bytes 192
2443
+ *
2444
+ * MPEG 2 values are the same since the framesize and samplerate
2445
+ * are each reduced by a factor of 2.
2446
+ * </PRE>
2447
+ */var kbps_header;if(1==gfp.version)kbps_header=XING_BITRATE1;else if(gfp.out_samplerate<16000)kbps_header=XING_BITRATE25;else kbps_header=XING_BITRATE2;if(gfp.VBR==$e674985ea62d27cf$var$VbrMode.vbr_off)kbps_header=gfp.brate;// make sure LAME Header fits into Frame
2448
+ var totalFrameSize=(gfp.version+1)*72000*kbps_header/gfp.out_samplerate;var headerSize=gfc.sideinfo_len+LAMEHEADERSIZE;gfc.VBR_seek_table.TotalFrameSize=totalFrameSize;if(totalFrameSize<headerSize||totalFrameSize>MAXFRAMESIZE){/* disable tag, it wont fit */gfp.bWriteVbrTag=false;return;}gfc.VBR_seek_table.nVbrNumFrames=0;gfc.VBR_seek_table.nBytesWritten=0;gfc.VBR_seek_table.sum=0;gfc.VBR_seek_table.seen=0;gfc.VBR_seek_table.want=1;gfc.VBR_seek_table.pos=0;if(gfc.VBR_seek_table.bag==null){gfc.VBR_seek_table.bag=new int[400]();gfc.VBR_seek_table.size=400;}// write dummy VBR tag of all 0's into bitstream
2449
+ var buffer=$e674985ea62d27cf$var$new_byte(MAXFRAMESIZE);setLameTagFrameHeader(gfp,buffer);var n=gfc.VBR_seek_table.TotalFrameSize;for(var i=0;i<n;++i)bs.add_dummy_byte(gfp,buffer[i]&0xff,1);};/**
2450
+ * Fast CRC-16 computation (uses table crc16Lookup).
2451
+ *
2452
+ * @param value
2453
+ * @param crc
2454
+ * @return
2455
+ */function crcUpdateLookup(value,crc){var tmp=crc^value;crc=crc>>8^crc16Lookup[tmp&0xff];return crc;}this.updateMusicCRC=function(crc,buffer,bufferPos,size){for(var i=0;i<size;++i)crc[0]=crcUpdateLookup(buffer[bufferPos+i],crc[0]);};/**
2456
+ * Write LAME info: mini version + info on various switches used (Jonathan
2457
+ * Dee 2001/08/31).
2458
+ *
2459
+ * @param gfp
2460
+ * global flags
2461
+ * @param musicLength
2462
+ * music length
2463
+ * @param streamBuffer
2464
+ * pointer to output buffer
2465
+ * @param streamBufferPos
2466
+ * offset into the output buffer
2467
+ * @param crc
2468
+ * computation of CRC-16 of Lame Tag so far (starting at frame
2469
+ * sync)
2470
+ * @return number of bytes written to the stream
2471
+ */function putLameVBR(gfp,musicLength,streamBuffer,streamBufferPos,crc){var gfc=gfp.internal_flags;var bytesWritten=0;/* encoder delay */var encDelay=gfp.encoder_delay;/* encoder padding */var encPadding=gfp.encoder_padding;/* recall: gfp.VBR_q is for example set by the switch -V */ /* gfp.quality by -q, -h, -f, etc */var quality=100-10*gfp.VBR_q-gfp.quality;var version=v.getLameVeryShortVersion();var vbr;var revision=0x00;var revMethod;// numbering different in vbr_mode vs. Lame tag
2472
+ var vbrTypeTranslator=[1,5,3,2,4,0,3];var lowpass=0|(gfp.lowpassfreq/100.0+.5>255?255:gfp.lowpassfreq/100.0+.5);var peakSignalAmplitude=0;var radioReplayGain=0;var audiophileReplayGain=0;var noiseShaping=gfp.internal_flags.noise_shaping;var stereoMode=0;var nonOptimal=0;var sourceFreq=0;var misc=0;var musicCRC=0;// psy model type: Gpsycho or NsPsytune
2473
+ var expNPsyTune=(gfp.exp_nspsytune&1)!=0;var safeJoint=(gfp.exp_nspsytune&2)!=0;var noGapMore=false;var noGapPrevious=false;var noGapCount=gfp.internal_flags.nogap_total;var noGapCurr=gfp.internal_flags.nogap_current;// 4 bits
2474
+ var athType=gfp.ATHtype;var flags=0;// vbr modes
2475
+ var abrBitrate;switch(gfp.VBR){case vbr_abr:abrBitrate=gfp.VBR_mean_bitrate_kbps;break;case vbr_off:abrBitrate=gfp.brate;break;default:abrBitrate=gfp.VBR_min_bitrate_kbps;}// revision and vbr method
2476
+ if(gfp.VBR.ordinal()<vbrTypeTranslator.length)vbr=vbrTypeTranslator[gfp.VBR.ordinal()];else vbr=0x00;// unknown
2477
+ revMethod=0x10*revision+vbr;// ReplayGain
2478
+ if(gfc.findReplayGain){if(gfc.RadioGain>0x1FE)gfc.RadioGain=0x1FE;if(gfc.RadioGain<-510)gfc.RadioGain=-510;// set name code
2479
+ radioReplayGain=0x2000;// set originator code to `determined automatically'
2480
+ radioReplayGain|=0xC00;if(gfc.RadioGain>=0)// set gain adjustment
2481
+ radioReplayGain|=gfc.RadioGain;else {// set the sign bit
2482
+ radioReplayGain|=0x200;// set gain adjustment
2483
+ radioReplayGain|=-gfc.RadioGain;}}// peak sample
2484
+ if(gfc.findPeakSample)peakSignalAmplitude=Math.abs(0|gfc.PeakSample/32767.0*Math.pow(2,23)+.5);// nogap
2485
+ if(noGapCount!=-1){if(noGapCurr>0)noGapPrevious=true;if(noGapCurr<noGapCount-1)noGapMore=true;}// flags
2486
+ flags=athType+((expNPsyTune?1:0)<<4)+((safeJoint?1:0)<<5)+((noGapMore?1:0)<<6)+((noGapPrevious?1:0)<<7);if(quality<0)quality=0;// stereo mode field (Intensity stereo is not implemented)
2487
+ switch(gfp.mode){case MONO:stereoMode=0;break;case STEREO:stereoMode=1;break;case DUAL_CHANNEL:stereoMode=2;break;case JOINT_STEREO:if(gfp.force_ms)stereoMode=4;else stereoMode=3;break;case NOT_SET://$FALL-THROUGH$
2488
+ default:stereoMode=7;break;}if(gfp.in_samplerate<=32000)sourceFreq=0x00;else if(gfp.in_samplerate==48000)sourceFreq=0x02;else if(gfp.in_samplerate>48000)sourceFreq=0x03;else// default is 44100Hz
2489
+ sourceFreq=0x01;// Check if the user overrided the default LAME behavior with some
2490
+ // nasty options
2491
+ if(gfp.short_blocks==$e674985ea62d27cf$var$ShortBlock.short_block_forced||gfp.short_blocks==$e674985ea62d27cf$var$ShortBlock.short_block_dispensed||gfp.lowpassfreq==-1&&gfp.highpassfreq==-1||/* "-k" */gfp.scale_left<gfp.scale_right||gfp.scale_left>gfp.scale_right||gfp.disable_reservoir&&gfp.brate<320||gfp.noATH||gfp.ATHonly||athType==0||gfp.in_samplerate<=32000)nonOptimal=1;misc=noiseShaping+(stereoMode<<2)+(nonOptimal<<5)+(sourceFreq<<6);musicCRC=gfc.nMusicCRC;// Write all this information into the stream
2492
+ createInteger(streamBuffer,streamBufferPos+bytesWritten,quality);bytesWritten+=4;for(var j=0;j<9;j++)streamBuffer[streamBufferPos+bytesWritten+j]=0xff&version.charAt(j);bytesWritten+=9;streamBuffer[streamBufferPos+bytesWritten]=0xff&revMethod;bytesWritten++;streamBuffer[streamBufferPos+bytesWritten]=0xff&lowpass;bytesWritten++;createInteger(streamBuffer,streamBufferPos+bytesWritten,peakSignalAmplitude);bytesWritten+=4;createShort(streamBuffer,streamBufferPos+bytesWritten,radioReplayGain);bytesWritten+=2;createShort(streamBuffer,streamBufferPos+bytesWritten,audiophileReplayGain);bytesWritten+=2;streamBuffer[streamBufferPos+bytesWritten]=0xff&flags;bytesWritten++;if(abrBitrate>=255)streamBuffer[streamBufferPos+bytesWritten]=0xFF;else streamBuffer[streamBufferPos+bytesWritten]=0xff&abrBitrate;bytesWritten++;streamBuffer[streamBufferPos+bytesWritten]=0xff&encDelay>>4;streamBuffer[streamBufferPos+bytesWritten+1]=0xff&(encDelay<<4)+(encPadding>>8);streamBuffer[streamBufferPos+bytesWritten+2]=0xff&encPadding;bytesWritten+=3;streamBuffer[streamBufferPos+bytesWritten]=0xff&misc;bytesWritten++;// unused in rev0
2493
+ streamBuffer[streamBufferPos+bytesWritten++]=0;createShort(streamBuffer,streamBufferPos+bytesWritten,gfp.preset);bytesWritten+=2;createInteger(streamBuffer,streamBufferPos+bytesWritten,musicLength);bytesWritten+=4;createShort(streamBuffer,streamBufferPos+bytesWritten,musicCRC);bytesWritten+=2;// Calculate tag CRC.... must be done here, since it includes previous
2494
+ // information
2495
+ for(var i=0;i<bytesWritten;i++)crc=crcUpdateLookup(streamBuffer[streamBufferPos+i],crc);createShort(streamBuffer,streamBufferPos+bytesWritten,crc);bytesWritten+=2;return bytesWritten;}function skipId3v2(fpStream){// seek to the beginning of the stream
2496
+ fpStream.seek(0);// read 10 bytes in case there's an ID3 version 2 header here
2497
+ var id3v2Header=$e674985ea62d27cf$var$new_byte(10);fpStream.readFully(id3v2Header);/* does the stream begin with the ID3 version 2 file identifier? */var id3v2TagSize;if(!new String(id3v2Header,"ISO-8859-1").startsWith("ID3"))/*
2498
+ * the tag size (minus the 10-byte header) is encoded into four
2499
+ * bytes where the most significant bit is clear in each byte
2500
+ */id3v2TagSize=((id3v2Header[6]&0x7f)<<21|(id3v2Header[7]&0x7f)<<14|(id3v2Header[8]&0x7f)<<7|id3v2Header[9]&0x7f)+id3v2Header.length;else/* no ID3 version 2 tag in this stream */id3v2TagSize=0;return id3v2TagSize;}this.getLameTagFrame=function(gfp,buffer){var gfc=gfp.internal_flags;if(!gfp.bWriteVbrTag)return 0;if(gfc.Class_ID!=Lame.LAME_ID)return 0;if(gfc.VBR_seek_table.pos<=0)return 0;if(buffer.length<gfc.VBR_seek_table.TotalFrameSize)return gfc.VBR_seek_table.TotalFrameSize;$e674985ea62d27cf$var$Arrays.fill(buffer,0,gfc.VBR_seek_table.TotalFrameSize,0);// 4 bytes frame header
2501
+ setLameTagFrameHeader(gfp,buffer);// Create TOC entries
2502
+ var toc=$e674985ea62d27cf$var$new_byte(NUMTOCENTRIES);if(gfp.free_format)for(var i=1;i<NUMTOCENTRIES;++i)toc[i]=0xff&255*i/100;else xingSeekTable(gfc.VBR_seek_table,toc);// Start writing the tag after the zero frame
2503
+ var streamIndex=gfc.sideinfo_len;/**
2504
+ * Note: Xing header specifies that Xing data goes in the ancillary data
2505
+ * with NO ERROR PROTECTION. If error protecton in enabled, the Xing
2506
+ * data still starts at the same offset, and now it is in sideinfo data
2507
+ * block, and thus will not decode correctly by non-Xing tag aware
2508
+ * players
2509
+ */if(gfp.error_protection)streamIndex-=2;// Put Vbr tag
2510
+ if(gfp.VBR==$e674985ea62d27cf$var$VbrMode.vbr_off){buffer[streamIndex++]=0xff&VBRTag1.charAt(0);buffer[streamIndex++]=0xff&VBRTag1.charAt(1);buffer[streamIndex++]=0xff&VBRTag1.charAt(2);buffer[streamIndex++]=0xff&VBRTag1.charAt(3);}else {buffer[streamIndex++]=0xff&VBRTag0.charAt(0);buffer[streamIndex++]=0xff&VBRTag0.charAt(1);buffer[streamIndex++]=0xff&VBRTag0.charAt(2);buffer[streamIndex++]=0xff&VBRTag0.charAt(3);}// Put header flags
2511
+ createInteger(buffer,streamIndex,FRAMES_FLAG+BYTES_FLAG+TOC_FLAG+VBR_SCALE_FLAG);streamIndex+=4;// Put Total Number of frames
2512
+ createInteger(buffer,streamIndex,gfc.VBR_seek_table.nVbrNumFrames);streamIndex+=4;// Put total audio stream size, including Xing/LAME Header
2513
+ var streamSize=gfc.VBR_seek_table.nBytesWritten+gfc.VBR_seek_table.TotalFrameSize;createInteger(buffer,streamIndex,0|streamSize);streamIndex+=4;/* Put TOC */$e674985ea62d27cf$var$System.arraycopy(toc,0,buffer,streamIndex,toc.length);streamIndex+=toc.length;if(gfp.error_protection)// (jo) error_protection: add crc16 information to header
2514
+ bs.CRC_writeheader(gfc,buffer);// work out CRC so far: initially crc = 0
2515
+ var crc=0x00;for(var i=0;i<streamIndex;i++)crc=crcUpdateLookup(buffer[i],crc);// Put LAME VBR info
2516
+ streamIndex+=putLameVBR(gfp,streamSize,buffer,streamIndex,crc);return gfc.VBR_seek_table.TotalFrameSize;};/**
2517
+ * Write final VBR tag to the file.
2518
+ *
2519
+ * @param gfp
2520
+ * global flags
2521
+ * @param stream
2522
+ * stream to add the VBR tag to
2523
+ * @return 0 (OK), -1 else
2524
+ * @throws IOException
2525
+ * I/O error
2526
+ */this.putVbrTag=function(gfp,stream){var gfc=gfp.internal_flags;if(gfc.VBR_seek_table.pos<=0)return -1;// Seek to end of file
2527
+ stream.seek(stream.length());// Get file size, abort if file has zero length.
2528
+ if(stream.length()==0)return -1;// The VBR tag may NOT be located at the beginning of the stream. If an
2529
+ // ID3 version 2 tag was added, then it must be skipped to write the VBR
2530
+ // tag data.
2531
+ var id3v2TagSize=skipId3v2(stream);// Seek to the beginning of the stream
2532
+ stream.seek(id3v2TagSize);var buffer=$e674985ea62d27cf$var$new_byte(MAXFRAMESIZE);var bytes=getLameTagFrame(gfp,buffer);if(bytes>buffer.length)return -1;if(bytes<1)return 0;// Put it all to disk again
2533
+ stream.write(buffer,0,bytes);// success
2534
+ return 0;};}$e674985ea62d27cf$exports=$e674985ea62d27cf$var$VBRTag;function $dd7ee3788d91dcb8$var$GetAudio(){this.setModules=function(parse2,mpg2){};}function $dd7ee3788d91dcb8$var$Parse(){this.setModules=function(ver2,id32,pre2){};}function $dd7ee3788d91dcb8$var$MPGLib(){}function $dd7ee3788d91dcb8$var$ID3Tag(){this.setModules=function(_bits,_ver){};}function $dd7ee3788d91dcb8$var$Mp3Encoder(channels,samplerate,kbps){if(arguments.length!=3){console.error("WARN: Mp3Encoder(channels, samplerate, kbps) not specified");channels=1;samplerate=44100;kbps=128;}var lame=new $kk1yk();var gaud=new $dd7ee3788d91dcb8$var$GetAudio();var ga=new $b8dhq();var bs=new $ctaQC();var p=new $7960aab77e945546$exports();var qupvt=new $84mea();var qu=new $df08f3a0d41b7a78$exports();var vbr=new $e674985ea62d27cf$exports();var ver=new $34609aeb1df0c2af$exports();var id3=new $dd7ee3788d91dcb8$var$ID3Tag();var rv=new $b5a7ab7c590f5d1e$exports();var tak=new $65Sx2();var parse=new $dd7ee3788d91dcb8$var$Parse();var mpg=new $dd7ee3788d91dcb8$var$MPGLib();lame.setModules(ga,bs,p,qupvt,qu,vbr,ver,id3,mpg);bs.setModules(ga,mpg,ver,vbr);id3.setModules(bs,ver);p.setModules(lame);qu.setModules(bs,rv,qupvt,tak);qupvt.setModules(tak,rv,lame.enc.psy);rv.setModules(bs);tak.setModules(qupvt);vbr.setModules(lame,bs,ver);gaud.setModules(parse,mpg);parse.setModules(ver,id3,p);var gfp=lame.lame_init();gfp.num_channels=channels;gfp.in_samplerate=samplerate;gfp.brate=kbps;gfp.mode=$jL6I1.STEREO;gfp.quality=3;gfp.bWriteVbrTag=false;gfp.disable_reservoir=true;gfp.write_id3tag_automatic=false;var retcode=lame.lame_init_params(gfp);$dd7ee3788d91dcb8$var$assert(0==retcode);var maxSamples=1152;var mp3buf_size=0|1.25*maxSamples+7200;var mp3buf=$dd7ee3788d91dcb8$var$new_byte(mp3buf_size);this.encodeBuffer=function(left,right){if(channels==1)right=left;$dd7ee3788d91dcb8$var$assert(left.length==right.length);if(left.length>maxSamples){maxSamples=left.length;mp3buf_size=0|1.25*maxSamples+7200;mp3buf=$dd7ee3788d91dcb8$var$new_byte(mp3buf_size);}var _sz=lame.lame_encode_buffer(gfp,left,right,left.length,mp3buf,0,mp3buf_size);return new Int8Array(mp3buf.subarray(0,_sz));};this.flush=function(){var _sz=lame.lame_encode_flush(gfp,mp3buf,0,mp3buf_size);return new Int8Array(mp3buf.subarray(0,_sz));};}function $dd7ee3788d91dcb8$var$WavHeader(){this.dataOffset=0;this.dataLen=0;this.channels=0;this.sampleRate=0;}function $dd7ee3788d91dcb8$var$fourccToInt(fourcc){return fourcc.charCodeAt(0)<<24|fourcc.charCodeAt(1)<<16|fourcc.charCodeAt(2)<<8|fourcc.charCodeAt(3);}$dd7ee3788d91dcb8$var$WavHeader.RIFF=$dd7ee3788d91dcb8$var$fourccToInt("RIFF");$dd7ee3788d91dcb8$var$WavHeader.WAVE=$dd7ee3788d91dcb8$var$fourccToInt("WAVE");$dd7ee3788d91dcb8$var$WavHeader.fmt_=$dd7ee3788d91dcb8$var$fourccToInt("fmt ");$dd7ee3788d91dcb8$var$WavHeader.data=$dd7ee3788d91dcb8$var$fourccToInt("data");$dd7ee3788d91dcb8$var$WavHeader.readHeader=function(dataView){var w=new $dd7ee3788d91dcb8$var$WavHeader();var header=dataView.getUint32(0,false);if($dd7ee3788d91dcb8$var$WavHeader.RIFF!=header)return;dataView.getUint32(4,true);if($dd7ee3788d91dcb8$var$WavHeader.WAVE!=dataView.getUint32(8,false))return;if($dd7ee3788d91dcb8$var$WavHeader.fmt_!=dataView.getUint32(12,false))return;var fmtLen=dataView.getUint32(16,true);var pos=20;switch(fmtLen){case 16:case 18:w.channels=dataView.getUint16(pos+2,true);w.sampleRate=dataView.getUint32(pos+4,true);break;default:throw "extended fmt chunk not implemented";}pos+=fmtLen;var data=$dd7ee3788d91dcb8$var$WavHeader.data;var len=0;while(data!=header){header=dataView.getUint32(pos,false);len=dataView.getUint32(pos+4,true);if(data==header)break;pos+=len+8;}w.dataLen=len;w.dataOffset=pos+8;return w;};$dd7ee3788d91dcb8$export$9ca5d136ebf61cf2=$dd7ee3788d91dcb8$var$Mp3Encoder;$dd7ee3788d91dcb8$export$cb948f2d6837f136=$dd7ee3788d91dcb8$var$WavHeader;
2535
+
2536
+ export { $dd7ee3788d91dcb8$export$9ca5d136ebf61cf2 as Mp3Encoder, $dd7ee3788d91dcb8$export$cb948f2d6837f136 as WavHeader, $dd7ee3788d91dcb8$exports as default };
2537
+ //# sourceMappingURL=lame.all.js.map