[xiph-commits] r16950 - trunk/vorbis/lib

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Thu Mar 4 10:21:43 PST 2010


Author: xiphmont
Date: 2010-03-04 10:21:43 -0800 (Thu, 04 Mar 2010)
New Revision: 16950

Modified:
   trunk/vorbis/lib/psy.c
Log:
Correct numerous small bugs in new coupling engine



Modified: trunk/vorbis/lib/psy.c
===================================================================
--- trunk/vorbis/lib/psy.c	2010-03-04 17:53:03 UTC (rev 16949)
+++ trunk/vorbis/lib/psy.c	2010-03-04 18:21:43 UTC (rev 16950)
@@ -1062,7 +1062,7 @@
     int k,j,jn = partition > n-i ? n-i : partition;
     int step,track = 0;
 
-    memcpy(nz,nonzero,sizeof(nz));
+    memcpy(nz,nonzero,sizeof(*nz)*ch);
 
     /* prefill */
     memset(flag[0],0,ch*partition*sizeof(**flag));
@@ -1077,7 +1077,7 @@
 
         for(j=0;j<jn;j++){
           quant[k][j] = raw[k][j] = mdct[k][i+j]*mdct[k][i+j];
-          if(mdct[k][i+j]<0) raw[k][j]*=-1.f;
+          if(mdct[k][i+j]<0.f) raw[k][j]*=-1.f;
           floor[k][j]*=floor[k][j];
         }
 
@@ -1085,7 +1085,7 @@
 
       }else{
         for(j=0;j<jn;j++){
-          floor[k][j] = 0.f;
+          floor[k][j] = 1e-10f;
           raw[k][j] = 0.f;
           quant[k][j] = 0.f;
           flag[k][j] = 0;
@@ -1129,19 +1129,23 @@
                 int A = iM[j];
                 int B = iA[j];
 
-                iA[j]=(A>abs(B)||B>abs(A) ? A-B : B-A);
-                if(abs(B)>abs(A))iM[j]=B;
+                if(abs(A)>abs(B)){
+                  iA[j]=(A>0?A-B:B-A);
+                }else{
+                  iA[j]=(B>0?A-B:B-A);
+                  iM[j]=B;
+                }
 
                 /* collapse two equivalent tuples to one */
-                if(abs(iM[j])*2==iA[j]){
+                if(iA[j]>=abs(iM[j])*2){
                   iA[j]= -iA[j];
                   iM[j]= -iM[j];
                 }
+
               }
 
             }else{
               /* lossy (point) coupling */
-
               if(j<limit-i){
                 /* dipole */
                 reM[j] += reA[j];
@@ -1175,4 +1179,14 @@
       }
     }
   }
+
+  for(i=0;i<vi->coupling_steps;i++){
+    /* make sure coupling a zero and a nonzero channel results in two
+       nonzero channels. */
+    if(nonzero[vi->coupling_mag[i]] ||
+       nonzero[vi->coupling_ang[i]]){
+      nonzero[vi->coupling_mag[i]]=1;
+      nonzero[vi->coupling_ang[i]]=1;
+    }
+  }
 }



More information about the commits mailing list