Files
HyperDRM/native/dark_color.h
T
2026-10-12 18:11:51 +02:00

17 lines
598 B
C

#ifndef HYPERDRM_DARK_COLOR_H
#define HYPERDRM_DARK_COLOR_H
/* Suppress near-black histogram residuals without changing channel ratios.
* Apply only to fresh histogram colors, before continuity and interpolation. */
static inline void dark_color_filter(unsigned char color[3]) {
unsigned peak = color[0];
for (unsigned c = 1; c < 3; c++)
if (color[c] > peak)
peak = color[c];
if (peak >= 24)
return;
unsigned gain = peak > 12 ? peak - 12 : 0;
for (unsigned c = 0; c < 3; c++)
color[c] = (unsigned char)((color[c] * gain + 6) / 12);
}
#endif