[Ffmpeg-devel] [PATCH] Cygwin vhook, always static avformat

wzrlpy at arsystel.com wzrlpy
Mon Jul 10 01:11:44 CEST 2006


Hi,

First of all, sorry to break the original thread, I needed to use another
mail account, mplayerhq.hu is rejecting my mails from Hotmail.
The original thread starts at
http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2006-May/010821.html

The objective of the patches is to make possible to compile vhook and
shared libraries under Cygwin (currently the build of shared libraries is
broken in this platform).

Here is a link to the patch:
http://usuarios.arsystel.com/wzrlpy/ffmpeg/ffmpeg.cygwin.vhook.3.patch

After the patch is applied, the shared library compilation succeeds, but
the resulting FFMpeg binary doesn't run, it crashes at startup.
The reason is the way "loop_input" is defined, it is confusing
Windows/Cygwin gcc/ldd.

There was a patch for loop_input, submitted by Todd Kirby on 2005-06-05
07:48:03 GMT:
http://news.gmane.org/find-root.php?message_id=%3c4b3e3180050605004865bb6dbd%40mail.gmail.com%3e

I have adapted it to SVN-5646, and that avoids ffmpeg.exe crash at
startup. It is here:
http://usuarios.arsystel.com/wzrlpy/ffmpeg/ffmpeg.cygwin.loop_input.2.patch


-----------------------------------------------
Here is the ffmpeg.cygwin.vhook.3.patch file:

diff -Naur ffmpeg-old/common.mak ffmpeg/common.mak
--- ffmpeg-old/common.mak 2006-06-10 15:44:49.000000000 +0200
+++ ffmpeg/common.mak 2006-07-07 20:52:14.250000000 +0200
@@ -10,6 +10,13 @@
LDFLAGS =
-Wl,--output-def,$(@:.dll=.def),--out-implib,lib$(SLIBNAME:$(SLIBSUF)=.dll.a)
endif

+#FIXME: This should be in configure/config.mak
+ifeq ($(TARGET_OS),CYGWIN)
+    ifeq ($(BUILD_SHARED),yes)
+        EXTRALIBS := -Wl,--no-whole-archive $(EXTRALIBS)
+    endif
+endif
+
ifeq ($(TARGET_GPROF),yes)
CFLAGS+=-p
LDFLAGS+=-p
@@ -79,12 +86,19 @@
ifeq ($(CONFIG_WIN32),yes)
install $(INSTALLSTRIP) -m 755 $(SLIBNAME) "$(prefix)"
else
+    ifeq ($(TARGET_OS),CYGWIN)
+ install -d "$(bindir)"
+ install $(INSTALLSTRIP) -m 755 $(SLIBNAME) \
+ $(bindir)/$(SLIBNAME)
+ install -m 755 lib$(NAME).dll.a $(libdir)
+    else
install $(INSTALLSTRIP) -m 755 $(SLIBNAME) \
$(libdir)/$(SLIBNAME_WITH_VERSION)
ln -sf $(SLIBNAME_WITH_VERSION) \
$(libdir)/$(SLIBNAME_WITH_MAJOR)
ln -sf $(SLIBNAME_WITH_VERSION) \
$(libdir)/$(SLIBNAME)
+    endif
endif

install-lib-static: $(LIB)
diff -Naur ffmpeg-old/configure ffmpeg/configure
--- ffmpeg-old/configure 2006-07-06 21:25:44.000000000 +0200
+++ ffmpeg/configure 2006-07-08 00:30:31.296875000 +0200
@@ -579,10 +579,14 @@
v4l2="no"
audio_oss="yes"
dv1394="no"
-vhook="no"
extralibs=""
cygwin="yes"
EXESUF=".exe"
+SLIBPREF="cyg"
+SLIBSUF=".dll"
+SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
+SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(NAME)-$(LIBMAJOR)$(SLIBSUF)'
+SHFLAGS='-shared
-Wl,--out-implib=lib$(NAME).dll.a,--export-all-symbols,--enable-auto-import,--whole-archive'
;;
Linux)
;;
diff -Naur ffmpeg-old/vhook/Makefile ffmpeg/vhook/Makefile
--- ffmpeg-old/vhook/Makefile 2006-07-06 21:25:35.000000000 +0200
+++ ffmpeg/vhook/Makefile 2006-07-08 00:27:36.468750000 +0200
@@ -6,6 +6,15 @@
       -I$(SRC_PATH)/libavcodec -I$(SRC_PATH)/libavutil -DHAVE_AV_CONFIG_H

#FIXME: This needs to be in configure/config.mak
+ifeq ($(TARGET_OS),CYGWIN)
+    EXTRALIBS := -Wl,--no-whole-archive \
+                 -L../libavformat -lavformat$(BUILDSUF) \
+ -L../libavcodec  -lavcodec$(BUILDSUF)  \
+ -L../libavutil   -lavutil$(BUILDSUF) $(EXTRALIBS)
+    SHFLAGS=-shared
-Wl,--export-all-symbols,--enable-auto-import,--whole-archive
+endif
+
+#FIXME: This needs to be in configure/config.mak
ifeq ($(CONFIG_DARWIN),yes)
SHFLAGS = -dynamiclib -Wl,-single_module -flat_namespace \
                  -undefined suppress -Wl,-install_name,$(libdir)/vhook/$@
@@ -14,13 +23,13 @@

ifeq ($(HAVE_IMLIB2),yes)
    HOOKS += imlib2$(SLIBSUF)
-    LDFLAGS += -lImlib2
+    EXTRALIBS += -lImlib2
endif

ifeq ($(HAVE_FREETYPE2),yes)
    HOOKS += drawtext$(SLIBSUF)
    CFLAGS += `freetype-config --cflags`
-    LDFLAGS += `freetype-config --libs`
+    EXTRALIBS += `freetype-config --libs`
endif

all: $(HOOKS)
@@ -40,7 +49,7 @@
-rmdir "$(libdir)/vhook/"

%$(SLIBSUF): %.o
- $(CC) $(LDFLAGS) -g -o $@ $(SHFLAGS) $<
+ $(CC) $(LDFLAGS) -g -o $@ $(SHFLAGS) $< $(EXTRALIBS)

clean:
rm -f *.o *.d *~ *.a *.lib *.so *.dylib *.dll


-----------------------------------------------
Here is the ffmpeg.cygwin.loop_input.2.patch file:

diff -Naur ffmpeg-old/ffmpeg.c ffmpeg/ffmpeg.c
--- ffmpeg-old/ffmpeg.c	2006-07-06 21:25:44.000000000 +0200
+++ ffmpeg/ffmpeg.c	2006-07-10 00:00:54.562500000 +0200
@@ -159,7 +159,7 @@
 static int frame_skip_threshold= 0;
 static int frame_skip_factor= 0;
 static int frame_skip_exp= 0;
-extern int loop_input; /* currently a hack */
+static int loop_input = 0;
 static int loop_output = AVFMT_NOOUTPUTLOOP;
 static int genpts = 0;
 static int qp_hist = 0;
@@ -2843,6 +2843,8 @@
         exit(1);
     }

+    ic->loop_input = loop_input;
+
     if(genpts)
         ic->flags|= AVFMT_FLAG_GENPTS;

diff -Naur ffmpeg-old/libavformat/avformat.h ffmpeg/libavformat/avformat.h
--- ffmpeg-old/libavformat/avformat.h	2006-07-06 21:25:44.000000000 +0200
+++ ffmpeg/libavformat/avformat.h	2006-07-09 23:58:45.250000000 +0200
@@ -5,8 +5,8 @@
 extern "C" {
 #endif

-#define LIBAVFORMAT_VERSION_INT ((50<<16)+(4<<8)+0)
-#define LIBAVFORMAT_VERSION     50.4.0
+#define LIBAVFORMAT_VERSION_INT ((50<<16)+(5<<8)+0)
+#define LIBAVFORMAT_VERSION     50.5.0
 #define LIBAVFORMAT_BUILD       LIBAVFORMAT_VERSION_INT

 #define LIBAVFORMAT_IDENT       "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
@@ -334,6 +334,7 @@
 #define AVFMT_INFINITEOUTPUTLOOP 0
     /* number of times to loop output in formats that support it */
     int loop_output;
+    int loop_input;

     int flags;
 #define AVFMT_FLAG_GENPTS       0x0001 ///< generate pts if missing even
if it requires parsing future frames
diff -Naur ffmpeg-old/libavformat/img.c ffmpeg/libavformat/img.c
--- ffmpeg-old/libavformat/img.c	2006-06-10 15:44:48.000000000 +0200
+++ ffmpeg/libavformat/img.c	2006-07-09 23:52:55.875000000 +0200
@@ -18,9 +18,6 @@
  */
 #include "avformat.h"

-/* XXX: this is a hack */
-int loop_input = 0;
-
 typedef struct {
     int width;
     int height;
@@ -200,7 +197,7 @@

     if (!s->is_pipe) {
         /* loop over input */
-        if (loop_input && s->img_number > s->img_last) {
+        if (s1->loop_input && s->img_number > s->img_last) {
             s->img_number = s->img_first;
         }
         if (get_frame_filename(filename, sizeof(filename),
diff -Naur ffmpeg-old/libavformat/img2.c ffmpeg/libavformat/img2.c
--- ffmpeg-old/libavformat/img2.c	2006-06-10 15:44:47.000000000 +0200
+++ ffmpeg/libavformat/img2.c	2006-07-09 23:52:55.890625000 +0200
@@ -19,9 +19,6 @@
  */
 #include "avformat.h"

-/* XXX: this is a hack */
-extern int loop_input;
-
 typedef struct {
     int img_first;
     int img_last;
@@ -236,7 +233,7 @@

     if (!s->is_pipe) {
         /* loop over input */
-        if (loop_input && s->img_number > s->img_last) {
+        if (s1->loop_input && s->img_number > s->img_last) {
             s->img_number = s->img_first;
         }
         if (get_frame_filename(filename, sizeof(filename),



Regards,
V?ctor Paesa




More information about the ffmpeg-devel mailing list