shithub: aubio

Download patch

ref: 50f39f5940cd6df6d651def78df1ee559d27c229
parent: 6d8a640382710b3383b31f749969546adecb4d8f
author: Paul Brossier <piem@piem.org>
date: Mon Apr 10 10:35:19 EDT 2017

src/io/source_avcodec.c: fix for windows vc9

--- a/src/io/source_avcodec.c
+++ b/src/io/source_avcodec.c
@@ -109,6 +109,12 @@
 
 aubio_source_avcodec_t * new_aubio_source_avcodec(const char_t * path, uint_t samplerate, uint_t hop_size) {
   aubio_source_avcodec_t * s = AUBIO_NEW(aubio_source_avcodec_t);
+  AVFormatContext *avFormatCtx = s->avFormatCtx;
+  AVCodecContext *avCodecCtx = s->avCodecCtx;
+  AVCodec *codec;
+  AVFrame *avFrame = s->avFrame;
+  uint_t i;
+  sint_t selected_stream = -1;
   int err;
   if (path == NULL) {
     AUBIO_ERR("source_avcodec: Aborted opening null path\n");
@@ -138,7 +144,6 @@
   }
 
   // try opening the file and get some info about it
-  AVFormatContext *avFormatCtx = s->avFormatCtx;
   avFormatCtx = NULL;
   if ( (err = avformat_open_input(&avFormatCtx, s->path, NULL, NULL) ) < 0 ) {
     char errorstr[256];
@@ -167,8 +172,6 @@
   //av_dump_format(avFormatCtx, 0, s->path, 0);
 
   // look for the first audio stream
-  uint_t i;
-  sint_t selected_stream = -1;
   for (i = 0; i < avFormatCtx->nb_streams; i++) {
 #if FF_API_LAVF_AVCTX
     if (avFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
@@ -190,7 +193,6 @@
   //AUBIO_DBG("Taking stream %d in file %s\n", selected_stream, s->path);
   s->selected_stream = selected_stream;
 
-  AVCodecContext *avCodecCtx = s->avCodecCtx;
 #if FF_API_LAVF_AVCTX
   AVCodecParameters *codecpar = avFormatCtx->streams[selected_stream]->codecpar;
   if (codecpar == NULL) {
@@ -197,7 +199,7 @@
     AUBIO_ERR("source_avcodec: Could not find decoder for %s", s->path);
     goto beach;
   }
-  AVCodec *codec = avcodec_find_decoder(codecpar->codec_id);
+  codec = avcodec_find_decoder(codecpar->codec_id);
 
   /* Allocate a codec context for the decoder */
   avCodecCtx = avcodec_alloc_context3(codec);
@@ -248,7 +250,6 @@
         s->input_samplerate, s->samplerate);
   }
 
-  AVFrame *avFrame = s->avFrame;
   avFrame = av_frame_alloc();
   if (!avFrame) {
     AUBIO_ERR("source_avcodec: Could not allocate frame for (%s)\n", s->path);