From 36310193f4577075762be7f4ce6ccc35a2d537dc Mon Sep 17 00:00:00 2001 From: Dan Dennedy Date: Mon, 8 Feb 2010 00:44:26 -0800 Subject: [PATCH] Fix audio muxing when downsampling >2 channels. 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/avformat/producer_avformat.c b/src/modules/avformat/producer_avformat.c index 227c3886..b886f483 100644 --- a/src/modules/avformat/producer_avformat.c +++ b/src/modules/avformat/producer_avformat.c @@ -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 ) { -- 2.39.2