about summary refs log tree commit diff
path: root/converter/other/fiasco/output/weights.c
diff options
context:
space:
mode:
Diffstat (limited to 'converter/other/fiasco/output/weights.c')
-rw-r--r--converter/other/fiasco/output/weights.c76
1 files changed, 38 insertions, 38 deletions
diff --git a/converter/other/fiasco/output/weights.c b/converter/other/fiasco/output/weights.c
index 0203fef0..4eb068ac 100644
--- a/converter/other/fiasco/output/weights.c
+++ b/converter/other/fiasco/output/weights.c
@@ -1,8 +1,8 @@
 /*
- *  weights.c:		Output of weights
+ *  weights.c:          Output of weights
+ *
+ *  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
  */
@@ -32,8 +32,8 @@
 
 /*****************************************************************************
 
-				public code
-  
+                                public code
+
 *****************************************************************************/
 
 void
@@ -45,20 +45,20 @@ write_weights (unsigned total, const wfa_t *wfa, bitfile_t *output)
  *  No return value.
  */
 {
-    unsigned  state, label;		/* current label */
-    unsigned  offset1, offset2;		/* model offsets. */
-    unsigned  offset3, offset4;		/* model offsets. */
-    unsigned *weights_array;		/* array of weights to encode */
-    unsigned *wptr;			/* pointer to current weight */
-    unsigned *level_array;		/* array of corresponding levels */
-    unsigned *lptr;			/* pointer to current corr. level */
-    int	     min_level, max_level;	/* min and max range level */
-    int	     d_min_level, d_max_level; 	/* min and max delta range level */
-    bool_t    dc, d_dc;			/* true if dc or delta dc are used */
-    bool_t    delta_approx = NO;		/* true if delta has been used */
-    unsigned  delta_count  = 0;		/* number of delta ranges */
-    unsigned  bits 	  = bits_processed (output);
-   
+    unsigned  state, label;             /* current label */
+    unsigned  offset1, offset2;         /* model offsets. */
+    unsigned  offset3, offset4;         /* model offsets. */
+    unsigned *weights_array;            /* array of weights to encode */
+    unsigned *wptr;                     /* pointer to current weight */
+    unsigned *level_array;              /* array of corresponding levels */
+    unsigned *lptr;                     /* pointer to current corr. level */
+    int      min_level, max_level;      /* min and max range level */
+    int      d_min_level, d_max_level;  /* min and max delta range level */
+    bool_t    dc, d_dc;                 /* true if dc or delta dc are used */
+    bool_t    delta_approx = NO;                /* true if delta has been used */
+    unsigned  delta_count  = 0;         /* number of delta ranges */
+    unsigned  bits        = bits_processed (output);
+
     /*
      *  Check whether delta approximation has been used
      */
@@ -68,14 +68,14 @@ write_weights (unsigned total, const wfa_t *wfa, bitfile_t *output)
             delta_approx = YES;
             break;
         }
-   
+
     /*
      *  Generate array of corresponding levels (context of probability model)
      */
     min_level = d_min_level = MAXLEVEL;
     max_level = d_max_level = 0;
-    dc 	     = d_dc	   = NO;
-   
+    dc       = d_dc        = NO;
+
     for (state = wfa->basis_states; state < wfa->states; state++)
         for (label = 0; label < MAXLABELS; label++)
             if (isrange (wfa->tree [state][label]))
@@ -95,24 +95,24 @@ write_weights (unsigned total, const wfa_t *wfa, bitfile_t *output)
                         dc = YES;
                 }
             }
-    if (min_level > max_level)		/* no lc found */
+    if (min_level > max_level)          /* no lc found */
         max_level = min_level - 1;
     if (d_min_level > d_max_level)
         d_max_level = d_min_level - 1;
 
     /*
      *  Context model:
-     *		0		DC weight
-     *		1		Delta DC weight
-     *		2-k		normal weights per level
-     *		k+1 - m		Delta weights per level
+     *          0               DC weight
+     *          1               Delta DC weight
+     *          2-k             normal weights per level
+     *          k+1 - m         Delta weights per level
      */
 
     offset1 = dc ? 1 : 0;
     offset2 = offset1 + (d_dc ? 1 : 0);
     offset3 = offset2 + (max_level - min_level + 1);
     offset4 = offset3 + (d_max_level - d_min_level + 1);
-   
+
     /*
      *  Weights are encoded as follows:
      *  all weights of state n
@@ -127,15 +127,15 @@ write_weights (unsigned total, const wfa_t *wfa, bitfile_t *output)
         for (label = 0; label < MAXLABELS; label++)
             if (isrange (wfa->tree [state][label]))
             {
-                int	edge;			/* current edge */
-                int	domain;			/* current domain (context of model) */
-	    
+                int     edge;                   /* current edge */
+                int     domain;                 /* current domain (context of model) */
+
                 for (edge = 0; isedge (domain = wfa->into [state][label][edge]);
                      edge++)
                 {
                     if (wptr - weights_array >= (int) total)
                         error ("Can't write more than %d weights.", total);
-                    if (domain)		/* not DC component */
+                    if (domain)         /* not DC component */
                     {
                         if (delta_approx && wfa->delta_state [state]) /* delta */
                         {
@@ -153,7 +153,7 @@ write_weights (unsigned total, const wfa_t *wfa, bitfile_t *output)
                                 + wfa->level_of_state [state] - 1 - min_level;
                         }
                     }
-                    else			/* DC component */
+                    else                        /* DC component */
                     {
                         if (delta_approx && wfa->delta_state [state]) /* delta */
                         {
@@ -172,9 +172,9 @@ write_weights (unsigned total, const wfa_t *wfa, bitfile_t *output)
             }
 
     {
-        unsigned	 i;
-        unsigned	*c_symbols = Calloc (offset4, sizeof (int));
-        const int	 scale 	   = 500;	/* scaling of probability model */
+        unsigned         i;
+        unsigned        *c_symbols = Calloc (offset4, sizeof (int));
+        const int        scale     = 500;       /* scaling of probability model */
 
         c_symbols [0] = 1 << (wfa->wfainfo->dc_rpf->mantissa_bits + 1);
         if (offset1 != offset2)
@@ -184,12 +184,12 @@ write_weights (unsigned total, const wfa_t *wfa, bitfile_t *output)
             c_symbols [i] = 1 << (wfa->wfainfo->rpf->mantissa_bits + 1);
         for (; i < offset4; i++)
             c_symbols [i] = 1 << (wfa->wfainfo->d_rpf->mantissa_bits + 1);
-      
+
         encode_array (output, weights_array, level_array, c_symbols, offset4,
                       total, scale);
         Free (c_symbols);
     }
-   
+
     debug_message ("%d delta weights out of %d.", delta_count, total);
     debug_message ("weights:      %5d bits. (%5d symbols => %5.2f bps)",
                    bits_processed (output) - bits, total,