[gegl] jp2-load: Init and cleanup Jasper



commit 6f109152faa74a4700cf4d58c993367a8b3572df
Author: Mukund Sivaraman <muks banu com>
Date:   Sat Sep 10 14:54:54 2011 +0530

    jp2-load: Init and cleanup Jasper

 operations/external/jp2-load.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/operations/external/jp2-load.c b/operations/external/jp2-load.c
index 6205582..1e444be 100644
--- a/operations/external/jp2-load.c
+++ b/operations/external/jp2-load.c
@@ -188,12 +188,14 @@ process (GeglOperation       *operation,
 
   width = height = depth = 0;
 
-  if (!query_jp2 (o->path, &width, &height, &depth, &image))
-    return FALSE;
+  jas_init ();
 
   ret = FALSE;
   b = FALSE;
 
+  if (!query_jp2 (o->path, &width, &height, &depth, &image))
+    goto ret;
+
   do
     {
       components[0] = jas_image_getcmptbytype
@@ -220,7 +222,7 @@ process (GeglOperation       *operation,
         }
 
       for (i = 0; i < 3; i++)
-        matrices[i] = jas_matrix_create(1, width);
+        matrices[i] = jas_matrix_create (1, width);
 
       switch (depth)
         {
@@ -234,7 +236,6 @@ process (GeglOperation       *operation,
 
         default:
           g_warning ("%s: Programmer stupidity error", G_STRLOC);
-          return FALSE;
         }
 
       for (row = 0; row < height; row++)
@@ -328,6 +329,8 @@ process (GeglOperation       *operation,
   if (image)
     jas_image_destroy (image);
 
+ ret:
+  jas_cleanup ();
   return ret;
 }
 
@@ -340,8 +343,10 @@ get_bounding_box (GeglOperation * operation)
 
   width = height = depth = 0;
 
+  jas_init ();
+
   if (!query_jp2 (o->path, &width, &height, &depth, NULL))
-    return result;
+    goto ret;
 
   result.width = width;
   result.height = height;
@@ -362,6 +367,8 @@ get_bounding_box (GeglOperation * operation)
       g_warning ("%s: Programmer stupidity error", G_STRLOC);
     }
 
+ ret:
+  jas_cleanup ();
   return result;
 }
 



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