summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrantišek Dvořák <valtri@users.sourceforge.net>2004-07-31 18:57:45 +0000
committerFrantišek Dvořák <valtri@users.sourceforge.net>2004-07-31 18:57:45 +0000
commit8e955f1787b1ebda35897e5b5f458e2f8735b8ab (patch)
tree157adfb91b7d5a67f242f1a5704f412a389d431c
parent40ec329706aff0c91cb0b5a8c5588ec4948d09ed (diff)
downloadxine-lib-8e955f1787b1ebda35897e5b5f458e2f8735b8ab.tar.gz
xine-lib-8e955f1787b1ebda35897e5b5f458e2f8735b8ab.tar.bz2
New configure option --with-external-ffmpeg[=PREFIX].
CVS patchset: 6865 CVS date: 2004/07/31 18:57:45
-rw-r--r--ChangeLog1
-rw-r--r--configure.ac31
-rw-r--r--m4/ffmpeg.m4145
-rw-r--r--src/libffmpeg/Makefile.am18
-rw-r--r--src/libffmpeg/dvaudio_decoder.c4
-rw-r--r--src/libffmpeg/video_decoder.c4
-rw-r--r--src/libffmpeg/xine_decoder.h4
-rw-r--r--src/libffmpeg/xine_encoder.c4
8 files changed, 197 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 3020e710b..96dc65936 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,7 @@ xine-lib (1-rc6)
* experimental time stretching plugin: play stream faster or
slower than original speed, optionally preserving pitch
* another win32 dll crash fix (after playing several files)
+ * configure option for building xine with external ffmpeg library
xine-lib (1-rc5)
* add support for ejecting removable media on Solaris
diff --git a/configure.ac b/configure.ac
index 9b0c75893..c6d70d312 100644
--- a/configure.ac
+++ b/configure.ac
@@ -329,6 +329,25 @@ AM_CONDITIONAL(HAVE_MLIB, test x$ac_have_mlib = "xyes")
AC_SUBST(MLIB_LIBS)
AC_SUBST(MLIB_CFLAGS)
+AC_ARG_WITH(external-ffmpeg,
+ AC_HELP_STRING(
+ [--with-external-ffmpeg],
+ [use external ffmpeg library]
+ ),
+ [external_ffmpeg="$withval"],
+ [external_ffmpeg="no"]
+)
+
+if test x"$external_ffmpeg" != "xno"; then
+ AM_PATH_FFMPEG(
+ AC_DEFINE(HAVE_FFMPEG, 1, [Define this if you have ffmpeg library])
+ )
+else
+ AC_MSG_RESULT([Use included ffmpeg])
+fi
+
+AM_CONDITIONAL(HAVE_FFMPEG, test x"$external_ffmpeg_found" = "xyes")
+
dnl ---------------------------------------------
dnl Checks for X11
@@ -2196,7 +2215,11 @@ dnl video decoders
echo " * video decoder plugins:"
echo " - MPEG 1,2 - Amiga Bitplane"
echo " - Raw RGB - Raw YUV"
-echo " - ffmpeg:"
+if test x"$external_ffmpeg_found" = "xyes"; then
+ echo " - ffmpeg (external library):"
+else
+ echo " - ffmpeg (internal library):"
+fi
echo " - MPEG-4 (ISO, Microsoft, DivX*, XviD)"
echo " - Creative YUV - Motion JPEG"
echo " - Cinepak - MS Video-1"
@@ -2233,7 +2256,11 @@ echo " * audio decoder plugins:"
echo " - A52/ra-dnet - DTS"
echo " - MAD (MPG 1/2/3) - GSM 06.10"
echo " - linear PCM - Nosefart (NSF)"
-echo " - ffmpeg:"
+if test x"$external_ffmpeg_found" = "xyes"; then
+ echo " - ffmpeg (external library):"
+else
+ echo " - ffmpeg (internal library):"
+fi
echo " - Windows Media Audio v1/v2"
echo " - DV - logarithmic PCM"
echo " - 14k4 - 28k8"
diff --git a/m4/ffmpeg.m4 b/m4/ffmpeg.m4
new file mode 100644
index 000000000..f413a74f7
--- /dev/null
+++ b/m4/ffmpeg.m4
@@ -0,0 +1,145 @@
+dnl
+dnl autoconf script for searching and checking ffmpeg
+dnl
+dnl written by Frantisek Dvorak <valtri@users.sourceforge.net>
+dnl
+dnl
+dnl AM_PATH_FFMPEG([ACTION IF FOUND [, ACTION IF NOT FOUND]]))
+dnl
+dnl It looks for ffmpeg, defines FFMPEG_CFLAGS and FFMPEG_LIBS.
+dnl
+AC_DEFUN([AM_PATH_FFMPEG], [
+
+dnl get the prefix, if specified
+if test x"$external_ffmpeg" != "xyes" -a x"$external_ffmpeg" != "xno"; then
+ ffmpeg_prefix="$withval"
+fi
+
+dnl disable test if requested
+AC_ARG_ENABLE(ffmpegtest,
+ AC_HELP_STRING([--disable-ffmpegtest],
+ [Do not try compile and run a test ffmpeg program. It will need specify custom FFMPEG_CFLAGS and FFMPEG_LIBS environment variables.]
+ ),
+ enable_ffmpegtest="$enableval",
+ enable_ffmpegtest=yes
+)
+
+if test x"$enable_ffmpegtest" = "xyes"; then
+ ac_save_LDFLAGS="${LDFLAGS}"
+ ac_save_CPPFLAGS="${CPPFLAGS}"
+ external_ffmpeg_found=no
+
+ dnl look for the ffmpeg or just check specified flags
+ if test x"$FFMPEG_CFLAGS" = x -a x"$FFMPEG_LIBS" = x; then
+ dnl look for ffmpeg
+ if test x"$ffmpeg_prefix" = x; then
+ prefixes="$ffmpeg_prefix /usr /usr/local /opt"
+ else
+ prefixes="$ffmpeg_prefix"
+ fi
+ for dir in $prefixes; do
+ FFMPEG_CFLAGS="-I${dir}/include/ffmpeg -I${dir}/include/postproc"
+ FFMPEG_LIBS="-L${dir}/lib"
+ CPPFLAGS="${ac_save_CFLAGS} ${FFMPEG_CFLAGS}"
+ LDFLAGS="${ac_save_LDFLAGS} ${FFMPEG_LIBS}"
+
+ dnl drop the cache
+ for i in "ac_cv_header_avcodec_h" "ac_cv_header_postprocess_h" \
+ "ac_cv_lib_avcodec_pp_get_context" \
+ "ac_cv_lib_postproc_pp_get_context" \
+ "ac_cv_lib_avcodec_register_avcodec"; do
+ $as_unset $i || test "${$i+set}" != set || { $i=; export $i; }
+ done
+
+ dnl check the headers
+ AC_CHECK_HEADERS(avcodec.h postprocess.h,
+ [dnl look for libpostproc inside libavcodec
+ AC_CHECK_LIB(avcodec, pp_get_context,
+ [external_ffmpeg_found=yes
+ FFMPEG_LIBS="${FFMPEG_LIBS} -lavcodec"
+ break],
+ [dnl look for shared libpostproc and avcodec
+ AC_CHECK_LIB(postproc, pp_get_context,
+ [AC_CHECK_LIB(avcodec, register_avcodec,
+ [external_ffmpeg_found=yes
+ FFMPEG_LIBS="${FFMPEG_LIBS} -lavcodec -lpostproc"
+ break],
+ [continue],
+ [-lavcodec]
+ )],
+ [continue]
+ )],
+ []
+ )],
+ [continue]
+ )
+ done
+
+ dnl result of autodetection
+ if test x"$external_ffmpeg_found" = "xyes"; then
+ AC_MSG_RESULT([External ffmpeg library was found in ${dir}])
+ else
+ AC_MSG_ERROR([External ffmpeg library not found.
+*********************************************************************
+You can try to specify prefix of ffmpeg library by the option
+--with-external-ffmpeg=prefix, or to specify custom FFMPEG_CFLAGS and
+FFMPEG_LIBS.
+
+If you would like to use the internal ffmpeg, please remove the configure
+option --with-external-ffmpeg.
+*********************************************************************])
+ fi
+ else
+ dnl check specified flags
+ CPPFLAGS="${ac_save_CFLAGS} ${FFMPEG_CFLAGS}"
+ LDFLAGS="${ac_save_LDFLAGS} ${FFMPEG_LIBS}"
+ AC_LINK_IFELSE([#include <avcodec.h>
+#include <postprocess.h>
+
+int main() {
+ register_avcodec((void *)0);
+ pp_get_context(0, 0, 0);
+}
+],
+ [external_ffmpeg_found=yes],
+ [external_ffmpeg_found=no],
+ )
+
+ dnl result
+ if test x"$external_ffmpeg_found" = "xyes"; then
+ AC_MSG_RESULT([Using custom FFMPEG_CFLAGS and FFMPEG_LIBS for external ffmpeg])
+ else
+ AC_MSG_ERROR([External ffmpeg library not found with specified options.
+*********************************************************************
+You can try to specify prefix of ffmpeg library by the option
+--with-external-ffmpeg=prefix, or to specify different FFMPEG_CFLAGS and
+FFMPEG_LIBS.
+
+If you would like to use the internal ffmpeg, please remove the configure
+option --with-external-ffmpeg.
+*********************************************************************])
+ fi
+ fi
+ CPPFLAGS="${ac_save_CPPFLAGS}"
+ LDFLAGS="${ac_save_LDFLAGS}"
+else
+ if test x"${FFMPEG_CFLAGS}" = "x" -a x"${FFMPEG_LIBS}" = "x"; then
+ external_ffmpeg_found=no
+ AC_MSG_ERROR([You should specify FFMPEG_CFLAGS and FFMPEG_LIBS])
+ else
+ external_ffmpeg_found=yes
+ AC_MSG_RESULT([Forced using custom FFMPEG_CFLAGS and FFMPEG_LIBS.])
+ fi
+fi
+
+dnl result
+if test x"$external_ffmpeg_found" = "xyes"; then
+ ifelse([$1], , :, [$1])
+else
+ ifelse([$2], , :, [$2])
+fi
+
+AC_SUBST(FFMPEG_CFLAGS)
+AC_SUBST(FFMPEG_LIBS)
+
+])
diff --git a/src/libffmpeg/Makefile.am b/src/libffmpeg/Makefile.am
index afe9fe713..0599d5890 100644
--- a/src/libffmpeg/Makefile.am
+++ b/src/libffmpeg/Makefile.am
@@ -1,6 +1,17 @@
include $(top_srcdir)/misc/Makefile.common
-SUBDIRS = libavcodec
+if HAVE_FFMPEG
+FF_CFLAGS = $(FFMPEG_CFLAGS)
+link_ffmpeg = $(FFMPEG_LIBS)
+else
+FF_CFLAGS = -I$(srcdir)/libavcodec -I$(srcdir)/libavcodec/libpostproc
+link_ffmpeg = \
+ $(top_builddir)/src/libffmpeg/libavcodec/libavcodec.la \
+ $(top_builddir)/src/libffmpeg/libavcodec/libpostproc/libpostprocess.la
+subdir_ffmpeg = libavcodec
+endif
+
+SUBDIRS = $(subdir_ffmpeg)
# this must always be included, even if the current machine has no DXR3...
EXTRA_DIST = xine_encoder.c diff_to_ffmpeg_cvs.txt
@@ -12,7 +23,7 @@ libdir = $(XINE_PLUGINDIR)
lib_LTLIBRARIES = xineplug_decode_ff.la xineplug_decode_dvaudio.la
if HAVE_DXR3
-AM_CPPFLAGS = -I$(top_srcdir)/src/dxr3 $(X_CFLAGS)
+AM_CPPFLAGS = -I$(top_srcdir)/src/dxr3 $(X_CFLAGS) $(FF_CFLAGS)
xineplug_decode_ff_la_SOURCES = xine_decoder.c audio_decoder.c video_decoder.c \
xine_encoder.c mpeg_parser.c
# The dxr3 uses ffmpegs MPEG encoder by dlopen()ing the ffmpeg plugin and
@@ -25,8 +36,7 @@ xineplug_decode_ff_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
endif
xineplug_decode_ff_la_LIBADD = $(MLIB_LIBS) $(XINE_LIB) -lm $(ZLIB_LIBS) \
- $(top_builddir)/src/libffmpeg/libavcodec/libavcodec.la \
- $(top_builddir)/src/libffmpeg/libavcodec/libpostproc/libpostprocess.la
+ $(link_ffmpeg)
xineplug_decode_dvaudio_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
xineplug_decode_dvaudio_la_SOURCES = dvaudio_decoder.c
diff --git a/src/libffmpeg/dvaudio_decoder.c b/src/libffmpeg/dvaudio_decoder.c
index 56538d2e1..4b4420ba5 100644
--- a/src/libffmpeg/dvaudio_decoder.c
+++ b/src/libffmpeg/dvaudio_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: dvaudio_decoder.c,v 1.2 2004/03/17 17:03:26 storri Exp $
+ * $Id: dvaudio_decoder.c,v 1.3 2004/07/31 18:57:45 valtri Exp $
*
* dv audio decoder based on patch by Dan Dennedy <dan@dennedy.org>
*
@@ -56,7 +56,7 @@
# undef uint64_t
#endif
-#include "libavcodec/avcodec.h"
+#include <avcodec.h>
#include "libavcodec/dvdata.h"
#ifdef _MSC_VER
diff --git a/src/libffmpeg/video_decoder.c b/src/libffmpeg/video_decoder.c
index c1e698380..8cff6acff 100644
--- a/src/libffmpeg/video_decoder.c
+++ b/src/libffmpeg/video_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: video_decoder.c,v 1.24 2004/07/30 19:08:48 miguelfreitas Exp $
+ * $Id: video_decoder.c,v 1.25 2004/07/31 18:57:45 valtri Exp $
*
* xine video decoder plugin using ffmpeg
*
@@ -47,7 +47,7 @@
#include "xine_decoder.h"
#include "mpeg_parser.h"
-#include "libavcodec/libpostproc/postprocess.h"
+#include <postprocess.h>
#define VIDEOBUFSIZE (128*1024)
#define SLICE_BUFFER_SIZE (1194*1024)
diff --git a/src/libffmpeg/xine_decoder.h b/src/libffmpeg/xine_decoder.h
index d96180702..91d32bff7 100644
--- a/src/libffmpeg/xine_decoder.h
+++ b/src/libffmpeg/xine_decoder.h
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_decoder.h,v 1.1 2004/01/31 01:19:17 jstembridge Exp $
+ * $Id: xine_decoder.h,v 1.2 2004/07/31 18:57:45 valtri Exp $
*
*/
@@ -36,7 +36,7 @@
# undef uint64_t
#endif
-#include "libavcodec/avcodec.h"
+#include <avcodec.h>
#ifdef _MSC_VER
# undef malloc
diff --git a/src/libffmpeg/xine_encoder.c b/src/libffmpeg/xine_encoder.c
index 8d6d72195..07bf9b8fa 100644
--- a/src/libffmpeg/xine_encoder.c
+++ b/src/libffmpeg/xine_encoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_encoder.c,v 1.16 2004/07/20 16:37:45 mroi Exp $
+ * $Id: xine_encoder.c,v 1.17 2004/07/31 18:57:45 valtri Exp $
*/
/* mpeg encoders for the dxr3 video out plugin. */
@@ -34,7 +34,7 @@
/* #define LOG */
#include "video_out_dxr3.h"
-#include "libavcodec/avcodec.h"
+#include <avcodec.h>
/* buffer size for encoded mpeg1 stream; will hold one intra frame
* at 640x480 typical sizes are <50 kB. 512 kB should be plenty */