mirror of https://bitbucket.org/ausocean/av.git
ADPCM: fixed conversions and calculations for block variables
This commit is contained in:
parent
48e848b7c4
commit
1ad2195938
|
@ -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++ {
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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++ {
|
||||
|
|
Loading…
Reference in New Issue