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