1
mirror of https://github.com/mpv-player/mpv synced 2025-01-16 22:37:28 +01:00

OSD seekbar fixed for mpeg/VCD

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@599 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
arpi_esp 2001-04-23 21:25:09 +00:00
parent 807ccd5431
commit 86151f639d
5 changed files with 31 additions and 8 deletions

View File

@ -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)); demuxer_t *d=malloc(sizeof(demuxer_t));
memset(d,0,sizeof(demuxer_t)); memset(d,0,sizeof(demuxer_t));
d->stream=stream; d->stream=stream;
d->movi_start=stream->start_pos;
d->movi_end=stream->end_pos;
d->synced=0; d->synced=0;
d->filepos=0; d->filepos=0;
d->audio=new_demuxer_stream(d,a_id); d->audio=new_demuxer_stream(d,a_id);

View File

@ -364,7 +364,6 @@ int i;
int seek_to_sec=0; int seek_to_sec=0;
int seek_to_byte=0; int seek_to_byte=0;
int f; // filedes int f; // filedes
int stream_type;
stream_t* stream=NULL; stream_t* stream=NULL;
int file_format=DEMUXER_TYPE_UNKNOWN; int file_format=DEMUXER_TYPE_UNKNOWN;
int has_audio=1; int has_audio=1;
@ -518,22 +517,32 @@ if(!parse_codec_cfg(get_path("codecs.conf"))){
if(vcd_track){ if(vcd_track){
//============ Open VideoCD track ============== //============ Open VideoCD track ==============
int ret; int ret,ret2;
f=open(filename,O_RDONLY); f=open(filename,O_RDONLY);
if(f<0){ printf("CD-ROM Device '%s' not found!\n",filename);return 1; } if(f<0){ printf("CD-ROM Device '%s' not found!\n",filename);return 1; }
vcd_read_toc(f); 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); ret=vcd_seek_to_track(f,vcd_track);
if(ret<0){ printf("Error selecting VCD track!\n");return 1;} if(ret<0){ printf("Error selecting VCD track!\n");return 1;}
seek_to_byte+=ret; seek_to_byte+=ret;
if(verbose) printf("VCD start byte position: 0x%X\n",seek_to_byte); if(verbose) printf("VCD start byte position: 0x%X end: 0x%X\n",seek_to_byte,ret2);
stream_type=STREAMTYPE_VCD;
#ifdef VCD_CACHE #ifdef VCD_CACHE
vcd_cache_init(vcd_cache_size); vcd_cache_init(vcd_cache_size);
#endif #endif
stream=new_stream(f,STREAMTYPE_VCD);
stream->start_pos=ret;
stream->end_pos=ret2;
} else { } else {
//============ Open plain FILE ============ //============ Open plain FILE ============
int len;
f=open(filename,O_RDONLY); f=open(filename,O_RDONLY);
if(f<0){ printf("File not found: '%s'\n",filename);return 1; } 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 #ifdef HAVE_LIBCSS
if (dvdimportkey) { if (dvdimportkey) {
if (dvd_import_key(dvdimportkey)) { if (dvd_import_key(dvdimportkey)) {
@ -547,10 +556,7 @@ if(vcd_track){
printf("DVD auth sequence seems to be OK.\n"); printf("DVD auth sequence seems to be OK.\n");
} }
#endif #endif
stream_type=STREAMTYPE_FILE;
}
stream=new_stream(f,stream_type);
//============ Open & Sync stream and detect file format =============== //============ Open & Sync stream and detect file format ===============
if(!has_audio) audio_id=-2; // do NOT read audio packets... if(!has_audio) audio_id=-2; // do NOT read audio packets...
@ -1896,7 +1902,7 @@ switch(file_format){
if(len>0){ if(len>0){
osd_visible=sh_video->fps; // 1 sec osd_visible=sh_video->fps; // 1 sec
vo_osd_progbar_type=0; 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 \n",vo_osd_progbar_value);
// printf("avi filepos = %d (len=%d) \n",demuxer->filepos,(demuxer->movi_end-demuxer->movi_start)); // printf("avi filepos = %d (len=%d) \n",demuxer->filepos,(demuxer->movi_end-demuxer->movi_start));

View File

@ -105,6 +105,7 @@ stream_t* new_stream(int fd,int type){
s->fd=fd; s->fd=fd;
s->type=type; s->type=type;
s->buf_pos=s->buf_len=0; s->buf_pos=s->buf_len=0;
s->start_pos=s->end_pos=0;
stream_reset(s); stream_reset(s);
return s; return s;
} }

View File

@ -21,6 +21,7 @@ typedef struct {
int eof; int eof;
int type; // 0=file 1=VCD int type; // 0=file 1=VCD
unsigned int buf_pos,buf_len; 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]; unsigned char buffer[STREAM_BUFFER_SIZE>VCD_SECTOR_SIZE?STREAM_BUFFER_SIZE:VCD_SECTOR_SIZE];
} stream_t; } stream_t;

View File

@ -25,6 +25,19 @@ int vcd_seek_to_track(int fd,int track){
return VCD_SECTOR_DATA*vcd_get_msf(); 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){ void vcd_read_toc(int fd){
struct cdrom_tochdr tochdr; struct cdrom_tochdr tochdr;
int i; int i;