|
Simple Graphics Library 1.0.0.0
Runtime-independent image processing primitives
|
Public API for memory, image processing, queues, and worker threads. More...
Go to the source code of this file.
Macros | |
| #define | SGL_UNUSED_PARAM(p) SGL_UNUSED(p) |
| Explicitly marks an intentionally unused parameter. | |
| #define | SGL_DIV_ROUNDUP(n, d) (((n) + (d) - 1) / (d)) |
Divides positive integer n by positive integer d, rounding upward. | |
| #define | SGL_SAFE_FREE(p) if ((p) != SGL_NULL) { sgl_free((p)); (p) = SGL_NULL; } |
| Releases an SGL allocation and sets the pointer lvalue to SGL_NULL. | |
| #define | SGL_THREADPOOL_DEFAULT_MAX_ROUTINE_LISTS (4U) |
| Default maximum routine-list count accepted by sgl_threadpool_create(). | |
| #define | SGL_GENERIC_BULK_SIZE (4) |
| Default row-group size used by scalar worker routines. | |
| #define | SGL_SIMD_BULK_SIZE (8) |
| Default row-group size used by SIMD worker routines. | |
| #define | SGL_BPP32 (4) |
| Four bytes per pixel. | |
| #define | SGL_BPP24 (3) |
| Three bytes per pixel. | |
| #define | SGL_BPP16 (2) |
| Two bytes per pixel. | |
| #define | SGL_BPP8 (1) |
| One byte per pixel. | |
Typedefs | |
| typedef struct sgl_nearest_neighbor_lookup_table | sgl_nearest_neighbor_lookup_t |
| Opaque nearest-neighbor resize lookup table. | |
| typedef struct sgl_bilinear_lookup_table | sgl_bilinear_lookup_t |
| Opaque bilinear resize lookup table. | |
| typedef struct sgl_bicubic_lookup_table | sgl_bicubic_lookup_t |
| Opaque bicubic resize lookup table. | |
| typedef struct sgl_rotate_lookup_table | sgl_rotate_lookup_t |
| Opaque nearest-neighbor rotation lookup table. | |
| typedef struct sgl_queue | sgl_queue_t |
| Opaque fixed-capacity queue. | |
| typedef struct sgl_threadpool | sgl_threadpool_t |
| Opaque synchronous worker-thread pool. | |
| typedef void(* | sgl_threadpool_routine_t) (void *current, void *cookie) |
| Processes one queue entry submitted to a thread pool. | |
Enumerations | |
| enum | sgl_result_t { SGL_SUCCESS , SGL_FAILURE , SGL_ERROR_INVALID_ARGUMENTS , SGL_ERROR_MEMORY_ALLOCATION , SGL_ERROR_MISSMATCHED_CAPACITY , SGL_ERROR_NOT_SUPPORTED , SGL_QUEUE_IS_EMPTY , SGL_QUEUE_IS_NOT_EMPTY , SGL_QUEUE_IS_FULL , SGL_QUEUE_IS_NOT_FULL } |
| Result codes returned by SGL operations. More... | |
Functions | |
| void * | sgl_memcpy (void *destination, const void *source, sgl_size_t size) |
| Copies bytes between non-overlapping memory ranges. | |
| void * | sgl_memset (void *destination, sgl_int32_t value, sgl_size_t size) |
| Fills a memory range with one byte value. | |
| sgl_result_t | sgl_memory_pool_initialize (void *memory, sgl_size_t size) |
| Registers the process-wide SGL memory pool. | |
| sgl_result_t | sgl_memory_pool_deinitialize (void) |
| Detaches the caller-owned memory pool. | |
| void * | sgl_malloc (sgl_size_t size) |
| Allocates an aligned block from the SGL memory pool. | |
| void * | sgl_calloc (sgl_size_t count, sgl_size_t size) |
| Allocates and zero-initializes an array from the SGL memory pool. | |
| void | sgl_free (void *memory) |
| Releases a block allocated by sgl_malloc() or sgl_calloc(). | |
| sgl_nearest_neighbor_lookup_t * | sgl_generic_create_nearest_neighbor_lut (sgl_int32_t d_width, sgl_int32_t d_height, sgl_int32_t s_width, sgl_int32_t s_height) |
| Creates a nearest-neighbor lookup table for one resize geometry. | |
| sgl_bilinear_lookup_t * | sgl_generic_create_bilinear_lut (sgl_int32_t d_width, sgl_int32_t d_height, sgl_int32_t s_width, sgl_int32_t s_height) |
| Creates a bilinear lookup table. | |
| sgl_bicubic_lookup_t * | sgl_generic_create_bicubic_lut (sgl_int32_t d_width, sgl_int32_t d_height, sgl_int32_t s_width, sgl_int32_t s_height) |
| Creates a bicubic lookup table. | |
| void | sgl_generic_destroy_nearest_neighbor_lut (sgl_nearest_neighbor_lookup_t *lut) |
| Destroys a nearest-neighbor LUT. | |
| void | sgl_generic_destroy_bilinear_lut (sgl_bilinear_lookup_t *lut) |
| Destroys a bilinear LUT. | |
| void | sgl_generic_destroy_bicubic_lut (sgl_bicubic_lookup_t *lut) |
| Destroys a bicubic LUT. | |
| sgl_result_t | sgl_generic_resize_nearest (sgl_threadpool_t *pool, sgl_nearest_neighbor_lookup_t *ext_lut, sgl_uint8_t *dst, sgl_int32_t d_width, sgl_int32_t d_height, sgl_uint8_t *src, sgl_int32_t s_width, sgl_int32_t s_height, sgl_int32_t bpp) |
| Resizes a packed image using nearest-neighbor sampling. | |
| sgl_result_t | sgl_generic_resize_bilinear (sgl_threadpool_t *pool, sgl_bilinear_lookup_t *ext_lut, sgl_uint8_t *dst, sgl_int32_t d_width, sgl_int32_t d_height, sgl_uint8_t *src, sgl_int32_t s_width, sgl_int32_t s_height, sgl_int32_t bpp) |
| Resizes a packed image using bilinear interpolation. | |
| sgl_result_t | sgl_generic_resize_bicubic (sgl_threadpool_t *pool, sgl_bicubic_lookup_t *ext_lut, sgl_uint8_t *dst, sgl_int32_t d_width, sgl_int32_t d_height, sgl_uint8_t *src, sgl_int32_t s_width, sgl_int32_t s_height, sgl_int32_t bpp) |
| Resizes a packed image using bicubic interpolation. | |
| sgl_result_t | sgl_simd_resize_nearest (sgl_threadpool_t *pool, sgl_nearest_neighbor_lookup_t *ext_lut, sgl_uint8_t *dst, sgl_int32_t d_width, sgl_int32_t d_height, sgl_uint8_t *src, sgl_int32_t s_width, sgl_int32_t s_height, sgl_int32_t bpp) |
| SIMD nearest-neighbor resize. | |
| sgl_result_t | sgl_simd_resize_bilinear (sgl_threadpool_t *pool, sgl_bilinear_lookup_t *ext_lut, sgl_uint8_t *dst, sgl_int32_t d_width, sgl_int32_t d_height, sgl_uint8_t *src, sgl_int32_t s_width, sgl_int32_t s_height, sgl_int32_t bpp) |
| SIMD bilinear resize. | |
| sgl_result_t | sgl_simd_resize_bicubic (sgl_threadpool_t *pool, sgl_bicubic_lookup_t *ext_lut, sgl_uint8_t *dst, sgl_int32_t d_width, sgl_int32_t d_height, sgl_uint8_t *src, sgl_int32_t s_width, sgl_int32_t s_height, sgl_int32_t bpp) |
| SIMD bicubic resize. | |
| sgl_result_t | sgl_generic_crop (sgl_threadpool_t *pool, const sgl_uint8_t *src, sgl_int32_t src_width, sgl_int32_t src_height, sgl_uint8_t *dst, sgl_int32_t x, sgl_int32_t y, sgl_int32_t crop_width, sgl_int32_t crop_height, sgl_int32_t bpp) |
| Copies a rectangular source region to a compact destination image. | |
| sgl_result_t | sgl_simd_crop (sgl_threadpool_t *pool, const sgl_uint8_t *src, sgl_int32_t src_width, sgl_int32_t src_height, sgl_uint8_t *dst, sgl_int32_t x, sgl_int32_t y, sgl_int32_t crop_width, sgl_int32_t crop_height, sgl_int32_t bpp) |
| SIMD crop implementation. | |
| sgl_result_t | sgl_get_rotated_dimensions (sgl_int32_t src_width, sgl_int32_t src_height, sgl_float64_t angle, sgl_int32_t *dst_width, sgl_int32_t *dst_height) |
| Calculates the destination bounding-box dimensions for a rotation. | |
| sgl_int32_t | sgl_get_rotated_size (sgl_int32_t src_width, sgl_int32_t src_height, sgl_int32_t bpp, sgl_float64_t angle) |
| Calculates the required destination buffer size for a rotation. | |
| sgl_rotate_lookup_t * | sgl_generic_create_rotate_lut (sgl_int32_t src_width, sgl_int32_t src_height, sgl_float64_t angle) |
| Creates a reusable rotation mapping table. | |
| void | sgl_generic_destroy_rotate_lut (sgl_rotate_lookup_t *lut) |
| Destroys a rotation LUT. | |
| sgl_result_t | sgl_generic_rotate (sgl_threadpool_t *pool, sgl_rotate_lookup_t *ext_lut, const sgl_uint8_t *src, sgl_int32_t src_width, sgl_int32_t src_height, sgl_uint8_t *dst, sgl_int32_t bpp, sgl_float64_t angle) |
| Rotates a tightly packed image using nearest-neighbor sampling. | |
| sgl_result_t | sgl_simd_rotate (sgl_threadpool_t *pool, sgl_rotate_lookup_t *ext_lut, const sgl_uint8_t *src, sgl_int32_t src_width, sgl_int32_t src_height, sgl_uint8_t *dst, sgl_int32_t bpp, sgl_float64_t angle) |
| SIMD rotation implementation. | |
| sgl_result_t | sgl_generic_rgb2yuv (sgl_threadpool_t *pool, const sgl_uint8_t *src, sgl_fourcc_t src_format, sgl_uint8_t *dst, sgl_fourcc_t dst_format, sgl_int32_t width, sgl_int32_t height) |
| Converts any supported RGB layout to any supported YUV layout. | |
| sgl_result_t | sgl_generic_rgb2rgb (sgl_threadpool_t *pool, const sgl_uint8_t *src, sgl_fourcc_t src_format, sgl_uint8_t *dst, sgl_fourcc_t dst_format, sgl_int32_t width, sgl_int32_t height) |
| Converts between any two supported RGB layouts. | |
| sgl_result_t | sgl_generic_yuv2rgb (sgl_threadpool_t *pool, const sgl_uint8_t *src, sgl_fourcc_t src_format, sgl_uint8_t *dst, sgl_fourcc_t dst_format, sgl_int32_t width, sgl_int32_t height) |
| Converts any supported YUV layout to any supported RGB layout. | |
| sgl_result_t | sgl_generic_yuv2yuv (sgl_threadpool_t *pool, const sgl_uint8_t *src, sgl_fourcc_t src_format, sgl_uint8_t *dst, sgl_fourcc_t dst_format, sgl_int32_t width, sgl_int32_t height) |
| Converts between any two supported YUV layouts. | |
| sgl_result_t | sgl_simd_rgb2yuv (sgl_threadpool_t *pool, const sgl_uint8_t *src, sgl_fourcc_t src_format, sgl_uint8_t *dst, sgl_fourcc_t dst_format, sgl_int32_t width, sgl_int32_t height) |
| SIMD RGB-to-YUV conversion. | |
| sgl_result_t | sgl_simd_rgb2rgb (sgl_threadpool_t *pool, const sgl_uint8_t *src, sgl_fourcc_t src_format, sgl_uint8_t *dst, sgl_fourcc_t dst_format, sgl_int32_t width, sgl_int32_t height) |
| SIMD RGB-to-RGB conversion. | |
| sgl_result_t | sgl_simd_yuv2rgb (sgl_threadpool_t *pool, const sgl_uint8_t *src, sgl_fourcc_t src_format, sgl_uint8_t *dst, sgl_fourcc_t dst_format, sgl_int32_t width, sgl_int32_t height) |
| SIMD YUV-to-RGB conversion. | |
| sgl_result_t | sgl_simd_yuv2yuv (sgl_threadpool_t *pool, const sgl_uint8_t *src, sgl_fourcc_t src_format, sgl_uint8_t *dst, sgl_fourcc_t dst_format, sgl_int32_t width, sgl_int32_t height) |
| SIMD YUV-to-YUV conversion. | |
| sgl_queue_t * | sgl_queue_create (sgl_size_t capacity) |
| Creates an empty queue. | |
| void | sgl_queue_destroy (sgl_queue_t **queue) |
| Destroys a queue and clears the caller's handle. | |
| sgl_result_t | sgl_queue_copy (sgl_queue_t *dst, const sgl_queue_t *src) |
| Copies queue state and entries without transferring object ownership. | |
| sgl_result_t | sgl_queue_unsafe_enqueue (sgl_queue_t *queue, const void *data) |
| Enqueues an object pointer without locking the queue. | |
| sgl_result_t | sgl_queue_enqueue (sgl_queue_t *queue, const void *data) |
| Enqueues an object pointer while holding the queue lock. | |
| void * | sgl_queue_dequeue (sgl_queue_t *queue) |
| Removes and returns the oldest queue entry. | |
| void * | sgl_queue_peek (sgl_queue_t *queue) |
| Returns the oldest queue entry without removing it. | |
| sgl_result_t | sgl_queue_is_empty (const sgl_queue_t *queue) |
| Tests whether a valid queue is empty. | |
| sgl_result_t | sgl_queue_is_full (const sgl_queue_t *queue) |
| Tests whether a valid queue is full. | |
| sgl_size_t | sgl_queue_get_capacity (const sgl_queue_t *queue) |
| Returns queue capacity. | |
| sgl_size_t | sgl_queue_get_count (const sgl_queue_t *queue) |
| Returns the current entry count. | |
| sgl_threadpool_t * | sgl_threadpool_create (sgl_size_t num_threads, sgl_size_t max_routine_lists, const char *base_name) |
| Creates a worker-thread pool. | |
| sgl_result_t | sgl_threadpool_destroy (sgl_threadpool_t *pool) |
| Stops workers and destroys a thread pool. | |
| sgl_size_t | sgl_threadpool_get_num_threads (const sgl_threadpool_t *pool) |
| Returns the number of background workers. | |
| sgl_result_t | sgl_threadpool_attach_routine (sgl_threadpool_t *pool, sgl_threadpool_routine_t routine, sgl_queue_t *operations, void *cookie) |
| Processes all queued operations and restores their queue entries. | |
| sgl_result_t | sgl_threadpool_attach_routine_consuming (sgl_threadpool_t *pool, sgl_threadpool_routine_t routine, sgl_queue_t *operations, void *cookie) |
| Processes and removes every operation entry from the queue. | |
Public API for memory, image processing, queues, and worker threads.
Include this header for the complete SGL runtime API. Image buffers are tightly packed and all dimensions are expressed in pixels unless stated otherwise. Source and destination ranges passed through SGL_RESTRICT must not overlap.
Definition in file sgl-core.h.