finalize mfi support.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4566 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
pontscho 2002-02-07 12:07:47 +00:00
parent c3c9527d3e
commit 103a960925
3 changed files with 66 additions and 38 deletions

View File

@ -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;

View File

@ -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:

View File

@ -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,"*" );
if ( glob( fname,0,NULL,&gg ) )
{ free( fname ); return 0; }
printf( "[mf] search expr: %s\n",fname );
mf=malloc( sizeof( mf_t ) );
mf->nr_of_files=gg.gl_pathc;
mf->names=malloc( 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++ )
fname=malloc( strlen( filename ) + 32 );
mf=calloc( 1,sizeof( mf_t ) );
if ( !strchr( filename,'%' ) )
{
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] );
}
globfree( &gg );
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( 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* ) );
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;
}
mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",filename );
while ( error_count < 5 )
{
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++;
}
}
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