summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNedeljko Babic <nbabic@mips.com>2012-03-27 12:45:05 +0200
committerNedeljko Babic <nbabic@mips.com>2012-04-03 15:38:03 +0200
commit80ca6dd0a063a59b974f0e59e451b9394da4ae47 (patch)
tree2ec7a85f83a43a9c173fdfc55abd3ed1d28da1bb
parentc2e70809a0c637cbfe6513ddb0344c246f933e43 (diff)
downloadtremor-80ca6dd0a063a59b974f0e59e451b9394da4ae47.tar.gz
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. [Impot changes from Tremor (3ada73c 2010-10-15)]
-rw-r--r--asm_arm.h10
-rw-r--r--floor0.c24
2 files changed, 19 insertions, 15 deletions
diff --git a/asm_arm.h b/asm_arm.h
index ed4225f..9b551f3 100644
--- a/asm_arm.h
+++ b/asm_arm.h
@@ -134,8 +134,9 @@ static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip,
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};"
@@ -158,9 +159,10 @@ static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip,
"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"
@@ -172,7 +174,7 @@ static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip,
"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"
@@ -186,7 +188,7 @@ static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip,
//}
/* normalize to max 16 sig figs */
- "2:"
+ "3:"
"mov r2,#0;"
"orr r1,%0,%1;"
"tst r1,#0xff000000;"
diff --git a/floor0.c b/floor0.c
index 6ac8566..d1d5c78 100644
--- a/floor0.c
+++ b/floor0.c
@@ -210,17 +210,19 @@ void vorbis_lsp_to_curve(ogg_int32_t *curve,int n,int ln,
#else
- 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;
+ j=1;
+ if(m>1){
+ qi*=labs(ilsp[0]-wi);
+ pi*=labs(ilsp[1]-wi);
+
+ 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]))