summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuenter Bartsch <guenter@users.sourceforge.net>2002-04-20 18:42:35 +0000
committerGuenter Bartsch <guenter@users.sourceforge.net>2002-04-20 18:42:35 +0000
commit157cc496c6378df5899b9e9ade8a37a1ee9706a7 (patch)
tree2cf32df0332fc4bbe4532ece780574ae40498997
parent2d46a96efe82d911a106c316d6d11ac9a64cd9e0 (diff)
downloadxine-lib-157cc496c6378df5899b9e9ade8a37a1ee9706a7.tar.gz
xine-lib-157cc496c6378df5899b9e9ade8a37a1ee9706a7.tar.bz2
clean up use of global CFLAGS, add xvid patch contributed by Tomas Kovar
CVS patchset: 1749 CVS date: 2002/04/20 18:42:35
-rw-r--r--AUTHORS2
-rw-r--r--ChangeLog5
-rw-r--r--configure.in49
-rwxr-xr-xcvscompile.sh2
-rw-r--r--m4/Makefile.am2
-rw-r--r--m4/xvid.m4102
-rw-r--r--src/Makefile.am2
-rw-r--r--src/libvorbis/xine_decoder.c6
-rw-r--r--src/libxvid/Makefile.am30
-rw-r--r--src/libxvid/xine_decoder.c264
10 files changed, 432 insertions, 32 deletions
diff --git a/AUTHORS b/AUTHORS
index 1ac0ad54e..7788cea99 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -197,7 +197,7 @@ Contributions
many translation files and man pages updates/fixes
Tomas Kovar <tomask@mac.com>
- slovak internationalization files (xine lib).
+ slovak internationalization files (xine lib), xvid support
Daniel Bena <Daniel.Bena@dm-drogeriemarkt.sk>
slovak internationalization files (xine ui).
diff --git a/ChangeLog b/ChangeLog
index 37f631f1e..0e888b500 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+xine (0.9.9) unstable; urgency=low
* new (fast) demuxer seeking
* libdivx4 updated to support divx5
@@ -17,7 +18,11 @@
* mms streaming plugin
* better playing support for ffmpeg/win32 codecs on slow machines
* using "%" instead of ":" as subtitle file seperator
+ * xvid (http://www.xvid.org) codec support
+ * use of $CFLAGS instead of $GLOBAL_CFLAGS
+ -- Guenter Bartsch <guenter@users.sourceforge.net> Sat Apr 20 20:32:33 CEST 2002
+
xine (0.9.8) unstable; urgency=low
* Linux framebuffer video out driver (experimental)
diff --git a/configure.in b/configure.in
index a37eece10..60e5da323 100644
--- a/configure.in
+++ b/configure.in
@@ -69,15 +69,6 @@ SPEC_VERSION=$XINE_MAJOR.$XINE_MINOR.$XINE_SUB$XINE_PRE
AC_SUBST(TAR_NAME)
AC_SUBST(SPEC_VERSION)
-
-dnl
-dnl Store and reset CFLAGS
-dnl
-cflags_set=${CFLAGS+set}
-cflags_saved="$CFLAGS"
-CFLAGS=""
-
-
dnl
AC_CANONICAL_SYSTEM
dnl AC_CANONICAL_HOST
@@ -160,8 +151,11 @@ AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AM_TYPE_PTRDIFF_T
+dnl
+dnl debug cflags
+dnl
AC_SUBST(DEBUG_CFLAGS)
-dnl AC_SUBST(GLOBAL_CFLAGS)
+DEBUG_CFLAGS="$CFLAGS -g -DEBUG"
dnl
dnl threads
@@ -169,8 +163,8 @@ dnl
case "$host" in
*-*-freebsd*)
THREAD_LIBS="-L/usr/local/lib -pthread"
- THREAD_CFLAGS="-I/usr/local/include -D_THREAD_SAFE"
- CFLAGS="-L/usr/local/lib $THREAD_CFLAGS"
+ CFLAGS="$CFLAGS -L/usr/local/lib -I/usr/local/include -D_THREAD_SAFE"
+ DEBUG_CFLAGS="$DEBUG_CFLAGS -L/usr/local/lib -I/usr/local/include -D_THREAD_SAFE"
CPPFLAGS="$CPPFLAGS -I/usr/local/include -L/usr/local/lib"
;;
*)
@@ -180,7 +174,6 @@ case "$host" in
;;
esac
AC_SUBST(THREAD_LIBS)
-AC_SUBST(THREAD_CFLAGS)
dnl
dnl dynamic linker
@@ -438,6 +431,14 @@ AM_CONDITIONAL(HAVE_VORBIS, [test x"$no_oggvorbis" = "xno"])
dnl
+dnl XviD libs.
+dnl
+
+AM_PATH_XVID(no_xvid=no, AC_MSG_RESULT([*** All of XviD dependent parts will be disabled ***]))
+AM_CONDITIONAL(HAVE_XVID, [test x"$no_xvid" != "xyes"])
+
+
+dnl
dnl OSS style audio interface
dnl
AC_MSG_CHECKING(for OSS audio support)
@@ -588,16 +589,16 @@ AC_TRY_CFLAGS("-Wall", wall="-Wall", wall="")
dnl Common cflags for all platforms
-COMMON_CFLAGS="$wall -D_REENTRANT -D_FILE_OFFSET_BITS=64 -DXINE_COMPILE"
+CFLAGS="$CFLAGS $wall -D_REENTRANT -D_FILE_OFFSET_BITS=64 -DXINE_COMPILE"
+DEBUG_CFLAGS="$DEBUG_CFLAGS $wall -D_REENTRANT -D_FILE_OFFSET_BITS=64 -DXINE_COMPILE"
enable_w32dll="no"
enable_ffmmx="no"
-
case "$host_or_hostalias" in
i386-*-freebsd*)
CFLAGS="$CFLAGS -pipe -fomit-frame-pointer -malign-functions=4 -malign-loops=4 -malign-jumps=4 -malign-functions=4 $m_wm $m_psb -fexpensive-optimizations $f_si $f_nsa -ffast-math -funroll-loops -finline-functions"
- DEBUG_CFLAGS="$X_CFLAGS $DEBUG_CFLAGS $CFLAGS"
+ DEBUG_CFLAGS="$X_CFLAGS $DEBUG_CFLAGS"
AC_DEFINE(__i386__)
AC_DEFINE([ARCH_X86],,[x86 architecture])
AC_DEFINE(FPM_INTEL)
@@ -788,15 +789,8 @@ case "$host_or_hostalias" in
esac
-CFLAGS="$CFLAGS $COMMON_CFLAGS $ALSA_CFLAGS $ESD_CFLAGS $ARTS_CFLAGS $IRIXAL_CFLAGS"
-dnl
-dnl Some CFLAGS was previously defined, use them too.
-dnl
-if test "$cflags_set" = "set"; then
- CFLAGS="$cflags_saved $CFLAGS"
-fi
-
-DEBUG_CFLAGS="$DEBUG_CFLAGS $COMMON_CFLAGS $ALSA_CFLAGS $ESD_CFLAGS $ARTS_CFLAGS $IRIXAL_CFLAGS -g -DDEBUG"
+CFLAGS="$CFLAGS $ALSA_CFLAGS $ESD_CFLAGS $ARTS_CFLAGS $IRIXAL_CFLAGS"
+DEBUG_CFLAGS="$DEBUG_CFLAGS $ALSA_CFLAGS $ESD_CFLAGS $ARTS_CFLAGS $IRIXAL_CFLAGS"
AM_CONDITIONAL(HAVE_W32DLL, test x"$enable_w32dll" = "xyes")
if test x"$enable_w32dll" = "xyes"; then
@@ -950,6 +944,7 @@ src/libsputext/Makefile
src/libspucc/Makefile
src/libvfill/Makefile
src/libvorbis/Makefile
+src/libxvid/Makefile
src/libdivx4/Makefile
src/xine-utils/Makefile
src/input/Makefile
@@ -1072,6 +1067,9 @@ echo " - vfill - divx4"
if test x"$no_oggvorbis" = "xno"; then
echo " - vorbis"
fi
+if test x"$no_xvid" = "xno"; then
+ echo " - xvid"
+fi
if test x"$have_dxr3" = "xyes"; then
echo " - dxr3"
fi
@@ -1104,3 +1102,4 @@ if test x"$have_cdrom_ioctls" = "xyes"; then
echo " - cda"
fi
echo "---"
+
diff --git a/cvscompile.sh b/cvscompile.sh
index e6c4c3428..5c4ffb45f 100755
--- a/cvscompile.sh
+++ b/cvscompile.sh
@@ -16,7 +16,7 @@ rm -f config.cache
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
-m4_files="_xine.m4 arts.m4 esd.m4 iconv.m4 lcmessage.m4 vorbis.m4 aa.m4 gettext.m4 irixal.m4 ogg.m4 alsa.m4 codeset.m4 glibc21.m4 isc-posix.m4 progtest.m4 sdl.m4"
+m4_files="_xine.m4 arts.m4 esd.m4 iconv.m4 lcmessage.m4 vorbis.m4 aa.m4 gettext.m4 irixal.m4 ogg.m4 alsa.m4 codeset.m4 glibc21.m4 isc-posix.m4 progtest.m4 sdl.m4 xvid.m4"
if test -d $srcdir/m4; then
rm -f acinclude.m4
for m4f in $m4_files; do
diff --git a/m4/Makefile.am b/m4/Makefile.am
index 565e289de..876abdecb 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -10,7 +10,7 @@ endif
m4data_DATA = xine.m4
EXTRA_DIST = xine.m4 _xine.m4 arts.m4 esd.m4 iconv.m4 lcmessage.m4 vorbis.m4 aa.m4 as.m4 \
- gettext.m4 irixal.m4 ogg.m4 alsa.m4 codeset.m4 glibc21.m4 isc-posix.m4 progtest.m4 sdl.m4
+ gettext.m4 irixal.m4 ogg.m4 alsa.m4 codeset.m4 glibc21.m4 isc-posix.m4 progtest.m4 sdl.m4 xvid.m4
debug:
diff --git a/m4/xvid.m4 b/m4/xvid.m4
new file mode 100644
index 000000000..f3a81a6c1
--- /dev/null
+++ b/m4/xvid.m4
@@ -0,0 +1,102 @@
+# Configure paths for libxvidcore
+# Tomas Kovar <tomask@mac.com> 03-31-2002
+# Stolen from ogg.m4
+
+dnl AM_PATH_XVID([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
+dnl Test for libxvidcore, and define XVID_CFLAGS and XVID_LIBS
+dnl
+AC_DEFUN([AM_PATH_XVID],
+[dnl
+dnl Get the cflags and libraries
+dnl
+AC_ARG_WITH(xvid-prefix,[ --with-xvid-prefix=PFX Prefix where XviD is installed (optional)], xvid_prefix="$withval", xvid_prefix="")
+AC_ARG_ENABLE(xvidtest, [ --disable-xvidtest Do not try to compile and run a test XviD program],, enable_xvidtest=yes)
+
+ if test x$xvid_prefix != x ; then
+ xvid_args="$xvid_args --prefix=$xvid_prefix"
+ XVID_CFLAGS="-I$xvid_prefix/include"
+ XVID_LIBS="-L$xvid_prefix/lib"
+ fi
+
+ XVID_LIBS="$XVID_LIBS -lxvidcore"
+
+ AC_MSG_CHECKING(for XviD)
+ no_xvid=""
+
+
+ if test "x$enable_xvidtest" = "xyes" ; then
+ ac_save_CFLAGS="$CFLAGS"
+ ac_save_LIBS="$LIBS"
+ CFLAGS="$CFLAGS $XVID_CFLAGS"
+ LIBS="$LIBS $XVID_LIBS"
+dnl
+dnl Now check if the installed XviD is sufficiently new.
+dnl
+ rm -f conf.xvidtest
+ AC_TRY_RUN([
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <xvid.h>
+
+int main ()
+{
+ XVID_INIT_PARAM xinit;
+ system("touch conf.xvidtest");
+
+ xinit.cpu_flags = 0;
+ xvid_init(NULL, 0, &xinit, NULL);
+
+ if (xinit.api_version == API_VERSION) {
+ return 0;
+ } else {
+ printf ("Header file and library are out of sync. Header file supports\n"
+ "version %d.%d API and shared library supports version %d.%d API.\n",
+ API_VERSION >> 16, API_VERSION & 0xFFFF,
+ xinit.api_version >> 16, xinit.api_version & 0xFFFF);
+ return 1;
+ }
+}
+
+],, no_xvid=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
+ CFLAGS="$ac_save_CFLAGS"
+ LIBS="$ac_save_LIBS"
+ fi
+
+ if test "x$no_xvid" = x ; then
+ AC_MSG_RESULT(yes)
+ ifelse([$1], , :, [$1])
+ else
+ AC_MSG_RESULT(no)
+ if test -f conf.xvidtest ; then
+ :
+ else
+ echo "*** Could not run XviD test program, checking why..."
+ CFLAGS="$CFLAGS $XVID_CFLAGS"
+ LIBS="$LIBS $XVID_LIBS"
+ AC_TRY_LINK([
+#include <stdio.h>
+#include <xvid.h>
+], [ return 0; ],
+ [ echo "*** The test program compiled, but did not run. This usually means"
+ echo "*** that the run-time linker is not finding XviD or finding the wrong"
+ echo "*** version of XviD. If it is not finding XviD, you'll need to set your"
+ echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
+ echo "*** to the installed location Also, make sure you have run ldconfig if that"
+ echo "*** is required on your system"
+ echo "***"
+ echo "*** If you have an old version installed, it is best to remove it, although"
+ echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
+ [ echo "*** The test program failed to compile or link. See the file config.log for the"
+ echo "*** exact error that occured. This usually means XviD was incorrectly installed." ])
+ CFLAGS="$ac_save_CFLAGS"
+ LIBS="$ac_save_LIBS"
+ fi
+ XVID_CFLAGS=""
+ XVID_LIBS=""
+ ifelse([$2], , :, [$2])
+ fi
+ AC_SUBST(XVID_CFLAGS)
+ AC_SUBST(XVID_LIBS)
+ rm -f conf.xvidtest
+])
diff --git a/src/Makefile.am b/src/Makefile.am
index df72f0989..62de0574d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,7 @@
SUBDIRS = xine-utils xine-engine audio_out video_out dxr3 input libmpeg2 libspudec demuxers \
liba52 libffmpeg liblpcm libw32dll libmad libdts \
- libvorbis libdivx4 libsputext libspucc
+ libvorbis libdivx4 libsputext libspucc libxvid
debug:
@list='$(SUBDIRS)'; for subdir in $$list; do \
diff --git a/src/libvorbis/xine_decoder.c b/src/libvorbis/xine_decoder.c
index 37e618bd7..883b2153c 100644
--- a/src/libvorbis/xine_decoder.c
+++ b/src/libvorbis/xine_decoder.c
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2000-2001 the xine project
+ * Copyright (C) 2000-2002 the xine project
*
- * This file is part of xine, a unix video player.
+ * This file is part of xine, a free video player.
*
* xine is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -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.c,v 1.8 2002/04/09 03:38:01 miguelfreitas Exp $
+ * $Id: xine_decoder.c,v 1.9 2002/04/20 18:42:35 guenter Exp $
*
* (ogg/)vorbis audio decoder plugin (libvorbis wrapper) for xine
*/
diff --git a/src/libxvid/Makefile.am b/src/libxvid/Makefile.am
new file mode 100644
index 000000000..f96609875
--- /dev/null
+++ b/src/libxvid/Makefile.am
@@ -0,0 +1,30 @@
+CFLAGS = @CFLAGS@ @XVID_CFLAGS@
+
+LIBTOOL = $(SHELL) $(top_builddir)/libtool-nofpic
+
+libdir = $(XINE_PLUGINDIR)
+
+
+if HAVE_XVID
+xvid_modules = xineplug_decode_xvid.la
+endif
+
+lib_LTLIBRARIES = $(xvid_modules)
+
+xineplug_decode_xvid_la_SOURCES = xine_decoder.c
+xineplug_decode_xvid_la_LIBADD = @XVID_LIBS@
+xineplug_decode_xvid_la_LDFLAGS = -avoid-version -module
+
+debug:
+ @$(MAKE) CFLAGS="$(DEBUG_CFLAGS)"
+
+install-debug: debug
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+mostlyclean-generic:
+ -rm -f *~ \#* .*~ .\#*
+
+maintainer-clean-generic:
+ -@echo "This command is intended for maintainers to use;"
+ -@echo "it deletes files that may require special tools to rebuild."
+ -rm -f Makefile.in
diff --git a/src/libxvid/xine_decoder.c b/src/libxvid/xine_decoder.c
new file mode 100644
index 000000000..b3b567d3b
--- /dev/null
+++ b/src/libxvid/xine_decoder.c
@@ -0,0 +1,264 @@
+/*
+ * Copyright (C) 2000-2002 the xine project
+ *
+ * This file is part of xine, a free video player.
+ *
+ * xine is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * xine is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * XviD video decoder plugin (libxvidcore wrapper) for xine
+ *
+ * by Tomas Kovar <tomask@mac.com>
+ * with ideas from the ffmpeg xine plugin.
+ *
+ * Requires the xvidcore library. Find it at http://www.xvid.org.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <pthread.h>
+#include <xvid.h>
+
+#include "bswap.h"
+#include "xine_internal.h"
+#include "buffer.h"
+#include "xine-utils/xineutils.h"
+
+#define VIDEOBUFSIZE 128 * 1024
+
+/*
+#define LOG
+*/
+
+/* word is that this is lifted from wine's vfw.h */
+typedef struct {
+ long biSize;
+ long biWidth;
+ long biHeight;
+ short biPlanes;
+ short biBitCount;
+ long biCompression;
+ long biSizeImage;
+ long biXPelsPerMeter;
+ long biYPelsPerMeter;
+ long biClrUsed;
+ long biClrImportant;
+} BITMAPINFOHEADER;
+
+typedef struct xvid_decoder_s {
+ video_decoder_t video_decoder;
+
+ vo_instance_t *video_out;
+ int decoder_running;
+ int skip_frames;
+
+ unsigned char *buffer;
+ int buffer_size;
+ int frame_size;
+
+ int frame_width;
+ int frame_height;
+
+ /* frame_duration a.k.a. video_step. It is one second metronom */
+ /* ticks (90,000) divided by fps (provided by demuxer from system */
+ /* stream), i.e. for how many ticks the frame will be displayed */
+ int frame_duration;
+
+ void *xvid_handle;
+} xvid_decoder_t;
+
+static int xvid_can_handle (video_decoder_t *this_gen, int buf_type) {
+ buf_type &= (BUF_MAJOR_MASK|BUF_DECODER_MASK);
+ return (buf_type == BUF_VIDEO_MPEG4);
+}
+
+static void xvid_init_plugin (video_decoder_t *this_gen, vo_instance_t *video_out) {
+ xvid_decoder_t *this = (xvid_decoder_t *) this_gen;
+
+ this->video_out = video_out;
+ this->decoder_running = 0;
+ this->buffer = NULL;
+ this->xvid_handle = NULL;
+}
+
+static void xvid_decode_data (video_decoder_t *this_gen, buf_element_t *buf) {
+ int xerr;
+ xvid_decoder_t *this = (xvid_decoder_t *) this_gen;
+
+#ifdef LOG
+ printf ("xvid: processing packet type = %08x, buf: %08x, buf->decoder_flags=%08x\n",
+ buf->type, buf, buf->decoder_flags);
+#endif
+
+ if (buf->decoder_flags & BUF_FLAG_HEADER) {
+ BITMAPINFOHEADER *bih;
+ XVID_DEC_PARAM xparam;
+
+ /* initialize data describing video stream */
+ bih = (BITMAPINFOHEADER *) buf->content;
+ this->frame_duration = buf->decoder_info[1];
+ /* FIXME: is BITMAPINFOHEADER always little-endian? ffmpeg plugin uses */
+ /* weird way to ensure correct endianess */
+ this->frame_width = le2me_32 (bih->biWidth);
+ this->frame_height = le2me_32 (bih->biHeight);
+
+ /* initialize decoder */
+ if (this->xvid_handle) {
+ xvid_decore (this->xvid_handle, XVID_DEC_DESTROY, NULL, NULL);
+ this->xvid_handle = NULL;
+ }
+
+ xparam.width = this->frame_width;
+ xparam.height = this->frame_height;
+ xparam.handle = NULL;
+ if ((xerr = xvid_decore (NULL, XVID_DEC_CREATE, &xparam, NULL)) == XVID_ERR_OK) {
+ this->xvid_handle = xparam.handle;
+
+ /* initialize video out */
+ this->video_out->open (this->video_out);
+
+ /* initialize buffer */
+ if (this->buffer) {
+ free (this->buffer);
+ }
+
+ this->buffer = malloc (VIDEOBUFSIZE);
+ this->buffer_size = VIDEOBUFSIZE;
+
+ this->decoder_running = 1;
+ this->skip_frames = 0;
+ } else {
+ printf ("xvid: cannot initialize xvid decoder, error = %d.\n", xerr);
+ return;
+ }
+
+ } else {
+ if (this->decoder_running) {
+
+ /* collect all video stream fragments until "end of frame" mark */
+ if (this->frame_size + buf->size > this->buffer_size) {
+ this->buffer_size = this->frame_size + 2 * buf->size;
+ printf ("xvid: increasing source buffer to %d to avoid overflow.\n", this->buffer_size);
+ this->buffer = realloc (this->buffer, this->buffer_size);
+ }
+
+ xine_fast_memcpy (&this->buffer[this->frame_size], buf->content, buf->size);
+ this->frame_size += buf->size;
+
+ /* after collecting complete frame, decode it and schedule to display it */
+ if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
+ vo_frame_t *image;
+ XVID_DEC_FRAME xframe;
+
+ image = this->video_out->get_frame (this->video_out,
+ this->frame_width, this->frame_height,
+ XINE_ASPECT_RATIO_DONT_TOUCH,
+ IMGFMT_YV12, VO_BOTH_FIELDS);
+ image->pts = buf->pts;
+ image->duration = this->frame_duration;
+ image->bad_frame = 0;
+
+ /* decode frame */
+ xframe.bitstream = this->buffer;
+ xframe.length = this->frame_size;
+ /* FIXME: This assumes, that YV12 planes are correctly laid off */
+ xframe.image = image->base[0];
+ xframe.stride = this->frame_width;
+ xframe.colorspace = XVID_CSP_YV12;
+
+ if ((xerr = xvid_decore (this->xvid_handle, XVID_DEC_DECODE, &xframe, NULL)) != XVID_ERR_OK
+ || this->skip_frames) {
+ if (this->skip_frames) {
+ printf ("xvid: skipping frame.\n");
+ } else {
+ printf ("xvid: error decompressing frame, error code = %d.\n", xerr);
+ }
+ image->bad_frame = 1;
+ }
+
+ /* add frame to display queue */
+ this->skip_frames = image->draw (image);
+ if (this->skip_frames < 0) {
+ this->skip_frames = 0;
+ }
+
+ image->free (image);
+ this->frame_size = 0;
+ }
+ }
+ }
+}
+
+static void xvid_flush (video_decoder_t *this_gen) {
+}
+
+static void xvid_close_plugin (video_decoder_t *this_gen) {
+ xvid_decoder_t *this = (xvid_decoder_t *) this_gen;
+
+ if (this->decoder_running) {
+ xvid_decore (this->xvid_handle, XVID_DEC_DESTROY, NULL, NULL);
+ this->xvid_handle = NULL;
+ this->video_out->close (this->video_out);
+ this->decoder_running = 0;
+ }
+ if (this->buffer) {
+ free (this->buffer);
+ this->buffer = NULL;
+ }
+}
+
+static char *xvid_get_id(void) {
+ return "XviD video decoder";
+}
+
+video_decoder_t *init_video_decoder_plugin (int iface_version, xine_t *xine) {
+ xvid_decoder_t *this;
+ XVID_INIT_PARAM xinit;
+
+ if (iface_version != 6) {
+ printf ("xvid: plugin doesn't support plugin API version %d.\n"
+ "xvid: this means there's a version mismatch between xine and this\n"
+ "xvid: decoder plugin. Installing current plugins should help.\n",
+ iface_version);
+ return NULL;
+ }
+
+ xinit.cpu_flags = 0;
+ xvid_init(NULL, 0, &xinit, NULL);
+ if (xinit.api_version != API_VERSION) {
+ printf ("xvid: there is mismatch between API used by currently installed XviD\n"
+ "xvid: library (%d.%d) and library used to compile this plugin (%d.%d).\n"
+ "xvid: Compiling this plugin against current XviD library should help.\n",
+ xinit.api_version >> 16, xinit.api_version & 0xFFFF,
+ API_VERSION >> 16, API_VERSION & 0xFFFF);
+ return NULL;
+ }
+
+ this = (xvid_decoder_t *) malloc (sizeof (xvid_decoder_t));
+
+ this->video_decoder.interface_version = iface_version;
+ this->video_decoder.can_handle = xvid_can_handle;
+ this->video_decoder.init = xvid_init_plugin;
+ this->video_decoder.decode_data = xvid_decode_data;
+ this->video_decoder.flush = xvid_flush;
+ this->video_decoder.close = xvid_close_plugin;
+ this->video_decoder.get_identifier = xvid_get_id;
+ this->video_decoder.priority = 6;
+ this->frame_size = 0;
+
+ return (video_decoder_t *) this;
+}