Imported from garbsam97/RAW_DEV (
AGENTS.md). Install upstream withnpx skills add garbsam97/RAW_DEV. Copyright stays with the author.
AGENTS.md
Scope and source of truth
- This repo is a C++20 RAW-processing playground centered on
rawdev_core; most exercised behavior still lives in tests. - The GUI direction is
src/gui/, which is reserved for Qt6-based interface code. - Treat tracked files under root,
src/, andtests/as source of truth; ignorecmake-build-debug/for design decisions. - Root
main.cppis not part of any target.
Build graph that is actually wired
- Root
CMakeLists.txtadds onlysrc/andtests/; testing is globally enabled. src/core/buildsrawdev_corefrom image, pipeline, PNG writer, and stage sources (white balance, black level, color matrix, gamma correction, tone mapping, sRGB color transform).src/cli/buildsrawdev_clifrommain.cpp,cli_options.*, andcli_runner.*; it linksrawdev_coreand now supports end-to-endprocessexecution on real input/output paths through the core facade.src/gui/buildsrawdev_guias a Qt6 executable (qt_add_executable) frommain_gui.cpp,main_window.*,widgets/image_view_widget.*, andcontrollers/app_controller.*.src/modules/linksrawdev_coreagainstlibraw::librawviasrc/modules/libraw-cmake; RAW ingestion is now implemented insrc/core/src/coreapi/import.cpp.tests/buildsrawdev_tests(GoogleTest IO/pipeline/golden/coreapi/CLI/LLVM suite) andrawdev_benchmarks(lightweight performance harness).
Core architecture and data flow
- Public headers live in
src/core/include/rawdev/...; implementations live insrc/core/src/.... rawdev::image::Image(src/core/include/rawdev/image/image.h) owns RGB data instd::vector<float>sizedw * h * 3.- Memory layout is interleaved RGB, not planar:
Image::view()buildsImageView(data, w, h, 3, w * 3)andImageView::at(x,y,c)indexesy*stride + x*channels + c. rawdev::pipeline::Pipeline(src/core/src/pipeline/pipeline.cpp) uses fast paths for empty pipelines and single in-place-capable stages, otherwise ping-pongs twoImageViews (original + scratch buffer) acrossProcessingStages, then copies back if needed.Pipeline::supportsInPlace()is now used byexecute()for the single-stage in-place fast path.- Current stages:
WhiteBalanceStage,BlackLevelStage,ColorMatrixStage,GammaCorrectionStage,ToneMappingStage,ColorTransformSrgbStage. ToneMappingStagenow has a guarded OpenMP path on a safe pixel loop whenRAWDEV_USE_OPENMP=1; serial fallback remains the default behavior when OpenMP is unavailable.ProcessingStagecontract insrc/core/include/rawdev/pipeline/pipeline.hnow documents shape invariants and in-place expectations; contract tests are intests/pipeline/test_stage_contracts.cpp.rawdev::coreapi::importRawImage(src/core/include/rawdev/coreapi/import.h) is the core-facing LibRaw import boundary that maps RAW decode failures to stable core-level errors.rawdev::coreapi::processImage(src/core/include/rawdev/coreapi/process.h) is the current high-level processing facade; it still supports in-memory input and can now also import RAW files viaProcessRequest::inputRawPath.- Golden fixtures under
tests/golden/fixtures/now provide deterministic seed images for stage golden tests, and regression coverage includes interleaved layout plus pipeline copy-back checks. - Additional regression coverage includes OpenMP tone-mapping parity (
tests/pipeline/test_openmp_tone_mapping_parity.cpp) and RAW import success/failure (tests/io/test_raw_import.cpp). - Benchmark baselines are tracked under
tests/benchmark/for reproducible median-based comparisons.
GUI boundary (Qt6)
- Keep GUI concerns in
src/gui/; keep image processing and reusable logic inrawdev_core. - Current GUI scaffolding splits responsibilities by layer:
main_gui.cpp: Qt app bootstrapmain_window.*: window composition and actionscontrollers/app_controller.*: GUI-to-core orchestrationwidgets/image_view_widget.*: preview widget surface
- Current phase-1 GUI wiring keeps minimal app state in
AppController(hasImage_,currentPath_,lastStatus_) and updates UI viastatusMessageChanged/imageAvailabilityChangedsignals;Run Pipelinestarts disabled until an image is marked as loaded. - Current phase-2 GUI preview adds
ImageViewWidget::setImage(...),clearImage(),hasImage(), and fit-centered rendering inpaintEvent(...). - Current phase-3 GUI adapter wiring converts core images through
rawdev::gui::adapters::toQImage(...)inAppController::openRaw()and updates preview throughpreviewImageChanged. - Prefer calling
rawdev_corefrom GUI adapters/controllers instead of embedding processing logic inside Qt widgets. - Avoid introducing Qt types in public
rawdev_coreheaders unless explicitly required by architecture changes.
CLI boundary
- Keep CLI-specific argument parsing and user-facing messages in
src/cli/. - Current CLI scaffolding splits responsibilities by file:
main.cpp: argv collection + command dispatchcli_options.*: command-line parsing (ParsedCommand,ProcessOptions)cli_runner.*: command execution flow and exit codes
- Treat
cli_runneras the integration boundary towardrawdev_core; keep reusable processing logic in core. - Current
processpath is integrated withrawdev::coreapi::processImageusing real--input/--outputpaths (inputRawPath+ PNG write).--white-balanceis now parsed as a typedr,g,btriplet with strict validation.
External dependencies and toolchain gotchas
- Git submodules in
.gitmodules:src/modules/libraw(0.22-stable),src/modules/libraw-cmake,src/modules/llvm(release/22.x). rawdev_coreusesfind_package(OpenMP)and definesRAWDEV_USE_OPENMP=1only when OpenMP is found.- On macOS/CLion, OpenMP may require
-DOpenMP_ROOT=/opt/homebrew/opt/libomp. tests/CMakeLists.txtrequires LLVM viafind_package(LLVM REQUIRED CONFIG)and linksCore,OrcJIT,ExecutionEngine,Support,native.- If CLion cannot find LLVM, set
LLVM_DIRto a folder containingLLVMConfig.cmake(commonly.../dist/lib/cmake/llvm). src/gui/CMakeLists.txtrequires Qt6 componentsCore,Gui,Widgets.- Keep strict warnings on first-party code; suppress third-party warning noise at integration points instead of weakening global flags.
Developer workflow in this workspace
- Default workflow is CLion-first: reload/update CMake from CLion, then build/run
rawdev_tests,rawdev_benchmarks,rawdev_cli, orrawdev_gui. - CLI fallback:
cmake -S . -B build cmake --build build ctest --test-dir build --output-on-failure - Benchmark fallback:
cmake --build build --target rawdev_benchmarks ./build/tests/benchmark/rawdev_benchmarks --out tests/benchmark/baseline_0.3.0-alpha.csv --runs 20 --warmup 5 --max-size 4096 --tag m5-baseline-macos - GoogleTest is fetched with
FetchContentat tagv1.14.0; test discovery usesgtest_discover_tests(rawdev_tests).
Project conventions to preserve
- Keep established target names:
rawdev_core,rawdev_cli,rawdev_gui,rawdev_tests,rawdev_benchmarks. - Prefer adding reusable functionality to
rawdev_corefirst, then covering it in tests before wiring CLI/GUI. - Keep GUI scaffolding modular (
main_window,controllers,widgets) and treat controllers as the boundary towardrawdev_core. - Use public include paths like
#include "rawdev/image/image.h"; avoid relative includes in new public headers. - Mirror new features with focused tests under
tests/io/,tests/pipeline/,tests/golden/,tests/coreapi/,tests/cli/,tests/llvm/, and benchmark additions undertests/benchmark/. - When writing tests over
Image::data, keep channel indexing consistent with interleaved RGB layout. - Follow Semantic Versioning for project releases; current pre-release line is
0.4.2-alpha.
Existing instruction sources discovered
AGENTS.mdREADME.mdtests/benchmark/README.mdsrc/modules/libraw/README.mdsrc/modules/libraw/RawSpeed3/README.mdsrc/modules/libraw-cmake/README.mdsrc/modules/llvm/README.md