Mercurial > mplayer.hg
changeset 4565:be1562b2c2d0
finalize mfi support.
author | pontscho |
---|---|
date | Thu, 07 Feb 2002 12:07:47 +0000 |
parents | 5e1221d4655e |
children | 3b1721b9e211 |
files | libmpdemux/demux_mf.c libmpdemux/demuxer.c libmpdemux/mf.c |
diffstat | 3 files changed, 62 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/demux_mf.c Thu Feb 07 05:55:29 2002 +0000 +++ b/libmpdemux/demux_mf.c Thu Feb 07 12:07:47 2002 +0000 @@ -22,6 +22,15 @@ } 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 @@ 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 @@ 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 @@ 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;
--- a/libmpdemux/demuxer.c Thu Feb 07 05:55:29 2002 +0000 +++ b/libmpdemux/demuxer.c Thu Feb 07 12:07:47 2002 +0000 @@ -776,6 +776,9 @@ 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:
--- a/libmpdemux/mf.c Thu Feb 07 05:55:29 2002 +0000 +++ b/libmpdemux/mf.c Thu Feb 07 12:07:47 2002 +0000 @@ -31,44 +31,62 @@ int i; char * fname; mf_t * mf; - - fname=malloc( strlen( filename ) + 2 ); - strcpy( fname,filename ); strcat( fname,"*" ); + int error_count = 0; + int count = 0; - if ( glob( fname,0,NULL,&gg ) ) - { free( fname ); return 0; } + fname=malloc( strlen( filename ) + 32 ); + mf=calloc( 1,sizeof( mf_t ) ); + + if ( !strchr( filename,'%' ) ) + { + strcpy( fname,filename ); + if ( !strchr( filename,'*' ) ) strcat( fname,"*" ); - printf( "[mf] search expr: %s\n",fname ); + mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",fname ); + + if ( glob( fname,0,NULL,&gg ) ) + { free( mf ); free( fname ); return 0; } + + 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* ) ); - mf=malloc( sizeof( mf_t ) ); - mf->nr_of_files=gg.gl_pathc; - mf->names=malloc( 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; + } - 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++ ) + 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