forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB576f72dTahinli3 months ago1275 commits

lib.rs67 lines, 2.4 KiBHistoryRawDownload
1//! Minimal libva (VA-API) bindings and a safe layer over them.
2//!
3//! This is the hardware-video foundation of the `edith_codecs` family: `ec-hw`
4//! builds stateless VA-API decoders and encoders on top of it, and nothing else
5//! in the family talks to libva directly.
6//!
7//! # Shape
8//!
9//! * [`sys`] — the entire FFI surface, hand-written, one screenful per concern.
10//! Every ABI assumption is stated there and checked by a `const` assertion
11//! against numbers printed by `crates/ec-va/abi-probe.c`.
12//! * Everything else is safe: [`Display`], [`Config`], [`Surface`], [`Context`]
13//! and [`Buffer`] are RAII handles that destroy exactly what they created, in
14//! the order libva requires (each child holds an `Arc` of its parent, so the
15//! ordering is a borrow-checker fact rather than a review comment).
16//! * [`Picture`] encodes the `begin -> render -> end -> sync` protocol as a
17//! typestate machine, so submitting out of order does not compile.
18//!
19//! # Version policy
20//!
21//! Built against libva **1.23** headers and refuses older runtimes with
22//! [`Error::Version`]. The alternative — assuming a struct layout and finding
23//! out at runtime — is what broke the previous generation of VA-API bindings
24//! when 1.23 shifted their generated definitions.
25//!
26//! # Example
27//!
28//! ```no_run
29//! use ec_va::{CapReport, Display, Surface, SurfaceSpec};
30//! use ec_va::caps::{Entrypoint, Profile};
31//!
32//! let display = Display::open()?;
33//! let caps = CapReport::probe(&display)?;
34//! assert!(caps.supports(Profile::H264Main, Entrypoint::VLD));
35//!
36//! let surfaces = Surface::create_pool(&display, &SurfaceSpec::nv12(1920, 1088), 8)?;
37//! # Ok::<(), ec_va::Error>(())
38//! ```
39
40#![deny(missing_docs)]
41#![deny(unsafe_op_in_unsafe_fn)]
42
43pub mod caps;
44pub mod config;
45pub mod display;
46pub mod error;
47pub mod picture;
48pub mod surface;
49pub mod sys;
50pub mod vpp;
51
52pub use caps::{CapEntry, CapReport, Entrypoint, Profile, fourcc_str};
53pub use config::{Config, ConfigAttrib, SurfaceCaps};
54pub use display::Display;
55pub use error::{Error, Result};
56pub use picture::{
57 Buffer, Context, Ended, MappedBuffer, New, Picture, PictureState, Rendering, Synced,
58};
59pub use surface::{
60 Image, MappedImage, PrimeLayer, PrimeObject, PrimeSurface, Surface, SurfaceSpec,
61};
62pub use vpp::Vpp;
63
64/// Major libva version this crate's ABI transcription targets.
65pub const MIN_VA_MAJOR: i32 = 1;
66/// Minimum libva minor version accepted at runtime.
67pub const MIN_VA_MINOR: i32 = 23;