From f0112b57dfac4d9afc86ce671e3127f6bf7a4cc1 Mon Sep 17 00:00:00 2001 From: "v.audacity" Date: Wed, 29 Aug 2012 21:31:11 +0000 Subject: [PATCH] Benjamin Drung's disable-dynamic-ffmpeg-v3.patch for bug 233 --- configure.in | 6 ++++++ m4/audacity_checklib_ffmpeg.m4 | 4 ++++ src/FFmpeg.cpp | 13 ++++++++++++- src/FFmpeg.h | 13 +++++++++++++ src/configtemplate.h | 3 +++ src/prefs/LibraryPrefs.cpp | 2 +- 6 files changed, 39 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index b1878292b..4df8c1c0c 100644 --- a/configure.in +++ b/configure.in @@ -180,6 +180,12 @@ AC_ARG_ENABLE(sse, [AC_HELP_STRING([--enable-sse],[enable SSE optimizations])], AC_ARG_ENABLE(universal_binary,[ --enable-universal_binary enable universal binary build: (default: disable)],[enable_universal_binary=$enableval],[enable_universal_binary=no]) +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,]])], diff --git a/m4/audacity_checklib_ffmpeg.m4 b/m4/audacity_checklib_ffmpeg.m4 index 41030747b..5fbeeb605 100644 --- a/m4/audacity_checklib_ffmpeg.m4 +++ b/m4/audacity_checklib_ffmpeg.m4 @@ -35,6 +35,10 @@ AC_DEFUN([AUDACITY_CHECKLIB_FFMPEG], [ 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 \ diff --git a/src/FFmpeg.cpp b/src/FFmpeg.cpp index 7739a133a..fe79d8b03 100644 --- a/src/FFmpeg.cpp +++ b/src/FFmpeg.cpp @@ -754,6 +754,10 @@ bool FFmpegLibs::FindLibs(wxWindow *parent) 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()) { @@ -837,6 +841,7 @@ bool FFmpegLibs::ValidLibsLoaded() bool FFmpegLibs::InitLibs(wxString libpath_format, bool showerr) { +#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) FreeLibs(); #if defined(__WXMSW__) @@ -1050,8 +1055,10 @@ bool FFmpegLibs::InitLibs(wxString libpath_format, bool showerr) FFMPEG_INITDYN(avutil, av_rescale_q); FFMPEG_INITDYN(avutil, avutil_version); - //FFmpeg initialization wxLogMessage(wxT("All symbols loaded successfully. Initializing the library.")); +#endif + + //FFmpeg initialization avcodec_init(); avcodec_register_all(); av_register_all(); @@ -1090,7 +1097,11 @@ bool FFmpegLibs::InitLibs(wxString libpath_format, bool showerr) return false; } +#if defined(DISABLE_DYNAMIC_LOADING_FFMPEG) && (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; } diff --git a/src/FFmpeg.h b/src/FFmpeg.h index e89cb0474..2ed4c06dc 100644 --- a/src/FFmpeg.h +++ b/src/FFmpeg.h @@ -368,6 +368,18 @@ streamContext *import_ffmpeg_read_next_frame(AVFormatContext* formatContext, int import_ffmpeg_decode_frame(streamContext *sc, bool flushing); +#if defined(DISABLE_DYNAMIC_LOADING_FFMPEG) + // Use the preprocessor to rename old function names instead of checking the + // function names with FFMPEG_INITALT when loading the library. + + #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 60, 0) + #define av_match_ext match_ext + #endif + + #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 64, 0) + #define av_guess_format guess_format + #endif +#else extern "C" { // A little explanation of what's going on here. // @@ -900,6 +912,7 @@ extern "C" { (protocol, size) ); }; +#endif #endif // USE_FFMPEG #endif // __AUDACITY_FFMPEG__ diff --git a/src/configtemplate.h b/src/configtemplate.h index a6182e07d..e9badaa39 100644 --- a/src/configtemplate.h +++ b/src/configtemplate.h @@ -87,6 +87,9 @@ /* Use system LAME library and disable dynamic loading of it. */ #undef DISABLE_DYNAMIC_LOADING_LAME +/* 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 diff --git a/src/prefs/LibraryPrefs.cpp b/src/prefs/LibraryPrefs.cpp index 31ddbe180..4a477fada 100644 --- a/src/prefs/LibraryPrefs.cpp +++ b/src/prefs/LibraryPrefs.cpp @@ -133,7 +133,7 @@ void LibraryPrefs::PopulateOrExchange(ShuttleGui & S) 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