mirror of
https://github.com/Nexoniarz/YAPF.git
synced 2026-11-03 04:54:26 +00:00
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:
parent
b9b8c93a22
commit
2ca726e3af
48 changed files with 14905 additions and 710 deletions
65
Makefile
Normal file
65
Makefile
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
# YAPF — simple build for Linux, macOS and other Unix systems.
|
||||
#
|
||||
# make library (static + shared) and the `yapf` tool, in build/
|
||||
# make test run the C test suite (and the JS one if node is present)
|
||||
# sudo make install install header, libraries and tool under $(PREFIX)
|
||||
# make NO_SIMD=1 plain C only
|
||||
#
|
||||
# Windows: use build.bat (LLVM) or any MinGW / MSVC compiler on yapf.c.
|
||||
|
||||
CC ?= cc
|
||||
CFLAGS ?= -O2
|
||||
PREFIX ?= /usr/local
|
||||
BUILD ?= build
|
||||
|
||||
YAPF_CFLAGS = -std=c99 -Wall -Wextra $(CFLAGS) $(if $(NO_SIMD),-DYAPF_NO_SIMD)
|
||||
LDLIBS = -lm -pthread
|
||||
|
||||
ifeq ($(shell uname -s),Darwin)
|
||||
SHARED = libyapf.dylib
|
||||
SHARED_FLAGS = -dynamiclib -install_name $(PREFIX)/lib/libyapf.dylib
|
||||
else
|
||||
SHARED = libyapf.so
|
||||
SHARED_FLAGS = -shared
|
||||
endif
|
||||
|
||||
all: $(BUILD)/libyapf.a $(BUILD)/$(SHARED) $(BUILD)/yapf
|
||||
|
||||
$(BUILD):
|
||||
mkdir -p $(BUILD)
|
||||
|
||||
$(BUILD)/yapf.o: yapf.c yapf.h | $(BUILD)
|
||||
$(CC) $(YAPF_CFLAGS) -fPIC -c yapf.c -o $@
|
||||
|
||||
$(BUILD)/libyapf.a: $(BUILD)/yapf.o
|
||||
$(AR) rcs $@ $^
|
||||
|
||||
$(BUILD)/$(SHARED): $(BUILD)/yapf.o
|
||||
$(CC) $(SHARED_FLAGS) $^ -o $@ -pthread
|
||||
|
||||
$(BUILD)/yapf: tools/yapf_cli.c yapf.c yapf.h | $(BUILD)
|
||||
$(CC) $(YAPF_CFLAGS) tools/yapf_cli.c yapf.c -o $@ $(LDLIBS)
|
||||
|
||||
$(BUILD)/test_yapf: tests/test_yapf.c yapf.c yapf.h | $(BUILD)
|
||||
$(CC) $(YAPF_CFLAGS) tests/test_yapf.c yapf.c -o $@ $(LDLIBS)
|
||||
|
||||
test: $(BUILD)/test_yapf
|
||||
$(BUILD)/test_yapf other/YAPF.YAPF
|
||||
@if command -v node >/dev/null 2>&1; then node bindings/js/test.js; \
|
||||
else echo "(node not found: skipped the JavaScript tests)"; fi
|
||||
|
||||
install: all
|
||||
install -d $(DESTDIR)$(PREFIX)/include $(DESTDIR)$(PREFIX)/lib $(DESTDIR)$(PREFIX)/bin
|
||||
install -m 644 yapf.h $(DESTDIR)$(PREFIX)/include/yapf.h
|
||||
install -m 644 $(BUILD)/libyapf.a $(DESTDIR)$(PREFIX)/lib/libyapf.a
|
||||
install -m 755 $(BUILD)/$(SHARED) $(DESTDIR)$(PREFIX)/lib/$(SHARED)
|
||||
install -m 755 $(BUILD)/yapf $(DESTDIR)$(PREFIX)/bin/yapf
|
||||
|
||||
uninstall:
|
||||
rm -f $(DESTDIR)$(PREFIX)/include/yapf.h $(DESTDIR)$(PREFIX)/lib/libyapf.a \
|
||||
$(DESTDIR)$(PREFIX)/lib/$(SHARED) $(DESTDIR)$(PREFIX)/bin/yapf
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD)
|
||||
|
||||
.PHONY: all test install uninstall clean
|
||||
Loading…
Reference in a new issue