├── src └── lib.rs ├── intel-mediasdk-sys ├── .gitignore ├── data │ └── mfxvideo.h ├── Cargo.toml ├── src │ └── lib.rs ├── build.rs └── LICENSE ├── .gitignore ├── Cargo.toml ├── README.md ├── LICENSE └── .github └── workflows └── intel-mediasdk.yml /src/lib.rs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /intel-mediasdk-sys/.gitignore: -------------------------------------------------------------------------------- 1 | src/mfxvideo.rs 2 | -------------------------------------------------------------------------------- /intel-mediasdk-sys/data/mfxvideo.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | 5 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 6 | # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock 7 | Cargo.lock 8 | target 9 | Cargo.lock 10 | -------------------------------------------------------------------------------- /intel-mediasdk-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "intel-mediasdk-sys" 3 | version = "0.1.0" 4 | authors = ["Luca Barbato "] 5 | license = "MIT" 6 | description = "FFI bindings to Intel Media SDK" 7 | repository = "https://github.com/rust-av/intel-mediasdk-rs" 8 | 9 | build = "build.rs" 10 | 11 | [build-dependencies] 12 | bindgen = "0.59" 13 | system-deps = "2.0" 14 | 15 | [package.metadata.system-deps] 16 | libmfx = "1.28" 17 | 18 | [dependencies] 19 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "intel-mediasdk" 3 | version = "0.1.0" 4 | authors = ["Luca Barbato "] 5 | license = "MIT" 6 | description = "Intel MediaSDK bindings" 7 | repository = "https://github.com/rust-av/intel-mediasdk-rs" 8 | readme = "README.md" 9 | keywords = ["qsv", "intel", "mediasdk"] 10 | 11 | [dependencies] 12 | intel-mediasdk-sys = { version = "0.1.0", path = "intel-mediasdk-sys" } 13 | 14 | [workspace] 15 | members = ["intel-mediasdk-sys"] 16 | 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Intel Media SDK bindings 2 | 3 | [![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) 4 | [![Actions Status](https://github.com/rust-av/intel-mediasdk-rs/workflows/intel-mediasdk/badge.svg)](https://github.com/rust-av/intel-mediasdk-rs/actions) 5 | 6 | It is a simple [binding][1] and safe abstraction over the [Intel Media SDK][2]. 7 | 8 | ## Building 9 | 10 | The bindings are generated using the headers and libraries that ought to be present in the system. 11 | On Linux the [main repository](https://github.com/Intel-Media-SDK/MediaSDK) provides full instructions, 12 | on Windows you may use the [repackaged dispatcher](https://github.com/lu-zero/mfx_dispatch). 13 | 14 | ## TODO 15 | - [x] Simple bindings 16 | - [ ] Safe abstraction 17 | - [ ] Examples 18 | 19 | [1]: https://github.com/rust-lang-nursery/rust-bindgen 20 | [2]: http://mediasdk.intel.com 21 | [3]: https://github.com/lu-zero/mfx_dispatch 22 | [4]: https://github.com/Intel-Media-SDK/MediaSDK 23 | -------------------------------------------------------------------------------- /intel-mediasdk-sys/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(dead_code)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_snake_case)] 4 | #![allow(non_upper_case_globals)] 5 | 6 | include!(concat!(env!("OUT_DIR"), "/mfxvideo.rs")); 7 | 8 | impl mfxVersion { 9 | pub fn new(Major: mfxU16, Minor: mfxU16) -> Self { 10 | mfxVersion { 11 | __bindgen_anon_1: mfxVersion__bindgen_ty_1 { Major, Minor }, 12 | } 13 | } 14 | } 15 | 16 | #[cfg(test)] 17 | mod tests { 18 | use super::*; 19 | use std::mem; 20 | #[test] 21 | fn init_and_version() { 22 | let mut sess = unsafe { mem::uninitialized() }; 23 | let im: mfxIMPL = MFX_IMPL_AUTO_ANY as mfxIMPL; 24 | let mut ver = mfxVersion::new(MFX_VERSION_MAJOR as u16, MFX_VERSION_MINOR as u16); 25 | 26 | let res = unsafe { 27 | MFXInit( 28 | im, 29 | &mut ver as *mut mfxVersion, 30 | &mut sess as *mut mfxSession, 31 | ) 32 | }; 33 | 34 | println!("Res {:?}", res); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /intel-mediasdk-sys/build.rs: -------------------------------------------------------------------------------- 1 | extern crate bindgen; 2 | extern crate system_deps; 3 | 4 | use std::env; 5 | use std::fs::File; 6 | use std::io::Write; 7 | use std::path::PathBuf; 8 | 9 | fn format_write(builder: bindgen::Builder) -> String { 10 | builder 11 | .generate() 12 | .unwrap() 13 | .to_string() 14 | .replace("/**", "/*") 15 | .replace("/*!", "/*") 16 | } 17 | 18 | fn main() { 19 | let libs = system_deps::Config::new().probe().unwrap(); 20 | let headers = libs.get("libmfx").unwrap().include_paths.clone(); 21 | 22 | let mut builder = bindgen::builder().header("data/mfxvideo.h"); 23 | 24 | for header in headers { 25 | builder = builder.clang_arg("-I").clang_arg(header.to_str().unwrap()); 26 | } 27 | 28 | // Manually fix the comment so rustdoc won't try to pick them 29 | let s = format_write(builder); 30 | 31 | let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); 32 | 33 | let mut file = File::create(out_path.join("mfxvideo.rs")).unwrap(); 34 | 35 | let _ = file.write(s.as_bytes()); 36 | } 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Luca Barbato 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /intel-mediasdk-sys/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Luca Barbato 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/intel-mediasdk.yml: -------------------------------------------------------------------------------- 1 | name: intel-mediasdk 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | 8 | env: 9 | INTEL_DIR: intel_dir 10 | 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v1 15 | - name: Install libdrm 16 | run: | 17 | sudo apt-get install libdrm-dev 18 | - name: Install Python3 packages 19 | env: 20 | PYTHON3_PKG: python3-setuptools python3-wheel 21 | run: | 22 | sudo apt-get install $PYTHON3_PKG 23 | - name: Install meson and ninja 24 | run: | 25 | sudo pip3 install meson ninja 26 | - name: Install libva 27 | env: 28 | LIBVA_DIR: libva_dir 29 | run: | 30 | git clone --depth 1 https://github.com/intel/libva.git 31 | cd libva 32 | meson build -Dprefix=$HOME/$LIBVA_DIR --buildtype release 33 | ninja -C build 34 | ninja -C build install 35 | - name: Install intel-mediasdk 36 | env: 37 | LIBVA_DIR: libva_dir 38 | PKG_PATH: lib/x86_64-linux-gnu/pkgconfig 39 | run: | 40 | export PKG_CONFIG_PATH=$HOME/$LIBVA_DIR/$PKG_PATH:$PKG_CONFIG_PATH 41 | git clone --depth 1 https://github.com/Intel-Media-SDK/MediaSDK msdk 42 | cd msdk 43 | mkdir -p build 44 | cd build 45 | cmake -DCMAKE_INSTALL_PREFIX=$HOME/$INTEL_DIR \ 46 | -DBUILD_SAMPLES=0 \ 47 | .. 48 | make -j12 49 | make install 50 | - name: Run tests 51 | run: | 52 | export PKG_CONFIG_PATH=$HOME/$INTEL_DIR/lib/pkgconfig:$PKG_CONFIG_PATH 53 | cargo test --all-features --verbose 54 | --------------------------------------------------------------------------------