#![allow(dead_code, unused_imports, unexpected_cfgs, mismatched_lifetime_syntaxes)]
#![allow(clippy::all)]
mod bindings;
pub mod buffer;
mod config;
mod context;
mod display;
mod generic_value;
mod image;
mod picture;
mod surface;
mod usage_hint;
pub mod bitstream_utils;
pub mod codec;
pub mod encode;
pub use bindings::_VADRMPRIMESurfaceDescriptor__bindgen_ty_1 as VADRMPRIMESurfaceDescriptorObject;
pub use bindings::_VADRMPRIMESurfaceDescriptor__bindgen_ty_2 as VADRMPRIMESurfaceDescriptorLayer;
pub use bindings::*;
pub use buffer::*;
pub use config::*;
pub use context::*;
pub use display::*;
pub use generic_value::*;
pub use image::*;
pub use picture::*;
pub use surface::*;
pub use usage_hint::*;
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub struct Resolution {
pub width: u32,
pub height: u32,
}
impl Resolution {
pub fn can_contain(&self, other: Self) -> bool {
self.width >= other.width && self.height >= other.height
}
pub fn get_area(&self) -> usize {
(self.width as usize) * (self.height as usize)
}
}
impl From<(u32, u32)> for Resolution {
fn from(value: (u32, u32)) -> Self {
Self {
width: value.0,
height: value.1,
}
}
}
impl From<Resolution> for (u32, u32) {
fn from(value: Resolution) -> Self {
(value.width, value.height)
}
}
use std::num::NonZeroI32;
#[derive(Debug)]
pub struct VaError(NonZeroI32);
impl VaError {
pub fn va_status(&self) -> VAStatus {
self.0.get() as VAStatus
}
}
impl std::fmt::Display for VaError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
use std::ffi::CStr;
let err_str = unsafe { CStr::from_ptr(bindings::vaErrorStr(self.0.get())) }
.to_str()
.unwrap();
f.write_str(err_str)
}
}
impl std::error::Error for VaError {}
fn va_check(code: VAStatus) -> Result<(), VaError> {
match code as u32 {
bindings::VA_STATUS_SUCCESS => Ok(()),
_ => Err(VaError(unsafe { NonZeroI32::new_unchecked(code) })),
}
}