udf: compatibility with UDF 1.02 (standard DVD Video) ISOs
authorVoyager1 <voyager@xbmc.org>
Sun, 5 Jan 2014 08:52:08 +0000 (09:52 +0100)
committerVoyager1 <voyager@xbmc.org>
Sat, 11 Jan 2014 07:18:13 +0000 (08:18 +0100)
xbmc/filesystem/udf25.cpp
xbmc/filesystem/udf25.h

index 49adac7..ee1c7c2 100644 (file)
@@ -718,6 +718,7 @@ int udf25::UDFFindPartition( int partnum, struct Partition *part )
         /* Partition Descriptor */
         UDFPartition( LogBlock, &part->Flags, &part->Number,
                       part->Contents, &part->Start, &part->Length );
+        part->Start_Correction = 0;
         part->valid = ( partnum == part->Number );
       } else if( ( TagID == 6 ) && ( !volvalid ) ) {
         /* Logical Volume Descriptor */
@@ -762,6 +763,8 @@ int udf25::UDFFindPartition( int partnum, struct Partition *part )
       UDFExtFileEntry( LogBlock, &File );
       if (File.Type == 250) {
         part->Start  += File.AD_chain[0].Location;
+        // we need to remember this correction because read positions are relative to the non-indirected partition start
+        part->Start_Correction = File.AD_chain[0].Location;
         part->Length  = File.AD_chain[0].Length;
         break;
       }
@@ -792,6 +795,7 @@ int udf25::UDFMapICB( struct AD ICB, struct Partition *partition, struct FileAD
   memset(File, 0, sizeof(*File));
   File->Partition       = partition->Number;
   File->Partition_Start = partition->Start;
+  File->Partition_Start_Correction = partition->Start_Correction;
 
   do {
     if( DVDReadLBUDF( lbnum++, 1, LogBlock, 0 ) <= 0 )
@@ -1109,7 +1113,8 @@ long udf25::ReadFile(HANDLE hFile, unsigned char *pBuffer, long lSize)
     if(len == 0)
       break;
 
-    pos -= 32 * DVD_VIDEO_LB_LEN; /* why? */
+    // correct for partition indirection if applicable
+    pos -= bdfile->file->Partition_Start_Correction * DVD_VIDEO_LB_LEN;
 
     if((uint32_t)lSize < len)
       len = lSize;
index 9213da9..c3a45f3 100644 (file)
@@ -46,6 +46,7 @@ struct Partition {
   uint32_t AccessType;
   uint32_t Start;
   uint32_t Length;
+  uint32_t Start_Correction;
 };
 
 struct AD {
@@ -75,6 +76,7 @@ struct FileAD {
     uint32_t num_AD;
     uint16_t Partition;
     uint32_t Partition_Start;
+    uint32_t Partition_Start_Correction;
     uint8_t  Type;
     uint16_t Flags;
     struct AD AD_chain[UDF_MAX_AD_CHAINS];