Mercurial > mplayer.hg
annotate dvdread/nav_read.c @ 24050:1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
author | diego |
---|---|
date | Wed, 15 Aug 2007 11:57:30 +0000 |
parents | de28f9e8cb00 |
children | b3bc18ea5878 |
rev | line source |
---|---|
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
1 /* -*- c-basic-offset: 2; indent-tabs-mode: nil -*- */ |
7029 | 2 /* |
15874 | 3 * Copyright (C) 2000, 2001, 2002, 2003 Håkan Hjort <d95hjort@dtek.chalmers.se> |
14938
25df9508f9a8
Mark modified files as such to comply more closely with GPL ¡ø2a.
diego
parents:
8257
diff
changeset
|
4 * |
7029 | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License as published by | |
7 * the Free Software Foundation; either version 2 of the License, or | |
8 * (at your option) any later version. | |
9 * | |
10 * This program is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 * GNU General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU General Public License | |
16 * along with this program; if not, write to the Free Software | |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 */ | |
19 | |
15874 | 20 #include "config.h" |
21 | |
7029 | 22 #include <stdio.h> |
23 #include <string.h> | |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
24 #if defined(HAVE_INTTYPES_H) |
7029 | 25 #include <inttypes.h> |
24047
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
26 #elif defined(HAVE_STDINT_H) |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
27 #include <stdint.h> |
de28f9e8cb00
Sync libdvdread with version 0.9.5 (functional changes).
diego
parents:
20981
diff
changeset
|
28 #endif |
7029 | 29 |
30 #include "bswap.h" | |
31 #include "nav_types.h" | |
32 #include "nav_read.h" | |
15874 | 33 #include "dvdread_internal.h" |
7029 | 34 |
35 void navRead_PCI(pci_t *pci, unsigned char *buffer) { | |
15874 | 36 int i, j; |
7029 | 37 |
15874 | 38 CHECK_VALUE(sizeof(pci_t) == PCI_BYTES - 1); // -1 for substream id |
7029 | 39 |
40 memcpy(pci, buffer, sizeof(pci_t)); | |
41 | |
42 /* Endian conversions */ | |
43 | |
44 /* pci pci_gi */ | |
45 B2N_32(pci->pci_gi.nv_pck_lbn); | |
46 B2N_16(pci->pci_gi.vobu_cat); | |
47 B2N_32(pci->pci_gi.vobu_s_ptm); | |
48 B2N_32(pci->pci_gi.vobu_e_ptm); | |
49 B2N_32(pci->pci_gi.vobu_se_e_ptm); | |
50 | |
51 /* pci nsml_agli */ | |
52 for(i = 0; i < 9; i++) | |
53 B2N_32(pci->nsml_agli.nsml_agl_dsta[i]); | |
54 | |
55 /* pci hli hli_gi */ | |
56 B2N_16(pci->hli.hl_gi.hli_ss); | |
57 B2N_32(pci->hli.hl_gi.hli_s_ptm); | |
58 B2N_32(pci->hli.hl_gi.hli_e_ptm); | |
59 B2N_32(pci->hli.hl_gi.btn_se_e_ptm); | |
60 | |
61 /* pci hli btn_colit */ | |
62 for(i = 0; i < 3; i++) | |
63 for(j = 0; j < 2; j++) | |
64 B2N_32(pci->hli.btn_colit.btn_coli[i][j]); | |
65 | |
15874 | 66 /* NOTE: I've had to change the structure from the disk layout to get |
67 * the packing to work with Sun's Forte C compiler. */ | |
68 | |
7029 | 69 /* pci hli btni */ |
70 for(i = 0; i < 36; i++) { | |
15874 | 71 char tmp[sizeof(pci->hli.btnit[i])], swap; |
72 memcpy(tmp, &(pci->hli.btnit[i]), sizeof(pci->hli.btnit[i])); | |
73 /* Byte 4 to 7 are 'rotated' was: ABCD EFGH IJ is: ABCG DEFH IJ */ | |
74 swap = tmp[6]; | |
75 tmp[6] = tmp[5]; | |
76 tmp[5] = tmp[4]; | |
77 tmp[4] = tmp[3]; | |
78 tmp[3] = swap; | |
79 | |
80 /* Then there are the two B2N_24(..) calls */ | |
81 #ifndef WORDS_BIGENDIAN | |
82 swap = tmp[0]; | |
83 tmp[0] = tmp[2]; | |
84 tmp[2] = swap; | |
85 | |
86 swap = tmp[4]; | |
87 tmp[4] = tmp[6]; | |
88 tmp[6] = swap; | |
89 #endif | |
90 memcpy(&(pci->hli.btnit[i]), tmp, sizeof(pci->hli.btnit[i])); | |
7029 | 91 } |
92 | |
93 | |
15874 | 94 #ifndef NDEBUG |
7029 | 95 /* Asserts */ |
96 | |
97 /* pci pci gi */ | |
15874 | 98 CHECK_VALUE(pci->pci_gi.zero1 == 0); |
7029 | 99 |
100 /* pci hli hli_gi */ | |
15874 | 101 CHECK_VALUE(pci->hli.hl_gi.zero1 == 0); |
102 CHECK_VALUE(pci->hli.hl_gi.zero2 == 0); | |
103 CHECK_VALUE(pci->hli.hl_gi.zero3 == 0); | |
104 CHECK_VALUE(pci->hli.hl_gi.zero4 == 0); | |
105 CHECK_VALUE(pci->hli.hl_gi.zero5 == 0); | |
7029 | 106 |
107 /* Are there buttons defined here? */ | |
108 if((pci->hli.hl_gi.hli_ss & 0x03) != 0) { | |
15874 | 109 CHECK_VALUE(pci->hli.hl_gi.btn_ns != 0); |
110 CHECK_VALUE(pci->hli.hl_gi.btngr_ns != 0); | |
7029 | 111 } else { |
15874 | 112 CHECK_VALUE((pci->hli.hl_gi.btn_ns != 0 && pci->hli.hl_gi.btngr_ns != 0) |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
113 || (pci->hli.hl_gi.btn_ns == 0 && pci->hli.hl_gi.btngr_ns == 0)); |
7029 | 114 } |
115 | |
116 /* pci hli btnit */ | |
117 for(i = 0; i < pci->hli.hl_gi.btngr_ns; i++) { | |
118 for(j = 0; j < (36 / pci->hli.hl_gi.btngr_ns); j++) { | |
8257
635df9d22d38
100l patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents:
8254
diff
changeset
|
119 int n = (36 / pci->hli.hl_gi.btngr_ns) * i + j; |
15874 | 120 CHECK_VALUE(pci->hli.btnit[n].zero1 == 0); |
121 CHECK_VALUE(pci->hli.btnit[n].zero2 == 0); | |
122 CHECK_VALUE(pci->hli.btnit[n].zero3 == 0); | |
123 CHECK_VALUE(pci->hli.btnit[n].zero4 == 0); | |
124 CHECK_VALUE(pci->hli.btnit[n].zero5 == 0); | |
125 CHECK_VALUE(pci->hli.btnit[n].zero6 == 0); | |
7029 | 126 |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
127 if (j < pci->hli.hl_gi.btn_ns) { |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
128 CHECK_VALUE(pci->hli.btnit[n].x_start <= pci->hli.btnit[n].x_end); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
129 CHECK_VALUE(pci->hli.btnit[n].y_start <= pci->hli.btnit[n].y_end); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
130 CHECK_VALUE(pci->hli.btnit[n].up <= pci->hli.hl_gi.btn_ns); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
131 CHECK_VALUE(pci->hli.btnit[n].down <= pci->hli.hl_gi.btn_ns); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
132 CHECK_VALUE(pci->hli.btnit[n].left <= pci->hli.hl_gi.btn_ns); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
133 CHECK_VALUE(pci->hli.btnit[n].right <= pci->hli.hl_gi.btn_ns); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
134 //vmcmd_verify(pci->hli.btnit[n].cmd); |
7029 | 135 } else { |
24050
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
136 int k; |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
137 CHECK_VALUE(pci->hli.btnit[n].btn_coln == 0); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
138 CHECK_VALUE(pci->hli.btnit[n].auto_action_mode == 0); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
139 CHECK_VALUE(pci->hli.btnit[n].x_start == 0); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
140 CHECK_VALUE(pci->hli.btnit[n].y_start == 0); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
141 CHECK_VALUE(pci->hli.btnit[n].x_end == 0); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
142 CHECK_VALUE(pci->hli.btnit[n].y_end == 0); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
143 CHECK_VALUE(pci->hli.btnit[n].up == 0); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
144 CHECK_VALUE(pci->hli.btnit[n].down == 0); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
145 CHECK_VALUE(pci->hli.btnit[n].left == 0); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
146 CHECK_VALUE(pci->hli.btnit[n].right == 0); |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
147 for (k = 0; k < 8; k++) |
1542693b2a30
Sync libdvdread with version 0.9.5 (cosmetic changes).
diego
parents:
24047
diff
changeset
|
148 CHECK_VALUE(pci->hli.btnit[n].cmd.bytes[k] == 0); //CHECK_ZERO? |
7029 | 149 } |
150 } | |
151 } | |
15874 | 152 #endif /* !NDEBUG */ |
7029 | 153 } |
154 | |
155 void navRead_DSI(dsi_t *dsi, unsigned char *buffer) { | |
156 int i; | |
157 | |
15874 | 158 CHECK_VALUE(sizeof(dsi_t) == DSI_BYTES - 1); // -1 for substream id |
7029 | 159 |
160 memcpy(dsi, buffer, sizeof(dsi_t)); | |
161 | |
162 /* Endian conversions */ | |
163 | |
164 /* dsi dsi gi */ | |
165 B2N_32(dsi->dsi_gi.nv_pck_scr); | |
166 B2N_32(dsi->dsi_gi.nv_pck_lbn); | |
167 B2N_32(dsi->dsi_gi.vobu_ea); | |
168 B2N_32(dsi->dsi_gi.vobu_1stref_ea); | |
169 B2N_32(dsi->dsi_gi.vobu_2ndref_ea); | |
170 B2N_32(dsi->dsi_gi.vobu_3rdref_ea); | |
171 B2N_16(dsi->dsi_gi.vobu_vob_idn); | |
172 | |
173 /* dsi sml pbi */ | |
174 B2N_16(dsi->sml_pbi.category); | |
175 B2N_32(dsi->sml_pbi.ilvu_ea); | |
176 B2N_32(dsi->sml_pbi.ilvu_sa); | |
177 B2N_16(dsi->sml_pbi.size); | |
178 B2N_32(dsi->sml_pbi.vob_v_s_s_ptm); | |
179 B2N_32(dsi->sml_pbi.vob_v_e_e_ptm); | |
180 | |
181 /* dsi sml agli */ | |
182 for(i = 0; i < 9; i++) { | |
183 B2N_32(dsi->sml_agli.data[ i ].address); | |
184 B2N_16(dsi->sml_agli.data[ i ].size); | |
185 } | |
186 | |
187 /* dsi vobu sri */ | |
188 B2N_32(dsi->vobu_sri.next_video); | |
189 for(i = 0; i < 19; i++) | |
190 B2N_32(dsi->vobu_sri.fwda[i]); | |
191 B2N_32(dsi->vobu_sri.next_vobu); | |
192 B2N_32(dsi->vobu_sri.prev_vobu); | |
193 for(i = 0; i < 19; i++) | |
194 B2N_32(dsi->vobu_sri.bwda[i]); | |
195 B2N_32(dsi->vobu_sri.prev_video); | |
196 | |
197 /* dsi synci */ | |
198 for(i = 0; i < 8; i++) | |
199 B2N_16(dsi->synci.a_synca[i]); | |
200 for(i = 0; i < 32; i++) | |
201 B2N_32(dsi->synci.sp_synca[i]); | |
202 | |
203 | |
204 /* Asserts */ | |
205 | |
206 /* dsi dsi gi */ | |
15874 | 207 CHECK_VALUE(dsi->dsi_gi.zero1 == 0); |
7029 | 208 } |
209 |