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