Mercurial > mplayer.hg
comparison demux_mpg.c @ 1466:7845f6d7c4ba
format-specific seeking code moved to demuxer_ stuff
author | arpi |
---|---|
date | Wed, 08 Aug 2001 19:37:45 +0000 |
parents | 1728d249c783 |
children | ad4d402b3d29 |
comparison
equal
deleted
inserted
replaced
1465:194c2f643d2c | 1466:7845f6d7c4ba |
---|---|
8 | 8 |
9 #include "config.h" | 9 #include "config.h" |
10 #include "dvdauth.h" | 10 #include "dvdauth.h" |
11 #include "stream.h" | 11 #include "stream.h" |
12 #include "demuxer.h" | 12 #include "demuxer.h" |
13 #include "parse_es.h" | |
13 | 14 |
14 //#define MAX_PS_PACKETSIZE 2048 | 15 //#define MAX_PS_PACKETSIZE 2048 |
15 #define MAX_PS_PACKETSIZE (224*1024) | 16 #define MAX_PS_PACKETSIZE (224*1024) |
16 | 17 |
17 static int mpeg_pts_error=0; | 18 static int mpeg_pts_error=0; |
30 return pts; | 31 return pts; |
31 } | 32 } |
32 | 33 |
33 //static unsigned int packet_start_pos=0; | 34 //static unsigned int packet_start_pos=0; |
34 | 35 |
35 extern void *new_sh_audio(demuxer_t *demux,int id); | 36 //extern void *new_sh_audio(demuxer_t *demux,int id); |
36 extern void *new_sh_video(demuxer_t *demux,int id); | 37 //extern void *new_sh_video(demuxer_t *demux,int id); |
38 #include "wine/mmreg.h" | |
39 #include "wine/avifmt.h" | |
40 #include "wine/vfw.h" | |
41 | |
42 #include "codec-cfg.h" | |
43 #include "stheader.h" | |
37 | 44 |
38 static int demux_mpg_read_packet(demuxer_t *demux,int id){ | 45 static int demux_mpg_read_packet(demuxer_t *demux,int id){ |
39 int d; | 46 int d; |
40 int len; | 47 int len; |
41 #ifdef HAVE_LIBCSS | 48 #ifdef HAVE_LIBCSS |
332 return 0; | 339 return 0; |
333 } | 340 } |
334 return 1; | 341 return 1; |
335 } | 342 } |
336 | 343 |
344 extern off_t seek_to_byte; | |
345 | |
346 void demux_seek_mpg(demuxer_t *demuxer,float rel_seek_secs,int flags){ | |
347 demux_stream_t *d_audio=demuxer->audio; | |
348 demux_stream_t *d_video=demuxer->video; | |
349 sh_audio_t *sh_audio=d_audio->sh; | |
350 sh_video_t *sh_video=d_video->sh; | |
351 | |
352 //================= seek in MPEG ========================== | |
353 off_t newpos; | |
354 if(!sh_video->i_bps) // unspecified? | |
355 newpos=demuxer->filepos+2324*75*rel_seek_secs; // 174.3 kbyte/sec | |
356 else | |
357 newpos=demuxer->filepos+(sh_video->i_bps)*rel_seek_secs; | |
358 | |
359 if(newpos<seek_to_byte) newpos=seek_to_byte; // for VCD | |
360 #ifdef _LARGEFILE_SOURCE | |
361 newpos&=~((long long)STREAM_BUFFER_SIZE-1); /* sector boundary */ | |
362 #else | |
363 newpos&=~(STREAM_BUFFER_SIZE-1); /* sector boundary */ | |
364 #endif | |
365 stream_seek(demuxer->stream,newpos); | |
366 | |
367 // re-sync video: | |
368 videobuf_code_len=0; // reset ES stream buffer | |
369 | |
370 ds_fill_buffer(d_video); | |
371 if(sh_audio){ | |
372 ds_fill_buffer(d_audio); | |
373 resync_audio_stream(sh_audio); | |
374 } | |
375 | |
376 while(1){ | |
377 int i; | |
378 if(sh_audio && !d_audio->eof && d_video->pts && d_audio->pts){ | |
379 float a_pts=d_audio->pts; | |
380 a_pts+=(ds_tell_pts(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps; | |
381 if(d_video->pts>a_pts){ | |
382 skip_audio_frame(sh_audio); // sync audio | |
383 continue; | |
384 } | |
385 } | |
386 i=sync_video_packet(d_video); | |
387 if(i==0x1B3 || i==0x1B8) break; // found it! | |
388 if(!i || !skip_video_packet(d_video)) break; // EOF? | |
389 } | |
390 | |
391 | |
392 } | |
393 |