@woosh/meep-engine 3.79.0 → 3.80.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.
- package/CHANGELOG.md +62 -3
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/format/image/webp/vp8/VP8BoolDecoder.d.ts +45 -0
- package/src/format/image/webp/vp8/VP8BoolDecoder.d.ts.map +1 -0
- package/src/format/image/webp/vp8/VP8BoolDecoder.js +137 -0
- package/src/format/image/webp/vp8/vp8_decode.d.ts +21 -0
- package/src/format/image/webp/vp8/vp8_decode.d.ts.map +1 -0
- package/src/format/image/webp/vp8/vp8_decode.js +756 -0
- package/src/format/image/webp/vp8/vp8_loop_filter.d.ts +31 -0
- package/src/format/image/webp/vp8/vp8_loop_filter.d.ts.map +1 -0
- package/src/format/image/webp/vp8/vp8_loop_filter.js +189 -0
- package/src/format/image/webp/vp8/vp8_predict.d.ts +48 -0
- package/src/format/image/webp/vp8/vp8_predict.d.ts.map +1 -0
- package/src/format/image/webp/vp8/vp8_predict.js +290 -0
- package/src/format/image/webp/vp8/vp8_tables.d.ts +34 -0
- package/src/format/image/webp/vp8/vp8_tables.d.ts.map +1 -0
- package/src/format/image/webp/vp8/vp8_tables.js +350 -0
- package/src/format/image/webp/vp8/vp8_transform.d.ts +22 -0
- package/src/format/image/webp/vp8/vp8_transform.d.ts.map +1 -0
- package/src/format/image/webp/vp8/vp8_transform.js +114 -0
- package/src/format/image/webp/vp8/vp8_yuv_to_rgba.d.ts +23 -0
- package/src/format/image/webp/vp8/vp8_yuv_to_rgba.d.ts.map +1 -0
- package/src/format/image/webp/vp8/vp8_yuv_to_rgba.js +133 -0
- package/src/format/image/webp/vp8l/VP8LBitReader.d.ts +47 -0
- package/src/format/image/webp/vp8l/VP8LBitReader.d.ts.map +1 -0
- package/src/format/image/webp/vp8l/VP8LBitReader.js +84 -0
- package/src/format/image/webp/vp8l/VP8LPrefixCode.d.ts +27 -0
- package/src/format/image/webp/vp8l/VP8LPrefixCode.d.ts.map +1 -0
- package/src/format/image/webp/vp8l/VP8LPrefixCode.js +184 -0
- package/src/format/image/webp/vp8l/vp8l_decode.d.ts +28 -0
- package/src/format/image/webp/vp8l/vp8l_decode.d.ts.map +1 -0
- package/src/format/image/webp/vp8l/vp8l_decode.js +261 -0
- package/src/format/image/webp/vp8l/vp8l_distance.d.ts +22 -0
- package/src/format/image/webp/vp8l/vp8l_distance.d.ts.map +1 -0
- package/src/format/image/webp/vp8l/vp8l_distance.js +62 -0
- package/src/format/image/webp/vp8l/vp8l_inverse_transforms.d.ts +50 -0
- package/src/format/image/webp/vp8l/vp8l_inverse_transforms.d.ts.map +1 -0
- package/src/format/image/webp/vp8l/vp8l_inverse_transforms.js +267 -0
- package/src/format/image/webp/vp8l/vp8l_read_prefix_code.d.ts +14 -0
- package/src/format/image/webp/vp8l/vp8l_read_prefix_code.d.ts.map +1 -0
- package/src/format/image/webp/vp8l/vp8l_read_prefix_code.js +99 -0
- package/src/format/image/webp/webp_decode.d.ts +23 -0
- package/src/format/image/webp/webp_decode.d.ts.map +1 -0
- package/src/format/image/webp/webp_decode.js +179 -0
- package/src/format/image/webp/webp_decode_alpha.d.ts +18 -0
- package/src/format/image/webp/webp_decode_alpha.d.ts.map +1 -0
- package/src/format/image/webp/webp_decode_alpha.js +84 -0
- package/src/format/texture/{basis → astc}/astc_block.d.ts +41 -0
- package/src/format/texture/astc/astc_block.d.ts.map +1 -0
- package/src/format/texture/{basis → astc}/astc_block.js +284 -164
- package/src/format/texture/astc/astc_decode_block.d.ts +68 -0
- package/src/format/texture/astc/astc_decode_block.d.ts.map +1 -0
- package/src/format/texture/astc/astc_decode_block.js +1119 -0
- package/src/format/texture/astc/astc_encode_block_4x4.d.ts +32 -0
- package/src/format/texture/astc/astc_encode_block_4x4.d.ts.map +1 -0
- package/src/format/texture/astc/astc_encode_block_4x4.js +181 -0
- package/src/format/texture/astc/astc_encode_block_4x4_rgba.d.ts +32 -0
- package/src/format/texture/astc/astc_encode_block_4x4_rgba.d.ts.map +1 -0
- package/src/format/texture/astc/astc_encode_block_4x4_rgba.js +337 -0
- package/src/format/texture/astc/astc_integer_sequence.d.ts.map +1 -0
- package/src/format/texture/{basis → astc}/astc_integer_sequence.js +251 -251
- package/src/format/texture/astc/astc_partition.d.ts.map +1 -0
- package/src/format/texture/{basis → astc}/astc_partition.js +199 -199
- package/src/format/texture/basis/transcode/etc1s_to_astc.js +329 -329
- package/src/format/texture/basis/transcode/etc1s_to_etc2.d.ts.map +1 -1
- package/src/format/texture/basis/transcode/etc1s_to_etc2.js +305 -332
- package/src/format/texture/basis/transcode/fit_endpoints.d.ts.map +1 -1
- package/src/format/texture/basis/transcode/fit_endpoints.js +14 -27
- package/src/format/texture/basis/uastc/uastc_bc7_tables.d.ts +66 -0
- package/src/format/texture/basis/uastc/uastc_bc7_tables.d.ts.map +1 -0
- package/src/format/texture/basis/uastc/uastc_bc7_tables.js +148 -0
- package/src/format/texture/basis/uastc/uastc_decode_block.js +463 -463
- package/src/format/texture/basis/uastc/uastc_to_astc.js +421 -421
- package/src/format/texture/basis/uastc/uastc_to_bc5.d.ts +1 -6
- package/src/format/texture/basis/uastc/uastc_to_bc5.d.ts.map +1 -1
- package/src/format/texture/basis/uastc/uastc_to_bc5.js +48 -115
- package/src/format/texture/basis/uastc/uastc_to_bc7.d.ts.map +1 -1
- package/src/format/texture/basis/uastc/uastc_to_bc7.js +604 -602
- package/src/format/texture/bc/bc1_decode_block.d.ts +19 -0
- package/src/format/texture/bc/bc1_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc1_decode_block.js +22 -0
- package/src/format/texture/bc/bc1_decode_colors.d.ts +27 -0
- package/src/format/texture/bc/bc1_decode_colors.d.ts.map +1 -0
- package/src/format/texture/bc/bc1_decode_colors.js +100 -0
- package/src/format/texture/bc/bc2_decode_block.d.ts +18 -0
- package/src/format/texture/bc/bc2_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc2_decode_block.js +28 -0
- package/src/format/texture/bc/bc3_decode_block.d.ts +18 -0
- package/src/format/texture/bc/bc3_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc3_decode_block.js +23 -0
- package/src/format/texture/bc/bc4_decode_channel.d.ts +56 -0
- package/src/format/texture/bc/bc4_decode_channel.d.ts.map +1 -0
- package/src/format/texture/bc/bc4_decode_channel.js +138 -0
- package/src/format/texture/bc/bc4_encode_block.d.ts +43 -0
- package/src/format/texture/bc/bc4_encode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc4_encode_block.js +324 -0
- package/src/format/texture/bc/bc4_snorm_decode_block.d.ts +18 -0
- package/src/format/texture/bc/bc4_snorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc4_snorm_decode_block.js +27 -0
- package/src/format/texture/bc/bc4_unorm_decode_block.d.ts +17 -0
- package/src/format/texture/bc/bc4_unorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc4_unorm_decode_block.js +26 -0
- package/src/format/texture/bc/bc5_encode_block.d.ts +25 -0
- package/src/format/texture/bc/bc5_encode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc5_encode_block.js +34 -0
- package/src/format/texture/bc/bc5_snorm_decode_block.d.ts +18 -0
- package/src/format/texture/bc/bc5_snorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc5_snorm_decode_block.js +27 -0
- package/src/format/texture/bc/bc5_unorm_decode_block.d.ts +17 -0
- package/src/format/texture/bc/bc5_unorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc5_unorm_decode_block.js +26 -0
- package/src/format/texture/bc/bc6h_decode_texels.d.ts +30 -0
- package/src/format/texture/bc/bc6h_decode_texels.d.ts.map +1 -0
- package/src/format/texture/bc/bc6h_decode_texels.js +430 -0
- package/src/format/texture/bc/bc6h_sfloat_decode_block.d.ts +20 -0
- package/src/format/texture/bc/bc6h_sfloat_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc6h_sfloat_decode_block.js +23 -0
- package/src/format/texture/bc/bc6h_ufloat_decode_block.d.ts +18 -0
- package/src/format/texture/bc/bc6h_ufloat_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc6h_ufloat_decode_block.js +21 -0
- package/src/format/texture/bc/bc7_decode_block.d.ts +30 -0
- package/src/format/texture/bc/bc7_decode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc7_decode_block.js +232 -0
- package/src/format/texture/bc/bc7_encode_block.d.ts +39 -0
- package/src/format/texture/bc/bc7_encode_block.d.ts.map +1 -0
- package/src/format/texture/bc/bc7_encode_block.js +423 -0
- package/src/format/texture/bc/bc7_tables.d.ts +126 -0
- package/src/format/texture/bc/bc7_tables.d.ts.map +1 -0
- package/src/format/texture/{basis/uastc → bc}/bc7_tables.js +225 -276
- package/src/format/texture/bc/bc7_write_block.d.ts +65 -0
- package/src/format/texture/bc/bc7_write_block.d.ts.map +1 -0
- package/src/format/texture/{basis/uastc → bc}/bc7_write_block.js +185 -227
- package/src/format/texture/etc/eac_decode_channel.d.ts +50 -0
- package/src/format/texture/etc/eac_decode_channel.d.ts.map +1 -0
- package/src/format/texture/etc/eac_decode_channel.js +142 -0
- package/src/format/texture/etc/eac_modifiers.d.ts +15 -0
- package/src/format/texture/etc/eac_modifiers.d.ts.map +1 -0
- package/src/format/texture/etc/eac_modifiers.js +31 -0
- package/src/format/texture/etc/eac_r11_snorm_decode_block.d.ts +21 -0
- package/src/format/texture/etc/eac_r11_snorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/eac_r11_snorm_decode_block.js +30 -0
- package/src/format/texture/etc/eac_r11_unorm_decode_block.d.ts +20 -0
- package/src/format/texture/etc/eac_r11_unorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/eac_r11_unorm_decode_block.js +29 -0
- package/src/format/texture/etc/eac_rg11_snorm_decode_block.d.ts +19 -0
- package/src/format/texture/etc/eac_rg11_snorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/eac_rg11_snorm_decode_block.js +28 -0
- package/src/format/texture/etc/eac_rg11_unorm_decode_block.d.ts +19 -0
- package/src/format/texture/etc/eac_rg11_unorm_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/eac_rg11_unorm_decode_block.js +28 -0
- package/src/format/texture/etc/etc2_decode_color.d.ts +25 -0
- package/src/format/texture/etc/etc2_decode_color.d.ts.map +1 -0
- package/src/format/texture/etc/etc2_decode_color.js +370 -0
- package/src/format/texture/etc/etc2_rgb8_decode_block.d.ts +18 -0
- package/src/format/texture/etc/etc2_rgb8_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/etc2_rgb8_decode_block.js +21 -0
- package/src/format/texture/etc/etc2_rgb8a1_decode_block.d.ts +21 -0
- package/src/format/texture/etc/etc2_rgb8a1_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/etc2_rgb8a1_decode_block.js +24 -0
- package/src/format/texture/etc/etc2_rgba8_decode_block.d.ts +18 -0
- package/src/format/texture/etc/etc2_rgba8_decode_block.d.ts.map +1 -0
- package/src/format/texture/etc/etc2_rgba8_decode_block.js +24 -0
- package/src/format/texture/fit/fit_line.d.ts +23 -0
- package/src/format/texture/fit/fit_line.d.ts.map +1 -0
- package/src/format/texture/fit/fit_line.js +123 -0
- package/src/format/texture/fit/fit_line_refine.d.ts +21 -0
- package/src/format/texture/fit/fit_line_refine.d.ts.map +1 -0
- package/src/format/texture/fit/fit_line_refine.js +69 -0
- package/src/format/texture/fit/fit_line_solve.d.ts +23 -0
- package/src/format/texture/fit/fit_line_solve.d.ts.map +1 -0
- package/src/format/texture/fit/fit_line_solve.js +71 -0
- package/src/format/texture/texel_decode_image.d.ts +44 -0
- package/src/format/texture/texel_decode_image.d.ts.map +1 -0
- package/src/format/texture/texel_decode_image.js +251 -0
- package/src/format/texture/texel_encode_image.d.ts +77 -0
- package/src/format/texture/texel_encode_image.d.ts.map +1 -0
- package/src/format/texture/texel_encode_image.js +187 -0
- package/src/shade/renderer/ShadeIndirectLightingMode.js +2 -0
- package/src/shade/renderer/acoustics/GPUAcousticLattice.d.ts +1 -1
- package/src/shade/renderer/acoustics/GPUAcoustics.d.ts +1 -1
- package/src/shade/renderer/loader/mtf/mtf_encode_texture.d.ts +1 -0
- package/src/shade/renderer/loader/mtf/mtf_encode_texture.d.ts.map +1 -1
- package/src/shade/renderer/loader/mtf/mtf_encode_texture.js +102 -28
- package/src/shade/renderer/loader/mtf/mtf_replace_textures.d.ts +19 -0
- package/src/shade/renderer/loader/mtf/mtf_replace_textures.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_replace_textures.js +60 -0
- package/src/shade/renderer/loader/mtf/mtf_write.d.ts.map +1 -1
- package/src/shade/renderer/loader/mtf/mtf_write.js +7 -31
- package/src/shade/renderer/loader/mtf/mtf_write_collection.d.ts +23 -0
- package/src/shade/renderer/loader/mtf/mtf_write_collection.d.ts.map +1 -0
- package/src/shade/renderer/loader/mtf/mtf_write_collection.js +36 -0
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4.d.ts +13 -0
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4.d.ts.map +1 -0
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4.js +39 -0
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.d.ts +3 -2
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.js +6 -21
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgba.d.ts +42 -0
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgba.d.ts.map +1 -0
- package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgba.js +612 -0
- package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.d.ts +5 -4
- package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.js +8 -25
- package/src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.js +3 -19
- package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.d.ts +14 -4
- package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.js +65 -54
- package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.d.ts +2 -2
- package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.js +5 -22
- package/src/shade/renderer/texture/encode/chunk_bc7_partition_2.js +1 -1
- package/src/shade/renderer/texture/encode/chunk_scatter_principal_axis.d.ts +27 -0
- package/src/shade/renderer/texture/encode/chunk_scatter_principal_axis.d.ts.map +1 -0
- package/src/shade/renderer/texture/encode/chunk_scatter_principal_axis.js +147 -0
- package/src/shade/renderer/texture/encode/shader_texture_encode_astc_4x4.d.ts +3 -4
- package/src/shade/renderer/texture/encode/shader_texture_encode_astc_4x4.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/shader_texture_encode_astc_4x4.js +6 -13
- package/src/shade/renderer/texture/encode/shader_texture_encode_bc7_rgb.d.ts +13 -0
- package/src/shade/renderer/texture/encode/shader_texture_encode_bc7_rgb.d.ts.map +1 -0
- package/src/shade/renderer/texture/encode/shader_texture_encode_bc7_rgb.js +66 -0
- package/src/shade/renderer/texture/encode/texture_encode.d.ts +28 -1
- package/src/shade/renderer/texture/encode/texture_encode.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/texture_encode.js +202 -168
- package/src/shade/renderer/texture/encode/texture_encode_shader.d.ts +13 -1
- package/src/shade/renderer/texture/encode/texture_encode_shader.d.ts.map +1 -1
- package/src/shade/renderer/texture/encode/texture_encode_shader.js +146 -108
- package/src/shade/renderer/texture/format/texture_formats_to_build.d.ts +20 -0
- package/src/shade/renderer/texture/format/texture_formats_to_build.d.ts.map +1 -0
- package/src/shade/renderer/texture/format/texture_formats_to_build.js +98 -0
- package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.d.ts.map +1 -1
- package/src/shade/renderer/texture/mipmaps/WebGPUMipmapGenerator.js +4 -23
- package/src/shade/renderer/texture/mipmaps/cpu/MipmapBilinearAxis.d.ts +53 -0
- package/src/shade/renderer/texture/mipmaps/cpu/MipmapBilinearAxis.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/MipmapBilinearAxis.js +76 -0
- package/src/shade/renderer/texture/mipmaps/cpu/MipmapKernelAxis.d.ts +40 -0
- package/src/shade/renderer/texture/mipmaps/cpu/MipmapKernelAxis.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/MipmapKernelAxis.js +43 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_centres.d.ts +17 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_centres.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_centres.js +29 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_sample.d.ts +21 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_sample.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_bilinear_sample.js +91 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_chain_cpu.d.ts +32 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_chain_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_chain_cpu.js +216 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_cubic_filter_cpu.d.ts +30 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_cubic_filter_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_cubic_filter_cpu.js +134 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_catmull_rom_cpu.d.ts +16 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_catmull_rom_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_catmull_rom_cpu.js +33 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_cpu.d.ts +18 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_cpu.js +71 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_normal_cpu.d.ts +20 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_normal_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_linear_normal_cpu.js +57 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_magic_kernel_cpu.d.ts +18 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_magic_kernel_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_magic_kernel_cpu.js +111 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mitchell_cpu.d.ts +16 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mitchell_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mitchell_cpu.js +33 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mks_cpu.d.ts +18 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mks_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_mks_cpu.js +128 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_wronski2021_cpu.d.ts +21 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_wronski2021_cpu.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_filter_wronski2021_cpu.js +169 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_kernel_reduce.d.ts +21 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_kernel_reduce.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_kernel_reduce.js +119 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_source_centre.d.ts +16 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_source_centre.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/mipmap_source_centre.js +19 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm.d.ts +24 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm.js +41 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm_srgb.d.ts +24 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm_srgb.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_f32_to_rgba8unorm_srgb.js +140 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_srgb_to_f32.d.ts +21 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_srgb_to_f32.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_srgb_to_f32.js +35 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_to_f32.d.ts +19 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_to_f32.d.ts.map +1 -0
- package/src/shade/renderer/texture/mipmaps/cpu/texels_rgba8unorm_to_f32.js +27 -0
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_catmull_rom.js +4 -4
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_linear.d.ts +13 -0
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_linear.d.ts.map +1 -1
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_linear.js +54 -4
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_mitchell.js +4 -4
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_mks.d.ts.map +1 -1
- package/src/shade/renderer/texture/mipmaps/filters/mipmap_shader_code_mks.js +9 -13
- package/src/shade/renderer/texture/texture_block_encodings.d.ts +33 -0
- package/src/shade/renderer/texture/texture_block_encodings.d.ts.map +1 -0
- package/src/shade/renderer/texture/texture_block_encodings.js +89 -0
- package/src/format/texture/basis/astc_block.d.ts.map +0 -1
- package/src/format/texture/basis/astc_integer_sequence.d.ts.map +0 -1
- package/src/format/texture/basis/astc_partition.d.ts.map +0 -1
- package/src/format/texture/basis/uastc/bc7_tables.d.ts +0 -111
- package/src/format/texture/basis/uastc/bc7_tables.d.ts.map +0 -1
- package/src/format/texture/basis/uastc/bc7_write_block.d.ts +0 -124
- package/src/format/texture/basis/uastc/bc7_write_block.d.ts.map +0 -1
- /package/src/format/texture/{basis → astc}/astc_integer_sequence.d.ts +0 -0
- /package/src/format/texture/{basis → astc}/astc_partition.d.ts +0 -0
|
@@ -0,0 +1,756 @@
|
|
|
1
|
+
import { VP8BoolDecoder } from "./VP8BoolDecoder.js";
|
|
2
|
+
import { vp8_normal_filter_edge, vp8_simple_filter_edge } from "./vp8_loop_filter.js";
|
|
3
|
+
import { vp8_predict_block, vp8_predict_subblock } from "./vp8_predict.js";
|
|
4
|
+
import {
|
|
5
|
+
VP8_AC_QUANTIZER,
|
|
6
|
+
VP8_COEFFICIENT_DEFAULT_PROBABILITIES,
|
|
7
|
+
VP8_COEFFICIENT_UPDATE_PROBABILITIES,
|
|
8
|
+
VP8_DC_QUANTIZER,
|
|
9
|
+
VP8_SUBBLOCK_MODE_PROBABILITIES
|
|
10
|
+
} from "./vp8_tables.js";
|
|
11
|
+
import { vp8_inverse_dct_add, vp8_inverse_wht } from "./vp8_transform.js";
|
|
12
|
+
import { vp8_yuv_to_rgba } from "./vp8_yuv_to_rgba.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Where the n-th coefficient read goes in a block's raster order.
|
|
16
|
+
*
|
|
17
|
+
* @type {Uint8Array}
|
|
18
|
+
*/
|
|
19
|
+
const ZIGZAG = new Uint8Array([0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15]);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The probability band of each coefficient position, and a 17th for the position after the last.
|
|
23
|
+
*
|
|
24
|
+
* @type {Uint8Array}
|
|
25
|
+
*/
|
|
26
|
+
const BANDS = new Uint8Array([0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 0]);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Probabilities of the extra bits of DCT_CAT3 to DCT_CAT6 (RFC 6386 §13.2).
|
|
30
|
+
*
|
|
31
|
+
* @type {number[][]}
|
|
32
|
+
*/
|
|
33
|
+
const CATEGORY_PROBABILITIES = [
|
|
34
|
+
[173, 148, 140],
|
|
35
|
+
[176, 155, 140, 135],
|
|
36
|
+
[180, 157, 141, 134, 130],
|
|
37
|
+
[254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129],
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The sub-block mode tree (RFC 6386 §11.2) as node pairs: a positive entry is the next node, an entry of zero or less
|
|
42
|
+
* is a leaf, the negated mode. Node `i` reads its bit with the `i`-th probability.
|
|
43
|
+
*
|
|
44
|
+
* @type {Int8Array}
|
|
45
|
+
*/
|
|
46
|
+
const SUBBLOCK_MODE_TREE = new Int8Array([0, 1, -1, 2, -2, 3, 4, 6, -3, 5, -4, -5, -6, 7, -7, 8, -8, -9]);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Block types, which select the coefficient probabilities.
|
|
50
|
+
*/
|
|
51
|
+
const TYPE_Y_AFTER_Y2 = 0;
|
|
52
|
+
const TYPE_Y2 = 1;
|
|
53
|
+
const TYPE_CHROMA = 2;
|
|
54
|
+
const TYPE_Y_WITH_DC = 3;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @param {number} v
|
|
58
|
+
* @param {number} max
|
|
59
|
+
* @returns {number}
|
|
60
|
+
*/
|
|
61
|
+
function clamp(v, max) {
|
|
62
|
+
return v < 0 ? 0 : v > max ? max : v;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* A coefficient's magnitude past 1 (RFC 6386 §13.2): DCT_2 to DCT_4, or a category and its extra bits.
|
|
67
|
+
*
|
|
68
|
+
* @param {VP8BoolDecoder} br
|
|
69
|
+
* @param {Uint8Array} probabilities
|
|
70
|
+
* @param {number} p where the context's 11 probabilities start
|
|
71
|
+
* @returns {number}
|
|
72
|
+
*/
|
|
73
|
+
function read_large_value(br, probabilities, p) {
|
|
74
|
+
if (br.bit(probabilities[p + 3]) === 0) {
|
|
75
|
+
return br.bit(probabilities[p + 4]) === 0 ? 2 : 3 + br.bit(probabilities[p + 5]);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (br.bit(probabilities[p + 6]) === 0) {
|
|
79
|
+
if (br.bit(probabilities[p + 7]) === 0) {
|
|
80
|
+
return 5 + br.bit(159);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return 7 + 2 * br.bit(165) + br.bit(145);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const high = br.bit(probabilities[p + 8]);
|
|
87
|
+
const category = 2 * high + br.bit(probabilities[p + 9 + high]);
|
|
88
|
+
const extra = CATEGORY_PROBABILITIES[category];
|
|
89
|
+
|
|
90
|
+
let v = 0;
|
|
91
|
+
|
|
92
|
+
for (let i = 0; i < extra.length; i++) {
|
|
93
|
+
v = 2 * v + br.bit(extra[i]);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return v + 3 + (8 << category);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* One block's coefficients (RFC 6386 §13), dequantized into raster order.
|
|
101
|
+
*
|
|
102
|
+
* @param {VP8BoolDecoder} br
|
|
103
|
+
* @param {Uint8Array} probabilities
|
|
104
|
+
* @param {number} type
|
|
105
|
+
* @param {number} context how many of the blocks above and to the left had coefficients
|
|
106
|
+
* @param {number} dc_factor
|
|
107
|
+
* @param {number} ac_factor
|
|
108
|
+
* @param {number} n the first position read: 1 for a luma block whose DC is in the second-order block
|
|
109
|
+
* @param {Int16Array} out
|
|
110
|
+
* @param {number} at where the block starts in `out`
|
|
111
|
+
* @returns {number} one past the last position read before the end of the block
|
|
112
|
+
*/
|
|
113
|
+
function read_coefficients(br, probabilities, type, context, dc_factor, ac_factor, n, out, at) {
|
|
114
|
+
const type_base = type * 8;
|
|
115
|
+
|
|
116
|
+
let p = ((type_base + BANDS[n]) * 3 + context) * 11;
|
|
117
|
+
|
|
118
|
+
for (; n < 16; n++) {
|
|
119
|
+
if (br.bit(probabilities[p]) === 0) {
|
|
120
|
+
return n;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
while (br.bit(probabilities[p + 1]) === 0) {
|
|
124
|
+
if (++n === 16) {
|
|
125
|
+
return 16;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
p = (type_base + BANDS[n]) * 33;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
let v;
|
|
132
|
+
let next_context;
|
|
133
|
+
|
|
134
|
+
if (br.bit(probabilities[p + 2]) === 0) {
|
|
135
|
+
v = 1;
|
|
136
|
+
next_context = 1;
|
|
137
|
+
} else {
|
|
138
|
+
v = read_large_value(br, probabilities, p);
|
|
139
|
+
next_context = 2;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
out[at + ZIGZAG[n]] = (br.bit(128) === 1 ? -v : v) * (n > 0 ? ac_factor : dc_factor);
|
|
143
|
+
|
|
144
|
+
p = ((type_base + BANDS[n + 1]) * 3 + next_context) * 11;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return 16;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @param {Int16Array} coefficients
|
|
152
|
+
* @param {number} at
|
|
153
|
+
* @returns {boolean} whether any of the 16 coefficients from `at` is not zero
|
|
154
|
+
*/
|
|
155
|
+
function any_coefficient(coefficients, at) {
|
|
156
|
+
for (let i = 0; i < 16; i++) {
|
|
157
|
+
if (coefficients[at + i] !== 0) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* A VP8 key frame, the payload of a `VP8 ` chunk (RFC 6386), decoded to RGBA as libwebp decodes it.
|
|
167
|
+
*
|
|
168
|
+
* The frame header, the intra modes and the DCT tokens are read; every macroblock is predicted and its residual added
|
|
169
|
+
* in raster order, prediction reading samples before any filtering; then the loop filter runs over the whole frame,
|
|
170
|
+
* macroblock by macroblock; then the picture is cropped out of the macroblock grid and converted.
|
|
171
|
+
*
|
|
172
|
+
* @param {Uint8Array} bytes
|
|
173
|
+
* @returns {{width: number, height: number, data: Uint8Array}} opaque RGBA
|
|
174
|
+
* @throws {Error} for an inter frame, and for a frame whose partitions do not fit its bytes. A partition whose data
|
|
175
|
+
* ends early reads zeros past its end, as the boolean decoder does anywhere
|
|
176
|
+
*
|
|
177
|
+
* @author Alex Goldring
|
|
178
|
+
* @copyright Company Named Limited (c) 2026
|
|
179
|
+
*/
|
|
180
|
+
export function vp8_decode(bytes) {
|
|
181
|
+
if (bytes.length < 10) {
|
|
182
|
+
throw new Error("WebP: a VP8 frame cut short");
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const tag = bytes[0] | (bytes[1] << 8) | (bytes[2] << 16);
|
|
186
|
+
|
|
187
|
+
if ((tag & 1) !== 0) {
|
|
188
|
+
throw new Error("WebP: a VP8 frame that is not a key frame");
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (((tag >> 1) & 7) > 3) {
|
|
192
|
+
throw new Error(`WebP: VP8 profile ${(tag >> 1) & 7}`);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const first_partition_size = tag >>> 5;
|
|
196
|
+
|
|
197
|
+
if (bytes[3] !== 0x9D || bytes[4] !== 0x01 || bytes[5] !== 0x2A) {
|
|
198
|
+
throw new Error("WebP: a VP8 key frame without its start code");
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const width = (bytes[6] | (bytes[7] << 8)) & 0x3FFF;
|
|
202
|
+
const height = (bytes[8] | (bytes[9] << 8)) & 0x3FFF;
|
|
203
|
+
|
|
204
|
+
if (width === 0 || height === 0) {
|
|
205
|
+
throw new Error("WebP: a VP8 frame of no size");
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const partitions_start = 10 + first_partition_size;
|
|
209
|
+
|
|
210
|
+
if (partitions_start > bytes.length) {
|
|
211
|
+
throw new Error("WebP: a VP8 frame's first partition runs past its bytes");
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const br = new VP8BoolDecoder(bytes, 10, partitions_start);
|
|
215
|
+
|
|
216
|
+
br.bit(128); // colour space: the one there is
|
|
217
|
+
br.bit(128); // clamping: always done here
|
|
218
|
+
|
|
219
|
+
// segmentation
|
|
220
|
+
const use_segment = br.bit(128) === 1;
|
|
221
|
+
const segment_quantizer = [0, 0, 0, 0];
|
|
222
|
+
const segment_filter = [0, 0, 0, 0];
|
|
223
|
+
const segment_probabilities = [255, 255, 255];
|
|
224
|
+
|
|
225
|
+
let update_map = false;
|
|
226
|
+
let absolute_delta = false;
|
|
227
|
+
|
|
228
|
+
if (use_segment) {
|
|
229
|
+
update_map = br.bit(128) === 1;
|
|
230
|
+
|
|
231
|
+
if (br.bit(128) === 1) {
|
|
232
|
+
absolute_delta = br.bit(128) === 1;
|
|
233
|
+
|
|
234
|
+
for (let s = 0; s < 4; s++) {
|
|
235
|
+
segment_quantizer[s] = br.optional_signed_literal(7);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
for (let s = 0; s < 4; s++) {
|
|
239
|
+
segment_filter[s] = br.optional_signed_literal(6);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (update_map) {
|
|
244
|
+
for (let s = 0; s < 3; s++) {
|
|
245
|
+
segment_probabilities[s] = br.bit(128) === 1 ? br.literal(8) : 255;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// loop filter
|
|
251
|
+
const simple_filter = br.bit(128) === 1;
|
|
252
|
+
const filter_level = br.literal(6);
|
|
253
|
+
const sharpness = br.literal(3);
|
|
254
|
+
const reference_delta = [0, 0, 0, 0];
|
|
255
|
+
const mode_delta = [0, 0, 0, 0];
|
|
256
|
+
const use_filter_delta = br.bit(128) === 1;
|
|
257
|
+
|
|
258
|
+
if (use_filter_delta && br.bit(128) === 1) {
|
|
259
|
+
for (let i = 0; i < 4; i++) {
|
|
260
|
+
if (br.bit(128) === 1) {
|
|
261
|
+
reference_delta[i] = br.signed_literal(6);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
for (let i = 0; i < 4; i++) {
|
|
266
|
+
if (br.bit(128) === 1) {
|
|
267
|
+
mode_delta[i] = br.signed_literal(6);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const filter_type = filter_level === 0 ? 0 : simple_filter ? 1 : 2;
|
|
273
|
+
|
|
274
|
+
// token partitions
|
|
275
|
+
const partition_count = 1 << br.literal(2);
|
|
276
|
+
const sizes_end = partitions_start + 3 * (partition_count - 1);
|
|
277
|
+
|
|
278
|
+
if (sizes_end > bytes.length) {
|
|
279
|
+
throw new Error("WebP: a VP8 frame's partition sizes run past its bytes");
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const partitions = [];
|
|
283
|
+
|
|
284
|
+
let partition_start = sizes_end;
|
|
285
|
+
|
|
286
|
+
for (let p = 0; p < partition_count; p++) {
|
|
287
|
+
let end = bytes.length;
|
|
288
|
+
|
|
289
|
+
if (p < partition_count - 1) {
|
|
290
|
+
const at = partitions_start + 3 * p;
|
|
291
|
+
|
|
292
|
+
end = partition_start + (bytes[at] | (bytes[at + 1] << 8) | (bytes[at + 2] << 16));
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (partition_start > bytes.length || end > bytes.length) {
|
|
296
|
+
throw new Error("WebP: a VP8 token partition runs past its frame");
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
partitions.push(new VP8BoolDecoder(bytes, partition_start, end));
|
|
300
|
+
|
|
301
|
+
partition_start = end;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// quantizers, one set a segment
|
|
305
|
+
const base_q = br.literal(7);
|
|
306
|
+
const y1_dc_delta = br.optional_signed_literal(4);
|
|
307
|
+
const y2_dc_delta = br.optional_signed_literal(4);
|
|
308
|
+
const y2_ac_delta = br.optional_signed_literal(4);
|
|
309
|
+
const uv_dc_delta = br.optional_signed_literal(4);
|
|
310
|
+
const uv_ac_delta = br.optional_signed_literal(4);
|
|
311
|
+
|
|
312
|
+
const quantizers = [];
|
|
313
|
+
|
|
314
|
+
for (let s = 0; s < 4; s++) {
|
|
315
|
+
const q = use_segment ? segment_quantizer[s] + (absolute_delta ? 0 : base_q) : base_q;
|
|
316
|
+
|
|
317
|
+
quantizers.push({
|
|
318
|
+
y1_dc: VP8_DC_QUANTIZER[clamp(q + y1_dc_delta, 127)],
|
|
319
|
+
y1_ac: VP8_AC_QUANTIZER[clamp(q, 127)],
|
|
320
|
+
y2_dc: VP8_DC_QUANTIZER[clamp(q + y2_dc_delta, 127)] * 2,
|
|
321
|
+
y2_ac: Math.max(8, (VP8_AC_QUANTIZER[clamp(q + y2_ac_delta, 127)] * 101581) >> 16),
|
|
322
|
+
uv_dc: VP8_DC_QUANTIZER[clamp(q + uv_dc_delta, 117)],
|
|
323
|
+
uv_ac: VP8_AC_QUANTIZER[clamp(q + uv_ac_delta, 127)],
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
br.bit(128); // whether to keep the probabilities for the next frame: there is none
|
|
328
|
+
|
|
329
|
+
const probabilities = VP8_COEFFICIENT_DEFAULT_PROBABILITIES.slice();
|
|
330
|
+
|
|
331
|
+
for (let i = 0; i < probabilities.length; i++) {
|
|
332
|
+
if (br.bit(VP8_COEFFICIENT_UPDATE_PROBABILITIES[i]) === 1) {
|
|
333
|
+
probabilities[i] = br.literal(8);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const use_skip = br.bit(128) === 1;
|
|
338
|
+
const skip_probability = use_skip ? br.literal(8) : 0;
|
|
339
|
+
|
|
340
|
+
// the frame, in planes with a border: 127 above the picture, 129 left of it, 127 at the corner
|
|
341
|
+
const mb_w = (width + 15) >> 4;
|
|
342
|
+
const mb_h = (height + 15) >> 4;
|
|
343
|
+
|
|
344
|
+
const y_stride = 1 + mb_w * 16;
|
|
345
|
+
const uv_stride = 1 + mb_w * 8;
|
|
346
|
+
|
|
347
|
+
const y_plane = new Uint8Array(y_stride * (1 + mb_h * 16));
|
|
348
|
+
const u_plane = new Uint8Array(uv_stride * (1 + mb_h * 8));
|
|
349
|
+
const v_plane = new Uint8Array(uv_stride * (1 + mb_h * 8));
|
|
350
|
+
|
|
351
|
+
y_plane.fill(127, 0, y_stride);
|
|
352
|
+
u_plane.fill(127, 0, uv_stride);
|
|
353
|
+
v_plane.fill(127, 0, uv_stride);
|
|
354
|
+
|
|
355
|
+
for (let r = 1; r <= mb_h * 16; r++) {
|
|
356
|
+
y_plane[r * y_stride] = 129;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
for (let r = 1; r <= mb_h * 8; r++) {
|
|
360
|
+
u_plane[r * uv_stride] = 129;
|
|
361
|
+
v_plane[r * uv_stride] = 129;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const intra_top = new Uint8Array(mb_w * 4);
|
|
365
|
+
const intra_left = new Uint8Array(4);
|
|
366
|
+
const nonzero_top = new Uint8Array(mb_w);
|
|
367
|
+
const nonzero_dc_top = new Uint8Array(mb_w);
|
|
368
|
+
|
|
369
|
+
const mb_segment = new Uint8Array(mb_w * mb_h);
|
|
370
|
+
const mb_is_4x4 = new Uint8Array(mb_w * mb_h);
|
|
371
|
+
const mb_inner = new Uint8Array(mb_w * mb_h);
|
|
372
|
+
|
|
373
|
+
const coefficients = new Int16Array(384);
|
|
374
|
+
const second_order = new Int16Array(16);
|
|
375
|
+
const sub_modes = new Uint8Array(16);
|
|
376
|
+
const above = new Uint8Array(8);
|
|
377
|
+
const left = new Uint8Array(4);
|
|
378
|
+
const top_right = new Uint8Array(4);
|
|
379
|
+
|
|
380
|
+
for (let mb_y = 0; mb_y < mb_h; mb_y++) {
|
|
381
|
+
const tokens = partitions[mb_y & (partition_count - 1)];
|
|
382
|
+
|
|
383
|
+
intra_left.fill(0);
|
|
384
|
+
|
|
385
|
+
let nonzero_left = 0;
|
|
386
|
+
let nonzero_dc_left = 0;
|
|
387
|
+
|
|
388
|
+
for (let mb_x = 0; mb_x < mb_w; mb_x++) {
|
|
389
|
+
const mb = mb_y * mb_w + mb_x;
|
|
390
|
+
|
|
391
|
+
// modes
|
|
392
|
+
const segment = update_map
|
|
393
|
+
? (br.bit(segment_probabilities[0]) === 0
|
|
394
|
+
? br.bit(segment_probabilities[1])
|
|
395
|
+
: 2 + br.bit(segment_probabilities[2]))
|
|
396
|
+
: 0;
|
|
397
|
+
|
|
398
|
+
const skip = use_skip ? br.bit(skip_probability) === 1 : false;
|
|
399
|
+
const is_4x4 = br.bit(145) === 0;
|
|
400
|
+
|
|
401
|
+
let y_mode = 0;
|
|
402
|
+
|
|
403
|
+
if (!is_4x4) {
|
|
404
|
+
y_mode = br.bit(156) === 1 ? (br.bit(128) === 1 ? 1 : 3) : (br.bit(163) === 1 ? 2 : 0);
|
|
405
|
+
|
|
406
|
+
intra_top.fill(y_mode, mb_x * 4, mb_x * 4 + 4);
|
|
407
|
+
intra_left.fill(y_mode);
|
|
408
|
+
} else {
|
|
409
|
+
for (let y = 0; y < 4; y++) {
|
|
410
|
+
let mode = intra_left[y];
|
|
411
|
+
|
|
412
|
+
for (let x = 0; x < 4; x++) {
|
|
413
|
+
const p = (intra_top[mb_x * 4 + x] * 10 + mode) * 9;
|
|
414
|
+
|
|
415
|
+
let i = SUBBLOCK_MODE_TREE[br.bit(VP8_SUBBLOCK_MODE_PROBABILITIES[p])];
|
|
416
|
+
|
|
417
|
+
while (i > 0) {
|
|
418
|
+
i = SUBBLOCK_MODE_TREE[2 * i + br.bit(VP8_SUBBLOCK_MODE_PROBABILITIES[p + i])];
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
mode = -i;
|
|
422
|
+
intra_top[mb_x * 4 + x] = mode;
|
|
423
|
+
sub_modes[y * 4 + x] = mode;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
intra_left[y] = mode;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
const uv_mode = br.bit(142) === 0 ? 0 : br.bit(114) === 0 ? 2 : br.bit(183) === 1 ? 1 : 3;
|
|
431
|
+
|
|
432
|
+
// residuals
|
|
433
|
+
coefficients.fill(0);
|
|
434
|
+
|
|
435
|
+
const quantizer = quantizers[segment];
|
|
436
|
+
|
|
437
|
+
if (skip) {
|
|
438
|
+
nonzero_top[mb_x] = 0;
|
|
439
|
+
nonzero_left = 0;
|
|
440
|
+
|
|
441
|
+
if (!is_4x4) {
|
|
442
|
+
nonzero_dc_top[mb_x] = 0;
|
|
443
|
+
nonzero_dc_left = 0;
|
|
444
|
+
}
|
|
445
|
+
} else {
|
|
446
|
+
let first = 0;
|
|
447
|
+
let type = TYPE_Y_WITH_DC;
|
|
448
|
+
|
|
449
|
+
if (!is_4x4) {
|
|
450
|
+
second_order.fill(0);
|
|
451
|
+
|
|
452
|
+
const n = read_coefficients(tokens, probabilities, TYPE_Y2, nonzero_dc_top[mb_x] + nonzero_dc_left,
|
|
453
|
+
quantizer.y2_dc, quantizer.y2_ac, 0, second_order, 0);
|
|
454
|
+
|
|
455
|
+
nonzero_dc_top[mb_x] = nonzero_dc_left = n > 0 ? 1 : 0;
|
|
456
|
+
|
|
457
|
+
if (n > 1) {
|
|
458
|
+
vp8_inverse_wht(second_order, coefficients);
|
|
459
|
+
} else {
|
|
460
|
+
const dc = (second_order[0] + 3) >> 3;
|
|
461
|
+
|
|
462
|
+
for (let i = 0; i < 256; i += 16) {
|
|
463
|
+
coefficients[i] = dc;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
first = 1;
|
|
468
|
+
type = TYPE_Y_AFTER_Y2;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
let top = nonzero_top[mb_x];
|
|
472
|
+
let next_top = 0;
|
|
473
|
+
let next_left = 0;
|
|
474
|
+
|
|
475
|
+
for (let y = 0; y < 4; y++) {
|
|
476
|
+
let l = (nonzero_left >> y) & 1;
|
|
477
|
+
|
|
478
|
+
for (let x = 0; x < 4; x++) {
|
|
479
|
+
const t = (top >> x) & 1;
|
|
480
|
+
const n = read_coefficients(tokens, probabilities, type, l + t,
|
|
481
|
+
quantizer.y1_dc, quantizer.y1_ac, first, coefficients, (y * 4 + x) * 16);
|
|
482
|
+
|
|
483
|
+
l = n > first ? 1 : 0;
|
|
484
|
+
|
|
485
|
+
// the bit for column x of the next row of blocks
|
|
486
|
+
top = (top & ~(1 << x)) | (l << x);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
next_left |= l << y;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
next_top = top & 0x0F;
|
|
493
|
+
|
|
494
|
+
for (let channel = 0; channel < 2; channel++) {
|
|
495
|
+
const shift = 4 + channel * 2;
|
|
496
|
+
|
|
497
|
+
let ctop = (nonzero_top[mb_x] >> shift) & 3;
|
|
498
|
+
|
|
499
|
+
for (let y = 0; y < 2; y++) {
|
|
500
|
+
let l = (nonzero_left >> (shift + y)) & 1;
|
|
501
|
+
|
|
502
|
+
for (let x = 0; x < 2; x++) {
|
|
503
|
+
const t = (ctop >> x) & 1;
|
|
504
|
+
const n = read_coefficients(tokens, probabilities, TYPE_CHROMA, l + t,
|
|
505
|
+
quantizer.uv_dc, quantizer.uv_ac, 0, coefficients, 256 + channel * 64 + (y * 2 + x) * 16);
|
|
506
|
+
|
|
507
|
+
l = n > 0 ? 1 : 0;
|
|
508
|
+
ctop = (ctop & ~(1 << x)) | (l << x);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
next_left |= l << (shift + y);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
next_top |= ctop << shift;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
nonzero_top[mb_x] = next_top;
|
|
518
|
+
nonzero_left = next_left;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
let has_coefficients = false;
|
|
522
|
+
|
|
523
|
+
for (let i = 0; i < 384 && !has_coefficients; i++) {
|
|
524
|
+
has_coefficients = coefficients[i] !== 0;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
mb_segment[mb] = segment;
|
|
528
|
+
mb_is_4x4[mb] = is_4x4 ? 1 : 0;
|
|
529
|
+
mb_inner[mb] = is_4x4 || has_coefficients ? 1 : 0;
|
|
530
|
+
|
|
531
|
+
// reconstruction
|
|
532
|
+
const y_at = (1 + mb_y * 16) * y_stride + 1 + mb_x * 16;
|
|
533
|
+
|
|
534
|
+
if (is_4x4) {
|
|
535
|
+
const row_above = y_at - y_stride;
|
|
536
|
+
|
|
537
|
+
if (mb_y === 0) {
|
|
538
|
+
top_right.fill(127);
|
|
539
|
+
} else if (mb_x < mb_w - 1) {
|
|
540
|
+
top_right.set(y_plane.subarray(row_above + 16, row_above + 20));
|
|
541
|
+
} else {
|
|
542
|
+
top_right.fill(y_plane[row_above + 15]);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
for (let n = 0; n < 16; n++) {
|
|
546
|
+
const sx = n & 3;
|
|
547
|
+
const sy = n >> 2;
|
|
548
|
+
const at = y_at + sy * 4 * y_stride + sx * 4;
|
|
549
|
+
|
|
550
|
+
for (let i = 0; i < 4; i++) {
|
|
551
|
+
above[i] = y_plane[at - y_stride + i];
|
|
552
|
+
above[4 + i] = sx === 3 ? top_right[i] : y_plane[at - y_stride + 4 + i];
|
|
553
|
+
left[i] = y_plane[at + i * y_stride - 1];
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
vp8_predict_subblock(y_plane, at, y_stride, sub_modes[n], above, left, y_plane[at - y_stride - 1]);
|
|
557
|
+
|
|
558
|
+
if (any_coefficient(coefficients, n * 16)) {
|
|
559
|
+
vp8_inverse_dct_add(coefficients, n * 16, y_plane, at, y_stride);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
} else {
|
|
563
|
+
vp8_predict_block(y_plane, y_at, y_stride, 16, y_mode, mb_y > 0, mb_x > 0);
|
|
564
|
+
|
|
565
|
+
for (let n = 0; n < 16; n++) {
|
|
566
|
+
if (any_coefficient(coefficients, n * 16)) {
|
|
567
|
+
vp8_inverse_dct_add(coefficients, n * 16, y_plane, y_at + (n >> 2) * 4 * y_stride + (n & 3) * 4, y_stride);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
const uv_at = (1 + mb_y * 8) * uv_stride + 1 + mb_x * 8;
|
|
573
|
+
|
|
574
|
+
for (let channel = 0; channel < 2; channel++) {
|
|
575
|
+
const plane = channel === 0 ? u_plane : v_plane;
|
|
576
|
+
|
|
577
|
+
vp8_predict_block(plane, uv_at, uv_stride, 8, uv_mode, mb_y > 0, mb_x > 0);
|
|
578
|
+
|
|
579
|
+
for (let n = 0; n < 4; n++) {
|
|
580
|
+
const from = 256 + channel * 64 + n * 16;
|
|
581
|
+
|
|
582
|
+
if (any_coefficient(coefficients, from)) {
|
|
583
|
+
vp8_inverse_dct_add(coefficients, from, plane, uv_at + (n >> 1) * 4 * uv_stride + (n & 1) * 4, uv_stride);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
if (filter_type !== 0) {
|
|
591
|
+
filter_frame(
|
|
592
|
+
y_plane, u_plane, v_plane, y_stride, uv_stride, mb_w, mb_h, filter_type, mb_segment, mb_is_4x4, mb_inner,
|
|
593
|
+
filter_strengths(use_segment, absolute_delta, segment_filter, filter_level, sharpness, use_filter_delta, reference_delta, mode_delta)
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
const data = vp8_yuv_to_rgba(y_plane, y_stride, y_stride + 1, u_plane, v_plane, uv_stride, uv_stride + 1, width, height);
|
|
598
|
+
|
|
599
|
+
return { width, height, data };
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* The loop filter's limits for each segment, for macroblocks predicted whole and in sub-blocks.
|
|
604
|
+
*
|
|
605
|
+
* @param {boolean} use_segment
|
|
606
|
+
* @param {boolean} absolute_delta
|
|
607
|
+
* @param {number[]} segment_filter
|
|
608
|
+
* @param {number} filter_level
|
|
609
|
+
* @param {number} sharpness
|
|
610
|
+
* @param {boolean} use_filter_delta
|
|
611
|
+
* @param {number[]} reference_delta
|
|
612
|
+
* @param {number[]} mode_delta
|
|
613
|
+
* @returns {{limit: number, interior: number, hev: number}[]} index `segment * 2 + is_4x4`; a limit of 0 filters nothing
|
|
614
|
+
*/
|
|
615
|
+
function filter_strengths(use_segment, absolute_delta, segment_filter, filter_level, sharpness, use_filter_delta, reference_delta, mode_delta) {
|
|
616
|
+
const strengths = [];
|
|
617
|
+
|
|
618
|
+
for (let s = 0; s < 4; s++) {
|
|
619
|
+
let base = filter_level;
|
|
620
|
+
|
|
621
|
+
if (use_segment) {
|
|
622
|
+
base = segment_filter[s] + (absolute_delta ? 0 : filter_level);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
for (let is_4x4 = 0; is_4x4 <= 1; is_4x4++) {
|
|
626
|
+
let level = base;
|
|
627
|
+
|
|
628
|
+
if (use_filter_delta) {
|
|
629
|
+
// an intra frame: the reference is the frame itself, and the only mode with a delta is B_PRED
|
|
630
|
+
level += reference_delta[0];
|
|
631
|
+
|
|
632
|
+
if (is_4x4 === 1) {
|
|
633
|
+
level += mode_delta[0];
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
level = clamp(level, 63);
|
|
638
|
+
|
|
639
|
+
if (level === 0) {
|
|
640
|
+
strengths.push({ limit: 0, interior: 0, hev: 0 });
|
|
641
|
+
continue;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
let interior = level;
|
|
645
|
+
|
|
646
|
+
if (sharpness > 0) {
|
|
647
|
+
interior >>= sharpness > 4 ? 2 : 1;
|
|
648
|
+
|
|
649
|
+
if (interior > 9 - sharpness) {
|
|
650
|
+
interior = 9 - sharpness;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
if (interior < 1) {
|
|
655
|
+
interior = 1;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
strengths.push({ limit: 2 * level + interior, interior, hev: level >= 40 ? 2 : level >= 15 ? 1 : 0 });
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
return strengths;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* The loop filter over the whole frame, macroblock by macroblock in raster order. Within one: its left edge, the edges
|
|
667
|
+
* inside it running down, its top edge, the edges inside it running across. The edges inside are filtered only where
|
|
668
|
+
* the macroblock was predicted in sub-blocks or has coefficients.
|
|
669
|
+
*
|
|
670
|
+
* @param {Uint8Array} y_plane
|
|
671
|
+
* @param {Uint8Array} u_plane
|
|
672
|
+
* @param {Uint8Array} v_plane
|
|
673
|
+
* @param {number} y_stride
|
|
674
|
+
* @param {number} uv_stride
|
|
675
|
+
* @param {number} mb_w
|
|
676
|
+
* @param {number} mb_h
|
|
677
|
+
* @param {number} filter_type 1 simple, 2 normal
|
|
678
|
+
* @param {Uint8Array} mb_segment
|
|
679
|
+
* @param {Uint8Array} mb_is_4x4
|
|
680
|
+
* @param {Uint8Array} mb_inner
|
|
681
|
+
* @param {{limit: number, interior: number, hev: number}[]} strengths
|
|
682
|
+
*/
|
|
683
|
+
function filter_frame(y_plane, u_plane, v_plane, y_stride, uv_stride, mb_w, mb_h, filter_type, mb_segment, mb_is_4x4, mb_inner, strengths) {
|
|
684
|
+
for (let mb_y = 0; mb_y < mb_h; mb_y++) {
|
|
685
|
+
for (let mb_x = 0; mb_x < mb_w; mb_x++) {
|
|
686
|
+
const mb = mb_y * mb_w + mb_x;
|
|
687
|
+
const strength = strengths[mb_segment[mb] * 2 + mb_is_4x4[mb]];
|
|
688
|
+
const limit = strength.limit;
|
|
689
|
+
|
|
690
|
+
if (limit === 0) {
|
|
691
|
+
continue;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
const inner = mb_inner[mb] === 1;
|
|
695
|
+
const y_at = (1 + mb_y * 16) * y_stride + 1 + mb_x * 16;
|
|
696
|
+
|
|
697
|
+
if (filter_type === 1) {
|
|
698
|
+
if (mb_x > 0) {
|
|
699
|
+
vp8_simple_filter_edge(y_plane, y_at, 1, y_stride, 16, limit + 4);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
if (inner) {
|
|
703
|
+
for (let k = 4; k < 16; k += 4) {
|
|
704
|
+
vp8_simple_filter_edge(y_plane, y_at + k, 1, y_stride, 16, limit);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
if (mb_y > 0) {
|
|
709
|
+
vp8_simple_filter_edge(y_plane, y_at, y_stride, 1, 16, limit + 4);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
if (inner) {
|
|
713
|
+
for (let k = 4; k < 16; k += 4) {
|
|
714
|
+
vp8_simple_filter_edge(y_plane, y_at + k * y_stride, y_stride, 1, 16, limit);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
continue;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
const interior = strength.interior;
|
|
722
|
+
const hev = strength.hev;
|
|
723
|
+
const uv_at = (1 + mb_y * 8) * uv_stride + 1 + mb_x * 8;
|
|
724
|
+
|
|
725
|
+
if (mb_x > 0) {
|
|
726
|
+
vp8_normal_filter_edge(y_plane, y_at, 1, y_stride, 16, limit + 4, interior, hev, true);
|
|
727
|
+
vp8_normal_filter_edge(u_plane, uv_at, 1, uv_stride, 8, limit + 4, interior, hev, true);
|
|
728
|
+
vp8_normal_filter_edge(v_plane, uv_at, 1, uv_stride, 8, limit + 4, interior, hev, true);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
if (inner) {
|
|
732
|
+
for (let k = 4; k < 16; k += 4) {
|
|
733
|
+
vp8_normal_filter_edge(y_plane, y_at + k, 1, y_stride, 16, limit, interior, hev, false);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
vp8_normal_filter_edge(u_plane, uv_at + 4, 1, uv_stride, 8, limit, interior, hev, false);
|
|
737
|
+
vp8_normal_filter_edge(v_plane, uv_at + 4, 1, uv_stride, 8, limit, interior, hev, false);
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
if (mb_y > 0) {
|
|
741
|
+
vp8_normal_filter_edge(y_plane, y_at, y_stride, 1, 16, limit + 4, interior, hev, true);
|
|
742
|
+
vp8_normal_filter_edge(u_plane, uv_at, uv_stride, 1, 8, limit + 4, interior, hev, true);
|
|
743
|
+
vp8_normal_filter_edge(v_plane, uv_at, uv_stride, 1, 8, limit + 4, interior, hev, true);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
if (inner) {
|
|
747
|
+
for (let k = 4; k < 16; k += 4) {
|
|
748
|
+
vp8_normal_filter_edge(y_plane, y_at + k * y_stride, y_stride, 1, 16, limit, interior, hev, false);
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
vp8_normal_filter_edge(u_plane, uv_at + 4 * uv_stride, uv_stride, 1, 8, limit, interior, hev, false);
|
|
752
|
+
vp8_normal_filter_edge(v_plane, uv_at + 4 * uv_stride, uv_stride, 1, 8, limit, interior, hev, false);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}
|