[DVDnav-discuss] r1043 - in trunk/libdvdnav/src/dvdread: dvd_reader.c dvd_reader.h ifo_read.c

nicodvb subversion at mplayerhq.hu
Tue May 27 23:53:10 CEST 2008


Author: nicodvb
Date: Tue May 27 23:53:10 2008
New Revision: 1043

Log:
workaround wrong filesize indicated in the UDF; patch by unknown author posted by Alexander Roalter it

Modified:
   trunk/libdvdnav/src/dvdread/dvd_reader.c
   trunk/libdvdnav/src/dvdread/dvd_reader.h
   trunk/libdvdnav/src/dvdread/ifo_read.c

Modified: trunk/libdvdnav/src/dvdread/dvd_reader.c
==============================================================================
--- trunk/libdvdnav/src/dvdread/dvd_reader.c	(original)
+++ trunk/libdvdnav/src/dvdread/dvd_reader.c	Tue May 27 23:53:10 2008
@@ -1042,6 +1042,28 @@ int32_t DVDFileSeek( dvd_file_t *dvd_fil
     return offset;
 }
 
+int DVDFileSeekForce(dvd_file_t *dvd_file, int offset, int force_size)
+{
+    /* Check arguments. */
+    if( dvd_file == NULL || offset <= 0 )
+        return -1;
+
+    if( dvd_file->dvd->isImageFile ) {
+        if( force_size < 0 )
+            force_size = (offset - 1) / DVD_VIDEO_LB_LEN + 1;
+        if( dvd_file->filesize < force_size ) {
+            dvd_file->filesize = force_size;
+            fprintf(stderr, "libdvdread: Ignored size of file indicated in UDF.\n");
+        }
+    }
+
+    if( offset > dvd_file->filesize * DVD_VIDEO_LB_LEN )
+        return -1;
+
+    dvd_file->seek_pos = (uint32_t) offset;
+    return offset;
+}
+
 ssize_t DVDReadBytes( dvd_file_t *dvd_file, void *data, size_t byte_size )
 {
     unsigned char *secbuf_base, *secbuf;
@@ -1082,7 +1104,7 @@ ssize_t DVDReadBytes( dvd_file_t *dvd_fi
     memcpy( data, &(secbuf[ seek_byte ]), byte_size );
     free( secbuf_base );
 
-    dvd_file->seek_pos += byte_size;
+    DVDFileSeekForce(dvd_file, dvd_file->seek_pos + byte_size, -1);
     return byte_size;
 }
 

Modified: trunk/libdvdnav/src/dvdread/dvd_reader.h
==============================================================================
--- trunk/libdvdnav/src/dvdread/dvd_reader.h	(original)
+++ trunk/libdvdnav/src/dvdread/dvd_reader.h	Tue May 27 23:53:10 2008
@@ -229,6 +229,8 @@ int DVDDiscID( dvd_reader_t *, unsigned 
 int DVDUDFVolumeInfo( dvd_reader_t *, char *, unsigned int,
 		      unsigned char *, unsigned int );
 
+int DVDFileSeekForce( dvd_file_t *, int offset, int force_size);
+
 /**
  * Get the ISO9660 VolumeIdentifier and VolumeSetIdentifier
  *

Modified: trunk/libdvdnav/src/dvdread/ifo_read.c
==============================================================================
--- trunk/libdvdnav/src/dvdread/ifo_read.c	(original)
+++ trunk/libdvdnav/src/dvdread/ifo_read.c	Tue May 27 23:53:10 2008
@@ -89,6 +89,9 @@ static void ifoFree_PGC(pgc_t *pgc);
 static void ifoFree_PGC_COMMAND_TBL(pgc_command_tbl_t *cmd_tbl);
 static void ifoFree_PGCIT_internal(pgcit_t *pgcit);
 
+static inline int DVDFileSeekForce_( dvd_file_t *dvd_file, uint32_t offset, int force_size ) {
+  return (DVDFileSeekForce(dvd_file, (int)offset, force_size) == (int)offset);
+}
 
 static inline int DVDFileSeek_( dvd_file_t *dvd_file, uint32_t offset ) {
   return (DVDFileSeek(dvd_file, (int)offset) == (int)offset);
@@ -1689,7 +1692,7 @@ static int ifoRead_VOBU_ADMAP_internal(i
   unsigned int i;
   int info_length;
 
-  if(!DVDFileSeek_(ifofile->file, sector * DVD_BLOCK_LEN))
+  if(!DVDFileSeekForce_(ifofile->file, sector * DVD_BLOCK_LEN, sector))
     return 0;
 
   if(!(DVDReadBytes(ifofile->file, vobu_admap, VOBU_ADMAP_SIZE)))



More information about the DVDnav-discuss mailing list