Mercurial > mplayer.hg
annotate libdvdread/ifo_read.c @ 27859:6aeb7cc0bba2
Intialize unused fd variables to -1 (which is actually invalid) instead
of 0 (which is stdin and can cause weird side-effects).
author | reimar |
---|---|
date | Tue, 04 Nov 2008 18:44:14 +0000 |
parents | ea01824701a5 |
children |
rev | line source |
---|---|
27466
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1 /* -*- c-basic-offset: 2; indent-tabs-mode: nil -*- */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2 /* |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
3 * Copyright (C) 2000, 2001, 2002, 2003 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
4 * Björn Englund <d4bjorn@dtek.chalmers.se>, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
5 * Håkan Hjort <d95hjort@dtek.chalmers.se> |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
6 * |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
7 * Modified for use with MPlayer, changes contained in libdvdread_changes.diff. |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
8 * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
9 * $Id$ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
10 * |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
11 * This program is free software; you can redistribute it and/or modify |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
12 * it under the terms of the GNU General Public License as published by |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
13 * the Free Software Foundation; either version 2 of the License, or |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
14 * (at your option) any later version. |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
15 * |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
16 * This program is distributed in the hope that it will be useful, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
19 * GNU General Public License for more details. |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
20 * |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
21 * You should have received a copy of the GNU General Public License |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
22 * along with this program; if not, write to the Free Software |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
24 */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
25 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
26 #include "config.h" |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
27 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
28 #include <stdio.h> |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
29 #include <stdlib.h> |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
30 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
31 #if defined(HAVE_INTTYPES_H) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
32 #include <inttypes.h> |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
33 #elif defined(HAVE_STDINT_H) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
34 #include <stdint.h> |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
35 #endif |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
36 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
37 #include <string.h> |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
38 #include <errno.h> |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
39 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
40 #include "bswap.h" |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
41 #include "ifo_types.h" |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
42 #include "ifo_read.h" |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
43 #include "dvd_reader.h" |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
44 #include "dvdread_internal.h" |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
45 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
46 #ifndef DVD_BLOCK_LEN |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
47 #define DVD_BLOCK_LEN 2048 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
48 #endif |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
49 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
50 #ifndef NDEBUG |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
51 #define CHECK_ZERO0(arg) \ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
52 if(arg != 0) { \ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
53 fprintf(stderr, "*** Zero check failed in %s:%i\n for %s = 0x%x\n", \ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
54 __FILE__, __LINE__, # arg, arg); \ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
55 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
56 #define CHECK_ZERO(arg) \ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
57 if(memcmp(my_friendly_zeros, &arg, sizeof(arg))) { \ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
58 unsigned int i_CZ; \ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
59 fprintf(stderr, "*** Zero check failed in %s:%i\n for %s = 0x", \ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
60 __FILE__, __LINE__, # arg ); \ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
61 for(i_CZ = 0; i_CZ < sizeof(arg); i_CZ++) \ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
62 fprintf(stderr, "%02x", *((uint8_t *)&arg + i_CZ)); \ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
63 fprintf(stderr, "\n"); \ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
64 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
65 static const uint8_t my_friendly_zeros[2048]; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
66 #else |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
67 #define CHECK_ZERO0(arg) (void)(arg) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
68 #define CHECK_ZERO(arg) (void)(arg) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
69 #endif |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
70 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
71 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
72 /* Prototypes for internal functions */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
73 static int ifoRead_VMG(ifo_handle_t *ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
74 static int ifoRead_VTS(ifo_handle_t *ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
75 static int ifoRead_PGC(ifo_handle_t *ifofile, pgc_t *pgc, unsigned int offset); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
76 static int ifoRead_PGC_COMMAND_TBL(ifo_handle_t *ifofile, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
77 pgc_command_tbl_t *cmd_tbl, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
78 unsigned int offset); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
79 static int ifoRead_PGC_PROGRAM_MAP(ifo_handle_t *ifofile, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
80 pgc_program_map_t *program_map, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
81 unsigned int nr, unsigned int offset); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
82 static int ifoRead_CELL_PLAYBACK_TBL(ifo_handle_t *ifofile, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
83 cell_playback_t *cell_playback, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
84 unsigned int nr, unsigned int offset); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
85 static int ifoRead_CELL_POSITION_TBL(ifo_handle_t *ifofile, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
86 cell_position_t *cell_position, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
87 unsigned int nr, unsigned int offset); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
88 static int ifoRead_VTS_ATTRIBUTES(ifo_handle_t *ifofile, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
89 vts_attributes_t *vts_attributes, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
90 unsigned int offset); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
91 static int ifoRead_C_ADT_internal(ifo_handle_t *ifofile, c_adt_t *c_adt, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
92 unsigned int sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
93 static int ifoRead_VOBU_ADMAP_internal(ifo_handle_t *ifofile, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
94 vobu_admap_t *vobu_admap, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
95 unsigned int sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
96 static int ifoRead_PGCIT_internal(ifo_handle_t *ifofile, pgcit_t *pgcit, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
97 unsigned int offset); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
98 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
99 static void ifoFree_PGC(pgc_t *pgc); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
100 static void ifoFree_PGC_COMMAND_TBL(pgc_command_tbl_t *cmd_tbl); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
101 static void ifoFree_PGCIT_internal(pgcit_t *pgcit); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
102 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
103 static ifo_handle_t *ifoOpen_File(ifo_handle_t *ifofile, int title, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
104 char *suffix); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
105 static ifo_handle_t *ifoOpenVMGI_File(ifo_handle_t *ifofile, char *suffix); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
106 static ifo_handle_t *ifoOpenVTSI_File(ifo_handle_t *ifofile, int title, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
107 char *suffix); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
108 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
109 static inline int DVDFileSeek_( dvd_file_t *dvd_file, uint32_t offset ) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
110 return (DVDFileSeek(dvd_file, (int)offset) == (int)offset); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
111 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
112 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
113 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
114 ifo_handle_t *ifoOpen(dvd_reader_t *dvd, int title) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
115 ifo_handle_t *ifofile; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
116 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
117 ifofile = malloc(sizeof(ifo_handle_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
118 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
119 return NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
120 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
121 memset(ifofile, 0, sizeof(ifo_handle_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
122 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
123 ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_FILE); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
124 if(!ifoOpen_File(ifofile, title, "IFO")) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
125 if(title) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
126 if(dvdread_verbose(dvd) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
127 fprintf(stderr, "libdvdread: Can't open file VTS_%02d_0.%s.\n", |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
128 title, "IFO"); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
129 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
130 } else { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
131 if(dvdread_verbose(dvd) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
132 fprintf(stderr, "libdvdread: Can't open file VIDEO_TS.%s.\n", "IFO"); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
133 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
134 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
135 /* lower functions free the pointer, reallocate */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
136 ifofile = (ifo_handle_t *)malloc(sizeof(ifo_handle_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
137 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
138 return NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
139 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
140 memset(ifofile, 0, sizeof(ifo_handle_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
141 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
142 ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_BACKUP_FILE); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
143 if(!ifoOpen_File(ifofile, title, "BUP")) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
144 if(title) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
145 if(dvdread_verbose(dvd) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
146 fprintf(stderr, "libdvdread: Can't open file VTS_%02d_0.%s.\n", |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
147 title, "BUP"); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
148 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
149 } else { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
150 if(dvdread_verbose(dvd) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
151 fprintf(stderr, "libdvdread: Can't open file VIDEO_TS.%s.\n", "BUP"); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
152 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
153 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
154 return NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
155 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
156 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
157 return ifofile; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
158 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
159 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
160 static ifo_handle_t *ifoOpen_File(ifo_handle_t *ifofile, int title, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
161 char *suffix) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
162 if(!ifofile->file) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
163 free(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
164 return NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
165 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
166 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
167 /* First check if this is a VMGI file. */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
168 if(ifoRead_VMG(ifofile)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
169 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
170 /* These are both mandatory. */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
171 if(!ifoRead_FP_PGC(ifofile) || !ifoRead_TT_SRPT(ifofile)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
172 if(dvdread_verbose(device_of_file(ifofile->file)) >= 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
173 fprintf(stderr, "libdvdread: Invalid main menu IFO (VIDEO_TS.%s).\n", |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
174 suffix); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
175 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
176 ifoClose(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
177 return NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
178 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
179 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
180 ifoRead_PGCI_UT(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
181 ifoRead_PTL_MAIT(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
182 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
183 /* This is also mandatory. */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
184 if(!ifoRead_VTS_ATRT(ifofile)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
185 if(dvdread_verbose(device_of_file(ifofile->file)) >= 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
186 fprintf(stderr, "libdvdread: Invalid main menu IFO (VIDEO_TS.%s).\n", |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
187 suffix); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
188 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
189 ifoClose(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
190 return NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
191 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
192 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
193 ifoRead_TXTDT_MGI(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
194 ifoRead_C_ADT(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
195 ifoRead_VOBU_ADMAP(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
196 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
197 return ifofile; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
198 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
199 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
200 if(ifoRead_VTS(ifofile)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
201 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
202 if(!ifoRead_VTS_PTT_SRPT(ifofile) || !ifoRead_PGCIT(ifofile)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
203 if(dvdread_verbose(device_of_file(ifofile->file)) >= 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
204 fprintf(stderr, "libdvdread: Invalid title IFO (VTS_%02d_0.%s).\n", |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
205 title, suffix); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
206 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
207 ifoClose(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
208 return NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
209 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
210 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
211 ifoRead_PGCI_UT(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
212 ifoRead_VTS_TMAPT(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
213 ifoRead_C_ADT(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
214 ifoRead_VOBU_ADMAP(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
215 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
216 if(!ifoRead_TITLE_C_ADT(ifofile) || !ifoRead_TITLE_VOBU_ADMAP(ifofile)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
217 if(dvdread_verbose(device_of_file(ifofile->file)) >= 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
218 fprintf(stderr, "libdvdread: Invalid title IFO (VTS_%02d_0.%s).\n", |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
219 title, suffix); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
220 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
221 ifoClose(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
222 return NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
223 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
224 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
225 return ifofile; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
226 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
227 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
228 if(title) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
229 if(dvdread_verbose(device_of_file(ifofile->file)) >= 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
230 fprintf(stderr, "libdvdread: Invalid IFO for title %d (VTS_%02d_0.%s).\n", |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
231 title, title, suffix); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
232 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
233 } else { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
234 if(dvdread_verbose(device_of_file(ifofile->file)) >= 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
235 fprintf(stderr, "libdvdread: Invalid IFO for VMGM (VIDEO_TS.%s).\n", |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
236 suffix); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
237 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
238 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
239 ifoClose(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
240 return NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
241 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
242 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
243 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
244 ifo_handle_t *ifoOpenVMGI(dvd_reader_t *dvd) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
245 ifo_handle_t *ifofile; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
246 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
247 ifofile = malloc(sizeof(ifo_handle_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
248 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
249 return NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
250 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
251 memset(ifofile, 0, sizeof(ifo_handle_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
252 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
253 ifofile->file = DVDOpenFile(dvd, 0, DVD_READ_INFO_FILE); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
254 if(!ifoOpenVMGI_File(ifofile, "IFO")) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
255 if(dvdread_verbose(dvd) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
256 fprintf(stderr, "libdvdread: Can't open file VIDEO_TS.IFO: %s\n", |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
257 strerror(errno)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
258 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
259 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
260 /* lower functions free the pointer, reallocate */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
261 ifofile = (ifo_handle_t *)malloc(sizeof(ifo_handle_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
262 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
263 return NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
264 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
265 memset(ifofile, 0, sizeof(ifo_handle_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
266 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
267 ifofile->file = DVDOpenFile(dvd, 0, DVD_READ_INFO_BACKUP_FILE); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
268 if(!ifoOpenVMGI_File(ifofile, "BUP")) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
269 if(dvdread_verbose(dvd) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
270 fprintf(stderr, "libdvdread: Can't open file VIDEO_TS.BUP: %s\n", |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
271 strerror(errno)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
272 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
273 return NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
274 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
275 return ifofile; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
276 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
277 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
278 static ifo_handle_t *ifoOpenVMGI_File(ifo_handle_t *ifofile, char *suffix) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
279 if(!ifofile->file) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
280 free(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
281 return NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
282 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
283 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
284 if(ifoRead_VMG(ifofile)) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
285 return ifofile; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
286 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
287 if(dvdread_verbose(device_of_file(ifofile->file)) >= 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
288 fprintf(stderr, "libdvdread: Invalid main menu IFO (VIDEO_TS.%s).\n", |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
289 suffix); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
290 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
291 ifoClose(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
292 return NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
293 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
294 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
295 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
296 ifo_handle_t *ifoOpenVTSI(dvd_reader_t *dvd, int title) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
297 ifo_handle_t *ifofile; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
298 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
299 ifofile = malloc(sizeof(ifo_handle_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
300 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
301 return NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
302 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
303 memset(ifofile, 0, sizeof(ifo_handle_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
304 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
305 if(title <= 0 || title > 99) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
306 if(dvdread_verbose(dvd) >= 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
307 fprintf(stderr, "libdvdread: ifoOpenVTSI invalid title (%d).\n", title); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
308 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
309 free(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
310 errno = EINVAL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
311 return NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
312 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
313 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
314 ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_FILE); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
315 if(!ifoOpenVTSI_File(ifofile, title, "IFO")) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
316 if(dvdread_verbose(dvd) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
317 fprintf(stderr, "libdvdread: Can't open file VTS_%02d_0.%s.\n", title, "IFO"); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
318 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
319 /* lower functions free the pointer, reallocate */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
320 ifofile = (ifo_handle_t *)malloc(sizeof(ifo_handle_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
321 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
322 return NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
323 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
324 memset(ifofile, 0, sizeof(ifo_handle_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
325 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
326 ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_BACKUP_FILE); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
327 if(!ifoOpenVTSI_File(ifofile, title, "BUP")) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
328 if(dvdread_verbose(dvd) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
329 fprintf(stderr, "libdvdread: Can't open file VTS_%02d_0.%s.\n", title, "BUP"); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
330 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
331 return NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
332 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
333 return ifofile; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
334 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
335 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
336 static ifo_handle_t *ifoOpenVTSI_File(ifo_handle_t* ifofile, int title, char *suffix) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
337 if(!ifofile->file) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
338 free(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
339 return NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
340 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
341 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
342 ifoRead_VTS(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
343 if(ifofile->vtsi_mat) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
344 return ifofile; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
345 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
346 if(dvdread_verbose(device_of_file(ifofile->file)) >= 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
347 fprintf(stderr, "libdvdread: Invalid IFO for title %d (VTS_%02d_0.%s).\n", |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
348 title, title, suffix); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
349 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
350 ifoClose(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
351 return NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
352 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
353 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
354 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
355 void ifoClose(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
356 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
357 return; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
358 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
359 ifoFree_VOBU_ADMAP(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
360 ifoFree_TITLE_VOBU_ADMAP(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
361 ifoFree_C_ADT(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
362 ifoFree_TITLE_C_ADT(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
363 ifoFree_TXTDT_MGI(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
364 ifoFree_VTS_ATRT(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
365 ifoFree_PTL_MAIT(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
366 ifoFree_PGCI_UT(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
367 ifoFree_TT_SRPT(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
368 ifoFree_FP_PGC(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
369 ifoFree_PGCIT(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
370 ifoFree_VTS_PTT_SRPT(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
371 ifoFree_VTS_TMAPT(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
372 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
373 if(ifofile->vmgi_mat) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
374 free(ifofile->vmgi_mat); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
375 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
376 if(ifofile->vtsi_mat) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
377 free(ifofile->vtsi_mat); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
378 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
379 DVDCloseFile(ifofile->file); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
380 ifofile->file = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
381 free(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
382 ifofile = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
383 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
384 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
385 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
386 static int ifoRead_VMG(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
387 vmgi_mat_t *vmgi_mat; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
388 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
389 vmgi_mat = malloc(sizeof(vmgi_mat_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
390 if(!vmgi_mat) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
391 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
392 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
393 ifofile->vmgi_mat = vmgi_mat; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
394 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
395 if(!DVDFileSeek_(ifofile->file, 0)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
396 free(ifofile->vmgi_mat); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
397 ifofile->vmgi_mat = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
398 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
399 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
400 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
401 if(!DVDReadBytes(ifofile->file, vmgi_mat, sizeof(vmgi_mat_t))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
402 free(ifofile->vmgi_mat); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
403 ifofile->vmgi_mat = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
404 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
405 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
406 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
407 if(strncmp("DVDVIDEO-VMG", vmgi_mat->vmg_identifier, 12) != 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
408 free(ifofile->vmgi_mat); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
409 ifofile->vmgi_mat = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
410 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
411 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
412 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
413 B2N_32(vmgi_mat->vmg_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
414 B2N_32(vmgi_mat->vmgi_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
415 B2N_32(vmgi_mat->vmg_category); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
416 B2N_16(vmgi_mat->vmg_nr_of_volumes); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
417 B2N_16(vmgi_mat->vmg_this_volume_nr); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
418 B2N_16(vmgi_mat->vmg_nr_of_title_sets); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
419 B2N_64(vmgi_mat->vmg_pos_code); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
420 B2N_32(vmgi_mat->vmgi_last_byte); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
421 B2N_32(vmgi_mat->first_play_pgc); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
422 B2N_32(vmgi_mat->vmgm_vobs); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
423 B2N_32(vmgi_mat->tt_srpt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
424 B2N_32(vmgi_mat->vmgm_pgci_ut); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
425 B2N_32(vmgi_mat->ptl_mait); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
426 B2N_32(vmgi_mat->vts_atrt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
427 B2N_32(vmgi_mat->txtdt_mgi); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
428 B2N_32(vmgi_mat->vmgm_c_adt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
429 B2N_32(vmgi_mat->vmgm_vobu_admap); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
430 B2N_16(vmgi_mat->vmgm_audio_attr.lang_code); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
431 B2N_16(vmgi_mat->vmgm_subp_attr.lang_code); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
432 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
433 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
434 CHECK_ZERO(vmgi_mat->zero_1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
435 CHECK_ZERO(vmgi_mat->zero_2); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
436 CHECK_ZERO(vmgi_mat->zero_3); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
437 CHECK_ZERO(vmgi_mat->zero_4); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
438 CHECK_ZERO(vmgi_mat->zero_5); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
439 CHECK_ZERO(vmgi_mat->zero_6); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
440 CHECK_ZERO(vmgi_mat->zero_7); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
441 CHECK_ZERO(vmgi_mat->zero_8); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
442 CHECK_ZERO(vmgi_mat->zero_9); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
443 CHECK_ZERO(vmgi_mat->zero_10); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
444 CHECK_VALUE(vmgi_mat->vmg_last_sector != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
445 CHECK_VALUE(vmgi_mat->vmgi_last_sector != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
446 CHECK_VALUE(vmgi_mat->vmgi_last_sector * 2 <= vmgi_mat->vmg_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
447 CHECK_VALUE(vmgi_mat->vmgi_last_sector * 2 <= vmgi_mat->vmg_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
448 CHECK_VALUE(vmgi_mat->vmg_nr_of_volumes != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
449 CHECK_VALUE(vmgi_mat->vmg_this_volume_nr != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
450 CHECK_VALUE(vmgi_mat->vmg_this_volume_nr <= vmgi_mat->vmg_nr_of_volumes); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
451 CHECK_VALUE(vmgi_mat->disc_side == 1 || vmgi_mat->disc_side == 2); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
452 CHECK_VALUE(vmgi_mat->vmg_nr_of_title_sets != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
453 CHECK_VALUE(vmgi_mat->vmgi_last_byte >= 341); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
454 CHECK_VALUE(vmgi_mat->vmgi_last_byte / DVD_BLOCK_LEN <= |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
455 vmgi_mat->vmgi_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
456 /* It seems that first_play_pgc is optional. */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
457 CHECK_VALUE(vmgi_mat->first_play_pgc < vmgi_mat->vmgi_last_byte); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
458 CHECK_VALUE(vmgi_mat->vmgm_vobs == 0 || |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
459 (vmgi_mat->vmgm_vobs > vmgi_mat->vmgi_last_sector && |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
460 vmgi_mat->vmgm_vobs < vmgi_mat->vmg_last_sector)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
461 CHECK_VALUE(vmgi_mat->tt_srpt <= vmgi_mat->vmgi_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
462 CHECK_VALUE(vmgi_mat->vmgm_pgci_ut <= vmgi_mat->vmgi_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
463 CHECK_VALUE(vmgi_mat->ptl_mait <= vmgi_mat->vmgi_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
464 CHECK_VALUE(vmgi_mat->vts_atrt <= vmgi_mat->vmgi_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
465 CHECK_VALUE(vmgi_mat->txtdt_mgi <= vmgi_mat->vmgi_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
466 CHECK_VALUE(vmgi_mat->vmgm_c_adt <= vmgi_mat->vmgi_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
467 CHECK_VALUE(vmgi_mat->vmgm_vobu_admap <= vmgi_mat->vmgi_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
468 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
469 CHECK_VALUE(vmgi_mat->nr_of_vmgm_audio_streams <= 1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
470 CHECK_VALUE(vmgi_mat->nr_of_vmgm_subp_streams <= 1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
471 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
472 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
473 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
474 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
475 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
476 static int ifoRead_VTS(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
477 vtsi_mat_t *vtsi_mat; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
478 int i; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
479 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
480 vtsi_mat = malloc(sizeof(vtsi_mat_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
481 if(!vtsi_mat) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
482 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
483 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
484 ifofile->vtsi_mat = vtsi_mat; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
485 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
486 if(!DVDFileSeek_(ifofile->file, 0)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
487 free(ifofile->vtsi_mat); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
488 ifofile->vtsi_mat = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
489 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
490 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
491 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
492 if(!(DVDReadBytes(ifofile->file, vtsi_mat, sizeof(vtsi_mat_t)))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
493 free(ifofile->vtsi_mat); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
494 ifofile->vtsi_mat = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
495 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
496 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
497 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
498 if(strncmp("DVDVIDEO-VTS", vtsi_mat->vts_identifier, 12) != 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
499 free(ifofile->vtsi_mat); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
500 ifofile->vtsi_mat = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
501 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
502 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
503 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
504 B2N_32(vtsi_mat->vts_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
505 B2N_32(vtsi_mat->vtsi_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
506 B2N_32(vtsi_mat->vts_category); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
507 B2N_32(vtsi_mat->vtsi_last_byte); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
508 B2N_32(vtsi_mat->vtsm_vobs); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
509 B2N_32(vtsi_mat->vtstt_vobs); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
510 B2N_32(vtsi_mat->vts_ptt_srpt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
511 B2N_32(vtsi_mat->vts_pgcit); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
512 B2N_32(vtsi_mat->vtsm_pgci_ut); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
513 B2N_32(vtsi_mat->vts_tmapt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
514 B2N_32(vtsi_mat->vtsm_c_adt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
515 B2N_32(vtsi_mat->vtsm_vobu_admap); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
516 B2N_32(vtsi_mat->vts_c_adt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
517 B2N_32(vtsi_mat->vts_vobu_admap); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
518 B2N_16(vtsi_mat->vtsm_audio_attr.lang_code); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
519 B2N_16(vtsi_mat->vtsm_subp_attr.lang_code); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
520 for(i = 0; i < 8; i++) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
521 B2N_16(vtsi_mat->vts_audio_attr[i].lang_code); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
522 for(i = 0; i < 32; i++) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
523 B2N_16(vtsi_mat->vts_subp_attr[i].lang_code); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
524 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
525 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
526 CHECK_ZERO(vtsi_mat->zero_1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
527 CHECK_ZERO(vtsi_mat->zero_2); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
528 CHECK_ZERO(vtsi_mat->zero_3); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
529 CHECK_ZERO(vtsi_mat->zero_4); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
530 CHECK_ZERO(vtsi_mat->zero_5); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
531 CHECK_ZERO(vtsi_mat->zero_6); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
532 CHECK_ZERO(vtsi_mat->zero_7); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
533 CHECK_ZERO(vtsi_mat->zero_8); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
534 CHECK_ZERO(vtsi_mat->zero_9); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
535 CHECK_ZERO(vtsi_mat->zero_10); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
536 CHECK_ZERO(vtsi_mat->zero_11); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
537 CHECK_ZERO(vtsi_mat->zero_12); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
538 CHECK_ZERO(vtsi_mat->zero_13); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
539 CHECK_ZERO(vtsi_mat->zero_14); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
540 CHECK_ZERO(vtsi_mat->zero_15); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
541 CHECK_ZERO(vtsi_mat->zero_16); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
542 CHECK_ZERO(vtsi_mat->zero_17); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
543 CHECK_ZERO(vtsi_mat->zero_18); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
544 CHECK_ZERO(vtsi_mat->zero_19); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
545 CHECK_ZERO(vtsi_mat->zero_20); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
546 CHECK_ZERO(vtsi_mat->zero_21); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
547 CHECK_VALUE(vtsi_mat->vtsi_last_sector*2 <= vtsi_mat->vts_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
548 CHECK_VALUE(vtsi_mat->vtsi_last_byte/DVD_BLOCK_LEN <= vtsi_mat->vtsi_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
549 CHECK_VALUE(vtsi_mat->vtsm_vobs == 0 || |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
550 (vtsi_mat->vtsm_vobs > vtsi_mat->vtsi_last_sector && |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
551 vtsi_mat->vtsm_vobs < vtsi_mat->vts_last_sector)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
552 CHECK_VALUE(vtsi_mat->vtstt_vobs == 0 || |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
553 (vtsi_mat->vtstt_vobs > vtsi_mat->vtsi_last_sector && |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
554 vtsi_mat->vtstt_vobs < vtsi_mat->vts_last_sector)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
555 CHECK_VALUE(vtsi_mat->vts_ptt_srpt <= vtsi_mat->vtsi_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
556 CHECK_VALUE(vtsi_mat->vts_pgcit <= vtsi_mat->vtsi_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
557 CHECK_VALUE(vtsi_mat->vtsm_pgci_ut <= vtsi_mat->vtsi_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
558 CHECK_VALUE(vtsi_mat->vts_tmapt <= vtsi_mat->vtsi_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
559 CHECK_VALUE(vtsi_mat->vtsm_c_adt <= vtsi_mat->vtsi_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
560 CHECK_VALUE(vtsi_mat->vtsm_vobu_admap <= vtsi_mat->vtsi_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
561 CHECK_VALUE(vtsi_mat->vts_c_adt <= vtsi_mat->vtsi_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
562 CHECK_VALUE(vtsi_mat->vts_vobu_admap <= vtsi_mat->vtsi_last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
563 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
564 CHECK_VALUE(vtsi_mat->nr_of_vtsm_audio_streams <= 1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
565 CHECK_VALUE(vtsi_mat->nr_of_vtsm_subp_streams <= 1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
566 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
567 CHECK_VALUE(vtsi_mat->nr_of_vts_audio_streams <= 8); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
568 for(i = vtsi_mat->nr_of_vts_audio_streams; i < 8; i++) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
569 CHECK_ZERO(vtsi_mat->vts_audio_attr[i]); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
570 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
571 CHECK_VALUE(vtsi_mat->nr_of_vts_subp_streams <= 32); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
572 for(i = vtsi_mat->nr_of_vts_subp_streams; i < 32; i++) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
573 CHECK_ZERO(vtsi_mat->vts_subp_attr[i]); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
574 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
575 for(i = 0; i < 8; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
576 CHECK_ZERO0(vtsi_mat->vts_mu_audio_attr[i].zero1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
577 CHECK_ZERO0(vtsi_mat->vts_mu_audio_attr[i].zero2); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
578 CHECK_ZERO0(vtsi_mat->vts_mu_audio_attr[i].zero3); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
579 CHECK_ZERO0(vtsi_mat->vts_mu_audio_attr[i].zero4); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
580 CHECK_ZERO0(vtsi_mat->vts_mu_audio_attr[i].zero5); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
581 CHECK_ZERO(vtsi_mat->vts_mu_audio_attr[i].zero6); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
582 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
583 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
584 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
585 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
586 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
587 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
588 static int ifoRead_PGC_COMMAND_TBL(ifo_handle_t *ifofile, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
589 pgc_command_tbl_t *cmd_tbl, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
590 unsigned int offset) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
591 unsigned int total; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
592 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
593 memset(cmd_tbl, 0, sizeof(pgc_command_tbl_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
594 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
595 if(!DVDFileSeek_(ifofile->file, offset)) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
596 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
597 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
598 if(!(DVDReadBytes(ifofile->file, cmd_tbl, PGC_COMMAND_TBL_SIZE))) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
599 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
600 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
601 B2N_16(cmd_tbl->nr_of_pre); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
602 B2N_16(cmd_tbl->nr_of_post); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
603 B2N_16(cmd_tbl->nr_of_cell); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
604 B2N_16(cmd_tbl->last_byte); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
605 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
606 total = cmd_tbl->nr_of_pre + cmd_tbl->nr_of_post + cmd_tbl->nr_of_cell; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
607 CHECK_VALUE(PGC_COMMAND_TBL_SIZE + total * COMMAND_DATA_SIZE |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
608 <= cmd_tbl->last_byte + 1U); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
609 CHECK_VALUE(total <= 255); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
610 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
611 if(cmd_tbl->nr_of_pre != 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
612 unsigned int pre_cmds_size = cmd_tbl->nr_of_pre * COMMAND_DATA_SIZE; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
613 cmd_tbl->pre_cmds = malloc(pre_cmds_size); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
614 if(!cmd_tbl->pre_cmds) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
615 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
616 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
617 if(!(DVDReadBytes(ifofile->file, cmd_tbl->pre_cmds, pre_cmds_size))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
618 free(cmd_tbl->pre_cmds); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
619 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
620 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
621 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
622 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
623 if(cmd_tbl->nr_of_post != 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
624 unsigned int post_cmds_size = cmd_tbl->nr_of_post * COMMAND_DATA_SIZE; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
625 cmd_tbl->post_cmds = malloc(post_cmds_size); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
626 if(!cmd_tbl->post_cmds) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
627 if(cmd_tbl->pre_cmds) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
628 free(cmd_tbl->pre_cmds); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
629 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
630 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
631 if(!(DVDReadBytes(ifofile->file, cmd_tbl->post_cmds, post_cmds_size))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
632 if(cmd_tbl->pre_cmds) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
633 free(cmd_tbl->pre_cmds); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
634 free(cmd_tbl->post_cmds); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
635 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
636 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
637 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
638 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
639 if(cmd_tbl->nr_of_cell != 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
640 unsigned int cell_cmds_size = cmd_tbl->nr_of_cell * COMMAND_DATA_SIZE; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
641 cmd_tbl->cell_cmds = malloc(cell_cmds_size); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
642 if(!cmd_tbl->cell_cmds) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
643 if(cmd_tbl->pre_cmds) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
644 free(cmd_tbl->pre_cmds); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
645 if(cmd_tbl->post_cmds) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
646 free(cmd_tbl->post_cmds); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
647 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
648 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
649 if(!(DVDReadBytes(ifofile->file, cmd_tbl->cell_cmds, cell_cmds_size))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
650 if(cmd_tbl->pre_cmds) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
651 free(cmd_tbl->pre_cmds); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
652 if(cmd_tbl->post_cmds) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
653 free(cmd_tbl->post_cmds); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
654 free(cmd_tbl->cell_cmds); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
655 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
656 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
657 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
658 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
659 /* |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
660 * Make a run over all the commands and see that we can interpret them all? |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
661 */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
662 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
663 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
664 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
665 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
666 static void ifoFree_PGC_COMMAND_TBL(pgc_command_tbl_t *cmd_tbl) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
667 if(cmd_tbl) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
668 if(cmd_tbl->nr_of_pre && cmd_tbl->pre_cmds) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
669 free(cmd_tbl->pre_cmds); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
670 if(cmd_tbl->nr_of_post && cmd_tbl->post_cmds) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
671 free(cmd_tbl->post_cmds); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
672 if(cmd_tbl->nr_of_cell && cmd_tbl->cell_cmds) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
673 free(cmd_tbl->cell_cmds); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
674 free(cmd_tbl); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
675 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
676 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
677 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
678 static int ifoRead_PGC_PROGRAM_MAP(ifo_handle_t *ifofile, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
679 pgc_program_map_t *program_map, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
680 unsigned int nr, unsigned int offset) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
681 unsigned int size = nr * sizeof(pgc_program_map_t); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
682 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
683 if(!DVDFileSeek_(ifofile->file, offset)) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
684 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
685 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
686 if(!(DVDReadBytes(ifofile->file, program_map, size))) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
687 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
688 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
689 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
690 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
691 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
692 static int ifoRead_CELL_PLAYBACK_TBL(ifo_handle_t *ifofile, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
693 cell_playback_t *cell_playback, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
694 unsigned int nr, unsigned int offset) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
695 unsigned int i; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
696 unsigned int size = nr * sizeof(cell_playback_t); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
697 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
698 if(!DVDFileSeek_(ifofile->file, offset)) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
699 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
700 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
701 if(!(DVDReadBytes(ifofile->file, cell_playback, size))) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
702 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
703 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
704 for(i = 0; i < nr; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
705 B2N_32(cell_playback[i].first_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
706 B2N_32(cell_playback[i].first_ilvu_end_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
707 B2N_32(cell_playback[i].last_vobu_start_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
708 B2N_32(cell_playback[i].last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
709 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
710 /* Changed < to <= because this was false in the movie 'Pi'. */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
711 CHECK_VALUE(cell_playback[i].last_vobu_start_sector <= |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
712 cell_playback[i].last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
713 CHECK_VALUE(cell_playback[i].first_sector <= |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
714 cell_playback[i].last_vobu_start_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
715 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
716 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
717 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
718 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
719 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
720 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
721 static int ifoRead_CELL_POSITION_TBL(ifo_handle_t *ifofile, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
722 cell_position_t *cell_position, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
723 unsigned int nr, unsigned int offset) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
724 unsigned int i; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
725 unsigned int size = nr * sizeof(cell_position_t); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
726 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
727 if(!DVDFileSeek_(ifofile->file, offset)) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
728 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
729 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
730 if(!(DVDReadBytes(ifofile->file, cell_position, size))) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
731 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
732 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
733 for(i = 0; i < nr; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
734 B2N_16(cell_position[i].vob_id_nr); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
735 CHECK_ZERO(cell_position[i].zero_1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
736 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
737 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
738 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
739 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
740 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
741 static int ifoRead_PGC(ifo_handle_t *ifofile, pgc_t *pgc, unsigned int offset) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
742 unsigned int i; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
743 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
744 if(!DVDFileSeek_(ifofile->file, offset)) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
745 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
746 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
747 if(!(DVDReadBytes(ifofile->file, pgc, PGC_SIZE))) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
748 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
749 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
750 B2N_16(pgc->next_pgc_nr); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
751 B2N_16(pgc->prev_pgc_nr); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
752 B2N_16(pgc->goup_pgc_nr); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
753 B2N_16(pgc->command_tbl_offset); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
754 B2N_16(pgc->program_map_offset); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
755 B2N_16(pgc->cell_playback_offset); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
756 B2N_16(pgc->cell_position_offset); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
757 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
758 for(i = 0; i < 8; i++) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
759 B2N_16(pgc->audio_control[i]); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
760 for(i = 0; i < 32; i++) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
761 B2N_32(pgc->subp_control[i]); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
762 for(i = 0; i < 16; i++) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
763 B2N_32(pgc->palette[i]); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
764 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
765 CHECK_ZERO(pgc->zero_1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
766 CHECK_VALUE(pgc->nr_of_programs <= pgc->nr_of_cells); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
767 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
768 /* verify time (look at print_time) */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
769 for(i = 0; i < 8; i++) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
770 if(!pgc->audio_control[i] & 0x8000) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
771 CHECK_ZERO(pgc->audio_control[i]); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
772 for(i = 0; i < 32; i++) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
773 if(!pgc->subp_control[i] & 0x80000000) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
774 CHECK_ZERO(pgc->subp_control[i]); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
775 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
776 /* Check that time is 0:0:0:0 also if nr_of_programs == 0 */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
777 if(pgc->nr_of_programs == 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
778 CHECK_ZERO(pgc->still_time); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
779 CHECK_ZERO(pgc->pg_playback_mode); // ?? |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
780 CHECK_VALUE(pgc->program_map_offset == 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
781 CHECK_VALUE(pgc->cell_playback_offset == 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
782 CHECK_VALUE(pgc->cell_position_offset == 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
783 } else { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
784 CHECK_VALUE(pgc->program_map_offset != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
785 CHECK_VALUE(pgc->cell_playback_offset != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
786 CHECK_VALUE(pgc->cell_position_offset != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
787 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
788 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
789 if(pgc->command_tbl_offset != 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
790 pgc->command_tbl = malloc(sizeof(pgc_command_tbl_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
791 if(!pgc->command_tbl) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
792 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
793 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
794 if(!ifoRead_PGC_COMMAND_TBL(ifofile, pgc->command_tbl, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
795 offset + pgc->command_tbl_offset)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
796 free(pgc->command_tbl); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
797 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
798 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
799 } else { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
800 pgc->command_tbl = NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
801 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
802 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
803 if(pgc->program_map_offset != 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
804 if(pgc->nr_of_programs != 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
805 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
806 pgc->program_map = malloc(pgc->nr_of_programs * sizeof(pgc_program_map_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
807 if(!pgc->program_map) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
808 ifoFree_PGC_COMMAND_TBL(pgc->command_tbl); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
809 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
810 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
811 if(!ifoRead_PGC_PROGRAM_MAP(ifofile, pgc->program_map,pgc->nr_of_programs, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
812 offset + pgc->program_map_offset)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
813 ifoFree_PGC_COMMAND_TBL(pgc->command_tbl); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
814 free(pgc->program_map); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
815 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
816 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
817 } else { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
818 pgc->program_map = NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
819 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
820 } else { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
821 pgc->program_map = NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
822 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
823 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
824 if(pgc->cell_playback_offset != 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
825 if(pgc->nr_of_cells != 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
826 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
827 pgc->cell_playback = malloc(pgc->nr_of_cells * sizeof(cell_playback_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
828 if(!pgc->cell_playback) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
829 ifoFree_PGC_COMMAND_TBL(pgc->command_tbl); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
830 if(pgc->program_map) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
831 free(pgc->program_map); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
832 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
833 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
834 if(!ifoRead_CELL_PLAYBACK_TBL(ifofile, pgc->cell_playback, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
835 pgc->nr_of_cells, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
836 offset + pgc->cell_playback_offset)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
837 ifoFree_PGC_COMMAND_TBL(pgc->command_tbl); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
838 if(pgc->program_map) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
839 free(pgc->program_map); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
840 free(pgc->cell_playback); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
841 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
842 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
843 } else { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
844 pgc->cell_playback = NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
845 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
846 } else { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
847 pgc->cell_playback = NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
848 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
849 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
850 if(pgc->cell_position_offset != 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
851 if(pgc->nr_of_cells != 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
852 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
853 pgc->cell_position = malloc(pgc->nr_of_cells * sizeof(cell_position_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
854 if(!pgc->cell_position) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
855 ifoFree_PGC(pgc); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
856 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
857 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
858 if(!ifoRead_CELL_POSITION_TBL(ifofile, pgc->cell_position, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
859 pgc->nr_of_cells, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
860 offset + pgc->cell_position_offset)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
861 ifoFree_PGC(pgc); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
862 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
863 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
864 } else { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
865 pgc->cell_position = NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
866 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
867 } else { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
868 pgc->cell_position = NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
869 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
870 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
871 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
872 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
873 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
874 int ifoRead_FP_PGC(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
875 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
876 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
877 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
878 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
879 if(!ifofile->vmgi_mat) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
880 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
881 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
882 /* It seems that first_play_pgc is optional after all. */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
883 ifofile->first_play_pgc = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
884 if(ifofile->vmgi_mat->first_play_pgc == 0) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
885 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
886 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
887 ifofile->first_play_pgc = malloc(sizeof(pgc_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
888 if(!ifofile->first_play_pgc) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
889 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
890 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
891 if(!ifoRead_PGC(ifofile, ifofile->first_play_pgc, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
892 ifofile->vmgi_mat->first_play_pgc)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
893 free(ifofile->first_play_pgc); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
894 ifofile->first_play_pgc = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
895 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
896 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
897 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
898 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
899 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
900 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
901 static void ifoFree_PGC(pgc_t *pgc) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
902 if(pgc) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
903 ifoFree_PGC_COMMAND_TBL(pgc->command_tbl); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
904 if(pgc->program_map) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
905 free(pgc->program_map); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
906 if(pgc->cell_playback) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
907 free(pgc->cell_playback); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
908 if(pgc->cell_position) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
909 free(pgc->cell_position); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
910 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
911 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
912 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
913 void ifoFree_FP_PGC(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
914 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
915 return; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
916 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
917 if(ifofile->first_play_pgc) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
918 ifoFree_PGC(ifofile->first_play_pgc); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
919 free(ifofile->first_play_pgc); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
920 ifofile->first_play_pgc = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
921 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
922 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
923 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
924 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
925 int ifoRead_TT_SRPT(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
926 tt_srpt_t *tt_srpt; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
927 int i, info_length; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
928 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
929 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
930 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
931 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
932 if(!ifofile->vmgi_mat) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
933 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
934 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
935 if(ifofile->vmgi_mat->tt_srpt == 0) /* mandatory */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
936 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
937 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
938 if(!DVDFileSeek_(ifofile->file, ifofile->vmgi_mat->tt_srpt * DVD_BLOCK_LEN)) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
939 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
940 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
941 tt_srpt = malloc(sizeof(tt_srpt_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
942 if(!tt_srpt) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
943 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
944 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
945 ifofile->tt_srpt = tt_srpt; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
946 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
947 if(!(DVDReadBytes(ifofile->file, tt_srpt, TT_SRPT_SIZE))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
948 if(dvdread_verbose(device_of_file(ifofile->file)) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
949 fprintf(stderr, "libdvdread: Unable to read read TT_SRPT.\n"); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
950 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
951 free(tt_srpt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
952 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
953 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
954 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
955 B2N_16(tt_srpt->nr_of_srpts); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
956 B2N_32(tt_srpt->last_byte); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
957 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
958 info_length = tt_srpt->last_byte + 1 - TT_SRPT_SIZE; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
959 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
960 tt_srpt->title = malloc(info_length); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
961 if(!tt_srpt->title) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
962 free(tt_srpt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
963 ifofile->tt_srpt = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
964 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
965 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
966 if(!(DVDReadBytes(ifofile->file, tt_srpt->title, info_length))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
967 if(dvdread_verbose(device_of_file(ifofile->file)) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
968 fprintf(stderr, "libdvdread: Unable to read read TT_SRPT.\n"); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
969 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
970 ifoFree_TT_SRPT(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
971 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
972 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
973 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
974 for(i = 0; i < tt_srpt->nr_of_srpts; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
975 B2N_16(tt_srpt->title[i].nr_of_ptts); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
976 B2N_16(tt_srpt->title[i].parental_id); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
977 B2N_32(tt_srpt->title[i].title_set_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
978 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
979 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
980 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
981 CHECK_ZERO(tt_srpt->zero_1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
982 CHECK_VALUE(tt_srpt->nr_of_srpts != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
983 CHECK_VALUE(tt_srpt->nr_of_srpts < 100); // ?? |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
984 CHECK_VALUE(tt_srpt->nr_of_srpts * sizeof(title_info_t) <= info_length); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
985 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
986 for(i = 0; i < tt_srpt->nr_of_srpts; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
987 CHECK_VALUE(tt_srpt->title[i].pb_ty.zero_1 == 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
988 CHECK_VALUE(tt_srpt->title[i].nr_of_angles != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
989 CHECK_VALUE(tt_srpt->title[i].nr_of_angles < 10); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
990 //CHECK_VALUE(tt_srpt->title[i].nr_of_ptts != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
991 // XXX: this assertion breaks Ghostbusters: |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
992 CHECK_VALUE(tt_srpt->title[i].nr_of_ptts < 1000); // ?? |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
993 CHECK_VALUE(tt_srpt->title[i].title_set_nr != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
994 CHECK_VALUE(tt_srpt->title[i].title_set_nr < 100); // ?? |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
995 CHECK_VALUE(tt_srpt->title[i].vts_ttn != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
996 CHECK_VALUE(tt_srpt->title[i].vts_ttn < 100); // ?? |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
997 //CHECK_VALUE(tt_srpt->title[i].title_set_sector != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
998 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
999 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1000 // Make this a function |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1001 #if 0 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1002 if(memcmp((uint8_t *)tt_srpt->title + |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1003 tt_srpt->nr_of_srpts * sizeof(title_info_t), |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1004 my_friendly_zeros, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1005 info_length - tt_srpt->nr_of_srpts * sizeof(title_info_t))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1006 fprintf(stderr, "VMG_PTT_SRPT slack is != 0, "); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1007 hexdump((uint8_t *)tt_srpt->title + |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1008 tt_srpt->nr_of_srpts * sizeof(title_info_t), |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1009 info_length - tt_srpt->nr_of_srpts * sizeof(title_info_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1010 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1011 #endif |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1012 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1013 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1014 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1015 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1016 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1017 void ifoFree_TT_SRPT(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1018 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1019 return; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1020 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1021 if(ifofile->tt_srpt) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1022 free(ifofile->tt_srpt->title); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1023 free(ifofile->tt_srpt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1024 ifofile->tt_srpt = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1025 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1026 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1027 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1028 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1029 int ifoRead_VTS_PTT_SRPT(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1030 vts_ptt_srpt_t *vts_ptt_srpt; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1031 int info_length, i, j; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1032 uint32_t *data; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1033 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1034 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1035 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1036 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1037 if(!ifofile->vtsi_mat) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1038 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1039 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1040 if(ifofile->vtsi_mat->vts_ptt_srpt == 0) /* mandatory */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1041 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1042 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1043 if(!DVDFileSeek_(ifofile->file, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1044 ifofile->vtsi_mat->vts_ptt_srpt * DVD_BLOCK_LEN)) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1045 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1046 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1047 vts_ptt_srpt = malloc(sizeof(vts_ptt_srpt_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1048 if(!vts_ptt_srpt) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1049 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1050 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1051 ifofile->vts_ptt_srpt = vts_ptt_srpt; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1052 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1053 if(!(DVDReadBytes(ifofile->file, vts_ptt_srpt, VTS_PTT_SRPT_SIZE))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1054 if(dvdread_verbose(device_of_file(ifofile->file)) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1055 fprintf(stderr, "libdvdread: Unable to read PTT search table.\n"); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1056 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1057 free(vts_ptt_srpt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1058 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1059 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1060 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1061 B2N_16(vts_ptt_srpt->nr_of_srpts); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1062 B2N_32(vts_ptt_srpt->last_byte); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1063 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1064 CHECK_ZERO(vts_ptt_srpt->zero_1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1065 CHECK_VALUE(vts_ptt_srpt->nr_of_srpts != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1066 CHECK_VALUE(vts_ptt_srpt->nr_of_srpts < 100); // ?? |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1067 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1068 info_length = vts_ptt_srpt->last_byte + 1 - VTS_PTT_SRPT_SIZE; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1069 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1070 data = malloc(info_length); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1071 if(!data) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1072 free(vts_ptt_srpt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1073 ifofile->vts_ptt_srpt = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1074 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1075 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1076 if(!(DVDReadBytes(ifofile->file, data, info_length))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1077 if(dvdread_verbose(device_of_file(ifofile->file)) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1078 fprintf(stderr, "libdvdread: Unable to read PTT search table.\n"); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1079 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1080 free(vts_ptt_srpt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1081 free(data); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1082 ifofile->vts_ptt_srpt = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1083 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1084 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1085 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1086 for(i = 0; i < vts_ptt_srpt->nr_of_srpts; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1087 B2N_32(data[i]); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1088 /* assert(data[i] + sizeof(ptt_info_t) <= vts_ptt_srpt->last_byte + 1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1089 Magic Knight Rayearth Daybreak is mastered very strange and has |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1090 Titles with 0 PTTs. They all have a data[i] offsets beyond the end of |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1091 of the vts_ptt_srpt structure. */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1092 CHECK_VALUE(data[i] + sizeof(ptt_info_t) <= vts_ptt_srpt->last_byte + 1 + 4); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1093 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1094 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1095 vts_ptt_srpt->ttu_offset = data; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1096 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1097 vts_ptt_srpt->title = malloc(vts_ptt_srpt->nr_of_srpts * sizeof(ttu_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1098 if(!vts_ptt_srpt->title) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1099 free(vts_ptt_srpt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1100 free(data); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1101 ifofile->vts_ptt_srpt = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1102 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1103 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1104 for(i = 0; i < vts_ptt_srpt->nr_of_srpts; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1105 int n; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1106 if(i < vts_ptt_srpt->nr_of_srpts - 1) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1107 n = (data[i+1] - data[i]); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1108 else |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1109 n = (vts_ptt_srpt->last_byte + 1 - data[i]); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1110 /* assert(n > 0 && (n % 4) == 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1111 Magic Knight Rayearth Daybreak is mastered very strange and has |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1112 Titles with 0 PTTs. */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1113 if(n < 0) n = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1114 CHECK_VALUE(n % 4 == 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1115 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1116 vts_ptt_srpt->title[i].nr_of_ptts = n / 4; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1117 vts_ptt_srpt->title[i].ptt = malloc(n * sizeof(ptt_info_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1118 if(!vts_ptt_srpt->title[i].ptt) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1119 for(n = 0; n < i; n++) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1120 free(vts_ptt_srpt->title[n].ptt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1121 free(vts_ptt_srpt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1122 free(data); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1123 ifofile->vts_ptt_srpt = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1124 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1125 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1126 for(j = 0; j < vts_ptt_srpt->title[i].nr_of_ptts; j++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1127 /* The assert placed here because of Magic Knight Rayearth Daybreak */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1128 CHECK_VALUE(data[i] + sizeof(ptt_info_t) <= vts_ptt_srpt->last_byte + 1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1129 vts_ptt_srpt->title[i].ptt[j].pgcn |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1130 = *(uint16_t*)(((char *)data) + data[i] + 4*j - VTS_PTT_SRPT_SIZE); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1131 vts_ptt_srpt->title[i].ptt[j].pgn |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1132 = *(uint16_t*)(((char *)data) + data[i] + 4*j + 2 - VTS_PTT_SRPT_SIZE); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1133 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1134 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1135 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1136 for(i = 0; i < vts_ptt_srpt->nr_of_srpts; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1137 for(j = 0; j < vts_ptt_srpt->title[i].nr_of_ptts; j++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1138 B2N_16(vts_ptt_srpt->title[i].ptt[j].pgcn); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1139 B2N_16(vts_ptt_srpt->title[i].ptt[j].pgn); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1140 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1141 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1142 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1143 for(i = 0; i < vts_ptt_srpt->nr_of_srpts; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1144 CHECK_VALUE(vts_ptt_srpt->title[i].nr_of_ptts < 1000); // ?? |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1145 for(j = 0; j < vts_ptt_srpt->title[i].nr_of_ptts; j++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1146 CHECK_VALUE(vts_ptt_srpt->title[i].ptt[j].pgcn != 0 ); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1147 CHECK_VALUE(vts_ptt_srpt->title[i].ptt[j].pgcn < 1000); // ?? |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1148 CHECK_VALUE(vts_ptt_srpt->title[i].ptt[j].pgn != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1149 CHECK_VALUE(vts_ptt_srpt->title[i].ptt[j].pgn < 100); // ?? |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1150 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1151 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1152 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1153 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1154 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1155 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1156 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1157 void ifoFree_VTS_PTT_SRPT(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1158 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1159 return; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1160 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1161 if(ifofile->vts_ptt_srpt) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1162 int i; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1163 for(i = 0; i < ifofile->vts_ptt_srpt->nr_of_srpts; i++) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1164 free(ifofile->vts_ptt_srpt->title[i].ptt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1165 free(ifofile->vts_ptt_srpt->ttu_offset); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1166 free(ifofile->vts_ptt_srpt->title); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1167 free(ifofile->vts_ptt_srpt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1168 ifofile->vts_ptt_srpt = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1169 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1170 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1171 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1172 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1173 int ifoRead_PTL_MAIT(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1174 ptl_mait_t *ptl_mait; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1175 int info_length; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1176 unsigned int i, j; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1177 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1178 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1179 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1180 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1181 if(!ifofile->vmgi_mat) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1182 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1183 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1184 if(ifofile->vmgi_mat->ptl_mait == 0) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1185 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1186 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1187 if(!DVDFileSeek_(ifofile->file, ifofile->vmgi_mat->ptl_mait * DVD_BLOCK_LEN)) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1188 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1189 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1190 ptl_mait = malloc(sizeof(ptl_mait_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1191 if(!ptl_mait) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1192 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1193 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1194 ifofile->ptl_mait = ptl_mait; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1195 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1196 if(!(DVDReadBytes(ifofile->file, ptl_mait, PTL_MAIT_SIZE))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1197 free(ptl_mait); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1198 ifofile->ptl_mait = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1199 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1200 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1201 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1202 B2N_16(ptl_mait->nr_of_countries); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1203 B2N_16(ptl_mait->nr_of_vtss); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1204 B2N_32(ptl_mait->last_byte); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1205 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1206 CHECK_VALUE(ptl_mait->nr_of_countries != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1207 CHECK_VALUE(ptl_mait->nr_of_countries < 100); // ?? |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1208 CHECK_VALUE(ptl_mait->nr_of_vtss != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1209 CHECK_VALUE(ptl_mait->nr_of_vtss < 100); // ?? |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1210 CHECK_VALUE(ptl_mait->nr_of_countries * PTL_MAIT_COUNTRY_SIZE |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1211 <= ptl_mait->last_byte + 1 - PTL_MAIT_SIZE); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1212 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1213 info_length = ptl_mait->nr_of_countries * sizeof(ptl_mait_country_t); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1214 ptl_mait->countries = malloc(info_length); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1215 if(!ptl_mait->countries) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1216 free(ptl_mait); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1217 ifofile->ptl_mait = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1218 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1219 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1220 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1221 for(i = 0; i < ptl_mait->nr_of_countries; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1222 if(!(DVDReadBytes(ifofile->file, &ptl_mait->countries[i], PTL_MAIT_COUNTRY_SIZE))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1223 if(dvdread_verbose(device_of_file(ifofile->file)) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1224 fprintf(stderr, "libdvdread: Unable to read PTL_MAIT.\n"); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1225 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1226 free(ptl_mait->countries); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1227 free(ptl_mait); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1228 ifofile->ptl_mait = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1229 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1230 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1231 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1232 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1233 for(i = 0; i < ptl_mait->nr_of_countries; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1234 B2N_16(ptl_mait->countries[i].country_code); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1235 B2N_16(ptl_mait->countries[i].pf_ptl_mai_start_byte); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1236 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1237 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1238 for(i = 0; i < ptl_mait->nr_of_countries; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1239 CHECK_ZERO(ptl_mait->countries[i].zero_1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1240 CHECK_ZERO(ptl_mait->countries[i].zero_2); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1241 CHECK_VALUE(ptl_mait->countries[i].pf_ptl_mai_start_byte + |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1242 16U * (ptl_mait->nr_of_vtss + 1) <= ptl_mait->last_byte + 1U); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1243 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1244 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1245 for(i = 0; i < ptl_mait->nr_of_countries; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1246 uint16_t *pf_temp; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1247 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1248 if(!DVDFileSeek_(ifofile->file, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1249 ifofile->vmgi_mat->ptl_mait * DVD_BLOCK_LEN |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1250 + ptl_mait->countries[i].pf_ptl_mai_start_byte)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1251 if(dvdread_verbose(device_of_file(ifofile->file)) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1252 fprintf(stderr, "libdvdread: Unable to seak PTL_MAIT table.\n"); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1253 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1254 free(ptl_mait->countries); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1255 free(ptl_mait); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1256 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1257 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1258 info_length = (ptl_mait->nr_of_vtss + 1) * sizeof(pf_level_t); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1259 pf_temp = malloc(info_length); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1260 if(!pf_temp) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1261 for(j = 0; j < i ; j++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1262 free(ptl_mait->countries[j].pf_ptl_mai); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1263 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1264 free(ptl_mait->countries); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1265 free(ptl_mait); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1266 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1267 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1268 if(!(DVDReadBytes(ifofile->file, pf_temp, info_length))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1269 if(dvdread_verbose(device_of_file(ifofile->file)) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1270 fprintf(stderr, "libdvdread: Unable to read PTL_MAIT table.\n"); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1271 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1272 free(pf_temp); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1273 for(j = 0; j < i ; j++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1274 free(ptl_mait->countries[j].pf_ptl_mai); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1275 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1276 free(ptl_mait->countries); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1277 free(ptl_mait); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1278 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1279 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1280 for (j = 0; j < ((ptl_mait->nr_of_vtss + 1) * 8); j++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1281 B2N_16(pf_temp[j]); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1282 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1283 ptl_mait->countries[i].pf_ptl_mai = malloc(info_length); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1284 if(!ptl_mait->countries[i].pf_ptl_mai) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1285 free(pf_temp); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1286 for(j = 0; j < i ; j++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1287 free(ptl_mait->countries[j].pf_ptl_mai); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1288 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1289 free(ptl_mait->countries); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1290 free(ptl_mait); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1291 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1292 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1293 { /* Transpose the array so we can use C indexing. */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1294 int level, vts; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1295 for(level = 0; level < 8; level++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1296 for(vts = 0; vts <= ptl_mait->nr_of_vtss; vts++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1297 ptl_mait->countries[i].pf_ptl_mai[vts][level] = |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1298 pf_temp[(7-level)*(ptl_mait->nr_of_vtss+1) + vts]; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1299 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1300 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1301 free(pf_temp); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1302 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1303 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1304 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1305 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1306 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1307 void ifoFree_PTL_MAIT(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1308 unsigned int i; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1309 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1310 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1311 return; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1312 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1313 if(ifofile->ptl_mait) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1314 for(i = 0; i < ifofile->ptl_mait->nr_of_countries; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1315 free(ifofile->ptl_mait->countries[i].pf_ptl_mai); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1316 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1317 free(ifofile->ptl_mait->countries); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1318 free(ifofile->ptl_mait); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1319 ifofile->ptl_mait = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1320 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1321 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1322 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1323 int ifoRead_VTS_TMAPT(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1324 vts_tmapt_t *vts_tmapt; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1325 uint32_t *vts_tmap_srp; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1326 unsigned int offset; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1327 int info_length; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1328 unsigned int i, j; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1329 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1330 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1331 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1332 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1333 if(!ifofile->vtsi_mat) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1334 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1335 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1336 /* Seems to be optional, at least when there are no OneSequencial Titles */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1337 if(ifofile->vtsi_mat->vts_tmapt == 0) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1338 ifofile->vts_tmapt = NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1339 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1340 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1341 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1342 offset = ifofile->vtsi_mat->vts_tmapt * DVD_BLOCK_LEN; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1343 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1344 if(!DVDFileSeek_(ifofile->file, offset)) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1345 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1346 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1347 vts_tmapt = malloc(sizeof(vts_tmapt_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1348 if(!vts_tmapt) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1349 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1350 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1351 ifofile->vts_tmapt = vts_tmapt; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1352 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1353 if(!(DVDReadBytes(ifofile->file, vts_tmapt, VTS_TMAPT_SIZE))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1354 if(dvdread_verbose(device_of_file(ifofile->file)) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1355 fprintf(stderr, "libdvdread: Unable to read VTS_TMAPT.\n"); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1356 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1357 free(vts_tmapt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1358 ifofile->vts_tmapt = NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1359 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1360 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1361 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1362 B2N_16(vts_tmapt->nr_of_tmaps); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1363 B2N_32(vts_tmapt->last_byte); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1364 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1365 CHECK_ZERO(vts_tmapt->zero_1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1366 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1367 info_length = vts_tmapt->nr_of_tmaps * 4; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1368 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1369 vts_tmap_srp = malloc(info_length); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1370 if(!vts_tmap_srp) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1371 free(vts_tmapt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1372 ifofile->vts_tmapt = NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1373 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1374 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1375 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1376 vts_tmapt->tmap_offset = vts_tmap_srp; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1377 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1378 if(!(DVDReadBytes(ifofile->file, vts_tmap_srp, info_length))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1379 if(dvdread_verbose(device_of_file(ifofile->file)) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1380 fprintf(stderr, "libdvdread: Unable to read VTS_TMAPT.\n"); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1381 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1382 free(vts_tmap_srp); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1383 free(vts_tmapt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1384 ifofile->vts_tmapt = NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1385 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1386 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1387 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1388 for (i = 0; i < vts_tmapt->nr_of_tmaps; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1389 B2N_32(vts_tmap_srp[i]); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1390 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1391 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1392 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1393 info_length = vts_tmapt->nr_of_tmaps * sizeof(vts_tmap_t); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1394 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1395 vts_tmapt->tmap = malloc(info_length); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1396 if(!vts_tmapt->tmap) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1397 free(vts_tmap_srp); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1398 free(vts_tmapt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1399 ifofile->vts_tmapt = NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1400 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1401 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1402 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1403 memset(vts_tmapt->tmap, 0, info_length); /* So ifoFree_VTS_TMAPT works. */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1404 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1405 for(i = 0; i < vts_tmapt->nr_of_tmaps; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1406 if(!DVDFileSeek_(ifofile->file, offset + vts_tmap_srp[i])) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1407 ifoFree_VTS_TMAPT(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1408 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1409 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1410 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1411 if(!(DVDReadBytes(ifofile->file, &vts_tmapt->tmap[i], VTS_TMAP_SIZE))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1412 if(dvdread_verbose(device_of_file(ifofile->file)) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1413 fprintf(stderr, "libdvdread: Unable to read VTS_TMAP.\n"); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1414 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1415 ifoFree_VTS_TMAPT(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1416 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1417 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1418 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1419 B2N_16(vts_tmapt->tmap[i].nr_of_entries); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1420 CHECK_ZERO(vts_tmapt->tmap[i].zero_1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1421 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1422 if(vts_tmapt->tmap[i].nr_of_entries == 0) { /* Early out if zero entries */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1423 vts_tmapt->tmap[i].map_ent = NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1424 continue; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1425 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1426 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1427 info_length = vts_tmapt->tmap[i].nr_of_entries * sizeof(map_ent_t); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1428 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1429 vts_tmapt->tmap[i].map_ent = malloc(info_length); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1430 if(!vts_tmapt->tmap[i].map_ent) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1431 ifoFree_VTS_TMAPT(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1432 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1433 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1434 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1435 if(!(DVDReadBytes(ifofile->file, vts_tmapt->tmap[i].map_ent, info_length))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1436 if(dvdread_verbose(device_of_file(ifofile->file)) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1437 fprintf(stderr, "libdvdread: Unable to read VTS_TMAP_ENT.\n"); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1438 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1439 ifoFree_VTS_TMAPT(ifofile); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1440 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1441 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1442 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1443 for(j = 0; j < vts_tmapt->tmap[i].nr_of_entries; j++) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1444 B2N_32(vts_tmapt->tmap[i].map_ent[j]); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1445 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1446 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1447 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1448 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1449 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1450 void ifoFree_VTS_TMAPT(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1451 unsigned int i; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1452 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1453 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1454 return; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1455 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1456 if(ifofile->vts_tmapt) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1457 for(i = 0; i < ifofile->vts_tmapt->nr_of_tmaps; i++) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1458 if(ifofile->vts_tmapt->tmap[i].map_ent) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1459 free(ifofile->vts_tmapt->tmap[i].map_ent); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1460 free(ifofile->vts_tmapt->tmap); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1461 free(ifofile->vts_tmapt->tmap_offset); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1462 free(ifofile->vts_tmapt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1463 ifofile->vts_tmapt = NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1464 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1465 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1466 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1467 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1468 int ifoRead_TITLE_C_ADT(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1469 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1470 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1471 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1472 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1473 if(!ifofile->vtsi_mat) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1474 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1475 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1476 if(ifofile->vtsi_mat->vts_c_adt == 0) /* mandatory */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1477 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1478 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1479 ifofile->vts_c_adt = malloc(sizeof(c_adt_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1480 if(!ifofile->vts_c_adt) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1481 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1482 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1483 if(!ifoRead_C_ADT_internal(ifofile, ifofile->vts_c_adt, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1484 ifofile->vtsi_mat->vts_c_adt)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1485 free(ifofile->vts_c_adt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1486 ifofile->vts_c_adt = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1487 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1488 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1489 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1490 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1491 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1492 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1493 int ifoRead_C_ADT(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1494 unsigned int sector; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1495 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1496 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1497 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1498 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1499 if(ifofile->vmgi_mat) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1500 if(ifofile->vmgi_mat->vmgm_c_adt == 0) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1501 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1502 sector = ifofile->vmgi_mat->vmgm_c_adt; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1503 } else if(ifofile->vtsi_mat) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1504 if(ifofile->vtsi_mat->vtsm_c_adt == 0) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1505 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1506 sector = ifofile->vtsi_mat->vtsm_c_adt; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1507 } else { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1508 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1509 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1510 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1511 ifofile->menu_c_adt = malloc(sizeof(c_adt_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1512 if(!ifofile->menu_c_adt) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1513 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1514 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1515 if(!ifoRead_C_ADT_internal(ifofile, ifofile->menu_c_adt, sector)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1516 free(ifofile->menu_c_adt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1517 ifofile->menu_c_adt = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1518 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1519 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1520 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1521 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1522 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1523 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1524 static int ifoRead_C_ADT_internal(ifo_handle_t *ifofile, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1525 c_adt_t *c_adt, unsigned int sector) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1526 int i, info_length; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1527 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1528 if(!DVDFileSeek_(ifofile->file, sector * DVD_BLOCK_LEN)) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1529 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1530 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1531 if(!(DVDReadBytes(ifofile->file, c_adt, C_ADT_SIZE))) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1532 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1533 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1534 B2N_16(c_adt->nr_of_vobs); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1535 B2N_32(c_adt->last_byte); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1536 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1537 info_length = c_adt->last_byte + 1 - C_ADT_SIZE; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1538 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1539 CHECK_ZERO(c_adt->zero_1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1540 /* assert(c_adt->nr_of_vobs > 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1541 Magic Knight Rayearth Daybreak is mastered very strange and has |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1542 Titles with a VOBS that has no cells. */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1543 CHECK_VALUE(info_length % sizeof(cell_adr_t) == 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1544 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1545 /* assert(info_length / sizeof(cell_adr_t) >= c_adt->nr_of_vobs); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1546 Enemy of the State region 2 (de) has Titles where nr_of_vobs field |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1547 is to high, they high ones are never referenced though. */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1548 if(info_length / sizeof(cell_adr_t) < c_adt->nr_of_vobs) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1549 if(dvdread_verbose(device_of_file(ifofile->file)) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1550 fprintf(stderr, "libdvdread: *C_ADT nr_of_vobs > avaiable info entries\n"); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1551 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1552 c_adt->nr_of_vobs = info_length / sizeof(cell_adr_t); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1553 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1554 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1555 c_adt->cell_adr_table = malloc(info_length); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1556 if(!c_adt->cell_adr_table) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1557 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1558 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1559 if(info_length && |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1560 !(DVDReadBytes(ifofile->file, c_adt->cell_adr_table, info_length))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1561 free(c_adt->cell_adr_table); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1562 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1563 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1564 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1565 for(i = 0; i < info_length/sizeof(cell_adr_t); i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1566 B2N_16(c_adt->cell_adr_table[i].vob_id); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1567 B2N_32(c_adt->cell_adr_table[i].start_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1568 B2N_32(c_adt->cell_adr_table[i].last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1569 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1570 CHECK_ZERO(c_adt->cell_adr_table[i].zero_1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1571 CHECK_VALUE(c_adt->cell_adr_table[i].vob_id > 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1572 CHECK_VALUE(c_adt->cell_adr_table[i].vob_id <= c_adt->nr_of_vobs); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1573 CHECK_VALUE(c_adt->cell_adr_table[i].cell_id > 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1574 CHECK_VALUE(c_adt->cell_adr_table[i].start_sector < |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1575 c_adt->cell_adr_table[i].last_sector); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1576 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1577 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1578 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1579 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1580 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1581 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1582 static void ifoFree_C_ADT_internal(c_adt_t *c_adt) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1583 if(c_adt) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1584 free(c_adt->cell_adr_table); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1585 free(c_adt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1586 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1587 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1588 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1589 void ifoFree_C_ADT(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1590 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1591 return; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1592 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1593 ifoFree_C_ADT_internal(ifofile->menu_c_adt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1594 ifofile->menu_c_adt = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1595 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1596 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1597 void ifoFree_TITLE_C_ADT(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1598 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1599 return; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1600 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1601 ifoFree_C_ADT_internal(ifofile->vts_c_adt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1602 ifofile->vts_c_adt = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1603 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1604 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1605 int ifoRead_TITLE_VOBU_ADMAP(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1606 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1607 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1608 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1609 if(!ifofile->vtsi_mat) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1610 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1611 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1612 if(ifofile->vtsi_mat->vts_vobu_admap == 0) /* mandatory */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1613 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1614 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1615 ifofile->vts_vobu_admap = malloc(sizeof(vobu_admap_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1616 if(!ifofile->vts_vobu_admap) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1617 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1618 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1619 if(!ifoRead_VOBU_ADMAP_internal(ifofile, ifofile->vts_vobu_admap, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1620 ifofile->vtsi_mat->vts_vobu_admap)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1621 free(ifofile->vts_vobu_admap); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1622 ifofile->vts_vobu_admap = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1623 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1624 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1625 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1626 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1627 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1628 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1629 int ifoRead_VOBU_ADMAP(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1630 unsigned int sector; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1631 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1632 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1633 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1634 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1635 if(ifofile->vmgi_mat) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1636 if(ifofile->vmgi_mat->vmgm_vobu_admap == 0) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1637 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1638 sector = ifofile->vmgi_mat->vmgm_vobu_admap; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1639 } else if(ifofile->vtsi_mat) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1640 if(ifofile->vtsi_mat->vtsm_vobu_admap == 0) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1641 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1642 sector = ifofile->vtsi_mat->vtsm_vobu_admap; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1643 } else { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1644 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1645 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1646 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1647 ifofile->menu_vobu_admap = malloc(sizeof(vobu_admap_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1648 if(!ifofile->menu_vobu_admap) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1649 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1650 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1651 if(!ifoRead_VOBU_ADMAP_internal(ifofile, ifofile->menu_vobu_admap, sector)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1652 free(ifofile->menu_vobu_admap); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1653 ifofile->menu_vobu_admap = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1654 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1655 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1656 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1657 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1658 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1659 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1660 static int ifoRead_VOBU_ADMAP_internal(ifo_handle_t *ifofile, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1661 vobu_admap_t *vobu_admap, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1662 unsigned int sector) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1663 unsigned int i; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1664 int info_length; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1665 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1666 if(!DVDFileSeek_(ifofile->file, sector * DVD_BLOCK_LEN)) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1667 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1668 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1669 if(!(DVDReadBytes(ifofile->file, vobu_admap, VOBU_ADMAP_SIZE))) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1670 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1671 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1672 B2N_32(vobu_admap->last_byte); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1673 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1674 info_length = vobu_admap->last_byte + 1 - VOBU_ADMAP_SIZE; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1675 /* assert(info_length > 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1676 Magic Knight Rayearth Daybreak is mastered very strange and has |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1677 Titles with a VOBS that has no VOBUs. */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1678 CHECK_VALUE(info_length % sizeof(uint32_t) == 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1679 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1680 vobu_admap->vobu_start_sectors = malloc(info_length); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1681 if(!vobu_admap->vobu_start_sectors) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1682 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1683 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1684 if(info_length && |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1685 !(DVDReadBytes(ifofile->file, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1686 vobu_admap->vobu_start_sectors, info_length))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1687 free(vobu_admap->vobu_start_sectors); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1688 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1689 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1690 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1691 for(i = 0; i < info_length/sizeof(uint32_t); i++) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1692 B2N_32(vobu_admap->vobu_start_sectors[i]); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1693 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1694 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1695 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1696 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1697 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1698 static void ifoFree_VOBU_ADMAP_internal(vobu_admap_t *vobu_admap) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1699 if(vobu_admap) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1700 free(vobu_admap->vobu_start_sectors); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1701 free(vobu_admap); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1702 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1703 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1704 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1705 void ifoFree_VOBU_ADMAP(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1706 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1707 return; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1708 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1709 ifoFree_VOBU_ADMAP_internal(ifofile->menu_vobu_admap); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1710 ifofile->menu_vobu_admap = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1711 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1712 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1713 void ifoFree_TITLE_VOBU_ADMAP(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1714 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1715 return; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1716 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1717 ifoFree_VOBU_ADMAP_internal(ifofile->vts_vobu_admap); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1718 ifofile->vts_vobu_admap = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1719 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1720 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1721 int ifoRead_PGCIT(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1722 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1723 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1724 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1725 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1726 if(!ifofile->vtsi_mat) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1727 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1728 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1729 if(ifofile->vtsi_mat->vts_pgcit == 0) /* mandatory */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1730 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1731 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1732 ifofile->vts_pgcit = malloc(sizeof(pgcit_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1733 if(!ifofile->vts_pgcit) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1734 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1735 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1736 if(!ifoRead_PGCIT_internal(ifofile, ifofile->vts_pgcit, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1737 ifofile->vtsi_mat->vts_pgcit * DVD_BLOCK_LEN)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1738 free(ifofile->vts_pgcit); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1739 ifofile->vts_pgcit = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1740 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1741 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1742 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1743 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1744 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1745 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1746 static int ifoRead_PGCIT_internal(ifo_handle_t *ifofile, pgcit_t *pgcit, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1747 unsigned int offset) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1748 int i, info_length; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1749 uint8_t *data, *ptr; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1750 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1751 if(!DVDFileSeek_(ifofile->file, offset)) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1752 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1753 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1754 if(!(DVDReadBytes(ifofile->file, pgcit, PGCIT_SIZE))) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1755 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1756 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1757 B2N_16(pgcit->nr_of_pgci_srp); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1758 B2N_32(pgcit->last_byte); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1759 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1760 CHECK_ZERO(pgcit->zero_1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1761 /* assert(pgcit->nr_of_pgci_srp != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1762 Magic Knight Rayearth Daybreak is mastered very strange and has |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1763 Titles with 0 PTTs. */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1764 CHECK_VALUE(pgcit->nr_of_pgci_srp < 10000); // ?? seen max of 1338 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1765 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1766 info_length = pgcit->nr_of_pgci_srp * PGCI_SRP_SIZE; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1767 data = malloc(info_length); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1768 if(!data) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1769 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1770 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1771 if(info_length && !(DVDReadBytes(ifofile->file, data, info_length))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1772 free(data); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1773 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1774 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1775 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1776 pgcit->pgci_srp = malloc(pgcit->nr_of_pgci_srp * sizeof(pgci_srp_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1777 if(!pgcit->pgci_srp) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1778 free(data); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1779 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1780 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1781 ptr = data; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1782 for(i = 0; i < pgcit->nr_of_pgci_srp; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1783 memcpy(&pgcit->pgci_srp[i], ptr, PGCI_SRP_SIZE); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1784 ptr += PGCI_SRP_SIZE; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1785 B2N_16(pgcit->pgci_srp[i].ptl_id_mask); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1786 B2N_32(pgcit->pgci_srp[i].pgc_start_byte); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1787 CHECK_VALUE(pgcit->pgci_srp[i].unknown1 == 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1788 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1789 free(data); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1790 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1791 for(i = 0; i < pgcit->nr_of_pgci_srp; i++) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1792 CHECK_VALUE(pgcit->pgci_srp[i].pgc_start_byte + PGC_SIZE <= pgcit->last_byte+1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1793 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1794 for(i = 0; i < pgcit->nr_of_pgci_srp; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1795 pgcit->pgci_srp[i].pgc = malloc(sizeof(pgc_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1796 if(!pgcit->pgci_srp[i].pgc) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1797 int j; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1798 for(j = 0; j < i; j++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1799 ifoFree_PGC(pgcit->pgci_srp[j].pgc); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1800 free(pgcit->pgci_srp[j].pgc); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1801 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1802 free(pgcit->pgci_srp); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1803 pgcit->pgci_srp = NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1804 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1805 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1806 if(!ifoRead_PGC(ifofile, pgcit->pgci_srp[i].pgc, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1807 offset + pgcit->pgci_srp[i].pgc_start_byte)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1808 int j; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1809 for(j = 0; j < i; j++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1810 ifoFree_PGC(pgcit->pgci_srp[j].pgc); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1811 free(pgcit->pgci_srp[j].pgc); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1812 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1813 free(pgcit->pgci_srp); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1814 pgcit->pgci_srp = NULL; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1815 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1816 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1817 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1818 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1819 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1820 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1821 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1822 static void ifoFree_PGCIT_internal(pgcit_t *pgcit) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1823 if(pgcit) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1824 int i; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1825 for(i = 0; i < pgcit->nr_of_pgci_srp; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1826 ifoFree_PGC(pgcit->pgci_srp[i].pgc); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1827 free(pgcit->pgci_srp[i].pgc); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1828 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1829 free(pgcit->pgci_srp); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1830 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1831 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1832 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1833 void ifoFree_PGCIT(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1834 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1835 return; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1836 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1837 if(ifofile->vts_pgcit) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1838 ifoFree_PGCIT_internal(ifofile->vts_pgcit); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1839 free(ifofile->vts_pgcit); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1840 ifofile->vts_pgcit = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1841 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1842 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1843 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1844 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1845 int ifoRead_PGCI_UT(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1846 pgci_ut_t *pgci_ut; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1847 unsigned int sector; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1848 unsigned int i; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1849 int info_length; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1850 uint8_t *data, *ptr; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1851 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1852 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1853 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1854 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1855 if(ifofile->vmgi_mat) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1856 if(ifofile->vmgi_mat->vmgm_pgci_ut == 0) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1857 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1858 sector = ifofile->vmgi_mat->vmgm_pgci_ut; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1859 } else if(ifofile->vtsi_mat) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1860 if(ifofile->vtsi_mat->vtsm_pgci_ut == 0) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1861 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1862 sector = ifofile->vtsi_mat->vtsm_pgci_ut; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1863 } else { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1864 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1865 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1866 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1867 ifofile->pgci_ut = malloc(sizeof(pgci_ut_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1868 if(!ifofile->pgci_ut) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1869 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1870 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1871 if(!DVDFileSeek_(ifofile->file, sector * DVD_BLOCK_LEN)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1872 free(ifofile->pgci_ut); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1873 ifofile->pgci_ut = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1874 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1875 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1876 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1877 if(!(DVDReadBytes(ifofile->file, ifofile->pgci_ut, PGCI_UT_SIZE))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1878 free(ifofile->pgci_ut); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1879 ifofile->pgci_ut = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1880 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1881 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1882 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1883 pgci_ut = ifofile->pgci_ut; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1884 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1885 B2N_16(pgci_ut->nr_of_lus); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1886 B2N_32(pgci_ut->last_byte); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1887 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1888 CHECK_ZERO(pgci_ut->zero_1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1889 CHECK_VALUE(pgci_ut->nr_of_lus != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1890 CHECK_VALUE(pgci_ut->nr_of_lus < 100); // ?? 3-4 ? |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1891 CHECK_VALUE((uint32_t)pgci_ut->nr_of_lus * PGCI_LU_SIZE < pgci_ut->last_byte); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1892 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1893 info_length = pgci_ut->nr_of_lus * PGCI_LU_SIZE; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1894 data = malloc(info_length); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1895 if(!data) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1896 free(pgci_ut); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1897 ifofile->pgci_ut = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1898 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1899 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1900 if(!(DVDReadBytes(ifofile->file, data, info_length))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1901 free(data); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1902 free(pgci_ut); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1903 ifofile->pgci_ut = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1904 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1905 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1906 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1907 pgci_ut->lu = malloc(pgci_ut->nr_of_lus * sizeof(pgci_lu_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1908 if(!pgci_ut->lu) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1909 free(data); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1910 free(pgci_ut); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1911 ifofile->pgci_ut = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1912 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1913 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1914 ptr = data; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1915 for(i = 0; i < pgci_ut->nr_of_lus; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1916 memcpy(&pgci_ut->lu[i], ptr, PGCI_LU_SIZE); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1917 ptr += PGCI_LU_SIZE; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1918 B2N_16(pgci_ut->lu[i].lang_code); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1919 B2N_32(pgci_ut->lu[i].lang_start_byte); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1920 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1921 free(data); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1922 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1923 for(i = 0; i < pgci_ut->nr_of_lus; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1924 // Maybe this is only defined for v1.1 and later titles? |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1925 /* If the bits in 'lu[i].exists' are enumerated abcd efgh then: |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1926 VTS_x_yy.IFO VIDEO_TS.IFO |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1927 a == 0x83 "Root" 0x82 "Title" |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1928 b == 0x84 "Subpicture" |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1929 c == 0x85 "Audio" |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1930 d == 0x86 "Angle" |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1931 e == 0x87 "PTT" |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1932 */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1933 CHECK_VALUE((pgci_ut->lu[i].exists & 0x07) == 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1934 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1935 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1936 for(i = 0; i < pgci_ut->nr_of_lus; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1937 pgci_ut->lu[i].pgcit = malloc(sizeof(pgcit_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1938 if(!pgci_ut->lu[i].pgcit) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1939 unsigned int j; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1940 for(j = 0; j < i; j++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1941 ifoFree_PGCIT_internal(pgci_ut->lu[j].pgcit); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1942 free(pgci_ut->lu[j].pgcit); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1943 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1944 free(pgci_ut->lu); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1945 free(pgci_ut); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1946 ifofile->pgci_ut = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1947 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1948 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1949 if(!ifoRead_PGCIT_internal(ifofile, pgci_ut->lu[i].pgcit, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1950 sector * DVD_BLOCK_LEN |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1951 + pgci_ut->lu[i].lang_start_byte)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1952 unsigned int j; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1953 for(j = 0; j < i; j++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1954 ifoFree_PGCIT_internal(pgci_ut->lu[j].pgcit); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1955 free(pgci_ut->lu[j].pgcit); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1956 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1957 free(pgci_ut->lu[i].pgcit); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1958 free(pgci_ut->lu); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1959 free(pgci_ut); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1960 ifofile->pgci_ut = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1961 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1962 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1963 // FIXME: Iterate and verify that all menus that should exists accordingly |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1964 // to pgci_ut->lu[i].exists really do? |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1965 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1966 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1967 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1968 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1969 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1970 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1971 void ifoFree_PGCI_UT(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1972 unsigned int i; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1973 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1974 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1975 return; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1976 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1977 if(ifofile->pgci_ut) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1978 for(i = 0; i < ifofile->pgci_ut->nr_of_lus; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1979 ifoFree_PGCIT_internal(ifofile->pgci_ut->lu[i].pgcit); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1980 free(ifofile->pgci_ut->lu[i].pgcit); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1981 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1982 free(ifofile->pgci_ut->lu); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1983 free(ifofile->pgci_ut); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1984 ifofile->pgci_ut = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1985 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1986 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1987 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1988 static int ifoRead_VTS_ATTRIBUTES(ifo_handle_t *ifofile, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1989 vts_attributes_t *vts_attributes, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1990 unsigned int offset) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1991 unsigned int i; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1992 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1993 if(!DVDFileSeek_(ifofile->file, offset)) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1994 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1995 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1996 if(!(DVDReadBytes(ifofile->file, vts_attributes, sizeof(vts_attributes_t)))) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1997 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1998 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
1999 B2N_32(vts_attributes->last_byte); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2000 B2N_32(vts_attributes->vts_cat); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2001 B2N_16(vts_attributes->vtsm_audio_attr.lang_code); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2002 B2N_16(vts_attributes->vtsm_subp_attr.lang_code); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2003 for(i = 0; i < 8; i++) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2004 B2N_16(vts_attributes->vtstt_audio_attr[i].lang_code); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2005 for(i = 0; i < 32; i++) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2006 B2N_16(vts_attributes->vtstt_subp_attr[i].lang_code); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2007 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2008 CHECK_ZERO(vts_attributes->zero_1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2009 CHECK_ZERO(vts_attributes->zero_2); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2010 CHECK_ZERO(vts_attributes->zero_3); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2011 CHECK_ZERO(vts_attributes->zero_4); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2012 CHECK_ZERO(vts_attributes->zero_5); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2013 CHECK_ZERO(vts_attributes->zero_6); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2014 CHECK_ZERO(vts_attributes->zero_7); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2015 CHECK_VALUE(vts_attributes->nr_of_vtsm_audio_streams <= 1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2016 CHECK_VALUE(vts_attributes->nr_of_vtsm_subp_streams <= 1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2017 CHECK_VALUE(vts_attributes->nr_of_vtstt_audio_streams <= 8); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2018 for(i = vts_attributes->nr_of_vtstt_audio_streams; i < 8; i++) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2019 CHECK_ZERO(vts_attributes->vtstt_audio_attr[i]); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2020 CHECK_VALUE(vts_attributes->nr_of_vtstt_subp_streams <= 32); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2021 { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2022 unsigned int nr_coded; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2023 CHECK_VALUE(vts_attributes->last_byte + 1 >= VTS_ATTRIBUTES_MIN_SIZE); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2024 nr_coded = (vts_attributes->last_byte + 1 - VTS_ATTRIBUTES_MIN_SIZE)/6; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2025 // This is often nr_coded = 70, how do you know how many there really are? |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2026 if(nr_coded > 32) { // We haven't read more from disk/file anyway |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2027 nr_coded = 32; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2028 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2029 CHECK_VALUE(vts_attributes->nr_of_vtstt_subp_streams <= nr_coded); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2030 for(i = vts_attributes->nr_of_vtstt_subp_streams; i < nr_coded; i++) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2031 CHECK_ZERO(vts_attributes->vtstt_subp_attr[i]); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2032 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2033 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2034 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2035 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2036 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2037 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2038 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2039 int ifoRead_VTS_ATRT(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2040 vts_atrt_t *vts_atrt; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2041 unsigned int i, info_length, sector; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2042 uint32_t *data; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2043 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2044 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2045 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2046 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2047 if(!ifofile->vmgi_mat) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2048 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2049 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2050 if(ifofile->vmgi_mat->vts_atrt == 0) /* mandatory */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2051 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2052 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2053 sector = ifofile->vmgi_mat->vts_atrt; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2054 if(!DVDFileSeek_(ifofile->file, sector * DVD_BLOCK_LEN)) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2055 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2056 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2057 vts_atrt = malloc(sizeof(vts_atrt_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2058 if(!vts_atrt) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2059 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2060 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2061 ifofile->vts_atrt = vts_atrt; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2062 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2063 if(!(DVDReadBytes(ifofile->file, vts_atrt, VTS_ATRT_SIZE))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2064 free(vts_atrt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2065 ifofile->vts_atrt = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2066 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2067 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2068 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2069 B2N_16(vts_atrt->nr_of_vtss); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2070 B2N_32(vts_atrt->last_byte); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2071 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2072 CHECK_ZERO(vts_atrt->zero_1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2073 CHECK_VALUE(vts_atrt->nr_of_vtss != 0); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2074 CHECK_VALUE(vts_atrt->nr_of_vtss < 100); //?? |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2075 CHECK_VALUE((uint32_t)vts_atrt->nr_of_vtss * (4 + VTS_ATTRIBUTES_MIN_SIZE) + |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2076 VTS_ATRT_SIZE < vts_atrt->last_byte + 1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2077 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2078 info_length = vts_atrt->nr_of_vtss * sizeof(uint32_t); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2079 data = malloc(info_length); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2080 if(!data) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2081 free(vts_atrt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2082 ifofile->vts_atrt = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2083 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2084 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2085 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2086 vts_atrt->vts_atrt_offsets = data; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2087 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2088 if(!(DVDReadBytes(ifofile->file, data, info_length))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2089 free(data); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2090 free(vts_atrt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2091 ifofile->vts_atrt = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2092 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2093 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2094 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2095 for(i = 0; i < vts_atrt->nr_of_vtss; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2096 B2N_32(data[i]); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2097 CHECK_VALUE(data[i] + VTS_ATTRIBUTES_MIN_SIZE < vts_atrt->last_byte + 1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2098 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2099 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2100 info_length = vts_atrt->nr_of_vtss * sizeof(vts_attributes_t); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2101 vts_atrt->vts = malloc(info_length); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2102 if(!vts_atrt->vts) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2103 free(data); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2104 free(vts_atrt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2105 ifofile->vts_atrt = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2106 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2107 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2108 for(i = 0; i < vts_atrt->nr_of_vtss; i++) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2109 unsigned int offset = data[i]; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2110 if(!ifoRead_VTS_ATTRIBUTES(ifofile, &(vts_atrt->vts[i]), |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2111 (sector * DVD_BLOCK_LEN) + offset)) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2112 free(data); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2113 free(vts_atrt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2114 ifofile->vts_atrt = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2115 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2116 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2117 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2118 // This assert cant be in ifoRead_VTS_ATTRIBUTES |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2119 CHECK_VALUE(offset + vts_atrt->vts[i].last_byte <= vts_atrt->last_byte + 1); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2120 // Is this check correct? |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2121 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2122 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2123 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2124 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2125 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2126 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2127 void ifoFree_VTS_ATRT(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2128 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2129 return; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2130 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2131 if(ifofile->vts_atrt) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2132 free(ifofile->vts_atrt->vts); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2133 free(ifofile->vts_atrt->vts_atrt_offsets); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2134 free(ifofile->vts_atrt); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2135 ifofile->vts_atrt = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2136 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2137 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2138 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2139 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2140 int ifoRead_TXTDT_MGI(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2141 txtdt_mgi_t *txtdt_mgi; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2142 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2143 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2144 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2145 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2146 if(!ifofile->vmgi_mat) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2147 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2148 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2149 /* Return successfully if there is nothing to read. */ |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2150 if(ifofile->vmgi_mat->txtdt_mgi == 0) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2151 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2152 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2153 if(!DVDFileSeek_(ifofile->file, |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2154 ifofile->vmgi_mat->txtdt_mgi * DVD_BLOCK_LEN)) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2155 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2156 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2157 txtdt_mgi = malloc(sizeof(txtdt_mgi_t)); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2158 if(!txtdt_mgi) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2159 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2160 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2161 ifofile->txtdt_mgi = txtdt_mgi; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2162 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2163 if(!(DVDReadBytes(ifofile->file, txtdt_mgi, TXTDT_MGI_SIZE))) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2164 if(dvdread_verbose(device_of_file(ifofile->file)) >= 1) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2165 fprintf(stderr, "libdvdread: Unable to read TXTDT_MGI.\n"); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2166 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2167 free(txtdt_mgi); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2168 ifofile->txtdt_mgi = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2169 return 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2170 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2171 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2172 // fprintf(stderr, "-- Not done yet --\n"); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2173 return 1; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2174 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2175 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2176 void ifoFree_TXTDT_MGI(ifo_handle_t *ifofile) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2177 if(!ifofile) |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2178 return; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2179 |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2180 if(ifofile->txtdt_mgi) { |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2181 free(ifofile->txtdt_mgi); |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2182 ifofile->txtdt_mgi = 0; |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2183 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2184 } |
ea01824701a5
Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents:
diff
changeset
|
2185 |