@carbonenginejs/runtime-resource 0.1.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 (372) hide show
  1. package/FORMAT-PROVENANCE.md +135 -0
  2. package/LICENSE +21 -0
  3. package/NOTICE +29 -0
  4. package/README.md +241 -0
  5. package/dist/CjsMotherLode.js +56 -0
  6. package/dist/CjsMotherLode.js.map +1 -0
  7. package/dist/CjsResMan.js +740 -0
  8. package/dist/CjsResMan.js.map +1 -0
  9. package/dist/CjsResManQueue.js +214 -0
  10. package/dist/CjsResManQueue.js.map +1 -0
  11. package/dist/CjsResource.js +366 -0
  12. package/dist/CjsResource.js.map +1 -0
  13. package/dist/CjsResourceSource.js +59 -0
  14. package/dist/CjsResourceSource.js.map +1 -0
  15. package/dist/_virtual/_rollupPluginBabelHelpers.js +153 -0
  16. package/dist/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
  17. package/dist/format/CjsFormat.js +178 -0
  18. package/dist/format/CjsFormat.js.map +1 -0
  19. package/dist/format/CjsResourceProbe.js +269 -0
  20. package/dist/format/CjsResourceProbe.js.map +1 -0
  21. package/dist/format/payloadContract.js +173 -0
  22. package/dist/format/payloadContract.js.map +1 -0
  23. package/dist/formats/black/CjsBlackFormat.js +272 -0
  24. package/dist/formats/black/CjsBlackFormat.js.map +1 -0
  25. package/dist/formats/black/core/CjsBlackBinaryReader.js +153 -0
  26. package/dist/formats/black/core/CjsBlackBinaryReader.js.map +1 -0
  27. package/dist/formats/black/core/CjsBlackPropertyReaders.js +382 -0
  28. package/dist/formats/black/core/CjsBlackPropertyReaders.js.map +1 -0
  29. package/dist/formats/black/core/CjsBlackReader.js +760 -0
  30. package/dist/formats/black/core/CjsBlackReader.js.map +1 -0
  31. package/dist/formats/black/core/CjsBlackSchemaRegistry.js +433 -0
  32. package/dist/formats/black/core/CjsBlackSchemaRegistry.js.map +1 -0
  33. package/dist/formats/black/core/black-schema-v1-2026-07-11.json.js +4 -0
  34. package/dist/formats/black/core/black-schema-v1-2026-07-11.json.js.map +1 -0
  35. package/dist/formats/black/core/blackConstants.js +7 -0
  36. package/dist/formats/black/core/blackConstants.js.map +1 -0
  37. package/dist/formats/black/core/blackDefinitions.js +10 -0
  38. package/dist/formats/black/core/blackDefinitions.js.map +1 -0
  39. package/dist/formats/black/core/blackEnums.js +6 -0
  40. package/dist/formats/black/core/blackEnums.js.map +1 -0
  41. package/dist/formats/black/core/blackSchema.js +3 -0
  42. package/dist/formats/black/core/blackSchema.js.map +1 -0
  43. package/dist/formats/black/core/blackVersion.js +22 -0
  44. package/dist/formats/black/core/blackVersion.js.map +1 -0
  45. package/dist/formats/black/core/helpers.js +182 -0
  46. package/dist/formats/black/core/helpers.js.map +1 -0
  47. package/dist/formats/black/core/schema.js +4 -0
  48. package/dist/formats/black/core/schema.js.map +1 -0
  49. package/dist/formats/black/index.js +2 -0
  50. package/dist/formats/black/index.js.map +1 -0
  51. package/dist/formats/bnk/CjsBnkFormat.js +245 -0
  52. package/dist/formats/bnk/CjsBnkFormat.js.map +1 -0
  53. package/dist/formats/bnk/core/helpers.js +354 -0
  54. package/dist/formats/bnk/core/helpers.js.map +1 -0
  55. package/dist/formats/bnk/core/soundbanksInfo.js +246 -0
  56. package/dist/formats/bnk/core/soundbanksInfo.js.map +1 -0
  57. package/dist/formats/bnk/index.js +3 -0
  58. package/dist/formats/bnk/index.js.map +1 -0
  59. package/dist/formats/cmf/CjsCmfFormat.js +491 -0
  60. package/dist/formats/cmf/CjsCmfFormat.js.map +1 -0
  61. package/dist/formats/cmf/core/binary.js +118 -0
  62. package/dist/formats/cmf/core/binary.js.map +1 -0
  63. package/dist/formats/cmf/core/buffers.js +233 -0
  64. package/dist/formats/cmf/core/buffers.js.map +1 -0
  65. package/dist/formats/cmf/core/constants.js +47 -0
  66. package/dist/formats/cmf/core/constants.js.map +1 -0
  67. package/dist/formats/cmf/core/gr2Anim.js +453 -0
  68. package/dist/formats/cmf/core/gr2Anim.js.map +1 -0
  69. package/dist/formats/cmf/core/helpers.js +287 -0
  70. package/dist/formats/cmf/core/helpers.js.map +1 -0
  71. package/dist/formats/cmf/core/pack.js +276 -0
  72. package/dist/formats/cmf/core/pack.js.map +1 -0
  73. package/dist/formats/cmf/core/schema.js +364 -0
  74. package/dist/formats/cmf/core/schema.js.map +1 -0
  75. package/dist/formats/cmf/core/shared.js +268 -0
  76. package/dist/formats/cmf/core/shared.js.map +1 -0
  77. package/dist/formats/cmf/core/writer.js +517 -0
  78. package/dist/formats/cmf/core/writer.js.map +1 -0
  79. package/dist/formats/cmf/index.js +2 -0
  80. package/dist/formats/cmf/index.js.map +1 -0
  81. package/dist/formats/dds/CjsDdsFormat.js +187 -0
  82. package/dist/formats/dds/CjsDdsFormat.js.map +1 -0
  83. package/dist/formats/dds/core/helpers.js +812 -0
  84. package/dist/formats/dds/core/helpers.js.map +1 -0
  85. package/dist/formats/dds/index.js +2 -0
  86. package/dist/formats/dds/index.js.map +1 -0
  87. package/dist/formats/fbx/CjsFbxFormat.js +260 -0
  88. package/dist/formats/fbx/CjsFbxFormat.js.map +1 -0
  89. package/dist/formats/fbx/core/helpers.js +3901 -0
  90. package/dist/formats/fbx/core/helpers.js.map +1 -0
  91. package/dist/formats/fbx/index.js +2 -0
  92. package/dist/formats/fbx/index.js.map +1 -0
  93. package/dist/formats/flac/CjsFlacFormat.js +81 -0
  94. package/dist/formats/flac/CjsFlacFormat.js.map +1 -0
  95. package/dist/formats/flac/core/helpers.js +295 -0
  96. package/dist/formats/flac/core/helpers.js.map +1 -0
  97. package/dist/formats/flac/index.js +2 -0
  98. package/dist/formats/flac/index.js.map +1 -0
  99. package/dist/formats/gif/CjsGifFormat.js +81 -0
  100. package/dist/formats/gif/CjsGifFormat.js.map +1 -0
  101. package/dist/formats/gif/core/helpers.js +360 -0
  102. package/dist/formats/gif/core/helpers.js.map +1 -0
  103. package/dist/formats/gif/index.js +2 -0
  104. package/dist/formats/gif/index.js.map +1 -0
  105. package/dist/formats/gltf/CjsGltfFormat.js +284 -0
  106. package/dist/formats/gltf/CjsGltfFormat.js.map +1 -0
  107. package/dist/formats/gltf/core/helpers.js +292 -0
  108. package/dist/formats/gltf/core/helpers.js.map +1 -0
  109. package/dist/formats/gltf/core/json.js +79 -0
  110. package/dist/formats/gltf/core/json.js.map +1 -0
  111. package/dist/formats/gltf/core/parser.js +666 -0
  112. package/dist/formats/gltf/core/parser.js.map +1 -0
  113. package/dist/formats/gltf/core/targets.js +163 -0
  114. package/dist/formats/gltf/core/targets.js.map +1 -0
  115. package/dist/formats/gltf/index.js +2 -0
  116. package/dist/formats/gltf/index.js.map +1 -0
  117. package/dist/formats/index.js +23 -0
  118. package/dist/formats/index.js.map +1 -0
  119. package/dist/formats/jpeg/CjsJpegFormat.js +200 -0
  120. package/dist/formats/jpeg/CjsJpegFormat.js.map +1 -0
  121. package/dist/formats/jpeg/core/helpers.js +350 -0
  122. package/dist/formats/jpeg/core/helpers.js.map +1 -0
  123. package/dist/formats/jpeg/core/jpeg.js +377 -0
  124. package/dist/formats/jpeg/core/jpeg.js.map +1 -0
  125. package/dist/formats/jpeg/index.js +2 -0
  126. package/dist/formats/jpeg/index.js.map +1 -0
  127. package/dist/formats/mp3/CjsMp3Format.js +186 -0
  128. package/dist/formats/mp3/CjsMp3Format.js.map +1 -0
  129. package/dist/formats/mp3/core/helpers.js +338 -0
  130. package/dist/formats/mp3/core/helpers.js.map +1 -0
  131. package/dist/formats/mp3/index.js +2 -0
  132. package/dist/formats/mp3/index.js.map +1 -0
  133. package/dist/formats/mp4/CjsMp4Format.js +185 -0
  134. package/dist/formats/mp4/CjsMp4Format.js.map +1 -0
  135. package/dist/formats/mp4/core/helpers.js +449 -0
  136. package/dist/formats/mp4/core/helpers.js.map +1 -0
  137. package/dist/formats/mp4/index.js +2 -0
  138. package/dist/formats/mp4/index.js.map +1 -0
  139. package/dist/formats/obj/CjsObjFormat.js +247 -0
  140. package/dist/formats/obj/CjsObjFormat.js.map +1 -0
  141. package/dist/formats/obj/core/helpers.js +573 -0
  142. package/dist/formats/obj/core/helpers.js.map +1 -0
  143. package/dist/formats/obj/core/json.js +64 -0
  144. package/dist/formats/obj/core/json.js.map +1 -0
  145. package/dist/formats/obj/core/parser.js +321 -0
  146. package/dist/formats/obj/core/parser.js.map +1 -0
  147. package/dist/formats/obj/index.js +2 -0
  148. package/dist/formats/obj/index.js.map +1 -0
  149. package/dist/formats/ogg/CjsOggFormat.js +82 -0
  150. package/dist/formats/ogg/CjsOggFormat.js.map +1 -0
  151. package/dist/formats/ogg/core/helpers.js +387 -0
  152. package/dist/formats/ogg/core/helpers.js.map +1 -0
  153. package/dist/formats/ogg/core/imdct.js +178 -0
  154. package/dist/formats/ogg/core/imdct.js.map +1 -0
  155. package/dist/formats/ogg/core/vorbis.js +999 -0
  156. package/dist/formats/ogg/core/vorbis.js.map +1 -0
  157. package/dist/formats/ogg/index.js +2 -0
  158. package/dist/formats/ogg/index.js.map +1 -0
  159. package/dist/formats/png/CjsPngFormat.js +189 -0
  160. package/dist/formats/png/CjsPngFormat.js.map +1 -0
  161. package/dist/formats/png/core/helpers.js +583 -0
  162. package/dist/formats/png/core/helpers.js.map +1 -0
  163. package/dist/formats/png/index.js +2 -0
  164. package/dist/formats/png/index.js.map +1 -0
  165. package/dist/formats/red/CjsRedFormat.js +247 -0
  166. package/dist/formats/red/CjsRedFormat.js.map +1 -0
  167. package/dist/formats/red/core/CjsRedReader.js +201 -0
  168. package/dist/formats/red/core/CjsRedReader.js.map +1 -0
  169. package/dist/formats/red/core/blackDefinitions.js +3 -0
  170. package/dist/formats/red/core/blackDefinitions.js.map +1 -0
  171. package/dist/formats/red/core/helpers.js +136 -0
  172. package/dist/formats/red/core/helpers.js.map +1 -0
  173. package/dist/formats/red/core/redGraph.js +68 -0
  174. package/dist/formats/red/core/redGraph.js.map +1 -0
  175. package/dist/formats/red/core/schema.js +4 -0
  176. package/dist/formats/red/core/schema.js.map +1 -0
  177. package/dist/formats/red/index.js +2 -0
  178. package/dist/formats/red/index.js.map +1 -0
  179. package/dist/formats/stl/CjsStlFormat.js +304 -0
  180. package/dist/formats/stl/CjsStlFormat.js.map +1 -0
  181. package/dist/formats/stl/core/helpers.js +257 -0
  182. package/dist/formats/stl/core/helpers.js.map +1 -0
  183. package/dist/formats/stl/core/json.js +51 -0
  184. package/dist/formats/stl/core/json.js.map +1 -0
  185. package/dist/formats/stl/core/stl.js +544 -0
  186. package/dist/formats/stl/core/stl.js.map +1 -0
  187. package/dist/formats/stl/core/targets.js +163 -0
  188. package/dist/formats/stl/core/targets.js.map +1 -0
  189. package/dist/formats/stl/index.js +2 -0
  190. package/dist/formats/stl/index.js.map +1 -0
  191. package/dist/formats/tga/CjsTgaFormat.js +186 -0
  192. package/dist/formats/tga/CjsTgaFormat.js.map +1 -0
  193. package/dist/formats/tga/core/helpers.js +446 -0
  194. package/dist/formats/tga/core/helpers.js.map +1 -0
  195. package/dist/formats/tga/index.js +2 -0
  196. package/dist/formats/tga/index.js.map +1 -0
  197. package/dist/formats/wav/CjsWavFormat.js +186 -0
  198. package/dist/formats/wav/CjsWavFormat.js.map +1 -0
  199. package/dist/formats/wav/core/helpers.js +328 -0
  200. package/dist/formats/wav/core/helpers.js.map +1 -0
  201. package/dist/formats/wav/index.js +2 -0
  202. package/dist/formats/wav/index.js.map +1 -0
  203. package/dist/formats/webm/CjsWebmFormat.js +185 -0
  204. package/dist/formats/webm/CjsWebmFormat.js.map +1 -0
  205. package/dist/formats/webm/core/helpers.js +537 -0
  206. package/dist/formats/webm/core/helpers.js.map +1 -0
  207. package/dist/formats/webm/index.js +2 -0
  208. package/dist/formats/webm/index.js.map +1 -0
  209. package/dist/formats/webp/CjsWebpFormat.js +80 -0
  210. package/dist/formats/webp/CjsWebpFormat.js.map +1 -0
  211. package/dist/formats/webp/core/helpers.js +214 -0
  212. package/dist/formats/webp/core/helpers.js.map +1 -0
  213. package/dist/formats/webp/index.js +2 -0
  214. package/dist/formats/webp/index.js.map +1 -0
  215. package/dist/formats/wem/CjsWemFormat.js +197 -0
  216. package/dist/formats/wem/CjsWemFormat.js.map +1 -0
  217. package/dist/formats/wem/core/bitStream.js +259 -0
  218. package/dist/formats/wem/core/bitStream.js.map +1 -0
  219. package/dist/formats/wem/core/codebookLibrary.js +164 -0
  220. package/dist/formats/wem/core/codebookLibrary.js.map +1 -0
  221. package/dist/formats/wem/core/helpers.js +336 -0
  222. package/dist/formats/wem/core/helpers.js.map +1 -0
  223. package/dist/formats/wem/core/packedCodebooksAotuv603.js +30 -0
  224. package/dist/formats/wem/core/packedCodebooksAotuv603.js.map +1 -0
  225. package/dist/formats/wem/core/wemToOgg.js +485 -0
  226. package/dist/formats/wem/core/wemToOgg.js.map +1 -0
  227. package/dist/formats/wem/index.js +2 -0
  228. package/dist/formats/wem/index.js.map +1 -0
  229. package/dist/formats/yaml/CjsYamlFormat.js +77 -0
  230. package/dist/formats/yaml/CjsYamlFormat.js.map +1 -0
  231. package/dist/formats/yaml/core/CjsYamlReader.js +304 -0
  232. package/dist/formats/yaml/core/CjsYamlReader.js.map +1 -0
  233. package/dist/formats/yaml/core/helpers.js +160 -0
  234. package/dist/formats/yaml/core/helpers.js.map +1 -0
  235. package/dist/formats/yaml/index.js +2 -0
  236. package/dist/formats/yaml/index.js.map +1 -0
  237. package/dist/generated/resources/AudioGeometryResData.js +47 -0
  238. package/dist/generated/resources/AudioGeometryResData.js.map +1 -0
  239. package/dist/generated/resources/CmfVertexReader.js +46 -0
  240. package/dist/generated/resources/CmfVertexReader.js.map +1 -0
  241. package/dist/generated/resources/GStateBindingCallbackData.js +31 -0
  242. package/dist/generated/resources/GStateBindingCallbackData.js.map +1 -0
  243. package/dist/generated/resources/MeshDecalData.js +37 -0
  244. package/dist/generated/resources/MeshDecalData.js.map +1 -0
  245. package/dist/generated/resources/MeshDecalLodData.js +34 -0
  246. package/dist/generated/resources/MeshDecalLodData.js.map +1 -0
  247. package/dist/generated/resources/Tr2AsyncSave.js +46 -0
  248. package/dist/generated/resources/Tr2AsyncSave.js.map +1 -0
  249. package/dist/generated/resources/Tr2CmfContents.js +37 -0
  250. package/dist/generated/resources/Tr2CmfContents.js.map +1 -0
  251. package/dist/generated/resources/Tr2GrannyIntersectionResult.js +58 -0
  252. package/dist/generated/resources/Tr2GrannyIntersectionResult.js.map +1 -0
  253. package/dist/generated/resources/Tr2LoadPrepareFence.js +37 -0
  254. package/dist/generated/resources/Tr2LoadPrepareFence.js.map +1 -0
  255. package/dist/generated/resources/Tr2MaterialArea.js +34 -0
  256. package/dist/generated/resources/Tr2MaterialArea.js.map +1 -0
  257. package/dist/generated/resources/Tr2MaterialMesh.js +31 -0
  258. package/dist/generated/resources/Tr2MaterialMesh.js.map +1 -0
  259. package/dist/generated/resources/Tr2MaterialRes.js +34 -0
  260. package/dist/generated/resources/Tr2MaterialRes.js.map +1 -0
  261. package/dist/generated/resources/Tr2ShaderPermutation.js +43 -0
  262. package/dist/generated/resources/Tr2ShaderPermutation.js.map +1 -0
  263. package/dist/generated/resources/Tr2TextureLodManager.js +60 -0
  264. package/dist/generated/resources/Tr2TextureLodManager.js.map +1 -0
  265. package/dist/generated/resources/Tr2TextureLodUpdateRequest.js +37 -0
  266. package/dist/generated/resources/Tr2TextureLodUpdateRequest.js.map +1 -0
  267. package/dist/generated/resources/Tr2TexturePackChannel.js +37 -0
  268. package/dist/generated/resources/Tr2TexturePackChannel.js.map +1 -0
  269. package/dist/generated/resources/Tr2TexturePipeline.js +44 -0
  270. package/dist/generated/resources/Tr2TexturePipeline.js.map +1 -0
  271. package/dist/generated/resources/Tr2TexturePipelineParams.js +34 -0
  272. package/dist/generated/resources/Tr2TexturePipelineParams.js.map +1 -0
  273. package/dist/generated/resources/Tr2TexturePipelineStepCompress.js +40 -0
  274. package/dist/generated/resources/Tr2TexturePipelineStepCompress.js.map +1 -0
  275. package/dist/generated/resources/Tr2TexturePipelineStepLimitSize.js +34 -0
  276. package/dist/generated/resources/Tr2TexturePipelineStepLimitSize.js.map +1 -0
  277. package/dist/generated/resources/Tr2TexturePipelineStepLoad.js +31 -0
  278. package/dist/generated/resources/Tr2TexturePipelineStepLoad.js.map +1 -0
  279. package/dist/generated/resources/Tr2TexturePipelineStepPack.js +43 -0
  280. package/dist/generated/resources/Tr2TexturePipelineStepPack.js.map +1 -0
  281. package/dist/generated/resources/TriGeometryResAreaData.js +59 -0
  282. package/dist/generated/resources/TriGeometryResAreaData.js.map +1 -0
  283. package/dist/generated/resources/TriGeometryResJointData.js +38 -0
  284. package/dist/generated/resources/TriGeometryResJointData.js.map +1 -0
  285. package/dist/generated/resources/TriGeometryResLodData.js +88 -0
  286. package/dist/generated/resources/TriGeometryResLodData.js.map +1 -0
  287. package/dist/generated/resources/TriGeometryResMeshData.js +63 -0
  288. package/dist/generated/resources/TriGeometryResMeshData.js.map +1 -0
  289. package/dist/generated/resources/TriGeometryResSkeletonData.js +34 -0
  290. package/dist/generated/resources/TriGeometryResSkeletonData.js.map +1 -0
  291. package/dist/generated/resources/TriJointBinding.js +38 -0
  292. package/dist/generated/resources/TriJointBinding.js.map +1 -0
  293. package/dist/generated/resources/TriMorphTargetGeometryConstants.js +46 -0
  294. package/dist/generated/resources/TriMorphTargetGeometryConstants.js.map +1 -0
  295. package/dist/generated/resources/TriRtGeometryConstants.js +88 -0
  296. package/dist/generated/resources/TriRtGeometryConstants.js.map +1 -0
  297. package/dist/generated/resources/enums.js +18 -0
  298. package/dist/generated/resources/enums.js.map +1 -0
  299. package/dist/generated/resources/index.js +32 -0
  300. package/dist/generated/resources/index.js.map +1 -0
  301. package/dist/index.js +52 -0
  302. package/dist/index.js.map +1 -0
  303. package/dist/resourcePath.js +18 -0
  304. package/dist/resourcePath.js.map +1 -0
  305. package/dist/resourceStates.js +9 -0
  306. package/dist/resourceStates.js.map +1 -0
  307. package/dist/resources/Tr2EffectRes.js +71 -0
  308. package/dist/resources/Tr2EffectRes.js.map +1 -0
  309. package/dist/resources/Tr2GrannyStateRes.js +44 -0
  310. package/dist/resources/Tr2GrannyStateRes.js.map +1 -0
  311. package/dist/resources/Tr2ImageRes.js +114 -0
  312. package/dist/resources/Tr2ImageRes.js.map +1 -0
  313. package/dist/resources/Tr2LightProfileRes.js +40 -0
  314. package/dist/resources/Tr2LightProfileRes.js.map +1 -0
  315. package/dist/resources/TriGeometryRes.js +216 -0
  316. package/dist/resources/TriGeometryRes.js.map +1 -0
  317. package/dist/resources/TriGrannyRes.js +43 -0
  318. package/dist/resources/TriGrannyRes.js.map +1 -0
  319. package/dist/resources/TriTextureRes.js +304 -0
  320. package/dist/resources/TriTextureRes.js.map +1 -0
  321. package/dist/resources/resourceBoundary.js +47 -0
  322. package/dist/resources/resourceBoundary.js.map +1 -0
  323. package/dist/texture/CjsTextureArrayRes.js +406 -0
  324. package/dist/texture/CjsTextureArrayRes.js.map +1 -0
  325. package/dist/texture/CjsTextureParameterProxy.js +133 -0
  326. package/dist/texture/CjsTextureParameterProxy.js.map +1 -0
  327. package/format-notices/black/LICENSE +21 -0
  328. package/format-notices/black/NOTICE +47 -0
  329. package/format-notices/bnk/LICENSE +21 -0
  330. package/format-notices/bnk/NOTICE +17 -0
  331. package/format-notices/cmf/LICENSE +21 -0
  332. package/format-notices/cmf/NOTICE +36 -0
  333. package/format-notices/dds/LICENSE +21 -0
  334. package/format-notices/dds/NOTICE +14 -0
  335. package/format-notices/fbx/LICENSE +21 -0
  336. package/format-notices/fbx/NOTICE +14 -0
  337. package/format-notices/flac/LICENSE +21 -0
  338. package/format-notices/flac/NOTICE +14 -0
  339. package/format-notices/gif/LICENSE +21 -0
  340. package/format-notices/gif/NOTICE +14 -0
  341. package/format-notices/gltf/LICENSE +21 -0
  342. package/format-notices/gltf/NOTICE +27 -0
  343. package/format-notices/jpeg/LICENSE +21 -0
  344. package/format-notices/jpeg/NOTICE +14 -0
  345. package/format-notices/mp3/LICENSE +21 -0
  346. package/format-notices/mp3/NOTICE +14 -0
  347. package/format-notices/mp4/LICENSE +21 -0
  348. package/format-notices/mp4/NOTICE +14 -0
  349. package/format-notices/obj/LICENSE +21 -0
  350. package/format-notices/obj/NOTICE +26 -0
  351. package/format-notices/ogg/LICENSE +21 -0
  352. package/format-notices/ogg/NOTICE +28 -0
  353. package/format-notices/png/LICENSE +21 -0
  354. package/format-notices/png/NOTICE +14 -0
  355. package/format-notices/red/LICENSE +21 -0
  356. package/format-notices/red/NOTICE +31 -0
  357. package/format-notices/stl/LICENSE +21 -0
  358. package/format-notices/stl/NOTICE +21 -0
  359. package/format-notices/tga/LICENSE +21 -0
  360. package/format-notices/tga/NOTICE +14 -0
  361. package/format-notices/wav/LICENSE +21 -0
  362. package/format-notices/wav/NOTICE +14 -0
  363. package/format-notices/webm/LICENSE +21 -0
  364. package/format-notices/webm/NOTICE +14 -0
  365. package/format-notices/webp/LICENSE +21 -0
  366. package/format-notices/webp/NOTICE +14 -0
  367. package/format-notices/wem/LICENSE +57 -0
  368. package/format-notices/wem/NOTICE +33 -0
  369. package/format-notices/yaml/LICENSE +21 -0
  370. package/format-notices/yaml/NOTICE +44 -0
  371. package/package.json +51 -0
  372. package/resource-lifecycle.md +487 -0
@@ -0,0 +1,999 @@
1
+ import { imdct, vorbisWindowSlope } from './imdct.js';
2
+
3
+ /**
4
+ * Pure-JS Ogg Vorbis PCM decoder.
5
+ *
6
+ * Implements Vorbis I decode: setup-header codebooks (huffman + VQ), floor
7
+ * type 1 with the spec's exact integer line rendering, residue types 0/1/2,
8
+ * square-polar channel de-coupling, IMDCT, and windowed center-aligned
9
+ * overlap-add with final granule trimming. Behavior follows the Vorbis I
10
+ * specification with stb_vorbis (public domain) consulted as a reference;
11
+ * floor type 0 streams are rejected (never produced by modern encoders).
12
+ */
13
+
14
+ const NO_CODE = 255;
15
+ const FAST_BITS = 10;
16
+ const FAST_SIZE = 1 << FAST_BITS;
17
+
18
+ /**
19
+ * The floor1 amplitude table from the Vorbis I specification
20
+ * (inverse_db_table); indexed by the integer floor curve value.
21
+ */
22
+ const INVERSE_DB_TABLE = new Float32Array([1.0649863e-07, 1.1341951e-07, 1.2079015e-07, 1.2863978e-07, 1.3699951e-07, 1.4590251e-07, 1.5538408e-07, 1.6548181e-07, 1.7623575e-07, 1.8768855e-07, 1.9988561e-07, 2.1287530e-07, 2.2670913e-07, 2.4144197e-07, 2.5713223e-07, 2.7384213e-07, 2.9163793e-07, 3.1059021e-07, 3.3077411e-07, 3.5226968e-07, 3.7516214e-07, 3.9954229e-07, 4.2550680e-07, 4.5315863e-07, 4.8260743e-07, 5.1396998e-07, 5.4737065e-07, 5.8294187e-07, 6.2082472e-07, 6.6116941e-07, 7.0413592e-07, 7.4989464e-07, 7.9862701e-07, 8.5052630e-07, 9.0579828e-07, 9.6466216e-07, 1.0273513e-06, 1.0941144e-06, 1.1652161e-06, 1.2409384e-06, 1.3215816e-06, 1.4074654e-06, 1.4989305e-06, 1.5963394e-06, 1.7000785e-06, 1.8105592e-06, 1.9282195e-06, 2.0535261e-06, 2.1869758e-06, 2.3290978e-06, 2.4804557e-06, 2.6416497e-06, 2.8133190e-06, 2.9961443e-06, 3.1908506e-06, 3.3982101e-06, 3.6190449e-06, 3.8542308e-06, 4.1047004e-06, 4.3714470e-06, 4.6555282e-06, 4.9580707e-06, 5.2802740e-06, 5.6234160e-06, 5.9888572e-06, 6.3780469e-06, 6.7925283e-06, 7.2339451e-06, 7.7040476e-06, 8.2047000e-06, 8.7378876e-06, 9.3057248e-06, 9.9104632e-06, 1.0554501e-05, 1.1240392e-05, 1.1970856e-05, 1.2748789e-05, 1.3577278e-05, 1.4459606e-05, 1.5399272e-05, 1.6400004e-05, 1.7465768e-05, 1.8600792e-05, 1.9809576e-05, 2.1096914e-05, 2.2467911e-05, 2.3928002e-05, 2.5482978e-05, 2.7139006e-05, 2.8902651e-05, 3.0780908e-05, 3.2781225e-05, 3.4911534e-05, 3.7180282e-05, 3.9596466e-05, 4.2169667e-05, 4.4910090e-05, 4.7828601e-05, 5.0936773e-05, 5.4246931e-05, 5.7772202e-05, 6.1526565e-05, 6.5524908e-05, 6.9783085e-05, 7.4317983e-05, 7.9147585e-05, 8.4291040e-05, 8.9768747e-05, 9.5602426e-05, 0.00010181521, 0.00010843174, 0.00011547824, 0.00012298267, 0.00013097477, 0.00013948625, 0.00014855085, 0.00015820453, 0.00016848555, 0.00017943469, 0.00019109536, 0.00020351382, 0.00021673929, 0.00023082423, 0.00024582449, 0.00026179955, 0.00027881276, 0.00029693158, 0.00031622787, 0.00033677814, 0.00035866388, 0.00038197188, 0.00040679456, 0.00043323036, 0.00046138411, 0.00049136745, 0.00052329927, 0.00055730621, 0.00059352311, 0.00063209358, 0.00067317058, 0.00071691700, 0.00076350630, 0.00081312324, 0.00086596457, 0.00092223983, 0.00098217216, 0.0010459992, 0.0011139742, 0.0011863665, 0.0012634633, 0.0013455702, 0.0014330129, 0.0015261382, 0.0016253153, 0.0017309374, 0.0018434235, 0.0019632195, 0.0020908006, 0.0022266726, 0.0023713743, 0.0025254795, 0.0026895994, 0.0028643847, 0.0030505286, 0.0032487691, 0.0034598925, 0.0036847358, 0.0039241906, 0.0041792066, 0.0044507950, 0.0047400328, 0.0050480668, 0.0053761186, 0.0057254891, 0.0060975636, 0.0064938176, 0.0069158225, 0.0073652516, 0.0078438871, 0.0083536271, 0.0088964928, 0.0094746370, 0.0100903520, 0.0107460800, 0.0114444210, 0.0121881440, 0.0129801980, 0.0138237250, 0.0147220680, 0.0156787910, 0.0166976870, 0.0177827970, 0.0189384230, 0.0201691490, 0.0214798540, 0.0228757350, 0.0243623300, 0.0259455310, 0.0276316180, 0.0294272760, 0.0313396260, 0.0333762520, 0.0355452280, 0.0378551570, 0.0403151990, 0.0429351080, 0.0457252730, 0.0486967580, 0.0518613480, 0.0552315910, 0.0588208500, 0.0626433610, 0.0667142790, 0.0710497490, 0.0756669620, 0.0805842270, 0.0858210440, 0.0913981790, 0.0973377470, 0.1036633000, 0.1103999300, 0.1175743400, 0.1252149800, 0.1333521500, 0.1420181300, 0.1512472700, 0.1610761700, 0.1715438000, 0.1826916800, 0.1945640200, 0.2072078800, 0.2206734200, 0.2350140200, 0.2502865600, 0.2665515900, 0.2838736100, 0.3023213200, 0.3219678600, 0.3428911400, 0.3651741400, 0.3889052100, 0.4141784700, 0.4410941200, 0.4697589000, 0.5002864800, 0.5327979100, 0.5674221200, 0.6042964000, 0.6435669900, 0.6853895900, 0.7299300700, 0.7773650400, 0.8278826000, 0.8816830700, 0.9389798000, 1.0]);
23
+ function decodeError(message) {
24
+ const error = new Error(`ogg: ${message}`);
25
+ error.code = "CJS_FORMAT_PARSE_ERROR";
26
+ return error;
27
+ }
28
+ function ilog(value) {
29
+ let result = 0;
30
+ let v = value | 0;
31
+ if (v < 0) return 0;
32
+ while (v) {
33
+ result++;
34
+ v >>= 1;
35
+ }
36
+ return result;
37
+ }
38
+ function float32Unpack(x) {
39
+ const mantissa = x & 0x1fffff;
40
+ const sign = x & 0x80000000;
41
+ const exponent = (x & 0x7fe00000) >>> 21;
42
+ const value = sign ? -mantissa : mantissa;
43
+ return value * Math.pow(2, exponent - 788);
44
+ }
45
+ function lookup1Values(entries, dimensions) {
46
+ if (dimensions === 0) return 0;
47
+ const bits = ilog(entries);
48
+ let vals = entries >>> Math.floor((bits - 1) * (dimensions - 1) / dimensions);
49
+ for (;;) {
50
+ let acc = 1;
51
+ let acc1 = 1;
52
+ for (let i = 0; i < dimensions; i++) {
53
+ acc *= vals;
54
+ acc1 *= vals + 1;
55
+ }
56
+ if (acc <= entries && acc1 > entries) return vals;
57
+ if (acc > entries) vals--;else vals++;
58
+ }
59
+ }
60
+
61
+ /**
62
+ * LSB-first bit reader over one Vorbis packet; reading past the end sets
63
+ * `eop` instead of throwing (end-of-packet is a defined decode condition).
64
+ */
65
+ class PacketReader {
66
+ constructor(bytes) {
67
+ this.bytes = bytes;
68
+ this.position = 0;
69
+ this.bitBuffer = 0;
70
+ this.bitsLeft = 0;
71
+ this.eop = false;
72
+ }
73
+ readBits(count) {
74
+ let value = 0;
75
+ for (let i = 0; i < count; i++) {
76
+ if (this.bitsLeft === 0) {
77
+ if (this.position >= this.bytes.length) {
78
+ this.eop = true;
79
+ return -1;
80
+ }
81
+ this.bitBuffer = this.bytes[this.position++];
82
+ this.bitsLeft = 8;
83
+ }
84
+ value |= (this.bitBuffer & 1) << i;
85
+ this.bitBuffer >>= 1;
86
+ this.bitsLeft--;
87
+ }
88
+ return value >>> 0;
89
+ }
90
+ }
91
+ class Codebook {
92
+ constructor() {
93
+ this.dimensions = 0;
94
+ this.entries = 0;
95
+ this.lookupType = 0;
96
+ this.sequenceP = false;
97
+ this.quantvals = 0;
98
+ this.values = null;
99
+ this.fastTable = null;
100
+ this.treeNodes = null;
101
+ this.maxLength = 0;
102
+ }
103
+ buildHuffman(lengths) {
104
+ const available = new Uint32Array(33);
105
+ this.fastTable = new Int32Array(FAST_SIZE).fill(-1);
106
+ // flat binary trie: two child slots per node; negative = -(symbol+1)
107
+ const nodes = [0, 0];
108
+ let assigned = false;
109
+ for (let symbol = 0; symbol < lengths.length; symbol++) {
110
+ const length = lengths[symbol];
111
+ if (length === NO_CODE) continue;
112
+ if (length > this.maxLength) this.maxLength = length;
113
+ let code;
114
+ if (!assigned) {
115
+ code = 0;
116
+ assigned = true;
117
+ for (let i = 1; i <= length; i++) available[i] = 1 << 32 - i >>> 0;
118
+ } else {
119
+ let z = length;
120
+ while (z > 0 && !available[z]) z--;
121
+ if (z === 0) throw decodeError("over-specified huffman codebook");
122
+ code = available[z];
123
+ available[z] = 0;
124
+ if (z !== length) {
125
+ for (let y = length; y > z; y--) {
126
+ available[y] = code + (1 << 32 - y) >>> 0;
127
+ }
128
+ }
129
+ }
130
+
131
+ // reversed code: first stream bit in bit 0
132
+ let reversed = 0;
133
+ for (let i = 0; i < length; i++) {
134
+ reversed |= (code >>> 31 - i & 1) << i;
135
+ }
136
+ reversed >>>= 0;
137
+ if (length <= FAST_BITS) {
138
+ for (let z = reversed; z < FAST_SIZE; z += 1 << length) {
139
+ this.fastTable[z] = symbol << 6 | length;
140
+ }
141
+ } else {
142
+ let node = 0;
143
+ for (let i = 0; i < length; i++) {
144
+ const bit = reversed >>> i & 1;
145
+ const slot = node * 2 + bit;
146
+ if (i === length - 1) {
147
+ nodes[slot] = -(symbol + 1);
148
+ } else {
149
+ if (!nodes[slot]) {
150
+ nodes[slot] = nodes.length / 2;
151
+ nodes.push(0, 0);
152
+ }
153
+ node = nodes[slot];
154
+ }
155
+ }
156
+ }
157
+ }
158
+ this.treeNodes = nodes;
159
+ }
160
+ decode(reader) {
161
+ // fast path: peek up to FAST_BITS without consuming
162
+ let peek = 0;
163
+ let peekBits = 0;
164
+ const savedPosition = reader.position;
165
+ const savedBuffer = reader.bitBuffer;
166
+ const savedLeft = reader.bitsLeft;
167
+ while (peekBits < FAST_BITS) {
168
+ const bit = reader.readBits(1);
169
+ if (bit < 0) break;
170
+ peek |= bit << peekBits;
171
+ peekBits++;
172
+ }
173
+ reader.position = savedPosition;
174
+ reader.bitBuffer = savedBuffer;
175
+ reader.bitsLeft = savedLeft;
176
+ reader.eop = false;
177
+ if (peekBits === FAST_BITS) {
178
+ const hit = this.fastTable[peek];
179
+ if (hit >= 0) {
180
+ reader.readBits(hit & 63);
181
+ return hit >> 6;
182
+ }
183
+ } else {
184
+ // short remainder: try fast table over what's left
185
+ const hit = this.fastTable[peek];
186
+ if (hit >= 0 && (hit & 63) <= peekBits) {
187
+ reader.readBits(hit & 63);
188
+ return hit >> 6;
189
+ }
190
+ }
191
+
192
+ // slow path: walk the trie bit by bit
193
+ let node = 0;
194
+ for (let i = 0; i < this.maxLength; i++) {
195
+ const bit = reader.readBits(1);
196
+ if (bit < 0) return -1;
197
+ const value = this.treeNodes[node * 2 + bit];
198
+ if (value < 0) return -value - 1;
199
+ if (value === 0) throw decodeError("invalid huffman code in stream");
200
+ node = value;
201
+ }
202
+ throw decodeError("huffman walk exceeded max code length");
203
+ }
204
+ vqValue(symbol, element) {
205
+ if (this.lookupType === 1) {
206
+ let index = symbol;
207
+ for (let i = 0; i < element; i++) index = Math.floor(index / this.quantvals);
208
+ return this.values[index % this.quantvals];
209
+ }
210
+ return this.values[symbol * this.dimensions + element];
211
+ }
212
+ }
213
+ function parseCodebook(reader) {
214
+ const sync = reader.readBits(24);
215
+ if (sync !== 0x564342) throw decodeError("invalid codebook sync pattern");
216
+ const book = new Codebook();
217
+ book.dimensions = reader.readBits(16);
218
+ book.entries = reader.readBits(24);
219
+ const lengths = new Uint8Array(book.entries);
220
+ const ordered = reader.readBits(1);
221
+ if (ordered) {
222
+ let currentEntry = 0;
223
+ let currentLength = reader.readBits(5) + 1;
224
+ while (currentEntry < book.entries) {
225
+ const number = reader.readBits(ilog(book.entries - currentEntry));
226
+ if (reader.eop) throw decodeError("codebook lengths truncated");
227
+ for (let i = 0; i < number; i++) lengths[currentEntry + i] = currentLength;
228
+ currentEntry += number;
229
+ currentLength++;
230
+ if (currentEntry > book.entries) throw decodeError("codebook entry overflow");
231
+ }
232
+ } else {
233
+ const sparse = reader.readBits(1);
234
+ for (let i = 0; i < book.entries; i++) {
235
+ const present = sparse ? reader.readBits(1) : 1;
236
+ lengths[i] = present ? reader.readBits(5) + 1 : NO_CODE;
237
+ }
238
+ }
239
+ if (reader.eop) throw decodeError("codebook lengths truncated");
240
+ book.buildHuffman(lengths);
241
+ book.lookupType = reader.readBits(4);
242
+ if (book.lookupType > 2) throw decodeError(`invalid codebook lookup type ${book.lookupType}`);
243
+ if (book.lookupType > 0) {
244
+ const minimum = float32Unpack(reader.readBits(32));
245
+ const delta = float32Unpack(reader.readBits(32));
246
+ const valueBits = reader.readBits(4) + 1;
247
+ book.sequenceP = reader.readBits(1) === 1;
248
+ const count = book.lookupType === 1 ? lookup1Values(book.entries, book.dimensions) : book.entries * book.dimensions;
249
+ book.quantvals = book.lookupType === 1 ? count : 0;
250
+ book.values = new Float32Array(count);
251
+ for (let i = 0; i < count; i++) {
252
+ book.values[i] = minimum + reader.readBits(valueBits) * delta;
253
+ }
254
+ if (reader.eop) throw decodeError("codebook lookup values truncated");
255
+ }
256
+ return book;
257
+ }
258
+ function parseFloor(reader, codebooks) {
259
+ const type = reader.readBits(16);
260
+ if (type !== 1) {
261
+ throw decodeError(`floor type ${type} is not supported (only floor 1)`);
262
+ }
263
+ const floor = {
264
+ partitions: reader.readBits(5),
265
+ partitionClassList: [],
266
+ classDimensions: [],
267
+ classSubclasses: [],
268
+ classMasterbooks: [],
269
+ subclassBooks: [],
270
+ multiplier: 0,
271
+ rangebits: 0,
272
+ xList: [0, 0]
273
+ };
274
+ let maximumClass = -1;
275
+ for (let i = 0; i < floor.partitions; i++) {
276
+ const partitionClass = reader.readBits(4);
277
+ floor.partitionClassList.push(partitionClass);
278
+ if (partitionClass > maximumClass) maximumClass = partitionClass;
279
+ }
280
+ for (let i = 0; i <= maximumClass; i++) {
281
+ floor.classDimensions.push(reader.readBits(3) + 1);
282
+ const subclasses = reader.readBits(2);
283
+ floor.classSubclasses.push(subclasses);
284
+ floor.classMasterbooks.push(subclasses ? reader.readBits(8) : -1);
285
+ const books = [];
286
+ for (let j = 0; j < 1 << subclasses; j++) {
287
+ books.push(reader.readBits(8) - 1);
288
+ }
289
+ floor.subclassBooks.push(books);
290
+ }
291
+ floor.multiplier = reader.readBits(2) + 1;
292
+ floor.rangebits = reader.readBits(4);
293
+ floor.xList = [0, 1 << floor.rangebits];
294
+ for (let i = 0; i < floor.partitions; i++) {
295
+ for (let j = 0; j < floor.classDimensions[floor.partitionClassList[i]]; j++) {
296
+ floor.xList.push(reader.readBits(floor.rangebits));
297
+ }
298
+ }
299
+ if (reader.eop) throw decodeError("floor configuration truncated");
300
+ for (const bookIndex of [...floor.classMasterbooks, ...floor.subclassBooks.flat()]) {
301
+ if (bookIndex >= codebooks.length) throw decodeError("floor references invalid codebook");
302
+ }
303
+
304
+ // sorted render order over unique X positions, computed once
305
+ floor.sortedIndex = floor.xList.map((x, index) => ({
306
+ x,
307
+ index
308
+ })).sort((a, b) => a.x - b.x || a.index - b.index).map(entry => entry.index);
309
+
310
+ // neighbor tables (over original ordering) computed once
311
+ floor.lowNeighbors = [];
312
+ floor.highNeighbors = [];
313
+ for (let i = 2; i < floor.xList.length; i++) {
314
+ let low = 0;
315
+ let high = 1;
316
+ for (let j = 0; j < i; j++) {
317
+ if (floor.xList[j] < floor.xList[i] && floor.xList[j] >= floor.xList[low]) low = j;
318
+ if (floor.xList[j] > floor.xList[i] && floor.xList[j] <= floor.xList[high]) high = j;
319
+ }
320
+ floor.lowNeighbors.push(low);
321
+ floor.highNeighbors.push(high);
322
+ }
323
+ return floor;
324
+ }
325
+ function parseResidue(reader, codebooks) {
326
+ const type = reader.readBits(16);
327
+ if (type > 2) throw decodeError(`invalid residue type ${type}`);
328
+ const residue = {
329
+ type,
330
+ begin: reader.readBits(24),
331
+ end: reader.readBits(24),
332
+ partSize: reader.readBits(24) + 1,
333
+ classifications: reader.readBits(6) + 1,
334
+ classbook: reader.readBits(8),
335
+ books: []
336
+ };
337
+ if (residue.classbook >= codebooks.length) throw decodeError("residue classbook out of range");
338
+ const cascades = [];
339
+ for (let i = 0; i < residue.classifications; i++) {
340
+ const lowBits = reader.readBits(3);
341
+ const flag = reader.readBits(1);
342
+ const highBits = flag ? reader.readBits(5) : 0;
343
+ cascades.push(highBits * 8 + lowBits);
344
+ }
345
+ for (let i = 0; i < residue.classifications; i++) {
346
+ const passBooks = [];
347
+ for (let pass = 0; pass < 8; pass++) {
348
+ if (cascades[i] & 1 << pass) {
349
+ const bookIndex = reader.readBits(8);
350
+ if (bookIndex >= codebooks.length) throw decodeError("residue book out of range");
351
+ if (codebooks[bookIndex].lookupType === 0) throw decodeError("residue book has no lookup values");
352
+ passBooks.push(bookIndex);
353
+ } else {
354
+ passBooks.push(-1);
355
+ }
356
+ }
357
+ residue.books.push(passBooks);
358
+ }
359
+ if (reader.eop) throw decodeError("residue configuration truncated");
360
+ return residue;
361
+ }
362
+ function parseMapping(reader, channels, floorCount, residueCount) {
363
+ const type = reader.readBits(16);
364
+ if (type !== 0) throw decodeError(`invalid mapping type ${type}`);
365
+ const mapping = {
366
+ submaps: 1,
367
+ couplingSteps: [],
368
+ mux: new Array(channels).fill(0),
369
+ submapFloor: [],
370
+ submapResidue: []
371
+ };
372
+ if (reader.readBits(1)) mapping.submaps = reader.readBits(4) + 1;
373
+ if (reader.readBits(1)) {
374
+ const steps = reader.readBits(8) + 1;
375
+ const bits = ilog(channels - 1);
376
+ for (let i = 0; i < steps; i++) {
377
+ const magnitude = reader.readBits(bits);
378
+ const angle = reader.readBits(bits);
379
+ if (magnitude === angle || magnitude >= channels || angle >= channels) {
380
+ throw decodeError("invalid channel coupling");
381
+ }
382
+ mapping.couplingSteps.push({
383
+ magnitude,
384
+ angle
385
+ });
386
+ }
387
+ }
388
+ if (reader.readBits(2) !== 0) throw decodeError("mapping reserved bits nonzero");
389
+ if (mapping.submaps > 1) {
390
+ for (let i = 0; i < channels; i++) {
391
+ mapping.mux[i] = reader.readBits(4);
392
+ if (mapping.mux[i] >= mapping.submaps) throw decodeError("mapping mux out of range");
393
+ }
394
+ }
395
+ for (let i = 0; i < mapping.submaps; i++) {
396
+ reader.readBits(8);
397
+ const floorIndex = reader.readBits(8);
398
+ const residueIndex = reader.readBits(8);
399
+ if (floorIndex >= floorCount || residueIndex >= residueCount) {
400
+ throw decodeError("mapping references invalid floor or residue");
401
+ }
402
+ mapping.submapFloor.push(floorIndex);
403
+ mapping.submapResidue.push(residueIndex);
404
+ }
405
+ return mapping;
406
+ }
407
+ const FLOOR1_RANGES = [256, 128, 86, 64];
408
+ function renderPoint(x0, y0, x1, y1, x) {
409
+ const dy = y1 - y0;
410
+ const adx = x1 - x0;
411
+ const err = Math.floor(Math.abs(dy) * (x - x0) / adx);
412
+ return dy < 0 ? y0 - err : y0 + err;
413
+ }
414
+ function decodeFloor1Posts(reader, floor, codebooks) {
415
+ if (reader.readBits(1) !== 1) return null;
416
+ const range = FLOOR1_RANGES[floor.multiplier - 1];
417
+ const posts = new Int32Array(floor.xList.length);
418
+ const yBits = ilog(range - 1);
419
+ posts[0] = reader.readBits(yBits);
420
+ posts[1] = reader.readBits(yBits);
421
+ let offset = 2;
422
+ for (let i = 0; i < floor.partitions; i++) {
423
+ const partitionClass = floor.partitionClassList[i];
424
+ const cdim = floor.classDimensions[partitionClass];
425
+ const cbits = floor.classSubclasses[partitionClass];
426
+ const csub = (1 << cbits) - 1;
427
+ let cval = 0;
428
+ if (cbits) {
429
+ cval = codebooks[floor.classMasterbooks[partitionClass]].decode(reader);
430
+ if (cval < 0) return null;
431
+ }
432
+ for (let j = 0; j < cdim; j++) {
433
+ const bookIndex = floor.subclassBooks[partitionClass][cval & csub];
434
+ cval >>= cbits;
435
+ if (bookIndex >= 0) {
436
+ const value = codebooks[bookIndex].decode(reader);
437
+ if (value < 0) return null;
438
+ posts[offset + j] = value;
439
+ } else {
440
+ posts[offset + j] = 0;
441
+ }
442
+ }
443
+ offset += cdim;
444
+ }
445
+ if (reader.eop) return null;
446
+ return posts;
447
+ }
448
+ function computeFloor1Curve(floor, posts, n2, output) {
449
+ const range = FLOOR1_RANGES[floor.multiplier - 1];
450
+ const count = floor.xList.length;
451
+ const finalY = new Int32Array(count);
452
+ const step2 = new Uint8Array(count);
453
+ step2[0] = 1;
454
+ step2[1] = 1;
455
+ finalY[0] = posts[0];
456
+ finalY[1] = posts[1];
457
+ for (let i = 2; i < count; i++) {
458
+ const low = floor.lowNeighbors[i - 2];
459
+ const high = floor.highNeighbors[i - 2];
460
+ const predicted = renderPoint(floor.xList[low], finalY[low], floor.xList[high], finalY[high], floor.xList[i]);
461
+ const value = posts[i];
462
+ const highroom = range - predicted;
463
+ const lowroom = predicted;
464
+ const room = (highroom < lowroom ? highroom : lowroom) * 2;
465
+ if (value) {
466
+ step2[low] = 1;
467
+ step2[high] = 1;
468
+ step2[i] = 1;
469
+ if (value >= room) {
470
+ finalY[i] = highroom > lowroom ? value - lowroom + predicted : predicted - value + highroom - 1;
471
+ } else {
472
+ finalY[i] = value & 1 ? predicted - (value + 1 >> 1) : predicted + (value >> 1);
473
+ }
474
+ } else {
475
+ step2[i] = 0;
476
+ finalY[i] = predicted;
477
+ }
478
+ }
479
+ output.fill(0);
480
+ let lx = 0;
481
+ let ly = finalY[floor.sortedIndex[0]] * floor.multiplier;
482
+ for (const index of floor.sortedIndex) {
483
+ if (!step2[index]) continue;
484
+ const hx = floor.xList[index];
485
+ const hy = finalY[index] * floor.multiplier;
486
+ if (hx > lx) renderLine(lx, ly, hx, hy, output, n2);
487
+ if (hx >= n2) return;
488
+ lx = hx;
489
+ ly = hy;
490
+ }
491
+ if (lx < n2) {
492
+ for (let i = lx; i < n2; i++) output[i] = INVERSE_DB_TABLE[ly & 255];
493
+ }
494
+ }
495
+ function renderLine(x0, y0, x1, y1, output, n) {
496
+ const dy = y1 - y0;
497
+ const adx = x1 - x0;
498
+ let ady = Math.abs(dy);
499
+ const base = dy / adx | 0;
500
+ const sy = dy < 0 ? base - 1 : base + 1;
501
+ let x = x0;
502
+ let y = y0;
503
+ let err = 0;
504
+ ady -= Math.abs(base) * adx;
505
+ const limit = x1 > n ? n : x1;
506
+ if (x < limit) output[x] = INVERSE_DB_TABLE[y & 255];
507
+ for (x++; x < limit; x++) {
508
+ err += ady;
509
+ if (err >= adx) {
510
+ err -= adx;
511
+ y += sy;
512
+ } else {
513
+ y += base;
514
+ }
515
+ output[x] = INVERSE_DB_TABLE[y & 255];
516
+ }
517
+ }
518
+ function decodeResidue(residue, reader, codebooks, buffers, doNotDecode, n2) {
519
+ const channelCount = buffers.length;
520
+ const classbook = codebooks[residue.classbook];
521
+ const classwords = classbook.dimensions;
522
+ const actualSize = residue.type === 2 ? n2 * channelCount : n2;
523
+ const limitBegin = Math.min(residue.begin, actualSize);
524
+ const limitEnd = Math.min(residue.end, actualSize);
525
+ const nRead = limitEnd - limitBegin;
526
+ const partRead = Math.floor(nRead / residue.partSize);
527
+ if (partRead <= 0) return;
528
+ if (residue.type === 2 && channelCount > 1) {
529
+ if (doNotDecode.every(Boolean)) return;
530
+ const classifications = new Int32Array(partRead + classwords);
531
+ for (let pass = 0; pass < 8; pass++) {
532
+ let pcount = 0;
533
+ while (pcount < partRead) {
534
+ if (pass === 0) {
535
+ let symbol = classbook.decode(reader);
536
+ if (symbol < 0) return;
537
+ for (let i = classwords - 1; i >= 0; i--) {
538
+ classifications[i + pcount] = symbol % residue.classifications;
539
+ symbol = Math.floor(symbol / residue.classifications);
540
+ }
541
+ }
542
+ for (let i = 0; i < classwords && pcount < partRead; i++, pcount++) {
543
+ const z = residue.begin + pcount * residue.partSize;
544
+ const bookIndex = residue.books[classifications[pcount]][pass];
545
+ if (bookIndex < 0) continue;
546
+ const book = codebooks[bookIndex];
547
+ let cInter = z % channelCount;
548
+ let pInter = Math.floor(z / channelCount);
549
+ let decoded = 0;
550
+ while (decoded < residue.partSize) {
551
+ const symbol = book.decode(reader);
552
+ if (symbol < 0) return;
553
+ let last = 0;
554
+ for (let e = 0; e < book.dimensions; e++) {
555
+ const value = book.vqValue(symbol, e) + (book.sequenceP ? last : 0);
556
+ if (book.sequenceP) last = value;
557
+ buffers[cInter][pInter] += value;
558
+ cInter++;
559
+ if (cInter === channelCount) {
560
+ cInter = 0;
561
+ pInter++;
562
+ }
563
+ }
564
+ decoded += book.dimensions;
565
+ }
566
+ }
567
+ }
568
+ }
569
+ return;
570
+ }
571
+ const classifications = [];
572
+ for (let j = 0; j < channelCount; j++) classifications.push(new Int32Array(partRead + classwords));
573
+ for (let pass = 0; pass < 8; pass++) {
574
+ let pcount = 0;
575
+ while (pcount < partRead) {
576
+ if (pass === 0) {
577
+ for (let j = 0; j < channelCount; j++) {
578
+ if (doNotDecode[j]) continue;
579
+ let symbol = classbook.decode(reader);
580
+ if (symbol < 0) return;
581
+ for (let i = classwords - 1; i >= 0; i--) {
582
+ classifications[j][i + pcount] = symbol % residue.classifications;
583
+ symbol = Math.floor(symbol / residue.classifications);
584
+ }
585
+ }
586
+ }
587
+ for (let i = 0; i < classwords && pcount < partRead; i++, pcount++) {
588
+ for (let j = 0; j < channelCount; j++) {
589
+ if (doNotDecode[j]) continue;
590
+ const bookIndex = residue.books[classifications[j][pcount]][pass];
591
+ if (bookIndex < 0) continue;
592
+ const book = codebooks[bookIndex];
593
+ const target = buffers[j];
594
+ const offset = residue.begin + pcount * residue.partSize;
595
+ if (residue.type === 0) {
596
+ const step = Math.floor(residue.partSize / book.dimensions);
597
+ for (let k = 0; k < step; k++) {
598
+ const symbol = book.decode(reader);
599
+ if (symbol < 0) return;
600
+ let last = 0;
601
+ for (let e = 0; e < book.dimensions; e++) {
602
+ const value = book.vqValue(symbol, e) + (book.sequenceP ? last : 0);
603
+ if (book.sequenceP) last = value;
604
+ target[offset + k + e * step] += value;
605
+ }
606
+ }
607
+ } else {
608
+ let k = 0;
609
+ while (k < residue.partSize) {
610
+ const symbol = book.decode(reader);
611
+ if (symbol < 0) return;
612
+ let last = 0;
613
+ for (let e = 0; e < book.dimensions; e++) {
614
+ const value = book.vqValue(symbol, e) + (book.sequenceP ? last : 0);
615
+ if (book.sequenceP) last = value;
616
+ target[offset + k + e] += value;
617
+ }
618
+ k += book.dimensions;
619
+ }
620
+ }
621
+ }
622
+ }
623
+ }
624
+ }
625
+ }
626
+ function buildWindow(n, blockflag, prevFlag, nextFlag, blocksize0) {
627
+ const window = new Float32Array(n);
628
+ const center = n >> 1;
629
+ let leftStart = 0;
630
+ let leftEnd = center;
631
+ let leftN = center;
632
+ let rightStart = center;
633
+ let rightEnd = n;
634
+ let rightN = center;
635
+ if (blockflag && !prevFlag) {
636
+ leftStart = (n >> 2) - (blocksize0 >> 2);
637
+ leftEnd = (n >> 2) + (blocksize0 >> 2);
638
+ leftN = blocksize0 >> 1;
639
+ }
640
+ if (blockflag && !nextFlag) {
641
+ rightStart = n - (n >> 2) - (blocksize0 >> 2);
642
+ rightEnd = n - (n >> 2) + (blocksize0 >> 2);
643
+ rightN = blocksize0 >> 1;
644
+ }
645
+ const leftSlope = vorbisWindowSlope(leftN);
646
+ const rightSlope = vorbisWindowSlope(rightN);
647
+ for (let i = leftStart; i < leftEnd; i++) window[i] = leftSlope[i - leftStart];
648
+ for (let i = leftEnd; i < rightStart; i++) window[i] = 1;
649
+ for (let i = rightStart; i < rightEnd; i++) window[i] = rightSlope[rightN - 1 - (i - rightStart)];
650
+ return window;
651
+ }
652
+ const windowVariantCache = new Map();
653
+ function getWindow(n, blockflag, prevFlag, nextFlag, blocksize0) {
654
+ const key = `${n}:${blockflag ? 1 : 0}${prevFlag ? 1 : 0}${nextFlag ? 1 : 0}:${blocksize0}`;
655
+ let window = windowVariantCache.get(key);
656
+ if (!window) {
657
+ window = buildWindow(n, blockflag, prevFlag, nextFlag, blocksize0);
658
+ windowVariantCache.set(key, window);
659
+ }
660
+ return window;
661
+ }
662
+
663
+ /**
664
+ * Split an Ogg stream into the first logical stream's packets.
665
+ *
666
+ * @param {Uint8Array} bytes Ogg bytes (already CRC-validated by inspection).
667
+ * @returns {object} `{ packets, lastGranule }` for the first stream.
668
+ */
669
+ function extractOggPackets(bytes) {
670
+ const packets = [];
671
+ let pending = [];
672
+ let serial = null;
673
+ let lastGranule = 0;
674
+ let offset = 0;
675
+ while (offset + 27 <= bytes.length) {
676
+ if (bytes[offset] !== 0x4f || bytes[offset + 1] !== 0x67 || bytes[offset + 2] !== 0x67 || bytes[offset + 3] !== 0x53) {
677
+ throw decodeError(`invalid page at byte ${offset}`);
678
+ }
679
+ const headerType = bytes[offset + 5];
680
+ let granule = 0;
681
+ for (let i = 7; i >= 0; i--) granule = granule * 256 + bytes[offset + 6 + i];
682
+ const pageSerial = (bytes[offset + 14] | bytes[offset + 15] << 8 | bytes[offset + 16] << 16 | bytes[offset + 17] * 0x1000000) >>> 0;
683
+ const segmentCount = bytes[offset + 26];
684
+ const tableOffset = offset + 27;
685
+ let cursor = tableOffset + segmentCount;
686
+ const isBos = (headerType & 0x02) !== 0;
687
+ if (serial === null && isBos) serial = pageSerial;
688
+ const ours = pageSerial === serial;
689
+ for (let i = 0; i < segmentCount; i++) {
690
+ const length = bytes[tableOffset + i];
691
+ if (ours && length > 0) pending.push(bytes.subarray(cursor, cursor + length));
692
+ cursor += length;
693
+ if (length < 255 && ours) {
694
+ packets.push(concatChunks(pending));
695
+ pending = [];
696
+ }
697
+ }
698
+ if (ours && granule !== 0xffffffffffffffff && Number.isSafeInteger(granule)) {
699
+ lastGranule = granule;
700
+ }
701
+ offset = cursor;
702
+ }
703
+ if (pending.length) packets.push(concatChunks(pending));
704
+ return {
705
+ packets,
706
+ lastGranule
707
+ };
708
+ }
709
+ function concatChunks(chunks) {
710
+ if (chunks.length === 1) return chunks[0];
711
+ let total = 0;
712
+ for (const chunk of chunks) total += chunk.length;
713
+ const bytes = new Uint8Array(total);
714
+ let cursor = 0;
715
+ for (const chunk of chunks) {
716
+ bytes.set(chunk, cursor);
717
+ cursor += chunk.length;
718
+ }
719
+ return bytes;
720
+ }
721
+ function expectHeader(packet, type) {
722
+ if (packet.length < 7 || packet[0] !== type || packet[1] !== 0x76 || packet[2] !== 0x6f || packet[3] !== 0x72 || packet[4] !== 0x62 || packet[5] !== 0x69 || packet[6] !== 0x73) {
723
+ throw decodeError(`missing vorbis header packet type ${type}`);
724
+ }
725
+ const reader = new PacketReader(packet);
726
+ reader.readBits(8);
727
+ for (let i = 0; i < 6; i++) reader.readBits(8);
728
+ return reader;
729
+ }
730
+ function parseComments(packet) {
731
+ const reader = new PacketReader(packet);
732
+ reader.readBits(8);
733
+ for (let i = 0; i < 6; i++) reader.readBits(8);
734
+ const readString = () => {
735
+ const length = reader.readBits(32);
736
+ let text = "";
737
+ for (let i = 0; i < length; i++) text += String.fromCharCode(reader.readBits(8));
738
+ return text;
739
+ };
740
+ const vendor = readString();
741
+ const count = reader.readBits(32);
742
+ const comments = [];
743
+ for (let i = 0; i < count && !reader.eop; i++) comments.push(readString());
744
+ let loop = null;
745
+ let loopStart = null;
746
+ let loopEnd = null;
747
+ for (const comment of comments) {
748
+ const match = /^(loopstart|loopend)=(\d+)$/iu.exec(comment);
749
+ if (!match) continue;
750
+ if (match[1].toLowerCase() === "loopstart") loopStart = Number(match[2]);else loopEnd = Number(match[2]);
751
+ }
752
+ if (loopStart !== null && loopEnd !== null) loop = {
753
+ start: loopStart,
754
+ end: loopEnd
755
+ };
756
+ return {
757
+ vendor,
758
+ comments,
759
+ loop
760
+ };
761
+ }
762
+
763
+ /**
764
+ * Decode an Ogg Vorbis stream to planar float PCM.
765
+ *
766
+ * @param {Uint8Array} bytes Complete Ogg Vorbis stream bytes.
767
+ * @returns {object} `{ channels, sampleRate, sampleCount, channelData, vendor, comments, loop, packetCount }`.
768
+ */
769
+ function decodeVorbis(bytes) {
770
+ const {
771
+ packets,
772
+ lastGranule
773
+ } = extractOggPackets(bytes);
774
+ if (packets.length < 3) throw decodeError("stream has no audio packets");
775
+
776
+ // identification header
777
+ const identReader = expectHeader(packets[0], 1);
778
+ if (identReader.readBits(32) !== 0) throw decodeError("unsupported vorbis version");
779
+ const channels = identReader.readBits(8);
780
+ const sampleRate = identReader.readBits(32);
781
+ identReader.readBits(32);
782
+ identReader.readBits(32);
783
+ identReader.readBits(32);
784
+ const blocksize0 = 1 << identReader.readBits(4);
785
+ const blocksize1 = 1 << identReader.readBits(4);
786
+ if (!channels || !sampleRate) throw decodeError("invalid identification header");
787
+ if (blocksize0 > blocksize1 || blocksize0 < 64 || blocksize1 > 8192) {
788
+ throw decodeError("invalid blocksizes");
789
+ }
790
+ const {
791
+ vendor,
792
+ comments,
793
+ loop
794
+ } = parseComments(packets[1]);
795
+
796
+ // setup header
797
+ const setup = expectHeader(packets[2], 5);
798
+ const codebooks = [];
799
+ const codebookCount = setup.readBits(8) + 1;
800
+ for (let i = 0; i < codebookCount; i++) codebooks.push(parseCodebook(setup));
801
+ const timeCount = setup.readBits(6) + 1;
802
+ for (let i = 0; i < timeCount; i++) {
803
+ if (setup.readBits(16) !== 0) throw decodeError("nonzero time-domain transform");
804
+ }
805
+ const floors = [];
806
+ const floorCount = setup.readBits(6) + 1;
807
+ for (let i = 0; i < floorCount; i++) floors.push(parseFloor(setup, codebooks));
808
+ const residues = [];
809
+ const residueCount = setup.readBits(6) + 1;
810
+ for (let i = 0; i < residueCount; i++) residues.push(parseResidue(setup, codebooks));
811
+ const mappings = [];
812
+ const mappingCount = setup.readBits(6) + 1;
813
+ for (let i = 0; i < mappingCount; i++) mappings.push(parseMapping(setup, channels, floorCount, residueCount));
814
+ const modes = [];
815
+ const modeCount = setup.readBits(6) + 1;
816
+ for (let i = 0; i < modeCount; i++) {
817
+ const blockflag = setup.readBits(1) === 1;
818
+ if (setup.readBits(16) !== 0 || setup.readBits(16) !== 0) {
819
+ throw decodeError("nonzero mode window/transform type");
820
+ }
821
+ const mapping = setup.readBits(8);
822
+ if (mapping >= mappingCount) throw decodeError("mode references invalid mapping");
823
+ modes.push({
824
+ blockflag,
825
+ mapping
826
+ });
827
+ }
828
+ if (setup.readBits(1) !== 1) throw decodeError("missing setup framing bit");
829
+ const modeBits = ilog(modeCount - 1);
830
+
831
+ // synthesis state
832
+ const n1 = blocksize1;
833
+ const spectrum = [];
834
+ const floorCurves = [];
835
+ const imdctOut = [];
836
+ for (let j = 0; j < channels; j++) {
837
+ spectrum.push(new Float32Array(n1 >> 1));
838
+ floorCurves.push(new Float32Array(n1 >> 1));
839
+ imdctOut.push(new Float32Array(n1));
840
+ }
841
+ const zeroChannel = new Array(channels).fill(false);
842
+ const floorPosts = new Array(channels).fill(null);
843
+ const tails = [];
844
+ for (let j = 0; j < channels; j++) tails.push(new Float32Array(n1 >> 1));
845
+ let prevN = 0;
846
+ const outputChunks = [];
847
+ let totalSamples = 0;
848
+ let packetCount = 0;
849
+ for (let p = 3; p < packets.length; p++) {
850
+ const reader = new PacketReader(packets[p]);
851
+ if (reader.readBits(1) !== 0) continue;
852
+ const modeNumber = reader.readBits(modeBits);
853
+ if (modeNumber < 0 || modeNumber >= modeCount) continue;
854
+ const mode = modes[modeNumber];
855
+ const mapping = mappings[mode.mapping];
856
+ const n = mode.blockflag ? blocksize1 : blocksize0;
857
+ const n2 = n >> 1;
858
+ let prevFlag = false;
859
+ let nextFlag = false;
860
+ if (mode.blockflag) {
861
+ prevFlag = reader.readBits(1) === 1;
862
+ nextFlag = reader.readBits(1) === 1;
863
+ }
864
+
865
+ // floors
866
+ for (let j = 0; j < channels; j++) {
867
+ const floor = floors[mapping.submapFloor[mapping.mux[j]]];
868
+ floorPosts[j] = decodeFloor1Posts(reader, floor, codebooks);
869
+ zeroChannel[j] = floorPosts[j] === null;
870
+ }
871
+
872
+ // coupling keeps partners decoding together
873
+ const reallyZero = zeroChannel.slice();
874
+ for (const step of mapping.couplingSteps) {
875
+ if (!zeroChannel[step.magnitude] || !zeroChannel[step.angle]) {
876
+ zeroChannel[step.magnitude] = false;
877
+ zeroChannel[step.angle] = false;
878
+ }
879
+ }
880
+
881
+ // residues per submap
882
+ for (let j = 0; j < channels; j++) spectrum[j].fill(0);
883
+ for (let s = 0; s < mapping.submaps; s++) {
884
+ const submapChannels = [];
885
+ const doNotDecode = [];
886
+ for (let j = 0; j < channels; j++) {
887
+ if (mapping.mux[j] !== s) continue;
888
+ submapChannels.push(spectrum[j]);
889
+ doNotDecode.push(zeroChannel[j]);
890
+ }
891
+ if (!submapChannels.length) continue;
892
+ decodeResidue(residues[mapping.submapResidue[s]], reader, codebooks, submapChannels, doNotDecode, n2);
893
+ }
894
+
895
+ // inverse coupling (reverse order)
896
+ for (let i = mapping.couplingSteps.length - 1; i >= 0; i--) {
897
+ const {
898
+ magnitude,
899
+ angle
900
+ } = mapping.couplingSteps[i];
901
+ const magnitudeVector = spectrum[magnitude];
902
+ const angleVector = spectrum[angle];
903
+ for (let k = 0; k < n2; k++) {
904
+ const m = magnitudeVector[k];
905
+ const a = angleVector[k];
906
+ let newM;
907
+ let newA;
908
+ if (m > 0) {
909
+ if (a > 0) {
910
+ newM = m;
911
+ newA = m - a;
912
+ } else {
913
+ newA = m;
914
+ newM = m + a;
915
+ }
916
+ } else if (a > 0) {
917
+ newM = m;
918
+ newA = m + a;
919
+ } else {
920
+ newA = m;
921
+ newM = m - a;
922
+ }
923
+ magnitudeVector[k] = newM;
924
+ angleVector[k] = newA;
925
+ }
926
+ }
927
+
928
+ // floor curve multiply + IMDCT + window
929
+ const window = getWindow(n, mode.blockflag, prevFlag, nextFlag, blocksize0);
930
+ for (let j = 0; j < channels; j++) {
931
+ const out = imdctOut[j];
932
+ if (reallyZero[j]) {
933
+ out.fill(0, 0, n);
934
+ continue;
935
+ }
936
+ const floor = floors[mapping.submapFloor[mapping.mux[j]]];
937
+ computeFloor1Curve(floor, floorPosts[j], n2, floorCurves[j]);
938
+ const curve = floorCurves[j];
939
+ const spec = spectrum[j];
940
+ for (let k = 0; k < n2; k++) spec[k] *= curve[k];
941
+ imdct(spec.subarray(0, n2), out, n);
942
+ for (let k = 0; k < n; k++) out[k] *= window[k];
943
+ }
944
+
945
+ // center-aligned overlap-add
946
+ if (prevN) {
947
+ const outCount = prevN + n >> 2;
948
+ const curStart = (prevN >> 2) - (n >> 2);
949
+ const chunk = [];
950
+ for (let j = 0; j < channels; j++) {
951
+ const samples = new Float32Array(outCount);
952
+ const tail = tails[j];
953
+ const cur = imdctOut[j];
954
+ for (let i = 0; i < outCount; i++) {
955
+ let value = i < prevN >> 1 ? tail[i] : 0;
956
+ const curIndex = i - curStart;
957
+ if (curIndex >= 0) value += cur[curIndex];
958
+ samples[i] = value;
959
+ }
960
+ chunk.push(samples);
961
+ }
962
+ outputChunks.push(chunk);
963
+ totalSamples += outCount;
964
+ }
965
+ for (let j = 0; j < channels; j++) {
966
+ tails[j].set(imdctOut[j].subarray(n >> 1, n));
967
+ }
968
+ prevN = n;
969
+ packetCount++;
970
+ }
971
+
972
+ // assemble planar output, trimmed to the stream's final granule
973
+ const finalCount = lastGranule && lastGranule < totalSamples ? lastGranule : totalSamples;
974
+ const channelData = [];
975
+ for (let j = 0; j < channels; j++) channelData.push(new Float32Array(finalCount));
976
+ let cursor = 0;
977
+ for (const chunk of outputChunks) {
978
+ const copyCount = Math.min(chunk[0].length, finalCount - cursor);
979
+ if (copyCount <= 0) break;
980
+ for (let j = 0; j < channels; j++) {
981
+ channelData[j].set(chunk[j].subarray(0, copyCount), cursor);
982
+ }
983
+ cursor += copyCount;
984
+ }
985
+ return {
986
+ channels,
987
+ sampleRate,
988
+ sampleCount: finalCount,
989
+ channelData,
990
+ vendor,
991
+ comments,
992
+ loop,
993
+ packetCount,
994
+ declaredGranule: lastGranule
995
+ };
996
+ }
997
+
998
+ export { decodeVorbis, extractOggPackets };
999
+ //# sourceMappingURL=vorbis.js.map