Changeset 313
- Timestamp:
- 01/29/07 00:02:58 (2 years ago)
- Files:
-
- trunk/Perian.xcodeproj/project.pbxproj (modified) (8 diffs)
- trunk/SSADocument.h (modified) (1 diff)
- trunk/SSADocument.m (modified) (8 diffs)
- trunk/SSARenderCodec.h (added)
- trunk/SSARenderCodec.m (added)
- trunk/SSATagParsing.m.rl (modified) (1 diff)
- trunk/SubImport.c (modified) (2 diffs)
- trunk/TextSubCodec.c (modified) (7 diffs)
- trunk/TextSubCodec.h (modified) (2 diffs)
- trunk/TextSubCodec.r (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Perian.xcodeproj/project.pbxproj
r312 r313 105 105 3D211A200B6B1A540051299D /* SSADocument.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D211A1F0B6B1A540051299D /* SSADocument.m */; }; 106 106 3D211A230B6B1A660051299D /* Categories.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D211A220B6B1A660051299D /* Categories.m */; }; 107 3D211A300B6B1AD80051299D /* SSATagParsing.m.rl in Resources */ = {isa = PBXBuildFile; fileRef = 3D211A2F0B6B1AD80051299D /* SSATagParsing.m.rl */; };107 3D211A300B6B1AD80051299D /* SSATagParsing.m.rl in Sources */ = {isa = PBXBuildFile; fileRef = 3D211A2F0B6B1AD80051299D /* SSATagParsing.m.rl */; }; 108 108 3D4A7A990B5533BC004C5D6A /* ColorConversions.c in Sources */ = {isa = PBXBuildFile; fileRef = 3D4A7A980B5533BC004C5D6A /* ColorConversions.c */; }; 109 3DAD32DA0B6DB26100DA0A72 /* StdIOCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 61CB114D0ACDF3C2007994BD /* StdIOCallback.cpp */; }; 109 110 3DB2BB290B6C92F000416863 /* SSARenderCodec.m in Sources */ = {isa = PBXBuildFile; fileRef = 3DB2BB280B6C92F000416863 /* SSARenderCodec.m */; }; 110 111 6116E5510B43C27B0020F1CE /* ACBaseCodec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6116E5370B43C27B0020F1CE /* ACBaseCodec.cpp */; }; … … 246 247 247 248 /* Begin PBXBuildRule section */ 248 3D 211A2D0B6B1A880051299D/* PBXBuildRule */ = {249 3D74F53C0B6DB50C0018BAC0 /* PBXBuildRule */ = { 249 250 isa = PBXBuildRule; 250 251 compilerSpec = com.apple.compilers.proxy.script; … … 254 255 outputFiles = ( 255 256 "$(DERIVED_FILES_DIR)/$(INPUT_FILE_BASE)", 256 ); 257 script = "RAGEL=${PROJECT_DIR}/ragel\nRLCODEGEN=${PROJECT_DIR}/rlcodegen\n\n${RAGEL} -o ${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.ragel ${INPUT_FILE_PATH} || exit\n${RLCODEGEN} -T1 -o ${DERIVED_FILES_DIR}/${INPUT_FILE_BASE} ${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.ragel || exit"; 257 "$(DERIVED_FILES_DIR)/$(INPUT_FILE_BASE).dot", 258 ); 259 script = "RAGEL=${PROJECT_DIR}/ragel\nRLCODEGEN=${PROJECT_DIR}/rlcodegen\n${RAGEL} -o ${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.ragel ${INPUT_FILE_PATH} || exit\n${RLCODEGEN} -T1 -o ${DERIVED_FILES_DIR}/${INPUT_FILE_BASE} ${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.ragel || exit\n${RLCODEGEN} -V ${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.ragel > ${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.dot"; 258 260 }; 259 261 /* End PBXBuildRule section */ … … 441 443 3D211A220B6B1A660051299D /* Categories.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = Categories.m; path = ../../SSAView/Categories.m; sourceTree = SOURCE_ROOT; }; 442 444 3D211A2E0B6B1AD80051299D /* SSATagParsing.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SSATagParsing.h; sourceTree = "<group>"; }; 443 3D211A2F0B6B1AD80051299D /* SSATagParsing.m.rl */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 30; path = SSATagParsing.m.rl; sourceTree = "<group>"; };445 3D211A2F0B6B1AD80051299D /* SSATagParsing.m.rl */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = SSATagParsing.m.rl; sourceTree = "<group>"; }; 444 446 3D4A7A970B5533BC004C5D6A /* ColorConversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorConversions.h; sourceTree = "<group>"; }; 445 447 3D4A7A980B5533BC004C5D6A /* ColorConversions.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ColorConversions.c; sourceTree = "<group>"; }; … … 1208 1210 ); 1209 1211 buildRules = ( 1210 3D 211A2D0B6B1A880051299D/* PBXBuildRule */,1212 3D74F53C0B6DB50C0018BAC0 /* PBXBuildRule */, 1211 1213 ); 1212 1214 dependencies = ( … … 1371 1373 11A70AD90A3D0149002058D4 /* FFusion.icns in Resources */, 1372 1374 11C85FE70A64315500DF3D73 /* Perian-Info.plist in Resources */, 1373 3D211A300B6B1AD80051299D /* SSATagParsing.m.rl in Resources */,1374 1375 ); 1375 1376 runOnlyForDeploymentPostprocessing = 0; … … 1491 1492 buildActionMask = 2147483647; 1492 1493 files = ( 1494 3D211A300B6B1AD80051299D /* SSATagParsing.m.rl in Sources */, 1493 1495 11C85ED80A641E6400DF3D73 /* ff_dataref.c in Sources */, 1494 1496 11C85EDA0A641E6400DF3D73 /* ff_private.c in Sources */, … … 1518 1520 3D211A230B6B1A660051299D /* Categories.m in Sources */, 1519 1521 3DB2BB290B6C92F000416863 /* SSARenderCodec.m in Sources */, 1522 3DAD32DA0B6DB26100DA0A72 /* StdIOCallback.cpp in Sources */, 1520 1523 ); 1521 1524 runOnlyForDeploymentPostprocessing = 0; trunk/SSADocument.h
r310 r313 55 55 -(NSString *)header; 56 56 -(SSAEvent *)movPacket:(int)i; 57 -(void) loadHeader:(NSString*)path; 57 58 -(unsigned)packetCount; 58 59 @end trunk/SSADocument.m
r312 r313 58 58 resX = rX; resY = rY; 59 59 60 timescale = (field = [hDict objectForKey:@"Timer"])? [field doubleValue] / 100. : 1 ;60 timescale = (field = [hDict objectForKey:@"Timer"])? [field doubleValue] / 100. : 1.; 61 61 collisiontype = Normal; 62 62 if ((field = [hDict objectForKey:@"Collisions"]) && [field isEqualToString:@"Reverse"]) collisiontype = Reverse; … … 337 337 while (1) { 338 338 ns = (NSString*)[lenum nextObject]; 339 if ( [ns length] == 0) continue;339 if (!ns || [ns length] == 0) continue; 340 340 else { 341 341 cai = [ns characterAtIndex:0]; … … 386 386 } 387 387 388 -(void) loadHeader:(NSString*) path388 -(void) loadHeader:(NSString*)ssa 389 389 { 390 390 NSError *err; 391 391 NSStringEncoding se = NSUTF8StringEncoding; 392 NSString *ssa = [[NSString stringWithContentsOfFile:path encoding:se error:&err] stringByStandardizingNewlines];393 392 if (!ssa) return; 394 393 NSArray *lines = [ssa componentsSeparatedByString:@"\n"]; … … 410 409 while (1) { 411 410 ns = (NSString*)[lenum nextObject]; 412 if ( [ns length] == 0) continue;411 if (!ns || [ns length] == 0) continue; 413 412 else { 414 413 cai = [ns characterAtIndex:0]; … … 441 440 442 441 while (1) { 443 if ([ns length] != 0) { 442 if (!ns) break; 443 else if ([ns length] != 0) { 444 444 cai = [ns characterAtIndex:0]; 445 445 … … 530 530 for (i = 0; i < packetCount; i++) { 531 531 SSAEvent *p = [ssa movPacket:i]; 532 TimeRecord movieStartTime = {SInt64ToWide(p->begin_time), 100, 0}; 533 TimeValue sampleTime; 532 534 const char *str = [p->line UTF8String]; 533 535 sampleLen = strlen(str); … … 535 537 PtrToHand(str,&sampleHndl,sampleLen); 536 538 537 err=AddMediaSample(theMedia,sampleHndl,0,sampleLen, p->end_time - p->begin_time,(SampleDescriptionHandle)textDesc, 1, 0, NULL); 538 if (err != noErr) {NSLog(@"a %d",GetMoviesError()); goto bail;} 539 539 err=AddMediaSample(theMedia,sampleHndl,0,sampleLen, p->end_time - p->begin_time,(SampleDescriptionHandle)textDesc, 1, 0, &sampleTime); 540 if (err != noErr) goto bail; 541 542 ConvertTimeScale(&movieStartTime, GetMovieTimeScale(theMovie)); 543 544 err = InsertMediaIntoTrack(theTrack, movieStartTime.value.lo, sampleTime, p->end_time - p->begin_time, fixed1); 545 if (err != noErr) {goto bail;} 546 540 547 DisposeHandle(sampleHndl); 541 548 } … … 543 550 EndMediaEdits(theMedia); 544 551 545 InsertMediaIntoTrack(theTrack,0,0,GetMediaDuration(theMedia),fixed1);546 if (err != noErr) NSLog(@"i %d",GetMoviesError());547 548 552 if (*firstSubTrack == NULL) 549 553 *firstSubTrack = theTrack; trunk/SSATagParsing.m.rl
r312 r313 93 93 NSString *sn = [ar objectAtIndex:2]; 94 94 int j; 95 95 96 for (j=0; j < ssa->stylecount; j++) { 96 97 if ([sn isEqualToString:ssa->styles[j].name]) { trunk/SubImport.c
r311 r313 201 201 202 202 err = InsertMediaIntoTrack(theTrack, movieStartTime.value.lo, sampleTime, duration, fixed1); 203 203 204 if (err) goto bail; 204 205 } … … 300 301 LoadSubRipSubtitles(&parentDir, cfFoundFilename, theMovie, &firstSubTrack); 301 302 303 // SubStationAlpha 302 304 actRange = CFStringFind(cfFoundFilename, CFSTR(".ass"), kCFCompareCaseInsensitive | kCFCompareBackwards); 303 305 if (actRange.location == extRange.location) 304 306 LoadSubStationAlphaSubtitles(&parentDir, cfFoundFilename, theMovie, &firstSubTrack); 305 307 308 actRange = CFStringFind(cfFoundFilename, CFSTR(".ssa"), kCFCompareCaseInsensitive | kCFCompareBackwards); 309 if (actRange.location == extRange.location) 310 LoadSubStationAlphaSubtitles(&parentDir, cfFoundFilename, theMovie, &firstSubTrack); 311 306 312 // VobSub 307 313 actRange = CFStringFind(cfFoundFilename, CFSTR(".idx"), kCFCompareCaseInsensitive | kCFCompareBackwards); trunk/TextSubCodec.c
r287 r313 10 10 11 11 #include "TextSubCodec.h" 12 #include "SSARenderCodec.h" 12 13 13 14 #define SubFontName "Helvetica" … … 32 33 ATSUStyle textStyle, italicStyle, boldStyle, biStyle; 33 34 ATSUTextLayout textLayout; 34 //Ptr textBuffer; 35 36 SSARenderGlobalsPtr ssa; 37 Boolean useSSA; 35 38 } TextSubGlobalsRecord, *TextSubGlobals; 36 39 … … 81 84 #endif 82 85 83 /* -- This Image Decompressor Use rthe Base Image Decompressor Component --86 /* -- This Image Decompressor Uses the Base Image Decompressor Component -- 84 87 The base image decompressor is an Apple-supplied component 85 88 that makes it easier for developers to create new decompressors. … … 105 108 if (err = MemError()) goto bail; 106 109 glob->drawBandUPP = NULL; 110 glob->ssa = NULL; 111 glob->useSSA = false; 107 112 108 113 // Open and target an instance of the base decompressor as we delegate … … 149 154 ATSUDisposeTextLayout(glob->textLayout); 150 155 } 156 if (glob->useSSA) SSA_Dispose(glob->ssa); 151 157 DisposePtr((Ptr)glob); 152 158 } … … 278 284 myDrp->depth = (**p->imageDescription).depth; 279 285 myDrp->dataSize = p->bufferSize; 286 287 glob->useSSA = (**p->imageDescription).cType == kSubFormatSSA; 288 if (glob->useSSA) { 289 long count; 290 CountImageDescriptionExtensionType(p->imageDescription,kSubFormatSSA,&count); 291 if (count == 1) { 292 Handle ssaheader; 293 GetImageDescriptionExtension(p->imageDescription,&ssaheader,kSubFormatSSA,1); 294 295 glob->ssa = SSA_Init(*ssaheader, GetHandleSize(ssaheader)); 296 } 297 } 280 298 281 299 return noErr; … … 306 324 8, drp->rowBytes, glob->colorSpace, 307 325 kCGImageAlphaPremultipliedFirst); 326 327 if (glob->useSSA) { 328 SSA_RenderLine(glob->ssa,c,drp->codecData,myDrp->dataSize,myDrp->width,myDrp->height); 329 return noErr; 330 } 308 331 309 332 if (!glob->textStyle) { //TODO: set language region based on track language... does that even matter? trunk/TextSubCodec.h
r218 r313 10 10 11 11 #define kTextSubCodecFormatName "Text Subtitle" 12 #define kSSASubCodecFormatName "SSA Text Subtitle" 12 13 13 14 #define kManufacturer 'Peri' … … 15 16 #define kTextSubCodecVersion (0x00020001) 16 17 18 #define kSSASubCodecResource 250 17 19 #define kTextSubCodecResource 252 trunk/TextSubCodec.r
r218 r313 69 69 resource 'cdci' (kTextSubCodecResource) { 70 70 kTextSubCodecFormatName, // Type 71 1, // Version 72 1, // Revision level 73 kManufacturer, // Manufacturer 74 kTextSubDecoFlags, // Decompression Flags 75 0, // Compression Flags 76 kTextSubFormatFlags, // Format Flags 77 128, // Compression Accuracy 78 128, // Decomression Accuracy 79 200, // Compression Speed 80 200, // Decompression Speed 81 128, // Compression Level 82 0, // Reserved 83 1, // Minimum Height 84 1, // Minimum Width 85 0, // Decompression Pipeline Latency 86 0, // Compression Pipeline Latency 87 0 // Private Data 88 }; 89 90 // Component Description 91 resource 'cdci' (kSSASubCodecResource) { 92 kSSASubCodecFormatName, // Type 71 93 1, // Version 72 94 1, // Revision level … … 138 160 }; 139 161 162 resource 'thng' (kSSASubCodecResource) { 163 decompressorComponentType, // Type 164 kSubFormatSSA, // SubType 165 kManufacturer, // Manufacturer 166 // - use componentHasMultiplePlatforms 167 0, // not used Component flags 168 0, // not used Component flags Mask 169 0, // not used Code Type 170 0, // not used Code ID 171 'STR ', // Name Type 172 kSSASubCodecResource, // Name ID 173 'STR ', // Info Type 174 kSSASubCodecResource + 1, // Info ID 175 0, // Icon Type 176 0, // Icon ID 177 kTextSubCodecVersion, // Version 178 componentHasMultiplePlatforms + // Registration Flags 179 componentDoAutoVersion, 180 0, // Resource ID of Icon Family 181 { 182 #if TARGET_OS_MAC 183 #if TARGET_REZ_CARBON_MACHO 184 #if !(TARGET_REZ_MAC_PPC || TARGET_REZ_MAC_X86) 185 #error "Platform architecture not defined, TARGET_REZ_MAC_PPC and/or TARGET_REZ_MAC_X86 must be defined!" 186 #endif 187 #if TARGET_REZ_MAC_PPC 188 kTextSubDecoFlags, 189 'dlle', // Code Resource type - Entry point found by symbol name 'dlle' resource 190 kTextSubCodecResource, // ID of 'dlle' resource 191 platformPowerPCNativeEntryPoint, // PPC 192 #endif 193 #if TARGET_REZ_MAC_X86 194 kTextSubDecoFlags, 195 'dlle', 196 kTextSubCodecResource, 197 platformIA32NativeEntryPoint, // INTEL 198 #endif 199 #else 200 #error "At least one non-obsolete TARGET_REZ_XXX_XXX platform must be defined." 201 #endif 202 #endif 203 #if TARGET_OS_WIN32 204 kTextSubDecoFlags, 205 'dlle', 206 kTextSubCodecResource, 207 platformWin32, 208 #endif 209 }; 210 }; 211 140 212 // Component Name 141 213 resource 'STR ' (kTextSubCodecResource) { … … 143 215 }; 144 216 217 resource 'STR ' (kSSASubCodecResource) { 218 "SSA Text Subtitle" 219 }; 220 145 221 // Component Information 222 146 223 resource 'STR ' (kTextSubCodecResource + 1) { 147 224 "Renders subtitles stored as text." 225 }; 226 227 resource 'STR ' (kSSASubCodecResource + 1) { 228 "Renders subtitles stored in SubStation Alpha format." 148 229 }; 149 230
