summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Roitzsch <mroi@users.sourceforge.net>2002-11-27 21:19:07 +0000
committerMichael Roitzsch <mroi@users.sourceforge.net>2002-11-27 21:19:07 +0000
commita0a7c3a8389dd1a21f286befa638d94a90463684 (patch)
tree7104c6fe93acf9045b78305e918e9ace3eeede75
parent4ab0fb4227cbba67eba08cc455ee38756d5e3f6b (diff)
downloadxine-lib-a0a7c3a8389dd1a21f286befa638d94a90463684.tar.gz
xine-lib-a0a7c3a8389dd1a21f286befa638d94a90463684.tar.bz2
sync to libdvdread cvs should fix segfault when playing DVDs copied to HD
thanks to Markus Plail for reporting this bug and the fix as well CVS patchset: 3381 CVS date: 2002/11/27 21:19:07
-rw-r--r--src/input/libdvdread/diff_against_cvs.patch207
-rw-r--r--src/input/libdvdread/dvd_input.c19
-rw-r--r--src/input/libdvdread/dvd_input.h16
-rw-r--r--src/input/libdvdread/dvd_reader.c64
-rw-r--r--src/input/libdvdread/dvd_reader.h126
-rw-r--r--src/input/libdvdread/ifo_print.c31
-rw-r--r--src/input/libdvdread/ifo_print.h1
-rw-r--r--src/input/libdvdread/ifo_read.c159
-rw-r--r--src/input/libdvdread/ifo_read.h13
-rw-r--r--src/input/libdvdread/ifo_types.h39
-rw-r--r--src/input/libdvdread/nav_print.h12
-rw-r--r--src/input/libdvdread/nav_read.h16
-rw-r--r--src/input/libdvdread/nav_types.h141
13 files changed, 515 insertions, 329 deletions
diff --git a/src/input/libdvdread/diff_against_cvs.patch b/src/input/libdvdread/diff_against_cvs.patch
index 38ba75796..f5470a554 100644
--- a/src/input/libdvdread/diff_against_cvs.patch
+++ b/src/input/libdvdread/diff_against_cvs.patch
@@ -1,15 +1,15 @@
---- src/input/libdvdread/dvd_input.c 2002-10-23 13:39:33.000000000 +0200
-+++ src/input/libdvdread/dvd_input.c 2002-09-05 12:41:52.000000000 +0200
-@@ -55,7 +55,7 @@
+--- src/input/libdvdread/dvd_input.c 2002-11-27 21:56:47.000000000 +0100
++++ src/input/libdvdread/dvd_input.c 2002-11-27 21:50:03.000000000 +0100
+@@ -63,7 +63,7 @@
dvd_input_t dev;
-
+
/* Allocate the handle structure */
- dev = (dvd_input_t) malloc(sizeof(dvd_input_t));
+ dev = (dvd_input_t) malloc(sizeof(*dev));
if(dev == NULL) {
fprintf(stderr, "libdvdread: Could not allocate memory.\n");
return NULL;
-@@ -134,7 +134,7 @@
+@@ -143,7 +143,7 @@
dvd_input_t dev;
/* Allocate the library structure */
@@ -18,8 +18,8 @@
if(dev == NULL) {
fprintf(stderr, "libdvdread: Could not allocate memory.\n");
return NULL;
---- src/input/libdvdread/dvd_reader.c 2002-10-23 13:39:33.000000000 +0200
-+++ src/input/libdvdread/dvd_reader.c 2002-10-23 13:30:07.000000000 +0200
+--- src/input/libdvdread/dvd_reader.c 2002-11-27 21:56:47.000000000 +0100
++++ src/input/libdvdread/dvd_reader.c 2002-11-27 21:51:31.000000000 +0100
@@ -28,7 +28,6 @@
#include <unistd.h>
#include <limits.h>
@@ -36,7 +36,7 @@
#include "dvd_udf.h"
#include "dvd_input.h"
#include "dvd_reader.h"
-@@ -288,7 +288,7 @@
+@@ -289,7 +289,7 @@
if( cdir >= 0 ) {
chdir( path_copy );
@@ -63,7 +63,7 @@
dvd_file_t *dvd_file;
struct stat fileinfo;
dvd_input_t dev;
-@@ -571,7 +571,7 @@
+@@ -570,7 +570,7 @@
static dvd_file_t *DVDOpenVOBPath( dvd_reader_t *dvd, int title, int menu )
{
char filename[ MAX_UDF_FILE_NAME_LEN ];
@@ -72,7 +72,7 @@
struct stat fileinfo;
dvd_file_t *dvd_file;
int i;
-@@ -857,7 +857,7 @@
+@@ -867,7 +867,7 @@
ssize_t DVDReadBytes( dvd_file_t *dvd_file, void *data, size_t byte_size )
{
@@ -81,17 +81,17 @@
unsigned int numsec, seek_sector, seek_byte;
int ret;
-@@ -865,7 +865,8 @@
- seek_byte = dvd_file->seek_pos % DVD_VIDEO_LB_LEN;
-
- numsec = ( ( seek_byte + byte_size ) / DVD_VIDEO_LB_LEN ) + 1;
+@@ -881,7 +881,8 @@
+ numsec = ( ( seek_byte + byte_size ) / DVD_VIDEO_LB_LEN ) +
+ ( ( ( seek_byte + byte_size ) % DVD_VIDEO_LB_LEN ) ? 1 : 0 );
+
- secbuf = (unsigned char *) malloc( numsec * DVD_VIDEO_LB_LEN );
+ secbuf_base = (unsigned char *) malloc( numsec * DVD_VIDEO_LB_LEN + 2048 );
+ secbuf = (unsigned char *)(((int)secbuf_base & ~2047) + 2048);
if( !secbuf ) {
fprintf( stderr, "libdvdread: Can't allocate memory "
"for file read!\n" );
-@@ -881,12 +882,12 @@
+@@ -897,12 +898,12 @@
}
if( ret != (int) numsec ) {
@@ -106,8 +106,8 @@
dvd_file->seek_pos += byte_size;
return byte_size;
---- src/input/libdvdread/dvd_udf.c 2002-10-23 13:39:33.000000000 +0200
-+++ src/input/libdvdread/dvd_udf.c 2002-10-23 13:30:07.000000000 +0200
+--- src/input/libdvdread/dvd_udf.c 2002-11-27 21:56:47.000000000 +0100
++++ src/input/libdvdread/dvd_udf.c 2002-11-27 21:50:03.000000000 +0100
@@ -123,7 +123,7 @@
static int UDFDescriptor( uint8_t *data, uint16_t *TagID )
{
@@ -222,8 +222,8 @@
UDFLongAD( &LogBlock[ 400 ], &RootICB );
}
} while( ( lbnum < partition.Start + partition.Length )
---- src/input/libdvdread/ifo_print.c 2002-08-19 18:18:03.000000000 +0200
-+++ src/input/libdvdread/ifo_print.c 2002-10-23 13:30:07.000000000 +0200
+--- src/input/libdvdread/ifo_print.c 2002-11-27 21:56:47.000000000 +0100
++++ src/input/libdvdread/ifo_print.c 2002-11-27 21:50:03.000000000 +0100
@@ -25,7 +25,7 @@
#include <ctype.h>
#include <assert.h>
@@ -238,7 +238,7 @@
printf("| ");
- //vmcmd(command);
-+ /* )vmcmd(command); */
++ /* vmcmd(command); */
printf("\n");
}
@@ -326,7 +326,7 @@
for(i = 0; i < ptl_mait->nr_of_countries; i++) {
printf("Country code: %c%c\n",
-@@ -825,7 +825,7 @@
+@@ -846,7 +846,7 @@
int i, entries;
printf("Number of VOBs in this VOBS: %i\n", c_adt->nr_of_vobs);
@@ -335,7 +335,7 @@
entries = (c_adt->last_byte + 1 - C_ADT_SIZE)/sizeof(c_adt_t);
for(i = 0; i < entries; i++) {
-@@ -975,7 +975,7 @@
+@@ -996,7 +996,7 @@
printf("\nText Data Manager Information\n");
printf( "-----------------------------\n");
if(ifohandle->txtdt_mgi) {
@@ -344,8 +344,8 @@
} else {
printf("No Text Data Manager Information present\n");
}
---- src/input/libdvdread/ifo_print.h 2002-10-23 13:39:33.000000000 +0200
-+++ src/input/libdvdread/ifo_print.h 2002-08-19 18:18:09.000000000 +0200
+--- src/input/libdvdread/ifo_print.h 2002-11-27 21:56:47.000000000 +0100
++++ src/input/libdvdread/ifo_print.h 2002-11-27 21:50:03.000000000 +0100
@@ -20,8 +20,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
@@ -357,8 +357,8 @@
#ifdef __cplusplus
extern "C" {
---- src/input/libdvdread/ifo_read.c 2002-08-19 18:18:03.000000000 +0200
-+++ src/input/libdvdread/ifo_read.c 2002-10-23 13:30:07.000000000 +0200
+--- src/input/libdvdread/ifo_read.c 2002-11-27 21:56:47.000000000 +0100
++++ src/input/libdvdread/ifo_read.c 2002-11-27 21:50:03.000000000 +0100
@@ -26,7 +26,7 @@
#include "dvd_reader.h"
@@ -368,7 +368,7 @@
#include "bswap.h"
#include "ifo_types.h"
#include "ifo_read.h"
-@@ -636,7 +636,7 @@
+@@ -643,7 +643,7 @@
/* Check that time is 0:0:0:0 also if nr_of_programs == 0 */
if(pgc->nr_of_programs == 0) {
CHECK_ZERO(pgc->still_time);
@@ -377,7 +377,7 @@
assert(pgc->program_map_offset == 0);
assert(pgc->cell_playback_offset == 0);
assert(pgc->cell_position_offset == 0);
-@@ -822,24 +822,24 @@
+@@ -829,24 +829,24 @@
CHECK_ZERO(tt_srpt->zero_1);
assert(tt_srpt->nr_of_srpts != 0);
@@ -410,7 +410,7 @@
#if 0
if(memcmp((uint8_t *)tt_srpt->title +
tt_srpt->nr_of_srpts * sizeof(title_info_t),
-@@ -903,7 +903,7 @@
+@@ -910,7 +910,7 @@
CHECK_ZERO(vts_ptt_srpt->zero_1);
assert(vts_ptt_srpt->nr_of_srpts != 0);
@@ -419,7 +419,7 @@
info_length = vts_ptt_srpt->last_byte + 1 - VTS_PTT_SRPT_SIZE;
-@@ -978,12 +978,12 @@
+@@ -985,12 +985,12 @@
}
for(i = 0; i < vts_ptt_srpt->nr_of_srpts; i++) {
@@ -435,7 +435,7 @@
}
}
-@@ -1043,9 +1043,9 @@
+@@ -1049,9 +1049,9 @@
info_length = ptl_mait->last_byte + 1 - PTL_MAIT_SIZE;
assert(ptl_mait->nr_of_countries != 0);
@@ -447,7 +447,7 @@
assert(ptl_mait->nr_of_countries * PTL_MAIT_COUNTRY_SIZE <= info_length);
/* Change this to read and 'translate' the tables too.
-@@ -1383,7 +1383,7 @@
+@@ -1519,7 +1519,7 @@
/* assert(pgcit->nr_of_pgci_srp != 0);
Magic Knight Rayearth Daybreak is mastered very strange and has
Titles with 0 PTTs. */
@@ -456,7 +456,7 @@
info_length = pgcit->nr_of_pgci_srp * PGCI_SRP_SIZE;
data = malloc(info_length);
-@@ -1504,7 +1504,7 @@
+@@ -1640,7 +1640,7 @@
CHECK_ZERO(pgci_ut->zero_1);
assert(pgci_ut->nr_of_lus != 0);
@@ -465,7 +465,7 @@
assert((uint32_t)pgci_ut->nr_of_lus * PGCI_LU_SIZE < pgci_ut->last_byte);
info_length = pgci_ut->nr_of_lus * PGCI_LU_SIZE;
-@@ -1539,8 +1539,9 @@
+@@ -1675,8 +1675,9 @@
for(i = 0; i < pgci_ut->nr_of_lus; i++) {
CHECK_ZERO(pgci_ut->lu[i].zero_1);
@@ -477,7 +477,7 @@
VTS_x_yy.IFO VIDEO_TS.IFO
a == 0x83 "Root" 0x82 "Title"
b == 0x84 "Subpicture"
-@@ -1578,8 +1579,10 @@
+@@ -1714,8 +1715,10 @@
ifofile->pgci_ut = 0;
return 0;
}
@@ -490,7 +490,7 @@
}
return 1;
-@@ -1640,8 +1643,8 @@
+@@ -1776,8 +1779,8 @@
unsigned int nr_coded;
assert(vts_attributes->last_byte + 1 >= VTS_ATTRIBUTES_MIN_SIZE);
nr_coded = (vts_attributes->last_byte + 1 - VTS_ATTRIBUTES_MIN_SIZE)/6;
@@ -501,7 +501,7 @@
nr_coded = 32;
}
assert(vts_attributes->nr_of_vtstt_subp_streams <= nr_coded);
-@@ -1689,7 +1692,7 @@
+@@ -1825,7 +1828,7 @@
CHECK_ZERO(vts_atrt->zero_1);
assert(vts_atrt->nr_of_vtss != 0);
@@ -510,7 +510,7 @@
assert((uint32_t)vts_atrt->nr_of_vtss * (4 + VTS_ATTRIBUTES_MIN_SIZE) +
VTS_ATRT_SIZE < vts_atrt->last_byte + 1);
-@@ -1730,9 +1733,9 @@
+@@ -1866,9 +1869,9 @@
return 0;
}
@@ -522,7 +522,7 @@
}
free(data);
-@@ -1782,7 +1785,7 @@
+@@ -1918,7 +1921,7 @@
return 0;
}
@@ -531,8 +531,8 @@
return 1;
}
---- src/input/libdvdread/ifo_read.h 2002-10-23 13:39:33.000000000 +0200
-+++ src/input/libdvdread/ifo_read.h 2002-08-19 18:18:09.000000000 +0200
+--- src/input/libdvdread/ifo_read.h 2002-11-27 21:56:47.000000000 +0100
++++ src/input/libdvdread/ifo_read.h 2002-11-27 21:50:03.000000000 +0100
@@ -20,8 +20,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
@@ -544,8 +544,9 @@
#ifdef __cplusplus
extern "C" {
---- src/input/libdvdread/ifo_types.h 2002-10-23 13:39:33.000000000 +0200
-+++ src/input/libdvdread/ifo_types.h 2002-10-23 13:30:07.000000000 +0200
+diff -urN libdvdread.cvs/ifo_types.h libdvdread.new/ifo_types.h
+--- src/input/libdvdread/ifo_types.h 2002-11-27 21:56:47.000000000 +0100
++++ src/input/libdvdread/ifo_types.h 2002-11-27 21:50:03.000000000 +0100
@@ -21,7 +21,7 @@
*/
@@ -801,17 +802,8 @@
subp_attr_t vtsm_subp_attr;
subp_attr_t zero_17[27];
uint8_t zero_18[2];
-@@ -739,7 +739,7 @@
- vtsi_mat_t *vtsi_mat;
- vts_ptt_srpt_t *vts_ptt_srpt;
- pgcit_t *vts_pgcit;
-- int *vts_tmapt; // FIXME add/correct the type
-+ int *vts_tmapt; /* FIXME add/correct the type */
- c_adt_t *vts_c_adt;
- vobu_admap_t *vts_vobu_admap;
- } ifo_handle_t;
---- src/input/libdvdread/nav_print.c 2002-08-19 18:18:03.000000000 +0200
-+++ src/input/libdvdread/nav_print.c 2002-10-23 13:30:07.000000000 +0200
+--- src/input/libdvdread/nav_print.c 2002-11-27 21:56:47.000000000 +0100
++++ src/input/libdvdread/nav_print.c 2002-11-27 21:50:03.000000000 +0100
@@ -27,7 +27,7 @@
#include <inttypes.h>
#include <assert.h>
@@ -830,8 +822,8 @@
printf("\n");
}
}
---- src/input/libdvdread/nav_print.h 2002-10-23 13:39:33.000000000 +0200
-+++ src/input/libdvdread/nav_print.h 2002-08-19 18:18:09.000000000 +0200
+--- src/input/libdvdread/nav_print.h 2002-11-27 21:56:47.000000000 +0100
++++ src/input/libdvdread/nav_print.h 2002-11-27 21:50:03.000000000 +0100
@@ -20,7 +20,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
@@ -839,10 +831,10 @@
-#include <dvdread/nav_types.h>
+#include "nav_types.h"
- #ifdef __cplusplus
- extern "C" {
---- src/input/libdvdread/nav_read.c 2002-10-23 13:39:33.000000000 +0200
-+++ src/input/libdvdread/nav_read.c 2002-10-23 13:30:08.000000000 +0200
+ /**
+ * Pretty printing of the NAV packets, PCI and DSI structs.
+--- src/input/libdvdread/nav_read.c 2002-11-27 21:56:47.000000000 +0100
++++ src/input/libdvdread/nav_read.c 2002-11-27 21:50:03.000000000 +0100
@@ -21,15 +21,19 @@
#include <inttypes.h>
#include <assert.h>
@@ -923,8 +915,8 @@
+#endif
}
---- src/input/libdvdread/nav_read.h 2002-10-23 13:39:33.000000000 +0200
-+++ src/input/libdvdread/nav_read.h 2002-08-19 18:18:09.000000000 +0200
+--- src/input/libdvdread/nav_read.h 2002-11-27 21:56:47.000000000 +0100
++++ src/input/libdvdread/nav_read.h 2002-11-27 21:50:03.000000000 +0100
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
@@ -932,97 +924,16 @@
-#include <dvdread/nav_types.h>
+#include "nav_types.h"
- #ifdef __cplusplus
- extern "C" {
---- src/input/libdvdread/nav_types.h 2002-10-23 13:39:33.000000000 +0200
-+++ src/input/libdvdread/nav_types.h 2002-10-23 13:30:08.000000000 +0200
+ /**
+ * Parsing of NAV data, PCI and DSI parts.
+--- src/input/libdvdread/nav_types.h 2002-11-27 21:56:47.000000000 +0100
++++ src/input/libdvdread/nav_types.h 2002-11-27 21:55:06.000000000 +0100
@@ -30,7 +30,7 @@
*/
#include <inttypes.h>
--#include <dvdread/ifo_types.h> // only dvd_time_t, vm_cmd_t and user_ops_t
+-#include <dvdread/ifo_types.h> /* only dvd_time_t, vm_cmd_t and user_ops_t */
+#include "ifo_types.h" /* only dvd_time_t, vm_cmd_t and user_ops_t */
#undef ATTRIBUTE_PACKED
-@@ -92,7 +92,7 @@
- * Highlight General Information
- */
- typedef struct {
-- uint16_t hli_ss; ///< only low 2 bits
-+ uint16_t hli_ss; /* < only low 2 bits */
- uint32_t hli_s_ptm;
- uint32_t hli_e_ptm;
- uint32_t btn_se_e_ptm;
-@@ -116,11 +116,11 @@
- unsigned int zero3 : 1;
- #endif
- uint8_t btn_ofn;
-- uint8_t btn_ns; ///< only low 6 bits
-- uint8_t nsl_btn_ns; ///< only low 6 bits
-+ uint8_t btn_ns; /* < only low 6 bits */
-+ uint8_t nsl_btn_ns; /* < only low 6 bits */
- uint8_t zero5;
-- uint8_t fosl_btnn; ///< only low 6 bits
-- uint8_t foac_btnn; ///< only low 6 bits
-+ uint8_t fosl_btnn; /* < only low 6 bits */
-+ uint8_t foac_btnn; /* < only low 6 bits */
- } ATTRIBUTE_PACKED hl_gi_t;
-
-
-@@ -217,12 +217,12 @@
- * Seamless Playback Information
- */
- typedef struct {
-- uint16_t category; ///< category of seamless VOBU
-- uint32_t ilvu_ea; ///< end address of interleaved Unit (sectors)
-- uint32_t ilvu_sa; ///< start address of next interleaved unit (sectors)
-- uint16_t size; ///< size of next interleaved unit (sectors)
-- uint32_t vob_v_s_s_ptm; ///< video start ptm in vob
-- uint32_t vob_v_e_e_ptm; ///< video end ptm in vob
-+ uint16_t category; /* category of seamless VOBU */
-+ uint32_t ilvu_ea; /* end address of interleaved Unit (sectors) */
-+ uint32_t ilvu_sa; /* start address of next interleaved unit (sectors) */
-+ uint16_t size; /* size of next interleaved unit (sectors) */
-+ uint32_t vob_v_s_s_ptm; /* video start ptm in vob */
-+ uint32_t vob_v_e_e_ptm; /* video end ptm in vob */
- struct {
- uint32_t stp_ptm1;
- uint32_t stp_ptm2;
-@@ -235,8 +235,8 @@
- * Seamless Angle Infromation for one angle
- */
- typedef struct {
-- uint32_t address; ///< Sector offset to next ILVU, high bit is before/after
-- uint16_t size; ///< Byte size of the ILVU poited to by address.
-+ uint32_t address; /* Sector offset to next ILVU, high bit is before/after */
-+ uint16_t size; /* Byte size of the ILVU poited to by address. */
- } ATTRIBUTE_PACKED sml_agl_data_t;
-
- /**
-@@ -250,11 +250,11 @@
- * VOBU Search Information
- */
- typedef struct {
-- uint32_t next_video; ///< Next vobu that contains video
-- uint32_t fwda[19]; ///< Forwards, time
-+ uint32_t next_video; /* Next vobu that contains video */
-+ uint32_t fwda[19]; /* Forwards, time */
- uint32_t next_vobu;
- uint32_t prev_vobu;
-- uint32_t bwda[19]; ///< Backwards, time
-+ uint32_t bwda[19]; /* Backwards, time */
- uint32_t prev_video;
- } ATTRIBUTE_PACKED vobu_sri_t;
-
-@@ -264,8 +264,8 @@
- * Synchronous Information
- */
- typedef struct {
-- uint16_t a_synca[8]; ///< Sector offset to first audio packet for this VOBU
-- uint32_t sp_synca[32]; ///< Sector offset to first subpicture packet
-+ uint16_t a_synca[8]; /* Sector offset to first audio packet for this VOBU */
-+ uint32_t sp_synca[32]; /* Sector offset to first subpicture packet */
- } ATTRIBUTE_PACKED synci_t;
-
- /**
diff --git a/src/input/libdvdread/dvd_input.c b/src/input/libdvdread/dvd_input.c
index ccd57dd5a..d1782500f 100644
--- a/src/input/libdvdread/dvd_input.c
+++ b/src/input/libdvdread/dvd_input.c
@@ -26,6 +26,14 @@
#include "dvd_reader.h"
#include "dvd_input.h"
+/* The function pointers that is the exported interface of this file. */
+dvd_input_t (*DVDinput_open) (const char *);
+int (*DVDinput_close) (dvd_input_t);
+int (*DVDinput_seek) (dvd_input_t, int);
+int (*DVDinput_title) (dvd_input_t, int);
+int (*DVDinput_read) (dvd_input_t, void *, int, int);
+char * (*DVDinput_error) (dvd_input_t);
+
/* For libdvdcss */
typedef struct dvdcss_s *dvdcss_handle;
@@ -53,7 +61,7 @@ struct dvd_input_s {
static dvd_input_t css_open(const char *target)
{
dvd_input_t dev;
-
+
/* Allocate the handle structure */
dev = (dvd_input_t) malloc(sizeof(*dev));
if(dev == NULL) {
@@ -83,9 +91,10 @@ static char *css_error(dvd_input_t dev)
/**
* seek into the device.
*/
-static int css_seek(dvd_input_t dev, int blocks, int flags)
+static int css_seek(dvd_input_t dev, int blocks)
{
- return DVDcss_seek(dev->dvdcss, blocks, flags);
+ /* DVDINPUT_NOFLAGS should match the DVDCSS_NOFLAGS value. */
+ return DVDcss_seek(dev->dvdcss, blocks, DVDINPUT_NOFLAGS);
}
/**
@@ -157,13 +166,13 @@ static dvd_input_t file_open(const char *target)
static char *file_error(dvd_input_t dev)
{
/* use strerror(errno)? */
- return "unknown error";
+ return (char *)"unknown error";
}
/**
* seek into the device.
*/
-static int file_seek(dvd_input_t dev, int blocks, int flags)
+static int file_seek(dvd_input_t dev, int blocks)
{
off_t pos;
diff --git a/src/input/libdvdread/dvd_input.h b/src/input/libdvdread/dvd_input.h
index 638d60aeb..0f13385bf 100644
--- a/src/input/libdvdread/dvd_input.h
+++ b/src/input/libdvdread/dvd_input.h
@@ -27,21 +27,17 @@
#define DVDINPUT_READ_DECRYPT (1 << 0)
-#define DVDINPUT_SEEK_MPEG (1 << 0)
-#define DVDINPUT_SEEK_KEY (1 << 1)
-
-
typedef struct dvd_input_s *dvd_input_t;
/**
* Pointers which will be filled either the input meathods functions.
*/
-dvd_input_t (*DVDinput_open) (const char *);
-int (*DVDinput_close) (dvd_input_t);
-int (*DVDinput_seek) (dvd_input_t, int, int);
-int (*DVDinput_title) (dvd_input_t, int);
-int (*DVDinput_read) (dvd_input_t, void *, int, int);
-char * (*DVDinput_error) (dvd_input_t);
+extern dvd_input_t (*DVDinput_open) (const char *);
+extern int (*DVDinput_close) (dvd_input_t);
+extern int (*DVDinput_seek) (dvd_input_t, int);
+extern int (*DVDinput_title) (dvd_input_t, int);
+extern int (*DVDinput_read) (dvd_input_t, void *, int, int);
+extern char * (*DVDinput_error) (dvd_input_t);
/**
* Setup function accessed by dvd_reader.c. Returns 1 if there is CSS support.
diff --git a/src/input/libdvdread/dvd_reader.c b/src/input/libdvdread/dvd_reader.c
index 1113cf92b..242bd2ba7 100644
--- a/src/input/libdvdread/dvd_reader.c
+++ b/src/input/libdvdread/dvd_reader.c
@@ -240,7 +240,8 @@ dvd_reader_t *DVDOpen( const char *path )
int ret, have_css;
char *dev_name = 0;
- if( !path ) return 0;
+ if( path == NULL )
+ return 0;
ret = stat( path, &fileinfo );
if( ret < 0 ) {
@@ -397,7 +398,6 @@ void DVDClose( dvd_reader_t *dvd )
if( dvd->dev ) DVDinput_close( dvd->dev );
if( dvd->path_root ) free( dvd->path_root );
free( dvd );
- dvd = 0;
}
}
@@ -558,8 +558,7 @@ static dvd_file_t *DVDOpenVOBUDF( dvd_reader_t *dvd, int title, int menu )
dvd->css_state = 2;
}
/*
- if( DVDinput_seek( dvd_file->dvd->dev,
- (int)start, DVDINPUT_SEEK_KEY ) < 0 ) {
+ if( DVDinput_title( dvd_file->dvd->dev, (int)start ) < 0 ) {
fprintf( stderr, "libdvdread: Error cracking CSS key for %s\n",
filename );
}
@@ -585,7 +584,7 @@ static dvd_file_t *DVDOpenVOBPath( dvd_reader_t *dvd, int title, int menu )
memset( dvd_file->title_sizes, 0, sizeof( dvd_file->title_sizes ) );
memset( dvd_file->title_devs, 0, sizeof( dvd_file->title_devs ) );
dvd_file->filesize = 0;
-
+
if( menu ) {
dvd_input_t dev;
@@ -612,7 +611,7 @@ static dvd_file_t *DVDOpenVOBPath( dvd_reader_t *dvd, int title, int menu )
}
dvd_file->title_sizes[ 0 ] = fileinfo.st_size / DVD_VIDEO_LB_LEN;
dvd_file->title_devs[ 0 ] = dev;
- DVDinput_seek( dvd_file->title_devs[0], 0, DVDINPUT_SEEK_KEY );
+ DVDinput_title( dvd_file->title_devs[0], 0);
dvd_file->filesize = dvd_file->title_sizes[ 0 ];
} else {
@@ -630,11 +629,10 @@ static dvd_file_t *DVDOpenVOBPath( dvd_reader_t *dvd, int title, int menu )
dvd_file->title_sizes[ i ] = fileinfo.st_size / DVD_VIDEO_LB_LEN;
dvd_file->title_devs[ i ] = DVDinput_open( full_path );
+ DVDinput_title( dvd_file->title_devs[ i ], 0);
dvd_file->filesize += dvd_file->title_sizes[ i ];
}
- if( dvd_file->title_devs[ 0 ] ) {
- DVDinput_seek( dvd_file->title_devs[ 0 ], 0, DVDINPUT_SEEK_KEY );
- } else {
+ if( !dvd_file->title_devs[ 0 ] ) {
free( dvd_file );
return 0;
}
@@ -647,6 +645,10 @@ dvd_file_t *DVDOpenFile( dvd_reader_t *dvd, int titlenum,
dvd_read_domain_t domain )
{
char filename[ MAX_UDF_FILE_NAME_LEN ];
+
+ /* Check arguments. */
+ if( dvd == NULL || titlenum < 0 )
+ return NULL;
switch( domain ) {
case DVD_READ_INFO_FILE:
@@ -680,7 +682,7 @@ dvd_file_t *DVDOpenFile( dvd_reader_t *dvd, int titlenum,
break;
default:
fprintf( stderr, "libdvdread: Invalid domain for file open.\n" );
- return 0;
+ return NULL;
}
if( dvd->isImageFile ) {
@@ -722,7 +724,7 @@ int DVDReadBlocksUDFRaw( dvd_reader_t *device, uint32_t lb_number,
return 0;
}
- ret = DVDinput_seek( device->dev, (int) lb_number, DVDINPUT_NOFLAGS );
+ ret = DVDinput_seek( device->dev, (int) lb_number );
if( ret != (int) lb_number ) {
fprintf( stderr, "libdvdread: Can't seek to block %u\n", lb_number );
return 0;
@@ -766,8 +768,7 @@ static int DVDReadBlocksPath( dvd_file_t *dvd_file, unsigned int offset,
if( offset < dvd_file->title_sizes[ i ] ) {
if( ( offset + block_count ) <= dvd_file->title_sizes[ i ] ) {
- off = DVDinput_seek( dvd_file->title_devs[ i ],
- (int)offset, DVDINPUT_NOFLAGS );
+ off = DVDinput_seek( dvd_file->title_devs[ i ], (int)offset );
if( off < 0 || off != (int)offset ) {
fprintf( stderr, "libdvdread: Can't seek to block %d\n",
offset );
@@ -782,8 +783,7 @@ static int DVDReadBlocksPath( dvd_file_t *dvd_file, unsigned int offset,
* (This is only true if you try and read >1GB at a time) */
/* Read part 1 */
- off = DVDinput_seek( dvd_file->title_devs[ i ],
- (int)offset, DVDINPUT_NOFLAGS );
+ off = DVDinput_seek( dvd_file->title_devs[ i ], (int)offset );
if( off < 0 || off != (int)offset ) {
fprintf( stderr, "libdvdread: Can't seek to block %d\n",
offset );
@@ -795,9 +795,11 @@ static int DVDReadBlocksPath( dvd_file_t *dvd_file, unsigned int offset,
/* FIXME: This is wrong if i is the last file in the set.
* also error from this read will not show in ret. */
+ /* Does the next part exist? If not then return now. */
+ if( !dvd_file->title_devs[ i + 1 ] ) return ret;
+
/* Read part 2 */
- off = DVDinput_seek( dvd_file->title_devs[ i + 1 ],
- 0, DVDINPUT_NOFLAGS );
+ off = DVDinput_seek( dvd_file->title_devs[ i + 1 ], 0 );
if( off < 0 || off != 0 ) {
fprintf( stderr, "libdvdread: Can't seek to block %d\n",
0 );
@@ -825,6 +827,10 @@ ssize_t DVDReadBlocks( dvd_file_t *dvd_file, int offset,
{
int ret;
+ /* Check arguments. */
+ if( dvd_file == NULL || offset < 0 || data == NULL )
+ return -1;
+
/* Hack, and it will still fail for multiple opens in a threaded app ! */
if( dvd_file->dvd->css_title != dvd_file->css_title ) {
dvd_file->dvd->css_title = dvd_file->css_title;
@@ -848,11 +854,15 @@ ssize_t DVDReadBlocks( dvd_file_t *dvd_file, int offset,
int32_t DVDFileSeek( dvd_file_t *dvd_file, int32_t offset )
{
- if( offset > dvd_file->filesize * DVD_VIDEO_LB_LEN ) {
+ /* Check arguments. */
+ if( dvd_file == NULL || offset < 0 )
return -1;
- }
- dvd_file->seek_pos = (uint32_t) offset;
- return offset;
+
+ 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 )
@@ -861,10 +871,16 @@ ssize_t DVDReadBytes( dvd_file_t *dvd_file, void *data, size_t byte_size )
unsigned int numsec, seek_sector, seek_byte;
int ret;
+ /* Check arguments. */
+ if( dvd_file == NULL || data == NULL )
+ return -1;
+
seek_sector = dvd_file->seek_pos / DVD_VIDEO_LB_LEN;
seek_byte = dvd_file->seek_pos % DVD_VIDEO_LB_LEN;
- numsec = ( ( seek_byte + byte_size ) / DVD_VIDEO_LB_LEN ) + 1;
+ numsec = ( ( seek_byte + byte_size ) / DVD_VIDEO_LB_LEN ) +
+ ( ( ( 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);
if( !secbuf ) {
@@ -895,5 +911,9 @@ ssize_t DVDReadBytes( dvd_file_t *dvd_file, void *data, size_t byte_size )
ssize_t DVDFileSize( dvd_file_t *dvd_file )
{
+ /* Check arguments. */
+ if( dvd_file == NULL )
+ return -1;
+
return dvd_file->filesize;
}
diff --git a/src/input/libdvdread/dvd_reader.h b/src/input/libdvdread/dvd_reader.h
index 75f718274..631475976 100644
--- a/src/input/libdvdread/dvd_reader.h
+++ b/src/input/libdvdread/dvd_reader.h
@@ -23,125 +23,159 @@
#include <sys/types.h>
/**
- * The length of one Logical Block of a DVD Video.
+ * The DVD access interface.
+ *
+ * This file contains the functions that form the interface to to
+ * reading files located on a DVD.
+ */
+
+/**
+ * The length of one Logical Block of a DVD.
*/
#define DVD_VIDEO_LB_LEN 2048
/**
- * Maximum length of filenames for UDF.
+ * Maximum length of filenames allowed in UDF.
*/
#define MAX_UDF_FILE_NAME_LEN 2048
#ifdef __cplusplus
extern "C" {
#endif
-
+
+/**
+ * Opaque type that is used as a handle for one instance of an opened DVD.
+ */
typedef struct dvd_reader_s dvd_reader_t;
+
+/**
+ * Opaque type for a file read handle, much like a normal fd or FILE *.
+ */
typedef struct dvd_file_s dvd_file_t;
/**
- * dvd = DVDOpen(path);
- *
* Opens a block device of a DVD-ROM file, or an image file, or a directory
- * name for a mounted DVD or HD copy of a DVD. Returns 0 if we can't get any
- * of those methods to work.
+ * name for a mounted DVD or HD copy of a DVD.
*
* If the given file is a block device, or is the mountpoint for a block
* device, then that device is used for CSS authentication using libdvdcss.
* If no device is available, then no CSS authentication is performed,
* and we hope that the image is decrypted.
*
- * If the path given is a directory, then the files in that directory may be in
- * any one of these formats:
+ * If the path given is a directory, then the files in that directory may be
+ * in any one of these formats:
*
* path/VIDEO_TS/VTS_01_1.VOB
* path/video_ts/vts_01_1.vob
* path/VTS_01_1.VOB
* path/vts_01_1.vob
+ *
+ * @param path Specifies the the device, file or directory to be used.
+ * @return If successful a a read handle is returned. Otherwise 0 is returned.
+ *
+ * dvd = DVDOpen(path);
*/
dvd_reader_t *DVDOpen( const char * );
/**
- * DVDClose(dvd);
+ * Closes and cleans up the DVD reader object.
+ *
+ * You must close all open files before calling this function.
*
- * Closes and cleans up the DVD reader object. You must close all open files
- * before calling this function.
+ * @param dvd A read handle that should be closed.
+ *
+ * DVDClose(dvd);
*/
void DVDClose( dvd_reader_t * );
/**
- * INFO_FILE : VIDEO_TS.IFO (manager)
- * VTS_XX_0.IFO (title)
- *
- * INFO_BACKUP_FILE: VIDEO_TS.BUP (manager)
- * VTS_XX_0.BUP (title)
- *
- * MENU_VOBS : VIDEO_TS.VOB (manager)
- * VTS_XX_0.VOB (title)
- *
- * TITLE_VOBS : VTS_XX_[1-9].VOB (title)
- * All files in the title set are opened and
- * read as a single file.
+ *
*/
typedef enum {
- DVD_READ_INFO_FILE,
- DVD_READ_INFO_BACKUP_FILE,
- DVD_READ_MENU_VOBS,
- DVD_READ_TITLE_VOBS
+ DVD_READ_INFO_FILE, /**< VIDEO_TS.IFO or VTS_XX_0.IFO (title) */
+ DVD_READ_INFO_BACKUP_FILE, /**< VIDEO_TS.BUP or VTS_XX_0.BUP (title) */
+ DVD_READ_MENU_VOBS, /**< VIDEO_TS.VOB or VTS_XX_0.VOB (title) */
+ DVD_READ_TITLE_VOBS /**< VTS_XX_[1-9].VOB (title). All files in
+ the title set are opened and read as a
+ single file. */
} dvd_read_domain_t;
/**
- * dvd_file = DVDOpenFile(dvd, titlenum, domain);
+ * Opens a file on the DVD given the title number and domain.
*
- * Opens a file on the DVD given the title number and domain. If the title
- * number is 0, the video manager information is opened
- * (VIDEO_TS.[IFO,BUP,VOB]). Returns a file structure which may be used for
- * reads, or 0 if the file was not found.
- */
-dvd_file_t *DVDOpenFile( dvd_reader_t *, int,
- dvd_read_domain_t );
+ * If the title number is 0, the video manager information is opened
+ * (VIDEO_TS.[IFO,BUP,VOB]). Returns a file structure which may be
+ * used for reads, or 0 if the file was not found.
+ *
+ * @param dvd A dvd read handle.
+ * @param titlenum Which Video Title Set should be used, VIDEO_TS is 0.
+ * @param domain Which domain.
+ * @return If successful a a file read handle is returned, otherwise 0.
+ *
+ * dvd_file = DVDOpenFile(dvd, titlenum, domain); */
+dvd_file_t *DVDOpenFile( dvd_reader_t *, int, dvd_read_domain_t );
/**
- * DVDCloseFile(dvd_file);
- *
* Closes a file and frees the associated structure.
+ *
+ * @param dvd_file The file read handle to be closed.
+ *
+ * DVDCloseFile(dvd_file);
*/
void DVDCloseFile( dvd_file_t * );
/**
- * blocks_read = DVDReadBlocks(dvd_file, offset, block_count, data);
- *
* Reads block_count number of blocks from the file at the given block offset.
* Returns number of blocks read on success, -1 on error. This call is only
* for reading VOB data, and should not be used when reading the IFO files.
* When reading from an encrypted drive, blocks are decrypted using libdvdcss
* where required.
+ *
+ * @param dvd_file A file read handle.
+ * @param offset Block offset from the start of the file to start reading at.
+ * @param block_count Number of block to read.
+ * @param data Pointer to a buffer to write the data into.
+ * @return Returns number of blocks read on success, -1 on error.
+ *
+ * blocks_read = DVDReadBlocks(dvd_file, offset, block_count, data);
*/
ssize_t DVDReadBlocks( dvd_file_t *, int, size_t, unsigned char * );
/**
- * offset_set = DVDFileSeek(dvd_file, seek_offset);
- *
* Seek to the given position in the file. Returns the resulting position in
* bytes from the beginning of the file. The seek position is only used for
* byte reads from the file, the block read call always reads from the given
* offset.
+ *
+ * @param dvd_file A file read handle.
+ * @param seek_offset Byte offset from the start of the file to seek to.
+ * @return The resulting position in bytes from the beginning of the file.
+ *
+ * offset_set = DVDFileSeek(dvd_file, seek_offset);
*/
int DVDFileSeek( dvd_file_t *, int );
/**
- * bytes_read = DVDReadBytes(dvd_file, data, bytes);
- *
* Reads the given number of bytes from the file. This call can only be used
* on the information files, and may not be used for reading from a VOB. This
* reads from and increments the currrent seek position for the file.
+ *
+ * @param dvd_file A file read handle.
+ * @param data Pointer to a buffer to write the data into.
+ * @param bytes Number of bytes to read.
+ * @return Returns number of bytes read on success, -1 on error.
+ *
+ * bytes_read = DVDReadBytes(dvd_file, data, bytes);
*/
ssize_t DVDReadBytes( dvd_file_t *, void *, size_t );
/**
- * blocks = DVDFileSize(dvd_file);
- *
* Returns the file size in blocks.
+ *
+ * @param dvd_file A file read handle.
+ * @return The size of the file in blocks, -1 on error.
+ *
+ * blocks = DVDFileSize(dvd_file);
*/
ssize_t DVDFileSize( dvd_file_t * );
diff --git a/src/input/libdvdread/ifo_print.c b/src/input/libdvdread/ifo_print.c
index ab96f9373..8dc03acd5 100644
--- a/src/input/libdvdread/ifo_print.c
+++ b/src/input/libdvdread/ifo_print.c
@@ -71,7 +71,7 @@ static void ifoPrint_CMD(int row, vm_cmd_t *command) {
printf("%02x ", command->bytes[i]);
printf("| ");
- /* )vmcmd(command); */
+ /* vmcmd(command); */
printf("\n");
}
@@ -820,6 +820,27 @@ void ifoPrint_PTL_MAIT(ptl_mait_t *ptl_mait) {
}
}
+void ifoPrint_VTS_TMAPT(vts_tmapt_t *vts_tmapt) {
+ unsigned int timeunit;
+ int i, j;
+
+ printf("Number of VTS_TMAPS: %i\n", vts_tmapt->nr_of_tmaps);
+ //printf("Last byte: %i\n", vts_tmapt->last_byte);
+
+ for(i = 0; i < vts_tmapt->nr_of_tmaps; i++) {
+ printf("TMAP %i\n", i);
+ printf(" Time unit (seconds): %i\n", vts_tmapt->tmap[i].tmu);
+ printf(" Number of entries: %i\n", vts_tmapt->tmap[i].nr_of_entries);
+ timeunit = vts_tmapt->tmap[i].tmu;
+ for(j = 0; j < vts_tmapt->tmap[i].nr_of_entries; j++) {
+ unsigned int ac_time = timeunit * (j + 1);
+ printf("Time: %2i:%02i:%02i VOBU Sector: 0x%08x %s\n",
+ ac_time / (60 * 60), (ac_time / 60) % 60, ac_time % 60,
+ vts_tmapt->tmap[i].map_ent[j] & 0x7fffffff,
+ (vts_tmapt->tmap[i].map_ent[j] >> 31) ? "discontinuity" : "");
+ }
+ }
+}
void ifoPrint_C_ADT(c_adt_t *c_adt) {
int i, entries;
@@ -1018,6 +1039,14 @@ void ifoPrint(dvd_reader_t *dvd, int title) {
} else {
printf("No Menu PGCI Unit table present\n");
}
+
+ printf("\nTime Search table\n");
+ printf( "-----------------\n");
+ if(ifohandle->vts_tmapt) {
+ ifoPrint_VTS_TMAPT(ifohandle->vts_tmapt);
+ } else {
+ printf("No Time Search table present\n");
+ }
printf("\nMenu Cell Adress table\n");
printf( "-----------------\n");
diff --git a/src/input/libdvdread/ifo_print.h b/src/input/libdvdread/ifo_print.h
index bf0bed366..fa69e1511 100644
--- a/src/input/libdvdread/ifo_print.h
+++ b/src/input/libdvdread/ifo_print.h
@@ -49,6 +49,7 @@ void ifoPrint_VTS_PTT_SRPT(vts_ptt_srpt_t *);
void ifoPrint_PGC(pgc_t *);
void ifoPrint_PGCIT(pgcit_t *);
void ifoPrint_PGCI_UT(pgci_ut_t *);
+void ifoPrint_VTS_TMAPT(vts_tmapt_t *);
void ifoPrint_C_ADT(c_adt_t *);
void ifoPrint_VOBU_ADMAP(vobu_admap_t *);
diff --git a/src/input/libdvdread/ifo_read.c b/src/input/libdvdread/ifo_read.c
index e435e4ecd..6dd5d3d5d 100644
--- a/src/input/libdvdread/ifo_read.c
+++ b/src/input/libdvdread/ifo_read.c
@@ -19,7 +19,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
+
#include <inttypes.h>
#include <string.h>
#include <assert.h>
@@ -83,7 +83,7 @@ static void ifoFree_PGC_COMMAND_TBL(pgc_command_tbl_t *cmd_tbl);
static void ifoFree_PGCIT_internal(pgcit_t *pgcit);
-static int DVDFileSeek_( dvd_file_t *dvd_file, uint32_t offset ) {
+static inline int DVDFileSeek_( dvd_file_t *dvd_file, uint32_t offset ) {
return (DVDFileSeek(dvd_file, (int)offset) == (int)offset);
}
@@ -98,6 +98,8 @@ ifo_handle_t *ifoOpen(dvd_reader_t *dvd, int title) {
memset(ifofile, 0, sizeof(ifo_handle_t));
ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_FILE);
+ if(!ifofile->file) /* Should really catch any error and try to fallback */
+ ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_BACKUP_FILE);
if(!ifofile->file) {
if(title) {
fprintf(stderr, "libdvdread: Can't open file VTS_%02d_0.IFO.\n", title);
@@ -146,6 +148,7 @@ ifo_handle_t *ifoOpen(dvd_reader_t *dvd, int title) {
ifoRead_PGCI_UT(ifofile);
+ ifoRead_VTS_TMAPT(ifofile);
ifoRead_C_ADT(ifofile);
ifoRead_VOBU_ADMAP(ifofile);
@@ -180,6 +183,8 @@ ifo_handle_t *ifoOpenVMGI(dvd_reader_t *dvd) {
memset(ifofile, 0, sizeof(ifo_handle_t));
ifofile->file = DVDOpenFile(dvd, 0, DVD_READ_INFO_FILE);
+ if(!ifofile->file) /* Should really catch any error and try to fallback */
+ ifofile->file = DVDOpenFile(dvd, 0, DVD_READ_INFO_BACKUP_FILE);
if(!ifofile->file) {
fprintf(stderr, "libdvdread: Can't open file VIDEO_TS.IFO.\n");
free(ifofile);
@@ -211,6 +216,8 @@ ifo_handle_t *ifoOpenVTSI(dvd_reader_t *dvd, int title) {
}
ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_FILE);
+ if(!ifofile->file) /* Should really catch any error and try to fallback */
+ ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_BACKUP_FILE);
if(!ifofile->file) {
fprintf(stderr, "libdvdread: Can't open file VTS_%02d_0.IFO.\n", title);
free(ifofile);
@@ -1020,8 +1027,7 @@ int ifoRead_PTL_MAIT(ifo_handle_t *ifofile) {
if(ifofile->vmgi_mat->ptl_mait == 0)
return 1;
- if(!DVDFileSeek_(ifofile->file,
- ifofile->vmgi_mat->ptl_mait * DVD_BLOCK_LEN))
+ if(!DVDFileSeek_(ifofile->file, ifofile->vmgi_mat->ptl_mait * DVD_BLOCK_LEN))
return 0;
ptl_mait = (ptl_mait_t *)malloc(sizeof(ptl_mait_t));
@@ -1077,7 +1083,6 @@ int ifoRead_PTL_MAIT(ifo_handle_t *ifofile) {
return 1;
}
-
void ifoFree_PTL_MAIT(ifo_handle_t *ifofile) {
if(!ifofile)
return;
@@ -1089,6 +1094,137 @@ void ifoFree_PTL_MAIT(ifo_handle_t *ifofile) {
}
}
+int ifoRead_VTS_TMAPT(ifo_handle_t *ifofile) {
+ vts_tmapt_t *vts_tmapt;
+ uint32_t *vts_tmap_srp;
+ unsigned int offset;
+ int info_length;
+ unsigned int i, j;
+
+ if(!ifofile)
+ return 0;
+
+ if(!ifofile->vtsi_mat)
+ return 0;
+
+ if(ifofile->vtsi_mat->vts_tmapt == 0) { /* optional(?) */
+ ifofile->vts_tmapt = NULL;
+ return 1;
+ }
+
+ offset = ifofile->vtsi_mat->vts_tmapt * DVD_BLOCK_LEN;
+
+ if(!DVDFileSeek_(ifofile->file, offset))
+ return 0;
+
+ vts_tmapt = (vts_tmapt_t *)malloc(sizeof(vts_tmapt_t));
+ if(!vts_tmapt)
+ return 0;
+
+ ifofile->vts_tmapt = vts_tmapt;
+
+ if(!(DVDReadBytes(ifofile->file, vts_tmapt, VTS_TMAPT_SIZE))) {
+ fprintf(stderr, "libdvdread: Unable to read VTS_TMAPT.\n");
+ free(vts_tmapt);
+ ifofile->vts_tmapt = NULL;
+ return 0;
+ }
+
+ B2N_16(vts_tmapt->nr_of_tmaps);
+ B2N_32(vts_tmapt->last_byte);
+
+ CHECK_ZERO(vts_tmapt->zero_1);
+
+ info_length = vts_tmapt->nr_of_tmaps * 4;
+
+ vts_tmap_srp = (uint32_t *)malloc(info_length);
+ if(!vts_tmap_srp) {
+ free(vts_tmapt);
+ ifofile->vts_tmapt = NULL;
+ return 0;
+ }
+
+ if(!(DVDReadBytes(ifofile->file, vts_tmap_srp, info_length))) {
+ fprintf(stderr, "libdvdread: Unable to read VTS_TMAPT.\n");
+ free(vts_tmap_srp);
+ free(vts_tmapt);
+ ifofile->vts_tmapt = NULL;
+ return 0;
+ }
+
+ info_length = vts_tmapt->nr_of_tmaps * sizeof(vts_tmap_t);
+
+ vts_tmapt->tmap = (vts_tmap_t *)malloc(info_length);
+ if(!vts_tmapt->tmap) {
+ free(vts_tmap_srp);
+ free(vts_tmapt);
+ ifofile->vts_tmapt = NULL;
+ return 0;
+ }
+ memset(vts_tmapt->tmap, 0, info_length); /* So ifoFree_VTS_TMAPT works. */
+
+ for(i = 0; i < vts_tmapt->nr_of_tmaps; i++) {
+ if(!DVDFileSeek_(ifofile->file, offset + vts_tmap_srp[i])) {
+ free(vts_tmap_srp);
+ ifoFree_VTS_TMAPT(ifofile);
+ return 0;
+ }
+ if(!(DVDReadBytes(ifofile->file, &vts_tmapt->tmap[i], VTS_TMAP_SIZE))) {
+ fprintf(stderr, "libdvdread: Unable to read VTS_TMAP.\n");
+ free(vts_tmap_srp);
+ ifoFree_VTS_TMAPT(ifofile);
+ return 0;
+ }
+
+ B2N_16(vts_tmapt->tmap[i].nr_of_entries);
+ CHECK_ZERO(vts_tmapt->tmap[i].zero_1);
+
+ if(vts_tmapt->tmap[i].nr_of_entries == 0) { /* Early out if zero entries */
+ vts_tmapt->tmap[i].map_ent = NULL;
+ continue;
+ }
+
+ info_length = vts_tmapt->tmap[i].nr_of_entries * sizeof(map_ent_t);
+
+ vts_tmapt->tmap[i].map_ent = (map_ent_t *)malloc(info_length);
+ if(!vts_tmapt->tmap[i].map_ent) {
+ free(vts_tmap_srp);
+ ifoFree_VTS_TMAPT(ifofile);
+ return 0;
+ }
+
+ if(!(DVDReadBytes(ifofile->file, vts_tmapt->tmap[i].map_ent, info_length))) {
+ fprintf(stderr, "libdvdread: Unable to read VTS_TMAP_ENT.\n");
+ free(vts_tmap_srp);
+ ifoFree_VTS_TMAPT(ifofile);
+ return 0;
+ }
+
+ for(j = 0; j < vts_tmapt->tmap[i].nr_of_entries; j++)
+ B2N_32(vts_tmapt->tmap[i].map_ent[j]);
+ }
+ free(vts_tmap_srp);
+
+ return 1;
+}
+
+void ifoFree_VTS_TMAPT(ifo_handle_t *ifofile) {
+ unsigned int i;
+
+ if(!ifofile)
+ return;
+
+ if(ifofile->vts_tmapt) {
+ for(i = 0; i < ifofile->vts_tmapt->nr_of_tmaps; i++)
+ if(ifofile->vts_tmapt->tmap[i].map_ent)
+ free(ifofile->vts_tmapt->tmap[i].map_ent);
+ free(ifofile->vts_tmapt->tmap);
+ free(ifofile->vts_tmapt);
+ ifofile->vts_tmapt = NULL;
+ }
+}
+
+
int ifoRead_TITLE_C_ADT(ifo_handle_t *ifofile) {
if(!ifofile)
@@ -1655,17 +1791,6 @@ static int ifoRead_VTS_ATTRIBUTES(ifo_handle_t *ifofile,
return 1;
}
-void hexdump (uint8_t *buf, int size) {
- int i;
-
- for (i=0; i<size; i++) {
- printf ("%02x ", buf[i]);
- if ( (i%8)==7)
- printf ("\n");
- }
- printf ("\n");
-
-}
int ifoRead_VTS_ATRT(ifo_handle_t *ifofile) {
@@ -1698,8 +1823,6 @@ int ifoRead_VTS_ATRT(ifo_handle_t *ifofile) {
return 0;
}
- /* hexdump (vts_atrt, VTS_ATRT_SIZE); */
-
B2N_16(vts_atrt->nr_of_vtss);
B2N_32(vts_atrt->last_byte);
diff --git a/src/input/libdvdread/ifo_read.h b/src/input/libdvdread/ifo_read.h
index 508b672d2..588d075b8 100644
--- a/src/input/libdvdread/ifo_read.h
+++ b/src/input/libdvdread/ifo_read.h
@@ -137,7 +137,17 @@ int ifoRead_PGCIT(ifo_handle_t *);
* VTSI files, this fills the ifofile->vtsm_pgci_ut structure.
*/
int ifoRead_PGCI_UT(ifo_handle_t *);
-
+
+/**
+ * okay = ifoRead_VTS_TMAPT(ifofile);
+ *
+ * Reads in the VTS Time Map Table, this data is only located in the video
+ * title set information file. This fills the ifofile->vts_tmapt structure
+ * and all its substructures. When pressent enables VOBU level time-based
+ * seeking for One_Sequential_PGC_Titles.
+ */
+int ifoRead_VTS_TMAPT(ifo_handle_t *);
+
/**
* okay = ifoRead_C_ADT(ifofile);
*
@@ -205,6 +215,7 @@ void ifoFree_VTS_PTT_SRPT(ifo_handle_t *);
void ifoFree_FP_PGC(ifo_handle_t *);
void ifoFree_PGCIT(ifo_handle_t *);
void ifoFree_PGCI_UT(ifo_handle_t *);
+void ifoFree_VTS_TMAPT(ifo_handle_t *);
void ifoFree_C_ADT(ifo_handle_t *);
void ifoFree_TITLE_C_ADT(ifo_handle_t *);
void ifoFree_VOBU_ADMAP(ifo_handle_t *);
diff --git a/src/input/libdvdread/ifo_types.h b/src/input/libdvdread/ifo_types.h
index f424e64ab..c0b6f57ea 100644
--- a/src/input/libdvdread/ifo_types.h
+++ b/src/input/libdvdread/ifo_types.h
@@ -189,8 +189,8 @@ typedef struct {
unsigned int stc_discontinuity: 1;
unsigned int seamless_angle : 1;
- unsigned int unknown1 : 1;
- unsigned int restricted : 1;
+ unsigned int playback_mode : 1; /**< When set, enter StillMode after each VOBU */
+ unsigned int restricted : 1; /**< ?? drop out of fastforward? */
unsigned int unknown2 : 6;
#else
unsigned int seamless_angle : 1;
@@ -202,7 +202,7 @@ typedef struct {
unsigned int unknown2 : 6;
unsigned int restricted : 1;
- unsigned int unknown1 : 1;
+ unsigned int playback_mode : 1;
#endif
uint8_t still_time;
uint8_t cell_cmd_nr;
@@ -397,7 +397,7 @@ typedef struct {
uint16_t nr_of_vobs; /* VOBs */
uint16_t zero_1;
uint32_t last_byte;
- cell_adr_t *cell_adr_table;
+ cell_adr_t *cell_adr_table; /* No explicit size given. */
} ATTRIBUTE_PACKED c_adt_t;
#define C_ADT_SIZE 8
@@ -708,6 +708,35 @@ typedef struct {
#define VTS_PTT_SRPT_SIZE 8
+/**
+ * Time Map Entry.
+ */
+/* Should this be bit field at all or just the uint32_t? */
+typedef uint32_t map_ent_t;
+
+/**
+ * Time Map.
+ */
+typedef struct {
+ uint8_t tmu; /* Time unit, in seconds */
+ uint8_t zero_1;
+ uint16_t nr_of_entries;
+ map_ent_t *map_ent;
+} ATTRIBUTE_PACKED vts_tmap_t;
+#define VTS_TMAP_SIZE 4
+
+/**
+ * Time Map Table.
+ */
+typedef struct {
+ uint16_t nr_of_tmaps;
+ uint16_t zero_1;
+ uint32_t last_byte;
+ vts_tmap_t *tmap;
+} ATTRIBUTE_PACKED vts_tmapt_t;
+#define VTS_TMAPT_SIZE 8
+
+
#if PRAGMA_PACK
#pragma pack()
#endif
@@ -739,7 +768,7 @@ typedef struct {
vtsi_mat_t *vtsi_mat;
vts_ptt_srpt_t *vts_ptt_srpt;
pgcit_t *vts_pgcit;
- int *vts_tmapt; /* FIXME add/correct the type */
+ vts_tmapt_t *vts_tmapt;
c_adt_t *vts_c_adt;
vobu_admap_t *vts_vobu_admap;
} ifo_handle_t;
diff --git a/src/input/libdvdread/nav_print.h b/src/input/libdvdread/nav_print.h
index f0551a39b..35d4b09f0 100644
--- a/src/input/libdvdread/nav_print.h
+++ b/src/input/libdvdread/nav_print.h
@@ -2,8 +2,8 @@
#define NAV_PRINT_H_INCLUDED
/*
- * Copyright (C) 2001 Billy Biggs <vektor@dumbterm.net>,
- * Håkan Hjort <d95hjort@dtek.chalmers.se>
+ * Copyright (C) 2001, 2002 Billy Biggs <vektor@dumbterm.net>,
+ * Håkan Hjort <d95hjort@dtek.chalmers.se>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,17 +22,25 @@
#include "nav_types.h"
+/**
+ * Pretty printing of the NAV packets, PCI and DSI structs.
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
/**
* Prints information contained in the PCI to stdout.
+ *
+ * @param pci Pointer to the PCI data structure to be printed.
*/
void navPrint_PCI(pci_t *);
/**
* Prints information contained in the DSI to stdout.
+ *
+ * @param dsi Pointer to the DSI data structure to be printed.
*/
void navPrint_DSI(dsi_t *);
diff --git a/src/input/libdvdread/nav_read.h b/src/input/libdvdread/nav_read.h
index bd48d5ce6..2f41c920d 100644
--- a/src/input/libdvdread/nav_read.h
+++ b/src/input/libdvdread/nav_read.h
@@ -2,7 +2,7 @@
#define NAV_READ_H_INCLUDED
/*
- * Copyright (C) 2000, 2001 Håkan Hjort <d95hjort@dtek.chalmers.se>.
+ * Copyright (C) 2000, 2001, 2002 Håkan Hjort <d95hjort@dtek.chalmers.se>.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,17 +21,27 @@
#include "nav_types.h"
+/**
+ * Parsing of NAV data, PCI and DSI parts.
+ */
+
#ifdef __cplusplus
extern "C" {
#endif
/**
- * Reads the PCI packet data pointed to into pci struct.
- */
+ * Reads the PCI packet data pointed to into th pci struct.
+ *
+ * @param pci Pointer to the PCI data structure to be filled in.
+ * @param bufffer Pointer to the buffer of the on disc PCI data.
+ */
void navRead_PCI(pci_t *, unsigned char *);
/**
* Reads the DSI packet data pointed to into dsi struct.
+ *
+ * @param dsi Pointer to the DSI data structure to be filled in.
+ * @param bufffer Pointer to the buffer of the on disc DSI data.
*/
void navRead_DSI(dsi_t *, unsigned char *);
diff --git a/src/input/libdvdread/nav_types.h b/src/input/libdvdread/nav_types.h
index 2400bbd99..33bb6d559 100644
--- a/src/input/libdvdread/nav_types.h
+++ b/src/input/libdvdread/nav_types.h
@@ -2,7 +2,7 @@
#define NAV_TYPES_H_INCLUDED
/*
- * Copyright (C) 2000, 2001 Håkan Hjort <d95hjort@dtek.chalmers.se>
+ * Copyright (C) 2000, 2001, 2002 Håkan Hjort <d95hjort@dtek.chalmers.se>
*
* The data structures in this file should represent the layout of the
* pci and dsi packets as they are stored in the stream. Information
@@ -70,14 +70,14 @@
* PCI General Information
*/
typedef struct {
- uint32_t nv_pck_lbn;
- uint16_t vobu_cat;
- uint16_t zero1;
- user_ops_t vobu_uop_ctl;
- uint32_t vobu_s_ptm;
- uint32_t vobu_e_ptm;
- uint32_t vobu_se_e_ptm;
- dvd_time_t e_eltm;
+ uint32_t nv_pck_lbn; /**< sector address of this nav pack */
+ uint16_t vobu_cat; /**< 'category' of vobu */
+ uint16_t zero1; /**< reserved */
+ user_ops_t vobu_uop_ctl; /**< UOP of vobu */
+ uint32_t vobu_s_ptm; /**< start presentation time of vobu */
+ uint32_t vobu_e_ptm; /**< end presentation time of vobu */
+ uint32_t vobu_se_e_ptm; /**< end ptm of sequence end in vobu */
+ dvd_time_t e_eltm; /**< Cell elapsed time */
char vobu_isrc[32];
} ATTRIBUTE_PACKED pci_gi_t;
@@ -85,26 +85,26 @@ typedef struct {
* Non Seamless Angle Information
*/
typedef struct {
- uint32_t nsml_agl_dsta[9];
+ uint32_t nsml_agl_dsta[9]; /**< address of destination vobu in AGL_C#n */
} ATTRIBUTE_PACKED nsml_agli_t;
/**
* Highlight General Information
*/
typedef struct {
- uint16_t hli_ss; /* < only low 2 bits */
- uint32_t hli_s_ptm;
- uint32_t hli_e_ptm;
- uint32_t btn_se_e_ptm;
+ uint16_t hli_ss; /**< status, only low 2 bits 0: no, 1: different 2: equal 3: eual except for button cmds */
+ uint32_t hli_s_ptm; /**< start ptm of hli */
+ uint32_t hli_e_ptm; /**< end ptm of hli */
+ uint32_t btn_se_e_ptm; /**< end ptm of button select */
#ifdef WORDS_BIGENDIAN
- unsigned int zero1 : 2;
- unsigned int btngr_ns : 2;
- unsigned int zero2 : 1;
- unsigned int btngr1_dsp_ty : 3;
- unsigned int zero3 : 1;
- unsigned int btngr2_dsp_ty : 3;
- unsigned int zero4 : 1;
- unsigned int btngr3_dsp_ty : 3;
+ unsigned int zero1 : 2; /**< reserved */
+ unsigned int btngr_ns : 2; /**< number of button groups */
+ unsigned int zero2 : 1; /**< reserved */
+ unsigned int btngr1_dsp_ty : 3; /**< display type of subpic stream for button group 1 */
+ unsigned int zero3 : 1; /**< reserved */
+ unsigned int btngr2_dsp_ty : 3; /**< display type of subpic stream for button group 2 */
+ unsigned int zero4 : 1; /**< reserved */
+ unsigned int btngr3_dsp_ty : 3; /**< display type of subpic stream for button group 3 */
#else
unsigned int btngr1_dsp_ty : 3;
unsigned int zero2 : 1;
@@ -115,20 +115,25 @@ typedef struct {
unsigned int btngr2_dsp_ty : 3;
unsigned int zero3 : 1;
#endif
- uint8_t btn_ofn;
- uint8_t btn_ns; /* < only low 6 bits */
- uint8_t nsl_btn_ns; /* < only low 6 bits */
- uint8_t zero5;
- uint8_t fosl_btnn; /* < only low 6 bits */
- uint8_t foac_btnn; /* < only low 6 bits */
+ uint8_t btn_ofn; /**< button offset number */
+ uint8_t btn_ns; /**< number of valid buttons (low 6 bits) */
+ uint8_t nsl_btn_ns; /**< number of buttons selectable by U_BTNNi (low 6 bits) nsl_btn_ns <= btn_ns */
+ uint8_t zero5; /**< reserved */
+ uint8_t fosl_btnn; /**< forcedly selected button (low 6 bits) */
+ uint8_t foac_btnn; /**< forcedly activated button (low 6 bits) */
} ATTRIBUTE_PACKED hl_gi_t;
/**
* Button Color Information Table
+ * Each entry beeing a 32bit word that contains the color indexs and alpha
+ * values to use. They are all represented by 4 bit number and stored
+ * like this [Ci3, Ci2, Ci1, Ci0, A3, A2, A1, A0]. The actual palette
+ * that the indexes reference is in the PGC.
+ * @TODO split the uint32_t into a struct
*/
typedef struct {
- uint32_t btn_coli[3][2];
+ uint32_t btn_coli[3][2]; /**< [button color number-1][select:0/action:1] */
} ATTRIBUTE_PACKED btn_colit_t;
/**
@@ -136,23 +141,23 @@ typedef struct {
*/
typedef struct {
#ifdef WORDS_BIGENDIAN
- unsigned int btn_coln : 2;
- unsigned int x_start : 10;
- unsigned int zero1 : 2;
- unsigned int x_end : 10;
- unsigned int auto_action_mode : 2;
- unsigned int y_start : 10;
- unsigned int zero2 : 2;
- unsigned int y_end : 10;
-
- unsigned int zero3 : 2;
- unsigned int up : 6;
- unsigned int zero4 : 2;
- unsigned int down : 6;
- unsigned int zero5 : 2;
- unsigned int left : 6;
- unsigned int zero6 : 2;
- unsigned int right : 6;
+ unsigned int btn_coln : 2; /**< button color number */
+ unsigned int x_start : 10; /**< x start offset within the overlay */
+ unsigned int zero1 : 2; /**< reserved */
+ unsigned int x_end : 10; /**< x end offset within the overlay */
+ unsigned int auto_action_mode : 2; /**< 0: no, 1: activated if selected */
+ unsigned int y_start : 10; /**< y start offset within the overlay */
+ unsigned int zero2 : 2; /**< reserved */
+ unsigned int y_end : 10; /**< y end offset within the overlay */
+
+ unsigned int zero3 : 2; /**< reserved */
+ unsigned int up : 6; /**< button index when pressing up */
+ unsigned int zero4 : 2; /**< reserved */
+ unsigned int down : 6; /**< button index when pressing down */
+ unsigned int zero5 : 2; /**< reserved */
+ unsigned int left : 6; /**< button index when pressing left */
+ unsigned int zero6 : 2; /**< reserved */
+ unsigned int right : 6; /**< button index when pressing right */
#else
unsigned int x_end : 10;
unsigned int zero1 : 2;
@@ -202,27 +207,27 @@ typedef struct {
*/
typedef struct {
uint32_t nv_pck_scr;
- uint32_t nv_pck_lbn;
- uint32_t vobu_ea;
- uint32_t vobu_1stref_ea;
- uint32_t vobu_2ndref_ea;
- uint32_t vobu_3rdref_ea;
- uint16_t vobu_vob_idn;
- uint8_t zero1;
- uint8_t vobu_c_idn;
- dvd_time_t c_eltm;
+ uint32_t nv_pck_lbn; /**< sector address of this nav pack */
+ uint32_t vobu_ea; /**< end address of this VOBU */
+ uint32_t vobu_1stref_ea; /**< end address of the 1st reference image */
+ uint32_t vobu_2ndref_ea; /**< end address of the 2nd reference image */
+ uint32_t vobu_3rdref_ea; /**< end address of the 3rd reference image */
+ uint16_t vobu_vob_idn; /**< VOB Id number that this VOBU is part of */
+ uint8_t zero1; /**< reserved */
+ uint8_t vobu_c_idn; /**< Cell Id number that this VOBU is part of */
+ dvd_time_t c_eltm; /**< Cell elapsed time */
} ATTRIBUTE_PACKED dsi_gi_t;
/**
* Seamless Playback Information
*/
typedef struct {
- uint16_t category; /* category of seamless VOBU */
- uint32_t ilvu_ea; /* end address of interleaved Unit (sectors) */
- uint32_t ilvu_sa; /* start address of next interleaved unit (sectors) */
- uint16_t size; /* size of next interleaved unit (sectors) */
- uint32_t vob_v_s_s_ptm; /* video start ptm in vob */
- uint32_t vob_v_e_e_ptm; /* video end ptm in vob */
+ uint16_t category; /**< 'category' of seamless VOBU */
+ uint32_t ilvu_ea; /**< end address of interleaved Unit */
+ uint32_t ilvu_sa; /**< start address of next interleaved unit */
+ uint16_t size; /**< size of next interleaved unit */
+ uint32_t vob_v_s_s_ptm; /**< video start ptm in vob */
+ uint32_t vob_v_e_e_ptm; /**< video end ptm in vob */
struct {
uint32_t stp_ptm1;
uint32_t stp_ptm2;
@@ -235,8 +240,8 @@ typedef struct {
* Seamless Angle Infromation for one angle
*/
typedef struct {
- uint32_t address; /* Sector offset to next ILVU, high bit is before/after */
- uint16_t size; /* Byte size of the ILVU poited to by address. */
+ uint32_t address; /**< offset to next ILVU, high bit is before/after */
+ uint16_t size; /**< byte size of the ILVU pointed to by address */
} ATTRIBUTE_PACKED sml_agl_data_t;
/**
@@ -250,11 +255,11 @@ typedef struct {
* VOBU Search Information
*/
typedef struct {
- uint32_t next_video; /* Next vobu that contains video */
- uint32_t fwda[19]; /* Forwards, time */
+ uint32_t next_video; /**< Next vobu that contains video */
+ uint32_t fwda[19]; /**< Forwards, time */
uint32_t next_vobu;
uint32_t prev_vobu;
- uint32_t bwda[19]; /* Backwards, time */
+ uint32_t bwda[19]; /**< Backwards, time */
uint32_t prev_video;
} ATTRIBUTE_PACKED vobu_sri_t;
@@ -264,8 +269,8 @@ typedef struct {
* Synchronous Information
*/
typedef struct {
- uint16_t a_synca[8]; /* Sector offset to first audio packet for this VOBU */
- uint32_t sp_synca[32]; /* Sector offset to first subpicture packet */
+ uint16_t a_synca[8]; /**< offset to first audio packet for this VOBU */
+ uint32_t sp_synca[32]; /**< offset to first subpicture packet */
} ATTRIBUTE_PACKED synci_t;
/**