Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,20 @@ gamma-encoded. If you touch either function, keep them in sync.

## Native RAW processor build paths

The canonical C source is `lib/ffi/raw/raw_processor_common.{c,h}`. Three
consumers include/compile it:
The canonical C source is `lib/ffi/raw/raw_processor_common.{c,h}`. All four
consumers compile a tiny wrapper that `#include`s it:

- Production Linux build (CMake) — `linux/raw_processor/raw_processor_wrapper.c`
which `#include`s `../../lib/ffi/raw/raw_processor_common.c`.
- Production Linux build (CMake) — `linux/raw_processor/raw_processor_wrapper.c`.
- Test libraries (`scripts/build_test_libs.sh`) — same wrapper.
- Flatpak (`dev.myyc.aks.yaml`) — same wrapper.
- macOS (`macos/raw_processor/raw_processor.c`) — **standalone copy**, not
wrapped. If you change the common source, mirror it here too or convert
macOS to use a wrapper the same way.
- macOS (`macos/raw_processor/raw_processor_wrapper.c`) — same wrapper.
`macos/build.sh` and `macos/Makefile` pass `-I../lib/ffi/raw` so the
canonical header is picked up; Xcode's "Build Native Libraries" phase
lists the wrapper + canonical `.c`/`.h` as input dependencies.

All three Linux paths were consolidated onto the wrapper in the
`refactor/cleanup-and-imagestate` branch; prior to that, stale duplicates
at `linux/raw_processor/raw_processor.c` kept drifting.
Consolidation history: Linux paths were unified on the
`refactor/cleanup-and-imagestate` branch; macOS was migrated on the
follow-up `followup/macos-parity-and-tone-curve-test` branch.

## Histogram

Expand Down
25 changes: 13 additions & 12 deletions linux/vulkan_processor/shaders/image_process.comp
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,22 @@ vec3 applyToneCurves(vec3 color) {
if (params.toneCurveEnabled == 0.0) {
return color;
}

// Convert to 0-255 range
ivec3 indices = ivec3(clamp(color * 255.0, 0.0, 255.0));

// Apply RGB master curve first
indices.r = int(getLutValue(rgbLut.data, uint(indices.r)));
indices.g = int(getLutValue(rgbLut.data, uint(indices.g)));
indices.b = int(getLutValue(rgbLut.data, uint(indices.b)));

// Then apply individual channel curves

// Round (not truncate) when sampling the 256-entry byte LUTs so
// colour 0.50196 (which is byte 128) hits index 128, not 127.
ivec3 indices = ivec3(clamp(color * 255.0 + 0.5, 0.0, 255.0));

// Must match the CPU order (cpu_processor.dart:_applyToneCurve):
// per-channel first, then master RGB. The two orders are not
// commutative for non-identity curves.
indices.r = int(getLutValue(redLut.data, uint(indices.r)));
indices.g = int(getLutValue(greenLut.data, uint(indices.g)));
indices.b = int(getLutValue(blueLut.data, uint(indices.b)));

// Convert back to 0-1 range

indices.r = int(getLutValue(rgbLut.data, uint(indices.r)));
indices.g = int(getLutValue(rgbLut.data, uint(indices.g)));
indices.b = int(getLutValue(rgbLut.data, uint(indices.b)));

return vec3(indices) / 255.0;
}

Expand Down
5 changes: 3 additions & 2 deletions macos/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ BUILD_DIR = .
# Targets
all: libraw_processor.dylib

libraw_processor.dylib: raw_processor/raw_processor.c
libraw_processor.dylib: raw_processor/raw_processor_wrapper.c ../lib/ffi/raw/raw_processor_common.c
$(CC) $(CFLAGS) -o $(BUILD_DIR)/libraw_processor.dylib \
raw_processor/raw_processor.c \
raw_processor/raw_processor_wrapper.c \
-I../lib/ffi/raw \
$(LIBRAW_FLAGS) -lm

clean:
Expand Down
5 changes: 3 additions & 2 deletions macos/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,9 @@
inputFileListPaths = (
);
inputPaths = (
"$(SRCROOT)/raw_processor/raw_processor.c",
"$(SRCROOT)/raw_processor/raw_processor.h",
"$(SRCROOT)/raw_processor/raw_processor_wrapper.c",
"$(SRCROOT)/../lib/ffi/raw/raw_processor_common.c",
"$(SRCROOT)/../lib/ffi/raw/raw_processor_common.h",
);
name = "Build Native Libraries";
outputFileListPaths = (
Expand Down
9 changes: 7 additions & 2 deletions macos/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,13 @@ if [ -n "$LIBRAW_STATIC" ]; then

# Set minimum macOS version to match system libraries
# Use 12.0 as a reasonable minimum that supports both Intel and Apple Silicon
# Source is the wrapper which includes the canonical C file at
# ../lib/ffi/raw/raw_processor_common.c — shared across Linux / macOS /
# Flatpak so the FFI surface never drifts across platforms.
clang -shared -fPIC -o libraw_processor.dylib \
-mmacosx-version-min=12.0 \
raw_processor/raw_processor.c \
raw_processor/raw_processor_wrapper.c \
-I"../lib/ffi/raw" \
-I"$LIBRAW_INCLUDE" \
"$LIBRAW_STATIC" \
$JPEG_LIB \
Expand All @@ -99,7 +103,8 @@ else
echo -e "${YELLOW}Using dynamic linking for libraw (may have dependency issues)${NC}"
clang -shared -fPIC -o libraw_processor.dylib \
-mmacosx-version-min=12.0 \
raw_processor/raw_processor.c \
raw_processor/raw_processor_wrapper.c \
-I"../lib/ffi/raw" \
-I"$LIBRAW_INCLUDE" -L"$LIBRAW_LIB" -lraw -lm \
-Wl,-rpath,@loader_path
fi
Expand Down
222 changes: 0 additions & 222 deletions macos/raw_processor/raw_processor.c

This file was deleted.

Loading
Loading