changeset 7195:5e5c1178ae9a libavcodec

Write for loops in a more standard way. In my opinion, they are much more readable now.
author vitor
date Fri, 04 Jul 2008 19:55:58 +0000
parents 8427f12555a6
children ab345b7d32ed
files ra288.c
diffstat 1 files changed, 32 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/ra288.c	Fri Jul 04 15:44:13 2008 +0000
+++ b/ra288.c	Fri Jul 04 19:55:58 2008 +0000
@@ -40,22 +40,27 @@
 /* Decode and produce output */
 static void decode(Real288_internal *glob, float gain, int cb_coef)
 {
-    unsigned int x, y;
+    int x, y;
     double sum, sumsum;
     float buffer[5];
 
-    for (x=36; x--; glob->sb[x+5] = glob->sb[x]);
+    for (x=35; x >= 0; x--)
+        glob->sb[x+5] = glob->sb[x];
 
-    for (x=5; x--;) {
+    for (x=4; x >= 0; x--) {
         float *p1 = glob->sb+x;
         float *p2 = glob->pr1;
-        for (sum=0, y=36; y--; sum -= (*(++p1))*(*(p2++)));
+        sum = 0;
+        for (y=0; y < 36; y++)
+            sum -= (*(++p1))*(*(p2++));
 
         glob->sb[x] = sum;
     }
 
     /* convert log and do rms */
-    for (sum=32, x=10; x--; sum -= glob->pr2[x] * glob->lhist[x]);
+    sum = 32;
+    for (x=0; x < 10; x++)
+        sum -= glob->pr2[x] * glob->lhist[x];
 
     if (sum < 0)
         sum = 0;
@@ -64,21 +69,25 @@
 
     sumsum = exp(sum * 0.1151292546497) * gain;    /* pow(10.0,sum/20)*f */
 
-    for (sum=0, x=5; x--;) {
+    sum = 0;
+    for (x=0; x < 5; x++) {
         buffer[x] = codetable[cb_coef][x] * sumsum;
         sum += buffer[x] * buffer[x];
     }
 
-    if ((sum /= 5) < 1)
+    sum /= 5;
+    if (sum < 1)
         sum = 1;
 
     /* shift and store */
-    for (x=10; --x; glob->lhist[x] = glob->lhist[x-1]);
+    for (x=10; x > 0; x--)
+        glob->lhist[x] = glob->lhist[x-1];
 
     *glob->lhist = glob->history[glob->phase] = 10 * log10(sum) - 32;
 
     for (x=1; x < 5; x++)
-        for (y=x; y--; buffer[x] -= glob->pr1[x-y-1] * buffer[y]);
+        for (y=x-1; y >= 0; y--)
+            buffer[x] -= glob->pr1[x-y-1] * buffer[y];
 
     /* output */
     for (x=0; x < 5; x++) {
@@ -119,7 +128,9 @@
             return 1;
 
         f1 = *(p1--);
-        for (y=x; --y; f1 += (*(p1--))*(*(p2++)));
+
+        for (y=0; y < x - 1; y++)
+            f1 += (*(p1--))*(*(p2++));
 
         p1 = tgt + x - 1;
         p2 = tgt;
@@ -143,7 +154,9 @@
     while (n >= 0) {
         float *p2 = src;
         float *p1 = p2 - n;
-        for (sum=0, x=len; x--; sum += (*p1++) * (*p2++));
+        sum = 0;
+        for (x=0; x < len; x++)
+            sum += (*p1++) * (*p2++);
         tgt[n--] = sum;
     }
 }
@@ -183,14 +196,18 @@
     float buffer1[40], temp1[37];
     float buffer2[8], temp2[11];
 
-    for (x=0, y=glob->phasep+5; x < 40; buffer1[x++] = glob->output[(y++)%40]);
+    y = glob->phasep+5;
+    for (x=0;  x < 40; x++)
+        buffer1[x] = glob->output[(y++)%40];
 
     co(36, 40, 35, buffer1, temp1, glob->st1a, glob->st1b, table1);
 
     if (pred(temp1, glob->st1, 36))
         colmult(glob->pr1, glob->st1, table1a, 36);
 
-    for (x=0, y=glob->phase + 1; x < 8; buffer2[x++] = glob->history[(y++) % 8]);
+    y = glob->phase + 1;
+    for (x=0; x < 8; x++)
+        buffer2[x] = glob->history[(y++) % 8];
 
     co(10, 8, 20, buffer2, temp2, glob->st2a, glob->st2b, table2);
 
@@ -223,7 +240,8 @@
         glob->phasep = (glob->phase = x & 7) * 5;
         decode(glob, gain, cb_coef);
 
-        for (y=0; y<5; *(out++) = 8 * glob->output[glob->phasep+(y++)]);
+        for (y=0; y < 5; y++)
+            *(out++) = 8 * glob->output[glob->phasep + y];
 
         if (glob->phase == 3)
             update(glob);