Public MP42TextSample

This commit is contained in:
Damiano Galassi committed 2013-11-01 11:07:35 +01:00
1 parent 796e9691ce
commit 077f0ff2f6
15 files changed
+169 -94

No files matched your search

+29 -2
View File
@@ -7,6 +7,9 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
A989F1001823AB2E0070AD8C /* MP42Track_Muxer.h in Headers */ = {isa = PBXBuildFile; fileRef = A989F0FF1823AB2E0070AD8C /* MP42Track_Muxer.h */; };
A989F10F1823B3B40070AD8C /* MP42TextSample.h in Headers */ = {isa = PBXBuildFile; fileRef = A989F10D1823B3B40070AD8C /* MP42TextSample.h */; settings = {ATTRIBUTES = (Public, ); }; };
A989F1101823B3B40070AD8C /* MP42TextSample.m in Sources */ = {isa = PBXBuildFile; fileRef = A989F10E1823B3B40070AD8C /* MP42TextSample.m */; };
A9B9C1F1182391DF00416A4E /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9B9C1F0182391DF00416A4E /* Cocoa.framework */; }; A9B9C1F1182391DF00416A4E /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9B9C1F0182391DF00416A4E /* Cocoa.framework */; };
A9B9C1FB182391DF00416A4E /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A9B9C1F9182391DF00416A4E /* InfoPlist.strings */; }; A9B9C1FB182391DF00416A4E /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A9B9C1F9182391DF00416A4E /* InfoPlist.strings */; };
A9B9C206182391DF00416A4E /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9B9C205182391DF00416A4E /* XCTest.framework */; }; A9B9C206182391DF00416A4E /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9B9C205182391DF00416A4E /* XCTest.framework */; };
@@ -118,6 +121,13 @@
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */ /* Begin PBXContainerItemProxy section */
A989F10A1823AEA90070AD8C /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A9B9C2B61823944700416A4E /* UniversalDetector.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 3DBF4F560BCD396800DA401A;
remoteInfo = universaldetector;
};
A9B9C208182391DF00416A4E /* PBXContainerItemProxy */ = { A9B9C208182391DF00416A4E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy; isa = PBXContainerItemProxy;
containerPortal = A9B9C1E4182391DF00416A4E /* Project object */; containerPortal = A9B9C1E4182391DF00416A4E /* Project object */;
@@ -149,6 +159,9 @@
/* End PBXContainerItemProxy section */ /* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
A989F0FF1823AB2E0070AD8C /* MP42Track_Muxer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MP42Track_Muxer.h; sourceTree = "<group>"; };
A989F10D1823B3B40070AD8C /* MP42TextSample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MP42TextSample.h; sourceTree = "<group>"; };
A989F10E1823B3B40070AD8C /* MP42TextSample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MP42TextSample.m; sourceTree = "<group>"; };
A9B9C1ED182391DF00416A4E /* MP42.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MP42.framework; sourceTree = BUILT_PRODUCTS_DIR; }; A9B9C1ED182391DF00416A4E /* MP42.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MP42.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A9B9C1F0182391DF00416A4E /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; A9B9C1F0182391DF00416A4E /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
A9B9C1F3182391DF00416A4E /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; A9B9C1F3182391DF00416A4E /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@@ -448,6 +461,7 @@
children = ( children = (
A9B9C2421823923100416A4E /* MP42Muxer.h */, A9B9C2421823923100416A4E /* MP42Muxer.h */,
A9B9C2431823923100416A4E /* MP42Muxer.m */, A9B9C2431823923100416A4E /* MP42Muxer.m */,
A989F0FF1823AB2E0070AD8C /* MP42Track_Muxer.h */,
A9B9C2481823923100416A4E /* MP42Sample.h */, A9B9C2481823923100416A4E /* MP42Sample.h */,
A9B9C2491823923100416A4E /* MP42Sample.m */, A9B9C2491823923100416A4E /* MP42Sample.m */,
A9B9C22D1823923100416A4E /* MP42ConverterProtocol.h */, A9B9C22D1823923100416A4E /* MP42ConverterProtocol.h */,
@@ -492,6 +506,10 @@
A9B9C4A418239B7E00416A4E /* Utility */ = { A9B9C4A418239B7E00416A4E /* Utility */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
A989F10D1823B3B40070AD8C /* MP42TextSample.h */,
A989F10E1823B3B40070AD8C /* MP42TextSample.m */,
A9B9C2381823923100416A4E /* MP42Image.h */,
A9B9C2391823923100416A4E /* MP42Image.m */,
A9B9C2521823923100416A4E /* MP42Utilities.h */, A9B9C2521823923100416A4E /* MP42Utilities.h */,
A9B9C2531823923100416A4E /* MP42Utilities.m */, A9B9C2531823923100416A4E /* MP42Utilities.m */,
A9B9C24E1823923100416A4E /* MP42SubUtilities.h */, A9B9C24E1823923100416A4E /* MP42SubUtilities.h */,
@@ -500,8 +518,6 @@
A9B9C2591823923200416A4E /* MP42XMLReader.m */, A9B9C2591823923200416A4E /* MP42XMLReader.m */,
A9B9C2361823923100416A4E /* MP42HtmlParser.h */, A9B9C2361823923100416A4E /* MP42HtmlParser.h */,
A9B9C2371823923100416A4E /* MP42HtmlParser.m */, A9B9C2371823923100416A4E /* MP42HtmlParser.m */,
A9B9C2381823923100416A4E /* MP42Image.h */,
A9B9C2391823923100416A4E /* MP42Image.m */,
A9B9C2C91823968400416A4E /* RegexKitLite.h */, A9B9C2C91823968400416A4E /* RegexKitLite.h */,
A9B9C2CA1823968400416A4E /* RegexKitLite.m */, A9B9C2CA1823968400416A4E /* RegexKitLite.m */,
A9B9C2CD182396A100416A4E /* SBRatings.h */, A9B9C2CD182396A100416A4E /* SBRatings.h */,
@@ -549,6 +565,7 @@
A9B9C2851823923200416A4E /* MP42MediaFormat.h in Headers */, A9B9C2851823923200416A4E /* MP42MediaFormat.h in Headers */,
A9B9C2781823923200416A4E /* MP42ConverterProtocol.h in Headers */, A9B9C2781823923200416A4E /* MP42ConverterProtocol.h in Headers */,
A9B9C2931823923200416A4E /* MP42Sample.h in Headers */, A9B9C2931823923200416A4E /* MP42Sample.h in Headers */,
A989F10F1823B3B40070AD8C /* MP42TextSample.h in Headers */,
A9B9C2911823923200416A4E /* MP42QTImporter.h in Headers */, A9B9C2911823923200416A4E /* MP42QTImporter.h in Headers */,
A9B9C28F1823923200416A4E /* MP42OCRWrapper.h in Headers */, A9B9C28F1823923200416A4E /* MP42OCRWrapper.h in Headers */,
A9B9C2811823923200416A4E /* MP42HtmlParser.h in Headers */, A9B9C2811823923200416A4E /* MP42HtmlParser.h in Headers */,
@@ -578,6 +595,7 @@
A9B9C29D1823923200416A4E /* MP42Utilities.h in Headers */, A9B9C29D1823923200416A4E /* MP42Utilities.h in Headers */,
A9B9C2661823923200416A4E /* MP42AACImporter.h in Headers */, A9B9C2661823923200416A4E /* MP42AACImporter.h in Headers */,
A9B9C2681823923200416A4E /* MP42AC3Importer.h in Headers */, A9B9C2681823923200416A4E /* MP42AC3Importer.h in Headers */,
A989F1001823AB2E0070AD8C /* MP42Track_Muxer.h in Headers */,
A9B9C26A1823923200416A4E /* MP42AudioConverter.h in Headers */, A9B9C26A1823923200416A4E /* MP42AudioConverter.h in Headers */,
A9B9C2A11823923200416A4E /* MP42VobSubImporter.h in Headers */, A9B9C2A11823923200416A4E /* MP42VobSubImporter.h in Headers */,
A9B9C2AC1823923200416A4E /* mbs.h in Headers */, A9B9C2AC1823923200416A4E /* mbs.h in Headers */,
@@ -600,6 +618,7 @@
buildRules = ( buildRules = (
); );
dependencies = ( dependencies = (
A989F10B1823AEA90070AD8C /* PBXTargetDependency */,
); );
name = MP42; name = MP42;
productName = MP42; productName = MP42;
@@ -735,6 +754,7 @@
A9B9C2821823923200416A4E /* MP42HtmlParser.m in Sources */, A9B9C2821823923200416A4E /* MP42HtmlParser.m in Sources */,
A9B9C2861823923200416A4E /* MP42MediaFormat.m in Sources */, A9B9C2861823923200416A4E /* MP42MediaFormat.m in Sources */,
A9B9C2A41823923200416A4E /* MP42XMLReader.m in Sources */, A9B9C2A41823923200416A4E /* MP42XMLReader.m in Sources */,
A989F1101823B3B40070AD8C /* MP42TextSample.m in Sources */,
A9B9C2751823923200416A4E /* MP42ChapterTrack.m in Sources */, A9B9C2751823923200416A4E /* MP42ChapterTrack.m in Sources */,
A9B9C2C51823957800416A4E /* SBLanguages.m in Sources */, A9B9C2C51823957800416A4E /* SBLanguages.m in Sources */,
A9B9C2841823923200416A4E /* MP42Image.m in Sources */, A9B9C2841823923200416A4E /* MP42Image.m in Sources */,
@@ -766,6 +786,11 @@
/* End PBXSourcesBuildPhase section */ /* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */ /* Begin PBXTargetDependency section */
A989F10B1823AEA90070AD8C /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = universaldetector;
targetProxy = A989F10A1823AEA90070AD8C /* PBXContainerItemProxy */;
};
A9B9C209182391DF00416A4E /* PBXTargetDependency */ = { A9B9C209182391DF00416A4E /* PBXTargetDependency */ = {
isa = PBXTargetDependency; isa = PBXTargetDependency;
target = A9B9C1EC182391DF00416A4E /* MP42 */; target = A9B9C1EC182391DF00416A4E /* MP42 */;
@@ -887,6 +912,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "MP42/MP42-Prefix.pch"; GCC_PREFIX_HEADER = "MP42/MP42-Prefix.pch";
INFOPLIST_FILE = "MP42/MP42-Info.plist"; INFOPLIST_FILE = "MP42/MP42-Info.plist";
INSTALL_PATH = "@loader_path/../Frameworks";
LIBRARY_SEARCH_PATHS = ( LIBRARY_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
/Users/damians/Desktop/MP42/mp4v2, /Users/damians/Desktop/MP42/mp4v2,
@@ -908,6 +934,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "MP42/MP42-Prefix.pch"; GCC_PREFIX_HEADER = "MP42/MP42-Prefix.pch";
INFOPLIST_FILE = "MP42/MP42-Info.plist"; INFOPLIST_FILE = "MP42/MP42-Info.plist";
INSTALL_PATH = "@loader_path/../Frameworks";
LIBRARY_SEARCH_PATHS = ( LIBRARY_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
/Users/damians/Desktop/MP42/mp4v2, /Users/damians/Desktop/MP42/mp4v2,
+2
View File
@@ -14,6 +14,8 @@
#import "MP42Fifo.h" #import "MP42Fifo.h"
#import "MP42Utilities.h" #import "MP42Utilities.h"
#import "MP42Track_Muxer.h"
#define FIFO_DURATION (0.5f) #define FIFO_DURATION (0.5f)
NSString * const SBMonoMixdown = @"SBMonoMixdown"; NSString * const SBMonoMixdown = @"SBMonoMixdown";
+4 -4
View File
@@ -143,14 +143,14 @@ static int ParseByte(const char *string, UInt8 *byte, Boolean hex)
continue; continue;
startTime = ParseTimeCode([[lineArray objectAtIndex:0] UTF8String], 30000, NO, &dropFrame); startTime = ParseTimeCode([[lineArray objectAtIndex:0] UTF8String], 30000, NO, &dropFrame);
SBTextSample *sample = [[SBTextSample alloc] init]; MP42TextSample *sample = [[MP42TextSample alloc] init];
sample.timestamp = startTime; sample.timestamp = startTime;
sample.title = [lineArray lastObject]; sample.title = [lineArray lastObject];
[sampleArray addObject:[sample autorelease]]; [sampleArray addObject:[sample autorelease]];
} }
for (SBTextSample *ccSample in sampleArray) { for (MP42TextSample *ccSample in sampleArray) {
if (_cancelled) if (_cancelled)
break; break;
@@ -177,7 +177,7 @@ static int ParseByte(const char *string, UInt8 *byte, Boolean hex)
} }
if (firstSample && ccSample.timestamp != 0 && i == 0) { if (firstSample && ccSample.timestamp != 0 && i == 0) {
SBTextSample *boh = [sampleArray objectAtIndex:1]; MP42TextSample *boh = [sampleArray objectAtIndex:1];
sampleDuration = boh.timestamp - ccSample.timestamp; sampleDuration = boh.timestamp - ccSample.timestamp;
firstSample = NO; firstSample = NO;
u_int8_t *emptyBuffer = malloc(sizeof(u_int8_t)*8); u_int8_t *emptyBuffer = malloc(sizeof(u_int8_t)*8);
@@ -200,7 +200,7 @@ static int ParseByte(const char *string, UInt8 *byte, Boolean hex)
minutesDrop += frameDrop; minutesDrop += frameDrop;
} }
else if (i+1 < [sampleArray count]) { else if (i+1 < [sampleArray count]) {
SBTextSample *boh = [sampleArray objectAtIndex:i+1]; MP42TextSample *boh = [sampleArray objectAtIndex:i+1];
sampleDuration = boh.timestamp - ccSample.timestamp; sampleDuration = boh.timestamp - ccSample.timestamp;
frameDrop += sampleDuration; frameDrop += sampleDuration;
minutesDrop += sampleDuration; minutesDrop += sampleDuration;
+4 -5
View File
@@ -8,8 +8,7 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "MP42Track.h" #import "MP42Track.h"
#import "MP42TextSample.h"
@class SBTextSample;
@interface MP42ChapterTrack : MP42Track <NSCoding> { @interface MP42ChapterTrack : MP42Track <NSCoding> {
NSMutableArray *chapters; NSMutableArray *chapters;
@@ -20,10 +19,10 @@
- (void)addChapter:(NSString *)title duration:(uint64_t)timestamp; - (void)addChapter:(NSString *)title duration:(uint64_t)timestamp;
- (void)removeChapterAtIndex:(NSUInteger)index; - (void)removeChapterAtIndex:(NSUInteger)index;
- (void)setTimestamp:(MP42Duration)timestamp forChapter:(SBTextSample *)chapterSample; - (void)setTimestamp:(MP42Duration)timestamp forChapter:(MP42TextSample *)chapterSample;
- (void)setTitle:(NSString*)title forChapter:(SBTextSample *)chapterSample; - (void)setTitle:(NSString*)title forChapter:(MP42TextSample *)chapterSample;
- (SBTextSample *)chapterAtIndex:(NSUInteger)index; - (MP42TextSample *)chapterAtIndex:(NSUInteger)index;
- (NSInteger)chapterCount; - (NSInteger)chapterCount;
+10 -10
View File
@@ -50,7 +50,7 @@
MP4Duration sum = 0; MP4Duration sum = 0;
while (i <= chapter_count) while (i <= chapter_count)
{ {
SBTextSample *chapter = [[SBTextSample alloc] init]; MP42TextSample *chapter = [[MP42TextSample alloc] init];
char * title = chapter_list[i-1].title; char * title = chapter_list[i-1].title;
if ((title[0] == '\xfe' && title[1] == '\xff') || (title[0] == '\xff' && title[1] == '\xfe')) { if ((title[0] == '\xfe' && title[1] == '\xff') || (title[0] == '\xff' && title[1] == '\xfe')) {
@@ -101,7 +101,7 @@
- (void)addChapter:(NSString *)title duration:(uint64_t)timestamp - (void)addChapter:(NSString *)title duration:(uint64_t)timestamp
{ {
SBTextSample *newChapter = [[SBTextSample alloc] init]; MP42TextSample *newChapter = [[MP42TextSample alloc] init];
newChapter.title = title; newChapter.title = title;
newChapter.timestamp = timestamp; newChapter.timestamp = timestamp;
@@ -118,20 +118,20 @@
[chapters removeObjectAtIndex:index]; [chapters removeObjectAtIndex:index];
} }
- (void)setTimestamp:(MP4Duration)timestamp forChapter:(SBTextSample *)chapterSample - (void)setTimestamp:(MP4Duration)timestamp forChapter:(MP42TextSample *)chapterSample
{ {
_isEdited = YES; _isEdited = YES;
[chapterSample setTimestamp:timestamp]; [chapterSample setTimestamp:timestamp];
[chapters sortUsingSelector:@selector(compare:)]; [chapters sortUsingSelector:@selector(compare:)];
} }
- (void)setTitle:(NSString *)title forChapter:(SBTextSample *)chapterSample - (void)setTitle:(NSString *)title forChapter:(MP42TextSample *)chapterSample
{ {
_isEdited = YES; _isEdited = YES;
[chapterSample setTitle:title]; [chapterSample setTitle:title];
} }
- (SBTextSample *)chapterAtIndex:(NSUInteger)index - (MP42TextSample *)chapterAtIndex:(NSUInteger)index
{ {
return [chapters objectAtIndex:index]; return [chapters objectAtIndex:index];
} }
@@ -161,9 +161,9 @@
if (chapterCount) { if (chapterCount) {
// Insert a chapter at time 0 if there isn't one // Insert a chapter at time 0 if there isn't one
SBTextSample * chapter = [chapters objectAtIndex:0]; MP42TextSample * chapter = [chapters objectAtIndex:0];
if (chapter.timestamp != 0) { if (chapter.timestamp != 0) {
SBTextSample *st = [[SBTextSample alloc] init]; MP42TextSample *st = [[MP42TextSample alloc] init];
st.timestamp = 0; st.timestamp = 0;
st.title = @"Chapter 0"; st.title = @"Chapter 0";
[chapters insertObject:st atIndex:0]; [chapters insertObject:st atIndex:0];
@@ -182,12 +182,12 @@
refTrackDuration = moovDuration; refTrackDuration = moovDuration;
for (i = 0; i < chapterCount; i++) { for (i = 0; i < chapterCount; i++) {
SBTextSample * chapter = [chapters objectAtIndex:i]; MP42TextSample * chapter = [chapters objectAtIndex:i];
if ([[chapter title] UTF8String]) if ([[chapter title] UTF8String])
strcpy(fileChapters[i].title, [[chapter title] UTF8String]); strcpy(fileChapters[i].title, [[chapter title] UTF8String]);
if (i + 1 < chapterCount && sum < refTrackDuration) { if (i + 1 < chapterCount && sum < refTrackDuration) {
SBTextSample * nextChapter = [chapters objectAtIndex:i+1]; MP42TextSample * nextChapter = [chapters objectAtIndex:i+1];
fileChapters[i].duration = nextChapter.timestamp - chapter.timestamp; fileChapters[i].duration = nextChapter.timestamp - chapter.timestamp;
sum = nextChapter.timestamp; sum = nextChapter.timestamp;
} }
@@ -232,7 +232,7 @@
NSMutableString* file = [[[NSMutableString alloc] init] autorelease]; NSMutableString* file = [[[NSMutableString alloc] init] autorelease];
NSUInteger x = 0; NSUInteger x = 0;
for (SBTextSample * chapter in chapters) { for (MP42TextSample * chapter in chapters) {
[file appendFormat:@"CHAPTER%02lu=%@\nCHAPTER%02luNAME=%@\n", (unsigned long)x, SRTStringFromTime([chapter timestamp], 1000, '.'), (unsigned long)x, [chapter title]]; [file appendFormat:@"CHAPTER%02lu=%@\nCHAPTER%02luNAME=%@\n", (unsigned long)x, SRTStringFromTime([chapter timestamp], 1000, '.'), (unsigned long)x, [chapter title]];
x++; x++;
} }
+3 -3
View File
@@ -660,7 +660,7 @@ NSString * const MP42OrganizeAlternateGroups = @"MP42AlternateGroups";
NSDictionary *attributes = [NSDictionary dictionaryWithObject:QTMovieFrameImageTypeNSImage forKey:QTMovieFrameImageType]; NSDictionary *attributes = [NSDictionary dictionaryWithObject:QTMovieFrameImageTypeNSImage forKey:QTMovieFrameImageType];
NSMutableArray *images = [[NSMutableArray alloc] initWithCapacity:[chapters count]]; NSMutableArray *images = [[NSMutableArray alloc] initWithCapacity:[chapters count]];
for (SBTextSample *chapter in chapters) { for (MP42TextSample *chapter in chapters) {
QTTime chapterTime = { QTTime chapterTime = {
[chapter timestamp] + 1500, // Add a short offset, hopefully we will get a better image [chapter timestamp] + 1500, // Add a short offset, hopefully we will get a better image
1000, // if there is a fade 1000, // if there is a fade
@@ -700,7 +700,7 @@ NSString * const MP42OrganizeAlternateGroups = @"MP42AlternateGroups";
generator.requestedTimeToleranceBefore = kCMTimeZero; generator.requestedTimeToleranceBefore = kCMTimeZero;
generator.requestedTimeToleranceAfter = kCMTimeZero; generator.requestedTimeToleranceAfter = kCMTimeZero;
for (SBTextSample * chapter in chapters) { for (MP42TextSample * chapter in chapters) {
CMTime time = CMTimeMake([chapter timestamp] + 1800, 1000); CMTime time = CMTimeMake([chapter timestamp] + 1800, 1000);
CGImageRef imgRef = [generator copyCGImageAtTime:time actualTime:NULL error:NULL]; CGImageRef imgRef = [generator copyCGImageAtTime:time actualTime:NULL error:NULL];
if (imgRef) { if (imgRef) {
@@ -783,7 +783,7 @@ NSString * const MP42OrganizeAlternateGroups = @"MP42AlternateGroups";
NSUInteger idx = 0; NSUInteger idx = 0;
MP4Duration duration = 0; MP4Duration duration = 0;
for (SBTextSample *chapterT in [chapterTrack chapters]) { for (MP42TextSample *chapterT in [chapterTrack chapters]) {
duration = MP4GetSampleDuration(_fileHandle, chapterTrack.Id, idx + 1); duration = MP4GetSampleDuration(_fileHandle, chapterTrack.Id, idx + 1);
// Scale the image. // Scale the image.
+2
View File
@@ -14,6 +14,8 @@
#import "mp4v2.h" #import "mp4v2.h"
#import "MP42Track_Muxer.h"
@class MP42Sample; @class MP42Sample;
@class MP42Metadata; @class MP42Metadata;
@class MP42Track; @class MP42Track;
+2
View File
@@ -18,6 +18,8 @@
#import "MP42Track.h" #import "MP42Track.h"
#import "MP42Fifo.h" #import "MP42Fifo.h"
#import "MP42Track_Muxer.h"
#if !__LP64__ #if !__LP64__
#import "MP42QTImporter.h" #import "MP42QTImporter.h"
#endif #endif
+1 -10
View File
@@ -8,18 +8,9 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <UniversalDetector.h> #import <UniversalDetector.h>
#import "MP42TextSample.h"
#import "mp4v2.h" #import "mp4v2.h"
@interface SBTextSample : NSObject <NSCoding> {
MP4Duration timestamp;
NSString *title;
}
@property(readwrite, retain) NSString *title;
@property(readwrite) MP4Duration timestamp;
@end
@interface SBSubLine : NSObject @interface SBSubLine : NSObject
{ {
@public @public
+2 -43
View File
@@ -12,47 +12,6 @@
#import "RegexKitLite.h" #import "RegexKitLite.h"
@implementation SBTextSample
-(NSComparisonResult)compare:(SBTextSample *)otherObject
{
MP4Duration otherTimestamp = [otherObject timestamp];
if (timestamp < otherTimestamp)
return NSOrderedAscending;
else if (timestamp > otherTimestamp)
return NSOrderedDescending;
return NSOrderedSame;
}
-(void) dealloc
{
[title release];
[super dealloc];
}
@synthesize timestamp;
@synthesize title;
- (void)encodeWithCoder:(NSCoder *)coder
{
[coder encodeInt64:timestamp forKey:@"timestamp"];
[coder encodeObject:title forKey:@"title"];
}
- (id)initWithCoder:(NSCoder *)decoder
{
self = [super init];
timestamp = [decoder decodeInt64ForKey:@"timestamp"];
title = [[decoder decodeObjectForKey:@"title"] retain];
return self;
}
@end
@implementation SBSubSerializer @implementation SBSubSerializer
-(id)init -(id)init
{ {
@@ -518,7 +477,7 @@ int LoadChaptersFromPath(NSString *path, NSMutableArray *ss)
res = [NSString stringWithFormat:@"Chapter %d", count]; res = [NSString stringWithFormat:@"Chapter %d", count];
[sc scanString:@"\n" intoString:nil]; [sc scanString:@"\n" intoString:nil];
SBTextSample *chapter = [[SBTextSample alloc] init]; MP42TextSample *chapter = [[MP42TextSample alloc] init];
chapter.timestamp = time; chapter.timestamp = time;
chapter.title = res; chapter.title = res;
@@ -548,7 +507,7 @@ int LoadChaptersFromPath(NSString *path, NSMutableArray *ss)
[sc scanString:@"\n" intoString:nil]; [sc scanString:@"\n" intoString:nil];
SBTextSample *chapter = [[SBTextSample alloc] init]; MP42TextSample *chapter = [[MP42TextSample alloc] init];
chapter.timestamp = time; chapter.timestamp = time;
chapter.title = res; chapter.title = res;
+21
View File
@@ -0,0 +1,21 @@
//
// SBTextSample.h
// MP42
//
// Created by Damiano Galassi on 01/11/13.
// Copyright (c) 2013 Damiano Galassi. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "MP42MediaFormat.h"
@interface MP42TextSample : NSObject <NSCoding> {
MP42Duration timestamp;
NSString *title;
}
@property(readwrite, retain) NSString *title;
@property(readwrite) MP42Duration timestamp;
@end
+50
View File
@@ -0,0 +1,50 @@
//
// SBTextSample.m
// MP42
//
// Created by Damiano Galassi on 01/11/13.
// Copyright (c) 2013 Damiano Galassi. All rights reserved.
//
#import "MP42TextSample.h"
@implementation MP42TextSample
-(NSComparisonResult)compare:(MP42TextSample *)otherObject
{
MP42Duration otherTimestamp = [otherObject timestamp];
if (timestamp < otherTimestamp)
return NSOrderedAscending;
else if (timestamp > otherTimestamp)
return NSOrderedDescending;
return NSOrderedSame;
}
-(void) dealloc
{
[title release];
[super dealloc];
}
@synthesize timestamp;
@synthesize title;
- (void)encodeWithCoder:(NSCoder *)coder
{
[coder encodeInt64:timestamp forKey:@"timestamp"];
[coder encodeObject:title forKey:@"title"];
}
- (id)initWithCoder:(NSCoder *)decoder
{
self = [super init];
timestamp = [decoder decodeInt64ForKey:@"timestamp"];
title = [[decoder decodeObjectForKey:@"title"] retain];
return self;
}
@end
-15
View File
@@ -14,18 +14,6 @@
@class MP42SampleBuffer; @class MP42SampleBuffer;
@class MP42Fifo; @class MP42Fifo;
typedef struct muxer_helper {
// Input helpers
MP42FileImporter *importer;
id demuxer_context;
// Output helpers
id <MP42ConverterProtocol> converter;
MP42Fifo *fifo;
BOOL done;
} muxer_helper;
@interface MP42Track : NSObject <NSCoding, NSCopying> { @interface MP42Track : NSObject <NSCoding, NSCopying> {
MP42TrackId _Id; MP42TrackId _Id;
MP42TrackId _sourceId; MP42TrackId _sourceId;
@@ -52,7 +40,6 @@ typedef struct muxer_helper {
MP42Duration _duration; MP42Duration _duration;
NSMutableDictionary *_updatedProperty; NSMutableDictionary *_updatedProperty;
muxer_helper *_helper;
} }
- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP42FileHandle)fileHandle; - (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP42FileHandle)fileHandle;
@@ -88,6 +75,4 @@ typedef struct muxer_helper {
@property(nonatomic, readwrite) uint64_t dataLength; @property(nonatomic, readwrite) uint64_t dataLength;
@property(nonatomic, readonly) muxer_helper *muxer_helper;
@end @end
+9 -2
View File
@@ -13,6 +13,15 @@
#import "MP42Fifo.h" #import "MP42Fifo.h"
#import "SBLanguages.h" #import "SBLanguages.h"
#import "MP42Track_Muxer.h"
@interface MP42Track () {
muxer_helper *_helper;
}
@end
@implementation MP42Track @implementation MP42Track
- (instancetype)init - (instancetype)init
@@ -333,8 +342,6 @@
@synthesize dataLength = _size; @synthesize dataLength = _size;
@synthesize mediaType = _mediaType; @synthesize mediaType = _mediaType;
@synthesize muxer_helper = _helper;
- (muxer_helper *)muxer_helper - (muxer_helper *)muxer_helper
{ {
if (_helper == NULL) if (_helper == NULL)
+30
View File
@@ -0,0 +1,30 @@
//
// MP42Track_MP42Track_Muxer.h
// MP42
//
// Created by Damiano Galassi on 01/11/13.
// Copyright (c) 2013 Damiano Galassi. All rights reserved.
//
#import "MP42Track.h"
#import "MP42FileImporter.h"
#import "MP42Fifo.h"
#import "MP42ConverterProtocol.h"
typedef struct muxer_helper {
// Input helpers
MP42FileImporter *importer;
id demuxer_context;
// Output helpers
id <MP42ConverterProtocol> converter;
MP42Fifo *fifo;
BOOL done;
} muxer_helper;
@interface MP42Track (MP42TrackMuxerExtentions)
@property(nonatomic, readonly) muxer_helper *muxer_helper;
@end