Changeset 91
- Timestamp:
- 09/20/06 19:57:49 (2 years ago)
- Files:
-
- trunk/ff_MovieImport.c (modified) (6 diffs)
- trunk/ff_private.c (modified) (2 diffs)
- trunk/ff_private.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ff_MovieImport.c
r86 r91 26 26 #include "allformats.h" 27 27 #include "Codecprintf.h" 28 #include "riff.h" 28 29 29 30 /* This one is a little big in ffmpeg and private anyway */ … … 237 238 } /* FFAvi_MovieImportValidate() */ 238 239 240 // this function is a small avi parser to get the video track's fourcc as 241 // fast as possible, so we can decide whether we can handle the necessary 242 // image description extensions for the format in ValidateDataRef() quickly 243 OSType get_avi_strf_fourcc(ByteIOContext *pb) 244 { 245 OSType tag, subtag; 246 unsigned int size; 247 248 if (get_be32(pb) != 'RIFF') 249 return 0; 250 251 // file size 252 get_le32(pb); 253 254 if (get_be32(pb) != 'AVI ') 255 return 0; 256 257 while (!url_feof(pb)) { 258 tag = get_be32(pb); 259 size = get_le32(pb); 260 261 if (tag == 'LIST') { 262 subtag = get_be32(pb); 263 264 // only lists we care about: hdrl & strl, so skip the rest 265 if (subtag != 'hdrl' && subtag != 'strl') 266 url_fskip(pb, size - 4 + (size & 1)); 267 268 } else if (tag == 'strf') { 269 // 16-byte offset to the fourcc 270 url_fskip(pb, 16); 271 return get_be32(pb); 272 } else 273 url_fskip(pb, size + (size & 1)); 274 } 275 return 0; 276 } 277 239 278 ComponentResult FFAvi_MovieImportValidateDataRef(ff_global_ptr storage, Handle dataRef, OSType dataRefType, UInt8 *valid) 240 279 { … … 244 283 AVProbeData *pd = (AVProbeData *)malloc(sizeof(AVProbeData)); 245 284 ByteIOContext byteContext; 246 AVFormatContext *ic = NULL;247 285 AVFormatParameters params; 248 286 int success, i; … … 266 304 *valid = 255; /* This means we can read the data */ 267 305 268 /* Prepare the iocontext structure */ 269 memset(&byteContext, 0, sizeof(byteContext)); 270 result = url_open_dataref(&byteContext, dataRef, dataRefType); 271 require_noerr(result, bail); 272 273 /* Open the Format Context */ 274 memset(¶ms, 0, sizeof(params)); 275 result = av_open_input_stream(&ic, &byteContext, "", storage->format, ¶ms); 276 require_noerr(result,bail); 277 278 for (i = 0; i < ic->nb_streams; i++) { 279 if (ic->streams[i]->codec->codec_id == CODEC_ID_MJPEG || 280 ic->streams[i]->codec->codec_id == CODEC_ID_MJPEGB || 281 ic->streams[i]->codec->codec_id == CODEC_ID_DVVIDEO) 282 /* but we don't do MJPEG's Huffman tables right yet, and DV video seems to have 283 an aspect ratio coded in the bitstream that ffmpeg doesn't read */ 306 /* we don't do MJPEG's Huffman tables right yet, and DV video seems to have 307 an aspect ratio coded in the bitstream that ffmpeg doesn't read, so let Apple's 308 AVI importer handle AVIs with these two video types */ 309 if (IS_AVI(storage->componentType)) { 310 /* Prepare the iocontext structure */ 311 memset(&byteContext, 0, sizeof(byteContext)); 312 result = url_open_dataref(&byteContext, dataRef, dataRefType); 313 require_noerr(result, bail); 314 315 OSType fourcc = get_avi_strf_fourcc(&byteContext); 316 317 if (codec_get_bmp_id(BSWAP(fourcc)) == CODEC_ID_MJPEG || 318 codec_get_bmp_id(BSWAP(fourcc)) == CODEC_ID_DVVIDEO) 284 319 *valid = 0; 285 320 } … … 289 324 if(dataHandler) 290 325 CloseComponent(dataHandler); 291 if(ic)292 av_close_input_file(ic);293 326 free(pd); 294 327 … … 363 396 if(ic->streams[0]->index_entries == NULL) 364 397 { 365 if ( storage->componentType == 'AVI ' || storage->componentType == 'VfW ' || storage->componentType == 'VFW ')398 if (IS_AVI(storage->componentType)) 366 399 //Try to seek to the first frame; don't care if it fails 367 400 // Is this really needed for AVIs w/out an index? It seems to work fine without, trunk/ff_private.c
r90 r91 28 28 #include <AudioToolbox/AudioToolbox.h> 29 29 30 #define BSWAP(a) ( (((a)&0xff) << 24) | (((a)&0xff00) << 8) | (((a)&0xff0000) >> 8) | (((a) >> 24) & 0xff) )31 32 30 /* This routine checks if the system requirements are fullfilled */ 33 31 ComponentResult check_system() … … 530 528 short import_avi(AVFormatContext *ic, NCStream *map, int64_t aviheader_offset) 531 529 { 532 int j, k, l ;530 int j, k, l, nextFrame; 533 531 NCStream *ncstr; 534 532 AVStream *stream; trunk/ff_private.h
r86 r91 37 37 AVRational base; 38 38 int64_t lastpts; 39 int idxEntry; 39 40 SampleReference64Record lastSample; 40 41 }; … … 68 69 uint8_t *write_data(uint8_t *target, uint8_t* data, int32_t data_size); 69 70 71 #define BSWAP(a) ( (((a)&0xff) << 24) | (((a)&0xff00) << 8) | (((a)&0xff0000) >> 8) | (((a) >> 24) & 0xff) ) 72 73 #define IS_AVI(x) (x == 'AVI ' || x == 'VfW ' || x == 'VFW ') 70 74 71 75 #endif
