Skip to main content

Crate libde265_sys2

Crate libde265_sys2 

Source
Expand description

§libde265-sys

libde265-sys is a binding to libde265.

A high-level wrapper libde265-rs is also available.

CHANGELOG

§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 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.

§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§

__BindgenBitfieldUnit
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§

LIBDE265_NUMERIC_VERSION
LIBDE265_VERSION

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 ===