[vlc-commits] avcodec encoder: handle planar formats

Rafaël Carré git at videolan.org
Tue Feb 12 07:58:00 CET 2013


vlc/vlc-2.0 | branch: master | Rafaël Carré <funman at videolan.org> | Mon Feb 11 14:53:57 2013 +0100| [9a9cfe849bed7574dc32b914f75714a20f23706a] | committer: Rafaël Carré

avcodec encoder: handle planar formats

Fix #8124

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

 modules/codec/avcodec/encoder.c |   27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 2a840b0..cd66623 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -1143,8 +1143,12 @@ static block_t *EncodeAudio( encoder_t *p_enc, aout_buffer_t *p_aout_buf )
             int i_size = (p_sys->i_frame_size - i_delay_size) *
                          p_sys->i_sample_bytes;
 
-            memcpy( p_sys->p_buffer + i_delay_size * p_sys->i_sample_bytes,
-                    p_buffer, i_size );
+            if( av_sample_fmt_is_planar( p_sys->p_context->sample_fmt ) )
+                Deinterleave( &p_sys->p_buffer[i_delay_size * p_sys->i_sample_bytes],
+                        p_buffer, i_samples_delay, p_enc->fmt_in.audio.i_channels, p_enc->fmt_in.i_codec );
+            else
+                memcpy( p_sys->p_buffer + i_delay_size * p_sys->i_sample_bytes,
+                        p_buffer, i_size );
             p_buffer -= i_delay_size * p_sys->i_sample_bytes;
             i_samples += i_samples_delay;
             i_samples_delay = 0;
@@ -1153,7 +1157,14 @@ static block_t *EncodeAudio( encoder_t *p_enc, aout_buffer_t *p_aout_buf )
         }
         else
         {
-            p_samples = p_buffer;
+            if( av_sample_fmt_is_planar( p_sys->p_context->sample_fmt ) ) {
+                Deinterleave( p_sys->p_buffer,
+                        p_buffer, p_sys->i_frame_size,
+                        p_enc->fmt_in.audio.i_channels,
+                        p_enc->fmt_in.i_codec );
+                p_samples = p_sys->p_buffer;
+            } else
+                p_samples = p_buffer;
         }
 
         i_out = avcodec_encode_audio( p_sys->p_context, p_sys->p_buffer_out,
@@ -1186,9 +1197,13 @@ static block_t *EncodeAudio( encoder_t *p_enc, aout_buffer_t *p_aout_buf )
     /* Backup the remaining raw samples */
     if( i_samples )
     {
-        memcpy( &p_sys->p_buffer[i_samples_delay * p_sys->i_sample_bytes],
-                p_buffer,
-                i_samples * p_sys->i_sample_bytes );
+        if( av_sample_fmt_is_planar( p_sys->p_context->sample_fmt ) )
+            Deinterleave( &p_sys->p_buffer[i_samples_delay * p_sys->i_sample_bytes],
+                    p_buffer, i_samples, p_enc->fmt_in.audio.i_channels, p_enc->fmt_in.i_codec );
+        else
+            memcpy( &p_sys->p_buffer[i_samples_delay * p_sys->i_sample_bytes],
+                    p_buffer,
+                    i_samples * p_sys->i_sample_bytes );
     }
 
     return p_chain;



More information about the vlc-commits mailing list