[gimp-gap] fixes for build in MinGW Windows environment



commit 01d94ca976fae3ce7ecfb6b25adb3df894fa12d4
Author: Wolfgang Hofer <wolfgangh svn gnome org>
Date:   Sun Sep 18 08:42:32 2011 +0200

    fixes for build in MinGW Windows environment

 ChangeLog                                      |   23 ++++++++++
 autogen.sh                                     |    2 +-
 configure.in                                   |   57 +++++++++++++++++------
 extern_libs/Makefile.am                        |    1 +
 extern_libs/configure_options_ffmpeg.txt       |    9 +++-
 extern_libs/configure_options_ffmpeg_win32.txt |   46 +++++++++++++++++++
 gap/gap_frame_fetcher.c                        |   22 ++++++---
 libgapbase/gap_base.c                          |   20 +++++---
 vid_enc_avi/gap_enc_avi_main.c                 |    2 +-
 vid_enc_ffmpeg/gap_enc_ffmpeg_main.c           |    2 +-
 vid_enc_rawframes/gap_enc_rawframes_main.c     |    2 +-
 vid_enc_single/gap_enc_singleframes_main.c     |    2 +-
 12 files changed, 151 insertions(+), 37 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ba66a01..88a89b3 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2011-09-18 Wolfgang Hofer <hof gimp org>
+
+- fixed configure / compile problems in MinGW environment
+  Now the configure script is using a MinGW variant of ffmpeg_configure options
+  The configuration that built usable Winows video encoder plug-in.exe files im my tests
+  is now the default setting in MinGW environment.
+  see extern_libs/configure_options_ffmpeg_win32.txt for more details.
+
+- fixed "array subscript is above array bounds" error in run procedures of the video encoder plu-ins 
+
+ * configure.in
+ * autogen.sh
+ * extern_libs/configure_options_ffmpeg_win32.txt       #new file
+ * extern_libs/configure_options_ffmpeg.txt
+ * extern_libs/Makefile.am
+ * libgapbase/gap_base.c
+ * gap/gap_frame_fetcher.c
+ 
+ * vid_enc_single/gap_enc_singleframes_main.c
+ * vid_enc_rawframes/gap_enc_rawframes_main.c
+ * vid_enc_ffmpeg/gap_enc_ffmpeg_main.c
+ * vid_enc_avi/gap_enc_main_avi.c
+
 2011-05-08 Wolfgang Hofer <hof gimp org>
 
 - added edit button in the Storyboard attributes dialog
diff --git a/autogen.sh b/autogen.sh
index b547acf..b53db5d 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,7 +1,7 @@
 #!/bin/sh 
 
 # This script does all the magic calls to automake/autoconf and
-# friends that are needed to configure a cvs checkout.  You need a
+# friends that are needed to configure a git checkout.  You need a
 # couple of extra tools to run this script successfully.
 #
 # If you are compiling from a released tarball you don't need these
diff --git a/configure.in b/configure.in
old mode 100755
new mode 100644
index 49113c2..9a0a681
--- a/configure.in
+++ b/configure.in
@@ -151,7 +151,14 @@ and OLD mpeg encoders.
 
 AM_CONDITIONAL(GAP_UNIX_FRONTENDS, test "x$enable_unix_frontends" != "xno")
 
-
+dnl check for sysinfo header (optional for reporting resource usage in developer debug messages)
+dnl see gap_frame_fetcher.c procedure p_dump_process_resource_usage
+dnl the check result has no impact on productive features.
+no_sysinfo=""
+AC_CHECK_HEADER(sys/sysinfo.h,
+          AC_DEFINE(GAP_HAVE_SYSINFO, 1,
+              [Define to 1 if you have the <sys/sysinfo.h> header file.]),
+          no_sysinfo="optional sysinfo header file (sys/sysinfo.h) not found Not critical.")
 
 dnl check for pthread library (required for libmpeg3 and recent versions of the xvid library)
 dnl the check result does not matter unless libmpeg3 or xvid is linked or built later on.
@@ -167,21 +174,35 @@ AC_CHECK_LIB(pthread, pthread_create,
               [Define to 1 if you have the <pthread.h> header file.])
   fi
 
+
 dnl check for bzip2 library (for ffmpeg matroskadec )
 dnl the check result does not matter unless libavformat is linked or built later on.
+dnl note: the procedures (BZ2_bzDecompressInit) of the bzip2 lib have different number
+dnl of parameters when compiled in Windows environment, therefore the check via AC_CHECK_LIB
+dnl fails on MinGW Windows environment, even if libbzip2 is available and proper installed.
+dnl therfore i decided to skip this check on Win32 systems.
 FF_BZIP2=""
 ffbz2_warn=""
 AC_ARG_ENABLE(ff_libbz2,
               [  --disable-ff-libbz2          configure libavformat without libbz2 disables matroskadec bz2 support])
   if test "x$enable_ff_libbz2" != "xno"; then
-    AC_CHECK_LIB(bz2, BZ2_bzDecompressInit,
+    if test "x$os_win32" = "xyes"; then
+      AC_CHECK_HEADER(bzlib.h,
+          FF_BZIP2="-lbz2",
+          ffbz2_warn="$NEW_LINE ** bzip2 header file (bzlib.h) not found (limited support for ffmpeg matroskadec codec )")
+    else
+      AC_CHECK_LIB(bz2, BZ2_bzDecompressInit,
         [AC_CHECK_HEADER(bzlib.h,
           FF_BZIP2="-lbz2",
           ffbz2_warn="$NEW_LINE ** bzip2 header file (bzlib.h) not found (limited support for ffmpeg matroskadec codec )")],
       ffbz2_warn="bzip2 library (libbz2) not found (there will be limited support)")    
+    fi
   fi
 
 
+
+
+
 dnl ## libmp3lame lame/lame.h lame_init -lmp3lame -lm
 
 dnl check for libmp3lame library (useful for ffmpeg audio MP3 support)
@@ -498,7 +519,11 @@ INFORMATION: old ffmpeg was moved to $FFMPEG_DIR-OLD
 
       dnl read configure options for the external lib from a file      
       dnl the current simple implementation requires all options in one line
-      FFMPEG_CONFIGURE_OPTIONS=`cat "$extern_libs_dir/configure_options_ffmpeg.txt" | grep -v '^#'`
+      if  test "x$os_win32" = "xyes"; then
+         FFMPEG_CONFIGURE_OPTIONS=`cat "$extern_libs_dir/configure_options_ffmpeg_win32.txt" | grep -v '^#'`
+      else
+         FFMPEG_CONFIGURE_OPTIONS=`cat "$extern_libs_dir/configure_options_ffmpeg.txt" | grep -v '^#'`
+      fi
       
       ff_pass_through_flags=""
       if test "x$prefix" != "x"; then
@@ -549,19 +574,13 @@ INFORMATION: old ffmpeg was moved to $FFMPEG_DIR-OLD
 
       dnl configure ffmpeg libxvid usage (for optional open xvid codec support via libxvid)
       if test "x$FF_LIBXVID" != "x"; then
-      	 FFMPEG_CONFIGURE_OPTIONS="$FFMPEG_CONFIGURE_OPTIONS --enable-pthreads --enable-libxvid"
+      	 dnl  --enable-pthreads is no longer mandatory when libxvid is enabled
+      	 FFMPEG_CONFIGURE_OPTIONS="$FFMPEG_CONFIGURE_OPTIONS --enable-libxvid"
       fi
 
       dnl in case nonfree libs are used ffmeg 0.6 configure requires --enable-nonfree
       FFMPEG_CONFIGURE_OPTIONS="$FFMPEG_CONFIGURE_OPTIONS $FFMPEG_ENABLE_NONFREE"
       
-      if  test "x$os_win32" = "xyes"; then
-         dnl here we could check for required win32 api version on MonGW Win32 Systems.
-         dnl for now always disable devices on MinGW (that requires latest win32 api to compile)
-         dnl disabling devices is not critical since GIMP-GAP does not use ffmpeg features that
-         dnl require other access than plain videofile io.
-      	 FFMPEG_CONFIGURE_OPTIONS="$FFMPEG_CONFIGURE_OPTIONS --disable-devices"
-      fi
 
       echo "================================="
       echo "Calling FFMPEG configure script options: $FFMPEG_CONFIGURE_OPTIONS"
@@ -1016,7 +1035,14 @@ dnl
 GTHREAD_LIBS=`$PKG_CONFIG --libs gthread-2.0`
 AC_SUBST(GTHREAD_LIBS)
 
-GAPVIDEOAPI_EXTLIBS="\$(GAP_VLIBS_FFMPEG) \$(GAP_VLIBS_MPEG3) -lpng -lz \$(GTHREAD_LIBS) \$(GAP_PTHREAD_LIB) -lm"
+PKGCONFIG=`type pkg-config`
+if test -x "$(PKGCONFIG)" ; then
+  GAP_VLIBS_PNG=`$(PKGCONFIG) --libs libpng`
+else
+  GAP_VLIBS_PNG="-lpng14"
+fi
+
+GAPVIDEOAPI_EXTLIBS="\$(GAP_VLIBS_FFMPEG) \$(GAP_VLIBS_MPEG3) \$(GAP_VLIBS_PNG) -lz \$(GTHREAD_LIBS) \$(GAP_PTHREAD_LIB) -lm"
 GAPVIDEOAPI_EXTINCS="\$(GAP_VINCS_FFMPEG) \$(GAP_VINCS_MPEG3)"
 AC_SUBST(GAPVIDEOAPI_EXTLIBS)
 AC_SUBST(GAPVIDEOAPI_EXTINCS)
@@ -1065,19 +1091,20 @@ AM_CONDITIONAL(BUILD_FFMPEG_LIBS, test "x$build_ffmpeg_libs_yesno" != "xno")
 AM_CONDITIONAL(BUILD_LIBMPEG3_LIB, test "x$build_libmpeg3_lib_yesno" != "xno")
 
 dnl
-dnl runtime recording is primary a developers feature
+dnl runtime recording is primary a developers feature 
 dnl for analyse and performance tuning purpose.
 dnl
-AC_ARG_ENABLE(runtime_recording,
+AC_ARG_ENABLE(runtime_recording_all,
               [  --enable-runtime-recording-all      enable runtime recording and logging of all procedures using GAP_TIMM macros (default is no for this debug feature)])
   if test "x$enable_runtime_recording_all" = "xyes"; then
     AC_DEFINE(GAP_RUNTIME_RECORDING_LOCK, 1,
               [use gap runtime recording and logging features (enables locking implementations GAP_TIMM_x_FUNCTION macros)])
     AC_DEFINE(GAP_RUNTIME_RECORDING_NOLOCK, 1,
               [use gap runtime recording and logging features (enables non-locking implementations GAP_TIMM_x_RECORD macros)])
+
   fi
 
-AC_ARG_ENABLE(runtime_recording,
+AC_ARG_ENABLE(runtime_recording_nolock,
               [  --enable-runtime-recording-nolock  enable runtime recording (only non-locking implementations, default is no for this debug feature)])
   if test "x$enable_runtime_recording_nolock" = "xyes"; then
     AC_DEFINE(GAP_RUNTIME_RECORDING_NOLOCK, 1,
diff --git a/extern_libs/Makefile.am b/extern_libs/Makefile.am
index 157dd5d..c9a5f7b 100644
--- a/extern_libs/Makefile.am
+++ b/extern_libs/Makefile.am
@@ -70,6 +70,7 @@ endif
 install-data-hook:
 	rm -f $(DESTDIR)$(GAPLIBDIR)/libavformat.a \
 	rm -f $(DESTDIR)$(GAPLIBDIR)/libavcodec.a \
+	rm -f $(DESTDIR)$(GAPLIBDIR)/libavutil.a \
 	rm -f $(DESTDIR)$(GAPLIBDIR)/libmpeg3.a
 
 EXTRA_DIST = \
diff --git a/extern_libs/configure_options_ffmpeg.txt b/extern_libs/configure_options_ffmpeg.txt
index 9f3d889..adccdde 100644
--- a/extern_libs/configure_options_ffmpeg.txt
+++ b/extern_libs/configure_options_ffmpeg.txt
@@ -1,5 +1,10 @@
 --disable-shared --enable-static --enable-gpl --enable-mmx --enable-mmx2 
-# --enable-mmx --enable-mmx2 
+#
+# This file provides configuration options for ffmpeg
+# and is included while GIMP-GAP configure script runs the ffmpeg configuration.
+#
+# Notes:
+#  there is another variant of this file for the Windows MinGW Environment named: configure_options_ffmpeg_win32.txt 
 # 
 # recent ffmpeg releases does no longer support --enable-liba52
 # for audio /mp3 encoding ffmpeg recommands to link with the external libraries.
@@ -11,7 +16,7 @@
 #  --enable-libfaad  (versions after ffmpeg-0.6 have removed this option)
 #  --enable-libmp3lame
 #  --enable-libx264  (old name: --enable-x264)
-#  --enable-libxvid  --enable-pthreads  (old name: --enable-xvid)
+#  --enable-libxvid  (old name: --enable-xvid)
 #  --enable-swscale
 #  --enable-nonfree
 # options for the ffmpeg configure
diff --git a/extern_libs/configure_options_ffmpeg_win32.txt b/extern_libs/configure_options_ffmpeg_win32.txt
new file mode 100644
index 0000000..e2b137c
--- /dev/null
+++ b/extern_libs/configure_options_ffmpeg_win32.txt
@@ -0,0 +1,46 @@
+--disable-shared --enable-static --enable-gpl --enable-mmx --enable-mmx2  --disable-devices --disable-pthreads  --disable-altivec  --disable-sse --disable-neon
+#
+# This file provides configuration options for ffmpeg
+# and is included while GIMP-GAP configure scriptruns the ffmpeg configuration on Windows environment.
+#
+# Notes:
+#  there is another variant of this file for Linux and Unix-like Os named: configure_options_ffmpeg.txt
+#
+# Tests on Windows MinGW using the gcc-4.6 compiler showed that special ffmpeg configure options
+# were required to produce working exutables of the ffmpeg based video encoders.
+# The options that were successful in my tests are:
+#
+#  --disable-altivec  --disable-sse --disable-neon
+# 
+# Those option turn off memory aling related optimizations.
+#
+# I also tested alternative variants 
+#  --enable-memalign-hack  as suggested by the ffmpeg configure script
+# this resulted in successful build, but in very unstable exutables
+# that crashed very often on XP (and immediate on Windows7) tests.
+#
+# other configure options (as recommanded in older tutorials)
+# --extra-cflags="--mno-cygwin --mms-bitfields" 
+# --extra-ldflags="-W1,--add-stdcall-alias"
+# were no longer supported by my newer gcc-4.6 compiler 
+#
+# --disable-devices        
+#  configures ffmpeg without video devices that would require latests win32 api version to build on MinGW Win32 Systems.
+#  disabling devices is not critical since GIMP-GAP does not use ffmpeg features that
+#  require other access than plain videofile io.
+# 
+# recent ffmpeg releases does no longer support --enable-liba52
+# for audio /mp3 encoding ffmpeg recommands to link with the external libraries.
+#
+# the gap main configure script checks if some of the external libs for ffmpeg
+# are installed and adds further options automatically
+#
+#  --enable-libfaac 
+#  --enable-libfaad  (versions after ffmpeg-0.6 have removed this option)
+#  --enable-libmp3lame
+#  --enable-libx264  (old name: --enable-x264)
+#  --enable-libxvid  (old name: --enable-xvid)
+#  --enable-swscale
+#  --enable-nonfree
+# options for the ffmpeg configure
+
diff --git a/gap/gap_frame_fetcher.c b/gap/gap_frame_fetcher.c
index e88acf2..c6d4814 100644
--- a/gap/gap_frame_fetcher.c
+++ b/gap/gap_frame_fetcher.c
@@ -67,10 +67,7 @@
 //#include <dirent.h>
 
 
-// TODO add configure option to check for HAVE_SYSINFO
-#define HAVE_SYSINFO 0
-
-#ifdef HAVE_SYSINFO
+#ifdef GAP_HAVE_SYSINFO
 #include <sys/sysinfo.h>
 #endif
 
@@ -1173,12 +1170,20 @@ p_dump_resources_gvahand()
 /* ----------------------------------------------------
  * p_dump_process_resource_usage
  * ----------------------------------------------------
- * getrusage did not work in 1st test on linux (and is not available on windows)
+ * print memory resources used (in case sysinfo was available on compiletime)
+ *
+ * NOTE: 
+ *   getrusage did not work in 1st test on linux (and is not available on windows)
+ *   while  sysinfo worked on my linux development environment, but was not availabe
+ *   on Windows MinGW environment.
+ *   therefore the configure script cheks for the sysinfo header and
+ *   sets the GAP_HAVE_SYSINFO define constant to 1 when available.
+ *      
  */
 static void
 p_dump_process_resource_usage()
 {
-#ifdef HAVE_SYSINFO
+#ifdef GAP_HAVE_SYSINFO
 
   int rc;
   struct sysinfo info;
@@ -1208,12 +1213,13 @@ p_dump_process_resource_usage()
   }
   else
   {
-    printf("FrameFetcher getrusage failed with retcode:%d\n", rc);
+    printf("FrameFetcher sysinfo failed with retcode:%d\n", rc);
   }
 
 
 #else
-  printf("FrameFetcher compiled without sysinfo support (HAVE_SYSINFO not dfined)\n");
+  printf("** WARNING FrameFetcher sysinfo memory resource usage NOT available "
+         " because the FrameFetcher was compiled without sysinfo support (GAP_HAVE_SYSINFO not dfined)\n");
 #endif
 }
 
diff --git a/libgapbase/gap_base.c b/libgapbase/gap_base.c
index 9378a33..82a0d6a 100644
--- a/libgapbase/gap_base.c
+++ b/libgapbase/gap_base.c
@@ -45,10 +45,6 @@
 #include <unistd.h>
 #endif
 
-#ifdef GAP_HAVE_PTHREAD
-#include "pthread.h"
-#endif
-
 
 #include <glib/gstdio.h>
 
@@ -70,7 +66,12 @@
 
 
 #ifdef G_OS_WIN32
-#include <process.h>            /* For _getpid() */
+#include <process.h>             /* For _getpid() */
+#else
+#ifdef GAP_HAVE_PTHREAD
+#define USE_PTHREAD_FOR_LINUX_THREAD_ID 1
+#include "pthread.h"             /* for pthread_self() */
+#endif
 #endif
 
 /* GAP includes */
@@ -644,7 +645,7 @@ gap_base_thread_init()
 
 
 /* ---------------------------------
- * gap_timm_get_thread_id
+ * gap_base_get_thread_id
  * ---------------------------------
  * get id of the current thread.
  * gthread does not provide that feature.
@@ -652,6 +653,11 @@ gap_base_thread_init()
  * therefore use pthread implementation to get the current thread id.
  * In case pthread is not available at compiletime this procedure
  * will always return 0 and runtime.
+ *
+ * WARNING: This procedure shall NOT be used in productive features,
+ * because there is no working variant implemented on other OS than Linux.
+ * The main purpose is for logging and performance measure purposes
+ * while development on Linux
  */
 gint64
 gap_base_get_thread_id()
@@ -662,7 +668,7 @@ gap_base_get_thread_id()
 //  threadId = (gint64)gettid();
 //#endif
 
-#ifdef GAP_HAVE_PTHREAD
+#ifdef USE_PTHREAD_FOR_LINUX_THREAD_ID
   threadId = pthread_self();
   if(gap_debug)
   {
diff --git a/vid_enc_avi/gap_enc_avi_main.c b/vid_enc_avi/gap_enc_avi_main.c
index 96cc0ec..881a2e7 100644
--- a/vid_enc_avi/gap_enc_avi_main.c
+++ b/vid_enc_avi/gap_enc_avi_main.c
@@ -268,7 +268,7 @@ run (const gchar *name,          /* name of plugin */
   GapGveAviValues *epp;
   GapGveAviGlobalParams *gpp;
 
-  static GimpParam values[1];
+  static GimpParam values[2];
   gint32     l_rc;
   const char *l_env;
   char       *l_ecp_key1;
diff --git a/vid_enc_ffmpeg/gap_enc_ffmpeg_main.c b/vid_enc_ffmpeg/gap_enc_ffmpeg_main.c
index f00172b..8e5f7db 100644
--- a/vid_enc_ffmpeg/gap_enc_ffmpeg_main.c
+++ b/vid_enc_ffmpeg/gap_enc_ffmpeg_main.c
@@ -533,7 +533,7 @@ run (const gchar      *name,
   GapGveFFMpegValues *epp;
   GapGveFFMpegGlobalParams *gpp;
 
-  static GimpParam values[1];
+  static GimpParam values[2];
   gint32     l_rc;
   const char *l_env;
   char       *l_ecp_key1;
diff --git a/vid_enc_rawframes/gap_enc_rawframes_main.c b/vid_enc_rawframes/gap_enc_rawframes_main.c
index d259539..d1c005d 100644
--- a/vid_enc_rawframes/gap_enc_rawframes_main.c
+++ b/vid_enc_rawframes/gap_enc_rawframes_main.c
@@ -255,7 +255,7 @@ run (const gchar *name,          /* name of plugin */
   GapGveRawValues *epp;
   GapGveRawGlobalParams *gpp;
 
-  static GimpParam values[1];
+  static GimpParam values[2];
   gint32     l_rc;
   const char *l_env;
   char       *l_ecp_key1;
diff --git a/vid_enc_single/gap_enc_singleframes_main.c b/vid_enc_single/gap_enc_singleframes_main.c
index 84e16e2..b1c88f6 100644
--- a/vid_enc_single/gap_enc_singleframes_main.c
+++ b/vid_enc_single/gap_enc_singleframes_main.c
@@ -246,7 +246,7 @@ run (const gchar *name,          /* name of plugin */
   GapGveSingleValues *epp;
   GapGveSingleGlobalParams *gpp;
 
-  static GimpParam values[1];
+  static GimpParam values[2];
   gint32     l_rc;
   const char *l_env;
   char       *l_ecp_key1;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]