Mercurial > libdvdread4.hg
comparison dvdnav_internal.h @ 0:427b7da5cbdb src
first split of dvdread; it's just a copy of dvdnav still to be cleaned
author | nicodvb |
---|---|
date | Sun, 01 Jun 2008 08:39:07 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:427b7da5cbdb |
---|---|
1 /* | |
2 * Copyright (C) 2001-2004 Rich Wareham <richwareham@users.sourceforge.net> | |
3 * | |
4 * This file is part of libdvdnav, a DVD navigation library. | |
5 * | |
6 * libdvdnav is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * libdvdnav is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
19 * | |
20 * $Id$ | |
21 * | |
22 */ | |
23 | |
24 #ifndef DVDNAV_INTERNAL_H_INCLUDED | |
25 #define DVDNAV_INTERNAL_H_INCLUDED | |
26 | |
27 #ifdef HAVE_CONFIG_H | |
28 #include "config.h" | |
29 #endif | |
30 | |
31 #ifdef WIN32 | |
32 | |
33 /* pthread_mutex_* wrapper for win32 */ | |
34 #include <windows.h> | |
35 #include <process.h> | |
36 typedef CRITICAL_SECTION pthread_mutex_t; | |
37 #define pthread_mutex_init(a, b) InitializeCriticalSection(a) | |
38 #define pthread_mutex_lock(a) EnterCriticalSection(a) | |
39 #define pthread_mutex_unlock(a) LeaveCriticalSection(a) | |
40 #define pthread_mutex_destroy(a) | |
41 | |
42 /* replacement gettimeofday implementation */ | |
43 #include <sys/timeb.h> | |
44 static inline int _private_gettimeofday( struct timeval *tv, void *tz ) | |
45 { | |
46 struct timeb t; | |
47 ftime( &t ); | |
48 tv->tv_sec = t.time; | |
49 tv->tv_usec = t.millitm * 1000; | |
50 return 0; | |
51 } | |
52 #define gettimeofday(TV, TZ) _private_gettimeofday((TV), (TZ)) | |
53 #include <io.h> /* read() */ | |
54 #define lseek64 _lseeki64 | |
55 | |
56 #else | |
57 | |
58 #include <pthread.h> | |
59 | |
60 #endif /* WIN32 */ | |
61 | |
62 /* where should libdvdnav write its messages (stdout/stderr) */ | |
63 #define MSG_OUT stdout | |
64 | |
65 /* Maximum length of an error string */ | |
66 #define MAX_ERR_LEN 255 | |
67 | |
68 /* Use the POSIX PATH_MAX if available */ | |
69 #ifdef PATH_MAX | |
70 #define MAX_PATH_LEN PATH_MAX | |
71 #else | |
72 #define MAX_PATH_LEN 255 /* Arbitrary */ | |
73 #endif | |
74 | |
75 #ifndef DVD_VIDEO_LB_LEN | |
76 #define DVD_VIDEO_LB_LEN 2048 | |
77 #endif | |
78 | |
79 typedef struct read_cache_s read_cache_t; | |
80 | |
81 /* | |
82 * These are defined here because they are | |
83 * not in ifo_types.h, they maybe one day | |
84 */ | |
85 | |
86 #ifndef audio_status_t | |
87 typedef struct { | |
88 #ifdef WORDS_BIGENDIAN | |
89 unsigned int available : 1; | |
90 unsigned int zero1 : 4; | |
91 unsigned int stream_number : 3; | |
92 uint8_t zero2; | |
93 #else | |
94 uint8_t zero2; | |
95 unsigned int stream_number : 3; | |
96 unsigned int zero1 : 4; | |
97 unsigned int available : 1; | |
98 #endif | |
99 } ATTRIBUTE_PACKED audio_status_t; | |
100 #endif | |
101 | |
102 #ifndef spu_status_t | |
103 typedef struct { | |
104 #ifdef WORDS_BIGENDIAN | |
105 unsigned int available : 1; | |
106 unsigned int zero1 : 2; | |
107 unsigned int stream_number_4_3 : 5; | |
108 unsigned int zero2 : 3; | |
109 unsigned int stream_number_wide : 5; | |
110 unsigned int zero3 : 3; | |
111 unsigned int stream_number_letterbox : 5; | |
112 unsigned int zero4 : 3; | |
113 unsigned int stream_number_pan_scan : 5; | |
114 #else | |
115 unsigned int stream_number_pan_scan : 5; | |
116 unsigned int zero4 : 3; | |
117 unsigned int stream_number_letterbox : 5; | |
118 unsigned int zero3 : 3; | |
119 unsigned int stream_number_wide : 5; | |
120 unsigned int zero2 : 3; | |
121 unsigned int stream_number_4_3 : 5; | |
122 unsigned int zero1 : 2; | |
123 unsigned int available : 1; | |
124 #endif | |
125 } ATTRIBUTE_PACKED spu_status_t; | |
126 #endif | |
127 | |
128 typedef struct dvdnav_vobu_s { | |
129 int32_t vobu_start; /* Logical Absolute. MAX needed is 0x300000 */ | |
130 int32_t vobu_length; | |
131 int32_t blockN; /* Relative offset */ | |
132 int32_t vobu_next; /* Relative offset */ | |
133 } dvdnav_vobu_t; | |
134 | |
135 /** The main DVDNAV type **/ | |
136 | |
137 struct dvdnav_s { | |
138 /* General data */ | |
139 char path[MAX_PATH_LEN]; /* Path to DVD device/dir */ | |
140 dvd_file_t *file; /* Currently opened file */ | |
141 | |
142 /* Position data */ | |
143 vm_position_t position_next; | |
144 vm_position_t position_current; | |
145 dvdnav_vobu_t vobu; | |
146 | |
147 /* NAV data */ | |
148 pci_t pci; | |
149 dsi_t dsi; | |
150 uint32_t last_cmd_nav_lbn; /* detects when a command is issued on an already left NAV */ | |
151 | |
152 /* Flags */ | |
153 int skip_still; /* Set when skipping a still */ | |
154 int sync_wait; /* applications should wait till they are in sync with us */ | |
155 int sync_wait_skip; /* Set when skipping wait state */ | |
156 int spu_clut_changed; /* The SPU CLUT changed */ | |
157 int started; /* vm_start has been called? */ | |
158 int use_read_ahead; /* 1 - use read-ahead cache, 0 - don't */ | |
159 int pgc_based; /* positioning works PGC based instead of PG based */ | |
160 int cur_cell_time; /* time expired since the beginning of the current cell, read from the dsi */ | |
161 | |
162 /* VM */ | |
163 vm_t *vm; | |
164 pthread_mutex_t vm_lock; | |
165 | |
166 /* Read-ahead cache */ | |
167 read_cache_t *cache; | |
168 | |
169 /* Errors */ | |
170 char err_str[MAX_ERR_LEN]; | |
171 }; | |
172 | |
173 /** HELPER FUNCTIONS **/ | |
174 | |
175 /* converts a dvd_time_t to PTS ticks */ | |
176 int64_t dvdnav_convert_time(dvd_time_t *time); | |
177 | |
178 /** USEFUL MACROS **/ | |
179 | |
180 #ifdef __GNUC__ | |
181 #define printerrf(format, args...) \ | |
182 do { if (this) snprintf(this->err_str, MAX_ERR_LEN, format, ## args); } while (0) | |
183 #else | |
184 #ifdef _MSC_VER | |
185 #define printerrf(str) \ | |
186 do { if (this) snprintf(this->err_str, MAX_ERR_LEN, str); } while (0) | |
187 #else | |
188 #define printerrf(...) \ | |
189 do { if (this) snprintf(this->err_str, MAX_ERR_LEN, __VA_ARGS__); } while (0) | |
190 #endif /* WIN32 */ | |
191 #endif | |
192 #define printerr(str) \ | |
193 do { if (this) strncpy(this->err_str, str, MAX_ERR_LEN - 1); } while (0) | |
194 | |
195 #endif /* DVDNAV_INTERNAL_H_INCLUDED */ |