]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - lib_generic/bzlib_huffman.c
* Patches by Xianghua Xiao, 15 Oct 2003:
[people/ms/u-boot.git] / lib_generic / bzlib_huffman.c
index 6cf336e3607e9684baa9ac25dae6ab2420f21cdd..effae98a733d1aba691c5aa66104afe214167fca 100644 (file)
@@ -91,8 +91,8 @@
       yy = zz << 1;                                   \
       if (yy > nHeap) break;                          \
       if (yy < nHeap &&                               \
-          weight[heap[yy+1]] < weight[heap[yy]])      \
-         yy++;                                        \
+         weight[heap[yy+1]] < weight[heap[yy]])      \
+        yy++;                                        \
       if (weight[tmp] < weight[heap[yy]]) break;      \
       heap[zz] = heap[yy];                            \
       zz = yy;                                        \
 
 /*---------------------------------------------------*/
 void BZ2_hbMakeCodeLengths ( UChar *len,
-                             Int32 *freq,
-                             Int32 alphaSize,
-                             Int32 maxLen )
+                            Int32 *freq,
+                            Int32 alphaSize,
+                            Int32 maxLen )
 {
    /*--
       Nodes and heap entries run from 1.  Entry 0
@@ -131,43 +131,43 @@ void BZ2_hbMakeCodeLengths ( UChar *len,
       parent[0] = -2;
 
       for (i = 1; i <= alphaSize; i++) {
-         parent[i] = -1;
-         nHeap++;
-         heap[nHeap] = i;
-         UPHEAP(nHeap);
+        parent[i] = -1;
+        nHeap++;
+        heap[nHeap] = i;
+        UPHEAP(nHeap);
       }
 
       AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 );
 
       while (nHeap > 1) {
-         n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
-         n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
-         nNodes++;
-         parent[n1] = parent[n2] = nNodes;
-         weight[nNodes] = ADDWEIGHTS(weight[n1], weight[n2]);
-         parent[nNodes] = -1;
-         nHeap++;
-         heap[nHeap] = nNodes;
-         UPHEAP(nHeap);
+        n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
+        n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
+        nNodes++;
+        parent[n1] = parent[n2] = nNodes;
+        weight[nNodes] = ADDWEIGHTS(weight[n1], weight[n2]);
+        parent[nNodes] = -1;
+        nHeap++;
+        heap[nHeap] = nNodes;
+        UPHEAP(nHeap);
       }
 
       AssertH( nNodes < (BZ_MAX_ALPHA_SIZE * 2), 2002 );
 
       tooLong = False;
       for (i = 1; i <= alphaSize; i++) {
-         j = 0;
-         k = i;
-         while (parent[k] >= 0) { k = parent[k]; j++; }
-         len[i-1] = j;
-         if (j > maxLen) tooLong = True;
+        j = 0;
+        k = i;
+        while (parent[k] >= 0) { k = parent[k]; j++; }
+        len[i-1] = j;
+        if (j > maxLen) tooLong = True;
       }
 
       if (! tooLong) break;
 
       for (i = 1; i < alphaSize; i++) {
-         j = weight[i] >> 8;
-         j = 1 + (j / 2);
-         weight[i] = j << 8;
+        j = weight[i] >> 8;
+        j = 1 + (j / 2);
+        weight[i] = j << 8;
       }
    }
 }
@@ -175,17 +175,17 @@ void BZ2_hbMakeCodeLengths ( UChar *len,
 
 /*---------------------------------------------------*/
 void BZ2_hbAssignCodes ( Int32 *code,
-                         UChar *length,
-                         Int32 minLen,
-                         Int32 maxLen,
-                         Int32 alphaSize )
+                        UChar *length,
+                        Int32 minLen,
+                        Int32 maxLen,
+                        Int32 alphaSize )
 {
    Int32 n, vec, i;
 
    vec = 0;
    for (n = minLen; n <= maxLen; n++) {
       for (i = 0; i < alphaSize; i++)
-         if (length[i] == n) { code[i] = vec; vec++; };
+        if (length[i] == n) { code[i] = vec; vec++; };
       vec <<= 1;
    }
 }
@@ -193,19 +193,19 @@ void BZ2_hbAssignCodes ( Int32 *code,
 
 /*---------------------------------------------------*/
 void BZ2_hbCreateDecodeTables ( Int32 *limit,
-                                Int32 *base,
-                                Int32 *perm,
-                                UChar *length,
-                                Int32 minLen,
-                                Int32 maxLen,
-                                Int32 alphaSize )
+                               Int32 *base,
+                               Int32 *perm,
+                               UChar *length,
+                               Int32 minLen,
+                               Int32 maxLen,
+                               Int32 alphaSize )
 {
    Int32 pp, i, j, vec;
 
    pp = 0;
    for (i = minLen; i <= maxLen; i++)
       for (j = 0; j < alphaSize; j++)
-         if (length[j] == i) { perm[pp] = j; pp++; };
+        if (length[j] == i) { perm[pp] = j; pp++; };
 
    for (i = 0; i < BZ_MAX_CODE_LEN; i++) base[i] = 0;
    for (i = 0; i < alphaSize; i++) base[length[i]+1]++;