[gst-embedded] Calculating RAW Audio Buffer Size

Sameer Naik sameer.subscriptions at damagehead.com
Tue Dec 23 21:22:42 PST 2008


Thanks a lot Mike, thats just what i needed to know.
 
to confirm, the samples_per_frame for mp3 frames can be either 1152 or 576. So 
basically a buffer of (1152 * width * channels) size should handle all (mpeg1, 
layer{1,2,3}) cases, right!

Secondly, how would the buffer size calculation go for AAC-HE audio frames, for 
say bitrate:320Kbps
channels: 2
sampling rate: 48000Hz
width: 16bits

Thanks again for all your help.

Regards
~Sameer

On Tuesday 23 December 2008 11:41:39 pm Michael Smith wrote:
> 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