From 86151f639d0c6e57f745674a0b342b02710acba0 Mon Sep 17 00:00:00 2001 From: arpi_esp Date: Mon, 23 Apr 2001 21:25:09 +0000 Subject: [PATCH] OSD seekbar fixed for mpeg/VCD git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@599 b3059339-0415-0410-9bf9-f77b7e298cf2 --- demuxer.c | 2 ++ mplayer.c | 22 ++++++++++++++-------- stream.c | 1 + stream.h | 1 + vcd_read.h | 13 +++++++++++++ 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/demuxer.c b/demuxer.c index c52c22c8d3..3dc8db4285 100644 --- a/demuxer.c +++ b/demuxer.c @@ -35,6 +35,8 @@ demuxer_t* new_demuxer(stream_t *stream,int type,int a_id,int v_id,int s_id){ demuxer_t *d=malloc(sizeof(demuxer_t)); memset(d,0,sizeof(demuxer_t)); d->stream=stream; + d->movi_start=stream->start_pos; + d->movi_end=stream->end_pos; d->synced=0; d->filepos=0; d->audio=new_demuxer_stream(d,a_id); diff --git a/mplayer.c b/mplayer.c index 2cb2dac650..6759b10013 100644 --- a/mplayer.c +++ b/mplayer.c @@ -364,7 +364,6 @@ int i; int seek_to_sec=0; int seek_to_byte=0; int f; // filedes -int stream_type; stream_t* stream=NULL; int file_format=DEMUXER_TYPE_UNKNOWN; int has_audio=1; @@ -518,22 +517,32 @@ if(!parse_codec_cfg(get_path("codecs.conf"))){ if(vcd_track){ //============ Open VideoCD track ============== - int ret; + int ret,ret2; f=open(filename,O_RDONLY); if(f<0){ printf("CD-ROM Device '%s' not found!\n",filename);return 1; } vcd_read_toc(f); + ret2=vcd_get_track_end(f,vcd_track); + if(ret2<0){ printf("Error selecting VCD track!\n");return 1;} ret=vcd_seek_to_track(f,vcd_track); if(ret<0){ printf("Error selecting VCD track!\n");return 1;} seek_to_byte+=ret; - if(verbose) printf("VCD start byte position: 0x%X\n",seek_to_byte); - stream_type=STREAMTYPE_VCD; + if(verbose) printf("VCD start byte position: 0x%X end: 0x%X\n",seek_to_byte,ret2); #ifdef VCD_CACHE vcd_cache_init(vcd_cache_size); #endif + stream=new_stream(f,STREAMTYPE_VCD); + stream->start_pos=ret; + stream->end_pos=ret2; } else { //============ Open plain FILE ============ + int len; f=open(filename,O_RDONLY); if(f<0){ printf("File not found: '%s'\n",filename);return 1; } + len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET); + stream=new_stream(f,STREAMTYPE_FILE); + stream->end_pos=len; +} + #ifdef HAVE_LIBCSS if (dvdimportkey) { if (dvd_import_key(dvdimportkey)) { @@ -547,10 +556,7 @@ if(vcd_track){ printf("DVD auth sequence seems to be OK.\n"); } #endif - stream_type=STREAMTYPE_FILE; -} -stream=new_stream(f,stream_type); //============ Open & Sync stream and detect file format =============== if(!has_audio) audio_id=-2; // do NOT read audio packets... @@ -1896,7 +1902,7 @@ switch(file_format){ if(len>0){ osd_visible=sh_video->fps; // 1 sec vo_osd_progbar_type=0; - vo_osd_progbar_value=(demuxer->filepos)/len; + vo_osd_progbar_value=(demuxer->filepos-demuxer->movi_start)/len; } //printf("avi filepos = %d \n",vo_osd_progbar_value); // printf("avi filepos = %d (len=%d) \n",demuxer->filepos,(demuxer->movi_end-demuxer->movi_start)); diff --git a/stream.c b/stream.c index 8cdffbf2e0..dcfdaab74c 100644 --- a/stream.c +++ b/stream.c @@ -105,6 +105,7 @@ stream_t* new_stream(int fd,int type){ s->fd=fd; s->type=type; s->buf_pos=s->buf_len=0; + s->start_pos=s->end_pos=0; stream_reset(s); return s; } diff --git a/stream.h b/stream.h index 110b3176ad..86c740b646 100644 --- a/stream.h +++ b/stream.h @@ -21,6 +21,7 @@ typedef struct { int eof; int type; // 0=file 1=VCD unsigned int buf_pos,buf_len; + long start_pos,end_pos; unsigned char buffer[STREAM_BUFFER_SIZE>VCD_SECTOR_SIZE?STREAM_BUFFER_SIZE:VCD_SECTOR_SIZE]; } stream_t; diff --git a/vcd_read.h b/vcd_read.h index b83247712d..057954532f 100644 --- a/vcd_read.h +++ b/vcd_read.h @@ -25,6 +25,19 @@ int vcd_seek_to_track(int fd,int track){ return VCD_SECTOR_DATA*vcd_get_msf(); } +int vcd_get_track_end(int fd,int track){ + struct cdrom_tochdr tochdr; + if (ioctl(fd,CDROMREADTOCHDR,&tochdr)==-1) + { perror("read CDROM toc header: "); return -1; } + vcd_entry.cdte_format = CDROM_MSF; + vcd_entry.cdte_track = track