]> git.sesse.net Git - mlt/commitdiff
Fix audio muxing when downsampling >2 channels.
authorDan Dennedy <dan@dennedy.org>
Mon, 8 Feb 2010 08:44:26 +0000 (00:44 -0800)
committerDan Dennedy <dan@dennedy.org>
Mon, 8 Feb 2010 08:44:26 +0000 (00:44 -0800)
A side effect of this bug was a big memory consumption. This occurs
mostly commonly when using 5.1 audio sources such as AVCHD or DVD and
encoding to 44.1 KHz.

src/modules/avformat/producer_avformat.c

index 227c388691fb9e9ef76238f9ecb940f186ee8ca1..b886f4834a667e3c2190da364956fda7657a6179 100644 (file)
@@ -1712,6 +1712,12 @@ static int producer_get_audio( mlt_frame frame, void **buffer, mlt_audio_format
                AVPacket pkt;
 
                av_init_packet( &pkt );
+               
+               // If not resampling, give consumer more than requested.
+               // It requested number samples based on requested frame rate.
+               // Do not clean this up with a samples *= ...!
+               if ( this->audio_index != INT_MAX && ! this->audio_resample[ this->audio_index ] )
+                       *samples = *samples * this->audio_codec[ this->audio_index ]->sample_rate / *frequency;
 
                while ( ret >= 0 && !got_audio )
                {