[gst-embedded] Calculating RAW Audio Buffer Size From: Sameer Naik - 2008-12-23 17:26:17 ```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? Thanks in advance Regards ~Sameer ```
 Re: [gst-embedded] Calculating RAW Audio Buffer Size From: Michael Smith - 2008-12-23 18:11:43 ```On Tue, Dec 23, 2008 at 9:12 AM, Sameer Naik 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 ```
 Re: [gst-embedded] Calculating RAW Audio Buffer Size From: Sameer Naik - 2008-12-24 05:45:19 ```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 > > 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 ```
 Re: [gst-embedded] Calculating RAW Audio Buffer Size From: Michael Smith - 2008-12-24 06:19:36 ```On Tue, Dec 23, 2008 at 9:22 PM, Sameer Naik wrote: > 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! Correct. > > Secondly, how would the buffer size calculation go for AAC-HE audio frames, for > say bitrate:320Kbps > channels: 2 > sampling rate: 48000Hz > width: 16bits You'd need to refer to the AAC-HE specification; I don't have a copy so I can't do this, to see what the possible frame sizes are. Mike ```
 Re: [gst-embedded] Calculating RAW Audio Buffer Size From: ved kpl - 2008-12-24 06:53:00 ```Hi, For Layer 1 it is 384 samples per frame I guess, which is neways obsolete now :) For AAC HE I think it is 1024 samples per frame. (1024 * sample_width * channels.) You can refer gst-plugins-bad-0.10.8/ext/faad/gstfaad.c Ved On Wed, Dec 24, 2008 at 11:49 AM, Michael Smith wrote: > On Tue, Dec 23, 2008 at 9:22 PM, Sameer Naik > wrote: >> 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! > > Correct. > >> >> Secondly, how would the buffer size calculation go for AAC-HE audio frames, for >> say bitrate:320Kbps >> channels: 2 >> sampling rate: 48000Hz >> width: 16bits > > You'd need to refer to the AAC-HE specification; I don't have a copy > so I can't do this, to see what the possible frame sizes are. > > Mike > > ------------------------------------------------------------------------------ > _______________________________________________ > Gstreamer-embedded mailing list > Gstreamer-embedded@... > https://lists.sourceforge.net/lists/listinfo/gstreamer-embedded > ```