libheif
heif_library.h
Go to the documentation of this file.
1 /*
2  * HEIF codec.
3  * Copyright (c) 2017-2023 Dirk Farin <dirk.farin@gmail.com>
4  *
5  * This file is part of libheif.
6  *
7  * libheif is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation, either version 3 of
10  * the License, or (at your option) any later version.
11  *
12  * libheif is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with libheif. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef LIBHEIF_HEIF_LIBRARY_H
22 #define LIBHEIF_HEIF_LIBRARY_H
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #include <stddef.h>
29 #include <stdint.h>
30 
31 
32 // API versions table
33 //
34 // release dec.options enc.options heif_reader heif_writer depth.rep col.profile
35 // ------------------------------------------------------------------------------------------
36 // 1.0 1 N/A N/A N/A 1 N/A
37 // 1.1 1 N/A N/A 1 1 N/A
38 // 1.3 1 1 1 1 1 N/A
39 // 1.4 1 1 1 1 1 1
40 // 1.7 2 1 1 1 1 1
41 // 1.9.2 2 2 1 1 1 1
42 // 1.10 2 3 1 1 1 1
43 // 1.11 2 4 1 1 1 1
44 // 1.13 3 4 1 1 1 1
45 // 1.14 3 5 1 1 1 1
46 // 1.15 4 5 1 1 1 1
47 // 1.16 5 6 1 1 1 1
48 // 1.18 5 7 1 1 1 1
49 // 1.19 6 7 2 1 1 1
50 // 1.20 7 7 2 1 1 1
51 // 1.21 8 7 2 1 1 1
52 // 1.22 9 8 2 1 1 1
53 // 1.23 10 8 2 1 1 1
54 
55 // The LIBHEIF_API export macro is defined in its own dependency-free header so
56 // that heif_error.h (which is needed by this header) can use it without
57 // creating an include cycle.
58 #include <libheif/heif_export.h>
59 
63 #define heif_fourcc(a, b, c, d) ((uint32_t)((a<<24) | (b<<16) | (c<<8) | d))
64 
65 #include <libheif/heif_version.h>
66 #include <libheif/heif_error.h>
67 
68 
69 /* === version numbers === */
70 
71 // Version string of linked libheif library.
72 LIBHEIF_API const char* heif_get_version(void);
73 
74 // Numeric version of linked libheif library, encoded as 0xHHMMLL00 = hh.mm.ll, where hh, mm, ll is the decimal representation of HH, MM, LL.
75 // For example: 0x02150300 is version 2.21.3
76 LIBHEIF_API uint32_t heif_get_version_number(void);
77 
78 // Numeric part "HH" from above. Returned as a decimal number.
79 LIBHEIF_API int heif_get_version_number_major(void);
80 // Numeric part "MM" from above. Returned as a decimal number.
81 LIBHEIF_API int heif_get_version_number_minor(void);
82 // Numeric part "LL" from above. Returned as a decimal number.
84 
85 // Helper macros to check for given versions of libheif at compile time.
86 #define LIBHEIF_MAKE_VERSION(h, m, l) ((h) << 24 | (m) << 16 | (l) << 8)
87 #define LIBHEIF_HAVE_VERSION(h, m, l) (LIBHEIF_NUMERIC_VERSION >= LIBHEIF_MAKE_VERSION(h, m, l))
88 
89 typedef struct heif_context heif_context;
91 
92 typedef uint32_t heif_item_id;
93 typedef uint32_t heif_property_id;
94 
99 LIBHEIF_API
100 void heif_string_release(const char*);
101 
102 
103 // ========================= library initialization ======================
104 
105 typedef struct heif_init_params
106 {
107  int version;
108 
109  // currently no parameters
111 
112 
132 LIBHEIF_API
134 
147 LIBHEIF_API
148 void heif_deinit(void);
149 
150 
151 // --- Codec plugins ---
152 
153 // --- Plugins are currently only supported on Unix platforms.
154 
155 typedef enum heif_plugin_type
156 {
160 
161 typedef struct heif_plugin_info
162 {
163  int version; // version of this info struct
165  const void* plugin;
166  void* internal_handle; // for internal use only
168 
169 LIBHEIF_API
170 heif_error heif_load_plugin(const char* filename, heif_plugin_info const** out_plugin);
171 
172 LIBHEIF_API
173 heif_error heif_load_plugins(const char* directory,
174  const heif_plugin_info** out_plugins,
175  int* out_nPluginsLoaded,
176  int output_array_size);
177 
178 LIBHEIF_API
179 heif_error heif_unload_plugin(const heif_plugin_info* plugin);
180 
181 // Get a NULL terminated array of the plugin directories that are searched by libheif.
182 // This includes the paths specified in the environment variable LIBHEIF_PLUGIN_PATHS and the built-in path
183 // (if not overridden by the environment variable).
184 LIBHEIF_API
185 const char* const* heif_get_plugin_directories(void);
186 
187 LIBHEIF_API
188 void heif_free_plugin_directories(const char* const*);
189 
190 
191 // --- register plugins
192 
195 
196 LIBHEIF_API
198 
199 LIBHEIF_API
201 
202 
203 // DEPRECATED. Use heif_register_decoder_plugin(const struct heif_decoder_plugin*) instead.
204 LIBHEIF_API
206 
207 #ifdef __cplusplus
208 }
209 #endif
210 
211 #endif
void heif_deinit(void)
Deinitialise and clean up library.
heif_plugin_type
Definition: heif_library.h:156
@ heif_plugin_type_decoder
Definition: heif_library.h:158
@ heif_plugin_type_encoder
Definition: heif_library.h:157
struct heif_decoder_plugin heif_decoder_plugin
Definition: heif_library.h:193
struct heif_init_params heif_init_params
uint32_t heif_property_id
Definition: heif_library.h:93
struct heif_image_handle heif_image_handle
Definition: heif_library.h:90
const char * heif_get_version(void)
heif_error heif_register_encoder_plugin(const heif_encoder_plugin *)
heif_error heif_init(heif_init_params *)
Initialise library.
int heif_get_version_number_maintenance(void)
int heif_get_version_number_major(void)
uint32_t heif_item_id
Definition: heif_library.h:92
uint32_t heif_get_version_number(void)
heif_error heif_load_plugin(const char *filename, heif_plugin_info const **out_plugin)
heif_error heif_unload_plugin(const heif_plugin_info *plugin)
void heif_string_release(const char *)
Free a string returned by libheif in various API functions.
void heif_free_plugin_directories(const char *const *)
heif_error heif_register_decoder(heif_context *heif, const heif_decoder_plugin *)
heif_error heif_load_plugins(const char *directory, const heif_plugin_info **out_plugins, int *out_nPluginsLoaded, int output_array_size)
heif_error heif_register_decoder_plugin(const heif_decoder_plugin *)
struct heif_plugin_info heif_plugin_info
struct heif_context heif_context
Definition: heif_library.h:89
const char *const * heif_get_plugin_directories(void)
struct heif_encoder_plugin heif_encoder_plugin
Definition: heif_library.h:194
int heif_get_version_number_minor(void)
Definition: heif_library.h:106
int version
Definition: heif_library.h:107
Definition: heif_library.h:162
void * internal_handle
Definition: heif_library.h:166
const void * plugin
Definition: heif_library.h:165
int version
Definition: heif_library.h:163
heif_plugin_type type
Definition: heif_library.h:164