Skip to content
Closed
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
1 change: 1 addition & 0 deletions changelog.d/changed/0846-cpp23-read-json-model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- `core/src/read_json_model`: converted to C++23 (`read_json_model.cpp`, ADR-0846 Wave 8). `goto`-based teardown replaced with a scoped RAII guard; `unique_ptr<char[]>` for collection-name buffer; `std::string` for feature-option key copy; `[[nodiscard]]` on capacity helpers. No behaviour change; public C API and ABI unchanged.
13 changes: 12 additions & 1 deletion core/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,16 @@ libvmaf/
is `push_c()` at entry → body → `pop()` before the `ferror`
check; dropping the `pop()` leaks a `locale_t` on POSIX and
leaves the calling thread locked to `"C"` on Windows.
- **JSON model loader is now `read_json_model.cpp` (ADR-0846 / Wave 8).**
The active translation unit is [`src/read_json_model.cpp`](src/read_json_model.cpp),
compiled as the isolated `read_json_model_cpp23_lib` static lib
(`cpp_std=c++23`). The original [`src/read_json_model.c`](src/read_json_model.c)
is still on disk but is **not compiled** — the `libvmaf_sources` list replaced
it with a comment. Do not re-add `read_json_model.c` to `libvmaf_sources`;
doing so produces duplicate-symbol link errors for all four `extern "C"` entry
points. The `.c` file will be deleted in a follow-on cleanup PR.
- **JSON model loader has no fixed feature/knot schema ceiling.**
[`src/read_json_model.c`](src/read_json_model.c) grows
[`src/read_json_model.cpp`](src/read_json_model.cpp) grows
`VmafModel.feature` and `score_transform.knots.list` from the JSON
payload. Do not restore the old `MAX_FEATURE_COUNT` / `MAX_KNOT_COUNT`
rejection pattern during an upstream sync; external model JSONs with
Expand Down Expand Up @@ -457,6 +465,7 @@ the corrected methodology.
— `enable_avx512=true` with `enable_asm=false` issues a warning (no-op, not an error);
— `enable_hipcc=true` with `enable_hip=false` issues a warning (no-op, not an error).
The checks run at configuration time (before `subdir()` calls) to catch misconfigurations early. The principle: every option that depends on another must `error()` on the bad combo, never silently no-op. See [`src/meson.build` lines 100–111, 74–76, 142–144](src/meson.build).
<<<<<<< HEAD

- **C→C++23 conversion safety invariants** (adversarial review 2026-05-28,
`docs/research/cpp23-wave-adversarial-review-20260528.md`):
Expand Down Expand Up @@ -512,6 +521,8 @@ the corrected methodology.
The legacy path (`VmafFeatureExtractor`, line ~301) retains the mapping as
documented debt — tracked as T-LEGACY-RUNNER-ANSNR-BROKEN in `docs/state.md`.
The checks run at configuration time (before `subdir()` calls) to catch misconfigurations early. The principle: every option that depends on another must `error()` on the bad combo, never silently no-op. See [`src/meson.build` lines 100–111, 74–76, 142–144](src/meson.build).
=======
>>>>>>> 24bb5daf89 (docs: post-merge-train sweep — VMAFx + core/ path refs, ADR index, state.md)

## Performance benchmark invariant (ADR-0752)

Expand Down
35 changes: 19 additions & 16 deletions core/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -551,27 +551,13 @@ libvmaf_include = include_directories(
is_nvtx_enabled ? '/usr/local/cuda/include' : '',
)

# GCC/Clang accept `c++23`; MSVC needs `vc++latest`; Intel oneAPI on Windows
# (icx-cl, `intel-llvm-cl`) and clang-cl reject `c++23` and need plain
# `c++latest`. Pick the right token per compiler so override_options
# doesn't fail meson configure.
_cpp_id = meson.get_compiler('cpp').get_id()
if _cpp_id == 'msvc'
libvmaf_cpu_cpp_std = 'vc++latest'
elif _cpp_id == 'intel-llvm-cl' or _cpp_id == 'intel-cl' or _cpp_id == 'clang-cl'
libvmaf_cpu_cpp_std = 'c++latest'
else
libvmaf_cpu_cpp_std = 'c++23'
endif

libvmaf_cpu_static_lib = static_library(
'libvmaf_cpu',
libvmaf_cpu_sources,
include_directories : [libvmaf_include],
# ADR-0755: cpu.cpp uses constinit (C++20) and std::atomic; override
# cpp_std so this TU compiles under C++23 without affecting other TUs.
# ADR-0860: MSVC-vs-GCC/Clang cpp_std token disagreement workaround.
override_options : ['cpp_std=' + libvmaf_cpu_cpp_std],
override_options : ['cpp_std=c++23'],
)

platform_specific_cpu_objects = []
Expand Down Expand Up @@ -1535,6 +1521,21 @@ metadata_handler_cpp20_lib = static_library(
install : false,
)

# ADR-0846: read_json_model.cpp is a C++23 Wave 8 TU. Compiled as an isolated
# static lib so its cpp_std override (c++23) does not propagate to any other TU
# in libvmaf. Mirrors the ADR-0708 pattern for metadata_handler_cpp20_lib.
# The four public entry points retain their original C signatures and are
# declared extern "C" inside the .cpp, so all existing C callers link without
# modification.
read_json_model_cpp23_lib = static_library(
'read_json_model_cpp23',
src_dir + 'read_json_model.cpp',
include_directories : [vmaf_base_include, libvmaf_include],
override_options : ['cpp_std=c++23'],
pic : true,
install : false,
)

libvmaf_sources = [
src_dir + 'libvmaf.c',
src_dir + 'predict.c',
Expand All @@ -1547,7 +1548,7 @@ libvmaf_sources = [
src_dir + 'dict.c',
src_dir + 'opt.c',
src_dir + 'ref.c',
src_dir + 'read_json_model.c',
# read_json_model.cpp is compiled as read_json_model_cpp23_lib (ADR-0846)
src_dir + 'pdjson.c',
src_dir + 'log.c',
src_dir + 'framesync.c',
Expand Down Expand Up @@ -1636,6 +1637,8 @@ libvmaf = library(
libsvm_static_lib.extract_all_objects(recursive: true),
# ADR-0708: C++20 pilot TU compiled as isolated static lib.
metadata_handler_cpp20_lib.extract_all_objects(recursive: true),
# ADR-0846: C++23 Wave 8 TU — read_json_model.cpp.
read_json_model_cpp23_lib.extract_all_objects(recursive: true),
],
version : vmaf_soname_version,
soversion : vmaf_soversion,
Expand Down
Loading
Loading