169169#ifndef ASTCENC_INCLUDED
170170#define ASTCENC_INCLUDED
171171
172- #include < cstddef>
173- #include < cstdint>
172+ #if defined(__cplusplus)
173+ #include < cstddef>
174+ #include < cstdint>
175+
176+ #define ASTCENC_EXTERN_C extern " C"
177+ #else
178+ #include < stddef.h>
179+ #include < stdint.h>
180+ #include < stdbool.h>
181+
182+ #define ASTCENC_EXTERN_C
183+ #endif
174184
175185#if defined(ASTCENC_DYNAMIC_LIBRARY)
176186 #if defined(_MSC_VER)
177- #define ASTCENC_PUBLIC extern " C " __declspec(dllexport)
187+ #define ASTCENC_PUBLIC ASTCENC_EXTERN_C __declspec (dllexport)
178188 #else
179- #define ASTCENC_PUBLIC extern " C " __attribute__ ((visibility (" default" )))
189+ #define ASTCENC_PUBLIC ASTCENC_EXTERN_C __attribute__ ((visibility (" default" )))
180190 #endif
181191#else
182- #define ASTCENC_PUBLIC
192+ #define ASTCENC_PUBLIC ASTCENC_EXTERN_C
183193#endif
184194
185195/* ============================================================================
@@ -284,13 +294,13 @@ enum astcenc_swz
284294struct astcenc_swizzle
285295{
286296 /* * @brief The red component selector. */
287- astcenc_swz r;
297+ enum astcenc_swz r;
288298 /* * @brief The green component selector. */
289- astcenc_swz g;
299+ enum astcenc_swz g;
290300 /* * @brief The blue component selector. */
291- astcenc_swz b;
301+ enum astcenc_swz b;
292302 /* * @brief The alpha component selector. */
293- astcenc_swz a;
303+ enum astcenc_swz a;
294304};
295305
296306/* *
@@ -309,7 +319,7 @@ enum astcenc_type
309319/* *
310320 * @brief Function pointer type for compression progress reporting callback.
311321 */
312- extern " C " typedef void (*astcenc_progress_callback)(float );
322+ ASTCENC_EXTERN_C typedef void (*astcenc_progress_callback)(float );
313323
314324/* *
315325 * @brief Enable normal map compression.
@@ -417,7 +427,7 @@ static const unsigned int ASTCENC_ALL_FLAGS =
417427struct astcenc_config
418428{
419429 /* * @brief The color profile. */
420- astcenc_profile profile;
430+ enum astcenc_profile profile;
421431
422432 /* * @brief The set of set flags. */
423433 unsigned int flags;
@@ -576,7 +586,7 @@ struct astcenc_config
576586 /* *
577587 * @brief The progress callback, can be @c nullptr.
578588 *
579- * If this is specified the codec will peridocially report progress for
589+ * If this is specified the codec will periodically report progress for
580590 * compression as a percentage between 0 and 100. The callback is called from one
581591 * of the compressor threads, so doing significant work in the callback will
582592 * reduce compression performance.
@@ -612,7 +622,7 @@ struct astcenc_image
612622 unsigned int dim_z;
613623
614624 /* * @brief The data type per component. */
615- astcenc_type data_type;
625+ enum astcenc_type data_type;
616626
617627 /* * @brief The array of 2D slices, of length @c dim_z. */
618628 void ** data;
@@ -627,7 +637,7 @@ struct astcenc_image
627637struct astcenc_block_info
628638{
629639 /* * @brief The block encoding color profile. */
630- astcenc_profile profile;
640+ enum astcenc_profile profile;
631641
632642 /* * @brief The number of texels in the X dimension. */
633643 unsigned int block_x;
@@ -712,14 +722,14 @@ struct astcenc_block_info
712722 * @return @c ASTCENC_SUCCESS on success, or an error if the inputs are invalid
713723 * either individually, or in combination.
714724 */
715- ASTCENC_PUBLIC astcenc_error astcenc_config_init (
716- astcenc_profile profile,
725+ ASTCENC_PUBLIC enum astcenc_error astcenc_config_init (
726+ enum astcenc_profile profile,
717727 unsigned int block_x,
718728 unsigned int block_y,
719729 unsigned int block_z,
720730 float quality,
721731 unsigned int flags,
722- astcenc_config* config);
732+ struct astcenc_config * config);
723733
724734/* *
725735 * @brief Allocate a new codec context based on a config.
@@ -748,11 +758,11 @@ ASTCENC_PUBLIC astcenc_error astcenc_config_init(
748758 *
749759 * @return @c ASTCENC_SUCCESS on success, or an error if context creation failed.
750760 */
751- ASTCENC_PUBLIC astcenc_error astcenc_context_alloc (
752- const astcenc_config* config,
761+ ASTCENC_PUBLIC enum astcenc_error astcenc_context_alloc (
762+ const struct astcenc_config * config,
753763 unsigned int thread_count,
754- astcenc_context** context,
755- const astcenc_context* parent_context);
764+ struct astcenc_context ** context,
765+ const struct astcenc_context * parent_context);
756766
757767/* *
758768 * @brief Compress an image.
@@ -772,10 +782,10 @@ ASTCENC_PUBLIC astcenc_error astcenc_context_alloc(
772782 *
773783 * @return @c ASTCENC_SUCCESS on success, or an error if compression failed.
774784 */
775- ASTCENC_PUBLIC astcenc_error astcenc_compress_image (
776- astcenc_context* context,
777- astcenc_image* image,
778- const astcenc_swizzle* swizzle,
785+ ASTCENC_PUBLIC enum astcenc_error astcenc_compress_image (
786+ struct astcenc_context * context,
787+ struct astcenc_image * image,
788+ const struct astcenc_swizzle * swizzle,
779789 uint8_t * data_out,
780790 size_t data_len,
781791 unsigned int thread_index);
@@ -793,8 +803,8 @@ ASTCENC_PUBLIC astcenc_error astcenc_compress_image(
793803 *
794804 * @return @c ASTCENC_SUCCESS on success, or an error if reset failed.
795805 */
796- ASTCENC_PUBLIC astcenc_error astcenc_compress_reset (
797- astcenc_context* context);
806+ ASTCENC_PUBLIC enum astcenc_error astcenc_compress_reset (
807+ struct astcenc_context * context);
798808
799809/* *
800810 * @brief Cancel any pending compression operation.
@@ -807,8 +817,8 @@ ASTCENC_PUBLIC astcenc_error astcenc_compress_reset(
807817 *
808818 * @return @c ASTCENC_SUCCESS on success, or an error if cancellation failed.
809819 */
810- ASTCENC_PUBLIC astcenc_error astcenc_compress_cancel (
811- astcenc_context* context);
820+ ASTCENC_PUBLIC enum astcenc_error astcenc_compress_cancel (
821+ struct astcenc_context * context);
812822
813823/* *
814824 * @brief Decompress an image.
@@ -822,12 +832,12 @@ ASTCENC_PUBLIC astcenc_error astcenc_compress_cancel(
822832 *
823833 * @return @c ASTCENC_SUCCESS on success, or an error if decompression failed.
824834 */
825- ASTCENC_PUBLIC astcenc_error astcenc_decompress_image (
826- astcenc_context* context,
835+ ASTCENC_PUBLIC enum astcenc_error astcenc_decompress_image (
836+ struct astcenc_context * context,
827837 const uint8_t * data,
828838 size_t data_len,
829- astcenc_image* image_out,
830- const astcenc_swizzle* swizzle,
839+ struct astcenc_image * image_out,
840+ const struct astcenc_swizzle * swizzle,
831841 unsigned int thread_index);
832842
833843/* *
@@ -843,16 +853,16 @@ ASTCENC_PUBLIC astcenc_error astcenc_decompress_image(
843853 *
844854 * @return @c ASTCENC_SUCCESS on success, or an error if reset failed.
845855 */
846- ASTCENC_PUBLIC astcenc_error astcenc_decompress_reset (
847- astcenc_context* context);
856+ ASTCENC_PUBLIC enum astcenc_error astcenc_decompress_reset (
857+ struct astcenc_context * context);
848858
849859/* *
850860 * Free the compressor context.
851861 *
852862 * @param context The codec context.
853863 */
854864ASTCENC_PUBLIC void astcenc_context_free (
855- astcenc_context* context);
865+ struct astcenc_context * context);
856866
857867/* *
858868 * @brief Provide a high level summary of a block's encoding.
@@ -868,10 +878,10 @@ ASTCENC_PUBLIC void astcenc_context_free(
868878 * function will return success even if the block itself was an error block encoding, as the
869879 * decode was correctly handled.
870880 */
871- ASTCENC_PUBLIC astcenc_error astcenc_get_block_info (
872- astcenc_context* context,
881+ ASTCENC_PUBLIC enum astcenc_error astcenc_get_block_info (
882+ struct astcenc_context * context,
873883 const uint8_t data[16 ],
874- astcenc_block_info* info);
884+ struct astcenc_block_info * info);
875885
876886/* *
877887 * @brief Get a printable string for specific status code.
@@ -881,6 +891,6 @@ ASTCENC_PUBLIC astcenc_error astcenc_get_block_info(
881891 * @return A human readable nul-terminated string.
882892 */
883893ASTCENC_PUBLIC const char * astcenc_get_error_string (
884- astcenc_error status);
894+ enum astcenc_error status);
885895
886896#endif
0 commit comments