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