[Mplayer-cvslog] CVS: mpg12play stream.c,1.1.1.1,1.2

Gernot Ziegler madmac at users.sourceforge.net
Thu May 24 15:35:10 CEST 2001


Update of /cvsroot/mplayer/mpg12play
In directory usw-pr-cvs1:/tmp/cvs-serv3962

Modified Files:
	stream.c 
Log Message:
Stream.c replaced.


Index: stream.c
===================================================================
RCS file: /cvsroot/mplayer/mpg12play/stream.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** stream.c	2001/05/15 01:20:52	1.1.1.1
--- stream.c	2001/05/24 13:35:08	1.2
***************
*** 1,2 ****
--- 1,3 ----
+ #ifdef VCD  // commented out for the moment
  //=================== VideoCD ==========================
  static struct cdrom_tocentry vcd_entry;
***************
*** 121,124 ****
--- 122,126 ----
  
  #endif
+ #endif
  
  //=================== STREAMER =========================
***************
*** 138,166 ****
  } stream_t;
  
! int stream_fill_buffer(stream_t *s){
    int len;
!   if(s->eof){ s->buf_pos=s->buf_len=0; return 0; }
!   switch(s->type){
!   case STREAMTYPE_FILE:
!     len=read(s->fd,s->buffer,STREAM_BUFFER_SIZE);break;
!   case STREAMTYPE_VCD:
  #ifdef VCD_CACHE
!     len=vcd_cache_read(s->fd,s->buffer);break;
  #else
!     len=vcd_read(s->fd,s->buffer);break;
  #endif
!   default: len=0;
!   }
!   if(len<=0){ s->eof=1; s->buf_pos=s->buf_len=0; return 0; }
    s->buf_pos=0;
    s->buf_len=len;
    s->pos+=len;
! //  printf("[%d]",len);fflush(stdout);
    return len;
  }
  
  inline unsigned 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++]:0);
  //  if(s->buf_pos<s->buf_len) return s->buffer[s->buf_pos++];
  //  stream_fill_buffer(s);
--- 140,178 ----
  } stream_t;
  
! int stream_fill_buffer(stream_t *s)
! {
    int len;
!   if(s->eof)
!     { s->buf_pos=s->buf_len=0; return 0; }
! 
!   switch(s->type)
!     {
!     case STREAMTYPE_FILE:
!       len=read(s->fd,s->buffer,STREAM_BUFFER_SIZE);break;
! #if 0 
!     case STREAMTYPE_VCD:
  #ifdef VCD_CACHE
!       len=vcd_cache_read(s->fd,s->buffer);break;
  #else
!       len=vcd_read(s->fd,s->buffer);break;
  #endif
! #endif
! 
!       default: len=0;
!     }
! 
!   if(len<=0)
!     { s->eof=1; s->buf_pos=s->buf_len=0; return 0; }
! 
    s->buf_pos=0;
    s->buf_len=len;
    s->pos+=len;
!   //  printf("[%d]",len);fflush(stdout);
    return len;
  }
  
  inline unsigned 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++]:0);
  //  if(s->buf_pos<s->buf_len) return s->buffer[s->buf_pos++];
  //  stream_fill_buffer(s);
***************
*** 169,180 ****
  }
  
! 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);
--- 181,195 ----
  }
  
! inline unsigned int stream_read_word(stream_t *s)
! {
    int x,y;
    x=stream_read_char(s);
    y=stream_read_char(s);
+   //printf("%s returns: %d\n", __FUNCTION__, (x<<8)|y);
    return (x<<8)|y;
  }
  
! inline unsigned int stream_read_dword(stream_t *s)
! {
    unsigned int y;
    y=stream_read_char(s);
***************
*** 182,192 ****
    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;
  }
--- 197,210 ----
    y=(y<<8)|stream_read_char(s);
    y=(y<<8)|stream_read_char(s);
+   //printf("%s returns: %d\n", __FUNCTION__, y);
    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);
+   //printf("%s returns: %d\n", __FUNCTION__, (y<<8)|x);
    return (y<<8)|x;
  }
***************
*** 198,236 ****
    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=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->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 void stream_seek(stream_t *s,int pos){
! int newpos;
!   if(pos<s->pos){
!     int x=pos-(s->pos-s->buf_len);
!     if(x>=0){
!       s->buf_pos=x;
! //      putchar('*');fflush(stdout);
!       return;
      }
!   }
! 
  #if 0
    printf("s->pos=%X  newpos=%X  new_bufpos=%X  buflen=%X  \n",
--- 216,263 ----
    y|=stream_read_char(s)<<16;
    y|=stream_read_char(s)<<24;
+   //printf("%s returns: %d\n", __FUNCTION__, y);
    return y;
  }
  
! inline void stream_read(stream_t *s,char* mem,int len)
! {
!   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->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 void stream_seek(stream_t *s,int pos)
! {
!   int newpos=0;
!   if(pos<s->pos)
!     {
!       int x=pos-(s->pos-s->buf_len);
!       if(x>=0)
! 	{
! 	  s->buf_pos=x;
! 	  //      putchar('*');fflush(stdout);
! 	  return;
! 	}
      }
!   
  #if 0
    printf("s->pos=%X  newpos=%X  new_bufpos=%X  buflen=%X  \n",
***************
*** 243,265 ****
    case STREAMTYPE_FILE:
      newpos=pos&(~4095);break;
    case STREAMTYPE_VCD:
      newpos=(pos/VCD_SECTOR_DATA)*VCD_SECTOR_DATA;break;
    }
  
    pos-=newpos;
  
! if(newpos==0 || newpos!=s->pos){
!   s->pos=newpos; // real seek
!   switch(s->type){
!   case STREAMTYPE_FILE:
!     lseek(s->fd,s->pos,SEEK_SET);
!     break;
!   case STREAMTYPE_VCD:
  #ifdef VCD_CACHE
!     vcd_cache_seek(s->pos/VCD_SECTOR_DATA);
  #else
!     vcd_set_msf(s->pos/VCD_SECTOR_DATA);
  #endif
      break;
    }
  //   putchar('.');fflush(stdout);
--- 270,297 ----
    case STREAMTYPE_FILE:
      newpos=pos&(~4095);break;
+ #ifdef VCD
    case STREAMTYPE_VCD:
      newpos=(pos/VCD_SECTOR_DATA)*VCD_SECTOR_DATA;break;
+ #endif
    }
  
    pos-=newpos;
  
!   if(newpos==0 || newpos!=s->pos)
!     {
!       s->pos=newpos; // real seek
!       switch(s->type){
!       case STREAMTYPE_FILE:
! 	lseek(s->fd,s->pos,SEEK_SET);
! 	break;
! #ifdef VCD
!       case STREAMTYPE_VCD:
  #ifdef VCD_CACHE
! 	vcd_cache_seek(s->pos/VCD_SECTOR_DATA);
  #else
! 	vcd_set_msf(s->pos/VCD_SECTOR_DATA);
  #endif
      break;
+ #endif
    }
  //   putchar('.');fflush(stdout);
***************
*** 273,295 ****
  }
  
! inline void stream_skip(stream_t *s,int len){
!   if(len>2*STREAM_BUFFER_SIZE){
      // 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){
    s->pos=0; //ftell(f);
    s->eof=0;
--- 305,331 ----
  }
  
! inline void stream_skip(stream_t *s,int len)
! {
!   if (len > 2*STREAM_BUFFER_SIZE){
      // 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)
! {
    s->pos=0; //ftell(f);
    s->eof=0;
***************
*** 297,301 ****
  }
  
! stream_t* new_stream(int fd,int type){
    stream_t *s=malloc(sizeof(stream_t));
    s->fd=fd;
--- 333,338 ----
  }
  
! stream_t* new_stream(int fd,int type)
! {
    stream_t *s=malloc(sizeof(stream_t));
    s->fd=fd;
***************
*** 305,309 ****
  }
  
! void free_stream(stream_t *s){
    free(s);
  }
--- 342,347 ----
  }
  
! void free_stream(stream_t *s)
! {
    free(s);
  }


_______________________________________________
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