History

lavu/samplefmt: add av_samples_alloc_array_and_pointers()

Stefano Sabatini committed 13 years ago

Commit 5c736451 parent 39aad434 files · +32 −1Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavutil/samplefmt.c +15 −0
  3. libavutil/samplefmt.h +13 −0
  4. libavutil/version.h +1 −1
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2012-10-22 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2013-03-30 - xxxxxxx - lavu 52.24.100 - samplefmt.h
19+ Add av_samples_alloc_array_and_samples().
20+
1821 2013-03-29 - xxxxxxx - lavf 55.1.100 - avformat.h
1922 Add av_guess_frame_rate()
2023
libavutil/samplefmt.c+15−0
@@ -207,6 +207,21 @@ int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels, · 206 unmodified lines
207207 #endif
208208 }
209209
210+int av_samples_alloc_array_and_samples(uint8_t ***audio_data, int *linesize, int nb_channels,
211+ int nb_samples, enum AVSampleFormat sample_fmt, int align)
212+{
213+ int ret, nb_planes = av_sample_fmt_is_planar(sample_fmt) ? nb_channels : 1;
214+
215+ *audio_data = av_calloc(nb_planes, sizeof(*audio_data));
216+ if (!*audio_data)
217+ return AVERROR(ENOMEM);
218+ ret = av_samples_alloc(*audio_data, linesize, nb_channels,
219+ nb_samples, sample_fmt, align);
220+ if (ret < 0)
221+ av_freep(audio_data);
222+ return ret;
223+}
224+
210225 int av_samples_copy(uint8_t **dst, uint8_t * const *src, int dst_offset,
211226 int src_offset, int nb_samples, int nb_channels,
212227 enum AVSampleFormat sample_fmt)
libavutil/samplefmt.h+13−0
@@ -209,10 +209,23 @@ int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, · 208 unmodified lines
209209 * @return >=0 on success or a negative error code on failure
210210 * @todo return the size of the allocated buffer in case of success at the next bump
211211 * @see av_samples_fill_arrays()
212+ * @see av_samples_alloc_array_and_samples()
212213 */
213214 int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels,
214215 int nb_samples, enum AVSampleFormat sample_fmt, int align);
215216
217+/**
218+ * Allocate a data pointers array, samples buffer for nb_samples
219+ * samples, and fill data pointers and linesize accordingly.
220+ *
221+ * This is the same as av_samples_alloc(), but also allocates the data
222+ * pointers array.
223+ *
224+ * @see av_samples_alloc()
225+ */
226+int av_samples_alloc_array_and_samples(uint8_t ***audio_data, int *linesize, int nb_channels,
227+ int nb_samples, enum AVSampleFormat sample_fmt, int align);
228+
216229 /**
217230 * Copy samples from src to dst.
218231 *
libavutil/version.h+1−1
@@ -75,7 +75,7 @@ · 74 unmodified lines
7575 */
7676
7777 #define LIBAVUTIL_VERSION_MAJOR 52
78−#define LIBAVUTIL_VERSION_MINOR 23
78+#define LIBAVUTIL_VERSION_MINOR 24
7979 #define LIBAVUTIL_VERSION_MICRO 100
8080
8181 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t