video-dither: remove check for below zero for unsigned value
authorLuis de Bethencourt <luis.bg@samsung.com>
Fri, 9 Jan 2015 15:38:09 +0000 (15:38 +0000)
committerLuis de Bethencourt <luis.bg@samsung.com>
Fri, 9 Jan 2015 15:38:09 +0000 (15:38 +0000)
CLAMP checks both if value is '< 0' and '> max'. Value will never be a negative
number since it is an unsigned integer. Removing that check and only checking if
it is bigger than max and setting it appropriately.

CID 1256559

gst-libs/gst/video/video-dither.c

index af609dd323639d8418539a9ae47faf8fc5fdbb71..430564c9a077d2ae0de1926c0d3f7f16fb5eb598 100644 (file)
@@ -97,7 +97,7 @@ dither_verterr_u16 (GstVideoDither * dither, gpointer pixels, guint x, guint y,
       e[i] = v & mp;
       /* quantize and store */
       v &= ~mp;
-      p[i] = CLAMP (v, 0, 65535);
+      p[i] = MIN (v, 65535);
     }
   }
 }
@@ -129,7 +129,7 @@ dither_floyd_steinberg_u8 (GstVideoDither * dither, gpointer pixels, guint x,
       e[i + 4] = v & mp;
       /* quantize and store */
       v &= ~mp;
-      p[i] = CLAMP (v, 0, 255);
+      p[i] = MIN (v, 255);
     }
   }
 #else
@@ -162,7 +162,7 @@ dither_floyd_steinberg_u16 (GstVideoDither * dither, gpointer pixels, guint x,
       e[i + 4] = v & mp;
       /* quantize and store */
       v &= ~mp;
-      p[i] = CLAMP (v, 0, 65535);
+      p[i] = MIN (v, 65535);
     }
   }
 }
@@ -189,7 +189,7 @@ dither_sierra_lite_u8 (GstVideoDither * dither, gpointer pixels, guint x,
     e[i + 4] = v & mp;
     /* quantize and store */
     v &= ~mp;
-    p[i] = CLAMP (v, 0, 255);
+    p[i] = MIN (v, 255);
   }
 }
 
@@ -215,7 +215,7 @@ dither_sierra_lite_u16 (GstVideoDither * dither, gpointer pixels, guint x,
     e[i + 4] = v & mp;
     /* quantize and store */
     v &= ~mp;
-    p[i] = CLAMP (v & ~mp, 0, 65535);
+    p[i] = MIN (v & ~mp, 65535);
   }
 }