[vlc-devel] [PATCH 1/5] aout: add aout_Interleave() helper for interleaving (cherry picked from commit 861e38b0fce9a5f74e99f9b203648379ad09e69d)
Rafaël Carré
funman at videolan.org
Sun Feb 10 15:57:34 CET 2013
From: Rémi Denis-Courmont <remi at remlab.net>
Conflicts:
src/libvlccore.sym
---
include/vlc_aout.h | 3 +++
src/audio_output/common.c | 36 ++++++++++++++++++++++++++++++++++++
src/libvlccore.sym | 1 +
3 files changed, 40 insertions(+)
diff --git a/include/vlc_aout.h b/include/vlc_aout.h
index fe0d355..ffc8e06 100644
--- a/include/vlc_aout.h
+++ b/include/vlc_aout.h
@@ -213,6 +213,9 @@ static const uint32_t pi_vlc_chan_order_wg4[] =
VLC_API int aout_CheckChannelReorder( const uint32_t *pi_chan_order_in, const uint32_t *pi_chan_order_out, uint32_t i_channel_mask, int i_channels, int *pi_chan_table );
VLC_API void aout_ChannelReorder( uint8_t *, int, int, const int *, int );
+VLC_API void aout_Interleave(void *dst, const void *src, unsigned samples,
+ unsigned channels, vlc_fourcc_t fourcc);
+
/**
* This fonction will compute the extraction parameter into pi_selection to go
* from i_channels with their type given by pi_order_src[] into the order
diff --git a/src/audio_output/common.c b/src/audio_output/common.c
index b8900ab..fe8e84c 100644
--- a/src/audio_output/common.c
+++ b/src/audio_output/common.c
@@ -650,6 +650,42 @@ void aout_ChannelReorder( uint8_t *p_buf, int i_buffer,
}
}
+/**
+ * Interleaves audio samples within a block of samples.
+ * \param dst destination buffer for interleaved samples
+ * \param src source buffer with consecutive planes of samples
+ * \param samples number of samples (per channel/per plane)
+ * \param chans channels/planes count
+ * \param fourcc sample format (must be a linear sample format)
+ * \note The samples must be naturally aligned in memory.
+ * \warning Destination and source buffers MUST NOT overlap.
+ */
+void aout_Interleave( void *restrict dst, const void *restrict src,
+ unsigned samples, unsigned chans, vlc_fourcc_t fourcc )
+{
+#define INTERLEAVE_TYPE(type) \
+do { \
+ type *d = dst; \
+ const type *s = src; \
+ for( size_t i = 0; i < chans; i++ ) { \
+ for( size_t j = 0, k = 0; j < samples; j++, k += chans ) \
+ d[k] = *(s++); \
+ d++; \
+ } \
+} while(0)
+
+ switch( fourcc )
+ {
+ case VLC_CODEC_U8: INTERLEAVE_TYPE(uint8_t); break;
+ case VLC_CODEC_S16N: INTERLEAVE_TYPE(uint16_t); break;
+ case VLC_CODEC_FL32: INTERLEAVE_TYPE(float); break;
+ case VLC_CODEC_S32N: INTERLEAVE_TYPE(int32_t); break;
+ case VLC_CODEC_FL64: INTERLEAVE_TYPE(double); break;
+ default: assert(0);
+ }
+#undef INTERLEAVE_TYPE
+}
+
/*****************************************************************************
* aout_ChannelExtract:
*****************************************************************************/
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 32f4ddd..6e20324 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -17,6 +17,7 @@ aout_filter_RequestVout
aout_FormatPrepare
aout_FormatPrint
aout_FormatPrintChannels
+aout_Interleave
aout_PacketInit
aout_PacketDestroy
aout_PacketPlay
--
1.7.10.4
More information about the vlc-devel
mailing list