Skip to content

v0.0.3

Choose a tag to compare

@MagicalTux MagicalTux released this 21 Jun 23:59
· 22 commits to master since this release
78dc0b9

Fixed

  • correct VA-API test assumptions (surface-id sentinel + VAProfileNone)

Other

  • refresh to current status, drop per-round changelog cruft
  • round 10: codec_id_for_profile — reverse lookup over the family table
  • round 9: drop unused EntrypointMatrix import in test
  • round 9: EntrypointMatrix — one-shot (profile, [entrypoints]) snapshot
  • lift codec id → VAProfile family map into public module

Added — Round 10 (reverse lookup: codec_id_for_profile)

Complements the round-8 forward map (codec_profiles(id) -> &[i32])
with the reverse direction: given a raw VAProfile value (or a typed
[VaProfile]), return the codec id of the family it belongs to.

This is the primitive callers need when iterating an
[EntrypointMatrix]'s advertised profile list and bucketing each
profile by codec — e.g. building a (codec, [profile]) index for the
HEVC / VP9 / AV1 adapters planned in the README roadmap. Without it,
each row has to re-scan KNOWN_CODECS by hand; the helper lifts the
scan into the table module so callers stay single-line.

  • New profiles::codec_id_for_profile(raw: i32) -> Option<&'static str>
    — O(KNOWN_CODECS · max_family_len) scan; returns the codec id of
    the row that contains raw, or None for unmapped values
    (VAProfileNone, future/vendor-specific values).
  • New profiles::codec_id_for_va_profile(VaProfile) -> Option<&'static str>
    — typed wrapper around the raw variant; same semantics, drops a
    .raw() at the call site.
  • Both helpers re-exported at the crate root.
  • 6 new unit tests in src/profiles.rs covering: H.264 / HEVC / VP9
    / AV1 family resolution, None for VAProfileNone and out-of-range
    values, typed-vs-raw parity across every table entry, and the
    forward-reverse round-trip (every profile in the table maps back to
    a codec id whose codec_profiles slice contains it).
  • New tests/round10_codec_id_lookup.rs (6 tests, skip-friendly on
    hosts with no render node):
    • reverse_lookup_covers_every_table_entry — pure table sweep.
    • reverse_lookup_returns_none_for_va_profile_none /
      _for_unknown_value — sentinel + range guards.
    • typed_and_raw_variants_agree_for_every_table_entry.
    • matrix_advertised_profiles_bucket_by_codec_without_panic /
      matrix_codec_id_lookup_matches_table_for_recognised_profiles
      — driver-touching parity checks against a real
      EntrypointMatrix.
    • reverse_lookup_zero_collision_across_families — guard against
      two rows accidentally claiming the same profile.

Added — Round 9 (EntrypointMatrix — one-shot (profile, [entrypoints]) snapshot)

Lifts the (profile, entrypoint) membership check out of
vaQueryConfigEntrypoints FFI traffic and into an in-memory snapshot
that callers consult freely. The naive shape — repeatedly calling
Display::is_supported(profile, entrypoint) for each codec family
and each entrypoint we care about — issued one
vaQueryConfigEntrypoints per pair. On a 25-profile driver with
seven codec families this came out to roughly fifty round-trips per
engine_info() invocation. With the matrix it's roughly twenty-five
(one per advertised profile) plus zero per query.

  • New display::EntrypointMatrix type — a Vec<(VaProfile, Vec<i32>)> wrapped behind a small public API:
    • profiles() -> impl Iterator<Item = VaProfile> — advertised
      profile list matching Display::profiles() exactly.
    • len() / is_empty() — trivial accessors.
    • entrypoints_for(profile) -> &[i32] — entrypoints advertised for
      a single profile; empty slice if the profile isn't in the matrix.
    • is_supported(profile, entrypoint) -> bool — O(rows) membership
      check, equivalent to Display::is_supported but no FFI.
    • profiles_with_entrypoint(entrypoint) -> Vec<VaProfile> —
      equivalent to Display::profiles_with_entrypoint, again FFI-free.
    • any_supports(&[i32], entrypoint) -> bool — "any profile in this
      list advertises this entrypoint" — the codec-family check shared
      between engine::collect_codecs and profiles::host_supports_codec_decode.
  • New Display::entrypoint_matrix() -> Result<EntrypointMatrix, VaError>
    — single-call constructor that issues vaQueryConfigProfiles once,
    then vaQueryConfigEntrypoints once per advertised profile.
  • engine::probe_node now builds the matrix once per device and
    threads it through collect_codecs + max_dims_across. Both
    functions drop their Display::is_supported calls in favour of
    matrix lookups; max_dims_across keeps its vaGetConfigAttributes
    calls because those answer a different question (per-pair max
    dimensions, not "is the pair advertised").
  • profiles::host_supports_codec_decode builds and consults the
    matrix internally — saves N-1 FFI calls on multi-profile families
    (h264 = 4, hevc = 6). New profiles::host_entrypoint_matrix() -> Option<EntrypointMatrix> factors out the "open /dev/dri/renderD128
    • build matrix" plumbing; new profiles::codec_decode_supported
      and profiles::codec_encode_supported take a &EntrypointMatrix
    • codec id so multi-codec pre-flights share one matrix.
  • New tests/round9_entrypoint_matrix.rs (9 tests, skip-friendly on
    hosts with no render node):
    • Round-trip checks: matrix profiles() == Display::profiles()
      and matrix is_supported(VLD) == Display::is_supported(VLD)
      for every advertised profile.
    • Bulk-filter parity: matrix profiles_with_entrypoint(VLD) ==
      Display::profiles_with_entrypoint(VLD).
    • Negative paths: any_supports over a bogus profile list returns
      false, entrypoints_for on an unadvertised profile returns an
      empty slice, codec_*_supported over an unknown codec id returns
      false without touching the matrix.
    • Convergence: codec_decode_supported(&matrix, "h264") agrees with
      host_supports_codec_decode("h264") — the two spellings of the
      same question.
    • Skip-friendly contract: host_entrypoint_matrix returns None
      on no-render-node hosts without panicking.

Added — Round 8 (codec-id → VA-API profile family map, shared by engine.rs + register())

Lifts the private CODEC_FAMILIES table that used to live inside
engine.rs into a public profiles module so codec adapters (today
just H.264, tomorrow HEVC and VP9) can consult one source of truth
for "which VAProfile values does codec id X refer to?".

  • New pub mod profiles (always compiled — no registry gate)
    exposing:
    • pub const KNOWN_CODECS: &[CodecFamily] — the codec id →
      VAProfile family table. 8 entries: h264 / hevc / av1 /
      vp8 / vp9 / mpeg2 / vc1 / jpeg. Ordering is ascending
      capability — the last entry is the "headline" profile used for
      vaGetConfigAttributes(MaxPictureWidth/Height) queries.
    • pub fn codec_profiles(codec_id) -> Option<&'static [i32]> —
      look up the family by id.
    • pub fn headline_profile(codec_id) -> Option<VaProfile> — last
      entry of the family list.
    • pub fn host_supports_codec_decode(codec_id) -> bool — opens
      /dev/dri/renderD128, checks VAEntrypointVLD against every
      family profile, returns false for unknown ids / sandbox CI
      hosts / drivers that don't accelerate the codec.
  • register() in lib.rs now calls
    host_supports_codec_decode("h264") instead of the private
    host_supports_h264_decode() helper (which is removed). Same
    semantics; any future codec adapter that needs the same
    pre-flight gets the helper for free.
  • engine.rs::collect_codecs consumes KNOWN_CODECS directly —
    the private CodecFamily struct + table are removed in favour
    of the shared one in profiles. Net delta in engine.rs:
    −60 LOC.
  • New tests/round8_codec_profiles.rs (6 tests) covers the codec
    id round-trip (KNOWN_CODECS ↔ codec_profiles), the headline
    profile choice for H.264 / HEVC, the unknown-codec fallback, the
    skip-friendly no-libva path, and (crucially) that every codec id
    surfaced by engine_info() is present in KNOWN_CODECS — i.e.
    the refactor doesn't drift between the two consumers.
  • New jpeg row in KNOWN_CODECS (one entry:
    VAProfileJPEGBaseline) — engine_info() will now surface a
    jpeg HwCodecCaps block on hosts where the driver advertises
    the JPEG baseline profile (e.g. Intel iHD's MFX JPEG decoder).