Mercurial > mplayer.hg
annotate mplayer.c @ 815:e34052fd9633
i_bps vs. nAvgBytesPerSec
author | arpi_esp |
---|---|
date | Wed, 16 May 2001 23:04:22 +0000 |
parents | cfb984ecb5fd |
children | 80698f8030b9 |
rev | line source |
---|---|
1 | 1 // AVI & MPEG Player v0.11 (C) 2000-2001. by A'rpi/ESP-team |
2 | |
112 | 3 // Enable ALSA emulation (using 32kB audio buffer) - timer testing only |
1 | 4 //#define SIMULATE_ALSA |
5 | |
721 | 6 #define RESET_AUDIO(audio_fd) ioctl(audio_fd, SNDCTL_DSP_RESET, NULL) |
780 | 7 //#define PAUSE_AUDIO(audio_fd) ioctl(audio_fd, SNDCTL_DSP_POST, NULL) |
721 | 8 //#define RESET_AUDIO(audio_fd) |
1 | 9 |
10 #include <stdio.h> | |
11 #include <stdlib.h> | |
109 | 12 #include <string.h> |
1 | 13 |
14 #include <signal.h> | |
15 | |
16 #include <sys/ioctl.h> | |
17 #include <unistd.h> | |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
18 #include <time.h> |
1 | 19 #include <sys/mman.h> |
20 | |
21 #include <sys/types.h> | |
22 #include <sys/wait.h> | |
23 #include <sys/time.h> | |
24 #include <sys/stat.h> | |
25 #include <fcntl.h> | |
26 #include <sys/soundcard.h> | |
27 #include <linux/cdrom.h> | |
28 | |
29 #include "version.h" | |
30 #include "config.h" | |
31 | |
746 | 32 #ifndef MAX_OUTBURST |
591 | 33 #error "=============================================" |
34 #error "Please re-run ./configure and then try again!" | |
35 #error "=============================================" | |
36 #endif | |
37 | |
147 | 38 #include "cfgparser.h" |
151 | 39 #include "cfg-mplayer-def.h" |
147 | 40 |
258 | 41 #include "subreader.h" |
42 | |
36 | 43 #include "libvo/video_out.h" |
220 | 44 #include "libvo/sub.h" |
36 | 45 |
1 | 46 // CODECS: |
47 #include "mp3lib/mp3.h" | |
48 #include "libac3/ac3.h" | |
49 #include "libmpeg2/mpeg2.h" | |
50 #include "libmpeg2/mpeg2_internal.h" | |
51 | |
52 #include "loader.h" | |
53 #include "wine/avifmt.h" | |
54 | |
303 | 55 #include "codec-cfg.h" |
175 | 56 |
492 | 57 #include "dvdauth.h" |
560
28ae99036574
Separated dvdsub code to be able to work with it easier
lgb
parents:
557
diff
changeset
|
58 #include "spudec.h" |
492 | 59 |
175 | 60 #ifdef USE_DIRECTSHOW |
61 #include "DirectShow/DS_VideoDec.h" | |
190 | 62 #include "DirectShow/DS_AudioDec.h" |
175 | 63 #endif |
64 | |
1 | 65 #include "opendivx/decore.h" |
66 | |
67 | |
68 #ifdef USE_XMMP_AUDIO | |
69 #include "libxmm/xmmp.h" | |
70 #include "libxmm/libxmm.h" | |
71 XMM xmm; | |
72 XMM_PluginSound *pSound=NULL; | |
73 #endif | |
74 | |
33 | 75 extern int vo_screenwidth; |
1 | 76 |
77 extern char* win32_codec_name; // must be set before calling DrvOpen() !!! | |
78 | |
79 extern int errno; | |
80 | |
81 #include "linux/getch2.h" | |
82 #include "linux/keycodes.h" | |
83 #include "linux/timer.h" | |
84 #include "linux/shmem.h" | |
85 | |
86 #ifdef HAVE_LIRC | |
87 #include "lirc_mp.h" | |
88 #endif | |
89 | |
90 #include "help_mp.h" | |
91 | |
92 #define DEBUG if(0) | |
723 | 93 #ifdef HAVE_GUI |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
94 int nogui=1; |
723 | 95 #endif |
362 | 96 int verbose=0; |
1 | 97 |
398 | 98 #define ABS(x) (((x)>=0)?(x):(-(x))) |
99 | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
100 static subtitle* subtitles=NULL; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
101 void find_sub(subtitle* subtitles,int key); |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
102 |
641
d161307f447a
The -osdlevel switch for setting default OSD level (useful in your .config for example if you don't like watching OSD timer by default)
lgb
parents:
638
diff
changeset
|
103 int osd_level=2; |
d161307f447a
The -osdlevel switch for setting default OSD level (useful in your .config for example if you don't like watching OSD timer by default)
lgb
parents:
638
diff
changeset
|
104 |
258 | 105 //**************************************************************************// |
106 // Config file | |
107 //**************************************************************************// | |
108 | |
153 | 109 static int cfg_inc_verbose(struct config *conf){ |
110 ++verbose; | |
111 return 0; | |
112 } | |
113 | |
162 | 114 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
|
115 return parse_config_file(conf, filename); |
162 | 116 } |
117 | |
178 | 118 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
|
119 char *homedir; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
120 char *buff; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
121 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
|
122 int len; |
178 | 123 |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
124 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
|
125 return NULL; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
126 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
|
127 if (filename == NULL) { |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
128 if ((buff = (char *) malloc(len)) == NULL) |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
129 return NULL; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
130 sprintf(buff, "%s%s", homedir, config_dir); |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
131 } else { |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
132 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
|
133 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
|
134 return NULL; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
135 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
|
136 } |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
137 return buff; |
178 | 138 } |
139 | |
1 | 140 static int max_framesize=0; |
141 | |
442 | 142 //static int dbg_es_sent=0; |
143 //static int dbg_es_rcvd=0; | |
1 | 144 |
145 //static int show_packets=0; | |
146 | |
147 //**************************************************************************// | |
442 | 148 //**************************************************************************// |
149 // Input media streaming & demultiplexer: | |
150 //**************************************************************************// | |
151 | |
578 | 152 #include "stream.h" |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
153 #include "demuxer.h" |
442 | 154 |
155 #include "stheader.h" | |
1 | 156 |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
157 #if 0 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
158 |
1 | 159 typedef struct { |
160 // file: | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
161 // MainAVIHeader avih; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
162 // unsigned int movi_start; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
163 // unsigned int movi_end; |
1 | 164 // index: |
165 AVIINDEXENTRY* idx; | |
166 int idx_size; | |
167 int idx_pos; | |
168 int idx_pos_a; | |
169 int idx_pos_v; | |
170 int idx_offset; // ennyit kell hozzaadni az index offset ertekekhez | |
171 // video: | |
291 | 172 unsigned int bitrate; |
1 | 173 } avi_header_t; |
174 | |
175 avi_header_t avi_header; | |
176 | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
177 #endif |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
178 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
179 int avi_bitrate=0; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
180 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
181 demuxer_t *demuxer=NULL; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
182 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
183 //#include "aviprint.c" |
1 | 184 |
442 | 185 sh_audio_t* new_sh_audio(int id){ |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
186 if(demuxer->a_streams[id]){ |
442 | 187 printf("Warning! Audio stream header %d redefined!\n",id); |
188 } else { | |
500
c2b3a1f340c8
MPEG-ES segfault fixed, stream list printfs moved v 1->0
arpi_esp
parents:
495
diff
changeset
|
189 printf("==> Found audio stream: %d\n",id); |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
190 demuxer->a_streams[id]=malloc(sizeof(sh_audio_t)); |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
191 memset(demuxer->a_streams[id],0,sizeof(sh_audio_t)); |
442 | 192 } |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
193 return demuxer->a_streams[id]; |
442 | 194 } |
1 | 195 |
442 | 196 sh_video_t* new_sh_video(int id){ |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
197 if(demuxer->v_streams[id]){ |
442 | 198 printf("Warning! video stream header %d redefined!\n",id); |
199 } else { | |
500
c2b3a1f340c8
MPEG-ES segfault fixed, stream list printfs moved v 1->0
arpi_esp
parents:
495
diff
changeset
|
200 printf("==> Found video stream: %d\n",id); |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
201 demuxer->v_streams[id]=malloc(sizeof(sh_video_t)); |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
202 memset(demuxer->v_streams[id],0,sizeof(sh_video_t)); |
442 | 203 } |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
204 return demuxer->v_streams[id]; |
442 | 205 } |
1 | 206 |
291 | 207 |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
208 //#include "demux_avi.c" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
209 //#include "demux_mpg.c" |
1 | 210 |
211 demux_stream_t *d_audio=NULL; | |
212 demux_stream_t *d_video=NULL; | |
554 | 213 demux_stream_t *d_dvdsub=NULL; |
1 | 214 |
442 | 215 sh_audio_t *sh_audio=NULL;//&sh_audio_i; |
216 sh_video_t *sh_video=NULL;//&sh_video_i; | |
217 | |
218 char* encode_name=NULL; | |
219 char* encode_index_name=NULL; | |
220 int encode_bitrate=0; | |
291 | 221 |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
222 extern int asf_packetsize; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
223 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
224 extern float avi_audio_pts; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
225 extern float avi_video_pts; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
226 extern float avi_video_ftime; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
227 extern int skip_video_frames; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
228 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
229 void read_avi_header(demuxer_t *demuxer,int index_mode); |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
230 demux_stream_t* demux_avi_select_stream(demuxer_t *demux,unsigned int id); |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
231 |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
232 int asf_check_header(demuxer_t *demuxer); |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
233 int read_asf_header(demuxer_t *demuxer); |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
234 |
1 | 235 // MPEG video stream parser: |
236 #include "parse_es.c" | |
237 | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
238 extern int num_elementary_packets100; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
239 extern int num_elementary_packets101; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
240 |
442 | 241 extern picture_t *picture; |
242 | |
112 | 243 static const int frameratecode2framerate[16] = { |
780 | 244 0, |
245 // Official mpeg1/2 framerates: | |
246 24000*10000/1001, 24*10000,25*10000, 30000*10000/1001, 30*10000,50*10000,60000*10000/1001, 60*10000, | |
247 // libmpeg3's "Unofficial economy rates": | |
248 1*10000,5*10000,10*10000,12*10000,15*10000,0,0 | |
112 | 249 }; |
250 | |
111 | 251 //**************************************************************************// |
252 // Audio codecs: | |
253 //**************************************************************************// | |
254 | |
296 | 255 // MP3 decoder buffer callback: |
1 | 256 int mplayer_audio_read(char *buf,int size){ |
257 int len; | |
291 | 258 len=demux_read_data(sh_audio->ds,buf,size); |
1 | 259 return len; |
260 } | |
261 | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
262 //#include "dec_audio.c" |
291 | 263 |
111 | 264 //**************************************************************************// |
265 // The OpenDivX stuff: | |
266 //**************************************************************************// | |
267 | |
1 | 268 unsigned char *opendivx_src[3]; |
269 int opendivx_stride[3]; | |
270 | |
111 | 271 // callback, the opendivx decoder calls this for each frame: |
80 | 272 void convert_linux(unsigned char *puc_y, int stride_y, |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
273 unsigned char *puc_u, unsigned char *puc_v, int stride_uv, |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
274 unsigned char *bmp, int width_y, int height_y){ |
1 | 275 |
276 // printf("convert_yuv called %dx%d stride: %d,%d\n",width_y,height_y,stride_y,stride_uv); | |
277 | |
278 opendivx_src[0]=puc_y; | |
279 opendivx_src[1]=puc_u; | |
280 opendivx_src[2]=puc_v; | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
281 |
1 | 282 opendivx_stride[0]=stride_y; |
283 opendivx_stride[1]=stride_uv; | |
284 opendivx_stride[2]=stride_uv; | |
285 } | |
286 | |
287 //**************************************************************************// | |
288 | |
289 #ifdef SIMULATE_ALSA | |
290 // Simulate ALSA buffering on OSS device :) (for testing...) | |
291 | |
292 #define fake_ALSA_size 32768 | |
293 char fake_ALSA_buffer[fake_ALSA_size]; | |
294 int fake_ALSA_len=0; | |
295 | |
296 void fake_ALSA_write(int audio_fd,char* a_buffer,int len){ | |
297 while(len>0){ | |
298 int x=fake_ALSA_size-fake_ALSA_len; | |
299 if(x>0){ | |
300 if(x>len) x=len; | |
301 memcpy(&fake_ALSA_buffer[fake_ALSA_len],a_buffer,x); | |
302 fake_ALSA_len+=x;len-=x; | |
303 } | |
304 if(fake_ALSA_len>=fake_ALSA_size){ | |
305 write(audio_fd,fake_ALSA_buffer,fake_ALSA_len); | |
306 fake_ALSA_len=0; | |
307 } | |
308 } | |
309 } | |
310 #endif | |
746 | 311 |
312 //**************************************************************************// | |
313 | |
314 int audio_delay_method=2; | |
315 int audio_buffer_size=-1; | |
316 | |
317 int get_audio_delay(int audio_fd){ | |
318 if(audio_delay_method==2){ | |
319 // | |
320 int r=0; | |
321 if(ioctl(audio_fd, SNDCTL_DSP_GETODELAY, &r)!=-1) | |
322 return r; | |
323 audio_delay_method=1; // fallback if not supported | |
324 } | |
325 if(audio_delay_method==1){ | |
326 // SNDCTL_DSP_GETOSPACE | |
327 audio_buf_info zz; | |
328 if(ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &zz)!=-1) | |
329 return audio_buffer_size-zz.bytes; | |
330 audio_delay_method=0; // fallback if not supported | |
331 } | |
332 return audio_buffer_size; | |
333 } | |
334 | |
335 | |
1 | 336 //**************************************************************************// |
337 | |
338 // AVI file header reader/parser/writer: | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
339 //#include "aviheader.c" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
340 //#include "aviwrite.c" |
1 | 341 |
342 // ASF headers: | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
343 //#include "asfheader.c" |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
344 //#include "demux_asf.c" |
1 | 345 |
346 // DLL codecs init routines | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
347 //#include "dll_init.c" |
1 | 348 |
112 | 349 // Common FIFO functions, and keyboard/event FIFO code |
350 #include "fifo.c" | |
351 | |
1 | 352 //**************************************************************************// |
353 | |
354 static vo_functions_t *video_out=NULL; | |
355 | |
356 static int play_in_bg=0; | |
357 | |
606 | 358 extern void avi_fixate(); |
359 | |
723 | 360 #ifdef HAVE_GUI |
361 #include "../Gui/mplayer/psignal.h" | |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
362 #define GUI_MSG(x) if ( !nogui ) { mplSendMessage( x ); usleep( 10000 ); } |
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
363 #else |
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
364 #define GUI_MSG(x) |
723 | 365 #endif |
366 | |
1 | 367 void exit_player(char* how){ |
723 | 368 |
369 #ifdef HAVE_GUI | |
370 if ( !nogui ) | |
371 { | |
372 if ( how != NULL ) | |
373 { | |
374 if ( !strcmp( how,"Quit" ) ) mplSendMessage( mplEndOfFile ); | |
375 if ( !strcmp( how,"End of file" ) ) mplSendMessage( mplEndOfFile ); | |
376 if ( !strcmp( how,"audio_init" ) ) mplSendMessage( mplAudioError ); | |
377 } | |
378 else mplSendMessage( mplUnknowError ); | |
379 } | |
380 #endif | |
381 | |
1 | 382 if(how) printf("\nExiting... (%s)\n",how); |
340 | 383 if(verbose) printf("max framesize was %d bytes\n",max_framesize); |
1 | 384 // restore terminal: |
385 getch2_disable(); | |
398 | 386 video_out->uninit(); |
1 | 387 #ifdef USE_XMMP_AUDIO |
388 if(verbose) printf("XMM: closing audio driver...\n"); | |
389 if(pSound){ | |
390 pSound->Exit( pSound ); | |
391 xmm_Exit( &xmm ); | |
392 } | |
393 #endif | |
394 if(encode_name) avi_fixate(); | |
395 #ifdef HAVE_LIRC | |
723 | 396 #ifdef HAVE_GUI |
397 if ( nogui ) | |
398 #endif | |
1 | 399 lirc_mp_cleanup(); |
400 #endif | |
401 //if(play_in_bg) system("xsetroot -solid \\#000000"); | |
402 exit(1); | |
403 } | |
404 | |
405 static char* current_module=NULL; // for debugging | |
406 | |
407 void exit_sighandler(int x){ | |
408 static int sig_count=0; | |
409 ++sig_count; | |
410 if(sig_count==2) exit(1); | |
411 if(sig_count>2){ | |
412 // can't stop :( | |
413 kill(getpid(),SIGKILL); | |
414 } | |
415 printf("\nMPlayer interrupted by signal %d in module: %s \n",x, | |
416 current_module?current_module:"unknown" | |
417 ); | |
723 | 418 #ifdef HAVE_GUI |
419 if ( !nogui ) | |
420 { | |
421 mplShMem->items.error.signal=x; | |
422 strcpy( mplShMem->items.error.module,current_module?current_module:"unknown" ); | |
423 } | |
424 #endif | |
1 | 425 exit_player(NULL); |
426 } | |
427 | |
428 int divx_quality=0; | |
429 | |
606 | 430 extern int vcd_get_track_end(int fd,int track); |
431 extern int init_audio(sh_audio_t *sh_audio); | |
432 extern int init_video_codec(sh_video_t *sh_video); | |
433 extern void mpeg2_allocate_image_buffers(picture_t * picture); | |
434 extern void write_avi_header_1(FILE *f,int fcc,float fps,int width,int height); | |
435 extern int vo_init(void); | |
746 | 436 extern int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen); |
606 | 437 |
1 | 438 char* filename=NULL; //"MI2-Trailer.avi"; |
439 int i; | |
440 int seek_to_sec=0; | |
441 int seek_to_byte=0; | |
442 int f; // filedes | |
443 stream_t* stream=NULL; | |
444 int file_format=DEMUXER_TYPE_UNKNOWN; | |
442 | 445 int has_audio=1; |
446 //int has_video=1; | |
1 | 447 // |
448 int audio_format=0; // override | |
626 | 449 #ifdef USE_DIRECTSHOW |
450 int allow_dshow=1; | |
451 #else | |
452 int allow_dshow=0; | |
453 #endif | |
1 | 454 #ifdef ALSA_TIMER |
455 int alsa=1; | |
456 #else | |
457 int alsa=0; | |
458 #endif | |
459 int audio_id=-1; | |
460 int video_id=-1; | |
552 | 461 int dvdsub_id=-1; |
780 | 462 float default_max_pts_correction=-1;//0.01f; |
1 | 463 int delay_corrected=1; |
464 float force_fps=0; | |
465 float audio_delay=0; | |
466 int vcd_track=0; | |
467 #ifdef VCD_CACHE | |
468 int vcd_cache_size=128; | |
469 #endif | |
564
747759a4a28f
seeking in raw/broken avi files (rebuilding index chunk)
arpi_esp
parents:
561
diff
changeset
|
470 int index_mode=-1; // -1=untouched 0=don't use index 1=use (geneate) index |
1 | 471 #ifdef AVI_SYNC_BPS |
472 int pts_from_bps=1; | |
473 #else | |
474 int pts_from_bps=0; | |
475 #endif | |
798 | 476 int frame_dropping=0; // option 0=no drop 1= drop vo 2= drop decode |
1 | 477 char* title="MPlayer"; |
478 // screen info: | |
479 char* video_driver=NULL; //"mga"; // default | |
480 int fullscreen=0; | |
208
ae0f909ccc7c
Adds code to deal with vidmode selection. -- mgraffam
mgraffam
parents:
190
diff
changeset
|
481 int vidmode=0; |
337 | 482 int softzoom=0; |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
483 int flip=-1; |
337 | 484 int screen_size_x=0;//SCREEN_SIZE_X; |
485 int screen_size_y=0;//SCREEN_SIZE_Y; | |
1 | 486 int screen_size_xy=0; |
487 // movie info: | |
488 int out_fmt=0; | |
489 char *dsp="/dev/dsp"; | |
490 int force_ni=0; | |
178 | 491 char *conffile; |
151 | 492 int conffile_fd; |
212 | 493 char *font_name=NULL; |
215 | 494 float font_factor=0.75; |
258 | 495 char *sub_name=NULL; |
496 float sub_delay=0; | |
497 float sub_fps=0; | |
510 | 498 int sub_auto = 1; |
552 | 499 char *stream_dump_name=NULL; |
549 | 500 int stream_dump_type=0; |
388 | 501 //int user_bpp=0; |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
502 |
723 | 503 int osd_visible=100; |
504 int osd_function=OSD_PLAY; | |
505 int osd_last_pts=-303; | |
506 | |
507 int rel_seek_secs=0; | |
508 | |
459 | 509 #include "mixer.h" |
147 | 510 #include "cfg-mplayer.h" |
1 | 511 |
723 | 512 void parse_cfgfiles( void ) |
513 { | |
147 | 514 if (parse_config_file(conf, "/etc/mplayer.conf") < 0) |
515 exit(1); | |
178 | 516 if ((conffile = get_path("")) == NULL) { |
147 | 517 printf("Can't find HOME dir\n"); |
518 } else { | |
178 | 519 mkdir(conffile, 0777); |
520 free(conffile); | |
521 if ((conffile = get_path("config")) == NULL) { | |
522 printf("get_path(\"config\") sziiiivas\n"); | |
523 } else { | |
524 if ((conffile_fd = open(conffile, O_CREAT | O_EXCL | O_WRONLY, 0666)) != -1) { | |
525 printf("Creating config file: %s\n", conffile); | |
526 write(conffile_fd, default_config, strlen(default_config)); | |
527 close(conffile_fd); | |
528 } | |
529 if (parse_config_file(conf, conffile) < 0) | |
530 exit(1); | |
531 free(conffile); | |
151 | 532 } |
1 | 533 } |
534 } | |
535 | |
723 | 536 #ifndef HAVE_GUI |
537 int main(int argc,char* argv[], char *envp[]){ | |
538 #else | |
539 int mplayer(int argc,char* argv[], char *envp[]){ | |
540 #endif | |
541 | |
542 printf("%s",banner_text); | |
543 | |
544 #ifdef HAVE_GUI | |
545 if ( nogui ) | |
546 { | |
547 #endif | |
751 | 548 parse_cfgfiles(); |
723 | 549 if (parse_command_line(conf, argc, argv, envp, &filename) < 0) exit(1); |
550 | |
551 // Many users forget to include command line in bugreports... | |
552 if(verbose){ | |
553 printf("CommandLine:"); | |
554 for(i=1;i<argc;i++)printf(" '%s'",argv[i]); | |
555 printf("\n"); | |
556 } | |
557 | |
558 if(video_driver && strcmp(video_driver,"help")==0){ | |
559 printf("Available video output drivers:\n"); | |
560 i=0; | |
561 while (video_out_drivers[i]) { | |
562 const vo_info_t *info = video_out_drivers[i++]->get_info (); | |
563 printf("\t%s\t%s\n", info->short_name, info->name); | |
564 } | |
565 printf("\n"); | |
566 exit(0); | |
567 } | |
568 #ifdef HAVE_GUI | |
569 } | |
570 #endif | |
1 | 571 |
442 | 572 if(!filename){ |
573 if(vcd_track) filename="/dev/cdrom"; | |
574 else { | |
575 printf("%s",help_text); exit(0); | |
576 } | |
577 } | |
578 | |
579 // check video_out driver name: | |
580 if(!video_driver) | |
581 video_out=video_out_drivers[0]; | |
582 else | |
583 for (i=0; video_out_drivers[i] != NULL; i++){ | |
584 const vo_info_t *info = video_out_drivers[i]->get_info (); | |
585 if(strcmp(info->short_name,video_driver) == 0){ | |
586 video_out = video_out_drivers[i];break; | |
587 } | |
588 } | |
589 if(!video_out){ | |
590 printf("Invalid video output driver name: %s\n",video_driver); | |
591 return 0; | |
592 } | |
593 | |
594 // check codec.conf | |
595 if(!parse_codec_cfg(get_path("codecs.conf"))){ | |
596 printf("(copy/link DOCS/codecs.conf to ~/.mplayer/codecs.conf)\n"); | |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
597 GUI_MSG( mplCodecConfNotFound ) |
442 | 598 exit(1); |
599 } | |
600 | |
212 | 601 // check font |
602 if(font_name){ | |
337 | 603 vo_font=read_font_desc(font_name,font_factor,verbose>1); |
212 | 604 if(!vo_font) printf("Can't load font: %s\n",font_name); |
220 | 605 } else { |
606 // try default: | |
337 | 607 vo_font=read_font_desc(get_path("font/font.desc"),font_factor,verbose>1); |
212 | 608 } |
609 | |
258 | 610 // check .sub |
611 if(sub_name){ | |
612 subtitles=sub_read_file(sub_name); | |
613 if(!subtitles) printf("Can't load subtitles: %s\n",font_name); | |
614 } else { | |
510 | 615 if ( sub_auto ) |
616 { | |
617 // auto load sub file ... | |
618 subtitles=sub_read_file( sub_filename( filename ) ); | |
619 if ( subtitles == NULL ) subtitles=sub_read_file(get_path("default.sub")); // try default: | |
620 } else subtitles=sub_read_file(get_path("default.sub")); // try default: | |
258 | 621 } |
622 | |
623 | |
1 | 624 if(vcd_track){ |
625 //============ Open VideoCD track ============== | |
598 | 626 int ret,ret2; |
1 | 627 f=open(filename,O_RDONLY); |
628 if(f<0){ printf("CD-ROM Device '%s' not found!\n",filename);return 1; } | |
629 vcd_read_toc(f); | |
598 | 630 ret2=vcd_get_track_end(f,vcd_track); |
631 if(ret2<0){ printf("Error selecting VCD track!\n");return 1;} | |
578 | 632 ret=vcd_seek_to_track(f,vcd_track); |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
633 if(ret<0){ printf("Error selecting VCD track!\n");return 1;} |
578 | 634 seek_to_byte+=ret; |
598 | 635 if(verbose) printf("VCD start byte position: 0x%X end: 0x%X\n",seek_to_byte,ret2); |
1 | 636 #ifdef VCD_CACHE |
637 vcd_cache_init(vcd_cache_size); | |
638 #endif | |
598 | 639 stream=new_stream(f,STREAMTYPE_VCD); |
640 stream->start_pos=ret; | |
641 stream->end_pos=ret2; | |
1 | 642 } else { |
643 //============ Open plain FILE ============ | |
598 | 644 int len; |
692 | 645 if(!strcmp(filename,"-")){ |
646 // read from stdin | |
647 printf("Reading from stdin...\n"); | |
648 f=0; // 0=stdin | |
649 stream=new_stream(f,STREAMTYPE_STREAM); | |
650 } else { | |
651 f=open(filename,O_RDONLY); | |
652 if(f<0){ printf("File not found: '%s'\n",filename);return 1; } | |
653 len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET); | |
654 stream=new_stream(f,STREAMTYPE_FILE); | |
655 stream->end_pos=len; | |
656 } | |
598 | 657 } |
658 | |
492 | 659 #ifdef HAVE_LIBCSS |
546 | 660 if (dvdimportkey) { |
661 if (dvd_import_key(dvdimportkey)) { | |
662 fprintf(stderr,"Error processing DVD KEY.\n"); | |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
663 GUI_MSG( mplErrorDVDKeyProcess ) |
546 | 664 exit(1); |
665 } | |
666 printf("DVD command line requested key is stored for descrambling.\n"); | |
667 } | |
492 | 668 if (dvd_device) { |
723 | 669 if (dvd_auth(dvd_device,f)) { |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
670 GUI_MSG( mplErrorDVDAuth ) |
723 | 671 exit(0); |
672 } | |
492 | 673 printf("DVD auth sequence seems to be OK.\n"); |
674 } | |
675 #endif | |
1 | 676 |
677 //============ Open & Sync stream and detect file format =============== | |
678 | |
442 | 679 if(!has_audio) audio_id=-2; // do NOT read audio packets... |
1 | 680 |
681 //=============== Try to open as AVI file: ================= | |
682 stream_reset(stream); | |
552 | 683 demuxer=new_demuxer(stream,DEMUXER_TYPE_AVI,audio_id,video_id,dvdsub_id); |
1 | 684 stream_seek(demuxer->stream,seek_to_byte); |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
685 //printf("stream3=0x%X vs. 0x%X\n",demuxer->stream,stream); |
1 | 686 { //---- RIFF header: |
687 int id=stream_read_dword_le(demuxer->stream); // "RIFF" | |
688 if(id==mmioFOURCC('R','I','F','F')){ | |
689 stream_read_dword_le(demuxer->stream); //filesize | |
690 id=stream_read_dword_le(demuxer->stream); // "AVI " | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
691 if(id==formtypeAVI){ |
1 | 692 printf("Detected AVI file format!\n"); |
693 file_format=DEMUXER_TYPE_AVI; | |
694 } | |
695 } | |
696 } | |
697 //=============== Try to open as ASF file: ================= | |
698 if(file_format==DEMUXER_TYPE_UNKNOWN){ | |
699 stream_reset(stream); | |
552 | 700 demuxer=new_demuxer(stream,DEMUXER_TYPE_ASF,audio_id,video_id,dvdsub_id); |
1 | 701 stream_seek(demuxer->stream,seek_to_byte); |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
702 if(asf_check_header(demuxer)){ |
1 | 703 printf("Detected ASF file format!\n"); |
704 file_format=DEMUXER_TYPE_ASF; | |
705 } | |
706 } | |
707 //=============== Try to open as MPEG-PS file: ================= | |
708 if(file_format==DEMUXER_TYPE_UNKNOWN){ | |
709 stream_reset(stream); | |
552 | 710 demuxer=new_demuxer(stream,DEMUXER_TYPE_MPEG_PS,audio_id,video_id,dvdsub_id); |
1 | 711 stream_seek(demuxer->stream,seek_to_byte); |
712 if(audio_format) demuxer->audio->type=audio_format; // override audio format | |
713 if(ds_fill_buffer(demuxer->video)){ | |
714 printf("Detected MPEG-PS file format!\n"); | |
715 file_format=DEMUXER_TYPE_MPEG_PS; | |
716 } else { | |
717 // some hack to get meaningfull error messages to our unhappy users: | |
718 // if(num_elementary_packets100>16 && | |
719 // abs(num_elementary_packets101-num_elementary_packets100)<8){ | |
720 if(num_elementary_packets100>=2 && num_elementary_packets101>=2 && | |
721 abs(num_elementary_packets101-num_elementary_packets100)<8){ | |
722 file_format=DEMUXER_TYPE_MPEG_ES; // <-- hack is here :) | |
723 } else { | |
724 if(demuxer->synced==2) | |
725 printf("Missing MPEG video stream!? contact the author, it may be a bug :(\n"); | |
726 else | |
727 printf("Not MPEG System Stream format... (maybe Transport Stream?)\n"); | |
728 } | |
729 } | |
730 } | |
731 //=============== Try to open as MPEG-ES file: ================= | |
732 if(file_format==DEMUXER_TYPE_MPEG_ES){ // little hack, see above! | |
733 stream_reset(stream); | |
552 | 734 demuxer=new_demuxer(stream,DEMUXER_TYPE_MPEG_ES,audio_id,video_id,dvdsub_id); |
1 | 735 stream_seek(demuxer->stream,seek_to_byte); |
736 if(!ds_fill_buffer(demuxer->video)){ | |
737 printf("Invalid MPEG-ES stream??? contact the author, it may be a bug :(\n"); | |
738 file_format=DEMUXER_TYPE_UNKNOWN; | |
739 } else { | |
740 printf("Detected MPEG-ES file format!\n"); | |
741 } | |
742 } | |
743 //=============== Unknown, exiting... =========================== | |
744 if(file_format==DEMUXER_TYPE_UNKNOWN){ | |
745 printf("============= Sorry, this file format not recognized/supported ===============\n"); | |
746 printf("=== If this file is an AVI, ASF or MPEG stream, please contact the author! ===\n"); | |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
747 GUI_MSG( mplUnknowFileType ) |
1 | 748 exit(1); |
749 } | |
750 //====== File format recognized, set up these for compatibility: ========= | |
751 d_audio=demuxer->audio; | |
752 d_video=demuxer->video; | |
554 | 753 d_dvdsub=demuxer->sub; |
442 | 754 //d_audio->sh=sh_audio; |
755 //d_video->sh=sh_video; | |
756 //sh_audio=d_audio->sh;sh_audio->ds=d_audio; | |
757 //sh_video=d_video->sh;sh_video->ds=d_video; | |
1 | 758 |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
759 sh_audio=NULL; |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
760 sh_video=NULL; |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
761 |
1 | 762 switch(file_format){ |
763 case DEMUXER_TYPE_AVI: { | |
764 //---- AVI header: | |
692 | 765 read_avi_header(demuxer,f?index_mode:-2); |
1 | 766 stream_reset(demuxer->stream); |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
767 stream_seek(demuxer->stream,demuxer->movi_start); |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
768 demuxer->idx_pos=0; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
769 demuxer->idx_pos_a=0; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
770 demuxer->idx_pos_v=0; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
771 if(demuxer->idx_size>0){ |
1 | 772 // decide index format: |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
773 if(((AVIINDEXENTRY *)demuxer->idx)[0].dwChunkOffset<demuxer->movi_start) |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
774 demuxer->idx_offset=demuxer->movi_start-4; |
1 | 775 else |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
776 demuxer->idx_offset=0; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
777 if(verbose) printf("AVI index offset: %d\n",demuxer->idx_offset); |
1 | 778 } |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
779 // demuxer->endpos=avi_header.movi_end; |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
780 |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
781 if(demuxer->idx_size>0){ |
1 | 782 // check that file is non-interleaved: |
783 int i; | |
784 int a_pos=-1; | |
785 int v_pos=-1; | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
786 for(i=0;i<demuxer->idx_size;i++){ |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
787 AVIINDEXENTRY* idx=&((AVIINDEXENTRY *)demuxer->idx)[i]; |
1 | 788 demux_stream_t* ds=demux_avi_select_stream(demuxer,idx->ckid); |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
789 int pos=idx->dwChunkOffset+demuxer->idx_offset; |
1 | 790 if(a_pos==-1 && ds==demuxer->audio){ |
791 a_pos=pos; | |
792 if(v_pos!=-1) break; | |
793 } | |
794 if(v_pos==-1 && ds==demuxer->video){ | |
795 v_pos=pos; | |
796 if(a_pos!=-1) break; | |
797 } | |
798 } | |
799 if(v_pos==-1){ | |
800 printf("AVI_NI: missing video stream!? contact the author, it may be a bug :(\n"); | |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
801 GUI_MSG( mplErrorAVINI ) |
1 | 802 exit(1); |
803 } | |
804 if(a_pos==-1){ | |
805 printf("AVI_NI: No audio stream found -> nosound\n"); | |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
806 has_audio=0;sh_audio=NULL; |
1 | 807 } else { |
808 if(force_ni || abs(a_pos-v_pos)>0x100000){ // distance > 1MB | |
809 printf("Detected NON-INTERLEAVED AVI file-format!\n"); | |
810 demuxer->type=DEMUXER_TYPE_AVI_NI; // HACK!!!! | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
811 pts_from_bps=1; // force BPS sync! |
1 | 812 } |
813 } | |
814 } else { | |
815 // no index | |
816 if(force_ni){ | |
817 printf("Using NON-INTERLEAVED Broken AVI file-format!\n"); | |
818 demuxer->type=DEMUXER_TYPE_AVI_NINI; // HACK!!!! | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
819 demuxer->idx_pos_a= |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
820 demuxer->idx_pos_v=demuxer->movi_start; |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
821 pts_from_bps=1; // force BPS sync! |
1 | 822 } |
823 } | |
824 if(!ds_fill_buffer(d_video)){ | |
825 printf("AVI: missing video stream!? contact the author, it may be a bug :(\n"); | |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
826 GUI_MSG( mplAVIErrorMissingVideoStream ) |
1 | 827 exit(1); |
828 } | |
442 | 829 sh_video=d_video->sh;sh_video->ds=d_video; |
1 | 830 if(has_audio){ |
442 | 831 if(verbose) printf("AVI: Searching for audio stream (id:%d)\n",d_audio->id); |
1 | 832 if(!ds_fill_buffer(d_audio)){ |
442 | 833 printf("AVI: No Audio stream found... ->nosound\n"); |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
834 has_audio=0;sh_audio=NULL; |
442 | 835 } else { |
836 sh_audio=d_audio->sh;sh_audio->ds=d_audio; | |
837 sh_audio->format=sh_audio->wf->wFormatTag; | |
838 } | |
1 | 839 } |
398 | 840 // calc. FPS: |
841 sh_video->fps=(float)sh_video->video.dwRate/(float)sh_video->video.dwScale; | |
842 sh_video->frametime=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; | |
375 | 843 // calculating video bitrate: |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
844 avi_bitrate=demuxer->movi_end-demuxer->movi_start-demuxer->idx_size*8; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
845 if(sh_audio) avi_bitrate-=sh_audio->audio.dwLength; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
846 if(verbose) printf("AVI video length=%d\n",avi_bitrate); |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
847 avi_bitrate=((float)avi_bitrate/(float)sh_video->video.dwLength)*sh_video->fps; |
606 | 848 printf("VIDEO: [%.4s] %ldx%ld %dbpp %4.2f fps %5.1f kbps (%4.1f kbyte/s)\n", |
849 (char *)&sh_video->bih->biCompression, | |
442 | 850 sh_video->bih->biWidth, |
851 sh_video->bih->biHeight, | |
852 sh_video->bih->biBitCount, | |
398 | 853 sh_video->fps, |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
854 avi_bitrate*0.008f, |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
855 avi_bitrate/1024.0f ); |
1 | 856 break; |
857 } | |
858 case DEMUXER_TYPE_ASF: { | |
859 //---- ASF header: | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
860 read_asf_header(demuxer); |
1 | 861 stream_reset(demuxer->stream); |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
862 stream_seek(demuxer->stream,demuxer->movi_start); |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
863 demuxer->idx_pos=0; |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
864 // demuxer->endpos=avi_header.movi_end; |
1 | 865 if(!ds_fill_buffer(d_video)){ |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
866 printf("ASF: no video stream found!\n"); |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
867 sh_video=NULL; |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
868 //printf("ASF: missing video stream!? contact the author, it may be a bug :(\n"); |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
869 //GUI_MSG( mplASFErrorMissingVideoStream ) |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
870 //exit(1); |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
871 } else { |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
872 sh_video=d_video->sh;sh_video->ds=d_video; |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
873 sh_video->fps=1000.0f; sh_video->frametime=0.001f; // 1ms |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
874 printf("VIDEO: [%.4s] %ldx%ld %dbpp\n", |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
875 (char *)&sh_video->bih->biCompression, |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
876 sh_video->bih->biWidth, |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
877 sh_video->bih->biHeight, |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
878 sh_video->bih->biBitCount); |
1 | 879 } |
880 if(has_audio){ | |
881 if(verbose) printf("ASF: Searching for audio stream (id:%d)\n",d_audio->id); | |
882 if(!ds_fill_buffer(d_audio)){ | |
883 printf("ASF: No Audio stream found... ->nosound\n"); | |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
884 has_audio=0;sh_audio=NULL; |
442 | 885 } else { |
886 sh_audio=d_audio->sh;sh_audio->ds=d_audio; | |
887 sh_audio->format=sh_audio->wf->wFormatTag; | |
888 } | |
1 | 889 } |
890 break; | |
891 } | |
892 case DEMUXER_TYPE_MPEG_ES: { | |
442 | 893 d_audio->type=0; |
500
c2b3a1f340c8
MPEG-ES segfault fixed, stream list printfs moved v 1->0
arpi_esp
parents:
495
diff
changeset
|
894 has_audio=0;sh_audio=NULL; // ES streams has no audio channel |
c2b3a1f340c8
MPEG-ES segfault fixed, stream list printfs moved v 1->0
arpi_esp
parents:
495
diff
changeset
|
895 d_video->sh=new_sh_video(0); // create dummy video stream header, id=0 |
375 | 896 break; |
897 } | |
898 case DEMUXER_TYPE_MPEG_PS: { | |
606 | 899 if(has_audio) { |
375 | 900 if(!ds_fill_buffer(d_audio)){ |
901 printf("MPEG: No Audio stream found... ->nosound\n"); | |
442 | 902 has_audio=0;sh_audio=NULL; |
375 | 903 } else { |
442 | 904 sh_audio=d_audio->sh;sh_audio->ds=d_audio; |
382 | 905 if(verbose) printf("detected MPG-PS audio format: %d\n",d_audio->type); |
375 | 906 switch(d_audio->type){ |
907 case 1: sh_audio->format=0x50;break; // mpeg | |
442 | 908 case 2: sh_audio->format=0x10001;break; // dvd pcm |
375 | 909 case 3: sh_audio->format=0x2000;break; // ac3 |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
910 default: has_audio=0;sh_audio=NULL; // unknown type |
375 | 911 } |
912 } | |
606 | 913 } |
375 | 914 break; |
915 } | |
916 } // switch(file_format) | |
917 | |
792 | 918 // DUMP STREAMS: |
919 if(stream_dump_type){ | |
920 FILE *f; | |
921 int len; | |
922 demux_stream_t *ds=NULL; | |
923 // select stream to dump | |
924 switch(stream_dump_type){ | |
925 case 1: ds=d_audio;break; | |
926 case 2: ds=d_video;break; | |
927 case 3: ds=d_dvdsub;break; | |
928 } | |
929 if(!ds){ | |
930 printf("dump: FATAL: selected stream missing!\n"); | |
931 exit(1); | |
932 } | |
933 // disable other streams: | |
934 if(d_audio && d_audio!=ds) {ds_free_packs(d_audio); d_audio->id=-2; } | |
935 if(d_video && d_video!=ds) {ds_free_packs(d_video); d_video->id=-2; } | |
936 if(d_dvdsub && d_dvdsub!=ds) {ds_free_packs(d_dvdsub); d_dvdsub->id=-2; } | |
937 // let's dump it! | |
938 f=fopen(stream_dump_name?stream_dump_name:"stream.dump","wb"); | |
939 if(!f){ printf("Can't open dump file!!!\n");exit(1); } | |
940 while(!ds->eof){ | |
941 unsigned char* start; | |
942 int in_size=ds_get_packet(ds,&start); | |
943 if(in_size>0) fwrite(start,in_size,1,f); | |
944 } | |
945 fclose(f); | |
946 printf("core dumped :)\n"); | |
947 exit(1); | |
948 } | |
949 | |
950 | |
375 | 951 // Determine image properties: |
952 switch(file_format){ | |
953 case DEMUXER_TYPE_AVI: | |
954 case DEMUXER_TYPE_ASF: { | |
955 // display info: | |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
956 if(sh_video){ |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
957 sh_video->format=sh_video->bih->biCompression; |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
958 sh_video->disp_w=sh_video->bih->biWidth; |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
959 sh_video->disp_h=abs(sh_video->bih->biHeight); |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
960 } |
375 | 961 break; |
962 } | |
963 case DEMUXER_TYPE_MPEG_ES: | |
964 case DEMUXER_TYPE_MPEG_PS: { | |
303 | 965 // Find sequence_header first: |
966 if(verbose) printf("Searching for sequence header... ");fflush(stdout); | |
967 while(1){ | |
968 int i=sync_video_packet(d_video); | |
969 if(i==0x1B3) break; // found it! | |
970 if(!i || !skip_video_packet(d_video)){ | |
971 if(verbose) printf("NONE :(\n"); | |
972 printf("MPEG: FATAL: EOF while searching for sequence header\n"); | |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
973 GUI_MSG( mplMPEGErrorSeqHeaderSearch ) |
303 | 974 exit(1); |
975 } | |
976 } | |
977 if(verbose) printf("OK!\n"); | |
442 | 978 sh_video=d_video->sh;sh_video->ds=d_video; |
303 | 979 sh_video->format=1; // mpeg video |
375 | 980 mpeg2_init(); |
981 // ========= Read & process sequence header & extension ============ | |
982 videobuffer=shmem_alloc(VIDEOBUFFER_SIZE); | |
723 | 983 if(!videobuffer){ |
984 printf("Cannot allocate shared memory\n"); | |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
985 GUI_MSG( mplErrorShMemAlloc ) |
723 | 986 exit(0); |
987 } | |
375 | 988 videobuf_len=0; |
723 | 989 if(!read_video_packet(d_video)){ |
990 printf("FATAL: Cannot read sequence header!\n"); | |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
991 GUI_MSG( mplMPEGErrorCannotReadSeqHeader ) |
723 | 992 exit(1); |
993 } | |
375 | 994 if(header_process_sequence_header (picture, &videobuffer[4])) { |
723 | 995 printf ("bad sequence header!\n"); |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
996 GUI_MSG( mplMPEGErrorBadSeqHeader ) |
723 | 997 exit(1); |
375 | 998 } |
999 if(sync_video_packet(d_video)==0x1B5){ // next packet is seq. ext. | |
1000 videobuf_len=0; | |
723 | 1001 if(!read_video_packet(d_video)){ |
1002 printf("FATAL: Cannot read sequence header extension!\n"); | |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
1003 GUI_MSG( mplMPEGErrorCannotReadSeqHeaderExt ) |
723 | 1004 exit(1); |
1005 } | |
375 | 1006 if(header_process_extension (picture, &videobuffer[4])) { |
723 | 1007 printf ("bad sequence header extension!\n"); |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
1008 GUI_MSG( mplMPEGErrorBadSeqHeaderExt ) |
723 | 1009 exit(1); |
303 | 1010 } |
1011 } | |
375 | 1012 // display info: |
398 | 1013 sh_video->fps=frameratecode2framerate[picture->frame_rate_code]*0.0001f; |
780 | 1014 if(!sh_video->fps){ |
1015 if(!force_fps){ | |
1016 printf("FPS not specified (or invalid) in the header! Use the -fps option!\n"); | |
1017 exit(1); | |
1018 } | |
1019 sh_video->frametime=0; | |
1020 } else { | |
1021 sh_video->frametime=10000.0f/(float)frameratecode2framerate[picture->frame_rate_code]; | |
1022 } | |
398 | 1023 sh_video->disp_w=picture->display_picture_width; |
1024 sh_video->disp_h=picture->display_picture_height; | |
375 | 1025 // info: |
1026 if(verbose) printf("mpeg bitrate: %d (%X)\n",picture->bitrate,picture->bitrate); | |
1027 printf("VIDEO: %s %dx%d (aspect %d) %4.2f fps %5.1f kbps (%4.1f kbyte/s)\n", | |
1028 picture->mpeg1?"MPEG1":"MPEG2", | |
398 | 1029 sh_video->disp_w,sh_video->disp_h, |
375 | 1030 picture->aspect_ratio_information, |
398 | 1031 sh_video->fps, |
375 | 1032 picture->bitrate*0.5f, |
1033 picture->bitrate/16.0f ); | |
1 | 1034 break; |
1035 } | |
1036 } // switch(file_format) | |
1037 | |
442 | 1038 //if(verbose) printf("file successfully opened (has_audio=%d)\n",has_audio); |
1 | 1039 |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1040 if(sh_video) |
398 | 1041 printf("[V] filefmt:%d fourcc:0x%X size:%dx%d fps:%5.2f ftime:=%6.4f\n", |
1042 file_format,sh_video->format,sh_video->disp_w,sh_video->disp_h, | |
1043 sh_video->fps,sh_video->frametime | |
1044 ); | |
1045 | |
1 | 1046 fflush(stdout); |
1047 | |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1048 if(!sh_video){ |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1049 printf("Sorry, no video stream... it's unplayable yet\n"); |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1050 exit(1); |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1051 } |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1052 |
303 | 1053 //================== Init AUDIO (codec) ========================== |
1054 if(has_audio){ | |
1055 // Go through the codec.conf and find the best codec... | |
626 | 1056 sh_audio->codec=NULL; |
1057 while(1){ | |
1058 sh_audio->codec=find_codec(sh_audio->format,NULL,sh_audio->codec,1); | |
1059 if(!sh_audio->codec){ | |
1060 printf("Can't find codec for audio format 0x%X !\n",sh_audio->format); | |
1061 has_audio=0; | |
1062 break; | |
1063 } | |
1064 if(audio_format>0 && sh_audio->codec->driver!=audio_format) continue; | |
340 | 1065 printf("Found audio codec: [%s] drv:%d (%s)\n",sh_audio->codec->name,sh_audio->codec->driver,sh_audio->codec->info); |
442 | 1066 //has_audio=sh_audio->codec->driver; |
626 | 1067 break; |
303 | 1068 } |
1 | 1069 } |
1070 | |
303 | 1071 if(has_audio){ |
1072 if(verbose) printf("Initializing audio codec...\n"); | |
442 | 1073 if(!init_audio(sh_audio)){ |
303 | 1074 printf("Couldn't initialize audio codec! -> nosound\n"); |
442 | 1075 has_audio=0; |
303 | 1076 } else { |
758 | 1077 printf("AUDIO: srate=%d chans=%d bps=%d sfmt=0x%X ratio: %d->%d\n",sh_audio->samplerate,sh_audio->channels,sh_audio->samplesize, |
1078 sh_audio->sample_format,sh_audio->i_bps,sh_audio->o_bps); | |
303 | 1079 } |
175 | 1080 } |
1081 | |
303 | 1082 //================== Init VIDEO (codec & libvo) ========================== |
1083 | |
1084 // Go through the codec.conf and find the best codec... | |
626 | 1085 sh_video->codec=NULL; |
1086 while(1){ | |
1087 sh_video->codec=find_codec(sh_video->format, | |
1088 sh_video->bih?((unsigned int*) &sh_video->bih->biCompression):NULL,sh_video->codec,0); | |
1089 if(!sh_video->codec){ | |
303 | 1090 printf("Can't find codec for video format 0x%X !\n",sh_video->format); |
723 | 1091 #ifdef HAVE_GUI |
1092 if ( !nogui ) | |
1093 { | |
1094 mplShMem->items.videodata.format=sh_video->format; | |
1095 mplSendMessage( mplCantFindCodecForVideoFormat ); | |
1096 usleep( 10000 ); | |
1097 } | |
1098 #endif | |
303 | 1099 exit(1); |
626 | 1100 } |
1101 if(!allow_dshow && sh_video->codec->driver==4) continue; // skip DShow | |
1102 break; | |
303 | 1103 } |
442 | 1104 //has_video=sh_video->codec->driver; |
303 | 1105 |
340 | 1106 printf("Found video codec: [%s] drv:%d (%s)\n",sh_video->codec->name,sh_video->codec->driver,sh_video->codec->info); |
303 | 1107 |
1108 for(i=0;i<CODECS_MAX_OUTFMT;i++){ | |
487 | 1109 int ret; |
303 | 1110 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
|
1111 if(out_fmt==0xFFFFFFFF) continue; |
487 | 1112 ret=video_out->query_format(out_fmt); |
1113 if(verbose) printf("vo_debug: query(0x%X) returned 0x%X\n",out_fmt,ret); | |
1114 if(ret) break; | |
303 | 1115 } |
1116 if(i>=CODECS_MAX_OUTFMT){ | |
1117 printf("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
|
1118 GUI_MSG( mplIncompatibleVideoOutDevice ) |
303 | 1119 exit(1); |
1120 } | |
1121 sh_video->outfmtidx=i; | |
1122 | |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1123 if(flip==-1){ |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1124 // autodetect flipping |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1125 flip=0; |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1126 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
|
1127 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
|
1128 flip=1; |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1129 } |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1130 |
487 | 1131 if(verbose) printf("vo_debug1: out_fmt=0x%08X\n",out_fmt); |
1132 | |
442 | 1133 switch(sh_video->codec->driver){ |
175 | 1134 case 2: { |
723 | 1135 if(!init_video_codec(sh_video)) { |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
1136 GUI_MSG( mplUnknowError ) |
723 | 1137 exit(1); |
1138 } | |
1 | 1139 if(verbose) printf("INFO: Win32 video codec init OK!\n"); |
1140 break; | |
1141 } | |
175 | 1142 case 4: { // Win32/DirectShow |
303 | 1143 #ifndef USE_DIRECTSHOW |
1144 printf("MPlayer was compiled WITHOUT directshow support!\n"); | |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
1145 GUI_MSG( mplCompileWithoutDSSupport ) |
303 | 1146 exit(1); |
1147 #else | |
291 | 1148 sh_video->our_out_buffer=NULL; |
442 | 1149 if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, &sh_video->our_out_buffer)){ |
715 | 1150 // if(DS_VideoDecoder_Open(sh_video->codec->dll,&sh_video->codec->guid, sh_video->bih, 0, NULL)){ |
303 | 1151 printf("ERROR: Couldn't open required DirectShow codec: %s\n",sh_video->codec->dll); |
273 | 1152 printf("Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n"); |
1153 printf("package from: ftp://thot.banki.hu/esp-team/linux/MPlayer/w32codec.zip !\n"); | |
1154 printf("Or you should disable DShow support: make distclean;make -f Makefile.No-DS\n"); | |
723 | 1155 #ifdef HAVE_GUI |
1156 if ( !nogui ) | |
1157 { | |
1158 strcpy( mplShMem->items.videodata.codecdll,sh_video->codec->dll ); | |
1159 mplSendMessage( mplDSCodecNotFound ); | |
1160 usleep( 10000 ); | |
1161 } | |
1162 #endif | |
273 | 1163 exit(1); |
1164 } | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1165 |
470 | 1166 switch(out_fmt){ |
1167 case IMGFMT_YUY2: | |
1168 case IMGFMT_UYVY: | |
1169 DS_VideoDecoder_SetDestFmt(16,out_fmt);break; // packed YUV | |
1170 case IMGFMT_YV12: | |
1171 case IMGFMT_I420: | |
1172 case IMGFMT_IYUV: | |
1173 DS_VideoDecoder_SetDestFmt(12,out_fmt);break; // planar YUV | |
1174 default: | |
1175 DS_VideoDecoder_SetDestFmt(out_fmt&255,0); // RGB/BGR | |
1176 } | |
175 | 1177 |
1178 DS_VideoDecoder_Start(); | |
1179 | |
1180 printf("DivX setting result = %d\n", DS_SetAttr_DivX("Quality",divx_quality) ); | |
1181 // printf("DivX setting result = %d\n", DS_SetValue_DivX("Brightness",60) ); | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1182 |
175 | 1183 if(verbose) printf("INFO: Win32/DShow video codec init OK!\n"); |
1184 break; | |
374 | 1185 #endif |
175 | 1186 } |
1 | 1187 case 3: { // OpenDivX |
1188 if(verbose) printf("OpenDivX video codec\n"); | |
1189 { DEC_PARAM dec_param; | |
1190 DEC_SET dec_set; | |
795
ec3accad050c
opendivx 0.50cvs stuff added (disabled by default)
arpi_esp
parents:
792
diff
changeset
|
1191 // DEC_MEM_REQS dec_mem; |
442 | 1192 dec_param.x_dim = sh_video->bih->biWidth; |
1193 dec_param.y_dim = sh_video->bih->biHeight; | |
795
ec3accad050c
opendivx 0.50cvs stuff added (disabled by default)
arpi_esp
parents:
792
diff
changeset
|
1194 #if 0 |
ec3accad050c
opendivx 0.50cvs stuff added (disabled by default)
arpi_esp
parents:
792
diff
changeset
|
1195 // 0.50-CVS |
ec3accad050c
opendivx 0.50cvs stuff added (disabled by default)
arpi_esp
parents:
792
diff
changeset
|
1196 decore(0x123, DEC_OPT_MEMORY_REQS, &dec_param, &dec_mem); |
ec3accad050c
opendivx 0.50cvs stuff added (disabled by default)
arpi_esp
parents:
792
diff
changeset
|
1197 dec_param.buffers.mp4_edged_ref_buffers=malloc(dec_mem.mp4_edged_ref_buffers_size); |
ec3accad050c
opendivx 0.50cvs stuff added (disabled by default)
arpi_esp
parents:
792
diff
changeset
|
1198 dec_param.buffers.mp4_edged_for_buffers=malloc(dec_mem.mp4_edged_for_buffers_size); |
ec3accad050c
opendivx 0.50cvs stuff added (disabled by default)
arpi_esp
parents:
792
diff
changeset
|
1199 dec_param.buffers.mp4_display_buffers=malloc(dec_mem.mp4_display_buffers_size); |
ec3accad050c
opendivx 0.50cvs stuff added (disabled by default)
arpi_esp
parents:
792
diff
changeset
|
1200 dec_param.buffers.mp4_state=malloc(dec_mem.mp4_state_size); |
ec3accad050c
opendivx 0.50cvs stuff added (disabled by default)
arpi_esp
parents:
792
diff
changeset
|
1201 dec_param.buffers.mp4_tables=malloc(dec_mem.mp4_tables_size); |
ec3accad050c
opendivx 0.50cvs stuff added (disabled by default)
arpi_esp
parents:
792
diff
changeset
|
1202 dec_param.buffers.mp4_stream=malloc(dec_mem.mp4_stream_size); |
ec3accad050c
opendivx 0.50cvs stuff added (disabled by default)
arpi_esp
parents:
792
diff
changeset
|
1203 #else |
ec3accad050c
opendivx 0.50cvs stuff added (disabled by default)
arpi_esp
parents:
792
diff
changeset
|
1204 dec_param.color_depth = 32; |
ec3accad050c
opendivx 0.50cvs stuff added (disabled by default)
arpi_esp
parents:
792
diff
changeset
|
1205 #endif |
442 | 1206 decore(0x123, DEC_OPT_INIT, &dec_param, NULL); |
1207 dec_set.postproc_level = divx_quality; | |
1208 decore(0x123, DEC_OPT_SETPP, &dec_set, NULL); | |
795
ec3accad050c
opendivx 0.50cvs stuff added (disabled by default)
arpi_esp
parents:
792
diff
changeset
|
1209 |
1 | 1210 } |
1211 if(verbose) printf("INFO: OpenDivX video codec init OK!\n"); | |
1212 break; | |
1213 } | |
1214 case 1: { | |
1215 // init libmpeg2: | |
41 | 1216 #ifdef MPEG12_POSTPROC |
1 | 1217 picture->pp_options=divx_quality; |
41 | 1218 #else |
1219 if(divx_quality){ | |
1220 printf("WARNING! You requested image postprocessing for an MPEG 1/2 video,\n"); | |
1221 printf(" but compiled MPlayer without MPEG 1/2 postprocessing support!\n"); | |
1222 printf(" #define MPEG12_POSTPROC in config.h, and recompile libmpeg2!\n"); | |
1223 } | |
1224 #endif | |
375 | 1225 mpeg2_allocate_image_buffers (picture); |
1 | 1226 break; |
1227 } | |
1228 } | |
1229 | |
487 | 1230 if(verbose) printf("vo_debug2: out_fmt=0x%08X\n",out_fmt); |
1231 | |
1 | 1232 // ================== Init output files for encoding =============== |
1233 if(encode_name){ | |
1234 // encode file!!! | |
1235 FILE *encode_file=fopen(encode_name,"rb"); | |
1236 if(encode_file){ | |
1237 fclose(encode_file); | |
1238 printf("File already exists: %s (don't overwrite your favourite AVI!)\n",encode_name); | |
1239 return 0; | |
1240 } | |
1241 encode_file=fopen(encode_name,"wb"); | |
1242 if(!encode_file){ | |
1243 printf("Cannot create file for encoding\n"); | |
1244 return 0; | |
1245 } | |
398 | 1246 write_avi_header_1(encode_file,mmioFOURCC('d', 'i', 'v', 'x'),sh_video->fps,sh_video->disp_w,sh_video->disp_h); |
1 | 1247 fclose(encode_file); |
1248 encode_index_name=malloc(strlen(encode_name)+8); | |
1249 strcpy(encode_index_name,encode_name); | |
1250 strcat(encode_index_name,".index"); | |
1251 if((encode_file=fopen(encode_index_name,"wb"))) | |
1252 fclose(encode_file); | |
1253 else encode_index_name=NULL; | |
1254 has_audio=0; // disable audio !!!!! | |
1255 } | |
1256 | |
1257 // ========== Init keyboard FIFO (connection to libvo) ============ | |
1258 | |
1259 make_pipe(&keyb_fifo_get,&keyb_fifo_put); | |
1260 | |
398 | 1261 // ========== Init display (sh_video->disp_w*sh_video->disp_h/out_fmt) ============ |
1 | 1262 |
1263 #ifdef X11_FULLSCREEN | |
1264 if(fullscreen){ | |
1265 if(vo_init()){ | |
1266 //if(verbose) printf("X11 running at %dx%d depth: %d\n",vo_screenwidth,vo_screenheight,vo_depthonscreen); | |
1267 } | |
1268 if(!screen_size_xy) screen_size_xy=vo_screenwidth; // scale with asp.ratio | |
1269 } | |
1270 #endif | |
1271 | |
1272 if(screen_size_xy>0){ | |
1273 if(screen_size_xy<=8){ | |
398 | 1274 screen_size_x=screen_size_xy*sh_video->disp_w; |
1275 screen_size_y=screen_size_xy*sh_video->disp_h; | |
1 | 1276 } else { |
1277 screen_size_x=screen_size_xy; | |
398 | 1278 screen_size_y=screen_size_xy*sh_video->disp_h/sh_video->disp_w; |
1 | 1279 } |
337 | 1280 } else if(!vidmode){ |
1281 if(!screen_size_x) screen_size_x=SCREEN_SIZE_X; | |
1282 if(!screen_size_y) screen_size_y=SCREEN_SIZE_Y; | |
398 | 1283 if(screen_size_x<=8) screen_size_x*=sh_video->disp_w; |
1284 if(screen_size_y<=8) screen_size_y*=sh_video->disp_h; | |
1 | 1285 } |
208
ae0f909ccc7c
Adds code to deal with vidmode selection. -- mgraffam
mgraffam
parents:
190
diff
changeset
|
1286 |
340 | 1287 { const vo_info_t *info = video_out->get_info(); |
766 | 1288 printf("VO: [%s] %dx%d => %dx%d %s%s%s%s ",info->short_name, |
398 | 1289 sh_video->disp_w,sh_video->disp_h, |
340 | 1290 screen_size_x,screen_size_y, |
1291 fullscreen?"fs ":"", | |
1292 vidmode?"vm ":"", | |
766 | 1293 softzoom?"zoom ":"", |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1294 (flip==1)?"flip ":"" |
766 | 1295 // fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3) |
340 | 1296 ); |
1297 if((out_fmt&IMGFMT_BGR_MASK)==IMGFMT_BGR) | |
1298 printf("BGR%d\n",out_fmt&255); else | |
766 | 1299 if((out_fmt&IMGFMT_RGB_MASK)==IMGFMT_RGB) |
340 | 1300 printf("RGB%d\n",out_fmt&255); else |
1301 if(out_fmt==IMGFMT_YUY2) printf("YUY2\n"); else | |
470 | 1302 if(out_fmt==IMGFMT_UYVY) printf("UYVY\n"); else |
766 | 1303 if(out_fmt==IMGFMT_YVYU) printf("YVYU\n"); else |
470 | 1304 if(out_fmt==IMGFMT_I420) printf("I420\n"); else |
1305 if(out_fmt==IMGFMT_IYUV) printf("IYUV\n"); else | |
340 | 1306 if(out_fmt==IMGFMT_YV12) printf("YV12\n"); |
1307 } | |
1308 | |
1309 // if(verbose) printf("Destination size: %d x %d out_fmt=%0X\n", | |
1310 // screen_size_x,screen_size_y,out_fmt); | |
1 | 1311 |
337 | 1312 if(verbose) printf("video_out->init(%dx%d->%dx%d,flags=%d,'%s',0x%X)\n", |
398 | 1313 sh_video->disp_w,sh_video->disp_h, |
1 | 1314 screen_size_x,screen_size_y, |
766 | 1315 fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3), |
337 | 1316 title,out_fmt); |
1 | 1317 |
487 | 1318 if(verbose) printf("vo_debug3: out_fmt=0x%08X\n",out_fmt); |
1319 | |
723 | 1320 #ifdef HAVE_GUI |
1321 if ( !nogui ) | |
1322 { | |
1323 mplShMem->items.videodata.width=sh_video->disp_w; | |
1324 mplShMem->items.videodata.height=sh_video->disp_h; | |
1325 mplSendMessage( mplSetVideoData ); | |
1326 } | |
1327 #endif | |
1328 | |
398 | 1329 if(video_out->init(sh_video->disp_w,sh_video->disp_h, |
1 | 1330 screen_size_x,screen_size_y, |
766 | 1331 fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3), |
337 | 1332 title,out_fmt)){ |
723 | 1333 printf("FATAL: Cannot initialize video driver!\n"); |
748
717e4677d9ce
stime compile bug fixed. and GUI_MSG macro defined.
pontscho
parents:
746
diff
changeset
|
1334 GUI_MSG( mplCantInitVideoDriver ) |
723 | 1335 exit(1); |
1 | 1336 } |
1337 if(verbose) printf("INFO: Video OUT driver init OK!\n"); | |
1338 | |
1339 fflush(stdout); | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1340 |
1 | 1341 //================== MAIN: ========================== |
1342 { | |
1343 int audio_fd=-1; | |
746 | 1344 int outburst=OUTBURST; |
1345 float audio_buffer_delay=0; | |
1346 | |
1347 //float buffer_delay=0; | |
1 | 1348 float frame_correction=0; // A-V timestamp kulonbseg atlagolas |
1349 int frame_corr_num=0; // | |
1350 float a_frame=0; // Audio | |
1351 float v_frame=0; // Video | |
1352 float time_frame=0; // Timer | |
1353 float c_total=0; | |
780 | 1354 float max_pts_correction=0;//default_max_pts_correction; |
1 | 1355 int eof=0; |
1356 int force_redraw=0; | |
1357 float num_frames=0; // number of frames played | |
1358 double video_time_usage=0; | |
1359 double vout_time_usage=0; | |
1360 double audio_time_usage=0; | |
36 | 1361 int grab_frames=0; |
212 | 1362 char osd_text_buffer[64]; |
715 | 1363 int drop_frame=0; |
1364 int drop_frame_cnt=0; | |
1 | 1365 |
1366 #ifdef HAVE_LIRC | |
723 | 1367 #ifdef HAVE_GUI |
1368 if ( nogui ) | |
1369 #endif | |
1 | 1370 lirc_mp_setup(); |
1371 #endif | |
1372 | |
1373 #ifdef USE_TERMCAP | |
1374 load_termcap(NULL); // load key-codes | |
1375 #endif | |
692 | 1376 if(f) getch2_enable(); |
1 | 1377 |
1378 //========= Catch terminate signals: ================ | |
1379 // terminate requests: | |
1380 signal(SIGTERM,exit_sighandler); // kill | |
1381 signal(SIGHUP,exit_sighandler); // kill -HUP / xterm closed | |
723 | 1382 |
1383 #ifdef HAVE_GUI | |
1384 if ( nogui ) | |
1385 #endif | |
1386 signal(SIGINT,exit_sighandler); // Interrupt from keyboard | |
1387 | |
1 | 1388 signal(SIGQUIT,exit_sighandler); // Quit from keyboard |
1389 // fatal errors: | |
1390 signal(SIGBUS,exit_sighandler); // bus error | |
1391 signal(SIGSEGV,exit_sighandler); // segfault | |
1392 signal(SIGILL,exit_sighandler); // illegal instruction | |
1393 signal(SIGFPE,exit_sighandler); // floating point exc. | |
1394 signal(SIGABRT,exit_sighandler); // abort() | |
1395 | |
1396 //================ SETUP AUDIO ========================== | |
1397 current_module="setup_audio"; | |
1398 | |
1399 if(has_audio){ | |
1400 #ifdef USE_XMMP_AUDIO | |
1401 xmm_Init( &xmm ); | |
1402 xmm.cSound = (XMM_PluginSound *)xmm_PluginRegister( XMMP_AUDIO_DRIVER ); | |
1403 if( xmm.cSound ){ | |
1404 pSound = xmm.cSound->Init( &xmm ); | |
296 | 1405 if( pSound && pSound->Start( pSound, sh_audio->samplerate, sh_audio->channels, |
1406 ( sh_audio->samplesize == 2 ) ? XMM_SOUND_FMT_S16LE : XMM_SOUND_FMT_U8 )){ | |
1 | 1407 printf("XMM: audio setup ok\n"); |
1408 } else { | |
1409 has_audio=0; | |
1410 } | |
1411 } else has_audio=0; | |
1412 #else | |
1413 audio_fd=open(dsp, O_WRONLY); | |
1414 if(audio_fd<0){ | |
1415 printf("Can't open audio device %s -> nosound\n",dsp); | |
1416 has_audio=0; | |
1417 } | |
1418 #endif | |
1419 } | |
1420 | |
1421 if(has_audio){ | |
1422 #ifdef USE_XMMP_AUDIO | |
1423 if(audio_buffer_size==-1){ | |
1424 // Measuring buffer size: | |
746 | 1425 audio_buffer_delay=pSound->QueryDelay(pSound, 0); |
1 | 1426 } else { |
1427 // -abs commandline option | |
746 | 1428 audio_buffer_delay=audio_buffer_size/(float)(sh_audio->o_bps); |
1 | 1429 } |
1430 #else | |
1431 int r; | |
746 | 1432 audio_buf_info zz; |
1433 | |
758 | 1434 r=sh_audio->sample_format; |
1435 // (sh_audio->samplesize==2)?AFMT_S16_LE:AFMT_U8; | |
1436 ioctl (audio_fd, SNDCTL_DSP_SETFMT, &r); | |
1437 printf("audio_setup: sample format: 0x%X (requested: 0x%X)\n",r,sh_audio->sample_format); | |
1438 | |
296 | 1439 r=sh_audio->channels-1; ioctl (audio_fd, SNDCTL_DSP_STEREO, &r); |
758 | 1440 |
746 | 1441 r=sh_audio->samplerate; if(ioctl (audio_fd, SNDCTL_DSP_SPEED, &r)==-1){ |
1442 printf("audio_setup: your card doesn't support %d Hz samplerate => nosound\n",r); | |
1443 has_audio=0; | |
1444 } else | |
1445 printf("audio_setup: using %d Hz samplerate (requested: %d)\n",r,sh_audio->samplerate); | |
1 | 1446 |
746 | 1447 if(ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &zz)==-1){ |
1448 printf("audio_setup: driver doesn't support SNDCTL_DSP_GETOSPACE :-(\n"); | |
1449 r=0; | |
1450 if(ioctl(audio_fd, SNDCTL_DSP_GETBLKSIZE, &r)==-1){ | |
1451 printf("audio_setup: %d bytes/frag (config.h)\n",outburst); | |
1452 } else { | |
1453 outburst=r; | |
1454 printf("audio_setup: %d bytes/frag (GETBLKSIZE)\n",outburst); | |
1455 } | |
1456 } else { | |
1457 printf("audio_setup: frags: %3d/%d (%d bytes/frag) free: %6d\n", | |
1458 zz.fragments, zz.fragstotal, zz.fragsize, zz.bytes); | |
1459 if(audio_buffer_size==-1) audio_buffer_size=zz.bytes; | |
1460 outburst=zz.fragsize; | |
1461 } | |
103 | 1462 |
1 | 1463 if(audio_buffer_size==-1){ |
1464 // Measuring buffer size: | |
1465 audio_buffer_size=0; | |
1466 #ifdef HAVE_AUDIO_SELECT | |
1467 while(audio_buffer_size<0x40000){ | |
1468 fd_set rfds; | |
1469 struct timeval tv; | |
1470 FD_ZERO(&rfds); FD_SET(audio_fd,&rfds); | |
1471 tv.tv_sec=0; tv.tv_usec = 0; | |
1472 if(!select(audio_fd+1, NULL, &rfds, NULL, &tv)) break; | |
746 | 1473 write(audio_fd,&sh_audio->a_buffer[sh_audio->a_buffer_len],outburst); |
1474 audio_buffer_size+=outburst; | |
1 | 1475 } |
1476 if(audio_buffer_size==0){ | |
1477 printf("\n *** Your audio driver DOES NOT support select() ***\n"); | |
1478 printf("Recompile mplayer with #undef HAVE_AUDIO_SELECT in config.h !\n\n"); | |
1479 exit_player("audio_init"); | |
1480 } | |
1481 #endif | |
1482 } | |
746 | 1483 audio_buffer_delay=audio_buffer_size/(float)(sh_audio->o_bps); |
1 | 1484 #endif |
746 | 1485 printf("Audio buffer size: %d bytes, delay: %5.3fs\n",audio_buffer_size,audio_buffer_delay); |
1486 | |
758 | 1487 // fixup audio buffer size: |
782 | 1488 // if(outburst<MAX_OUTBURST){ |
1489 // sh_audio->a_buffer_size=sh_audio->audio_out_minsize+outburst; | |
1490 // printf("Audio out buffer size reduced to %d bytes\n",sh_audio->a_buffer_size); | |
1491 // } | |
758 | 1492 |
746 | 1493 // a_frame=-(audio_buffer_delay); |
1494 a_frame=0; | |
721 | 1495 // RESET_AUDIO(audio_fd); |
1 | 1496 } |
1497 | |
1498 | |
340 | 1499 if(!has_audio){ |
1 | 1500 printf("Audio: no sound\n"); |
1501 if(verbose) printf("Freeing %d unused audio chunks\n",d_audio->packs); | |
1502 ds_free_packs(d_audio); // free buffered chunks | |
1503 d_audio->id=-2; // do not read audio chunks | |
442 | 1504 if(sh_audio) if(sh_audio->a_buffer) free(sh_audio->a_buffer); |
296 | 1505 alsa=1; |
1506 // fake, required for timer: | |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1507 #if 1 |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1508 sh_audio=NULL; |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1509 #else |
442 | 1510 sh_audio=new_sh_audio(255); // FIXME!!!!!!!!!! |
296 | 1511 sh_audio->samplerate=76800; |
1512 sh_audio->samplesize=sh_audio->channels=2; | |
1513 sh_audio->o_bps=sh_audio->channels*sh_audio->samplerate*sh_audio->samplesize; | |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1514 #endif |
1 | 1515 } |
1516 | |
1517 current_module=NULL; | |
1518 | |
1519 //==================== START PLAYING ======================= | |
1520 | |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1521 if(file_format==DEMUXER_TYPE_AVI && has_audio){ |
780 | 1522 //a_pts=d_audio->pts; |
1523 printf("Initial frame delay A: %d V: %d\n",sh_audio->audio.dwInitialFrames,sh_video->video.dwInitialFrames); | |
1524 if(!pts_from_bps){ | |
1525 float x=(float)(sh_audio->audio.dwInitialFrames-sh_video->video.dwInitialFrames)*sh_video->frametime; | |
1526 audio_delay-=x; | |
1527 printf("AVI Initial frame delay: %5.3f\n",x); | |
1528 } | |
340 | 1529 if(verbose){ |
780 | 1530 // printf("v: audio_delay=%5.3f buffer_delay=%5.3f a_pts=%5.3f a_frame=%5.3f\n", |
1531 // audio_delay,audio_buffer_delay,a_pts,a_frame); | |
340 | 1532 printf("START: a_pts=%5.3f v_pts=%5.3f \n",d_audio->pts,d_video->pts); |
1533 } | |
1 | 1534 delay_corrected=0; // has to correct PTS diffs |
1535 d_video->pts=0;d_audio->pts=0; // PTS is outdated now! | |
780 | 1536 } else { |
1537 pts_from_bps=0; // it must be 0 for mpeg/asf ! | |
1 | 1538 } |
398 | 1539 if(force_fps){ |
1540 sh_video->fps=force_fps; | |
1541 sh_video->frametime=1.0f/sh_video->fps; | |
1542 } | |
1 | 1543 |
1544 printf("Start playing...\n");fflush(stdout); | |
1545 | |
1546 InitTimer(); | |
1547 | |
1548 while(!eof){ | |
1549 | |
1550 /*========================== PLAY AUDIO ============================*/ | |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1551 //if(!has_audio){ |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1552 // int playsize=512; |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1553 // a_frame+=playsize/(float)(sh_audio->o_bps); |
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1554 // a_pts+=playsize/(float)(sh_audio->o_bps); |
746 | 1555 //time_frame+=playsize/(float)(sh_audio->o_bps); |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
1556 //} else |
1 | 1557 while(has_audio){ |
746 | 1558 unsigned int t; |
1559 int playsize=outburst; | |
1560 audio_buf_info zz; | |
1561 int use_select=1; | |
1562 | |
1563 if(ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &zz)!=-1){ | |
1564 // calculate exact buffer space: | |
1565 playsize=zz.fragments*zz.fragsize; | |
1566 if(!playsize) break; // buffer is full, do not block here!!! | |
1567 use_select=0; | |
1568 } | |
1569 | |
1570 if(playsize>MAX_OUTBURST) playsize=MAX_OUTBURST; // we shouldn't exceed it! | |
1571 //if(playsize>outburst) playsize=outburst; | |
291 | 1572 |
1573 // Update buffer if needed | |
746 | 1574 t=GetTimer(); |
1 | 1575 current_module="decode_audio"; // Enter AUDIO decoder module |
746 | 1576 while(sh_audio->a_buffer_len<playsize && !d_audio->eof){ |
1577 int ret=decode_audio(sh_audio,&sh_audio->a_buffer[sh_audio->a_buffer_len], | |
1578 playsize-sh_audio->a_buffer_len,sh_audio->a_buffer_size-sh_audio->a_buffer_len); | |
296 | 1579 if(ret>0) sh_audio->a_buffer_len+=ret; else break; |
1 | 1580 } |
1581 current_module=NULL; // Leave AUDIO decoder module | |
291 | 1582 t=GetTimer()-t;audio_time_usage+=t*0.000001; |
746 | 1583 |
1584 if(playsize>sh_audio->a_buffer_len) playsize=sh_audio->a_buffer_len; | |
1585 playsize/=outburst; playsize*=outburst; // rounding to fragment boundary | |
1586 | |
1587 // printf("play %d bytes of %d [max: %d]\n",playsize,sh_audio->a_buffer_len,sh_audio->a_buffer_size); | |
1 | 1588 |
1589 // Play sound from the buffer: | |
746 | 1590 if(playsize>0){ // if not EOF |
1 | 1591 #ifdef USE_XMMP_AUDIO |
746 | 1592 pSound->Write( pSound, sh_audio->a_buffer, playsize ); |
1 | 1593 #else |
1594 #ifdef SIMULATE_ALSA | |
746 | 1595 fake_ALSA_write(audio_fd,sh_audio->a_buffer,playsize); // for testing purposes |
1 | 1596 #else |
746 | 1597 playsize=write(audio_fd,sh_audio->a_buffer,playsize); |
1 | 1598 #endif |
1599 #endif | |
746 | 1600 if(playsize>0){ |
1601 sh_audio->a_buffer_len-=playsize; | |
1602 memcpy(sh_audio->a_buffer,&sh_audio->a_buffer[playsize],sh_audio->a_buffer_len); | |
1603 a_frame+=playsize/(float)(sh_audio->o_bps); | |
1604 //a_pts+=playsize/(float)(sh_audio->o_bps); | |
1605 // time_frame+=playsize/(float)(sh_audio->o_bps); | |
1606 } | |
1 | 1607 #ifndef USE_XMMP_AUDIO |
1608 #ifndef SIMULATE_ALSA | |
1609 // check buffer | |
1610 #ifdef HAVE_AUDIO_SELECT | |
746 | 1611 if(use_select){ // do not use this code if SNDCTL_DSP_GETOSPACE works |
1612 fd_set rfds; | |
1 | 1613 struct timeval tv; |
1614 FD_ZERO(&rfds); | |
1615 FD_SET(audio_fd, &rfds); | |
1616 tv.tv_sec = 0; | |
1617 tv.tv_usec = 0; | |
1618 if(select(audio_fd+1, NULL, &rfds, NULL, &tv)){ | |
296 | 1619 a_frame+=OUTBURST/(float)(sh_audio->o_bps); |
746 | 1620 // a_pts+=OUTBURST/(float)(sh_audio->o_bps); |
1 | 1621 // printf("Filling audio buffer...\n"); |
1622 continue; | |
1623 // } else { | |
1624 // printf("audio buffer full...\n"); | |
1625 } | |
1626 } | |
1627 #endif | |
1628 #endif | |
1629 #endif | |
1630 } | |
1631 | |
1632 break; | |
1633 } // if(has_audio) | |
1634 | |
1635 /*========================== UPDATE TIMERS ============================*/ | |
746 | 1636 #if 0 |
1 | 1637 if(alsa){ |
1638 // Use system timer for sync, not audio card/driver | |
1639 time_frame-=GetRelativeTime(); | |
1640 if(time_frame<-0.1 || time_frame>0.1){ | |
1641 time_frame=0; | |
1642 } else { | |
398 | 1643 while(time_frame>0.022){ |
535 | 1644 usleep(time_frame-0.022); |
398 | 1645 time_frame-=GetRelativeTime(); |
1646 } | |
103 | 1647 while(time_frame>0.007){ |
398 | 1648 usleep(0); |
103 | 1649 time_frame-=GetRelativeTime(); |
1650 } | |
398 | 1651 } |
1 | 1652 } |
746 | 1653 #endif |
1 | 1654 |
1655 /*========================== PLAY VIDEO ============================*/ | |
1656 | |
1657 if(1) | |
746 | 1658 while(1){ |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1659 |
398 | 1660 float frame_time=1; |
1661 float pts1=d_video->pts; | |
1 | 1662 |
1663 current_module="decode_video"; | |
715 | 1664 |
746 | 1665 // if(!force_redraw && v_frame+0.1<a_frame) drop_frame=1; else drop_frame=0; |
798 | 1666 // if(drop_frame) ++drop_frame_cnt; |
1 | 1667 |
1668 //-------------------- Decode a frame: ----------------------- | |
442 | 1669 switch(sh_video->codec->driver){ |
1 | 1670 case 3: { |
1671 // OpenDivX | |
1672 unsigned int t=GetTimer(); | |
1673 unsigned int t2; | |
1674 DEC_FRAME dec_frame; | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
1675 unsigned char* start=NULL; |
1 | 1676 int in_size=ds_get_packet(d_video,&start); |
1677 if(in_size<0){ eof=1;break;} | |
1678 if(in_size>max_framesize) max_framesize=in_size; | |
1679 // let's decode | |
1680 dec_frame.length = in_size; | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1681 dec_frame.bitstream = start; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1682 dec_frame.render_flag = 1; |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1683 decore(0x123, 0, &dec_frame, NULL); |
1 | 1684 t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; |
1685 | |
1686 if(opendivx_src[0]){ | |
1687 video_out->draw_slice(opendivx_src,opendivx_stride, | |
398 | 1688 sh_video->disp_w,sh_video->disp_h,0,0); |
1 | 1689 opendivx_src[0]=NULL; |
1690 } | |
1691 t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; | |
1692 | |
1693 break; | |
1694 } | |
175 | 1695 #ifdef USE_DIRECTSHOW |
1696 case 4: { // W32/DirectShow | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
1697 unsigned char* start=NULL; |
175 | 1698 unsigned int t=GetTimer(); |
1699 unsigned int t2; | |
1700 int in_size=ds_get_packet(d_video,&start); | |
1701 if(in_size<0){ eof=1;break;} | |
1702 if(in_size>max_framesize) max_framesize=in_size; | |
1703 | |
798 | 1704 if(drop_frame<2) DS_VideoDecoder_DecodeFrame(start, in_size, 0, !drop_frame); |
470 | 1705 current_module="draw_frame"; |
1706 | |
721 | 1707 if(!drop_frame && sh_video->our_out_buffer){ |
175 | 1708 t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; |
470 | 1709 if(out_fmt==IMGFMT_YV12||out_fmt==IMGFMT_IYUV||out_fmt==IMGFMT_I420){ |
1710 uint8_t* dst[3]; | |
1711 int stride[3]; | |
1712 stride[0]=sh_video->disp_w; | |
1713 stride[1]=stride[2]=sh_video->disp_w/2; | |
1714 dst[0]=sh_video->our_out_buffer; | |
1715 dst[2]=dst[0]+sh_video->disp_w*sh_video->disp_h; | |
1716 dst[1]=dst[2]+sh_video->disp_w*sh_video->disp_h/4; | |
1717 video_out->draw_slice(dst,stride,sh_video->disp_w,sh_video->disp_h,0,0); | |
1718 } else | |
291 | 1719 video_out->draw_frame((uint8_t **)&sh_video->our_out_buffer); |
175 | 1720 t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; |
715 | 1721 } |
175 | 1722 break; |
1723 } | |
1724 #endif | |
1 | 1725 case 2: { |
1726 HRESULT ret; | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
1727 unsigned char* start=NULL; |
1 | 1728 unsigned int t=GetTimer(); |
1729 unsigned int t2; | |
1730 int in_size=ds_get_packet(d_video,&start); | |
1731 if(in_size<0){ eof=1;break;} | |
1732 if(in_size>max_framesize) max_framesize=in_size; | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1733 |
442 | 1734 if(in_size){ |
1735 sh_video->bih->biSizeImage = in_size; | |
1736 // ret = ICDecompress(avi_header.hic, ICDECOMPRESS_NOTKEYFRAME|(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL), | |
715 | 1737 ret = ICDecompress(sh_video->hic, ICDECOMPRESS_NOTKEYFRAME | |
798 | 1738 ( (drop_frame==2)?(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL):0 ) , |
442 | 1739 sh_video->bih, start, |
715 | 1740 &sh_video->o_bih, |
1741 drop_frame ? 0 : sh_video->our_out_buffer); | |
1742 | |
606 | 1743 if(ret){ printf("Error decompressing frame, err=%d\n",(int)ret);break; } |
442 | 1744 } |
470 | 1745 current_module="draw_frame"; |
715 | 1746 if(!drop_frame){ |
1 | 1747 t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; |
470 | 1748 // if(out_fmt==IMGFMT_YV12){ |
1749 if(out_fmt==IMGFMT_YV12||out_fmt==IMGFMT_IYUV||out_fmt==IMGFMT_I420){ | |
1750 uint8_t* dst[3]; | |
1751 int stride[3]; | |
1752 stride[0]=sh_video->disp_w; | |
1753 stride[1]=stride[2]=sh_video->disp_w/2; | |
1754 dst[0]=sh_video->our_out_buffer; | |
1755 dst[2]=dst[0]+sh_video->disp_w*sh_video->disp_h; | |
1756 dst[1]=dst[2]+sh_video->disp_w*sh_video->disp_h/4; | |
1757 video_out->draw_slice(dst,stride,sh_video->disp_w,sh_video->disp_h,0,0); | |
1758 } else | |
291 | 1759 video_out->draw_frame((uint8_t **)&sh_video->our_out_buffer); |
1 | 1760 t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; |
715 | 1761 } |
1 | 1762 break; |
1763 } | |
1764 case 1: { | |
111 | 1765 int in_frame=0; |
398 | 1766 int t=0; |
1767 float newfps; | |
111 | 1768 videobuf_len=0; |
1769 while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE){ | |
1770 int i=sync_video_packet(d_video); | |
1771 if(in_frame){ | |
1772 if(i<0x101 || i>=0x1B0){ // not slice code -> end of frame | |
398 | 1773 #if 1 |
111 | 1774 // send END OF FRAME code: |
1775 videobuffer[videobuf_len+0]=0; | |
1776 videobuffer[videobuf_len+1]=0; | |
1777 videobuffer[videobuf_len+2]=1; | |
1778 videobuffer[videobuf_len+3]=0xFF; | |
1779 videobuf_len+=4; | |
1780 #endif | |
1781 if(!i) eof=1; // EOF | |
1782 break; | |
1783 } | |
1784 } else { | |
1785 //if(i==0x100) in_frame=1; // picture startcode | |
1786 if(i>=0x101 && i<0x1B0) in_frame=1; // picture startcode | |
1787 else if(!i){ eof=1; break;} // EOF | |
1788 } | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1789 if(grab_frames==2 && (i==0x1B3 || i==0x1B8)) grab_frames=1; |
111 | 1790 if(!read_video_packet(d_video)){ eof=1; break;} // EOF |
1791 //printf("read packet 0x%X, len=%d\n",i,videobuf_len); | |
1792 } | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1793 |
111 | 1794 if(videobuf_len>max_framesize) max_framesize=videobuf_len; // debug |
1795 //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
|
1796 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
|
1797 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
|
1798 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
|
1799 fclose(f); |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1800 } |
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1801 |
398 | 1802 t-=GetTimer(); |
111 | 1803 mpeg2_decode_data(video_out, videobuffer, videobuffer+videobuf_len); |
398 | 1804 t+=GetTimer(); video_time_usage+=t*0.000001; |
111 | 1805 |
398 | 1806 newfps=frameratecode2framerate[picture->frame_rate_code]*0.0001f; |
442 | 1807 if(ABS(sh_video->fps-newfps)>0.01f) if(!force_fps){ |
398 | 1808 printf("Warning! FPS changed %5.3f -> %5.3f (%f) [%d] \n",sh_video->fps,newfps,sh_video->fps-newfps,picture->frame_rate_code); |
1809 sh_video->fps=newfps; | |
1810 sh_video->frametime=10000.0f/(float)frameratecode2framerate[picture->frame_rate_code]; | |
1 | 1811 } |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
1812 |
398 | 1813 frame_time=(100+picture->repeat_count)*0.01f; |
1814 picture->repeat_count=0; | |
1815 | |
1 | 1816 break; |
1817 } | |
1818 } // switch | |
1819 //------------------------ frame decoded. -------------------- | |
1820 | |
398 | 1821 // Increase video timers: |
1822 num_frames+=frame_time; | |
1823 frame_time*=sh_video->frametime; | |
442 | 1824 if(file_format==DEMUXER_TYPE_ASF && !force_fps){ |
398 | 1825 // .ASF files has no fixed FPS - just frame durations! |
1826 float d=d_video->pts-pts1; | |
1827 if(d>=0 && d<5) frame_time=d; | |
595 | 1828 if(d>0){ |
1829 if(verbose) | |
1830 if((int)sh_video->fps==1000) | |
1831 printf("\rASF framerate: %d fps \n",(int)(1.0f/d)); | |
1832 sh_video->frametime=d; // 1ms | |
1833 sh_video->fps=1.0f/d; | |
1834 } | |
398 | 1835 } |
1836 v_frame+=frame_time; | |
780 | 1837 //v_pts+=frame_time; |
746 | 1838 time_frame+=frame_time; // for nosound |
1839 | |
780 | 1840 if(file_format==DEMUXER_TYPE_MPEG_PS) d_video->pts+=frame_time; |
1841 | |
798 | 1842 if(drop_frame){ |
746 | 1843 |
798 | 1844 if(has_audio){ |
1845 int delay=get_audio_delay(audio_fd); | |
1846 if(verbose>1)printf("delay=%d\n",delay); | |
1847 time_frame=v_frame; | |
1848 time_frame-=a_frame-(float)delay/(float)sh_audio->o_bps; | |
1849 if(time_frame>-0.1) drop_frame=0; // stop dropping frames | |
1850 } | |
1851 | |
1852 } else { | |
780 | 1853 // It's time to sleep... |
1854 current_module="sleep"; | |
1855 | |
1856 time_frame-=GetRelativeTime(); // reset timer | |
1857 | |
1858 if(has_audio){ | |
746 | 1859 int delay=get_audio_delay(audio_fd); |
758 | 1860 if(verbose>1)printf("delay=%d\n",delay); |
746 | 1861 time_frame=v_frame; |
1862 time_frame-=a_frame-(float)delay/(float)sh_audio->o_bps; | |
798 | 1863 // we are out of time... drop next frame! |
1864 if(time_frame<-0.1){ | |
1865 drop_frame=frame_dropping; // tricky! | |
1866 ++drop_frame_cnt; | |
1867 } | |
780 | 1868 } else { |
746 | 1869 if(time_frame<-0.1 || time_frame>0.1) time_frame=0; |
780 | 1870 } |
798 | 1871 |
758 | 1872 if(verbose>1)printf("sleep: %5.3f a:%6.3f v:%6.3f \n",time_frame,a_frame,v_frame); |
746 | 1873 |
1874 while(time_frame>0.005){ | |
1875 if(time_frame<=0.020) | |
1876 usleep(0); // sleep 10ms | |
1877 else | |
1878 usleep(1000000*(time_frame-0.002)); | |
1879 time_frame-=GetRelativeTime(); | |
1880 } | |
117 | 1881 |
715 | 1882 current_module="flip_page"; |
1883 video_out->flip_page(); | |
1884 // usleep(50000); // test only! | |
780 | 1885 |
715 | 1886 } |
780 | 1887 |
1888 current_module=NULL; | |
715 | 1889 |
1 | 1890 if(eof) break; |
220 | 1891 if(force_redraw){ |
1892 --force_redraw; | |
577 | 1893 if(!force_redraw) osd_function=OSD_PLAY; |
746 | 1894 continue; |
220 | 1895 } |
1 | 1896 |
1897 // 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,a_frame); | |
1898 // fflush(stdout); | |
1899 | |
1900 #if 1 | |
1901 /*================ A-V TIMESTAMP CORRECTION: =========================*/ | |
1902 if(has_audio){ | |
780 | 1903 float a_pts=0; |
1904 float v_pts=0; | |
1905 | |
746 | 1906 // unplayed bytes in our and soundcard/dma buffer: |
1907 int delay_bytes=get_audio_delay(audio_fd)+sh_audio->a_buffer_len; | |
1908 float delay=(float)delay_bytes/(float)sh_audio->o_bps; | |
1909 | |
780 | 1910 if(pts_from_bps){ |
1911 // PTS = (audio position)/(bytes per sec) | |
815 | 1912 // a_pts=(ds_tell(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps; |
1913 a_pts=(ds_tell(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->wf->nAvgBytesPerSec; | |
1 | 1914 delay_corrected=1; // hack |
780 | 1915 } else { |
1916 if(!delay_corrected && d_audio->pts){ | |
746 | 1917 float x=d_audio->pts-d_video->pts-(delay+audio_delay); |
1918 float y=-(delay+audio_delay); | |
1 | 1919 printf("Initial PTS delay: %5.3f sec (calculated: %5.3f)\n",x,y); |
1920 audio_delay+=x; | |
1921 delay_corrected=1; | |
340 | 1922 if(verbose) |
1 | 1923 printf("v: audio_delay=%5.3f buffer_delay=%5.3f a.pts=%5.3f v.pts=%5.3f\n", |
746 | 1924 audio_delay,delay,d_audio->pts,d_video->pts); |
1 | 1925 } |
780 | 1926 // PTS = (last timestamp) + (bytes after last timestamp)/(bytes per sec) |
746 | 1927 a_pts=d_audio->pts; |
1928 a_pts+=(ds_tell_pts(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps; | |
780 | 1929 } |
746 | 1930 |
780 | 1931 v_pts=d_video->pts-frame_time; |
1932 | |
1933 if(verbose)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); | |
1934 | |
1935 if(frame_corr_num==1){ | |
1936 float x=frame_correction; | |
398 | 1937 if(delay_corrected){ |
746 | 1938 // printf("A:%6.1f V:%6.1f A-V:%7.3f",a_pts-audio_delay-delay,v_pts,x); |
1939 printf("A:%6.1f (%6.1f) V:%6.1f A-V:%7.3f",a_pts,a_pts-audio_delay-delay,v_pts,x); | |
780 | 1940 x*=0.1f; |
1 | 1941 if(x<-max_pts_correction) x=-max_pts_correction; else |
1942 if(x> max_pts_correction) x= max_pts_correction; | |
780 | 1943 if(default_max_pts_correction>=0) |
1944 max_pts_correction=default_max_pts_correction; | |
1945 else | |
1946 max_pts_correction=sh_video->frametime*0.10; // +-10% of time | |
1 | 1947 a_frame+=x; c_total+=x; |
798 | 1948 printf(" ct:%7.3f %3d %2d%% %2d%% %3.1f%% %d\r",c_total, |
1 | 1949 (int)num_frames, |
1950 (v_frame>0.5)?(int)(100.0*video_time_usage/(double)v_frame):0, | |
1951 (v_frame>0.5)?(int)(100.0*vout_time_usage/(double)v_frame):0, | |
442 | 1952 (v_frame>0.5)?(100.0*audio_time_usage/(double)v_frame):0 |
798 | 1953 ,drop_frame_cnt |
442 | 1954 // dbg_es_sent-dbg_es_rcvd |
1 | 1955 ); |
1956 fflush(stdout); | |
1957 } | |
1958 frame_corr_num=0; frame_correction=0; | |
1959 } | |
780 | 1960 |
746 | 1961 if(frame_corr_num>=0) frame_correction+=(a_pts-delay-audio_delay)-v_pts; |
780 | 1962 |
1 | 1963 } else { |
1964 // No audio: | |
780 | 1965 //if(d_video->pts) |
1966 int v_pts=d_video->pts; | |
1 | 1967 if(frame_corr_num==5){ |
1968 // printf("A: --- V:%6.1f \r",v_pts); | |
442 | 1969 printf("V:%6.1f %3d %2d%% %2d%% %3.1f%% \r",v_pts, |
1 | 1970 (int)num_frames, |
1971 (v_frame>0.5)?(int)(100.0*video_time_usage/(double)v_frame):0, | |
1972 (v_frame>0.5)?(int)(100.0*vout_time_usage/(double)v_frame):0, | |
442 | 1973 (v_frame>0.5)?(100.0*audio_time_usage/(double)v_frame):0 |
1974 // dbg_es_sent-dbg_es_rcvd | |
1975 ); | |
1 | 1976 |
1977 fflush(stdout); | |
1978 frame_corr_num=0; | |
1979 } | |
1980 } | |
1981 ++frame_corr_num; | |
1982 #endif | |
1983 | |
220 | 1984 if(osd_visible){ |
1985 --osd_visible; | |
1986 if(!osd_visible) vo_osd_progbar_type=-1; // disable | |
1987 } | |
371 | 1988 |
1989 if(osd_function==OSD_PAUSE){ | |
1990 printf("\n------ PAUSED -------\r");fflush(stdout); | |
780 | 1991 RESET_AUDIO(audio_fd); // stop audio |
723 | 1992 #ifdef HAVE_GUI |
1993 if ( nogui ) | |
1994 { | |
1995 #endif | |
1996 while( | |
371 | 1997 #ifdef HAVE_LIRC |
723 | 1998 lirc_mp_getinput()<=0 && |
371 | 1999 #endif |
723 | 2000 (!f || getch2(20)<=0) && mplayer_get_key()<=0){ |
2001 video_out->check_events(); | |
2002 if(!f) usleep(1000); // do not eat the CPU | |
2003 } | |
2004 osd_function=OSD_PLAY; | |
2005 #ifdef HAVE_GUI | |
2006 } else while( osd_function != OSD_PLAY ) usleep( 1000 ); | |
2007 #endif | |
371 | 2008 } |
2009 | |
746 | 2010 |
2011 if(!force_redraw) break; | |
1 | 2012 } // while(v_frame<a_frame || force_redraw) |
2013 | |
2014 | |
2015 //================= Keyboard events, SEEKing ==================== | |
2016 | |
723 | 2017 { int c; |
1 | 2018 while( |
2019 #ifdef HAVE_LIRC | |
2020 (c=lirc_mp_getinput())>0 || | |
2021 #endif | |
701 | 2022 (f && (c=getch2(0))>0) || (c=mplayer_get_key())>0) switch(c){ |
1 | 2023 // seek 10 sec |
2024 case KEY_RIGHT: | |
220 | 2025 osd_function=OSD_FFW; |
1 | 2026 rel_seek_secs+=10;break; |
2027 case KEY_LEFT: | |
220 | 2028 osd_function=OSD_REW; |
1 | 2029 rel_seek_secs-=10;break; |
2030 // seek 1 min | |
2031 case KEY_UP: | |
220 | 2032 osd_function=OSD_FFW; |
1 | 2033 rel_seek_secs+=60;break; |
2034 case KEY_DOWN: | |
220 | 2035 osd_function=OSD_REW; |
1 | 2036 rel_seek_secs-=60;break; |
651 | 2037 // seek 10 min |
2038 case KEY_PAGE_UP: | |
2039 rel_seek_secs+=600;break; | |
2040 case KEY_PAGE_DOWN: | |
2041 rel_seek_secs-=600;break; | |
1 | 2042 // delay correction: |
2043 case '+': | |
746 | 2044 audio_delay+=0.1; // increase audio buffer delay |
1 | 2045 a_frame-=0.1; |
2046 break; | |
2047 case '-': | |
746 | 2048 audio_delay-=0.1; // decrease audio buffer delay |
1 | 2049 a_frame+=0.1; |
2050 break; | |
2051 // quit | |
2052 case KEY_ESC: // ESC | |
2053 case KEY_ENTER: // ESC | |
2054 case 'q': exit_player("Quit"); | |
36 | 2055 case 'g': grab_frames=2;break; |
1 | 2056 // pause |
2057 case 'p': | |
2058 case ' ': | |
220 | 2059 osd_function=OSD_PAUSE; |
371 | 2060 break; |
2061 case 'o': // toggle OSD | |
2062 osd_level=(osd_level+1)%3; | |
1 | 2063 break; |
459 | 2064 case '*': |
555 | 2065 case '/': { |
2066 int mixer_l=0; int mixer_r=0; | |
2067 mixer_getvolume( &mixer_l,&mixer_r ); | |
2068 if(c=='*'){ | |
2069 if ( mixer_l < 100 ) mixer_l++; | |
2070 if ( mixer_r < 100 ) mixer_r++; | |
2071 } else { | |
2072 if ( mixer_l > 0 ) mixer_l--; | |
2073 if ( mixer_r > 0 ) mixer_r--; | |
2074 } | |
2075 mixer_setvolume( mixer_l,mixer_r ); | |
2076 | |
2077 if(osd_level){ | |
2078 osd_visible=sh_video->fps; // 1 sec | |
2079 vo_osd_progbar_type=OSD_VOLUME; | |
2080 vo_osd_progbar_value=(mixer_l+mixer_r)*5/4; | |
2081 //printf("volume: %d\n",vo_osd_progbar_value); | |
2082 } | |
2083 } | |
2084 break; | |
459 | 2085 case 'm': |
510 | 2086 mixer_usemaster=!mixer_usemaster; |
459 | 2087 break; |
715 | 2088 case 'd': |
798 | 2089 frame_dropping=(frame_dropping+1)%3; |
2090 printf("== drop: %d == \n",frame_dropping); | |
715 | 2091 break; |
1 | 2092 } |
651 | 2093 if (seek_to_sec) { |
2094 rel_seek_secs += seek_to_sec; | |
2095 seek_to_sec = 0; | |
2096 } | |
1 | 2097 if(rel_seek_secs) |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
2098 if(file_format==DEMUXER_TYPE_AVI && demuxer->idx_size<=0){ |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
2099 printf("Can't seek in raw .AVI streams! (index required, try with the -idx switch!) \n"); |
1 | 2100 } else { |
2101 int skip_audio_bytes=0; | |
2102 float skip_audio_secs=0; | |
2103 | |
2104 // clear demux buffers: | |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
2105 if(has_audio){ ds_free_packs(d_audio);sh_audio->a_buffer_len=0;} |
1 | 2106 ds_free_packs(d_video); |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
2107 |
296 | 2108 // printf("sh_audio->a_buffer_len=%d \n",sh_audio->a_buffer_len); |
778
13c0dfde813b
removed dummy audio track for -nosound, vo: flip detection
arpi_esp
parents:
766
diff
changeset
|
2109 |
1 | 2110 |
2111 switch(file_format){ | |
2112 | |
2113 case DEMUXER_TYPE_AVI: { | |
2114 //================= seek in AVI ========================== | |
398 | 2115 int rel_seek_frames=rel_seek_secs*sh_video->fps; |
1 | 2116 int curr_audio_pos=0; |
2117 int audio_chunk_pos=-1; | |
2118 int video_chunk_pos=d_video->pos; | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
2119 |
1 | 2120 skip_video_frames=0; |
2121 | |
2122 // SEEK streams | |
2123 // if(d_video->pts) avi_video_pts=d_video->pts; | |
2124 avi_audio_pts=0; | |
2125 d_video->pts=0; | |
2126 d_audio->pts=0; | |
2127 | |
2128 // find video chunk pos: | |
2129 if(rel_seek_frames>0){ | |
2130 // seek forward | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
2131 while(video_chunk_pos<demuxer->idx_size){ |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
2132 int id=((AVIINDEXENTRY *)demuxer->idx)[video_chunk_pos].ckid; |
1 | 2133 // if(LOWORD(id)==aviTWOCC('0','0')){ // video frame |
2134 if(avi_stream_id(id)==d_video->id){ // video frame | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
2135 if((--rel_seek_frames)<0 && ((AVIINDEXENTRY *)demuxer->idx)[video_chunk_pos].dwFlags&AVIIF_KEYFRAME) break; |
780 | 2136 //v_pts+=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; |
1 | 2137 ++skip_audio_bytes; |
2138 } | |
2139 ++video_chunk_pos; | |
2140 } | |
2141 } else { | |
2142 // seek backward | |
2143 while(video_chunk_pos>=0){ | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
2144 int id=((AVIINDEXENTRY *)demuxer->idx)[video_chunk_pos].ckid; |
1 | 2145 // if(LOWORD(id)==aviTWOCC('0','0')){ // video frame |
2146 if(avi_stream_id(id)==d_video->id){ // video frame | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
2147 if((++rel_seek_frames)>0 && ((AVIINDEXENTRY *)demuxer->idx)[video_chunk_pos].dwFlags&AVIIF_KEYFRAME) break; |
780 | 2148 //v_pts-=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; |
1 | 2149 --skip_audio_bytes; |
2150 } | |
2151 --video_chunk_pos; | |
2152 } | |
2153 } | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
2154 demuxer->idx_pos_a=demuxer->idx_pos_v= |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
2155 demuxer->idx_pos=video_chunk_pos; |
1 | 2156 // printf("%d frames skipped\n",skip_audio_bytes); |
2157 | |
2158 #if 1 | |
2159 // re-calc video pts: | |
2160 avi_video_pts=0; | |
2161 for(i=0;i<video_chunk_pos;i++){ | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
2162 int id=((AVIINDEXENTRY *)demuxer->idx)[i].ckid; |
1 | 2163 // if(LOWORD(id)==aviTWOCC('0','0')){ // video frame |
2164 if(avi_stream_id(id)==d_video->id){ // video frame | |
291 | 2165 avi_video_pts+=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; |
1 | 2166 } |
2167 } | |
2168 //printf("v-pts recalc! %5.3f -> %5.3f \n",v_pts,avi_video_pts); | |
780 | 2169 //v_pts=avi_video_pts; |
2170 //#else | |
2171 //avi_video_pts=v_pts; | |
1 | 2172 #endif |
780 | 2173 //a_pts=avi_video_pts; |
1 | 2174 //a_pts=v_pts; //-(buffer_delay+audio_delay); |
2175 | |
2176 if(has_audio){ | |
2177 int i; | |
2178 int apos=0; | |
2179 int last=0; | |
2180 int len=0; | |
2181 | |
2182 // calc new audio position in audio stream: (using avg.bps value) | |
442 | 2183 curr_audio_pos=(avi_video_pts) * sh_audio->wf->nAvgBytesPerSec; |
1 | 2184 if(curr_audio_pos<0)curr_audio_pos=0; |
2185 #if 1 | |
2186 curr_audio_pos&=~15; // requires for PCM formats!!! | |
2187 #else | |
442 | 2188 curr_audio_pos/=sh_audio->wf->nBlockAlign; |
2189 curr_audio_pos*=sh_audio->wf->nBlockAlign; | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
2190 demuxer->audio_seekable=1; |
1 | 2191 #endif |
2192 | |
2193 // find audio chunk pos: | |
2194 for(i=0;i<video_chunk_pos;i++){ | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
2195 int id=((AVIINDEXENTRY *)demuxer->idx)[i].ckid; |
1 | 2196 //if(TWOCCFromFOURCC(id)==cktypeWAVEbytes){ |
2197 if(avi_stream_id(id)==d_audio->id){ | |
2198 int aid=StreamFromFOURCC(id); | |
2199 if(d_audio->id==aid || d_audio->id==-1){ | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
2200 len=((AVIINDEXENTRY *)demuxer->idx)[i].dwChunkLength; |
1 | 2201 last=i; |
2202 if(apos<=curr_audio_pos && curr_audio_pos<(apos+len)){ | |
2203 if(verbose)printf("break;\n"); | |
2204 break; | |
2205 } | |
2206 apos+=len; | |
2207 } | |
2208 } | |
2209 } | |
2210 if(verbose)printf("XXX i=%d last=%d apos=%d curr_audio_pos=%d \n", | |
2211 i,last,apos,curr_audio_pos); | |
2212 // audio_chunk_pos=last; // maybe wrong (if not break; ) | |
2213 audio_chunk_pos=i; // maybe wrong (if not break; ) | |
2214 skip_audio_bytes=curr_audio_pos-apos; | |
2215 | |
2216 // update stream position: | |
2217 d_audio->pos=audio_chunk_pos; | |
2218 d_audio->dpos=apos; | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
2219 demuxer->idx_pos_a=demuxer->idx_pos_v= |
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
2220 demuxer->idx_pos=audio_chunk_pos; |
1 | 2221 |
303 | 2222 if(!(sh_audio->codec->flags&CODECS_FLAG_SEEKABLE)){ |
1 | 2223 #if 0 |
2224 // curr_audio_pos=apos; // selected audio codec can't seek in chunk | |
442 | 2225 skip_audio_secs=(float)skip_audio_bytes/(float)sh_audio->wf->nAvgBytesPerSec; |
1 | 2226 //printf("Seek_AUDIO: %d bytes --> %5.3f secs\n",skip_audio_bytes,skip_audio_secs); |
2227 skip_audio_bytes=0; | |
2228 #else | |
442 | 2229 int d=skip_audio_bytes % sh_audio->wf->nBlockAlign; |
1 | 2230 skip_audio_bytes-=d; |
2231 // curr_audio_pos-=d; | |
442 | 2232 skip_audio_secs=(float)d/(float)sh_audio->wf->nAvgBytesPerSec; |
1 | 2233 //printf("Seek_AUDIO: %d bytes --> %5.3f secs\n",d,skip_audio_secs); |
2234 #endif | |
2235 } | |
2236 // now: audio_chunk_pos=pos in index | |
2237 // skip_audio_bytes=bytes to skip from that chunk | |
2238 // skip_audio_secs=time to play audio before video (if can't skip) | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
2239 |
1 | 2240 // calc skip_video_frames & adjust video pts counter: |
2241 // i=last; | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
2242 i=demuxer->idx_pos; |
1 | 2243 while(i<video_chunk_pos){ |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
2244 int id=((AVIINDEXENTRY *)demuxer->idx)[i].ckid; |
1 | 2245 // if(LOWORD(id)==aviTWOCC('0','0')){ // video frame |
2246 if(avi_stream_id(id)==d_video->id){ // video frame | |
2247 ++skip_video_frames; | |
2248 // requires for correct audio pts calculation (demuxer): | |
291 | 2249 avi_video_pts-=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; |
1 | 2250 } |
2251 ++i; | |
2252 } | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
2253 |
1 | 2254 } |
2255 | |
2256 if(verbose) printf("SEEK: idx=%d (a:%d v:%d) v.skip=%d a.skip=%d/%4.3f \n", | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
2257 demuxer->idx_pos,audio_chunk_pos,video_chunk_pos, |
1 | 2258 skip_video_frames,skip_audio_bytes,skip_audio_secs); |
2259 | |
2260 } | |
2261 break; | |
2262 | |
2263 case DEMUXER_TYPE_ASF: { | |
2264 //================= seek in ASF ========================== | |
2265 float p_rate=10; // packets / sec | |
2266 int rel_seek_packs=rel_seek_secs*p_rate; | |
587
8511095c5283
stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents:
578
diff
changeset
|
2267 int rel_seek_bytes=rel_seek_packs*asf_packetsize; |
1 | 2268 int newpos; |
2269 //printf("ASF: packs: %d duration: %d \n",(int)fileh.packets,*((int*)&fileh.duration)); | |
2270 // printf("ASF_seek: %d secs -> %d packs -> %d bytes \n", | |
2271 // rel_seek_secs,rel_seek_packs,rel_seek_bytes); | |
2272 newpos=demuxer->filepos+rel_seek_bytes; | |
638 | 2273 if(newpos<0 || newpos<demuxer->movi_start) newpos=demuxer->movi_start; |
645 | 2274 // printf("\r -- asf: newpos=%d -- \n",newpos); |
1 | 2275 stream_seek(demuxer->stream,newpos); |
2276 } | |
2277 break; | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
2278 |
1 | 2279 case DEMUXER_TYPE_MPEG_ES: |
2280 case DEMUXER_TYPE_MPEG_PS: { | |
2281 //================= seek in MPEG ========================== | |
2282 int newpos; | |
2283 if(picture->bitrate==0x3FFFF) // unspecified? | |
2284 newpos=demuxer->filepos+2324*75*rel_seek_secs; // 174.3 kbyte/sec | |
2285 else | |
2286 newpos=demuxer->filepos+(picture->bitrate*1000/16)*rel_seek_secs; | |
2287 | |
2288 if(newpos<seek_to_byte) newpos=seek_to_byte; | |
495
d4eb6bd44bbc
Seeking to sector boundary (STREAM_BUFFER_SIZE) for MPEGs
lgb
parents:
492
diff
changeset
|
2289 newpos&=~(STREAM_BUFFER_SIZE-1); /* sector boundary */ |
1 | 2290 stream_seek(demuxer->stream,newpos); |
2291 // re-sync video: | |
2292 videobuf_code_len=0; // reset ES stream buffer | |
2293 while(1){ | |
2294 int i=sync_video_packet(d_video); | |
2295 if(i==0x1B3 || i==0x1B8) break; // found it! | |
2296 if(!i || !skip_video_packet(d_video)){ eof=1; break;} // EOF | |
2297 } | |
2298 } | |
2299 break; | |
2300 | |
2301 } // switch(file_format) | |
2302 | |
595 | 2303 // Set OSD: |
2304 if(osd_level){ | |
2305 int len=((demuxer->movi_end-demuxer->movi_start)>>8); | |
2306 if(len>0){ | |
2307 osd_visible=sh_video->fps; // 1 sec | |
2308 vo_osd_progbar_type=0; | |
598 | 2309 vo_osd_progbar_value=(demuxer->filepos-demuxer->movi_start)/len; |
595 | 2310 } |
780 | 2311 //printf("avi filepos = %d (len=%d)\n",vo_osd_progbar_value,len); |
595 | 2312 } |
2313 | |
1 | 2314 //====================== re-sync audio: ===================== |
2315 if(has_audio){ | |
2316 | |
2317 if(skip_audio_bytes){ | |
2318 demux_read_data(d_audio,NULL,skip_audio_bytes); | |
2319 d_audio->pts=0; // PTS is outdated because of the raw data skipping | |
2320 } | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
2321 |
1 | 2322 current_module="resync_audio"; |
2323 | |
442 | 2324 switch(sh_audio->codec->driver){ |
1 | 2325 case 1: |
2326 MP3_DecodeFrame(NULL,-2); // resync | |
2327 MP3_DecodeFrame(NULL,-2); // resync | |
2328 MP3_DecodeFrame(NULL,-2); // resync | |
2329 break; | |
2330 case 3: | |
2331 ac3_bitstream_reset(); // reset AC3 bitstream buffer | |
2332 // if(verbose){ printf("Resyncing AC3 audio...");fflush(stdout);} | |
291 | 2333 sh_audio->ac3_frame=ac3_decode_frame(); // resync |
1 | 2334 // if(verbose) printf(" OK!\n"); |
2335 break; | |
2336 case 4: | |
291 | 2337 case 7: |
2338 sh_audio->a_in_buffer_len=0; // reset ACM/DShow audio buffer | |
1 | 2339 break; |
2340 } | |
2341 | |
2342 // re-sync PTS (MPEG-PS only!!!) | |
2343 if(file_format==DEMUXER_TYPE_MPEG_PS) | |
2344 if(d_video->pts && d_audio->pts){ | |
2345 if (d_video->pts < d_audio->pts){ | |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
2346 |
1 | 2347 } else { |
2348 while(d_video->pts > d_audio->pts){ | |
442 | 2349 switch(sh_audio->codec->driver){ |
1 | 2350 case 1: MP3_DecodeFrame(NULL,-2);break; // skip MPEG frame |
291 | 2351 case 3: sh_audio->ac3_frame=ac3_decode_frame();break; // skip AC3 frame |
1 | 2352 default: ds_fill_buffer(d_audio); // skip PCM frame |
2353 } | |
2354 } | |
2355 } | |
2356 } | |
2357 | |
722 | 2358 RESET_AUDIO(audio_fd); |
2359 | |
1 | 2360 current_module=NULL; |
2361 | |
2362 c_total=0; // kell ez? | |
2363 printf("A:%6.1f V:%6.1f A-V:%7.3f",d_audio->pts,d_video->pts,0.0f); | |
2364 printf(" ct:%7.3f \r",c_total);fflush(stdout); | |
2365 } else { | |
2366 printf("A: --- V:%6.1f \r",d_video->pts);fflush(stdout); | |
2367 } | |
2368 | |
2369 max_pts_correction=0.1; | |
2370 frame_corr_num=-5; frame_correction=0; | |
2371 force_redraw=5; | |
746 | 2372 a_frame=-skip_audio_secs; |
1 | 2373 // a_frame=-audio_delay-buffer_delay-skip_audio_secs; |
2374 v_frame=0; // !!!!!! | |
2375 audio_time_usage=0; video_time_usage=0; vout_time_usage=0; | |
2376 // num_frames=real_num_frames=0; | |
721 | 2377 |
1 | 2378 } |
723 | 2379 rel_seek_secs=0; |
1 | 2380 } // keyboard event handler |
2381 | |
220 | 2382 //================= Update OSD ==================== |
2383 { int i; | |
371 | 2384 if(osd_level>=2){ |
780 | 2385 int pts=d_video->pts; |
595 | 2386 if(pts==osd_last_pts-1) ++pts; else osd_last_pts=pts; |
371 | 2387 vo_osd_text=osd_text_buffer; |
595 | 2388 sprintf(vo_osd_text,"%c %02d:%02d:%02d",osd_function,pts/3600,(pts/60)%60,pts%60); |
371 | 2389 } else { |
2390 vo_osd_text=NULL; | |
2391 } | |
220 | 2392 // for(i=1;i<=11;i++) osd_text_buffer[10+i]=i;osd_text_buffer[10+i]=0; |
371 | 2393 // vo_osd_text=osd_text_buffer; |
458
49b0474b2e26
I really hope that you will learn how to use cvs, sooner or later...
arpi_esp
parents:
452
diff
changeset
|
2394 |
258 | 2395 // find sub |
2396 if(subtitles){ | |
780 | 2397 int pts=d_video->pts; |
398 | 2398 if(sub_fps==0) sub_fps=sh_video->fps; |
482 | 2399 current_module="find_sub"; |
780 | 2400 find_sub(subtitles,sub_uses_time?(100*(pts+sub_delay)):((pts+sub_delay)*sub_fps)); // FIXME! frame counter... |
482 | 2401 current_module=NULL; |
258 | 2402 } |
554 | 2403 |
2404 // DVD sub: | |
557 | 2405 { unsigned char* packet=NULL; |
2406 int len=ds_get_packet_sub(d_dvdsub,&packet); | |
2407 if(len>=2){ | |
2408 int len2; | |
2409 len2=(packet[0]<<8)+packet[1]; | |
561 | 2410 if(verbose) printf("\rDVD sub: %d / %d \n",len,len2); |
2411 if(len==len2) | |
2412 spudec_decode(packet,len); | |
2413 else | |
2414 printf("fragmented dvd-subs not yet supported!!!\n"); | |
557 | 2415 } else if(len>=0) { |
2416 printf("invalud dvd sub\n"); | |
554 | 2417 } |
2418 } | |
2419 | |
220 | 2420 } |
1 | 2421 |
2422 } // while(!eof) | |
2423 | |
2424 //printf("\nEnd of file.\n"); | |
2425 exit_player("End of file"); | |
109 | 2426 } |
2427 return 1; | |
2428 } |