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