| Crates.io | libde265-sys2 |
| lib.rs | libde265-sys2 |
| version | 0.1.0 |
| created_at | 2025-09-12 08:50:32.145862+00 |
| updated_at | 2025-09-12 08:50:32.145862+00 |
| description | libde265 bindings |
| homepage | |
| repository | https://github.com/cykooz/libde265-sys |
| max_upload_size | |
| id | 1835360 |
| size | 2,086,338 |
libde265-sys is a binding to libde265.
A high-level wrapper libde265-rs is also available.
libde265-dev >= 1.0.0.The crate uses pkg-confing to find installed libde265 (with
help of system-deps crate).
You can also enable embedded-libde265 feature to compile
libde265 v1.0.16 from embedded sources and then link it statically.
The crate uses vcpkg crate
to find libde265 installed with help of vcpkg.
You can use cargo-vcpkg
to install libde265 with help of cargo command:
cargo vcpkg -v build
cargo-vcpkg can fetch and build a vcpkg installation of required
packages from scratch. It merges package requirements specified in
the Cargo.toml of crates in the dependency tree.
use std::fs::File;
use std::io::Read;
use std::os::raw::c_int;
use std::ptr;
use libde265_sys2::*;
#[test]
fn decode_h265() {
unsafe {
let decoder_ctx = de265_new_decoder();
let mut file = File::open("./data/girlshy.h265").unwrap();
// The buffer is small on purpose, just for the example.
let mut buf = vec![0; 1024];
let mut images_count = 0;
loop {
let mut more: c_int = 0;
let err = de265_decode(decoder_ctx, &mut more);
match err {
de265_error::DE265_OK if more == 0 => break,
de265_error::DE265_OK | de265_error::DE265_ERROR_IMAGE_BUFFER_FULL => {
// Get available images
while let img = de265_peek_next_picture(decoder_ctx)
&& !img.is_null()
{
images_count += 1;
let width = de265_get_image_width(img, 0);
let height = de265_get_image_height(img, 0);
assert_eq!(width, 316);
assert_eq!(height, 240);
let mut stride: c_int = 0;
let plane_buf = de265_get_image_plane(img, 0, &mut stride);
assert!(!plane_buf.is_null());
assert_eq!(stride, 320);
de265_release_next_picture(decoder_ctx);
}
}
de265_error::DE265_ERROR_WAITING_FOR_INPUT_DATA => {}
_ => panic!("unexpected error: {:?}", err),
}
// Load more video data into 'buf'
let size = file.read(&mut buf).unwrap();
if size == 0 {
// EOF
assert_eq!(de265_flush_data(decoder_ctx), de265_error::DE265_OK);
} else {
assert_eq!(
de265_push_data(
decoder_ctx,
buf.as_ptr() as _,
size as _,
0,
ptr::null_mut(),
),
de265_error::DE265_OK
);
}
}
assert_eq!(images_count, 75);
de265_free_decoder(decoder_ctx);
}
}