annotate libmpdemux/mf.c @ 5266:413e450da31c

try to uncomment this line - very funny effect (skipping I frames) usefull for testing/checking how usefull/powerfull the ME/MC is in divx/mpeg4
author arpi
date Sat, 23 Mar 2002 02:41:31 +0000
parents be1562b2c2d0
children cf2882606e72
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
1
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
2 #include <ctype.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
3 #include <stdio.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
4 #include <stdlib.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
5 #include <string.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
6 #include <unistd.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
7 #include <fcntl.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
8 #include <glob.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
9 #include <errno.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
10 #include <sys/types.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
11 #include <sys/stat.h>
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
12
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
13 #include "config.h"
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
14
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
15 #include "mp_msg.h"
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
16 #include "help_mp.h"
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
17 #include "stream.h"
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
18
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
19 #include "mf.h"
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
20
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
21 int mf_support = 0;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
22 int mf_w = 352;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
23 int mf_h = 288;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
24 int mf_fps = 25;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
25 char * mf_type = "jpg";
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
26
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
27 int stream_open_mf(char * filename,stream_t * stream)
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
28 {
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
29 glob_t gg;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
30 struct stat fs;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
31 int i;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
32 char * fname;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
33 mf_t * mf;
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
34 int error_count = 0;
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
35 int count = 0;
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
36
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
37 fname=malloc( strlen( filename ) + 32 );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
38 mf=calloc( 1,sizeof( mf_t ) );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
39
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
40 if ( !strchr( filename,'%' ) )
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
41 {
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
42 strcpy( fname,filename );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
43 if ( !strchr( filename,'*' ) ) strcat( fname,"*" );
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
44
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
45 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",fname );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
46
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
47 if ( glob( fname,0,NULL,&gg ) )
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
48 { free( mf ); free( fname ); return 0; }
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
49
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
50 mf->nr_of_files=gg.gl_pathc;
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
51 mf->names=malloc( gg.gl_pathc * sizeof( char* ) );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
52
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
53 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d (%d)\n",mf->nr_of_files, gg.gl_pathc * sizeof( char* ) );
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
54
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
55 for( i=0;i < gg.gl_pathc;i++ )
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
56 {
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
57 stat( gg.gl_pathv[i],&fs );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
58 if( S_ISDIR( fs.st_mode ) ) continue;
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
59 mf->names[i]=strdup( gg.gl_pathv[i] );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
60 // mp_msg( MSGT_STREAM,MSGL_DBG2,"[mf] added file %d.: %s\n",i,mf->names[i] );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
61 }
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
62 globfree( &gg );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
63 goto exit_mf;
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
64 }
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
65
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
66 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",filename );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
67
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
68 while ( error_count < 5 )
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
69 {
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
70 sprintf( fname,filename,count++ );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
71 if ( stat( fname,&fs ) )
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
72 {
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
73 error_count++;
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
74 mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
75 }
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
76 else
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
77 {
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
78 mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
79 mf->names[mf->nr_of_files]=strdup( fname );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
80 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
81 mf->nr_of_files++;
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
82 }
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
83 }
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
84
4565
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
85 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files );
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
86
be1562b2c2d0 finalize mfi support.
pontscho
parents: 4549
diff changeset
87 exit_mf:
4549
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
88 free( fname );
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
89 stream->priv=(void*)mf;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
90 return 1;
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
91 }
d5c91be7f9c9 add mfi support
pontscho
parents:
diff changeset
92