From 6ebd4723871e8984989f14542db0ed6b468aba72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Fri, 23 Feb 2024 15:33:53 +0100 Subject: [PATCH] project: fix math interval notation Source: https://en.wikipedia.org/wiki/Interval_(mathematics) --- doc/usr/ref/eval.md | 4 ++-- libnopegl/nodes.specs | 6 +++--- libnopegl/src/distmap.c | 2 +- libnopegl/src/glsl/distmap.frag | 2 +- libnopegl/src/glsl/distmap.vert | 2 +- libnopegl/src/glsl/filter_contrast.glsl | 2 +- libnopegl/src/glsl/filter_selector.glsl | 2 +- libnopegl/src/glsl/hdr_pq2sdr.frag | 2 +- libnopegl/src/glsl/helper_noise.glsl | 6 +++--- libnopegl/src/glsl/path.frag | 2 +- libnopegl/src/glsl/text_chars.frag | 2 +- libnopegl/src/math_utils.h | 4 ++-- libnopegl/src/node_colorkey.c | 2 +- libnopegl/src/node_filters.c | 2 +- libnopegl/src/node_renderother.c | 4 ++-- libnopegl/src/node_texture.c | 2 +- libnopegl/src/noise.c | 8 ++++---- libnopegl/src/path.c | 4 ++-- libnopegl/src/text.h | 2 +- pynopegl-utils/pynopegl_utils/diff/shaders/diff.frag | 2 +- pynopegl-utils/pynopegl_utils/diff/shaders/diff.vert | 4 ++-- .../pynopegl_utils/examples/shaders/audiotex.frag | 6 +++--- pynopegl-utils/pynopegl_utils/tests/cmp_cuepoints.py | 2 +- 23 files changed, 37 insertions(+), 37 deletions(-) diff --git a/doc/usr/ref/eval.md b/doc/usr/ref/eval.md index a7d518623..95442ad0f 100644 --- a/doc/usr/ref/eval.md +++ b/doc/usr/ref/eval.md @@ -59,7 +59,7 @@ component of the 3+ dimensional input resources identified by "foo". | `isinf(x)` | `1` if `x` is infinite, `0` otherwise | | `isnan(x)` | `1` if `x` is not a number (`NaN`), `0` otherwise | | `isnormal(x)` | `1` if `x` is normal, `0` otherwise | -| `linear(a,b,x)` | linearly remap `x` in range `[a;b]` to `[0;1]` | +| `linear(a,b,x)` | linearly remap `x` in range `[a,b]` to `[0,1]` | | `linear2srgb(x)` | convert `x` from linear to sRGB (see also `srgb2linear(x)`) | | `linearstep(a,b,x)` | saturated version of `linear()` (equivalent to `sat(linear(a,b,x))`) | | `log(x)` | natural logarithm of `x` (see `e`), also called "ln" in math terminology | @@ -69,7 +69,7 @@ component of the 3+ dimensional input resources identified by "foo". | `luma(r,g,b)` | gamma encoded luma Y' of the R'G'B' value, as defined by BT.709 | | `max(a,b)` | maximum value between `a` and `b` | | `min(a,b)` | minimum value between `a` and `b` | -| `mix(a,b,x)` | linearly remap `x` in range `[0;1]` to `[a;b]` | +| `mix(a,b,x)` | linearly remap `x` in range `[0,1]` to `[a,b]` | | `mla(a,b,c)` | multiply-add in one operation (`a*b + c`) | | `mod_e(a,b)` | euclidean modulo: `a - b*sign(b)*floor(a/abs(b))` | | `mod_f(a,b)` | floored modulo: `a - b*floor(a/b)` | diff --git a/libnopegl/nodes.specs b/libnopegl/nodes.specs index 074fe3c0c..87dd32576 100644 --- a/libnopegl/nodes.specs +++ b/libnopegl/nodes.specs @@ -1724,7 +1724,7 @@ "type": "f32", "default": 0.000000, "flags": ["live", "node"], - "desc": "position of the gradient point on the axis (within [0;1])" + "desc": "position of the gradient point on the axis (within [0,1])" }, { "name": "color", @@ -3120,7 +3120,7 @@ "type": "u32", "default": 3, "flags": [], - "desc": "number of accumulated noise layers (controls the level of details), must in [1;8]" + "desc": "number of accumulated noise layers (controls the level of details), must in [1,8]" }, { "name": "lacunarity", @@ -3922,7 +3922,7 @@ "type": "bool", "default": 0, "flags": [], - "desc": "clamp ngl_texvideo() output to [0;1]" + "desc": "clamp ngl_texvideo() output to [0,1]" }, { "name": "clear_color", diff --git a/libnopegl/src/distmap.c b/libnopegl/src/distmap.c index 7eb488ddb..937da755d 100644 --- a/libnopegl/src/distmap.c +++ b/libnopegl/src/distmap.c @@ -534,7 +534,7 @@ int ngli_distmap_finalize(struct distmap *s) /* * We normalize the coordinates with regards to the container shape so that - * distances are within [0;1] while remaining proportionnal against each + * distances are within [0,1] while remaining proportionnal against each * others. This help making effects consistent accross all shapes. */ normalize_coordinates(s); diff --git a/libnopegl/src/glsl/distmap.frag b/libnopegl/src/glsl/distmap.frag index 1c8eaeff5..aeb6de220 100644 --- a/libnopegl/src/glsl/distmap.frag +++ b/libnopegl/src/glsl/distmap.frag @@ -92,7 +92,7 @@ vec3 stitch_3_roots(int topology, vec3 roots, float a, float b, float c) /* * Got 3 roots but expected only 1. Likely scenario: the roots are outside - * the [0;1] range, but we can't just exclude outside the boundaries due to + * the [0,1] range, but we can't just exclude outside the boundaries due to * float inaccuracies. */ float da = 3.0 * a, db = 2.0 * b, dc = c; diff --git a/libnopegl/src/glsl/distmap.vert b/libnopegl/src/glsl/distmap.vert index 3bca76a07..c2dd5c466 100644 --- a/libnopegl/src/glsl/distmap.vert +++ b/libnopegl/src/glsl/distmap.vert @@ -25,7 +25,7 @@ const vec2 uvs[] = vec2[](vec2(0.0, 0.0), vec2(0.0, 2.0), vec2(2.0, 0.0)); void main() { vec2 ref_uv = uvs[ngl_vertex_index]; - vec4 centered_vertices = vertices * 2.0 - 1.0; // [0;1] -> [-1;1] + vec4 centered_vertices = vertices * 2.0 - 1.0; // [0,1] -> [-1,1] vec2 out_pos = mix(centered_vertices.xy, centered_vertices.zw, ref_uv); ngl_out_pos = vec4(out_pos, 0.0, 1.0); uv = ref_uv; diff --git a/libnopegl/src/glsl/filter_contrast.glsl b/libnopegl/src/glsl/filter_contrast.glsl index ae56b9c1b..06cd8face 100644 --- a/libnopegl/src/glsl/filter_contrast.glsl +++ b/libnopegl/src/glsl/filter_contrast.glsl @@ -24,7 +24,7 @@ vec4 filter_contrast(vec4 color, vec2 coords, float contrast, float pivot) { vec3 rgb = color.rgb; - /* remap contrast in [0;2] to polar coordinates (in [0;PI/2]) */ + /* remap contrast in [0,2] to polar coordinates (in [0,PI/2]) */ float polar_c = contrast * ngli_pi / 4.0; if (abs(polar_c - ngli_pi / 2.0) < 1e-6) /* at contrast=2, strength is infinite */ return vec4(step(vec3(pivot), rgb), color.a); diff --git a/libnopegl/src/glsl/filter_selector.glsl b/libnopegl/src/glsl/filter_selector.glsl index 0881d7702..0b92665d9 100644 --- a/libnopegl/src/glsl/filter_selector.glsl +++ b/libnopegl/src/glsl/filter_selector.glsl @@ -28,7 +28,7 @@ vec4 filter_selector(vec4 color, vec2 coords, vec2 range, int component, int dro bool within; // whether we are within the range or not if (component == 2) { - // If we selected the hue, bring both value and reference in the same [0;𝜏] range + // If we selected the hue, bring both value and reference in the same [0,𝜏] range range = mod(range, ngli_tau); value = mod(value, ngli_tau); if (range.x > range.y) { diff --git a/libnopegl/src/glsl/hdr_pq2sdr.frag b/libnopegl/src/glsl/hdr_pq2sdr.frag index 7543061f7..2111c5c7f 100644 --- a/libnopegl/src/glsl/hdr_pq2sdr.frag +++ b/libnopegl/src/glsl/hdr_pq2sdr.frag @@ -113,7 +113,7 @@ void main() { vec4 hdr = ngl_texvideo(tex, tex_coord); - /* Linearize the PQ signal and ensure it is in the [0; 10000] range */ + /* Linearize the PQ signal and ensure it is in the [0,10000] range */ vec3 rgb_linear = pq_eotf3(hdr.rgb); rgb_linear = clamp(rgb_linear, 0.0, 10000.0); diff --git a/libnopegl/src/glsl/helper_noise.glsl b/libnopegl/src/glsl/helper_noise.glsl index 8b9e1e973..f65cef87f 100644 --- a/libnopegl/src/glsl/helper_noise.glsl +++ b/libnopegl/src/glsl/helper_noise.glsl @@ -22,7 +22,7 @@ */ /* - * Return a random single-precision float between [0;1) + * Return a random single-precision float between [0,1) * Derived from http://prng.di.unimi.it/ */ highp float u32tof32(highp uint x) @@ -61,7 +61,7 @@ highp float random(highp uvec3 x) highp vec2 random2(highp uvec3 x) { - /* Generate 2 random floats in [0;1] using 16-bit of information for each */ + /* Generate 2 random floats in [0,1] using 16-bit of information for each */ uint h = hash(x); float r0 = u32tof32(0x00010001U * (h & 0xffffU)); float r1 = u32tof32(0x00010001U * (h>>16 & 0xffffU)); @@ -150,7 +150,7 @@ float noise_blocky(vec3 t, uint seed) float res = bicubic(y0, y1, y2, y3, evolution_f); - /* Scale noise from the [0;1] range to [-1;1] */ + /* Scale noise from the [0,1] range to [-1,1] */ return res * 2.0 - 1.0; } diff --git a/libnopegl/src/glsl/path.frag b/libnopegl/src/glsl/path.frag index b79822eb4..52901d0c5 100644 --- a/libnopegl/src/glsl/path.frag +++ b/libnopegl/src/glsl/path.frag @@ -24,7 +24,7 @@ void main() { /* - * uv_* are normalized [0;1] quad coordinate which we map to the atlas + * uv_* are normalized [0,1] quad coordinate which we map to the atlas * element coordinate boundaries */ vec2 uv_fill = mix(coords_fill.xy, coords_fill.zw, uv); diff --git a/libnopegl/src/glsl/text_chars.frag b/libnopegl/src/glsl/text_chars.frag index eba1dadde..398192fa6 100644 --- a/libnopegl/src/glsl/text_chars.frag +++ b/libnopegl/src/glsl/text_chars.frag @@ -25,7 +25,7 @@ void main() { /* - * uv is a normalized [0;1] quad coordinate which we map to the atlas + * uv is a normalized [0,1] quad coordinate which we map to the atlas * element coordinate boundaries */ vec2 chr_uv = mix(coords.xy, coords.zw, uv); diff --git a/libnopegl/src/math_utils.h b/libnopegl/src/math_utils.h index 3fb2e959e..68ffec939 100644 --- a/libnopegl/src/math_utils.h +++ b/libnopegl/src/math_utils.h @@ -37,11 +37,11 @@ #define NGLI_DEG2RAD(x) ((x) * (TAU_F32 / 360.f)) #define NGLI_CEIL_RSHIFT(a, b) -((-(a)) >> (b)) -/* Map a normalized value to [a;b] range */ +/* Map a normalized value to [a,b] range */ #define NGLI_MIX_F32(a, b, x) ((a)*(1.f-(x)) + (b)*(x)) #define NGLI_MIX_F64(a, b, x) ((a)*(1.0-(x)) + (b)*(x)) -/* Map a value in [a;b] range to a normalized value */ +/* Map a value in [a,b] range to a normalized value */ #define NGLI_LINEAR_NORM(a, b, x) (((x) - (a)) / ((b) - (a))) #define NGLI_VEC2_ADD(a, b) {(a)[0] + (b)[0], (a)[1] + (b)[1]} diff --git a/libnopegl/src/node_colorkey.c b/libnopegl/src/node_colorkey.c index 27808a521..1b499c0c0 100644 --- a/libnopegl/src/node_colorkey.c +++ b/libnopegl/src/node_colorkey.c @@ -29,7 +29,7 @@ static const struct node_param colorkey_params[] = { {"position", NGLI_PARAM_TYPE_F32, OFFSET(position_node), {.f32=0.f}, .flags=NGLI_PARAM_FLAG_ALLOW_LIVE_CHANGE | NGLI_PARAM_FLAG_ALLOW_NODE, - .desc=NGLI_DOCSTRING("position of the gradient point on the axis (within [0;1])")}, + .desc=NGLI_DOCSTRING("position of the gradient point on the axis (within [0,1])")}, {"color", NGLI_PARAM_TYPE_VEC3, OFFSET(color_node), {.vec={1.f, 1.f, 1.f}}, .flags=NGLI_PARAM_FLAG_ALLOW_LIVE_CHANGE | NGLI_PARAM_FLAG_ALLOW_NODE, .desc=NGLI_DOCSTRING("color at this specific position")}, diff --git a/libnopegl/src/node_filters.c b/libnopegl/src/node_filters.c index f51dea73d..f32adadd4 100644 --- a/libnopegl/src/node_filters.c +++ b/libnopegl/src/node_filters.c @@ -345,7 +345,7 @@ static int filtercolormap_init(struct ngl_node *node) /* Convert input color to grayscale to obtain the interpolation index */ ngli_bstr_print(str, I "float t = dot(color.rgb, ngli_luma_weights);\n\n"); - /* Switch colors to linear space and saturate pos within [0;1] */ + /* Switch colors to linear space and saturate pos within [0,1] */ for (size_t i = 0; i < o->nb_colorkeys; i++) { ngli_bstr_printf(str, I "pos%zu = ngli_sat(pos%zu);\n", i, i); ngli_bstr_printf(str, I "color%zu = ngli_srgb2linear(color%zu);\n", i, i); diff --git a/libnopegl/src/node_renderother.c b/libnopegl/src/node_renderother.c index 59ae2406d..9dfb88b37 100644 --- a/libnopegl/src/node_renderother.c +++ b/libnopegl/src/node_renderother.c @@ -448,7 +448,7 @@ static const struct node_param rendernoise_params[] = { .flags=NGLI_PARAM_FLAG_ALLOW_NODE, .desc=NGLI_DOCSTRING("by how much it oscillates")}, {"octaves", NGLI_PARAM_TYPE_U32, OFFSET(octaves), {.u32=3}, - .desc=NGLI_DOCSTRING("number of accumulated noise layers (controls the level of details), must in [1;8]")}, + .desc=NGLI_DOCSTRING("number of accumulated noise layers (controls the level of details), must in [1,8]")}, {"lacunarity", NGLI_PARAM_TYPE_F32, OFFSET(lacunarity_node), {.f32=2.f}, .flags=NGLI_PARAM_FLAG_ALLOW_NODE, .desc=NGLI_DOCSTRING("frequency multiplier per octave")}, @@ -715,7 +715,7 @@ static int rendernoise_init(struct ngl_node *node) struct rendernoise_priv *s = node->priv_data; struct rendernoise_opts *o = node->opts; if (o->octaves < 1 || o->octaves > 8) { - LOG(ERROR, "octaves must be in [1;8]"); + LOG(ERROR, "octaves must be in [1,8]"); return NGL_ERROR_INVALID_ARG; } diff --git a/libnopegl/src/node_texture.c b/libnopegl/src/node_texture.c index 37243f1bc..2b108282c 100644 --- a/libnopegl/src/node_texture.c +++ b/libnopegl/src/node_texture.c @@ -191,7 +191,7 @@ static const struct node_param texture2d_params[] = { {"direct_rendering", NGLI_PARAM_TYPE_BOOL, OFFSET(direct_rendering), {.i32=1}, .desc=NGLI_DOCSTRING("whether direct rendering is allowed or not for media playback")}, {"clamp_video", NGLI_PARAM_TYPE_BOOL, OFFSET(clamp_video), {.i32=0}, - .desc=NGLI_DOCSTRING("clamp ngl_texvideo() output to [0;1]")}, + .desc=NGLI_DOCSTRING("clamp ngl_texvideo() output to [0,1]")}, {"clear_color", NGLI_PARAM_TYPE_VEC4, OFFSET(clear_color), .desc=NGLI_DOCSTRING("color used to clear the texture when used as an implicit render target")}, {"forward_transforms", NGLI_PARAM_TYPE_BOOL, OFFSET(forward_transforms), {.i32=0}, diff --git a/libnopegl/src/noise.c b/libnopegl/src/noise.c index fb79396a0..678e03479 100644 --- a/libnopegl/src/noise.c +++ b/libnopegl/src/noise.c @@ -61,7 +61,7 @@ static uint32_t hash(uint32_t x) } /* - * Return a random single-precision float between [0;1) + * Return a random single-precision float between [0,1) * Derived from http://prng.di.unimi.it/ */ static float u32tof32(uint32_t x) @@ -70,7 +70,7 @@ static float u32tof32(uint32_t x) return u.f - 1.f; } -/* Gradient noise, returns a value in [-.5;.5) */ +/* Gradient noise, returns a value in [-.5,.5) */ static float noise(const struct noise *s, float t) { const float i = floorf(t); // integer part (lattice point) @@ -79,8 +79,8 @@ static float noise(const struct noise *s, float t) /* * The random values correspond to the random slopes found at the 2 lattice - * points surrounding our current point; they are between [0;1) so we - * rescale them to [-1;1), which is equivalent to a tilt between [-π/4;π/4) + * points surrounding our current point; they are between [0,1) so we + * rescale them to [-1,1), which is equivalent to a tilt between [-π/4,π/4) */ const float s0 = u32tof32(hash(x)) * 2.f - 1.f; const float s1 = u32tof32(hash(x + 1)) * 2.f - 1.f; diff --git a/libnopegl/src/path.c b/libnopegl/src/path.c index bd93cdb0f..a207b76a7 100644 --- a/libnopegl/src/path.c +++ b/libnopegl/src/path.c @@ -552,7 +552,7 @@ int ngli_path_init(struct path *s, int32_t precision) * defined by 2 consecutive points in the `values` array, with `values` * composed of monotonically increasing values. * - * The range of the returned index is within [0;nb_values-2]. + * The range of the returned index is within [0,nb_values-2]. * * Example: * values: 2 3 5 8 9 @@ -593,7 +593,7 @@ static int get_vector_id(const float *values, int nb_values, int *cache, float v return ret; } -/* Remap x from [c;d] to [a;b] */ +/* Remap x from [c,d] to [a,b] */ static float remap(float a, float b, float c, float d, float x) { const float ratio = NGLI_LINEAR_NORM(c, d, x); diff --git a/libnopegl/src/text.h b/libnopegl/src/text.h index 283d158ed..c3bc1dbca 100644 --- a/libnopegl/src/text.h +++ b/libnopegl/src/text.h @@ -112,7 +112,7 @@ struct text_effects_pointers { struct effect_segmentation { size_t *positions; // character index (in chars darray) to position in "target unit" (char, word, ...) - size_t total_segments; // total number of segment: all values in positions are between [0;total_segments-1] + size_t total_segments; // total number of segment: all values in positions are between [0,total_segments-1] }; struct text { diff --git a/pynopegl-utils/pynopegl_utils/diff/shaders/diff.frag b/pynopegl-utils/pynopegl_utils/diff/shaders/diff.frag index 6ec794a89..60213a68f 100644 --- a/pynopegl-utils/pynopegl_utils/diff/shaders/diff.frag +++ b/pynopegl-utils/pynopegl_utils/diff/shaders/diff.frag @@ -35,7 +35,7 @@ vec4 color_diff(vec4 c0, vec4 c1) vec4 diff2 = diff * diff * vec4(show_r, show_g, show_b, show_a); // filtered squared difference float sum = diff2.r + diff2.g + diff2.b + diff2.a; float err = sqrt(sum / n); - float amp = (err - threshold) / (1 - threshold); // remap err from [0;1] to [thres;1] + float amp = (err - threshold) / (1 - threshold); // remap err from [0,1] to [thres,1] float amount = pow(amp, 1.0 / 3.0); // power 1/3 to boost the differences of the small amplitude vec3 grad = lin_mix(lin_mix(cmap0, cmap1, amount), lin_mix(cmap1, cmap2, amount), amount); diff --git a/pynopegl-utils/pynopegl_utils/diff/shaders/diff.vert b/pynopegl-utils/pynopegl_utils/diff/shaders/diff.vert index 0535a5dc1..b7c8f2164 100644 --- a/pynopegl-utils/pynopegl_utils/diff/shaders/diff.vert +++ b/pynopegl-utils/pynopegl_utils/diff/shaders/diff.vert @@ -24,7 +24,7 @@ void main() ngl_out_pos = ngl_projection_matrix * ngl_modelview_matrix * vec4(ngl_position, 1.0); uv = ngl_uvcoord; - /* Re-center space from UV in [0;1] to geometric [-1;1] (+ y-axis flip) */ + /* Re-center space from UV in [0,1] to geometric [-1,1] (+ y-axis flip) */ vec2 st = vec2(uv.x, 1.0 - uv.y) * 2.0 - 1.0; /* @@ -36,7 +36,7 @@ void main() vec2 off = -reframing_off * scale; st = st * scale + off; - /* Restore space to [0;1] (+ y-axis flip) */ + /* Restore space to [0,1] (+ y-axis flip) */ st = vec2(st.x + 1.0, 1.0 - st.y) / 2.0; tex0_coord = (tex0_coord_matrix * vec4(st, 0.0, 1.0)).xy; diff --git a/pynopegl-utils/pynopegl_utils/examples/shaders/audiotex.frag b/pynopegl-utils/pynopegl_utils/examples/shaders/audiotex.frag index 0a80eb56c..ce69b38f2 100644 --- a/pynopegl-utils/pynopegl_utils/examples/shaders/audiotex.frag +++ b/pynopegl-utils/pynopegl_utils/examples/shaders/audiotex.frag @@ -1,7 +1,7 @@ float wave(float amp, float y, float yoff) { - float s = (amp + 1.0) / 2.0; // [-1;1] -> [0;1] - float v = yoff + s/4.0; // [0;1] -> [off;off+0.25] + float s = (amp + 1.0) / 2.0; // [-1,1] -> [0,1] + float v = yoff + s/4.0; // [0,1] -> [off,off+0.25] return smoothstep(v-0.005, v, y) - smoothstep(v, v+0.005, y); } @@ -9,7 +9,7 @@ float wave(float amp, float y, float yoff) float freq(float power, float y, float yoff) { float p = sqrt(power); - float v = clamp(p, 0.0, 1.0) / 4.0; // [0;+oo] -> [0;0.25] + float v = clamp(p, 0.0, 1.0) / 4.0; // [0,+oo] -> [0,0.25] float a = yoff + 0.25; float b = a - v; return step(y, a) * (1.0 - step(y, b)); // y <= a && y > b diff --git a/pynopegl-utils/pynopegl_utils/tests/cmp_cuepoints.py b/pynopegl-utils/pynopegl_utils/tests/cmp_cuepoints.py index c87aa4aa6..98bf9a123 100644 --- a/pynopegl-utils/pynopegl_utils/tests/cmp_cuepoints.py +++ b/pynopegl-utils/pynopegl_utils/tests/cmp_cuepoints.py @@ -40,7 +40,7 @@ def __init__( ): """ points: dictionary associating point names with their 2D coordinates - within [-1;1] space + within [-1,1] space """ super().__init__(scene_func, width=width, height=height, **kwargs) self._points = points