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
+34 -36

No files matched your search

+3 -3
View File
@@ -719,10 +719,10 @@ static bool GetFirstHeader(FILE* inFile)
newTrack.sourceURL = _fileURL;
if (!inFile)
inFile = fopen([[_fileURL path] UTF8String], "rb");
inFile = fopen([[_fileURL path] fileSystemRepresentation], "rb");
struct stat st;
stat([[_fileURL path] UTF8String], &st);
stat([[_fileURL path] fileSystemRepresentation], &st);
size = st.st_size * 8;
// collect all the necessary meta information
@@ -822,7 +822,7 @@ static bool GetFirstHeader(FILE* inFile)
{
@autoreleasepool {
if (!inFile)
inFile = fopen([[_fileURL path] UTF8String], "rb");
inFile = fopen([[_fileURL path] fileSystemRepresentation], "rb");
MP4TrackId trackId = [[_inputTracks lastObject] sourceId];
+3 -3
View File
@@ -266,10 +266,10 @@ static bool GetFirstHeader(FILE* inFile)
newTrack.sourceURL = _fileURL;
if (!inFile)
inFile = fopen([[_fileURL path] UTF8String], "rb");
inFile = fopen([[_fileURL path] fileSystemRepresentation], "rb");
struct stat st;
stat([[_fileURL path] UTF8String], &st);
stat([[_fileURL path] fileSystemRepresentation], &st);
size = st.st_size * 8;
// collect all the necessary meta information
@@ -340,7 +340,7 @@ static bool GetFirstHeader(FILE* inFile)
{
@autoreleasepool {
if (!inFile)
inFile = fopen([[_fileURL path] UTF8String], "rb");
inFile = fopen([[_fileURL path] fileSystemRepresentation], "rb");
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 {
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) {
self.status = MP42StatusReading;
@@ -124,7 +124,7 @@ static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap)
- (BOOL)startWriting {
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) {
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];
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;
});
@@ -660,7 +660,7 @@ static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap)
supportedBrandsCount = 2;
}
self.fileHandle = MP4CreateEx([[self.URL path] UTF8String],
self.fileHandle = MP4CreateEx([[self.URL path] fileSystemRepresentation],
flags, 1, 1,
majorBrand, 0,
supportedBrands, supportedBrandsCount);
@@ -818,11 +818,10 @@ static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap)
MP4SetTrackIntegerProperty(self.fileHandle, jpegTrack, "tkhd.layer", 1);
MP4SetTrackDisabled(self.fileHandle, jpegTrack);
NSUInteger idx = 0;
MP4Duration duration = 0;
NSUInteger idx = 1;
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;
@@ -861,7 +860,6 @@ static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap)
duration,
0,
true);
idx++;
}
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);
MP4SetTrackDisabled(self.fileHandle, jpegTrack);
NSUInteger idx = 0;
MP4Duration duration = 0;
for (MP42TextSample *chapterT in [chapterTrack chapters]) {
duration = MP4GetSampleDuration(self.fileHandle, chapterTrack.Id, idx + 1);
for (NSUInteger idx = 0; idx < [[chapterTrack chapters] count]; idx++) {
MP4Duration duration = MP4GetSampleDuration(self.fileHandle, chapterTrack.Id, idx + 1);
// Scale the image.
NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
@@ -977,8 +972,9 @@ static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap)
[[NSColor blackColor] set];
NSRectFill(rect);
if (idx < [images count])
if (idx < [images count]) {
[[images objectAtIndex:idx] drawInRect:rect fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0];
}
[NSGraphicsContext restoreGraphicsState];
@@ -992,7 +988,6 @@ static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap)
duration,
0,
true);
idx++;
}
MP4RemoveAllTrackReferences(self.fileHandle, "tref.chap", refTrack.Id);
@@ -1004,6 +999,7 @@ static void logCallback(MP4LogLevel loglevel, const char* fmt, va_list ap)
}
return YES;
} else if (chapterTrack && jpegTrack) {
// We already have all the tracks, so hook them up.
if (![self startWriting])
+5 -5
View File
@@ -24,7 +24,7 @@ static const framerate_t framerates[] =
{ 60, 600, 10 },
{ 0, 24000, 1001 } };
static const framerate_t framerates_thousand[] =
/*static const framerate_t framerates_thousand[] =
{ { 2398, 24000, 1001 },
{ 2400, 600, 25 },
{ 2500, 600, 24 },
@@ -33,7 +33,7 @@ static const framerate_t framerates_thousand[] =
{ 5000, 600, 12 },
{ 5994, 60000, 1001 },
{ 6000, 600, 10 },
{ 0, 24000, 1001 } };
{ 0, 24000, 1001 } };*/
typedef struct h264_decode_t {
uint8_t profile;
@@ -1363,10 +1363,10 @@ NSData* H264Info(const char *filePath, uint32_t *pic_width, uint32_t *pic_height
newTrack.sourceURL = _fileURL;
if (!inFile)
inFile = fopen([[_fileURL path] UTF8String], "rb");
inFile = fopen([[_fileURL path] fileSystemRepresentation], "rb");
struct stat st;
stat([[_fileURL path] UTF8String], &st);
stat([[_fileURL path] fileSystemRepresentation], &st);
_size = st.st_size;
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];
if (!inFile)
inFile = fopen([[_fileURL path] UTF8String], "rb");
inFile = fopen([[_fileURL path] fileSystemRepresentation], "rb");
MP42Track *track = [_inputTracks lastObject];
MP4TrackId trackId = [track sourceId];
+11 -9
View File
@@ -167,7 +167,7 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t
return nil;
}
//SegmentInfo *info = mkv_GetFileInfo(matroskaFile);
//SegmentInfo *info = mkv_GetFileInfo(_matroskaFile);
uint64_t *trackSizes = [self copyGuessedTrackDataLength];
NSInteger trackCount = mkv_GetNumTracks(_matroskaFile);
@@ -238,7 +238,7 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t
newTrack.startOffset = [self matroskaTrackStartTime:mkvTrack Id:i];
if ([newTrack.format isEqualToString:MP42VideoFormatH264]) {
uint8_t* avcCAtom = (uint8_t *)malloc(mkvTrack->CodecPrivateSize); // mkv stores h.264 avcC in CodecPrivate
uint8_t *avcCAtom = (uint8_t *)malloc(mkvTrack->CodecPrivateSize); // mkv stores h.264 avcC in CodecPrivate
memcpy(avcCAtom, mkvTrack->CodecPrivate, mkvTrack->CodecPrivateSize);
if (mkvTrack->CodecPrivateSize >= 3) {
[(MP42VideoTrack*)newTrack setOrigProfile:avcCAtom[1]];
@@ -505,9 +505,7 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t
[magicCookie appendBytes:aac length:2];
return [magicCookie autorelease];
}
if (!strcmp(trackInfo->CodecID, "A_AC3")) {
} else if (!strcmp(trackInfo->CodecID, "A_AC3")) {
mkv_SetTrackMask(_matroskaFile, ~(1 << [track sourceId]));
uint64_t StartTime, EndTime, FilePos;
@@ -556,8 +554,7 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t
}
else
return nil;
}
else if (!strcmp(trackInfo->CodecID, "S_VOBSUB")) {
} else if (!strcmp(trackInfo->CodecID, "S_VOBSUB")) {
char *string = (char *) trackInfo->CodecPrivate;
char *palette = strnstr(string, "palette:", trackInfo->CodecPrivateSize);
@@ -573,7 +570,7 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t
return [NSData dataWithBytes:colorPalette length:sizeof(UInt32)*16];
}
NSData * magicCookie = [NSData dataWithBytes:trackInfo->CodecPrivate length:trackInfo->CodecPrivateSize];
NSData *magicCookie = [NSData dataWithBytes:trackInfo->CodecPrivate length:trackInfo->CodecPrivateSize];
if (magicCookie)
return magicCookie;
@@ -620,6 +617,10 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t
}
}
if (!demuxHelper) {
continue;
}
TrackInfo *trackInfo = mkv_GetTrackInfo(_matroskaFile, Track);
if (trackInfo->Type == TT_AUDIO) {
@@ -647,8 +648,9 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t
demuxHelper->ss = [[SBSubSerializer alloc] init];
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);
}
if ([string length]) {
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)
progress += [importerHelper progress];
progress = progress /= tracksImportersCount;
progress /= tracksImportersCount;
[_delegate progressStatus:progress];
}