Use NSString’s fileSystemRepresentation where possible and fixed some clang static analyzer warning.

This commit is contained in:
Damiano Galassi committed 2014-02-15 08:29:00 +01:00
1 parent 70095c73a7
commit 86b600b6a6
6 files changed
+32 -34

No files matched your search

+3 -3
View File
@@ -719,10 +719,10 @@ static bool GetFirstHeader(FILE* inFile)
newTrack.sourceURL = _fileURL; newTrack.sourceURL = _fileURL;
if (!inFile) if (!inFile)
inFile = fopen([[_fileURL path] UTF8String], "rb"); inFile = fopen([[_fileURL path] fileSystemRepresentation], "rb");
struct stat st; struct stat st;
stat([[_fileURL path] UTF8String], &st); stat([[_fileURL path] fileSystemRepresentation], &st);
size = st.st_size * 8; size = st.st_size * 8;
// collect all the necessary meta information // collect all the necessary meta information
@@ -822,7 +822,7 @@ static bool GetFirstHeader(FILE* inFile)
{ {
@autoreleasepool { @autoreleasepool {
if (!inFile) if (!inFile)
inFile = fopen([[_fileURL path] UTF8String], "rb"); inFile = fopen([[_fileURL path] fileSystemRepresentation], "rb");
MP4TrackId trackId = [[_inputTracks lastObject] sourceId]; MP4TrackId trackId = [[_inputTracks lastObject] sourceId];
+3 -3
View File
@@ -266,10 +266,10 @@ static bool GetFirstHeader(FILE* inFile)
newTrack.sourceURL = _fileURL; newTrack.sourceURL = _fileURL;
if (!inFile) if (!inFile)
inFile = fopen([[_fileURL path] UTF8String], "rb"); inFile = fopen([[_fileURL path] fileSystemRepresentation], "rb");
struct stat st; struct stat st;
stat([[_fileURL path] UTF8String], &st); stat([[_fileURL path] fileSystemRepresentation], &st);
size = st.st_size * 8; size = st.st_size * 8;
// collect all the necessary meta information // collect all the necessary meta information
@@ -340,7 +340,7 @@ static bool GetFirstHeader(FILE* inFile)
{ {
@autoreleasepool { @autoreleasepool {
if (!inFile) if (!inFile)
inFile = fopen([[_fileURL path] UTF8String], "rb"); inFile = fopen([[_fileURL path] fileSystemRepresentation], "rb");
MP4TrackId trackId = [[_inputTracks lastObject] sourceId]; MP4TrackId trackId = [[_inputTracks lastObject] sourceId];
+11 -15
View File
@@ -105,7 +105,7 @@ static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap)
- (BOOL)startReading { - (BOOL)startReading {
NSAssert(self.fileHandle == MP4_INVALID_FILE_HANDLE, @"File Handle already open"); NSAssert(self.fileHandle == MP4_INVALID_FILE_HANDLE, @"File Handle already open");
_fileHandle = MP4Read([[self.URL path] UTF8String]); _fileHandle = MP4Read([[self.URL path] fileSystemRepresentation]);
if (self.fileHandle != MP4_INVALID_FILE_HANDLE) { if (self.fileHandle != MP4_INVALID_FILE_HANDLE) {
self.status = MP42StatusReading; self.status = MP42StatusReading;
@@ -124,7 +124,7 @@ static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap)
- (BOOL)startWriting { - (BOOL)startWriting {
NSAssert(self.fileHandle == MP4_INVALID_FILE_HANDLE, @"File Handle already open"); NSAssert(self.fileHandle == MP4_INVALID_FILE_HANDLE, @"File Handle already open");
_fileHandle = MP4Modify([[self.URL path] UTF8String], 0); _fileHandle = MP4Modify([[self.URL path] fileSystemRepresentation], 0);
if (self.fileHandle != MP4_INVALID_FILE_HANDLE) { if (self.fileHandle != MP4_INVALID_FILE_HANDLE) {
self.status = MP42StatusWriting; self.status = MP42StatusWriting;
@@ -537,7 +537,7 @@ static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap)
unsigned long long originalFileSize = [[[fileManager attributesOfItemAtPath:[self.URL path] error:nil] valueForKey:NSFileSize] unsignedLongLongValue]; unsigned long long originalFileSize = [[[fileManager attributesOfItemAtPath:[self.URL path] error:nil] valueForKey:NSFileSize] unsignedLongLongValue];
dispatch_async(dispatch_get_global_queue(0, 0), ^{ dispatch_async(dispatch_get_global_queue(0, 0), ^{
noErr = MP4Optimize([[self.URL path] UTF8String], [[tempURL path] UTF8String]); noErr = MP4Optimize([[self.URL path] fileSystemRepresentation], [[tempURL path] fileSystemRepresentation]);
done = YES; done = YES;
}); });
@@ -660,7 +660,7 @@ static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap)
supportedBrandsCount = 2; supportedBrandsCount = 2;
} }
self.fileHandle = MP4CreateEx([[self.URL path] UTF8String], self.fileHandle = MP4CreateEx([[self.URL path] fileSystemRepresentation],
flags, 1, 1, flags, 1, 1,
majorBrand, 0, majorBrand, 0,
supportedBrands, supportedBrandsCount); supportedBrands, supportedBrandsCount);
@@ -818,11 +818,10 @@ static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap)
MP4SetTrackIntegerProperty(self.fileHandle, jpegTrack, "tkhd.layer", 1); MP4SetTrackIntegerProperty(self.fileHandle, jpegTrack, "tkhd.layer", 1);
MP4SetTrackDisabled(self.fileHandle, jpegTrack); MP4SetTrackDisabled(self.fileHandle, jpegTrack);
NSUInteger idx = 0; NSUInteger idx = 1;
MP4Duration duration = 0;
for (MP42TextSample *chapterT in [chapterTrack chapters]) { for (MP42TextSample *chapterT in [chapterTrack chapters]) {
duration = MP4GetSampleDuration(self.fileHandle, chapterTrack.Id, idx + 1); MP4Duration duration = MP4GetSampleDuration(self.fileHandle, chapterTrack.Id, idx++);
NSData *imageData = chapterT.image.data; NSData *imageData = chapterT.image.data;
@@ -861,7 +860,6 @@ static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap)
duration, duration,
0, 0,
true); true);
idx++;
} }
MP4RemoveAllTrackReferences(self.fileHandle, "tref.chap", videoTrack.Id); MP4RemoveAllTrackReferences(self.fileHandle, "tref.chap", videoTrack.Id);
@@ -953,11 +951,8 @@ static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap)
MP4SetTrackIntegerProperty(self.fileHandle, jpegTrack, "tkhd.layer", 1); MP4SetTrackIntegerProperty(self.fileHandle, jpegTrack, "tkhd.layer", 1);
MP4SetTrackDisabled(self.fileHandle, jpegTrack); MP4SetTrackDisabled(self.fileHandle, jpegTrack);
NSUInteger idx = 0; for (NSUInteger idx = 0; idx < [[chapterTrack chapters] count]; idx++) {
MP4Duration duration = 0; MP4Duration duration = MP4GetSampleDuration(self.fileHandle, chapterTrack.Id, idx + 1);
for (MP42TextSample *chapterT in [chapterTrack chapters]) {
duration = MP4GetSampleDuration(self.fileHandle, chapterTrack.Id, idx + 1);
// Scale the image. // Scale the image.
NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
@@ -977,8 +972,9 @@ static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap)
[[NSColor blackColor] set]; [[NSColor blackColor] set];
NSRectFill(rect); NSRectFill(rect);
if (idx < [images count]) if (idx < [images count]) {
[[images objectAtIndex:idx] drawInRect:rect fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0]; [[images objectAtIndex:idx] drawInRect:rect fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0];
}
[NSGraphicsContext restoreGraphicsState]; [NSGraphicsContext restoreGraphicsState];
@@ -992,7 +988,6 @@ static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap)
duration, duration,
0, 0,
true); true);
idx++;
} }
MP4RemoveAllTrackReferences(self.fileHandle, "tref.chap", refTrack.Id); MP4RemoveAllTrackReferences(self.fileHandle, "tref.chap", refTrack.Id);
@@ -1004,6 +999,7 @@ static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap)
} }
return YES; return YES;
} else if (chapterTrack && jpegTrack) { } else if (chapterTrack && jpegTrack) {
// We already have all the tracks, so hook them up. // We already have all the tracks, so hook them up.
if (![self startWriting]) if (![self startWriting])
+5 -5
View File
@@ -24,7 +24,7 @@ static const framerate_t framerates[] =
{ 60, 600, 10 }, { 60, 600, 10 },
{ 0, 24000, 1001 } }; { 0, 24000, 1001 } };
static const framerate_t framerates_thousand[] = /*static const framerate_t framerates_thousand[] =
{ { 2398, 24000, 1001 }, { { 2398, 24000, 1001 },
{ 2400, 600, 25 }, { 2400, 600, 25 },
{ 2500, 600, 24 }, { 2500, 600, 24 },
@@ -33,7 +33,7 @@ static const framerate_t framerates_thousand[] =
{ 5000, 600, 12 }, { 5000, 600, 12 },
{ 5994, 60000, 1001 }, { 5994, 60000, 1001 },
{ 6000, 600, 10 }, { 6000, 600, 10 },
{ 0, 24000, 1001 } }; { 0, 24000, 1001 } };*/
typedef struct h264_decode_t { typedef struct h264_decode_t {
uint8_t profile; uint8_t profile;
@@ -1363,10 +1363,10 @@ NSData* H264Info(const char *filePath, uint32_t *pic_width, uint32_t *pic_height
newTrack.sourceURL = _fileURL; newTrack.sourceURL = _fileURL;
if (!inFile) if (!inFile)
inFile = fopen([[_fileURL path] UTF8String], "rb"); inFile = fopen([[_fileURL path] fileSystemRepresentation], "rb");
struct stat st; struct stat st;
stat([[_fileURL path] UTF8String], &st); stat([[_fileURL path] fileSystemRepresentation], &st);
_size = st.st_size; _size = st.st_size;
uint32_t tw, th; uint32_t tw, th;
@@ -1416,7 +1416,7 @@ NSData* H264Info(const char *filePath, uint32_t *pic_width, uint32_t *pic_height
{ {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
if (!inFile) if (!inFile)
inFile = fopen([[_fileURL path] UTF8String], "rb"); inFile = fopen([[_fileURL path] fileSystemRepresentation], "rb");
MP42Track *track = [_inputTracks lastObject]; MP42Track *track = [_inputTracks lastObject];
MP4TrackId trackId = [track sourceId]; MP4TrackId trackId = [track sourceId];
+9 -7
View File
@@ -167,7 +167,7 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t
return nil; return nil;
} }
//SegmentInfo *info = mkv_GetFileInfo(matroskaFile); //SegmentInfo *info = mkv_GetFileInfo(_matroskaFile);
uint64_t *trackSizes = [self copyGuessedTrackDataLength]; uint64_t *trackSizes = [self copyGuessedTrackDataLength];
NSInteger trackCount = mkv_GetNumTracks(_matroskaFile); NSInteger trackCount = mkv_GetNumTracks(_matroskaFile);
@@ -505,9 +505,7 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t
[magicCookie appendBytes:aac length:2]; [magicCookie appendBytes:aac length:2];
return [magicCookie autorelease]; return [magicCookie autorelease];
} } else if (!strcmp(trackInfo->CodecID, "A_AC3")) {
if (!strcmp(trackInfo->CodecID, "A_AC3")) {
mkv_SetTrackMask(_matroskaFile, ~(1 << [track sourceId])); mkv_SetTrackMask(_matroskaFile, ~(1 << [track sourceId]));
uint64_t StartTime, EndTime, FilePos; uint64_t StartTime, EndTime, FilePos;
@@ -556,8 +554,7 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t
} }
else else
return nil; return nil;
} } else if (!strcmp(trackInfo->CodecID, "S_VOBSUB")) {
else if (!strcmp(trackInfo->CodecID, "S_VOBSUB")) {
char *string = (char *) trackInfo->CodecPrivate; char *string = (char *) trackInfo->CodecPrivate;
char *palette = strnstr(string, "palette:", trackInfo->CodecPrivateSize); char *palette = strnstr(string, "palette:", trackInfo->CodecPrivateSize);
@@ -620,6 +617,10 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t
} }
} }
if (!demuxHelper) {
continue;
}
TrackInfo *trackInfo = mkv_GetTrackInfo(_matroskaFile, Track); TrackInfo *trackInfo = mkv_GetTrackInfo(_matroskaFile, Track);
if (trackInfo->Type == TT_AUDIO) { if (trackInfo->Type == TT_AUDIO) {
@@ -647,8 +648,9 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t
demuxHelper->ss = [[SBSubSerializer alloc] init]; demuxHelper->ss = [[SBSubSerializer alloc] init];
NSString *string = [[[NSString alloc] initWithBytes:frame length:FrameSize encoding:NSUTF8StringEncoding] autorelease]; NSString *string = [[[NSString alloc] initWithBytes:frame length:FrameSize encoding:NSUTF8StringEncoding] autorelease];
if (!strcmp(trackInfo->CodecID, "S_TEXT/ASS") || !strcmp(trackInfo->CodecID, "S_TEXT/SSA")) if (!strcmp(trackInfo->CodecID, "S_TEXT/ASS") || !strcmp(trackInfo->CodecID, "S_TEXT/SSA")) {
string = StripSSALine(string); string = StripSSALine(string);
}
if ([string length]) { if ([string length]) {
SBSubLine *sl = [[SBSubLine alloc] initWithLine:string start:StartTime/1000000 end:EndTime/1000000]; SBSubLine *sl = [[SBSubLine alloc] initWithLine:string start:StartTime/1000000 end:EndTime/1000000];
+1 -1
View File
@@ -411,7 +411,7 @@
for (id importerHelper in trackImportersArray) for (id importerHelper in trackImportersArray)
progress += [importerHelper progress]; progress += [importerHelper progress];
progress = progress /= tracksImportersCount; progress /= tracksImportersCount;
[_delegate progressStatus:progress]; [_delegate progressStatus:progress];
} }