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