mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
gaudieffects: remove < 0 comparison on guint32
Current CLAMP checks both if the value is below 0 or above 255. Considering it is an unsigned value it can never be less than zero, so that comparison is unnecessary. Switching to using if just for the upper bound. CID #1139796
This commit is contained in:
parent
267bc774ec
commit
3e452352f0
1 changed files with 8 additions and 9 deletions
|
@ -317,7 +317,7 @@ transform (guint32 * src, guint32 * dest, gint video_area,
|
|||
static const guint floor = 0;
|
||||
static const guint ceiling = 255;
|
||||
|
||||
gint period, up_length, down_length, height_scale, param;
|
||||
gint period, up_length, down_length, param;
|
||||
|
||||
period = end - start;
|
||||
if (period == 0) {
|
||||
|
@ -334,8 +334,6 @@ transform (guint32 * src, guint32 * dest, gint video_area,
|
|||
down_length = 1;
|
||||
}
|
||||
|
||||
height_scale = ceiling - floor;
|
||||
|
||||
/* Loop through pixels. */
|
||||
for (x = 0; x < video_area; x++) {
|
||||
in = *src++;
|
||||
|
@ -344,7 +342,6 @@ transform (guint32 * src, guint32 * dest, gint video_area,
|
|||
color[1] = (in >> 8) & 0xff;
|
||||
color[2] = (in) & 0xff;
|
||||
|
||||
|
||||
/* Loop through colors. */
|
||||
for (c = 0; c < 3; c++) {
|
||||
param = color[c];
|
||||
|
@ -353,20 +350,22 @@ transform (guint32 * src, guint32 * dest, gint video_area,
|
|||
param %= period;
|
||||
|
||||
if (param < up_length) {
|
||||
color[c] = param * height_scale;
|
||||
color[c] = param * ceiling;
|
||||
color[c] /= up_length;
|
||||
color[c] += floor;
|
||||
} else {
|
||||
color[c] = down_length - (param - up_length);
|
||||
color[c] *= height_scale;
|
||||
color[c] *= ceiling;
|
||||
color[c] /= down_length;
|
||||
color[c] += floor;
|
||||
}
|
||||
}
|
||||
|
||||
color[0] = CLAMP (color[0], 0, 255);
|
||||
color[1] = CLAMP (color[1], 0, 255);
|
||||
color[2] = CLAMP (color[2], 0, 255);
|
||||
/* Clamp colors */
|
||||
for (c = 0; c < 3; c++) {
|
||||
if (G_UNLIKELY (color[c] > 255))
|
||||
color[c] = 255;
|
||||
}
|
||||
|
||||
*dest++ = (color[0] << 16) | (color[1] << 8) | color[2];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue