Skip to content

Instantly share code, notes, and snippets.

@jserv
jserv / amei.c
Created March 16, 2026 09:08
aMEI face decoder
/* Amei face decoder: gcc -O2 amei.c -lm && ./a.out > amei.png */
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#define foreach(a, d) for (int a = 0; a < d; a++)
#define A(v) ((v) < 0 ? -(v) : (v))
#define C8(v) ((v) < 0 ? 0 : (v) > 255 ? 255 : (v))
static const uint32_t ct[] = { /* Streaming PNG: 16-entry nibble CRC */
0, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, 0x6b6b51f4,