[MPlayer-dev-eng] [PATCH] updated diff for libdvdread-0.9.5

Emanuele Giaquinta emanuele.giaquinta at gmail.com
Fri Jan 27 14:40:30 CET 2006


Hi,

Attached is the patchset for libdvdread, updated for version 0.9.5.

--
Emanuele Giaquinta
-------------- next part --------------
--- dvdread/bswap.h	2006-01-26 13:11:45.000000000 +0100
+++ dvdread/bswap.h	2006-01-26 13:04:03.000000000 +0100
@@ -76,13 +76,51 @@
 #define B2N_32(x) x = be32toh(x)
 #define B2N_64(x) x = be64toh(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.
  * Old FreeBSD's and Solaris don't have <byteswap.h> or any other such 
  * functionality! 
  */
 
-#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) || defined(WIN32) || defined(__BEOS__) || defined(__INTERIX)
+#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) || defined(WIN32) || defined(__BEOS__) || defined(__INTERIX) || defined(__CYGWIN__)
 #define B2N_16(x)                               \
   x = ((((x) & 0xff00) >> 8) |                  \
        (((x) & 0x00ff) << 8))
--- dvdread/dvd_input.c	2006-01-26 13:11:07.000000000 +0100
+++ dvdread/dvd_input.c	2006-01-26 13:04:10.000000000 +0100
@@ -46,7 +46,7 @@
 
 #ifdef HAVE_DVDCSS_DVDCSS_H
 /* linking to libdvdcss */
-#include <dvdcss/dvdcss.h>
+#include "dvdcss.h"
 #define DVDcss_open(a) dvdcss_open((char*)(a))
 #define DVDcss_close   dvdcss_close
 #define DVDcss_seek    dvdcss_seek
--- dvdread/dvd_reader.c	2006-01-26 13:11:07.000000000 +0100
+++ dvdread/dvd_reader.c	2006-01-27 14:27:25.000000000 +0100
@@ -33,18 +33,30 @@
 #include <limits.h>
 #include <dirent.h>
  
-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__bsdi__) || defined(__DARWIN__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__bsdi__) || defined(__DARWIN__) || defined(__DragonFly__)
 #define SYS_BSD 1
 #endif
 
 #if defined(__sun)
 #include <sys/mnttab.h>
+#elif defined(hpux)
+#include </usr/conf/h/mnttab.h>
 #elif defined(SYS_BSD)
 #include <fstab.h>
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__CYGWIN__)
 #include <mntent.h>
 #endif
 
+#ifdef __MINGW32__
+#include <sys/timeb.h>
+static void gettimeofday(struct timeval* t,void* timezone){
+    struct timeb timebuffer;
+    ftime( &timebuffer );
+    t->tv_sec=timebuffer.time;
+    t->tv_usec=1000*timebuffer.millitm;
+}
+#endif
+
 #include "dvd_reader.h"
 #include "dvd_input.h"
 #include "dvd_udf.h"
@@ -52,7 +64,7 @@
 
 #include "dvdread_internal.h"
 
-#define DEFAULT_UDF_CACHE_LEVEL 1
+#define DEFAULT_UDF_CACHE_LEVEL 0
 
 struct dvd_reader_s {
   /* Basic information. */
@@ -403,6 +415,11 @@
    BSD/OS  /dev/sr0c (if not mounted) or /dev/rsr0c ('c' any letter will do) */
 static char *bsd_block2char( const char *path )
 {
+#if defined(__FreeBSD__)
+{
+    return (char *) strdup( path );
+}
+#else
   char *new_path;
 
   /* If it doesn't start with "/dev/" or does start with "/dev/r" exit */ 
@@ -416,6 +433,7 @@
 
   return new_path;
 }
+#endif /* __FreeBSD__ */
 #endif
 
 
@@ -481,7 +499,7 @@
     char *path_copy;
 #if defined(SYS_BSD)
     struct fstab* fe;
-#elif defined(__sun) || defined(__linux__)
+#elif defined(__sun) || defined(__linux__) || defined(__CYGWIN__)
     FILE *mntfile;
 #endif
 
@@ -585,7 +603,7 @@
       }
       fclose( mntfile );
     }
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__CYGWIN__)
     mntfile = fopen( MOUNTED, "r" );
     if( mntfile ) {
       struct mntent *me;
@@ -610,6 +628,9 @@
       }
       fclose( mntfile );
     }
+#elif defined(__MINGW32__)	
+	dev_name = strdup(path);
+	auth_drive = DVDOpenImageFile( path, have_css );
 #endif
     if( !dev_name ) {
       if(verbose >= 1) {
@@ -828,8 +849,8 @@
   }
     
   if( dvd->css_state == 1 /* Need key init */ ) {
-    initAllCSSKeys( dvd );
-    dvd->css_state = 2;
+//    initAllCSSKeys( dvd );
+//    dvd->css_state = 2;
   }
   /*    
         if( dvdinput_title( dvd_file->dvd->dev, (int)start ) < 0 ) {
@@ -1191,12 +1212,7 @@
   return offset;
 }
 
-#ifndef HAVE_UINTPTR_T
-#warning "Assuming that (unsigned long) can hold (void *)"
-typedef unsigned long uintptr_t;
-#endif
-
-#define DVD_ALIGN(ptr) (void *)((((uintptr_t)(ptr)) + (DVD_VIDEO_LB_LEN-1)) \
+#define DVD_ALIGN(ptr) (void *)((((unsigned long)(ptr)) + (DVD_VIDEO_LB_LEN-1)) \
                                 / DVD_VIDEO_LB_LEN * DVD_VIDEO_LB_LEN)
 
 ssize_t DVDReadBytes( dvd_file_t *dvd_file, void *data, size_t byte_size )
--- dvdread/dvd_udf.c	2006-01-26 13:11:07.000000000 +0100
+++ dvdread/dvd_udf.c	2006-01-27 14:27:41.000000000 +0100
@@ -54,12 +54,7 @@
 #define EMEDIUMTYPE ENOENT
 #endif
 
-#ifndef HAVE_UINTPTR_T
-#warning "Assuming that (unsigned long) can hold (void *)"
-typedef unsigned long uintptr_t;
-#endif
-
-#define DVD_ALIGN(ptr) (void *)((((uintptr_t)(ptr)) + (DVD_VIDEO_LB_LEN-1)) \
+#define DVD_ALIGN(ptr) (void *)((((unsigned long)(ptr)) + (DVD_VIDEO_LB_LEN-1)) \
                                 / DVD_VIDEO_LB_LEN * DVD_VIDEO_LB_LEN)
 
 typedef struct {
--- dvdread/dvdread_internal.h	2006-01-26 13:11:07.000000000 +0100
+++ dvdread/dvdread_internal.h	2006-01-26 13:04:28.000000000 +0100
@@ -3,12 +3,7 @@
 #define DVDREAD_INTERNAL_H
 
 
-#define CHECK_VALUE(arg)                                                \
-  if(!(arg)) {                                                          \
-    fprintf(stderr, "\n*** libdvdread: CHECK_VALUE failed in %s:%i ***" \
-            "\n*** for %s ***\n\n",                                     \
-            __FILE__, __LINE__, # arg );                                \
-  }
+#define CHECK_VALUE(arg)
 
 
 int get_verbose(void);
--- dvdread/ifo_print.c	2006-01-26 13:11:16.000000000 +0100
+++ dvdread/ifo_print.c	2006-01-27 14:16:06.000000000 +0100
@@ -793,14 +793,14 @@
   ifoPrint_USER_OPS(&pgc->prohibited_ops);
   
   for(i = 0; i < 8; i++) {
-    if(pgc->audio_control[i] & 0x8000) { /* The 'is present' bit */
+    if(pgc->audio_control[i].present) {
       printf("Audio stream %i control: %04x\n", 
              i, pgc->audio_control[i]);
     }
   }
   
   for(i = 0; i < 32; i++) {
-    if(pgc->subp_control[i] & 0x80000000) { /* The 'is present' bit */
+    if(pgc->subp_control[i].present) {
       printf("Subpicture stream %2i control: %08x\n", 
              i, pgc->subp_control[i]);
     }
--- dvdread/ifo_print.h	2006-01-26 13:11:16.000000000 +0100
+++ dvdread/ifo_print.h	2006-01-26 13:04:36.000000000 +0100
@@ -21,8 +21,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" {
--- dvdread/ifo_read.c	2006-01-26 13:11:16.000000000 +0100
+++ dvdread/ifo_read.c	2006-01-26 13:04:36.000000000 +0100
@@ -751,10 +751,6 @@
   B2N_16(pgc->cell_playback_offset);
   B2N_16(pgc->cell_position_offset);
 
-  for(i = 0; i < 8; i++)
-    B2N_16(pgc->audio_control[i]);
-  for(i = 0; i < 32; i++)
-    B2N_32(pgc->subp_control[i]);
   for(i = 0; i < 16; i++)
     B2N_32(pgc->palette[i]);
   
@@ -763,10 +759,10 @@
 
   /* verify time (look at print_time) */
   for(i = 0; i < 8; i++)
-    if(!pgc->audio_control[i] & 0x8000) /* The 'is present' bit */
+    if(!pgc->audio_control[i].present)
       CHECK_ZERO(pgc->audio_control[i]);
   for(i = 0; i < 32; i++)
-    if(!pgc->subp_control[i] & 0x80000000) /* The 'is present' bit */
+    if(!pgc->subp_control[i].present)
       CHECK_ZERO(pgc->subp_control[i]);
   
   /* Check that time is 0:0:0:0 also if nr_of_programs == 0 */
--- dvdread/ifo_read.h	2006-01-26 13:11:16.000000000 +0100
+++ dvdread/ifo_read.h	2006-01-26 13:04:36.000000000 +0100
@@ -21,8 +21,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" {
--- dvdread/ifo_types.h	2006-01-26 13:11:16.000000000 +0100
+++ dvdread/ifo_types.h	2006-01-26 13:04:36.000000000 +0100
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include <dvdread/dvd_reader.h>
+#include "dvd_reader.h"
 
 #if defined(__BEOS__)
 #if !defined(_INTTYPES_H_) && !defined(_INTTYPES_H) && !defined(_STDINT_H_) && !defined(_STDINT_H)
@@ -403,6 +403,55 @@
 } ATTRIBUTE_PACKED user_ops_t;
 
 /**
+ * Subpicture stream mapping for a subtitle
+ */
+typedef struct {
+#ifdef WORDS_BIGENDIAN
+  unsigned int present   : 1;
+  unsigned int zero1     : 2;
+  unsigned int s_4p3     : 5; /* stream for 4:3 on any display */
+
+  unsigned int zero2     : 3;
+  unsigned int s_wide    : 5; /* stream for 16:9 on widescreen display */
+
+  unsigned int zero3     : 3;
+  unsigned int s_lbox    : 5; /* stream for 16:9 on letterboxed 4:3 display */
+
+  unsigned int zero4     : 3;
+  unsigned int s_panscan : 5; /* stream for 16:9 with pan&scan data on 4:3 display */
+#else
+  unsigned int s_4p3     : 5; /* stream for 4:3 on any display */
+  unsigned int zero1     : 2;
+  unsigned int present   : 1;
+
+  unsigned int s_wide    : 5; /* stream for 16:9 on widescreen display */
+  unsigned int zero2     : 3;
+
+  unsigned int s_lbox    : 5; /* stream for 16:9 on letterboxed 4:3 display */
+  unsigned int zero3     : 3;
+
+  unsigned int s_panscan : 5; /* stream for 16:9 with pan&scan data on 4:3 display */
+  unsigned int zero4     : 3;
+#endif
+} ATTRIBUTE_PACKED subp_mapping_t;
+
+/**
+ * Audio stream mapping for a soundtrack
+ */
+typedef struct {
+#ifdef WORDS_BIGENDIAN
+  unsigned int present : 1;
+  unsigned int zero1   : 4;
+  unsigned int s_audio : 3;
+#else
+  unsigned int s_audio : 3;
+  unsigned int zero1   : 4;
+  unsigned int present : 1;
+#endif
+  uint8_t zero2;
+} ATTRIBUTE_PACKED audio_mapping_t;
+
+/**
  * Program Chain Information.
  */
 typedef struct {
@@ -411,8 +460,8 @@
   uint8_t  nr_of_cells;
   dvd_time_t playback_time;
   user_ops_t prohibited_ops;
-  uint16_t audio_control[8]; /* New type? */
-  uint32_t subp_control[32]; /* New type? */
+  audio_mapping_t audio_control[8]; /* New type? */
+  subp_mapping_t subp_control[32]; /* New type? */
   uint16_t next_pgc_nr;
   uint16_t prev_pgc_nr;
   uint16_t goup_pgc_nr;
--- dvdread/nav_print.h	2006-01-26 13:11:11.000000000 +0100
+++ dvdread/nav_print.h	2006-01-26 13:04:39.000000000 +0100
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include <dvdread/nav_types.h>
+#include "nav_types.h"
 
 /**
  * Pretty printing of the NAV packets, PCI and DSI structs.
--- dvdread/nav_read.h	2006-01-26 13:11:11.000000000 +0100
+++ dvdread/nav_read.h	2006-01-26 13:09:55.000000000 +0100
@@ -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"
 
 /**
  * Parsing of NAV data, PCI and DSI parts.
--- dvdread/nav_types.h	2006-01-26 13:11:11.000000000 +0100
+++ dvdread/nav_types.h	2006-01-26 13:04:39.000000000 +0100
@@ -30,7 +30,7 @@
  * USA
  */
 
-#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 */
 /* If it's ever removed add a uintX_t test. */
 
 #undef ATTRIBUTE_PACKED



More information about the MPlayer-dev-eng mailing list