chromeos / cros-libva Goto Github PK
View Code? Open in Web Editor NEWLicense: BSD 3-Clause "New" or "Revised" License
License: BSD 3-Clause "New" or "Revised" License
We could use a private trait in favor of BufferType
enum. Something like:
trait BufferElement: Into<Self::RawType> {
const TYPE: bindings::VABufferType::Type;
type RawType;
fn raw_element_size() -> usize {
std::mem::size_of::<Self::RawType>()
}
}
Replace tuple structs with strongly typed and documented copy of raw struct. It would have to be converted to raw when added to the picture (or prior vaRenderPicture
), but during this step we could clone Rc<>
s to dependencies (like surfaces and EncCodedBuffer) to Picture<>
so those wouldn't get dropped before sync. It would clean up some cros-codecs code.
Also Picture::add_buffer
could accept a trait that would wrap our use cases. Like so:
trait BufferContents {
const TYPE: bindings::VABufferType::Type;
fn element_size(&self) -> usize;
fn num_elements(&self) -> usize;
unsafe fn data_ptr(&mut self) -> *mut std::ffi::c_void;
}
// Or just use slice somehow
pub struct BufferArray<T>
where
T: BufferElement,
{
array: Vec<T::RawType>,
// ... deps
}
impl<T> BufferContents for BufferArray<T>
where
T: BufferElement,
{
// ...
}
impl<T> BufferContents for Box<T> // Or just T
where
T: BufferElement,
{
// ...
}
impl BufferContents for SliceData
{
// ...
}
In this way we could handle buffer arrays and single element buffers transparently.
On top of that we maybe could look into doing some validations.
Libva mentions the following:
All VAAPI functions implemented in libva are thread-safe. For any VAAPI function that requires the implementation of a backend (e.g. hardware driver), the backend must ensure that its implementation is also thread-safe. If the backend implementation of a VAAPI function is not thread-safe then this should be considered as a bug against the backend implementation.
It is assumed that none of the VAAPI functions will be called from signal handlers.
Thread-safety in this context means that when VAAPI is being called by multiple concurrent threads, it will not crash or hang the OS, and VAAPI internal data structures will not be corrupted. When multiple threads are operating on the same VAAPI objects, it is the application's responsibility to synchronize these operations in order to generate the expected results. For example, using a single VAContext from multiple threads may generate unexpected results.
I think it's safe to implement Send + Sync for cros_libva::Display
, although I haven't yet tested it.
VA-API supports JPEG encoding and decoding via VAProfileJpegBaseline
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.