Protect against possible bounds error in Q65 snr calculation.

This commit is contained in:
Joe Taylor 2021-03-17 09:23:24 -04:00
parent 0107901be9
commit d2b4fdad5f

View File

@ -678,8 +678,8 @@ subroutine q65_snr(dat4,dtdec,f0dec,mode_q65,nused,snr2)
i0=nint(f0dec/df)
nsum=max(10*mode_q65,nint(50.0/df))
ia=i0 - 2*nsum
ib=i0 + 2*nsum
ia=max(1,i0-2*nsum)
ib=min(iz0,i0+2*nsum)
sum1=sum(spec(ia:ia+nsum-1))
sum2=sum(spec(ib-nsum+1:ib))
avg=(sum1+sum2)/(2.0*nsum)