[Mplayer-cvslog] CVS: main stream.h,NONE,1.1 stream.c,1.4,1.5 mplayer.c,1.90,1.91 Makefile,1.20,1.21

GEREOFFY arpi_esp at users.sourceforge.net
Sun Apr 22 18:56:22 CEST 2001


Update of /cvsroot/mplayer/main
In directory usw-pr-cvs1:/tmp/cvs-serv4603

Modified Files:
	stream.c mplayer.c Makefile 
Added Files:
	stream.h 
Log Message:
something moved to brand new stream.h

--- NEW FILE ---

#define STREAM_BUFFER_SIZE 2048

#define STREAMTYPE_FILE 0
#define STREAMTYPE_VCD  1

#define VCD_SECTOR_SIZE 2352
#define VCD_SECTOR_OFFS 24
#define VCD_SECTOR_DATA 2324

int vcd_seek_to_track(int fd,int track);
void vcd_read_toc(int fd);

#ifdef VCD_CACHE
void vcd_cache_init(int s);
#endif

typedef struct {
  int fd;
  long pos;
  int eof;
  int type; // 0=file 1=VCD
  unsigned int buf_pos,buf_len;
  unsigned char buffer[STREAM_BUFFER_SIZE];
} stream_t;

int stream_fill_buffer(stream_t *s);
int stream_seek_long(stream_t *s,unsigned int pos);

inline static int stream_read_char(stream_t *s){
  return (s->buf_pos<s->buf_len)?s->buffer[s->buf_pos++]:
    (stream_fill_buffer(s)?s->buffer[s->buf_pos++]:-256);
//  if(s->buf_pos<s->buf_len) return s->buffer[s->buf_pos++];
//  stream_fill_buffer(s);
//  if(s->buf_pos<s->buf_len) return s->buffer[s->buf_pos++];
//  return 0; // EOF
}

inline static unsigned int stream_read_word(stream_t *s){
  int x,y;
  x=stream_read_char(s);
  y=stream_read_char(s);
  return (x<<8)|y;
}

inline static unsigned int stream_read_dword(stream_t *s){
  unsigned int y;
  y=stream_read_char(s);
  y=(y<<8)|stream_read_char(s);
  y=(y<<8)|stream_read_char(s);
  y=(y<<8)|stream_read_char(s);
  return y;
}

inline static unsigned int stream_read_word_le(stream_t *s){
  int x,y;
  x=stream_read_char(s);
  y=stream_read_char(s);
  return (y<<8)|x;
}

inline static unsigned int stream_read_dword_le(stream_t *s){
  unsigned int y;
  y=stream_read_char(s);
  y|=stream_read_char(s)<<8;
  y|=stream_read_char(s)<<16;
  y|=stream_read_char(s)<<24;
  return y;
}

inline static void stream_read(stream_t *s,char* mem,int len){
  while(len>0){
    int x;
    x=s->buf_len-s->buf_pos;
    if(x==0){
      if(!stream_fill_buffer(s)) return; // EOF
      x=s->buf_len-s->buf_pos;
    }
    if(s->buf_pos>s->buf_len) printf("stream_read: WARNING! s->buf_pos>s->buf_len\n");
    if(x>len) x=len;
    memcpy(mem,&s->buffer[s->buf_pos],x);
    s->buf_pos+=x; mem+=x; len-=x;
  }
}

inline static int stream_eof(stream_t *s){
  return s->eof;
}

inline static int stream_tell(stream_t *s){
  return s->pos+s->buf_pos-s->buf_len;
}

inline static int stream_seek(stream_t *s,unsigned int pos){

//  if(verbose>=3) printf("seek to 0x%X\n",pos);

  if(pos<s->pos){
    int x=pos-(s->pos-s->buf_len);
    if(x>=0){
      s->buf_pos=x;
//      putchar('*');fflush(stdout);
      return 1;
    }
  }
  
  return stream_seek_long(s,pos);
}

inline static void stream_skip(stream_t *s,int len){
  if(len<0 || len>2*STREAM_BUFFER_SIZE){
    // negative or big skip!
    stream_seek(s,stream_tell(s)+len);
    return;
  }
  while(len>0){
    int x=s->buf_len-s->buf_pos;
    if(x==0){
      if(!stream_fill_buffer(s)) return; // EOF
      x=s->buf_len-s->buf_pos;
    }
    if(x>len) x=len;
    //memcpy(mem,&s->buf[s->buf_pos],x);
    s->buf_pos+=x; len-=x;
  }
}

void stream_reset(stream_t *s);
stream_t* new_stream(int fd,int type);
void free_stream(stream_t *s);


Index: stream.c
===================================================================
RCS file: /cvsroot/mplayer/main/stream.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** stream.c	2001/04/20 01:07:14	1.4
--- stream.c	2001/04/22 16:56:20	1.5
***************
*** 1,20 ****
  
! #include "vcd_read.c"
  
! //=================== STREAMER =========================
  
! #define STREAM_BUFFER_SIZE 2048
  
! #define STREAMTYPE_FILE 0
! #define STREAMTYPE_VCD  1
  
! typedef struct {
!   int fd;
!   long pos;
!   int eof;
!   int type; // 0=file 1=VCD
!   unsigned int buf_pos,buf_len;
!   unsigned char buffer[STREAM_BUFFER_SIZE];
! } stream_t;
  
  int stream_fill_buffer(stream_t *s){
--- 1,22 ----
  
! #include <stdio.h>
! #include <stdlib.h>
  
! #include <sys/ioctl.h>
! #include <unistd.h>
! 
! //#include <sys/types.h>
! //#include <sys/stat.h>
! //#include <fcntl.h>
! 
! #include <linux/cdrom.h>
  
! #include "stream.h"
  
! extern int verbose; // defined in mplayer.c
  
! #include "vcd_read.c"
! 
! //=================== STREAMER =========================
  
  int stream_fill_buffer(stream_t *s){
***************
*** 39,124 ****
    return len;
  }
- 
- inline int stream_read_char(stream_t *s){
-   return (s->buf_pos<s->buf_len)?s->buffer[s->buf_pos++]:
-     (stream_fill_buffer(s)?s->buffer[s->buf_pos++]:-256);
- //  if(s->buf_pos<s->buf_len) return s->buffer[s->buf_pos++];
- //  stream_fill_buffer(s);
- //  if(s->buf_pos<s->buf_len) return s->buffer[s->buf_pos++];
- //  return 0; // EOF
- }
- 
- inline unsigned int stream_read_word(stream_t *s){
-   int x,y;
-   x=stream_read_char(s);
-   y=stream_read_char(s);
-   return (x<<8)|y;
- }
- 
- inline unsigned int stream_read_dword(stream_t *s){
-   unsigned int y;
-   y=stream_read_char(s);
-   y=(y<<8)|stream_read_char(s);
-   y=(y<<8)|stream_read_char(s);
-   y=(y<<8)|stream_read_char(s);
-   return y;
- }
- 
- inline unsigned int stream_read_word_le(stream_t *s){
-   int x,y;
-   x=stream_read_char(s);
-   y=stream_read_char(s);
-   return (y<<8)|x;
- }
  
! inline unsigned int stream_read_dword_le(stream_t *s){
!   unsigned int y;
!   y=stream_read_char(s);
!   y|=stream_read_char(s)<<8;
!   y|=stream_read_char(s)<<16;
!   y|=stream_read_char(s)<<24;
!   return y;
! }
! 
! inline void stream_read(stream_t *s,char* mem,int len){
!   while(len>0){
!     int x;
!     x=s->buf_len-s->buf_pos;
!     if(x==0){
!       if(!stream_fill_buffer(s)) return; // EOF
!       x=s->buf_len-s->buf_pos;
!     }
!     if(s->buf_pos>s->buf_len) printf("stream_read: WARNING! s->buf_pos>s->buf_len\n");
!     if(x>len) x=len;
!     memcpy(mem,&s->buffer[s->buf_pos],x);
!     s->buf_pos+=x; mem+=x; len-=x;
!   }
! }
! 
! inline int stream_eof(stream_t *s){
!   return s->eof;
! }
! 
! inline int stream_tell(stream_t *s){
!   return s->pos+s->buf_pos-s->buf_len;
! }
! 
! inline int stream_seek(stream_t *s,unsigned int pos){
  unsigned int newpos;
  
!   if(verbose>=3) printf("seek to 0x%X\n",pos);
! 
!   if(pos<s->pos){
!     int x=pos-(s->pos-s->buf_len);
!     if(x>=0){
!       s->buf_pos=x;
! //      putchar('*');fflush(stdout);
!       return 1;
!     }
!   }
  
  if(verbose>=3){
    printf("s->pos=%X  newpos=%X  new_bufpos=%X  buflen=%X  \n",
!     s->pos,newpos,pos,s->buf_len);
  }
  
--- 41,53 ----
    return len;
  }
  
! int stream_seek_long(stream_t *s,unsigned int pos){
  unsigned int newpos;
  
! //  if(verbose>=3) printf("seek to 0x%X\n",pos);
  
  if(verbose>=3){
    printf("s->pos=%X  newpos=%X  new_bufpos=%X  buflen=%X  \n",
!     (unsigned int)s->pos,newpos,pos,s->buf_len);
  }
  
***************
*** 158,182 ****
      return 1;
    }
!   printf("stream_seek: WARNING! Can't seek to 0x%X !\n",pos+newpos);
    return 0;
  }
  
- inline void stream_skip(stream_t *s,int len){
-   if(len<0 || len>2*STREAM_BUFFER_SIZE){
-     // negative or big skip!
-     stream_seek(s,stream_tell(s)+len);
-     return;
-   }
-   while(len>0){
-     int x=s->buf_len-s->buf_pos;
-     if(x==0){
-       if(!stream_fill_buffer(s)) return; // EOF
-       x=s->buf_len-s->buf_pos;
-     }
-     if(x>len) x=len;
-     //memcpy(mem,&s->buf[s->buf_pos],x);
-     s->buf_pos+=x; len-=x;
-   }
- }
  
  void stream_reset(stream_t *s){
--- 87,94 ----
      return 1;
    }
!   if(verbose) printf("stream_seek: WARNING! Can't seek to 0x%X !\n",pos+newpos);
    return 0;
  }
  
  
  void stream_reset(stream_t *s){

Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -C2 -r1.90 -r1.91
*** mplayer.c	2001/04/22 16:29:25	1.90
--- mplayer.c	2001/04/22 16:56:20	1.91
***************
*** 234,238 ****
  //**************************************************************************//
  
! #include "stream.c"
  #include "demuxer.c"
  
--- 234,238 ----
  //**************************************************************************//
  
! #include "stream.h"
  #include "demuxer.c"
  
***************
*** 606,614 ****
  if(vcd_track){
  //============ Open VideoCD track ==============
    f=open(filename,O_RDONLY);
    if(f<0){ printf("CD-ROM Device '%s' not found!\n",filename);return 1; }
    vcd_read_toc(f);
!   if(!vcd_seek_to_track(f,vcd_track)){ printf("Error selecting VCD track!\n");return 1;}
!   seek_to_byte+=VCD_SECTOR_DATA*vcd_get_msf();
    if(verbose) printf("VCD start byte position: 0x%X\n",seek_to_byte);
    stream_type=STREAMTYPE_VCD;
--- 606,616 ----
  if(vcd_track){
  //============ Open VideoCD track ==============
+   int ret;
    f=open(filename,O_RDONLY);
    if(f<0){ printf("CD-ROM Device '%s' not found!\n",filename);return 1; }
    vcd_read_toc(f);
!   ret=vcd_seek_to_track(f,vcd_track);
!   if(ret==-1){ 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;

Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/Makefile,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -r1.20 -r1.21
*** Makefile	2001/04/21 15:38:01	1.20
--- Makefile	2001/04/22 16:56:20	1.21
***************
*** 21,26 ****
  BINDIR = ${prefix}/bin
  # BINDIR = /usr/local/bin
! SRCS = codec-cfg.c subreader.c linux/getch2.c linux/timer-lx.c linux/shmem.c xa/xa_gsm.c lirc_mp.c cfgparser.c mixer.c dvdauth.c spudec.c
! OBJS = codec-cfg.o subreader.o linux/getch2.o linux/timer-lx.o linux/shmem.o xa/xa_gsm.o lirc_mp.o cfgparser.o mixer.o dvdauth.o spudec.o
  CFLAGS = $(OPTFLAGS) $(CSS_INC) -Iloader -Ilibvo # -Wall
  A_LIBS = -Lmp3lib -lMP3 -Llibac3 -lac3
--- 21,26 ----
  BINDIR = ${prefix}/bin
  # BINDIR = /usr/local/bin
! SRCS = stream.c codec-cfg.c subreader.c linux/getch2.c linux/timer-lx.c linux/shmem.c xa/xa_gsm.c lirc_mp.c cfgparser.c mixer.c dvdauth.c spudec.c
! OBJS = stream.o codec-cfg.o subreader.o linux/getch2.o linux/timer-lx.o linux/shmem.o xa/xa_gsm.o lirc_mp.o cfgparser.o mixer.o dvdauth.o spudec.o
  CFLAGS = $(OPTFLAGS) $(CSS_INC) -Iloader -Ilibvo # -Wall
  A_LIBS = -Lmp3lib -lMP3 -Llibac3 -lac3


_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog



More information about the MPlayer-cvslog mailing list