[Mplayer-cvslog] CVS: main/libmpdvdkit2 bswap.h,1.1,1.2 css.c,1.2,1.3 device.c,1.1,1.2 dvd_input.c,1.1,1.2 dvd_reader.c,1.1,1.2 dvd_udf.c,1.1,1.2 dvdcss.h,1.1,1.2 error.c,1.1,1.2 ifo_print.c,1.1,1.2 ifo_print.h,1.1,1.2 ifo_read.c,1.1,1.2 ifo_read.h,1.1,1.2 ifo_types.h,1.1,1.2 libdvdcss.c,1.2,1.3 nav_print.c,1.1,1.2 nav_print.h,1.1,1.2 nav_read.c,1.1,1.2 nav_read.h,1.1,1.2 nav_types.h,1.1,1.2

Arpi of Ize arpi at mplayerhq.hu
Sat Aug 17 00:50:25 CEST 2002


Update of /cvsroot/mplayer/main/libmpdvdkit2
In directory mail:/var/tmp.root/cvs-serv21024

Modified Files:
	bswap.h css.c device.c dvd_input.c dvd_reader.c dvd_udf.c 
	dvdcss.h error.c ifo_print.c ifo_print.h ifo_read.c ifo_read.h 
	ifo_types.h libdvdcss.c nav_print.c nav_print.h nav_read.c 
	nav_read.h nav_types.h 
Log Message:
apply mplayer-specific patches


Index: bswap.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit2/bswap.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- bswap.h	16 Aug 2002 22:37:48 -0000	1.1
+++ bswap.h	16 Aug 2002 22:50:21 -0000	1.2
@@ -20,8 +20,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
-#include <config.h>
-
 #if defined(WORDS_BIGENDIAN)
 /* All bigendian systems are fine, just ignore the swaps. */  
 #define B2N_16(x) (void)(x)
@@ -48,13 +46,51 @@
 #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 
  * functionality! 
  */
 
-#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__)
+#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) || defined(__CYGWIN__)
 #define B2N_16(x) \
  x = ((((x) & 0xff00) >> 8) | \
       (((x) & 0x00ff) << 8))

Index: css.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit2/css.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- css.c	16 Aug 2002 22:46:01 -0000	1.2
+++ css.c	16 Aug 2002 22:50:21 -0000	1.3
@@ -42,7 +42,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
-#include "dvdcss/dvdcss.h"
+#include "dvdcss.h"
 
 #include "common.h"
 #include "css.h"

Index: device.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit2/device.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- device.c	16 Aug 2002 22:35:45 -0000	1.1
+++ device.c	16 Aug 2002 22:50:21 -0000	1.2
@@ -45,7 +45,7 @@
 #   include <sys/uio.h>                                      /* struct iovec */
 #endif
 
-#include "dvdcss/dvdcss.h"
+#include "dvdcss.h"
 
 #include "common.h"
 #include "css.h"

Index: dvd_input.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit2/dvd_input.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- dvd_input.c	16 Aug 2002 22:37:48 -0000	1.1
+++ dvd_input.c	16 Aug 2002 22:50:21 -0000	1.2
@@ -21,13 +21,11 @@
 #include <stdlib.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <dlfcn.h>
 
 #include "dvd_reader.h"
 #include "dvd_input.h"
 
-/* For libdvdcss */
-typedef struct dvdcss_s *dvdcss_handle;
+#include "dvdcss.h"
 
 dvdcss_handle (*DVDcss_open)  (const char *);
 int           (*DVDcss_close) (dvdcss_handle);
@@ -123,176 +121,26 @@
 
 
 
-
-
-
-/**
- * initialize and open a DVD device or file.
- */
-static dvd_input_t file_open(const char *target)
-{
-  dvd_input_t dev;
-  
-  /* Allocate the library structure */
-  dev = (dvd_input_t) malloc(sizeof(dvd_input_t));
-  if(dev == NULL) {
-    fprintf(stderr, "libdvdread: Could not allocate memory.\n");
-    return NULL;
-  }
-  
-  /* Open the device */
-  dev->fd = open(target, O_RDONLY);
-  if(dev->fd < 0) {
-    perror("libdvdread: Could not open input");
-    free(dev);
-    return NULL;
-  }
-  
-  return dev;
-}
-
-/**
- * return the last error message
- */
-static char *file_error(dvd_input_t dev)
-{
-  /* use strerror(errno)? */
-  return "unknown error";
-}
-
-/**
- * seek into the device.
- */
-static int file_seek(dvd_input_t dev, int blocks, int flags)
-{
-  off_t pos;
-
-  pos = lseek(dev->fd, (off_t)blocks * (off_t)DVD_VIDEO_LB_LEN, SEEK_SET);
-  if(pos < 0) {
-      return pos;
-  }
-  /* assert pos % DVD_VIDEO_LB_LEN == 0 */
-  return (int) (pos / DVD_VIDEO_LB_LEN);
-}
-
-/**
- * set the block for the begining of a new title (key).
- */
-static int file_title(dvd_input_t dev, int block)
-{
-  return -1;
-}
-
-/**
- * read data from the device.
- */
-static int file_read(dvd_input_t dev, void *buffer, int blocks, int flags)
-{
-  size_t len;
-  ssize_t ret;
-  
-  len = (size_t)blocks * DVD_VIDEO_LB_LEN;
-  
-  while(len > 0) {
-    
-    ret = read(dev->fd, buffer, len);
-    
-    if(ret < 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 ret;
-    }
-    
-    if(ret == 0) {
-      /* Nothing more to read.  Return the whole blocks, if any, that we got.
-	 and adjust the file possition back to the previous block boundary. */
-      size_t bytes = (size_t)blocks * DVD_VIDEO_LB_LEN - len;
-      off_t over_read = -(bytes % DVD_VIDEO_LB_LEN);
-      /*off_t pos =*/ lseek(dev->fd, over_read, SEEK_CUR);
-      /* should have pos % 2048 == 0 */
-      return (int) (bytes / DVD_VIDEO_LB_LEN);
-    }
-    
-    len -= ret;
-  }
-
-  return blocks;
-}
-
-/**
- * close the DVD device and clean up.
- */
-static int file_close(dvd_input_t dev)
-{
-  int ret;
-
-  ret = close(dev->fd);
-
-  if(ret < 0)
-    return ret;
-
-  free(dev);
-
-  return 0;
-}
-
-
 /**
  * Setup read functions with either libdvdcss or minimal DVD access.
  */
 int DVDInputSetup(void)
 {
-  void *dvdcss_library = NULL;
-  char **dvdcss_version = NULL;
-  
-  dvdcss_library = dlopen("libdvdcss.so.2", RTLD_LAZY);
-  
-  if(dvdcss_library != NULL) {
-#if defined(__OpenBSD__) && !defined(__ELF__)
-#define U_S "_"
-#else
-#define U_S
-#endif
-    DVDcss_open = (dvdcss_handle (*)(const char*))
-      dlsym(dvdcss_library, U_S "dvdcss_open");
-    DVDcss_close = (int (*)(dvdcss_handle))
-      dlsym(dvdcss_library, U_S "dvdcss_close");
-    DVDcss_title = (int (*)(dvdcss_handle, int))
-      dlsym(dvdcss_library, U_S "dvdcss_title");
-    DVDcss_seek = (int (*)(dvdcss_handle, int, int))
-      dlsym(dvdcss_library, U_S "dvdcss_seek");
-    DVDcss_read = (int (*)(dvdcss_handle, void*, int, int))
-      dlsym(dvdcss_library, U_S "dvdcss_read");
-    DVDcss_error = (char* (*)(dvdcss_handle))
-      dlsym(dvdcss_library, U_S "dvdcss_error");
+    DVDcss_open = dvdcss_open;
+    DVDcss_close = dvdcss_close;
+    DVDcss_title = dvdcss_title;
+    DVDcss_seek = dvdcss_seek;
+    DVDcss_read = dvdcss_read;
+    DVDcss_error = dvdcss_error;
     
-    dvdcss_version = (char **)dlsym(dvdcss_library, U_S "dvdcss_interface_2");
-
-    if(dlsym(dvdcss_library, U_S "dvdcss_crack")) {
-      fprintf(stderr, 
-	      "libdvdread: Old (pre-0.0.2) version of libdvdcss found.\n"
-	      "libdvdread: You should get the latest version from "
-	      "http://www.videolan.org/\n" );
-      dlclose(dvdcss_library);
-      dvdcss_library = NULL;
-    } else if(!DVDcss_open  || !DVDcss_close || !DVDcss_title || !DVDcss_seek
-	      || !DVDcss_read || !DVDcss_error || !dvdcss_version) {
-      fprintf(stderr,  "libdvdread: Missing symbols in libdvdcss.so.2, "
-	      "this shouldn't happen !\n");
-      dlclose(dvdcss_library);
-    }
-  }
-  
-  if(dvdcss_library != NULL) {
     /*
     char *psz_method = getenv( "DVDCSS_METHOD" );
     char *psz_verbose = getenv( "DVDCSS_VERBOSE" );
     fprintf(stderr, "DVDCSS_METHOD %s\n", psz_method);
     fprintf(stderr, "DVDCSS_VERBOSE %s\n", psz_verbose);
     */
-    fprintf(stderr, "libdvdread: Using libdvdcss version %s for DVD access\n",
-	    *dvdcss_version);
+//    fprintf(stderr, "libdvdread: Using libdvdcss version %s for DVD access\n",
+//	    *dvdcss_version);
     
     /* libdvdcss wraper functions */
     DVDinput_open  = css_open;
@@ -303,16 +151,4 @@
     DVDinput_error = css_error;
     return 1;
     
-  } else {
-    fprintf(stderr, "libdvdread: Encrypted DVD support unavailable.\n");
-
-    /* libdvdcss replacement functions */
-    DVDinput_open  = file_open;
-    DVDinput_close = file_close;
-    DVDinput_seek  = file_seek;
-    DVDinput_title = file_title;
-    DVDinput_read  = file_read;
-    DVDinput_error = file_error;
-    return 0;
-  }
 }

Index: dvd_reader.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit2/dvd_reader.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- dvd_reader.c	16 Aug 2002 22:37:48 -0000	1.1
+++ dvd_reader.c	16 Aug 2002 22:50:21 -0000	1.2
@@ -17,6 +17,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  */
 
+#include "config.h"
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/time.h> /* For the timing of dvdcss_title crack. */
@@ -144,6 +146,13 @@
 }
 
 
+#ifndef HAVE_MPLAYER
+ #include "get_path.c"
+#else
+ extern char * get_path( char * filename );
+#endif
+
+extern char * dvdcss_cache_dir;
 
 /**
  * Open a DVD image or block device file.
@@ -152,7 +161,16 @@
 {
     dvd_reader_t *dvd;
     dvd_input_t dev;
+
+    /* setup cache dir */
+    if(!dvdcss_cache_dir){
+	dvdcss_cache_dir=get_path( "" );
+	if ( dvdcss_cache_dir ) { mkdir( dvdcss_cache_dir,493 ); free( dvdcss_cache_dir ); }
+	dvdcss_cache_dir=get_path( "DVDKeys" );
+	if(dvdcss_cache_dir) mkdir( dvdcss_cache_dir,493 );
+    }
     
+    /* open it */
     dev = DVDinput_open( location );
     if( !dev ) {
 	fprintf( stderr, "libdvdread: Can't open %s for reading\n", location );
@@ -364,6 +382,9 @@
             }
             fclose( mntfile );
 	}
+#elif defined(WIN32)	
+	dev_name = strdup(path);
+	auth_drive = DVDOpenImageFile( path, have_css );
 #endif
 	if( !dev_name ) {
 	  fprintf( stderr, "libdvdread: Couldn't find device name.\n" );
@@ -554,8 +575,8 @@
     }
     
     if( dvd->css_state == 1 /* Need key init */ ) {
-        initAllCSSKeys( dvd );
-	dvd->css_state = 2;
+//        initAllCSSKeys( dvd );
+//	dvd->css_state = 2;
     }
     /*    
     if( DVDinput_seek( dvd_file->dvd->dev, 

Index: dvd_udf.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit2/dvd_udf.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- dvd_udf.c	16 Aug 2002 22:37:48 -0000	1.1
+++ dvd_udf.c	16 Aug 2002 22:50:21 -0000	1.2
@@ -30,7 +30,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <assert.h>
+//#include <assert.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/stat.h>

Index: dvdcss.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit2/dvdcss.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- dvdcss.h	16 Aug 2002 22:35:45 -0000	1.1
+++ dvdcss.h	16 Aug 2002 22:50:21 -0000	1.2
@@ -61,12 +61,18 @@
  */
 extern char *        dvdcss_interface_2;
 
+/*
+ * Path to CSS key cache. Default == NULL (no cache).
+ */
+extern char * dvdcss_cache_dir;
 
 /*
  * Exported prototypes.
  */
 extern dvdcss_t dvdcss_open  ( char *psz_target );
 extern int      dvdcss_close ( dvdcss_t );
+extern int      dvdcss_title ( dvdcss_t,
+                               int i_block );
 extern int      dvdcss_seek  ( dvdcss_t,
                                int i_blocks,
                                int i_flags );

Index: error.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit2/error.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- error.c	16 Aug 2002 22:35:45 -0000	1.1
+++ error.c	16 Aug 2002 22:50:21 -0000	1.2
@@ -25,7 +25,7 @@
 
 #include <stdio.h>
 
-#include "dvdcss/dvdcss.h"
+#include "dvdcss.h"
 
 #include "common.h"
 #include "css.h"

Index: ifo_print.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit2/ifo_print.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ifo_print.c	16 Aug 2002 22:37:48 -0000	1.1
+++ ifo_print.c	16 Aug 2002 22:50:21 -0000	1.2
@@ -23,7 +23,7 @@
 #include <inttypes.h>
 #include <string.h>
 #include <ctype.h>
-#include <assert.h>
+//#include <assert.h>
 
 #include "config.h" // Needed for WORDS_BIGENDIAN
 #include "ifo_types.h"

Index: ifo_print.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit2/ifo_print.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ifo_print.h	16 Aug 2002 22:37:48 -0000	1.1
+++ ifo_print.h	16 Aug 2002 22:50:21 -0000	1.2
@@ -20,8 +20,8 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include <dvdread/ifo_types.h>
-#include <dvdread/dvd_reader.h>
+#include "ifo_types.h"
+#include "dvd_reader.h"
 
 #ifdef __cplusplus
 extern "C" {

Index: ifo_read.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit2/ifo_read.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ifo_read.c	16 Aug 2002 22:37:48 -0000	1.1
+++ ifo_read.c	16 Aug 2002 22:50:21 -0000	1.2
@@ -22,7 +22,7 @@
 #include <unistd.h>
 #include <inttypes.h>
 #include <string.h>
-#include <assert.h>
+//#include <assert.h>
 
 #include "dvd_reader.h"
 

Index: ifo_read.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit2/ifo_read.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ifo_read.h	16 Aug 2002 22:37:48 -0000	1.1
+++ ifo_read.h	16 Aug 2002 22:50:21 -0000	1.2
@@ -20,8 +20,8 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include <dvdread/ifo_types.h>
-#include <dvdread/dvd_reader.h>
+#include "ifo_types.h"
+#include "dvd_reader.h"
 
 #ifdef __cplusplus
 extern "C" {

Index: ifo_types.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit2/ifo_types.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ifo_types.h	16 Aug 2002 22:37:48 -0000	1.1
+++ ifo_types.h	16 Aug 2002 22:50:21 -0000	1.2
@@ -21,7 +21,7 @@
  */
 
 #include <inttypes.h>
-#include <dvdread/dvd_reader.h>
+#include "dvd_reader.h"
 
 
 #undef ATTRIBUTE_PACKED

Index: libdvdcss.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit2/libdvdcss.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- libdvdcss.c	16 Aug 2002 22:46:01 -0000	1.2
+++ libdvdcss.c	16 Aug 2002 22:50:22 -0000	1.3
@@ -97,7 +97,7 @@
 #   include <unistd.h>
 #endif
 
-#include "dvdcss/dvdcss.h"
+#include "dvdcss.h"
 
 #include "common.h"
 #include "css.h"

Index: nav_print.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit2/nav_print.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- nav_print.c	16 Aug 2002 22:37:48 -0000	1.1
+++ nav_print.c	16 Aug 2002 22:50:22 -0000	1.2
@@ -25,7 +25,7 @@
 
 #include <stdio.h>
 #include <inttypes.h>
-#include <assert.h>
+//#include <assert.h>
 
 #include "config.h" // Needed for WORDS_BIGENDIAN
 #include "nav_types.h"

Index: nav_print.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit2/nav_print.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- nav_print.h	16 Aug 2002 22:37:48 -0000	1.1
+++ nav_print.h	16 Aug 2002 22:50:22 -0000	1.2
@@ -20,7 +20,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include <dvdread/nav_types.h>
+#include "nav_types.h"
 
 #ifdef __cplusplus
 extern "C" {

Index: nav_read.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit2/nav_read.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- nav_read.c	16 Aug 2002 22:37:48 -0000	1.1
+++ nav_read.c	16 Aug 2002 22:50:22 -0000	1.2
@@ -19,7 +19,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <inttypes.h>
-#include <assert.h>
+//#include <assert.h>
 
 #include "config.h" // Needed for WORDS_BIGENDIAN
 #include "bswap.h"

Index: nav_read.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit2/nav_read.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- nav_read.h	16 Aug 2002 22:37:48 -0000	1.1
+++ nav_read.h	16 Aug 2002 22:50:22 -0000	1.2
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include <dvdread/nav_types.h>
+#include "nav_types.h"
 
 #ifdef __cplusplus
 extern "C" {

Index: nav_types.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit2/nav_types.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- nav_types.h	16 Aug 2002 22:37:48 -0000	1.1
+++ nav_types.h	16 Aug 2002 22:50:22 -0000	1.2
@@ -30,7 +30,7 @@
  */
 
 #include <inttypes.h>
-#include <dvdread/ifo_types.h> // only dvd_time_t, vm_cmd_t and user_ops_t
+#include "ifo_types.h" // only dvd_time_t, vm_cmd_t and user_ops_t
 
 
 #undef ATTRIBUTE_PACKED




More information about the MPlayer-cvslog mailing list