diff options
author | pontscho <pontscho@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-02-07 12:07:47 +0000 |
---|---|---|
committer | pontscho <pontscho@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-02-07 12:07:47 +0000 |
commit | 103a960925a147adb113e0e4aab1159caade126c (patch) | |
tree | 80a40bf0f24f67ee8cdc5aba49c0baf3a9e2278b | |
parent | c3c9527d3eccd66fd2ade4dfaddaa03a8b77e3eb (diff) | |
download | mpv-103a960925a147adb113e0e4aab1159caade126c.tar.bz2 mpv-103a960925a147adb113e0e4aab1159caade126c.tar.xz |
finalize mfi support.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4566 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | libmpdemux/demux_mf.c | 17 | ||||
-rw-r--r-- | libmpdemux/demuxer.c | 3 | ||||
-rw-r--r-- | libmpdemux/mf.c | 72 |
3 files changed, 60 insertions, 32 deletions
diff --git a/libmpdemux/demux_mf.c b/libmpdemux/demux_mf.c index ceb173d4f6..06f8fb9036 100644 --- a/libmpdemux/demux_mf.c +++ b/libmpdemux/demux_mf.c @@ -22,6 +22,15 @@ typedef struct } demuxer_mf_t; void demux_seek_mf(demuxer_t *demuxer,float rel_seek_secs,int flags){ + demuxer_mf_t * mf = (demuxer_mf_t *)demuxer->priv; + sh_video_t * sh_video = demuxer->video->sh; + int newpos = (flags & 1)?0:mf->curr_frame; + + if ( flags & 2 ) newpos+=rel_seek_secs*mf->nr_of_frames; + else newpos+=rel_seek_secs * sh_video->fps; + if ( newpos < 0 ) newpos=0; + if( newpos > mf->nr_of_frames) newpos=mf->nr_of_frames; + mf->curr_frame=newpos; } // return value: @@ -38,14 +47,13 @@ int demux_mf_fill_buffer(demuxer_t *demuxer){ mf=(mf_t*)demuxer->stream->priv; stat( mf->names[dmf->curr_frame],&fs ); - printf( "[demux_mf] frame: %d (%s,%d)\n",dmf->curr_frame,mf->names[dmf->curr_frame],fs.st_size ); +// printf( "[demux_mf] frame: %d (%s,%d)\n",dmf->curr_frame,mf->names[dmf->curr_frame],fs.st_size ); if ( !( f=fopen( mf->names[dmf->curr_frame],"r" ) ) ) return 0; { sh_video_t * sh_video = demuxer->video->sh; demux_packet_t * dp = new_demux_packet( fs.st_size ); -// stream_read(stream,dp->buffer,len); - if ( !fread( dp->buffer,1,fs.st_size,f ) ) return 0; + if ( !fread( dp->buffer,fs.st_size,1,f ) ) return 0; dp->pts=dmf->curr_frame / sh_video->fps; dp->pos=dmf->curr_frame; dp->flags=0; @@ -63,7 +71,6 @@ demuxer_t* demux_open_mf(demuxer_t* demuxer){ mf_t *mf = NULL; demuxer_mf_t *dmf = NULL; - mp_msg( MSGT_DEMUX,MSGL_V,"[demux_mf] mf demuxer opened.\n" ); mf=(mf_t*)demuxer->stream->priv; dmf=calloc( 1,sizeof( demuxer_mf_t ) ); @@ -106,7 +113,7 @@ demuxer_t* demux_open_mf(demuxer_t* demuxer){ sh_video->bih->biSizeImage=sh_video->bih->biWidth*sh_video->bih->biHeight*3; /* disable seeking */ - demuxer->seekable = 0; +// demuxer->seekable = 0; demuxer->priv=(void*)dmf; diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c index d4cd4104af..e4d68e38c3 100644 --- a/libmpdemux/demuxer.c +++ b/libmpdemux/demuxer.c @@ -776,6 +776,9 @@ switch(demuxer->file_format){ case DEMUXER_TYPE_Y4M: demux_seek_y4m(demuxer,rel_seek_secs,flags); break; + case DEMUXER_TYPE_MF: + demux_seek_mf(demuxer,rel_seek_secs,flags); break; + case DEMUXER_TYPE_FLI: demux_seek_fli(demuxer,rel_seek_secs,flags); break; case DEMUXER_TYPE_NUV: diff --git a/libmpdemux/mf.c b/libmpdemux/mf.c index c0b5afd331..0d2d0d8744 100644 --- a/libmpdemux/mf.c +++ b/libmpdemux/mf.c @@ -31,44 +31,62 @@ int stream_open_mf(char * filename,stream_t * stream) int i; char * fname; mf_t * mf; + int error_count = 0; + int count = 0; - fname=malloc( strlen( filename ) + 2 ); - strcpy( fname,filename ); strcat( fname,"*" ); + fname=malloc( strlen( filename ) + 32 ); + mf=calloc( 1,sizeof( mf_t ) ); + + if ( !strchr( filename,'%' ) ) + { + strcpy( fname,filename ); + if ( !strchr( filename,'*' ) ) strcat( fname,"*" ); + + mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",fname ); - if ( glob( fname,0,NULL,&gg ) ) - { free( fname ); return 0; } + if ( glob( fname,0,NULL,&gg ) ) + { free( mf ); free( fname ); return 0; } - printf( "[mf] search expr: %s\n",fname ); + mf->nr_of_files=gg.gl_pathc; + mf->names=malloc( gg.gl_pathc * sizeof( char* ) ); - mf=malloc( sizeof( mf_t ) ); - mf->nr_of_files=gg.gl_pathc; - mf->names=malloc( gg.gl_pathc * sizeof( char* ) ); + mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d (%d)\n",mf->nr_of_files, gg.gl_pathc * sizeof( char* ) ); - printf( "[mf] number of files: %d (%d)\n",mf->nr_of_files, gg.gl_pathc * sizeof( char* ) ); + for( i=0;i < gg.gl_pathc;i++ ) + { + stat( gg.gl_pathv[i],&fs ); + if( S_ISDIR( fs.st_mode ) ) continue; + mf->names[i]=strdup( gg.gl_pathv[i] ); +// mp_msg( MSGT_STREAM,MSGL_DBG2,"[mf] added file %d.: %s\n",i,mf->names[i] ); + } + globfree( &gg ); + goto exit_mf; + } - for( i=0;i < gg.gl_pathc;i++ ) + mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",filename ); + + while ( error_count < 5 ) { - stat( gg.gl_pathv[i],&fs ); - if( S_ISDIR( fs.st_mode ) ) continue; - mf->names[i]=strdup( gg.gl_pathv[i] ); -// printf( "[mf] added file %d.: %s\n",i,mf->names[i] ); + sprintf( fname,filename,count++ ); + if ( stat( fname,&fs ) ) + { + error_count++; + mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname ); + } + else + { + mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) ); + mf->names[mf->nr_of_files]=strdup( fname ); +// mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] ); + mf->nr_of_files++; + } } - globfree( &gg ); + mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files ); + +exit_mf: free( fname ); stream->priv=(void*)mf; - return 1; } -#if 0 - -stream_t stream; - -int main( void ) -{ - stream_open_mf( "tmp/a",&stream ); - return 0; -} - -#endif |