]> git.sesse.net Git - mlt/commitdiff
Fix channel count for resizing decoded audio buffer when not resampling.
authorDan Dennedy <dan@dennedy.org>
Fri, 6 May 2011 06:07:27 +0000 (23:07 -0700)
committerDan Dennedy <dan@dennedy.org>
Fri, 6 May 2011 06:07:27 +0000 (23:07 -0700)
src/modules/avformat/producer_avformat.c

index 185515628106dc1d1925d8c1f23e2f870827a944..f686fd805f7dc229fd6e78b12b458205984806d2 100644 (file)
@@ -2120,10 +2120,12 @@ static int producer_get_audio( mlt_frame frame, void **buffer, mlt_audio_format
                        ret = av_read_frame( context, &pkt );
 
                        // We only deal with audio from the selected audio index
-                       if ( ret >= 0 && pkt.data && pkt.size > 0 && ( pkt.stream_index == self->audio_index ||
-                                ( self->audio_index == INT_MAX && context->streams[ pkt.stream_index ]->codec->codec_type == CODEC_TYPE_AUDIO ) ) )
+                       index = pkt.stream_index;
+                       if ( ret >= 0 && pkt.data && pkt.size > 0 && ( index == self->audio_index ||
+                                ( self->audio_index == INT_MAX && context->streams[ index ]->codec->codec_type == CODEC_TYPE_AUDIO ) ) )
                        {
-                               int channels2 = self->audio_index == INT_MAX ? self->audio_codec[pkt.stream_index]->channels : *channels;
+                               int channels2 = ( self->audio_index == INT_MAX || !self->audio_resample[index] ) ?
+                                       self->audio_codec[index]->channels : *channels;
                                ret = decode_audio( self, &ignore, pkt, channels2, *samples, real_timecode, fps );
                        }
                        av_free_packet( &pkt );