cosmopolitan/dsp/core/c331.h
Justine Tunney fa20edc44d
Reduce header complexity
- 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
2023-11-28 14:39:42 -08:00

27 lines
557 B
C

#ifndef COSMOPOLITAN_DSP_CORE_C331_H_
#define COSMOPOLITAN_DSP_CORE_C331_H_
COSMOPOLITAN_C_START_
/**
* Fixed-point 8-bit magic edge resampling kernel.
*
* @define (3*a + 3*b + 1*c) / 7
* @see C1331()
*/
__funline unsigned char C331(unsigned char al, unsigned char bl,
unsigned char cl) {
unsigned eax, ebx, ecx;
eax = al;
ebx = bl;
ecx = cl;
eax += ebx;
eax *= 3 * 2350;
ecx *= 1 * 2350;
eax += ecx;
eax >>= 14;
al = eax;
return al;
}
COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_DSP_CORE_C331_H_ */