Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 44 additions & 36 deletions Source/astcenc.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,25 @@
#ifndef ASTCENC_INCLUDED
#define ASTCENC_INCLUDED

#if defined(__cplusplus)
#include <cstddef>
#include <cstdint>
#define ASTCENC_EXTERN_C extern "C"
#else
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#define ASTCENC_EXTERN_C
#endif

#if defined(ASTCENC_DYNAMIC_LIBRARY)
#if defined(_MSC_VER)
#define ASTCENC_PUBLIC extern "C" __declspec(dllexport)
#define ASTCENC_PUBLIC ASTCENC_EXTERN_C __declspec(dllexport)
#else
#define ASTCENC_PUBLIC extern "C" __attribute__ ((visibility ("default")))
#define ASTCENC_PUBLIC ASTCENC_EXTERN_C __attribute__ ((visibility ("default")))
#endif
#else
#define ASTCENC_PUBLIC
#define ASTCENC_PUBLIC ASTCENC_EXTERN_C
#endif

/* ============================================================================
Expand Down Expand Up @@ -282,13 +290,13 @@ enum astcenc_swz
struct astcenc_swizzle
{
/** @brief The red component selector. */
astcenc_swz r;
enum astcenc_swz r;
/** @brief The green component selector. */
astcenc_swz g;
enum astcenc_swz g;
/** @brief The blue component selector. */
astcenc_swz b;
enum astcenc_swz b;
/** @brief The alpha component selector. */
astcenc_swz a;
enum astcenc_swz a;
};

/**
Expand All @@ -307,7 +315,7 @@ enum astcenc_type
/**
* @brief Function pointer type for compression progress reporting callback.
*/
extern "C" typedef void (*astcenc_progress_callback)(float);
ASTCENC_EXTERN_C typedef void (*astcenc_progress_callback)(float);

/**
* @brief Enable normal map compression.
Expand Down Expand Up @@ -415,7 +423,7 @@ static const unsigned int ASTCENC_ALL_FLAGS =
struct astcenc_config
{
/** @brief The color profile. */
astcenc_profile profile;
enum astcenc_profile profile;

/** @brief The set of set flags. */
unsigned int flags;
Expand Down Expand Up @@ -610,7 +618,7 @@ struct astcenc_image
unsigned int dim_z;

/** @brief The data type per component. */
astcenc_type data_type;
enum astcenc_type data_type;

/** @brief The array of 2D slices, of length @c dim_z. */
void** data;
Expand All @@ -625,7 +633,7 @@ struct astcenc_image
struct astcenc_block_info
{
/** @brief The block encoding color profile. */
astcenc_profile profile;
enum astcenc_profile profile;

/** @brief The number of texels in the X dimension. */
unsigned int block_x;
Expand Down Expand Up @@ -710,14 +718,14 @@ struct astcenc_block_info
* @return @c ASTCENC_SUCCESS on success, or an error if the inputs are invalid
* either individually, or in combination.
*/
ASTCENC_PUBLIC astcenc_error astcenc_config_init(
astcenc_profile profile,
ASTCENC_PUBLIC enum astcenc_error astcenc_config_init(
enum astcenc_profile profile,
unsigned int block_x,
unsigned int block_y,
unsigned int block_z,
float quality,
unsigned int flags,
astcenc_config* config);
struct astcenc_config* config);

/**
* @brief Allocate a new codec context based on a config.
Expand All @@ -737,10 +745,10 @@ ASTCENC_PUBLIC astcenc_error astcenc_config_init(
*
* @return @c ASTCENC_SUCCESS on success, or an error if context creation failed.
*/
ASTCENC_PUBLIC astcenc_error astcenc_context_alloc(
const astcenc_config* config,
ASTCENC_PUBLIC enum astcenc_error astcenc_context_alloc(
const struct astcenc_config* config,
unsigned int thread_count,
astcenc_context** context);
struct astcenc_context** context);

/**
* @brief Compress an image.
Expand All @@ -760,10 +768,10 @@ ASTCENC_PUBLIC astcenc_error astcenc_context_alloc(
*
* @return @c ASTCENC_SUCCESS on success, or an error if compression failed.
*/
ASTCENC_PUBLIC astcenc_error astcenc_compress_image(
astcenc_context* context,
astcenc_image* image,
const astcenc_swizzle* swizzle,
ASTCENC_PUBLIC enum astcenc_error astcenc_compress_image(
struct astcenc_context* context,
struct astcenc_image* image,
const struct astcenc_swizzle* swizzle,
uint8_t* data_out,
size_t data_len,
unsigned int thread_index);
Expand All @@ -781,8 +789,8 @@ ASTCENC_PUBLIC astcenc_error astcenc_compress_image(
*
* @return @c ASTCENC_SUCCESS on success, or an error if reset failed.
*/
ASTCENC_PUBLIC astcenc_error astcenc_compress_reset(
astcenc_context* context);
ASTCENC_PUBLIC enum astcenc_error astcenc_compress_reset(
struct astcenc_context* context);

/**
* @brief Cancel any pending compression operation.
Expand All @@ -795,8 +803,8 @@ ASTCENC_PUBLIC astcenc_error astcenc_compress_reset(
*
* @return @c ASTCENC_SUCCESS on success, or an error if cancellation failed.
*/
ASTCENC_PUBLIC astcenc_error astcenc_compress_cancel(
astcenc_context* context);
ASTCENC_PUBLIC enum astcenc_error astcenc_compress_cancel(
struct astcenc_context* context);

/**
* @brief Decompress an image.
Expand All @@ -810,12 +818,12 @@ ASTCENC_PUBLIC astcenc_error astcenc_compress_cancel(
*
* @return @c ASTCENC_SUCCESS on success, or an error if decompression failed.
*/
ASTCENC_PUBLIC astcenc_error astcenc_decompress_image(
astcenc_context* context,
ASTCENC_PUBLIC enum astcenc_error astcenc_decompress_image(
struct astcenc_context* context,
const uint8_t* data,
size_t data_len,
astcenc_image* image_out,
const astcenc_swizzle* swizzle,
struct astcenc_image* image_out,
const struct astcenc_swizzle* swizzle,
unsigned int thread_index);

/**
Expand All @@ -831,16 +839,16 @@ ASTCENC_PUBLIC astcenc_error astcenc_decompress_image(
*
* @return @c ASTCENC_SUCCESS on success, or an error if reset failed.
*/
ASTCENC_PUBLIC astcenc_error astcenc_decompress_reset(
astcenc_context* context);
ASTCENC_PUBLIC enum astcenc_error astcenc_decompress_reset(
struct astcenc_context* context);

/**
* Free the compressor context.
*
* @param context The codec context.
*/
ASTCENC_PUBLIC void astcenc_context_free(
astcenc_context* context);
struct astcenc_context* context);

/**
* @brief Provide a high level summary of a block's encoding.
Expand All @@ -856,10 +864,10 @@ ASTCENC_PUBLIC void astcenc_context_free(
* function will return success even if the block itself was an error block encoding, as the
* decode was correctly handled.
*/
ASTCENC_PUBLIC astcenc_error astcenc_get_block_info(
astcenc_context* context,
ASTCENC_PUBLIC enum astcenc_error astcenc_get_block_info(
struct astcenc_context* context,
const uint8_t data[16],
astcenc_block_info* info);
struct astcenc_block_info* info);

/**
* @brief Get a printable string for specific status code.
Expand All @@ -869,6 +877,6 @@ ASTCENC_PUBLIC astcenc_error astcenc_get_block_info(
* @return A human readable nul-terminated string.
*/
ASTCENC_PUBLIC const char* astcenc_get_error_string(
astcenc_error status);
enum astcenc_error status);

#endif
2 changes: 2 additions & 0 deletions Source/astcenccli_platform_dependents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
#if defined(_WIN32) && !defined(__CYGWIN__)

#define WIN32_LEAN_AND_MEAN
#if !defined(NOMINMAX)
#define NOMINMAX
#endif
#include <windows.h>
#include <Processthreadsapi.h>
#include <algorithm>
Expand Down