mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 04:55:42 +09:00
fix(app): crop animated images on web with libwebp (#2947)
This commit is contained in:
1 parent
e0843ac4f5
commit
bbfe809bef
104 files changed
+10884
-7316
No files matched your search
@@ -0,0 +1,6 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
#ifndef FLUXWEBP_ASSERT_H
|
||||
#define FLUXWEBP_ASSERT_H
|
||||
#define assert(expr) ((void)0)
|
||||
#endif
|
||||
@@ -0,0 +1,6 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
#ifndef FLUXWEBP_INTTYPES_H
|
||||
#define FLUXWEBP_INTTYPES_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
@@ -0,0 +1,33 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
#ifndef FLUXWEBP_MATH_H
|
||||
#define FLUXWEBP_MATH_H
|
||||
double fluxwebp_shim_pow(double x, double y);
|
||||
double fluxwebp_shim_log(double x);
|
||||
float fluxwebp_shim_expf(float x);
|
||||
double fluxwebp_shim_log10(double x);
|
||||
float fluxwebp_shim_logf(float x);
|
||||
double fluxwebp_shim_round(double x);
|
||||
#define pow(x, y) fluxwebp_shim_pow(x, y)
|
||||
#define log(x) fluxwebp_shim_log(x)
|
||||
#define expf(x) fluxwebp_shim_expf(x)
|
||||
#define log10(x) fluxwebp_shim_log10(x)
|
||||
#define logf(x) fluxwebp_shim_logf(x)
|
||||
#define round(x) fluxwebp_shim_round(x)
|
||||
#define fabs(x) __builtin_fabs(x)
|
||||
#define floor(x) __builtin_floor(x)
|
||||
#define ceil(x) __builtin_ceil(x)
|
||||
#define sqrt(x) __builtin_sqrt(x)
|
||||
#define sqrtf(x) __builtin_sqrtf(x)
|
||||
#define rint(x) __builtin_rint(x)
|
||||
#define rintf(x) __builtin_rintf(x)
|
||||
#define fabsf(x) __builtin_fabsf(x)
|
||||
#define floorf(x) __builtin_floorf(x)
|
||||
#define ceilf(x) __builtin_ceilf(x)
|
||||
#define isnan(x) __builtin_isnan(x)
|
||||
#define isinf(x) __builtin_isinf(x)
|
||||
#define lrint(x) ((long)__builtin_rint(x))
|
||||
#define llrint(x) ((long long)__builtin_rint(x))
|
||||
#define lrintf(x) ((long)__builtin_rintf(x))
|
||||
#define llrintf(x) ((long long)__builtin_rintf(x))
|
||||
#endif
|
||||
@@ -0,0 +1,50 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
#ifndef FLUXWEBP_STDIO_H
|
||||
#define FLUXWEBP_STDIO_H
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
typedef struct FluxWebpFile FILE;
|
||||
#define stderr ((FILE*)0)
|
||||
#define stdout ((FILE*)0)
|
||||
#define fprintf(f, ...) ((void)0)
|
||||
#define printf(...) ((void)0)
|
||||
#define fflush(f) ((void)0)
|
||||
|
||||
static inline void fluxwebp_shim_put(char* buf, size_t cap, size_t* n, char c) {
|
||||
if (*n + 1 < cap) buf[*n] = c;
|
||||
(*n)++;
|
||||
}
|
||||
|
||||
static inline int snprintf(char* buf, size_t cap, const char* fmt, ...) {
|
||||
va_list ap;
|
||||
size_t n = 0;
|
||||
va_start(ap, fmt);
|
||||
for (; *fmt; fmt++) {
|
||||
if (*fmt != '%') {
|
||||
fluxwebp_shim_put(buf, cap, &n, *fmt);
|
||||
continue;
|
||||
}
|
||||
fmt++;
|
||||
if (*fmt == 's') {
|
||||
const char* s = va_arg(ap, const char*);
|
||||
while (s && *s) fluxwebp_shim_put(buf, cap, &n, *s++);
|
||||
} else if (*fmt == 'd') {
|
||||
int v = va_arg(ap, int);
|
||||
char tmp[12];
|
||||
int i = 0;
|
||||
unsigned int u = v < 0 ? 0u - (unsigned int)v : (unsigned int)v;
|
||||
if (v < 0) fluxwebp_shim_put(buf, cap, &n, '-');
|
||||
do { tmp[i++] = (char)('0' + u % 10); u /= 10; } while (u);
|
||||
while (i) fluxwebp_shim_put(buf, cap, &n, tmp[--i]);
|
||||
} else if (*fmt == '%') {
|
||||
fluxwebp_shim_put(buf, cap, &n, '%');
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
va_end(ap);
|
||||
if (cap) buf[n < cap ? n : cap - 1] = '\0';
|
||||
return (int)n;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
#ifndef FLUXWEBP_STDLIB_H
|
||||
#define FLUXWEBP_STDLIB_H
|
||||
#include <stddef.h>
|
||||
void* fluxwebp_shim_malloc(size_t size);
|
||||
void* fluxwebp_shim_calloc(size_t nmemb, size_t size);
|
||||
void fluxwebp_shim_free(void* ptr);
|
||||
void fluxwebp_shim_qsort(void* base, size_t nitems, size_t size, int (*compar)(const void*, const void*));
|
||||
#define malloc(size) fluxwebp_shim_malloc(size)
|
||||
#define calloc(nmemb, size) fluxwebp_shim_calloc(nmemb, size)
|
||||
#define free(ptr) fluxwebp_shim_free(ptr)
|
||||
#define qsort(base, nitems, size, compar) fluxwebp_shim_qsort(base, nitems, size, compar)
|
||||
#define abort() __builtin_trap()
|
||||
static inline int abs(int x) { return x < 0 ? -x : x; }
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
#ifndef FLUXWEBP_STRING_H
|
||||
#define FLUXWEBP_STRING_H
|
||||
#include <stddef.h>
|
||||
#define memcpy(d, s, n) __builtin_memcpy(d, s, n)
|
||||
#define memmove(d, s, n) __builtin_memmove(d, s, n)
|
||||
#define memset(d, c, n) __builtin_memset(d, c, n)
|
||||
#define memcmp(a, b, n) __builtin_memcmp(a, b, n)
|
||||
#define strlen(s) __builtin_strlen(s)
|
||||
#endif
|
||||
Reference in new issue
Block a user