Mercurial > mplayer.hg
annotate libmpdemux/mf.c @ 28677:cd9aa9b2533a
ffvc1vdpau and ffwmv3vdpau should be marked as buggy in the same
way as the software decoders, otherwise they will be preferred over
the software decoders which just breaks things when using e.g. xv vo.
author | reimar |
---|---|
date | Mon, 23 Feb 2009 11:48:45 +0000 |
parents | cb07fc632de1 |
children | d643e4643313 |
rev | line source |
---|---|
19300 | 1 |
2 #include <ctype.h> | |
3 #include <stdio.h> | |
4 #include <stdlib.h> | |
5 #include <string.h> | |
6 #include <unistd.h> | |
7 #include <fcntl.h> | |
8 #include <errno.h> | |
9 #include <sys/types.h> | |
10 #include <sys/stat.h> | |
11 | |
12 #include "config.h" | |
13 | |
14 #ifdef HAVE_GLOB | |
15 #include <glob.h> | |
16 #else | |
17 #include "osdep/glob.h" | |
18 #endif | |
19 | |
20 #include "mp_msg.h" | |
21 #include "help_mp.h" | |
22605
4d81dbdf46b9
Add explicit location for headers from the stream/ directory.
diego
parents:
19300
diff
changeset
|
22 #include "stream/stream.h" |
19300 | 23 |
24 #include "mf.h" | |
25 | |
26 int mf_w = 0; //352; // let codecs to detect it | |
27 int mf_h = 0; //288; | |
25964 | 28 double mf_fps = 25.0; |
19300 | 29 char * mf_type = NULL; //"jpg"; |
30 | |
31 mf_t* open_mf(char * filename){ | |
32 #if defined(HAVE_GLOB) || defined(__MINGW32__) | |
33 glob_t gg; | |
34 struct stat fs; | |
35 int i; | |
36 char * fname; | |
37 mf_t * mf; | |
38 int error_count = 0; | |
39 int count = 0; | |
40 | |
41 mf=calloc( 1,sizeof( mf_t ) ); | |
42 | |
43 if( filename[0] == '@' ) | |
44 { | |
45 FILE *lst_f=fopen(filename + 1,"r"); | |
46 if ( lst_f ) | |
47 { | |
48 fname=malloc( 255 ); | |
49 while ( fgets( fname,255,lst_f ) ) | |
50 { | |
51 /* remove spaces from end of fname */ | |
52 char *t=fname + strlen( fname ) - 1; | |
53 while ( t > fname && isspace( *t ) ) *(t--)=0; | |
54 if ( stat( fname,&fs ) ) | |
55 { | |
56 mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname ); | |
57 } | |
58 else | |
59 { | |
60 mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) ); | |
61 mf->names[mf->nr_of_files]=strdup( fname ); | |
62 mf->nr_of_files++; | |
63 } | |
64 } | |
65 fclose( lst_f ); | |
66 | |
67 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files ); | |
68 goto exit_mf; | |
69 } | |
70 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] %s is not indirect filelist\n",filename+1 ); | |
71 } | |
72 | |
73 if( strchr( filename,',') ) | |
74 { | |
75 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] filelist: %s\n",filename ); | |
76 | |
77 while ( ( fname=strsep( &filename,"," ) ) ) | |
78 { | |
79 if ( stat( fname,&fs ) ) | |
80 { | |
81 mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname ); | |
82 } | |
83 else | |
84 { | |
85 mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) ); | |
86 mf->names[mf->nr_of_files]=strdup( fname ); | |
87 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] ); | |
88 mf->nr_of_files++; | |
89 } | |
90 } | |
91 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files ); | |
92 | |
93 goto exit_mf; | |
94 } | |
95 | |
96 fname=malloc( strlen( filename ) + 32 ); | |
97 | |
98 if ( !strchr( filename,'%' ) ) | |
99 { | |
100 strcpy( fname,filename ); | |
101 if ( !strchr( filename,'*' ) ) strcat( fname,"*" ); | |
102 | |
103 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",fname ); | |
104 | |
105 if ( glob( fname,0,NULL,&gg ) ) | |
106 { free( mf ); free( fname ); return NULL; } | |
107 | |
108 mf->nr_of_files=gg.gl_pathc; | |
109 mf->names=calloc( gg.gl_pathc, sizeof( char* ) ); | |
110 | |
111 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d (%d)\n",mf->nr_of_files, gg.gl_pathc * sizeof( char* ) ); | |
112 | |
113 for( i=0;i < gg.gl_pathc;i++ ) | |
114 { | |
115 stat( gg.gl_pathv[i],&fs ); | |
116 if( S_ISDIR( fs.st_mode ) ) continue; | |
117 mf->names[i]=strdup( gg.gl_pathv[i] ); | |
118 // mp_msg( MSGT_STREAM,MSGL_DBG2,"[mf] added file %d.: %s\n",i,mf->names[i] ); | |
119 } | |
120 globfree( &gg ); | |
121 goto exit_mf; | |
122 } | |
123 | |
124 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] search expr: %s\n",filename ); | |
125 | |
126 while ( error_count < 5 ) | |
127 { | |
128 sprintf( fname,filename,count++ ); | |
129 if ( stat( fname,&fs ) ) | |
130 { | |
131 error_count++; | |
132 mp_msg( MSGT_STREAM,MSGL_V,"[mf] file not found: '%s'\n",fname ); | |
133 } | |
134 else | |
135 { | |
136 mf->names=realloc( mf->names,( mf->nr_of_files + 1 ) * sizeof( char* ) ); | |
137 mf->names[mf->nr_of_files]=strdup( fname ); | |
138 // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] ); | |
139 mf->nr_of_files++; | |
140 } | |
141 } | |
142 | |
143 mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files ); | |
144 | |
145 exit_mf: | |
146 free( fname ); | |
147 return mf; | |
148 #else | |
149 mp_msg(MSGT_STREAM,MSGL_FATAL,"[mf] mf support is disabled on your os\n"); | |
150 return 0; | |
151 #endif | |
152 } | |
153 |