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