[Libav-user] libswresample, packed samples and alignment
Brad O'Hearne
brado at bighillsoftware.com
Wed Mar 27 21:00:49 CET 2013
On Mar 26, 2013, at 12:14 PM, Brad O'Hearne <brado at bighillsoftware.com> wrote:
> Hello,
>
> I've noticed that several functions in samplefmt.h take an "align" parameter, such as the function calls:
>
> int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels,
> int nb_samples, enum AVSampleFormat sample_fmt, int align);
>
> int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
> enum AVSampleFormat sample_fmt, int align);
>
> int av_samples_fill_arrays(uint8_t **audio_data, int *linesize,
> const uint8_t *buf,
> int nb_channels, int nb_samples,
> enum AVSampleFormat sample_fmt, int align);
>
> This align parameter has the following description:
>
> * @param align buffer size alignment (0 = default, 1 = no alignment)
>
> I want to make sure that I'm properly understanding the purpose and setting of this parameter. As I understand it, a sample is "packed" if its sample bits occupy the entire available bits for the channel. If a sample's bits do not occupy the entire available bits for the channel it is not packed, and then the data is either high or low-aligned within the channel.
>
> In the case of my app, my sample format of captured audio is:
>
> Linear PCM, 32 bit little-endian floating point, 2 channels, 44100 Hz
>
> and this data IS indeed packed, meaning that there is neither high nor low alignment. In setting the appropriate align value for the aforementioned functions, I have two questions:
>
> 1. What is "default" alignment according to the documentation? Is that high or low, or something else?
>
> 2. Based on my captured sample data being packed, shouldn't this mean that there is NO alignment, and therefore the value for these method invocations be 1?
This is essentially a "bump" given my reference to this issue in my post in another thread, but I'll add the detail that I revisited the resampling_audio.c example and I noticed that both 0 and 1 align parameter values are being used, and I wasn't completely clear as to why. If someone could speak to the questions I asked above, this would help to clear up the principle of the issue, plus it might have a bearing on the bigger audio problem I'm having.
Thanks,
Brad
More information about the Libav-user
mailing list