adpcm: added function for calculating number of adpcm bytes output per given pcm bytes

This commit is contained in:
Trek H 2019-04-26 20:28:53 +09:30
parent a9b1891bbb
commit c089980175
1 changed files with 7 additions and 0 deletions

View File

@ -390,3 +390,10 @@ func (d *decoder) Write(inAdpcm []byte) (int, error) {
return n, nil
}
// BytesOutput will return the number of adpcm bytes that will be generated for the given pcm data
func BytesOutput(pcm int) int {
// for X pcm bytes, 2 bytes are left uncompressed, the rest is compressed by a factor of 4
// and a start index and padding byte are added.
return (pcm-2)/4 + 2 + 1 + 1
}