summaryrefslogtreecommitdiff
path: root/floor1.c
diff options
context:
space:
mode:
authorMonty <xiphmont@xiph.org>2007-06-21 04:45:02 +0000
committerMonty <xiphmont@xiph.org>2007-06-21 04:45:02 +0000
commit1f1e23ac32fc806efbe90507a8c8e5c360e23f96 (patch)
tree4472f91d7dc90ad4b528f97771c514e2ffe11ad6 /floor1.c
parent2add9160a69a69f40216c5df60638a0ddc7cceee (diff)
downloadtremor-1f1e23ac32fc806efbe90507a8c8e5c360e23f96.tar.gz
Add proper guarding to cases where declared floor/residue decode size
is *larger* than the current blocksize. Handle according to spec. git-svn-id: https://svn.xiph.org/trunk/Tremor@13156 0101bb08-14d6-0310-b084-bc0e0c8e3800
Diffstat (limited to 'floor1.c')
-rw-r--r--floor1.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/floor1.c b/floor1.c
index 80c6dd2..276ed8d 100644
--- a/floor1.c
+++ b/floor1.c
@@ -282,7 +282,7 @@ static const ogg_int32_t FLOOR_fromdB_LOOKUP[256]={
XdB(0x69f80e9a), XdB(0x70dafda8), XdB(0x78307d76), XdB(0x7fffffff),
};
-static void render_line(int x0,int x1,int y0,int y1,ogg_int32_t *d){
+static void render_line(int n, int x0,int x1,int y0,int y1,ogg_int32_t *d){
int dy=y1-y0;
int adx=x1-x0;
int ady=abs(dy);
@@ -292,11 +292,13 @@ static void render_line(int x0,int x1,int y0,int y1,ogg_int32_t *d){
int y=y0;
int err=0;
+ if(n>x1)n=x1;
ady-=abs(base*adx);
- d[x]= MULT31_SHIFT15(d[x],FLOOR_fromdB_LOOKUP[y]);
+ if(x<n)
+ d[x]= MULT31_SHIFT15(d[x],FLOOR_fromdB_LOOKUP[y]);
- while(++x<x1){
+ while(++x<n){
err=err+ady;
if(err>=adx){
err-=adx;
@@ -418,7 +420,7 @@ static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo,
hy*=info->mult;
hx=info->postlist[current];
- render_line(lx,hx,ly,hy,out);
+ render_line(n,lx,hx,ly,hy,out);
lx=hx;
ly=hy;