[vlc-devel] [PATCH 3/6] avcodec: handle planar samples from libavcodec (cherry picked from commit 45032ec3b271641aaa3d9613e7c579fabc3d475a)

Rafaël Carré funman at videolan.org
Mon Feb 11 15:28:44 CET 2013


From: Ilkka Ollakka <ileoo at videolan.org>

Conflicts:
	modules/codec/avcodec/audio.c
---
 modules/codec/avcodec/audio.c |   30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index f02f595..312cd62 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -268,6 +268,7 @@ static aout_buffer_t *SplitBuffer( decoder_t *p_dec )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
     int i_samples = __MIN( p_sys->i_samples, 4096 );
+    int sample_planar=0;
     aout_buffer_t *p_buffer;
 
     if( i_samples == 0 ) return NULL;
@@ -279,16 +280,26 @@ static aout_buffer_t *SplitBuffer( decoder_t *p_dec )
     p_buffer->i_length = date_Increment( &p_sys->end_date, i_samples )
                          - p_buffer->i_pts;
 
+    sample_planar = av_sample_fmt_is_planar( p_sys->p_context->sample_fmt );
+    if( sample_planar )
+        Interleave( p_buffer->p_buffer, p_sys->p_samples, i_samples, p_sys->p_context->channels, p_dec->fmt_out.audio.i_format );
+
     if( p_sys->b_extract )
+    {
+        if( sample_planar )
+            memcpy( p_sys->p_samples, p_buffer->p_buffer, p_buffer->i_buffer );
+
         aout_ChannelExtract( p_buffer->p_buffer, p_dec->fmt_out.audio.i_channels,
                              p_sys->p_samples, p_sys->p_context->channels, i_samples,
                              p_sys->pi_extraction, p_dec->fmt_out.audio.i_bitspersample );
-    else
+    }
+    else if (!sample_planar)
         memcpy( p_buffer->p_buffer, p_sys->p_samples, p_buffer->i_buffer );
 
     p_sys->p_samples += i_samples * p_sys->p_context->channels * ( p_dec->fmt_out.audio.i_bitspersample / 8 );
     p_sys->i_samples -= i_samples;
 
+
     return p_buffer;
 }
 
@@ -457,11 +468,18 @@ void EndAudioDec( decoder_t *p_dec )
 vlc_fourcc_t GetVlcAudioFormat( int fmt )
 {
     static const vlc_fourcc_t fcc[] = {
-        [AV_SAMPLE_FMT_U8]   = VLC_CODEC_U8,
-        [AV_SAMPLE_FMT_S16]  = VLC_CODEC_S16N,
-        [AV_SAMPLE_FMT_S32]  = VLC_CODEC_S32N,
-        [AV_SAMPLE_FMT_FLT]  = VLC_CODEC_FL32,
-        [AV_SAMPLE_FMT_DBL]  = VLC_CODEC_FL64,
+        [AV_SAMPLE_FMT_U8]    = VLC_CODEC_U8,
+        [AV_SAMPLE_FMT_S16]   = VLC_CODEC_S16N,
+        [AV_SAMPLE_FMT_S32]   = VLC_CODEC_S32N,
+        [AV_SAMPLE_FMT_FLT]   = VLC_CODEC_FL32,
+        [AV_SAMPLE_FMT_DBL]   = VLC_CODEC_FL64,
+#ifdef HAVE_AVUTIL_PLANAR
+        [AV_SAMPLE_FMT_U8P]   = VLC_CODEC_U8,
+        [AV_SAMPLE_FMT_S16P]  = VLC_CODEC_S16N,
+        [AV_SAMPLE_FMT_S32P]  = VLC_CODEC_S32N,
+        [AV_SAMPLE_FMT_FLTP]  = VLC_CODEC_FL32,
+        [AV_SAMPLE_FMT_DBLP]  = VLC_CODEC_FL64,
+#endif
     };
     if( (sizeof(fcc) / sizeof(fcc[0])) > (unsigned)fmt )
         return fcc[fmt];
-- 
1.7.10.4



More information about the vlc-devel mailing list