[vlc-commits] aout: rework aout_Interleave()

Rémi Denis-Courmont git at videolan.org
Thu Aug 8 19:21:08 CEST 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Aug  8 20:17:59 2013 +0300| [a7877a29f0c8dd4383bce50e308d95790daf4b52] | committer: Rémi Denis-Courmont

aout: rework aout_Interleave()

This no longer assumes that planes are contiguous. It should help with
libav reference counting, and also avoids interleaving unused padding.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a7877a29f0c8dd4383bce50e308d95790daf4b52
---

 include/vlc_aout.h            |    5 +++--
 modules/codec/avcodec/audio.c |   10 +++++++---
 src/audio_output/common.c     |    6 +++---
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/include/vlc_aout.h b/include/vlc_aout.h
index 49c0ec6..5d1d068 100644
--- a/include/vlc_aout.h
+++ b/include/vlc_aout.h
@@ -195,8 +195,9 @@ VLC_API unsigned aout_CheckChannelReorder( const uint32_t *, const uint32_t *,
                                            uint32_t mask, uint8_t *table );
 VLC_API void aout_ChannelReorder(void *, size_t, unsigned, const uint8_t *, vlc_fourcc_t);
 
-VLC_API void aout_Interleave(void *dst, const void *src, unsigned samples,
-                             unsigned channels, vlc_fourcc_t fourcc);
+VLC_API void aout_Interleave(void *dst, const void *const *planes,
+                             unsigned samples, unsigned channels,
+                             vlc_fourcc_t fourcc);
 VLC_API void aout_Deinterleave(void *dst, const void *src, unsigned samples,
                              unsigned channels, vlc_fourcc_t fourcc);
 
diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index 4bf21df..8511751 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -340,9 +340,13 @@ block_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block )
         block_t *p_buffer = block_Alloc( p_block->i_buffer );
         if( unlikely(p_buffer == NULL) )
             goto drop;
-        aout_Interleave( p_buffer->p_buffer, p_block->p_buffer,
-                         p_block->i_nb_samples, ctx->channels,
-                         p_dec->fmt_out.audio.i_format );
+
+        const void *planes[ctx->channels];
+        for( int i = 0; i < ctx->channels; i++)
+            planes[i] = frame.extended_data[i];
+
+        aout_Interleave( p_buffer->p_buffer, planes, frame.nb_samples,
+                         ctx->channels, p_dec->fmt_out.audio.i_format );
         if( ctx->channels > AV_NUM_DATA_POINTERS )
             free( frame.extended_data );
         block_Release( p_block );
diff --git a/src/audio_output/common.c b/src/audio_output/common.c
index 1742cab..b66f16c 100644
--- a/src/audio_output/common.c
+++ b/src/audio_output/common.c
@@ -343,21 +343,21 @@ do { \
 /**
  * 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 srcv source buffers (one per plane) of uninterleaved 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,
+void aout_Interleave( void *restrict dst, const void *const *srcv,
                       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++ ) { \
+        const type *s = srcv[i]; \
         for( size_t j = 0, k = 0; j < samples; j++, k += chans ) \
             d[k] = *(s++); \
         d++; \



More information about the vlc-commits mailing list