Expand description
§libde265-sys
libde265-sys is a binding to libde265.
A high-level wrapper libde265-rs is also available.
§System dependencies
libde265-dev>= 1.0.0.
§Linux
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.
§Windows
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 buildcargo-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.
§Example of decoding H265 stream
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);
}
}Modules§
- de265_
acceleration - de265_
chroma - de265_
error - de265_
image_ format - de265_
param - en265_
encoder_ state - en265_
nal_ unit_ type - en265_
packet_ content_ type - en265_
parameter_ type
Structs§
- __
Bindgen Bitfield Unit - de265_
image - The image is currently always 3-channel YCbCr, with 4:2:0 chroma. But you may want to check the chroma format anyway for future compatibility.
- de265_
image_ allocation - de265_
image_ spec - en265_
encoder_ context - ========== encoder context ==========
- en265_
packet
Constants§
Functions§
- de265_
alloc_ ⚠image_ plane - de265_
change_ ⚠framerate - de265_
decode ⚠ - Do some decoding. Returns status whether it did perform some decoding or why it could not do so. If ‘more’ is non-null, indicates whether de265_decode() should be called again (possibly after resolving the indicated problem). DE265_OK - decoding ok DE265_ERROR_IMAGE_BUFFER_FULL - DPB full, extract some images before continuing DE265_ERROR_WAITING_FOR_INPUT_DATA - insert more data before continuing
- de265_
decode_ ⚠data - Push more data into the decoder, must be raw h265. All complete images in the data will be decoded, hence, do not push too much data at once to prevent image buffer overflows. The end of a picture can only be detected when the succeeding start-code is read from the data. If you want to flush the data and force decoding of the data so far (e.g. at the end of a file), call de265_decode_data() with ‘length’ zero.
- de265_
disable_ ⚠logging - de265_
flush_ ⚠data - Indicate the end-of-stream. All data pending at the decoder input will be pushed into the decoder and the decoded picture queue will be completely emptied.
- de265_
free ⚠ - Free global library data. An implicit free call is made in de265_free_decoder(). Returns false if library was not initialized before, or if ‘free’ was called more often than ‘init’.
- de265_
free_ ⚠decoder - Free decoder context. May only be called once on a context.
- de265_
free_ ⚠image_ plane - de265_
get_ ⚠bits_ per_ pixel - de265_
get_ ⚠chroma_ format - de265_
get_ ⚠current_ TID - de265_
get_ ⚠default_ image_ allocation_ functions - de265_
get_ ⚠error_ text - de265_
get_ ⚠highest_ TID - — frame dropping API —
- de265_
get_ ⚠image_ NAL_ header - Get NAL-header information of this frame. You can pass in NULL pointers if you do not need this piece of information.
- de265_
get_ ⚠image_ PTS - de265_
get_ ⚠image_ colour_ primaries - de265_
get_ ⚠image_ full_ range_ flag - de265_
get_ ⚠image_ height - de265_
get_ ⚠image_ matrix_ coefficients - de265_
get_ ⚠image_ plane - The |out_stride| is returned as “bytes per line” if a non-NULL parameter is given.
- de265_
get_ ⚠image_ plane_ user_ data - de265_
get_ ⚠image_ transfer_ characteristics - de265_
get_ ⚠image_ user_ data - de265_
get_ ⚠image_ width - de265_
get_ ⚠next_ picture - Get next decoded picture and remove this picture from the decoder output queue. Returns NULL is there is no decoded picture ready. You can use the picture only until you call any other de265_* function.
- de265_
get_ ⚠number_ of_ NAL_ units_ pending - Return number of NAL units pending at the decoder input. Can be used to avoid overflowing the decoder with too much data.
- de265_
get_ ⚠number_ of_ input_ bytes_ pending - Return number of bytes pending at the decoder input. Can be used to avoid overflowing the decoder with too much data.
- de265_
get_ ⚠parameter_ bool - Get decoding parameters.
- de265_
get_ ⚠version - version of linked libde265 library
- de265_
get_ ⚠version_ number - returns the version number as a BCD number. 0xAABBCCDD is interpreted as version AA.BB.CC. For example: 0x02143000 is version 2.14.30
- de265_
get_ ⚠version_ number_ maintenance - de265_
get_ ⚠version_ number_ major - de265_
get_ ⚠version_ number_ minor - de265_
get_ ⚠warning - de265_
init ⚠ - Static library initialization. Must be paired with de265_free(). Initialization is optional, since it will be done implicitly in de265_new_decoder(). Return value is false if initialization failed. Only call de265_free() when initialization was successful. Multiple calls to ‘init’ are allowed, but must be matched with an equal number of ‘free’ calls.
- de265_
isOK ⚠ - Returns true, if ‘err’ is DE265_OK or a warning.
- de265_
new_ ⚠decoder - Get a new decoder context. Must be freed with de265_free_decoder().
- de265_
peek_ ⚠next_ picture - Return next decoded picture, if there is any. If no complete picture has been decoded yet, NULL is returned. You should call de265_release_next_picture() to advance to the next picture.
- de265_
push_ ⚠NAL - Push a complete NAL unit without startcode into the decoder. The data must still contain all stuffing-bytes. This function only pushes data into the decoder, nothing will be decoded.
- de265_
push_ ⚠data - Push more data into the decoder, must be a raw h265 bytestream with startcodes. The PTS is assigned to all NALs whose start-code 0x000001 is contained in the data. The bytestream must contain all stuffing-bytes. This function only pushes data into the decoder, nothing will be decoded.
- de265_
push_ ⚠end_ of_ NAL - Indicate that de265_push_data has just received data until the end of a NAL. The remaining pending input data is put into a NAL package and forwarded to the decoder.
- de265_
push_ ⚠end_ of_ frame - Indicate that de265_push_data has just received data until the end of a frame. All data pending at the decoder input will be pushed into the decoder and the decoded picture is pushed to the output queue.
- de265_
release_ ⚠next_ picture - Release the current decoded picture for reuse in the decoder. You should not use the data anymore after calling this function.
- de265_
reset ⚠ - Clear decoder state. Call this when skipping in the stream.
- de265_
set_ ⚠framerate_ ratio - de265_
set_ ⚠image_ allocation_ functions - The user data pointer will be given to the get_buffer() and release_buffer() functions in de265_image_allocation.
- de265_
set_ ⚠image_ plane - de265_
set_ ⚠image_ user_ data - de265_
set_ ⚠limit_ TID - de265_
set_ ⚠parameter_ bool - Set decoding parameters.
- de265_
set_ ⚠parameter_ int - de265_
set_ ⚠verbosity - de265_
start_ ⚠worker_ threads - Initialize background decoding threads. If this function is not called, all decoding is done in the main thread (no multi-threading).
- en265_
allocate_ ⚠image - If we have provided our own memory release function, no image memory will be allocated.
- en265_
block_ ⚠on_ input_ queue_ length - block when there are more than max_input_images in the input queue
- en265_
current_ ⚠input_ queue_ length - en265_
encode ⚠ - Run encoder in main thread. Only use this when not using background threads.
- en265_
free_ ⚠encoder - Free encoder context. May only be called once on a context.
- en265_
free_ ⚠packet - en265_
get_ ⚠encoder_ state - en265_
get_ ⚠image_ spec - Request a specification of the image memory layout for an image of the specified dimensions.
- en265_
get_ ⚠packet - timeout_ms - timeout in milliseconds. 0 - no timeout, -1 - block forever
- en265_
get_ ⚠parameter_ type - en265_
list_ ⚠parameter_ choices - en265_
list_ ⚠parameters - en265_
new_ ⚠encoder - Get a new encoder context. Must be freed with en265_free_encoder().
- en265_
number_ ⚠of_ queued_ packets - en265_
parse_ ⚠command_ line_ parameters - — convenience functions for command-line parameters —
- en265_
push_ ⚠eof - en265_
push_ ⚠image - Image memory layout specification for an image returned by en265_allocate_image().
- en265_
set_ ⚠parameter_ bool - ========== encoder parameters ==========
- en265_
set_ ⚠parameter_ choice - en265_
set_ ⚠parameter_ int - en265_
set_ ⚠parameter_ string - en265_
show_ ⚠parameters - en265_
start_ ⚠encoder - ========== encoding loop ==========
- en265_
trim_ ⚠input_ queue
Type Aliases§
- de265_
PTS - de265_
decoder_ context - === decoder ===