[DVDnav-discuss] [PATCH] Fix DVDDiscID from reading non-existent IFO files
Steve Dibb
steve.dibb at gmail.com
Mon Feb 17 01:14:04 CET 2014
First patch, and from a C noob even, so go easy on me. :)
In dvd_reader.c, the DVDDiscID function gets the MD5 from the total contents
of the IFO files on the disc. However, it gets it by looping through the
the first ten IFO files, whether they exist or not.
This results in spewage, where a disc has less than ten. In this case,
Dragonheart only has two:
libdvdnav:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VTS_03_0.IFO failed
libdvdnav:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VTS_04_0.IFO failed
libdvdnav:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VTS_05_0.IFO failed
libdvdnav:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VTS_06_0.IFO failed
libdvdnav:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VTS_07_0.IFO failed
libdvdnav:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VTS_08_0.IFO failed
libdvdnav:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VTS_09_0.IFO failed
Instead of using a set limit of 10 IFOs, this patch counts the number of
VTSes existing on the DVD, and will use that number instead if it is less
than 10.
Also, doesn't break backwards compatability -- MD5 sum is the same before
and after the patch. :)
--- src/dvd_reader.c.orig 2014-02-16 15:39:51.890964032 -0700
+++ src/dvd_reader.c 2014-02-16 16:37:42.269821221 -0700
@@ -70,6 +70,7 @@
#include "dvd_input.h"
#include "dvdread/dvd_reader.h"
#include "md5.h"
+#include "dvdread/ifo_read.h"
#define DEFAULT_UDF_CACHE_LEVEL 1
@@ -1329,16 +1330,31 @@
{
struct md5_ctx ctx;
int title;
+ int title_sets;
int nr_of_files = 0;
+ ifo_handle_t *vmg_ifo;
/* Check arguments. */
if( dvd == NULL || discid == NULL )
return 0;
- /* Go through the first 10 IFO:s, in order,
+ vmg_ifo = ifoOpen( dvd, 0 );
+ if( !vmg_ifo ) {
+ fprintf( stderr, "libdvdread: DVDDiscId, failed to "
+ "open VMG IFO!\n" );
+ return -1;
+ }
+
+ title_sets = vmg_ifo->vmgi_mat->vmg_nr_of_title_sets + 1;
+ ifoClose( vmg_ifo );
+
+ if( title_sets > 10 )
+ title_sets = 10;
+
+ /* Go through the first IFO:s, in order, up until the tenth,
* and md5sum them, i.e VIDEO_TS.IFO and VTS_0?_0.IFO */
md5_init_ctx( &ctx );
- for( title = 0; title < 10; title++ ) {
+ for( title = 0; title < title_sets; title++ ) {
dvd_file_t *dvd_file = DVDOpenFile( dvd, title, DVD_READ_INFO_FILE );
if( dvd_file != NULL ) {
ssize_t bytes_read;
More information about the DVDnav-discuss
mailing list