[gthumb/gthumb-3-2] image rotation: fixed error when using libjpeg_turbo



commit 0584493e4dfc16a4c4f2cbdff6985fe9f894982b
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Fri Oct 11 11:30:36 2013 +0200

    image rotation: fixed error when using libjpeg_turbo

 extensions/jpeg_utils/transupp-80.c |   25 +++++++++++++++++++------
 extensions/jpeg_utils/transupp-80.h |   16 +++++++++++++---
 2 files changed, 32 insertions(+), 9 deletions(-)
---
diff --git a/extensions/jpeg_utils/transupp-80.c b/extensions/jpeg_utils/transupp-80.c
index 58a47d5..b2be184 100644
--- a/extensions/jpeg_utils/transupp-80.c
+++ b/extensions/jpeg_utils/transupp-80.c
@@ -45,6 +45,13 @@
 #include <ctype.h>             /* to declare isdigit() */
 
 
+#ifdef LIBJPEG_TURBO_VERSION
+# define info_slow_hflip info->slow_hflip
+#else
+# define info_slow_hflip 0
+#endif
+
+
 #if TRANSFORMS_SUPPORTED
 
 /*
@@ -1002,10 +1009,16 @@ jtransform_request_workspace (j_decompress_ptr srcinfo,
     else
       yoffset = info->crop_yoffset;
     /* Now adjust so that upper left corner falls at an iMCU boundary */
-    info->output_width =
-      info->crop_width + (xoffset % info->iMCU_sample_width);
-    info->output_height =
-      info->crop_height + (yoffset % info->iMCU_sample_height);
+    if (info->crop_width_set == JCROP_FORCE)
+      info->output_width = info->crop_width;
+    else
+      info->output_width =
+        info->crop_width + (xoffset % info->iMCU_sample_width);
+    if (info->crop_height_set == JCROP_FORCE)
+      info->output_height = info->crop_height;
+    else
+      info->output_height =
+        info->crop_height + (yoffset % info->iMCU_sample_height);
     /* Save x/y offsets measured in iMCUs */
     info->x_crop_offset = xoffset / info->iMCU_sample_width;
     info->y_crop_offset = yoffset / info->iMCU_sample_height;
@@ -1028,7 +1041,7 @@ jtransform_request_workspace (j_decompress_ptr srcinfo,
   case JXFORM_FLIP_H:
     if (info->trim)
       trim_right_edge(info, srcinfo->output_width);
-    if (info->y_crop_offset != 0)
+    if (info->y_crop_offset != 0 || info_slow_hflip)
       need_workspace = TRUE;
     /* do_flip_h_no_crop doesn't need a workspace array */
     break;
@@ -1440,7 +1453,7 @@ jtransform_execute_transform (j_decompress_ptr srcinfo,
              src_coef_arrays, dst_coef_arrays);
     break;
   case JXFORM_FLIP_H:
-    if (info->y_crop_offset != 0)
+    if (info->y_crop_offset != 0 || info_slow_hflip)
       do_flip_h(srcinfo, dstinfo, info->x_crop_offset, info->y_crop_offset,
                src_coef_arrays, dst_coef_arrays);
     else
diff --git a/extensions/jpeg_utils/transupp-80.h b/extensions/jpeg_utils/transupp-80.h
index 3e21b57..d6acce2 100644
--- a/extensions/jpeg_utils/transupp-80.h
+++ b/extensions/jpeg_utils/transupp-80.h
@@ -115,7 +115,8 @@ typedef enum { /*< skip >*/
 typedef enum { /*< skip >*/
        JCROP_UNSET,
        JCROP_POS,
-       JCROP_NEG
+       JCROP_NEG,
+       JCROP_FORCE
 } JCROP_CODE;
 
 /*
@@ -131,14 +132,23 @@ typedef struct {
   boolean trim;                        /* if TRUE, trim partial MCUs as needed */
   boolean force_grayscale;     /* if TRUE, convert color image to grayscale */
   boolean crop;                        /* if TRUE, crop source image */
+#ifdef LIBJPEG_TURBO_VERSION
+  boolean slow_hflip;  /* For best performance, the JXFORM_FLIP_H transform
+                          normally modifies the source coefficients in place.
+                          Setting this to TRUE will instead use a slower,
+                          double-buffered algorithm, which leaves the source
+                          coefficients in tact (necessary if other transformed
+                          images must be generated from the same set of
+                          coefficients. */
+#endif
 
   /* Crop parameters: application need not set these unless crop is TRUE.
    * These can be filled in by jtransform_parse_crop_spec().
    */
   JDIMENSION crop_width;       /* Width of selected region */
-  JCROP_CODE crop_width_set;
+  JCROP_CODE crop_width_set;    /* (forced disables adjustment) */
   JDIMENSION crop_height;      /* Height of selected region */
-  JCROP_CODE crop_height_set;
+  JCROP_CODE crop_height_set;   /* (forced disables adjustment) */
   JDIMENSION crop_xoffset;     /* X offset of selected region */
   JCROP_CODE crop_xoffset_set; /* (negative measures from right edge) */
   JDIMENSION crop_yoffset;     /* Y offset of selected region */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]