From c089980175afabdc7694c7829fe6334dc3df9311 Mon Sep 17 00:00:00 2001 From: Trek H Date: Fri, 26 Apr 2019 20:28:53 +0930 Subject: [PATCH] adpcm: added function for calculating number of adpcm bytes output per given pcm bytes --- codec/adpcm/adpcm.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/codec/adpcm/adpcm.go b/codec/adpcm/adpcm.go index f32c8875..58942f74 100644 --- a/codec/adpcm/adpcm.go +++ b/codec/adpcm/adpcm.go @@ -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 +}