mirror of
https://github.com/mpv-player/mpv
synced 2024-12-24 15:52:25 +00: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:
parent
807ccd5431
commit
86151f639d
@ -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);
|
||||
|
22
mplayer.c
22
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));
|
||||
|
1
stream.c
1
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;
|
||||
}
|
||||
|
1
stream.h
1
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;
|
||||
|
||||
|
13
vcd_read.h
13
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<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;
|
||||
|
Loading…
Reference in New Issue
Block a user