Skip to content

Commit

Permalink
do not compile public experimental API if disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Oct 13, 2024
1 parent 26714aa commit 660ede4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
18 changes: 10 additions & 8 deletions libheif/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ set(libheif_headers
api/libheif/heif_items.h
${CMAKE_CURRENT_BINARY_DIR}/heif_version.h)

option(INSTALL_EXPERIMENTAL_HEADERS "Install headers with unstable API" OFF)

if (INSTALL_EXPERIMENTAL_HEADERS)
list(APPEND libheif_headers api/libheif/heif_experimental.h)
endif()

set(libheif_sources
bitstream.cc
bitstream.h
Expand Down Expand Up @@ -55,8 +49,6 @@ set(libheif_sources
api/libheif/heif_plugin.cc
api/libheif/heif_properties.cc
api/libheif/heif_items.cc
api/libheif/heif_experimental.h
api/libheif/heif_experimental.cc
codecs/decoder.h
codecs/decoder.cc
image-items/hevc.cc
Expand Down Expand Up @@ -137,6 +129,16 @@ if (ENABLE_PLUGIN_LOADING)
endif ()
endif ()

option(WITH_EXPERIMENTAL_FEATURES "Compile experimental features and install headers with unstable API" OFF)
if (WITH_EXPERIMENTAL_FEATURES)
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)
endif()

# Needed to find libheif/heif_version.h while compiling the library
target_include_directories(heif PRIVATE ${libheif_BINARY_DIR} ${libheif_SOURCE_DIR}/libheif ${libheif_SOURCE_DIR}/libheif/api)

Expand Down
20 changes: 13 additions & 7 deletions libheif/api/libheif/heif_experimental.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
extern "C" {
#endif

#if WITH_EXPERIMENTAL_FEATURES

/* ===================================================================================
* This file contains candidate APIs that did not make it into the public API yet.
Expand Down Expand Up @@ -109,6 +110,7 @@ struct heif_error heif_property_camera_extrinsic_matrix_get_position_vector(cons
//LIBHEIF_API
struct heif_error heif_property_camera_extrinsic_matrix_get_world_coordinate_system_id(const struct heif_property_camera_extrinsic_matrix* matrix,
uint32_t* out_wcs_id);
#endif

// --- Tiled images

Expand All @@ -135,13 +137,13 @@ struct heif_tiled_image_parameters {
uint8_t tiles_are_sequential; // TODO: can we derive this automatically
};


#if WITH_EXPERIMENTAL_FEATURES
LIBHEIF_API
struct heif_error heif_context_add_tiled_image(struct heif_context* ctx,
const struct heif_tiled_image_parameters* parameters,
const struct heif_encoding_options* options, // TODO: do we need this?
struct heif_image_handle** out_tiled_image_handle);

#endif

// --- 'unci' images

Expand All @@ -161,14 +163,14 @@ struct heif_unci_image_parameters {
// TODO: interleave type, padding
};


#if WITH_EXPERIMENTAL_FEATURES
LIBHEIF_API
struct heif_error heif_context_add_unci_image(struct heif_context* ctx,
const struct heif_unci_image_parameters* parameters,
const struct heif_encoding_options* encoding_options,
const struct heif_image* prototype,
struct heif_image_handle** out_unci_image_handle);

#endif

// --- 'pymd' entity group (pyramid layers)

Expand All @@ -179,6 +181,7 @@ struct heif_pyramid_layer_info {
uint32_t tiles_in_layer_column;
};

#if WITH_EXPERIMENTAL_FEATURES
LIBHEIF_API
struct heif_error heif_context_add_pyramid_entity_group(struct heif_context* ctx,
uint16_t tile_width,
Expand All @@ -192,7 +195,7 @@ struct heif_pyramid_layer_info* heif_context_get_pyramid_entity_group_info(struc

LIBHEIF_API
void heif_pyramid_layer_info_release(struct heif_pyramid_layer_info*);

#endif

// --- other pixel datatype support

Expand All @@ -205,7 +208,7 @@ enum heif_channel_datatype
heif_channel_datatype_complex_number = 4
};


#if WITH_EXPERIMENTAL_FEATURES
LIBHEIF_API
struct heif_error heif_image_add_channel(struct heif_image* image,
enum heif_channel channel,
Expand All @@ -219,7 +222,7 @@ int heif_image_list_channels(struct heif_image*,

LIBHEIF_API
void heif_channel_release_list(enum heif_channel** channels);

#endif

struct heif_complex32 {
float real, imaginary;
Expand All @@ -229,6 +232,7 @@ struct heif_complex64 {
double real, imaginary;
};

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

Expand Down Expand Up @@ -334,6 +338,8 @@ struct heif_complex64* heif_image_get_channel_complex64(struct heif_image*,
enum heif_channel channel,
uint32_t* out_stride);

#endif

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 2 additions & 0 deletions libheif/box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -668,9 +668,11 @@ Error Box::read(BitstreamRange& range, std::shared_ptr<Box>* result, const heif_
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'
Expand Down

0 comments on commit 660ede4

Please sign in to comment.