annotate dvdread/ifo_read.c @ 24465:8eb74a8f8da7

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