00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef LIBDVDNAV_DVDNAV_INTERNAL_H
00022 #define LIBDVDNAV_DVDNAV_INTERNAL_H
00023
00024 #ifdef HAVE_CONFIG_H
00025 #include "config.h"
00026 #endif
00027
00028 #ifdef _WIN32
00029
00030
00031 #include <windows.h>
00032 #include <process.h>
00033 typedef CRITICAL_SECTION pthread_mutex_t;
00034 #define pthread_mutex_init(a, b) InitializeCriticalSection(a)
00035 #define pthread_mutex_lock(a) EnterCriticalSection(a)
00036 #define pthread_mutex_unlock(a) LeaveCriticalSection(a)
00037 #define pthread_mutex_destroy(a) DeleteCriticalSection(a)
00038
00039 #if HAVE_GETTIMEOFDAY == 0
00040
00041 #include <sys/timeb.h>
00042 static inline int _private_gettimeofday( struct timeval *tv, void *tz )
00043 {
00044 struct timeb t;
00045 ftime( &t );
00046 tv->tv_sec = t.time;
00047 tv->tv_usec = t.millitm * 1000;
00048 return 0;
00049 }
00050 #define gettimeofday(TV, TZ) _private_gettimeofday((TV), (TZ))
00051 #endif
00052
00053 #include <io.h>
00054 #define lseek64 _lseeki64
00055
00056 #else
00057
00058 #include <pthread.h>
00059
00060 #endif
00061
00062
00063 #define MSG_OUT stderr
00064
00065
00066 #define MAX_ERR_LEN 255
00067
00068
00069 #ifdef PATH_MAX
00070 #define MAX_PATH_LEN PATH_MAX
00071 #else
00072 #define MAX_PATH_LEN 255
00073 #endif
00074
00075 #ifndef DVD_VIDEO_LB_LEN
00076 #define DVD_VIDEO_LB_LEN 2048
00077 #endif
00078
00079 typedef struct read_cache_s read_cache_t;
00080
00081
00082
00083
00084
00085
00086 #ifndef audio_status_t
00087 typedef struct {
00088 #if HAVE_BIGENDIAN
00089 unsigned int available : 1;
00090 unsigned int zero1 : 4;
00091 unsigned int stream_number : 3;
00092 uint8_t zero2;
00093 #else
00094 uint8_t zero2;
00095 unsigned int stream_number : 3;
00096 unsigned int zero1 : 4;
00097 unsigned int available : 1;
00098 #endif
00099 } ATTRIBUTE_PACKED audio_status_t;
00100 #endif
00101
00102 #ifndef spu_status_t
00103 typedef struct {
00104 #if HAVE_BIGENDIAN
00105 unsigned int available : 1;
00106 unsigned int zero1 : 2;
00107 unsigned int stream_number_4_3 : 5;
00108 unsigned int zero2 : 3;
00109 unsigned int stream_number_wide : 5;
00110 unsigned int zero3 : 3;
00111 unsigned int stream_number_letterbox : 5;
00112 unsigned int zero4 : 3;
00113 unsigned int stream_number_pan_scan : 5;
00114 #else
00115 unsigned int stream_number_pan_scan : 5;
00116 unsigned int zero4 : 3;
00117 unsigned int stream_number_letterbox : 5;
00118 unsigned int zero3 : 3;
00119 unsigned int stream_number_wide : 5;
00120 unsigned int zero2 : 3;
00121 unsigned int stream_number_4_3 : 5;
00122 unsigned int zero1 : 2;
00123 unsigned int available : 1;
00124 #endif
00125 } ATTRIBUTE_PACKED spu_status_t;
00126 #endif
00127
00128 typedef struct dvdnav_vobu_s {
00129 int32_t vobu_start;
00130 int32_t vobu_length;
00131 int32_t blockN;
00132 int32_t vobu_next;
00133 } dvdnav_vobu_t;
00134
00137 struct dvdnav_s {
00138
00139 char path[MAX_PATH_LEN];
00140 dvd_file_t *file;
00141
00142
00143 vm_position_t position_next;
00144 vm_position_t position_current;
00145 dvdnav_vobu_t vobu;
00146
00147
00148 pci_t pci;
00149 dsi_t dsi;
00150 uint32_t last_cmd_nav_lbn;
00151
00152
00153 int skip_still;
00154 int sync_wait;
00155 int sync_wait_skip;
00156 int spu_clut_changed;
00157 int started;
00158 int use_read_ahead;
00159 int pgc_based;
00160 int cur_cell_time;
00161
00162
00163 vm_t *vm;
00164 pthread_mutex_t vm_lock;
00165
00166
00167 read_cache_t *cache;
00168
00169
00170 char err_str[MAX_ERR_LEN];
00171 };
00172
00175
00176 int64_t dvdnav_convert_time(dvd_time_t *time);
00177
00180 #ifdef __GNUC__
00181 #define printerrf(format, args...) \
00182 do { if (this) snprintf(this->err_str, MAX_ERR_LEN, format, ## args); } while (0)
00183 #else
00184 #ifdef _MSC_VER
00185 #define printerrf(str) \
00186 do { if (this) snprintf(this->err_str, MAX_ERR_LEN, str); } while (0)
00187 #else
00188 #define printerrf(...) \
00189 do { if (this) snprintf(this->err_str, MAX_ERR_LEN, __VA_ARGS__); } while (0)
00190 #endif
00191 #endif
00192 #define printerr(str) \
00193 do { if (this) strncpy(this->err_str, str, MAX_ERR_LEN - 1); } while (0)
00194
00195 #endif