[MPlayer-dev-eng] [PATCH] cygwin dvd, bswap, and vo2

Joey Parrish joey at yunamusic.com
Sun Jun 23 12:34:52 CEST 2002


On Sun, Jun 23, 2002 at 05:31:14AM -0500, Joey Parrish wrote:
> Hello,
> 
> Attached are three patches,

Ah, well, I forgot to attach them.
But this time I mean it, there really are
three patches attached.  :-)

--Joey

> one to get dvd support working
> under cygwin, one to optimize mpdvdkit's bswap for x86, and
> one to remove references to libvo2.  I hope I read correctly
> in the DOCS that libvo2 was abandoned.
> 
> The cygwin dvd patch is untested, but it currently does not
> compile mpdvdkit at all, so hopefully it's a start.  Vlc code
> that uses input_iovec.h was added to mpdvdkit, but that header
> itself was not.  This is fixed in this patch.  I also tweaked
> the use of certain system headers on cygwin/win32 so that
> the code would compile cleanly.
> 
> The bswap patch is based from the bswap.h found elsewhere
> in the mplayer tree.  I just added to mpdvdkit's bswap rather
> than replacing it, but would it be a better idea to use only
> one such file in the whole tree instead of two or three?
> 
> Slightly off-topic, but before I begin work on porting the
> xine/libquicktime sorenson code, is anybody else already
> doing this?
> 
> --Joey

-- 

"All you need is love." --Darth Vader
-------------- next part --------------
diff -Naur -x CVS -x libavcodec ../main.cvs/configure ./configure
--- ../main.cvs/configure	Mon Jun 17 04:10:32 2002
+++ ./configure	Sun Jun 23 02:13:37 2002
@@ -2973,9 +2973,11 @@
  fi
 fi
 if test "$_dvdkit" = yes ; then
-  if test "$_dvd" = yes || test "$_cdrom" = yes || test "$_cdio" = yes || test "$_dvdio" = yes || test "$_bdsi_dvd" = yes ; then
+  if test "$_dvd" = yes || test "$_cdrom" = yes || test "$_cdio" = yes || test "$_dvdio" = yes || test "$_bdsi_dvd" = yes || cygwin; then
     _inputmodules="mpdvdkit $_inputmodules"
     _dvdread=included
+  else
+    _noinputmodules="mpdvdkit $_noinputmodules"
   fi
   _def_dvd_linux='#undef HAVE_LINUX_DVD_STRUCT'
   _def_dvd_bsd='#undef HAVE_BSD_DVD_STRUCT'
diff -Naur -x CVS -x libavcodec ../main.cvs/libmpdvdkit/common.h ./libmpdvdkit/common.h
--- ../main.cvs/libmpdvdkit/common.h	Wed Jun 19 01:57:32 2002
+++ ./libmpdvdkit/common.h	Sun Jun 23 02:13:37 2002
@@ -140,7 +140,8 @@
  *****************************************************************************/
 #ifdef NTOHL_IN_SYS_PARAM_H
 #   include <sys/param.h>
-#elif defined(WIN32) && !defined(__CYGWIN__)
+#elif defined(WIN32)
+#   define NONAMELESSUNION
 #   include <winsock.h>
 #else
 #   include <netinet/in.h>
diff -Naur -x CVS -x libavcodec ../main.cvs/libmpdvdkit/css.c ./libmpdvdkit/css.c
--- ../main.cvs/libmpdvdkit/css.c	Thu Apr 25 12:08:03 2002
+++ ./libmpdvdkit/css.c	Sun Jun 23 02:13:37 2002
@@ -33,6 +33,12 @@
  * Preamble
  *****************************************************************************/
 
+#include "config.h"
+
+#if defined(WIN32)
+# define __USE_W32_SOCKETS 1
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -40,7 +46,6 @@
 
 #include <sys/types.h>
 
-#include "config.h"
 #include "common.h"
 
 #include "dvdcss.h"
diff -Naur -x CVS -x libavcodec ../main.cvs/libmpdvdkit/dvd_reader.c ./libmpdvdkit/dvd_reader.c
--- ../main.cvs/libmpdvdkit/dvd_reader.c	Thu Jun 13 00:11:16 2002
+++ ./libmpdvdkit/dvd_reader.c	Sun Jun 23 02:13:37 2002
@@ -16,6 +16,8 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include "config.h"
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/time.h> /* For the timing of dvdcss_title crack. */
@@ -40,8 +42,14 @@
 #include <mntent.h>
 #endif
 
-#if defined(SYS_BSD) || defined(__CYGWIN__)
+#if defined(SYS_BSD)
 typedef off_t off64_t;
+#define lseek64 lseek
+#define stat64 stat
+#endif
+
+#if defined(WIN32)
+typedef u_int64_t off64_t;
 #define lseek64 lseek
 #define stat64 stat
 #endif
diff -Naur -x CVS -x libavcodec ../main.cvs/libmpdvdkit/input_iovec.h ./libmpdvdkit/input_iovec.h
--- ../main.cvs/libmpdvdkit/input_iovec.h	Wed Dec 31 18:00:00 1969
+++ ./libmpdvdkit/input_iovec.h	Sun Jun 23 02:13:37 2002
@@ -0,0 +1,79 @@
+/*****************************************************************************
+ * input_iovec.h: iovec structure
+ *****************************************************************************
+ * Copyright (C) 2001 VideoLAN
+ *
+ * Authors: Samuel Hocevar <sam at zoy.org>
+ *          Jon Lech Johansen <jon-vl at nanocrew.net>
+ *
+ * This program 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.
+ * 
+ * This program 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, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * iovec structure: vectored data entry
+ *****************************************************************************/
+struct iovec
+{
+    void *iov_base;     /* Pointer to data. */
+    size_t iov_len;     /* Length of data.  */
+};
+
+/*****************************************************************************
+ * readv_*: readv() replacements for iovec-impaired C libraries
+ *****************************************************************************/
+#if defined( WIN32 )
+static inline int readv( int i_fd, struct iovec *p_iovec, int i_count )
+{
+    int i_index, i_len, i_total = 0;
+    unsigned char *p_base;
+    int i_bytes;
+
+    for( i_index = i_count; i_index; i_index-- )
+    {
+
+        i_len  = p_iovec->iov_len;
+        p_base = p_iovec->iov_base;
+
+        /* Loop is unrolled one time to spare the (i_bytes <= 0) test */
+
+        if( i_len > 0 )
+        {
+            i_bytes = read( i_fd, p_base, i_len );
+
+            if( i_bytes < 0 )
+            {
+                /* One of the reads failed, too bad.
+                   We won't even bother returning the reads that went ok,
+                   and as in the posix spec the file postition is left
+                   unspecified after a failure */
+                return -1;
+            }
+
+            i_total += i_bytes;
+
+            if( i_bytes != i_len )
+            {
+                /* we reached the end of the file or a signal interrupted
+                   the read */
+                return i_total;
+            }
+        }
+
+        p_iovec++;
+    }
+
+    return i_total;
+}
+#endif /* WIN32 */
diff -Naur -x CVS -x libavcodec ../main.cvs/libmpdvdkit/ioctl.c ./libmpdvdkit/ioctl.c
--- ../main.cvs/libmpdvdkit/ioctl.c	Thu Jun 13 18:10:12 2002
+++ ./libmpdvdkit/ioctl.c	Sun Jun 23 02:13:37 2002
@@ -29,6 +29,11 @@
  *****************************************************************************/
 #include "config.h"
 
+#if defined(WIN32)
+# define __USE_W32_SOCKETS 1
+# define NONAMELESSUNION
+#endif
+
 #include <string.h>                                    /* memcpy(), memset() */
 #include <sys/types.h>
 
diff -Naur -x CVS -x libavcodec ../main.cvs/libmpdvdkit/ioctl.h ./libmpdvdkit/ioctl.h
--- ../main.cvs/libmpdvdkit/ioctl.h	Tue Jun  4 15:11:15 2002
+++ ./libmpdvdkit/ioctl.h	Sun Jun 23 02:13:37 2002
@@ -32,13 +32,6 @@
 int ioctl_SendChallenge     ( int, int *, u8 * );
 int ioctl_SendKey2          ( int, int *, u8 * );
 
-#if defined (__CYGWIN__)
-#include <w32api/windef.h>
-#include <w32api/winnt.h>
-#define va_list void
-#include <w32api/winbase.h>
-#endif
-
 /*****************************************************************************
  * Common macro, BeOS specific
  *****************************************************************************/
diff -Naur -x CVS -x libavcodec ../main.cvs/libmpdvdkit/libdvdcss.c ./libmpdvdkit/libdvdcss.c
--- ../main.cvs/libmpdvdkit/libdvdcss.c	Tue Jun  4 15:11:15 2002
+++ ./libmpdvdkit/libdvdcss.c	Sun Jun 23 02:13:37 2002
@@ -26,6 +26,12 @@
  * Preamble
  *****************************************************************************/
 
+#include "config.h"
+
+#if defined(WIN32)
+# define __USE_W32_SOCKETS 1
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -34,16 +40,15 @@
 #include <fcntl.h>
 #include <unistd.h>
 
-#if defined( WIN32 ) && !defined(__CYGWIN__)
+#if defined( WIN32 )
 #   include <io.h>                                                 /* read() */
 #else
 #   include <sys/uio.h>                                      /* struct iovec */
 #endif
 
-#include "config.h"
 #include "common.h"
 
-#if defined( WIN32 ) && !defined(__CYGWIN__)
+#if defined( WIN32 )
 #   include "input_iovec.h"
 #endif
 
@@ -495,7 +500,15 @@
 
     if( WIN2K )
     {
+#if defined(__CYGWIN__)
+	struct {
+		uint32_t LowPart;
+		uint32_t HighPart;
+		uint32_t QuadPart;
+	} li_read;
+#else
         LARGE_INTEGER li_read;
+#endif
 
 #ifndef INVALID_SET_FILE_POINTER
 #define INVALID_SET_FILE_POINTER ((DWORD)-1)
@@ -505,9 +518,12 @@
 
         li_read.LowPart = SetFilePointer( (HANDLE) dvdcss->i_fd,
                                           li_read.LowPart,
-                                          &li_read.HighPart, FILE_BEGIN );
+                                          &(li_read.HighPart), FILE_BEGIN );
         if( (li_read.LowPart == INVALID_SET_FILE_POINTER)
-            && GetLastError() != NO_ERROR)
+#if !defined(__CYGWIN)
+            && GetLastError() != NO_ERROR
+#endif
+	    )
         {
             li_read.QuadPart = -DVDCSS_BLOCK_SIZE;
         }
-------------- next part --------------
diff -Naur -x CVS -x libavcodec ../main.cvs/libmpdvdkit/bswap.h ./libmpdvdkit/bswap.h
--- ../main.cvs/libmpdvdkit/bswap.h	Tue Jun  4 15:11:15 2002
+++ ./libmpdvdkit/bswap.h	Sun Jun 23 02:13:36 2002
@@ -48,6 +48,44 @@
 #define B2N_32(x) x = swap32(x)
 #define B2N_64(x) x = swap64(x)
 
+#elif defined(ARCH_X86)
+inline static unsigned short bswap_16(unsigned short x)
+{
+  __asm("xchgb %b0,%h0" :
+        "=q" (x)        :
+        "0" (x));
+    return x;
+}
+#define B2N_16(x) x = bswap_16(x)
+
+inline static unsigned int bswap_32(unsigned int x)
+{
+ __asm(
+#if __CPU__ > 386
+      "bswap   %0":
+      "=r" (x)     :
+#else
+      "xchgb   %b0,%h0\n"
+      " rorl    $16,%0\n"
+      " xchgb   %b0,%h0":
+      "=q" (x)          :
+#endif
+      "0" (x));
+  return x;
+}
+#define B2N_32(x) x = bswap_32(x)
+
+inline static unsigned long long int bswap_64(unsigned long long int x)
+{
+  register union { __extension__ uint64_t __ll;
+          uint32_t __l[2]; } __x;
+  asm("xchgl    %0,%1":
+      "=r"(__x.__l[0]),"=r"(__x.__l[1]):
+      "0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32))));
+  return __x.__ll;
+}
+#define B2N_64(x) x = bswap_64(x)
+
 /* This is a slow but portable implementation, it has multiple evaluation 
  * problems so beware.
  * FreeBSD and Solaris don't have <byteswap.h> or any other such 
-------------- next part --------------
diff -Naur -x CVS -x libavcodec ../main.cvs/Makefile ./Makefile
--- ../main.cvs/Makefile	Fri Jun 21 01:25:01 2002
+++ ./Makefile	Sun Jun 23 02:13:39 2002
@@ -38,13 +38,8 @@
 OBJS_MENCODER = $(SRCS_MENCODER:.c=.o)
 OBJS_MPLAYER = $(SRCS_MPLAYER:.c=.o)
 
-ifeq ($(VO2),yes)
-VO_LIBS = -Llibvo2 -lvo2
-VO_INC = -Ilibvo2
-else
 VO_LIBS = -Llibvo -lvo
 VO_INC = -Ilibvo
-endif
 V_LIBS = $(X_LIB) $(MP1E_LIB) $(GGI_LIB) $(MLIB_LIB) $(SDL_LIB) $(SVGA_LIB) $(AA_LIB) $(DIRECTFB_LIB)
 
 AO_LIBS = -Llibao2 -lao2
@@ -57,15 +52,10 @@
 endif
 CFLAGS = $(OPTFLAGS) -Ilibmpdemux -Iloader $(VO_INC) $(EXTRA_INC) $(CDPARANOIA_INC)# -Wall
 
-PARTS = libfame libmpdemux libmpcodecs mp3lib liba52 libmp1e libmpeg2 libavcodec libao2 drivers linux postproc input libmpdvdkit
+PARTS = libfame libmpdemux libmpcodecs mp3lib liba52 libmp1e libmpeg2 libavcodec libao2 drivers linux postproc input libmpdvdkit libvo
 ifeq ($(VIDIX),yes)
 PARTS += libdha vidix
 endif
-ifeq ($(VO2),yes)
-PARTS += libvo2
-else
-PARTS += libvo
-endif
 
 ifeq ($(GUI),yes)
 PARTS += Gui
@@ -97,16 +87,11 @@
 .c.o:
 	$(CC) -c $(CFLAGS) -o $@ $<
 
-COMMON_DEPS = libmpdemux/libmpdemux.a libmpcodecs/libmpcodecs.a libao2/libao2.a liba52/liba52.a mp3lib/libMP3.a libmpeg2/libmpeg2.a linux/libosdep.a postproc/libpostproc.a input/libinput.a
+COMMON_DEPS = libmpdemux/libmpdemux.a libmpcodecs/libmpcodecs.a libao2/libao2.a liba52/liba52.a mp3lib/libMP3.a libmpeg2/libmpeg2.a linux/libosdep.a postproc/libpostproc.a input/libinput.a libvo/libvo.a
 
 ifeq ($(VIDIX),yes)
 COMMON_DEPS += libdha/libdha.so vidix/libvidix.a
 endif
-ifeq ($(VO2),yes)
-COMMON_DEPS += libvo2/libvo2.a
-else
-COMMON_DEPS += libvo/libvo.a
-endif
 ifeq ($(FAME),yes)
 COMMON_DEPS += libfame/libfame.a
 endif
@@ -153,9 +138,6 @@
 
 libvo/libvo.a:
 	$(MAKE) -C libvo
-
-libvo2/libvo2.a:
-	$(MAKE) -C libvo2
 
 libao2/libao2.a:
 	$(MAKE) -C libao2
diff -Naur -x CVS -x libavcodec ../main.cvs/configure ./configure
--- ../main.cvs/configure	Mon Jun 17 04:10:32 2002
+++ ./configure	Sun Jun 23 02:13:39 2002
@@ -20,7 +20,7 @@
 # GOTCHAS:
 #  - config files are currently:
 #    config.h config.mak libvo/config.mak libao2/config.mak
-#    Gui/config.mak libvo2/config.mak
+#    Gui/config.mak
 #
 #############################################################################
 
@@ -956,7 +956,6 @@
 _directfb=auto
 _zr=no
 _largefiles=no
-_vo2=no
 _language=en
 _shm=auto
 _linux_devfs=no
@@ -1110,8 +1109,6 @@
   --disable-mtrr)	_mtrr=no	;;
   --enable-largefiles)	_largefiles=yes	;;
   --disable-largefiles)	_largefiles=no	;;
-  --enable-vo2)		_vo2=yes	;;
-  --disable-vo2)	_vo2=no		;;
   --enable-shm)		_shm=yes	;;
   --disable-shm)	_shm=no         ;;
   --enable-select)	_select=yes	;;
@@ -4021,8 +4018,6 @@
 
 OPENDIVX = $_opendivx
 
-VO2 = $_vo2
-
 PNG = $_mkf_png
 JPEG = $_mkf_jpg
 GIF = $_mkf_gif
@@ -4493,20 +4488,6 @@
 OPTIONAL_SRCS = $_vosrc
 OPTIONAL_OBJS = $_voobj
 EOF
-
-#############################################################################
-
-if test -d "libvo2" ; then
-
-echo "Creating libvo2/config.mak"
-_vo2obj=`echo $_vo2src | sed -e 's/\.c/\.o/g'`
-cat > libvo2/config.mak << EOF
-include ../config.mak
-OPTIONAL_SRCS = $_vo2src
-OPTIONAL_OBJS = $_vo2obj
-EOF
-
-fi
 
 #############################################################################
 
diff -Naur -x CVS -x libavcodec ../main.cvs/dll_init.c ./dll_init.c
--- ../main.cvs/dll_init.c	Sun Apr 21 06:37:44 2002
+++ ./dll_init.c	Sun Jun 23 02:13:39 2002
@@ -24,11 +24,7 @@
 
 #include "dll_init.h"
 
-#ifdef USE_LIBVO2
-#include "libvo2/img_format.h"
-#else
 #include "libvo/img_format.h"
-#endif
 #include "linux/shmem.h"
 
 extern int divx_quality;
diff -Naur -x CVS -x libavcodec ../main.cvs/find_sub.c ./find_sub.c
--- ../main.cvs/find_sub.c	Mon Apr 15 14:17:12 2002
+++ ./find_sub.c	Sun Jun 23 02:13:39 2002
@@ -8,13 +8,8 @@
 
 #include <stdio.h>
 
-#ifdef USE_LIBVO2
-#include "libvo2/libvo2.h"
-#include "libvo2/sub.h"
-#else
 #include "libvo/video_out.h"
 #include "libvo/sub.h"
-#endif
 #include "subreader.h"
 
 static int current_sub=0;
diff -Naur -x CVS -x libavcodec ../main.cvs/xacodec.c ./xacodec.c
--- ../main.cvs/xacodec.c	Sat Mar 23 12:38:41 2002
+++ ./xacodec.c	Sun Jun 23 02:13:39 2002
@@ -29,11 +29,7 @@
 #include "codec-cfg.h"
 #include "stheader.h"
 
-#ifdef USE_LIBVO2
-#include "libvo2/img_format.h"
-#else
 #include "libvo/img_format.h"
-#endif
 #include "linux/timer.h"
 #include "xacodec.h"
 


More information about the MPlayer-dev-eng mailing list