[gst-embedded] Calculating RAW Audio Buffer Size
Michael Smith
msmith at xiph.org
Tue Dec 23 10:11:39 PST 2008
On Tue, Dec 23, 2008 at 9:12 AM, Sameer Naik
<sameer.subscriptions at damagehead.com> wrote:
> Hi,
> I am writing a gstreamer plugin in which i need to calculate the raw audio
> buffer size for a give sample rate, channels, etc.
>
> for example if i have a mp3 frame with the following parameters:
> bitrate: 320Kbps
> sampling rate: 48000Hz
> Channels: 2
>
> How can i calculate the buffer size that would be required by the output buffer
> to store the raw decoded data for this frame? basically what is the formula
> for this calculation?
size = samples_per_frame * channels * width
You give channels here, so that's easy. Width depends on the format
you're decoding to - e.g. if you have 32 bit floating point samples,
width is 4 (bytes). If you have 16 bit samples, it's 2.
samples_per_frame is mp3-specific. It's either 1152 or 576, depending
on the bitrate (and layer, and whether it's using the "mpeg 2.5"
extensions. For 320 kbps mp3, it's 1152.
So: size = 1152 * 2 * sample_width
Mike
More information about the Gstreamer-embedded
mailing list