YAPF v1: fast byte-aligned format, SIMD, tools and plugins

Format (version 1, replaces the earlier experimental versions):
- per-tile YCoCg-R or subtract-green colour transform, 8-bit modular
- 12 row filters per 8-row band (Left, Gradient, Up-right, Up-average,
  Up 1-8 rows), none with more than a one-add serial dependency
- residuals in groups of 8 at the group's width (w bits x 8 = w bytes),
  4-bit control codes with repeat-previous-width runs chosen by DP
- constant and stored tiles, independent 64x64 tiles, mips, GPU hints
- all sizes validated before decoding; corrupt input is rejected

Library:
- SIMD on by default: SSSE3 (runtime CPUID check; GCC, Clang, MSVC,
  MinGW) and NEON on ARM64; -DYAPF_NO_SIMD for plain C
- yapf_load_memory, yapf_load_mt, yapf_load_memory_mt
- 6-10x faster decoding than PNG (stb_image) on one core; -O2 and -O3
  builds perform the same
- fixes for macOS (sysconf) and the Windows import library exports

Tools and integrations:
- `yapf` CLI: convert PNG/JPG/TGA/BMP/PSD/GIF <-> YAPF, info, bench,
  thumbnail, mips
- JavaScript and Python bindings (byte-identical to the C encoder)
- GIMP 3 plugin: exports the flattened image, optional mipmaps
- Blender extension: import (also as plane), export, drag and drop
- VS Code preview, Figma plugin, Photoshop scripts, Linux MIME type and
  thumbnailer
- Makefile, updated build.sh / build.bat, tools/build_release.sh
- tests/test_yapf.c (784 checks) and bindings/js/test.js

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nexoniarz 2026-10-03 14:17:59 +02:00
commit 2ca726e3af
48 changed files with 14905 additions and 710 deletions

View file

@ -10,7 +10,7 @@ setlocal enabledelayedexpansion
::
:: Options:
:: --debug Debug build (no optimisation, full symbols)
:: --simd Enable SIMD paths (-DYAPF_USE_SIMD)
:: --no-simd Plain C only (SIMD is on by default, picked at run time)
:: --static-only Build only static libraries
:: --shared-only Build only shared libraries (DLL)
:: --help Show this message
@ -45,13 +45,13 @@ if !ANSI_OK!==1 (
:: ── Option parsing ───────────────────────────────────────────────────
set OPT_DEBUG=0
set OPT_SIMD=0
set OPT_NOSIMD=0
set OPT_STATIC_ONLY=0
set OPT_SHARED_ONLY=0
for %%A in (%*) do (
if /i "%%A"=="--debug" set OPT_DEBUG=1
if /i "%%A"=="--simd" set OPT_SIMD=1
if /i "%%A"=="--no-simd" set OPT_NOSIMD=1
if /i "%%A"=="--static-only" set OPT_STATIC_ONLY=1
if /i "%%A"=="--shared-only" set OPT_SHARED_ONLY=1
if /i "%%A"=="--help" goto :show_help
@ -115,9 +115,11 @@ if !OPT_DEBUG!==1 (
echo !C_CYN![info]!C_RST! Mode : release
)
if !OPT_SIMD!==1 (
set CFLAGS=!CFLAGS! -DYAPF_USE_SIMD
echo !C_CYN![info]!C_RST! SIMD : enabled
if !OPT_NOSIMD!==1 (
set CFLAGS=!CFLAGS! -DYAPF_NO_SIMD
echo !C_CYN![info]!C_RST! SIMD : disabled
) else (
echo !C_CYN![info]!C_RST! SIMD : SSSE3 / NEON, chosen at run time
)
set BUILD_SHARED=1
@ -139,6 +141,9 @@ echo !C_GRN![ ok ]!C_RST! Header ^→ dist\include\yapf.h
echo LIBRARY yapf
echo EXPORTS
echo yapf_load
echo yapf_load_memory
echo yapf_load_mt
echo yapf_load_memory_mt
echo yapf_save
echo yapf_free
) > dist\_yapf.def
@ -183,6 +188,15 @@ if !BUILD_STATIC!==1 (
echo !C_GRN![ ok ]!C_RST! dist\windows-x64\libyapf.a (static)
)
:: Command-line tool
clang --target=x86_64-w64-windows-gnu !CFLAGS! !LFLAGS! -Wno-unused-function ^
tools\yapf_cli.c yapf.c -o dist\windows-x64\yapf.exe
if errorlevel 1 (
echo !C_YLW![warn]!C_RST! yapf.exe build failed (non-fatal)
) else (
echo !C_GRN![ ok ]!C_RST! dist\windows-x64\yapf.exe (command-line tool)
)
:: ====================================================================
:: Build: Windows ARM64
:: ====================================================================
@ -227,6 +241,10 @@ if !BUILD_STATIC!==1 (
)
)
clang --target=aarch64-w64-windows-gnu !CFLAGS! !LFLAGS! -Wno-unused-function ^
tools\yapf_cli.c yapf.c -o dist\windows-arm64\yapf.exe
if not errorlevel 1 echo !C_GRN![ ok ]!C_RST! dist\windows-arm64\yapf.exe (command-line tool)
:skip_arm64
:: ── Cleanup temp files ───────────────────────────────────────────────