1 Commits

Author SHA1 Message Date
claude-noether 3e996d09e2 iter1 Phase 4: plan — contract clauses, diff scope, Phase 7 harness
Phase 4 plan for the iter1 MPEG-2 fix, structured per the
feedback_dev_process.md Phase 6 contract-before-code worked example
(0012-h264-omit-scaling-matrix-frame-based.patch shape):
contract clauses with citations first, then code changes mapping
1:1 to clauses.

Phase 1 criterion #3 re-locked per Phase 3 → Phase 1 loopback:

  Original: "mpv --hwdec=vaapi-copy ... engages backend"
  Adjusted: "ffmpeg -hwaccel vaapi ... engages backend"

  Phase 3 Baseline A established mpv silently filters MPEG-2 out
  before libva is loaded; the original wording was unfalsifiable.
  ffmpeg-direct exercises the path. mpv-driven testing → separate
  follow-up task.

Other 4 criteria unchanged (vainfo regression, vaCreateConfig
SUCCESS, DMA-BUF GL pixel verify HW=SW at +02s, T4 H.264
regression).

Six contract clauses cited from authoritative sources:

  Clause 1 — Three split controls in one batched VIDIOC_S_EXT_CTRLS
    Authority: linux/v4l2-controls.h:1988-2105
    Reference impl: FFmpeg libavcodec/v4l2_request_mpeg2.c:130-155
    Empirical anchor: Phase 3 Baseline C verbatim payload

  Clause 2 — v4l2_ctrl_mpeg2_sequence layout (12 bytes)
    Authority: linux/v4l2-controls.h:2009-2017
    Field-by-field VAAPI source mapping table
    Note: progressive_frame is used as proxy for progressive_sequence
          (VAAPI doesn't expose the latter; same bit for BBB).

  Clause 3 — v4l2_ctrl_mpeg2_picture layout (32 bytes)
    Authority: linux/v4l2-controls.h:2056-2065
    reserved[5] MUST be zeroed (kernel doc 2052)
    8 picture flags decoded; field-by-field VAAPI mapping

  Clause 4 — v4l2_ctrl_mpeg2_quantisation layout (256 bytes)
    Authority: linux/v4l2-controls.h:2089-2096
    Matrices in zigzag scanning order; no permutation in libva backend
    (kernel hantro_mpeg2_dec_copy_qtable handles zigzag-to-raster)
    Decision: when iqmatrix_set is false, populate from MPEG-2 spec
    defaults (ISO/IEC 13818-2 Table 7-3) to avoid kernel rejecting
    a batch missing the QUANTISATION control.

  Clause 5 — Per-frame submission via v4l2_set_controls
    Authority: existing src/h264.c:986 pattern
    surface_object->request_fd binds controls to per-surface request

  Clause 6 — config.c MPEG-2 case must break;
    Authority: C semantics; H.264 case shape at config.c:62-63
    Empirical anchor: Phase 3 Baseline B confirmed scratch-fix shape.

Diff scope:

  src/config.c    — 3 lines added (break for MPEG-2 cases) + drop
                    stale #include <mpeg2-ctrls.h>
  src/mpeg2.c     — full rewrite of mpeg2_set_controls against new
                    split API; ~120 lines replaced; switches from
                    2× v4l2_set_control(single) to 1× batched
                    v4l2_set_controls(3-control array)
  include/mpeg2-ctrls.h — DELETE (staging-era, masks kernel UAPI)
  src/picture.c, src/context.c, meson.build — no changes
                    (verified Phase 2 + Phase 3)

Phase 6 implementation order (3 logical commits):

  Commit A: config.c break — substrate fix in isolation
  Commit B: mpeg2.c rewrite + drop mpeg2-ctrls.h includes
  Commit C: delete include/mpeg2-ctrls.h

Phase 7 verification harness (full Bash incantations included in
plan body):

  Criterion 1: vainfo MPEG-2 enumeration regression check
  Criterion 2: vaCreateConfig SUCCESS via libva trace
  Criterion 3: ffmpeg -hwaccel vaapi exit 0, no Failed-to-create
  Criterion 4: mpv --hwdec=vaapi --vo=image at +02s seek; HW=SW
               byte-identical hashes for 2 distinct frames
               (fallback to ffmpeg hwdownload if mpv-vaapi also
               filters MPEG-2; criterion holds, harness adapts)
  Criterion 5: T4 H.264 hashes still f623d5f7... and 7d7bc6f2...
  Bonus: byte-compare post-fix S_EXT_CTRLS payload vs Baseline C

Pre-identified Phase 7 → Phase 4 loopback triggers:

  1. S_EXT_CTRLS EINVAL post-fix → check pic.reserved[5] memset,
     struct sizes, flag value collisions
  2. Pixel hash mismatch → check f_code packing, field/frame
     interpretation, ref timestamps, IQ matrix order
  3. mpv-vaapi filters MPEG-2 out (same as -copy) → fall-forward
     to ffmpeg hwdownload pixel verify (criterion holds, harness
     adapts; do not redefine criterion)
  4. H.264 regression → re-locate the offending change in Bug 1
  5. Header deletion breaks unaudited consumer → git grep audit

Out of scope (LOCKED): HEVC/VP9/VP8 (later iterations); vaDerive
Image cache-stale fix; chromium-fourier 149 install; perf metrics;
long-duration stress; other MPEG-2 containers; mpv-hwdec follow-up;
context.c H.264 device-init EINVAL (auxiliary, intentional);
profile/chroma/progressive_sequence refinement; upstream engagement.

Phase 5 entry: artifacts handover (no summary, raw bundle) per
feedback_dev_process.md — phase0_findings_iter1.md,
phase2_iter1_situation.md, phase3_iter1_baseline.md,
phase4_iter1_plan.md, plus phase0_evidence/2026-05-07/iter1_phase3/.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 04:38:53 +00:00