audio/internal/convert/resampling: Better boundary check

This commit is contained in:
Hajime Hoshi 2017-07-12 00:40:15 +09:00
parent 8912563555
commit 1828830b4a

View File

@ -131,12 +131,12 @@ func (r *Resampling) at(t int64) (float64, float64, error) {
if startN < 0 { if startN < 0 {
startN = 0 startN = 0
} }
if r.size/4 < startN { if r.size/4 <= startN {
startN = r.size / 4 startN = r.size/4 - 1
} }
endN := int64(tInSrc) + windowSize + 1 endN := int64(tInSrc) + windowSize + 1
if r.size/4 < endN { if r.size/4 <= endN {
endN = r.size / 4 endN = r.size/4 - 1
} }
lv := 0.0 lv := 0.0
rv := 0.0 rv := 0.0