Code Monkey home page Code Monkey logo

libheif's Introduction

libheif

Build Status Build Status Coverity Scan Build Status

libheif is an ISO/IEC 23008-12:2017 HEIF and AVIF (AV1 Image File Format) file format decoder and encoder. There is partial support for ISO/IEC 23008-12:2022 (2nd Edition) capabilities.

HEIF and AVIF are new image file formats employing HEVC (H.265) or AV1 image coding, respectively, for the best compression ratios currently possible.

libheif makes use of libde265 for HEIF image decoding and x265 for encoding. For AVIF, libaom, dav1d, svt-av1, or rav1e are used as codecs.

Supported features

libheif has support for:

  • HEIC, AVIF, JPEG-in-HEIF, JPEG2000, uncompressed (ISO/IEC 23001-17:2023)
  • alpha channels, depth maps, thumbnails, auxiliary images
  • multiple images in a file
  • HDR images, correct color transform according to embedded color profiles
  • image transformations (crop, mirror, rotate), overlay images
  • plugin interface to add alternative codecs
  • reading EXIF and XMP metadata
  • region annotations and mask images
  • decoding of files while downloading (e.g. extract image size before file has been completely downloaded)

Supported codecs:

Format Decoders Encoders
HEIC libde265, ffmpeg x265, kvazaar
AVIF AOM, dav1d AOM, rav1e, svt-av1
JPEG libjpeg(-turbo) libjpeg(-turbo)
JPEG2000 OpenJPEG OpenJPEG
uncompressed built-in built-in

API

The library has a C API for easy integration and wide language support. Note that the API is still work in progress and may still change.

The decoder automatically supports both HEIF and AVIF through the same API. No changes are required to existing code to support AVIF. The encoder can be switched between HEIF and AVIF simply by setting heif_compression_HEVC or heif_compression_AV1 to heif_context_get_encoder_for_format().

Loading the primary image in an HEIF file is as easy as this:

heif_context* ctx = heif_context_alloc();
heif_context_read_from_file(ctx, input_filename, nullptr);

// get a handle to the primary image
heif_image_handle* handle;
heif_context_get_primary_image_handle(ctx, &handle);

// decode the image and convert colorspace to RGB, saved as 24bit interleaved
heif_image* img;
heif_decode_image(handle, &img, heif_colorspace_RGB, heif_chroma_interleaved_RGB, nullptr);

int stride;
const uint8_t* data = heif_image_get_plane_readonly(img, heif_channel_interleaved, &stride);

// ... process data as needed ...

// clean up resources
heif_image_release(img);
heif_image_handle_release(handle);
heif_context_free(ctx);

Writing an HEIF file can be done like this:

heif_context* ctx = heif_context_alloc();

// get the default encoder
heif_encoder* encoder;
heif_context_get_encoder_for_format(ctx, heif_compression_HEVC, &encoder);

// set the encoder parameters
heif_encoder_set_lossy_quality(encoder, 50);

// encode the image
heif_image* image; // code to fill in the image omitted in this example
heif_context_encode_image(ctx, image, encoder, nullptr, nullptr);

heif_encoder_release(encoder);

heif_context_write_to_file(ctx, "output.heic");

heif_context_free(ctx);

Get the EXIF data from an HEIF file:

heif_item_id exif_id;

int n = heif_image_handle_get_list_of_metadata_block_IDs(image_handle, "Exif", &exif_id, 1);
if (n==1) {
  size_t exifSize = heif_image_handle_get_metadata_size(image_handle, exif_id);
  uint8_t* exifData = malloc(exifSize);
  struct heif_error error = heif_image_handle_get_metadata(image_handle, exif_id, exifData);
}

See the header file heif.h for the complete C API.

There is also a C++ API which is a header-only wrapper to the C API. Hence, you can use the C++ API and still be binary compatible. Code using the C++ API is much less verbose than using the C API directly.

There is also an experimental Go API, but this is not stable yet.

Compiling

This library uses the CMake build system (the earlier autotools build files have been removed in v1.16.0).

For a minimal configuration, we recommend to use the codecs libde265 and x265 for HEIC and AOM for AVIF. Make sure that you compile and install libde265 first, so that the configuration script will find this. Also install x265 and its development files if you want to use HEIF encoding, but note that x265 is GPL. An alternative to x265 is kvazaar (BSD).

The basic build steps are as follows (--preset argument needs CMake >= 3.21):

mkdir build
cd build
cmake --preset=release ..
make

There are CMake presets to cover the most frequent use cases.

  • release: the preferred preset which compiles all codecs as separate plugins. If you do not want to distribute some of these plugins (e.g. HEIC), you can omit packaging these.
  • release-noplugins: this is a smaller, self-contained build of libheif without using the plugin system. A single library is built with support for HEIC and AVIF.
  • testing: for building and executing the unit tests. Also the internal library symbols are exposed. Do not use for distribution.
  • fuzzing: all codecs like in release build, but configured into a self-contained library with enabled fuzzers. The library should not distributed.

You can optionally adapt these standard configurations to your needs. This can be done, for example, by calling ccmake . from within the build directory.

CMake configuration variables

Libheif supports many different codecs. In order to reduce the number of dependencies and the library size, you can choose which of these codecs to include. Each codec can be compiled either as built-in to the library with a hard dependency, or as a separate plugin file that is loaded dynamically.

For each codec, there are two configuration variables:

  • WITH_{codec}: enables the codec
  • WITH_{codec}_PLUGIN: when enabled, the codec is compiled as a separate plugin.

In order to use dynamic plugins, also make sure that ENABLE_PLUGIN_LOADING is enabled. The placeholder {codec} can have these values: LIBDE265, X265, AOM_DECODER, AOM_ENCODER, SvtEnc, DAV1D, FFMPEG_DECODER, JPEG_DECODER, JPEG_ENCODER, KVAZAAR, OpenJPEG_DECODER, OpenJPEG_ENCODER.

Further options are:

  • WITH_UNCOMPRESSED_CODEC: enable support for uncompressed images according to ISO/IEC 23001-17:2023. This is experimental and not available as a dynamic plugin.
  • WITH_DEFLATE_HEADER_COMPRESSION: enables support for compressed metadata. When enabled, it adds a dependency to zlib. Note that header compression is not widely supported yet.
  • WITH_LIBSHARPYUV: enables high-quality YCbCr/RGB color space conversion algorithms (requires libsharpyuv, e.g. from the third-party directory).
  • ENABLE_MULTITHREADING_SUPPORT: can be used to disable any multithreading support, e.g. for embedded platforms.
  • ENABLE_PARALLEL_TILE_DECODING: when enabled, libheif will decode tiled images in parallel to speed up compilation.
  • PLUGIN_DIRECTORY: the directory where libheif will search for dynamic plugins when the environment variable LIBHEIF_PLUGIN_PATH is not set.
  • WITH_REDUCED_VISIBILITY: only export those symbols into the library that are public API. Has to be turned off for running the tests.

macOS

  1. Install dependencies with Homebrew

    brew install cmake make pkg-config x265 libde265 libjpeg libtool
  2. Configure and build project (--preset argument needs CMake >= 3.21):

    mkdir build
    cd build
    cmake --preset=release ..
    ./configure
    make

Windows

You can build and install libheif using the vcpkg dependency manager:

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.bat
./vcpkg integrate install
./vcpkg install libheif

The libheif port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository.

Adding libaom encoder/decoder for AVIF

  • Run the aom.cmd script in the third-party directory to download libaom and compile it.

When running cmake or configure, make sure that the environment variable PKG_CONFIG_PATH includes the absolute path to third-party/aom/dist/lib/pkgconfig.

Adding rav1e encoder for AVIF

  • Install cargo.
  • Install cargo-c by executing
cargo install --force cargo-c
  • Run the rav1e.cmd script in the third-party directory to download rav1e and compile it.

When running cmake, make sure that the environment variable PKG_CONFIG_PATH includes the absolute path to third-party/rav1e/dist/lib/pkgconfig.

Adding dav1d decoder for AVIF

  • Install meson.
  • Run the dav1d.cmd script in the third-party directory to download dav1d and compile it.

When running cmake, make sure that the environment variable PKG_CONFIG_PATH includes the absolute path to third-party/dav1d/dist/lib/x86_64-linux-gnu/pkgconfig.

Adding SVT-AV1 encoder for AVIF

You can either use the SVT-AV1 encoder libraries installed in the system or use a self-compiled current version. If you want to compile SVT-AV1 yourself,

  • Run the svt.cmd script in the third-party directory to download SVT-AV1 and compile it.

When running cmake or configure, make sure that the environment variable PKG_CONFIG_PATH includes the absolute path to third-party/SVT-AV1/Build/linux/install/lib/pkgconfig. You may have to replace linux in this path with your system's identifier.

You have to enable SVT-AV1 with CMake.

Codec plugins

Starting with v1.14.0, each codec backend can be compiled statically into libheif or as a dynamically loaded plugin (currently Linux only). You can choose this individually for each codec backend in the CMake settings. Compiling a codec backend as dynamic plugin will generate a shared library that is installed in the system together with libheif. The advantage is that only the required plugins have to be installed and libheif has fewer dependencies.

The plugins are loaded from the colon-separated (semicolon-separated on Windows) list of directories stored in the environment variable LIBHEIF_PLUGIN_PATH. If this variable is empty, they are loaded from a directory specified in the CMake configuration. You can also add plugin directories programmatically.

Codec specific notes

  • the FFMPEG decoding plugin can make use of h265 hardware decoders. However, it currently (v1.17.0, ffmpeg v4.4.2) does not work correctly with all streams. Thus, libheif still prefers the libde265 decoder if it is available.

Encoder benchmark

A current benchmark of the AVIF encoders (as of 14 Oct 2022) can be found on the Wiki page AVIF encoding benchmark.

Language bindings

Languages that can directly interface with C libraries (e.g., Swift, C#) should work out of the box.

Compiling to JavaScript / WASM

libheif can also be compiled to JavaScript using emscripten. It can be built like this (in the libheif directory):

mkdir buildjs
cd buildjs
USE_WASM=0 ../build-emscripten.sh ..

Set USE_WASM=1 to build with WASM output. See the build-emscripten.sh script for further options.

Online demo

Check out this online demo. This is libheif running in JavaScript in your browser.

Example programs

Some example programs are provided in the examples directory. The program heif-convert converts all images stored in an HEIF/AVIF file to JPEG or PNG. heif-enc lets you convert JPEG files to HEIF/AVIF. The program heif-info is a simple, minimal decoder that dumps the file structure to the console.

For example convert example.heic to JPEGs and one of the JPEGs back to HEIF:

cd examples/
./heif-convert example.heic example.jpeg
./heif-enc example-1.jpeg -o example.heif

In order to convert example-1.jpeg to AVIF use:

./heif-enc example-1.jpeg -A -o example.avif

There is also a GIMP plugin using libheif here.

HEIF/AVIF thumbnails for the Gnome desktop

The program heif-thumbnailer can be used as an HEIF/AVIF thumbnailer for the Gnome desktop. The matching Gnome configuration files are in the gnome directory. Place the files heif.xml and avif.xml into /usr/share/mime/packages and heif.thumbnailer into /usr/share/thumbnailers. You may have to run update-mime-database /usr/share/mime to update the list of known MIME types.

gdk-pixbuf loader

libheif also includes a gdk-pixbuf loader for HEIF/AVIF images. 'make install' will copy the plugin into the system directories. However, you will still have to run gdk-pixbuf-query-loaders --update-cache to update the gdk-pixbuf loader database.

Software using libheif

Packaging status

libheif packaging status

Sponsors

Since I work as an independent developer, I need your support to be able to allocate time for libheif. You can sponsor the development using the link in the right hand column.

A big thank you goes to these major sponsors for supporting the development of libheif:

  • Pinterest
  • Shopify shopify-logo
  • StrukturAG

License

The libheif is distributed under the terms of the GNU Lesser General Public License. The sample applications are distributed under the terms of the MIT License.

See COPYING for more details.

Copyright (c) 2017-2020 Struktur AG
Copyright (c) 2017-2023 Dirk Farin
Contact: Dirk Farin [email protected]

libheif's People

Contributors

0xc0000054 avatar amyspark avatar arjendekorte avatar bradh avatar cryptomilk avatar darthsim avatar dependabot[bot] avatar dlemstra avatar dloebl avatar dsookhoo avatar dukesook avatar edi61 avatar ewouth avatar fancycode avatar farindk avatar jamaika1 avatar jerbob92 avatar jonsneyers avatar jsoref avatar kleisauke avatar kmilos avatar lovell avatar maryla-uc avatar ohwgiles avatar piponazo avatar pszemus avatar tingping avatar wantehchang avatar xiaoxiaoafeifei avatar xyproto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libheif's Issues

Use-of-uninitialized-value (9231)

The @ImageMagick project is using https://github.com/google/oss-fuzz to find bugs in our own library and in libraries that we use. The fuzzer found an issue and we think this is an issue that should be resolved in the library that we use. This issue is posted under the url https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9231 that is not publicly visible yet but added as a link for future reference. Below are the details of the issue that can be reproduced using the following technique: https://github.com/google/oss-fuzz/blob/master/docs/reproducing.md

Stacktrace:

WARNING: MemorySanitizer: use-of-uninitialized-value
--
  | #0 0x15a256e in heif::HeifContext::decode_overlay_image(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&) const libheif/src/heif_context.cc:1186:28
  | #1 0x159a257 in heif::HeifContext::decode_image(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>&, heif_decoding_options const*) const libheif/src/heif_context.cc:843:13
  | #2 0x15a2b1b in heif::HeifContext::decode_and_paste_tile_image(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const libheif/src/heif_context.cc:1070:15
  | #3 0x15b9f4a in __invoke<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, const heif::HeifContext *, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int, void> /usr/local/include/c++/v1/type_traits:4421:1
  | #4 0x15b9f4a in heif::Error std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, heif::HeifContext const*, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int>::__execute<1ul, 2ul, 3ul, 4ul, 5ul>(std::__1::__tuple_indices<1ul, 2ul, 3ul, 4ul, 5ul>) /usr/local/include/c++/v1/future:2330
  | #5 0x15b9c08 in std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, heif::HeifContext const*, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int>::operator()() /usr/local/include/c++/v1/future:2323:16
  | #6 0x15b8e4b in std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, heif::HeifContext const*, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> >::__execute() /usr/local/include/c++/v1/future:985:25
  | #7 0x15ba2b7 in __invoke<void (std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, const heif::HeifContext *, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> >::*)(), std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, const heif::HeifContext *, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> > *, void> /usr/local/include/c++/v1/type_traits:4421:1
  | #8 0x15ba2b7 in __thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, const heif::HeifContext *, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> >::*)(), std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, const heif::HeifContext *, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> > *, 2> /usr/local/include/c++/v1/thread:342
  | #9 0x15ba2b7 in void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, heif::HeifContext const*, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> >::*)(), std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, heif::HeifContext const*, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> >*> >(void*) /usr/local/include/c++/v1/thread:352

Links:

if (w >= MAX_IMAGE_WIDTH || h >= MAX_IMAGE_HEIGHT) {

Commit: 01fe0a8
Testcase file: clusterfuzz-testcase-minimized-encoder_heic_fuzzer-5171925214035968.zip

install libheif with apt-get

i have ubuntu 16.04 , can i install libheif with apt-get instead of cloning this git repository and run ./configure, make and make install ?

Compilation failure with recent change in heif.h

In file included from interface.h:25,
from interface.c:28:
/usr/local/include/libheif/heif.h:299:3: error: expected specifier-qualifier-list before ‘heif_reader_grow_status’
heif_reader_grow_status (wait_for_file_size)(int64_t target_size, void userdata);
^~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [Makefile:422: heif_gimp_plugin-interface.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from interface.h:25,
from main.c:30:
/usr/local/include/libheif/heif.h:299:3: error: expected specifier-qualifier-list before ‘heif_reader_grow_status’
heif_reader_grow_status (wait_for_file_size)(int64_t target_size, void userdata);
^~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [Makefile:436: heif_gimp_plugin-main.o] Error 1
make[2]: Leaving directory '/usr/src/strukturag/heif-gimp-plugin/src'

CI: Run tests against fuzzer crash files.

Thanks to @dlemstra we have a couple of fuzzing result files that triggered crashes / undefined behaviour in the past (e.g. #48). We should add them to the repository and run our tests against them from CI to prevent future regressions.

set up a fuzzer test for heif encoder

We should also check the encoding in the fuzzer. Fuzzed parameters could be the image size, color format, encoder parameters and algorithmically generated image content.

Abrt (8922)

The @ImageMagick project is using https://github.com/google/oss-fuzz to find bugs in our own library and in libraries that we use. The fuzzer found an issue and we think this is an issue that should be resolved in the library that we use. This issue is posted under the url https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=8922 that is not publicly visible yet but added as a link for future reference. Below are the details of the issue that can be reproduced using the following technique: https://github.com/google/oss-fuzz/blob/master/docs/reproducing.md

Stacktrace:

==1==ERROR: AddressSanitizer: ABRT on unknown address 0x000000000001 (pc 0x7f5904896428 bp 0x0000018f7ca0 sp 0x7ffc65bccdd8 T0)
--
  | SCARINESS: 10 (signal)
  | #0 0x7f5904896427 in gsignal /build/glibc-Cl5G7W/glibc-2.23/sysdeps/unix/sysv/linux/raise.c:54
  | #1 0x7f5904898029 in abort /build/glibc-Cl5G7W/glibc-2.23/stdlib/abort.c:89
  | #2 0x7f590488ebd6 in __assert_fail_base /build/glibc-Cl5G7W/glibc-2.23/assert/assert.c:92
  | #3 0x7f590488ec81 in __assert_fail /build/glibc-Cl5G7W/glibc-2.23/assert/assert.c:101
  | #4 0xdc0e27 in heif::BitstreamRange::skip_without_advancing_file_pos(long) libheif/libheif/bitstream.cc:303:3
  | #5 0xdc323c in heif::BitstreamRange::skip_to_end_of_box() libheif/libheif/bitstream.h:171:27
  | #6 0xdc856b in heif::Box::read(heif::BitstreamRange&, std::__1::shared_ptr<heif::Box>*) libheif/libheif/box.cc:481:12
  | #7 0xdc9efd in heif::Box::read_children(heif::BitstreamRange&, int) libheif/libheif/box.cc:540:19
  | #8 0xdd67bd in heif::Box_iprp::parse(heif::BitstreamRange&) libheif/libheif/box.cc:1476:10
  | #9 0xdc8454 in heif::Box::read(heif::BitstreamRange&, std::__1::shared_ptr<heif::Box>*) libheif/libheif/box.cc:476:20
  | #10 0xdc9efd in heif::Box::read_children(heif::BitstreamRange&, int) libheif/libheif/box.cc:540:19
  | #11 0xdd626c in heif::Box_iinf::parse(heif::BitstreamRange&) libheif/libheif/box.cc:1457:10
  | #12 0xdc8454 in heif::Box::read(heif::BitstreamRange&, std::__1::shared_ptr<heif::Box>*) libheif/libheif/box.cc:476:20
  | #13 0xdc9efd in heif::Box::read_children(heif::BitstreamRange&, int) libheif/libheif/box.cc:540:19
  | #14 0xdcc183 in heif::Box_meta::parse(heif::BitstreamRange&) libheif/libheif/box.cc:714:10
  | #15 0xdc8454 in heif::Box::read(heif::BitstreamRange&, std::__1::shared_ptr<heif::Box>*) libheif/libheif/box.cc:476:20
  | #16 0xdfd67c in heif::HeifFile::parse_heif_file(heif::BitstreamRange&) libheif/libheif/heif_file.cc:166:19
  | #17 0xdfcbf8 in heif::HeifFile::read(std::__1::shared_ptr<heif::StreamReader>) libheif/libheif/heif_file.cc:82:17
  | #18 0xdfcf68 in heif::HeifFile::read_from_memory(void const*, unsigned long, bool) libheif/libheif/heif_file.cc:71:10
  | #19 0xd9e356 in heif::HeifContext::read_from_memory(void const*, unsigned long, bool) libheif/libheif/heif_context.cc:356:28
  | #20 0xd85d0d in heif_context_read_from_memory libheif/libheif/heif.cc:107:29

Links:

assert(n<=m_remaining);

Commit: 2706077
Testcase file: clusterfuzz-testcase-minimized-encoder_heic_fuzzer-6193003164073984.zip

Cant open images saved with alpha on Mac

We have address fault error on openning alpha item. And test on gimp and error appears on gimp too.
Steps:

  1. Open png image on mac Preview
  2. Save as Heic with alpha
  3. Open image with gimp

Plug-in crashed: "file-heif"
(/Applications/Gimp-2.10.app/Contents/Resources/lib/gimp/2.0/plug-ins/file-heif)

The dying plug-in may have messed up GIMP's internal state. You may want to save your images and restart GIMP to be on the safe side.
screen shot 2018-07-31 at 3 45 19 pm

handle missing image conversion DLL's

I built the heif_covert sample code and ran a simple test to convert an heif file to jpeg, there was no error AND no file. I had forgotten to download and install a jpeg conversion DLL.

I recommend adding the following to help others that might forget to include the conversion DLLs

file: heif_convert.cc after line 106 - insert the following

#if !(HAVE_LIBJPEG || HAVE_LIBPNG)
fprintf(stderr, "Your build does not include a PNG or JPG encoder, no conversion possible\n");
return 1;
#endif

Linking fails without -no-undefined

By the way, as a followup of PR #25, there is a last problem whose solution, I haven't found yet.
A simple make (crossbuild with mingw-w64) fails during linking with:

make  all-recursive
make[1]: Entering directory '/opt/user-cache/jehan/dev/crossbuild/w64/libheif'
Making all in src
make[2]: Entering directory '/opt/user-cache/jehan/dev/crossbuild/w64/libheif/src'
/bin/sh ../libtool  --tag=CXX   --mode=link x86_64-w64-mingw32-g++  -I/home/jehan/.local/share/crossroad/roads/w64/libheif/include   -DLIBHEIF_EXPORTS  -g -O2 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -version-info 2:0:1  -o libheif.la -rpath /home/jehan/.local/share/crossroad/roads/w64/libheif/lib libheif_la-bitstream.lo libheif_la-box.lo libheif_la-error.lo libheif_la-heif_file.lo libheif_la-heif_image.lo libheif_la-heif.lo libheif_la-heif_context.lo libheif_la-heif_hevc.lo libheif_la-heif_plugin_registry.lo libheif_la-heif_plugin.lo libheif_la-heif_decoder_libde265.lo  -lde265 -L/home/jehan/.local/share/crossroad/roads/w64/libheif/lib   -lpthread 
libtool:   error: can't build x86_64-w64-mingw32 shared library unless -no-undefined is specified
make[2]: *** [Makefile:647: libheif.la] Error 1
make[2]: Leaving directory '/opt/user-cache/jehan/dev/crossbuild/w64/libheif/src'
make[1]: *** [Makefile:502: all-recursive] Error 1
make[1]: Leaving directory '/opt/user-cache/jehan/dev/crossbuild/w64/libheif'
make: *** [Makefile:411: all] Error 2

A workaround exists, which is to build with make LDFLAGS=-no-undefined instead (as proposed by the error message). Then it goes to the end.
I'm not sure of the cause yet. Maybe some library is missing on the linking flags.

10bit YUV444

Do you any plan add to libheif support > 10-16 bit and 4:4:4 chroma subsampling ?

../libheif/.libs/libheif.so: undefined reference to `de265_get_bits_per_pixel'

CentOS Linux release 7.5.1804 (Core)

yum list installed | grep libde
libde265.x86_64 0.8-1.el7.nux @nux-dextop
libde265-debuginfo.x86_64 0.8-1.el7.nux @nux-dextop
libde265-devel.x86_64 0.8-1.el7.nux @nux-dextop
libde265-examples.x86_64 0.8-1.el7.nux @nux-dextop

Trying to build - libheif-1.3.2
Om master branch the same.

make

make all-recursive
make[1]: Entering directory /root/libheif-1.3.2' Making all in libheif make[2]: Entering directory /root/libheif-1.3.2/libheif'
depbase=echo box_fuzzer.o | sed 's|[^/]*$|.deps/&|;s|\.o$||';
g++ -DHAVE_CONFIG_H -I. -I.. -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT box_fuzzer.o -MD -MP -MF $depbase.Tpo -c -o box_fuzzer.o box_fuzzer.cc &&
mv -f $depbase.Tpo $depbase.Po
depbase=echo encoder_fuzzer.o | sed 's|[^/]*$|.deps/&|;s|\.o$||';
g++ -DHAVE_CONFIG_H -I. -I.. -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT encoder_fuzzer.o -MD -MP -MF $depbase.Tpo -c -o encoder_fuzzer.o encoder_fuzzer.cc &&
mv -f $depbase.Tpo $depbase.Po
depbase=echo file_fuzzer.o | sed 's|[^/]*$|.deps/&|;s|\.o$||';
g++ -DHAVE_CONFIG_H -I. -I.. -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT file_fuzzer.o -MD -MP -MF $depbase.Tpo -c -o file_fuzzer.o file_fuzzer.cc &&
mv -f $depbase.Tpo $depbase.Po
rm -f libfuzzers.a
ar cru libfuzzers.a box_fuzzer.o encoder_fuzzer.o file_fuzzer.o
ranlib libfuzzers.a
/bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-bitstream.lo -MD -MP -MF .deps/libheif_la-bitstream.Tpo -c -o libheif_la-bitstream.lo test -f 'bitstream.cc' || echo './'bitstream.cc
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-bitstream.lo -MD -MP -MF .deps/libheif_la-bitstream.Tpo -c bitstream.cc -fPIC -DPIC -o .libs/libheif_la-bitstream.o
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-bitstream.lo -MD -MP -MF .deps/libheif_la-bitstream.Tpo -c bitstream.cc -o libheif_la-bitstream.o >/dev/null 2>&1
mv -f .deps/libheif_la-bitstream.Tpo .deps/libheif_la-bitstream.Plo
/bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-box.lo -MD -MP -MF .deps/libheif_la-box.Tpo -c -o libheif_la-box.lo test -f 'box.cc' || echo './'box.cc
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-box.lo -MD -MP -MF .deps/libheif_la-box.Tpo -c box.cc -fPIC -DPIC -o .libs/libheif_la-box.o
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-box.lo -MD -MP -MF .deps/libheif_la-box.Tpo -c box.cc -o libheif_la-box.o >/dev/null 2>&1
mv -f .deps/libheif_la-box.Tpo .deps/libheif_la-box.Plo
/bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-error.lo -MD -MP -MF .deps/libheif_la-error.Tpo -c -o libheif_la-error.lo test -f 'error.cc' || echo './'error.cc
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-error.lo -MD -MP -MF .deps/libheif_la-error.Tpo -c error.cc -fPIC -DPIC -o .libs/libheif_la-error.o
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-error.lo -MD -MP -MF .deps/libheif_la-error.Tpo -c error.cc -o libheif_la-error.o >/dev/null 2>&1
mv -f .deps/libheif_la-error.Tpo .deps/libheif_la-error.Plo
/bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_file.lo -MD -MP -MF .deps/libheif_la-heif_file.Tpo -c -o libheif_la-heif_file.lo test -f 'heif_file.cc' || echo './'heif_file.cc
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_file.lo -MD -MP -MF .deps/libheif_la-heif_file.Tpo -c heif_file.cc -fPIC -DPIC -o .libs/libheif_la-heif_file.o
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_file.lo -MD -MP -MF .deps/libheif_la-heif_file.Tpo -c heif_file.cc -o libheif_la-heif_file.o >/dev/null 2>&1
mv -f .deps/libheif_la-heif_file.Tpo .deps/libheif_la-heif_file.Plo
/bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_image.lo -MD -MP -MF .deps/libheif_la-heif_image.Tpo -c -o libheif_la-heif_image.lo test -f 'heif_image.cc' || echo './'heif_image.cc
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_image.lo -MD -MP -MF .deps/libheif_la-heif_image.Tpo -c heif_image.cc -fPIC -DPIC -o .libs/libheif_la-heif_image.o
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_image.lo -MD -MP -MF .deps/libheif_la-heif_image.Tpo -c heif_image.cc -o libheif_la-heif_image.o >/dev/null 2>&1
mv -f .deps/libheif_la-heif_image.Tpo .deps/libheif_la-heif_image.Plo
/bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif.lo -MD -MP -MF .deps/libheif_la-heif.Tpo -c -o libheif_la-heif.lo test -f 'heif.cc' || echo './'heif.cc
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif.lo -MD -MP -MF .deps/libheif_la-heif.Tpo -c heif.cc -fPIC -DPIC -o .libs/libheif_la-heif.o
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif.lo -MD -MP -MF .deps/libheif_la-heif.Tpo -c heif.cc -o libheif_la-heif.o >/dev/null 2>&1
mv -f .deps/libheif_la-heif.Tpo .deps/libheif_la-heif.Plo
/bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_context.lo -MD -MP -MF .deps/libheif_la-heif_context.Tpo -c -o libheif_la-heif_context.lo test -f 'heif_context.cc' || echo './'heif_context.cc
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_context.lo -MD -MP -MF .deps/libheif_la-heif_context.Tpo -c heif_context.cc -fPIC -DPIC -o .libs/libheif_la-heif_context.o
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_context.lo -MD -MP -MF .deps/libheif_la-heif_context.Tpo -c heif_context.cc -o libheif_la-heif_context.o >/dev/null 2>&1
mv -f .deps/libheif_la-heif_context.Tpo .deps/libheif_la-heif_context.Plo
/bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_hevc.lo -MD -MP -MF .deps/libheif_la-heif_hevc.Tpo -c -o libheif_la-heif_hevc.lo test -f 'heif_hevc.cc' || echo './'heif_hevc.cc
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_hevc.lo -MD -MP -MF .deps/libheif_la-heif_hevc.Tpo -c heif_hevc.cc -fPIC -DPIC -o .libs/libheif_la-heif_hevc.o
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_hevc.lo -MD -MP -MF .deps/libheif_la-heif_hevc.Tpo -c heif_hevc.cc -o libheif_la-heif_hevc.o >/dev/null 2>&1
mv -f .deps/libheif_la-heif_hevc.Tpo .deps/libheif_la-heif_hevc.Plo
/bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_plugin_registry.lo -MD -MP -MF .deps/libheif_la-heif_plugin_registry.Tpo -c -o libheif_la-heif_plugin_registry.lo test -f 'heif_plugin_registry.cc' || echo './'heif_plugin_registry.cc
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_plugin_registry.lo -MD -MP -MF .deps/libheif_la-heif_plugin_registry.Tpo -c heif_plugin_registry.cc -fPIC -DPIC -o .libs/libheif_la-heif_plugin_registry.o
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_plugin_registry.lo -MD -MP -MF .deps/libheif_la-heif_plugin_registry.Tpo -c heif_plugin_registry.cc -o libheif_la-heif_plugin_registry.o >/dev/null 2>&1
mv -f .deps/libheif_la-heif_plugin_registry.Tpo .deps/libheif_la-heif_plugin_registry.Plo
/bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_plugin.lo -MD -MP -MF .deps/libheif_la-heif_plugin.Tpo -c -o libheif_la-heif_plugin.lo test -f 'heif_plugin.cc' || echo './'heif_plugin.cc
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_plugin.lo -MD -MP -MF .deps/libheif_la-heif_plugin.Tpo -c heif_plugin.cc -fPIC -DPIC -o .libs/libheif_la-heif_plugin.o
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_plugin.lo -MD -MP -MF .deps/libheif_la-heif_plugin.Tpo -c heif_plugin.cc -o libheif_la-heif_plugin.o >/dev/null 2>&1
mv -f .deps/libheif_la-heif_plugin.Tpo .deps/libheif_la-heif_plugin.Plo
/bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_decoder_libde265.lo -MD -MP -MF .deps/libheif_la-heif_decoder_libde265.Tpo -c -o libheif_la-heif_decoder_libde265.lo test -f 'heif_decoder_libde265.cc' || echo './'heif_decoder_libde265.cc
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_decoder_libde265.lo -MD -MP -MF .deps/libheif_la-heif_decoder_libde265.Tpo -c heif_decoder_libde265.cc -fPIC -DPIC -o .libs/libheif_la-heif_decoder_libde265.o
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT libheif_la-heif_decoder_libde265.lo -MD -MP -MF .deps/libheif_la-heif_decoder_libde265.Tpo -c heif_decoder_libde265.cc -o libheif_la-heif_decoder_libde265.o >/dev/null 2>&1
mv -f .deps/libheif_la-heif_decoder_libde265.Tpo .deps/libheif_la-heif_decoder_libde265.Plo
/bin/sh ../libtool --tag=CXX --mode=link g++ -fvisibility=hidden -DLIBHEIF_EXPORTS -I.. -DHAVE_VISIBILITY -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -version-info 4:2:3 -o libheif.la -rpath /usr/local/lib libheif_la-bitstream.lo libheif_la-box.lo libheif_la-error.lo libheif_la-heif_file.lo libheif_la-heif_image.lo libheif_la-heif.lo libheif_la-heif_context.lo libheif_la-heif_hevc.lo libheif_la-heif_plugin_registry.lo libheif_la-heif_plugin.lo libheif_la-heif_decoder_libde265.lo -lde265 -lpthread
libtool: link: rm -fr .libs/libheif.a .libs/libheif.la .libs/libheif.lai .libs/libheif.so .libs/libheif.so.1 .libs/libheif.so.1.3.2
libtool: link: g++ -fPIC -DPIC -shared -nostdlib /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtbeginS.o .libs/libheif_la-bitstream.o .libs/libheif_la-box.o .libs/libheif_la-error.o .libs/libheif_la-heif_file.o .libs/libheif_la-heif_image.o .libs/libheif_la-heif.o .libs/libheif_la-heif_context.o .libs/libheif_la-heif_hevc.o .libs/libheif_la-heif_plugin_registry.o .libs/libheif_la-heif_plugin.o .libs/libheif_la-heif_decoder_libde265.o -lde265 -lpthread -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../.. -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtendS.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crtn.o -O2 -Wl,-soname -Wl,libheif.so.1 -o .libs/libheif.so.1.3.2
libtool: link: (cd ".libs" && rm -f "libheif.so.1" && ln -s "libheif.so.1.3.2" "libheif.so.1")
libtool: link: (cd ".libs" && rm -f "libheif.so" && ln -s "libheif.so.1.3.2" "libheif.so")
libtool: link: ar cru .libs/libheif.a libheif_la-bitstream.o libheif_la-box.o libheif_la-error.o libheif_la-heif_file.o libheif_la-heif_image.o libheif_la-heif.o libheif_la-heif_context.o libheif_la-heif_hevc.o libheif_la-heif_plugin_registry.o libheif_la-heif_plugin.o libheif_la-heif_decoder_libde265.o
libtool: link: ranlib .libs/libheif.a
libtool: link: ( cd ".libs" && rm -f "libheif.la" && ln -s "../libheif.la" "libheif.la" )
make[2]: Leaving directory /root/libheif-1.3.2/libheif' Making all in examples make[2]: Entering directory /root/libheif-1.3.2/examples'
g++ -DHAVE_CONFIG_H -I. -I.. -I.. -I../. -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT heif_convert-encoder.o -MD -MP -MF .deps/heif_convert-encoder.Tpo -c -o heif_convert-encoder.o test -f 'encoder.cc' || echo './'encoder.cc
mv -f .deps/heif_convert-encoder.Tpo .deps/heif_convert-encoder.Po
g++ -DHAVE_CONFIG_H -I. -I.. -I.. -I../. -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT heif_convert-heif_convert.o -MD -MP -MF .deps/heif_convert-heif_convert.Tpo -c -o heif_convert-heif_convert.o test -f 'heif_convert.cc' || echo './'heif_convert.cc
mv -f .deps/heif_convert-heif_convert.Tpo .deps/heif_convert-heif_convert.Po
g++ -DHAVE_CONFIG_H -I. -I.. -I.. -I../. -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT heif_convert-encoder_jpeg.o -MD -MP -MF .deps/heif_convert-encoder_jpeg.Tpo -c -o heif_convert-encoder_jpeg.o test -f 'encoder_jpeg.cc' || echo './'encoder_jpeg.cc
mv -f .deps/heif_convert-encoder_jpeg.Tpo .deps/heif_convert-encoder_jpeg.Po
/bin/sh ../libtool --tag=CXX --mode=link g++ -I.. -I../. -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -o heif-convert heif_convert-encoder.o heif_convert-heif_convert.o heif_convert-encoder_jpeg.o ../libheif/libheif.la -ljpeg -lpthread
libtool: link: g++ -I.. -I../. -g -O2 -std=gnu++11 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -o .libs/heif-convert heif_convert-encoder.o heif_convert-heif_convert.o heif_convert-encoder_jpeg.o ../libheif/.libs/libheif.so -lde265 -ljpeg -lpthread -Wl,-rpath -Wl,/usr/local/lib
../libheif/.libs/libheif.so: undefined reference to de265_get_bits_per_pixel' collect2: error: ld returned 1 exit status make[2]: *** [heif-convert] Error 1 make[2]: Leaving directory /root/libheif-1.3.2/examples'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/libheif-1.3.2'
make: *** [all] Error 2

-Werror failures

With gcc 7.3 compiling libheif1.3.2 fails with:

make  all-recursive
make[1]: Entering directory '/src/gnome/gimp/libheif-1.3.2'
Making all in libheif
make[2]: Entering directory '/src/gnome/gimp/libheif-1.3.2/libheif'
  CXX      encoder_fuzzer.o
encoder_fuzzer.cc: In function ‘heif_error writer_write(heif_context*, const void*, size_t, void*)’:
encoder_fuzzer.cc:112:60: error: unused parameter ‘ctx’ [-Werror=unused-parameter]
 static struct heif_error writer_write(struct heif_context* ctx, const void* data, size_t size, void* userdata) {
                                                            ^~~
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:779: encoder_fuzzer.o] Error 1
  CXX      file_fuzzer.o
file_fuzzer.cc: In function ‘void TestDecodeImage(heif_context*, const heif_image_handle*)’:
file_fuzzer.cc:29:50: error: unused parameter ‘ctx’ [-Werror=unused-parameter]
 static void TestDecodeImage(struct heif_context* ctx,
                                                  ^~~
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:779: file_fuzzer.o] Error 1
  CXX      libheif_la-heif.lo
heif.cc: In function ‘int heif_image_handle_get_depth_image_representation_info(const heif_image_handle*, heif_item_id, const heif_depth_representation_info**)’:
heif.cc:358:72: error: unused parameter ‘depth_image_id’ [-Werror=unused-parameter]
                                                           heif_item_id depth_image_id,
                                                                        ^~~~~~~~~~~~~~
heif.cc: In function ‘heif_error heif_image_scale_image(const heif_image*, heif_image**, int, int, const heif_scaling_options*)’:
heif.cc:574:77: error: unused parameter ‘options’ [-Werror=unused-parameter]
                                          const struct heif_scaling_options* options)
                                                                             ^~~~~~~
heif.cc: In function ‘int heif_context_get_encoder_descriptors(heif_context*, heif_compression_format, const char*, const heif_encoder_descriptor**, int)’:
heif.cc:799:63: error: unused parameter ‘ctx’ [-Werror=unused-parameter]
 int heif_context_get_encoder_descriptors(struct heif_context* ctx,
                                                               ^~~
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:838: libheif_la-heif.lo] Error 1
  CXX      libheif_la-heif_context.lo
heif_context.cc: In constructor ‘heif_encoder::heif_encoder(std::shared_ptr<heif::HeifContext>, const heif_encoder_plugin*)’:
heif_context.cc:51:63: error: unused parameter ‘_context’ [-Werror=unused-parameter]
 heif_encoder::heif_encoder(std::shared_ptr<heif::HeifContext> _context,
                                                               ^~~~~~~~
In file included from heif_hevc.h:24:0,
                 from heif_context.cc:43:
heif_context.cc: In member function ‘void ImageOverlay::get_offset(size_t, int32_t*, int32_t*) const’:
heif_context.cc:312:21: error: comparison of unsigned expression >= 0 is always true [-Werror=type-limits]
   assert(image_index>=0 && image_index<m_offsets.size());
          ~~~~~~~~~~~^~~
heif_context.cc: In member function ‘heif::Error heif::HeifContext::encode_image(std::shared_ptr<heif::HeifPixelImage>, heif_encoder*, const heif_encoding_options*, heif_image_input_class, std::shared_ptr<heif::HeifContext::Image>&)’:
heif_context.cc:1402:61: error: unused parameter ‘input_class’ [-Werror=unused-parameter]
                                 enum heif_image_input_class input_class,
                                                             ^~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:845: libheif_la-heif_context.lo] Error 1
make[2]: Target 'all' not remade because of errors.
make[2]: Leaving directory '/src/gnome/gimp/libheif-1.3.2/libheif'
Making all in examples
make[2]: Entering directory '/src/gnome/gimp/libheif-1.3.2/examples'
  CXX      heif_convert-encoder.o
In file included from encoder.cc:30:0:
encoder.h: In member function ‘virtual void Encoder::UpdateDecodingOptions(const heif_image_handle*, heif_decoding_options*) const’:
encoder.h:35:70: error: unused parameter ‘handle’ [-Werror=unused-parameter]
   virtual void UpdateDecodingOptions(const struct heif_image_handle* handle,
                                                                      ^~~~~~
encoder.h:36:37: error: unused parameter ‘options’ [-Werror=unused-parameter]
       struct heif_decoding_options *options) const {
                                     ^~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:644: heif_convert-encoder.o] Error 1
  CXX      heif_convert-heif_convert.o
In file included from heif_convert.cc:36:0:
encoder.h: In member function ‘virtual void Encoder::UpdateDecodingOptions(const heif_image_handle*, heif_decoding_options*) const’:
encoder.h:35:70: error: unused parameter ‘handle’ [-Werror=unused-parameter]
   virtual void UpdateDecodingOptions(const struct heif_image_handle* handle,
                                                                      ^~~~~~
encoder.h:36:37: error: unused parameter ‘options’ [-Werror=unused-parameter]
       struct heif_decoding_options *options) const {
                                     ^~~~~~~
In file included from heif_convert.cc:38:0:
encoder_jpeg.h: In member function ‘virtual heif_colorspace JpegEncoder::colorspace(bool) const’:
encoder_jpeg.h:37:35: error: unused parameter ‘has_alpha’ [-Werror=unused-parameter]
   heif_colorspace colorspace(bool has_alpha) const override {
                                   ^~~~~~~~~
encoder_jpeg.h: In member function ‘virtual heif_chroma JpegEncoder::chroma(bool) const’:
encoder_jpeg.h:41:27: error: unused parameter ‘has_alpha’ [-Werror=unused-parameter]
   heif_chroma chroma(bool has_alpha) const override {
                           ^~~~~~~~~
In file included from heif_convert.cc:41:0:
encoder_png.h: In member function ‘virtual heif_colorspace PngEncoder::colorspace(bool) const’:
encoder_png.h:31:35: error: unused parameter ‘has_alpha’ [-Werror=unused-parameter]
   heif_colorspace colorspace(bool has_alpha) const override {
                                   ^~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:658: heif_convert-heif_convert.o] Error 1
  CXX      heif_convert-encoder_jpeg.o
In file included from encoder_jpeg.h:31:0,
                 from encoder_jpeg.cc:26:
encoder.h: In member function ‘virtual void Encoder::UpdateDecodingOptions(const heif_image_handle*, heif_decoding_options*) const’:
encoder.h:35:70: error: unused parameter ‘handle’ [-Werror=unused-parameter]
   virtual void UpdateDecodingOptions(const struct heif_image_handle* handle,
                                                                      ^~~~~~
encoder.h:36:37: error: unused parameter ‘options’ [-Werror=unused-parameter]
       struct heif_decoding_options *options) const {
                                     ^~~~~~~
In file included from encoder_jpeg.cc:26:0:
encoder_jpeg.h: In member function ‘virtual heif_colorspace JpegEncoder::colorspace(bool) const’:
encoder_jpeg.h:37:35: error: unused parameter ‘has_alpha’ [-Werror=unused-parameter]
   heif_colorspace colorspace(bool has_alpha) const override {
                                   ^~~~~~~~~
encoder_jpeg.h: In member function ‘virtual heif_chroma JpegEncoder::chroma(bool) const’:
encoder_jpeg.h:41:27: error: unused parameter ‘has_alpha’ [-Werror=unused-parameter]
   heif_chroma chroma(bool has_alpha) const override {
                           ^~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:672: heif_convert-encoder_jpeg.o] Error 1
  CXX      heif_convert-encoder_png.o
In file included from encoder_png.h:25:0,
                 from encoder_png.cc:26:
encoder.h: In member function ‘virtual void Encoder::UpdateDecodingOptions(const heif_image_handle*, heif_decoding_options*) const’:
encoder.h:35:70: error: unused parameter ‘handle’ [-Werror=unused-parameter]
   virtual void UpdateDecodingOptions(const struct heif_image_handle* handle,
                                                                      ^~~~~~
encoder.h:36:37: error: unused parameter ‘options’ [-Werror=unused-parameter]
       struct heif_decoding_options *options) const {
                                     ^~~~~~~
In file included from encoder_png.cc:26:0:
encoder_png.h: In member function ‘virtual heif_colorspace PngEncoder::colorspace(bool) const’:
encoder_png.h:31:35: error: unused parameter ‘has_alpha’ [-Werror=unused-parameter]
   heif_colorspace colorspace(bool has_alpha) const override {
                                   ^~~~~~~~~
encoder_png.cc: In member function ‘virtual bool PngEncoder::Encode(const heif_image_handle*, const heif_image*, const string&)’:
encoder_png.cc:40:57: error: unused parameter ‘handle’ [-Werror=unused-parameter]
 bool PngEncoder::Encode(const struct heif_image_handle* handle,
                                                         ^~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:686: heif_convert-encoder_png.o] Error 1
make[2]: *** No rule to make target '../libheif/libheif.la', needed by 'heif-convert'.
  CXX      heif_enc-heif_enc.o
heif_enc.cc: In function ‘void show_help(const char*)’:
heif_enc.cc:66:28: error: unused parameter ‘argv0’ [-Werror=unused-parameter]
 void show_help(const char* argv0)
                            ^~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:700: heif_enc-heif_enc.o] Error 1
  CXX      heif_info-heif_info.o
heif_info.cc: In function ‘void show_help(const char*)’:
heif_info.cc:64:28: error: unused parameter ‘argv0’ [-Werror=unused-parameter]
 void show_help(const char* argv0)
                            ^~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:714: heif_info-heif_info.o] Error 1
  CXX      heif_thumbnailer-encoder.o
In file included from encoder.cc:30:0:
encoder.h: In member function ‘virtual void Encoder::UpdateDecodingOptions(const heif_image_handle*, heif_decoding_options*) const’:
encoder.h:35:70: error: unused parameter ‘handle’ [-Werror=unused-parameter]
   virtual void UpdateDecodingOptions(const struct heif_image_handle* handle,
                                                                      ^~~~~~
encoder.h:36:37: error: unused parameter ‘options’ [-Werror=unused-parameter]
       struct heif_decoding_options *options) const {
                                     ^~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:742: heif_thumbnailer-encoder.o] Error 1
  CXX      heif_thumbnailer-heif_thumbnailer.o
In file included from heif_thumbnailer.cc:36:0:
encoder.h: In member function ‘virtual void Encoder::UpdateDecodingOptions(const heif_image_handle*, heif_decoding_options*) const’:
encoder.h:35:70: error: unused parameter ‘handle’ [-Werror=unused-parameter]
   virtual void UpdateDecodingOptions(const struct heif_image_handle* handle,
                                                                      ^~~~~~
encoder.h:36:37: error: unused parameter ‘options’ [-Werror=unused-parameter]
       struct heif_decoding_options *options) const {
                                     ^~~~~~~
In file included from heif_thumbnailer.cc:38:0:
encoder_png.h: In member function ‘virtual heif_colorspace PngEncoder::colorspace(bool) const’:
encoder_png.h:31:35: error: unused parameter ‘has_alpha’ [-Werror=unused-parameter]
   heif_colorspace colorspace(bool has_alpha) const override {
                                   ^~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:756: heif_thumbnailer-heif_thumbnailer.o] Error 1
  CXX      heif_thumbnailer-encoder_png.o
In file included from encoder_png.h:25:0,
                 from encoder_png.cc:26:
encoder.h: In member function ‘virtual void Encoder::UpdateDecodingOptions(const heif_image_handle*, heif_decoding_options*) const’:
encoder.h:35:70: error: unused parameter ‘handle’ [-Werror=unused-parameter]
   virtual void UpdateDecodingOptions(const struct heif_image_handle* handle,
                                                                      ^~~~~~
encoder.h:36:37: error: unused parameter ‘options’ [-Werror=unused-parameter]
       struct heif_decoding_options *options) const {
                                     ^~~~~~~
In file included from encoder_png.cc:26:0:
encoder_png.h: In member function ‘virtual heif_colorspace PngEncoder::colorspace(bool) const’:
encoder_png.h:31:35: error: unused parameter ‘has_alpha’ [-Werror=unused-parameter]
   heif_colorspace colorspace(bool has_alpha) const override {
                                   ^~~~~~~~~
encoder_png.cc: In member function ‘virtual bool PngEncoder::Encode(const heif_image_handle*, const heif_image*, const string&)’:
encoder_png.cc:40:57: error: unused parameter ‘handle’ [-Werror=unused-parameter]
 bool PngEncoder::Encode(const struct heif_image_handle* handle,
                                                         ^~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:770: heif_thumbnailer-encoder_png.o] Error 1
  CXX      heif_test-heif_test.o
heif_test.cc: In function ‘void show_help(const char*)’:
heif_test.cc:49:28: error: unused parameter ‘argv0’ [-Werror=unused-parameter]
 void show_help(const char* argv0)
                            ^~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [Makefile:728: heif_test-heif_test.o] Error 1
make[2]: Target 'all' not remade because of errors.
make[2]: Leaving directory '/src/gnome/gimp/libheif-1.3.2/examples'
Making all in extra
make[2]: Entering directory '/src/gnome/gimp/libheif-1.3.2/extra'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/src/gnome/gimp/libheif-1.3.2/extra'
Making all in gnome
make[2]: Entering directory '/src/gnome/gimp/libheif-1.3.2/gnome'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/src/gnome/gimp/libheif-1.3.2/gnome'
Making all in go
make[2]: Entering directory '/src/gnome/gimp/libheif-1.3.2/go'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/src/gnome/gimp/libheif-1.3.2/go'
Making all in scripts
make[2]: Entering directory '/src/gnome/gimp/libheif-1.3.2/scripts'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/src/gnome/gimp/libheif-1.3.2/scripts'
make[2]: Entering directory '/src/gnome/gimp/libheif-1.3.2'
make[2]: Leaving directory '/src/gnome/gimp/libheif-1.3.2'
make[1]: *** [Makefile:507: all-recursive] Error 1
make[1]: Leaving directory '/src/gnome/gimp/libheif-1.3.2'
make: *** [Makefile:416: all] Error 2

New release?

Apologies, asking for a release/asking for information on when the next release is likely to be always feels like a big of a nag.

Just wondering if it'd be possible to get an estimate on that because the current 1.1.0 release doesn't compile on macOS. Has already been fixed in master with 001a93c2, 7ac92eb0 & a237e50a. As far as I'm aware those are the only clang/macOS issues present currently; the current master branch here builds fine.

Adding support for HEIC to JPG conversion ?

The README sort of implies that heif-convert can convert to PNG or JPG right out of the box but I'm finding that isn't the case. Is there something that needs to be enabled when running the configure script so JPEG support is added? I have jpeg-9c built and installed but the libheif build doesn't see it (configure: JPEG output: no). When I attempt to convert example.heic to jpg I get the following error message, "Unknown file type in example.jpg", hinting that HAVE_LIBJPEG isn't defined.

Converting animated heif to jpeg - Which frame ?

Hi all,
Sorry if it's the wrong channel to ask this question.
I m using Imagemagick + libheif to convert heif to jpeg.

When converting an animated heif, which frame is used to convert the animated image to jpeg ?
Is it something you compute, a fix frame number or something else ?

Thank you

Stack-overflow (8136)

The @ImageMagick project is using https://github.com/google/oss-fuzz to find bugs in our own library and in libraries that we use. The fuzzer found an issue and we think this is an issue that should be resolved in the library that we use. This issue is posted under the url https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=8136 that is not publicly visible yet but added as a link for future reference. Below are the details of the issue that can be reproduced using the following technique: https://github.com/google/oss-fuzz/blob/master/docs/reproducing.md

Stacktrace:

==1==ERROR: AddressSanitizer: stack-overflow on address 0x7ffdcfa72ff8 (pc 0x000000db0f88 bp 0x7ffdcfa73010 sp 0x7ffdcfa73000 T0)
--
  | SCARINESS: 10 (stack-overflow)
  | #0 0xdb0f87 in heif::BitstreamRange::read(unsigned long) libheif/src/bitstream.h:65
  | #1 0xdb1055 in heif::BitstreamRange::read(unsigned long) libheif/src/bitstream.h:68:27
  | #2 0xdb1055 in heif::BitstreamRange::read(unsigned long) libheif/src/bitstream.h:68:27
  | #3 0xdb1055 in heif::BitstreamRange::read(unsigned long) libheif/src/bitstream.h:68:27
  | #4 0xdb1055 in heif::BitstreamRange::read(unsigned long) libheif/src/bitstream.h:68:27
  | #5 0xdb1055 in heif::BitstreamRange::read(unsigned long) libheif/src/bitstream.h:68:27
  | #6 0xdb1055 in heif::BitstreamRange::read(unsigned long) libheif/src/bitstream.h:68:27
  | #7 0xdb1055 in heif::BitstreamRange::read(unsigned long) libheif/src/bitstream.h:68:27
  | #8 0xdb1055 in heif::BitstreamRange::read(unsigned long) libheif/src/bitstream.h:68:27

Links:

bool read(uint64_t n) {

m_parent_range->read(n);

Commit: 0a0db99
Testcase file: clusterfuzz-testcase-minimized-ping_heic_fuzzer-4721040704929792.zip

Parsing file path to create output filename might be problematic

When extracting multiple images from a HEIC file the code that creates the output filename is using find() to search out the period in the file extension from the path (see heif-convert.cc). This is a problem if the path itself has a period somewhere in it prior to the actual file,
ie; /users/username/somedirname.version/filename.ext

In the example above the '.' in "somedirname.version" will be found and changed as if it's the output file when the last period is desired. Using output_filename.find_last_of('.') would be a better solution.

error message in C api.

We are using libheif in the @ImageMagick project and I was trying to print the message from the heif_error struct to give our users a better error message. But it turns out that we cannot use this in the C api because the error class is freed and then error.message points to an invalid memory block.

struct heif_error heif_decode_image(const struct heif_image_handle* in_handle,
                                    struct heif_image** out_img,
                                    heif_colorspace colorspace,
                                    heif_chroma chroma,
                                    const struct heif_decoding_options* options)
{
  std::shared_ptr<HeifPixelImage> img;

  Error err = in_handle->image->decode_image(img,
                                             colorspace,
                                             chroma,
                                             options);
  if (err.error_code != heif_error_Ok) {
    // After the return `err` gets freed and message points to an invalid block of memory.
    return err.error_struct(in_handle->image.get());
  }

  *out_img = new heif_image();
  (*out_img)->image = std::move(img);

  return Error::Ok.error_struct(in_handle->image.get());
}

This can be resolved by making a copy of the string before this is copied to the error message but that means we would need to free the error message after each call. There is a comment that the error message will never be null. But I personally don't care about the error message when the message is Success and then we would need to free it every time. I don't know what the best solution is for this issue so I will leave the solution up to you.

heif sequence file type support?

Hello all,

Will libheif support heif sequence file? 

I downloaded samples from https://github.com/nokiatech/heif and tried to display the heif sequence file( bird_burst.heic in image_sequences folder).

From the heif-info program, it shows up 4 still images but no burst images.

I dug the libheif and found no moov box implementation. 

So I think currently not support for heif sequence file? Will it support in the feature? Thanks

examples/encoder.cc failed to compile with VPATH

Building within subdirectory still fails.

Steps to reproduce:

cd /usr/src/1div0/libheif/Linux/x86-64

../../configure --prefix=/usr/local --libdir=/usr/local/lib64

make
make all-recursive
make[1]: Entering directory '/usr/src/1div0/libheif/Linux/x86-64'
Making all in libheif
make[2]: Entering directory '/usr/src/1div0/libheif/Linux/x86-64/libheif'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/usr/src/1div0/libheif/Linux/x86-64/libheif'
Making all in examples
make[2]: Entering directory '/usr/src/1div0/libheif/Linux/x86-64/examples'
g++ -DHAVE_CONFIG_H -I. -I../../../examples -I.. -I../../.. -I../. -I/usr/include/libpng16 -g -O2 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -MT heif_convert-encoder.o -MD -MP -MF .deps/heif_convert-encoder.Tpo -c -o heif_convert-encoder.o test -f 'encoder.cc' || echo '../../../examples/'encoder.cc
In file included from ../../../examples/encoder.h:26,
from ../../../examples/encoder.cc:30:
../../../libheif/heif.h:31:10: fatal error: heif_version.h: No such file or directory
#include "heif_version.h"
^~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [Makefile:643: heif_convert-encoder.o] Error 1
make[2]: Leaving directory '/usr/src/1div0/libheif/Linux/x86-64/examples'
make[1]: *** [Makefile:506: all-recursive] Error 1
make[1]: Leaving directory '/usr/src/1div0/libheif/Linux/x86-64'
make: *** [Makefile:415: all] Error 2

examples for heic muxer

Hello,

I am using this libheif for some developments. My goal is to use libheif as a muxer. Now I can get  single HEVC I-Frame and want to use this libheif to mux(convert) to heic format.

From readme, it tells the "heif_context_write_to_file()" can output the heic file with encoded heic_image structure. Can I just memcpy the prepared hevc image to heic_image plane and invoke heif_context_write_to_file() to generate the heic file?.

Any comments or documents are welcome, thank you.

Build failure when compiling against libjpeg-turbo 2.0

After upgrading from libjpeg-turbo 1.5.3 to 2.0.0 from https://github.com/libjpeg-turbo/libjpeg-turbo/releases/tag/2.0.0, libheif fails to build:

(min) hmage@min:~/norm.x86_64-pc-linux-gnu.2.24.haswell.min/tmp/compile/libheif/libheif_libheif-1.3.2.tar.gz$ make
make  all-recursive
make[1]: Entering directory '/home/hmage/norm.x86_64-pc-linux-gnu.2.24.haswell.min/tmp/compile/libheif/libheif_libheif-1.3.2.tar.gz'
Making all in libheif
make[2]: Entering directory '/home/hmage/norm.x86_64-pc-linux-gnu.2.24.haswell.min/tmp/compile/libheif/libheif_libheif-1.3.2.tar.gz/libheif'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/hmage/norm.x86_64-pc-linux-gnu.2.24.haswell.min/tmp/compile/libheif/libheif_libheif-1.3.2.tar.gz/libheif'
Making all in examples
make[2]: Entering directory '/home/hmage/norm.x86_64-pc-linux-gnu.2.24.haswell.min/tmp/compile/libheif/libheif_libheif-1.3.2.tar.gz/examples'
c++ -DHAVE_CONFIG_H -I. -I..   -I/home/hmage/norm.x86_64-pc-linux-gnu.2.24.haswell.min/include -march=native -fdebug-prefix-map=/home/hmage/norm.x86_64-pc-linux-gnu.2.24.haswell.min=/build -ffunction-sections -fdata-sections -I.. -I../.   -g -O2 -Wall -Werror -Wsign-compare -Wconversion -Wno-sign-conversion -Wno-error=conversion -c -o heif_convert-heif_convert.o `test -f 'heif_convert.cc' || echo './'`heif_convert.cc
In file included from /home/hmage/norm.x86_64-pc-linux-gnu.2.24.haswell.min/include/jpeglib.h:29:0,
                 from encoder_jpeg.h:27,
                 from heif_convert.cc:38:
/home/hmage/norm.x86_64-pc-linux-gnu.2.24.haswell.min/include/jconfig.h:39:0: error: "HAVE_STDDEF_H" redefined [-Werror]
 #define HAVE_STDDEF_H

In file included from heif_convert.cc:21:0:
../config.h:38:0: note: this is the location of the previous definition
 #define HAVE_STDDEF_H 1

In file included from /home/hmage/norm.x86_64-pc-linux-gnu.2.24.haswell.min/include/jpeglib.h:29:0,
                 from encoder_jpeg.h:27,
                 from heif_convert.cc:38:
/home/hmage/norm.x86_64-pc-linux-gnu.2.24.haswell.min/include/jconfig.h:42:0: error: "HAVE_STDLIB_H" redefined [-Werror]
 #define HAVE_STDLIB_H

In file included from heif_convert.cc:21:0:
../config.h:44:0: note: this is the location of the previous definition
 #define HAVE_STDLIB_H 1

cc1plus: all warnings being treated as errors
Makefile:662: recipe for target 'heif_convert-heif_convert.o' failed
make[2]: *** [heif_convert-heif_convert.o] Error 1
make[2]: Leaving directory '/home/hmage/norm.x86_64-pc-linux-gnu.2.24.haswell.min/tmp/compile/libheif/libheif_libheif-1.3.2.tar.gz/examples'
Makefile:507: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/hmage/norm.x86_64-pc-linux-gnu.2.24.haswell.min/tmp/compile/libheif/libheif_libheif-1.3.2.tar.gz'
Makefile:416: recipe for target 'all' failed
make: *** [all] Error 2

Didn't have time yet to track down exactly why, but better have the bugreport rather than not.

Build libheif with Visual Studio 2013.

We create binaries for the @ImageMagick project with Visual Studio 2013 but that fails to build at the moment. This is failing because constexpr is not supported. The main issue is fourcc and the switch in Box::read because that actually requires a constant value. This is what they use in webp:

#define MKFOURCC(a, b, c, d) ((a) | (b) << 8 | (c) << 16 | (uint32_t)(d) << 24)

I don't mind sending and testing a PR if you tell me what kind of solution you want for this.

Integer-overflow (8062)

The @ImageMagick project is using https://github.com/google/oss-fuzz to find bugs in our own library and in libraries that we use. The fuzzer found an issue and we think this is an issue that should be resolved in the library that we use. This issue is posted under the url https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=8062 that is not publicly visible yet but added as a link for future reference. Below are the details of the issue that can be reproduced using the following technique: https://github.com/google/oss-fuzz/blob/master/docs/reproducing.md

Stacktrace:

/usr/local/bin/../include/c++/v1/sstream:599:12: runtime error: signed integer overflow: 16 + 9223372036854775792 cannot be represented in type 'long long'
	#0 0x437982 in std::__1::basic_stringbuf<char, std::__1::char_traits<char>, std::__1::allocator<char> >::seekoff(long long, std::__1::ios_base::seekdir, unsigned int) /usr/local/include/c++/v1/sstream:599:12
	#1 0xf9608c in std::__1::basic_istream<char, std::__1::char_traits<char> >::seekg(long long, std::__1::ios_base::seekdir)
	#2 0x9329d4 in heif::Box::parse(heif::BitstreamRange&) libheif/src/box.cc:291:28
	#3 0x934025 in heif::Box::read(heif::BitstreamRange&, std::__1::shared_ptr<heif::Box>*) libheif/src/box.cc:434:20
	#4 0x96d96b in heif::HeifFile::parse_heif_file(heif::BitstreamRange&) libheif/src/heif_file.cc:165:19
	#5 0x971c78 in heif::HeifFile::read_from_memory(void const*, unsigned long) libheif/src/heif_file.cc:81:17
	#6 0x916524 in heif::HeifContext::read_from_memory(void const*, unsigned long) libheif/src/heif_context.cc:361:28
	#7 0x9029b8 in heif_context_read_from_memory libheif/src/heif.cc:107:29
	#8 0x7add39 in ReadHEICImage imagemagick/coders/heic.c:195:9
	#9 0x53fc60 in ReadImage imagemagick/MagickCore/constitute.c:500:13

Links:

range.get_istream()->seekg(get_box_size() - get_header_size(), std::ios_base::cur);

Commit: b56e683
Testcase file: clusterfuzz-testcase-minimized-ping_heic_fuzzer-5816072648261632.zip

Question about compile & usage on iOS/macOS platform

Hello. I'm a iOS developer and recently I'm build a iOS-library which integrate libheif to a third-party lib SDWebImageHEIFCoder. Which support HEIF/HEIC decoding in old version iOS/macOS firmware. (Since iOS 11 & macOS 10.13 support HEIC natively)

But since I'm not an expert in image processing field, here are some questions I faced during the development. Some questions may be silly and I hope this will not bother someone :)

Readme

It seems some part of Readme is out-of-date.

  • heif_context_new_heic this API is not available now. Maybe we can update the demo code about encoding ?
  • frame-parallel branch described in the compile part seems out-of-date. I try this branch of libde265 but this can't compile with the master branch of libheif or latest v1.1.0 tag. So I then use the latest v1.0.3 tag of libde265 with v1.1.0 libheif tag to compile to iOS/macOS platform.

Compile

I find that your're also the maintainer of libde265, So I put the question here.

To compile to iOS platform, I'm using Cmake with ios-cmake. For macOS, just using the official Cmake. All of following problem is about Cmake compile issue. (Not using autoconf)

  • libde265 master branch or latest tag can not compile with the build-in config. It seems this API memalign is not availble on macOS & iOS platform.

I solve this by passing -DHAVE_POSIX_MEMALIGN flag to Cmake to use posix_memalign instead. However, since Cmake support feature detect, maybe this flag can be automatically config instead of manual set?

  • libde265 master branch or latest tag can not compile with the build-in config. It seems the SSE4.1 detect cause some issue. See the log here:
[ 34%] Building CXX object libde265/x86/CMakeFiles/x86_sse.dir/sse-motion.cc.o
/Users/lizhuoli/Documents/GitHub/libde265/libde265/x86/sse-motion.cc:746:29: error: 
      always_inline function '_mm_packus_epi32' requires target feature
      'sse4.1', but would be inlined into function
      'ff_hevc_weighted_pred_avg_8_sse4' that is compiled without support for
      'sse4.1'
                       r0 = _mm_packus_epi32(r0, r2);
                            ^
/Users/lizhuoli/Documents/GitHub/libde265/libde265/x86/sse-motion.cc:747:29: error: 
      always_inline function '_mm_packus_epi32' requires target feature
      'sse4.1', but would be inlined into function
      'ff_hevc_weighted_pred_avg_8_sse4' that is compiled without support for
      'sse4.1'
                       r1 = _mm_packus_epi32(r1, r3);

I solve this by passing -DDISABLE_SSE flag to Cmake to disable it. However, since ARM64 support SSE4.1, I guess this is not a good solution.

Usage

After I compile the binary for iOS & macOS platform and start using libheif. Though I can successfully run the demo and see the HEIF image decoding works. But there are some question I want to know.

  • Does libheif support progressive/Incremental image decoding ? Because my lib is a plugin to an image loading system, which support rendering partial image during large image download.

  • libheif's this encoding API heif_context_write seems a little wired. I think this may be some misunderstanding from me but libheif library (See the code comments below). I use this API to write the encoded heif data to a memory representation but not file.

static struct heif_error WriteImageData(struct heif_context* ctx,
                                                const void* data, size_t size, void* userdata) {
    __autoreleasing NSData **imageData = (__autoreleasing NSData **)userdata;
    NSCParameterAssert(imageData);
    
    heif_error error;
    if (!data) {
        // Can this rgba data be NULL ?
        // And how can I get the error information about this because there are no public API or input arg to grab the error information
        error.code = heif_error_Encoder_plugin_error;
        return error;
    }
    *imageData = [NSData dataWithBytes:data length:size];
    
    error.code = heif_error_Ok;
    return error;
}

// test code
void test() {
    NSData *data;
    heif_writer *writer;
    writer->writer_api_version = 1;
    writer->write = WriteImageData; // This is a function pointer
    
    error = heif_context_write(ctx, writer, &data);
}

Use-of-uninitialized-value (8158)

The @ImageMagick project is using https://github.com/google/oss-fuzz to find bugs in our own library and in libraries that we use. The fuzzer found an issue and we think this is an issue that should be resolved in the library that we use. This issue is posted under the url https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=8158 that is not publicly visible yet but added as a link for future reference. Below are the details of the issue that can be reproduced using the following technique: https://github.com/google/oss-fuzz/blob/master/docs/reproducing.md

Stacktrace:

#0 0x15b8c88 in heif::HeifContext::decode_full_grid_image(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>&, std::__1::vector<unsigned char, std::__1::allocator<unsigned char> > const&) const libheif/libheif/heif_context.cc:987:28
--
  | #1 0x15b2765 in heif::HeifContext::decode_image(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>&, heif_decoding_options const*) const libheif/libheif/heif_context.cc:822:13
  | #2 0x15b07d2 in heif::HeifContext::Image::decode_image(std::__1::shared_ptr<heif::HeifPixelImage>&, heif_colorspace, heif_chroma, heif_decoding_options const*) const libheif/libheif/heif_context.cc:728:31
  | #3 0x158e433 in heif_decode_image libheif/libheif/heif.cc:458:33
  | #4 0x109acd2 in ReadHEICImage imagemagick/coders/heic.c:267:9
  | #5 0x7d3ce9 in ReadImage imagemagick/MagickCore/constitute.c:500:13
  | #6 0x6fd87a in BlobToImage imagemagick/MagickCore/blob.c:473:13
  | #7 0x593661 in Magick::Image::read(Magick::Blob const&) imagemagick/Magick++/lib/Image.cpp:4029:12
  | #8 0x4a4f5c in LLVMFuzzerTestOneInput imagemagick/Magick++/fuzz/encoder_fuzzer.cc:46:11
  | #9 0x4ec19c in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/libfuzzer/FuzzerLoop.cpp:526:13


Links:

if (w >= MAX_IMAGE_WIDTH || h >= MAX_IMAGE_HEIGHT) {

Commit: 2706077
Testcase file: clusterfuzz-testcase-minimized-encoder_heic_fuzzer-5362068734607360.zip

How to run heif_enc?

I have install X265 and turn on HAVE_X265 ,but i can't find heif_encoder_x265.h . should I rename x265.h to heif_encoder_x265.h.

Duplicate condition

The function HeifContext::is_grid_item is checking twice for !m_is_primary:

bool is_grid_item(){ return !m_is_primary && !m_is_primary && !m_is_alpha_channel && !m_is_depth_channel; };

Can the duplicated check simply be removed, or should it check for something else?

This was found by Coverity Scan.

Integer-overflow (9244)

The @ImageMagick project is using https://github.com/google/oss-fuzz to find bugs in our own library and in libraries that we use. The fuzzer found an issue and we think this is an issue that should be resolved in the library that we use. This issue is posted under the url https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9244 that is not publicly visible yet but added as a link for future reference. Below are the details of the issue that can be reproduced using the following technique: https://github.com/google/oss-fuzz/blob/master/docs/reproducing.md

Stacktrace:

bitstream.cc:301:48: runtime error: signed integer overflow: 16 + 9223372036854775797 cannot be represented in type 'long'
--
  | #0 0x93c48d in heif::BitstreamRange::wait_for_available_bytes(long) libheif/libheif/bitstream.cc:301:48
  | #1 0x943af7 in heif::Box::read(heif::BitstreamRange&, std::__1::shared_ptr<heif::Box>*) libheif/libheif/box.cc:465:23
  | #2 0x97df7b in heif::HeifFile::parse_heif_file(heif::BitstreamRange&) libheif/libheif/heif_file.cc:166:19
  | #3 0x97db94 in heif::HeifFile::read(std::__1::shared_ptr<heif::StreamReader>) libheif/libheif/heif_file.cc:82:17
  | #4 0x97de51 in heif::HeifFile::read_from_memory(void const*, unsigned long, bool) libheif/libheif/heif_file.cc:71:10
  | #5 0x91f77c in heif::HeifContext::read_from_memory(void const*, unsigned long, bool) libheif/libheif/heif_context.cc:357:28
  | #6 0x90910e in heif_context_read_from_memory libheif/libheif/heif.cc:107:29
  | #7 0x7b3f29 in ReadHEICImage imagemagick/coders/heic.c:195:9
  | #8 0x544570 in ReadImage imagemagick/MagickCore/constitute.c:500:13
  | #9 0x6724cb in ReadStream imagemagick/MagickCore/stream.c:1043:9

Links:

int64_t target_size = m_istr->get_position() + nBytes;

Commit: 1fe0a821d5feefb5e8cdefbf2310a07b25b04a8
Testcase file: clusterfuzz-testcase-minimized-ping_heic_fuzzer-5764869918818304.zip

Saving in RGB colorspace (was: "heif-enc lossless isn't lossless")

I used heif-enc to convert a png "losslessly" then converted it back to png with heif-convert and the results where not lossless. I attached the original png bellow as well as the difference between them (levels increased dramatically).

heif-enc -L tree.png
heif-convert tree.heic tree.png

ash_tree_-geograph org uk-_590710
png-heic-png

Automatic color profile determination is broken

Revision 943361a breaks automatic color profile determination:

./examples/heif-enc ~/Desktop/rndimg.png 
Assertion failed: (m_color_profile), function write, file box.cc, line 1693.
Abort trap: 6

Conversion works fine without the patch.

resize heic file exception

please refer to the issue https://github.com/ImageMagick/ImageMagick/issues/1173

when I resize a heic file by imagemagick, I got an error as below:
suse11sp1:~/lzz # convert -resize 120x120 20171218_IMG_0449.HEIC 20171218_IMG_0449.jpg terminate called after throwing an instance of 'std::system_error' what(): Resource temporarily unavailable Aborted

and I find that the error is related to the heic file size.
when the file size is 1.4M, I can resize the file right.
but when the file size is 5.5M, I got the errors.

`suse11sp1:~/lzz # ll -h
total 30M
-rw-r--r-- 1 root root 1.4M Dec 18 08:41 20171218_IMG_0446.HEIC
-rw-r--r-- 1 root root 5.5M Dec 18 08:41 20171218_IMG_0449.HEIC
-rw-r--r-- 1 root root 595K Dec 18 08:41 20171218_IMG_0455.HEIC
-rw-r--r-- 1 root root 66K Jun 14 06:01 20171218_IMG_0455.jpg

suse11sp1:/lzz # convert -resize 120x120 20171218_IMG_0446.HEIC 20171218_IMG_0446.jpg
suse11sp1:/lzz # convert -resize 120x120 20171218_IMG_0449.HEIC 20171218_IMG_0449.jpg
terminate called after throwing an instance of 'std::system_error'
what(): Resource temporarily unavailable
Aborted`

Null-dereference READ (9283)

The @ImageMagick project is using https://github.com/google/oss-fuzz to find bugs in our own library and in libraries that we use. The fuzzer found an issue and we think this is an issue that should be resolved in the library that we use. This issue is posted under the url https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9283 that is not publicly visible yet but added as a link for future reference. Below are the details of the issue that can be reproduced using the following technique: https://github.com/google/oss-fuzz/blob/master/docs/reproducing.md

Stacktrace:

SCARINESS: 10 (null-deref)
--
  | #0 0x7fb55a54dba5 in memcpy-avx-unaligned.S:180 /build/glibc-Cl5G7W/glibc-2.23/sysdeps/x86_64/multiarch/memcpy-avx-unaligned.S:180
  | #1 0x4eba2a in __asan_memcpy _asan_rtl_
  | #2 0xdaadca in heif::HeifContext::decode_and_paste_tile_image(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const libheif/libheif/heif_context.cc:1148:7
  | #3 0xdbe62a in __invoke<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, const heif::HeifContext *, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int, void> /usr/local/include/c++/v1/type_traits:4286:1
  | #4 0xdbe62a in heif::Error std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, heif::HeifContext const*, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int>::__execute<1ul, 2ul, 3ul, 4ul, 5ul>(std::__1::__tuple_indices<1ul, 2ul, 3ul, 4ul, 5ul>) /usr/local/include/c++/v1/future:2330
  | #5 0xdbe3a8 in std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, heif::HeifContext const*, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int>::operator()() /usr/local/include/c++/v1/future:2323:16
  | #6 0xdbdb8a in std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, heif::HeifContext const*, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> >::__execute() /usr/local/include/c++/v1/future:985:25
  | #7 0xdbe884 in __invoke<void (std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, const heif::HeifContext *, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> >::*)(), std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, const heif::HeifContext *, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> > *, void> /usr/local/include/c++/v1/type_traits:4286:1
  | #8 0xdbe884 in __thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, const heif::HeifContext *, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> >::*)(), std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, const heif::HeifContext *, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> > *, 2> /usr/local/include/c++/v1/thread:342
  | #9 0xdbe884 in void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, heif::HeifContext const*, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> >::*)(), std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, heif::HeifContext const*, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> >*> >(void*) /usr/local/include/c++/v1/thread:352
  | #10 0x7fb55adf36b9 in start_thread
  | #11 0x7fb55a50741c in clone /build/glibc-Cl5G7W/glibc-2.23/sysdeps/unix/sysv/linux/x86_64/clone.S:109

Links:

memcpy(out_data + xs + (ys+py)*out_stride,

Commit: 01fe0a8
Testcase file: clusterfuzz-testcase-minimized-encoder_heic_fuzzer-4878614100180992.zip

libheif.js

Is there any builds/download available for libheif.js?

Abrt (9175)

The @ImageMagick project is using https://github.com/google/oss-fuzz to find bugs in our own library and in libraries that we use. The fuzzer found an issue and we think this is an issue that should be resolved in the library that we use. This issue is posted under the url https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=8922 that is not publicly visible yet but added as a link for future reference. Below are the details of the issue that can be reproduced using the following technique: https://github.com/google/oss-fuzz/blob/master/docs/reproducing.md

Stacktrace:

SCARINESS: 10 (signal)
--
  | #0 0x7f35ed949427 in gsignal /build/glibc-Cl5G7W/glibc-2.23/sysdeps/unix/sysv/linux/raise.c:54
  | #1 0x7f35ed94b029 in abort /build/glibc-Cl5G7W/glibc-2.23/stdlib/abort.c:89
  | #2 0x7f35ed941bd6 in __assert_fail_base /build/glibc-Cl5G7W/glibc-2.23/assert/assert.c:92
  | #3 0x7f35ed941c81 in __assert_fail /build/glibc-Cl5G7W/glibc-2.23/assert/assert.c:101
  | #4 0xdc8aef in heif::BitstreamRange::prepare_read(long) libheif/libheif/bitstream.cc:274:5
  | #5 0xdce843 in heif::Box::parse(heif::BitstreamRange&) libheif/libheif/box.cc:312:15
  | #6 0xdd0d84 in heif::Box::read(heif::BitstreamRange&, std::__1::shared_ptr<heif::Box>*) libheif/libheif/box.cc:476:20
  | #7 0xe05df5 in heif::HeifFile::parse_heif_file(heif::BitstreamRange&) libheif/libheif/heif_file.cc:166:19
  | #8 0xe05368 in heif::HeifFile::read(std::__1::shared_ptr<heif::StreamReader>) libheif/libheif/heif_file.cc:82:17
  | #9 0xe056d8 in heif::HeifFile::read_from_memory(void const*, unsigned long, bool) libheif/libheif/heif_file.cc:71:10
  | #10 0xda0796 in heif::HeifContext::read_from_memory(void const*, unsigned long, bool) libheif/libheif/heif_context.cc:357:28
  | #11 0xd8812d in heif_context_read_from_memory libheif/libheif/heif.cc:107:29
  | #12 0xae518e in ReadHEICImage imagemagick/coders/heic.c:195:9

Links:

assert(false);

Commit: 2706077
Testcase file: clusterfuzz-testcase-minimized-ping_heic_fuzzer-5723660210929664.zip

autoconfig with undefined macro: AC_CHECK_HEADER_STDBOOL

Hello,

I have another one of those cursed autoconfig error messages:

$ pkg-config --version
0.29.2
$ git pull
$ ./autogen.sh
hook ...
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy --force
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, '.'.
libtoolize: copying file './ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
autoreconf: running: /usr/local/bin/autoconf --force
configure.ac:40: error: possibly undefined macro: AC_CHECK_HEADER_STDBOOL
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
autoreconf: /usr/local/bin/autoconf failed with exit status: 1

In a previous step I could build libde265 successfully though.

Thanks for your support!
Axel.

What is HEIF/HEIC magic number?

Hi!

At GIMP's we had a report about a file wrongly interpreted as HEIC because of the wrong extension. Normally we are able to avoid this kind of error if we add magic number detection.

I couldn't get clear details about what can be considered as HEIC/HEIF magic number. Looking at a few sample images, I found that the string "ftyp" at the 5th bytes seems like a constant in every HEIC/HEIF file. Yet since I understand that HEIC/HEIF is a subformat of ISOBMFF, it looks like this magic number would also detect non-HEIC files which are ISOBMFF, right? At least it also worked with a .mov file (unfortunately!).

In the various HEIC files I could find, the longer string was either ftypmif1 or ftypheic. Would both these strings qualify as good magic numbers? Can there be other variants?
All the files I had in my possession also had the string mif1heic at the 16th byte. Is it also a confirmed constant? Can I use this as magic keyword instead?

Thanks! :-)

Thread safety

We got an issue reported for ImageMagick (ImageMagick/ImageMagick#1131) about a crash when reading an heic image multithreaded. Is this a bug in the library or should we make sure that heic images are always read in a single thread?

heif-convert Windows versus maOS

The attached file (and others) convert fine using the sample heif-convert program (to png) on macOS (10.12.6
IMG_4453.HEIC.zip), but give "Could not read HEIF file: Invalid input: No 'meta' box" on Windows (7 and 10). I can clearly see the "meta" box tag in a hex editor:

bbmbp081:~ vico$ xxd -l 128 projects/apple_formats/media/Archive_from_MikeH/Archive/IMG_4453.HEIC
00000000: 0000 0018 6674 7970 6865 6963 0000 0000 ....ftypheic....
00000010: 6d69 6631 6865 6963 0000 0f74 6d65 7461 mif1heic...tmeta
00000020: 0000 0000 0000 0022 6864 6c72 0000 0000 ......."hdlr....

Any ideas? (I had to zip the file to attach it.)

Negative-size-param (8871)

The @ImageMagick project is using https://github.com/google/oss-fuzz to find bugs in our own library and in libraries that we use. The fuzzer found an issue and we think this is an issue that should be resolved in the library that we use. This issue is posted under the url https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=8871 that is not publicly visible yet but added as a link for future reference. Below are the details of the issue that can be reproduced using the following technique: https://github.com/google/oss-fuzz/blob/master/docs/reproducing.md

Stacktrace:

==1==ERROR: AddressSanitizer: negative-size-param: (size=-320)
--
  | SCARINESS: 10 (negative-size-param)
  | #0 0x4ebcd3 in __asan_memcpy _asan_rtl_
  | #1 0xda345d in heif::HeifContext::decode_and_paste_tile_image(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const libheif/libheif/heif_context.cc:1092:7
  | #2 0xdb1a0a in __invoke<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, const heif::HeifContext *, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int, void> /usr/local/include/c++/v1/type_traits:4286:1
  | #3 0xdb1a0a in heif::Error std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, heif::HeifContext const*, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int>::__execute<1ul, 2ul, 3ul, 4ul, 5ul>(std::__1::__tuple_indices<1ul, 2ul, 3ul, 4ul, 5ul>) /usr/local/include/c++/v1/future:2330
  | #4 0xdb1788 in std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, heif::HeifContext const*, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int>::operator()() /usr/local/include/c++/v1/future:2323:16
  | #5 0xdb0f6a in std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, heif::HeifContext const*, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> >::__execute() /usr/local/include/c++/v1/future:985:25
  | #6 0xdb1c64 in __invoke<void (std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, const heif::HeifContext *, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> >::*)(), std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, const heif::HeifContext *, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> > *, void> /usr/local/include/c++/v1/type_traits:4286:1
  | #7 0xdb1c64 in __thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, const heif::HeifContext *, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> >::*)(), std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, const heif::HeifContext *, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> > *, 2> /usr/local/include/c++/v1/thread:342
  | #8 0xdb1c64 in void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, heif::HeifContext const*, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> >::*)(), std::__1::__async_assoc_state<heif::Error, std::__1::__async_func<heif::Error (heif::HeifContext::*)(unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int) const, heif::HeifContext const*, unsigned int, std::__1::shared_ptr<heif::HeifPixelImage>, int, int> >*> >(void*) /usr/local/include/c++/v1/thread:352
  | #9 0x7fb17f2ab6b9 in start_thread
  | #10 0x7fb17e9bf41c in clone /build/glibc-Cl5G7W/glibc-2.23/sysdeps/unix/sysv/linux/x86_64/clone.S:109
  | 0x7fb17b40d800 is located 0 bytes inside of 262144-byte region [0x7fb17b40d800,0x7fb17b44d800)
  | allocated by thread T4 here:
  | #0 0x52b3f8 in operator new(unsigned long) _asan_rtl_
  | #1 0xdb2b68 in __libcpp_allocate /usr/local/include/c++/v1/new:259:10
  | #2 0xdb2b68 in allocate /usr/local/include/c++/v1/memory:1799

Links:

memcpy(out_data + xs + (ys+py)*out_stride,

Commit: 2706077
Testcase file: clusterfuzz-testcase-minimized-encoder_heic_fuzzer-5666980618043392.zip

Thread safe in decoding hevc image

ImageMagick has used libheif to support HEVC format. Note that it sets hevc encoder is thread support, but decoder is not. I’m here to confirm whether this assumption is correct. Libheif doc does’t mention anything about it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.