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