Skip to content

Commit 48d614f

Browse files
authored
Merge branch 'master' into evc_boxes_2024-10-29
2 parents 2eb8e5d + 331bd06 commit 48d614f

File tree

116 files changed

+27797
-18970
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+27797
-18970
lines changed

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required (VERSION 3.16.3) # Oldest Ubuntu LTS (20.04 currently)
22

3-
project(libheif LANGUAGES C CXX VERSION 1.19.1)
3+
project(libheif LANGUAGES C CXX VERSION 1.19.5)
44

55
# compatibility_version is never allowed to be decreased for any specific SONAME.
66
# Libtool in the libheif-1.15.1 release had set it to 17.0.0, so we have to use this for the v1.x.y versions.
@@ -416,6 +416,9 @@ endif()
416416
if (KVAZAAR_FOUND AND NOT (PLUGIN_LOADING_SUPPORTED_AND_ENABLED AND WITH_KVAZAAR_PLUGIN))
417417
list(APPEND REQUIRES_PRIVATE "kvazaar")
418418
endif()
419+
if (OpenH264_FOUND AND (WITH_OpenH264_DECODER AND NOT (PLUGIN_LOADING_SUPPORTED_AND_ENABLED AND WITH_OpenH264_DECODER_PLUGIN)))
420+
list(APPEND REQUIRES_PRIVATE "openh264")
421+
endif()
419422
if ((AOM_DECODER_FOUND AND NOT (PLUGIN_LOADING_SUPPORTED_AND_ENABLED AND WITH_AOM_DECODER_PLUGIN))
420423
OR (AOM_ENCODER_FOUND AND NOT (PLUGIN_LOADING_SUPPORTED_AND_ENABLED AND WITH_AOM_ENCODER_PLUGIN)))
421424
list(APPEND REQUIRES_PRIVATE "aom")
@@ -438,6 +441,9 @@ endif()
438441
if (OpenJPEG_FOUND AND ((WITH_OpenJPEG_DECODER AND NOT (PLUGIN_LOADING_SUPPORTED_AND_ENABLED AND WITH_OpenJPEG_DECODER_PLUGIN)) OR (WITH_OpenJPEG_ENCODER AND NOT (PLUGIN_LOADING_SUPPORTED_AND_ENABLED AND WITH_OpenJPEG_ENCODER_PLUGIN))))
439442
list(APPEND REQUIRES_PRIVATE "libopenjp2")
440443
endif()
444+
if (OPENJPH_FOUND AND (WITH_OPENJPH_ENCODER AND NOT (PLUGIN_LOADING_SUPPORTED_AND_ENABLED AND WITH_OPENJPH_ENCODER_PLUGIN)))
445+
list(APPEND REQUIRES_PRIVATE "openjph")
446+
endif()
441447
if (LIBSHARPYUV_FOUND)
442448
list(APPEND REQUIRES_PRIVATE "libsharpyuv")
443449
endif()
@@ -543,6 +549,7 @@ if(ENABLE_COVERAGE)
543549
endif()
544550

545551
option(BUILD_TESTING "" ON)
552+
set(CMAKE_CTEST_ARGUMENTS "--output-on-failure")
546553
include(CTest)
547554
if(BUILD_TESTING)
548555
# TODO: fix tests on windows.

appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ before_build:
2727
- mkdir build
2828
- cd build
2929
- cmake .. -A %arch% -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake -DWITH_DAV1D=ON -DWITH_AOM_DECODER=ON -DWITH_AOM_ENCODER=ON -DWITH_JPEG_DECODER=ON -DWITH_JPEG_ENCODER=ON -DWITH_UNCOMPRESSED_CODEC=ON -DWITH_HEADER_COMPRESSION=ON -DWITH_FFMPEG_DECODER=ON
30+
- dir
3031

3132
build:
33+
project: build\libheif.sln
3234
parallel: true
3335
verbosity: normal
3436

examples/heif_dec.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -858,9 +858,12 @@ int main(int argc, char** argv)
858858

859859
decode_options->strict_decoding = strict_decoding;
860860
decode_options->decoder_id = decoder_id;
861-
decode_options->start_progress = start_progress;
862-
decode_options->on_progress = on_progress;
863-
decode_options->end_progress = end_progress;
861+
862+
if (!option_quiet) {
863+
decode_options->start_progress = start_progress;
864+
decode_options->on_progress = on_progress;
865+
decode_options->end_progress = end_progress;
866+
}
864867

865868
if (chroma_upsampling=="nearest-neighbor") {
866869
decode_options->color_conversion_options.preferred_chroma_upsampling_algorithm = heif_chroma_upsampling_nearest_neighbor;

examples/heif_enc.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void show_help(const char* argv0)
210210
<< " --tiled-image-height # override image height of tiled image\n"
211211
<< " --tiled-input-x-y usually, the first number in the input tile filename should be the y position.\n"
212212
<< " With this option, this can be swapped so that the first number is x, the second number y.\n"
213-
#if ENABLE_EXPERIMENTAL_FEATURES
213+
#if HEIF_ENABLE_EXPERIMENTAL_FEATURES
214214
<< " --tiling-method METHOD choose one of these methods: grid, tili, unci. The default is 'grid'.\n"
215215
<< " --add-pyramid-group when several images are given, put them into a multi-resolution pyramid group.\n"
216216
#endif
@@ -749,7 +749,7 @@ heif_image_handle* encode_tiled(heif_context* ctx, heif_encoder* encoder, heif_e
749749
return nullptr;
750750
}
751751
}
752-
#if ENABLE_EXPERIMENTAL_FEATURES
752+
#if HEIF_ENABLE_EXPERIMENTAL_FEATURES
753753
else if (tiling_method == "tili") {
754754
heif_tiled_image_parameters tiled_params{};
755755
tiled_params.version = 1;
@@ -776,7 +776,7 @@ heif_image_handle* encode_tiled(heif_context* ctx, heif_encoder* encoder, heif_e
776776
params.tile_height = tiling.tile_height;
777777
params.compression = unci_compression;
778778

779-
std::string input_filename = tile_generator.filename(0, 0);
779+
std::string input_filename = tile_generator.filename(0, 0).string();
780780
InputImage prototype_image = load_image(input_filename, output_bit_depth);
781781

782782
heif_error error = heif_context_add_unci_image(ctx, &params, options, prototype_image.image.get(), &tiled_image);
@@ -974,7 +974,7 @@ int main(int argc, char** argv)
974974
case OPTION_TILING_METHOD:
975975
tiling_method = optarg;
976976
if (tiling_method != "grid"
977-
#if ENABLE_EXPERIMENTAL_FEATURES
977+
#if HEIF_ENABLE_EXPERIMENTAL_FEATURES
978978
&& tiling_method != "tili" && tiling_method != "unci"
979979
#endif
980980
) {
@@ -1393,7 +1393,7 @@ int main(int argc, char** argv)
13931393
heif_image_handle_release(primary_image_handle);
13941394
}
13951395

1396-
#if ENABLE_EXPERIMENTAL_FEATURES
1396+
#if HEIF_ENABLE_EXPERIMENTAL_FEATURES
13971397
if (add_pyramid_group && encoded_image_ids.size() > 1) {
13981398
error = heif_context_add_pyramid_entity_group(context.get(), encoded_image_ids.data(), encoded_image_ids.size(), nullptr);
13991399
if (error.code) {

examples/heif_info.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ static struct option long_options[] = {
7777
{0, 0, 0, 0}
7878
};
7979

80-
const char* fourcc_to_string(uint32_t fourcc)
80+
// Note: the same function is also exists in common_utils.h, but is not in the public API.
81+
static const char* fourcc_to_string(uint32_t fourcc)
8182
{
8283
static char fcc[5];
8384
fcc[0] = (char) ((fourcc >> 24) & 0xFF);
@@ -272,7 +273,7 @@ int main(int argc, char** argv)
272273
if (err.code) {
273274
std::cerr << "Error while trying to get image tiling information: " << err.message << "\n";
274275
}
275-
else if (tiling.num_columns > 0) {
276+
else if (tiling.num_columns != 1 || tiling.num_rows != 1) {
276277
std::cout << " tiles: " << tiling.num_columns << "x" << tiling.num_rows
277278
<< ", tile size: " << tiling.tile_width << "x" << tiling.tile_height << "\n";
278279
}

fuzzing/color_conversion_fuzzer.cc

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static bool read_plane(BitstreamRange* range,
7070
if (!range->prepare_read(static_cast<size_t>(width) * height)) {
7171
return false;
7272
}
73-
if (!image->add_plane(channel, width, height, bit_depth)) {
73+
if (auto err = image->add_plane(channel, width, height, bit_depth, heif_get_disabled_security_limits())) {
7474
return false;
7575
}
7676
uint32_t stride;
@@ -96,7 +96,7 @@ static bool read_plane_interleaved(BitstreamRange* range,
9696
if (!range->prepare_read(static_cast<size_t>(width) * height * comps)) {
9797
return false;
9898
}
99-
if (!image->add_plane(channel, width, height, bit_depth)) {
99+
if (auto err = image->add_plane(channel, width, height, bit_depth, heif_get_disabled_security_limits())) {
100100
return false;
101101
}
102102
uint32_t stride;
@@ -250,19 +250,23 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
250250
int output_bpp = 0; // Same as input.
251251
heif_encoding_options* options = heif_encoding_options_alloc();
252252

253-
auto out_image = convert_colorspace(in_image,
254-
static_cast<heif_colorspace>(out_colorspace),
255-
static_cast<heif_chroma>(out_chroma),
256-
nullptr,
257-
output_bpp,
258-
options->color_conversion_options);
253+
auto out_image_result = convert_colorspace(in_image,
254+
static_cast<heif_colorspace>(out_colorspace),
255+
static_cast<heif_chroma>(out_chroma),
256+
nullptr,
257+
output_bpp,
258+
options->color_conversion_options,
259+
heif_get_disabled_security_limits());
260+
259261
heif_encoding_options_free(options);
260262

261-
if (!out_image) {
263+
if (out_image_result.error) {
262264
// Conversion is not supported.
263265
return 0;
264266
}
265267

268+
auto out_image = *out_image_result;
269+
266270
assert(out_image->get_width() == width);
267271
assert(out_image->get_height() == height);
268272
assert(out_image->get_chroma_format() ==

fuzzing/file_fuzzer.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ static void TestDecodeImage(struct heif_context* ctx,
5151
heif_image_handle_get_metadata_type(handle, metadata_ids[i]);
5252
heif_image_handle_get_metadata_content_type(handle, metadata_ids[i]);
5353
size_t metadata_size = heif_image_handle_get_metadata_size(handle, metadata_ids[i]);
54-
assert(metadata_size < filesize);
54+
55+
// This assertion is invalid. Metadata can in fact be larger than the file if there are several
56+
// overlapping iloc extents. Does not make much sense, but it is technically valid.
57+
//assert(metadata_size < filesize);
58+
5559
uint8_t* metadata_data = static_cast<uint8_t*>(malloc(metadata_size));
5660
assert(metadata_data);
5761
heif_image_handle_get_metadata(handle, metadata_ids[i], metadata_data);

libheif/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ if (ENABLE_EXPERIMENTAL_FEATURES)
140140

141141
list(APPEND libheif_headers api/libheif/heif_experimental.h)
142142

143-
target_compile_definitions(heif PUBLIC ENABLE_EXPERIMENTAL_FEATURES)
143+
target_compile_definitions(heif PUBLIC HEIF_ENABLE_EXPERIMENTAL_FEATURES)
144144
endif()
145145

146146
# Needed to find libheif/heif_version.h while compiling the library

libheif/api/libheif/heif.cc

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,8 @@ struct heif_error heif_image_handle_get_tile_size(const struct heif_image_handle
10201020

10211021

10221022
struct heif_entity_group* heif_context_get_entity_groups(const struct heif_context* ctx,
1023-
uint32_t type_filter, uint32_t item_filter,
1023+
uint32_t type_filter,
1024+
heif_item_id item_filter,
10241025
int* out_num_groups)
10251026
{
10261027
std::shared_ptr<Box_grpl> grplBox = ctx->context->get_heif_file()->get_grpl_box();
@@ -1557,7 +1558,7 @@ void heif_image_get_content_light_level(const struct heif_image* image, struct h
15571558

15581559
int heif_image_handle_get_content_light_level(const struct heif_image_handle* handle, struct heif_content_light_level* out)
15591560
{
1560-
auto clli = handle->image->get_file()->get_property<Box_clli>(handle->image->get_id());
1561+
auto clli = handle->image->get_property<Box_clli>();
15611562
if (out && clli) {
15621563
*out = clli->clli;
15631564
}
@@ -1587,7 +1588,7 @@ void heif_image_get_mastering_display_colour_volume(const struct heif_image* ima
15871588

15881589
int heif_image_handle_get_mastering_display_colour_volume(const struct heif_image_handle* handle, struct heif_mastering_display_colour_volume* out)
15891590
{
1590-
auto mdcv = handle->image->get_file()->get_property<Box_mdcv>(handle->image->get_id());
1591+
auto mdcv = handle->image->get_property<Box_mdcv>();
15911592
if (out && mdcv) {
15921593
*out = mdcv->mdcv;
15931594
}
@@ -1664,7 +1665,7 @@ void heif_image_get_pixel_aspect_ratio(const struct heif_image* image, uint32_t*
16641665

16651666
int heif_image_handle_get_pixel_aspect_ratio(const struct heif_image_handle* handle, uint32_t* aspect_h, uint32_t* aspect_v)
16661667
{
1667-
auto pasp = handle->image->get_file()->get_property<Box_pasp>(handle->image->get_id());
1668+
auto pasp = handle->image->get_property<Box_pasp>();
16681669
if (pasp) {
16691670
*aspect_h = pasp->hSpacing;
16701671
*aspect_v = pasp->vSpacing;
@@ -1773,7 +1774,7 @@ heif_error heif_image_crop(struct heif_image* img,
17731774
"Image size exceeds maximum supported size"};
17741775
}
17751776

1776-
auto cropResult = img->image->crop(left, static_cast<int>(w) - 1 - right, top, static_cast<int>(h) - 1 - bottom);
1777+
auto cropResult = img->image->crop(left, static_cast<int>(w) - 1 - right, top, static_cast<int>(h) - 1 - bottom, nullptr);
17771778
if (cropResult.error) {
17781779
return cropResult.error.error_struct(img->image.get());
17791780
}
@@ -1805,11 +1806,9 @@ int heif_image_has_channel(const struct heif_image* img, enum heif_channel chann
18051806
struct heif_error heif_image_add_plane(struct heif_image* image,
18061807
heif_channel channel, int width, int height, int bit_depth)
18071808
{
1808-
if (!image->image->add_plane(channel, width, height, bit_depth)) {
1809-
struct heif_error err = {heif_error_Memory_allocation_error,
1810-
heif_suberror_Unspecified,
1811-
"Cannot allocate memory for image plane"};
1812-
return err;
1809+
// Note: no security limit, because this is explicitly requested by the user.
1810+
if (auto err = image->image->add_plane(channel, width, height, bit_depth, nullptr)) {
1811+
return err.error_struct(image->image.get());
18131812
}
18141813
else {
18151814
return heif_error_success;
@@ -1822,7 +1821,7 @@ struct heif_error heif_image_add_channel(struct heif_image* image,
18221821
int width, int height,
18231822
heif_channel_datatype datatype, int bit_depth)
18241823
{
1825-
if (!image->image->add_channel(channel, width, height, datatype, bit_depth)) {
1824+
if (!image->image->add_channel(channel, width, height, datatype, bit_depth, nullptr)) {
18261825
struct heif_error err = {heif_error_Memory_allocation_error,
18271826
heif_suberror_Unspecified,
18281827
"Cannot allocate memory for image plane"};
@@ -1996,11 +1995,9 @@ int heif_image_is_premultiplied_alpha(struct heif_image* image)
19961995

19971996
struct heif_error heif_image_extend_padding_to_size(struct heif_image* image, int min_physical_width, int min_physical_height)
19981997
{
1999-
bool mem_alloc_success = image->image->extend_padding_to_size(min_physical_width, min_physical_height);
2000-
if (!mem_alloc_success) {
2001-
return heif_error{heif_error_Memory_allocation_error,
2002-
heif_suberror_Unspecified,
2003-
"Cannot allocate image memory."};
1998+
Error err = image->image->extend_padding_to_size(min_physical_width, min_physical_height, false, nullptr);
1999+
if (err) {
2000+
return err.error_struct(image->image.get());
20042001
}
20052002
else {
20062003
return heif_error_success;
@@ -2015,7 +2012,7 @@ struct heif_error heif_image_scale_image(const struct heif_image* input,
20152012
{
20162013
std::shared_ptr<HeifPixelImage> out_img;
20172014

2018-
Error err = input->image->scale_nearest_neighbor(out_img, width, height);
2015+
Error err = input->image->scale_nearest_neighbor(out_img, width, height, nullptr);
20192016
if (err) {
20202017
return err.error_struct(input->image.get());
20212018
}
@@ -2030,11 +2027,9 @@ struct heif_error heif_image_scale_image(const struct heif_image* input,
20302027
struct heif_error heif_image_extend_to_size_fill_with_zero(struct heif_image* image,
20312028
uint32_t width, uint32_t height)
20322029
{
2033-
bool success = image->image->extend_to_size_with_zero(width, height);
2034-
if (!success) {
2035-
return heif_error{heif_error_Memory_allocation_error,
2036-
heif_suberror_Unspecified,
2037-
"Not enough memory to extend image size."};
2030+
Error err = image->image->extend_to_size_with_zero(width, height, nullptr);
2031+
if (err) {
2032+
return err.error_struct(image->image.get());
20382033
}
20392034

20402035
return heif_error_ok;
@@ -3055,7 +3050,7 @@ heif_encoder_parameter_get_valid_integer_range(const struct heif_encoder_paramet
30553050
return heif_error_success;
30563051
}
30573052

3058-
LIBHEIF_API
3053+
30593054
struct heif_error heif_encoder_parameter_get_valid_integer_values(const struct heif_encoder_parameter* param,
30603055
int* have_minimum, int* have_maximum,
30613056
int* minimum, int* maximum,
@@ -3650,7 +3645,7 @@ struct heif_error heif_context_add_image_tile(struct heif_context* ctx,
36503645
}
36513646
#endif
36523647
else if (auto grid_item = std::dynamic_pointer_cast<ImageItem_Grid>(tiled_image->image)) {
3653-
Error err = grid_item->add_image_tile(tiled_image->image->get_id(), tile_x, tile_y, image->image, encoder);
3648+
Error err = grid_item->add_image_tile(tile_x, tile_y, image->image, encoder);
36543649
return err.error_struct(ctx->context.get());
36553650
}
36563651
else {

libheif/api/libheif/heif.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ extern "C" {
5555
// 1.18 5 7 1 1 1 1
5656
// 1.19 6 7 2 1 1 1
5757

58-
#if defined(_MSC_VER) && !defined(LIBHEIF_STATIC_BUILD)
58+
#if (defined(_WIN32) || defined __CYGWIN__) && !defined(LIBHEIF_STATIC_BUILD)
5959
#ifdef LIBHEIF_EXPORTS
6060
#define LIBHEIF_API __declspec(dllexport)
6161
#else
@@ -1324,7 +1324,10 @@ struct heif_entity_group
13241324
// Use 0 for `type_filter` or `item_filter` to disable the filter.
13251325
// Returns an array of heif_entity_group structs with *out_num_groups entries.
13261326
LIBHEIF_API
1327-
struct heif_entity_group* heif_context_get_entity_groups(const struct heif_context*, uint32_t type_filter, uint32_t item_filter, int* out_num_groups);
1327+
struct heif_entity_group* heif_context_get_entity_groups(const struct heif_context*,
1328+
uint32_t type_filter,
1329+
heif_item_id item_filter,
1330+
int* out_num_groups);
13281331

13291332
// Release an array of entity groups returned by heif_context_get_entity_groups().
13301333
LIBHEIF_API
@@ -2363,7 +2366,7 @@ struct heif_encoding_options
23632366

23642367
// Set this to the NCLX parameters to be used in the output image or set to NULL
23652368
// when the same parameters as in the input image should be used.
2366-
const struct heif_color_profile_nclx* output_nclx_profile;
2369+
struct heif_color_profile_nclx* output_nclx_profile;
23672370

23682371
uint8_t macOS_compatibility_workaround_no_nclx_profile;
23692372

0 commit comments

Comments
 (0)