changeset 598:c7117e17e20b

OSD seekbar fixed for mpeg/VCD
author arpi_esp
date Mon, 23 Apr 2001 21:25:09 +0000
parents d751f549f29f
children 33f68d0f5fd1
files demuxer.c mplayer.c stream.c stream.h vcd_read.h
diffstat 5 files changed, 31 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/demuxer.c	Mon Apr 23 20:16:37 2001 +0000
+++ b/demuxer.c	Mon Apr 23 21:25:09 2001 +0000
@@ -35,6 +35,8 @@
   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);
--- a/mplayer.c	Mon Apr 23 20:16:37 2001 +0000
+++ b/mplayer.c	Mon Apr 23 21:25:09 2001 +0000
@@ -364,7 +364,6 @@
 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(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 @@
     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 @@
         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));
--- a/stream.c	Mon Apr 23 20:16:37 2001 +0000
+++ b/stream.c	Mon Apr 23 21:25:09 2001 +0000
@@ -105,6 +105,7 @@
   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;
 }
--- a/stream.h	Mon Apr 23 20:16:37 2001 +0000
+++ b/stream.h	Mon Apr 23 21:25:09 2001 +0000
@@ -21,6 +21,7 @@
   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;
 
--- a/vcd_read.h	Mon Apr 23 20:16:37 2001 +0000
+++ b/vcd_read.h	Mon Apr 23 21:25:09 2001 +0000
@@ -25,6 +25,19 @@
   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<tochdr.cdth_trk1?(track+1):CDROM_LEADOUT;
+  if (ioctl(fd, CDROMREADTOCENTRY, &vcd_entry)) {
+    perror("ioctl dif2");
+    return -1;
+  }
+  return VCD_SECTOR_DATA*vcd_get_msf();
+}
+
 void vcd_read_toc(int fd){
   struct cdrom_tochdr tochdr;
   int i;