reassign 303541 libdvdnav4
tag 303541 +patch
thanks

On Sat, Jul 15, 2006, Andreas Henriksson wrote:

> Changing line 95 to read 0 instead of 1 makes it possible to play the
> dvd image:
> #define DVD_READ_CACHE 0
> 
> Hopefully this workaround can be applied on atleast amd64 where I've
> confirmed it working until someone digs deeper and finds the cause of
> the cache not working.

   As discussed on IRC, I am reassigning this to libdvdnav and attaching
a patch for 64-bit cleanness.

Regards,
-- 
Sam.
diff -puriN libdvdnav-0.1.9.orig/src/dvd_reader.c 
libdvdnav-0.1.9/src/dvd_reader.c
--- libdvdnav-0.1.9.orig/src/dvd_reader.c       2003-05-01 22:19:19.000000000 
+0200
+++ libdvdnav-0.1.9/src/dvd_reader.c    2006-07-15 21:46:08.000000000 +0200
@@ -23,6 +23,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/time.h> /* For the timing of dvdcss_title crack. */
+#include <stdint.h>
 #include <fcntl.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -1000,7 +1001,7 @@ ssize_t DVDReadBytes( dvd_file_t *dvd_fi
       ( ( ( seek_byte + byte_size ) % DVD_VIDEO_LB_LEN ) ? 1 : 0 );
     
     secbuf_base = (unsigned char *) malloc( numsec * DVD_VIDEO_LB_LEN + 2048 );
-    secbuf = (unsigned char *)(((int)secbuf_base & ~2047) + 2048);
+    secbuf = (unsigned char *)(((uintptr_t)secbuf_base & ~(uintptr_t)2047) + 
2048);
     if( !secbuf_base ) {
        fprintf( stderr, "libdvdread: Can't allocate memory " 
                 "for file read!\n" );
@@ -1054,7 +1055,7 @@ int DVDDiscID( dvd_reader_t *dvd, unsign
            ssize_t bytes_read;
            size_t file_size = dvd_file->filesize * DVD_VIDEO_LB_LEN;
            char *buffer_base = malloc( file_size + 2048 );
-           char *buffer = (unsigned char *)(((int)buffer_base & ~2047) + 2048);
+           char *buffer = (unsigned char *)(((uintptr_t)buffer_base & 
~(uintptr_t)2047) + 2048);
            
            if( buffer_base == NULL ) {
                fprintf( stderr, "libdvdread: DVDDiscId, failed to "
@@ -1099,7 +1100,7 @@ int DVDISOVolumeInfo( dvd_reader_t *dvd,
   }
   
   buffer_base = malloc( DVD_VIDEO_LB_LEN + 2048 );
-  buffer = (unsigned char *)(((int)buffer_base & ~2047) + 2048);
+  buffer = (unsigned char *)(((uintptr_t)buffer_base & ~(uintptr_t)2047) + 
2048);
 
   if( buffer_base == NULL ) {
     fprintf( stderr, "libdvdread: DVDISOVolumeInfo, failed to "
diff -puriN libdvdnav-0.1.9.orig/src/dvd_udf.c libdvdnav-0.1.9/src/dvd_udf.c
--- libdvdnav-0.1.9.orig/src/dvd_udf.c  2003-04-29 17:13:59.000000000 +0200
+++ libdvdnav-0.1.9/src/dvd_udf.c       2006-07-15 21:47:30.000000000 +0200
@@ -492,7 +492,7 @@ static int UDFMapICB( dvd_reader_t *devi
                      struct Partition *partition, struct AD *File ) 
 {
     uint8_t LogBlock_base[DVD_VIDEO_LB_LEN + 2048];
-    uint8_t *LogBlock = (uint8_t *)(((int)LogBlock_base & ~2047) + 2048);
+    uint8_t *LogBlock = (uint8_t *)(((uintptr_t)LogBlock_base & 
~(uintptr_t)2047) + 2048);
     uint32_t lbnum;
     uint16_t TagID;
     struct icbmap tmpmap;
@@ -537,7 +537,7 @@ static int UDFScanDir( dvd_reader_t *dev
 {
     char filename[ MAX_UDF_FILE_NAME_LEN ];
     uint8_t directory_base[ 2 * DVD_VIDEO_LB_LEN + 2048];
-    uint8_t *directory = (uint8_t *)(((int)directory_base & ~2047) + 2048);
+    uint8_t *directory = (uint8_t *)(((uintptr_t)directory_base & 
~(uintptr_t)2047) + 2048);
     uint32_t lbnum;
     uint16_t TagID;
     uint8_t filechar;
@@ -559,7 +559,7 @@ static int UDFScanDir( dvd_reader_t *dev
        if((cached_dir_base = malloc(dir_lba * DVD_VIDEO_LB_LEN + 2048)) == 
NULL) {
          return 0;
        }
-       cached_dir = (uint8_t *)(((int)cached_dir_base & ~2047) + 2048);
+       cached_dir = (uint8_t *)(((uintptr_t)cached_dir_base & 
~(uintptr_t)2047) + 2048);
        if( DVDReadLBUDF( device, lbnum, dir_lba, cached_dir, 0) <= 0 ) {
          free(cached_dir_base);
          cached_dir = NULL;
@@ -650,7 +650,7 @@ static int UDFGetAVDP( dvd_reader_t *dev
                       struct avdp_t *avdp)
 {
   uint8_t Anchor_base[ DVD_VIDEO_LB_LEN + 2048 ];
-  uint8_t *Anchor = (uint8_t *)(((int)Anchor_base & ~2047) + 2048);
+  uint8_t *Anchor = (uint8_t *)(((uintptr_t)Anchor_base & ~(uintptr_t)2047) + 
2048);
   uint32_t lbnum, MVDS_location, MVDS_length;
   uint16_t TagID;
   uint32_t lastsector;
@@ -722,7 +722,7 @@ static int UDFFindPartition( dvd_reader_
                             struct Partition *part ) 
 {
     uint8_t LogBlock_base[ DVD_VIDEO_LB_LEN + 2048 ];
-    uint8_t *LogBlock = (uint8_t *)(((int)LogBlock_base & ~2047) + 2048);
+    uint8_t *LogBlock = (uint8_t *)(((uintptr_t)LogBlock_base & 
~(uintptr_t)2047) + 2048);
     uint32_t lbnum, MVDS_location, MVDS_length;
     uint16_t TagID;
     int i, volvalid;
@@ -785,7 +785,7 @@ uint32_t UDFFindFile( dvd_reader_t *devi
                      uint32_t *filesize )
 {
     uint8_t LogBlock_base[ DVD_VIDEO_LB_LEN + 2048 ];
-    uint8_t *LogBlock = (uint8_t *)(((int)LogBlock_base & ~2047) + 2048);
+    uint8_t *LogBlock = (uint8_t *)(((uintptr_t)LogBlock_base & 
~(uintptr_t)2047) + 2048);
     uint32_t lbnum;
     uint16_t TagID;
     struct Partition partition;
@@ -930,7 +930,7 @@ static int UDFGetDescriptor( dvd_reader_
 static int UDFGetPVD(dvd_reader_t *device, struct pvd_t *pvd)
 {
   uint8_t pvd_buf_base[DVD_VIDEO_LB_LEN + 2048];
-  uint8_t *pvd_buf = (uint8_t *)(((int)pvd_buf_base & ~2047) + 2048);
+  uint8_t *pvd_buf = (uint8_t *)(((uintptr_t)pvd_buf_base & ~(uintptr_t)2047) 
+ 2048);
   
   if(GetUDFCache(device, PVDCache, 0, pvd)) {
     return 1;
diff -puriN libdvdnav-0.1.9.orig/src/read_cache.c 
libdvdnav-0.1.9/src/read_cache.c
--- libdvdnav-0.1.9.orig/src/read_cache.c       2003-04-28 18:29:22.000000000 
+0200
+++ libdvdnav-0.1.9/src/read_cache.c    2006-07-15 21:44:00.000000000 +0200
@@ -27,6 +27,7 @@
 
 #include "dvdnav.h"
 #include "read_cache.h"
+#include <stdint.h>
 #include <pthread.h>
 #include <sys/time.h>
 #include <time.h>
@@ -448,7 +449,7 @@ void dvdnav_pre_cache_blocks(read_cache_
       self->chunk[use].cache_buffer_base = 
realloc(self->chunk[use].cache_buffer_base,
         block_count * DVD_VIDEO_LB_LEN + ALIGNMENT);
       self->chunk[use].cache_buffer =
-        (uint8_t *)(((int)self->chunk[use].cache_buffer_base & ~(ALIGNMENT - 
1)) + ALIGNMENT);
+        (uint8_t *)(((uintptr_t)self->chunk[use].cache_buffer_base & 
~(uintptr_t)(ALIGNMENT - 1)) + ALIGNMENT);
       dprintf("pre_cache DVD read realloc happened\n");
       self->chunk[use].cache_malloc_size = block_count;
     } else {
@@ -466,7 +467,7 @@ void dvdnav_pre_cache_blocks(read_cache_
        self->chunk[i].cache_buffer_base =
          malloc((block_count > 500 ? block_count : 500) * DVD_VIDEO_LB_LEN + 
ALIGNMENT);
        self->chunk[i].cache_buffer =
-         (uint8_t *)(((int)self->chunk[i].cache_buffer_base & ~(ALIGNMENT - 
1)) + ALIGNMENT);
+         (uint8_t *)(((uintptr_t)self->chunk[i].cache_buffer_base & 
~(uintptr_t)(ALIGNMENT - 1)) + ALIGNMENT);
        self->chunk[i].cache_malloc_size = block_count > 500 ? block_count : 
500;
        dprintf("pre_cache DVD read malloc %d blocks\n",
          (block_count > 500 ? block_count : 500 ));

Reply via email to