diff --git a/.github/workflows/check_and_test.yaml b/.github/workflows/check_and_test.yaml index 6b812d9..1b0f1ce 100644 --- a/.github/workflows/check_and_test.yaml +++ b/.github/workflows/check_and_test.yaml @@ -5,7 +5,7 @@ on: branches: [ "master" ] pull_request: branches: [ "master" ] - workflow_dispatch: {} + workflow_dispatch: { } env: @@ -15,31 +15,27 @@ env: jobs: run_tests_on_linux: name: Test `cargo check/test` on Ubuntu - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: root suid tar run: sudo chown root:sudo /bin/tar && sudo chmod u+s /bin/tar - name: Cache APT id: cache-apt - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | /etc/apt /var/lib/apt key: ${{ runner.os }}-apt - - name: Add libheif PPA - if: steps.cache-apt.outputs.cache-hit != 'true' - run: sudo add-apt-repository -y ppa:strukturag/libheif - - - name: Install libheif + - name: Install libheif dependencies uses: awalsh128/cache-apt-pkgs-action@latest with: - packages: libheif-dev libdav1d-dev - version: 1.16.2 + packages: libheif-dev libdav1d-dev libnuma-dev + version: 1.18.2 - uses: Swatinem/rust-cache@v2 with: @@ -47,15 +43,15 @@ jobs: - name: Run tests run: | - cargo check -p libheif-sys - cargo test + cargo check -p libheif-sys --features use-bindgen,embedded-libheif-plugins + cargo test --features use-bindgen,embedded-libheif-plugins run_tests_on_windows: name: Test `cargo check/test` on Windows runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Cache rust artifacts uses: Swatinem/rust-cache@v2 @@ -65,7 +61,7 @@ jobs: - name: Cache vcpkg id: cache-vcpkg - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: "target/vcpkg" key: ${{ runner.os }}-vcpkg diff --git a/CHANGELOG.md b/CHANGELOG.md index 745124f..73074b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,120 @@ # Change Log +## [Unreleased] - ReleaseDate + +### Added + +- Added features to compile `libheif` source-code form GitHub and + link it statically (not supported for Windows): + - `compile-libheif` + - `embedded-libheif-plugins` +- Updated "bindings.rs" to correspond `libheif 1.18.2`: + - added new values into `heif_suberror_code` "enum': + - `heif_suberror_code_heif_suberror_No_ispe_property` + - `heif_suberror_code_heif_suberror_Camera_intrinsic_matrix_undefined` + - `heif_suberror_code_heif_suberror_Camera_extrinsic_matrix_undefined` + - `heif_suberror_code_heif_suberror_Invalid_J2K_codestream` + - `heif_suberror_code_heif_suberror_No_vvcC_box` + - `heif_suberror_code_heif_suberror_No_icbr_box` + - `heif_suberror_code_heif_suberror_Decompression_invalid_data` + - `heif_suberror_code_heif_suberror_Compression_initialisation_error` + - `heif_suberror_code_heif_suberror_Unsupported_generic_compression_method` + - `heif_suberror_code_heif_suberror_No_matching_decoder_installed` + - added new values into `heif_compression_format` "enum': + - `heif_compression_format_heif_compression_HTJ2K` + - added new values into `heif_metadata_compression` "enum': + - `heif_metadata_compression_heif_metadata_compression_zlib` + - `heif_metadata_compression_heif_metadata_compression_brotli` + - added field `prefer_uncC_short_form` into struct `heif_encoding_options` + - added structs: + - `heif_camera_intrinsic_matrix` + - `heif_property_user_description` + - `heif_region_item` + - `heif_region` + - added enums: + - `heif_item_property_type` + - `heif_transform_mirror_direction` + - `heif_region_type` + - added functions: + - `heif_has_compatible_filetype` + - `heif_context_add_compatible_brand` + - `heif_context_encode_grid` + - `heif_context_add_generic_uri_metadata` + - `heif_context_get_number_of_items` + - `heif_context_get_list_of_item_IDs` + - `heif_item_get_item_type` + - `heif_item_is_item_hidden` + - `heif_item_get_mime_item_content_type` + - `heif_item_get_mime_item_content_encoding` + - `heif_item_get_uri_item_uri_type` + - `heif_item_get_item_name` + - `heif_item_set_item_name` + - `heif_item_get_item_data` + - `heif_release_item_data` + - `heif_context_get_item_references` + - `heif_release_item_references` + - `heif_context_add_item_reference` + - `heif_context_add_item_references` + - `heif_context_add_item` + - `heif_context_add_mime_item` + - `heif_context_add_precompressed_mime_item` + - `heif_context_add_uri_item` + - `heif_item_get_properties_of_type` + - `heif_item_get_transformation_properties` + - `heif_item_get_property_type` + - `heif_item_get_property_user_description` + - `heif_item_add_property_user_description` + - `heif_property_user_description_release` + - `heif_item_get_property_transform_mirror` + - `heif_item_get_property_transform_rotation_ccw` + - `heif_item_get_property_transform_crop_borders` + - `heif_item_add_raw_property` + - `heif_item_get_property_raw_size` + - `heif_item_get_property_raw_data` + - `heif_image_handle_get_number_of_region_items` + - `heif_image_handle_get_list_of_region_item_ids` + - `heif_context_get_region_item` + - `heif_region_item_get_id` + - `heif_region_item_release` + - `heif_region_item_get_reference_size` + - `heif_region_item_get_number_of_regions` + - `heif_region_item_get_list_of_regions` + - `heif_region_release` + - `heif_region_release_many` + - `heif_region_get_type` + - `heif_region_get_point` + - `heif_region_get_point_transformed` + - `heif_region_get_rectangle` + - `heif_region_get_rectangle_transformed` + - `heif_region_get_ellipse` + - `heif_region_get_ellipse_transformed` + - `heif_region_get_polygon_num_points` + - `heif_region_get_polygon_points` + - `heif_region_get_polygon_points_transformed` + - `heif_region_get_polyline_num_points` + - `heif_region_get_polyline_points` + - `heif_region_get_polyline_points_transformed` + - `heif_region_get_referenced_mask_ID` + - `heif_region_get_inline_mask_data_len` + - `heif_region_get_inline_mask_data` + - `heif_region_get_mask_image` + - `heif_image_handle_add_region_item` + - `heif_region_item_add_region_point` + - `heif_region_item_add_region_rectangle` + - `heif_region_item_add_region_ellipse` + - `heif_region_item_add_region_polygon` + - `heif_region_item_add_region_polyline` + - `heif_region_item_add_region_referenced_mask` + - `heif_region_item_add_region_inline_mask_data` + - `heif_region_item_add_region_inline_mask` + +### Fixed + +- **BREAKING**: Deleted deriving `Copy` and `Clone` for structs with pointers: + - `heif_plugin_info` + - `heif_decoding_options` + - `heif_encoding_options` + ## [2.1.1] - 2024-05-08 - Fixed minimal required version of `libheif` specified in `build.rs`. diff --git a/Cargo.toml b/Cargo.toml index 408c6bb..2559b97 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,12 +21,16 @@ libc = "0.2" default = ["use-bindgen"] # Use bindgen to generate bindings for libheif, # instead using of pre-generated bindings.rs. -use-bindgen = ["dep:bindgen"] +use-bindgen = ["dep:bindgen", "dep:prettyplease"] +compile-libheif = ["dep:cmake"] +embedded-libheif-plugins = ["compile-libheif"] [build-dependencies] -bindgen = { version = "0.69", optional = true } pkg-config = "0.3" +prettyplease = { version = "0.2", optional = true } +bindgen = { version = "0.70.1", optional = true } +cmake = { version = "0.1.50", optional = true } [target.'cfg(windows)'.build-dependencies] @@ -36,7 +40,7 @@ walkdir = "2" [package.metadata.vcpkg] git = "https://github.com/microsoft/vcpkg" -tag = "2023.11.20" +tag = "2024.10.21" dependencies = ["libheif"] diff --git a/README.md b/README.md index bb96d50..f905dbb 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ## System dependencies -- `libheif-dev` >= 1.17.0 (any version if `use-bindgen` feature is enabled) +- `libheif-dev` >= 1.18.0 (any version if `use-bindgen` feature is enabled). - `clang` - to generate rust bindings for `libheif`. [See bindgen requirements.](https://rust-lang.github.io/rust-bindgen/requirements.html) @@ -12,13 +12,30 @@ In this case the pre-generated file `bindings.rs` will be used instead of generating it on the fly with help of `bindgen` crate. +
+ Warning: `bindings.rs` file was generated under x64 linux and may not work as expected under x32 architectures or other operating systems. +
+ ### Linux The crate uses `pkg-confing` to find installed `libheif`. +Also, you can enable all or one of next features to compile `libheif` from +`GitHub` and link it statically: + +- `compile-libheif` +- `embedded-libheif-plugins` + +
+ +Note: Static linked version of `libheif` doesn't have statically linked +it dependencies, such as `libde256`, `libaom` and other. + +
+ ### Windows The crate uses [vcpkg crate](https://crates.io/crates/vcpkg) @@ -35,7 +52,7 @@ cargo vcpkg -v build packages from scratch. It merges package requirements specified in the `Cargo.toml` of crates in the dependency tree. -## Example of reading and decoding of HEIF-image +## Example of reading and decoding HEIF-image ```rust use std::ffi; @@ -49,15 +66,19 @@ fn read_and_decode_heic_file() { lh::heif_init(ptr::null_mut()); let ctx = lh::heif_context_alloc(); - assert_ne!(ctx, ptr::null_mut()); + assert!(!ctx.is_null()); let c_name = ffi::CString::new("data/test.heif").unwrap(); - let err = lh::heif_context_read_from_file(ctx, c_name.as_ptr(), ptr::null()); - assert_eq!(err.code, 0); + let err = lh::heif_context_read_from_file( + ctx, + c_name.as_ptr(), + ptr::null() + ); + assert_eq!(err.code, lh::heif_error_code_heif_error_Ok); let mut handle = ptr::null_mut(); let err = lh::heif_context_get_primary_image_handle(ctx, &mut handle); - assert_eq!(err.code, 0); + assert_eq!(err.code, lh::heif_error_code_heif_error_Ok); assert!(!handle.is_null()); let width = lh::heif_image_handle_get_width(handle); @@ -65,27 +86,32 @@ fn read_and_decode_heic_file() { let height = lh::heif_image_handle_get_height(handle); assert_eq!(height, 3024); - let options = lh::heif_decoding_options_alloc(); - let mut image = ptr::null_mut(); + let options = lh::heif_decoding_options_alloc(); let err = lh::heif_decode_image( handle, &mut image, lh::heif_colorspace_heif_colorspace_RGB, - lh::heif_chroma_heif_chroma_444, + lh::heif_chroma_heif_chroma_interleaved_RGB, options, ); lh::heif_decoding_options_free(options); - assert_eq!(err.code, 0); + assert_eq!(err.code, lh::heif_error_code_heif_error_Ok); assert!(!image.is_null()); let colorspace = lh::heif_image_get_colorspace(image); assert_eq!(colorspace, lh::heif_colorspace_heif_colorspace_RGB); let chroma_format = lh::heif_image_get_chroma_format(image); - assert_eq!(chroma_format, lh::heif_chroma_heif_chroma_444); - let width = lh::heif_image_get_width(image, lh::heif_channel_heif_channel_R); + assert_eq!(chroma_format, lh::heif_chroma_heif_chroma_interleaved_RGB); + let width = lh::heif_image_get_width( + image, + lh::heif_channel_heif_channel_interleaved + ); assert_eq!(width, 4032); - let height = lh::heif_image_get_height(image, lh::heif_channel_heif_channel_R); + let height = lh::heif_image_get_height( + image, + lh::heif_channel_heif_channel_interleaved + ); assert_eq!(height, 3024); lh::heif_context_free(ctx); diff --git a/build.rs b/build.rs index 64a1e6c..877dfde 100644 --- a/build.rs +++ b/build.rs @@ -1,101 +1,233 @@ +use std::path::PathBuf; +use std::process::Command; + +#[allow(dead_code)] +const MIN_LIBHEIF_VERSION: &str = "1.18"; +#[allow(dead_code)] +const LIBHEIF_GITHUB_VERSION: &str = "v1.18.2"; + fn main() { if std::env::var("DOCS_RS").is_ok() { // Don't link with libheif in case of building documentation for docs.rs. - println!("cargo:rustc-cfg=docs_rs"); return; } - // Tell cargo to tell rustc to link the system heif - // shared library. + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-changed=wrapper.hpp"); + + // Tell cargo to tell rustc to link the heif library. #[allow(unused_mut)] #[allow(unused_variables)] #[allow(unused_assignments)] let mut include_dirs: Vec = Vec::new(); #[cfg(not(target_os = "windows"))] - match pkg_config::Config::new() - .atleast_version("1.17") - .probe("libheif") { - Ok(library) => { - include_dirs = library - .include_paths - .iter() - .map(|dir| dir.to_string_lossy().to_string()) - .collect(); + #[cfg(feature = "compile-libheif")] + compile_libheif(); + + include_dirs.extend(find_libheif()); + } + + #[cfg(target_os = "windows")] + include_dirs.extend(install_libheif_by_vcpkg()); + + #[cfg(feature = "use-bindgen")] + run_bindgen(&include_dirs); +} + +#[allow(dead_code)] +fn run_command(description: &str, cmd: &mut Command) -> String { + match cmd.output() { + Ok(output) if !output.status.success() => { + let std_err = String::from_utf8_lossy(&output.stderr); + println!( + "cargo:warning=Failed {}.\n{}\n{}", + description, output.status, std_err + ); + std::process::exit(1); + } + Err(e) => { + println!("cargo:warning={}", e); + std::process::exit(1); + } + Ok(output) => String::from_utf8_lossy(&output.stdout).to_string(), + } +} + +#[allow(dead_code)] +fn fetch_libheif() -> PathBuf { + let out_path = PathBuf::from(std::env::var("OUT_DIR").unwrap()); + let libheif_dir = out_path.join("libheif"); + if libheif_dir.exists() { + let stdout = run_command( + "getting 'libheif' version from exists git repo", + Command::new("git").args([ + "-C", + libheif_dir.to_str().unwrap(), + "describe", + "--exact-match", + "--tags", + ]), + ); + if stdout.trim() != LIBHEIF_GITHUB_VERSION { + std::fs::remove_dir_all(&libheif_dir).unwrap(); } + } + + if !libheif_dir.exists() { + run_command( + "fetching 'libheif' from GitHub", + Command::new("git").args([ + "clone", + "--depth", + "1", + "--branch", + LIBHEIF_GITHUB_VERSION, + "https://github.com/strukturag/libheif.git", + libheif_dir.to_str().unwrap(), + ]), + ); + } + + libheif_dir +} + +#[cfg(feature = "compile-libheif")] +fn compile_libheif() { + use std::path::PathBuf; + + let out_path = PathBuf::from(std::env::var("OUT_DIR").unwrap()); + let libheif_dir = fetch_libheif(); + let mut build_config = cmake::Config::new(libheif_dir); + build_config.out_dir(out_path.join("libheif_build")); + build_config.define("BUILD_SHARED_LIBS", "OFF"); + + #[cfg(feature = "embedded-libheif-plugins")] + for key in [ + "WITH_AOM_DECODER_PLUGIN", + "WITH_AOM_ENCODER_PLUGIN", + "WITH_DAV1D_PLUGIN", + "WITH_FFMPEG_DECODER_PLUGIN", + "WITH_JPEG_DECODER_PLUGIN", + "WITH_JPEG_ENCODER_PLUGIN", + "WITH_KVAZAAR_PLUGIN", + "WITH_LIBDE265_PLUGIN", + "WITH_OPENJPH_ENCODER_PLUGIN", + "WITH_OpenJPEG_DECODER_PLUGIN", + "WITH_OpenJPEG_ENCODER_PLUGIN", + "WITH_RAV1E_PLUGIN", + "WITH_SvtEnc_PLUGIN", + "WITH_UVG266_PLUGIN", + "WITH_VVDEC_PLUGIN", + "WITH_VVENC_PLUGIN", + "WITH_X265_PLUGIN", + ] { + build_config.define(key, "OFF"); + } + + let libheif_build = build_config.build(); + + let pkgconfig_dir = libheif_build + .join("lib/pkgconfig") + .to_string_lossy() + .to_string(); + std::env::set_var("PKG_CONFIG_PATH", pkgconfig_dir); +} + +#[cfg(not(target_os = "windows"))] +fn find_libheif() -> Vec { + let mut config = pkg_config::Config::new(); + config.atleast_version(MIN_LIBHEIF_VERSION); + #[cfg(feature = "compile-libheif")] + config.statik(true); + + match config.probe("libheif") { + Ok(library) => library + .include_paths + .iter() + .map(|dir| dir.to_string_lossy().to_string()) + .collect(), Err(err) => { println!("cargo:warning={}", err); std::process::exit(1); } } +} - #[cfg(target_os = "windows")] - { - let vcpkg_lib = vcpkg::Config::new() - .emit_includes(true) - .find_package("libheif"); - match vcpkg_lib { - Ok(lib) => { - // https://users.rust-lang.org/t/bindgen-cant-find-included-file/62687 - use walkdir::WalkDir; - for path in lib.include_paths { - for subdir in WalkDir::new(path) - .into_iter() - .filter_entry(|e| e.file_type().is_dir()) - { - let dir = subdir.unwrap().path().to_string_lossy().to_string(); - include_dirs.push(dir); - } +#[cfg(target_os = "windows")] +fn install_libheif_by_vcpkg() -> Vec { + let vcpkg_lib = vcpkg::Config::new() + .emit_includes(true) + .find_package("libheif"); + let mut include_dirs = Vec::new(); + match vcpkg_lib { + Ok(lib) => { + // https://users.rust-lang.org/t/bindgen-cant-find-included-file/62687 + use walkdir::WalkDir; + for path in lib.include_paths { + for subdir in WalkDir::new(path) + .into_iter() + .filter_entry(|e| e.file_type().is_dir()) + { + let dir = subdir.unwrap().path().to_string_lossy().to_string(); + include_dirs.push(dir); } } - Err(err) => { - println!("cargo:warning={}", err); - std::process::exit(1); - } + include_dirs + } + Err(err) => { + println!("cargo:warning={}", err); + std::process::exit(1); } } +} - #[cfg(feature = "use-bindgen")] - { - use std::env; - use std::path::PathBuf; - // The bindgen::Builder is the main entry point - // to bindgen, and lets you build up options for - // the resulting bindings. - let mut builder = bindgen::Builder::default() - // The input header we would like to generate - // bindings for. - .header("wrapper.h") - .generate_comments(true) - .generate_cstr(true) - .ctypes_prefix("libc") - .allowlist_function("heif_.*") - .allowlist_type("heif_.*") - .size_t_is_usize(true) - .clang_args([ - "-fparse-all-comments", - "-fretain-comments-from-system-headers", - ]); - if !include_dirs.is_empty() { - dbg!(&include_dirs); - builder = builder.clang_args( - include_dirs - .iter() - .map(|dir| format!("--include-directory={}", dir)), - ); - } +#[cfg(feature = "use-bindgen")] +fn run_bindgen(include_dirs: &[String]) { + let mut base_builder = bindgen::Builder::default() + .generate_comments(true) + .formatter(bindgen::Formatter::Rustfmt) + .generate_cstr(true) + .disable_name_namespacing() + .array_pointers_in_arguments(true) + .ctypes_prefix("libc") + .allowlist_function("heif_.*") + .allowlist_type("heif_.*") + .size_t_is_usize(true) + .clang_args([ + "-fparse-all-comments", + "-fretain-comments-from-system-headers", + ]); + if !include_dirs.is_empty() { + base_builder = base_builder.clang_args( + include_dirs + .iter() + .map(|dir| format!("--include-directory={}", dir)), + ); + } - // Finish the builder and generate the bindings. - let bindings = builder - .generate() - // Unwrap the Result and panic on failure. - .expect("Unable to generate bindings"); - - // Write the bindings to the $OUT_DIR/bindings.rs file. - let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); - bindings - .write_to_file(out_path.join("bindings.rs")) - .expect("Couldn't write bindings!"); + // Don't derive Copy and Clone for structures with pointers. + for struct_name in [ + "heif_plugin_info", + "heif_decoding_options", + "heif_encoding_options", + "heif_property_user_description", + ] { + base_builder = base_builder.no_copy(struct_name); } + + // The main module + let builder = base_builder.clone().header("wrapper.hpp"); + // Finish the builder and generate the bindings. + let bindings = builder + .generate() + // Unwrap the Result and panic on failure. + .expect("Unable to generate bindings"); + + // Write the bindings to the $OUT_DIR/bindings.rs file. + let out_path = PathBuf::from(std::env::var("OUT_DIR").unwrap()); + bindings + .write_to_file(out_path.join("bindings.rs")) + .expect("Couldn't write bindings!"); } diff --git a/src/bindings.rs b/src/bindings.rs index a9232d0..c46a15a 100644 --- a/src/bindings.rs +++ b/src/bindings.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.69.1 */ +/* automatically generated by rust-bindgen 0.70.1 */ extern "C" { #[doc = " Version string of linked libheif library."] @@ -141,8 +141,27 @@ pub const heif_suberror_code_heif_suberror_Unknown_NCLX_matrix_coefficients: hei 135; #[doc = " Invalid specification of region item"] pub const heif_suberror_code_heif_suberror_Invalid_region_data: heif_suberror_code = 136; +#[doc = " Image has no ispe property"] +pub const heif_suberror_code_heif_suberror_No_ispe_property: heif_suberror_code = 137; +#[doc = " Image has no ispe property"] +pub const heif_suberror_code_heif_suberror_Camera_intrinsic_matrix_undefined: heif_suberror_code = + 138; +#[doc = " Image has no ispe property"] +pub const heif_suberror_code_heif_suberror_Camera_extrinsic_matrix_undefined: heif_suberror_code = + 139; +#[doc = " Invalid JPEG 2000 codestream - usually a missing marker"] +pub const heif_suberror_code_heif_suberror_Invalid_J2K_codestream: heif_suberror_code = 140; +#[doc = " Invalid JPEG 2000 codestream - usually a missing marker"] +pub const heif_suberror_code_heif_suberror_No_vvcC_box: heif_suberror_code = 141; +#[doc = " icbr is only needed in some situations, this error is for those cases"] +pub const heif_suberror_code_heif_suberror_No_icbr_box: heif_suberror_code = 142; +#[doc = " Decompressing generic compression or header compression data failed (e.g. bitstream corruption)"] +pub const heif_suberror_code_heif_suberror_Decompression_invalid_data: heif_suberror_code = 150; #[doc = " A security limit preventing unreasonable memory allocations was exceeded by the input file.\n Please check whether the file is valid. If it is, contact us so that we could increase the\n security limits further."] pub const heif_suberror_code_heif_suberror_Security_limit_exceeded: heif_suberror_code = 1000; +#[doc = " There was an error from the underlying compression / decompression library.\n One possibility is lack of resources (e.g. memory)."] +pub const heif_suberror_code_heif_suberror_Compression_initialisation_error: heif_suberror_code = + 1001; #[doc = " also used for Invalid_input"] pub const heif_suberror_code_heif_suberror_Nonexisting_item_referenced: heif_suberror_code = 2000; #[doc = " An API argument was given a NULL pointer, which is not allowed for that function."] @@ -176,6 +195,9 @@ pub const heif_suberror_code_heif_suberror_Unsupported_item_construction_method: #[doc = " The conversion of the source image to the requested chroma / colorspace is not supported."] pub const heif_suberror_code_heif_suberror_Unsupported_header_compression_method: heif_suberror_code = 3005; +#[doc = " Generically compressed data used an unsupported compression method"] +pub const heif_suberror_code_heif_suberror_Unsupported_generic_compression_method: + heif_suberror_code = 3006; #[doc = " --- Encoder_plugin_error ---"] pub const heif_suberror_code_heif_suberror_Unsupported_bit_depth: heif_suberror_code = 4000; #[doc = " --- Encoding_error ---"] @@ -194,6 +216,8 @@ pub const heif_suberror_code_heif_suberror_Plugin_loading_error: heif_suberror_c pub const heif_suberror_code_heif_suberror_Plugin_is_not_loaded: heif_suberror_code = 6001; #[doc = " error while scanning the directory for plugins"] pub const heif_suberror_code_heif_suberror_Cannot_read_plugin_directory: heif_suberror_code = 6002; +#[doc = " no decoder found for that compression format"] +pub const heif_suberror_code_heif_suberror_No_matching_decoder_installed: heif_suberror_code = 6003; pub type heif_suberror_code = libc::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -205,51 +229,14 @@ pub struct heif_error { #[doc = " textual error message (is always defined, you do not have to check for NULL)"] pub message: *const libc::c_char, } -#[test] -fn bindgen_test_layout_heif_error() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(heif_error)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(heif_error)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).code) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(heif_error), - "::", - stringify!(code) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).subcode) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(heif_error), - "::", - stringify!(subcode) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).message) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(heif_error), - "::", - stringify!(message) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of heif_error"][::std::mem::size_of::() - 16usize]; + ["Alignment of heif_error"][::std::mem::align_of::() - 8usize]; + ["Offset of field: heif_error::code"][::std::mem::offset_of!(heif_error, code) - 0usize]; + ["Offset of field: heif_error::subcode"][::std::mem::offset_of!(heif_error, subcode) - 4usize]; + ["Offset of field: heif_error::message"][::std::mem::offset_of!(heif_error, message) - 8usize]; +}; pub type heif_item_id = u32; pub type heif_property_id = u32; #[doc = " Unspecified / undefined compression format.\n\n This is used to mean \"no match\" or \"any decoder\" for some parts of the\n API. It does not indicate a specific compression format."] @@ -272,6 +259,8 @@ pub const heif_compression_format_heif_compression_JPEG2000: heif_compression_fo pub const heif_compression_format_heif_compression_uncompressed: heif_compression_format = 8; #[doc = " Mask image encoding.\n\n See ISO/IEC 23008-12:2022 Section 6.10.2"] pub const heif_compression_format_heif_compression_mask: heif_compression_format = 9; +#[doc = " High Throughput JPEG 2000 (HT-J2K) compression.\n\n The encapsulation of HT-J2K is specified in ISO/IEC 15444-16:2021.\n The core encoding is defined in ISO/IEC 15444-15, or ITU-T T.814."] +pub const heif_compression_format_heif_compression_HTJ2K: heif_compression_format = 10; #[doc = " libheif known compression formats."] pub type heif_compression_format = libc::c_uint; pub const heif_chroma_heif_chroma_undefined: heif_chroma = 99; @@ -313,31 +302,13 @@ pub type heif_channel = libc::c_uint; pub struct heif_init_params { pub version: libc::c_int, } -#[test] -fn bindgen_test_layout_heif_init_params() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(heif_init_params)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(heif_init_params)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(heif_init_params), - "::", - stringify!(version) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of heif_init_params"][::std::mem::size_of::() - 4usize]; + ["Alignment of heif_init_params"][::std::mem::align_of::() - 4usize]; + ["Offset of field: heif_init_params::version"] + [::std::mem::offset_of!(heif_init_params, version) - 0usize]; +}; extern "C" { #[doc = " Initialise library.\n\n You should call heif_init() when you start using libheif and heif_deinit() when you are finished.\n These calls are reference counted. Each call to heif_init() should be matched by one call to heif_deinit().\n\n For backwards compatibility, it is not really necessary to call heif_init(), but some library memory objects\n will never be freed if you do not call heif_init()/heif_deinit().\n\n heif_init() will load the external modules installed in the default plugin path. Thus, you need it when you\n want to load external plugins from the default path.\n Codec plugins that are compiled into the library directly (selected by the compile-time parameters of libheif)\n will be available even without heif_init().\n\n Make sure that you do not have one part of your program use heif_init()/heif_deinit() and another part that does\n not use it as the latter may try to use an uninitialized library. If in doubt, enclose everything with init/deinit.\n\n You may pass nullptr to get default parameters. Currently, no parameters are supported."] pub fn heif_init(arg1: *mut heif_init_params) -> heif_error; @@ -351,7 +322,7 @@ pub const heif_plugin_type_heif_plugin_type_decoder: heif_plugin_type = 1; #[doc = " --- Plugins are currently only supported on Unix platforms."] pub type heif_plugin_type = libc::c_uint; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug)] pub struct heif_plugin_info { #[doc = " version of this info struct"] pub version: libc::c_int, @@ -360,61 +331,19 @@ pub struct heif_plugin_info { #[doc = " for internal use only"] pub internal_handle: *mut libc::c_void, } -#[test] -fn bindgen_test_layout_heif_plugin_info() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(heif_plugin_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(heif_plugin_info)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(heif_plugin_info), - "::", - stringify!(version) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(heif_plugin_info), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).plugin) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(heif_plugin_info), - "::", - stringify!(plugin) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).internal_handle) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(heif_plugin_info), - "::", - stringify!(internal_handle) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of heif_plugin_info"][::std::mem::size_of::() - 24usize]; + ["Alignment of heif_plugin_info"][::std::mem::align_of::() - 8usize]; + ["Offset of field: heif_plugin_info::version"] + [::std::mem::offset_of!(heif_plugin_info, version) - 0usize]; + ["Offset of field: heif_plugin_info::type_"] + [::std::mem::offset_of!(heif_plugin_info, type_) - 4usize]; + ["Offset of field: heif_plugin_info::plugin"] + [::std::mem::offset_of!(heif_plugin_info, plugin) - 8usize]; + ["Offset of field: heif_plugin_info::internal_handle"] + [::std::mem::offset_of!(heif_plugin_info, internal_handle) - 16usize]; +}; extern "C" { pub fn heif_load_plugin( filename: *const libc::c_char, @@ -452,6 +381,10 @@ extern "C" { #[doc = " input data should be at least 12 bytes"] pub fn heif_check_filetype(data: *const u8, len: libc::c_int) -> heif_filetype_result; } +extern "C" { + #[doc = " Check the filetype box content for a supported file type.\n\n

The data is assumed to start from the start of the `ftyp` box.\n\n

This function checks the compatible brands.\n\n @returns heif_error_ok if a supported brand is found, or other error if not."] + pub fn heif_has_compatible_filetype(data: *const u8, len: libc::c_int) -> heif_error; +} extern "C" { pub fn heif_check_jpeg_filetype(data: *const u8, len: libc::c_int) -> libc::c_int; } @@ -582,71 +515,19 @@ pub struct heif_reader { ) -> heif_reader_grow_status, >, } -#[test] -fn bindgen_test_layout_heif_reader() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 40usize, - concat!("Size of: ", stringify!(heif_reader)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(heif_reader)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reader_api_version) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(heif_reader), - "::", - stringify!(reader_api_version) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).get_position) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(heif_reader), - "::", - stringify!(get_position) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).read) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(heif_reader), - "::", - stringify!(read) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).seek) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(heif_reader), - "::", - stringify!(seek) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).wait_for_file_size) as usize - ptr as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(heif_reader), - "::", - stringify!(wait_for_file_size) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of heif_reader"][::std::mem::size_of::() - 40usize]; + ["Alignment of heif_reader"][::std::mem::align_of::() - 8usize]; + ["Offset of field: heif_reader::reader_api_version"] + [::std::mem::offset_of!(heif_reader, reader_api_version) - 0usize]; + ["Offset of field: heif_reader::get_position"] + [::std::mem::offset_of!(heif_reader, get_position) - 8usize]; + ["Offset of field: heif_reader::read"][::std::mem::offset_of!(heif_reader, read) - 16usize]; + ["Offset of field: heif_reader::seek"][::std::mem::offset_of!(heif_reader, seek) - 24usize]; + ["Offset of field: heif_reader::wait_for_file_size"] + [::std::mem::offset_of!(heif_reader, wait_for_file_size) - 32usize]; +}; extern "C" { #[doc = " Read a HEIF file from a named disk file.\n The heif_reading_options should currently be set to NULL."] pub fn heif_context_read_from_file( @@ -838,158 +719,45 @@ pub struct heif_depth_representation_info { pub depth_nonlinear_representation_model_size: u32, pub depth_nonlinear_representation_model: *mut u8, } -#[test] -fn bindgen_test_layout_heif_depth_representation_info() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 64usize, - concat!("Size of: ", stringify!(heif_depth_representation_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(heif_depth_representation_info)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(heif_depth_representation_info), - "::", - stringify!(version) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).has_z_near) as usize - ptr as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(heif_depth_representation_info), - "::", - stringify!(has_z_near) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).has_z_far) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(heif_depth_representation_info), - "::", - stringify!(has_z_far) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).has_d_min) as usize - ptr as usize }, - 3usize, - concat!( - "Offset of field: ", - stringify!(heif_depth_representation_info), - "::", - stringify!(has_d_min) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).has_d_max) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(heif_depth_representation_info), - "::", - stringify!(has_d_max) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).z_near) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(heif_depth_representation_info), - "::", - stringify!(z_near) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).z_far) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(heif_depth_representation_info), - "::", - stringify!(z_far) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).d_min) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(heif_depth_representation_info), - "::", - stringify!(d_min) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).d_max) as usize - ptr as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(heif_depth_representation_info), - "::", - stringify!(d_max) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).depth_representation_type) as usize - ptr as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(heif_depth_representation_info), - "::", - stringify!(depth_representation_type) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).disparity_reference_view) as usize - ptr as usize }, - 44usize, - concat!( - "Offset of field: ", - stringify!(heif_depth_representation_info), - "::", - stringify!(disparity_reference_view) - ) - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).depth_nonlinear_representation_model_size) as usize - - ptr as usize - }, - 48usize, - concat!( - "Offset of field: ", - stringify!(heif_depth_representation_info), - "::", - stringify!(depth_nonlinear_representation_model_size) - ) - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).depth_nonlinear_representation_model) as usize - - ptr as usize - }, - 56usize, - concat!( - "Offset of field: ", - stringify!(heif_depth_representation_info), - "::", - stringify!(depth_nonlinear_representation_model) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of heif_depth_representation_info"] + [::std::mem::size_of::() - 64usize]; + ["Alignment of heif_depth_representation_info"] + [::std::mem::align_of::() - 8usize]; + ["Offset of field: heif_depth_representation_info::version"] + [::std::mem::offset_of!(heif_depth_representation_info, version) - 0usize]; + ["Offset of field: heif_depth_representation_info::has_z_near"] + [::std::mem::offset_of!(heif_depth_representation_info, has_z_near) - 1usize]; + ["Offset of field: heif_depth_representation_info::has_z_far"] + [::std::mem::offset_of!(heif_depth_representation_info, has_z_far) - 2usize]; + ["Offset of field: heif_depth_representation_info::has_d_min"] + [::std::mem::offset_of!(heif_depth_representation_info, has_d_min) - 3usize]; + ["Offset of field: heif_depth_representation_info::has_d_max"] + [::std::mem::offset_of!(heif_depth_representation_info, has_d_max) - 4usize]; + ["Offset of field: heif_depth_representation_info::z_near"] + [::std::mem::offset_of!(heif_depth_representation_info, z_near) - 8usize]; + ["Offset of field: heif_depth_representation_info::z_far"] + [::std::mem::offset_of!(heif_depth_representation_info, z_far) - 16usize]; + ["Offset of field: heif_depth_representation_info::d_min"] + [::std::mem::offset_of!(heif_depth_representation_info, d_min) - 24usize]; + ["Offset of field: heif_depth_representation_info::d_max"] + [::std::mem::offset_of!(heif_depth_representation_info, d_max) - 32usize]; + ["Offset of field: heif_depth_representation_info::depth_representation_type"][::std::mem::offset_of!( + heif_depth_representation_info, + depth_representation_type + ) - 40usize]; + ["Offset of field: heif_depth_representation_info::disparity_reference_view"][::std::mem::offset_of!( + heif_depth_representation_info, + disparity_reference_view + ) - 44usize]; + ["Offset of field: heif_depth_representation_info::depth_nonlinear_representation_model_size"] [:: std :: mem :: offset_of ! (heif_depth_representation_info , depth_nonlinear_representation_model_size) - 48usize] ; + ["Offset of field: heif_depth_representation_info::depth_nonlinear_representation_model"][::std::mem::offset_of!( + heif_depth_representation_info, + depth_nonlinear_representation_model + ) + - 56usize]; +}; extern "C" { pub fn heif_depth_representation_info_free(info: *const heif_depth_representation_info); } @@ -1239,152 +1007,38 @@ pub struct heif_color_profile_nclx { pub color_primary_white_x: f32, pub color_primary_white_y: f32, } -#[test] -fn bindgen_test_layout_heif_color_profile_nclx() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 52usize, - concat!("Size of: ", stringify!(heif_color_profile_nclx)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(heif_color_profile_nclx)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(heif_color_profile_nclx), - "::", - stringify!(version) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).color_primaries) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(heif_color_profile_nclx), - "::", - stringify!(color_primaries) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).transfer_characteristics) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(heif_color_profile_nclx), - "::", - stringify!(transfer_characteristics) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).matrix_coefficients) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(heif_color_profile_nclx), - "::", - stringify!(matrix_coefficients) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).full_range_flag) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(heif_color_profile_nclx), - "::", - stringify!(full_range_flag) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).color_primary_red_x) as usize - ptr as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(heif_color_profile_nclx), - "::", - stringify!(color_primary_red_x) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).color_primary_red_y) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(heif_color_profile_nclx), - "::", - stringify!(color_primary_red_y) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).color_primary_green_x) as usize - ptr as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(heif_color_profile_nclx), - "::", - stringify!(color_primary_green_x) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).color_primary_green_y) as usize - ptr as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(heif_color_profile_nclx), - "::", - stringify!(color_primary_green_y) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).color_primary_blue_x) as usize - ptr as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(heif_color_profile_nclx), - "::", - stringify!(color_primary_blue_x) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).color_primary_blue_y) as usize - ptr as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(heif_color_profile_nclx), - "::", - stringify!(color_primary_blue_y) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).color_primary_white_x) as usize - ptr as usize }, - 44usize, - concat!( - "Offset of field: ", - stringify!(heif_color_profile_nclx), - "::", - stringify!(color_primary_white_x) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).color_primary_white_y) as usize - ptr as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(heif_color_profile_nclx), - "::", - stringify!(color_primary_white_y) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of heif_color_profile_nclx"][::std::mem::size_of::() - 52usize]; + ["Alignment of heif_color_profile_nclx"] + [::std::mem::align_of::() - 4usize]; + ["Offset of field: heif_color_profile_nclx::version"] + [::std::mem::offset_of!(heif_color_profile_nclx, version) - 0usize]; + ["Offset of field: heif_color_profile_nclx::color_primaries"] + [::std::mem::offset_of!(heif_color_profile_nclx, color_primaries) - 4usize]; + ["Offset of field: heif_color_profile_nclx::transfer_characteristics"] + [::std::mem::offset_of!(heif_color_profile_nclx, transfer_characteristics) - 8usize]; + ["Offset of field: heif_color_profile_nclx::matrix_coefficients"] + [::std::mem::offset_of!(heif_color_profile_nclx, matrix_coefficients) - 12usize]; + ["Offset of field: heif_color_profile_nclx::full_range_flag"] + [::std::mem::offset_of!(heif_color_profile_nclx, full_range_flag) - 16usize]; + ["Offset of field: heif_color_profile_nclx::color_primary_red_x"] + [::std::mem::offset_of!(heif_color_profile_nclx, color_primary_red_x) - 20usize]; + ["Offset of field: heif_color_profile_nclx::color_primary_red_y"] + [::std::mem::offset_of!(heif_color_profile_nclx, color_primary_red_y) - 24usize]; + ["Offset of field: heif_color_profile_nclx::color_primary_green_x"] + [::std::mem::offset_of!(heif_color_profile_nclx, color_primary_green_x) - 28usize]; + ["Offset of field: heif_color_profile_nclx::color_primary_green_y"] + [::std::mem::offset_of!(heif_color_profile_nclx, color_primary_green_y) - 32usize]; + ["Offset of field: heif_color_profile_nclx::color_primary_blue_x"] + [::std::mem::offset_of!(heif_color_profile_nclx, color_primary_blue_x) - 36usize]; + ["Offset of field: heif_color_profile_nclx::color_primary_blue_y"] + [::std::mem::offset_of!(heif_color_profile_nclx, color_primary_blue_y) - 40usize]; + ["Offset of field: heif_color_profile_nclx::color_primary_white_x"] + [::std::mem::offset_of!(heif_color_profile_nclx, color_primary_white_x) - 44usize]; + ["Offset of field: heif_color_profile_nclx::color_primary_white_y"] + [::std::mem::offset_of!(heif_color_profile_nclx, color_primary_white_y) - 48usize]; +}; extern "C" { pub fn heif_nclx_color_profile_set_color_primaries( nclx: *mut heif_color_profile_nclx, @@ -1435,6 +1089,69 @@ extern "C" { out_data: *mut *mut heif_color_profile_nclx, ) -> heif_error; } +#[doc = " ------------------------- intrinsic and extrinsic matrices -------------------------"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct heif_camera_intrinsic_matrix { + pub focal_length_x: f64, + pub focal_length_y: f64, + pub principal_point_x: f64, + pub principal_point_y: f64, + pub skew: f64, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of heif_camera_intrinsic_matrix"] + [::std::mem::size_of::() - 40usize]; + ["Alignment of heif_camera_intrinsic_matrix"] + [::std::mem::align_of::() - 8usize]; + ["Offset of field: heif_camera_intrinsic_matrix::focal_length_x"] + [::std::mem::offset_of!(heif_camera_intrinsic_matrix, focal_length_x) - 0usize]; + ["Offset of field: heif_camera_intrinsic_matrix::focal_length_y"] + [::std::mem::offset_of!(heif_camera_intrinsic_matrix, focal_length_y) - 8usize]; + ["Offset of field: heif_camera_intrinsic_matrix::principal_point_x"] + [::std::mem::offset_of!(heif_camera_intrinsic_matrix, principal_point_x) - 16usize]; + ["Offset of field: heif_camera_intrinsic_matrix::principal_point_y"] + [::std::mem::offset_of!(heif_camera_intrinsic_matrix, principal_point_y) - 24usize]; + ["Offset of field: heif_camera_intrinsic_matrix::skew"] + [::std::mem::offset_of!(heif_camera_intrinsic_matrix, skew) - 32usize]; +}; +extern "C" { + pub fn heif_image_handle_has_camera_intrinsic_matrix( + handle: *const heif_image_handle, + ) -> libc::c_int; +} +extern "C" { + pub fn heif_image_handle_get_camera_intrinsic_matrix( + handle: *const heif_image_handle, + out_matrix: *mut heif_camera_intrinsic_matrix, + ) -> heif_error; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct heif_camera_extrinsic_matrix { + _unused: [u8; 0], +} +extern "C" { + pub fn heif_image_handle_has_camera_extrinsic_matrix( + handle: *const heif_image_handle, + ) -> libc::c_int; +} +extern "C" { + pub fn heif_image_handle_get_camera_extrinsic_matrix( + handle: *const heif_image_handle, + out_matrix: *mut *mut heif_camera_extrinsic_matrix, + ) -> heif_error; +} +extern "C" { + pub fn heif_camera_extrinsic_matrix_release(arg1: *mut heif_camera_extrinsic_matrix); +} +extern "C" { + pub fn heif_camera_extrinsic_matrix_get_rotation_matrix( + arg1: *const heif_camera_extrinsic_matrix, + out_matrix_row_major: *mut f64, + ) -> heif_error; +} pub const heif_progress_step_heif_progress_step_total: heif_progress_step = 0; pub const heif_progress_step_heif_progress_step_load_tile: heif_progress_step = 1; #[doc = " Planar RGB images are specified as heif_colorspace_RGB / heif_chroma_444."] @@ -1462,72 +1179,32 @@ pub struct heif_color_conversion_options { #[doc = " When set to 'false' libheif may also use a different algorithm if the preferred one is not available\n or using a different algorithm is computationally less complex. Note that currently (v1.17.0) this\n means that for RGB input it will usually choose nearest-neighbor sampling because this is computationally\n the simplest.\n Set this field to 'true' if you want to make sure that the specified algorithm is used even\n at the cost of slightly higher computation times."] pub only_use_preferred_chroma_algorithm: u8, } -#[test] -fn bindgen_test_layout_heif_color_conversion_options() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(heif_color_conversion_options)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(heif_color_conversion_options)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(heif_color_conversion_options), - "::", - stringify!(version) - ) - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).preferred_chroma_downsampling_algorithm) as usize - - ptr as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(heif_color_conversion_options), - "::", - stringify!(preferred_chroma_downsampling_algorithm) - ) - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).preferred_chroma_upsampling_algorithm) as usize - - ptr as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(heif_color_conversion_options), - "::", - stringify!(preferred_chroma_upsampling_algorithm) - ) - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).only_use_preferred_chroma_algorithm) as usize - ptr as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(heif_color_conversion_options), - "::", - stringify!(only_use_preferred_chroma_algorithm) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of heif_color_conversion_options"] + [::std::mem::size_of::() - 16usize]; + ["Alignment of heif_color_conversion_options"] + [::std::mem::align_of::() - 4usize]; + ["Offset of field: heif_color_conversion_options::version"] + [::std::mem::offset_of!(heif_color_conversion_options, version) - 0usize]; + ["Offset of field: heif_color_conversion_options::preferred_chroma_downsampling_algorithm"][::std::mem::offset_of!( + heif_color_conversion_options, + preferred_chroma_downsampling_algorithm + ) + - 4usize]; + ["Offset of field: heif_color_conversion_options::preferred_chroma_upsampling_algorithm"][::std::mem::offset_of!( + heif_color_conversion_options, + preferred_chroma_upsampling_algorithm + ) + - 8usize]; + ["Offset of field: heif_color_conversion_options::only_use_preferred_chroma_algorithm"][::std::mem::offset_of!( + heif_color_conversion_options, + only_use_preferred_chroma_algorithm + ) + - 12usize]; +}; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug)] pub struct heif_decoding_options { pub version: u8, #[doc = " Ignore geometric transformations like cropping, rotation, mirroring.\n Default: false (do not ignore)."] @@ -1559,122 +1236,32 @@ pub struct heif_decoding_options { #[doc = " version 5 options"] pub color_conversion_options: heif_color_conversion_options, } -#[test] -fn bindgen_test_layout_heif_decoding_options() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 72usize, - concat!("Size of: ", stringify!(heif_decoding_options)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(heif_decoding_options)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(heif_decoding_options), - "::", - stringify!(version) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).ignore_transformations) as usize - ptr as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(heif_decoding_options), - "::", - stringify!(ignore_transformations) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).start_progress) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(heif_decoding_options), - "::", - stringify!(start_progress) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).on_progress) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(heif_decoding_options), - "::", - stringify!(on_progress) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).end_progress) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(heif_decoding_options), - "::", - stringify!(end_progress) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).progress_user_data) as usize - ptr as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(heif_decoding_options), - "::", - stringify!(progress_user_data) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).convert_hdr_to_8bit) as usize - ptr as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(heif_decoding_options), - "::", - stringify!(convert_hdr_to_8bit) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).strict_decoding) as usize - ptr as usize }, - 41usize, - concat!( - "Offset of field: ", - stringify!(heif_decoding_options), - "::", - stringify!(strict_decoding) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).decoder_id) as usize - ptr as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(heif_decoding_options), - "::", - stringify!(decoder_id) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).color_conversion_options) as usize - ptr as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(heif_decoding_options), - "::", - stringify!(color_conversion_options) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of heif_decoding_options"][::std::mem::size_of::() - 72usize]; + ["Alignment of heif_decoding_options"] + [::std::mem::align_of::() - 8usize]; + ["Offset of field: heif_decoding_options::version"] + [::std::mem::offset_of!(heif_decoding_options, version) - 0usize]; + ["Offset of field: heif_decoding_options::ignore_transformations"] + [::std::mem::offset_of!(heif_decoding_options, ignore_transformations) - 1usize]; + ["Offset of field: heif_decoding_options::start_progress"] + [::std::mem::offset_of!(heif_decoding_options, start_progress) - 8usize]; + ["Offset of field: heif_decoding_options::on_progress"] + [::std::mem::offset_of!(heif_decoding_options, on_progress) - 16usize]; + ["Offset of field: heif_decoding_options::end_progress"] + [::std::mem::offset_of!(heif_decoding_options, end_progress) - 24usize]; + ["Offset of field: heif_decoding_options::progress_user_data"] + [::std::mem::offset_of!(heif_decoding_options, progress_user_data) - 32usize]; + ["Offset of field: heif_decoding_options::convert_hdr_to_8bit"] + [::std::mem::offset_of!(heif_decoding_options, convert_hdr_to_8bit) - 40usize]; + ["Offset of field: heif_decoding_options::strict_decoding"] + [::std::mem::offset_of!(heif_decoding_options, strict_decoding) - 41usize]; + ["Offset of field: heif_decoding_options::decoder_id"] + [::std::mem::offset_of!(heif_decoding_options, decoder_id) - 48usize]; + ["Offset of field: heif_decoding_options::color_conversion_options"] + [::std::mem::offset_of!(heif_decoding_options, color_conversion_options) - 56usize]; +}; extern "C" { #[doc = " Allocate decoding options and fill with default values.\n Note: you should always get the decoding options through this function since the\n option structure may grow in size in future versions."] pub fn heif_decoding_options_alloc() -> *mut heif_decoding_options; @@ -1811,42 +1398,17 @@ pub struct heif_content_light_level { pub max_content_light_level: u16, pub max_pic_average_light_level: u16, } -#[test] -fn bindgen_test_layout_heif_content_light_level() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(heif_content_light_level)) - ); - assert_eq!( - ::std::mem::align_of::(), - 2usize, - concat!("Alignment of ", stringify!(heif_content_light_level)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).max_content_light_level) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(heif_content_light_level), - "::", - stringify!(max_content_light_level) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).max_pic_average_light_level) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(heif_content_light_level), - "::", - stringify!(max_pic_average_light_level) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of heif_content_light_level"] + [::std::mem::size_of::() - 4usize]; + ["Alignment of heif_content_light_level"] + [::std::mem::align_of::() - 2usize]; + ["Offset of field: heif_content_light_level::max_content_light_level"] + [::std::mem::offset_of!(heif_content_light_level, max_content_light_level) - 0usize]; + ["Offset of field: heif_content_light_level::max_pic_average_light_level"] + [::std::mem::offset_of!(heif_content_light_level, max_pic_average_light_level) - 2usize]; +}; extern "C" { pub fn heif_image_has_content_light_level(arg1: *const heif_image) -> libc::c_int; } @@ -1873,92 +1435,35 @@ pub struct heif_mastering_display_colour_volume { pub max_display_mastering_luminance: u32, pub min_display_mastering_luminance: u32, } -#[test] -fn bindgen_test_layout_heif_mastering_display_colour_volume() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!( - "Size of: ", - stringify!(heif_mastering_display_colour_volume) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!( - "Alignment of ", - stringify!(heif_mastering_display_colour_volume) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).display_primaries_x) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(heif_mastering_display_colour_volume), - "::", - stringify!(display_primaries_x) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).display_primaries_y) as usize - ptr as usize }, - 6usize, - concat!( - "Offset of field: ", - stringify!(heif_mastering_display_colour_volume), - "::", - stringify!(display_primaries_y) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).white_point_x) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(heif_mastering_display_colour_volume), - "::", - stringify!(white_point_x) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).white_point_y) as usize - ptr as usize }, - 14usize, - concat!( - "Offset of field: ", - stringify!(heif_mastering_display_colour_volume), - "::", - stringify!(white_point_y) - ) - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).max_display_mastering_luminance) as usize - ptr as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(heif_mastering_display_colour_volume), - "::", - stringify!(max_display_mastering_luminance) - ) - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).min_display_mastering_luminance) as usize - ptr as usize - }, - 20usize, - concat!( - "Offset of field: ", - stringify!(heif_mastering_display_colour_volume), - "::", - stringify!(min_display_mastering_luminance) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of heif_mastering_display_colour_volume"] + [::std::mem::size_of::() - 24usize]; + ["Alignment of heif_mastering_display_colour_volume"] + [::std::mem::align_of::() - 4usize]; + ["Offset of field: heif_mastering_display_colour_volume::display_primaries_x"][::std::mem::offset_of!( + heif_mastering_display_colour_volume, + display_primaries_x + ) - 0usize]; + ["Offset of field: heif_mastering_display_colour_volume::display_primaries_y"][::std::mem::offset_of!( + heif_mastering_display_colour_volume, + display_primaries_y + ) - 6usize]; + ["Offset of field: heif_mastering_display_colour_volume::white_point_x"] + [::std::mem::offset_of!(heif_mastering_display_colour_volume, white_point_x) - 12usize]; + ["Offset of field: heif_mastering_display_colour_volume::white_point_y"] + [::std::mem::offset_of!(heif_mastering_display_colour_volume, white_point_y) - 14usize]; + ["Offset of field: heif_mastering_display_colour_volume::max_display_mastering_luminance"][::std::mem::offset_of!( + heif_mastering_display_colour_volume, + max_display_mastering_luminance + ) + - 16usize]; + ["Offset of field: heif_mastering_display_colour_volume::min_display_mastering_luminance"][::std::mem::offset_of!( + heif_mastering_display_colour_volume, + min_display_mastering_luminance + ) + - 20usize]; +}; #[doc = " The units for max_display_mastering_luminance and min_display_mastering_luminance is Candelas per square meter."] #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -1970,92 +1475,33 @@ pub struct heif_decoded_mastering_display_colour_volume { pub max_display_mastering_luminance: f64, pub min_display_mastering_luminance: f64, } -#[test] -fn bindgen_test_layout_heif_decoded_mastering_display_colour_volume() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!( - "Size of: ", - stringify!(heif_decoded_mastering_display_colour_volume) - ) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!( - "Alignment of ", - stringify!(heif_decoded_mastering_display_colour_volume) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).display_primaries_x) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(heif_decoded_mastering_display_colour_volume), - "::", - stringify!(display_primaries_x) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).display_primaries_y) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(heif_decoded_mastering_display_colour_volume), - "::", - stringify!(display_primaries_y) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).white_point_x) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(heif_decoded_mastering_display_colour_volume), - "::", - stringify!(white_point_x) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).white_point_y) as usize - ptr as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(heif_decoded_mastering_display_colour_volume), - "::", - stringify!(white_point_y) - ) - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).max_display_mastering_luminance) as usize - ptr as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(heif_decoded_mastering_display_colour_volume), - "::", - stringify!(max_display_mastering_luminance) - ) - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).min_display_mastering_luminance) as usize - ptr as usize - }, - 40usize, - concat!( - "Offset of field: ", - stringify!(heif_decoded_mastering_display_colour_volume), - "::", - stringify!(min_display_mastering_luminance) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of heif_decoded_mastering_display_colour_volume"] + [::std::mem::size_of::() - 48usize]; + ["Alignment of heif_decoded_mastering_display_colour_volume"] + [::std::mem::align_of::() - 8usize]; + ["Offset of field: heif_decoded_mastering_display_colour_volume::display_primaries_x"][::std::mem::offset_of!( + heif_decoded_mastering_display_colour_volume, + display_primaries_x + ) + - 0usize]; + ["Offset of field: heif_decoded_mastering_display_colour_volume::display_primaries_y"][::std::mem::offset_of!( + heif_decoded_mastering_display_colour_volume, + display_primaries_y + ) + - 12usize]; + ["Offset of field: heif_decoded_mastering_display_colour_volume::white_point_x"][::std::mem::offset_of!( + heif_decoded_mastering_display_colour_volume, + white_point_x + ) - 24usize]; + ["Offset of field: heif_decoded_mastering_display_colour_volume::white_point_y"][::std::mem::offset_of!( + heif_decoded_mastering_display_colour_volume, + white_point_y + ) - 28usize]; + ["Offset of field: heif_decoded_mastering_display_colour_volume::max_display_mastering_luminance"] [:: std :: mem :: offset_of ! (heif_decoded_mastering_display_colour_volume , max_display_mastering_luminance) - 32usize] ; + ["Offset of field: heif_decoded_mastering_display_colour_volume::min_display_mastering_luminance"] [:: std :: mem :: offset_of ! (heif_decoded_mastering_display_colour_volume , min_display_mastering_luminance) - 40usize] ; +}; extern "C" { pub fn heif_image_has_mastering_display_colour_volume(arg1: *const heif_image) -> libc::c_int; } @@ -2110,41 +1556,14 @@ pub struct heif_writer { ) -> heif_error, >, } -#[test] -fn bindgen_test_layout_heif_writer() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(heif_writer)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(heif_writer)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).writer_api_version) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(heif_writer), - "::", - stringify!(writer_api_version) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).write) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(heif_writer), - "::", - stringify!(write) - ) - ); -} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of heif_writer"][::std::mem::size_of::() - 16usize]; + ["Alignment of heif_writer"][::std::mem::align_of::() - 8usize]; + ["Offset of field: heif_writer::writer_api_version"] + [::std::mem::offset_of!(heif_writer, writer_api_version) - 0usize]; + ["Offset of field: heif_writer::write"][::std::mem::offset_of!(heif_writer, write) - 8usize]; +}; extern "C" { pub fn heif_context_write( arg1: *mut heif_context, @@ -2152,6 +1571,10 @@ extern "C" { userdata: *mut libc::c_void, ) -> heif_error; } +extern "C" { + #[doc = " Add a compatible brand that is now added automatically by libheif when encoding images (e.g. some application brands like 'geo1')."] + pub fn heif_context_add_compatible_brand(ctx: *mut heif_context, compatible_brand: heif_brand2); +} #[doc = " The encoder used for actually encoding an image."] #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -2450,7 +1873,7 @@ pub const heif_orientation_heif_orientation_rotate_270_cw: heif_orientation = 8; #[doc = " The orientation values are defined equal to the EXIF Orientation tag."] pub type heif_orientation = libc::c_uint; #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug)] pub struct heif_encoding_options { pub version: u8, #[doc = " default: true"] @@ -2466,111 +1889,39 @@ pub struct heif_encoding_options { pub image_orientation: heif_orientation, #[doc = " version 6 options"] pub color_conversion_options: heif_color_conversion_options, -} -#[test] -fn bindgen_test_layout_heif_encoding_options() { - const UNINIT: ::std::mem::MaybeUninit = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 40usize, - concat!("Size of: ", stringify!(heif_encoding_options)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(heif_encoding_options)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(heif_encoding_options), - "::", - stringify!(version) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).save_alpha_channel) as usize - ptr as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(heif_encoding_options), - "::", - stringify!(save_alpha_channel) - ) - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).macOS_compatibility_workaround) as usize - ptr as usize - }, - 2usize, - concat!( - "Offset of field: ", - stringify!(heif_encoding_options), - "::", - stringify!(macOS_compatibility_workaround) - ) - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).save_two_colr_boxes_when_ICC_and_nclx_available) as usize - - ptr as usize - }, - 3usize, - concat!( - "Offset of field: ", - stringify!(heif_encoding_options), - "::", - stringify!(save_two_colr_boxes_when_ICC_and_nclx_available) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).output_nclx_profile) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(heif_encoding_options), - "::", - stringify!(output_nclx_profile) - ) - ); - assert_eq!( - unsafe { - ::std::ptr::addr_of!((*ptr).macOS_compatibility_workaround_no_nclx_profile) as usize - - ptr as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(heif_encoding_options), - "::", - stringify!(macOS_compatibility_workaround_no_nclx_profile) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).image_orientation) as usize - ptr as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(heif_encoding_options), - "::", - stringify!(image_orientation) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).color_conversion_options) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(heif_encoding_options), - "::", - stringify!(color_conversion_options) - ) - ); -} + #[doc = " Set this to true to use compressed form of uncC where possible"] + pub prefer_uncC_short_form: u8, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of heif_encoding_options"][::std::mem::size_of::() - 48usize]; + ["Alignment of heif_encoding_options"] + [::std::mem::align_of::() - 8usize]; + ["Offset of field: heif_encoding_options::version"] + [::std::mem::offset_of!(heif_encoding_options, version) - 0usize]; + ["Offset of field: heif_encoding_options::save_alpha_channel"] + [::std::mem::offset_of!(heif_encoding_options, save_alpha_channel) - 1usize]; + ["Offset of field: heif_encoding_options::macOS_compatibility_workaround"] + [::std::mem::offset_of!(heif_encoding_options, macOS_compatibility_workaround) - 2usize]; + ["Offset of field: heif_encoding_options::save_two_colr_boxes_when_ICC_and_nclx_available"][::std::mem::offset_of!( + heif_encoding_options, + save_two_colr_boxes_when_ICC_and_nclx_available + ) + - 3usize]; + ["Offset of field: heif_encoding_options::output_nclx_profile"] + [::std::mem::offset_of!(heif_encoding_options, output_nclx_profile) - 8usize]; + ["Offset of field: heif_encoding_options::macOS_compatibility_workaround_no_nclx_profile"][::std::mem::offset_of!( + heif_encoding_options, + macOS_compatibility_workaround_no_nclx_profile + ) + - 16usize]; + ["Offset of field: heif_encoding_options::image_orientation"] + [::std::mem::offset_of!(heif_encoding_options, image_orientation) - 20usize]; + ["Offset of field: heif_encoding_options::color_conversion_options"] + [::std::mem::offset_of!(heif_encoding_options, color_conversion_options) - 24usize]; + ["Offset of field: heif_encoding_options::prefer_uncC_short_form"] + [::std::mem::offset_of!(heif_encoding_options, prefer_uncC_short_form) - 40usize]; +}; extern "C" { pub fn heif_encoding_options_alloc() -> *mut heif_encoding_options; } @@ -2587,6 +1938,18 @@ extern "C" { out_image_handle: *mut *mut heif_image_handle, ) -> heif_error; } +extern "C" { + #[doc = " @brief Encodes an array of images into a grid.\n\n @param ctx The file context\n @param tiles User allocated array of images that will form the grid.\n @param rows The number of rows in the grid.\n @param columns The number of columns in the grid.\n @param encoder Defines the encoder to use. See heif_context_get_encoder_for_format()\n @param input_options Optional, may be nullptr.\n @param out_image_handle Returns a handle to the grid. The caller is responsible for freeing it.\n @return Returns an error if ctx, tiles, or encoder is nullptr. If rows or columns is 0."] + pub fn heif_context_encode_grid( + ctx: *mut heif_context, + tiles: *mut *mut heif_image, + rows: u16, + columns: u16, + encoder: *mut heif_encoder, + input_options: *const heif_encoding_options, + out_image_handle: *mut *mut heif_image_handle, + ) -> heif_error; +} extern "C" { pub fn heif_context_set_primary_image( arg1: *mut heif_context, @@ -2607,8 +1970,14 @@ extern "C" { } pub const heif_metadata_compression_heif_metadata_compression_off: heif_metadata_compression = 0; pub const heif_metadata_compression_heif_metadata_compression_auto: heif_metadata_compression = 1; -pub const heif_metadata_compression_heif_metadata_compression_deflate: heif_metadata_compression = +#[doc = " only used when reading unknown method from input file"] +pub const heif_metadata_compression_heif_metadata_compression_unknown: heif_metadata_compression = 2; +pub const heif_metadata_compression_heif_metadata_compression_deflate: heif_metadata_compression = + 3; +#[doc = " do not use for header data"] +pub const heif_metadata_compression_heif_metadata_compression_zlib: heif_metadata_compression = 4; +pub const heif_metadata_compression_heif_metadata_compression_brotli: heif_metadata_compression = 5; pub type heif_metadata_compression = libc::c_uint; extern "C" { #[doc = " Assign 'thumbnail_image' as the thumbnail image of 'master_image'."] @@ -2658,7 +2027,18 @@ extern "C" { ) -> heif_error; } extern "C" { - #[doc = " Create a new image of the specified resolution and colorspace.\n Note: no memory for the actual image data is reserved yet. You have to use\n heif_image_add_plane() to add the image planes required by your colorspace/chroma."] + #[doc = " Add generic metadata with item_type \"uri \". Items with this type do not have a content_type, but\n an item_uri_type and they have no content_encoding (they are always stored uncompressed)."] + pub fn heif_context_add_generic_uri_metadata( + ctx: *mut heif_context, + image_handle: *const heif_image_handle, + data: *const libc::c_void, + size: libc::c_int, + item_uri_type: *const libc::c_char, + out_item_id: *mut heif_item_id, + ) -> heif_error; +} +extern "C" { + #[doc = " Create a new image of the specified resolution and colorspace.\n\n

This does not allocate memory for the image data. Use {@link heif_image_add_plane} to\n add the corresponding planes to match the specified {@code colorspace} and {@code chroma}.\n\n @param width the width of the image in pixels\n @param height the height of the image in pixels\n @param colorspace the colorspace of the image\n @param chroma the chroma of the image\n @param out_image pointer to pointer of the resulting image\n @return whether the creation succeeded or there was an error"] pub fn heif_image_create( width: libc::c_int, height: libc::c_int, @@ -2668,7 +2048,7 @@ extern "C" { ) -> heif_error; } extern "C" { - #[doc = " The indicated bit_depth corresponds to the bit depth per channel.\n I.e. for interleaved formats like RRGGBB, the bit_depth would be, e.g., 10 bit instead\n of 30 bits or 3*16=48 bits.\n For backward compatibility, one can also specify 24bits for RGB and 32bits for RGBA,\n instead of the preferred 8 bits."] + #[doc = " Add an image plane to the image.\n\n

The image plane needs to match the colorspace and chroma of the image. Note\n that this does not need to be a single \"planar\" format - interleaved pixel channels\n can also be used if the chroma is interleaved.\n\n

The indicated bit_depth corresponds to the bit depth per channel. For example,\n with an interleaved format like RRGGBB where each color is represented by 10 bits,\n the {@code bit_depth} would be {@code 10} rather than {@code 30}.\n\n

For backward compatibility, one can also specify 24bits for RGB and 32bits for RGBA,\n instead of the preferred 8 bits. However, this use is deprecated.\n\n @param image the parent image to add the channel plane to\n @param channel the channel of the plane to add\n @param width the width of the plane\n @param height the height of the plane\n @param bit_depth the bit depth per color channel\n @return whether the addition succeeded or there was an error\n\n @note The width and height are usually the same as the parent image, but can be\n less for subsampling.\n\n @note The specified width can differ from the row stride of the resulting image plane.\n Always use the result of {@link heif_image_get_plane} or {@link heif_image_get_plane_readonly}\n to determine row stride."] pub fn heif_image_add_plane( image: *mut heif_image, channel: heif_channel, @@ -2731,3 +2111,633 @@ extern "C" { arg1: *const heif_encoder_descriptor, ) -> libc::c_int; } +extern "C" { + #[doc = " Gets the number of items.\n\n This is not the same as the number of images, since there can be other types of items,\n such as metadata.\n\n @param ctx the file context\n @return the number of items"] + pub fn heif_context_get_number_of_items(ctx: *const heif_context) -> libc::c_int; +} +extern "C" { + #[doc = " Get the item identifiers.\n\n Fills in the item IDs into the user-supplied array {@code ID_array}, preallocated with {@code count} entries.\n\n @param ctx the file context\n @param ID_array the output array.\n @param count the number of items allocated within {@code ID_array}.\n @return the total number of IDs filled into the array, which may be less than {@code count}."] + pub fn heif_context_get_list_of_item_IDs( + ctx: *const heif_context, + ID_array: *mut heif_item_id, + count: libc::c_int, + ) -> libc::c_int; +} +extern "C" { + #[doc = " Gets the item type.\n\n Usually, this is a four character code (e.g. `mime` or `uri `), but it can theoretically be\n any 4-byte number. Thus, the type is returned as an integer. You can use {@link heif_fourcc} to map\n between the two representations.\n\n @param ctx the file context\n @param item_id the item identifier for the item\n @return the item type"] + pub fn heif_item_get_item_type(ctx: *const heif_context, item_id: heif_item_id) -> u32; +} +extern "C" { + pub fn heif_item_is_item_hidden(ctx: *const heif_context, item_id: heif_item_id) + -> libc::c_int; +} +extern "C" { + #[doc = " Gets the MIME content_type for an item.\n\n Only valid if the item type is `mime`.\n If the item does not exist, or if it is not a `mime` item, NULL is returned.\n\n @param ctx the file context\n @param item_id the item identifier for the item\n @return the item content_type"] + pub fn heif_item_get_mime_item_content_type( + ctx: *const heif_context, + item_id: heif_item_id, + ) -> *const libc::c_char; +} +extern "C" { + #[doc = " Gets the content_encoding for a MIME item.\n\n Only valid if the item type is `mime`.\n If the item does not exist, or if it is not a `mime` item, NULL is returned.\n\n If the item is not encoded, the returned value will be an empty string (not null).\n\n @param ctx the file context\n @param item_id the item identifier for the item\n @return the item content_type"] + pub fn heif_item_get_mime_item_content_encoding( + ctx: *const heif_context, + item_id: heif_item_id, + ) -> *const libc::c_char; +} +extern "C" { + #[doc = " Gets the item_uri_type for an item.\n\n Only valid if the item type is `uri `.\n If the item does not exist, or if it is not a `uri ` item, NULL is returned.\n\n @param ctx the file context\n @param item_id the item identifier for the item\n @return the item item_uri_type"] + pub fn heif_item_get_uri_item_uri_type( + ctx: *const heif_context, + item_id: heif_item_id, + ) -> *const libc::c_char; +} +extern "C" { + pub fn heif_item_get_item_name( + ctx: *const heif_context, + item_id: heif_item_id, + ) -> *const libc::c_char; +} +extern "C" { + pub fn heif_item_set_item_name( + ctx: *mut heif_context, + item: heif_item_id, + item_name: *const libc::c_char, + ) -> heif_error; +} +extern "C" { + #[doc = " Gets the raw metadata, as stored in the HEIF file.\n\n Data in a \"mime\" item with \"content_encoding\" can be compressed.\n When `out_compression_format` is NULL, the decompressed data will be returned.\n Otherwise, the compressed data is returned and `out_compression_format` will be filled with the\n compression format.\n If the compression method is not supported, an error will be returned.\n\n It is valid to set `out_data` to NULL. In that case, only the `out_data_size` is filled.\n Note that it is inefficient to use `out_data=NULL` just to get the size of compressed data.\n In general, this should be avoided.\n\n If there is no data assigned to the item or there is an error, `out_data_size` is set to zero.\n\n @param ctx the file context\n @param item_id the item identifier for the item\n @param out_compression_format how the data is compressed. If the pointer is NULL, the decompressed data will be returned.\n @param out_data the corresponding raw metadata\n @param out_data_size the size of the metadata in bytes\n @return whether the call succeeded, or there was an error"] + pub fn heif_item_get_item_data( + ctx: *const heif_context, + item_id: heif_item_id, + out_compression_format: *mut heif_metadata_compression, + out_data: *mut *mut u8, + out_data_size: *mut usize, + ) -> heif_error; +} +extern "C" { + #[doc = " Free the item data.\n\n This is used to free memory associated with the data returned by\n {@link heif_item_get_item_data} in 'out_data' and set the pointer to NULL.\n\n @param ctx the file context\n @param item_data the data to free"] + pub fn heif_release_item_data(ctx: *const heif_context, item_data: *mut *mut u8); +} +extern "C" { + #[doc = " Get the item ids that reference the given item.\n\n @param ctx the file context.\n @param from_item_id the item identifier for the item.\n @param index the index of the reference to get.\n @param out_reference_type_4cc The 4cc of the reference. (e.g dimg, thmb, cdsc, or auxl)\n @param out_references_to the item references. Use {@link heif_release_item_references} to free the memory.\n @return the number of items that reference the given item. Returns 0 if the index exceeds the number of references."] + pub fn heif_context_get_item_references( + ctx: *const heif_context, + from_item_id: heif_item_id, + index: libc::c_int, + out_reference_type_4cc: *mut u32, + out_references_to: *mut *mut heif_item_id, + ) -> usize; +} +extern "C" { + pub fn heif_release_item_references( + ctx: *const heif_context, + references: *mut *mut heif_item_id, + ); +} +extern "C" { + pub fn heif_context_add_item_reference( + ctx: *mut heif_context, + reference_type: u32, + from_item: heif_item_id, + to_item: heif_item_id, + ) -> heif_error; +} +extern "C" { + pub fn heif_context_add_item_references( + ctx: *mut heif_context, + reference_type: u32, + from_item: heif_item_id, + to_item: *const heif_item_id, + num_to_items: libc::c_int, + ) -> heif_error; +} +extern "C" { + #[doc = " ------------------------- adding new items -------------------------"] + pub fn heif_context_add_item( + ctx: *mut heif_context, + item_type: *const libc::c_char, + data: *const libc::c_void, + size: libc::c_int, + out_item_id: *mut heif_item_id, + ) -> heif_error; +} +extern "C" { + pub fn heif_context_add_mime_item( + ctx: *mut heif_context, + content_type: *const libc::c_char, + content_encoding: heif_metadata_compression, + data: *const libc::c_void, + size: libc::c_int, + out_item_id: *mut heif_item_id, + ) -> heif_error; +} +extern "C" { + pub fn heif_context_add_precompressed_mime_item( + ctx: *mut heif_context, + content_type: *const libc::c_char, + content_encoding: *const libc::c_char, + data: *const libc::c_void, + size: libc::c_int, + out_item_id: *mut heif_item_id, + ) -> heif_error; +} +extern "C" { + pub fn heif_context_add_uri_item( + ctx: *mut heif_context, + item_uri_type: *const libc::c_char, + data: *const libc::c_void, + size: libc::c_int, + out_item_id: *mut heif_item_id, + ) -> heif_error; +} +#[doc = " heif_item_property_unknown = -1,"] +pub const heif_item_property_type_heif_item_property_type_invalid: heif_item_property_type = 0; +#[doc = " heif_item_property_unknown = -1,"] +pub const heif_item_property_type_heif_item_property_type_user_description: + heif_item_property_type = 1969513843; +#[doc = " heif_item_property_unknown = -1,"] +pub const heif_item_property_type_heif_item_property_type_transform_mirror: + heif_item_property_type = 1768778098; +#[doc = " heif_item_property_unknown = -1,"] +pub const heif_item_property_type_heif_item_property_type_transform_rotation: + heif_item_property_type = 1769107316; +#[doc = " heif_item_property_unknown = -1,"] +pub const heif_item_property_type_heif_item_property_type_transform_crop: heif_item_property_type = + 1668047216; +#[doc = " heif_item_property_unknown = -1,"] +pub const heif_item_property_type_heif_item_property_type_image_size: heif_item_property_type = + 1769173093; +#[doc = " heif_item_property_unknown = -1,"] +pub const heif_item_property_type_heif_item_property_type_uuid: heif_item_property_type = + 1970628964; +#[doc = " ------------------------- item properties -------------------------"] +pub type heif_item_property_type = libc::c_uint; +extern "C" { + #[doc = " Get the heif_property_id for a heif_item_id.\n You may specify which property 'type' you want to receive.\n If you specify 'heif_item_property_type_invalid', all properties associated to that item are returned.\n The number of properties is returned, which are not more than 'count' if (out_list != nullptr).\n By setting out_list==nullptr, you can query the number of properties, 'count' is ignored."] + pub fn heif_item_get_properties_of_type( + context: *const heif_context, + id: heif_item_id, + type_: heif_item_property_type, + out_list: *mut heif_property_id, + count: libc::c_int, + ) -> libc::c_int; +} +extern "C" { + #[doc = " Returns all transformative properties in the correct order.\n This includes \"irot\", \"imir\", \"clap\".\n The number of properties is returned, which are not more than 'count' if (out_list != nullptr).\n By setting out_list==nullptr, you can query the number of properties, 'count' is ignored."] + pub fn heif_item_get_transformation_properties( + context: *const heif_context, + id: heif_item_id, + out_list: *mut heif_property_id, + count: libc::c_int, + ) -> libc::c_int; +} +extern "C" { + pub fn heif_item_get_property_type( + context: *const heif_context, + id: heif_item_id, + property_id: heif_property_id, + ) -> heif_item_property_type; +} +#[doc = " The strings are managed by libheif. They will be deleted in heif_property_user_description_release()."] +#[repr(C)] +#[derive(Debug)] +pub struct heif_property_user_description { + pub version: libc::c_int, + #[doc = " version 1"] + pub lang: *const libc::c_char, + pub name: *const libc::c_char, + pub description: *const libc::c_char, + pub tags: *const libc::c_char, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of heif_property_user_description"] + [::std::mem::size_of::() - 40usize]; + ["Alignment of heif_property_user_description"] + [::std::mem::align_of::() - 8usize]; + ["Offset of field: heif_property_user_description::version"] + [::std::mem::offset_of!(heif_property_user_description, version) - 0usize]; + ["Offset of field: heif_property_user_description::lang"] + [::std::mem::offset_of!(heif_property_user_description, lang) - 8usize]; + ["Offset of field: heif_property_user_description::name"] + [::std::mem::offset_of!(heif_property_user_description, name) - 16usize]; + ["Offset of field: heif_property_user_description::description"] + [::std::mem::offset_of!(heif_property_user_description, description) - 24usize]; + ["Offset of field: heif_property_user_description::tags"] + [::std::mem::offset_of!(heif_property_user_description, tags) - 32usize]; +}; +extern "C" { + #[doc = " Get the \"udes\" user description property content.\n Undefined strings are returned as empty strings."] + pub fn heif_item_get_property_user_description( + context: *const heif_context, + itemId: heif_item_id, + propertyId: heif_property_id, + out: *mut *mut heif_property_user_description, + ) -> heif_error; +} +extern "C" { + #[doc = " Add a \"udes\" user description property to the item.\n If any string pointers are NULL, an empty string will be used instead."] + pub fn heif_item_add_property_user_description( + context: *const heif_context, + itemId: heif_item_id, + description: *const heif_property_user_description, + out_propertyId: *mut heif_property_id, + ) -> heif_error; +} +extern "C" { + #[doc = " Release all strings and the object itself.\n Only call for objects that you received from heif_item_get_property_user_description()."] + pub fn heif_property_user_description_release(arg1: *mut heif_property_user_description); +} +pub const heif_transform_mirror_direction_heif_transform_mirror_direction_invalid: + heif_transform_mirror_direction = -1; +#[doc = " flip image vertically"] +pub const heif_transform_mirror_direction_heif_transform_mirror_direction_vertical: + heif_transform_mirror_direction = 0; +#[doc = " flip image horizontally"] +pub const heif_transform_mirror_direction_heif_transform_mirror_direction_horizontal: + heif_transform_mirror_direction = 1; +pub type heif_transform_mirror_direction = libc::c_int; +extern "C" { + #[doc = " Will return 'heif_transform_mirror_direction_invalid' in case of error."] + pub fn heif_item_get_property_transform_mirror( + context: *const heif_context, + itemId: heif_item_id, + propertyId: heif_property_id, + ) -> heif_transform_mirror_direction; +} +extern "C" { + #[doc = " Returns only 0, 90, 180, or 270 angle values.\n Returns -1 in case of error (but it will only return an error in case of wrong usage)."] + pub fn heif_item_get_property_transform_rotation_ccw( + context: *const heif_context, + itemId: heif_item_id, + propertyId: heif_property_id, + ) -> libc::c_int; +} +extern "C" { + #[doc = " Returns the number of pixels that should be removed from the four edges.\n Because of the way this data is stored, you have to pass the image size at the moment of the crop operation\n to compute the cropped border sizes."] + pub fn heif_item_get_property_transform_crop_borders( + context: *const heif_context, + itemId: heif_item_id, + propertyId: heif_property_id, + image_width: libc::c_int, + image_height: libc::c_int, + left: *mut libc::c_int, + top: *mut libc::c_int, + right: *mut libc::c_int, + bottom: *mut libc::c_int, + ); +} +extern "C" { + #[doc = " @param context\n @param itemId The image item id to which this property belongs.\n @param fourcc_type The short four-cc type of the property to add.\n @param uuid_type If fourcc_type=='uuid', this should point to a 16-byte UUID type. It is ignored otherwise and can be NULL.\n @param data Data to insert for this property (including a full-box header, if required for this box).\n @param size Length of data in bytes.\n @param is_essential Whether this property is essential (boolean).\n @param out_propertyId Outputs the id of the inserted property. Can be NULL."] + pub fn heif_item_add_raw_property( + context: *const heif_context, + itemId: heif_item_id, + fourcc_type: u32, + uuid_type: *const u8, + data: *const u8, + size: usize, + is_essential: libc::c_int, + out_propertyId: *mut heif_property_id, + ) -> heif_error; +} +extern "C" { + pub fn heif_item_get_property_raw_size( + context: *const heif_context, + itemId: heif_item_id, + propertyId: heif_property_id, + out_size: *mut usize, + ) -> heif_error; +} +extern "C" { + #[doc = " @param data_out User-supplied array to write the property data to. The required size of the output array is given by heif_item_get_property_raw_size()."] + pub fn heif_item_get_property_raw_data( + context: *const heif_context, + itemId: heif_item_id, + propertyId: heif_property_id, + out_data: *mut u8, + ) -> heif_error; +} +#[doc = " See ISO/IEC 23008-12:2022 Section 6.10 \"Region items and region annotations\""] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct heif_region_item { + _unused: [u8; 0], +} +#[doc = " Point gemetry.\n\n The region is represented by a single point."] +pub const heif_region_type_heif_region_type_point: heif_region_type = 0; +#[doc = " Rectangle geometry.\n\n The region is represented by a top left position, and a size defined\n by a width and height. All of the interior points and the edge are\n part of the region."] +pub const heif_region_type_heif_region_type_rectangle: heif_region_type = 1; +#[doc = " Ellipse geometry.\n\n The region is represented by a centre point, and radii in the X and\n Y directions. All of the interior points and the edge are part of the\n region."] +pub const heif_region_type_heif_region_type_ellipse: heif_region_type = 2; +#[doc = " Polygon geometry.\n\n The region is represented by a sequence of points, which is considered\n implicitly closed. All of the interior points and the edge are part\n of the region."] +pub const heif_region_type_heif_region_type_polygon: heif_region_type = 3; +#[doc = " Reference mask.\n\n The region geometry is described by the pixels in another image item,\n which has a item reference of type `mask` from the region item to the\n image item containing the mask.\n\n The image item containing the mask is one of:\n\n - a mask item (see ISO/IEC 23008-12:2022 Section 6.10.2), or a derived\n image from a mask item\n\n - an image item in monochrome format (4:0:0 chroma)\n\n - an image item in colour format with luma and chroma planes (e.g. 4:2:0)\n\n If the pixel value is equal to the minimum sample value (e.g. 0 for unsigned\n integer), the pixel is not part of the region. If the pixel value is equal\n to the maximum sample value (e.g. 255 for 8 bit unsigned integer), the pixel\n is part of the region. If the pixel value is between the minimum sample value\n and maximum sample value, the pixel value represents an (application defined)\n probability that the pixel is part of the region, where higher pixel values\n correspond to higher probability values."] +pub const heif_region_type_heif_region_type_referenced_mask: heif_region_type = 4; +#[doc = " Inline mask.\n\n The region geometry is described by a sequence of bits stored in inline\n in the region, one bit per pixel. If the bit value is `1`, the pixel is\n part of the region. If the bit value is `0`, the pixel is not part of the\n region."] +pub const heif_region_type_heif_region_type_inline_mask: heif_region_type = 5; +#[doc = " Polyline geometry.\n\n The region is represented by a sequence of points, which are not\n considered to form a closed surface. Only the edge is part of the region."] +pub const heif_region_type_heif_region_type_polyline: heif_region_type = 6; +#[doc = " Region type.\n\n Each region item will contain zero or more regions, which may have different geometry or\n mask representations."] +pub type heif_region_type = libc::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct heif_region { + _unused: [u8; 0], +} +extern "C" { + #[doc = " Get the number of region items that are attached to an image.\n\n @param image_handle the image handle for the image to query.\n @return the number of region items, which can be zero."] + pub fn heif_image_handle_get_number_of_region_items( + image_handle: *const heif_image_handle, + ) -> libc::c_int; +} +extern "C" { + #[doc = " Get the region item identifiers for the region items attached to an image.\n\n Possible usage (in C++):\n @code\n int numRegionItems = heif_image_handle_get_number_of_region_items(handle);\n if (numRegionItems > 0) {\n std::vector region_item_ids(numRegionItems);\n heif_image_handle_get_list_of_region_item_ids(handle, region_item_ids.data(), numRegionItems);\n // use region item ids\n }\n @endcode\n\n @param image_handle the image handle for the parent image to query\n @param region_item_ids_array array to put the item identifiers into\n @param max_count the maximum number of region identifiers\n @return the number of region item identifiers that were returned."] + pub fn heif_image_handle_get_list_of_region_item_ids( + image_handle: *const heif_image_handle, + region_item_ids_array: *mut heif_item_id, + max_count: libc::c_int, + ) -> libc::c_int; +} +extern "C" { + #[doc = " Get the region item.\n\n Caller is responsible for release of the output heif_region_item with heif_region_item_release().\n\n @param context the context to get the region item from, usually from a file operation\n @param region_item_id the identifier for the region item\n @param out pointer to pointer to the resulting region item\n @return heif_error_ok on success, or an error value indicating the problem"] + pub fn heif_context_get_region_item( + context: *const heif_context, + region_item_id: heif_item_id, + out: *mut *mut heif_region_item, + ) -> heif_error; +} +extern "C" { + #[doc = " Get the item identifier for a region item.\n\n @param region_item the region item to query\n @return the region item identifier (or -1 if the region_item is null)"] + pub fn heif_region_item_get_id(region_item: *mut heif_region_item) -> heif_item_id; +} +extern "C" { + #[doc = " Release a region item.\n\n This should be called on items from heif_context_get_region_item().\n\n @param region_item the item to release."] + pub fn heif_region_item_release(region_item: *mut heif_region_item); +} +extern "C" { + #[doc = " Get the reference size for a region item.\n\n The reference size specifies the coordinate space used for the region items.\n When the reference size does not match the image size, the regions need to be\n scaled to correspond.\n\n @param out_width the return value for the reference width (before any transformation)\n @param out_height the return value for the reference height (before any transformation)"] + pub fn heif_region_item_get_reference_size( + arg1: *mut heif_region_item, + out_width: *mut u32, + out_height: *mut u32, + ); +} +extern "C" { + #[doc = " Get the number of regions within a region item.\n\n @param region_item the region item to query.\n @return the number of regions"] + pub fn heif_region_item_get_number_of_regions( + region_item: *const heif_region_item, + ) -> libc::c_int; +} +extern "C" { + #[doc = " Get the regions that are part of a region item.\n\n Caller is responsible for releasing the returned `heif_region` objects, using heif_region_release()\n on each region, or heif_region_release_many() on the returned array.\n\n Possible usage (in C++):\n @code\n int num_regions = heif_image_handle_get_number_of_regions(region_item);\n if (num_regions > 0) {\n std::vector regions(num_regions);\n int n = heif_region_item_get_list_of_regions(region_item, regions.data(), (int)regions.size());\n // use regions\n heif_region_release_many(regions.data(), n);\n }\n @endcode\n\n @param region_item the region_item to query\n @param out_regions_array array to put the region pointers into\n @param max_count the maximum number of regions, which needs to correspond to the size of the out_regions_array\n @return the number of regions that were returned."] + pub fn heif_region_item_get_list_of_regions( + region_item: *const heif_region_item, + out_regions_array: *mut *mut heif_region, + max_count: libc::c_int, + ) -> libc::c_int; +} +extern "C" { + #[doc = " Release a region.\n\n This should be called on regions from heif_region_item_get_list_of_regions().\n\n @param region the region to release.\n\n \\sa heif_region_release_many() to release the whole list"] + pub fn heif_region_release(region: *const heif_region); +} +extern "C" { + #[doc = " Release a list of regions.\n\n This should be called on the list of regions from heif_region_item_get_list_of_regions().\n\n @param regions_array the regions to release.\n @param num_items the number of items in the array\n\n \\sa heif_region_release() to release a single region"] + pub fn heif_region_release_many( + regions_array: *const *const heif_region, + num_items: libc::c_int, + ); +} +extern "C" { + #[doc = " Get the region type for a specified region.\n\n @param region the region to query\n @return the corresponding region type as an enumeration value"] + pub fn heif_region_get_type(region: *const heif_region) -> heif_region_type; +} +extern "C" { + #[doc = " Get the values for a point region.\n\n This returns the coordinates in the reference coordinate space (from the parent region item).\n\n @param region the region to query, which must be of type #heif_region_type_point.\n @param out_x the X coordinate, where 0 is the left-most column.\n @param out_y the Y coordinate, where 0 is the top-most row.\n @return heif_error_ok on success, or an error value indicating the problem on failure\n\n \\sa heif_region_get_point_transformed() for a version in pixels after all transformative properties have been applied."] + pub fn heif_region_get_point( + region: *const heif_region, + out_x: *mut i32, + out_y: *mut i32, + ) -> heif_error; +} +extern "C" { + #[doc = " Get the transformed values for a point region.\n\n This returns the coordinates in pixels after all transformative properties have been applied.\n\n @param region the region to query, which must be of type #heif_region_type_point.\n @param image_id the identifier for the image to transform / scale the region to\n @param out_x the X coordinate, where 0 is the left-most column.\n @param out_y the Y coordinate, where 0 is the top-most row.\n @return heif_error_ok on success, or an error value indicating the problem on failure\n\n \\sa heif_region_get_point() for a version that returns the values in the reference coordinate space."] + pub fn heif_region_get_point_transformed( + region: *const heif_region, + image_id: heif_item_id, + out_x: *mut f64, + out_y: *mut f64, + ) -> heif_error; +} +extern "C" { + #[doc = " Get the values for a rectangle region.\n\n This returns the values in the reference coordinate space (from the parent region item).\n The rectangle is represented by a top left corner position, and a size defined\n by a width and height. All of the interior points and the edge are\n part of the region.\n\n @param region the region to query, which must be of type #heif_region_type_rectangle.\n @param out_x the X coordinate for the top left corner, where 0 is the left-most column.\n @param out_y the Y coordinate for the top left corner, where 0 is the top-most row.\n @param out_width the width of the rectangle\n @param out_height the height of the rectangle\n @return heif_error_ok on success, or an error value indicating the problem on failure\n\n \\sa heif_region_get_rectangle_transformed() for a version in pixels after all transformative properties have been applied."] + pub fn heif_region_get_rectangle( + region: *const heif_region, + out_x: *mut i32, + out_y: *mut i32, + out_width: *mut u32, + out_height: *mut u32, + ) -> heif_error; +} +extern "C" { + #[doc = " Get the transformed values for a rectangle region.\n\n This returns the coordinates in pixels after all transformative properties have been applied.\n The rectangle is represented by a top left corner position, and a size defined\n by a width and height. All of the interior points and the edge are\n part of the region.\n\n @param region the region to query, which must be of type #heif_region_type_rectangle.\n @param image_id the identifier for the image to transform / scale the region to\n @param out_x the X coordinate for the top left corner, where 0 is the left-most column.\n @param out_y the Y coordinate for the top left corner, where 0 is the top-most row.\n @param out_width the width of the rectangle\n @param out_height the height of the rectangle\n @return heif_error_ok on success, or an error value indicating the problem on failure\n\n \\sa heif_region_get_rectangle() for a version that returns the values in the reference coordinate space."] + pub fn heif_region_get_rectangle_transformed( + region: *const heif_region, + image_id: heif_item_id, + out_x: *mut f64, + out_y: *mut f64, + out_width: *mut f64, + out_height: *mut f64, + ) -> heif_error; +} +extern "C" { + #[doc = " Get the values for an ellipse region.\n\n This returns the values in the reference coordinate space (from the parent region item).\n The ellipse is represented by a centre position, and a size defined\n by radii in the X and Y directions. All of the interior points and the edge are\n part of the region.\n\n @param region the region to query, which must be of type #heif_region_type_ellipse.\n @param out_x the X coordinate for the centre point, where 0 is the left-most column.\n @param out_y the Y coordinate for the centre point, where 0 is the top-most row.\n @param out_radius_x the radius value in the X direction.\n @param out_radius_y the radius value in the Y direction\n @return heif_error_ok on success, or an error value indicating the problem on failure\n\n \\sa heif_region_get_ellipse_transformed() for a version in pixels after all transformative properties have been applied."] + pub fn heif_region_get_ellipse( + region: *const heif_region, + out_x: *mut i32, + out_y: *mut i32, + out_radius_x: *mut u32, + out_radius_y: *mut u32, + ) -> heif_error; +} +extern "C" { + #[doc = " Get the transformed values for an ellipse region.\n\n This returns the coordinates in pixels after all transformative properties have been applied.\n The ellipse is represented by a centre position, and a size defined\n by radii in the X and Y directions. All of the interior points and the edge are\n part of the region.\n\n @param region the region to query, which must be of type #heif_region_type_ellipse.\n @param image_id the identifier for the image to transform / scale the region to\n @param out_x the X coordinate for the centre point, where 0 is the left-most column.\n @param out_y the Y coordinate for the centre point, where 0 is the top-most row.\n @param out_radius_x the radius value in the X direction.\n @param out_radius_y the radius value in the Y direction\n @return heif_error_ok on success, or an error value indicating the problem on failure\n\n \\sa heif_region_get_ellipse() for a version that returns the values in the reference coordinate space."] + pub fn heif_region_get_ellipse_transformed( + region: *const heif_region, + image_id: heif_item_id, + out_x: *mut f64, + out_y: *mut f64, + out_radius_x: *mut f64, + out_radius_y: *mut f64, + ) -> heif_error; +} +extern "C" { + #[doc = " Get the number of points in a polygon.\n\n @param region the region to query, which must be of type #heif_region_type_polygon\n @return the number of points, or -1 on error."] + pub fn heif_region_get_polygon_num_points(region: *const heif_region) -> libc::c_int; +} +extern "C" { + #[doc = " Get the points in a polygon region.\n\n This returns the values in the reference coordinate space (from the parent region item).\n\n A polygon is a sequence of points that form a closed shape. The first point does\n not need to be repeated as the last point. All of the interior points and the edge are\n part of the region.\n The points are returned as pairs of X,Y coordinates, in the order X1,\n Y1, X2, Y2, ..., Xn, Yn.\n\n @param region the region to equery, which must be of type #heif_region_type_polygon\n @param out_pts_array the array to return the points in, which must have twice as many entries as there are points\n in the polygon.\n @return heif_error_ok on success, or an error value indicating the problem on failure\n\n \\sa heif_region_get_polygon_points_transformed() for a version in pixels after all transformative properties have been applied."] + pub fn heif_region_get_polygon_points( + region: *const heif_region, + out_pts_array: *mut i32, + ) -> heif_error; +} +extern "C" { + #[doc = " Get the transformed points in a polygon region.\n\n This returns the coordinates in pixels after all transformative properties have been applied.\n\n A polygon is a sequence of points that form a closed shape. The first point does\n not need to be repeated as the last point. All of the interior points and the edge are\n part of the region.\n The points are returned as pairs of X,Y coordinates, in the order X1,\n Y1, X2, Y2, ..., Xn, Yn.\n\n @param region the region to equery, which must be of type #heif_region_type_polygon\n @param image_id the identifier for the image to transform / scale the region to\n @param out_pts_array the array to return the points in, which must have twice as many entries as there are points\n in the polygon.\n @return heif_error_ok on success, or an error value indicating the problem on failure\n\n \\sa heif_region_get_polygon_points() for a version that returns the values in the reference coordinate space."] + pub fn heif_region_get_polygon_points_transformed( + region: *const heif_region, + image_id: heif_item_id, + out_pts_array: *mut f64, + ) -> heif_error; +} +extern "C" { + #[doc = " Get the number of points in a polyline.\n\n @param region the region to query, which must be of type #heif_region_type_polyline\n @return the number of points, or -1 on error."] + pub fn heif_region_get_polyline_num_points(region: *const heif_region) -> libc::c_int; +} +extern "C" { + #[doc = " Get the points in a polyline region.\n\n This returns the values in the reference coordinate space (from the parent region item).\n\n A polyline is a sequence of points that does not form a closed shape. Even if the\n polyline is closed, the only points that are part of the region are those that\n intersect (even minimally) a one-pixel line drawn along the polyline.\n The points are provided as pairs of X,Y coordinates, in the order X1,\n Y1, X2, Y2, ..., Xn, Yn.\n\n Possible usage (in C++):\n @code\n int num_polyline_points = heif_region_get_polyline_num_points(region);\n if (num_polyline_points > 0) {\n std::vector polyline(num_polyline_points * 2);\n heif_region_get_polyline_points(region, polyline.data());\n // do something with points ...\n }\n @endcode\n\n @param region the region to equery, which must be of type #heif_region_type_polyline\n @param out_pts_array the array to return the points in, which must have twice as many entries as there are points\n in the polyline.\n @return heif_error_ok on success, or an error value indicating the problem on failure\n\n \\sa heif_region_get_polyline_points_transformed() for a version in pixels after all transformative properties have been applied."] + pub fn heif_region_get_polyline_points( + region: *const heif_region, + out_pts_array: *mut i32, + ) -> heif_error; +} +extern "C" { + #[doc = " Get the transformed points in a polyline region.\n\n This returns the coordinates in pixels after all transformative properties have been applied.\n\n A polyline is a sequence of points that does not form a closed shape. Even if the\n polyline is closed, the only points that are part of the region are those that\n intersect (even minimally) a one-pixel line drawn along the polyline.\n The points are provided as pairs of X,Y coordinates, in the order X1,\n Y1, X2, Y2, ..., Xn, Yn.\n\n @param region the region to query, which must be of type #heif_region_type_polyline\n @param image_id the identifier for the image to transform / scale the region to\n @param out_pts_array the array to return the points in, which must have twice as many entries as there are points\n in the polyline.\n @return heif_error_ok on success, or an error value indicating the problem on failure\n\n \\sa heif_region_get_polyline_points() for a version that returns the values in the reference coordinate space."] + pub fn heif_region_get_polyline_points_transformed( + region: *const heif_region, + image_id: heif_item_id, + out_pts_array: *mut f64, + ) -> heif_error; +} +extern "C" { + #[doc = " Get a referenced item mask region.\n\n This returns the values in the reference coordinate space (from the parent region item).\n The mask location is represented by a top left corner position, and a size defined\n by a width and height. The value of each sample in that mask identifies whether the\n corresponding pixel is part of the region.\n\n The mask is provided as an image in another item. The image item containing the mask\n is one of:\n\n - a mask item (see ISO/IEC 23008-12:2022 Section 6.10.2), or a derived\n image from a mask item\n\n - an image item in monochrome format (4:0:0 chroma)\n\n - an image item in colour format with luma and chroma planes (e.g. 4:2:0)\n\n If the pixel value is equal to the minimum sample value (e.g. 0 for unsigned\n integer), the pixel is not part of the region. If the pixel value is equal\n to the maximum sample value (e.g. 255 for 8 bit unsigned integer), the pixel\n is part of the region. If the pixel value is between the minimum sample value\n and maximum sample value, the pixel value represents an (application defined)\n probability that the pixel is part of the region, where higher pixel values\n correspond to higher probability values.\n\n @param region the region to query, which must be of type #heif_region_type_referenced_mask.\n @param out_x the X coordinate for the top left corner, where 0 is the left-most column.\n @param out_y the Y coordinate for the top left corner, where 0 is the top-most row.\n @param out_width the width of the mask region\n @param out_height the height of the mask region\n @param out_mask_item_id the item identifier for the image that provides the mask.\n @return heif_error_ok on success, or an error value indicating the problem on failure"] + pub fn heif_region_get_referenced_mask_ID( + region: *const heif_region, + out_x: *mut i32, + out_y: *mut i32, + out_width: *mut u32, + out_height: *mut u32, + out_mask_item_id: *mut heif_item_id, + ) -> heif_error; +} +extern "C" { + #[doc = " Get the length of the data in an inline mask region.\n\n @param region the region to query, which must be of type #heif_region_type_inline_mask.\n @return the number of bytes in the mask data, or 0 on error."] + pub fn heif_region_get_inline_mask_data_len(region: *const heif_region) -> usize; +} +extern "C" { + #[doc = " Get data for an inline mask region.\n\n This returns the values in the reference coordinate space (from the parent region item).\n The mask location is represented by a top left corner position, and a size defined\n by a width and height.\n\n The mask is held as inline data on the region, one bit per pixel, most significant\n bit first pixel, no padding. If the bit value is `1`, the corresponding pixel is\n part of the region. If the bit value is `0`, the corresponding pixel is not part of the\n region.\n\n Possible usage (in C++):\n @code\n long unsigned int data_len = heif_region_get_inline_mask_data_len(region);\n int32_t x, y;\n uint32_t width, height;\n std::vector mask_data(data_len);\n err = heif_region_get_inline_mask(region, &x, &y, &width, &height, mask_data.data());\n @endcode\n\n @param region the region to query, which must be of type #heif_region_type_inline_mask.\n @param out_x the X coordinate for the top left corner, where 0 is the left-most column.\n @param out_y the Y coordinate for the top left corner, where 0 is the top-most row.\n @param out_width the width of the mask region\n @param out_height the height of the mask region\n @param out_mask_data the location to return the mask data\n @return heif_error_ok on success, or an error value indicating the problem on failure"] + pub fn heif_region_get_inline_mask_data( + region: *const heif_region, + out_x: *mut i32, + out_y: *mut i32, + out_width: *mut u32, + out_height: *mut u32, + out_mask_data: *mut u8, + ) -> heif_error; +} +extern "C" { + #[doc = " Get a mask region image.\n\n This returns the values in the reference coordinate space (from the parent region item).\n The mask location is represented by a top left corner position, and a size defined\n by a width and height.\n\n This function works when the passed region is either a heif_region_type_referenced_mask or\n a heif_region_type_inline_mask.\n The returned image is a monochrome image where each pixel represents the (scaled) probability\n of the pixel being part of the mask.\n\n If the region type is an inline mask, which always holds a binary mask, this function\n converts the binary inline mask to an 8-bit monochrome image with the values '0' and '255'.\n The pixel value is set to `255` where the pixel is part of the region, and `0` where the\n pixel is not part of the region.\n\n @param region the region to query, which must be of type #heif_region_type_inline_mask.\n @param out_x the X coordinate for the top left corner, where 0 is the left-most column.\n @param out_y the Y coordinate for the top left corner, where 0 is the top-most row.\n @param out_width the width of the mask region\n @param out_height the height of the mask region\n @param out_mask_image the returned mask image\n @return heif_error_ok on success, or an error value indicating the problem on failure\n\n \\note the caller is responsible for releasing the mask image"] + pub fn heif_region_get_mask_image( + region: *const heif_region, + out_x: *mut i32, + out_y: *mut i32, + out_width: *mut u32, + out_height: *mut u32, + out_mask_image: *mut *mut heif_image, + ) -> heif_error; +} +extern "C" { + #[doc = " Add a region item to an image.\n\n The region item is a collection of regions (point, polyline, polygon, rectangle, ellipse or mask)\n along with a reference size (width and height) that forms the coordinate basis for the regions.\n\n The concept is to add the region item, then add one or more regions to the region item.\n\n @param image_handle the image to attach the region item to.\n @param reference_width the width of the reference size.\n @param reference_height the height of the reference size.\n @param out_region_item the resulting region item\n @return heif_error_ok on success, or an error indicating the problem on failure"] + pub fn heif_image_handle_add_region_item( + image_handle: *mut heif_image_handle, + reference_width: u32, + reference_height: u32, + out_region_item: *mut *mut heif_region_item, + ) -> heif_error; +} +extern "C" { + #[doc = " Add a point region to the region item.\n\n @param region_item the region item that holds this point region\n @param x the x value for the point location\n @param y the y value for the point location\n @param out_region pointer to pointer to the returned region (optional, see below)\n @return heif_error_ok on success, or an error indicating the problem on failure\n\n @note The `out_region` parameter is optional, and can be set to `NULL` if not needed."] + pub fn heif_region_item_add_region_point( + region_item: *mut heif_region_item, + x: i32, + y: i32, + out_region: *mut *mut heif_region, + ) -> heif_error; +} +extern "C" { + #[doc = " Add a rectangle region to the region item.\n\n @param region_item the region item that holds this rectangle region\n @param x the x value for the top-left corner of this rectangle region\n @param y the y value for the top-left corner of this rectangle region\n @param width the width of this rectangle region\n @param height the height of this rectangle region\n @param out_region pointer to pointer to the returned region (optional, see below)\n @return heif_error_ok on success, or an error indicating the problem on failure\n\n @note The `out_region` parameter is optional, and can be set to `NULL` if not needed."] + pub fn heif_region_item_add_region_rectangle( + region_item: *mut heif_region_item, + x: i32, + y: i32, + width: u32, + height: u32, + out_region: *mut *mut heif_region, + ) -> heif_error; +} +extern "C" { + #[doc = " Add a ellipse region to the region item.\n\n @param region_item the region item that holds this ellipse region\n @param x the x value for the centre of this ellipse region\n @param y the y value for the centre of this ellipse region\n @param radius_x the radius of the ellipse in the X (horizontal) direction\n @param radius_y the radius of the ellipse in the Y (vertical) direction\n @param out_region pointer to pointer to the returned region (optional, see below)\n @return heif_error_ok on success, or an error indicating the problem on failure\n\n @note The `out_region` parameter is optional, and can be set to `NULL` if not needed."] + pub fn heif_region_item_add_region_ellipse( + region_item: *mut heif_region_item, + x: i32, + y: i32, + radius_x: u32, + radius_y: u32, + out_region: *mut *mut heif_region, + ) -> heif_error; +} +extern "C" { + #[doc = " Add a polygon region to the region item.\n\n A polygon is a sequence of points that form a closed shape. The first point does\n not need to be repeated as the last point.\n The points are provided as pairs of X,Y coordinates, in the order X1,\n Y1, X2, Y2, ..., Xn, Yn.\n\n @param region_item the region item that holds this polygon region\n @param pts_array the array of points in X,Y order (see above)\n @param nPoints the number of points\n @param out_region pointer to pointer to the returned region (optional, see below)\n @return heif_error_ok on success, or an error indicating the problem on failure\n\n @note `nPoints` is the number of points, not the number of elements in the array\n @note The `out_region` parameter is optional, and can be set to `NULL` if not needed."] + pub fn heif_region_item_add_region_polygon( + region_item: *mut heif_region_item, + pts_array: *const i32, + nPoints: libc::c_int, + out_region: *mut *mut heif_region, + ) -> heif_error; +} +extern "C" { + #[doc = " Add a polyline region to the region item.\n\n A polyline is a sequence of points that does not form a closed shape. Even if the\n polyline is closed, the only points that are part of the region are those that\n intersect (even minimally) a one-pixel line drawn along the polyline.\n The points are provided as pairs of X,Y coordinates, in the order X1,\n Y1, X2, Y2, ..., Xn, Yn.\n\n @param region_item the region item that holds this polyline region\n @param pts_array the array of points in X,Y order (see above)\n @param nPoints the number of points\n @param out_region pointer to pointer to the returned region (optional, see below)\n @return heif_error_ok on success, or an error indicating the problem on failure\n\n @note `nPoints` is the number of points, not the number of elements in the array\n @note The `out_region` parameter is optional, and can be set to `NULL` if not needed."] + pub fn heif_region_item_add_region_polyline( + region_item: *mut heif_region_item, + pts_array: *const i32, + nPoints: libc::c_int, + out_region: *mut *mut heif_region, + ) -> heif_error; +} +extern "C" { + #[doc = " Add a referenced mask region to the region item.\n\n The region geometry is described by the pixels in another image item,\n which has a item reference of type `mask` from the region item to the\n image item containing the mask.\n\n The image item containing the mask is one of:\n\n - a mask item (see ISO/IEC 23008-12:2022 Section 6.10.2), or a derived\n image from a mask item\n\n - an image item in monochrome format (4:0:0 chroma)\n\n - an image item in colour format with luma and chroma planes (e.g. 4:2:0)\n\n If the pixel value is equal to the minimum sample value (e.g. 0 for unsigned\n integer), the pixel is not part of the region. If the pixel value is equal\n to the maximum sample value (e.g. 255 for 8 bit unsigned integer), the pixel\n is part of the region. If the pixel value is between the minimum sample value\n and maximum sample value, the pixel value represents an (application defined)\n probability that the pixel is part of the region, where higher pixel values\n correspond to higher probability values.\n\n @param region_item the region item that holds this mask region\n @param x the x value for the top-left corner of this mask region\n @param y the y value for the top-left corner of this mask region\n @param width the width of this mask region\n @param height the height of this mask region\n @param mask_item_id the item identifier for the mask that is referenced\n @param out_region pointer to pointer to the returned region (optional, see below)\n @return heif_error_ok on success, or an error indicating the problem on failure\n\n @note The `out_region` parameter is optional, and can be set to `NULL` if not needed."] + pub fn heif_region_item_add_region_referenced_mask( + region_item: *mut heif_region_item, + x: i32, + y: i32, + width: u32, + height: u32, + mask_item_id: heif_item_id, + out_region: *mut *mut heif_region, + ) -> heif_error; +} +extern "C" { + #[doc = " Add an inline mask region to the region item.\n\n The region geometry is described by a top left corner position, and a size defined\n by a width and height.\n\n The mask is held as inline data on the region, one bit per pixel, most significant\n bit first pixel, no padding. If the bit value is `1`, the corresponding pixel is\n part of the region. If the bit value is `0`, the corresponding pixel is not part of the\n region.\n\n @param region_item the region item that holds this mask region\n @param x the x value for the top-left corner of this mask region\n @param y the y value for the top-left corner of this mask region\n @param width the width of this mask region\n @param height the height of this mask region\n @param mask_data the location to return the mask data\n @param mask_data_len the length of the mask data, in bytes\n @param out_region pointer to pointer to the returned region (optional, see below)\n @return heif_error_ok on success, or an error value indicating the problem on failure"] + pub fn heif_region_item_add_region_inline_mask_data( + region_item: *mut heif_region_item, + x: i32, + y: i32, + width: u32, + height: u32, + mask_data: *const u8, + mask_data_len: usize, + out_region: *mut *mut heif_region, + ) -> heif_error; +} +extern "C" { + #[doc = " Add an inline mask region image to the region item.\n\n The region geometry is described by a top left corner position, and a size defined\n by a width and height.\n\n The mask data is held as inline data on the region, one bit per pixel. The provided\n image is converted to inline data, where any pixel with a value >= 0x80 becomes part of the\n mask region. If the image width is less that the specified width, it is expanded\n to match the width of the region (zero fill on the right). If the image height is\n less than the specified height, it is expanded to match the height of the region\n (zero fill on the bottom). If the image width or height is greater than the\n width or height (correspondingly) of the region, the image is cropped.\n\n @param region_item the region item that holds this mask region\n @param x the x value for the top-left corner of this mask region\n @param y the y value for the top-left corner of this mask region\n @param width the width of this mask region\n @param height the height of this mask region\n @param image the image to convert to an inline mask\n @param out_region pointer to pointer to the returned region (optional, see below)\n @return heif_error_ok on success, or an error value indicating the problem on failure"] + pub fn heif_region_item_add_region_inline_mask( + region_item: *mut heif_region_item, + x: i32, + y: i32, + width: u32, + height: u32, + image: *mut heif_image, + out_region: *mut *mut heif_region, + ) -> heif_error; +} diff --git a/src/lib.rs b/src/lib.rs index 4b6b44e..3098649 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,10 +3,10 @@ #![allow(non_camel_case_types)] #![allow(non_snake_case)] -#[cfg(all(feature = "use-bindgen", not(docs_rs)))] +#[cfg(all(feature = "use-bindgen", not(docsrs)))] include!(concat!(env!("OUT_DIR"), "/bindings.rs")); -#[cfg(any(not(feature = "use-bindgen"), docs_rs))] +#[cfg(any(not(feature = "use-bindgen"), docsrs))] mod bindings; -#[cfg(any(not(feature = "use-bindgen"), docs_rs))] +#[cfg(any(not(feature = "use-bindgen"), docsrs))] pub use bindings::*; diff --git a/tests/integration_test.rs b/tests/integration_test.rs index aa4d784..0480791 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -1,3 +1,4 @@ +use std::ffi::CStr; use std::ptr; use libheif_sys as lh; @@ -6,6 +7,8 @@ use libheif_sys as lh; fn create_heic_context() { unsafe { lh::heif_init(ptr::null_mut()); + let version = CStr::from_ptr(lh::heif_get_version()).to_string_lossy(); + assert_eq!(version, "1.18.2"); let ctx = lh::heif_context_alloc(); assert!(!ctx.is_null()); diff --git a/wrapper.h b/wrapper.h deleted file mode 100644 index 4c412d9..0000000 --- a/wrapper.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/wrapper.hpp b/wrapper.hpp new file mode 100644 index 0000000..8e1be3f --- /dev/null +++ b/wrapper.hpp @@ -0,0 +1,7 @@ +#include +#if __has_include("libheif/heif_items.h") + // heif_items.h was added in version 1.18 + #include +#endif +#include +#include