Mercurial > mplayer.hg
changeset 1428:a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
author | arpi |
---|---|
date | Tue, 31 Jul 2001 23:18:16 +0000 |
parents | 0ca4e638b696 |
children | 8986d06b2816 |
files | configure demuxer.c demuxer.h mplayer.c seek.c stream.c stream.h |
diffstat | 7 files changed, 99 insertions(+), 48 deletions(-) [+] |
line wrap: on
line diff
--- a/configure Tue Jul 31 22:20:43 2001 +0000 +++ b/configure Tue Jul 31 23:18:16 2001 +0000 @@ -6,6 +6,9 @@ # # Changes in reversed order: # +# 2001/07/31 by Steve Davies +# - added --enable-largefiles +# # 2001/07/12 by Juergen Keil # - add support for non-x86 targets # - add autoconf checks for loader/wine @@ -122,6 +125,7 @@ data [/usr/local/share/mplayer] --enable-debug[=1-3] compile debugging information into mplayer [disable] --enable-profile compile profiling information into mplayer [disable] + --enable-largefiles build with support for files >2^32 bytes long [disable] --enable-mmx build with mmx support [autodetect] --enable-mmx2 build with mmx2 support (PIII, Athlon) [autodetect] --enable-3dnow build with 3dnow! support [autodetect] @@ -962,6 +966,9 @@ --enable-debug) _debug='-g' ;; + --enable-largefiles) + _largefiles=yes + ;; --enable-debug=*) _debug=`echo $_echo_n '-g'$_echo_c; echo $ac_option | cut -d '=' -f 2` ;; @@ -1575,6 +1582,11 @@ CFLAGS="$CFLAGS -D_THREAD_SAFE" fi +# 64 bit file offsets? +if [ "$_largefiles" = "yes" ]; then +CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" +fi + # echo 'CFLAGS=$(OPTFLAGS) -Wall -DMPG12PLAY' >> config.mak echo "Creating $CCONF"
--- a/demuxer.c Tue Jul 31 22:20:43 2001 +0000 +++ b/demuxer.c Tue Jul 31 23:18:16 2001 +0000 @@ -1,5 +1,8 @@ //=================== DEMUXER v2.5 ========================= +#include <sys/types.h> +#include <sys/stat.h> + #include <stdio.h> #include <stdlib.h> @@ -96,12 +99,12 @@ ds->first=ds->last=dp; } if(verbose>=2) - printf("DEMUX: Append packet to %s, len=%d pts=%5.3f pos=%d [packs: A=%d V=%d]\n", + printf("DEMUX: Append packet to %s, len=%d pts=%5.3f pos=%u [packs: A=%d V=%d]\n", (ds==ds->demuxer->audio)?"d_audio":"d_video", - dp->len,dp->pts,dp->pos,ds->demuxer->audio->packs,ds->demuxer->video->packs); + dp->len,dp->pts,(unsigned int)dp->pos,ds->demuxer->audio->packs,ds->demuxer->video->packs); } -void ds_read_packet(demux_stream_t *ds,stream_t *stream,int len,float pts,int pos,int flags){ +void ds_read_packet(demux_stream_t *ds,stream_t *stream,int len,float pts,off_t pos,int flags){ demux_packet_t* dp=new_demux_packet(len); stream_read(stream,dp->buffer,len); dp->pts=pts; //(float)pts/90000.0f; @@ -574,4 +577,3 @@ demuxer->file_format=file_format; return demuxer; } -
--- a/demuxer.h Tue Jul 31 22:20:43 2001 +0000 +++ b/demuxer.h Tue Jul 31 23:18:16 2001 +0000 @@ -18,10 +18,11 @@ #define DEMUXER_TIME_BPS 3 +// Holds one packet/frame/whatever typedef struct demux_packet_st { int len; float pts; - int pos; // pozicio indexben (AVI) ill. fileban (MPG) + off_t pos; // pozicio indexben (AVI) ill. fileban (MPG) unsigned char* buffer; int flags; // keyframe, etc struct demux_packet_st* next; @@ -34,8 +35,8 @@ float pts; // current buffer's pts int pts_bytes; // number of bytes read after last pts stamp int eof; // end of demuxed stream? (true if all buffer empty) - int pos; // position in the input stream (file) - int dpos; // position in the demuxed stream + off_t pos; // position in the input stream (file) + off_t dpos; // position in the demuxed stream int pack_no; // serial number of packet int flags; // flags of current packet (keyframe etc) //--------------- @@ -55,12 +56,12 @@ typedef struct demuxer_st { stream_t *stream; int synced; // stream synced (used by mpeg) - int filepos; // input stream current pos. + off_t filepos; // input stream current pos. int type; // demuxer type: mpeg PS, mpeg ES, avi, avi-ni, avi-nini, asf int file_format; // file format: mpeg/avi/asf // int time_src;// time source (pts/file/bps) - unsigned int movi_start; - unsigned int movi_end; + off_t movi_start; + off_t movi_end; // demux_stream_t *audio; demux_stream_t *video; @@ -68,6 +69,7 @@ // index: // AVIINDEXENTRY* idx; +// FIXME: off_t??? void* idx; int idx_size; int idx_pos; @@ -103,12 +105,12 @@ demuxer_t* new_demuxer(stream_t *stream,int type,int a_id,int v_id,int s_id); void ds_add_packet(demux_stream_t *ds,demux_packet_t* dp); -void ds_read_packet(demux_stream_t *ds,stream_t *stream,int len,float pts,int pos,int flags); +void ds_read_packet(demux_stream_t *ds,stream_t *stream,int len,float pts,off_t pos,int flags); int demux_fill_buffer(demuxer_t *demux,demux_stream_t *ds); int ds_fill_buffer(demux_stream_t *ds); -inline static int ds_tell(demux_stream_t *ds){ +inline static off_t ds_tell(demux_stream_t *ds){ return (ds->dpos-ds->buffer_size)+ds->buffer_pos; }
--- a/mplayer.c Tue Jul 31 22:20:43 2001 +0000 +++ b/mplayer.c Tue Jul 31 23:18:16 2001 +0000 @@ -1,25 +1,26 @@ // AVI & MPEG Player v0.18 (C) 2000-2001. by A'rpi/ESP-team +#include "version.h" +#include "config.h" + +#include <sys/ioctl.h> +#include <sys/mman.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <sys/time.h> +#include <sys/stat.h> + +#include <signal.h> + +#include <time.h> + +#include <fcntl.h> +#include <unistd.h> + #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <signal.h> - -#include <sys/ioctl.h> -#include <unistd.h> -#include <time.h> -#include <sys/mman.h> - -#include <sys/types.h> -#include <sys/wait.h> -#include <sys/time.h> -#include <sys/stat.h> -#include <fcntl.h> - -#include "version.h" -#include "config.h" - #ifdef __FreeBSD__ #include <sys/cdrio.h> #endif @@ -227,7 +228,7 @@ int osd_level=2; int divx_quality=0; char *seek_to_sec=NULL; -int seek_to_byte=0; +off_t seek_to_byte=0; int has_audio=1; char *audio_codec=NULL; // override audio codec char *video_codec=NULL; // override video codec @@ -641,7 +642,7 @@ stream->end_pos=ret2; } else { //============ Open plain FILE ============ - int len; + off_t len; if(!strcmp(filename,"-")){ // read from stdin printf("Reading from stdin...\n"); @@ -656,6 +657,14 @@ f=open(filename,O_RDONLY); if(f<0){ fprintf(stderr,"File not found: '%s'\n",filename);return 1; } len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET); + if (len == -1) + perror("Error: lseek failed to obtain video file size"); + else +#ifdef _LARGEFILE_SOURCE + fprintf(stderr, "File size is %lld bytes\n", (long long)len); +#else + fprintf(stderr, "File size is %u bytes\n", (unsigned int)len); +#endif stream=new_stream(f,STREAMTYPE_FILE); stream->end_pos=len; #ifdef STREAMING
--- a/seek.c Tue Jul 31 22:20:43 2001 +0000 +++ b/seek.c Tue Jul 31 23:18:16 2001 +0000 @@ -58,6 +58,7 @@ switch(demuxer->file_format){ + //FIXME: OFF_T - Didn't check AVI case yet (avi files can't be >2G anyway?) case DEMUXER_TYPE_AVI: { //================= seek in AVI ========================== int rel_seek_frames=rel_seek_secs*sh_video->fps; @@ -187,12 +188,14 @@ } break; + //FIXME: OFF_T - didn't test ASF case yet (don't have a large asf...) + //FIXME: reports good or bad to steve@daviesfam.org please case DEMUXER_TYPE_ASF: { //================= seek in ASF ========================== float p_rate=10; // packets / sec - int rel_seek_packs=rel_seek_secs*p_rate; - int rel_seek_bytes=rel_seek_packs*asf_packetsize; - int newpos; + off_t rel_seek_packs=rel_seek_secs*p_rate; // FIXME: int may be enough? + off_t rel_seek_bytes=rel_seek_packs*asf_packetsize; + off_t newpos; //printf("ASF: packs: %d duration: %d \n",(int)fileh.packets,*((int*)&fileh.duration)); // printf("ASF_seek: %d secs -> %d packs -> %d bytes \n", // rel_seek_secs,rel_seek_packs,rel_seek_bytes); @@ -228,14 +231,18 @@ case DEMUXER_TYPE_MPEG_ES: case DEMUXER_TYPE_MPEG_PS: { //================= seek in MPEG ========================== - int newpos; + off_t newpos; if(!sh_video->i_bps) // unspecified? newpos=demuxer->filepos+2324*75*rel_seek_secs; // 174.3 kbyte/sec else newpos=demuxer->filepos+(sh_video->i_bps)*rel_seek_secs; if(newpos<seek_to_byte) newpos=seek_to_byte; +#ifdef _LARGEFILE_SOURCE + newpos&=~((long long)STREAM_BUFFER_SIZE-1); /* sector boundary */ +#else newpos&=~(STREAM_BUFFER_SIZE-1); /* sector boundary */ +#endif stream_seek(demuxer->stream,newpos); // re-sync video:
--- a/stream.c Tue Jul 31 22:20:43 2001 +0000 +++ b/stream.c Tue Jul 31 23:18:16 2001 +0000 @@ -1,10 +1,15 @@ + +#include "config.h" + +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/ioctl.h> +#include <fcntl.h> +#include <unistd.h> #include <stdio.h> #include <stdlib.h> -#include <sys/ioctl.h> -#include <unistd.h> - #include "stream.h" extern int verbose; // defined in mplayer.c @@ -40,14 +45,19 @@ return len; } -int stream_seek_long(stream_t *s,unsigned int pos){ -unsigned int newpos; +int stream_seek_long(stream_t *s,off_t pos){ +off_t newpos; -// if(verbose>=3) printf("seek to 0x%X\n",pos); +// if(verbose>=3) printf("seek to 0x%X\n",(unsigned int)pos); if(verbose>=3){ +#ifdef _LARGEFILE_SOURCE + printf("s->pos=%llX newpos=%llX new_bufpos=%llX buflen=%X \n", + (long long)s->pos,(long long)newpos,(long long)pos,s->buf_len); +#else printf("s->pos=%X newpos=%X new_bufpos=%X buflen=%X \n", (unsigned int)s->pos,newpos,pos,s->buf_len); +#endif } s->buf_pos=s->buf_len=0; @@ -55,7 +65,11 @@ switch(s->type){ case STREAMTYPE_FILE: case STREAMTYPE_STREAM: +#ifdef _LARGEFILE_SOURCE + newpos=pos&(~((long long)STREAM_BUFFER_SIZE-1));break; +#else newpos=pos&(~(STREAM_BUFFER_SIZE-1));break; +#endif case STREAMTYPE_VCD: newpos=(pos/VCD_SECTOR_DATA)*VCD_SECTOR_DATA;break; } @@ -97,7 +111,11 @@ s->buf_pos=pos; // byte position in sector return 1; } - if(verbose) printf("stream_seek: WARNING! Can't seek to 0x%X !\n",pos+newpos); +#ifdef _LARGEFILE_SOURCE + if(verbose) printf("stream_seek: WARNING! Can't seek to 0x%llX !\n",(long long)(pos+newpos)); +#else + if(verbose) printf("stream_seek: WARNING! Can't seek to 0x%X !\n",(pos+newpos)); +#endif return 0; }
--- a/stream.h Tue Jul 31 22:20:43 2001 +0000 +++ b/stream.h Tue Jul 31 23:18:16 2001 +0000 @@ -20,16 +20,17 @@ typedef struct { int fd; - long pos; + off_t pos; int eof; int type; // 0=file 1=VCD unsigned int buf_pos,buf_len; - long start_pos,end_pos; + off_t start_pos,end_pos; unsigned char buffer[STREAM_BUFFER_SIZE>VCD_SECTOR_SIZE?STREAM_BUFFER_SIZE:VCD_SECTOR_SIZE]; } stream_t; int stream_fill_buffer(stream_t *s); -int stream_seek_long(stream_t *s,unsigned int pos); + +int stream_seek_long(stream_t *s,off_t pos); inline static int stream_read_char(stream_t *s){ return (s->buf_pos<s->buf_len)?s->buffer[s->buf_pos++]: @@ -91,16 +92,16 @@ return s->eof; } -inline static int stream_tell(stream_t *s){ +inline static off_t 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){ +inline static int stream_seek(stream_t *s,off_t pos){ -// if(verbose>=3) printf("seek to 0x%X\n",pos); +// if(verbose>=3) printf("seek to 0x%qX\n",(long long)pos); if(pos<s->pos){ - int x=pos-(s->pos-s->buf_len); + off_t x=pos-(s->pos-s->buf_len); if(x>=0){ s->buf_pos=x; // putchar('*');fflush(stdout);