changeset 8349:916d5392dcc9

- It fixes a small bug where a byte value is divided by 255.0 to convert to a float within [0.0, 1.0] and later multiplied by 256.0 to convert back. This makes the luminance lookup table more correct, although the visual difference is relatively small. - speedup of inner loop, using dst[i] instead of *dst++ based on patch by Linards Ticmanis <ticmanis@coli.uni-sb.de>
author arpi
date Wed, 04 Dec 2002 22:00:03 +0000
parents 1cf5d8a5bbe8
children 9e045c59ffb8
files libmpcodecs/vf_eq2.c
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vf_eq2.c	Wed Dec 04 21:48:15 2002 +0000
+++ b/libmpcodecs/vf_eq2.c	Wed Dec 04 22:00:03 2002 +0000
@@ -70,7 +70,9 @@
         eq2->lut[i] = 255;
       }
       else {
-        eq2->lut[i] = (unsigned char) (256.0 * v);
+        /* we divided by 255.0 so now we also multiply by 255.0, not
+           by 256.0. "+ 0.5" ensures proper rounding */
+        eq2->lut[i] = (unsigned char) (255.0 * v + 0.5);
       }
     }
   }
@@ -85,11 +87,10 @@
 
   for (j = 0; j < h; j++) {
     for (i = 0; i < w; i++) {
-      *(dst++) = lut[*(src++)];
+      dst[i] = lut[src[i]];
     }
-
-    src += sstride - w;
-    dst += dstride - w;
+    src += sstride;
+    dst += dstride;
   }
 }