fix BS related with jpeg rotation.
authorjypark <jypark@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 6 Mar 2012 11:52:03 +0000 (11:52 +0000)
committerjypark <jypark@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 6 Mar 2012 11:52:03 +0000 (11:52 +0000)
during decoding, ie's w and h should not change it's value
because several objects use same cache entry

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@68809 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/modules/loaders/jpeg/evas_image_load_jpeg.c

index a74064f..73a7310 100644 (file)
@@ -272,10 +272,7 @@ evas_image_load_file_head_jpeg_internal(Image_Entry *ie,
          *error = EVAS_LOAD_ERROR_UNKNOWN_FORMAT;
        return EINA_FALSE;
      }
-
-   degree = 0;
-   change_wh = EINA_FALSE;
-   jpeg_create_decompress(&cinfo);
+  jpeg_create_decompress(&cinfo);
 
    if (_evas_jpeg_membuf_src(&cinfo, map, length))
      {
@@ -511,7 +508,7 @@ evas_image_load_file_data_jpeg_internal(Image_Entry *ie,
    unsigned int x, y, l, i, scans;
    int region = 0;
    /* rotation setting */
-   unsigned int tmp;
+   unsigned int ie_w = 0, ie_h = 0;
    unsigned int load_region_x = 0, load_region_y = 0;
    unsigned int load_region_w = 0, load_region_h = 0;
    volatile int degree = 0;
@@ -585,9 +582,13 @@ evas_image_load_file_data_jpeg_internal(Image_Entry *ie,
 
    if (change_wh)
      {
-        tmp = ie->w;
-        ie->w = ie->h;
-        ie->h = tmp;
+        ie_w = ie->h;
+        ie_h = ie->w;
+     }
+   else
+     {
+        ie_w = ie->w;
+        ie_h = ie->h;
      }
 
    if ((ie->load_opts.region.w > 0) && (ie->load_opts.region.h > 0))
@@ -632,20 +633,31 @@ evas_image_load_file_data_jpeg_internal(Image_Entry *ie,
         cinfo.region_h = ie->load_opts.region.h;
 #endif
      }
-   if ((!region) && ((w != ie->w) || (h != ie->h)))
+   if ((!region) && ((w != ie_w) || (h != ie_h)))
      {
-       // race condition, the file could have change from when we call header
-       // this test will not solve the problem with region code.
-       jpeg_destroy_decompress(&cinfo);
+        // race condition, the file could have change from when we call header
+        // this test will not solve the problem with region code.
+        jpeg_destroy_decompress(&cinfo);
         _evas_jpeg_membuf_src_term(&cinfo);
-       *error = EVAS_LOAD_ERROR_GENERIC;
-       return EINA_FALSE;
+        *error = EVAS_LOAD_ERROR_GENERIC;
+        return EINA_FALSE;
      }
    if ((region) &&
-       ((ie->w != ie->load_opts.region.w) || (ie->h != ie->load_opts.region.h)))
+       ((ie_w != ie->load_opts.region.w) || (ie_h != ie->load_opts.region.h)))
      {
-        ie->w = ie->load_opts.region.w;
-        ie->h = ie->load_opts.region.h;
+        ie_w = ie->load_opts.region.w;
+        ie_h = ie->load_opts.region.h;
+        if (change_wh)
+          {
+             ie->w = ie_h;
+             ie->h = ie_w;
+          }
+        else
+          {
+             ie->w = ie_w;
+             ie->h = ie_h;
+          }
+
      }
 
    if (!(((cinfo.out_color_space == JCS_RGB) &&
@@ -976,13 +988,6 @@ done:
         DATA32             *data1, *data2,  *to, *from;
         int                 lx, ly, lw, lh,  hw;
 
-        if (change_wh)
-          {
-             tmp = ie->w;
-             ie->w = ie->h;
-             ie->h = tmp;
-          }
-
         lw = ie->w;
         lh = ie->h;
         hw =lw * lh;
@@ -1049,6 +1054,7 @@ done:
              ie->load_opts.region.h = load_region_h;
           }
      }
+
    if (line_done)
      {
         jpeg_destroy_decompress(&cinfo);