]> git.sesse.net Git - mlt/commitdiff
Extend fix for audio encoding distortion to flush stage. (3576437)
authorDan Dennedy <dan@dennedy.org>
Sat, 10 Nov 2012 18:29:43 +0000 (10:29 -0800)
committerDan Dennedy <dan@dennedy.org>
Sat, 10 Nov 2012 18:29:43 +0000 (10:29 -0800)
src/modules/avformat/consumer_avformat.c

index d105caf9f621380c6cb738f6b7992eed6bb1a132..37f4ef96b119c0f7ffddf0c35eac8b2c1ea07f2d 100644 (file)
@@ -1932,7 +1932,22 @@ static void *consumer_thread( void *arg )
                                ( channels * audio_input_frame_size < sample_fifo_used( fifo ) / sample_bytes ) )
                        {
                                sample_fifo_fetch( fifo, audio_buf_1, channels * audio_input_frame_size * sample_bytes );
-                               pkt.size = avcodec_encode_audio( c, audio_outbuf, audio_outbuf_size, (short*) audio_buf_1 );
+                               void* p = audio_buf_1;
+#if LIBAVUTIL_VERSION_INT >= ((51<<16)+(17<<8)+0)
+                               if ( c->sample_fmt == AV_SAMPLE_FMT_FLTP )
+                                       p = interleaved_to_planar( audio_input_frame_size, channels, p, sizeof( float ) );
+                               else if ( c->sample_fmt == AV_SAMPLE_FMT_S16P )
+                                       p = interleaved_to_planar( audio_input_frame_size, channels, p, sizeof( int16_t ) );
+                               else if ( c->sample_fmt == AV_SAMPLE_FMT_S32P )
+                                       p = interleaved_to_planar( audio_input_frame_size, channels, p, sizeof( int32_t ) );
+#endif
+                               pkt.size = avcodec_encode_audio( c, audio_outbuf, audio_outbuf_size, p );
+#if LIBAVUTIL_VERSION_INT >= ((51<<16)+(17<<8)+0)
+                               if ( c->sample_fmt == AV_SAMPLE_FMT_FLTP
+                                    || c->sample_fmt == AV_SAMPLE_FMT_S16P
+                                    || c->sample_fmt == AV_SAMPLE_FMT_S32P )
+                                       mlt_pool_release( p );
+#endif
                        }
                        if ( pkt.size <= 0 )
                                pkt.size = avcodec_encode_audio( c, audio_outbuf, audio_outbuf_size, NULL );