@woosh/meep-engine 3.9.0 → 3.10.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 (696) hide show
  1. package/build/bundle-worker-image-decoder.js +1 -1
  2. package/build/bundle-worker-terrain.js +1 -1
  3. package/package.json +3 -2
  4. package/src/avif/encode_image_source.d.ts +70 -0
  5. package/src/avif/encode_image_source.d.ts.map +1 -0
  6. package/src/avif/encode_image_source.js +117 -0
  7. package/src/avif/encoder_worker.js +15 -126
  8. package/src/avif/index.d.ts +4 -2
  9. package/src/avif/index.js +21 -2
  10. package/src/avif/native/DECISIONS.md +537 -0
  11. package/src/avif/native/NOTICE.md +61 -0
  12. package/src/avif/native/api/AvifDecoder.d.ts +67 -0
  13. package/src/avif/native/api/AvifDecoder.d.ts.map +1 -0
  14. package/src/avif/native/api/AvifDecoder.js +121 -0
  15. package/src/avif/native/api/apply_transformations.d.ts +30 -0
  16. package/src/avif/native/api/apply_transformations.d.ts.map +1 -0
  17. package/src/avif/native/api/apply_transformations.js +120 -0
  18. package/src/avif/native/api/avif_to_sampler2d.d.ts +25 -0
  19. package/src/avif/native/api/avif_to_sampler2d.d.ts.map +1 -0
  20. package/src/avif/native/api/avif_to_sampler2d.js +42 -0
  21. package/src/avif/native/api/convert_to_rgba.d.ts +54 -0
  22. package/src/avif/native/api/convert_to_rgba.d.ts.map +1 -0
  23. package/src/avif/native/api/convert_to_rgba.js +204 -0
  24. package/src/avif/native/api/decode_avif.d.ts +24 -0
  25. package/src/avif/native/api/decode_avif.d.ts.map +1 -0
  26. package/src/avif/native/api/decode_avif.js +111 -0
  27. package/src/avif/native/api/decode_image_item.d.ts +18 -0
  28. package/src/avif/native/api/decode_image_item.d.ts.map +1 -0
  29. package/src/avif/native/api/decode_image_item.js +234 -0
  30. package/src/avif/native/api/encode_avif.d.ts +73 -0
  31. package/src/avif/native/api/encode_avif.d.ts.map +1 -0
  32. package/src/avif/native/api/encode_avif.js +488 -0
  33. package/src/avif/native/api/sampler2d_to_avif.d.ts +22 -0
  34. package/src/avif/native/api/sampler2d_to_avif.d.ts.map +1 -0
  35. package/src/avif/native/api/sampler2d_to_avif.js +108 -0
  36. package/src/avif/native/av1/decode/Av1FrameContext.d.ts +286 -0
  37. package/src/avif/native/av1/decode/Av1FrameContext.d.ts.map +1 -0
  38. package/src/avif/native/av1/decode/Av1FrameContext.js +622 -0
  39. package/src/avif/native/av1/decode/block_decoded.d.ts +27 -0
  40. package/src/avif/native/av1/decode/block_decoded.d.ts.map +1 -0
  41. package/src/avif/native/av1/decode/block_decoded.js +59 -0
  42. package/src/avif/native/av1/decode/decode_av1_still.d.ts +22 -0
  43. package/src/avif/native/av1/decode/decode_av1_still.d.ts.map +1 -0
  44. package/src/avif/native/av1/decode/decode_av1_still.js +309 -0
  45. package/src/avif/native/av1/decode/decode_coefficients.d.ts +20 -0
  46. package/src/avif/native/av1/decode/decode_coefficients.d.ts.map +1 -0
  47. package/src/avif/native/av1/decode/decode_coefficients.js +259 -0
  48. package/src/avif/native/av1/decode/decode_palette.d.ts +28 -0
  49. package/src/avif/native/av1/decode/decode_palette.d.ts.map +1 -0
  50. package/src/avif/native/av1/decode/decode_palette.js +442 -0
  51. package/src/avif/native/av1/decode/decode_tile.d.ts +14 -0
  52. package/src/avif/native/av1/decode/decode_tile.d.ts.map +1 -0
  53. package/src/avif/native/av1/decode/decode_tile.js +1213 -0
  54. package/src/avif/native/av1/decode/get_scan.d.ts +16 -0
  55. package/src/avif/native/av1/decode/get_scan.d.ts.map +1 -0
  56. package/src/avif/native/av1/decode/get_scan.js +138 -0
  57. package/src/avif/native/av1/decode/read_lr.d.ts +35 -0
  58. package/src/avif/native/av1/decode/read_lr.d.ts.map +1 -0
  59. package/src/avif/native/av1/decode/read_lr.js +277 -0
  60. package/src/avif/native/av1/decode/read_transform_type.d.ts +19 -0
  61. package/src/avif/native/av1/decode/read_transform_type.d.ts.map +1 -0
  62. package/src/avif/native/av1/decode/read_transform_type.js +92 -0
  63. package/src/avif/native/av1/decode/reconstruct.d.ts +36 -0
  64. package/src/avif/native/av1/decode/reconstruct.d.ts.map +1 -0
  65. package/src/avif/native/av1/decode/reconstruct.js +241 -0
  66. package/src/avif/native/av1/decode/transform_type.d.ts +49 -0
  67. package/src/avif/native/av1/decode/transform_type.d.ts.map +1 -0
  68. package/src/avif/native/av1/decode/transform_type.js +137 -0
  69. package/src/avif/native/av1/encode/Av1BlockSnapshot.d.ts +81 -0
  70. package/src/avif/native/av1/encode/Av1BlockSnapshot.d.ts.map +1 -0
  71. package/src/avif/native/av1/encode/Av1BlockSnapshot.js +299 -0
  72. package/src/avif/native/av1/encode/Av1EncodeContext.d.ts +384 -0
  73. package/src/avif/native/av1/encode/Av1EncodeContext.d.ts.map +1 -0
  74. package/src/avif/native/av1/encode/Av1EncodeContext.js +590 -0
  75. package/src/avif/native/av1/encode/build_headers.d.ts +50 -0
  76. package/src/avif/native/av1/encode/build_headers.d.ts.map +1 -0
  77. package/src/avif/native/av1/encode/build_headers.js +359 -0
  78. package/src/avif/native/av1/encode/choose_chroma_alpha.d.ts +26 -0
  79. package/src/avif/native/av1/encode/choose_chroma_alpha.d.ts.map +1 -0
  80. package/src/avif/native/av1/encode/choose_chroma_alpha.js +90 -0
  81. package/src/avif/native/av1/encode/choose_filters.d.ts +21 -0
  82. package/src/avif/native/av1/encode/choose_filters.d.ts.map +1 -0
  83. package/src/avif/native/av1/encode/choose_filters.js +318 -0
  84. package/src/avif/native/av1/encode/choose_restoration.d.ts +35 -0
  85. package/src/avif/native/av1/encode/choose_restoration.d.ts.map +1 -0
  86. package/src/avif/native/av1/encode/choose_restoration.js +616 -0
  87. package/src/avif/native/av1/encode/decode_effort.d.ts +57 -0
  88. package/src/avif/native/av1/encode/decode_effort.d.ts.map +1 -0
  89. package/src/avif/native/av1/encode/decode_effort.js +59 -0
  90. package/src/avif/native/av1/encode/encode_av1_still.d.ts +17 -0
  91. package/src/avif/native/av1/encode/encode_av1_still.d.ts.map +1 -0
  92. package/src/avif/native/av1/encode/encode_av1_still.js +194 -0
  93. package/src/avif/native/av1/encode/encode_effort.d.ts +56 -0
  94. package/src/avif/native/av1/encode/encode_effort.d.ts.map +1 -0
  95. package/src/avif/native/av1/encode/encode_effort.js +97 -0
  96. package/src/avif/native/av1/encode/encode_tile.d.ts +26 -0
  97. package/src/avif/native/av1/encode/encode_tile.d.ts.map +1 -0
  98. package/src/avif/native/av1/encode/encode_tile.js +2331 -0
  99. package/src/avif/native/av1/encode/quantise.d.ts +51 -0
  100. package/src/avif/native/av1/encode/quantise.d.ts.map +1 -0
  101. package/src/avif/native/av1/encode/quantise.js +212 -0
  102. package/src/avif/native/av1/encode/write_coefficients.d.ts +42 -0
  103. package/src/avif/native/av1/encode/write_coefficients.d.ts.map +1 -0
  104. package/src/avif/native/av1/encode/write_coefficients.js +367 -0
  105. package/src/avif/native/av1/encode/write_lr.d.ts +33 -0
  106. package/src/avif/native/av1/encode/write_lr.d.ts.map +1 -0
  107. package/src/avif/native/av1/encode/write_lr.js +174 -0
  108. package/src/avif/native/av1/encode/write_transform_type.d.ts +21 -0
  109. package/src/avif/native/av1/encode/write_transform_type.d.ts.map +1 -0
  110. package/src/avif/native/av1/encode/write_transform_type.js +70 -0
  111. package/src/avif/native/av1/entropy/CdfContext.d.ts +167 -0
  112. package/src/avif/native/av1/entropy/CdfContext.d.ts.map +1 -0
  113. package/src/avif/native/av1/entropy/CdfContext.js +433 -0
  114. package/src/avif/native/av1/entropy/SymbolReader.d.ts +103 -0
  115. package/src/avif/native/av1/entropy/SymbolReader.d.ts.map +1 -0
  116. package/src/avif/native/av1/entropy/SymbolReader.js +317 -0
  117. package/src/avif/native/av1/entropy/SymbolWriter.d.ts +107 -0
  118. package/src/avif/native/av1/entropy/SymbolWriter.d.ts.map +1 -0
  119. package/src/avif/native/av1/entropy/SymbolWriter.js +352 -0
  120. package/src/avif/native/av1/entropy/coefficient_context.d.ts +71 -0
  121. package/src/avif/native/av1/entropy/coefficient_context.d.ts.map +1 -0
  122. package/src/avif/native/av1/entropy/coefficient_context.js +325 -0
  123. package/src/avif/native/av1/entropy/partition_cdf.d.ts +54 -0
  124. package/src/avif/native/av1/entropy/partition_cdf.d.ts.map +1 -0
  125. package/src/avif/native/av1/entropy/partition_cdf.js +98 -0
  126. package/src/avif/native/av1/entropy/symbol_cost.d.ts +37 -0
  127. package/src/avif/native/av1/entropy/symbol_cost.d.ts.map +1 -0
  128. package/src/avif/native/av1/entropy/symbol_cost.js +76 -0
  129. package/src/avif/native/av1/filter/cdef.d.ts +15 -0
  130. package/src/avif/native/av1/filter/cdef.d.ts.map +1 -0
  131. package/src/avif/native/av1/filter/cdef.js +313 -0
  132. package/src/avif/native/av1/filter/loop_filter.d.ts +14 -0
  133. package/src/avif/native/av1/filter/loop_filter.d.ts.map +1 -0
  134. package/src/avif/native/av1/filter/loop_filter.js +377 -0
  135. package/src/avif/native/av1/filter/loop_restoration.d.ts +42 -0
  136. package/src/avif/native/av1/filter/loop_restoration.d.ts.map +1 -0
  137. package/src/avif/native/av1/filter/loop_restoration.js +451 -0
  138. package/src/avif/native/av1/filter/superres.d.ts +18 -0
  139. package/src/avif/native/av1/filter/superres.d.ts.map +1 -0
  140. package/src/avif/native/av1/filter/superres.js +86 -0
  141. package/src/avif/native/av1/grain/FilmGrainState.d.ts +62 -0
  142. package/src/avif/native/av1/grain/FilmGrainState.d.ts.map +1 -0
  143. package/src/avif/native/av1/grain/FilmGrainState.js +87 -0
  144. package/src/avif/native/av1/grain/film_grain.d.ts +16 -0
  145. package/src/avif/native/av1/grain/film_grain.d.ts.map +1 -0
  146. package/src/avif/native/av1/grain/film_grain.js +623 -0
  147. package/src/avif/native/av1/obu/FrameHeader.d.ts +248 -0
  148. package/src/avif/native/av1/obu/FrameHeader.d.ts.map +1 -0
  149. package/src/avif/native/av1/obu/FrameHeader.js +381 -0
  150. package/src/avif/native/av1/obu/ObuHeader.d.ts +53 -0
  151. package/src/avif/native/av1/obu/ObuHeader.d.ts.map +1 -0
  152. package/src/avif/native/av1/obu/ObuHeader.js +62 -0
  153. package/src/avif/native/av1/obu/SequenceHeader.d.ts +157 -0
  154. package/src/avif/native/av1/obu/SequenceHeader.d.ts.map +1 -0
  155. package/src/avif/native/av1/obu/SequenceHeader.js +225 -0
  156. package/src/avif/native/av1/obu/for_each_obu.d.ts +24 -0
  157. package/src/avif/native/av1/obu/for_each_obu.d.ts.map +1 -0
  158. package/src/avif/native/av1/obu/for_each_obu.js +50 -0
  159. package/src/avif/native/av1/obu/parse_frame_header.d.ts +18 -0
  160. package/src/avif/native/av1/obu/parse_frame_header.d.ts.map +1 -0
  161. package/src/avif/native/av1/obu/parse_frame_header.js +841 -0
  162. package/src/avif/native/av1/obu/parse_obu_header.d.ts +23 -0
  163. package/src/avif/native/av1/obu/parse_obu_header.d.ts.map +1 -0
  164. package/src/avif/native/av1/obu/parse_obu_header.js +69 -0
  165. package/src/avif/native/av1/obu/parse_sequence_header.d.ts +17 -0
  166. package/src/avif/native/av1/obu/parse_sequence_header.d.ts.map +1 -0
  167. package/src/avif/native/av1/obu/parse_sequence_header.js +263 -0
  168. package/src/avif/native/av1/obu/write_frame_header.d.ts +16 -0
  169. package/src/avif/native/av1/obu/write_frame_header.d.ts.map +1 -0
  170. package/src/avif/native/av1/obu/write_frame_header.js +579 -0
  171. package/src/avif/native/av1/obu/write_sequence_header.d.ts +17 -0
  172. package/src/avif/native/av1/obu/write_sequence_header.d.ts.map +1 -0
  173. package/src/avif/native/av1/obu/write_sequence_header.js +189 -0
  174. package/src/avif/native/av1/predict/IntraPredictionState.d.ts +49 -0
  175. package/src/avif/native/av1/predict/IntraPredictionState.d.ts.map +1 -0
  176. package/src/avif/native/av1/predict/IntraPredictionState.js +58 -0
  177. package/src/avif/native/av1/predict/intra_filter_type.d.ts +17 -0
  178. package/src/avif/native/av1/predict/intra_filter_type.d.ts.map +1 -0
  179. package/src/avif/native/av1/predict/intra_filter_type.js +79 -0
  180. package/src/avif/native/av1/predict/predict_chroma_from_luma.d.ts +50 -0
  181. package/src/avif/native/av1/predict/predict_chroma_from_luma.d.ts.map +1 -0
  182. package/src/avif/native/av1/predict/predict_chroma_from_luma.js +153 -0
  183. package/src/avif/native/av1/predict/predict_intra.d.ts +42 -0
  184. package/src/avif/native/av1/predict/predict_intra.d.ts.map +1 -0
  185. package/src/avif/native/av1/predict/predict_intra.js +803 -0
  186. package/src/avif/native/av1/predict/predict_palette.d.ts +23 -0
  187. package/src/avif/native/av1/predict/predict_palette.d.ts.map +1 -0
  188. package/src/avif/native/av1/predict/predict_palette.js +36 -0
  189. package/src/avif/native/av1/tables/av1_symbols.d.ts +411 -0
  190. package/src/avif/native/av1/tables/av1_symbols.d.ts.map +1 -0
  191. package/src/avif/native/av1/tables/av1_symbols.js +419 -0
  192. package/src/avif/native/av1/tables/block_tables.d.ts +181 -0
  193. package/src/avif/native/av1/tables/block_tables.d.ts.map +1 -0
  194. package/src/avif/native/av1/tables/block_tables.js +270 -0
  195. package/src/avif/native/av1/tables/cdf_tables.d.ts +961 -0
  196. package/src/avif/native/av1/tables/cdf_tables.d.ts.map +1 -0
  197. package/src/avif/native/av1/tables/cdf_tables.js +1893 -0
  198. package/src/avif/native/av1/tables/coefficient_tables.d.ts +41 -0
  199. package/src/avif/native/av1/tables/coefficient_tables.d.ts.map +1 -0
  200. package/src/avif/native/av1/tables/coefficient_tables.js +82 -0
  201. package/src/avif/native/av1/tables/derived_block_tables.d.ts +15 -0
  202. package/src/avif/native/av1/tables/derived_block_tables.d.ts.map +1 -0
  203. package/src/avif/native/av1/tables/derived_block_tables.js +23 -0
  204. package/src/avif/native/av1/tables/filter_tables.d.ts +171 -0
  205. package/src/avif/native/av1/tables/filter_tables.d.ts.map +1 -0
  206. package/src/avif/native/av1/tables/filter_tables.js +313 -0
  207. package/src/avif/native/av1/tables/grain_tables.d.ts +11 -0
  208. package/src/avif/native/av1/tables/grain_tables.d.ts.map +1 -0
  209. package/src/avif/native/av1/tables/grain_tables.js +190 -0
  210. package/src/avif/native/av1/tables/prediction_tables.d.ts +141 -0
  211. package/src/avif/native/av1/tables/prediction_tables.d.ts.map +1 -0
  212. package/src/avif/native/av1/tables/prediction_tables.js +223 -0
  213. package/src/avif/native/av1/tables/quantizer_matrix_tables.d.ts +21 -0
  214. package/src/avif/native/av1/tables/quantizer_matrix_tables.d.ts.map +1 -0
  215. package/src/avif/native/av1/tables/quantizer_matrix_tables.js +38 -0
  216. package/src/avif/native/av1/tables/quantizer_tables.d.ts +21 -0
  217. package/src/avif/native/av1/tables/quantizer_tables.d.ts.map +1 -0
  218. package/src/avif/native/av1/tables/quantizer_tables.js +160 -0
  219. package/src/avif/native/av1/tables/scan_tables.d.ts +321 -0
  220. package/src/avif/native/av1/tables/scan_tables.d.ts.map +1 -0
  221. package/src/avif/native/av1/tables/scan_tables.js +727 -0
  222. package/src/avif/native/av1/tables/segmentation_tables.d.ts +31 -0
  223. package/src/avif/native/av1/tables/segmentation_tables.d.ts.map +1 -0
  224. package/src/avif/native/av1/tables/segmentation_tables.js +48 -0
  225. package/src/avif/native/av1/tables/transform_tables.d.ts +91 -0
  226. package/src/avif/native/av1/tables/transform_tables.d.ts.map +1 -0
  227. package/src/avif/native/av1/tables/transform_tables.js +140 -0
  228. package/src/avif/native/av1/tables/unpack_table.d.ts +33 -0
  229. package/src/avif/native/av1/tables/unpack_table.d.ts.map +1 -0
  230. package/src/avif/native/av1/tables/unpack_table.js +73 -0
  231. package/src/avif/native/av1/transform/forward_transform_2d.d.ts +61 -0
  232. package/src/avif/native/av1/transform/forward_transform_2d.d.ts.map +1 -0
  233. package/src/avif/native/av1/transform/forward_transform_2d.js +574 -0
  234. package/src/avif/native/av1/transform/inverse_transform_1d.d.ts +76 -0
  235. package/src/avif/native/av1/transform/inverse_transform_1d.d.ts.map +1 -0
  236. package/src/avif/native/av1/transform/inverse_transform_1d.js +590 -0
  237. package/src/avif/native/av1/transform/inverse_transform_2d.d.ts +46 -0
  238. package/src/avif/native/av1/transform/inverse_transform_2d.d.ts.map +1 -0
  239. package/src/avif/native/av1/transform/inverse_transform_2d.js +180 -0
  240. package/src/avif/native/av1/util/ceil_log2.d.ts +13 -0
  241. package/src/avif/native/av1/util/ceil_log2.d.ts.map +1 -0
  242. package/src/avif/native/av1/util/ceil_log2.js +18 -0
  243. package/src/avif/native/av1/util/floor_log2.d.ts +20 -0
  244. package/src/avif/native/av1/util/floor_log2.d.ts.map +1 -0
  245. package/src/avif/native/av1/util/floor_log2.js +20 -0
  246. package/src/avif/native/av1/util/round2.d.ts +22 -0
  247. package/src/avif/native/av1/util/round2.d.ts.map +1 -0
  248. package/src/avif/native/av1/util/round2.js +27 -0
  249. package/src/avif/native/av1/util/round2_signed.d.ts +14 -0
  250. package/src/avif/native/av1/util/round2_signed.d.ts.map +1 -0
  251. package/src/avif/native/av1/util/round2_signed.js +17 -0
  252. package/src/avif/native/av1/util/tile_log2.d.ts +16 -0
  253. package/src/avif/native/av1/util/tile_log2.d.ts.map +1 -0
  254. package/src/avif/native/av1/util/tile_log2.js +23 -0
  255. package/src/avif/native/bitstream/BitReader.d.ts +174 -0
  256. package/src/avif/native/bitstream/BitReader.d.ts.map +1 -0
  257. package/src/avif/native/bitstream/BitReader.js +391 -0
  258. package/src/avif/native/bitstream/BitWriter.d.ts +122 -0
  259. package/src/avif/native/bitstream/BitWriter.d.ts.map +1 -0
  260. package/src/avif/native/bitstream/BitWriter.js +351 -0
  261. package/src/avif/native/color/ColourTransform.d.ts +62 -0
  262. package/src/avif/native/color/ColourTransform.d.ts.map +1 -0
  263. package/src/avif/native/color/ColourTransform.js +189 -0
  264. package/src/avif/native/color/YuvImage.d.ts +51 -0
  265. package/src/avif/native/color/YuvImage.d.ts.map +1 -0
  266. package/src/avif/native/color/YuvImage.js +66 -0
  267. package/src/avif/native/color/clamp_sample.d.ts +18 -0
  268. package/src/avif/native/color/clamp_sample.d.ts.map +1 -0
  269. package/src/avif/native/color/clamp_sample.js +25 -0
  270. package/src/avif/native/color/linear_to_transfer.d.ts +24 -0
  271. package/src/avif/native/color/linear_to_transfer.d.ts.map +1 -0
  272. package/src/avif/native/color/linear_to_transfer.js +126 -0
  273. package/src/avif/native/color/primaries.d.ts +20 -0
  274. package/src/avif/native/color/primaries.d.ts.map +1 -0
  275. package/src/avif/native/color/primaries.js +94 -0
  276. package/src/avif/native/color/rgb_row_to_ycbcr.d.ts +20 -0
  277. package/src/avif/native/color/rgb_row_to_ycbcr.d.ts.map +1 -0
  278. package/src/avif/native/color/rgb_row_to_ycbcr.js +78 -0
  279. package/src/avif/native/color/transfer_to_linear.d.ts +49 -0
  280. package/src/avif/native/color/transfer_to_linear.d.ts.map +1 -0
  281. package/src/avif/native/color/transfer_to_linear.js +171 -0
  282. package/src/avif/native/color/upsample_chroma_row.d.ts +35 -0
  283. package/src/avif/native/color/upsample_chroma_row.d.ts.map +1 -0
  284. package/src/avif/native/color/upsample_chroma_row.js +89 -0
  285. package/src/avif/native/color/ycbcr_row_to_rgb.d.ts +23 -0
  286. package/src/avif/native/color/ycbcr_row_to_rgb.d.ts.map +1 -0
  287. package/src/avif/native/color/ycbcr_row_to_rgb.js +78 -0
  288. package/src/avif/native/heif/AvifFile.d.ts +112 -0
  289. package/src/avif/native/heif/AvifFile.d.ts.map +1 -0
  290. package/src/avif/native/heif/AvifFile.js +142 -0
  291. package/src/avif/native/heif/ItemProperty.d.ts +244 -0
  292. package/src/avif/native/heif/ItemProperty.d.ts.map +1 -0
  293. package/src/avif/native/heif/ItemProperty.js +321 -0
  294. package/src/avif/native/heif/find_item_property.d.ts +17 -0
  295. package/src/avif/native/heif/find_item_property.d.ts.map +1 -0
  296. package/src/avif/native/heif/find_item_property.js +28 -0
  297. package/src/avif/native/heif/find_item_references.d.ts +16 -0
  298. package/src/avif/native/heif/find_item_references.d.ts.map +1 -0
  299. package/src/avif/native/heif/find_item_references.js +29 -0
  300. package/src/avif/native/heif/find_items_referencing.d.ts +17 -0
  301. package/src/avif/native/heif/find_items_referencing.d.ts.map +1 -0
  302. package/src/avif/native/heif/find_items_referencing.js +36 -0
  303. package/src/avif/native/heif/parse_avif_file.d.ts +15 -0
  304. package/src/avif/native/heif/parse_avif_file.d.ts.map +1 -0
  305. package/src/avif/native/heif/parse_avif_file.js +383 -0
  306. package/src/avif/native/heif/parse_image_grid.d.ts +18 -0
  307. package/src/avif/native/heif/parse_image_grid.d.ts.map +1 -0
  308. package/src/avif/native/heif/parse_image_grid.js +48 -0
  309. package/src/avif/native/heif/parse_item_property.d.ts +18 -0
  310. package/src/avif/native/heif/parse_item_property.d.ts.map +1 -0
  311. package/src/avif/native/heif/parse_item_property.js +243 -0
  312. package/src/avif/native/heif/read_item_data.d.ts +22 -0
  313. package/src/avif/native/heif/read_item_data.d.ts.map +1 -0
  314. package/src/avif/native/heif/read_item_data.js +97 -0
  315. package/src/avif/native/heif/write_avif_file.d.ts +50 -0
  316. package/src/avif/native/heif/write_avif_file.d.ts.map +1 -0
  317. package/src/avif/native/heif/write_avif_file.js +348 -0
  318. package/src/avif/native/heif/write_item_property.d.ts +16 -0
  319. package/src/avif/native/heif/write_item_property.d.ts.map +1 -0
  320. package/src/avif/native/heif/write_item_property.js +182 -0
  321. package/src/avif/native/index.d.ts +14 -0
  322. package/src/avif/native/index.d.ts.map +1 -0
  323. package/src/avif/native/index.js +56 -0
  324. package/src/avif/native/isobmff/BoxHeader.d.ts +50 -0
  325. package/src/avif/native/isobmff/BoxHeader.d.ts.map +1 -0
  326. package/src/avif/native/isobmff/BoxHeader.js +57 -0
  327. package/src/avif/native/isobmff/BoxWriter.d.ts +118 -0
  328. package/src/avif/native/isobmff/BoxWriter.d.ts.map +1 -0
  329. package/src/avif/native/isobmff/BoxWriter.js +264 -0
  330. package/src/avif/native/isobmff/ByteCursor.d.ts +125 -0
  331. package/src/avif/native/isobmff/ByteCursor.d.ts.map +1 -0
  332. package/src/avif/native/isobmff/ByteCursor.js +298 -0
  333. package/src/avif/native/isobmff/for_each_box.d.ts +23 -0
  334. package/src/avif/native/isobmff/for_each_box.d.ts.map +1 -0
  335. package/src/avif/native/isobmff/for_each_box.js +39 -0
  336. package/src/avif/native/isobmff/read_box_header.d.ts +22 -0
  337. package/src/avif/native/isobmff/read_box_header.d.ts.map +1 -0
  338. package/src/avif/native/isobmff/read_box_header.js +59 -0
  339. package/src/avif/native/isobmff/read_full_box_header.d.ts +26 -0
  340. package/src/avif/native/isobmff/read_full_box_header.d.ts.map +1 -0
  341. package/src/avif/native/isobmff/read_full_box_header.js +33 -0
  342. package/src/avif/threaded_image_encoder.d.ts +7 -2
  343. package/src/avif/threaded_image_encoder.d.ts.map +1 -1
  344. package/src/avif/threaded_image_encoder.js +107 -21
  345. package/src/core/binary/BinaryBuffer.d.ts +40 -0
  346. package/src/core/binary/BinaryBuffer.d.ts.map +1 -1
  347. package/src/core/binary/BinaryBuffer.js +100 -0
  348. package/src/core/binary/hash/crc32.d.ts +16 -0
  349. package/src/core/binary/hash/crc32.d.ts.map +1 -0
  350. package/src/core/binary/hash/crc32.js +96 -0
  351. package/src/core/binary/utf8/utf8_decode.d.ts +21 -0
  352. package/src/core/binary/utf8/utf8_decode.d.ts.map +1 -0
  353. package/src/core/binary/utf8/utf8_decode.js +43 -0
  354. package/src/core/binary/utf8/utf8_encode_into.d.ts +20 -0
  355. package/src/core/binary/utf8/utf8_encode_into.d.ts.map +1 -0
  356. package/src/core/binary/utf8/utf8_encode_into.js +48 -0
  357. package/src/core/binary/utf8/utf8_encoded_length.d.ts +14 -0
  358. package/src/core/binary/utf8/utf8_encoded_length.d.ts.map +1 -0
  359. package/src/core/binary/utf8/utf8_encoded_length.js +36 -0
  360. package/src/core/color/COLOR_FIX_PLAN_2026_08_28.md +417 -0
  361. package/src/core/color/COLOR_REVIEW_2026_08_28.md +779 -0
  362. package/src/core/color/Color.d.ts +128 -20
  363. package/src/core/color/Color.d.ts.map +1 -1
  364. package/src/core/color/Color.js +959 -866
  365. package/src/core/color/PQ/PQ_constants.d.ts +10 -0
  366. package/src/core/color/PQ/PQ_constants.d.ts.map +1 -1
  367. package/src/core/color/PQ/PQ_constants.js +10 -0
  368. package/src/core/color/PQ/linear_to_PQ.d.ts.map +1 -1
  369. package/src/core/color/PQ/linear_to_PQ.js +6 -0
  370. package/src/core/color/REC709_PRIMARIES.d.ts +50 -0
  371. package/src/core/color/REC709_PRIMARIES.d.ts.map +1 -0
  372. package/src/core/color/REC709_PRIMARIES.js +53 -0
  373. package/src/core/color/construct/color_from_hex.d.ts +21 -0
  374. package/src/core/color/construct/color_from_hex.d.ts.map +1 -0
  375. package/src/core/color/construct/color_from_hex.js +33 -0
  376. package/src/core/color/construct/color_from_temperature.d.ts +22 -0
  377. package/src/core/color/construct/color_from_temperature.d.ts.map +1 -0
  378. package/src/core/color/construct/color_from_temperature.js +33 -0
  379. package/src/core/color/construct/color_from_uint24.d.ts +19 -0
  380. package/src/core/color/construct/color_from_uint24.d.ts.map +1 -0
  381. package/src/core/color/construct/color_from_uint24.js +26 -0
  382. package/src/core/color/construct/color_from_uint32.d.ts +20 -0
  383. package/src/core/color/construct/color_from_uint32.d.ts.map +1 -0
  384. package/src/core/color/construct/color_from_uint32.js +39 -0
  385. package/src/core/color/construct/color_gray.d.ts +17 -0
  386. package/src/core/color/construct/color_gray.d.ts.map +1 -0
  387. package/src/core/color/construct/color_gray.js +22 -0
  388. package/src/core/color/hex/hex2rgb.d.ts +1 -11
  389. package/src/core/color/hex/hex2rgb.d.ts.map +1 -1
  390. package/src/core/color/hex/hex2rgb.js +7 -24
  391. package/src/core/color/hex/hex_to_rgb.d.ts +18 -0
  392. package/src/core/color/hex/hex_to_rgb.d.ts.map +1 -0
  393. package/src/core/color/hex/hex_to_rgb.js +62 -0
  394. package/src/core/color/hex/rgb2hex.d.ts +1 -8
  395. package/src/core/color/hex/rgb2hex.d.ts.map +1 -1
  396. package/src/core/color/hex/rgb2hex.js +7 -13
  397. package/src/core/color/hex/rgb_to_hex.d.ts +9 -0
  398. package/src/core/color/hex/rgb_to_hex.d.ts.map +1 -0
  399. package/src/core/color/hex/rgb_to_hex.js +13 -0
  400. package/src/core/color/hex/rgba_to_hex.d.ts +19 -0
  401. package/src/core/color/hex/rgba_to_hex.d.ts.map +1 -0
  402. package/src/core/color/hex/rgba_to_hex.js +23 -0
  403. package/src/core/color/hsv/hsv2rgb.d.ts +1 -12
  404. package/src/core/color/hsv/hsv2rgb.d.ts.map +1 -1
  405. package/src/core/color/hsv/hsv2rgb.js +8 -21
  406. package/src/core/color/hsv/hsv2rgb_float.d.ts +1 -12
  407. package/src/core/color/hsv/hsv2rgb_float.d.ts.map +1 -1
  408. package/src/core/color/hsv/hsv2rgb_float.js +8 -56
  409. package/src/core/color/hsv/hsv_to_rgb.d.ts +13 -0
  410. package/src/core/color/hsv/hsv_to_rgb.d.ts.map +1 -0
  411. package/src/core/color/hsv/hsv_to_rgb.js +39 -0
  412. package/src/core/color/hsv/hsv_to_rgb_uint8.d.ts +13 -0
  413. package/src/core/color/hsv/hsv_to_rgb_uint8.d.ts.map +1 -0
  414. package/src/core/color/hsv/hsv_to_rgb_uint8.js +21 -0
  415. package/src/core/color/hsv/hue_to_rgb_sextant.d.ts +24 -0
  416. package/src/core/color/hsv/hue_to_rgb_sextant.d.ts.map +1 -0
  417. package/src/core/color/hsv/hue_to_rgb_sextant.js +67 -0
  418. package/src/core/color/hsv/rgb2hsv.d.ts +1 -12
  419. package/src/core/color/hsv/rgb2hsv.d.ts.map +1 -1
  420. package/src/core/color/hsv/rgb2hsv.js +7 -42
  421. package/src/core/color/hsv/rgb_to_hsv.d.ts +13 -0
  422. package/src/core/color/hsv/rgb_to_hsv.d.ts.map +1 -0
  423. package/src/core/color/hsv/rgb_to_hsv.js +42 -0
  424. package/src/core/color/hunt/hpe_to_xyz.d.ts +2 -0
  425. package/src/core/color/hunt/hpe_to_xyz.d.ts.map +1 -0
  426. package/src/core/color/hunt/hpe_to_xyz.js +4 -0
  427. package/src/core/color/hunt/xyz_to_hpe.d.ts +1 -6
  428. package/src/core/color/hunt/xyz_to_hpe.d.ts.map +1 -1
  429. package/src/core/color/hunt/xyz_to_hpe.js +12 -15
  430. package/src/core/color/illuminant/D65_spd_tabulated.d.ts.map +1 -1
  431. package/src/core/color/illuminant/D65_spd_tabulated.js +107 -104
  432. package/src/core/color/int2rgb.d.ts +1 -10
  433. package/src/core/color/int2rgb.d.ts.map +1 -1
  434. package/src/core/color/int2rgb.js +7 -12
  435. package/src/core/color/int_to_rgb.d.ts +21 -0
  436. package/src/core/color/int_to_rgb.d.ts.map +1 -0
  437. package/src/core/color/int_to_rgb.js +33 -0
  438. package/src/core/color/kelvin/kelvin_to_rgb.d.ts.map +1 -1
  439. package/src/core/color/kelvin/kelvin_to_rgb.js +22 -2
  440. package/src/core/color/kelvin/rgb_to_kelvin.d.ts +22 -2
  441. package/src/core/color/kelvin/rgb_to_kelvin.d.ts.map +1 -1
  442. package/src/core/color/kelvin/rgb_to_kelvin.js +22 -2
  443. package/src/core/color/lab/lab_to_xyz.d.ts +20 -0
  444. package/src/core/color/lab/lab_to_xyz.d.ts.map +1 -0
  445. package/src/core/color/lab/lab_to_xyz.js +69 -0
  446. package/src/core/color/oklab/gamut_clip_adaptive_l0.d.ts +34 -0
  447. package/src/core/color/oklab/gamut_clip_adaptive_l0.d.ts.map +1 -0
  448. package/src/core/color/oklab/gamut_clip_adaptive_l0.js +46 -0
  449. package/src/core/color/oklab/gamut_clip_at_l0.d.ts +33 -0
  450. package/src/core/color/oklab/gamut_clip_at_l0.d.ts.map +1 -0
  451. package/src/core/color/oklab/gamut_clip_at_l0.js +84 -0
  452. package/src/core/color/oklab/gamut_clip_preserve_chroma.d.ts +24 -0
  453. package/src/core/color/oklab/gamut_clip_preserve_chroma.d.ts.map +1 -0
  454. package/src/core/color/oklab/gamut_clip_preserve_chroma.js +37 -0
  455. package/src/core/color/oklab/gamut_clip_project_to_lcusp.d.ts +23 -0
  456. package/src/core/color/oklab/gamut_clip_project_to_lcusp.d.ts.map +1 -0
  457. package/src/core/color/oklab/gamut_clip_project_to_lcusp.js +46 -0
  458. package/src/core/color/oklab/linear_srgb_to_okhsl.d.ts +19 -0
  459. package/src/core/color/oklab/linear_srgb_to_okhsl.d.ts.map +1 -0
  460. package/src/core/color/oklab/linear_srgb_to_okhsl.js +93 -0
  461. package/src/core/color/oklab/linear_srgb_to_okhsv.d.ts +12 -4
  462. package/src/core/color/oklab/linear_srgb_to_okhsv.d.ts.map +1 -1
  463. package/src/core/color/oklab/linear_srgb_to_okhsv.js +108 -84
  464. package/src/core/color/oklab/linear_srgb_to_oklab.d.ts +13 -4
  465. package/src/core/color/oklab/linear_srgb_to_oklab.d.ts.map +1 -1
  466. package/src/core/color/oklab/linear_srgb_to_oklab.js +28 -19
  467. package/src/core/color/oklab/okhsl_chroma_bounds.d.ts +51 -0
  468. package/src/core/color/oklab/okhsl_chroma_bounds.d.ts.map +1 -0
  469. package/src/core/color/oklab/okhsl_chroma_bounds.js +128 -0
  470. package/src/core/color/oklab/okhsl_to_linear_srgb.d.ts +19 -0
  471. package/src/core/color/oklab/okhsl_to_linear_srgb.d.ts.map +1 -0
  472. package/src/core/color/oklab/okhsl_to_linear_srgb.js +85 -0
  473. package/src/core/color/oklab/oklab_to_oklch.d.ts +24 -0
  474. package/src/core/color/oklab/oklab_to_oklch.d.ts.map +1 -0
  475. package/src/core/color/oklab/oklab_to_oklch.js +35 -0
  476. package/src/core/color/oklab/oklch_to_oklab.d.ts +18 -0
  477. package/src/core/color/oklab/oklch_to_oklab.d.ts.map +1 -0
  478. package/src/core/color/oklab/oklch_to_oklab.js +26 -0
  479. package/src/core/color/oklab/toe.d.ts +12 -0
  480. package/src/core/color/oklab/toe.d.ts.map +1 -1
  481. package/src/core/color/oklab/toe.js +34 -22
  482. package/src/core/color/operations/color_add.d.ts +21 -0
  483. package/src/core/color/operations/color_add.d.ts.map +1 -0
  484. package/src/core/color/operations/color_add.js +23 -0
  485. package/src/core/color/operations/color_add_scaled.d.ts +20 -0
  486. package/src/core/color/operations/color_add_scaled.d.ts.map +1 -0
  487. package/src/core/color/operations/color_add_scaled.js +30 -0
  488. package/src/core/color/operations/color_clamp.d.ts +22 -0
  489. package/src/core/color/operations/color_clamp.d.ts.map +1 -0
  490. package/src/core/color/operations/color_clamp.js +25 -0
  491. package/src/core/color/operations/color_darken.d.ts +2 -1
  492. package/src/core/color/operations/color_darken.d.ts.map +1 -1
  493. package/src/core/color/operations/color_darken.js +25 -24
  494. package/src/core/color/operations/color_desaturate.d.ts +2 -1
  495. package/src/core/color/operations/color_desaturate.d.ts.map +1 -1
  496. package/src/core/color/operations/color_desaturate.js +25 -24
  497. package/src/core/color/operations/color_get_hsl.d.ts +18 -0
  498. package/src/core/color/operations/color_get_hsl.d.ts.map +1 -0
  499. package/src/core/color/operations/color_get_hsl.js +60 -0
  500. package/src/core/color/operations/color_is_in_gamut.d.ts +20 -0
  501. package/src/core/color/operations/color_is_in_gamut.d.ts.map +1 -0
  502. package/src/core/color/operations/color_is_in_gamut.js +30 -0
  503. package/src/core/color/operations/color_lerp.d.ts +12 -3
  504. package/src/core/color/operations/color_lerp.d.ts.map +1 -1
  505. package/src/core/color/operations/color_lerp.js +55 -46
  506. package/src/core/color/operations/color_lighten.d.ts +9 -5
  507. package/src/core/color/operations/color_lighten.d.ts.map +1 -1
  508. package/src/core/color/operations/color_lighten.js +29 -24
  509. package/src/core/color/operations/color_mix_okhsv_channel.d.ts +24 -0
  510. package/src/core/color/operations/color_mix_okhsv_channel.d.ts.map +1 -0
  511. package/src/core/color/operations/color_mix_okhsv_channel.js +48 -0
  512. package/src/core/color/operations/color_multiply_rgb.d.ts +21 -0
  513. package/src/core/color/operations/color_multiply_rgb.d.ts.map +1 -0
  514. package/src/core/color/operations/color_multiply_rgb.js +26 -0
  515. package/src/core/color/operations/color_saturate.d.ts +9 -5
  516. package/src/core/color/operations/color_saturate.d.ts.map +1 -1
  517. package/src/core/color/operations/color_saturate.js +29 -24
  518. package/src/core/color/operations/color_scale_okhsv_channel.d.ts +1 -1
  519. package/src/core/color/operations/color_scale_okhsv_channel.d.ts.map +1 -1
  520. package/src/core/color/operations/color_scale_okhsv_channel.js +58 -45
  521. package/src/core/color/operations/color_srgb_apply.d.ts +28 -0
  522. package/src/core/color/operations/color_srgb_apply.d.ts.map +1 -0
  523. package/src/core/color/operations/color_srgb_apply.js +40 -0
  524. package/src/core/color/operations/color_sub.d.ts +16 -0
  525. package/src/core/color/operations/color_sub.d.ts.map +1 -0
  526. package/src/core/color/operations/color_sub.js +18 -0
  527. package/src/core/color/parse_color.d.ts +10 -1
  528. package/src/core/color/parse_color.d.ts.map +1 -1
  529. package/src/core/color/parse_color.js +100 -84
  530. package/src/core/color/parse_color_normalized.d.ts +24 -0
  531. package/src/core/color/parse_color_normalized.d.ts.map +1 -0
  532. package/src/core/color/parse_color_normalized.js +38 -0
  533. package/src/core/color/rgb2uint24.d.ts +1 -8
  534. package/src/core/color/rgb2uint24.d.ts.map +1 -1
  535. package/src/core/color/rgb2uint24.js +7 -20
  536. package/src/core/color/rgb2uint32.d.ts +1 -9
  537. package/src/core/color/rgb2uint32.d.ts.map +1 -1
  538. package/src/core/color/rgb2uint32.js +7 -18
  539. package/src/core/color/rgb_to_luminance.d.ts +14 -5
  540. package/src/core/color/rgb_to_luminance.d.ts.map +1 -1
  541. package/src/core/color/rgb_to_luminance.js +24 -13
  542. package/src/core/color/rgb_to_uint24.d.ts +9 -0
  543. package/src/core/color/rgb_to_uint24.d.ts.map +1 -0
  544. package/src/core/color/rgb_to_uint24.js +20 -0
  545. package/src/core/color/rgb_to_uint32.d.ts +10 -0
  546. package/src/core/color/rgb_to_uint32.d.ts.map +1 -0
  547. package/src/core/color/rgb_to_uint32.js +21 -0
  548. package/src/core/color/sRGB/linear_to_sRGB.d.ts +7 -0
  549. package/src/core/color/sRGB/linear_to_sRGB.d.ts.map +1 -1
  550. package/src/core/color/sRGB/linear_to_sRGB.js +39 -32
  551. package/src/core/color/xyz/hpe_to_xyz.d.ts +24 -0
  552. package/src/core/color/xyz/hpe_to_xyz.d.ts.map +1 -0
  553. package/src/core/color/xyz/hpe_to_xyz.js +39 -0
  554. package/src/core/color/xyz/rgb_to_xyz.d.ts +17 -2
  555. package/src/core/color/xyz/rgb_to_xyz.d.ts.map +1 -1
  556. package/src/core/color/xyz/rgb_to_xyz.js +44 -18
  557. package/src/core/color/xyz/xyz_cmf_tabulated.d.ts.map +1 -1
  558. package/src/core/color/xyz/xyz_cmf_tabulated.js +217 -211
  559. package/src/core/color/xyz/xyz_cmf_wyman.d.ts +4 -0
  560. package/src/core/color/xyz/xyz_cmf_wyman.d.ts.map +1 -1
  561. package/src/core/color/xyz/xyz_cmf_wyman.js +74 -65
  562. package/src/core/color/xyz/xyz_to_hpe.d.ts +18 -0
  563. package/src/core/color/xyz/xyz_to_hpe.d.ts.map +1 -0
  564. package/src/core/color/xyz/xyz_to_hpe.js +33 -0
  565. package/src/core/color/xyz/xyz_to_rgb.d.ts +17 -2
  566. package/src/core/color/xyz/xyz_to_rgb.d.ts.map +1 -1
  567. package/src/core/color/xyz/xyz_to_rgb.js +39 -16
  568. package/src/core/color/ycxcz/xyz_to_ycxcz.d.ts +7 -2
  569. package/src/core/color/ycxcz/xyz_to_ycxcz.d.ts.map +1 -1
  570. package/src/core/color/ycxcz/xyz_to_ycxcz.js +33 -28
  571. package/src/core/events/signal/Signal.js +820 -820
  572. package/src/core/math/clamp_index.d.ts +18 -0
  573. package/src/core/math/clamp_index.d.ts.map +1 -0
  574. package/src/core/math/clamp_index.js +23 -0
  575. package/src/engine/asset/loaders/image/IMAGE_CODEC_REVIEW_2026_08_28.md +803 -0
  576. package/src/engine/asset/loaders/image/jpeg/JpegFrame.d.ts +5 -3
  577. package/src/engine/asset/loaders/image/jpeg/JpegFrame.d.ts.map +1 -1
  578. package/src/engine/asset/loaders/image/jpeg/JpegFrame.js +5 -3
  579. package/src/engine/asset/loaders/image/jpeg/JpegFrameComponent.d.ts +2 -1
  580. package/src/engine/asset/loaders/image/jpeg/JpegFrameComponent.d.ts.map +1 -1
  581. package/src/engine/asset/loaders/image/jpeg/JpegFrameComponent.js +2 -1
  582. package/src/engine/asset/loaders/image/jpeg/JpegImage.d.ts +17 -0
  583. package/src/engine/asset/loaders/image/jpeg/JpegImage.d.ts.map +1 -1
  584. package/src/engine/asset/loaders/image/jpeg/JpegImage.js +197 -157
  585. package/src/engine/asset/loaders/image/jpeg/idct8x8_float.d.ts +0 -1
  586. package/src/engine/asset/loaders/image/jpeg/idct8x8_float.d.ts.map +1 -1
  587. package/src/engine/asset/loaders/image/jpeg/idct8x8_float.js +0 -1
  588. package/src/engine/asset/loaders/image/jpeg/jpeg_component_row.d.ts +28 -0
  589. package/src/engine/asset/loaders/image/jpeg/jpeg_component_row.d.ts.map +1 -0
  590. package/src/engine/asset/loaders/image/jpeg/jpeg_component_row.js +31 -0
  591. package/src/engine/asset/loaders/image/png/PNG.d.ts +3 -18
  592. package/src/engine/asset/loaders/image/png/PNG.d.ts.map +1 -1
  593. package/src/engine/asset/loaders/image/png/PNG.js +3 -139
  594. package/src/engine/asset/loaders/image/png/PNGReader.d.ts +16 -16
  595. package/src/engine/asset/loaders/image/png/PNGReader.d.ts.map +1 -1
  596. package/src/engine/asset/loaders/image/png/PNGReader.js +143 -160
  597. package/src/engine/asset/loaders/image/png/chunk/png_chunk_decode_iTXt.js +3 -3
  598. package/src/engine/asset/loaders/image/png/chunk/png_chunk_decode_zTXt.js +3 -3
  599. package/src/engine/asset/loaders/image/png/crc32.d.ts +1 -15
  600. package/src/engine/asset/loaders/image/png/crc32.d.ts.map +1 -1
  601. package/src/engine/asset/loaders/image/png/crc32.js +5 -89
  602. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.d.ts +12 -10
  603. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.d.ts.map +1 -1
  604. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterNone.js +20 -45
  605. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterSub.d.ts +2 -1
  606. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterSub.d.ts.map +1 -1
  607. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterSub.js +2 -0
  608. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterUp.d.ts +2 -1
  609. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterUp.d.ts.map +1 -1
  610. package/src/engine/asset/loaders/image/png/filter/png_filter_unFilterUp.js +2 -0
  611. package/src/engine/asset/loaders/image/png/filter/png_unfilter.d.ts +22 -0
  612. package/src/engine/asset/loaders/image/png/filter/png_unfilter.d.ts.map +1 -0
  613. package/src/engine/asset/loaders/image/png/filter/png_unfilter.js +68 -0
  614. package/src/engine/asset/loaders/image/png/png_inflate.d.ts +20 -0
  615. package/src/engine/asset/loaders/image/png/png_inflate.d.ts.map +1 -0
  616. package/src/engine/asset/loaders/image/png/png_inflate.js +85 -0
  617. package/src/engine/asset/loaders/image/png/png_unpack_samples.d.ts +22 -0
  618. package/src/engine/asset/loaders/image/png/png_unpack_samples.d.ts.map +1 -0
  619. package/src/engine/asset/loaders/image/png/png_unpack_samples.js +38 -0
  620. package/src/engine/graphics/ecs/sprite/SpriteSystemPE.d.ts.map +1 -1
  621. package/src/engine/graphics/ecs/sprite/SpriteSystemPE.js +135 -132
  622. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.d.ts +16 -3
  623. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.d.ts.map +1 -1
  624. package/src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +1157 -1149
  625. package/src/engine/graphics/render/frame_graph/FrameGraph.js +900 -900
  626. package/src/engine/physics/ecs/PhysicsSystem.d.ts +72 -81
  627. package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
  628. package/src/engine/physics/ecs/PhysicsSystem.js +86 -77
  629. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  630. package/src/shade/device/IMMEDIATE_DATA_PLAN_2026_08_28.md +451 -0
  631. package/src/shade/device/timing/GPU_PROFILER_PROPOSAL_2026_08_28.md +625 -0
  632. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  633. package/src/shade/renderer/scene/serialization/decode_image_source_hdr.d.ts +14 -3
  634. package/src/shade/renderer/scene/serialization/decode_image_source_hdr.d.ts.map +1 -1
  635. package/src/shade/renderer/scene/serialization/decode_image_source_hdr.js +50 -51
  636. package/src/shade/renderer/scene/serialization/deserialize_scene.d.ts.map +1 -1
  637. package/src/shade/renderer/scene/serialization/deserialize_scene.js +531 -521
  638. package/src/shade/renderer/scene/serialization/write_image_source.d.ts.map +1 -1
  639. package/src/shade/renderer/scene/serialization/write_image_source.js +6 -4
  640. package/src/shade/renderer/shader/chunk/color/chunk_rgb_to_luminance.d.ts.map +1 -1
  641. package/src/shade/renderer/shader/chunk/color/chunk_rgb_to_luminance.js +34 -32
  642. package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_eotf_st2084.d.ts +31 -0
  643. package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_eotf_st2084.d.ts.map +1 -1
  644. package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_eotf_st2084.js +62 -31
  645. package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_inverse_eotf_st2084.d.ts +10 -0
  646. package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_inverse_eotf_st2084.d.ts.map +1 -1
  647. package/src/shade/renderer/shader/chunk/color/iCtCp/chunk_inverse_eotf_st2084.js +32 -22
  648. package/src/shade/renderer/shader/chunk/color/sRGB/chunk_sRGBTransferOETF.d.ts.map +1 -1
  649. package/src/shade/renderer/shader/chunk/color/sRGB/chunk_sRGBTransferOETF.js +22 -21
  650. package/src/shade/renderer/shader/chunk/color/tonemap/gt7/chunk_tonemap_gt7.d.ts +6 -0
  651. package/src/shade/renderer/shader/chunk/color/tonemap/gt7/chunk_tonemap_gt7.d.ts.map +1 -1
  652. package/src/shade/renderer/shader/chunk/color/tonemap/gt7/chunk_tonemap_gt7.js +110 -104
  653. package/src/shade/renderer/shader/chunk/color/xyz/chunk_rgb_to_xyz.d.ts.map +1 -1
  654. package/src/shade/renderer/shader/chunk/color/xyz/chunk_rgb_to_xyz.js +23 -21
  655. package/src/view/elements/ColorPickerView.js +296 -296
  656. package/src/avif/codec/dec/Readme.md +0 -14
  657. package/src/avif/codec/dec/avif_dec.cpp +0 -234
  658. package/src/avif/codec/dec/avif_dec.d.ts +0 -3
  659. package/src/avif/codec/dec/avif_dec.d.ts.map +0 -1
  660. package/src/avif/codec/dec/avif_dec.js +0 -16
  661. package/src/avif/codec/dec/avif_dec.wasm +0 -0
  662. package/src/avif/codec/enc/README.md +0 -37
  663. package/src/avif/codec/enc/avif_enc.cpp +0 -216
  664. package/src/avif/codec/enc/avif_enc.d.ts +0 -3
  665. package/src/avif/codec/enc/avif_enc.d.ts.map +0 -1
  666. package/src/avif/codec/enc/avif_enc.js +0 -6144
  667. package/src/avif/codec/enc/avif_enc.wasm +0 -0
  668. package/src/avif/codec/enc/avif_enc_mt.d.ts +0 -3
  669. package/src/avif/codec/enc/avif_enc_mt.d.ts.map +0 -1
  670. package/src/avif/codec/enc/avif_enc_mt.js +0 -6811
  671. package/src/avif/codec/enc/avif_enc_mt.wasm +0 -0
  672. package/src/avif/codec/enc/avif_enc_mt.worker.d.mts +0 -2
  673. package/src/avif/codec/enc/avif_enc_mt.worker.d.mts.map +0 -1
  674. package/src/avif/codec/enc/avif_enc_mt.worker.d.ts +0 -11
  675. package/src/avif/codec/enc/avif_enc_mt.worker.d.ts.map +0 -1
  676. package/src/avif/codec/enc/avif_enc_mt.worker.js +0 -171
  677. package/src/avif/codec/enc/avif_enc_mt.worker.mjs +0 -1
  678. package/src/avif/decode.d.ts +0 -3
  679. package/src/avif/decode.d.ts.map +0 -1
  680. package/src/avif/decode.js +0 -42
  681. package/src/avif/encode.d.ts +0 -3
  682. package/src/avif/encode.d.ts.map +0 -1
  683. package/src/avif/encode.js +0 -75
  684. package/src/avif/meta.d.ts +0 -24
  685. package/src/avif/meta.d.ts.map +0 -1
  686. package/src/avif/meta.js +0 -23
  687. package/src/avif/tsconfig.tsbuildinfo +0 -1
  688. package/src/avif/utils.d.ts +0 -17
  689. package/src/avif/utils.d.ts.map +0 -1
  690. package/src/avif/utils.js +0 -31
  691. package/src/engine/asset/loaders/image/jpeg/idct8x8_fixed.d.ts +0 -23
  692. package/src/engine/asset/loaders/image/jpeg/idct8x8_fixed.d.ts.map +0 -1
  693. package/src/engine/asset/loaders/image/jpeg/idct8x8_fixed.js +0 -214
  694. package/src/engine/asset/loaders/image/png/inflate.d.ts +0 -7
  695. package/src/engine/asset/loaders/image/png/inflate.d.ts.map +0 -1
  696. package/src/engine/asset/loaders/image/png/inflate.js +0 -20
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Quantise one transform block's coefficients.
3
+ *
4
+ * The step is exactly the one `reconstruct` will divide back out, taken from the same tables, so
5
+ * that the only error is the rounding this chooses to make.
6
+ *
7
+ * At quantizer index zero the step is four rather than one — the lossless transform is scaled to
8
+ * match, and the division here is exact — so the lossless path needs no special case.
9
+ *
10
+ * That rounding is deliberately biased towards zero. A coefficient that quantises to zero costs
11
+ * almost nothing to code, and one that quantises to one costs a symbol and a sign; giving up the
12
+ * last fraction of a step buys a great many bits back on the kind of content still images are made
13
+ * of.
14
+ *
15
+ * The pass runs in scan order and carries two answers out with it that the caller would otherwise
16
+ * pay for separately: the end-of-block position, which the coefficient writer used to find by
17
+ * walking a thousand positions backwards, and the squared error the quantiser cost in the
18
+ * coefficient domain, which is what saves the rate-distortion search an inverse transform per
19
+ * candidate. Both are free here and neither is anywhere else.
20
+ *
21
+ * @param {Av1EncodeContext} ec
22
+ * @param {number} plane
23
+ * @param {number} tx_size
24
+ * @param {number} tx_type
25
+ * @param {Int32Array} coefficients
26
+ * @param {Int32Array} levels filled with the signed quantised levels
27
+ * @param {number} levels_offset where in `levels` this transform block's start, so that a block's
28
+ * transform blocks can share one buffer
29
+ * @param {Uint16Array} scan the order the coefficients will be coded in
30
+ * @returns {number} the end-of-block position: one past the last coefficient in scan order that
31
+ * survived, and zero for a block that did not
32
+ * @see AV1 spec 7.12.2 "Dequantization functions", which this is the inverse of
33
+ *
34
+ * @author Alex Goldring
35
+ * @copyright Company Named Limited (c) 2026
36
+ */
37
+ export function quantise_transform_block(ec: Av1EncodeContext, plane: number, tx_size: number, tx_type: number, coefficients: Int32Array, levels: Int32Array, levels_offset: number, scan: Uint16Array): number;
38
+ /**
39
+ * The coefficient magnitude below which the quantiser produces nothing at all.
40
+ *
41
+ * A coefficient quantises to zero when `|c| * denominator / step + rounding` stays under one, and
42
+ * the DC step is the smaller of the two, so a magnitude under this survives at no position. A block
43
+ * whose largest possible coefficient is under it is a block the transform need not be run on.
44
+ *
45
+ * @param {Av1EncodeContext} ec
46
+ * @param {number} plane
47
+ * @param {number} tx_size
48
+ * @returns {number}
49
+ */
50
+ export function quantiser_zero_threshold(ec: Av1EncodeContext, plane: number, tx_size: number): number;
51
+ //# sourceMappingURL=quantise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quantise.d.ts","sourceRoot":"","sources":["../../../../../../src/avif/native/av1/encode/quantise.js"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,sEAfW,MAAM,WACN,MAAM,WACN,MAAM,gBACN,UAAU,UACV,UAAU,iBACV,MAAM,QAEN,WAAW,GACT,MAAM,CA2FlB;AAED;;;;;;;;;;;GAWG;AACH,sEAJW,MAAM,WACN,MAAM,GACJ,MAAM,CAclB"}
@@ -0,0 +1,212 @@
1
+ import {
2
+ TX_16X32,
3
+ TX_16X64,
4
+ TX_32X16,
5
+ TX_32X32,
6
+ TX_32X64,
7
+ TX_64X16,
8
+ TX_64X32,
9
+ TX_64X64
10
+ } from "../tables/av1_symbols.js";
11
+ import { TX_HEIGHT, TX_WIDTH } from "../tables/block_tables.js";
12
+ import { ac_quant, dc_quant, get_qindex } from "../decode/reconstruct.js";
13
+
14
+ /**
15
+ * Largest level the format can carry. The decoder masks a coefficient to twenty bits before
16
+ * dequantising, so anything past this would come back as something else entirely.
17
+ * @type {number}
18
+ */
19
+ const MAX_LEVEL = 0xfffff;
20
+
21
+ /**
22
+ * Quantise one transform block's coefficients.
23
+ *
24
+ * The step is exactly the one `reconstruct` will divide back out, taken from the same tables, so
25
+ * that the only error is the rounding this chooses to make.
26
+ *
27
+ * At quantizer index zero the step is four rather than one — the lossless transform is scaled to
28
+ * match, and the division here is exact — so the lossless path needs no special case.
29
+ *
30
+ * That rounding is deliberately biased towards zero. A coefficient that quantises to zero costs
31
+ * almost nothing to code, and one that quantises to one costs a symbol and a sign; giving up the
32
+ * last fraction of a step buys a great many bits back on the kind of content still images are made
33
+ * of.
34
+ *
35
+ * The pass runs in scan order and carries two answers out with it that the caller would otherwise
36
+ * pay for separately: the end-of-block position, which the coefficient writer used to find by
37
+ * walking a thousand positions backwards, and the squared error the quantiser cost in the
38
+ * coefficient domain, which is what saves the rate-distortion search an inverse transform per
39
+ * candidate. Both are free here and neither is anywhere else.
40
+ *
41
+ * @param {Av1EncodeContext} ec
42
+ * @param {number} plane
43
+ * @param {number} tx_size
44
+ * @param {number} tx_type
45
+ * @param {Int32Array} coefficients
46
+ * @param {Int32Array} levels filled with the signed quantised levels
47
+ * @param {number} levels_offset where in `levels` this transform block's start, so that a block's
48
+ * transform blocks can share one buffer
49
+ * @param {Uint16Array} scan the order the coefficients will be coded in
50
+ * @returns {number} the end-of-block position: one past the last coefficient in scan order that
51
+ * survived, and zero for a block that did not
52
+ * @see AV1 spec 7.12.2 "Dequantization functions", which this is the inverse of
53
+ *
54
+ * @author Alex Goldring
55
+ * @copyright Company Named Limited (c) 2026
56
+ */
57
+ export function quantise_transform_block(ec, plane, tx_size, tx_type, coefficients, levels, levels_offset, scan) {
58
+ const ctx = ec.frame_context;
59
+ const frame = ec.frame;
60
+
61
+ const width = TX_WIDTH[tx_size];
62
+ const height = TX_HEIGHT[tx_size];
63
+
64
+ const tw = Math.min(32, width);
65
+ const th = Math.min(32, height);
66
+
67
+ // the scan's positions are raster indices into the coded corner, whose stride is `tw`; the
68
+ // coefficients the transform produced are strided by the transform's full width. This encoder
69
+ // emits nothing wider than the corner, so the two agree — and if that ever changes, the scan
70
+ // would be indexing the wrong samples silently
71
+ if (tw !== width) {
72
+ throw new Error(`a transform ${width} wide codes only its first ${tw} columns, which this does not handle`);
73
+ }
74
+
75
+ const denominator = dequant_denominator(tx_size);
76
+
77
+ const qindex = get_qindex(ctx);
78
+
79
+ const dc_step = dc_quant(ctx.bit_depth, qindex + dc_delta(frame, plane));
80
+ const ac_step = ac_quant(ctx.bit_depth, qindex + ac_delta(frame, plane));
81
+
82
+ const rounding = ec.rounding;
83
+
84
+ // what the decoder will multiply these levels back up by, left where whatever wants to reason
85
+ // about a level's worth can find it without deriving it a second time
86
+ ec.step_dc = dc_step;
87
+ ec.step_ac = ac_step;
88
+ ec.step_denominator = denominator;
89
+
90
+ // a reciprocal, because this is the innermost loop of the encoder and a division here is worth
91
+ // twenty multiplications. The step is an integer under two thousand and the magnitude an
92
+ // integer under a million, so the product is exact well past the point the rounding decides
93
+ const dc_scale = denominator / dc_step;
94
+ const ac_scale = denominator / ac_step;
95
+
96
+ // one, a half or a quarter, all of them exact in floating point, so this is the dequantiser's
97
+ // division without the division
98
+ const inverse_denominator = 1 / denominator;
99
+
100
+ const count = tw * th;
101
+
102
+ // in scan order rather than in raster order, so that the end-of-block position — which the
103
+ // coefficient writer would otherwise find by walking a thousand positions backwards looking for
104
+ // one that is not zero — falls out of the same pass
105
+ let eob = 0;
106
+ let error = 0;
107
+
108
+ for (let c = 0; c < count; c++) {
109
+ const pos = scan[c];
110
+
111
+ const coefficient = coefficients[pos];
112
+
113
+ const magnitude = coefficient < 0 ? -coefficient : coefficient;
114
+
115
+ const scale = pos === 0 ? dc_scale : ac_scale;
116
+
117
+ let level = (magnitude * scale + rounding) | 0;
118
+
119
+ if (level > MAX_LEVEL) {
120
+ level = MAX_LEVEL;
121
+ }
122
+
123
+ levels[levels_offset + pos] = coefficient < 0 ? -level : level;
124
+
125
+ if (level !== 0) {
126
+ eob = c + 1;
127
+ }
128
+
129
+ // what the decoder will reconstruct, and therefore what this cost in accuracy. Squared
130
+ // error in the coefficient domain, which the caller scales into samples
131
+ const step = pos === 0 ? dc_step : ac_step;
132
+
133
+ const difference = magnitude - ((level * step * inverse_denominator) | 0);
134
+
135
+ error += difference * difference;
136
+ }
137
+
138
+ ec.quantised_error = error;
139
+
140
+ return eob;
141
+ }
142
+
143
+ /**
144
+ * The coefficient magnitude below which the quantiser produces nothing at all.
145
+ *
146
+ * A coefficient quantises to zero when `|c| * denominator / step + rounding` stays under one, and
147
+ * the DC step is the smaller of the two, so a magnitude under this survives at no position. A block
148
+ * whose largest possible coefficient is under it is a block the transform need not be run on.
149
+ *
150
+ * @param {Av1EncodeContext} ec
151
+ * @param {number} plane
152
+ * @param {number} tx_size
153
+ * @returns {number}
154
+ */
155
+ export function quantiser_zero_threshold(ec, plane, tx_size) {
156
+ const ctx = ec.frame_context;
157
+ const frame = ec.frame;
158
+
159
+ const qindex = get_qindex(ctx);
160
+
161
+ const dc_step = dc_quant(ctx.bit_depth, qindex + dc_delta(frame, plane));
162
+ const ac_step = ac_quant(ctx.bit_depth, qindex + ac_delta(frame, plane));
163
+
164
+ const step = dc_step < ac_step ? dc_step : ac_step;
165
+
166
+ return ((1 - ec.rounding) * step) / dequant_denominator(tx_size);
167
+ }
168
+
169
+ /**
170
+ * The divisor the dequantiser applies after multiplying by the step, which is how large transforms
171
+ * keep their coefficients in range.
172
+ *
173
+ * @param {number} tx_size
174
+ * @returns {number}
175
+ */
176
+ function dequant_denominator(tx_size) {
177
+ if (tx_size === TX_32X32 || tx_size === TX_16X32 || tx_size === TX_32X16 || tx_size === TX_16X64 || tx_size === TX_64X16) {
178
+ return 2;
179
+ }
180
+
181
+ if (tx_size === TX_64X64 || tx_size === TX_32X64 || tx_size === TX_64X32) {
182
+ return 4;
183
+ }
184
+
185
+ return 1;
186
+ }
187
+
188
+ /**
189
+ * @param {FrameHeader} frame
190
+ * @param {number} plane
191
+ * @returns {number}
192
+ */
193
+ function dc_delta(frame, plane) {
194
+ if (plane === 0) {
195
+ return frame.delta_q_y_dc;
196
+ }
197
+
198
+ return plane === 1 ? frame.delta_q_u_dc : frame.delta_q_v_dc;
199
+ }
200
+
201
+ /**
202
+ * @param {FrameHeader} frame
203
+ * @param {number} plane
204
+ * @returns {number}
205
+ */
206
+ function ac_delta(frame, plane) {
207
+ if (plane === 0) {
208
+ return 0;
209
+ }
210
+
211
+ return plane === 1 ? frame.delta_q_u_ac : frame.delta_q_v_ac;
212
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Write the coefficients of one transform block.
3
+ *
4
+ * The mirror of `decode_coefficients`, and deliberately written to look like it: every context here
5
+ * has to be derived from exactly the state the decoder will have when it reads the symbol back, so
6
+ * the two read as the same sequence of decisions with the arrows reversed.
7
+ *
8
+ * `levels` holds the signed quantised coefficients by raster position. On return `ctx.quant` holds
9
+ * what the decoder would have, so `reconstruct` can be called on it directly — which is what keeps
10
+ * the encoder's picture and the decoder's identical rather than merely close.
11
+ *
12
+ * ### Costing a block without coding it
13
+ *
14
+ * Passing a writer in its costing mode, and `record` of zero, runs the whole syntax against
15
+ * something that adds up what each symbol would cost and writes nothing, leaving the block's
16
+ * entropy contexts and recorded transform types untouched. That is how the encoder prices a decision: the rate it weighs
17
+ * is the rate of exactly these symbols through exactly these contexts, because it *is* this
18
+ * function. `ctx.quant` is filled either way, so a trial can still be reconstructed and measured.
19
+ *
20
+ * @param {Av1FrameContext} ctx
21
+ * @param {SymbolWriter} writer where the symbols go, or what prices them
22
+ * @param {number} record `1` to update the entropy contexts and transform types this block leaves
23
+ * behind, `0` for a trial that must leave no trace
24
+ * @param {number} plane
25
+ * @param {number} start_x left edge of the transform block in plane samples
26
+ * @param {number} start_y
27
+ * @param {number} tx_size
28
+ * @param {number} tx_type the type the coefficients were produced with
29
+ * @param {Int32Array} levels
30
+ * @param {number} levels_offset where in `levels` this transform block starts
31
+ * @param {number} eob one past the last coefficient in scan order that survived the quantiser, as
32
+ * `quantise_transform_block` returned it. Passing it rather than looking for it is worth having:
33
+ * finding it here means walking the scan backwards from its end, which for a 32x32 block is a
34
+ * thousand positions to reach an answer that is usually under a hundred
35
+ * @returns {number} the same end-of-block position
36
+ * @see AV1 spec 5.11.39 "Coefficients syntax"
37
+ *
38
+ * @author Alex Goldring
39
+ * @copyright Company Named Limited (c) 2026
40
+ */
41
+ export function write_coefficients(ctx: Av1FrameContext, writer: SymbolWriter, record: number, plane: number, start_x: number, start_y: number, tx_size: number, tx_type: number, levels: Int32Array, levels_offset: number, eob: number): number;
42
+ //# sourceMappingURL=write_coefficients.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write_coefficients.d.ts","sourceRoot":"","sources":["../../../../../../src/avif/native/av1/encode/write_coefficients.js"],"names":[],"mappings":"AA+BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,uFAnBW,MAAM,SAEN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,UACN,UAAU,iBACV,MAAM,OACN,MAAM,GAIJ,MAAM,CAoKlB"}
@@ -0,0 +1,367 @@
1
+ import {
2
+ BR_CDF_SIZE,
3
+ COEFF_BASE_RANGE,
4
+ DCT_DCT,
5
+ NUM_BASE_LEVELS,
6
+ SIG_COEF_CONTEXTS,
7
+ SIG_COEF_CONTEXTS_EOB,
8
+ TX_16X64,
9
+ TX_32X32,
10
+ TX_64X16,
11
+ TX_CLASS_2D
12
+ } from "../tables/av1_symbols.js";
13
+ import {
14
+ ADJUSTED_TX_SIZE,
15
+ TX_HEIGHT,
16
+ TX_HEIGHT_LOG2,
17
+ TX_SIZE_SQR,
18
+ TX_SIZE_SQR_UP,
19
+ TX_WIDTH,
20
+ TX_WIDTH_LOG2
21
+ } from "../tables/block_tables.js";
22
+ import {
23
+ get_all_zero_ctx,
24
+ get_coeff_base_ctx,
25
+ get_coeff_br_ctx,
26
+ get_dc_sign_ctx
27
+ } from "../entropy/coefficient_context.js";
28
+ import { get_scan } from "../decode/get_scan.js";
29
+ import { get_tx_class } from "../decode/transform_type.js";
30
+ import { write_transform_type } from "./write_transform_type.js";
31
+
32
+ /**
33
+ * Write the coefficients of one transform block.
34
+ *
35
+ * The mirror of `decode_coefficients`, and deliberately written to look like it: every context here
36
+ * has to be derived from exactly the state the decoder will have when it reads the symbol back, so
37
+ * the two read as the same sequence of decisions with the arrows reversed.
38
+ *
39
+ * `levels` holds the signed quantised coefficients by raster position. On return `ctx.quant` holds
40
+ * what the decoder would have, so `reconstruct` can be called on it directly — which is what keeps
41
+ * the encoder's picture and the decoder's identical rather than merely close.
42
+ *
43
+ * ### Costing a block without coding it
44
+ *
45
+ * Passing a writer in its costing mode, and `record` of zero, runs the whole syntax against
46
+ * something that adds up what each symbol would cost and writes nothing, leaving the block's
47
+ * entropy contexts and recorded transform types untouched. That is how the encoder prices a decision: the rate it weighs
48
+ * is the rate of exactly these symbols through exactly these contexts, because it *is* this
49
+ * function. `ctx.quant` is filled either way, so a trial can still be reconstructed and measured.
50
+ *
51
+ * @param {Av1FrameContext} ctx
52
+ * @param {SymbolWriter} writer where the symbols go, or what prices them
53
+ * @param {number} record `1` to update the entropy contexts and transform types this block leaves
54
+ * behind, `0` for a trial that must leave no trace
55
+ * @param {number} plane
56
+ * @param {number} start_x left edge of the transform block in plane samples
57
+ * @param {number} start_y
58
+ * @param {number} tx_size
59
+ * @param {number} tx_type the type the coefficients were produced with
60
+ * @param {Int32Array} levels
61
+ * @param {number} levels_offset where in `levels` this transform block starts
62
+ * @param {number} eob one past the last coefficient in scan order that survived the quantiser, as
63
+ * `quantise_transform_block` returned it. Passing it rather than looking for it is worth having:
64
+ * finding it here means walking the scan backwards from its end, which for a 32x32 block is a
65
+ * thousand positions to reach an answer that is usually under a hundred
66
+ * @returns {number} the same end-of-block position
67
+ * @see AV1 spec 5.11.39 "Coefficients syntax"
68
+ *
69
+ * @author Alex Goldring
70
+ * @copyright Company Named Limited (c) 2026
71
+ */
72
+ export function write_coefficients(ctx, writer, record, plane, start_x, start_y, tx_size, tx_type, levels, levels_offset, eob) {
73
+ const cdf = ctx.cdf;
74
+
75
+ const x4 = start_x >> 2;
76
+ const y4 = start_y >> 2;
77
+ const w4 = TX_WIDTH[tx_size] >> 2;
78
+ const h4 = TX_HEIGHT[tx_size] >> 2;
79
+
80
+ const tx_size_ctx = (TX_SIZE_SQR[tx_size] + TX_SIZE_SQR_UP[tx_size] + 1) >> 1;
81
+ const plane_type = plane > 0 ? 1 : 0;
82
+
83
+ const seg_eob = tx_size === TX_16X64 || tx_size === TX_64X16
84
+ ? 512
85
+ : Math.min(1024, TX_WIDTH[tx_size] * TX_HEIGHT[tx_size]);
86
+
87
+ const scan = get_scan(tx_size, tx_type);
88
+
89
+ const quant = ctx.quant;
90
+
91
+ quant.fill(0, 0, seg_eob);
92
+
93
+ const all_zero_ctx = get_all_zero_ctx(ctx, plane, x4, y4, w4, h4, tx_size);
94
+
95
+ writer.write_symbol(eob === 0 ? 1 : 0, cdf.txb_skip, (tx_size_ctx * 13 + all_zero_ctx) * 3, 2);
96
+
97
+ let cul_level = 0;
98
+ let dc_category = 0;
99
+
100
+ if (eob === 0) {
101
+ if (record === 1) {
102
+ if (plane === 0) {
103
+ for (let i = 0; i < w4; i++) {
104
+ for (let j = 0; j < h4; j++) {
105
+ ctx.tx_types[(y4 + j) * ctx.mi_stride + x4 + i] = DCT_DCT;
106
+ }
107
+ }
108
+ }
109
+
110
+ update_contexts(ctx, plane, x4, y4, w4, h4, 0, 0);
111
+ }
112
+
113
+ return 0;
114
+ }
115
+
116
+ // the type is coded here, after the block is known not to be empty, because that is where the
117
+ // decoder reads it
118
+ if (plane === 0) {
119
+ write_transform_type(ctx, writer, record, x4, y4, tx_size, tx_type);
120
+ }
121
+
122
+ ctx.plane_tx_type = tx_type;
123
+
124
+ const tx_class = get_tx_class(tx_type);
125
+
126
+ write_eob_position(ctx, writer, tx_size, tx_size_ctx, plane_type, tx_class, eob);
127
+
128
+ const adjusted = ADJUSTED_TX_SIZE[tx_size];
129
+ const bwl = TX_WIDTH_LOG2[adjusted];
130
+ const adjusted_width = 1 << bwl;
131
+ const adjusted_height = TX_HEIGHT[adjusted];
132
+
133
+ const br_cdf_size_ctx = Math.min(tx_size_ctx, TX_32X32);
134
+
135
+ // the magnitudes the decoder holds while it reads: capped, because anything larger is coded as
136
+ // a suffix in the second pass and the contexts below never see the true value
137
+ const cap = NUM_BASE_LEVELS + COEFF_BASE_RANGE + 1;
138
+
139
+ for (let c = eob - 1; c >= 0; c--) {
140
+ const pos = scan[c];
141
+
142
+ const magnitude = Math.abs(levels[levels_offset + pos]);
143
+ const capped = magnitude < cap ? magnitude : cap;
144
+
145
+ if (c === eob - 1) {
146
+ const eob_ctx = get_coeff_base_ctx(quant, tx_class, bwl, adjusted_width, adjusted_height, pos, c, 1, tx_size)
147
+ - SIG_COEF_CONTEXTS + SIG_COEF_CONTEXTS_EOB;
148
+
149
+ writer.write_symbol(
150
+ (capped < 3 ? capped : 3) - 1,
151
+ cdf.coeff_base_eob,
152
+ ((tx_size_ctx * 2 + plane_type) * SIG_COEF_CONTEXTS_EOB + eob_ctx) * 4,
153
+ 3
154
+ );
155
+ } else {
156
+ const base_ctx = get_coeff_base_ctx(quant, tx_class, bwl, adjusted_width, adjusted_height, pos, c, 0, tx_size);
157
+
158
+ writer.write_symbol(
159
+ capped < 3 ? capped : 3,
160
+ cdf.coeff_base,
161
+ ((tx_size_ctx * 2 + plane_type) * SIG_COEF_CONTEXTS + base_ctx) * 5,
162
+ 4
163
+ );
164
+ }
165
+
166
+ if (capped > NUM_BASE_LEVELS) {
167
+ const br_ctx = get_coeff_br_ctx(quant, tx_class, bwl, adjusted_width, adjusted_height, pos);
168
+
169
+ let remaining = capped - (NUM_BASE_LEVELS + 1);
170
+
171
+ for (let idx = 0; idx < COEFF_BASE_RANGE / (BR_CDF_SIZE - 1); idx++) {
172
+ const chunk = remaining < BR_CDF_SIZE - 1 ? remaining : BR_CDF_SIZE - 1;
173
+
174
+ writer.write_symbol(
175
+ chunk,
176
+ cdf.coeff_br,
177
+ ((br_cdf_size_ctx * 2 + plane_type) * 21 + br_ctx) * 5,
178
+ 4
179
+ );
180
+
181
+ remaining -= chunk;
182
+
183
+ if (chunk < BR_CDF_SIZE - 1) {
184
+ break;
185
+ }
186
+ }
187
+ }
188
+
189
+ quant[pos] = capped;
190
+ }
191
+
192
+ const dc_sign_ctx = get_dc_sign_ctx(ctx, plane, x4, y4, w4, h4);
193
+
194
+ for (let c = 0; c < eob; c++) {
195
+ const pos = scan[c];
196
+
197
+ const level = levels[levels_offset + pos];
198
+ const magnitude = Math.abs(level);
199
+
200
+ const sign = level < 0 ? 1 : 0;
201
+
202
+ if (magnitude !== 0) {
203
+ if (c === 0) {
204
+ writer.write_symbol(sign, cdf.dc_sign, (plane_type * 3 + dc_sign_ctx) * 3, 2);
205
+ } else {
206
+ writer.write_bool(sign);
207
+ }
208
+ }
209
+
210
+ if (quant[pos] > NUM_BASE_LEVELS + COEFF_BASE_RANGE) {
211
+ write_golomb(writer, magnitude - (NUM_BASE_LEVELS + COEFF_BASE_RANGE));
212
+ }
213
+
214
+ if (pos === 0 && magnitude > 0) {
215
+ dc_category = sign !== 0 ? 1 : 2;
216
+ }
217
+
218
+ cul_level += magnitude;
219
+
220
+ quant[pos] = level;
221
+ }
222
+
223
+ cul_level = Math.min(63, cul_level);
224
+
225
+ if (record === 1) {
226
+ update_contexts(ctx, plane, x4, y4, w4, h4, cul_level, dc_category);
227
+ }
228
+
229
+ return eob;
230
+ }
231
+
232
+ /**
233
+ * Write the end-of-block position, which is coded as a bucket and then the offset within it.
234
+ *
235
+ * @param {Av1FrameContext} ctx
236
+ * @param {SymbolWriter} writer
237
+ * @param {number} tx_size
238
+ * @param {number} tx_size_ctx
239
+ * @param {number} plane_type
240
+ * @param {number} tx_class
241
+ * @param {number} eob
242
+ */
243
+ function write_eob_position(ctx, writer, tx_size, tx_size_ctx, plane_type, tx_class, eob) {
244
+ const cdf = ctx.cdf;
245
+
246
+ // the bucket is the position of the top set bit, offset so that one and two get buckets of
247
+ // their own
248
+ let eob_pt = 1;
249
+
250
+ while (eob_pt < 11 && eob > bucket_base(eob_pt)) {
251
+ eob_pt++;
252
+ }
253
+
254
+ const eob_multisize = Math.min(TX_WIDTH_LOG2[tx_size], 5) + Math.min(TX_HEIGHT_LOG2[tx_size], 5) - 4;
255
+
256
+ const eob_class_ctx = tx_class === TX_CLASS_2D ? 0 : 1;
257
+
258
+ if (eob_multisize === 0) {
259
+ writer.write_symbol(eob_pt - 1, cdf.eob_pt_16, ((plane_type * 2) + eob_class_ctx) * 6, 5);
260
+ } else if (eob_multisize === 1) {
261
+ writer.write_symbol(eob_pt - 1, cdf.eob_pt_32, ((plane_type * 2) + eob_class_ctx) * 7, 6);
262
+ } else if (eob_multisize === 2) {
263
+ writer.write_symbol(eob_pt - 1, cdf.eob_pt_64, ((plane_type * 2) + eob_class_ctx) * 8, 7);
264
+ } else if (eob_multisize === 3) {
265
+ writer.write_symbol(eob_pt - 1, cdf.eob_pt_128, ((plane_type * 2) + eob_class_ctx) * 9, 8);
266
+ } else if (eob_multisize === 4) {
267
+ writer.write_symbol(eob_pt - 1, cdf.eob_pt_256, ((plane_type * 2) + eob_class_ctx) * 10, 9);
268
+ } else if (eob_multisize === 5) {
269
+ writer.write_symbol(eob_pt - 1, cdf.eob_pt_512, plane_type * 11, 10);
270
+ } else {
271
+ writer.write_symbol(eob_pt - 1, cdf.eob_pt_1024, plane_type * 12, 11);
272
+ }
273
+
274
+ const base = bucket_base(eob_pt - 1) + 1;
275
+
276
+ let remainder = eob - base;
277
+
278
+ let eob_shift = Math.max(-1, eob_pt - 3);
279
+
280
+ if (eob_shift < 0) {
281
+ return;
282
+ }
283
+
284
+ const extra = (remainder >> eob_shift) & 1;
285
+
286
+ writer.write_symbol(
287
+ extra,
288
+ cdf.eob_extra,
289
+ ((tx_size_ctx * 2 + plane_type) * 9 + (eob_pt - 3)) * 3,
290
+ 2
291
+ );
292
+
293
+ for (let i = 1; i < Math.max(0, eob_pt - 2); i++) {
294
+ eob_shift = Math.max(0, eob_pt - 2) - 1 - i;
295
+
296
+ writer.write_bool((remainder >> eob_shift) & 1);
297
+ }
298
+ }
299
+
300
+ /**
301
+ * The largest end-of-block position a bucket covers.
302
+ *
303
+ * @param {number} eob_pt
304
+ * @returns {number}
305
+ */
306
+ function bucket_base(eob_pt) {
307
+ if (eob_pt < 1) {
308
+ return 0;
309
+ }
310
+
311
+ if (eob_pt < 2) {
312
+ return eob_pt;
313
+ }
314
+
315
+ return (1 << (eob_pt - 1));
316
+ }
317
+
318
+ /**
319
+ * Write the Exp-Golomb suffix for a coefficient beyond the range the base symbols reach.
320
+ *
321
+ * @param {SymbolWriter} writer
322
+ * @param {number} value at least one
323
+ */
324
+ function write_golomb(writer, value) {
325
+ let length = 0;
326
+
327
+ for (let probe = value; probe > 0; probe >>= 1) {
328
+ length++;
329
+ }
330
+
331
+ for (let i = 0; i < length - 1; i++) {
332
+ writer.write_bool(0);
333
+ }
334
+
335
+ writer.write_bool(1);
336
+
337
+ for (let i = length - 2; i >= 0; i--) {
338
+ writer.write_bool((value >> i) & 1);
339
+ }
340
+ }
341
+
342
+ /**
343
+ * @param {Av1FrameContext} ctx
344
+ * @param {number} plane
345
+ * @param {number} x4
346
+ * @param {number} y4
347
+ * @param {number} w4
348
+ * @param {number} h4
349
+ * @param {number} cul_level
350
+ * @param {number} dc_category
351
+ */
352
+ function update_contexts(ctx, plane, x4, y4, w4, h4, cul_level, dc_category) {
353
+ const above_level = ctx.above_level_context[plane];
354
+ const above_dc = ctx.above_dc_context[plane];
355
+ const left_level = ctx.left_level_context[plane];
356
+ const left_dc = ctx.left_dc_context[plane];
357
+
358
+ for (let i = 0; i < w4; i++) {
359
+ above_level[x4 + i] = cul_level;
360
+ above_dc[x4 + i] = dc_category;
361
+ }
362
+
363
+ for (let i = 0; i < h4; i++) {
364
+ left_level[y4 + i] = cul_level;
365
+ left_dc[y4 + i] = dc_category;
366
+ }
367
+ }