Changeset 256
- Timestamp:
- 01/06/07 18:12:59 (2 years ago)
- Files:
-
- trunk/MatroskaCodecIDs.cpp (modified) (2 diffs)
- trunk/MatroskaCodecIDs.h (modified) (1 diff)
- trunk/Perian.xcodeproj/project.pbxproj (modified) (9 diffs)
- trunk/bitstream_info.c (added)
- trunk/bitstream_info.h (added)
- trunk/ff_MovieImport.c (modified) (1 diff)
- trunk/ff_private.c (modified) (13 diffs)
- trunk/ff_private.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/MatroskaCodecIDs.cpp
r242 r256 573 573 }; 574 574 575 extern "C"{ 575 576 576 577 AudioChannelLayout GetDefaultChannelLayout(AudioStreamBasicDescription *asbd) … … 598 599 599 600 return acl; 601 } 602 600 603 } 601 604 trunk/MatroskaCodecIDs.h
r242 r256 53 53 ComponentResult MkvFinishASBD(KaxTrackEntry *tr_entry, AudioStreamBasicDescription *asbd); 54 54 FourCharCode GetFourCC(KaxTrackEntry *tr_entry); 55 extern "C"{ 55 56 AudioChannelLayout GetDefaultChannelLayout(AudioStreamBasicDescription *asbd); 56 57 } 57 58 #endif trunk/Perian.xcodeproj/project.pbxproj
r253 r256 214 214 8F483B5E0A6426C1002CCA73 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8F483B5D0A6426C1002CCA73 /* AudioToolbox.framework */; }; 215 215 8F483B8C0A642886002CCA73 /* PerianAviImporter.r in Rez */ = {isa = PBXBuildFile; fileRef = 8F483B8B0A642886002CCA73 /* PerianAviImporter.r */; }; 216 F52286260B50625E00F8CF7D /* bitstream_info.c in Sources */ = {isa = PBXBuildFile; fileRef = F52286250B50625E00F8CF7D /* bitstream_info.c */; }; 216 217 F53E18E50B4F483C003A0471 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F53E18E40B4F483C003A0471 /* Security.framework */; }; 217 218 F59E09F10A670E570019A3F0 /* Perian.component in CopyFiles */ = {isa = PBXBuildFile; fileRef = 11A70AC10A3D0105002058D4 /* Perian.component */; }; … … 540 541 8F483BBC0A642B3D002CCA73 /* ff_MovieImportDispatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ff_MovieImportDispatch.h; sourceTree = "<group>"; }; 541 542 F50D440703EAD8DF01B1D299 /* FFusion.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = FFusion.icns; sourceTree = "<group>"; }; 543 F52286240B50625E00F8CF7D /* bitstream_info.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bitstream_info.h; sourceTree = "<group>"; }; 544 F52286250B50625E00F8CF7D /* bitstream_info.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bitstream_info.c; sourceTree = "<group>"; }; 542 545 F53E18E40B4F483C003A0471 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = "<absolute>"; }; 543 546 F560DECD03D61B6101ABA332 /* Components.k.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Components.k.h; sourceTree = "<group>"; }; … … 546 549 F560DF0003D61D0101ABA332 /* FFusionCodec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = FFusionCodec.c; sourceTree = "<group>"; }; 547 550 F560DF0203D622D001ABA332 /* FFusionCodec.r */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.rez; path = FFusionCodec.r; sourceTree = "<group>"; }; 548 F5CFD1B40B50009000616865 /* PerianPanePListGenerator */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = PerianPanePListGenerator; sourceTree = BUILT_PRODUCTS_DIR; };551 F5CFD1B40B50009000616865 /* PerianPanePListGenerator */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = PerianPanePListGenerator; sourceTree = BUILT_PRODUCTS_DIR; }; 549 552 F5CFD1BC0B5000CE00616865 /* GBPerianPanePListGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GBPerianPanePListGenerator.h; sourceTree = "<group>"; }; 550 553 F5CFD1BD0B5000CE00616865 /* GBPerianPanePListGenerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GBPerianPanePListGenerator.m; sourceTree = "<group>"; }; … … 943 946 11C85ED60A641E6400DF3D73 /* ff_private.c */, 944 947 11C85ED70A641E6400DF3D73 /* ff_private.h */, 948 F52286240B50625E00F8CF7D /* bitstream_info.h */, 949 F52286250B50625E00F8CF7D /* bitstream_info.c */, 945 950 ); 946 951 name = "File Import"; … … 962 967 F5CFD2D60B5012A100616865 /* A52Codec.component */, 963 968 F5CFD2D80B5012A100616865 /* AC3MovieImport.component */, 964 F5CFD2DA0B5012A100616865 /* Preferences.app */,969 F5CFD2DA0B5012A100616865 /* A52Preferences.app */, 965 970 ); 966 971 name = Products; … … 1177 1182 sourceTree = BUILT_PRODUCTS_DIR; 1178 1183 }; 1179 F5CFD2DA0B5012A100616865 /* Preferences.app */ = {1184 F5CFD2DA0B5012A100616865 /* A52Preferences.app */ = { 1180 1185 isa = PBXReferenceProxy; 1181 1186 fileType = wrapper.application; 1182 path = Preferences.app;1187 path = A52Preferences.app; 1183 1188 remoteRef = F5CFD2D90B5012A100616865 /* PBXContainerItemProxy */; 1184 1189 sourceTree = BUILT_PRODUCTS_DIR; … … 1319 1324 6116E6220B44A5BC0020F1CE /* CABundleLocker.cpp in Sources */, 1320 1325 61FD41330B4F6F0800BEEFEA /* MatroskaImportPrivate.cpp in Sources */, 1326 F52286260B50625E00F8CF7D /* bitstream_info.c in Sources */, 1321 1327 ); 1322 1328 runOnlyForDeploymentPostprocessing = 0; … … 1478 1484 ); 1479 1485 COPY_PHASE_STRIP = NO; 1480 DEAD_CODE_STRIPPING = YES;1486 DEAD_CODE_STRIPPING = NO; 1481 1487 EXPORTED_SYMBOLS_FILE = "$(SOURCE_ROOT)/exportedSymbols"; 1482 1488 FRAMEWORK_SEARCH_PATHS = ( … … 1518 1524 OTHER_REZFLAGS = "-rd -d ppc_$(ppc) -d i386_$(i386) -d TARGET_REZ_CARBON_MACHO=1"; 1519 1525 PREBINDING = NO; 1520 PRESERVE_DEAD_CODE_INITS_AND_TERMS = YES;1526 PRESERVE_DEAD_CODE_INITS_AND_TERMS = NO; 1521 1527 PRODUCT_NAME = Perian; 1522 1528 REZ_PREPROCESSOR_DEFINITIONS = ""; trunk/ff_MovieImport.c
r243 r256 418 418 if(inFlags & movieImportMustUseTrack) { 419 419 storage->map_count = 1; 420 prepare_track( ic, &storage->stream_map, targetTrack, dataRef, dataRefType);420 prepare_track(storage, targetTrack, dataRef, dataRefType); 421 421 } else { 422 422 storage->map_count = ic->nb_streams; 423 prepare_movie( ic, &storage->stream_map, theMovie, dataRef, dataRefType);423 prepare_movie(storage, theMovie, dataRef, dataRefType); 424 424 } 425 425 trunk/ff_private.c
r255 r256 32 32 #include <QuickTime/QuickTime.h> 33 33 34 #include "bitstream_info.h" 35 34 36 /* This routine checks if the system requirements are fullfilled */ 35 37 ComponentResult check_system() … … 66 68 * < 0: couldn't find a matching track 67 69 */ 68 int prepare_track( AVFormatContext *ic, NCStream **out_map, Track targetTrack, Handle dataRef, OSType dataRefType)70 int prepare_track(ff_global_ptr storage, Track targetTrack, Handle dataRef, OSType dataRefType) 69 71 { 70 72 int j; … … 73 75 Media media; 74 76 NCStream *map = NULL; 77 AVFormatContext *ic = storage->format_context; 75 78 76 79 /* If the track has already a media, return an err */ … … 99 102 100 103 if(st->codec->codec_type == CODEC_TYPE_VIDEO) 101 initialize_video_map(map, targetTrack, dataRef, dataRefType );104 initialize_video_map(map, targetTrack, dataRef, dataRefType, storage->firstFrames + st->index); 102 105 else if(st->codec->codec_type == CODEC_TYPE_AUDIO) 103 initialize_audio_map(map, targetTrack, dataRef, dataRefType );106 initialize_audio_map(map, targetTrack, dataRef, dataRefType, storage->firstFrames + st->index); 104 107 105 108 /* return the map */ 106 *out_map = map;109 storage->stream_map = map; 107 110 108 111 return 0; … … 114 117 115 118 /* Initializes the map & targetTrack to receive video data */ 116 void initialize_video_map(NCStream *map, Track targetTrack, Handle dataRef, OSType dataRefType )119 void initialize_video_map(NCStream *map, Track targetTrack, Handle dataRef, OSType dataRefType, AVPacket *firstFrame) 117 120 { 118 121 Media media; … … 174 177 175 178 /* Initializes the map & targetTrack to receive audio data */ 176 void initialize_audio_map(NCStream *map, Track targetTrack, Handle dataRef, OSType dataRefType )179 void initialize_audio_map(NCStream *map, Track targetTrack, Handle dataRef, OSType dataRefType, AVPacket *firstFrame) 177 180 { 178 181 Media media; … … 243 246 int aclSize = 0; //Set this if you intend to use it 244 247 memset(&acl, 0, sizeof(AudioChannelLayout)); 245 if(asbd.mChannelsPerFrame > 2) 248 249 /* We have to parse the format */ 250 int useDefault = 1; 251 if(asbd.mFormatID == 'ac-3' || asbd.mFormatID == 'ms \0') 246 252 { 247 /* We have to just guess what layout to use. People, add them here: */ 248 if((asbd.mFormatID == 'ac-3' || asbd.mFormatID == 'ms \0') && asbd.mChannelsPerFrame == 5) 253 if(parse_ac3_bitstream(&asbd, &acl, firstFrame->data, firstFrame->size)) 249 254 { 250 /* likely really 5.1, but not absolutely sure. guess it is, can't do any better */ 251 asbd.mChannelsPerFrame++; 252 acl.mChannelLayoutTag = kAudioChannelLayoutTag_ITU_3_2_1; 255 useDefault = 0; 253 256 aclSize = sizeof(AudioChannelLayout); 254 257 } 258 } 259 if(useDefault && asbd.mChannelsPerFrame > 2) 260 { 261 acl.mChannelLayoutTag = GetDefaultChannelLayout(); 262 aclSize = sizeof(AudioChannelLayout); 255 263 } 256 264 err = QTSoundDescriptionCreate(&asbd, aclSize == 0 ? NULL : &acl, aclSize, NULL, 0, kQTSoundDescriptionKind_Movie_Version2, &sndHdl); … … 483 491 * 0: ok 484 492 */ 485 int prepare_movie( AVFormatContext *ic, NCStream **out_map, Movie theMovie, Handle dataRef, OSType dataRefType)493 int prepare_movie(ff_global_ptr storage, Movie theMovie, Handle dataRef, OSType dataRefType) 486 494 { 487 495 int j; … … 490 498 Track track; 491 499 Track first_audio_track = NULL; 500 AVFormatContext *ic = storage->format_context; 492 501 493 502 /* make the stream map structure */ … … 502 511 if(st->codec->codec_type == CODEC_TYPE_VIDEO) { 503 512 track = NewMovieTrack(theMovie, st->codec->width << 16, st->codec->height << 16, kNoVolume); 504 initialize_video_map(&map[j], track, dataRef, dataRefType );513 initialize_video_map(&map[j], track, dataRef, dataRefType, storage->firstFrames + j); 505 514 } else if (st->codec->codec_type == CODEC_TYPE_AUDIO) { 506 515 track = NewMovieTrack(theMovie, 0, 0, kFullVolume); 507 initialize_audio_map(&map[j], track, dataRef, dataRefType );516 initialize_audio_map(&map[j], track, dataRef, dataRefType, storage->firstFrames + j); 508 517 509 518 if (first_audio_track == NULL) … … 516 525 add_metadata(ic, theMovie); 517 526 518 *out_map = map;527 storage->stream_map = map; 519 528 520 529 return 0; … … 542 551 else 543 552 { 553 int streamsRead = 0; 544 554 result = av_seek_frame(formatContext, -1, 0, 0); 545 555 if(result < 0) goto bail; … … 554 564 } 555 565 } 556 av_free_packet(&packet); 566 while(streamsRead < formatContext->nb_streams) 567 { 568 int streamIndex = packet.stream_index; 569 if(storage->firstFrames[streamIndex].size == 0) 570 { 571 memcpy(storage->firstFrames + streamIndex, &packet, sizeof(AVPacket)); 572 streamsRead++; 573 if(streamsRead == formatContext->nb_streams) 574 break; 575 } 576 else 577 av_free_packet(&packet); 578 formatContext->iformat->read_packet(formatContext, &packet); 579 } 557 580 558 581 // seek back to the beginning, otherwise av_read_frame-based decoding will skip a few packets. trunk/ff_private.h
r221 r256 77 77 int map_count; 78 78 int64_t header_offset; 79 80 AVPacket firstFrames[MAX_STREAMS]; 79 81 }; 80 82 typedef struct _ff_global_context ff_global_context; … … 91 93 92 94 /* Import routines */ 93 int prepare_track( AVFormatContext *ic, NCStream **out_map, Track targetTrack, Handle dataRef, OSType dataRefType);94 int prepare_movie( AVFormatContext *ic, NCStream **out_map, Movie theMovie, Handle dataRef, OSType dataRefType);95 void initialize_video_map(NCStream *map, Track targetTrack, Handle dataRef, OSType dataRefType );96 void initialize_audio_map(NCStream *map, Track targetTrack, Handle dataRef, OSType dataRefType );95 int prepare_track(ff_global_ptr storage, Track targetTrack, Handle dataRef, OSType dataRefType); 96 int prepare_movie(ff_global_ptr storage, Movie theMovie, Handle dataRef, OSType dataRefType); 97 void initialize_video_map(NCStream *map, Track targetTrack, Handle dataRef, OSType dataRefType, AVPacket *firstFrame); 98 void initialize_audio_map(NCStream *map, Track targetTrack, Handle dataRef, OSType dataRefType, AVPacket *firstFrame); 97 99 98 100 int determine_header_offset(ff_global_ptr storage);
