QuickTime in24 and in32 PCM audio support
[mplayer/glamo.git] / libmpdvdkit2 / libdvdread_changes.diff
blobe343a217dbf95d157bf8b79bfec1353b02a3d8fd
1 diff -Naur dvdread.orig/bswap.h dvdread/bswap.h
2 --- dvdread.orig/bswap.h 2005-06-23 00:18:54.000000000 +0200
3 +++ dvdread/bswap.h 2005-06-23 00:19:10.000000000 +0200
4 @@ -20,8 +20,6 @@
5 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6 */
8 -#include <config.h>
10 #if defined(WORDS_BIGENDIAN)
11 /* All bigendian systems are fine, just ignore the swaps. */
12 #define B2N_16(x) (void)(x)
13 @@ -59,13 +57,57 @@
14 #define B2N_32(x) x = be32toh(x)
15 #define B2N_64(x) x = be64toh(x)
17 +#elif defined(__DragonFly__)
18 +#include <sys/endian.h>
19 +#define B2N_16(x) x = be16toh(x)
20 +#define B2N_32(x) x = be32toh(x)
21 +#define B2N_64(x) x = be64toh(x)
23 +#elif defined(ARCH_X86)
24 +inline static unsigned short bswap_16(unsigned short x)
26 + __asm("xchgb %b0,%h0" :
27 + "=q" (x) :
28 + "0" (x));
29 + return x;
31 +#define B2N_16(x) x = bswap_16(x)
33 +inline static unsigned int bswap_32(unsigned int x)
35 + __asm(
36 +#if __CPU__ > 386
37 + "bswap %0":
38 + "=r" (x) :
39 +#else
40 + "xchgb %b0,%h0\n"
41 + " rorl $16,%0\n"
42 + " xchgb %b0,%h0":
43 + "=q" (x) :
44 +#endif
45 + "0" (x));
46 + return x;
48 +#define B2N_32(x) x = bswap_32(x)
50 +inline static unsigned long long int bswap_64(unsigned long long int x)
52 + register union { __extension__ uint64_t __ll;
53 + uint32_t __l[2]; } __x;
54 + asm("xchgl %0,%1":
55 + "=r"(__x.__l[0]),"=r"(__x.__l[1]):
56 + "0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32))));
57 + return __x.__ll;
59 +#define B2N_64(x) x = bswap_64(x)
61 /* This is a slow but portable implementation, it has multiple evaluation
62 * problems so beware.
63 * Old FreeBSD's and Solaris don't have <byteswap.h> or any other such
64 * functionality!
67 -#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__)
68 +#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) || defined(__CYGWIN__)
69 #define B2N_16(x) \
70 x = ((((x) & 0xff00) >> 8) | \
71 (((x) & 0x00ff) << 8))
72 diff -Naur dvdread.orig/.cvsignore dvdread/.cvsignore
73 diff -Naur dvdread.orig/dvd_input.c dvdread/dvd_input.c
74 --- dvdread.orig/dvd_input.c 2005-06-23 00:18:54.000000000 +0200
75 +++ dvdread/dvd_input.c 2005-06-23 00:30:23.000000000 +0200
76 @@ -37,7 +37,7 @@
78 #ifdef HAVE_DVDCSS_DVDCSS_H
79 /* linking to libdvdcss */
80 -#include <dvdcss/dvdcss.h>
81 +#include "dvdcss.h"
82 #define DVDcss_open(a) dvdcss_open((char*)(a))
83 #define DVDcss_close dvdcss_close
84 #define DVDcss_seek dvdcss_seek
85 @@ -74,7 +74,7 @@
86 dvd_input_t dev;
88 /* Allocate the handle structure */
89 - dev = (dvd_input_t) malloc(sizeof(dvd_input_t));
90 + dev = (dvd_input_t) malloc(sizeof(struct dvd_input_s));
91 if(dev == NULL) {
92 fprintf(stderr, "libdvdread: Could not allocate memory.\n");
93 return NULL;
94 @@ -158,7 +158,7 @@
95 dvd_input_t dev;
97 /* Allocate the library structure */
98 - dev = (dvd_input_t) malloc(sizeof(dvd_input_t));
99 + dev = (dvd_input_t) malloc(sizeof(struct dvd_input_s));
100 if(dev == NULL) {
101 fprintf(stderr, "libdvdread: Could not allocate memory.\n");
102 return NULL;
103 @@ -320,8 +320,10 @@
104 fprintf(stderr, "DVDCSS_METHOD %s\n", psz_method);
105 fprintf(stderr, "DVDCSS_VERBOSE %s\n", psz_verbose);
107 + /*
108 fprintf(stderr, "libdvdread: Using libdvdcss version %s for DVD access\n",
109 *dvdcss_version);
110 + */
112 /* libdvdcss wrapper functions */
113 dvdinput_open = css_open;
114 diff -Naur dvdread.orig/dvd_input.h dvdread/dvd_input.h
115 diff -Naur dvdread.orig/dvd_reader.c dvdread/dvd_reader.c
116 --- dvdread.orig/dvd_reader.c 2005-06-23 00:18:54.000000000 +0200
117 +++ dvdread/dvd_reader.c 2005-06-23 00:19:10.000000000 +0200
118 @@ -32,24 +32,36 @@
119 #include <limits.h>
120 #include <dirent.h>
122 -#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__bsdi__)|| defined(__DARWIN__)
123 +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__bsdi__) || defined(__DARWIN__) || defined(__DragonFly__)
124 #define SYS_BSD 1
125 #endif
127 #if defined(__sun)
128 #include <sys/mnttab.h>
129 +#elif defined(hpux)
130 +#include </usr/conf/h/mnttab.h>
131 #elif defined(SYS_BSD)
132 #include <fstab.h>
133 -#elif defined(__linux__)
134 +#elif defined(__linux__) || defined(__CYGWIN__)
135 #include <mntent.h>
136 #endif
138 +#ifdef __MINGW32__
139 +#include <sys/timeb.h>
140 +static void gettimeofday(struct timeval* t,void* timezone){
141 + struct timeb timebuffer;
142 + ftime( &timebuffer );
143 + t->tv_sec=timebuffer.time;
144 + t->tv_usec=1000*timebuffer.millitm;
146 +#endif
148 #include "dvd_udf.h"
149 #include "dvd_input.h"
150 #include "dvd_reader.h"
151 #include "md5.h"
153 -#define DEFAULT_UDF_CACHE_LEVEL 1
154 +#define DEFAULT_UDF_CACHE_LEVEL 0
156 struct dvd_reader_s {
157 /* Basic information. */
158 @@ -194,6 +206,13 @@
162 +#ifndef HAVE_MPLAYER
163 + #include "get_path.c"
164 +#else
165 + extern char * get_path( char * filename );
166 +#endif
168 +//extern char * dvdcss_cache_dir;
171 * Open a DVD image or block device file.
172 @@ -278,11 +297,16 @@
173 Darwin /dev/rdisk0, it needs to be the raw device
174 BSD/OS /dev/sr0c (if not mounted) or /dev/rsr0c ('c' any letter will do) */
175 static char *bsd_block2char( const char *path )
176 +#if defined(__FreeBSD__)
178 + return (char *) strdup( path );
180 +#else
182 char *new_path;
184 /* If it doesn't start with "/dev/" or does start with "/dev/r" exit */
185 - if( !strncmp( path, "/dev/", 5 ) || strncmp( path, "/dev/r", 6 ) )
186 + if( strncmp( path, "/dev/", 5 ) || !strncmp( path, "/dev/r", 6 ) )
187 return (char *) strdup( path );
189 /* Replace "/dev/" with "/dev/r" */
190 @@ -292,6 +316,7 @@
192 return new_path;
194 +#endif /* __FreeBSD__ */
195 #endif
197 dvd_reader_t *DVDOpen( const char *path )
198 @@ -303,6 +328,16 @@
199 if( path == NULL )
200 return 0;
202 +#ifdef WIN32
203 + /* Stat doesn't work on devices under mingwin/cygwin. */
204 + if( path[0] && path[1] == ':' && path[2] == '\0' )
206 + /* Don't try to stat the file */
207 + fileinfo.st_mode = S_IFBLK;
209 + else
210 +#endif
212 ret = stat( path, &fileinfo );
213 if( ret < 0 ) {
214 /* If we can't stat the file, give up */
215 @@ -310,6 +345,7 @@
216 perror("");
217 return 0;
221 /* Try to open libdvdcss or fall back to standard functions */
222 have_css = dvdinput_setup();
223 @@ -335,7 +371,7 @@
224 char *path_copy;
225 #if defined(SYS_BSD)
226 struct fstab* fe;
227 -#elif defined(__sun) || defined(__linux__)
228 +#elif defined(__sun) || defined(__linux__) || defined(__CYGWIN__)
229 FILE *mntfile;
230 #endif
232 @@ -350,7 +386,9 @@
233 if( cdir >= 0 ) {
234 chdir( path_copy );
235 new_path = getcwd( NULL, PATH_MAX );
236 +#ifndef __MINGW32__
237 fchdir( cdir );
238 +#endif
239 close( cdir );
240 if( new_path ) {
241 free( path_copy );
242 @@ -406,7 +444,7 @@
244 fclose( mntfile );
246 -#elif defined(__linux__)
247 +#elif defined(__linux__) || defined(__CYGWIN__)
248 mntfile = fopen( MOUNTED, "r" );
249 if( mntfile ) {
250 struct mntent *me;
251 @@ -425,6 +463,9 @@
253 fclose( mntfile );
255 +#elif defined(__MINGW32__)
256 + dev_name = strdup(path);
257 + auth_drive = DVDOpenImageFile( path, have_css );
258 #endif
259 if( !dev_name ) {
260 fprintf( stderr, "libdvdread: Couldn't find device name.\n" );
261 @@ -615,8 +656,8 @@
264 if( dvd->css_state == 1 /* Need key init */ ) {
265 - initAllCSSKeys( dvd );
266 - dvd->css_state = 2;
267 +// initAllCSSKeys( dvd );
268 +// dvd->css_state = 2;
271 if( dvdinput_title( dvd_file->dvd->dev, (int)start ) < 0 ) {
272 @@ -915,7 +956,7 @@
273 return (ssize_t)ret;
276 -int32_t DVDFileSeek( dvd_file_t *dvd_file, int32_t offset )
277 +int DVDFileSeek( dvd_file_t *dvd_file, int offset )
279 /* Check arguments. */
280 if( dvd_file == NULL || offset < 0 )
281 diff -Naur dvdread.orig/dvdread_internal.h dvdread/dvdread_internal.h
282 --- dvdread.orig/dvdread_internal.h 2005-06-23 00:18:54.000000000 +0200
283 +++ dvdread/dvdread_internal.h 2005-06-23 00:19:10.000000000 +0200
284 @@ -2,11 +2,7 @@
285 #define DVDREAD_INTERNAL_H
288 -#define CHECK_VALUE(arg) \
289 - if(!(arg)) { \
290 - fprintf(stderr, "\n*** libdvdread: CHECK_VALUE failed in %s:%i ***" \
291 - "\n*** for %s ***\n\n", \
292 - __FILE__, __LINE__, # arg ); \
294 +#define CHECK_VALUE(arg)
297 #endif /* DVDREAD_INTERNAL_H */
298 diff -Naur dvdread.orig/dvd_udf.c dvdread/dvd_udf.c
299 --- dvdread.orig/dvd_udf.c 2005-06-23 00:18:54.000000000 +0200
300 +++ dvdread/dvd_udf.c 2005-06-23 00:19:10.000000000 +0200
301 @@ -33,7 +33,9 @@
302 #include <stdio.h>
303 #include <stdlib.h>
304 #include <string.h>
305 +#ifndef __MINGW32__
306 #include <sys/ioctl.h>
307 +#endif
308 #include <sys/types.h>
309 #include <sys/stat.h>
310 #include <unistd.h>
311 diff -Naur dvdread.orig/ifo_print.c dvdread/ifo_print.c
312 --- dvdread.orig/ifo_print.c 30 Jun 2005 22:48:26 -0000 1.4
313 +++ dvdread/ifo_print.c 3 Oct 2005 14:29:01 -0000 1.5
314 @@ -761,14 +761,14 @@
315 ifoPrint_USER_OPS(&pgc->prohibited_ops);
317 for(i = 0; i < 8; i++) {
318 - if(pgc->audio_control[i] & 0x8000) { /* The 'is present' bit */
319 + if(pgc->audio_control[i].present) {
320 printf("Audio stream %i control: %04x\n",
321 i, pgc->audio_control[i]);
325 for(i = 0; i < 32; i++) {
326 - if(pgc->subp_control[i] & 0x80000000) { /* The 'is present' bit */
327 + if(pgc->subp_control[i].present) {
328 printf("Subpicture stream %2i control: %08x\n",
329 i, pgc->subp_control[i]);
332 diff -Naur dvdread.orig/ifo_print.h dvdread/ifo_print.h
333 --- dvdread/ifo_print.h 2002-08-15 22:13:21.000000000 +0200
334 +++ /home/diego/src/mplayer/vanilla/libmpdvdkit2/ifo_print.h 2005-12-29 13:13:21.000000000 +0100
335 @@ -20,8 +20,8 @@
336 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
339 -#include <dvdread/ifo_types.h>
340 -#include <dvdread/dvd_reader.h>
341 +#include "ifo_types.h"
342 +#include "dvd_reader.h"
344 #ifdef __cplusplus
345 extern "C" {
346 diff -Naur dvdread.orig/ifo_read.c dvdread/ifo_read.c
347 --- dvdread.orig/ifo_read.c 30 Jun 2005 22:48:26 -0000 1.4
348 +++ dvdread/ifo_read.c 3 Oct 2005 14:29:01 -0000 1.5
349 @@ -638,10 +638,6 @@
350 B2N_16(pgc->cell_playback_offset);
351 B2N_16(pgc->cell_position_offset);
353 - for(i = 0; i < 8; i++)
354 - B2N_16(pgc->audio_control[i]);
355 - for(i = 0; i < 32; i++)
356 - B2N_32(pgc->subp_control[i]);
357 for(i = 0; i < 16; i++)
358 B2N_32(pgc->palette[i]);
360 @@ -650,10 +646,10 @@
362 /* verify time (look at print_time) */
363 for(i = 0; i < 8; i++)
364 - if(!pgc->audio_control[i] & 0x8000) /* The 'is present' bit */
365 + if(!pgc->audio_control[i].present)
366 CHECK_ZERO(pgc->audio_control[i]);
367 for(i = 0; i < 32; i++)
368 - if(!pgc->subp_control[i] & 0x80000000) /* The 'is present' bit */
369 + if(!pgc->subp_control[i].present)
370 CHECK_ZERO(pgc->subp_control[i]);
372 /* Check that time is 0:0:0:0 also if nr_of_programs == 0 */
374 diff -Naur dvdread.orig/ifo_read.h dvdread/ifo_read.h
375 --- dvdread.orig/ifo_read.h 2005-06-23 00:18:54.000000000 +0200
376 +++ dvdread/ifo_read.h 2005-06-23 00:19:10.000000000 +0200
377 @@ -20,8 +20,8 @@
378 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
381 -#include <dvdread/ifo_types.h>
382 -#include <dvdread/dvd_reader.h>
383 +#include "ifo_types.h"
384 +#include "dvd_reader.h"
386 #ifdef __cplusplus
387 extern "C" {
388 diff -Naur dvdread.orig/ifo_types.h dvdread/ifo_types.h
389 --- dvdread.orig/ifo_types.h 2005-06-23 00:18:54.000000000 +0200
390 +++ dvdread/ifo_types.h 2005-06-23 00:19:10.000000000 +0200
391 @@ -21,7 +21,7 @@
394 #include <inttypes.h>
395 -#include <dvdread/dvd_reader.h>
396 +#include "dvd_reader.h"
399 #undef ATTRIBUTE_PACKED
400 @@ -394,6 +394,55 @@
401 } ATTRIBUTE_PACKED user_ops_t;
404 + * Subpicture stream mapping for a subtitle
405 + */
406 +typedef struct {
407 +#ifdef WORDS_BIGENDIAN
408 + unsigned int present : 1;
409 + unsigned int zero1 : 2;
410 + unsigned int s_4p3 : 5; /* stream for 4:3 on any display */
412 + unsigned int zero2 : 3;
413 + unsigned int s_wide : 5; /* stream for 16:9 on widescreen display */
415 + unsigned int zero3 : 3;
416 + unsigned int s_lbox : 5; /* stream for 16:9 on letterboxed 4:3 display */
418 + unsigned int zero4 : 3;
419 + unsigned int s_panscan : 5; /* stream for 16:9 with pan&scan data on 4:3 display */
420 +#else
421 + unsigned int s_4p3 : 5; /* stream for 4:3 on any display */
422 + unsigned int zero1 : 2;
423 + unsigned int present : 1;
425 + unsigned int s_wide : 5; /* stream for 16:9 on widescreen display */
426 + unsigned int zero2 : 3;
428 + unsigned int s_lbox : 5; /* stream for 16:9 on letterboxed 4:3 display */
429 + unsigned int zero3 : 3;
431 + unsigned int s_panscan : 5; /* stream for 16:9 with pan&scan data on 4:3 display */
432 + unsigned int zero4 : 3;
433 +#endif
434 +} ATTRIBUTE_PACKED subp_mapping_t;
436 +/**
437 + * Audio stream mapping for a soundtrack
438 + */
439 +typedef struct {
440 +#ifdef WORDS_BIGENDIAN
441 + unsigned int present : 1;
442 + unsigned int zero1 : 4;
443 + unsigned int s_audio : 3;
444 +#else
445 + unsigned int s_audio : 3;
446 + unsigned int zero1 : 4;
447 + unsigned int present : 1;
448 +#endif
449 + uint8_t zero2;
450 +} ATTRIBUTE_PACKED audio_mapping_t;
452 +/**
453 * Program Chain Information.
455 typedef struct {
456 @@ -402,8 +451,8 @@
457 uint8_t nr_of_cells;
458 dvd_time_t playback_time;
459 user_ops_t prohibited_ops;
460 - uint16_t audio_control[8]; /* New type? */
461 - uint32_t subp_control[32]; /* New type? */
462 + audio_mapping_t audio_control[8];
463 + subp_mapping_t subp_control[32];
464 uint16_t next_pgc_nr;
465 uint16_t prev_pgc_nr;
466 uint16_t goup_pgc_nr;
467 diff -Naur dvdread.orig/nav_print.c dvdread/nav_print.c
468 diff -Naur dvdread.orig/nav_print.h dvdread/nav_print.h
469 --- dvdread.orig/nav_print.h 2005-06-23 00:18:54.000000000 +0200
470 +++ dvdread/nav_print.h 2005-06-23 00:19:10.000000000 +0200
471 @@ -20,7 +20,7 @@
472 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
475 -#include <dvdread/nav_types.h>
476 +#include "nav_types.h"
479 * Pretty printing of the NAV packets, PCI and DSI structs.
480 diff -Naur dvdread.orig/nav_read.c dvdread/nav_read.c
481 diff -Naur dvdread.orig/nav_read.h dvdread/nav_read.h
482 --- dvdread.orig/nav_read.h 2005-06-23 00:18:54.000000000 +0200
483 +++ dvdread/nav_read.h 2005-06-23 00:19:10.000000000 +0200
484 @@ -19,7 +19,7 @@
485 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
488 -#include <dvdread/nav_types.h>
489 +#include "nav_types.h"
492 * Parsing of NAV data, PCI and DSI parts.
493 diff -Naur dvdread.orig/nav_types.h dvdread/nav_types.h
494 --- dvdread.orig/nav_types.h 2005-06-23 00:18:54.000000000 +0200
495 +++ dvdread/nav_types.h 2005-06-23 00:19:10.000000000 +0200
496 @@ -30,7 +30,7 @@
499 #include <inttypes.h>
500 -#include <dvdread/ifo_types.h> /* only dvd_time_t, vm_cmd_t and user_ops_t */
501 +#include "ifo_types.h" /* only dvd_time_t, vm_cmd_t and user_ops_t */
504 #undef ATTRIBUTE_PACKED