chiark / gitweb /
Reverse order of samples in Rgb and other optimisations
[ypp-sc-tools.main.git] / pctb / structure.h
index 73f65718354a19e88dcdde11c307010d90f709f5..263a26ad86fe1e8ea5e0ee588b88d4c1cba0393a 100644 (file)
@@ -50,43 +50,41 @@ static inline char canon_lookup_colour(unsigned char r,
   return blues->blue2[b];
 }
 
-#define CANONICALISE_IMAGE(im,w,h,rgb_save, COMPUTE_RGB) do{   \
-    /* compute_rgb should be a number of statements, or                \
-     * a block, which assigns to                               \
-     *   Rgb rgb;                                              \
-     * given the values of                                     \
-     *   int x,y;                                              \
-     * all of which are anamorphic.  Result is stored in im.   \
-     * The COMPUTE_RGB is executed exactly once for            \
-     * each pixel in reading order.                            \
-     */                                                                \
-    (im)= alloc_canon_image((w), (h));                         \
-    (rgb_save)= alloc_rgb_image((w), (h));                     \
-                                                               \
-    int x,y;                                                   \
-    for (y=0; y<(h); y++) {                                    \
-      for (x=0; x<(w); x++) {                                  \
-        unsigned char r,g,b;                                   \
-       COMPUTE_RGB;                                            \
-        CANONIMG_ALSO_STORERGB((rgb_save));                    \
-       (im)->d[y*(w) + x]= canon_lookup_colour(r,g,b);         \
-      }                                                                \
-      if (DEBUGP(rect)) {                                      \
-       fprintf(debug, "%4d ",y);                               \
-       fwrite(im->d + y*(w), 1,(w), debug);                    \
-       fputc('\n',debug);                                      \
-      }                                                                \
-    }                                                          \
-    debug_flush();                                             \
+#define CANONICALISE_IMAGE(im,w,h,rgb_save, COMPUTE_RGB) do{           \
+    /* compute_rgb should be a number of statements, or                        \
+     * a block, which assigns to                                       \
+     *   Rgb rgb;                                                      \
+     * given the values of                                             \
+     *   int x,y;                                                      \
+     * all of which are anamorphic.  Result is stored in im.           \
+     * The COMPUTE_RGB is executed exactly once for                    \
+     * each pixel in reading order.                                    \
+     */                                                                        \
+    (im)= alloc_canon_image((w), (h));                                 \
+    (rgb_save)= alloc_rgb_image((w), (h));                             \
+                                                                       \
+    int x,y;                                                           \
+    for (y=0; y<(h); y++) {                                            \
+      for (x=0; x<(w); x++) {                                          \
+        Rgb rgb;                                                       \
+       COMPUTE_RGB;                                                    \
+        CANONIMG_ALSO_STORERGB((rgb_save));                            \
+       (im)->d[y*(w) + x]= canon_lookup_colour(rgb, rgb>>8, rgb>>16);  \
+      }                                                                        \
+      if (DEBUGP(rect)) {                                              \
+       fprintf(debug, "%4d ",y);                                       \
+       fwrite(im->d + y*(w), 1,(w), debug);                            \
+       fputc('\n',debug);                                              \
+      }                                                                        \
+    }                                                                  \
+    debug_flush();                                                     \
   }while(0)
 
 
 #define CANONIMG_ALSO_STORERGB(ri)             \
   do{                                          \
-    unsigned char *rip= RI_PIXEL((ri),x,y);    \
-    rip[0]= r;                                 \
-    rip[1]= g;                                 \
-    rip[2]= b;                                 \
+    Rgb *rip= RI_PIXEL32((ri),x,y);            \
+    *rip= rgb;                                 \
   }while(0)