about summary refs log tree commit diff
path: root/converter/other/fiasco/codec/tiling.c
diff options
context:
space:
mode:
Diffstat (limited to 'converter/other/fiasco/codec/tiling.c')
-rw-r--r--converter/other/fiasco/codec/tiling.c166
1 files changed, 83 insertions, 83 deletions
diff --git a/converter/other/fiasco/codec/tiling.c b/converter/other/fiasco/codec/tiling.c
index 9af43da0..08423b24 100644
--- a/converter/other/fiasco/codec/tiling.c
+++ b/converter/other/fiasco/codec/tiling.c
@@ -1,8 +1,8 @@
 /*
- *  tiling.c:		Subimage permutation
+ *  tiling.c:           Subimage permutation
+ *
+ *  Written by:         Ullrich Hafner
  *
- *  Written by:		Ullrich Hafner
- *		
  *  This file is part of FIASCO (Fractal Image And Sequence COdec)
  *  Copyright (C) 1994-2000 Ullrich Hafner
  */
@@ -33,8 +33,8 @@
 
 typedef struct var_list
 {
-   int	  address;			/* bintree address */
-   real_t variance;			/* variance of tile */
+   int    address;                      /* bintree address */
+   real_t variance;                     /* variance of tile */
 } var_list_t;
 
 #ifndef LITERAL_FN_DEF_MATCH
@@ -71,17 +71,17 @@ cmpdecvar(const void * const value1,
 
 tiling_t *
 alloc_tiling (fiasco_tiling_e method, unsigned tiling_exponent,
-	      unsigned image_level)
+              unsigned image_level)
 /*
  *  Image tiling constructor.
  *  Allocate memory for the tiling_t structure.
  *  `method' defines the tiling method (spiral or variance,
  *  ascending or descending).
  *  In case of invalid parameters, a structure with tiling.exponent == 0 is
- *  returned. 
+ *  returned.
  *
  *  Return value
- *	pointer to the new tiling structure on success
+ *      pointer to the new tiling structure on success
  */
 {
    tiling_t *tiling = Calloc (1, sizeof (tiling_t));
@@ -90,21 +90,21 @@ alloc_tiling (fiasco_tiling_e method, unsigned tiling_exponent,
    {
       tiling_exponent = 6;
       warning (_("Image tiles must be at least 8x8 pixels large.\n"
-		 "Setting tiling size to 8x8 pixels."));
+                 "Setting tiling size to 8x8 pixels."));
    }
-   
+
    switch (method)
    {
       case FIASCO_TILING_SPIRAL_ASC:
       case FIASCO_TILING_SPIRAL_DSC:
       case FIASCO_TILING_VARIANCE_ASC:
       case FIASCO_TILING_VARIANCE_DSC:
-	 tiling_exponent = tiling_exponent;
-	 break;
+         tiling_exponent = tiling_exponent;
+         break;
       default:
-	 warning (_("Invalid tiling method specified. Disabling tiling."));
-	 tiling_exponent = 0;
-	 break;
+         warning (_("Invalid tiling method specified. Disabling tiling."));
+         tiling_exponent = 0;
+         break;
    }
 
    return tiling;
@@ -119,7 +119,7 @@ free_tiling (tiling_t *tiling)
  *  No return value.
  *
  *  Side effects:
- *	structure 'tiling' is discarded.
+ *      structure 'tiling' is discarded.
  */
 {
    if (tiling->vorder)
@@ -145,88 +145,88 @@ perform_tiling (const image_t *image, tiling_t *tiling)
  *  No return value.
  *
  *  Side effects:
- *	The tiling permutation is stored in 'tiling->vorder'.
+ *      The tiling permutation is stored in 'tiling->vorder'.
  */
 {
    if (tiling->exponent)
    {
-      unsigned 	tiles = 1 << tiling->exponent; /* number of image tiles */
-      bool_t   *tile_valid;		/* tile i is in valid range ? */
-      
+      unsigned  tiles = 1 << tiling->exponent; /* number of image tiles */
+      bool_t   *tile_valid;             /* tile i is in valid range ? */
+
       tiling->vorder = Calloc (tiles, sizeof (int));
       tile_valid     = Calloc (tiles, sizeof (bool_t));
 
       if (tiling->method == FIASCO_TILING_VARIANCE_ASC
-	  || tiling->method == FIASCO_TILING_VARIANCE_DSC)
+          || tiling->method == FIASCO_TILING_VARIANCE_DSC)
       {
-	 unsigned    address;		/* bintree address of tile */
-	 unsigned    number;		/* number of image tiles */
-	 unsigned    lx       = log2 (image->width - 1) + 1; /* x level */
-	 unsigned    ly       = log2 (image->height - 1) + 1; /* y level */
-	 unsigned    level    = MAX(lx, ly) * 2 - ((ly == lx + 1) ? 1 : 0);
-	 var_list_t *var_list = Calloc (tiles, sizeof (var_list_t));
-	 
-	 /*
-	  *  Compute variances of image tiles
-	  */
-	 for (number = 0, address = 0; address < tiles; address++)
-	 {
-	    unsigned width, height;	/* size of image tile */
-	    unsigned x0, y0;		/* NW corner of image tile */
-      
-	    locate_subimage (level, level - tiling->exponent, address,
-			     &x0, &y0, &width, &height);
-	    if (x0 < image->width && y0 < image->height) /* valid range */
-	    {
-	       if (x0 + width > image->width)	/* outside image area */
-		  width = image->width - x0;
-	       if (y0 + height > image->height) /* outside image area */
-		  height = image->height - y0;
-
-	       var_list [number].variance
-		  = variance (image->pixels [GRAY], x0, y0,
-			      width, height, image->width);
-	       var_list [number].address  = address;
-	       number++;
-	       tile_valid [address] = YES;
-	    }
-	    else
-	       tile_valid [address] = NO;
-	 }
-
-	 /*
-	  *  Sort image tiles according to sign of 'tiling->exp'
-	  */
-	 if (tiling->method == FIASCO_TILING_VARIANCE_DSC)
-	    qsort (var_list, number, sizeof (var_list_t), cmpdecvar);
-	 else
-	    qsort (var_list, number, sizeof (var_list_t), cmpincvar);
-
-	 for (number = 0, address = 0; address < tiles; address++)
-	    if (tile_valid [address])
-	    {
-	       tiling->vorder [address] = var_list [number].address;
-	       number++;
-	       debug_message ("tile number %d has original address %d",
-			      number, tiling->vorder [address]);
-	    }
-	    else
-	       tiling->vorder [address] = -1;
-
-	 Free (var_list);
+         unsigned    address;           /* bintree address of tile */
+         unsigned    number;            /* number of image tiles */
+         unsigned    lx       = log2 (image->width - 1) + 1; /* x level */
+         unsigned    ly       = log2 (image->height - 1) + 1; /* y level */
+         unsigned    level    = MAX(lx, ly) * 2 - ((ly == lx + 1) ? 1 : 0);
+         var_list_t *var_list = Calloc (tiles, sizeof (var_list_t));
+
+         /*
+          *  Compute variances of image tiles
+          */
+         for (number = 0, address = 0; address < tiles; address++)
+         {
+            unsigned width, height;     /* size of image tile */
+            unsigned x0, y0;            /* NW corner of image tile */
+
+            locate_subimage (level, level - tiling->exponent, address,
+                             &x0, &y0, &width, &height);
+            if (x0 < image->width && y0 < image->height) /* valid range */
+            {
+               if (x0 + width > image->width)   /* outside image area */
+                  width = image->width - x0;
+               if (y0 + height > image->height) /* outside image area */
+                  height = image->height - y0;
+
+               var_list [number].variance
+                  = variance (image->pixels [GRAY], x0, y0,
+                              width, height, image->width);
+               var_list [number].address  = address;
+               number++;
+               tile_valid [address] = YES;
+            }
+            else
+               tile_valid [address] = NO;
+         }
+
+         /*
+          *  Sort image tiles according to sign of 'tiling->exp'
+          */
+         if (tiling->method == FIASCO_TILING_VARIANCE_DSC)
+            qsort (var_list, number, sizeof (var_list_t), cmpdecvar);
+         else
+            qsort (var_list, number, sizeof (var_list_t), cmpincvar);
+
+         for (number = 0, address = 0; address < tiles; address++)
+            if (tile_valid [address])
+            {
+               tiling->vorder [address] = var_list [number].address;
+               number++;
+               debug_message ("tile number %d has original address %d",
+                              number, tiling->vorder [address]);
+            }
+            else
+               tiling->vorder [address] = -1;
+
+         Free (var_list);
       }
       else if (tiling->method == FIASCO_TILING_SPIRAL_DSC
-	       || tiling->method == FIASCO_TILING_SPIRAL_ASC)
+               || tiling->method == FIASCO_TILING_SPIRAL_ASC)
       {
-	 compute_spiral (tiling->vorder, image->width, image->height,
-			 tiling->exponent,
-			 tiling->method == FIASCO_TILING_SPIRAL_ASC);
+         compute_spiral (tiling->vorder, image->width, image->height,
+                         tiling->exponent,
+                         tiling->method == FIASCO_TILING_SPIRAL_ASC);
       }
       else
       {
-	 warning ("We do not know the tiling method.\n"
-		  "Skipping image tiling step.");
-	 tiling->exponent = 0;
+         warning ("We do not know the tiling method.\n"
+                  "Skipping image tiling step.");
+         tiling->exponent = 0;
       }
    }
 }