Skip to content

refactor(core): cpp23 Wave 4 — output writers (ADR-0733) - #56

Merged
lusoris merged 1 commit into
masterfrom
feat/cpp23-wave4-output-writers-20260528
May 28, 2026
Merged

lusoris merged 1 commit into
masterfrom
feat/cpp23-wave4-output-writers-20260528

Conversation

@lusoris

@lusoris lusoris commented May 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Convert core/src/output.c → output.cpp as Wave 4 of the ADR-0708 C++23 internals migration
  • All four format writers (XML, JSON, CSV, MicroDVD subtitle) compiled under -std=c++23 via isolated static_library + override_options=['cpp_std=c++23']
  • Remove stale test_ansnr_simd meson.build entries blocking meson setup after the ADR-0720 ansnr drop

C++23 idioms applied

  • LocaleGuard RAII: vmaf_thread_locale_pop runs on destruction — cleanup guaranteed on all exit paths
  • std::string_view: score-format parameter threaded through all helpers, eliminating implicit strlen per write call
  • [[nodiscard]]: all four public entry points annotated
  • constexpr: pool_method_name[] and DEFAULT_SCORE_FORMAT
  • static_cast<VmafPoolingMethod>: explicit enum cast replacing implicit C unsigned→enum conversions
  • extern "C" wrapper: feature/alias.h, feature_collector.h, thread_locale.h wrapped at include site (they lack their own guards)

Deep-dive deliverables

  • Research digest: no digest needed: Wave 4 continues ADR-0708 playbook
  • Decision matrix: ADR-0733 ## Alternatives considered (per-file split vs bundle; std::ofstream vs FILE*; std::format vs printf-style)
  • core/AGENTS.md invariant: Wave 4 RAII pattern + extern "C" wrapper note + upstream rebase guidance
  • Reproducer / smoke test (see below)
  • changelog.d/changed/cpp23-wave4.md
  • docs/rebase-notes.md entry

Per-surface docs

no user-discoverable surface change — internal refactor; output schema bit-equivalent (verified via smoke test below)

Smoke test

# Build (CPU only, no GPU deps)
meson setup build -Denable_cuda=false -Denable_sycl=false -Denable_vulkan=disabled
ninja -C build

# XML output smoke (5 frames, Netflix golden YUV pair)
build/tools/vmaf \
  -r python/test/resource/yuv/src01_hrc00_576x324.yuv \
  -d python/test/resource/yuv/src01_hrc01_576x324.yuv \
  -w 576 -h 324 -p 420 -b 8 \
  -m version=vmaf_v0.6.1 \
  --output /tmp/out.xml --xml --frame_cnt 5

# JSON output smoke
build/tools/vmaf \
  -r python/test/resource/yuv/src01_hrc00_576x324.yuv \
  -d python/test/resource/yuv/src01_hrc01_576x324.yuv \
  -w 576 -h 324 -p 420 -b 8 \
  -m version=vmaf_v0.6.1 \
  --output /tmp/out.json --json --frame_cnt 5

# Fast test suite (49/49 pass)
meson test -C build --suite=fast

docs/state.md

no bug opened/closed/ruled-out — pure internal refactor

Merge-train note

Waves 1–3 in flight (PRs #41, #43, #44, #45, #48, #51, #54). This PR is independent of all of them (touches only output.c/.cpp, output.h, meson.build, and test/meson.build). No Vulkan-drop (#47) overlap confirmed (gh pr diff 47 --name-only | grep output → no output).

🤖 Generated with Claude Code

@lusoris
lusoris marked this pull request as ready for review May 28, 2026 17:28
@lusoris
lusoris enabled auto-merge (squash) May 28, 2026 17:28
@lusoris
lusoris force-pushed the feat/cpp23-wave4-output-writers-20260528 branch 2 times, most recently from 7f5aff0 to 8aeab24 Compare May 28, 2026 19:36
Convert core/src/output.c → output.cpp as Wave 4 of the ADR-0708 C++23
internals migration. All four format writers (XML, JSON, CSV, MicroDVD
subtitle) compiled under std=c++23 via an isolated static_library with
override_options=['cpp_std=c++23'], matching the Wave 1/3 pattern.

C++23 idioms applied:
- LocaleGuard RAII: vmaf_thread_locale_pop runs on destruction, removing
  the manual push/pop pair and guarding against future early returns.
- std::string_view: score-format parameter threaded through all helpers,
  eliminating implicit strlen per write call.
- [[nodiscard]] on all four public entry points.
- constexpr pool_method_name / DEFAULT_SCORE_FORMAT.
- static_cast<VmafPoolingMethod> for the unsigned→enum loop variable.
- extern "C" wrapper in output.cpp for the internal C headers that lack
  their own guards (feature/alias.h, feature_collector.h, thread_locale.h).

Public C ABI and output bytes are bit-identical (test_output pass,
49/49 fast suite pass, XML/JSON smoke test against Netflix golden YUV).

Also removes stale test_ansnr_simd entries from core/test/meson.build
that blocked meson setup after the ansnr feature drop (ADR-0720).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lusoris
lusoris force-pushed the feat/cpp23-wave4-output-writers-20260528 branch from 8aeab24 to f7e7100 Compare May 28, 2026 21:57
@lusoris
lusoris merged commit e73dd94 into master May 28, 2026
46 of 63 checks passed
@lusoris
lusoris deleted the feat/cpp23-wave4-output-writers-20260528 branch May 28, 2026 22:35
@lusoris lusoris added this to the 1.0.0 — First release milestone Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant