[libdvdnav-devel] [PATCH] [RFC] Read in advance all the IFO file, in order to reduce number of read access

Jean-Baptiste Kempf jb at videolan.org
Fri Aug 29 01:51:27 CEST 2014


From: David Dielsky <david122192 at gmail.com>

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
---
 src/ifo_read.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/ifo_read.c b/src/ifo_read.c
index 4659136..c852e9c 100644
--- a/src/ifo_read.c
+++ b/src/ifo_read.c
@@ -304,6 +304,15 @@ ifo_handle_t *ifoOpen(dvd_reader_t *dvd, int title) {
     bup_file_opened = 1;
   }
 
+  // read in advance all the IFO file, in order to keep it in the system buffer and reduce number of read access
+  ssize_t s = DVDFileSize(ifofile->file)*DVD_VIDEO_LB_LEN;
+  void* null_buffer = malloc(s);
+  if (null_buffer)
+  {
+    DVDReadBytes(ifofile->file, null_buffer, s);
+    free(null_buffer);
+  }
+
   if (title)
     snprintf(ifo_filename, 13, "VTS_%02d_0.%s", title, bup_file_opened ? "BUP" : "IFO");
   else
@@ -440,6 +449,15 @@ ifo_handle_t *ifoOpenVMGI(dvd_reader_t *dvd) {
     return NULL;
   }
 
+  // read in advance all the IFO file, in order to keep it in the system buffer and reduce number of read access
+  ssize_t s = DVDFileSize(ifofile->file)*DVD_VIDEO_LB_LEN;
+  void* null_buffer = malloc(s);
+  if (null_buffer)
+  {
+    DVDReadBytes(ifofile->file, null_buffer, s);
+    free(null_buffer);
+  }
+
   if(ifoRead_VMG(ifofile))
     return ifofile;
 
@@ -473,6 +491,15 @@ ifo_handle_t *ifoOpenVTSI(dvd_reader_t *dvd, int title) {
     return NULL;
   }
 
+  // read in advance all the IFO file, in order to keep it in the system buffer and reduce number of read access
+  ssize_t s = DVDFileSize(ifofile->file)*DVD_VIDEO_LB_LEN;
+  void* null_buffer = malloc(s);
+  if (null_buffer)
+  {
+    DVDReadBytes(ifofile->file, null_buffer, s);
+    free(null_buffer);
+  }
+
   if(ifoRead_VTS(ifofile) && ifofile->vtsi_mat)
     return ifofile;
 
-- 
2.1.0



More information about the libdvdnav-devel mailing list