Merge branch 'fix/avr_context'
authorPaul Brossier <piem@piem.org>
Mon, 6 Aug 2018 15:46:22 +0000 (17:46 +0200)
committerPaul Brossier <piem@piem.org>
Mon, 6 Aug 2018 15:46:22 +0000 (17:46 +0200)
src/io/source_avcodec.c

index 8197445..2186858 100644 (file)
@@ -275,6 +275,8 @@ aubio_source_avcodec_t * new_aubio_source_avcodec(const char_t * path, uint_t sa
   // default to mono output
   aubio_source_avcodec_reset_resampler(s, 0);
 
+  if (s->avr == NULL) goto beach;
+
   s->eof = 0;
   s->multi = 0;
 
@@ -423,6 +425,15 @@ void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s, uint_t * read_sam
     goto beach;
   }
 
+#if LIBAVUTIL_VERSION_MAJOR > 52
+  if (avFrame->channels != (sint_t)s->input_channels) {
+    AUBIO_WRN ("source_avcodec: trying to read from %d channel(s),"
+        "but configured for %d; is '%s' corrupt?\n", avFrame->channels,
+        s->input_channels, s->path);
+    goto beach;
+  }
+#endif
+
 #ifdef HAVE_AVRESAMPLE
   in_linesize = 0;
   av_samples_get_buffer_size(&in_linesize, avCodecCtx->channels,