[FFmpeg-devel] [PATCH] Implement av_samples_fill_arrays().

Stefano Sabatini stefano.sabatini-lala
Sat Jan 15 02:27:03 CET 2011


---
 libavcore/audioconvert.c |   14 ++++++++++++++
 libavcore/audioconvert.h |   21 +++++++++++++++++++++
 2 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/libavcore/audioconvert.c b/libavcore/audioconvert.c
index 1c6a511..7a46a3e 100644
--- a/libavcore/audioconvert.c
+++ b/libavcore/audioconvert.c
@@ -166,3 +166,17 @@ int av_samples_fill_pointers(uint8_t *pointers[8], uint8_t *buf, int buf_size,
 
     return per_channel_size / sample_size;
 }
+
+int av_samples_fill_arrays(uint8_t *data[8], int linesizes[8],
+                           uint8_t *buf, int buf_size,
+                           enum AVSampleFormat sample_fmt, int planar,
+                           int64_t channel_layout, int nb_channels)
+{
+    int ret;
+    if ((ret = av_samples_fill_linesizes(linesizes, sample_fmt,
+                                         planar, channel_layout, nb_channels)) < 0)
+        return ret;
+
+    return av_samples_fill_pointers(data, buf, buf_size, sample_fmt,
+                                    planar, channel_layout, nb_channels);
+}
diff --git a/libavcore/audioconvert.h b/libavcore/audioconvert.h
index 297f147..7aa4c03 100644
--- a/libavcore/audioconvert.h
+++ b/libavcore/audioconvert.h
@@ -129,4 +129,25 @@ int av_samples_fill_pointers(uint8_t *pointers[8], uint8_t *buf, int buf_size,
                              enum AVSampleFormat sample_fmt, int planar,
                              int64_t channel_layout, int nb_channels);
 
+/**
+ * Fill channel data pointers and linesizes for samples with sample
+ * format sample_fmt.
+ *
+ * @param buf the pointer to a buffer containing the samples, must
+ * contain an integer number of samples
+ * @param buf_size the size of buf in bytes
+ * @param planar if >0 if the samples layout is planar, 0 if it is packed
+ * @param channel_layout flags which specify the channel layout, see
+ * AV_CH_LAYOUT_*, <= 0 if unknown
+ * @param nb_channels the number of channels, <=0 if unknown
+ * @param linesizes array to be filled with the linesize for each channel
+ * @return the number of samples in buf, a negative error code in case
+ * of failure
+ * @see av_samples_fill_pointers() and av_samples_fill_linesizes()
+ */
+int av_samples_fill_arrays(uint8_t *data[8], int linesizes[8],
+                           uint8_t *buf, int buf_size,
+                           enum AVSampleFormat sample_fmt, int planar,
+                           int64_t channel_layout, int nb_channels);
+
 #endif /* AVCORE_AUDIOCONVERT_H */
-- 
1.7.2.3




More information about the ffmpeg-devel mailing list