mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 11:37:35 +00:00
fa20edc44d
- Remove most __ASSEMBLER__ __LINKER__ ifdefs - Rename libc/intrin/bits.h to libc/serialize.h - Block pthread cancelation in fchmodat() polyfill - Remove `clang-format off` statements in third_party
21 lines
919 B
C
21 lines
919 B
C
#ifndef COSMOPOLITAN_DSP_CORE_GAMMA_H_
|
|
#define COSMOPOLITAN_DSP_CORE_GAMMA_H_
|
|
#include "libc/math.h"
|
|
|
|
#define COMPANDLUMA(X, ...) COMPANDLUMA_(X, __VA_ARGS__)
|
|
#define COMPANDLUMA_(X, K1, K2, K3, K4) \
|
|
((X) > (K3) / (K4) ? (1 + (K2)) * pow((X), 1 / (K1)) - (K2) : (X) * (K4))
|
|
|
|
#define UNCOMPANDLUMA(X, ...) UNCOMPANDLUMA_(X, __VA_ARGS__)
|
|
#define UNCOMPANDLUMA_(X, K1, K2, K3, K4) \
|
|
((X) > (K3) ? pow(1 / (1 + (K2)) * ((X) + (K2)), K1) : (X) / (K4))
|
|
|
|
#define COMPANDLUMA_SRGB_MAGNUM .055, .04045, 12.92
|
|
#define COMPANDLUMA_SRGB(X, G) COMPANDLUMA(X, G, COMPANDLUMA_SRGB_MAGNUM)
|
|
#define UNCOMPANDLUMA_SRGB(X, G) UNCOMPANDLUMA(X, G, COMPANDLUMA_SRGB_MAGNUM)
|
|
|
|
#define COMPANDLUMA_BT1886_MAGNUM 1 / .45, .099, .081, 4.5
|
|
#define COMPANDLUMA_BT1886(X) COMPANDLUMA(X, COMPANDLUMA_BT1886_MAGNUM)
|
|
#define UNCOMPANDLUMA_BT1886(X) UNCOMPANDLUMA(X, COMPANDLUMA_BT1886_MAGNUM)
|
|
|
|
#endif /* COSMOPOLITAN_DSP_CORE_GAMMA_H_ */
|