]> git.sesse.net Git - mlt/blobdiff - src/modules/avformat/producer_avformat.c
Fix compile warning about planar_to_interleaved() unused.
[mlt] / src / modules / avformat / producer_avformat.c
index 89d59b7ea39434b72f30eed0301d461a13db2034..9068f0815448160b12cb5dab19f2b11046af99e2 100644 (file)
@@ -2010,31 +2010,33 @@ static int sample_bytes( AVCodecContext *context )
 #endif
 }
 
-static void planar_to_interleaved( uint8_t *dest, uint8_t *src, int samples, int channels, int bytes_per_sample )
+#if LIBAVCODEC_VERSION_MAJOR >= 55
+static void planar_to_interleaved( uint8_t *dest, AVFrame *src, int samples, int channels, int bytes_per_sample )
 {
        int s, c;
        for ( s = 0; s < samples; s++ )
        {
                for ( c = 0; c < channels; c++ )
                {
-                       memcpy( dest, src + ( c * samples + s ) * bytes_per_sample, bytes_per_sample );
+                       memcpy( dest, &src->data[c][s * bytes_per_sample], bytes_per_sample );
                        dest += bytes_per_sample;
                }
        }
 }
-
-static void planar_to_interleaved2( uint8_t *dest, AVFrame *src, int samples, int channels, int bytes_per_sample )
+#else
+static void planar_to_interleaved( uint8_t *dest, uint8_t *src, int samples, int channels, int bytes_per_sample )
 {
        int s, c;
        for ( s = 0; s < samples; s++ )
        {
                for ( c = 0; c < channels; c++ )
                {
-                       memcpy( dest, &src->data[c][s * bytes_per_sample], bytes_per_sample );
+                       memcpy( dest, src + ( c * samples + s ) * bytes_per_sample, bytes_per_sample );
                        dest += bytes_per_sample;
                }
        }
 }
+#endif
 
 static int decode_audio( producer_avformat self, int *ignore, AVPacket pkt, int channels, int samples, double timecode, double fps )
 {
@@ -2106,7 +2108,7 @@ static int decode_audio( producer_avformat self, int *ignore, AVPacket pkt, int
                        case AV_SAMPLE_FMT_S32P:
                        case AV_SAMPLE_FMT_FLTP:
 #if LIBAVCODEC_VERSION_MAJOR >= 55
-                               planar_to_interleaved2( dest, self->audio_frame, convert_samples, codec_context->channels, sizeof_sample );
+                               planar_to_interleaved( dest, self->audio_frame, convert_samples, codec_context->channels, sizeof_sample );
 #else
                                planar_to_interleaved( dest, decode_buffer, convert_samples, codec_context->channels, sizeof_sample );
 #endif
@@ -2537,14 +2539,11 @@ static void producer_set_up_audio( producer_avformat self, mlt_frame frame )
                                audio_codec_init( self, index, properties );
                }
        }
-       else if ( context && index > -1 && audio_codec_init( self, index, properties ) )
+       else if ( context && index > -1 && index < MAX_AUDIO_STREAMS &&
+               audio_codec_init( self, index, properties ) )
        {
-               // Set the frame properties
-               if ( index < MAX_AUDIO_STREAMS )
-               {
-                       mlt_properties_set_int( frame_properties, "audio_frequency", self->audio_codec[ index ]->sample_rate );
-                       mlt_properties_set_int( frame_properties, "audio_channels", self->audio_codec[ index ]->channels );
-               }
+               mlt_properties_set_int( frame_properties, "audio_frequency", self->audio_codec[ index ]->sample_rate );
+               mlt_properties_set_int( frame_properties, "audio_channels", self->audio_codec[ index ]->channels );
        }
        if ( context && index > -1 )
        {