diff --git a/Cargo.toml b/Cargo.toml index eaf1851..47ca3a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fev" -version = "0.2.0" +version = "0.2.1" edition = "2021" license = "0BSD" description = "High-level VA-API bindings" diff --git a/README.md b/README.md index 097e09e..bba63ca 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Ferrovanadium: VA-API bindings for Rust +# VA-API bindings for Rust This library provides high-level wrappers around **VA-API** (*libva*), the Video Acceleration API used by Linux, Android, and BSD systems. diff --git a/src/dlopen.rs b/src/dlopen.rs index 3a2a3c5..2672d92 100644 --- a/src/dlopen.rs +++ b/src/dlopen.rs @@ -2,7 +2,7 @@ //! //! Types used by the bindings are defined throughout the library. -#![allow(bad_style)] +#![allow(bad_style, non_camel_case_types)] use std::{ os::raw::{c_char, c_float, c_int, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void}, diff --git a/src/surface.rs b/src/surface.rs index bce700e..8766715 100644 --- a/src/surface.rs +++ b/src/surface.rs @@ -1,5 +1,7 @@ //! [`Surface`]s and surface attributes. +#[cfg_attr(docsrs, doc(cfg(target_os = "linux")))] +#[cfg(target_os = "linux")] pub mod drm; use core::fmt; @@ -62,7 +64,14 @@ bitflags! { } } -/// A [`Surface`] attribute. +/// A [`Surface`] attribute can be used to request a specific property or configuration during +/// [`Surface`] creation. +/// +/// It can be created [`From`] a [`SurfaceAttribEnum`], or queried from a [`Config`] via +/// [`Config::query_surface_attributes`]. +/// +/// [`Config`]: crate::config::Config +/// [`Config::query_surface_attributes`]: crate::config::Config::query_surface_attributes #[derive(Clone, Copy)] #[repr(C)] pub struct SurfaceAttrib { @@ -318,6 +327,9 @@ bitflags! { } /// A graphics surface or texture. +/// +/// A [`Surface`] acts as either the input of an encoding operation, or the output of a decoding +/// operation. It can also be used as either the source or target of a VPP operation. #[derive(Debug)] pub struct Surface { d: Arc, @@ -325,11 +337,16 @@ pub struct Surface { } impl Surface { + /// Creates a [`Surface`] with the given [`RTFormat`]. pub fn new(display: &Display, width: u32, height: u32, format: RTFormat) -> Result { log::trace!("creating {width}x{height} surface with {format:?}"); Self::with_attribs(display, width, height, format, &mut []) } + /// Creates a [`Surface`] with the given [`PixelFormat`]. + /// + /// This will try to derive a matching [`RTFormat`] automatically via + /// [`PixelFormat::to_rtformat`]. pub fn with_pixel_format( display: &Display, width: u32, @@ -353,6 +370,8 @@ impl Surface { ) } + /// Creates a [`Surface`] with the given [`RTFormat`] and a list of [`SurfaceAttrib`]utes to + /// apply. pub fn with_attribs( display: &Display, width: u32, @@ -402,6 +421,10 @@ impl Surface { Ok(()) } + /// Returns the current [`SurfaceStatus`] of this [`Surface`]. + /// + /// The [`SurfaceStatus`] indicates whether and how the [`Surface`] is currently being used by a + /// VA-API operation. pub fn status(&self) -> Result { let mut status = SurfaceStatus(0); unsafe { @@ -417,9 +440,9 @@ impl Surface { /// Copies all pixels from `self` to the given [`Image`]. /// - /// This calls `vaGetImage`, which may be expensive on some drivers (eg. - /// Intel). If possible, [`SurfaceWithImage`] should be used, so that - /// `vaDeriveImage` is used instead if the driver supports it. + /// This calls `vaGetImage`, which may be expensive on some drivers (eg. Intel). If possible, + /// [`SurfaceWithImage`] should be used, so that `vaDeriveImage` is used instead if the driver + /// supports it. pub fn copy_to_image(&mut self, image: &mut Image) -> Result<()> { self.sync()?; @@ -519,6 +542,11 @@ impl Surface { /// /// **Note**: The underlying function, `vaGetSurfaceBufferWl`, is not implemented on Mesa/AMD, /// so this will always return an error there. + /// + /// (also note that the `wl_buffer` type in the documentation is deliberately private; cast it + /// to the desired type to use it) + #[cfg(target_os = "linux")] + #[cfg_attr(docsrs, doc(cfg(target_os = "linux")))] pub fn wayland_buffer(&self) -> Result<*mut wl_buffer> { unsafe { let mut wlbufferptr = MaybeUninit::uninit(); @@ -636,6 +664,7 @@ impl DerefMut for SurfaceWithImage { } } +/// Enumeration of supported [`SurfaceAttrib`]utes. #[derive(Debug)] #[non_exhaustive] pub enum SurfaceAttribEnum {