[vlc-commits] avcodec: handle planar samples from libavcodec

Ilkka Ollakka git at videolan.org
Sun Dec 30 13:13:03 CET 2012


vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Fri Dec 28 12:54:39 2012 +0200| [45032ec3b271641aaa3d9613e7c579fabc3d475a] | committer: Ilkka Ollakka

avcodec: handle planar samples from libavcodec

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

 modules/codec/avcodec/audio.c |   28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index 44731da..9c65abc 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -221,6 +221,7 @@ static block_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;
     block_t *p_buffer;
 
     if( i_samples == 0 ) return NULL;
@@ -232,16 +233,26 @@ static block_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 )
+        aout_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;
 }
 
@@ -410,11 +421,16 @@ 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,
+        [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,
     };
     if( sizeof(fcc) / sizeof(fcc[0]) < (unsigned)fmt )
         return fcc[fmt];



More information about the vlc-commits mailing list