annotate dvdread/ifo_read.c @ 23582:c73cc80ec43a

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