diff --git a/cmd/adpcm/decode-pcm/decode-pcm.go b/cmd/adpcm/decode-pcm/decode-pcm.go index 45a27f90..f664141f 100644 --- a/cmd/adpcm/decode-pcm/decode-pcm.go +++ b/cmd/adpcm/decode-pcm/decode-pcm.go @@ -54,7 +54,7 @@ func main() { // decode adpcm inBSize := 256 - numBlocks := int(len(comp) / inBSize) + numBlocks := len(comp) / inBSize outBSize := 2 + (inBSize-4)*4 // 2 bytes are copied, 2 are used as block header info, the remaining bytes are decompressed 1:4 decoded := make([]byte, 0, outBSize*numBlocks) for i := 0; i < numBlocks; i++ { diff --git a/cmd/adpcm/encode-pcm/encode-pcm.go b/cmd/adpcm/encode-pcm/encode-pcm.go index a014ef53..8da0aa77 100644 --- a/cmd/adpcm/encode-pcm/encode-pcm.go +++ b/cmd/adpcm/encode-pcm/encode-pcm.go @@ -54,8 +54,8 @@ func main() { //encode adpcm inBSize := 1010 - numBlocks := int(len(pcm) / inBSize) - outBSize := int(float32(inBSize/4) + float32(3.5)) // compression is 4:1 and 3.5 bytes of info are added to each block + numBlocks := len(pcm) / inBSize + outBSize := int(float64(inBSize)/4 + 3.5) // compression is 4:1 and 3.5 bytes of info are added to each block comp := make([]byte, 0, outBSize*numBlocks) for i := 0; i < numBlocks; i++ { block := pcm[inBSize*i : inBSize*(i+1)] diff --git a/stream/adpcm/adpcm_test.go b/stream/adpcm/adpcm_test.go index e9cb05aa..5e991ddc 100644 --- a/stream/adpcm/adpcm_test.go +++ b/stream/adpcm/adpcm_test.go @@ -45,8 +45,8 @@ func TestEncodeBlock(t *testing.T) { //encode adpcm inBSize := 1010 - numBlocks := int(len(pcm) / inBSize) - outBSize := int(float32(inBSize/4) + float32(3.5)) // compression is 4:1 and 3.5 bytes of info are added to each block + numBlocks := len(pcm) / inBSize + outBSize := int(float64(inBSize)/4 + 3.5) // compression is 4:1 and 3.5 bytes of info are added to each block comp := make([]byte, 0, outBSize*numBlocks) for i := 0; i < numBlocks; i++ { block := pcm[inBSize*i : inBSize*(i+1)] @@ -79,7 +79,7 @@ func TestDecodeBlock(t *testing.T) { //decode adpcm inBSize := 256 - numBlocks := int(len(comp) / inBSize) + numBlocks := len(comp) / inBSize outBSize := 2 + (inBSize-4)*4 // 2 bytes are copied, 2 are used as block header info, the remaining bytes are decompressed 1:4 decoded := make([]byte, 0, outBSize*numBlocks) for i := 0; i < numBlocks; i++ {