Skip to content

Audio/video codec preference generics (3rd-codec-domain pending) #310

@crippledgeek

Description

@crippledgeek

From the 2026-05-21 code-quality sprint (PR A grandfather list).

cargo-dupes reports 5 groups of duplication between audio and video helper functions in `rdlp-ffmpeg`:

Fingerprint Pair Similarity
`611204904b3045f3` `preferred_audio_encoder` × `preferred_video_encoder` exact
`5f3484e2369caff5` `pick_audio_sample_format` × `pick_video_pixel_format` exact
`c724f5103213d974` `resolve_audio_encoder` × `resolve_encoder` (video) exact
`3b98ca18011a1100` `list_available_audio_codecs` × `list_available_codecs` (video) 96%
`2171a47deb213f3b` closures inside `list_*_codecs` helpers 95%

Investigation (spec design phase): the bodies are structurally identical but call different availability-check functions (`is_audio_encoder_available` vs `is_encoder_available`) and iterate over different static tables (`AUDIO_CODEC_PREFERENCES` vs `CODEC_PREFERENCES`). ffmpeg-the-third upstream also keeps audio/video separate because the underlying capability sets (sample formats vs pixel formats, channel layouts vs frame dimensions) are incompatible.

Rule of Three pending: only 2 codec domains today (audio, video). Activate generics work only if a 3rd codec domain appears — e.g. subtitle codec preference logic, which would force unifying `preferred__encoder` via a trait `CodecDomain`. When activated, remove the 5 grandfather entries above from `.dupes-ignore.toml` in the same change.

References

  • Spec: `docs/superpowers/specs/2026-05-21-code-quality-sprint-design.md` (PR A grandfather table + decision log)
  • Grandfather entries: `.dupes-ignore.toml` (5 fingerprints listed above)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions