Skip to content

Commit

Permalink
fix rounding in HLS
Browse files Browse the repository at this point in the history
  • Loading branch information
jerch committed Aug 30, 2021
1 parent c6f212e commit f5239d5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions wasm/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ static inline int normalize_hls(int hi, int li, int si) {
float s = ((float) si) / 100;
float t1 = l < 0.5f ? l * (1 + s) : l * (1 - s) + s;
float t2 = l * 2 - t1;
unsigned char r = 255 * h2c(t1, t2, h + 0.3333333433f); // + 1.0f / 3
unsigned char g = 255 * h2c(t1, t2, h);
unsigned char b = 255 * h2c(t1, t2, h - 0.3333333433f); // - 1.0f / 3
unsigned char r = 255 * h2c(t1, t2, h + 0.3333333433f) + 0.5f; // + 1.0f / 3
unsigned char g = 255 * h2c(t1, t2, h) + 0.5f;
unsigned char b = 255 * h2c(t1, t2, h - 0.3333333433f) + 0.5f; // - 1.0f / 3
return 0xFF000000 | b << 16 | g << 8 | r;
}

Expand Down

0 comments on commit f5239d5

Please sign in to comment.