edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB5591c0eTahinli3 months ago1014 commits
| 1 | //! Stateless VA-API video decoding and encoding. |
| 2 | //! |
| 3 | //! "Stateless" is the VA-API decode model, not a description of this crate: the |
| 4 | //! driver decodes one picture at a time and knows nothing between pictures, so |
| 5 | //! everything a codec spreads across frames — the decoded picture buffer, |
| 6 | //! reference lists, picture order counts, reference slot updates — is kept |
| 7 | //! here, in Rust, and handed to the driver per picture. That is the whole job. |
| 8 | //! |
| 9 | //! ```no_run |
| 10 | //! use ec_hw::{Codec, Decoder}; |
| 11 | //! |
| 12 | //! let display = ec_va::Display::open()?; |
| 13 | //! let mut decoder = Decoder::new(&display, Codec::H264)?; |
| 14 | //! # let annex_b_access_unit: &[u8] = &[]; |
| 15 | //! decoder.decode(annex_b_access_unit, 0)?; |
| 16 | //! while let Some(frame) = decoder.next_frame() { |
| 17 | //! let planes = frame.to_i420()?; // or frame.export_prime() for zero copy |
| 18 | //! } |
| 19 | //! # Ok::<(), ec_hw::Error>(()) |
| 20 | //! ``` |
| 21 | //! # Bit depth |
| 22 | //! |
| 23 | //! [`Frame::to_i420`] truncates a 10-bit (P010) surface to 8 bits, because a |
| 24 | //! byte per sample is what the software path speaks. A 10-bit consumer must |
| 25 | //! call [`Frame::to_i420_16`] instead — that is the lossless path that keeps |
| 26 | //! all ten bits. |
| 27 | //! |
| 28 | //! # Shape |
| 29 | //! |
| 30 | //! * [`params`] — the `#[repr(C)]` codec parameter buffers, each checked |
| 31 | //! against the system headers by a `const` assertion. |
| 32 | //! * [`dec`] — one stateless decoder per codec behind [`Decoder`]. |
| 33 | //! * [`enc`] — H.264 and HEVC encoders, and an opt-in AV1 one. |
| 34 | //! * [`SurfacePool`] / [`Frame`] — surface recycling and pixel access. |
| 35 | //! |
| 36 | //! # Unsafe |
| 37 | //! |
| 38 | //! This crate is not `forbid(unsafe_code)`: handing a parameter struct to the |
| 39 | //! driver and walking a coded-buffer segment list are both pointer work that |
| 40 | //! `ec-va` cannot type for us. Both are confined to two functions — |
| 41 | //! [`params::param_buffer`] and `enc::coded_bytes` — and everything else, |
| 42 | //! including every codec's parameter derivation, is safe Rust. |
| 43 | //! |
| 44 | //! # Panics |
| 45 | //! |
| 46 | //! None by contract. Every driver and bitstream fault is an [`Error`], because |
| 47 | //! edith loads this path as a `dlopen`ed plugin whose fall back to software is |
| 48 | //! only as good as that promise. |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | pub use ; |
| 61 | pub use |
| 62 | |
| 63 | ; |
| 64 | pub use ; |
| 65 | pub use ; |
| 66 | pub use ; |