Commit b57f18e9 authored by Monty's avatar Monty
Browse files

Correct numerous small bugs in new coupling engine


svn path=/trunk/vorbis/; revision=16950
parent 399301e3
......@@ -1062,7 +1062,7 @@ void _vp_couple_quantize_normalize(int blobno,
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 @@ void _vp_couple_quantize_normalize(int blobno,
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 @@ void _vp_couple_quantize_normalize(int blobno,
}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 @@ void _vp_couple_quantize_normalize(int blobno,
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 @@ void _vp_couple_quantize_normalize(int blobno,
}
}
}
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;
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment