Commit Graph

1 Commits

Author SHA1 Message Date
claude-noether 2651e4cfdf iter4 Phase 2: situation analysis — VP9 backend gaps + compressed-
header parser requirement

Source-read of every file the iter4 patch series will touch, plus
kernel UAPI + VAAPI + downstream FFmpeg + kernel rkvdec reference
sources. Conducted on noether against fork tip e1aca9c (iter3 close).

Critical scope-shaping finding: rkvdec on RK3399 REQUIRES
V4L2_CID_STATELESS_VP9_COMPRESSED_HDR (not optional). Per
drivers/staging/media/rkvdec/rkvdec-vp9.c::rkvdec_vp9_run_preamble
lines 752-754:

  ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl,
                        V4L2_CID_STATELESS_VP9_COMPRESSED_HDR);
  if (WARN_ON(!ctrl))
      return -EINVAL;

VAAPI does NOT expose compressed-header probability updates
(va_dec_vp9.h:50-192 — only frame parameters + segmentation;
vendor VAAPI drivers parse compressed header in firmware/GPU).
Therefore the libva backend MUST parse the compressed header
itself via a VPX boolean decoder + inv_map_table[]. ~150-200 LOC
of bitstream parsing logic (port from FFmpeg
v4l2_request_vp9.c::fill_compressed_hdr).

Bug enumeration (12 sites):

  B1   config.c::RequestQueryConfigProfiles    enum block missing
  B2   config.c::RequestCreateConfig           VP9 case missing
  B3   config.c::RequestQueryConfigEntrypoints VP9 case missing
  B4   src/vp9.c                               new file ~500-600 LOC
  B5   src/vp9.h                               new file ~35-45 LOC
  B6   src/vp9_rac.h                           NEW or inline (Phase 4
                                                 plan locks Option A:
                                                 inline in vp9.c)
  B7   picture.c::codec_set_controls           VP9 dispatch missing
  B8   picture.c::codec_store_buffer           2 buffer-type cases
                                                 (Picture + Slice;
                                                 NOT 4 like VP8)
  B9   picture.c::RequestBeginPicture          predicted no reset
                                                 needed (no flag-state
                                                 like VP8 iqmatrix_set)
  B10  surface.h::object_surface::params union vp9 member missing
  B11  meson.build                             vp9.c/vp9.h not in lists
  B12  buffer.c                                predicted no change
                                                 needed (VP9 uses
                                                 Picture/Slice/SliceData
                                                 — all whitelisted)

Non-bugs (intentionally untouched): context.c (no DECODE_MODE/
START_CODE menus per FFmpeg ref), video.c (CAPTURE-side format
list), v4l2.c (fourcc-agnostic), include/hevc-ctrls.h (already
includes <linux/v4l2-controls.h>).

Contract surface cited verbatim:

  V4L2_CID_STATELESS_VP9_FRAME = 0xa40b2c (~144 bytes — much
    smaller than VP8's 1232 bytes because VP9_FRAME carries no
    entropy table; that's in COMPRESSED_HDR)
  V4L2_CID_STATELESS_VP9_COMPRESSED_HDR = 0xa40b2d (~1947 bytes
    — coef[4][2][2][6][6][3] alone is 1728 bytes)
  Per-frame submission: 2 controls batched in single S_EXT_CTRLS
  v4l2_request_vp9.c references confirmed: 2-control shape,
    runtime-probed COMPRESSED_HDR availability (rkvdec advertises
    it; we MUST provide)

VAAPI buffer types: 2 per frame (Picture + Slice) vs iter3 VP8's
4. NO Probability buffer (VP9 keeps probs in compressed header).
NO IQMatrix (VP9 keeps quant in slice's per-segment seg_param[8]).

VAAPI → V4L2 mapping table: 30+ fields enumerated. Several gap
candidates identified for Phase 3 empirical resolution:

  Q1 lf.ref_deltas/mode_deltas/flags — not in VAAPI; FFmpeg reads
     from VP9Context internal. BBB likely zero.
  Q2 quant.base_q_idx + deltas — VAAPI exposes only effective
     per-segment scales. Inverse-derive needed.
  Q3 reference_mode — not in VAAPI. Default to SELECT?
  Q4 interpolation_filter mapping (FFmpeg ^ remap)
  Q5 reset_frame_context off-by-one (FFmpeg > 0 ? - 1 : 0)
  Q6 Per-segment feature_data[8][4] derivation from VAAPI's
     effective scales is non-trivial
  Q7 mpv 0.41.0 VP9 hwdec engagement (per memory feedback_hw_
     decode_engagement_check.md — known gap from iter3 VP8)
  Q8 rkvdec dma_resv issue? (predicted NO based on iter1+iter2
     successful mpv-DMA-BUF-GL on rkvdec)

Patch-shape prediction: ~580-690 LOC across 5 modified + 2 new
files (closer to iter2 HEVC's 470 than iter3 VP8's 370). Compressed-
header parser is the dominant cost.

Phase 3 baseline targets queued: cross-validator strace verbatim
S_EXT_CTRLS payloads (both controls), VAAPI consumer trace, mpv-
VP9-vaapi engagement check, rkvdec readback non-zero check.

Phase 4 plan structure anticipated: 10-clause template per
iter2/iter3, with new Clause 8 dedicated to compressed-header
parser.

Refs:
  phase0_findings_iter4.md (Phase 1 lock)
  phase8_iteration3_close.md (predecessor)
  references/ffmpeg-kwiboo/libavcodec/v4l2_request_vp9.c (V4L2 ref)
  references/ffmpeg-kwiboo/libavcodec/vaapi_vp9.c (VAAPI ref)
  /home/mfritsche/src/linux-rfc/drivers/staging/media/rkvdec/
    rkvdec-vp9.c (kernel driver — confirms COMPRESSED_HDR
    requirement at lines 752-754)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 05:20:07 +00:00