Skip to content

Commit

Permalink
source/nlm.ispc: fix overflow on integer rgb format (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
WolframRhodium committed Apr 9, 2022
1 parent cb15eaf commit 698c2a8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions source/nlm.ispc
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ export void nlmDistanceRGB_u8(
uniform float u1_pq_2 = neighborp2[neighbor_idx];
uniform float u1_pq_3 = neighborp3[neighbor_idx];

uniform float m_red = (u1_1 + u1_pq_1) / 6.0f;
uniform float m_red = (u1_1 + u1_pq_1) / 6.0f * inv_divisor;

uniform float dst = (
(2.0f / 3.0f + m_red) * square(u1_1 - u1_pq_1) +
Expand All @@ -765,7 +765,7 @@ export void nlmDistanceRGB_u8(
float u1_pq_2 = neighborp2[neighbor_idx];
float u1_pq_3 = neighborp3[neighbor_idx];

float m_red = (u1_1 + u1_pq_1) / 6.0f;
float m_red = (u1_1 + u1_pq_1) / 6.0f * inv_divisor;

float dst = (
(2.0f / 3.0f + m_red) * square(u1_1 - u1_pq_1) +
Expand All @@ -787,7 +787,7 @@ export void nlmDistanceRGB_u8(
uniform float u1_pq_2 = neighborp2[neighbor_idx];
uniform float u1_pq_3 = neighborp3[neighbor_idx];

uniform float m_red = (u1_1 + u1_pq_1) / 6.0f;
uniform float m_red = (u1_1 + u1_pq_1) / 6.0f * inv_divisor;

uniform float dst = (
(2.0f / 3.0f + m_red) * square(u1_1 - u1_pq_1) +
Expand Down Expand Up @@ -833,7 +833,7 @@ export void nlmDistanceRGB_u16(
uniform float u1_pq_2 = neighborp2[neighbor_idx];
uniform float u1_pq_3 = neighborp3[neighbor_idx];

uniform float m_red = (u1_1 + u1_pq_1) / 6.0f;
uniform float m_red = (u1_1 + u1_pq_1) / 6.0f * inv_divisor;

uniform float dst = (
(2.0f / 3.0f + m_red) * square(u1_1 - u1_pq_1) +
Expand All @@ -855,7 +855,7 @@ export void nlmDistanceRGB_u16(
float u1_pq_2 = neighborp2[neighbor_idx];
float u1_pq_3 = neighborp3[neighbor_idx];

float m_red = (u1_1 + u1_pq_1) / 6.0f;
float m_red = (u1_1 + u1_pq_1) / 6.0f * inv_divisor;

float dst = (
(2.0f / 3.0f + m_red) * square(u1_1 - u1_pq_1) +
Expand All @@ -877,7 +877,7 @@ export void nlmDistanceRGB_u16(
uniform float u1_pq_2 = neighborp2[neighbor_idx];
uniform float u1_pq_3 = neighborp3[neighbor_idx];

uniform float m_red = (u1_1 + u1_pq_1) / 6.0f;
uniform float m_red = (u1_1 + u1_pq_1) / 6.0f * inv_divisor;

uniform float dst = (
(2.0f / 3.0f + m_red) * square(u1_1 - u1_pq_1) +
Expand Down

0 comments on commit 698c2a8

Please sign in to comment.