[vlc-commits] aout: rework aout_Interleave()

Rémi Denis-Courmont git at videolan.org
Tue Sep 17 19:08:12 CEST 2013


vlc/vlc-2.1 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Aug  8 20:17:59 2013 +0300| [382065757bc1cba8c91e619627081e8fac48855f] | committer: Jean-Baptiste Kempf

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.

(cherry picked from commit a7877a29f0c8dd4383bce50e308d95790daf4b52)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

Conflicts:
	modules/codec/avcodec/audio.c

This is backported manually because it fixes the cracks of
luckynight.rmvb

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

 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 c223ede..571bf5d 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -346,9 +346,13 @@ block_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block )
     /* Interleave audio if required */
     if( av_sample_fmt_is_planar( ctx->sample_fmt ) )
     {
-        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