[FFmpeg-devel] [PATCH] examples/resampling_audio: make use of av_samples_alloc_pointers()
Stefano Sabatini
stefasab at gmail.com
Thu Mar 21 20:54:38 CET 2013
Simplify.
---
doc/examples/resampling_audio.c | 16 ++--------------
1 file changed, 2 insertions(+), 14 deletions(-)
diff --git a/doc/examples/resampling_audio.c b/doc/examples/resampling_audio.c
index dd128e8..7f057e2 100644
--- a/doc/examples/resampling_audio.c
+++ b/doc/examples/resampling_audio.c
@@ -78,18 +78,6 @@ void fill_samples(double *dst, int nb_samples, int nb_channels, int sample_rate,
}
}
-int alloc_samples_array_and_data(uint8_t ***data, int *linesize, int nb_channels,
- int nb_samples, enum AVSampleFormat sample_fmt, int align)
-{
- int nb_planes = av_sample_fmt_is_planar(sample_fmt) ? nb_channels : 1;
-
- *data = av_malloc(sizeof(*data) * nb_planes);
- if (!*data)
- return AVERROR(ENOMEM);
- return av_samples_alloc(*data, linesize, nb_channels,
- nb_samples, sample_fmt, align);
-}
-
int main(int argc, char **argv)
{
int64_t src_ch_layout = AV_CH_LAYOUT_STEREO, dst_ch_layout = AV_CH_LAYOUT_SURROUND;
@@ -164,8 +152,8 @@ int main(int argc, char **argv)
/* buffer is going to be directly written to a rawaudio file, no alignment */
dst_nb_channels = av_get_channel_layout_nb_channels(dst_ch_layout);
- ret = alloc_samples_array_and_data(&dst_data, &dst_linesize, dst_nb_channels,
- dst_nb_samples, dst_sample_fmt, 0);
+ ret = av_samples_alloc_pointers(&dst_data, &dst_linesize, dst_nb_channels,
+ dst_nb_samples, dst_sample_fmt, 0);
if (ret < 0) {
fprintf(stderr, "Could not allocate destination samples\n");
goto end;
--
1.7.9.5
More information about the ffmpeg-devel
mailing list