Skip to content

Commit

Permalink
fix compilation when ENABLE_EXPERIMENTAL_FEATURS is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Oct 15, 2024
1 parent df56a03 commit 13a23cf
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 64 deletions.
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"CMAKE_BUILD_TYPE": "Debug",
"BUILD_SHARED_LIBS": "ON",
"BUILD_TESTING" : "ON",
"WITH_EXPERIMENTAL_FEATURES" : "ON",
"ENABLE_EXPERIMENTAL_FEATURS" : "ON",

"ENABLE_PLUGIN_LOADING" : "OFF",
"WITH_AOM_DECODER" : "ON",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ Further options are:
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).
* `WITH_EXPERIMENTAL_FEATURES`: enables functions that are currently in development and for which the API is not stable yet.
* `ENABLE_EXPERIMENTAL_FEATURS`: enables functions that are currently in development and for which the API is not stable yet.
When this is enabled, a header `heif_experimental.h` will be installed that contains this unstable API.
Distributions that rely on a stable API should not enable this.
* `ENABLE_MULTITHREADING_SUPPORT`: can be used to disable any multithreading support, e.g. for embedded platforms.
Expand Down
8 changes: 4 additions & 4 deletions examples/heif_enc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void show_help(const char* argv0)
<< " --tiled-image-height # override image height of tiled image\n"
<< " --tiled-input-x-y usually, the first number in the input tile filename should be the y position.\n"
<< " With this option, this can be swapped so that the first number is x, the second number y.\n"
#if WITH_EXPERIMENTAL_FEATURES
#if ENABLE_EXPERIMENTAL_FEATURS
<< " --tiling-method METHOD choose one of these methods: grid, tili, unci. The default is 'grid'.\n"
<< " --add-pyramid-group when several images are given, put them into a multi-resolution pyramid group.\n"
#endif
Expand Down Expand Up @@ -772,7 +772,7 @@ heif_image_handle* encode_tiled(heif_context* ctx, heif_encoder* encoder, heif_e
return nullptr;
}
}
#if WITH_EXPERIMENTAL_FEATURES
#if ENABLE_EXPERIMENTAL_FEATURS
else if (tiling_method == "tili") {
heif_tiled_image_parameters tiled_params{};
tiled_params.version = 1;
Expand Down Expand Up @@ -992,7 +992,7 @@ int main(int argc, char** argv)
case OPTION_TILING_METHOD:
tiling_method = optarg;
if (tiling_method != "grid"
#if WITH_EXPERIMENTAL_FEATURES
#if ENABLE_EXPERIMENTAL_FEATURS
&& tiling_method != "tili" && tiling_method != "unci"
#endif
) {
Expand Down Expand Up @@ -1411,7 +1411,7 @@ int main(int argc, char** argv)
heif_image_handle_release(primary_image_handle);
}

#if WITH_EXPERIMENTAL_FEATURES
#if ENABLE_EXPERIMENTAL_FEATURS
if (add_pyramid_group && encoded_image_ids.size() > 1) {
error = heif_context_add_pyramid_entity_group(context.get(), encoded_image_ids.data(), encoded_image_ids.size(), nullptr);
if (error.code) {
Expand Down
6 changes: 3 additions & 3 deletions libheif/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ if (ENABLE_PLUGIN_LOADING)
endif ()
endif ()

option(WITH_EXPERIMENTAL_FEATURES "Compile experimental features and install headers with unstable API" OFF)
if (WITH_EXPERIMENTAL_FEATURES)
option(ENABLE_EXPERIMENTAL_FEATURS "Compile experimental features and install headers with unstable API" OFF)
if (ENABLE_EXPERIMENTAL_FEATURS)
list(APPEND libheif_sources api/libheif/heif_experimental.h
api/libheif/heif_experimental.cc)

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

target_compile_definitions(heif PUBLIC WITH_EXPERIMENTAL_FEATURES)
target_compile_definitions(heif PUBLIC ENABLE_EXPERIMENTAL_FEATURS)
endif()

# Needed to find libheif/heif_version.h while compiling the library
Expand Down
16 changes: 8 additions & 8 deletions libheif/api/libheif/heif_experimental.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
extern "C" {
#endif

#if WITH_EXPERIMENTAL_FEATURES
#if ENABLE_EXPERIMENTAL_FEATURS

/* ===================================================================================
* This file contains candidate APIs that did not make it into the public API yet.
Expand Down Expand Up @@ -137,7 +137,7 @@ struct heif_tiled_image_parameters {
uint8_t tiles_are_sequential; // TODO: can we derive this automatically
};

#if WITH_EXPERIMENTAL_FEATURES
#if ENABLE_EXPERIMENTAL_FEATURS
LIBHEIF_API
struct heif_error heif_context_add_tiled_image(struct heif_context* ctx,
const struct heif_tiled_image_parameters* parameters,
Expand All @@ -164,7 +164,7 @@ struct heif_unci_image_parameters {
// TODO: interleave type, padding
};

#if WITH_EXPERIMENTAL_FEATURES
#if ENABLE_EXPERIMENTAL_FEATURS
LIBHEIF_API
struct heif_error heif_context_add_unci_image(struct heif_context* ctx,
const struct heif_unci_image_parameters* parameters,
Expand All @@ -182,7 +182,7 @@ struct heif_pyramid_layer_info {
uint32_t tiles_in_layer_column;
};

#if WITH_EXPERIMENTAL_FEATURES
#if ENABLE_EXPERIMENTAL_FEATURS
// The input images are automatically sorted according to resolution. You can provide them in any order.
LIBHEIF_API
struct heif_error heif_context_add_pyramid_entity_group(struct heif_context* ctx,
Expand All @@ -208,7 +208,7 @@ enum heif_channel_datatype
heif_channel_datatype_complex_number = 4
};

#if WITH_EXPERIMENTAL_FEATURES
#if ENABLE_EXPERIMENTAL_FEATURS
LIBHEIF_API
struct heif_error heif_image_add_channel(struct heif_image* image,
enum heif_channel channel,
Expand All @@ -232,7 +232,7 @@ struct heif_complex64 {
double real, imaginary;
};

#if WITH_EXPERIMENTAL_FEATURES
#if ENABLE_EXPERIMENTAL_FEATURS
LIBHEIF_API
enum heif_channel_datatype heif_image_get_datatype(const struct heif_image* img, enum heif_channel channel);

Expand Down Expand Up @@ -359,7 +359,7 @@ struct heif_tai_clock_info
};


#if WITH_EXPERIMENTAL_FEATURES
#if ENABLE_EXPERIMENTAL_FEATURS
int heif_is_tai_clock_info_drift_rate_undefined(int32_t drift_rate);


Expand Down Expand Up @@ -391,7 +391,7 @@ struct heif_tai_timestamp_packet
uint8_t timestamp_is_modified; // bool
};

#if WITH_EXPERIMENTAL_FEATURES
#if ENABLE_EXPERIMENTAL_FEATURS

// Creates a new TAI timestamp property if one doesn't already exist for itemId.
// Creates a new clock info property if one doesn't already exist for itemId.
Expand Down
76 changes: 39 additions & 37 deletions libheif/api/libheif/heif_properties.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,43 +317,6 @@ int heif_is_tai_clock_info_drift_rate_undefined(int32_t drift_rate)
}


struct heif_error heif_property_set_clock_info(struct heif_context* ctx,
heif_item_id itemId,
const heif_tai_clock_info* clock,
heif_property_id* out_propertyId)
{
if (!ctx || !clock) {
return {heif_error_Usage_error, heif_suberror_Null_pointer_argument, "NULL passed"};
}

// Check if itemId exists
auto file = ctx->context->get_heif_file();
if (!file->image_exists(itemId)) {
return {heif_error_Input_does_not_exist, heif_suberror_Invalid_parameter_value, "itemId does not exist"};
}

// Create new taic if one doesn't exist for the itemId.
auto taic = ctx->context->get_heif_file()->get_property<Box_taic>(itemId);
if (!taic) {
taic = std::make_shared<Box_taic>();
}

taic->set_time_uncertainty(clock->time_uncertainty);
taic->set_clock_resolution(clock->clock_resolution);
taic->set_clock_drift_rate(clock->clock_drift_rate);
taic->set_clock_type(clock->clock_type);

bool essential = false;
heif_property_id id = ctx->context->add_property(itemId, taic, essential);

if (out_propertyId) {
*out_propertyId = id;
}

return heif_error_success;
}


struct heif_error heif_item_add_raw_property(const struct heif_context* context,
heif_item_id itemId,
uint32_t short_type,
Expand Down Expand Up @@ -410,6 +373,44 @@ struct heif_error find_property(const struct heif_context* context,
}


#if ENABLE_EXPERIMENTAL_FEATURS
struct heif_error heif_property_set_clock_info(struct heif_context* ctx,
heif_item_id itemId,
const heif_tai_clock_info* clock,
heif_property_id* out_propertyId)
{
if (!ctx || !clock) {
return {heif_error_Usage_error, heif_suberror_Null_pointer_argument, "NULL passed"};
}

// Check if itemId exists
auto file = ctx->context->get_heif_file();
if (!file->image_exists(itemId)) {
return {heif_error_Input_does_not_exist, heif_suberror_Invalid_parameter_value, "itemId does not exist"};
}

// Create new taic if one doesn't exist for the itemId.
auto taic = ctx->context->get_heif_file()->get_property<Box_taic>(itemId);
if (!taic) {
taic = std::make_shared<Box_taic>();
}

taic->set_time_uncertainty(clock->time_uncertainty);
taic->set_clock_resolution(clock->clock_resolution);
taic->set_clock_drift_rate(clock->clock_drift_rate);
taic->set_clock_type(clock->clock_type);

bool essential = false;
heif_property_id id = ctx->context->add_property(itemId, taic, essential);

if (out_propertyId) {
*out_propertyId = id;
}

return heif_error_success;
}


struct heif_error heif_property_get_clock_info(const struct heif_context* ctx,
heif_item_id itemId,
heif_tai_clock_info* out_clock)
Expand Down Expand Up @@ -521,6 +522,7 @@ struct heif_error heif_property_get_tai_timestamp(const struct heif_context* ctx

return heif_error_success;
}
#endif


struct heif_error heif_item_get_property_raw_size(const struct heif_context* context,
Expand Down
1 change: 1 addition & 0 deletions libheif/bitstream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <utility>
#include <cstring>
#include <cassert>
#include <bit>

#define MAX_UVLC_LEADING_ZEROS 20

Expand Down
20 changes: 11 additions & 9 deletions libheif/box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -656,13 +656,20 @@ Error Box::read(BitstreamRange& range, std::shared_ptr<Box>* result, const heif_
box = std::make_shared<Box_j2kL>();
break;

#if ENABLE_EXPERIMENTAL_FEATURS
case fourcc("tilC"):
box = std::make_shared<Box_tilC>();
break;
#endif

// --- mski

case fourcc("mskC"):
box = std::make_shared<Box_mskC>();
break;

// --- TAI timestamps
#if ENABLE_EXPERIMENTAL_FEATURS
// --- TAI timestamps

case fourcc("itai"):
box = std::make_shared<Box_itai>();
Expand All @@ -671,19 +678,14 @@ Error Box::read(BitstreamRange& range, std::shared_ptr<Box>* result, const heif_
case fourcc("taic"):
box = std::make_shared<Box_taic>();
break;
#endif

// --- AVC (H.264)

case fourcc("avcC"):
box = std::make_shared<Box_avcC>();
break;

#if WITH_EXPERIMENTAL_FEATURES
case fourcc("tilC"):
box = std::make_shared<Box_tilC>();
break;
#endif

case fourcc("mdat"):
// avoid generating a 'Box_other'
box = std::make_shared<Box>();
Expand Down Expand Up @@ -4363,7 +4365,7 @@ Error Box_cmex::write(StreamWriter& writer) const
}



#if ENABLE_EXPERIMENTAL_FEATURS
std::string Box_taic::dump(Indent& indent) const {
std::ostringstream sstr;
sstr << Box::dump(indent);
Expand Down Expand Up @@ -4441,4 +4443,4 @@ Error Box_itai::parse(BitstreamRange& range, const heif_security_limits*) {

return range.get_error();
}

#endif
3 changes: 2 additions & 1 deletion libheif/box.h
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,7 @@ class Box_udes : public FullBox
};



#if ENABLE_EXPERIMENTAL_FEATURS
class Box_taic : public FullBox
{
public:
Expand Down Expand Up @@ -1592,5 +1592,6 @@ class Box_itai : public FullBox
bool m_timestamp_generation_failure;
bool m_timestamp_is_modified;
};
#endif

#endif

0 comments on commit 13a23cf

Please sign in to comment.