[xiph-commits] r17538 - in trunk: Tremor vorbis/lib

tterribe at svn.xiph.org tterribe at svn.xiph.org
Thu Oct 14 19:52:29 PDT 2010


Author: tterribe
Date: 2010-10-14 19:52:29 -0700 (Thu, 14 Oct 2010)
New Revision: 17538

Modified:
   trunk/Tremor/asm_arm.h
   trunk/Tremor/floor0.c
   trunk/vorbis/lib/lsp.c
Log:
Fix decoder handling of floor0 when the LSP order is 1.

Header setup allows the LSP order to be as low as one, but the code in
 vorbis_lsp_to_curve() assumed it was at least two.
This wasn't terrible in libvorbis... it would multiply a nonsense (but defined)
 value into the output, and nothing more.
In Tremor, it referenced several completely undefined (stack) values, which
 could cause out-of-bounds lookup table accesses and crashes.


Modified: trunk/Tremor/asm_arm.h
===================================================================
--- trunk/Tremor/asm_arm.h	2010-10-14 17:26:48 UTC (rev 17537)
+++ trunk/Tremor/asm_arm.h	2010-10-15 02:52:29 UTC (rev 17538)
@@ -132,8 +132,9 @@
   ogg_int32_t qexp=*qexpp;
 
   asm("mov     r0,%3;"
-      "mov     r1,%5,asr#1;"
+      "movs    r1,%5,asr#1;"
       "add     r0,r0,r1,lsl#3;"
+      "beq 2f;\n"
       "1:"
       
       "ldmdb   r0!,{r1,r3};"
@@ -156,9 +157,10 @@
       "cmp     r0,%3;\n"
       "bhi     1b;\n"
       
+      "2:"
       // odd filter assymetry
       "ands    r0,%5,#1;\n"
-      "beq     2f;\n"
+      "beq     3f;\n"
       "add     r0,%3,%5,lsl#2;\n"
       
       "ldr     r1,[r0,#-4];\n"
@@ -170,7 +172,7 @@
       "umull   %1,r3,r0,%1;\n"       //pi*=labs(ilsp[j+1]-wi)
       
       "cmn     r2,r3;\n"             // shift down 16?
-      "beq     2f;\n"
+      "beq     3f;\n"
       "add     %2,%2,#16;\n"
       "mov     %0,%0,lsr #16;\n"
       "orr     %0,%0,r2,lsl #16;\n"
@@ -184,7 +186,7 @@
       //}
 	 
       /* normalize to max 16 sig figs */
-      "2:"
+      "3:"
       "mov     r2,#0;"
       "orr     r1,%0,%1;"
       "tst     r1,#0xff000000;"

Modified: trunk/Tremor/floor0.c
===================================================================
--- trunk/Tremor/floor0.c	2010-10-14 17:26:48 UTC (rev 17537)
+++ trunk/Tremor/floor0.c	2010-10-15 02:52:29 UTC (rev 17538)
@@ -197,16 +197,19 @@
 
 #else
 
-    qi*=labs(ilsp[0]-wi);
-    pi*=labs(ilsp[1]-wi);
+    j=1;
+    if(m>1){
+      qi*=labs(ilsp[0]-wi);
+      pi*=labs(ilsp[1]-wi);
 
-    for(j=3;j<m;j+=2){
-      if(!(shift=MLOOP_1[(pi|qi)>>25]))
-	if(!(shift=MLOOP_2[(pi|qi)>>19]))
-	  shift=MLOOP_3[(pi|qi)>>16];
-      qi=(qi>>shift)*labs(ilsp[j-1]-wi);
-      pi=(pi>>shift)*labs(ilsp[j]-wi);
-      qexp+=shift;
+      for(j+=2;j<m;j+=2){
+        if(!(shift=MLOOP_1[(pi|qi)>>25]))
+          if(!(shift=MLOOP_2[(pi|qi)>>19]))
+            shift=MLOOP_3[(pi|qi)>>16];
+        qi=(qi>>shift)*labs(ilsp[j-1]-wi);
+        pi=(pi>>shift)*labs(ilsp[j]-wi);
+        qexp+=shift;
+      }
     }
     if(!(shift=MLOOP_1[(pi|qi)>>25]))
       if(!(shift=MLOOP_2[(pi|qi)>>19]))

Modified: trunk/vorbis/lib/lsp.c
===================================================================
--- trunk/vorbis/lib/lsp.c	2010-10-14 17:26:48 UTC (rev 17537)
+++ trunk/vorbis/lib/lsp.c	2010-10-15 02:52:29 UTC (rev 17538)
@@ -81,11 +81,11 @@
     float *ftmp=lsp;
     int c=m>>1;
 
-    do{
+    while(c--){
       q*=ftmp[0]-w;
       p*=ftmp[1]-w;
       ftmp+=2;
-    }while(--c);
+    }
 
     if(m&1){
       /* odd order filter; slightly assymetric */



More information about the commits mailing list