[MN-dev] [mndiff]: r103 - trunk/noe/rs.c

michael subversion at mplayerhq.hu
Wed Oct 22 08:58:31 CEST 2008


Author: michael
Date: Wed Oct 22 08:58:31 2008
New Revision: 103

Log:
optimize rsTransform()


Modified:
   trunk/noe/rs.c

Modified: trunk/noe/rs.c
==============================================================================
--- trunk/noe/rs.c	(original)
+++ trunk/noe/rs.c	Wed Oct 22 08:58:31 2008
@@ -73,8 +73,9 @@ int EXT(rsTransform)(GFF4Element *data, 
     GFF4Element temp[SIZE-1];
     char *stats= (char*)temp;
     GFF4Element t= data[ tLocation ];
+    int statsSize= encode ? parityCount + t + 1 : t;
 
-    if(tLocation<0 || tLocation>=dataCount)
+    if(tLocation<0 || tLocation>=dataCount || statsSize>SIZE)
         return -1;
 
     if(tPoly[0]<=0){
@@ -84,20 +85,21 @@ int EXT(rsTransform)(GFF4Element *data, 
         memcpy(tPoly, temp + dataCount, parityCount*sizeof(GFF4Element));
     }
 
-    memset(stats, 0, SIZE);
+    memset(stats, 0, statsSize);
 
     for(i=0; i<parityCount; i++){
         GFF4Element p= diff(data[i+dataCount], prod(tPoly[i], t));
 
-        stats[ prod(MINUS1 - p, inv(tPoly[i])) ]=1; //FIXME get rid of the neg
+        j= prod(MINUS1 - p, inv(tPoly[i]));  //FIXME get rid of the neg
+        if(j<statsSize)
+            stats[j]=1;
     }
 
     if(encode){
         for(j=i=0; i<SIZE && j<=t; i++)
             j+= !stats[i];
         i--;
-        if(i>=SIZE)
-            return -1;
+        assert(i<SIZE);
     }else{
         for(j=i=0; j<t; j++)
             i+= stats[j]^1;



More information about the Mndiff-dev mailing list