[SCM] audacity/master: Refresh disable dynamic loading patches.

bdrung at users.alioth.debian.org bdrung at users.alioth.debian.org
Tue Apr 12 23:54:43 UTC 2011


The following commit has been merged in the master branch:
commit 242da56bc031dc9d949a59c5b62219a4fb3c6fd0
Author: Benjamin Drung <bdrung at ubuntu.com>
Date:   Wed Apr 13 00:55:27 2011 +0200

    Refresh disable dynamic loading patches.

diff --git a/debian/patches/disable-dynamic-ffmpeg.patch b/debian/patches/disable-dynamic-ffmpeg.patch
new file mode 100644
index 0000000..51f43e5
--- /dev/null
+++ b/debian/patches/disable-dynamic-ffmpeg.patch
@@ -0,0 +1,139 @@
+Description: Add configure option to disable dynamic loading of FFmpeg.
+Author: Benjamin Drung <bdrung at debian.org>
+Bug: http://bugzilla.audacityteam.org/show_bug.cgi?id=233
+
+--- a/configure.in
++++ b/configure.in
+@@ -173,6 +173,12 @@
+             lib_preference=$withval,
+             lib_preference="system local")
+ 
++AC_ARG_ENABLE(dynamic-loading,
++            [AS_HELP_STRING([--enable-dynamic-loading],
++                            [enable dynamic loading of lame and FFmpeg [default=yes]])],
++            [dynamic_loading="$enableval"],
++            [dynamic_loading="yes"])
++
+ dnl AC_ARG_WITH(wx-version,
+ dnl            [AS_HELP_STRING([--with-wx-version],
+ dnl                            [select wxWidgets version (if both installed) [2.8,]])],
+--- a/m4/audacity_checklib_ffmpeg.m4
++++ b/m4/audacity_checklib_ffmpeg.m4
+@@ -35,6 +35,10 @@
+       FFMPEG_SYSTEM_AVAILABLE="yes"
+       FFMPEG_SYSTEM_CXXFLAGS="$AVCODEC_CFLAGS $AVFORMAT_CFLAGS $AVUTIL_CFLAGS"
+       FFMPEG_SYSTEM_CPPSYMBOLS="USE_FFMPEG"
++      if test "x$dynamic_loading" = "xno"; then
++         FFMPEG_SYSTEM_LIBS="$AVCODEC_LIBS $AVFORMAT_LIBS $AVUTIL_LIBS"
++         AC_DEFINE(DISABLE_DYNAMIC_LOADING_FFMPEG, 1, [Use system FFmpeg library and disable dynamic loading of it.])
++      fi
+       dnl build the extra object files needed to use FFmpeg. Paths inside
+       dnl the audacity src/ dir, as this is subsitiuted into src/Makefile.in
+       FFMPEG_SYSTEM_OPTOBJS="import/ImportFFmpeg.o export/ExportFFmpeg.o \
+--- a/src/FFmpeg.cpp
++++ b/src/FFmpeg.cpp
+@@ -611,6 +611,10 @@
+ 
+ bool FFmpegLibs::LoadLibs(wxWindow *parent, bool showerr)
+ {
++#if defined(DISABLE_DYNAMIC_LOADING_FFMPEG)
++   mLibsLoaded = InitLibs(wxEmptyString, showerr);
++   return mLibsLoaded;
++#endif
+ 
+    wxLogMessage(wxT("Trying to load FFmpeg libraries..."));
+    if (ValidLibsLoaded()) {
+@@ -681,6 +685,7 @@
+ 
+ bool FFmpegLibs::InitLibs(wxString libpath_format, bool showerr)
+ {
++#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG)
+    FreeLibs();
+ 
+ #if defined(__WXMSW__)
+@@ -881,8 +886,10 @@
+    FFMPEG_INITDYN(util, av_rescale_q);
+    FFMPEG_INITDYN(util, avutil_version);
+ 
+-   //FFmpeg initialization
+    wxLogMessage(wxT("All symbols loaded successfully. Initializing the library."));
++#endif
++
++   //FFmpeg initialization
+    avcodec_init();
+    avcodec_register_all();
+    av_register_all();
+@@ -921,7 +928,11 @@
+       return false;
+    }
+ 
++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 69, 0)
++   av_register_protocol(&ufile_protocol);
++#else
+    av_register_protocol2(&ufile_protocol, sizeof(ufile_protocol));
++#endif
+ 
+    return true;
+ }
+--- a/src/FFmpeg.h
++++ b/src/FFmpeg.h
+@@ -47,6 +47,20 @@
+    #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(52, 94, 1)
+    #define AVSampleFormat SampleFormat
+    #endif
++
++   #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 64, 0)
++   #define av_guess_format guess_format
++   #endif
++
++   #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 60, 0)
++   #define av_match_ext match_ext
++   #endif
++
++   #define avio_read get_buffer
++   #define avio_seek url_fseek
++   #define avio_close url_fclose
++   #define av_metadata_set2 av_metadata_set
++   #define av_get_bits_per_sample_fmt av_get_bits_per_sample_format
+ }
+ #endif
+ 
+@@ -335,6 +349,7 @@
+ } streamContext;
+ #endif
+ 
++#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG)
+ extern "C" {
+    // A little explanation of what's going on here.
+    //
+@@ -827,6 +842,7 @@
+       (protocol, size)
+    );
+ };
++#endif
+ 
+ #endif // USE_FFMPEG
+ #endif // __AUDACITY_FFMPEG__
+--- a/src/configtemplate.h
++++ b/src/configtemplate.h
+@@ -84,6 +84,9 @@
+    */
+ #undef USE_FFMPEG
+ 
++/* Use system FFmpeg library and disable dynamic loading of it. */
++#undef DISABLE_DYNAMIC_LOADING_FFMPEG
++
+ /* Define if LADSPA plug-ins are enabled */
+ #undef USE_LADSPA
+ 
+--- a/src/prefs/LibraryPrefs.cpp
++++ b/src/prefs/LibraryPrefs.cpp
+@@ -129,7 +129,7 @@
+          S.Id(ID_FFMPEG_DOWN_BUTTON);
+          wxButton *bdwn = S.AddButton(_("Dow&nload"),
+                                       wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
+-#if !defined(USE_FFMPEG)
++#if !defined(USE_FFMPEG) || defined(DISABLE_DYNAMIC_LOADING_FFMPEG)
+          bdwn->Enable(FALSE);
+          bfnd->Enable(FALSE);
+ #endif
diff --git a/debian/patches/disable-dynamic-loading-lame.patch b/debian/patches/disable-dynamic-lame.patch
similarity index 94%
rename from debian/patches/disable-dynamic-loading-lame.patch
rename to debian/patches/disable-dynamic-lame.patch
index 5c4c2bc..aebbafd 100644
--- a/debian/patches/disable-dynamic-loading-lame.patch
+++ b/debian/patches/disable-dynamic-lame.patch
@@ -78,7 +78,7 @@ Author: Benjamin Drung <bdrung at debian.org>
  
 --- a/src/export/ExportMP3.cpp
 +++ b/src/export/ExportMP3.cpp
-@@ -89,7 +89,11 @@
+@@ -90,7 +90,11 @@
  
  #include "Export.h"
  
@@ -90,7 +90,7 @@ Author: Benjamin Drung <bdrung at debian.org>
  
  #ifdef USE_LIBID3TAG 
  #include <id3tag.h>
-@@ -532,6 +536,8 @@
+@@ -561,6 +565,8 @@
  {
  public:
  
@@ -99,7 +99,7 @@ Author: Benjamin Drung <bdrung at debian.org>
     FindDialog(wxWindow *parent, wxString path, wxString name, wxString type)
     :  wxDialog(parent, wxID_ANY, wxString(_("Locate Lame")))
     {
-@@ -624,28 +630,36 @@
+@@ -653,28 +659,36 @@
        return mLibPath.GetFullPath();
     }
  
@@ -136,7 +136,7 @@ Author: Benjamin Drung <bdrung at debian.org>
  typedef lame_global_flags *lame_init_t(void);
  typedef int lame_init_params_t(lame_global_flags*);
  typedef const char* get_lame_version_t(void);
-@@ -689,6 +703,8 @@
+@@ -718,6 +732,8 @@
  typedef size_t lame_get_lametag_frame_t(const lame_global_flags *, unsigned char* buffer, size_t size);
  typedef void lame_mp3_tags_fid_t(lame_global_flags *, FILE *);
  
@@ -145,7 +145,7 @@ Author: Benjamin Drung <bdrung at debian.org>
  #if defined(__WXMSW__)
  // An alternative solution to give Windows an additional chance of writing the tag before
  // falling bato to lame_mp3_tag_fid().  The latter can have DLL sharing issues when mixing
-@@ -741,9 +757,11 @@
+@@ -770,9 +786,11 @@
     MP3Exporter();
     virtual ~MP3Exporter();
  
@@ -157,7 +157,7 @@ Author: Benjamin Drung <bdrung at debian.org>
  
     /* These global settings keep state over the life of the object */
     void SetMode(int mode);
-@@ -785,9 +803,11 @@
+@@ -814,9 +832,11 @@
  
  private:
  
@@ -169,7 +169,7 @@ Author: Benjamin Drung <bdrung at debian.org>
  
  #if defined(__WXMSW__)
     wxString mBladeVersion;
-@@ -800,6 +820,7 @@
+@@ -829,6 +849,7 @@
     int mRoutine;
     int mChannel;
  
@@ -177,7 +177,7 @@ Author: Benjamin Drung <bdrung at debian.org>
     /* function pointers to the symbols we get from the library */
     lame_init_t* lame_init;
     lame_init_params_t* lame_init_params;
-@@ -829,6 +850,7 @@
+@@ -858,6 +879,7 @@
     beWriteInfoTag_t *beWriteInfoTag;
     beVersion_t *beVersion;
  #endif
@@ -185,7 +185,7 @@ Author: Benjamin Drung <bdrung at debian.org>
  
     lame_global_flags *mGF;
  
-@@ -845,13 +867,17 @@
+@@ -874,13 +896,17 @@
  
  MP3Exporter::MP3Exporter()
  {
@@ -203,7 +203,7 @@ Author: Benjamin Drung <bdrung at debian.org>
  
     mBitrate = 128;
     mQuality = QUALITY_2;
-@@ -865,6 +891,8 @@
+@@ -894,6 +920,8 @@
     FreeLibrary();
  }
  
@@ -212,7 +212,7 @@ Author: Benjamin Drung <bdrung at debian.org>
  bool MP3Exporter::FindLibrary(wxWindow *parent)
  {
     wxString path;
-@@ -958,6 +986,8 @@
+@@ -992,6 +1020,8 @@
     return mLibraryLoaded;
  }
  
@@ -221,15 +221,15 @@ Author: Benjamin Drung <bdrung at debian.org>
  void MP3Exporter::SetMode(int mode)
  {
     mMode = mode;
-@@ -981,6 +1011,7 @@
- 
- bool MP3Exporter::InitLibrary(wxString libpath)
+@@ -1017,6 +1047,7 @@
  {
+    wxLogMessage(wxT("Loading LAME from %s"), libpath.c_str());
+ 
 +#ifndef DISABLE_DYNAMIC_LOADING_LAME
     if (!lame_lib.Load(libpath, wxDL_LAZY)) {
+       wxLogMessage(wxT("load failed"));
        return false;
-    }
-@@ -1079,6 +1110,7 @@
+@@ -1120,6 +1151,7 @@
        lame_lib.Unload();
        return false;
     }
@@ -237,7 +237,7 @@ Author: Benjamin Drung <bdrung at debian.org>
  
     mGF = lame_init();
     if (mGF == NULL) {
-@@ -1095,25 +1127,31 @@
+@@ -1136,25 +1168,31 @@
        mGF = NULL;
     }
  
@@ -269,10 +269,10 @@ Author: Benjamin Drung <bdrung at debian.org>
  
     if (channels > 2) {
        return -1;
-@@ -1124,7 +1162,10 @@
+@@ -1165,7 +1203,10 @@
     lame_set_in_samplerate(mGF, sampleRate);
     lame_set_out_samplerate(mGF, sampleRate);
-    lame_set_disable_reservoir(mGF, true);
+    lame_set_disable_reservoir(mGF, false);
 +#ifndef DISABLE_DYNAMIC_LOADING_LAME
 +// TODO: Make this configurable (detect the existance of this function)
     lame_set_padding_type(mGF, PAD_NO);
@@ -280,7 +280,7 @@ Author: Benjamin Drung <bdrung at debian.org>
  
     // Add the VbrTag for all types.  For ABR/VBR, a Xing tag will be created.
     // For CBR, it will be a Lame Info tag.
-@@ -1269,9 +1310,13 @@
+@@ -1310,9 +1351,13 @@
  
     int result = lame_encode_flush(mGF, outbuffer, mOutBufferSize);
  
@@ -294,7 +294,7 @@ Author: Benjamin Drung <bdrung at debian.org>
  
     return result;
  }
-@@ -1516,10 +1561,20 @@
+@@ -1565,10 +1610,20 @@
                         int subformat)
  {
     int rate = lrint(project->GetRate());
@@ -315,7 +315,7 @@ Author: Benjamin Drung <bdrung at debian.org>
     if (!exporter.LoadLibrary(parent, MP3Exporter::Maybe)) {
        wxMessageBox(_("Could not open MP3 encoding library!"));
        gPrefs->Write(wxT("/MP3/MP3LibPath"), wxString(wxT("")));
-@@ -1533,7 +1588,8 @@
+@@ -1582,7 +1637,8 @@
        
        return false;
     }
@@ -325,7 +325,7 @@ Author: Benjamin Drung <bdrung at debian.org>
     // Retrieve preferences
     int highrate = 48000;
     int lowrate = 8000;
-@@ -1969,13 +2025,17 @@
+@@ -2012,13 +2068,17 @@
     MP3Exporter exporter;
     wxString versionString = _("MP3 export library not found");
  
@@ -367,9 +367,9 @@ Author: Benjamin Drung <bdrung at debian.org>
     }
 --- a/src/prefs/PrefsDialog.cpp
 +++ b/src/prefs/PrefsDialog.cpp
-@@ -99,7 +99,9 @@
-          w = new TracksPrefs(mCategories);      mCategories->AddPage(w, w->GetName(), false, 0);
+@@ -101,7 +101,9 @@
           w = new ImportExportPrefs(mCategories);mCategories->AddPage(w, w->GetName(), false, 0);
+          w = new ExtImportPrefs(mCategories);   mCategories->AddPage(w, w->GetName(), false, 0);
           w = new ProjectsPrefs(mCategories);    mCategories->AddPage(w, w->GetName(), false, 0);
 +#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) || !defined(DISABLE_DYNAMIC_LOADING_LAME)
           w = new LibraryPrefs(mCategories);     mCategories->AddPage(w, w->GetName(), false, 0);
diff --git a/debian/patches/disable-dynamic-loading.patch b/debian/patches/disable-dynamic-loading.patch
deleted file mode 100644
index 19cd4cf..0000000
--- a/debian/patches/disable-dynamic-loading.patch
+++ /dev/null
@@ -1,1139 +0,0 @@
-Description: Add configure option to disable dynamic loading of FFmpeg
- This patch also adds support for FFmpeg >= 0.6
-Author: Benjamin Drung <bdrung at ubuntu.com>
-Bug: http://bugzilla.audacityteam.org/show_bug.cgi?id=233
-
---- a/configure.in
-+++ b/configure.in
-@@ -173,6 +173,12 @@
-             lib_preference=$withval,
-             lib_preference="system local")
- 
-+AC_ARG_ENABLE(dynamic-loading,
-+            [AS_HELP_STRING([--enable-dynamic-loading],
-+                            [enable dynamic loading of lame and FFmpeg [default=yes]])],
-+            [dynamic_loading="$enableval"],
-+            [dynamic_loading="yes"])
-+
- dnl AC_ARG_WITH(wx-version,
- dnl            [AS_HELP_STRING([--with-wx-version],
- dnl                            [select wxWidgets version (if both installed) [2.8,]])],
---- a/m4/audacity_checklib_ffmpeg.m4
-+++ b/m4/audacity_checklib_ffmpeg.m4
-@@ -2,7 +2,7 @@
- dnl
- dnl Please increment the serial number below whenever you alter this macro
- dnl for the benefit of automatic macro update systems
--# audacity_checklib_ffmpeg.m4 serial 1
-+# audacity_checklib_ffmpeg.m4 serial 2
- dnl Check for a copy of ffmpeg, whoose headers we will use for the importer
- AC_DEFUN([AUDACITY_CHECKLIB_FFMPEG], [
-    AC_ARG_WITH(ffmpeg,
-@@ -26,18 +26,27 @@
-    PKG_CHECK_MODULES(AVFORMAT, libavformat >= 52.12,
-                      avformat_available_system="yes",
-                      avformat_available_system="no")
-+   PKG_CHECK_MODULES(AVUTIL, libavutil,
-+                     libavutil_available_system="yes",
-+                     libavutil_available_system="no")
- 
-    FFMPEG_SYSTEM_AVAILABLE="no"
-    if test "x$avcodec_available_system" = "xyes" ; then
-       if test "x$avformat_available_system" = "xyes" ; then
--	     FFMPEG_SYSTEM_AVAILABLE="yes"
--         FFMPEG_SYSTEM_CXXFLAGS="$AVCODEC_CFLAGS $AVFORMAT_CFLAGS"
--         FFMPEG_SYSTEM_CPPSYMBOLS="USE_FFMPEG"
--		 dnl build the extra object files needed to use FFmpeg. Paths inside
--		 dnl the audacity src/ dir, as this is subsitiuted into src/Makefile.in
--		 FFMPEG_SYSTEM_OPTOBJS="import/ImportFFmpeg.o export/ExportFFmpeg.o \
--		 	export/ExportFFmpegDialogs.o"
--         AC_MSG_NOTICE([FFmpeg library available as system library])
-+         if test "x$libavutil_available_system" = "xyes" ; then
-+            FFMPEG_SYSTEM_AVAILABLE="yes"
-+            FFMPEG_SYSTEM_CXXFLAGS="$AVCODEC_CFLAGS $AVFORMAT_CFLAGS $AVUTIL_CFLAGS"
-+            FFMPEG_SYSTEM_CPPSYMBOLS="USE_FFMPEG"
-+            if test "x$dynamic_loading" = "xno"; then
-+               FFMPEG_SYSTEM_LIBS="$AVCODEC_LIBS $AVFORMAT_LIBS $AVUTIL_LIBS"
-+               FFMPEG_SYSTEM_CPPSYMBOLS="$FFMPEG_SYSTEM_CPPSYMBOLS DISABLE_DYNAMIC_LOADING_FFMPEG"
-+            fi
-+            dnl build the extra object files needed to use FFmpeg. Paths inside
-+            dnl the audacity src/ dir, as this is subsitiuted into src/Makefile.in
-+            FFMPEG_SYSTEM_OPTOBJS="import/ImportFFmpeg.o export/ExportFFmpeg.o \
-+               export/ExportFFmpegDialogs.o"
-+            AC_MSG_NOTICE([FFmpeg library available as system library])
-+         fi
-       fi
-    fi
-    if test "x$FFMPEG_SYSTEM_AVAILABLE" = "xno" ; then
---- a/src/FFmpeg.cpp
-+++ b/src/FFmpeg.cpp
-@@ -40,6 +40,8 @@
- 
- #else
- 
-+#ifndef DISABLE_DYNAMIC_LOADING_FFMPEG
-+
- /** This pointer to the shared object has global scope and is used to track the
-  * singleton object which wraps the FFmpeg codecs */
- FFmpegLibs *FFmpegLibsInst = NULL;
-@@ -122,6 +124,8 @@
-    return versionString;
- }
- 
-+#endif // DISABLE_DYNAMIC_LOADING_FFMPEG
-+
- void av_log_wx_callback(void* ptr, int level, const char* fmt, va_list vl)
- {
-    //Most of this stuff is taken from FFmpeg tutorials and FFmpeg itself
-@@ -204,7 +208,12 @@
-    return ret;
- }
- 
-+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 68, 0)
- static int ufile_write(URLContext *h, unsigned char *buf, int size)
-+#else
-+static int ufile_write(URLContext *h, const unsigned char *buf, int size)
-+#endif
-+
- {
-    return (int) ((wxFile *) h->priv_data)->Write(buf, size);
- }
-@@ -265,15 +274,15 @@
-    // Open the file using our custom protocol and passing the (possibly) Unicode
-    // filename.  This is playing a slight trick since our ufile_open() routine above
-    // knows that the "char *" name may actually be wide characters.
--   err = FFmpegLibsInst->url_open_protocol(&h, &ufile_protocol, (const char *) name.c_str(), flags);
-+   err = FFMPEG_LIB(url_open_protocol(&h, &ufile_protocol, (const char *) name.c_str(), flags));
-    if (err < 0) {
-       return err;
-    }
- 
-    // Associate the file with a context
--   err = FFmpegLibsInst->url_fdopen(s, h);
-+   err = FFMPEG_LIB(url_fdopen(s, h));
-    if (err < 0) {
--      FFmpegLibsInst->url_close(h);
-+      FFMPEG_LIB(url_close(h));
-       return err;
-    }
- 
-@@ -307,7 +316,7 @@
-    // Initialize probe data...go ahead and preallocate the maximum buffer size.
-    pd.filename = filename;
-    pd.buf_size = 0;
--   pd.buf = (unsigned char *) FFmpegLibsInst->av_malloc(PROBE_BUF_MAX + AVPROBE_PADDING_SIZE);
-+   pd.buf = (unsigned char *) FFMPEG_LIB(av_malloc(PROBE_BUF_MAX + AVPROBE_PADDING_SIZE));
-    if (pd.buf == NULL) {
-       err = AVERROR_NOMEM;
-       goto fail;
-@@ -322,7 +331,7 @@
-       int score_max = probe_size < PROBE_BUF_MAX ? AVPROBE_SCORE_MAX / 4 : 0;
- 
-       // Read up to a "probe_size" worth of data
--      pd.buf_size = FFmpegLibsInst->get_buffer(pb, pd.buf, probe_size);
-+      pd.buf_size = FFMPEG_LIB(get_buffer(pb, pd.buf, probe_size));
- 
-       // AWD: with zero-length input files buf_size can come back negative;
-       // this causes problems so we might as well just fail
-@@ -335,14 +344,14 @@
-       memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);
- 
-       // Reposition file for succeeding scan
--      if (FFmpegLibsInst->url_fseek(pb, 0, SEEK_SET) < 0) {
-+      if (FFMPEG_LIB(url_fseek(pb, 0, SEEK_SET)) < 0) {
-          err = AVERROR(EIO);
-          goto fail;
-       }
- 
-       // Scan all input formats
-       fmt = NULL;
--      for (fmt1 = FFmpegLibsInst->av_iformat_next(NULL); fmt1 != NULL; fmt1 = FFmpegLibsInst->av_iformat_next(fmt1)) {
-+      for (fmt1 = FFMPEG_LIB(av_iformat_next(NULL)); fmt1 != NULL; fmt1 = FFMPEG_LIB(av_iformat_next(fmt1))) {
-          int score = 0;
- 
-          // Ignore the ones that are not file based
-@@ -356,7 +365,11 @@
-          }
-          // Otherwize, resort to extension matching if available
-          else if (fmt1->extensions) {
--            if (FFmpegLibsInst->match_ext(filename, fmt1->extensions)) {
-+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 60, 0)
-+            if (FFMPEG_LIB(match_ext(filename, fmt1->extensions))) {
-+#else
-+            if (FFMPEG_LIB(av_match_ext(filename, fmt1->extensions))) {
-+#endif
-                score = 50;
-             }
-          }
-@@ -379,23 +392,23 @@
-    }
- 
-    // And finally, attempt to associate an input stream with the file
--   err = FFmpegLibsInst->av_open_input_stream(ic_ptr, pb, filename, fmt, NULL);
-+   err = FFMPEG_LIB(av_open_input_stream(ic_ptr, pb, filename, fmt, NULL));
-    if (err) {
-       goto fail;
-    }
- 
-    // Done with the probe buffer
--   FFmpegLibsInst->av_freep(&pd.buf);
-+   FFMPEG_LIB(av_freep(&pd.buf));
- 
-    return 0;
- 
- fail:
-    if (pd.buf) {
--      FFmpegLibsInst->av_freep(&pd.buf);
-+      FFMPEG_LIB(av_freep(&pd.buf));
-    }
- 
-    if (pb) {
--      FFmpegLibsInst->url_fclose(pb);
-+      FFMPEG_LIB(url_fclose(pb));
-    }
- 
-    *ic_ptr = NULL;
-@@ -405,6 +418,8 @@
- 
- /*******************************************************/
- 
-+#ifndef DISABLE_DYNAMIC_LOADING_FFMPEG
-+
- class FFmpegNotFoundDialog;
- 
- //----------------------------------------------------------------------------
-@@ -820,8 +835,13 @@
-    INITDYN(avformat,url_fclose);
-    INITDYN(avformat,url_fsize);
-    INITDYN(avformat,av_new_stream);
-+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 64, 0)
-    INITDYN(avformat,av_alloc_format_context);
-    INITDYN(avformat,guess_format);
-+#else
-+   INITDYN(avformat,avformat_alloc_context);
-+   INITDYN(avformat,av_guess_format);
-+#endif
-    INITDYN(avformat,av_write_trailer);
-    INITDYN(avformat,av_codec_get_id);
-    INITDYN(avformat,av_codec_get_tag);
-@@ -829,7 +849,11 @@
-    INITDYN(avformat,av_open_input_file);
-    INITDYN(avformat,av_open_input_stream);
-    INITDYN(avformat,get_buffer);
-+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 60, 0)
-    INITDYN(avformat,match_ext);
-+#else
-+   INITDYN(avformat,av_match_ext);
-+#endif
- 
- #if FFMPEG_STABLE
-    INITDYN(avformat,av_init_packet);
-@@ -939,4 +963,6 @@
-    return;
- }
- 
-+#endif // DISABLE_DYNAMIC_LOADING_FFMPEG
-+
- #endif //USE_FFMPEG
---- a/src/FFmpeg.h
-+++ b/src/FFmpeg.h
-@@ -39,6 +39,11 @@
-    #include <libavcodec/avcodec.h>
-    #include <libavformat/avformat.h>
-    #include <libavutil/fifo.h>
-+
-+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 60, 0)
-+   // Declare internal FFmpeg function
-+   int match_ext(const char *filename, const char *extensions);
-+#endif
- }
- #endif
- 
-@@ -90,6 +95,13 @@
- int modify_file_url_to_utf8(char* buffer, size_t buffer_size, const wchar_t* url);
- #endif
- 
-+
-+#ifdef DISABLE_DYNAMIC_LOADING_FFMPEG
-+#define FFMPEG_LIB(x) x
-+#else //DISABLE_DYNAMIC_LOADING_FFMPEG
-+
-+#define FFMPEG_LIB(x) FFmpegLibsInst->x
-+
- //----------------------------------------------------------------------------
- // Attempt to load and enable/disable FFmpeg at startup
- //----------------------------------------------------------------------------
-@@ -222,9 +234,18 @@
-    int               (*url_fclose)                    (ByteIOContext *s);
-    int               (*url_fsize)                     (ByteIOContext *s);
-    AVStream*         (*av_new_stream)                 (AVFormatContext *s, int id);
-+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 64, 0)
-    AVFormatContext*  (*av_alloc_format_context)       (void);
-    AVOutputFormat*   (*guess_format)                  (const char *short_name, const char *filename, const char *mime_type);
-+#else
-+   AVFormatContext*  (*avformat_alloc_context)        (void);
-+   AVOutputFormat*   (*av_guess_format)               (const char *short_name, const char *filename, const char *mime_type);
-+#endif
-+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 60, 0)
-    int               (*match_ext)                     (const char *filename, const char *extensions);
-+#else
-+   int               (*av_match_ext)                  (const char *filename, const char *extensions);
-+#endif
-    int               (*av_write_trailer)              (AVFormatContext *s);
-    int               (*av_interleaved_write_frame)    (AVFormatContext *s, AVPacket *pkt);
-    int               (*av_write_frame)                (AVFormatContext *s, AVPacket *pkt);
-@@ -396,6 +417,10 @@
- ///! anymore, or just decrements it's reference count
- void        DropFFmpegLibs();
- 
-+extern FFmpegLibs *FFmpegLibsInst;
-+
-+#endif // DISABLE_DYNAMIC_LOADING_FFMPEG
-+
- int ufile_fopen(ByteIOContext **s, const wxString & name, int flags);
- int ufile_fopen_input(AVFormatContext **ic_ptr, wxString & name);
- 
---- a/src/configtemplate.h
-+++ b/src/configtemplate.h
-@@ -84,6 +84,9 @@
-    */
- #undef USE_FFMPEG
- 
-+/* Use system FFmpeg library and disable dynamic loading of it. */
-+#undef DISABLE_DYNAMIC_LOADING_FFMPEG
-+
- /* Define if LADSPA plug-ins are enabled */
- #undef USE_LADSPA
- 
---- a/src/AudacityApp.cpp
-+++ b/src/AudacityApp.cpp
-@@ -1117,7 +1117,13 @@
-    mLogger->SetLogLevel(wxLOG_Max);
- 
-    #ifdef USE_FFMPEG
-+   #ifdef DISABLE_DYNAMIC_LOADING_FFMPEG
-+   avcodec_init();
-+   avcodec_register_all();
-+   av_register_all();
-+   #else //DISABLE_DYNAMIC_LOADING_FFMPEG
-    FFmpegStartup();
-+   #endif //DISABLE_DYNAMIC_LOADING_FFMPEG
-    #endif
- 
-    #ifdef USE_GSTREAMER
-@@ -1707,7 +1713,9 @@
-    FinishPreferences();
- 
-    #ifdef USE_FFMPEG
-+   #ifndef DISABLE_DYNAMIC_LOADING_FFMPEG
-    DropFFmpegLibs();
-+   #endif //DISABLE_DYNAMIC_LOADING_FFMPEG
-    #endif
- 
-    UnloadEffects();
---- a/src/export/ExportFFmpeg.cpp
-+++ b/src/export/ExportFFmpeg.cpp
-@@ -50,8 +50,7 @@
- 
- #if defined(USE_FFMPEG)
- 
--extern FFmpegLibs *FFmpegLibsInst;
--
-+#ifndef DISABLE_DYNAMIC_LOADING_FFMPEG
- static bool CheckFFmpegPresence()
- {
-    bool result = true;
-@@ -64,6 +63,7 @@
-    DropFFmpegLibs();
-    return result;
- }
-+#endif //DISABLE_DYNAMIC_LOADING_FFMPEG
- 
- static int AdjustFormatIndex(int format)
- {
-@@ -178,18 +178,28 @@
-    mSampleRate = 0;
-    mSupportsUTF8 = true;
- 
-+#ifndef DISABLE_DYNAMIC_LOADING_FFMPEG
-    PickFFmpegLibs(); // DropFFmpegLibs() call is in ExportFFmpeg::Destroy()
-+#endif //DISABLE_DYNAMIC_LOADING_FFMPEG
-    int newfmt;
-    // Adds export types from the export type list
-    for (newfmt = 0; newfmt < FMT_LAST; newfmt++)
-    {
-       wxString shortname(ExportFFmpegOptions::fmts[newfmt].shortname);
-       //Don't hide export types when there's no av-libs, and don't hide FMT_OTHER
-+#ifdef DISABLE_DYNAMIC_LOADING_FFMPEG
-+      if (newfmt < FMT_OTHER)
-+#else
-       if (newfmt < FMT_OTHER && FFmpegLibsInst->ValidLibsLoaded())
-+#endif //DISABLE_DYNAMIC_LOADING_FFMPEG
-       {
-          // Format/Codec support is compiled in?
--         AVOutputFormat *avoformat = FFmpegLibsInst->guess_format(shortname.mb_str(), NULL, NULL);
--         AVCodec *avcodec = FFmpegLibsInst->avcodec_find_encoder(ExportFFmpegOptions::fmts[newfmt].codecid);
-+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 64, 0)
-+         AVOutputFormat *avoformat = FFMPEG_LIB(guess_format(shortname.mb_str(), NULL, NULL));
-+#else
-+         AVOutputFormat *avoformat = FFMPEG_LIB(av_guess_format(shortname.mb_str(), NULL, NULL));
-+#endif
-+         AVCodec *avcodec = FFMPEG_LIB(avcodec_find_encoder(ExportFFmpegOptions::fmts[newfmt].codecid));
-          if (avoformat == NULL || avcodec == NULL)
-          {
-             ExportFFmpegOptions::fmts[newfmt].compiledIn = false;
-@@ -223,7 +233,9 @@
- 
- void ExportFFmpeg::Destroy()
- {
-+#ifndef DISABLE_DYNAMIC_LOADING_FFMPEG
-    DropFFmpegLibs();
-+#endif //DISABLE_DYNAMIC_LOADING_FFMPEG
-    delete this;
- }
- 
-@@ -239,10 +251,12 @@
-    }
-    else
- #endif
-+#ifndef DISABLE_DYNAMIC_LOADING_FFMPEG
-    if (!CheckFFmpegPresence())
-    {
-       result = false;
-    }
-+#endif //DISABLE_DYNAMIC_LOADING_FFMPEG
-    return result;
- }
- 
-@@ -251,23 +265,33 @@
-    int err;
-    //FFmpegLibsInst->LoadLibs(NULL,true); //Loaded at startup or from Prefs now
- 
-+#ifndef DISABLE_DYNAMIC_LOADING_FFMPEG
-    if (!FFmpegLibsInst->ValidLibsLoaded()) return false;
-+#endif //DISABLE_DYNAMIC_LOADING_FFMPEG
- 
--   FFmpegLibsInst->av_log_set_callback(av_log_wx_callback);
-+   FFMPEG_LIB(av_log_set_callback(av_log_wx_callback));
- 
-    AVFormatParameters	fpOutFile;
- 
-    // See if libavformat has modules that can write our output format. If so, mEncFormatDesc
-    // will describe the functions used to write the format (used internally by libavformat)
-    // and the default video/audio codecs that the format uses.
--   if ((mEncFormatDesc = FFmpegLibsInst->guess_format(shortname, OSINPUT(mName), NULL)) == NULL)
-+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 64, 0)
-+   if ((mEncFormatDesc = FFMPEG_LIB(guess_format(shortname, OSINPUT(mName), NULL))) == NULL)
-+#else
-+   if ((mEncFormatDesc = FFMPEG_LIB(av_guess_format(shortname, OSINPUT(mName), NULL))) == NULL)
-+#endif
-    {
-       wxLogMessage(wxT("FFmpeg : ERROR - Can't determine format description for file \"%s\"."), mName.c_str());
-       return false;
-    }
- 
-    // mEncFormatCtx is used by libavformat to carry around context data re our output file.
--   if ((mEncFormatCtx = FFmpegLibsInst->av_alloc_format_context()) == NULL)
-+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 64, 0)
-+   if ((mEncFormatCtx = FFMPEG_LIB(av_alloc_format_context())) == NULL)
-+#else
-+   if ((mEncFormatCtx = FFMPEG_LIB(avformat_alloc_context())) == NULL)
-+#endif
-    {
-       wxLogMessage(wxT("FFmpeg : ERROR - Can't allocate output format context."));
-       return false;
-@@ -278,7 +302,7 @@
-    memcpy(mEncFormatCtx->filename, OSINPUT(mName), strlen(OSINPUT(mName))+1);
-    
-    // At the moment Audacity can export only one audio stream
--   if ((mEncAudioStream = FFmpegLibsInst->av_new_stream(mEncFormatCtx, 1)) == NULL)
-+   if ((mEncAudioStream = FFMPEG_LIB(av_new_stream(mEncFormatCtx, 1))) == NULL)
-    {
-       wxLogMessage(wxT("FFmpeg : ERROR - Can't add audio stream to output file \"%s\"."), mName.c_str());
-       return false;
-@@ -299,7 +323,7 @@
- 
-    // Set default parameters on the format context.
-    memset(&fpOutFile, 0, sizeof(AVFormatParameters));
--   if ((err = FFmpegLibsInst->av_set_parameters(mEncFormatCtx, &fpOutFile)) < 0)
-+   if ((err = FFMPEG_LIB(av_set_parameters(mEncFormatCtx, &fpOutFile))) < 0)
-    {
-       wxLogMessage(wxT("FFmpeg : ERROR - Can't set output parameters for output file \"%s\". Error code is %d."), mName.c_str(),err);
-       return false;
-@@ -324,7 +348,7 @@
-    }
- 
-    // Write headers to the output file.
--   if ((err = FFmpegLibsInst->av_write_header(mEncFormatCtx)) < 0)
-+   if ((err = FFMPEG_LIB(av_write_header(mEncFormatCtx))) < 0)
-    {
-       wxLogMessage(wxT("FFmpeg : ERROR - Can't write headers to output file \"%s\". Error code is %d."), mName.c_str(),err);
- 
-@@ -349,11 +373,11 @@
-    // Configure the audio stream's codec context.
-    mEncAudioCodecCtx = mEncAudioStream->codec;
-   
--   FFmpegLibsInst->avcodec_get_context_defaults(mEncAudioCodecCtx);
-+   FFMPEG_LIB(avcodec_get_context_defaults(mEncAudioCodecCtx));
- 
-    mEncAudioCodecCtx->codec_id = ExportFFmpegOptions::fmts[mSubFormat].codecid;
-    mEncAudioCodecCtx->codec_type = CODEC_TYPE_AUDIO;
--   mEncAudioCodecCtx->codec_tag = FFmpegLibsInst->av_codec_get_tag((const AVCodecTag **)mEncFormatCtx->oformat->codec_tag,mEncAudioCodecCtx->codec_id);
-+   mEncAudioCodecCtx->codec_tag = FFMPEG_LIB(av_codec_get_tag((const AVCodecTag **)mEncFormatCtx->oformat->codec_tag,mEncAudioCodecCtx->codec_id));
-    mSampleRate = (int)project->GetRate();
-    mEncAudioCodecCtx->global_quality = -99999; //quality mode is off by default;
- 
-@@ -448,7 +472,7 @@
-    //mEncAudioCodecCtx->strict_std_compliance = FF_COMPLIANCE_STRICT;
- 
-    // Is the required audio codec compiled into libavcodec?
--   if ((codec = FFmpegLibsInst->avcodec_find_encoder(mEncAudioCodecCtx->codec_id)) == NULL)
-+   if ((codec = FFMPEG_LIB(avcodec_find_encoder(mEncAudioCodecCtx->codec_id))) == NULL)
-    {
-       wxLogMessage(wxT("FFmpeg : ERROR - Can't find audio codec 0x%x."),mEncAudioCodecCtx->codec_id);
-       wxMessageBox(wxString::Format(_("FFmpeg cannot find audio codec 0x%x.\nSupport for this codec is probably not compiled in."),mEncAudioCodecCtx->codec_id));
-@@ -462,7 +486,7 @@
-    }
- 
-    // Open the codec.
--   if (FFmpegLibsInst->avcodec_open(mEncAudioCodecCtx, codec) < 0 || mEncAudioCodecCtx->frame_size == 0) 
-+   if (FFMPEG_LIB(avcodec_open(mEncAudioCodecCtx, codec)) < 0 || mEncAudioCodecCtx->frame_size == 0) 
-    {
-       wxLogMessage(wxT("FFmpeg : ERROR - Can't open audio codec 0x%x."),mEncAudioCodecCtx->codec_id);
-       return false;
-@@ -475,7 +499,7 @@
-       mEncAudioEncodedBufSiz = FF_MIN_BUFFER_SIZE;
-    }
-    // Allocate a buffer for the encoder to store encoded audio frames into.
--   if ((mEncAudioEncodedBuf = (uint8_t*)FFmpegLibsInst->av_malloc(mEncAudioEncodedBufSiz)) == NULL)
-+   if ((mEncAudioEncodedBuf = (uint8_t*)FFMPEG_LIB(av_malloc(mEncAudioEncodedBufSiz))) == NULL)
-    {
-       wxLogMessage(wxT("FFmpeg : ERROR - Can't allocate buffer to hold encoded audio."));
-       return false;
-@@ -485,13 +509,13 @@
-    // guarantee we'll get this minimum each time an audio frame is decoded from the input file so 
-    // we use a FIFO to store up incoming raw samples until we have enough for one call to the codec.
- #if FFMPEG_STABLE
--   FFmpegLibsInst->av_fifo_init(&mEncAudioFifo, 1024);
-+   FFMPEG_LIB(av_fifo_init(&mEncAudioFifo, 1024));
- #else
--   mEncAudioFifo = FFmpegLibsInst->av_fifo_alloc(1024);
-+   mEncAudioFifo = FFMPEG_LIB(av_fifo_alloc(1024));
- #endif
- 
-    // Allocate a buffer to read OUT of the FIFO into. The FIFO maintains its own buffer internally.
--   if ((mEncAudioFifoOutBuf = (uint8_t*)FFmpegLibsInst->av_malloc(2*MAX_AUDIO_PACKET_SIZE)) == NULL)
-+   if ((mEncAudioFifoOutBuf = (uint8_t*)FFMPEG_LIB(av_malloc(2*MAX_AUDIO_PACKET_SIZE))) == NULL)
-    {
-       wxLogMessage(wxT("FFmpeg : ERROR - Can't allocate buffer to read into from audio FIFO."));
-       return false;
-@@ -509,9 +533,9 @@
-    {
-       AVPacket	pkt;
- #if FFMPEG_STABLE
--      int		nFifoBytes = FFmpegLibsInst->av_fifo_size(&mEncAudioFifo);	// any bytes left in audio FIFO?
-+      int		nFifoBytes = FFMPEG_LIB(av_fifo_size(&mEncAudioFifo));	// any bytes left in audio FIFO?
- #else
--      int		nFifoBytes = FFmpegLibsInst->av_fifo_size(mEncAudioFifo);	// any bytes left in audio FIFO?
-+      int		nFifoBytes = FFMPEG_LIB(av_fifo_size(mEncAudioFifo));	// any bytes left in audio FIFO?
- #endif
- 
-       nEncodedBytes = 0;
-@@ -550,15 +574,15 @@
- 
-             // Pull the bytes out from the FIFO and feed them to the encoder.
- #if FFMPEG_STABLE
--            if (FFmpegLibsInst->av_fifo_read(&mEncAudioFifo, mEncAudioFifoOutBuf, nFifoBytes) == 0)
-+            if (FFMPEG_LIB(av_fifo_read(&mEncAudioFifo, mEncAudioFifoOutBuf, nFifoBytes)) == 0)
- #else
--            if (FFmpegLibsInst->av_fifo_generic_read(mEncAudioFifo, mEncAudioFifoOutBuf, nFifoBytes, NULL) == 0)
-+            if (FFMPEG_LIB(av_fifo_generic_read(mEncAudioFifo, mEncAudioFifoOutBuf, nFifoBytes, NULL)) == 0)
- #endif
-             {
-                if (mEncAudioCodecCtx->frame_size != 1)
--                  nEncodedBytes = FFmpegLibsInst->avcodec_encode_audio(mEncAudioCodecCtx, mEncAudioEncodedBuf, mEncAudioEncodedBufSiz, (int16_t*)mEncAudioFifoOutBuf);
-+                  nEncodedBytes = FFMPEG_LIB(avcodec_encode_audio(mEncAudioCodecCtx, mEncAudioEncodedBuf, mEncAudioEncodedBufSiz, (int16_t*)mEncAudioFifoOutBuf));
-                else
--                  nEncodedBytes = FFmpegLibsInst->avcodec_encode_audio(mEncAudioCodecCtx, mEncAudioEncodedBuf, nFifoBytes, (int16_t*)mEncAudioFifoOutBuf);
-+                  nEncodedBytes = FFMPEG_LIB(avcodec_encode_audio(mEncAudioCodecCtx, mEncAudioEncodedBuf, nFifoBytes, (int16_t*)mEncAudioFifoOutBuf));
-             }
- 
-             mEncAudioCodecCtx->frame_size = nFrameSizeTmp;		// restore the native frame size
-@@ -567,13 +591,13 @@
- 
-       // Now flush the encoder.
-       if (nEncodedBytes <= 0)
--         nEncodedBytes = FFmpegLibsInst->avcodec_encode_audio(mEncAudioCodecCtx, mEncAudioEncodedBuf, mEncAudioEncodedBufSiz, NULL);
-+         nEncodedBytes = FFMPEG_LIB(avcodec_encode_audio(mEncAudioCodecCtx, mEncAudioEncodedBuf, mEncAudioEncodedBufSiz, NULL));
- 
-       if (nEncodedBytes <= 0)			
-          break;
- 
-       // Okay, we got a final encoded frame we can write to the output file.
--      FFmpegLibsInst->av_init_packet(&pkt);
-+      FFMPEG_LIB(av_init_packet(&pkt));
- 
-       pkt.stream_index = mEncAudioStream->index;
-       pkt.data = mEncAudioEncodedBuf;
-@@ -582,9 +606,9 @@
- 
-       // Set presentation time of frame (currently in the codec's timebase) in the stream timebase.
-       if(mEncAudioCodecCtx->coded_frame && mEncAudioCodecCtx->coded_frame->pts != int64_t(AV_NOPTS_VALUE))
--         pkt.pts = FFmpegLibsInst->av_rescale_q(mEncAudioCodecCtx->coded_frame->pts, mEncAudioCodecCtx->time_base, mEncAudioStream->time_base);
-+         pkt.pts = FFMPEG_LIB(av_rescale_q(mEncAudioCodecCtx->coded_frame->pts, mEncAudioCodecCtx->time_base, mEncAudioStream->time_base));
- 
--      if (FFmpegLibsInst->av_interleaved_write_frame(mEncFormatCtx, &pkt) != 0)
-+      if (FFMPEG_LIB(av_interleaved_write_frame(mEncFormatCtx, &pkt)) != 0)
-       {
-          wxLogMessage(wxT("FFmpeg : ERROR - Couldn't write last audio frame to output file."));
-          break;
-@@ -592,35 +616,35 @@
-    }
- 
-    // Write any file trailers.
--   FFmpegLibsInst->av_write_trailer(mEncFormatCtx);
-+   FFMPEG_LIB(av_write_trailer(mEncFormatCtx));
- 
-    // Close the codecs.
-    if (mEncAudioStream != NULL)
--      FFmpegLibsInst->avcodec_close(mEncAudioStream->codec);
-+      FFMPEG_LIB(avcodec_close(mEncAudioStream->codec));
- 
-    for (i = 0; i < (int)mEncFormatCtx->nb_streams; i++)
-    {
--      FFmpegLibsInst->av_freep(&mEncFormatCtx->streams[i]->codec);
--      FFmpegLibsInst->av_freep(&mEncFormatCtx->streams[i]);
-+      FFMPEG_LIB(av_freep(&mEncFormatCtx->streams[i]->codec));
-+      FFMPEG_LIB(av_freep(&mEncFormatCtx->streams[i]));
-    }
- 
-    // Close the output file if we created it.
-    if (!(mEncFormatDesc->flags & AVFMT_NOFILE))
--      FFmpegLibsInst->url_fclose(mEncFormatCtx->pb);
-+      FFMPEG_LIB(url_fclose(mEncFormatCtx->pb));
- 
-    // Free any buffers or structures we allocated.
--   FFmpegLibsInst->av_free(mEncFormatCtx);
-+   FFMPEG_LIB(av_free(mEncFormatCtx));
- 
-    if (mEncAudioEncodedBuf != NULL)
--      FFmpegLibsInst->av_free(mEncAudioEncodedBuf);
-+      FFMPEG_LIB(av_free(mEncAudioEncodedBuf));
- 
-    if (mEncAudioFifoOutBuf != NULL)
--      FFmpegLibsInst->av_free(mEncAudioFifoOutBuf);
-+      FFMPEG_LIB(av_free(mEncAudioFifoOutBuf));
- 
- #if FFMPEG_STABLE
--   FFmpegLibsInst->av_fifo_free(&mEncAudioFifo);
-+   FFMPEG_LIB(av_fifo_free(&mEncAudioFifo));
- #else
--   FFmpegLibsInst->av_fifo_free(mEncAudioFifo);
-+   FFMPEG_LIB(av_fifo_free(mEncAudioFifo));
-    mEncAudioFifo = NULL;
- #endif
-    return true;
-@@ -638,33 +662,33 @@
-    nBytesToWrite = frameSize;
-    pRawSamples  = (uint8_t*)pFrame;
- #if FFMPEG_STABLE
--   FFmpegLibsInst->av_fifo_realloc(&mEncAudioFifo, FFmpegLibsInst->av_fifo_size(&mEncAudioFifo) + frameSize);
-+   FFMPEG_LIB(av_fifo_realloc(&mEncAudioFifo, FFMPEG_LIB(av_fifo_size(&mEncAudioFifo)) + frameSize));
- #else
--   FFmpegLibsInst->av_fifo_realloc2(mEncAudioFifo, FFmpegLibsInst->av_fifo_size(mEncAudioFifo) + frameSize);
-+   FFMPEG_LIB(av_fifo_realloc2(mEncAudioFifo, FFMPEG_LIB(av_fifo_size(mEncAudioFifo)) + frameSize));
- #endif
-    // Put the raw audio samples into the FIFO.
- #if FFMPEG_STABLE
--   ret = FFmpegLibsInst->av_fifo_generic_write(&mEncAudioFifo, pRawSamples, nBytesToWrite,NULL);
-+   ret = FFMPEG_LIB(av_fifo_generic_write(&mEncAudioFifo, pRawSamples, nBytesToWrite,NULL));
- #else
--   ret = FFmpegLibsInst->av_fifo_generic_write(mEncAudioFifo, pRawSamples, nBytesToWrite,NULL);
-+   ret = FFMPEG_LIB(av_fifo_generic_write(mEncAudioFifo, pRawSamples, nBytesToWrite,NULL));
- #endif
-    wxASSERT(ret == nBytesToWrite);
- 
-    // Read raw audio samples out of the FIFO in nAudioFrameSizeOut byte-sized groups to encode.
- #if FFMPEG_STABLE
--   while ((ret = FFmpegLibsInst->av_fifo_size(&mEncAudioFifo)) >= nAudioFrameSizeOut)
-+   while ((ret = FFMPEG_LIB(av_fifo_size(&mEncAudioFifo))) >= nAudioFrameSizeOut)
-    {
--      ret = FFmpegLibsInst->av_fifo_read(&mEncAudioFifo, mEncAudioFifoOutBuf, nAudioFrameSizeOut);
-+      ret = FFMPEG_LIB(av_fifo_read(&mEncAudioFifo, mEncAudioFifoOutBuf, nAudioFrameSizeOut));
- #else
--   while ((ret = FFmpegLibsInst->av_fifo_size(mEncAudioFifo)) >= nAudioFrameSizeOut)
-+   while ((ret = FFMPEG_LIB(av_fifo_size(mEncAudioFifo))) >= nAudioFrameSizeOut)
-    {
--      ret = FFmpegLibsInst->av_fifo_generic_read(mEncAudioFifo, mEncAudioFifoOutBuf, nAudioFrameSizeOut, NULL);
-+      ret = FFMPEG_LIB(av_fifo_generic_read(mEncAudioFifo, mEncAudioFifoOutBuf, nAudioFrameSizeOut, NULL));
- #endif
--      FFmpegLibsInst->av_init_packet(&pkt);
-+      FFMPEG_LIB(av_init_packet(&pkt));
- 
--      pkt.size = FFmpegLibsInst->avcodec_encode_audio(mEncAudioCodecCtx, 
-+      pkt.size = FFMPEG_LIB(avcodec_encode_audio(mEncAudioCodecCtx, 
-          mEncAudioEncodedBuf, mEncAudioEncodedBufSiz,		// out
--         (int16_t*)mEncAudioFifoOutBuf);				// in
-+         (int16_t*)mEncAudioFifoOutBuf));				// in
-       if (mEncAudioCodecCtx->frame_size == 1) { wxASSERT(pkt.size == mEncAudioEncodedBufSiz); }
-       if (pkt.size < 0)
-       {
-@@ -674,7 +698,7 @@
- 
-       // Rescale from the codec time_base to the AVStream time_base.
-       if (mEncAudioCodecCtx->coded_frame && mEncAudioCodecCtx->coded_frame->pts != int64_t(AV_NOPTS_VALUE))
--         pkt.pts = FFmpegLibsInst->av_rescale_q(mEncAudioCodecCtx->coded_frame->pts, mEncAudioCodecCtx->time_base, mEncAudioStream->time_base);
-+         pkt.pts = FFMPEG_LIB(av_rescale_q(mEncAudioCodecCtx->coded_frame->pts, mEncAudioCodecCtx->time_base, mEncAudioStream->time_base));
-       //wxLogMessage(wxT("FFmpeg : (%d) Writing audio frame with PTS: %lld."), mEncAudioCodecCtx->frame_number, pkt.pts);
- 
-       pkt.stream_index = mEncAudioStream->index;
-@@ -682,7 +706,7 @@
-       pkt.flags |= PKT_FLAG_KEY;
- 
-       // Write the encoded audio frame to the output file.
--      if ((ret = FFmpegLibsInst->av_interleaved_write_frame(mEncFormatCtx, &pkt)) != 0)
-+      if ((ret = FFMPEG_LIB(av_interleaved_write_frame(mEncFormatCtx, &pkt))) != 0)
-       {
-          wxLogMessage(wxT("FFmpeg : ERROR - Failed to write audio frame to file."));
-          return false;
-@@ -696,8 +720,10 @@
-                        int channels, wxString fName,
-                        bool selectionOnly, double t0, double t1, MixerSpec *mixerSpec, Tags *metadata, int subformat)
- {
-+#ifndef DISABLE_DYNAMIC_LOADING_FFMPEG
-    if (!CheckFFmpegPresence())
-       return false;
-+#endif //DISABLE_DYNAMIC_LOADING_FFMPEG
-    mChannels = channels;
-    // subformat index may not correspond directly to fmts[] index, convert it
-    mSubFormat = AdjustFormatIndex(subformat);
-@@ -871,8 +897,10 @@
- 
- bool ExportFFmpeg::DisplayOptions(wxWindow *parent, int format)
- {
-+#ifndef DISABLE_DYNAMIC_LOADING_FFMPEG
-    if (!CheckFFmpegPresence())
-       return false;
-+#endif //DISABLE_DYNAMIC_LOADING_FFMPEG
-    // subformat index may not correspond directly to fmts[] index, convert it
-    mSubFormat = AdjustFormatIndex(format);
-    if (mSubFormat == FMT_M4A)
---- a/src/export/ExportFFmpegDialogs.cpp
-+++ b/src/export/ExportFFmpegDialogs.cpp
-@@ -73,8 +73,6 @@
- 
- #if defined(USE_FFMPEG)
- 
--extern FFmpegLibs *FFmpegLibsInst;
--
- /// This construction defines a enumeration of UI element IDs, and a static
- /// array of their string representations (this way they're always synchronized).
- /// Do not store the enumerated values in external files, as they may change;
-@@ -1291,7 +1289,9 @@
- {
-    delete mPresets;
-    delete mPresetNames;
-+#ifndef DISABLE_DYNAMIC_LOADING_FFMPEG
-    DropFFmpegLibs();
-+#endif //DISABLE_DYNAMIC_LOADING_FFMPEG
- }
- 
- ExportFFmpegOptions::ExportFFmpegOptions(wxWindow *parent)
-@@ -1299,13 +1299,17 @@
-             wxString(_("Specify Other Options")))
- {
-    ShuttleGui S(this, eIsCreatingFromPrefs);
-+#ifndef DISABLE_DYNAMIC_LOADING_FFMPEG
-    PickFFmpegLibs();
-+#endif //DISABLE_DYNAMIC_LOADING_FFMPEG
-    //FFmpegLibsInst->LoadLibs(NULL,true); //Loaded at startup or from Prefs now
- 
-    mPresets = new FFmpegPresets();
-    mPresetNames = mPresets->GetPresetList();
- 
-+#ifndef DISABLE_DYNAMIC_LOADING_FFMPEG
-    if (FFmpegLibsInst->ValidLibsLoaded())
-+#endif //DISABLE_DYNAMIC_LOADING_FFMPEG
-    {
-       FetchFormatList();
-       FetchCodecList();
-@@ -1329,7 +1333,7 @@
-       DoOnFormatList();
- 
-       //Select the codec that was selected last time this dialog was closed
--      AVCodec *codec = FFmpegLibsInst->avcodec_find_encoder((CodecID)gPrefs->Read(wxT("/FileFormats/FFmpegCodec"),(long)CODEC_ID_NONE));
-+      AVCodec *codec = FFMPEG_LIB(avcodec_find_encoder((CodecID)gPrefs->Read(wxT("/FileFormats/FFmpegCodec"),(long)CODEC_ID_NONE)));
-       if (codec != NULL) mCodecList->Select(mCodecList->FindString(wxString::FromUTF8(codec->name)));
-       DoOnCodecList();
-    }
-@@ -1342,7 +1346,7 @@
- {
-    // Enumerate all output formats
-    AVOutputFormat *ofmt = NULL;
--   while ((ofmt = FFmpegLibsInst->av_oformat_next(ofmt)))
-+   while ((ofmt = FFMPEG_LIB(av_oformat_next(ofmt))))
-    {
-       // Any audio-capable format has default audio codec.
-       // If it doesn't, then it doesn't supports any audio codecs
-@@ -1363,7 +1367,7 @@
- {
-    // Enumerate all codecs
-    AVCodec *codec = NULL;
--   while ((codec = FFmpegLibsInst->av_codec_next(codec)))
-+   while ((codec = FFMPEG_LIB(av_codec_next(codec))))
-    {
-       // We're only interested in audio and only in encoders
-       if (codec->type == CODEC_TYPE_AUDIO && codec->encode)
-@@ -1604,7 +1608,7 @@
-             break;
-          }
-          // Find the codec, that is claimed to be compatible
--         AVCodec *codec = FFmpegLibsInst->avcodec_find_encoder(CompatibilityList[i].codec);
-+         AVCodec *codec = FFMPEG_LIB(avcodec_find_encoder(CompatibilityList[i].codec));
-          // If it exists, is audio and has encoder
-          if (codec != NULL && (codec->type == CODEC_TYPE_AUDIO) && codec->encode)
-          {
-@@ -1619,7 +1623,7 @@
-    if (found == 2)
-    {
-       AVCodec *codec = NULL;
--      while ((codec = FFmpegLibsInst->av_codec_next(codec)))
-+      while ((codec = FFMPEG_LIB(av_codec_next(codec))))
-       {
-          if (codec->type == CODEC_TYPE_AUDIO && codec->encode)
-          {
-@@ -1637,10 +1641,14 @@
-    else if (found == 0)
-    {
-       wxCharBuffer buf = str.ToUTF8();
--      AVOutputFormat *format = FFmpegLibsInst->guess_format(buf,NULL,NULL);
-+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 64, 0)
-+      AVOutputFormat *format = FFMPEG_LIB(guess_format(buf,NULL,NULL));
-+#else
-+      AVOutputFormat *format = FFMPEG_LIB(av_guess_format(buf,NULL,NULL));
-+#endif
-       if (format != NULL)
-       {
--         AVCodec *codec = FFmpegLibsInst->avcodec_find_encoder(format->audio_codec);
-+         AVCodec *codec = FFMPEG_LIB(avcodec_find_encoder(format->audio_codec));
-          if (codec != NULL && (codec->type == CODEC_TYPE_AUDIO) && codec->encode)
-          {
-             if ((id >= 0) && codec->id == id) index = mShownCodecNames.GetCount();
-@@ -1674,7 +1682,11 @@
-          if ((selfmt != NULL) && (selfmt->Cmp(CompatibilityList[i].fmt) == 0)) index = mShownFormatNames.GetCount();
-          FromList.Add(CompatibilityList[i].fmt);
-          mShownFormatNames.Add(CompatibilityList[i].fmt);
--         AVOutputFormat *tofmt = FFmpegLibsInst->guess_format(wxString(CompatibilityList[i].fmt).ToUTF8(),NULL,NULL);
-+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 64, 0)
-+         AVOutputFormat *tofmt = FFMPEG_LIB(guess_format(wxString(CompatibilityList[i].fmt).ToUTF8(),NULL,NULL));
-+#else
-+         AVOutputFormat *tofmt = FFMPEG_LIB(av_guess_format(wxString(CompatibilityList[i].fmt).ToUTF8(),NULL,NULL));
-+#endif
-          if (tofmt != NULL) mShownFormatLongNames.Add(wxString::Format(wxT("%s - %s"),CompatibilityList[i].fmt,wxString::FromUTF8(tofmt->long_name).c_str()));
-       }
-    }
-@@ -1694,7 +1706,7 @@
-    if (found)
-    {
-       // Find all formats which have this codec as default and which are not in the list yet and add them too
--      while ((ofmt = FFmpegLibsInst->av_oformat_next(ofmt)))
-+      while ((ofmt = FFMPEG_LIB(av_oformat_next(ofmt))))
-       {
-          if (ofmt->audio_codec == id)
-          {
-@@ -1879,7 +1891,11 @@
-    wxString *selcdclong = NULL;
-    FindSelectedCodec(&selcdc, &selcdclong);
- 
--   AVOutputFormat *fmt = FFmpegLibsInst->guess_format(selfmt->ToUTF8(),NULL,NULL);
-+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 64, 0)
-+   AVOutputFormat *fmt = FFMPEG_LIB(guess_format(selfmt->ToUTF8(),NULL,NULL));
-+#else
-+   AVOutputFormat *fmt = FFMPEG_LIB(av_guess_format(selfmt->ToUTF8(),NULL,NULL));
-+#endif
-    if (fmt == NULL)
-    {
-       //This shouldn't really happen
-@@ -1891,7 +1907,7 @@
- 
-    if (selcdc != NULL)
-    {
--      AVCodec *cdc = FFmpegLibsInst->avcodec_find_encoder_by_name(selcdc->ToUTF8());
-+      AVCodec *cdc = FFMPEG_LIB(avcodec_find_encoder_by_name(selcdc->ToUTF8()));
-       if (cdc != NULL)
-       {
-          selcdcid = cdc->id;
-@@ -1902,7 +1918,7 @@
- 
-    AVCodec *cdc = NULL;
-    if (selcdc != NULL)
--      cdc = FFmpegLibsInst->avcodec_find_encoder_by_name(selcdc->ToUTF8());
-+      cdc = FFMPEG_LIB(avcodec_find_encoder_by_name(selcdc->ToUTF8()));
-    EnableDisableControls(cdc, selfmt);
-    Layout();
-    Fit();
-@@ -1923,7 +1939,7 @@
-    wxString *selfmtlong = NULL;
-    FindSelectedFormat(&selfmt, &selfmtlong);
- 
--   AVCodec *cdc = FFmpegLibsInst->avcodec_find_encoder_by_name(selcdc->ToUTF8());
-+   AVCodec *cdc = FFMPEG_LIB(avcodec_find_encoder_by_name(selcdc->ToUTF8()));
-    if (cdc == NULL)
-    {
-       //This shouldn't really happen
-@@ -1934,7 +1950,11 @@
- 
-    if (selfmt != NULL)
-    {
--      AVOutputFormat *fmt = FFmpegLibsInst->guess_format(selfmt->ToUTF8(),NULL,NULL);
-+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 64, 0)
-+      AVOutputFormat *fmt = FFMPEG_LIB(guess_format(selfmt->ToUTF8(),NULL,NULL));
-+#else
-+      AVOutputFormat *fmt = FFMPEG_LIB(av_guess_format(selfmt->ToUTF8(),NULL,NULL));
-+#endif
-       if (fmt == NULL)
-       {
-          selfmt = NULL;
-@@ -1971,7 +1991,7 @@
- {
-    int selcdc = mCodecList->GetSelection();
-    int selfmt = mFormatList->GetSelection();
--   if (selcdc > -1) gPrefs->Write(wxT("/FileFormats/FFmpegCodec"),(long)FFmpegLibsInst->avcodec_find_encoder_by_name(mCodecList->GetString(selcdc).ToUTF8())->id);
-+   if (selcdc > -1) gPrefs->Write(wxT("/FileFormats/FFmpegCodec"),(long)FFMPEG_LIB(avcodec_find_encoder_by_name(mCodecList->GetString(selcdc).ToUTF8()))->id);
-    if (selfmt > -1) gPrefs->Write(wxT("/FileFormats/FFmpegFormat"),mFormatList->GetString(selfmt));
-    ShuttleGui S(this, eIsSavingToPrefs);
-    PopulateOrExchange(S);
---- a/src/import/ImportFFmpeg.cpp
-+++ b/src/import/ImportFFmpeg.cpp
-@@ -159,8 +159,6 @@
- #include "../ondemand/ODDecodeFFmpegTask.h"
- #endif
- 
--extern FFmpegLibs *FFmpegLibsInst;
--
- class FFmpegImportFileHandle;
- //moving from ImportFFmpeg.cpp to FFMpeg.h so other cpp files can use this struct.
- #ifndef EXPERIMENTAL_OD_FFMPEG
-@@ -319,6 +317,7 @@
-       //insdead of usual wxMessageBox()
-       bool newsession = false;
-       gPrefs->Read(wxT("/NewImportingSession"), &newsession);
-+#ifndef DISABLE_DYNAMIC_LOADING_FFMPEG
-       if (!FFmpegLibsInst->ValidLibsLoaded())
-       {
-          int dontShowDlg;
-@@ -332,12 +331,15 @@
-             delete dlg;
-          }         
-       }
-+#endif //DISABLE_DYNAMIC_LOADING_FFMPEG
-    }
-+#ifndef DISABLE_DYNAMIC_LOADING_FFMPEG
-    if (!FFmpegLibsInst->ValidLibsLoaded())
-    {
-       delete handle;
-       return NULL;
-    }
-+#endif //DISABLE_DYNAMIC_LOADING_FFMPEG
- 
-    // Open the file for import  
-    bool success = handle->Init();
-@@ -353,7 +355,9 @@
- FFmpegImportFileHandle::FFmpegImportFileHandle(const wxString & name)
- :  ImportFileHandle(name)
- {
-+#ifndef DISABLE_DYNAMIC_LOADING_FFMPEG
-    PickFFmpegLibs();
-+#endif //DISABLE_DYNAMIC_LOADING_FFMPEG
- 
-    mStreamInfo = new wxArrayString();
-    mFormatContext = NULL;
-@@ -371,9 +375,11 @@
- {
-    //FFmpegLibsInst->LoadLibs(NULL,false); //Loaded at startup or from Prefs now
- 
-+#ifndef DISABLE_DYNAMIC_LOADING_FFMPEG
-    if (!FFmpegLibsInst->ValidLibsLoaded()) return false;
-+#endif //DISABLE_DYNAMIC_LOADING_FFMPEG
- 
--   FFmpegLibsInst->av_log_set_callback(av_log_wx_callback);
-+   FFMPEG_LIB(av_log_set_callback(av_log_wx_callback));
- 
-    int err = ufile_fopen_input(&mFormatContext, mName);
-    if (err < 0)
-@@ -382,7 +388,7 @@
-       return false;
-    }
- 
--   err = FFmpegLibsInst->av_find_stream_info(mFormatContext);
-+   err = FFMPEG_LIB(av_find_stream_info(mFormatContext));
-    if (err < 0)
-    {
-       wxLogMessage(wxT("FFmpeg : av_find_stream_info() failed for file %s"),mName.c_str());
-@@ -410,7 +416,7 @@
-          sc->m_stream = mFormatContext->streams[i];
-          sc->m_codecCtx = sc->m_stream->codec;
- 
--         AVCodec *codec = FFmpegLibsInst->avcodec_find_decoder(sc->m_codecCtx->codec_id);
-+         AVCodec *codec = FFMPEG_LIB(avcodec_find_decoder(sc->m_codecCtx->codec_id));
-          if (codec == NULL)
-          {
-             wxLogMessage(wxT("FFmpeg : avcodec_find_decoder() failed. Index[%02d], Codec[%02x - %s]"),i,sc->m_codecCtx->codec_id,sc->m_codecCtx->codec_name);
-@@ -426,7 +432,7 @@
-             continue;
-          }
- 
--         if (FFmpegLibsInst->avcodec_open(sc->m_codecCtx, codec) < 0)
-+         if (FFMPEG_LIB(avcodec_open(sc->m_codecCtx, codec) < 0))
-          {
-             wxLogMessage(wxT("FFmpeg : avcodec_open() failed. Index[%02d], Codec[%02x - %s]"),i,sc->m_codecCtx->codec_id,sc->m_codecCtx->codec_name);
-             //Can't open decoder - skip this stream
-@@ -631,7 +637,7 @@
- #if FFMPEG_STABLE
-             av_free_packet(&sc->m_pkt);
- #else
--            FFmpegLibsInst->av_free_packet(&sc->m_pkt);
-+            FFMPEG_LIB(av_free_packet(&sc->m_pkt));
- #endif
-             sc->m_pktValid = 0;
-          }    
-@@ -652,7 +658,7 @@
- #if FFMPEG_STABLE
-                av_free_packet(&mScs[i]->m_pkt);
- #else
--               FFmpegLibsInst->av_free_packet(&mScs[i]->m_pkt);
-+               FFMPEG_LIB(av_free_packet(&mScs[i]->m_pkt));
- #endif
-                mScs[i]->m_pktValid = 0;
-             }				
-@@ -707,7 +713,7 @@
-    streamContext *sc = NULL;
-    AVPacket pkt;
- 
--   if (FFmpegLibsInst->av_read_frame(mFormatContext,&pkt) < 0)
-+   if (FFMPEG_LIB(av_read_frame(mFormatContext,&pkt)) < 0)
-    {
-       return NULL;
-    }
-@@ -726,7 +732,7 @@
- #if FFMPEG_STABLE
-       av_free_packet(&pkt);
- #else
--      FFmpegLibsInst->av_free_packet(&pkt);
-+      FFMPEG_LIB(av_free_packet(&pkt));
- #endif
-       return (streamContext*)1;
-    }
-@@ -772,10 +778,10 @@
-       //\warning { for some reason using the following macro call right in the function call
-       // causes Audacity to crash in some unknown place. With "newsize" it works fine }
-       int newsize = FFMAX(sc->m_pkt.size*sizeof(*sc->m_decodedAudioSamples), AVCODEC_MAX_AUDIO_FRAME_SIZE);
--      sc->m_decodedAudioSamples = (int16_t*)FFmpegLibsInst->av_fast_realloc(sc->m_decodedAudioSamples, 
-+      sc->m_decodedAudioSamples = (int16_t*)FFMPEG_LIB(av_fast_realloc(sc->m_decodedAudioSamples, 
-          &sc->m_decodedAudioSamplesSiz,
-          newsize
--         );
-+         ));
- 
-       if (sc->m_decodedAudioSamples == NULL)
-       {
-@@ -787,10 +793,10 @@
-    // avcodec_decode_audio2() expects the size of the output buffer as the 3rd parameter but
-    // also returns the number of bytes it decoded in the same parameter.
-    sc->m_decodedAudioSamplesValidSiz = sc->m_decodedAudioSamplesSiz;
--   nBytesDecoded = FFmpegLibsInst->avcodec_decode_audio2(sc->m_codecCtx, 
-+   nBytesDecoded = FFMPEG_LIB(avcodec_decode_audio2(sc->m_codecCtx, 
-       sc->m_decodedAudioSamples,		      // out
-       &sc->m_decodedAudioSamplesValidSiz,	// in/out
--      pDecode, nDecodeSiz);				   // in
-+      pDecode, nDecodeSiz));				   // in
- 
-    if (nBytesDecoded < 0)
-    {
-@@ -866,7 +872,7 @@
-    // Try to update the progress indicator (and see if user wants to cancel)
-    int updateResult = eProgressSuccess;
-    // PTS (presentation time) is the proper way of getting current position
--   if (sc->m_pkt.pts != AV_NOPTS_VALUE && mFormatContext->duration != AV_NOPTS_VALUE)
-+   if (sc->m_pkt.pts != int64_t(AV_NOPTS_VALUE) && mFormatContext->duration != int64_t(AV_NOPTS_VALUE))
-    {
-       mProgressPos = sc->m_pkt.pts * sc->m_stream->time_base.num / sc->m_stream->time_base.den;
-       mProgressLen = (mFormatContext->duration > 0 ? mFormatContext->duration / AV_TIME_BASE: 1);
-@@ -912,16 +918,18 @@
-    if(!mUsingOD)
-    {
- #endif
-+#ifndef DISABLE_DYNAMIC_LOADING_FFMPEG
-    if (FFmpegLibsInst->ValidLibsLoaded())
-+#endif //DISABLE_DYNAMIC_LOADING_FFMPEG
-    {
--      if (mFormatContext) FFmpegLibsInst->av_close_input_file(mFormatContext);
--      FFmpegLibsInst->av_log_set_callback(FFmpegLibsInst->av_log_default_callback);
-+      if (mFormatContext) FFMPEG_LIB(av_close_input_file(mFormatContext));
-+      FFMPEG_LIB(av_log_set_callback(FFMPEG_LIB(av_log_default_callback)));
-    }
- 
-    for (int i = 0; i < mNumStreams; i++)
-    {
-       if (mScs[i]->m_decodedAudioSamples != NULL)
--         FFmpegLibsInst->av_free(mScs[i]->m_decodedAudioSamples);
-+         FFMPEG_LIB(av_free(mScs[i]->m_decodedAudioSamples));
- 
-       delete mScs[i];
-    }
-@@ -933,7 +941,9 @@
- 
-    delete mStreamInfo;
- 
-+#ifndef DISABLE_DYNAMIC_LOADING_FFMPEG
-    DropFFmpegLibs();
-+#endif //DISABLE_DYNAMIC_LOADING_FFMPEG
- }
- 
- #endif //USE_FFMPEG
---- a/src/prefs/LibraryPrefs.cpp
-+++ b/src/prefs/LibraryPrefs.cpp
-@@ -129,6 +129,10 @@
-          S.Id(ID_FFMPEG_DOWN_BUTTON);
-          wxButton *bdwn = S.AddButton(_("Dow&nload"),
-                                       wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
-+#ifdef DISABLE_DYNAMIC_LOADING_FFMPEG
-+         bdwn->Enable(FALSE);
-+         bfnd->Enable(FALSE);
-+#endif //DISABLE_DYNAMIC_LOADING_FFMPEG
- #if !defined(USE_FFMPEG)
-          bdwn->Enable(FALSE);
-          bfnd->Enable(FALSE);
-@@ -163,12 +167,22 @@
- 
- void LibraryPrefs::SetFFmpegVersionText()
- {
-+#ifdef DISABLE_DYNAMIC_LOADING_FFMPEG
-+   int avcver = avcodec_version();
-+   int avfver = avformat_version();
-+   int avuver = avutil_version();
-+   mFFmpegVersion->SetLabel(wxString::Format(wxT("F(%d.%d.%d),C(%d.%d.%d),U(%d.%d.%d)"),
-+                                             avfver >> 16 & 0xFF, avfver >> 8 & 0xFF, avfver & 0xFF,
-+                                             avcver >> 16 & 0xFF, avcver >> 8 & 0xFF, avcver & 0xFF,
-+                                             avuver >> 16 & 0xFF, avuver >> 8 & 0xFF, avuver & 0xFF));
-+#else //DISABLE_DYNAMIC_LOADING_FFMPEG
-    mFFmpegVersion->SetLabel(GetFFmpegVersion(this));
-+#endif //DISABLE_DYNAMIC_LOADING_FFMPEG
- }
- 
- void LibraryPrefs::OnFFmpegFindButton(wxCommandEvent & e)
- {
--#ifdef USE_FFMPEG
-+#ifndef DISABLE_DYNAMIC_LOADING_FFMPEG
-    FFmpegLibs* FFmpegLibsInst = PickFFmpegLibs();
-    bool showerrs =
- #if defined(__WXDEBUG__)
-@@ -200,7 +214,7 @@
-    SetFFmpegVersionText();
- 
-    DropFFmpegLibs();
--#endif
-+#endif //DISABLE_DYNAMIC_LOADING_FFMPEG
- }
- 
- void LibraryPrefs::OnFFmpegDownButton(wxCommandEvent & e)
diff --git a/debian/patches/series b/debian/patches/series
index 907f0a4..ceadbe1 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,2 @@
-disable-dynamic-loading.patch
-disable-dynamic-loading-lame.patch
-configure.patch
+disable-dynamic-ffmpeg.patch
+disable-dynamic-lame.patch

-- 
Audacity debian packaging



More information about the pkg-multimedia-commits mailing list