]> git.sesse.net Git - vlc/blob - extras/contrib/src/Patches/dvdnav.patch
* fix ffmpeg compilation by reverting their revision 11100
[vlc] / extras / contrib / src / Patches / dvdnav.patch
1 diff -ur libdvdnav/Makefile.am libdvdnav.new/Makefile.am
2 --- libdvdnav/Makefile.am       2004-10-26 18:26:07.000000000 +0100
3 +++ libdvdnav.new/Makefile.am   2005-11-28 16:19:13.343750000 +0000
4 @@ -2,7 +2,7 @@
5  
6  AUTOMAKE_OPTIONS = 1.3
7  
8 -SUBDIRS = src examples doc misc m4
9 +SUBDIRS = src misc m4
10  
11  EXTRA_DIST = autogen.sh \
12              AUTHORS \
13 diff -ur libdvdnav/src/dvdnav.c libdvdnav.new/src/dvdnav.c
14 --- libdvdnav/src/dvdnav.c      2005-02-11 12:33:19.000000000 +0000
15 +++ libdvdnav.new/src/dvdnav.c  2005-11-28 16:19:13.328125000 +0000
16 @@ -31,7 +31,6 @@
17  
18  #include "dvdnav_internal.h"
19  #include "read_cache.h"
20 -#include "nav_read.h"
21  
22  #include <stdlib.h>
23  #include <stdio.h>
24 diff -ur libdvdnav/src/dvdnav.h libdvdnav.new/src/dvdnav.h
25 --- libdvdnav/src/dvdnav.h      2005-02-11 12:33:19.000000000 +0000
26 +++ libdvdnav.new/src/dvdnav.h  2005-11-28 16:19:13.328125000 +0000
27 @@ -33,16 +33,19 @@
28  extern "C" {
29  #endif
30  
31 +#include <inttypes.h>
32 +
33 +#include <dvdread/dvd_reader.h>
34 +#include <dvdread/nav_types.h>
35 +#include <dvdread/nav_read.h>
36 +#include <dvdread/ifo_types.h> /* For vm_cmd_t */
37 +
38  #ifdef DVDNAV_COMPILE
39  #  include "dvdnav_events.h"
40  #  include "dvd_types.h"
41 -#  include "dvd_reader.h"
42 -#  include "ifo_types.h" /* For vm_cmd_t */
43  #else
44  #  include <dvdnav/dvdnav_events.h>
45  #  include <dvdnav/dvd_types.h>
46 -#  include <dvdnav/dvd_reader.h>
47 -#  include <dvdnav/ifo_types.h> /* For vm_cmd_t */
48  #endif
49  
50  
51 diff -ur libdvdnav/src/dvdnav_events.h libdvdnav.new/src/dvdnav_events.h
52 --- libdvdnav/src/dvdnav_events.h       2005-02-11 12:33:19.000000000 +0000
53 +++ libdvdnav.new/src/dvdnav_events.h   2005-11-28 16:19:13.328125000 +0000
54 @@ -28,10 +28,6 @@
55  #ifndef DVDNAV_EVENTS_H_INCLUDED
56  #define DVDNAV_EVENTS_H_INCLUDED
57  
58 -#include "ifo_types.h"
59 -#include "dvd_reader.h"
60 -#include "nav_types.h"
61 -
62  
63  /*
64   * DVDNAV_BLOCK_OK
65 diff -ur libdvdnav/src/dvdread/Makefile.am libdvdnav.new/src/dvdread/Makefile.am
66 --- libdvdnav/src/dvdread/Makefile.am   2004-05-19 19:31:11.000000000 +0100
67 +++ libdvdnav.new/src/dvdread/Makefile.am       2005-12-01 22:26:05.078125000 +0000
68 @@ -1,10 +1,10 @@
69  include $(top_srcdir)/misc/Makefile.common
70  
71 -includedir = ${prefix}/include/dvdnav
72 +includedir = ${prefix}/include/dvdread
73  
74  AM_CPPFLAGS = -DDVDNAV_COMPILE -I$(top_srcdir)/src/vm
75  
76 -noinst_LTLIBRARIES = libdvdread.la
77 +lib_LTLIBRARIES = libdvdread.la
78  
79  libdvdread_la_SOURCES = dvd_reader.c nav_read.c ifo_read.c \
80         dvd_input.c dvd_udf.c md5.c nav_print.c ifo_print.c \
81 diff -ur libdvdnav/src/dvdread/bswap.h libdvdnav.new/src/dvdread/bswap.h
82 --- libdvdnav/src/dvdread/bswap.h       2004-01-11 21:43:13.000000000 +0000
83 +++ libdvdnav.new/src/dvdread/bswap.h   2005-12-01 21:55:20.328125000 +0000
84 @@ -65,7 +65,7 @@
85   * functionality! 
86   */
87  
88 -#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) || defined(WIN32) || defined(__CYGWIN__)
89 +#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) || defined(WIN32) || defined(__CYGWIN__) || defined(__BEOS__)
90  #define B2N_16(x) \
91   x = ((((x) & 0xff00) >> 8) | \
92        (((x) & 0x00ff) << 8))
93 @@ -75,14 +75,14 @@
94        (((x) & 0x0000ff00) <<  8) | \
95        (((x) & 0x000000ff) << 24))
96  #define B2N_64(x) \
97 - x = ((((x) & 0xff00000000000000) >> 56) | \
98 -      (((x) & 0x00ff000000000000) >> 40) | \
99 -      (((x) & 0x0000ff0000000000) >> 24) | \
100 -      (((x) & 0x000000ff00000000) >>  8) | \
101 -      (((x) & 0x00000000ff000000) <<  8) | \
102 -      (((x) & 0x0000000000ff0000) << 24) | \
103 -      (((x) & 0x000000000000ff00) << 40) | \
104 -      (((x) & 0x00000000000000ff) << 56))
105 + x = ((((x) & 0xff00000000000000LL) >> 56) | \
106 +      (((x) & 0x00ff000000000000LL) >> 40) | \
107 +      (((x) & 0x0000ff0000000000LL) >> 24) | \
108 +      (((x) & 0x000000ff00000000LL) >>  8) | \
109 +      (((x) & 0x00000000ff000000LL) <<  8) | \
110 +      (((x) & 0x0000000000ff0000LL) << 24) | \
111 +      (((x) & 0x000000000000ff00LL) << 40) | \
112 +      (((x) & 0x00000000000000ffLL) << 56))
113  
114  #else
115  
116 diff -ur libdvdnav/src/dvdread/dvd_input.c libdvdnav.new/src/dvdread/dvd_input.c
117 --- libdvdnav/src/dvdread/dvd_input.c   2004-04-09 13:15:26.000000000 +0100
118 +++ libdvdnav.new/src/dvdread/dvd_input.c       2005-11-30 23:07:47.140625000 +0000
119 @@ -21,12 +21,24 @@
120  
121  #include <stdio.h>
122  #include <stdlib.h>
123 +
124 +#if defined(HAVE_INTTYPES_H)
125 +#include <inttypes.h>
126 +#elif defined(HAVE_STDINT_H)
127 +#include <stdint.h>
128 +#endif
129 +
130  #include <fcntl.h>
131  #include <unistd.h>
132  
133  #include "dvd_reader.h"
134  #include "dvd_input.h"
135  
136 +#ifdef WIN32
137 +#   define lseek _lseeki64
138 +#   undef off_t
139 +#   define off_t int64_t
140 +#endif
141  
142  /* The function pointers that is the exported interface of this file. */
143  dvd_input_t (*dvdinput_open)  (const char *);
144 diff -ur libdvdnav/src/dvdread/dvd_reader.c libdvdnav.new/src/dvdread/dvd_reader.c
145 --- libdvdnav/src/dvdread/dvd_reader.c  2004-09-12 16:18:16.000000000 +0100
146 +++ libdvdnav.new/src/dvdread/dvd_reader.c      2005-12-01 22:19:07.750000000 +0000
147 @@ -347,9 +347,7 @@
148         }
149  #endif
150      
151 -    ret = stat( path, &fileinfo );
152 -
153 -    if( ret < 0 ) {
154 +    if( *path && (ret = stat( path, &fileinfo ) < 0) ) {
155  
156          /* maybe "host:port" url? try opening it with acCeSS library */
157          if( strchr(path,':') ) {
158 @@ -366,7 +364,7 @@
159      }
160  
161      /* First check if this is a block/char device or a file*/
162 -    if( S_ISBLK( fileinfo.st_mode ) || 
163 +    if( !*path || S_ISBLK( fileinfo.st_mode ) || 
164         S_ISCHR( fileinfo.st_mode ) || 
165         S_ISREG( fileinfo.st_mode ) ) {
166  
167 @@ -404,14 +402,15 @@
168  
169         /* Resolve any symlinks and get the absolut dir name. */
170         {
171 +               char *current_path;
172             char *new_path;
173 -           int cdir = open( ".", O_RDONLY );
174 -           
175 -           if( cdir >= 0 ) {
176 +          
177 +               current_path = getcwd( NULL, PATH_MAX );
178 +               if( current_path ) {
179                 chdir( path_copy );
180                 new_path = getcwd( NULL, PATH_MAX );
181 -               fchdir( cdir );
182 -               close( cdir );
183 +               chdir( current_path );
184 +               free( current_path );
185                 if( new_path ) {
186                     free( path_copy );
187                     path_copy = new_path;
188 @@ -586,10 +585,12 @@
189              sprintf( filename, "%s%s%s", path,
190                       ( ( path[ strlen( path ) - 1 ] == '/' ) ? "" : "/" ),
191                       ent->d_name );
192 +            closedir( dir );
193              return 0;
194          }
195      }
196  
197 +    closedir( dir );
198      return -1;
199  }
200  
201 diff -ur libdvdnav/src/highlight.c libdvdnav.new/src/highlight.c
202 --- libdvdnav/src/highlight.c   2005-02-11 12:33:19.000000000 +0000
203 +++ libdvdnav.new/src/highlight.c       2005-11-28 16:19:13.343750000 +0000
204 @@ -26,7 +26,6 @@
205  #endif
206  
207  #include <assert.h>
208 -#include "nav_types.h"
209  #include "dvdnav_internal.h"
210  
211  /*
212 diff -ur libdvdnav/src/remap.c libdvdnav.new/src/remap.c
213 --- libdvdnav/src/remap.c       2005-02-11 12:33:19.000000000 +0000
214 +++ libdvdnav.new/src/remap.c   2005-11-28 16:19:13.343750000 +0000
215 @@ -189,7 +189,11 @@
216      remap_t *map;
217  
218      /* Build the map filename */
219 -    home = getenv("HOME"); assert(home);
220 +    home = getenv("HOME");
221 +    if (!home) {
222 +       fprintf(MSG_OUT, "libdvdnav: Unable to find map for title '%s'\n", title);
223 +       return NULL;
224 +    }
225      strncpy(fname, home, sizeof(fname));
226      strncat(fname, "/.dvdnav/", sizeof(fname));
227      strncat(fname, title, sizeof(fname));
228 diff -ur libdvdnav/src/vm/decoder.c libdvdnav.new/src/vm/decoder.c
229 --- libdvdnav/src/vm/decoder.c  2005-02-11 12:33:19.000000000 +0000
230 +++ libdvdnav.new/src/vm/decoder.c      2005-11-28 16:19:13.343750000 +0000
231 @@ -31,7 +31,6 @@
232  #include <stdlib.h>
233  #include <inttypes.h>
234  #include <string.h>  /* For memset */
235 -#include "ifo_types.h" /* vm_cmd_t */
236  
237  #include "dvdnav_internal.h"
238  
239 diff -ur libdvdnav/src/vm/decoder.h libdvdnav.new/src/vm/decoder.h
240 --- libdvdnav/src/vm/decoder.h  2005-02-11 12:33:19.000000000 +0000
241 +++ libdvdnav.new/src/vm/decoder.h      2005-11-28 16:19:13.343750000 +0000
242 @@ -28,7 +28,7 @@
243  #include <inttypes.h>
244  #include <sys/time.h>
245  
246 -#include "ifo_types.h" /*  vm_cmd_t */
247 +#include <dvdread/ifo_types.h> /*  vm_cmd_t */
248  #include "dvdnav_internal.h"
249  
250  /* link command types */
251 diff -ur libdvdnav/src/vm/vm.c libdvdnav.new/src/vm/vm.c
252 --- libdvdnav/src/vm/vm.c       2005-02-11 12:33:19.000000000 +0000
253 +++ libdvdnav.new/src/vm/vm.c   2005-11-28 16:19:13.343750000 +0000
254 @@ -38,13 +38,17 @@
255  #include <sys/stat.h>
256  #include <fcntl.h>
257  
258 -#include "ifo_types.h"
259 -#include "ifo_read.h"
260 +/* from dvdread */
261 +#include <dvdread/ifo_types.h>
262 +#include <dvdread/ifo_read.h>
263  
264  #include "dvdnav_internal.h"
265  
266  #ifdef _MSC_VER
267  #include <io.h>   /* read() */
268 +#elif defined(WIN32)
269 +#   define lseek _lseeki64
270 +#   define off_t int64_t
271  #endif /* _MSC_VER */
272  
273  /*
274 @@ -126,24 +130,25 @@
275  }
276  #endif
277  
278 +#include <dvdread/dvd_input.h>
279 +
280  static void dvd_read_name(char *name, const char *device) {
281      /* Because we are compiling with _FILE_OFFSET_BITS=64
282       * all off_t are 64bit.
283       */
284      off_t off;
285 -    int fd, i;
286 +    dvd_input_t fd; int i;
287      uint8_t data[DVD_VIDEO_LB_LEN];
288  
289      /* Read DVD name */
290 -    fd = open(device, O_RDONLY);
291 +    fd = dvdinput_open(device);
292      if (fd > 0) { 
293 -      off = lseek( fd, 32 * (off_t) DVD_VIDEO_LB_LEN, SEEK_SET );
294 -      if( off == ( 32 * (off_t) DVD_VIDEO_LB_LEN ) ) {
295 -        off = read( fd, data, DVD_VIDEO_LB_LEN ); 
296 -        close(fd);
297 -        if (off == ( (off_t) DVD_VIDEO_LB_LEN )) {
298 +      off = dvdinput_seek( fd, 16 );
299 +      if( off == 16 ) {
300 +        off = dvdinput_read( fd, data, 1, DVDINPUT_NOFLAGS ); 
301 +        if (off == 1 ) {
302            fprintf(MSG_OUT, "libdvdnav: DVD Title: ");
303 -          for(i=25; i < 73; i++ ) {
304 +          for(i=40; i < 73; i++ ) {
305              if((data[i] == 0)) break;
306              if((data[i] > 32) && (data[i] < 127)) {
307                fprintf(MSG_OUT, "%c", data[i]);
308 @@ -151,10 +156,12 @@
309                fprintf(MSG_OUT, " ");
310              }
311            }
312 -          strncpy(name, &data[25], 48);
313 -          name[48] = 0;
314 +          strncpy(name, &data[40], 32);
315 +          i=31;
316 +          while( (i >= 0) && (name[i] <= ' ')) --i;
317 +          name[i+1] = '\0';
318            fprintf(MSG_OUT, "\nlibdvdnav: DVD Serial Number: ");
319 -          for(i=73; i < 89; i++ ) {
320 +          for(i=813; i < 829; i++ ) {
321              if((data[i] == 0)) break;
322              if((data[i] > 32) && (data[i] < 127)) {
323                fprintf(MSG_OUT, "%c", data[i]);
324 @@ -178,7 +185,7 @@
325        } else {
326          fprintf(MSG_OUT, "libdvdnav: Can't seek to block %u\n", 32 );
327        }
328 -      close(fd);
329 +      dvdinput_close(fd);
330      } else {
331      fprintf(MSG_OUT, "NAME OPEN FAILED\n");
332    }
333 --- libdvdnav/misc/dvdnav-config.in     2003-04-27 02:26:17.000000000 +0100
334 +++ libdvdnav.new/misc/dvdnav-config.in 2005-12-02 09:29:48.265625000 +0000
335 @@ -76,5 +76,5 @@
336  fi
337  
338  if test "$echo_libs" = "yes"; then
339 -      echo -L@libdir@ -ldvdnav @THREAD_LIBS@
340 +      echo -L@libdir@ -ldvdnav -ldvdread @THREAD_LIBS@
341  fi      
342 --- libdvdnav/configure.ac      2005-02-11 12:33:19.000000000 +0000
343 +++ libdvdnav.new/configure.ac  2005-12-02 15:23:13.921875000 +0000
344 @@ -128,7 +128,10 @@
345  AC_TYPE_SIZE_T
346  dnl AC_CHECK_TYPES([ptrdiff_t])
347  AC_C_BIGENDIAN
348 -
349 +dnl ---------------------------------------------
350 +dnl Check for basic *nix fonction that we may emulate on other OS
351 +dnl ---------------------------------------------
352 +AC_CHECK_FUNCS(gettimeofday)
353  dnl ---------------------------------------------
354  dnl threads
355  dnl ---------------------------------------------
356 @@ -138,7 +138,7 @@
357      THREAD_CFLAGS="-I/usr/local/include -D_THREAD_SAFE"
358      CFLAGS="$THREAD_CFLAGS $CFLAGS"
359      ;;
360 -  *mingw32* | *cygwin*)
361 +  *mingw32* | *cygwin* | *beos*)
362      ;;
363    *)
364      AC_CHECK_LIB(pthread, pthread_create,
365 @@ -149,26 +149,63 @@
366  AC_SUBST(THREAD_LIBS)
367  AC_SUBST(THREAD_CFLAGS)
368  
369 +link_dvdcss=no
370 +dvdcss_path=""
371  dnl ---------------------------------------------
372 -dnl dynamic linker
373 +dnl dvdcss checking
374  dnl ---------------------------------------------
375 -case $host in
376 -  *mingw32*)
377 -    CFLAGS="-idirafter \$(top_srcdir)/msvc/include $CFLAGS"
378 -    LDFLAGS="-no-undefined $LDFLAGS"
379 -    ;;
380 -  *cygwin*)
381 -    LDFLAGS="-no-undefined $LDFLAGS"
382 -    ;;
383 -  *)
384 -    AC_CHECK_LIB(c, dlopen,
385 -                DYNAMIC_LD_LIBS="",
386 -                AC_CHECK_LIB(dl, dlopen,
387 -                             DYNAMIC_LD_LIBS="-ldl",
388 -                             AC_MSG_ERROR(dynamic linker needed)))
389 -    AC_SUBST(DYNAMIC_LD_LIBS)
390 -    ;;
391 -esac
392 +AC_ARG_WITH( [libdvdcss],
393 +    [ --with-libdvdcss[=PATH]    force linking against libdvdcss],
394 +    [if test x"$withval" != xno; then
395 +       link_dvdcss=yes
396 +     fi
397 +     if test x"$withval" != xyes; then
398 +       dvdcss_path=$withval
399 +     fi])
400 +
401 +if test x"$link_dvdcss" != xyes; then
402 +dnl dlopen libdvdcss
403 +  AC_CHECK_FUNC( dlopen,
404 +    [DL_LIBS="" ],
405 +    AC_CHECK_LIB( dl, dlopen,
406 +      [DL_LIBS=-ld ],
407 +      AC_MSG_ERROR(You need libdl (dlopen))
408 +    )
409 +  )
410 +else
411 +dnl link with libdvdcss
412 +  if test -z "$dvdcss_path"; then
413 +    AC_CHECK_LIB(dvdcss, dvdcss_interface_2,
414 +      [ CSS_LIBS=-ldvdcss ],
415 +      AC_MSG_ERROR(You need libdvdcss.so.2 or later)
416 +    )
417 +    AC_CHECK_HEADERS(dvdcss/dvdcss.h,
418 +      [ ],
419 +      AC_MSG_ERROR(You need libdvdcss (dvdcss.h))
420 +    )
421 +  else
422 +    saved_CFLAGS=$CFLAGS
423 +    CFLAGS="$CFLAGS -L$dvdcss_path/lib"
424 +    AC_CHECK_LIB(dvdcss, dvdcss_interface_2,
425 +      [ CSS_LIBS="-L$dvdcss_path/lib -R$dvdcss_path/lib -ldvdcss"
426 +        CSS_CFLAGS=-I$dvdcss_path/include ],
427 +      AC_MSG_ERROR(You need libdvdcss.so.2 or later)
428 +    )
429 +    CFLAGS=$saved_CFLAGS
430 +    dnl -w added to shutup GCC3.1's cpp warning about -I/usr/local
431 +    saved_CPPFLAGS=$CPPFLAGS
432 +    CPPFLAGS="-w $CPPFLAGS -I$dvdcss_path/include"
433 +    AC_CHECK_HEADERS(dvdcss/dvdcss.h,
434 +      [ ],
435 +      AC_MSG_ERROR(You need libdvdcss (dvdcss.h))
436 +    )
437 +    CPPFLAGS=$saved_CPPFLAGS
438 +  fi
439 +fi
440 +
441 +AC_SUBST(DL_LIBS)
442 +AC_SUBST(CSS_LIBS)
443 +AC_SUBST(CSS_CFLAGS)
444  
445  dnl ---------------------------------------------
446  dnl cflags
447 --- libdvdnav/src/dvdnav_internal.h     2005-02-11 12:25:11.000000000 +0000
448 +++ libdvdnav.new/src/dvdnav_internal.h 2005-12-02 15:29:35.250000000 +0000
449 @@ -59,6 +59,15 @@
450  #include <io.h> /* read() */
451  #define lseek64 _lseeki64
452  
453 +#elif defined(__BEOS__)
454 +
455 +#include <OS.h>
456 +typedef sem_id pthread_mutex_t;
457 +#define pthread_mutex_init(a, b) (*a) = create_sem( 1,"" )
458 +#define pthread_mutex_lock(a)    acquire_sem( *a )
459 +#define pthread_mutex_unlock(a)  release_sem( *a )
460 +#define pthread_mutex_destroy(a) delete_sem( *a )
461 +
462  #else
463  
464  #include <pthread.h>
465 --- libdvdnav/examples/Makefile.am      2004-01-11 21:43:12.000000000 +0000
466 +++ libdvdnav.new/examples/Makefile.am  2005-12-02 15:24:58.671875000 +0000
467 @@ -7,7 +7,7 @@
468  noinst_PROGRAMS = menus
469  
470  menus_SOURCES = menus.c
471 -menus_LDFLAGS = -L$(top_srcdir)/src/
472 +menus_LDFLAGS = -L$(top_srcdir)/src/ $(CSS_LIBS)
473  menus_LDADD   = $(DVDNAV_LIB)
474  
475  $(DVDNAV_LIB):
476 --- libdvdnav/src/dvdnav_internal.h.orig        2007-02-19 18:41:27.784456800 +0000
477 +++ libdvdnav/src/dvdnav_internal.h     2007-02-19 18:41:50.706478500 +0000
478 @@ -45,6 +45,7 @@
479  #define pthread_mutex_unlock(a)  LeaveCriticalSection(a)
480  #define pthread_mutex_destroy(a)
481  
482 +#ifndef HAVE_GETTIMEOFDAY
483  /* replacement gettimeofday implementation */
484  #include <sys/timeb.h>
485  static inline int _private_gettimeofday( struct timeval *tv, void *tz )
486 @@ -56,6 +57,8 @@
487    return 0;
488  }
489  #define gettimeofday(TV, TZ) _private_gettimeofday((TV), (TZ))
490 +#endif
491 +
492  #include <io.h> /* read() */
493  #define lseek64 _lseeki64
494