Changeset 21
- Timestamp:
- 07/11/06 17:03:40 (3 years ago)
- Files:
-
- trunk/ff_MovieImport.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ff_MovieImport.c
r20 r21 28 28 #define PROBE_BUF_SIZE 64 29 29 30 /* Global variables declaration & definition */31 AVInputFormat *avi_iformat;32 33 /* This one is used because Global variables are initialized ONE time34 * until the application quits. Thus, we have to make sure we're initialize35 * the libavformat only once or we get an endlos loop when registering the same36 * element twice!! */37 Boolean initLib = TRUE;38 39 30 #include <CoreServices/CoreServices.h> 40 31 #include <QuickTime/QuickTime.h> … … 59 50 ImageDescriptionHandle imgHdl; 60 51 SoundDescriptionHandle sndHdl; 52 AVInputFormat *format; 61 53 }; 62 54 typedef struct _ff_global_context ff_global_context; … … 68 60 69 61 #pragma mark - 62 63 void initLib() 64 { 65 /* This one is used because Global variables are initialized ONE time 66 * until the application quits. Thus, we have to make sure we're initialize 67 * the libavformat only once or we get an endlos loop when registering the same 68 * element twice!! */ 69 static Boolean inited = FALSE; 70 71 /* Register the Parser of ffmpeg, needed because we do no proper setup of the libraries */ 72 if(!inited) { 73 inited = TRUE; 74 av_register_all(); 75 } 76 } 70 77 71 78 /************************************ … … 207 214 ComponentResult FFAvi_MovieImportValidateDataRef(ff_global_ptr storage, Handle dataRef, OSType dataRefType, UInt8 *valid) 208 215 { 209 AVInputFormat *format = avi_iformat;210 216 ComponentResult result = noErr; 211 217 DataHandler dataHandler = NULL; … … 227 233 require_noerr(result,bail); 228 234 229 success = format->read_probe(pd); 230 if(success) 235 initLib(); 236 storage->format = av_probe_input_format(pd, 1); 237 if(storage->format != NULL) 231 238 *valid = 255; /* This means we can read the data */ 232 239 bail: … … 279 286 *outFlags = 0; 280 287 281 /* Register the Parser of ffmpeg, needed because we do no proper setup of the libraries*/282 if(initLib) {283 initLib = FALSE;284 register_parsers();285 }288 /* probe the format first */ 289 UInt8 valid = 0; 290 FFAvi_MovieImportValidateDataRef(storage, dataRef, dataRefType, &valid); 291 if(valid != 255) 292 goto bail; 286 293 287 294 /* Prepare the iocontext structure */ … … 292 299 /* Open the Format Context */ 293 300 memset(¶ms, 0, sizeof(params)); 294 if (avi_iformat == NULL) 295 avi_iformat = (AVInputFormat *)malloc(sizeof(AVInputFormat)); 296 result = av_open_input_stream(&ic, &byteContext, "", avi_iformat, ¶ms); 301 result = av_open_input_stream(&ic, &byteContext, "", storage->format, ¶ms); 297 302 require_noerr(result,bail); 298 303 299 304 /* Get the Stream Infos if not already read */ 300 305 result = av_find_stream_info(ic); 301 require_noerr(result,bail); 306 if(result < 0) 307 goto bail; 302 308 303 309 /* Seek backwards to get a manually read packet for file offset */
