Mercurial > mplayer.hg
annotate mplayer.c @ 1422:d02e0dcaf077
libvo2 support
author | arpi |
---|---|
date | Mon, 30 Jul 2001 02:00:54 +0000 |
parents | ea0a0b9e6fbc |
children | a90d889eb649 |
rev | line source |
---|---|
1237 | 1 // AVI & MPEG Player v0.18 (C) 2000-2001. by A'rpi/ESP-team |
1 | 2 |
3 #include <stdio.h> | |
4 #include <stdlib.h> | |
109 | 5 #include <string.h> |
1 | 6 |
7 #include <signal.h> | |
8 | |
9 #include <sys/ioctl.h> | |
10 #include <unistd.h> | |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
11 #include <time.h> |
1 | 12 #include <sys/mman.h> |
13 | |
14 #include <sys/types.h> | |
15 #include <sys/wait.h> | |
16 #include <sys/time.h> | |
17 #include <sys/stat.h> | |
18 #include <fcntl.h> | |
19 | |
20 #include "version.h" | |
21 #include "config.h" | |
22 | |
1289 | 23 #ifdef __FreeBSD__ |
1177
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1156
diff
changeset
|
24 #include <sys/cdrio.h> |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
25 #endif |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
26 |
1289 | 27 #ifdef sun |
28 #define DEFAULT_CDROM_DEVICE "/vol/dev/aliases/cdrom0" | |
29 #else | |
30 #define DEFAULT_CDROM_DEVICE "/dev/cdrom" | |
31 #endif | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
32 |
147 | 33 #include "cfgparser.h" |
151 | 34 #include "cfg-mplayer-def.h" |
147 | 35 |
1422 | 36 #ifdef USE_SUB |
258 | 37 #include "subreader.h" |
1422 | 38 #endif |
258 | 39 |
1422 | 40 #ifdef USE_LIBVO2 |
41 #include "libvo2/libvo2.h" | |
42 #else | |
36 | 43 #include "libvo/video_out.h" |
1422 | 44 #endif |
45 | |
46 //#ifdef USE_OSD | |
220 | 47 #include "libvo/sub.h" |
1422 | 48 //#endif |
36 | 49 |
955 | 50 #include "libao2/audio_out.h" |
51 | |
1 | 52 #include "libmpeg2/mpeg2.h" |
53 #include "libmpeg2/mpeg2_internal.h" | |
54 | |
55 #include "loader.h" | |
56 #include "wine/avifmt.h" | |
57 | |
303 | 58 #include "codec-cfg.h" |
175 | 59 |
492 | 60 #include "dvdauth.h" |
560
28ae99036574
Separated dvdsub code to be able to work with it easier
lgb
parents:
557
diff
changeset
|
61 #include "spudec.h" |
492 | 62 |
1 | 63 extern char* win32_codec_name; // must be set before calling DrvOpen() !!! |
64 | |
65 #include "linux/getch2.h" | |
66 #include "linux/keycodes.h" | |
67 #include "linux/timer.h" | |
68 #include "linux/shmem.h" | |
69 | |
70 #ifdef HAVE_LIRC | |
71 #include "lirc_mp.h" | |
72 #endif | |
73 | |
74 #include "help_mp.h" | |
75 | |
842
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
76 #ifdef STREAMING |
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
77 #include "url.h" |
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
78 #include "network.h" |
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
79 static URL_t* url; |
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
80 #endif |
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
81 |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
82 |
1 | 83 #define DEBUG if(0) |
723 | 84 #ifdef HAVE_GUI |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
85 int nogui=1; |
723 | 86 #endif |
362 | 87 int verbose=0; |
1 | 88 |
398 | 89 #define ABS(x) (((x)>=0)?(x):(-(x))) |
90 | |
1422 | 91 #ifdef USE_SUB |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
92 void find_sub(subtitle* subtitles,int key); |
1422 | 93 #endif |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
94 |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
95 static int |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
96 usec_sleep(int usec_delay) |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
97 { |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
98 #if 1 |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
99 struct timespec ts; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
100 ts.tv_sec = usec_delay / 1000000; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
101 ts.tv_nsec = (usec_delay % 1000000) * 1000; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
102 return nanosleep(&ts, NULL); |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
103 #else |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
104 return usleep(usec_delay); |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
105 #endif |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
106 } |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
107 |
258 | 108 //**************************************************************************// |
109 // Config file | |
110 //**************************************************************************// | |
111 | |
153 | 112 static int cfg_inc_verbose(struct config *conf){ |
113 ++verbose; | |
114 return 0; | |
115 } | |
116 | |
162 | 117 static int cfg_include(struct config *conf, char *filename){ |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
118 return parse_config_file(conf, filename); |
162 | 119 } |
120 | |
178 | 121 char *get_path(char *filename){ |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
122 char *homedir; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
123 char *buff; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
124 static char *config_dir = "/.mplayer"; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
125 int len; |
178 | 126 |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
127 if ((homedir = getenv("HOME")) == NULL) |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
128 return NULL; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
129 len = strlen(homedir) + strlen(config_dir) + 1; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
130 if (filename == NULL) { |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
131 if ((buff = (char *) malloc(len)) == NULL) |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
132 return NULL; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
133 sprintf(buff, "%s%s", homedir, config_dir); |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
134 } else { |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
135 len += strlen(filename) + 1; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
136 if ((buff = (char *) malloc(len)) == NULL) |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
137 return NULL; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
138 sprintf(buff, "%s%s/%s", homedir, config_dir, filename); |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
139 } |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
140 return buff; |
178 | 141 } |
142 | |
1 | 143 //**************************************************************************// |
442 | 144 //**************************************************************************// |
145 // Input media streaming & demultiplexer: | |
146 //**************************************************************************// | |
147 | |
1289 | 148 static int max_framesize=0; |
149 | |
578 | 150 #include "stream.h" |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
151 #include "demuxer.h" |
442 | 152 |
153 #include "stheader.h" | |
1 | 154 |
442 | 155 char* encode_name=NULL; |
156 char* encode_index_name=NULL; | |
157 int encode_bitrate=0; | |
291 | 158 |
1015 | 159 extern int asf_packetsize; // for seeking |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
160 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
161 extern float avi_audio_pts; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
162 extern float avi_video_pts; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
163 extern float avi_video_ftime; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
164 extern int skip_video_frames; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
165 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
166 void read_avi_header(demuxer_t *demuxer,int index_mode); |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
167 demux_stream_t* demux_avi_select_stream(demuxer_t *demux,unsigned int id); |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
168 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
169 int asf_check_header(demuxer_t *demuxer); |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
170 int read_asf_header(demuxer_t *demuxer); |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
171 |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
172 demuxer_t* demux_open(stream_t *stream,int file_format); |
1405 | 173 int demux_seek(demuxer_t *demuxer,float rel_seek_secs,int flags); |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
174 |
1 | 175 // MPEG video stream parser: |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
176 #include "parse_es.h" |
1 | 177 |
1015 | 178 extern int num_elementary_packets100; // for MPEG-ES fileformat detection |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
179 extern int num_elementary_packets101; |
1338
345585097137
mpeg PES steram support (only 1E0 & 1C0 packets, no 1BA/1BB headers)
arpi
parents:
1334
diff
changeset
|
180 extern int num_elementary_packetsPES; |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
181 |
1015 | 182 extern picture_t *picture; // exported from libmpeg2/decode.c |
442 | 183 |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
184 int frameratecode2framerate[16] = { |
780 | 185 0, |
186 // Official mpeg1/2 framerates: | |
187 24000*10000/1001, 24*10000,25*10000, 30000*10000/1001, 30*10000,50*10000,60000*10000/1001, 60*10000, | |
188 // libmpeg3's "Unofficial economy rates": | |
189 1*10000,5*10000,10*10000,12*10000,15*10000,0,0 | |
112 | 190 }; |
191 | |
111 | 192 //**************************************************************************// |
1 | 193 //**************************************************************************// |
194 | |
112 | 195 // Common FIFO functions, and keyboard/event FIFO code |
196 #include "fifo.c" | |
197 | |
1 | 198 //**************************************************************************// |
199 | |
1422 | 200 #ifdef USE_LIBVO2 |
201 static vo2_handle_t *video_out=NULL; | |
202 #else | |
1 | 203 static vo_functions_t *video_out=NULL; |
1422 | 204 #endif |
1289 | 205 static ao_functions_t *audio_out=NULL; |
1 | 206 |
1400 | 207 float c_total=0; |
208 | |
1291 | 209 double video_time_usage=0; |
210 double vout_time_usage=0; | |
1289 | 211 static double audio_time_usage=0; |
212 static int total_time_usage_start=0; | |
213 static int benchmark=0; | |
1124
0e95f30ffd4c
-frames and -benchmark options to make chl & gabucino happy
arpi_esp
parents:
1059
diff
changeset
|
214 |
1 | 215 static int play_in_bg=0; |
216 | |
606 | 217 extern void avi_fixate(); |
218 | |
723 | 219 #ifdef HAVE_GUI |
220 #include "../Gui/mplayer/psignal.h" | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
221 #define GUI_MSG(x) if ( !nogui ) { mplSendMessage( x ); usec_sleep( 10000 ); } |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
222 #else |
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
223 #define GUI_MSG(x) |
723 | 224 #endif |
225 | |
1014
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
226 // options: |
1015 | 227 int osd_level=2; |
1014
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
228 int divx_quality=0; |
937 | 229 char *seek_to_sec=NULL; |
1 | 230 int seek_to_byte=0; |
442 | 231 int has_audio=1; |
1286
543a94b241a2
Replaced LGBs video codec forcing change with mine for audio and video codecs, which is IMHO more convenient cause codecs are selected by name instead of number, one unclearity is left to me, that's why audio_format is used once before codecs selection for MPEG_PS files, that's why I left -afm in for that one.
atmos4
parents:
1285
diff
changeset
|
232 char *audio_codec=NULL; // override audio codec |
543a94b241a2
Replaced LGBs video codec forcing change with mine for audio and video codecs, which is IMHO more convenient cause codecs are selected by name instead of number, one unclearity is left to me, that's why audio_format is used once before codecs selection for MPEG_PS files, that's why I left -afm in for that one.
atmos4
parents:
1285
diff
changeset
|
233 char *video_codec=NULL; // override video codec |
1299
fa50e6bc6091
As promised, -afm and -vfm to prefer audio/video driver family, -ac and -vc have higher precedence, so they can override -afm/-vfm.
atmos4
parents:
1296
diff
changeset
|
234 int audio_family=-1; // override audio codec family |
fa50e6bc6091
As promised, -afm and -vfm to prefer audio/video driver family, -ac and -vc have higher precedence, so they can override -afm/-vfm.
atmos4
parents:
1296
diff
changeset
|
235 int video_family=-1; // override video codec family |
1285
202d9e2dc202
-vcodec option (maybe some other name would be better though) to select between driver types without editing codecs.conf. mplayer will default to normal codec search loop if it does not find codec for the specified driver type. config range checking for the parameter (an integer) should be cleaned, IMHO
lgb
parents:
1255
diff
changeset
|
236 |
1299
fa50e6bc6091
As promised, -afm and -vfm to prefer audio/video driver family, -ac and -vc have higher precedence, so they can override -afm/-vfm.
atmos4
parents:
1296
diff
changeset
|
237 // IMHO this stuff is no longer of use, or is there a special |
fa50e6bc6091
As promised, -afm and -vfm to prefer audio/video driver family, -ac and -vc have higher precedence, so they can override -afm/-vfm.
atmos4
parents:
1296
diff
changeset
|
238 // reason why dshow should be completely disabled? - atmos :: |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1302
diff
changeset
|
239 // yes, people without working c++ compiler can disable it - A'rpi |
626 | 240 #ifdef USE_DIRECTSHOW |
241 int allow_dshow=1; | |
242 #else | |
243 int allow_dshow=0; | |
244 #endif | |
1014
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
245 |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
246 //#ifdef ALSA_TIMER |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
247 //int alsa=1; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
248 //#else |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
249 //int alsa=0; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
250 //#endif |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
251 |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
252 // streaming: |
1 | 253 int audio_id=-1; |
254 int video_id=-1; | |
552 | 255 int dvdsub_id=-1; |
1014
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
256 int vcd_track=0; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
257 char *stream_dump_name=NULL; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
258 int stream_dump_type=0; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
259 int index_mode=-1; // -1=untouched 0=don't use index 1=use (geneate) index |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
260 int force_ni=0; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
261 |
780 | 262 float default_max_pts_correction=-1;//0.01f; |
1400 | 263 float max_pts_correction=0;//default_max_pts_correction; |
1 | 264 #ifdef AVI_SYNC_BPS |
265 int pts_from_bps=1; | |
266 #else | |
267 int pts_from_bps=0; | |
268 #endif | |
1014
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
269 |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
270 float force_fps=0; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
271 int force_srate=0; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
272 float audio_delay=0; |
798 | 273 int frame_dropping=0; // option 0=no drop 1= drop vo 2= drop decode |
1124
0e95f30ffd4c
-frames and -benchmark options to make chl & gabucino happy
arpi_esp
parents:
1059
diff
changeset
|
274 int play_n_frames=-1; |
1014
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
275 |
1 | 276 // screen info: |
277 char* video_driver=NULL; //"mga"; // default | |
956
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
278 char* audio_driver=NULL; |
1 | 279 int fullscreen=0; |
208
ae0f909ccc7c
Adds code to deal with vidmode selection. -- mgraffam
mgraffam
parents:
190
diff
changeset
|
280 int vidmode=0; |
337 | 281 int softzoom=0; |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
282 int flip=-1; |
337 | 283 int screen_size_x=0;//SCREEN_SIZE_X; |
284 int screen_size_y=0;//SCREEN_SIZE_Y; | |
1 | 285 int screen_size_xy=0; |
1014
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
286 |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
287 // sub: |
212 | 288 char *font_name=NULL; |
215 | 289 float font_factor=0.75; |
258 | 290 char *sub_name=NULL; |
291 float sub_delay=0; | |
292 float sub_fps=0; | |
510 | 293 int sub_auto = 1; |
1255
94f2853ec6f4
-dsp option removed, displaying help text (-ao oss:dsp_path)
alex
parents:
1250
diff
changeset
|
294 /*DSP!!char *dsp=NULL;*/ |
723 | 295 |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
296 float rel_seek_secs=0; |
1400 | 297 float initial_pts_delay=0; |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
298 |
1183 | 299 extern char *vo_subdevice; |
300 extern char *ao_subdevice; | |
1156 | 301 |
302 void exit_player(char* how){ | |
303 total_time_usage_start=GetTimer()-total_time_usage_start; | |
304 | |
305 #ifdef HAVE_GUI | |
306 if ( !nogui ) | |
307 { | |
308 if ( how != NULL ) | |
309 { | |
310 if ( !strcmp( how,"Quit" ) ) mplSendMessage( mplEndOfFile ); | |
311 if ( !strcmp( how,"End of file" ) ) mplSendMessage( mplEndOfFile ); | |
312 if ( !strcmp( how,"audio_init" ) ) mplSendMessage( mplAudioError ); | |
313 } | |
314 else mplSendMessage( mplUnknowError ); | |
315 } | |
316 #endif | |
317 | |
318 if(how) printf("\nExiting... (%s)\n",how); | |
319 if(verbose) printf("max framesize was %d bytes\n",max_framesize); | |
320 if(benchmark){ | |
321 double tot=video_time_usage+vout_time_usage+audio_time_usage; | |
322 double total_time_usage=(float)total_time_usage_start*0.000001; | |
323 printf("BENCHMARKs: V:%8.3fs VO:%8.3fs A:%8.3fs Sys:%8.3fs = %8.3fs\n", | |
324 video_time_usage,vout_time_usage,audio_time_usage, | |
325 total_time_usage-tot,total_time_usage); | |
326 if(total_time_usage>0.0) | |
327 printf("BENCHMARK%%: V:%8.4f%% VO:%8.4f%% A:%8.4f%% Sys:%8.4f%% = %8.4f%%\n", | |
328 100.0*video_time_usage/total_time_usage, | |
329 100.0*vout_time_usage/total_time_usage, | |
330 100.0*audio_time_usage/total_time_usage, | |
331 100.0*(total_time_usage-tot)/total_time_usage, | |
332 100.0); | |
333 } | |
334 // restore terminal: | |
335 #ifdef HAVE_GUI | |
336 if ( nogui ) | |
337 #endif | |
338 getch2_disable(); | |
1422 | 339 #ifdef USE_LIBVO2 |
340 if(video_out) vo2_close(video_out); | |
341 #else | |
1156 | 342 if(video_out) video_out->uninit(); |
1422 | 343 #endif |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
344 if(audio_out) audio_out->uninit(); |
1156 | 345 if(encode_name) avi_fixate(); |
346 #ifdef HAVE_LIRC | |
347 #ifdef HAVE_GUI | |
348 if ( nogui ) | |
349 #endif | |
350 lirc_mp_cleanup(); | |
351 #endif | |
352 exit(1); | |
353 } | |
354 | |
1400 | 355 char* current_module=NULL; // for debugging |
1156 | 356 |
357 void exit_sighandler(int x){ | |
358 static int sig_count=0; | |
359 ++sig_count; | |
360 if(sig_count==2) exit(1); | |
361 if(sig_count>2){ | |
362 // can't stop :( | |
363 kill(getpid(),SIGKILL); | |
364 } | |
1217 | 365 fprintf(stderr,"\nMPlayer interrupted by signal %d in module: %s \n",x, |
1156 | 366 current_module?current_module:"unknown" |
367 ); | |
368 #ifdef HAVE_GUI | |
369 if ( !nogui ) | |
370 { | |
371 mplShMem->items.error.signal=x; | |
372 strcpy( mplShMem->items.error.module,current_module?current_module:"unknown" ); | |
373 } | |
374 #endif | |
375 exit_player(NULL); | |
376 } | |
377 | |
378 extern int vcd_get_track_end(int fd,int track); | |
379 extern void write_avi_header_1(FILE *f,int fcc,float fps,int width,int height); | |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1302
diff
changeset
|
380 |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1302
diff
changeset
|
381 // dec_audio.c: |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1302
diff
changeset
|
382 extern int init_audio(sh_audio_t *sh_audio); |
1156 | 383 extern int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen); |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1302
diff
changeset
|
384 extern void resync_audio_stream(sh_audio_t *sh_audio); |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1302
diff
changeset
|
385 extern void skip_audio_frame(sh_audio_t *sh_audio); |
1156 | 386 |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1302
diff
changeset
|
387 // dec_video.c: |
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1302
diff
changeset
|
388 extern int init_video(sh_video_t *sh_video); |
1422 | 389 #ifdef USE_LIBVO2 |
390 extern int decode_video(vo2_handle_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame); | |
391 #else | |
1327
b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
arpi
parents:
1302
diff
changeset
|
392 extern int decode_video(vo_functions_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame); |
1422 | 393 #endif |
1156 | 394 |
459 | 395 #include "mixer.h" |
147 | 396 #include "cfg-mplayer.h" |
1 | 397 |
723 | 398 void parse_cfgfiles( void ) |
399 { | |
1014
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
400 char *conffile; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
401 int conffile_fd; |
147 | 402 if (parse_config_file(conf, "/etc/mplayer.conf") < 0) |
403 exit(1); | |
178 | 404 if ((conffile = get_path("")) == NULL) { |
147 | 405 printf("Can't find HOME dir\n"); |
406 } else { | |
178 | 407 mkdir(conffile, 0777); |
408 free(conffile); | |
409 if ((conffile = get_path("config")) == NULL) { | |
410 printf("get_path(\"config\") sziiiivas\n"); | |
411 } else { | |
412 if ((conffile_fd = open(conffile, O_CREAT | O_EXCL | O_WRONLY, 0666)) != -1) { | |
413 printf("Creating config file: %s\n", conffile); | |
414 write(conffile_fd, default_config, strlen(default_config)); | |
415 close(conffile_fd); | |
416 } | |
417 if (parse_config_file(conf, conffile) < 0) | |
418 exit(1); | |
419 free(conffile); | |
151 | 420 } |
1 | 421 } |
422 } | |
423 | |
723 | 424 #ifndef HAVE_GUI |
425 int main(int argc,char* argv[], char *envp[]){ | |
426 #else | |
427 int mplayer(int argc,char* argv[], char *envp[]){ | |
428 #endif | |
429 | |
1422 | 430 #ifdef USE_SUB |
1289 | 431 static subtitle* subtitles=NULL; |
1422 | 432 #endif |
1289 | 433 |
434 static demuxer_t *demuxer=NULL; | |
435 | |
436 static demux_stream_t *d_audio=NULL; | |
437 static demux_stream_t *d_video=NULL; | |
438 static demux_stream_t *d_dvdsub=NULL; | |
439 | |
440 static sh_audio_t *sh_audio=NULL; | |
441 static sh_video_t *sh_video=NULL; | |
442 | |
1014
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
443 char* filename=NULL; //"MI2-Trailer.avi"; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
444 stream_t* stream=NULL; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
445 int file_format=DEMUXER_TYPE_UNKNOWN; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
446 // |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
447 int delay_corrected=1; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
448 #ifdef VCD_CACHE |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
449 int vcd_cache_size=128; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
450 #endif |
1177
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1156
diff
changeset
|
451 #ifdef __FreeBSD__ |
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1156
diff
changeset
|
452 int bsize = VCD_SECTOR_SIZE; |
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1156
diff
changeset
|
453 #endif |
1014
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
454 char* title="MPlayer"; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
455 |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
456 // movie info: |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
457 int out_fmt=0; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
458 |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
459 int osd_visible=100; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
460 int osd_function=OSD_PLAY; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
461 int osd_last_pts=-303; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
462 |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
463 //float a_frame=0; // Audio |
1014
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
464 |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
465 float rel_seek_secs=0; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
466 |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
467 int i; |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
468 int f; // filedes |
e01dc1a88edf
fixed punkso's mess... local variables moved back to main()
arpi_esp
parents:
1009
diff
changeset
|
469 |
723 | 470 printf("%s",banner_text); |
471 | |
472 #ifdef HAVE_GUI | |
473 if ( nogui ) | |
474 { | |
475 #endif | |
751 | 476 parse_cfgfiles(); |
723 | 477 if (parse_command_line(conf, argc, argv, envp, &filename) < 0) exit(1); |
478 | |
479 // Many users forget to include command line in bugreports... | |
480 if(verbose){ | |
481 printf("CommandLine:"); | |
482 for(i=1;i<argc;i++)printf(" '%s'",argv[i]); | |
483 printf("\n"); | |
484 } | |
485 | |
1422 | 486 #ifndef USE_LIBVO2 |
723 | 487 if(video_driver && strcmp(video_driver,"help")==0){ |
488 printf("Available video output drivers:\n"); | |
489 i=0; | |
490 while (video_out_drivers[i]) { | |
491 const vo_info_t *info = video_out_drivers[i++]->get_info (); | |
492 printf("\t%s\t%s\n", info->short_name, info->name); | |
493 } | |
494 printf("\n"); | |
495 exit(0); | |
956
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
496 } |
1422 | 497 #endif |
956
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
498 if(audio_driver && strcmp(audio_driver,"help")==0){ |
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
499 printf("Available audio output drivers:\n"); |
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
500 i=0; |
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
501 while (audio_out_drivers[i]) { |
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
502 const ao_info_t *info = audio_out_drivers[i++]->info; |
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
503 printf("\t%s\t%s\n", info->short_name, info->name); |
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
504 } |
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
505 printf("\n"); |
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
506 exit(0); |
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
507 } |
723 | 508 #ifdef HAVE_GUI |
509 } | |
510 #endif | |
1 | 511 |
442 | 512 if(!filename){ |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
513 if(vcd_track) filename=DEFAULT_CDROM_DEVICE; |
442 | 514 else { |
515 printf("%s",help_text); exit(0); | |
516 } | |
517 } | |
518 | |
1422 | 519 #ifdef USE_LIBVO2 |
520 video_out=vo2_new(video_driver); | |
521 #else | |
442 | 522 // check video_out driver name: |
1183 | 523 if (video_driver) |
524 if ((i = strcspn(video_driver, ":")) > 0) | |
525 { | |
526 size_t i2 = strlen(video_driver); | |
527 | |
1190
98f732a23cb4
egy hulye kis checking kimaradt az strcspn fv. jovoltabol
al3x
parents:
1183
diff
changeset
|
528 if (video_driver[i] == ':') |
98f732a23cb4
egy hulye kis checking kimaradt az strcspn fv. jovoltabol
al3x
parents:
1183
diff
changeset
|
529 { |
98f732a23cb4
egy hulye kis checking kimaradt az strcspn fv. jovoltabol
al3x
parents:
1183
diff
changeset
|
530 vo_subdevice = malloc(i2-i); |
98f732a23cb4
egy hulye kis checking kimaradt az strcspn fv. jovoltabol
al3x
parents:
1183
diff
changeset
|
531 if (vo_subdevice != NULL) |
98f732a23cb4
egy hulye kis checking kimaradt az strcspn fv. jovoltabol
al3x
parents:
1183
diff
changeset
|
532 strncpy(vo_subdevice, (char *)(video_driver+i+1), i2-i); |
98f732a23cb4
egy hulye kis checking kimaradt az strcspn fv. jovoltabol
al3x
parents:
1183
diff
changeset
|
533 video_driver[i] = '\0'; |
98f732a23cb4
egy hulye kis checking kimaradt az strcspn fv. jovoltabol
al3x
parents:
1183
diff
changeset
|
534 } |
1183 | 535 // printf("video_driver: %s, subdevice: %s\n", video_driver, vo_subdevice); |
536 } | |
442 | 537 if(!video_driver) |
538 video_out=video_out_drivers[0]; | |
539 else | |
540 for (i=0; video_out_drivers[i] != NULL; i++){ | |
541 const vo_info_t *info = video_out_drivers[i]->get_info (); | |
542 if(strcmp(info->short_name,video_driver) == 0){ | |
543 video_out = video_out_drivers[i];break; | |
544 } | |
545 } | |
1422 | 546 #endif |
442 | 547 if(!video_out){ |
1422 | 548 fprintf(stderr,"Invalid video output driver name: %s\nUse '-vo help' to get a list of available video drivers.\n",video_driver?video_driver:"?"); |
956
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
549 return 0; |
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
550 } |
1422 | 551 |
956
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
552 // check audio_out driver name: |
1183 | 553 if (audio_driver) |
554 if ((i = strcspn(audio_driver, ":")) > 0) | |
555 { | |
556 size_t i2 = strlen(audio_driver); | |
557 | |
1190
98f732a23cb4
egy hulye kis checking kimaradt az strcspn fv. jovoltabol
al3x
parents:
1183
diff
changeset
|
558 if (audio_driver[i] == ':') |
98f732a23cb4
egy hulye kis checking kimaradt az strcspn fv. jovoltabol
al3x
parents:
1183
diff
changeset
|
559 { |
98f732a23cb4
egy hulye kis checking kimaradt az strcspn fv. jovoltabol
al3x
parents:
1183
diff
changeset
|
560 ao_subdevice = malloc(i2-i); |
98f732a23cb4
egy hulye kis checking kimaradt az strcspn fv. jovoltabol
al3x
parents:
1183
diff
changeset
|
561 if (ao_subdevice != NULL) |
98f732a23cb4
egy hulye kis checking kimaradt az strcspn fv. jovoltabol
al3x
parents:
1183
diff
changeset
|
562 strncpy(ao_subdevice, (char *)(audio_driver+i+1), i2-i); |
98f732a23cb4
egy hulye kis checking kimaradt az strcspn fv. jovoltabol
al3x
parents:
1183
diff
changeset
|
563 audio_driver[i] = '\0'; |
98f732a23cb4
egy hulye kis checking kimaradt az strcspn fv. jovoltabol
al3x
parents:
1183
diff
changeset
|
564 } |
1183 | 565 // printf("audio_driver: %s, subdevice: %s\n", audio_driver, ao_subdevice); |
566 } | |
956
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
567 if(!audio_driver) |
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
568 audio_out=audio_out_drivers[0]; |
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
569 else |
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
570 for (i=0; audio_out_drivers[i] != NULL; i++){ |
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
571 const ao_info_t *info = audio_out_drivers[i]->info; |
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
572 if(strcmp(info->short_name,audio_driver) == 0){ |
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
573 audio_out = audio_out_drivers[i];break; |
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
574 } |
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
575 } |
a6cecd9a1bad
'-ao' switch (including '-ao help'), fixing Arpi's bug (short name 'null' for both of oss and null driver ;)
lgb
parents:
955
diff
changeset
|
576 if (!audio_out){ |
1217 | 577 fprintf(stderr,"Invalid audio output driver name: %s\nUse '-ao help' to get a list of available audio drivers.\n",audio_driver); |
442 | 578 return 0; |
579 } | |
1255
94f2853ec6f4
-dsp option removed, displaying help text (-ao oss:dsp_path)
alex
parents:
1250
diff
changeset
|
580 /*DSP!! if(dsp) audio_out->control(AOCONTROL_SET_DEVICE,(int)dsp);*/ |
955 | 581 |
442 | 582 // check codec.conf |
583 if(!parse_codec_cfg(get_path("codecs.conf"))){ | |
1353 | 584 if(!parse_codec_cfg(DATADIR"/codecs.conf")){ |
585 printf("(copy/link DOCS/codecs.conf to ~/.mplayer/codecs.conf)\n"); | |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
586 GUI_MSG( mplCodecConfNotFound ) |
442 | 587 exit(1); |
1353 | 588 } |
442 | 589 } |
590 | |
212 | 591 // check font |
1422 | 592 #ifdef USE_OSD |
212 | 593 if(font_name){ |
337 | 594 vo_font=read_font_desc(font_name,font_factor,verbose>1); |
1217 | 595 if(!vo_font) fprintf(stderr,"Can't load font: %s\n",font_name); |
220 | 596 } else { |
597 // try default: | |
337 | 598 vo_font=read_font_desc(get_path("font/font.desc"),font_factor,verbose>1); |
1353 | 599 if(!vo_font) |
600 vo_font=read_font_desc(DATADIR"/font/font.desc",font_factor,verbose>1); | |
212 | 601 } |
1422 | 602 #endif |
212 | 603 |
1422 | 604 #ifdef USE_SUB |
258 | 605 // check .sub |
606 if(sub_name){ | |
607 subtitles=sub_read_file(sub_name); | |
1217 | 608 if(!subtitles) fprintf(stderr,"Can't load subtitles: %s\n",sub_name); |
258 | 609 } else { |
510 | 610 if ( sub_auto ) |
611 { | |
612 // auto load sub file ... | |
892 | 613 subtitles=sub_read_file( sub_filename( get_path("sub/"), filename ) ); |
614 } | |
615 if ( subtitles == NULL ) subtitles=sub_read_file(get_path("default.sub")); // try default: | |
258 | 616 } |
1422 | 617 #endif |
258 | 618 |
1 | 619 if(vcd_track){ |
620 //============ Open VideoCD track ============== | |
598 | 621 int ret,ret2; |
1 | 622 f=open(filename,O_RDONLY); |
1217 | 623 if(f<0){ fprintf(stderr,"CD-ROM Device '%s' not found!\n",filename);return 1; } |
1 | 624 vcd_read_toc(f); |
598 | 625 ret2=vcd_get_track_end(f,vcd_track); |
1296 | 626 if(ret2<0){ fprintf(stderr,"Error selecting VCD track! (get)\n");return 1;} |
578 | 627 ret=vcd_seek_to_track(f,vcd_track); |
1296 | 628 if(ret<0){ fprintf(stderr,"Error selecting VCD track! (seek)\n");return 1;} |
578 | 629 seek_to_byte+=ret; |
598 | 630 if(verbose) printf("VCD start byte position: 0x%X end: 0x%X\n",seek_to_byte,ret2); |
1 | 631 #ifdef VCD_CACHE |
632 vcd_cache_init(vcd_cache_size); | |
633 #endif | |
1177
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1156
diff
changeset
|
634 #ifdef __FreeBSD__ |
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1156
diff
changeset
|
635 if (ioctl (f, CDRIOCSETBLOCKSIZE, &bsize) == -1) { |
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1156
diff
changeset
|
636 perror ( "Error in CDRIOCSETBLOCKSIZE"); |
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1156
diff
changeset
|
637 } |
f2516027a346
FreeBSD patch by Vladimir Kushnir <vkushnir@Alfacom.net>
arpi_esp
parents:
1156
diff
changeset
|
638 #endif |
598 | 639 stream=new_stream(f,STREAMTYPE_VCD); |
640 stream->start_pos=ret; | |
641 stream->end_pos=ret2; | |
1 | 642 } else { |
643 //============ Open plain FILE ============ | |
598 | 644 int len; |
692 | 645 if(!strcmp(filename,"-")){ |
646 // read from stdin | |
647 printf("Reading from stdin...\n"); | |
648 f=0; // 0=stdin | |
649 stream=new_stream(f,STREAMTYPE_STREAM); | |
650 } else { | |
842
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
651 #ifdef STREAMING |
906 | 652 url = url_new(filename); |
842
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
653 if(url==NULL) { |
906 | 654 // failed to create a new URL, so it's not an URL (or a malformed URL) |
842
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
655 #endif |
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
656 f=open(filename,O_RDONLY); |
1217 | 657 if(f<0){ fprintf(stderr,"File not found: '%s'\n",filename);return 1; } |
842
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
658 len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET); |
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
659 stream=new_stream(f,STREAMTYPE_FILE); |
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
660 stream->end_pos=len; |
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
661 #ifdef STREAMING |
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
662 } else { |
1002
f035bd1f2749
Streaming function return the file_format and should be tested.
bertrand
parents:
984
diff
changeset
|
663 file_format=autodetectProtocol( url, &f ); |
f035bd1f2749
Streaming function return the file_format and should be tested.
bertrand
parents:
984
diff
changeset
|
664 if( file_format==DEMUXER_TYPE_UNKNOWN ) { |
1217 | 665 fprintf(stderr,"Unable to open URL: %s\n", filename); |
906 | 666 url_free(url); |
842
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
667 return 1; |
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
668 } else { |
1002
f035bd1f2749
Streaming function return the file_format and should be tested.
bertrand
parents:
984
diff
changeset
|
669 f=streaming_start( &url, f, file_format ); |
1217 | 670 if(f<0){ fprintf(stderr,"Unable to open URL: %s\n", url->url); return 1; } |
842
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
671 printf("Connected to server: %s\n", url->hostname ); |
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
672 } |
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
673 stream=new_stream(f,STREAMTYPE_STREAM); |
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
674 } |
80698f8030b9
Now Check if the 'filename' is an URL and connect to the server.
bertrand
parents:
815
diff
changeset
|
675 #endif |
692 | 676 } |
598 | 677 } |
678 | |
492 | 679 #ifdef HAVE_LIBCSS |
546 | 680 if (dvdimportkey) { |
681 if (dvd_import_key(dvdimportkey)) { | |
682 fprintf(stderr,"Error processing DVD KEY.\n"); | |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
683 GUI_MSG( mplErrorDVDKeyProcess ) |
546 | 684 exit(1); |
685 } | |
686 printf("DVD command line requested key is stored for descrambling.\n"); | |
687 } | |
1018
e5fc7ec51fa3
-dvd is renamed to -dvdauth, variable dvd_device is renamed to dvd_auth_device. These changes are needed for future DVD playback developmenting
lgb
parents:
1015
diff
changeset
|
688 if (dvd_auth_device) { |
1042
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1039
diff
changeset
|
689 // if (dvd_auth(dvd_auth_device,f)) { |
b333271f4e7c
Solaris 8 DVD support and other fixes by Juergen Keil <jk@tools.de>
arpi_esp
parents:
1039
diff
changeset
|
690 if (dvd_auth(dvd_auth_device,filename)) { |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
691 GUI_MSG( mplErrorDVDAuth ) |
723 | 692 exit(0); |
693 } | |
492 | 694 printf("DVD auth sequence seems to be OK.\n"); |
695 } | |
696 #endif | |
1 | 697 |
698 //============ Open & Sync stream and detect file format =============== | |
699 | |
442 | 700 if(!has_audio) audio_id=-2; // do NOT read audio packets... |
1 | 701 |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
702 demuxer=demux_open(stream,file_format); |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
703 if(!demuxer) exit(1); // ERROR |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
704 |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
705 file_format=demuxer->file_format; |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
706 |
1 | 707 d_audio=demuxer->audio; |
708 d_video=demuxer->video; | |
554 | 709 d_dvdsub=demuxer->sub; |
1 | 710 |
792 | 711 // DUMP STREAMS: |
712 if(stream_dump_type){ | |
713 FILE *f; | |
714 demux_stream_t *ds=NULL; | |
715 // select stream to dump | |
716 switch(stream_dump_type){ | |
717 case 1: ds=d_audio;break; | |
718 case 2: ds=d_video;break; | |
719 case 3: ds=d_dvdsub;break; | |
720 } | |
721 if(!ds){ | |
1217 | 722 fprintf(stderr,"dump: FATAL: selected stream missing!\n"); |
792 | 723 exit(1); |
724 } | |
725 // disable other streams: | |
726 if(d_audio && d_audio!=ds) {ds_free_packs(d_audio); d_audio->id=-2; } | |
727 if(d_video && d_video!=ds) {ds_free_packs(d_video); d_video->id=-2; } | |
728 if(d_dvdsub && d_dvdsub!=ds) {ds_free_packs(d_dvdsub); d_dvdsub->id=-2; } | |
729 // let's dump it! | |
730 f=fopen(stream_dump_name?stream_dump_name:"stream.dump","wb"); | |
1217 | 731 if(!f){ fprintf(stderr,"Can't open dump file!!!\n");exit(1); } |
792 | 732 while(!ds->eof){ |
733 unsigned char* start; | |
734 int in_size=ds_get_packet(ds,&start); | |
1246
7f69c1dd1e91
-dumpvideo stores frame size for avi/asf video frames (for ffmpeg testing)
arpi
parents:
1237
diff
changeset
|
735 if( (file_format==DEMUXER_TYPE_AVI || file_format==DEMUXER_TYPE_ASF) |
7f69c1dd1e91
-dumpvideo stores frame size for avi/asf video frames (for ffmpeg testing)
arpi
parents:
1237
diff
changeset
|
736 && stream_dump_type==2) fwrite(&in_size,1,4,f); |
792 | 737 if(in_size>0) fwrite(start,in_size,1,f); |
738 } | |
739 fclose(f); | |
740 printf("core dumped :)\n"); | |
741 exit(1); | |
742 } | |
743 | |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
744 sh_audio=d_audio->sh; |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
745 sh_video=d_video->sh; |
792 | 746 |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
747 if(sh_video){ |
1 | 748 |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
749 if(!video_read_properties(sh_video)) exit(1); // couldn't read header? |
1 | 750 |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
751 printf("[V] filefmt:%d fourcc:0x%X size:%dx%d fps:%5.2f ftime:=%6.4f\n", |
1183 | 752 file_format,sh_video->format, sh_video->disp_w,sh_video->disp_h, |
398 | 753 sh_video->fps,sh_video->frametime |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
754 ); |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
755 |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
756 if(!sh_video->fps && !force_fps){ |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
757 fprintf(stderr,"FPS not specified (or invalid) in the header! Use the -fps option!\n"); |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
758 exit(1); |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
759 } |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
760 |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1369
diff
changeset
|
761 } |
398 | 762 |
1 | 763 fflush(stdout); |
764 | |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
765 if(!sh_video){ |
1217 | 766 fprintf(stderr,"Sorry, no video stream... it's unplayable yet\n"); |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
767 exit(1); |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
768 } |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
769 |
303 | 770 //================== Init AUDIO (codec) ========================== |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
771 if(sh_audio){ |
303 | 772 // Go through the codec.conf and find the best codec... |
626 | 773 sh_audio->codec=NULL; |
1302 | 774 if(audio_family!=-1) printf("Trying to force audio codec driver family %d ...\n",audio_family); |
626 | 775 while(1){ |
776 sh_audio->codec=find_codec(sh_audio->format,NULL,sh_audio->codec,1); | |
777 if(!sh_audio->codec){ | |
1299
fa50e6bc6091
As promised, -afm and -vfm to prefer audio/video driver family, -ac and -vc have higher precedence, so they can override -afm/-vfm.
atmos4
parents:
1296
diff
changeset
|
778 if(audio_family!=-1) { |
fa50e6bc6091
As promised, -afm and -vfm to prefer audio/video driver family, -ac and -vc have higher precedence, so they can override -afm/-vfm.
atmos4
parents:
1296
diff
changeset
|
779 sh_audio->codec=NULL; /* re-search */ |
fa50e6bc6091
As promised, -afm and -vfm to prefer audio/video driver family, -ac and -vc have higher precedence, so they can override -afm/-vfm.
atmos4
parents:
1296
diff
changeset
|
780 printf("Can't find audio codec for forced driver family, fallback to other drivers.\n"); |
fa50e6bc6091
As promised, -afm and -vfm to prefer audio/video driver family, -ac and -vc have higher precedence, so they can override -afm/-vfm.
atmos4
parents:
1296
diff
changeset
|
781 audio_family=-1; |
fa50e6bc6091
As promised, -afm and -vfm to prefer audio/video driver family, -ac and -vc have higher precedence, so they can override -afm/-vfm.
atmos4
parents:
1296
diff
changeset
|
782 continue; |
fa50e6bc6091
As promised, -afm and -vfm to prefer audio/video driver family, -ac and -vc have higher precedence, so they can override -afm/-vfm.
atmos4
parents:
1296
diff
changeset
|
783 } |
626 | 784 printf("Can't find codec for audio format 0x%X !\n",sh_audio->format); |
919 | 785 printf("*** Try to upgrade %s from DOCS/codecs.conf\n",get_path("codecs.conf")); |
786 printf("*** If it's still not OK, then read DOCS/CODECS!\n"); | |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
787 sh_audio=NULL; |
626 | 788 break; |
789 } | |
1286
543a94b241a2
Replaced LGBs video codec forcing change with mine for audio and video codecs, which is IMHO more convenient cause codecs are selected by name instead of number, one unclearity is left to me, that's why audio_format is used once before codecs selection for MPEG_PS files, that's why I left -afm in for that one.
atmos4
parents:
1285
diff
changeset
|
790 if(audio_codec && strcmp(sh_audio->codec->name,audio_codec)) continue; |
1299
fa50e6bc6091
As promised, -afm and -vfm to prefer audio/video driver family, -ac and -vc have higher precedence, so they can override -afm/-vfm.
atmos4
parents:
1296
diff
changeset
|
791 else if(audio_family!=-1 && sh_audio->codec->driver!=audio_family) continue; |
1286
543a94b241a2
Replaced LGBs video codec forcing change with mine for audio and video codecs, which is IMHO more convenient cause codecs are selected by name instead of number, one unclearity is left to me, that's why audio_format is used once before codecs selection for MPEG_PS files, that's why I left -afm in for that one.
atmos4
parents:
1285
diff
changeset
|
792 printf("%s audio codec: [%s] drv:%d (%s)\n",audio_codec?"Forcing":"Detected",sh_audio->codec->name,sh_audio->codec->driver,sh_audio->codec->info); |
626 | 793 break; |
303 | 794 } |
1 | 795 } |
796 | |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
797 if(sh_audio){ |
303 | 798 if(verbose) printf("Initializing audio codec...\n"); |
442 | 799 if(!init_audio(sh_audio)){ |
303 | 800 printf("Couldn't initialize audio codec! -> nosound\n"); |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
801 sh_audio=0; |
303 | 802 } else { |
758 | 803 printf("AUDIO: srate=%d chans=%d bps=%d sfmt=0x%X ratio: %d->%d\n",sh_audio->samplerate,sh_audio->channels,sh_audio->samplesize, |
804 sh_audio->sample_format,sh_audio->i_bps,sh_audio->o_bps); | |
303 | 805 } |
175 | 806 } |
807 | |
303 | 808 //================== Init VIDEO (codec & libvo) ========================== |
809 | |
810 // Go through the codec.conf and find the best codec... | |
626 | 811 sh_video->codec=NULL; |
1299
fa50e6bc6091
As promised, -afm and -vfm to prefer audio/video driver family, -ac and -vc have higher precedence, so they can override -afm/-vfm.
atmos4
parents:
1296
diff
changeset
|
812 if(video_family!=-1) printf("Trying to force video codec driver family %d ...\n",video_family); |
626 | 813 while(1){ |
814 sh_video->codec=find_codec(sh_video->format, | |
815 sh_video->bih?((unsigned int*) &sh_video->bih->biCompression):NULL,sh_video->codec,0); | |
816 if(!sh_video->codec){ | |
1299
fa50e6bc6091
As promised, -afm and -vfm to prefer audio/video driver family, -ac and -vc have higher precedence, so they can override -afm/-vfm.
atmos4
parents:
1296
diff
changeset
|
817 if(video_family!=-1) { |
fa50e6bc6091
As promised, -afm and -vfm to prefer audio/video driver family, -ac and -vc have higher precedence, so they can override -afm/-vfm.
atmos4
parents:
1296
diff
changeset
|
818 sh_video->codec=NULL; /* re-search */ |
fa50e6bc6091
As promised, -afm and -vfm to prefer audio/video driver family, -ac and -vc have higher precedence, so they can override -afm/-vfm.
atmos4
parents:
1296
diff
changeset
|
819 printf("Can't find video codec for forced driver family, fallback to other drivers.\n"); |
fa50e6bc6091
As promised, -afm and -vfm to prefer audio/video driver family, -ac and -vc have higher precedence, so they can override -afm/-vfm.
atmos4
parents:
1296
diff
changeset
|
820 video_family=-1; |
fa50e6bc6091
As promised, -afm and -vfm to prefer audio/video driver family, -ac and -vc have higher precedence, so they can override -afm/-vfm.
atmos4
parents:
1296
diff
changeset
|
821 continue; |
fa50e6bc6091
As promised, -afm and -vfm to prefer audio/video driver family, -ac and -vc have higher precedence, so they can override -afm/-vfm.
atmos4
parents:
1296
diff
changeset
|
822 } |
303 | 823 printf("Can't find codec for video format 0x%X !\n",sh_video->format); |
919 | 824 printf("*** Try to upgrade %s from DOCS/codecs.conf\n",get_path("codecs.conf")); |
825 printf("*** If it's still not OK, then read DOCS/CODECS!\n"); | |
723 | 826 #ifdef HAVE_GUI |
827 if ( !nogui ) | |
828 { | |
829 mplShMem->items.videodata.format=sh_video->format; | |
830 mplSendMessage( mplCantFindCodecForVideoFormat ); | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
831 usec_sleep( 10000 ); |
723 | 832 } |
833 #endif | |
303 | 834 exit(1); |
626 | 835 } |
1286
543a94b241a2
Replaced LGBs video codec forcing change with mine for audio and video codecs, which is IMHO more convenient cause codecs are selected by name instead of number, one unclearity is left to me, that's why audio_format is used once before codecs selection for MPEG_PS files, that's why I left -afm in for that one.
atmos4
parents:
1285
diff
changeset
|
836 // is next line needed anymore? - atmos :: |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1406
diff
changeset
|
837 if(!allow_dshow && sh_video->codec->driver==VFM_DSHOW) continue; // skip DShow |
1286
543a94b241a2
Replaced LGBs video codec forcing change with mine for audio and video codecs, which is IMHO more convenient cause codecs are selected by name instead of number, one unclearity is left to me, that's why audio_format is used once before codecs selection for MPEG_PS files, that's why I left -afm in for that one.
atmos4
parents:
1285
diff
changeset
|
838 else if(video_codec && strcmp(sh_video->codec->name,video_codec)) continue; |
1299
fa50e6bc6091
As promised, -afm and -vfm to prefer audio/video driver family, -ac and -vc have higher precedence, so they can override -afm/-vfm.
atmos4
parents:
1296
diff
changeset
|
839 else if(video_family!=-1 && sh_video->codec->driver!=video_family) continue; |
626 | 840 break; |
303 | 841 } |
842 | |
1286
543a94b241a2
Replaced LGBs video codec forcing change with mine for audio and video codecs, which is IMHO more convenient cause codecs are selected by name instead of number, one unclearity is left to me, that's why audio_format is used once before codecs selection for MPEG_PS files, that's why I left -afm in for that one.
atmos4
parents:
1285
diff
changeset
|
843 printf("%s video codec: [%s] drv:%d (%s)\n",video_codec?"Forcing":"Detected",sh_video->codec->name,sh_video->codec->driver,sh_video->codec->info); |
303 | 844 |
845 for(i=0;i<CODECS_MAX_OUTFMT;i++){ | |
487 | 846 int ret; |
303 | 847 out_fmt=sh_video->codec->outfmt[i]; |
534
2a45d5adcc88
do not query vo drivers for format 0xFFFFFFFF (thanx to szabi)
arpi_esp
parents:
510
diff
changeset
|
848 if(out_fmt==0xFFFFFFFF) continue; |
1422 | 849 #ifdef USE_LIBVO2 |
850 ret=vo2_query_format(video_out); | |
851 #else | |
487 | 852 ret=video_out->query_format(out_fmt); |
1422 | 853 #endif |
1183 | 854 if(verbose) printf("vo_debug: query(%s) returned 0x%X\n",vo_format_name(out_fmt),ret); |
487 | 855 if(ret) break; |
303 | 856 } |
857 if(i>=CODECS_MAX_OUTFMT){ | |
1217 | 858 fprintf(stderr,"Sorry, selected video_out device is incompatible with this codec.\n"); |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
859 GUI_MSG( mplIncompatibleVideoOutDevice ) |
303 | 860 exit(1); |
861 } | |
862 sh_video->outfmtidx=i; | |
863 | |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
864 if(flip==-1){ |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
865 // autodetect flipping |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
866 flip=0; |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
867 if(sh_video->codec->outflags[i]&CODECS_FLAG_FLIP) |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
868 if(!(sh_video->codec->outflags[i]&CODECS_FLAG_NOFLIP)) |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
869 flip=1; |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
870 } |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
871 |
1183 | 872 if(verbose) printf("vo_debug1: out_fmt=%s\n",vo_format_name(out_fmt)); |
487 | 873 |
1291 | 874 if(!init_video(sh_video)){ |
875 fprintf(stderr,"FATAL: Couldn't initialize video codec :(\n"); | |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
876 GUI_MSG( mplUnknowError ) |
723 | 877 exit(1); |
1 | 878 } |
879 | |
880 // ================== Init output files for encoding =============== | |
881 if(encode_name){ | |
882 // encode file!!! | |
883 FILE *encode_file=fopen(encode_name,"rb"); | |
884 if(encode_file){ | |
885 fclose(encode_file); | |
1217 | 886 fprintf(stderr,"File already exists: %s (don't overwrite your favourite AVI!)\n",encode_name); |
1 | 887 return 0; |
888 } | |
889 encode_file=fopen(encode_name,"wb"); | |
890 if(!encode_file){ | |
1217 | 891 fprintf(stderr,"Cannot create file for encoding\n"); |
1 | 892 return 0; |
893 } | |
398 | 894 write_avi_header_1(encode_file,mmioFOURCC('d', 'i', 'v', 'x'),sh_video->fps,sh_video->disp_w,sh_video->disp_h); |
1 | 895 fclose(encode_file); |
896 encode_index_name=malloc(strlen(encode_name)+8); | |
897 strcpy(encode_index_name,encode_name); | |
898 strcat(encode_index_name,".index"); | |
899 if((encode_file=fopen(encode_index_name,"wb"))) | |
900 fclose(encode_file); | |
901 else encode_index_name=NULL; | |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
902 sh_audio=0; // disable audio !!!!! |
1 | 903 } |
904 | |
905 // ========== Init keyboard FIFO (connection to libvo) ============ | |
906 | |
907 make_pipe(&keyb_fifo_get,&keyb_fifo_put); | |
908 | |
398 | 909 // ========== Init display (sh_video->disp_w*sh_video->disp_h/out_fmt) ============ |
1 | 910 |
911 #ifdef X11_FULLSCREEN | |
912 if(fullscreen){ | |
913 if(vo_init()){ | |
914 //if(verbose) printf("X11 running at %dx%d depth: %d\n",vo_screenwidth,vo_screenheight,vo_depthonscreen); | |
915 } | |
916 if(!screen_size_xy) screen_size_xy=vo_screenwidth; // scale with asp.ratio | |
917 } | |
918 #endif | |
919 | |
920 if(screen_size_xy>0){ | |
921 if(screen_size_xy<=8){ | |
398 | 922 screen_size_x=screen_size_xy*sh_video->disp_w; |
923 screen_size_y=screen_size_xy*sh_video->disp_h; | |
1 | 924 } else { |
925 screen_size_x=screen_size_xy; | |
398 | 926 screen_size_y=screen_size_xy*sh_video->disp_h/sh_video->disp_w; |
1 | 927 } |
337 | 928 } else if(!vidmode){ |
929 if(!screen_size_x) screen_size_x=SCREEN_SIZE_X; | |
930 if(!screen_size_y) screen_size_y=SCREEN_SIZE_Y; | |
398 | 931 if(screen_size_x<=8) screen_size_x*=sh_video->disp_w; |
932 if(screen_size_y<=8) screen_size_y*=sh_video->disp_h; | |
1 | 933 } |
208
ae0f909ccc7c
Adds code to deal with vidmode selection. -- mgraffam
mgraffam
parents:
190
diff
changeset
|
934 |
1422 | 935 #ifndef USE_LIBVO2 |
340 | 936 { const vo_info_t *info = video_out->get_info(); |
1183 | 937 printf("VO: [%s] %dx%d => %dx%d %s %s%s%s%s\n",info->short_name, |
398 | 938 sh_video->disp_w,sh_video->disp_h, |
340 | 939 screen_size_x,screen_size_y, |
1183 | 940 vo_format_name(out_fmt), |
340 | 941 fullscreen?"fs ":"", |
942 vidmode?"vm ":"", | |
766 | 943 softzoom?"zoom ":"", |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
944 (flip==1)?"flip ":"" |
766 | 945 // fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3) |
340 | 946 ); |
1237 | 947 printf("VO: Description: %s\n" |
948 "VO: Author: %s\n", | |
949 info->name, | |
950 info->author | |
951 ); | |
952 if(strlen(info->comment) > 0) | |
953 printf("VO: Comment: %s\n", info->comment); | |
340 | 954 } |
1422 | 955 #endif |
340 | 956 |
337 | 957 if(verbose) printf("video_out->init(%dx%d->%dx%d,flags=%d,'%s',0x%X)\n", |
398 | 958 sh_video->disp_w,sh_video->disp_h, |
1 | 959 screen_size_x,screen_size_y, |
766 | 960 fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3), |
337 | 961 title,out_fmt); |
1 | 962 |
723 | 963 #ifdef HAVE_GUI |
964 if ( !nogui ) | |
965 { | |
966 mplShMem->items.videodata.width=sh_video->disp_w; | |
967 mplShMem->items.videodata.height=sh_video->disp_h; | |
968 mplSendMessage( mplSetVideoData ); | |
969 } | |
970 #endif | |
971 | |
1422 | 972 #ifdef USE_LIBVO2 |
973 if(!vo2_start(video_out, | |
974 sh_video->disp_w,sh_video->disp_h,out_fmt,0, | |
975 fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3) )){ | |
976 fprintf(stderr,"FATAL: Cannot initialize video driver!\n"); | |
977 GUI_MSG( mplCantInitVideoDriver ) | |
978 exit(1); | |
979 } | |
980 #else | |
398 | 981 if(video_out->init(sh_video->disp_w,sh_video->disp_h, |
1 | 982 screen_size_x,screen_size_y, |
766 | 983 fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3), |
337 | 984 title,out_fmt)){ |
1217 | 985 fprintf(stderr,"FATAL: Cannot initialize video driver!\n"); |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
986 GUI_MSG( mplCantInitVideoDriver ) |
723 | 987 exit(1); |
1 | 988 } |
1422 | 989 #endif |
1 | 990 if(verbose) printf("INFO: Video OUT driver init OK!\n"); |
991 | |
992 fflush(stdout); | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
993 |
1 | 994 //================== MAIN: ========================== |
995 { | |
746 | 996 |
1420 | 997 //float frame_correction=0; // average of A-V timestamp differences |
998 //int frame_corr_num=0; // | |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
999 //float v_frame=0; // Video |
1 | 1000 float time_frame=0; // Timer |
1001 int eof=0; | |
1002 int force_redraw=0; | |
1400 | 1003 //float num_frames=0; // number of frames played |
1382 | 1004 int grab_frames=0; |
212 | 1005 char osd_text_buffer[64]; |
715 | 1006 int drop_frame=0; |
1007 int drop_frame_cnt=0; | |
1 | 1008 |
1009 #ifdef HAVE_LIRC | |
723 | 1010 #ifdef HAVE_GUI |
1011 if ( nogui ) | |
1012 #endif | |
1 | 1013 lirc_mp_setup(); |
1014 #endif | |
1015 | |
1005 | 1016 #ifdef HAVE_GUI |
1017 if ( nogui ) | |
1018 { | |
1019 #endif | |
1 | 1020 #ifdef USE_TERMCAP |
1021 load_termcap(NULL); // load key-codes | |
1022 #endif | |
692 | 1023 if(f) getch2_enable(); |
1005 | 1024 #ifdef HAVE_GUI |
1025 } | |
1026 #endif | |
1 | 1027 |
1028 //========= Catch terminate signals: ================ | |
1029 // terminate requests: | |
1030 signal(SIGTERM,exit_sighandler); // kill | |
1031 signal(SIGHUP,exit_sighandler); // kill -HUP / xterm closed | |
723 | 1032 |
1033 #ifdef HAVE_GUI | |
1034 if ( nogui ) | |
1035 #endif | |
1036 signal(SIGINT,exit_sighandler); // Interrupt from keyboard | |
1037 | |
1 | 1038 signal(SIGQUIT,exit_sighandler); // Quit from keyboard |
1039 // fatal errors: | |
1040 signal(SIGBUS,exit_sighandler); // bus error | |
1041 signal(SIGSEGV,exit_sighandler); // segfault | |
1042 signal(SIGILL,exit_sighandler); // illegal instruction | |
1043 signal(SIGFPE,exit_sighandler); // floating point exc. | |
1044 signal(SIGABRT,exit_sighandler); // abort() | |
1045 | |
1046 //================ SETUP AUDIO ========================== | |
1047 current_module="setup_audio"; | |
1048 | |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1049 if(sh_audio){ |
1237 | 1050 |
1051 const ao_info_t *info=audio_out->info; | |
1052 printf("AO: [%s] %iHz %s %s\n" | |
1053 "AO: Description: %s\n" | |
1054 "AO: Author: %s\n", | |
1055 info->short_name, | |
1056 force_srate?force_srate:sh_audio->samplerate, | |
1057 sh_audio->channels>1?"Stereo":"Mono", | |
1058 audio_out_format_name(sh_audio->sample_format), | |
1059 info->name, | |
1060 info->author | |
1061 ); | |
1062 if(strlen(info->comment) > 0) | |
1063 printf("AO: Comment: %s\n", info->comment); | |
955 | 1064 |
969 | 1065 if(!audio_out->init(force_srate?force_srate:sh_audio->samplerate, |
1066 sh_audio->channels,sh_audio->sample_format,0)){ | |
955 | 1067 printf("couldn't open/init audio device -> NOSOUND\n"); |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1068 sh_audio=0; audio_out=NULL; |
1 | 1069 } |
1070 | |
955 | 1071 // printf("Audio buffer size: %d bytes, delay: %5.3fs\n",audio_buffer_size,audio_buffer_delay); |
746 | 1072 |
758 | 1073 // fixup audio buffer size: |
782 | 1074 // if(outburst<MAX_OUTBURST){ |
1075 // sh_audio->a_buffer_size=sh_audio->audio_out_minsize+outburst; | |
1076 // printf("Audio out buffer size reduced to %d bytes\n",sh_audio->a_buffer_size); | |
1077 // } | |
758 | 1078 |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1079 // sh_audio->timer=-(audio_buffer_delay); |
1 | 1080 } |
1081 | |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1082 sh_video->timer=0; |
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1083 if(sh_audio) sh_audio->timer=0; |
1 | 1084 |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1085 if(!sh_audio){ |
1 | 1086 printf("Audio: no sound\n"); |
1087 if(verbose) printf("Freeing %d unused audio chunks\n",d_audio->packs); | |
1088 ds_free_packs(d_audio); // free buffered chunks | |
1089 d_audio->id=-2; // do not read audio chunks | |
442 | 1090 if(sh_audio) if(sh_audio->a_buffer) free(sh_audio->a_buffer); |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1091 if(audio_out){ audio_out->uninit(); audio_out=NULL;} // close device |
1 | 1092 } |
1093 | |
1094 current_module=NULL; | |
1095 | |
1096 //==================== START PLAYING ======================= | |
1097 | |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1098 if(file_format==DEMUXER_TYPE_AVI && sh_audio){ |
780 | 1099 //a_pts=d_audio->pts; |
1334 | 1100 if(verbose) printf("Initial frame delay A: %d V: %d\n",(int)sh_audio->audio.dwInitialFrames,(int)sh_video->video.dwInitialFrames); |
780 | 1101 if(!pts_from_bps){ |
1102 float x=(float)(sh_audio->audio.dwInitialFrames-sh_video->video.dwInitialFrames)*sh_video->frametime; | |
1103 audio_delay-=x; | |
1334 | 1104 if(verbose) printf("AVI Initial frame delay: %5.3f\n",x); |
780 | 1105 } |
340 | 1106 if(verbose){ |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1107 // printf("v: audio_delay=%5.3f buffer_delay=%5.3f a_pts=%5.3f sh_audio->timer=%5.3f\n", |
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1108 // audio_delay,audio_buffer_delay,a_pts,sh_audio->timer); |
340 | 1109 printf("START: a_pts=%5.3f v_pts=%5.3f \n",d_audio->pts,d_video->pts); |
1110 } | |
1 | 1111 delay_corrected=0; // has to correct PTS diffs |
1112 d_video->pts=0;d_audio->pts=0; // PTS is outdated now! | |
780 | 1113 } else { |
1114 pts_from_bps=0; // it must be 0 for mpeg/asf ! | |
1 | 1115 } |
398 | 1116 if(force_fps){ |
1117 sh_video->fps=force_fps; | |
1118 sh_video->frametime=1.0f/sh_video->fps; | |
955 | 1119 printf("FPS forced to be %5.3f (ftime: %5.3f)\n",sh_video->fps,sh_video->frametime); |
398 | 1120 } |
1 | 1121 |
1122 printf("Start playing...\n");fflush(stdout); | |
1123 | |
1124 InitTimer(); | |
1125 | |
1124
0e95f30ffd4c
-frames and -benchmark options to make chl & gabucino happy
arpi_esp
parents:
1059
diff
changeset
|
1126 total_time_usage_start=GetTimer(); |
0e95f30ffd4c
-frames and -benchmark options to make chl & gabucino happy
arpi_esp
parents:
1059
diff
changeset
|
1127 |
1 | 1128 while(!eof){ |
1129 | |
1125 | 1130 if(play_n_frames>=0){ |
1131 --play_n_frames; | |
1132 if(play_n_frames<0) exit_player("Requested number of frames played"); | |
1133 } | |
1134 | |
1 | 1135 /*========================== PLAY AUDIO ============================*/ |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1136 while(sh_audio){ |
746 | 1137 unsigned int t; |
955 | 1138 int playsize=audio_out->get_space(); |
746 | 1139 |
955 | 1140 if(!playsize) break; // buffer is full, do not block here!!! |
746 | 1141 |
1142 if(playsize>MAX_OUTBURST) playsize=MAX_OUTBURST; // we shouldn't exceed it! | |
1143 //if(playsize>outburst) playsize=outburst; | |
291 | 1144 |
1145 // Update buffer if needed | |
746 | 1146 t=GetTimer(); |
1 | 1147 current_module="decode_audio"; // Enter AUDIO decoder module |
746 | 1148 while(sh_audio->a_buffer_len<playsize && !d_audio->eof){ |
1149 int ret=decode_audio(sh_audio,&sh_audio->a_buffer[sh_audio->a_buffer_len], | |
1150 playsize-sh_audio->a_buffer_len,sh_audio->a_buffer_size-sh_audio->a_buffer_len); | |
296 | 1151 if(ret>0) sh_audio->a_buffer_len+=ret; else break; |
1 | 1152 } |
1153 current_module=NULL; // Leave AUDIO decoder module | |
291 | 1154 t=GetTimer()-t;audio_time_usage+=t*0.000001; |
746 | 1155 |
1156 if(playsize>sh_audio->a_buffer_len) playsize=sh_audio->a_buffer_len; | |
1157 | |
955 | 1158 playsize=audio_out->play(sh_audio->a_buffer,playsize,0); |
1 | 1159 |
955 | 1160 if(playsize>0){ |
746 | 1161 sh_audio->a_buffer_len-=playsize; |
1162 memcpy(sh_audio->a_buffer,&sh_audio->a_buffer[playsize],sh_audio->a_buffer_len); | |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1163 sh_audio->timer+=playsize/(float)(sh_audio->o_bps); |
1 | 1164 } |
1165 | |
1166 break; | |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1167 } // if(sh_audio) |
1 | 1168 |
1169 /*========================== UPDATE TIMERS ============================*/ | |
746 | 1170 #if 0 |
1 | 1171 if(alsa){ |
1172 // Use system timer for sync, not audio card/driver | |
1173 time_frame-=GetRelativeTime(); | |
1174 if(time_frame<-0.1 || time_frame>0.1){ | |
1175 time_frame=0; | |
1176 } else { | |
398 | 1177 while(time_frame>0.022){ |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1178 usec_sleep(time_frame-0.022); |
398 | 1179 time_frame-=GetRelativeTime(); |
1180 } | |
103 | 1181 while(time_frame>0.007){ |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1182 usec_sleep(1000); // sleeps 1 clock tick (10ms)! |
103 | 1183 time_frame-=GetRelativeTime(); |
1184 } | |
398 | 1185 } |
1 | 1186 } |
746 | 1187 #endif |
1 | 1188 |
1189 /*========================== PLAY VIDEO ============================*/ | |
1190 | |
1191 if(1) | |
746 | 1192 while(1){ |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1193 |
398 | 1194 float frame_time=1; |
1195 float pts1=d_video->pts; | |
1291 | 1196 int blit_frame=0; |
1 | 1197 |
1198 current_module="decode_video"; | |
715 | 1199 |
1 | 1200 //-------------------- Decode a frame: ----------------------- |
1201 | |
1291 | 1202 if(file_format==DEMUXER_TYPE_MPEG_ES || file_format==DEMUXER_TYPE_MPEG_PS){ |
111 | 1203 int in_frame=0; |
398 | 1204 float newfps; |
111 | 1205 videobuf_len=0; |
1206 while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE){ | |
1207 int i=sync_video_packet(d_video); | |
1295 | 1208 void* buffer=&videobuffer[videobuf_len+4]; |
111 | 1209 if(in_frame){ |
1210 if(i<0x101 || i>=0x1B0){ // not slice code -> end of frame | |
398 | 1211 #if 1 |
111 | 1212 // send END OF FRAME code: |
1213 videobuffer[videobuf_len+0]=0; | |
1214 videobuffer[videobuf_len+1]=0; | |
1215 videobuffer[videobuf_len+2]=1; | |
1216 videobuffer[videobuf_len+3]=0xFF; | |
1217 videobuf_len+=4; | |
1218 #endif | |
1421 | 1219 if(!i) eof=2; // EOF |
111 | 1220 break; |
1221 } | |
1222 } else { | |
1223 //if(i==0x100) in_frame=1; // picture startcode | |
1224 if(i>=0x101 && i<0x1B0) in_frame=1; // picture startcode | |
1421 | 1225 else if(!i){ eof=3; break;} // EOF |
111 | 1226 } |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1227 if(grab_frames==2 && (i==0x1B3 || i==0x1B8)) grab_frames=1; |
1421 | 1228 if(!read_video_packet(d_video)){ eof=4; break;} // EOF |
111 | 1229 //printf("read packet 0x%X, len=%d\n",i,videobuf_len); |
1410
eda16e490ae7
using AFM_/VFM_ macros instead of hardcoded constants (idea by al3x)
arpi
parents:
1406
diff
changeset
|
1230 if(sh_video->codec->driver!=VFM_MPEG){ |
1296 | 1231 // if not libmpeg2: |
1295 | 1232 switch(i){ |
1233 case 0x1B3: header_process_sequence_header (picture, buffer);break; | |
1234 case 0x1B5: header_process_extension (picture, buffer);break; | |
1235 } | |
1236 } | |
111 | 1237 } |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1238 |
111 | 1239 if(videobuf_len>max_framesize) max_framesize=videobuf_len; // debug |
1240 //printf("--- SEND %d bytes\n",videobuf_len); | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1241 if(grab_frames==1){ |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1242 FILE *f=fopen("grab.mpg","ab"); |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1243 fwrite(videobuffer,videobuf_len-4,1,f); |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1244 fclose(f); |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1245 } |
1291 | 1246 |
1247 blit_frame=decode_video(video_out,sh_video,videobuffer,videobuf_len,drop_frame); | |
111 | 1248 |
1291 | 1249 // get mpeg fps: |
1250 newfps=frameratecode2framerate[picture->frame_rate_code]*0.0001f; | |
1251 if(ABS(sh_video->fps-newfps)>0.01f) if(!force_fps){ | |
398 | 1252 printf("Warning! FPS changed %5.3f -> %5.3f (%f) [%d] \n",sh_video->fps,newfps,sh_video->fps-newfps,picture->frame_rate_code); |
1253 sh_video->fps=newfps; | |
1254 sh_video->frametime=10000.0f/(float)frameratecode2framerate[picture->frame_rate_code]; | |
1291 | 1255 } |
1256 | |
1257 // fix mpeg2 frametime: | |
1258 frame_time=(100+picture->repeat_count)*0.01f; | |
1259 picture->repeat_count=0; | |
398 | 1260 |
1291 | 1261 } else { |
1262 // frame-based file formats: (AVI,ASF,MOV) | |
1263 unsigned char* start=NULL; | |
1264 int in_size=ds_get_packet(d_video,&start); | |
1421 | 1265 if(in_size<0){ eof=5;break;} |
1291 | 1266 if(in_size>max_framesize) max_framesize=in_size; |
1267 blit_frame=decode_video(video_out,sh_video,start,in_size,drop_frame); | |
1 | 1268 } |
1291 | 1269 |
1 | 1270 //------------------------ frame decoded. -------------------- |
1271 | |
398 | 1272 // Increase video timers: |
1400 | 1273 sh_video->num_frames+=frame_time; |
398 | 1274 frame_time*=sh_video->frametime; |
442 | 1275 if(file_format==DEMUXER_TYPE_ASF && !force_fps){ |
398 | 1276 // .ASF files has no fixed FPS - just frame durations! |
1277 float d=d_video->pts-pts1; | |
1278 if(d>=0 && d<5) frame_time=d; | |
595 | 1279 if(d>0){ |
1280 if(verbose) | |
1281 if((int)sh_video->fps==1000) | |
1282 printf("\rASF framerate: %d fps \n",(int)(1.0f/d)); | |
1283 sh_video->frametime=d; // 1ms | |
1284 sh_video->fps=1.0f/d; | |
1285 } | |
398 | 1286 } |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1287 sh_video->timer+=frame_time; |
746 | 1288 time_frame+=frame_time; // for nosound |
1289 | |
780 | 1290 if(file_format==DEMUXER_TYPE_MPEG_PS) d_video->pts+=frame_time; |
940 | 1291 |
1292 if(verbose>1) printf("*** ftime=%5.3f ***\n",frame_time); | |
780 | 1293 |
798 | 1294 if(drop_frame){ |
746 | 1295 |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1296 if(sh_audio && !d_audio->eof){ |
955 | 1297 int delay=audio_out->get_delay(); |
798 | 1298 if(verbose>1)printf("delay=%d\n",delay); |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1299 time_frame=sh_video->timer; |
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1300 time_frame-=sh_audio->timer-(float)delay/(float)sh_audio->o_bps; |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1301 if(time_frame>-2*frame_time) { |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1302 drop_frame=0; // stop dropping frames |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1303 if (verbose>0) printf("\nstop frame drop %.2f\n", time_frame); |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1304 }else{ |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1305 ++drop_frame_cnt; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1306 if (verbose > 0 && drop_frame_cnt%10 == 0) |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1307 printf("\nstill dropping, %.2f\n", time_frame); |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1308 } |
798 | 1309 } |
1310 | |
1311 } else { | |
780 | 1312 // It's time to sleep... |
1313 current_module="sleep"; | |
1314 | |
1315 time_frame-=GetRelativeTime(); // reset timer | |
1316 | |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1317 if(sh_audio && !d_audio->eof){ |
955 | 1318 int delay=audio_out->get_delay(); |
758 | 1319 if(verbose>1)printf("delay=%d\n",delay); |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1320 time_frame=sh_video->timer; |
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1321 time_frame-=sh_audio->timer-(float)delay/(float)sh_audio->o_bps; |
798 | 1322 // we are out of time... drop next frame! |
940 | 1323 if(time_frame<-2*frame_time){ |
798 | 1324 drop_frame=frame_dropping; // tricky! |
1325 ++drop_frame_cnt; | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1326 if (verbose>0) printf("\nframe drop %d, %.2f\n", drop_frame, time_frame); |
798 | 1327 } |
780 | 1328 } else { |
1124
0e95f30ffd4c
-frames and -benchmark options to make chl & gabucino happy
arpi_esp
parents:
1059
diff
changeset
|
1329 if( (time_frame<-3*frame_time || time_frame>3*frame_time) || benchmark) |
0e95f30ffd4c
-frames and -benchmark options to make chl & gabucino happy
arpi_esp
parents:
1059
diff
changeset
|
1330 time_frame=0; |
0e95f30ffd4c
-frames and -benchmark options to make chl & gabucino happy
arpi_esp
parents:
1059
diff
changeset
|
1331 |
780 | 1332 } |
798 | 1333 |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1334 // if(verbose>1)printf("sleep: %5.3f a:%6.3f v:%6.3f \n",time_frame,sh_audio->timer,sh_video->timer); |
746 | 1335 |
1336 while(time_frame>0.005){ | |
1337 if(time_frame<=0.020) | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1338 usec_sleep(10000); // sleeps 1 clock tick (10ms)! |
746 | 1339 else |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1340 usec_sleep(1000000*(time_frame-0.002)); |
746 | 1341 time_frame-=GetRelativeTime(); |
1342 } | |
117 | 1343 |
715 | 1344 current_module="flip_page"; |
1422 | 1345 #ifdef USE_LIBVO2 |
1346 if(blit_frame) vo2_flip(video_out,0); | |
1347 #else | |
1250 | 1348 if(blit_frame) video_out->flip_page(); |
1422 | 1349 #endif |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1350 // usec_sleep(50000); // test only! |
780 | 1351 |
715 | 1352 } |
780 | 1353 |
1354 current_module=NULL; | |
715 | 1355 |
1 | 1356 if(eof) break; |
220 | 1357 if(force_redraw){ |
1358 --force_redraw; | |
577 | 1359 if(!force_redraw) osd_function=OSD_PLAY; |
746 | 1360 continue; |
220 | 1361 } |
1 | 1362 |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1363 // printf("A:%6.1f V:%6.1f A-V:%7.3f frame=%5.2f \r",d_audio->pts,d_video->pts,d_audio->pts-d_video->pts,sh_audio->timer); |
1 | 1364 // fflush(stdout); |
1365 | |
1366 #if 1 | |
1367 /*================ A-V TIMESTAMP CORRECTION: =========================*/ | |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1368 if(sh_audio){ |
780 | 1369 float a_pts=0; |
1370 float v_pts=0; | |
1371 | |
746 | 1372 // unplayed bytes in our and soundcard/dma buffer: |
955 | 1373 int delay_bytes=audio_out->get_delay()+sh_audio->a_buffer_len; |
746 | 1374 float delay=(float)delay_bytes/(float)sh_audio->o_bps; |
1375 | |
780 | 1376 if(pts_from_bps){ |
1377 // PTS = (audio position)/(bytes per sec) | |
815 | 1378 // a_pts=(ds_tell(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps; |
1379 a_pts=(ds_tell(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->wf->nAvgBytesPerSec; | |
1 | 1380 delay_corrected=1; // hack |
889 | 1381 v_pts=d_video->pack_no*(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; |
1382 if(verbose)printf("%5.3f|",v_pts-d_video->pts); | |
780 | 1383 } else { |
1384 if(!delay_corrected && d_audio->pts){ | |
746 | 1385 float x=d_audio->pts-d_video->pts-(delay+audio_delay); |
1386 float y=-(delay+audio_delay); | |
1 | 1387 printf("Initial PTS delay: %5.3f sec (calculated: %5.3f)\n",x,y); |
933 | 1388 initial_pts_delay+=x; |
1 | 1389 audio_delay+=x; |
1390 delay_corrected=1; | |
340 | 1391 if(verbose) |
1 | 1392 printf("v: audio_delay=%5.3f buffer_delay=%5.3f a.pts=%5.3f v.pts=%5.3f\n", |
746 | 1393 audio_delay,delay,d_audio->pts,d_video->pts); |
1 | 1394 } |
780 | 1395 // PTS = (last timestamp) + (bytes after last timestamp)/(bytes per sec) |
746 | 1396 a_pts=d_audio->pts; |
1397 a_pts+=(ds_tell_pts(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps; | |
889 | 1398 v_pts=d_video->pts-frame_time; |
780 | 1399 } |
746 | 1400 |
933 | 1401 if(verbose>1)printf("### A:%8.3f (%8.3f) V:%8.3f A-V:%7.4f \n",a_pts,a_pts-audio_delay-delay,v_pts,(a_pts-delay-audio_delay)-v_pts); |
780 | 1402 |
398 | 1403 if(delay_corrected){ |
1420 | 1404 float x=(a_pts-delay-audio_delay)-v_pts; |
746 | 1405 // printf("A:%6.1f V:%6.1f A-V:%7.3f",a_pts-audio_delay-delay,v_pts,x); |
1406 printf("A:%6.1f (%6.1f) V:%6.1f A-V:%7.3f",a_pts,a_pts-audio_delay-delay,v_pts,x); | |
780 | 1407 x*=0.1f; |
1 | 1408 if(x<-max_pts_correction) x=-max_pts_correction; else |
1409 if(x> max_pts_correction) x= max_pts_correction; | |
780 | 1410 if(default_max_pts_correction>=0) |
1411 max_pts_correction=default_max_pts_correction; | |
1412 else | |
1413 max_pts_correction=sh_video->frametime*0.10; // +-10% of time | |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1414 sh_audio->timer+=x; c_total+=x; |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1415 printf(" ct:%7.3f %3d %2d%% %2d%% %4.1f%% %d\r",c_total, |
1400 | 1416 (int)sh_video->num_frames, |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1417 (sh_video->timer>0.5)?(int)(100.0*video_time_usage/(double)sh_video->timer):0, |
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1418 (sh_video->timer>0.5)?(int)(100.0*vout_time_usage/(double)sh_video->timer):0, |
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1419 (sh_video->timer>0.5)?(100.0*audio_time_usage/(double)sh_video->timer):0 |
798 | 1420 ,drop_frame_cnt |
1 | 1421 ); |
1422 fflush(stdout); | |
1423 } | |
780 | 1424 |
1 | 1425 } else { |
1426 // No audio: | |
1420 | 1427 |
1428 printf("V:%6.1f %3d %2d%% %2d%% %3.1f%% \r",d_video->pts, | |
1400 | 1429 (int)sh_video->num_frames, |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1430 (sh_video->timer>0.5)?(int)(100.0*video_time_usage/(double)sh_video->timer):0, |
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1431 (sh_video->timer>0.5)?(int)(100.0*vout_time_usage/(double)sh_video->timer):0, |
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1432 (sh_video->timer>0.5)?(100.0*audio_time_usage/(double)sh_video->timer):0 |
442 | 1433 ); |
1 | 1434 |
1435 fflush(stdout); | |
1420 | 1436 |
1 | 1437 } |
1438 #endif | |
1439 | |
1422 | 1440 #ifdef USE_OSD |
220 | 1441 if(osd_visible){ |
1442 --osd_visible; | |
1443 if(!osd_visible) vo_osd_progbar_type=-1; // disable | |
1444 } | |
1422 | 1445 #endif |
371 | 1446 |
1447 if(osd_function==OSD_PAUSE){ | |
1448 printf("\n------ PAUSED -------\r");fflush(stdout); | |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1449 if (audio_out && sh_audio) |
1156 | 1450 audio_out->pause(); // pause audio, keep data if possible |
723 | 1451 #ifdef HAVE_GUI |
1452 if ( nogui ) | |
1453 { | |
1454 #endif | |
1455 while( | |
371 | 1456 #ifdef HAVE_LIRC |
723 | 1457 lirc_mp_getinput()<=0 && |
371 | 1458 #endif |
723 | 1459 (!f || getch2(20)<=0) && mplayer_get_key()<=0){ |
1422 | 1460 #ifndef USE_LIBVO2 |
723 | 1461 video_out->check_events(); |
1422 | 1462 #endif |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1463 if(!f) usec_sleep(1000); // do not eat the CPU |
723 | 1464 } |
1465 osd_function=OSD_PLAY; | |
1466 #ifdef HAVE_GUI | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1467 } else while( osd_function != OSD_PLAY ) usec_sleep( 1000 ); |
723 | 1468 #endif |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1469 if (audio_out && sh_audio) |
1156 | 1470 audio_out->resume(); // resume audio |
371 | 1471 } |
1472 | |
746 | 1473 |
1474 if(!force_redraw) break; | |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1475 } // while(sh_video->timer<sh_audio->timer || force_redraw) |
1 | 1476 |
1477 | |
1478 //================= Keyboard events, SEEKing ==================== | |
1479 | |
723 | 1480 { int c; |
1 | 1481 while( |
1482 #ifdef HAVE_LIRC | |
1483 (c=lirc_mp_getinput())>0 || | |
1484 #endif | |
701 | 1485 (f && (c=getch2(0))>0) || (c=mplayer_get_key())>0) switch(c){ |
1 | 1486 // seek 10 sec |
1487 case KEY_RIGHT: | |
220 | 1488 osd_function=OSD_FFW; |
1 | 1489 rel_seek_secs+=10;break; |
1490 case KEY_LEFT: | |
220 | 1491 osd_function=OSD_REW; |
1 | 1492 rel_seek_secs-=10;break; |
1493 // seek 1 min | |
1494 case KEY_UP: | |
220 | 1495 osd_function=OSD_FFW; |
1 | 1496 rel_seek_secs+=60;break; |
1497 case KEY_DOWN: | |
220 | 1498 osd_function=OSD_REW; |
1 | 1499 rel_seek_secs-=60;break; |
651 | 1500 // seek 10 min |
1501 case KEY_PAGE_UP: | |
1502 rel_seek_secs+=600;break; | |
1503 case KEY_PAGE_DOWN: | |
1504 rel_seek_secs-=600;break; | |
1 | 1505 // delay correction: |
1506 case '+': | |
746 | 1507 audio_delay+=0.1; // increase audio buffer delay |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1508 if(sh_audio) sh_audio->timer-=0.1; |
1 | 1509 break; |
1510 case '-': | |
746 | 1511 audio_delay-=0.1; // decrease audio buffer delay |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1512 if(sh_audio) sh_audio->timer+=0.1; |
1 | 1513 break; |
1514 // quit | |
1515 case KEY_ESC: // ESC | |
1516 case KEY_ENTER: // ESC | |
1517 case 'q': exit_player("Quit"); | |
36 | 1518 case 'g': grab_frames=2;break; |
1 | 1519 // pause |
1520 case 'p': | |
1521 case ' ': | |
220 | 1522 osd_function=OSD_PAUSE; |
371 | 1523 break; |
1524 case 'o': // toggle OSD | |
1525 osd_level=(osd_level+1)%3; | |
1 | 1526 break; |
939 | 1527 case 'z': |
1528 sub_delay -= 0.1; | |
1529 break; | |
1530 case 'x': | |
1531 sub_delay += 0.1; | |
1532 break; | |
459 | 1533 case '*': |
555 | 1534 case '/': { |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1535 float mixer_l, mixer_r; |
555 | 1536 mixer_getvolume( &mixer_l,&mixer_r ); |
1537 if(c=='*'){ | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1538 mixer_l++; if ( mixer_l > 100 ) mixer_l = 100; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1539 mixer_r++; if ( mixer_r > 100 ) mixer_r = 100; |
555 | 1540 } else { |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1541 mixer_l--; if ( mixer_l < 0 ) mixer_l = 0; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1026
diff
changeset
|
1542 mixer_r--; if ( mixer_r < 0 ) mixer_r = 0; |
555 | 1543 } |
1544 mixer_setvolume( mixer_l,mixer_r ); | |
1545 | |
1422 | 1546 #ifdef USE_OSD |
555 | 1547 if(osd_level){ |
1548 osd_visible=sh_video->fps; // 1 sec | |
1549 vo_osd_progbar_type=OSD_VOLUME; | |
1550 vo_osd_progbar_value=(mixer_l+mixer_r)*5/4; | |
1551 //printf("volume: %d\n",vo_osd_progbar_value); | |
1552 } | |
1422 | 1553 #endif |
555 | 1554 } |
1555 break; | |
459 | 1556 case 'm': |
510 | 1557 mixer_usemaster=!mixer_usemaster; |
459 | 1558 break; |
715 | 1559 case 'd': |
798 | 1560 frame_dropping=(frame_dropping+1)%3; |
1561 printf("== drop: %d == \n",frame_dropping); | |
715 | 1562 break; |
1 | 1563 } |
1406 | 1564 } // keyboard event handler |
1565 | |
651 | 1566 if (seek_to_sec) { |
937 | 1567 int a,b; float d; |
1568 | |
1569 if (sscanf(seek_to_sec, "%d:%d:%f", &a,&b,&d)==3) | |
1570 rel_seek_secs += 3600*a +60*b +d ; | |
1571 else if (sscanf(seek_to_sec, "%d:%f", &a, &d)==2) | |
1572 rel_seek_secs += 60*a +d; | |
1573 else if (sscanf(seek_to_sec, "%f", &d)==1) | |
1574 rel_seek_secs += d; | |
1575 | |
1576 seek_to_sec = NULL; | |
651 | 1577 } |
937 | 1578 |
1 | 1579 if(rel_seek_secs) |
1405 | 1580 if(demux_seek(demuxer,rel_seek_secs,0)){ |
1581 // success: | |
889 | 1582 |
1369
7a2f1881b776
a_frame, v_frame killed, using sh_audio/video->timer. has_audio not more used after initialization.
arpi
parents:
1353
diff
changeset
|
1583 if(sh_audio){ |
1334 | 1584 current_module="audio_reset"; |
1585 audio_out->reset(); // stop audio, throwing away buffered data | |
889 | 1586 current_module=NULL; |
1 | 1587 } |
1588 | |
1422 | 1589 #ifdef USE_OSD |
1334 | 1590 // Set OSD: |
1591 if(osd_level){ | |
1592 int len=((demuxer->movi_end-demuxer->movi_start)>>8); | |
1593 if(len>0){ | |
1594 osd_visible=sh_video->fps; // 1 sec | |
1595 vo_osd_progbar_type=0; | |
1596 vo_osd_progbar_value=(demuxer->filepos-demuxer->movi_start)/len; | |
1597 } | |
1598 } | |
1422 | 1599 #endif |
1405 | 1600 |
1420 | 1601 c_total=0; |
1 | 1602 max_pts_correction=0.1; |
1603 force_redraw=5; | |
1604 audio_time_usage=0; video_time_usage=0; vout_time_usage=0; | |
1405 | 1605 |
1 | 1606 } |
1405 | 1607 rel_seek_secs=0; |
1608 | |
220 | 1609 //================= Update OSD ==================== |
1422 | 1610 #ifdef USE_OSD |
1421 | 1611 if(osd_level>=2){ |
780 | 1612 int pts=d_video->pts; |
595 | 1613 if(pts==osd_last_pts-1) ++pts; else osd_last_pts=pts; |
371 | 1614 vo_osd_text=osd_text_buffer; |
595 | 1615 sprintf(vo_osd_text,"%c %02d:%02d:%02d",osd_function,pts/3600,(pts/60)%60,pts%60); |
371 | 1616 } else { |
1617 vo_osd_text=NULL; | |
1618 } | |
220 | 1619 // for(i=1;i<=11;i++) osd_text_buffer[10+i]=i;osd_text_buffer[10+i]=0; |
371 | 1620 // vo_osd_text=osd_text_buffer; |
1422 | 1621 #endif |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1622 |
1422 | 1623 #ifdef USE_SUB |
258 | 1624 // find sub |
1204 | 1625 if(subtitles && d_video->pts>0){ |
780 | 1626 int pts=d_video->pts; |
398 | 1627 if(sub_fps==0) sub_fps=sh_video->fps; |
482 | 1628 current_module="find_sub"; |
780 | 1629 find_sub(subtitles,sub_uses_time?(100*(pts+sub_delay)):((pts+sub_delay)*sub_fps)); // FIXME! frame counter... |
482 | 1630 current_module=NULL; |
258 | 1631 } |
1422 | 1632 #endif |
554 | 1633 |
1634 // DVD sub: | |
557 | 1635 { unsigned char* packet=NULL; |
1636 int len=ds_get_packet_sub(d_dvdsub,&packet); | |
1637 if(len>=2){ | |
1638 int len2; | |
1639 len2=(packet[0]<<8)+packet[1]; | |
561 | 1640 if(verbose) printf("\rDVD sub: %d / %d \n",len,len2); |
1641 if(len==len2) | |
1642 spudec_decode(packet,len); | |
1643 else | |
1644 printf("fragmented dvd-subs not yet supported!!!\n"); | |
557 | 1645 } else if(len>=0) { |
1646 printf("invalud dvd sub\n"); | |
554 | 1647 } |
1648 } | |
1649 | |
1421 | 1650 } // while(!eof) |
1 | 1651 |
1421 | 1652 if(verbose) printf("EOF code: %d \n",eof); |
1 | 1653 |
1654 exit_player("End of file"); | |
109 | 1655 } |
1656 return 1; | |
1657 } |