diff options
author | Stefano Sabatini <stefasab@gmail.com> | 2013-03-21 11:48:28 +0100 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2013-03-31 18:00:44 +0200 |
commit | 5c73645d91e6a91c849e08e0fc58bdeab9b7b76f (patch) | |
tree | 986d39f92a94a7334cce88ceae79a6c6d7e841ee /libavutil/samplefmt.c | |
parent | 39aad4346562e208ad494093e2995d9bc8fb3410 (diff) | |
download | ffmpeg-5c73645d91e6a91c849e08e0fc58bdeab9b7b76f.tar.gz |
lavu/samplefmt: add av_samples_alloc_array_and_pointers()
Diffstat (limited to 'libavutil/samplefmt.c')
-rw-r--r-- | libavutil/samplefmt.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libavutil/samplefmt.c b/libavutil/samplefmt.c index 6f762df9b4..445009745c 100644 --- a/libavutil/samplefmt.c +++ b/libavutil/samplefmt.c @@ -207,6 +207,21 @@ int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels, #endif } +int av_samples_alloc_array_and_samples(uint8_t ***audio_data, int *linesize, int nb_channels, + int nb_samples, enum AVSampleFormat sample_fmt, int align) +{ + int ret, nb_planes = av_sample_fmt_is_planar(sample_fmt) ? nb_channels : 1; + + *audio_data = av_calloc(nb_planes, sizeof(*audio_data)); + if (!*audio_data) + return AVERROR(ENOMEM); + ret = av_samples_alloc(*audio_data, linesize, nb_channels, + nb_samples, sample_fmt, align); + if (ret < 0) + av_freep(audio_data); + return ret; +} + int av_samples_copy(uint8_t **dst, uint8_t * const *src, int dst_offset, int src_offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt) |