Update of /cvsroot/ufraw/ufraw
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25053

Modified Files:
        ufraw.h ufraw_preview.c ufraw_ufraw.c 
Log Message:
Small code simplification.


Index: ufraw.h
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufraw.h,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -d -r1.119 -r1.120
--- ufraw.h     18 Sep 2009 18:39:18 -0000      1.119
+++ ufraw.h     26 Sep 2009 01:23:17 -0000      1.120
@@ -313,7 +313,9 @@
 int ufraw_convert_image_init(ufraw_data *uf);
 int ufraw_convert_image_first_phase(ufraw_data *uf, gboolean lensfix);
 int ufraw_convert_image_init_phase(ufraw_data *uf);
-ufraw_image_data *ufraw_convert_image_area (ufraw_data *uf, int saidx, 
UFRawPhase phase);
+ufraw_image_data *ufraw_convert_get_final_image(ufraw_data *uf);
+ufraw_image_data *ufraw_convert_image_area(ufraw_data *uf, unsigned saidx,
+       UFRawPhase phase);
 void ufraw_close(ufraw_data *uf);
 void ufraw_flip_orientation(ufraw_data *uf, int flip);
 int ufraw_flip_image(ufraw_data *uf, int flip);

Index: ufraw_ufraw.c
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufraw_ufraw.c,v
retrieving revision 1.185
retrieving revision 1.186
diff -u -d -r1.185 -r1.186
--- ufraw_ufraw.c       23 Sep 2009 13:30:04 -0000      1.185
+++ ufraw_ufraw.c       26 Sep 2009 01:23:17 -0000      1.186
@@ -1103,26 +1103,34 @@
     return UFRAW_SUCCESS;
 }
 
-ufraw_image_data *ufraw_convert_image_area (
-    ufraw_data *uf, int saidx, UFRawPhase phase)
+ufraw_image_data *ufraw_convert_get_final_image(ufraw_data *uf)
+{
+#ifdef HAVE_LENSFUN
+    if (uf->modifier &&
+       (uf->postproc_ops & (LF_MODIFY_TCA | LF_MODIFY_DISTORTION |
+                            LF_MODIFY_GEOMETRY | LF_MODIFY_SCALE)))
+       return &uf->Images[ufraw_lensfun_phase];
+#endif /* HAVE_LENSFUN */
+    return &uf->Images[ufraw_develop_phase];
+}
+
+ufraw_image_data *ufraw_convert_image_area(ufraw_data *uf, unsigned saidx,
+       UFRawPhase phase)
 {
     int x = 0, y = 0, w = 0, h = 0;
     ufraw_image_data *out = &uf->Images [phase];
 
-    if (saidx >= 0)
-    {
-        if (out->valid & (1 << saidx))
-            return out; // the subarea has been already computed
-
-        /* Get subarea coordinates */
-        ufraw_img_get_subarea_coord (out, saidx, &x, &y, &w, &h);
-    }
+    if (out->valid & (1 << saidx))
+        return out; // the subarea has been already computed
 
     /* Get the subarea image for previous phase */
     ufraw_image_data *in = (phase > ufraw_first_phase) ?
         ufraw_convert_image_area (uf, saidx, phase - 1) :
         &uf->Images [ufraw_first_phase];
 
+    /* Get subarea coordinates */
+    ufraw_img_get_subarea_coord(out, saidx, &x, &y, &w, &h);
+
     switch (phase)
     {
         case ufraw_denoise_phase:
@@ -1131,9 +1139,6 @@
                     // No denoise phase, return the image from previous phase
                     return in;
 
-                if (saidx < 0)
-                    return out;
-
                 dcraw_image_data tmp;
                 /* With shrink==2 the border should be 16 pixels */
                 int border = 16 * 2 / uf->ConvertShrink;
@@ -1170,9 +1175,6 @@
 
         case ufraw_develop_phase:
             {
-                if (saidx < 0)
-                    return out;
-
                 int yy;
                 for (yy = y; yy < y + h; yy++)
                 {
@@ -1206,9 +1208,6 @@
                                           LF_MODIFY_GEOMETRY | 
LF_MODIFY_SCALE)))
                     return in;
 
-                if (saidx < 0)
-                    return out;
-
                 int yy;
                 float *buff = g_new (float, (w < 8) ? 8 * 2 * 3 : w * 2 * 3);
 
@@ -1233,7 +1232,7 @@
                 for (yy = 0; yy < 8 * 2 * 3; yy += 2)
                 {
                     int idx = ufraw_img_get_subarea_idx (in, buff [yy], buff 
[yy + 1]);
-                    if (idx >= 0 && idx <= 31)
+                    if (idx <= 31)
                         ufraw_convert_image_area (uf, idx, phase - 1);
                 }
 

Index: ufraw_preview.c
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufraw_preview.c,v
retrieving revision 1.271
retrieving revision 1.272
diff -u -d -r1.271 -r1.272
--- ufraw_preview.c     23 Sep 2009 13:15:13 -0000      1.271
+++ ufraw_preview.c     26 Sep 2009 01:23:17 -0000      1.272
@@ -581,8 +581,8 @@
  * This approach makes computing width/height just a matter of
  * substracting X1 from X2 or Y1 from Y2.
  */
-static void preview_draw_img_area(preview_data *data, ufraw_image_data *img,
-                                  int x, int y, int width, int height)
+static void preview_draw_area(preview_data *data,
+       int x, int y, int width, int height)
 {
     int pixbufHeight = gdk_pixbuf_get_height(data->PreviewPixbuf);
     if ( y<0 || y>=pixbufHeight )
@@ -627,6 +627,9 @@
     int SpotX1 = floor(MIN(data->SpotX1, data->SpotX2) * scale_x);
     int SpotX2 =  ceil(MAX(data->SpotX1, data->SpotX2) * scale_x);
     int xx, yy, c;
+
+    ufraw_image_data *img = ufraw_convert_get_final_image(data->UF);
+
     for (yy=y; yy<y+height; yy++) {
        p8 = pixies+yy*rowstride+x*3;
        memcpy(p8, img->buffer + yy*img->rowstride + x*img->depth,
@@ -689,14 +692,6 @@
     image_draw_area(data, x, y, width, height);
 }
 
-static void preview_draw_area(preview_data *data, int x, int y,
-                              int width, int height)
-{
-    preview_draw_img_area(
-        data, ufraw_convert_image_area(data->UF, -1, ufraw_phases_num - 1),
-        x, y, width, height);
-}
-
 static gboolean switch_highlights(gpointer ptr)
 {
     preview_data *data = ptr;
@@ -1008,13 +1003,12 @@
 #ifdef HAVE_GTKIMAGEVIEW
     int max_area = -1;
     int i, x, y, w, h;
-    ufraw_image_data *img;
 
     /* First of all, find the maximally visible yet unrendered subarea.
      * Refreshing visible subareas in the first place improves visual
      * feedback and overall user experience.
      */
-    img = ufraw_convert_image_area(data->UF, -1, ufraw_phases_num - 1);
+    ufraw_image_data *img = ufraw_convert_get_final_image(data->UF);
 
     GdkRectangle viewport;
     gtk_image_view_get_viewport(
@@ -1083,7 +1077,6 @@
 {
     gboolean again = FALSE;
     int chosen = 0;
-    int subarea;
 
     if (data->FreezeDialog) return FALSE;
 
@@ -1096,8 +1089,11 @@
         return FALSE;
 
 #ifdef _OPENMP
-#pragma omp parallel shared(chosen,data) private(subarea) reduction(||:again)
+#pragma omp parallel shared(chosen,data) reduction(||:again)
     {
+#endif
+    int subarea;
+#ifdef _OPENMP
 #pragma omp critical
 #endif
     subarea = choose_subarea(data, &chosen);
@@ -1110,7 +1106,7 @@
        if (img1) {
            int x, y, w, h;
            ufraw_img_get_subarea_coord(img1, subarea, &x, &y, &w, &h);
-           preview_draw_img_area(data, img1, x, y, w, h);
+           preview_draw_area(data, x, y, w, h);
            again = TRUE;
        }
     }


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
ufraw-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ufraw-cvs

Reply via email to