Skip to content

feat(vmaf-tune): ADR-0498 follow-up #7 — encoder stats, x264 detection, backend dispatch, codec-list parser - #573

Merged
lusoris merged 4 commits into
masterfrom
feat/vmaf-tune-adr-0498-followup-7
Jun 3, 2026
Merged

lusoris merged 4 commits into
masterfrom
feat/vmaf-tune-adr-0498-followup-7

Conversation

@lusoris

@lusoris lusoris commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Sub-task 1 (x264/x265/libvpx detection): extend _VERSION_PROBE_PATTERNS to cover libx265 and libvpx-vp9 in addition to the existing entries; add EncoderInfo dataclass (encoder, codec_detected: bool, version_label: str) and probe_encoder_info() public helper so callers check codec_detected instead of parsing the version string.
  • Sub-task 2 (stats-file regression): remove duplicate fallback_duration assignment in build_pass1_stats_command (dead first write left by the fix(build): stop VMAF_VERSION degrading to a bare commit abbreviation #1266 refactor; second identical assignment overwrote it immediately).
  • Sub-task 3 (backend dispatch): add backend kwarg to _build_production_sample_extractor and forward it to run_score; _build_prod_predictor and fast_recommend forward the backend selected by score_backend.select_backend so all 30 TPE probe-encode trials score on GPU when available. Remove dead _ = backend stub from _gpu_verify.
  • Sub-task 4 (codec-list parser): implement codec_adapters.parse_available_codecs(stdout, *, restrict_to_known=True) that parses ffmpeg -hide_banner -encoders into a frozenset of available codec names.

Test plan

  • pytest tools/vmaf-tune/tests/test_adr_0498_followup7.py — 16 new tests, all pass.
  • pytest tools/vmaf-tune/tests/test_encoder_stats_capture_x264.py — existing stats-capture tests still pass.
  • pytest tools/vmaf-tune/tests/test_bbb_e2e_v2_bug_cluster.py — existing probe-cache tests still pass.
  • pytest tools/vmaf-tune/tests/test_encode_dispatcher_per_adapter.py — all pass after fix to capture first subprocess call only.
  • pytest tools/vmaf-tune/tests/test_fast.py — all pass.
  • Full suite: 1499 passed, 16 skipped, 2 xfailed (pre-existing test_format_both_json.py failure unrelated to this PR).

Reproducer / smoke test

# Sub-task 1
python -c "from vmaftune.encode import probe_encoder_info; print(probe_encoder_info.__doc__)"

# Sub-task 4
python -c "from vmaftune.codec_adapters import parse_available_codecs; print(parse_available_codecs.__doc__)"

# All tests
pytest tools/vmaf-tune/tests/test_adr_0498_followup7.py -v

ADR-0108 deliverables checklist

  • Research digest: no digest needed: trivial (all four sub-tasks are bug fixes / follow-up implementations with one obvious approach each)
  • Decision matrix: no alternatives: only-one-way fix (duplicate assignment removal, probe pattern extension, backend kwarg forwarding, codec-list parser are all single-path implementations)
  • AGENTS.md invariant note: tools/vmaf-tune/AGENTS.md updated with probe-cache expansion, backend kwarg, and codec-list parser invariants
  • Reproducer / smoke-test command: see Test plan above
  • Changelog fragment: changelog.d/fixed/0498-vmaf-tune-adr-0498-followup7.md
  • Rebase-notes entry: docs/rebase-notes.md — no rebase impact (all changes fork-local to tools/vmaf-tune/)

State.md

No bugs opened or closed by this PR; no state.md update required.

ffmpeg-patches

No public C-API surfaces, CLI flags, or meson_options.txt entries touched; no patch update required.

Semgrep note

The semgrep-local hook was skipped via SKIP=semgrep-local due to a pre-existing io_uring_queue_init memory allocation failure in the dev environment (documented in .pre-commit-config.yaml lines 241-275 as a known system RLIMIT_MEMLOCK issue). Manual verification via python -m semgrep --config .semgrep.yml --error --quiet --jobs 1 <files> returns exit 0 on all changed files.

🤖 Generated with Claude Code

Lusoris and others added 4 commits June 3, 2026 23:35
…llow-up #7)

Extend _VERSION_PROBE_PATTERNS to cover libx265 and libvpx-vp9 in addition
to the existing libx264 and libsvtav1 entries, so _probe_encoder_version_from_ffmpeg
can detect all three software encoder families from the ffmpeg -version
configure summary.

Add EncoderInfo dataclass (encoder, codec_detected: bool, version_label: str)
and the public probe_encoder_info() helper that returns it. Callers can now
check codec_detected directly instead of parsing the version label string.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ollow-up #7)

_build_production_sample_extractor now accepts a backend kwarg and forwards
it to run_score, so all 30 TPE probe-encode trials score on the same GPU
backend as the mandatory verify pass. Previously the extractor always
defaulted to CPU even when a GPU was available.

_build_prod_predictor gains a backend kwarg forwarded to the extractor.
fast_recommend (production path) calls select_backend once and passes the
result to both the predictor and the verify pass.

Remove the dead _ = backend stub from _gpu_verify that was left over from
before the encode_runner forwarding was implemented.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… follow-up #7)

Add codec_adapters.parse_available_codecs(stdout, *, restrict_to_known=True)
that parses ffmpeg -hide_banner -encoders output into a frozenset of available
codec names. This is the codec-list parser that was deferred from the initial
codec_adapters scaffolding ("parser arrives in a follow-up").

When restrict_to_known=True (default) only names in the adapter registry are
returned; set False to get the full encoder list. Also update the
supports_encoder_stats Protocol comment to remove the "parser arrives in a
follow-up PR" placeholder and clarify the current state (x264+x265 text
formats supported; libvpx binary format deferred).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add test_adr_0498_followup7.py covering all four sub-tasks:
- EncoderInfo fields and probe_encoder_info detection for x264/x265/libvpx-vp9
- _VERSION_PROBE_PATTERNS coverage assertions
- build_pass1_stats_command duplicate-fallback_duration removal regression
- _build_production_sample_extractor backend parameter signature
- _gpu_verify dead stub removal via source inspection
- backend forwarding to run_score via mock injection
- parse_available_codecs parsing and frozenset contract

Fix test_encode_dispatcher_per_adapter to capture only the first subprocess
call (the encode argv); the probe-cache expansion for libvpx-vp9 adds a
second ffmpeg -version call that would otherwise overwrite the captured cmd.

ADR-0108 deliverables:
- changelog.d/fixed/0498-vmaf-tune-adr-0498-followup7.md
- docs/rebase-notes.md (no rebase impact, all changes fork-local)
- AGENTS.md invariant notes for probe-cache expansion, backend kwarg, parser

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lusoris
lusoris force-pushed the feat/vmaf-tune-adr-0498-followup-7 branch from 9cb4054 to c470023 Compare June 3, 2026 21:40
@lusoris
lusoris marked this pull request as ready for review June 3, 2026 21:40
Copilot AI review requested due to automatic review settings June 3, 2026 21:40
@lusoris
lusoris merged commit ecb019a into master Jun 3, 2026
59 of 96 checks passed
@lusoris
lusoris deleted the feat/vmaf-tune-adr-0498-followup-7 branch June 3, 2026 21:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR is a vmaf-tune follow-up for ADR-0498 that tightens encoder capability probing, fixes a pass-1 stats command regression, ensures fast-path proxy trials score on the selected libvmaf backend, and adds an ffmpeg encoder-list parser to gate codec-specific behavior on runtime availability.

Changes:

  • Add structured encoder probe results (EncoderInfo + probe_encoder_info) and extend _VERSION_PROBE_PATTERNS to include libx265 and libvpx-vp9.
  • Forward the selected scoring backend through the fast-path production sample extractor so TPE probe trials can score on GPU backends when available.
  • Introduce codec_adapters.parse_available_codecs() to parse ffmpeg -hide_banner -encoders output into an available-codec set, and add regression tests.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tools/vmaf-tune/src/vmaftune/encode.py Extends encoder configure-flag probing and adds EncoderInfo + probe_encoder_info; removes duplicate fallback_duration assignment.
tools/vmaf-tune/src/vmaftune/fast.py Threads a backend kwarg into the production sample extractor and forwards it to run_score.
tools/vmaf-tune/src/vmaftune/codec_adapters/init.py Adds parse_available_codecs() and updates codec stats-support documentation.
tools/vmaf-tune/tests/test_encode_dispatcher_per_adapter.py Stabilizes subprocess argv capture by ignoring the follow-up ffmpeg -version probe call.
tools/vmaf-tune/tests/test_adr_0498_followup7.py Adds regression coverage for all four sub-tasks (encoder probe, stats command, backend forwarding, codec parser).
tools/vmaf-tune/AGENTS.md Documents new invariants for probing, backend forwarding, and codec parsing.
docs/rebase-notes.md Records fork-local rebase impact notes for this feature.
changelog.d/fixed/0498-vmaf-tune-adr-0498-followup7.md Adds changelog entry for the fixes and new helper/parser.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +233 to +235
flags, name = tokens[0], tokens[1]
if len(flags) >= 1 and flags[0] in ("V", "A", "S"):
found.add(name)
Comment on lines 652 to 654
sample_extractor=sample_extractor,
backend=_prod_backend,
)
Comment on lines +230 to +236
return ScoreResult(
request=req,
vmaf_score=85.0,
feature_means={},
exit_status=0,
stderr_tail="",
)
Comment on lines +331 to +332
result = parse_available_codecs(_SAMPLE_FFMPEG_ENCODERS, restrict_to_known=False)
assert "libx264rgb" in result
@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.

2 participants