Cosmetics.
This commit is contained in:
1 parent
53c3bb45f8
commit
85eb58a521
1 file changed
+11
-11
+11
-11
@@ -264,13 +264,13 @@ static NSArray* LoadVobSubSubtitles(NSURL *theDirectory, NSString *filename)
|
|||||||
return NSMakeSize([(MP42SubtitleTrack*)track trackWidth], [(MP42SubtitleTrack*) track trackHeight]);
|
return NSMakeSize([(MP42SubtitleTrack*)track trackWidth], [(MP42SubtitleTrack*) track trackHeight]);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSData*)magicCookieForTrack:(MP42Track *)track
|
- (NSData *)magicCookieForTrack:(MP42Track *)track
|
||||||
{
|
{
|
||||||
SBVobSubTrack *vobTrack = [_VobSubTracks objectAtIndex:track.sourceId];
|
SBVobSubTrack *vobTrack = [_VobSubTracks objectAtIndex:track.sourceId];
|
||||||
NSMutableData *magicCookie = nil;
|
NSMutableData *magicCookie = nil;
|
||||||
|
|
||||||
for (NSString *line in vobTrack->privateData) {
|
for (NSString *line in vobTrack->privateData) {
|
||||||
if([line hasPrefix:@"palette: "]) {
|
if ([line hasPrefix:@"palette: "]) {
|
||||||
const char *palette = [line UTF8String];
|
const char *palette = [line UTF8String];
|
||||||
UInt32 colorPalette[16];
|
UInt32 colorPalette[16];
|
||||||
|
|
||||||
@@ -290,7 +290,7 @@ static NSArray* LoadVobSubSubtitles(NSURL *theDirectory, NSString *filename)
|
|||||||
|
|
||||||
- (void)demux:(id)sender
|
- (void)demux:(id)sender
|
||||||
{
|
{
|
||||||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSURL *subFileURL = [[_fileURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"sub"];
|
NSURL *subFileURL = [[_fileURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"sub"];
|
||||||
|
|
||||||
NSData *subFileData = [NSData dataWithContentsOfURL:subFileURL];
|
NSData *subFileData = [NSData dataWithContentsOfURL:subFileURL];
|
||||||
@@ -309,12 +309,12 @@ static NSArray* LoadVobSubSubtitles(NSURL *theDirectory, NSString *filename)
|
|||||||
SBVobSubSample *currentSample = [vobTrack->samples objectAtIndex:i];
|
SBVobSubSample *currentSample = [vobTrack->samples objectAtIndex:i];
|
||||||
int offset = currentSample->fileOffset;
|
int offset = currentSample->fileOffset;
|
||||||
int nextOffset;
|
int nextOffset;
|
||||||
if(i == sampleCount - 1)
|
if (i == sampleCount - 1)
|
||||||
nextOffset = [subFileData length];
|
nextOffset = [subFileData length];
|
||||||
else
|
else
|
||||||
nextOffset = ((SBVobSubSample *)[vobTrack->samples objectAtIndex:i+1])->fileOffset;
|
nextOffset = ((SBVobSubSample *)[vobTrack->samples objectAtIndex:i+1])->fileOffset;
|
||||||
int size = nextOffset - offset;
|
int size = nextOffset - offset;
|
||||||
if(size < 0)
|
if (size < 0)
|
||||||
//Skip samples for which we cannot determine size
|
//Skip samples for which we cannot determine size
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -325,7 +325,7 @@ static NSArray* LoadVobSubSubtitles(NSURL *theDirectory, NSString *filename)
|
|||||||
|
|
||||||
uint16_t startTimestamp, endTimestamp;
|
uint16_t startTimestamp, endTimestamp;
|
||||||
uint8_t forced;
|
uint8_t forced;
|
||||||
if(!ReadPacketTimes(extracted, extractedSize, &startTimestamp, &endTimestamp, &forced)) {
|
if (!ReadPacketTimes(extracted, extractedSize, &startTimestamp, &endTimestamp, &forced)) {
|
||||||
free(extracted);
|
free(extracted);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -334,21 +334,21 @@ static NSArray* LoadVobSubSubtitles(NSURL *theDirectory, NSString *filename)
|
|||||||
uint32_t endTime = currentSample->timeStamp + endTimestamp;
|
uint32_t endTime = currentSample->timeStamp + endTimestamp;
|
||||||
|
|
||||||
int duration = endTimestamp - startTimestamp;
|
int duration = endTimestamp - startTimestamp;
|
||||||
if(duration <= 0 && i < sampleCount - 1) {
|
if (duration <= 0 && i < sampleCount - 1) {
|
||||||
//Sample with no end duration, use the duration of the next one
|
//Sample with no end duration, use the duration of the next one
|
||||||
endTime = ((SBVobSubSample *)[vobTrack->samples objectAtIndex:i+1])->timeStamp;
|
endTime = ((SBVobSubSample *)[vobTrack->samples objectAtIndex:i+1])->timeStamp;
|
||||||
duration = endTime - startTime;
|
duration = endTime - startTime;
|
||||||
}
|
}
|
||||||
if(duration <= 0) {
|
if (duration <= 0) {
|
||||||
//Skip samples which are broken
|
//Skip samples which are broken
|
||||||
free(extracted);
|
free(extracted);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(firstSample == nil) {
|
if (firstSample == nil) {
|
||||||
currentSample->timeStamp = startTime;
|
currentSample->timeStamp = startTime;
|
||||||
firstSample = currentSample;
|
firstSample = currentSample;
|
||||||
}
|
}
|
||||||
if(lastTime != startTime) {
|
if (lastTime != startTime) {
|
||||||
//insert a sample with no real data, to clear the subs
|
//insert a sample with no real data, to clear the subs
|
||||||
MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init];
|
MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init];
|
||||||
sample->size = 2;
|
sample->size = 2;
|
||||||
@@ -397,7 +397,7 @@ static NSArray* LoadVobSubSubtitles(NSURL *theDirectory, NSString *filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
[_VobSubTracks release];
|
[_VobSubTracks release];
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user