From e5095a611ac14f3979eaea0d733798e0353db9d7 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Mon, 24 Aug 2015 17:32:42 +0200 Subject: [PATCH] Enabled more warnings, switched the deployment target to 10.7 and minor code cleanup --- MP42/MP42AACImporter.h | 5 +- MP42/MP42AC3Importer.h | 5 +- MP42/MP42AVFImporter.h | 2 + MP42/MP42AVFImporter.m | 13 ++- MP42/MP42AudioConverter.m | 18 ++-- MP42/MP42BitmapSubConverter.m | 6 +- MP42/MP42CCImporter.h | 6 +- MP42/MP42ChapterTrack.h | 2 +- MP42/MP42ChapterTrack.m | 15 +-- MP42/MP42File.m | 4 +- MP42/MP42FileImporter.h | 6 +- MP42/MP42FileImporter.m | 19 ++-- MP42/MP42H264Importer.h | 5 +- MP42/MP42HtmlParser.h | 16 +-- MP42/MP42Metadata.m | 22 ++-- MP42/MP42MkvImporter.h | 3 +- MP42/MP42MkvImporter.m | 20 ++-- MP42/MP42Mp4Importer.h | 3 +- MP42/MP42Mp4Importer.m | 12 +-- MP42/MP42Muxer.m | 18 ++-- MP42/MP42PrivateUtilities.m | 7 +- MP42/MP42QTImporter.h | 3 +- MP42/MP42Ratings.h | 17 +-- MP42/MP42Ratings.m | 4 +- MP42/MP42SrtImporter.h | 3 +- MP42/MP42SubUtilities.h | 2 +- MP42/MP42SubUtilities.m | 7 +- MP42/MP42VideoTrack.m | 12 +-- MP42/MP42VobSubImporter.h | 1 + MP42/MP42XMLReader.h | 6 +- MP42/QTKitDecrap.h | 125 +---------------------- MP42/muxer/MatroskaFile.h | 2 +- MP42Foundation.xcodeproj/project.pbxproj | 36 ++++--- 33 files changed, 167 insertions(+), 258 deletions(-) diff --git a/MP42/MP42AACImporter.h b/MP42/MP42AACImporter.h index d72635d..bdd72d6 100644 --- a/MP42/MP42AACImporter.h +++ b/MP42/MP42AACImporter.h @@ -10,11 +10,12 @@ #import "MP42FileImporter.h" @interface MP42AACImporter : MP42FileImporter { - FILE* inFile; +@private + FILE *inFile; int64_t size; NSMutableData *aacInfo; u_int32_t samplesPerSecond; } -@end \ No newline at end of file +@end diff --git a/MP42/MP42AC3Importer.h b/MP42/MP42AC3Importer.h index 1b89d3c..b93b45f 100644 --- a/MP42/MP42AC3Importer.h +++ b/MP42/MP42AC3Importer.h @@ -10,11 +10,12 @@ #import "MP42FileImporter.h" @interface MP42AC3Importer : MP42FileImporter { - FILE* inFile; +@private + FILE *inFile; int64_t size; NSMutableData *ac3Info; u_int32_t samplesPerSecond; } -@end \ No newline at end of file +@end diff --git a/MP42/MP42AVFImporter.h b/MP42/MP42AVFImporter.h index f9cf466..b3bafaf 100644 --- a/MP42/MP42AVFImporter.h +++ b/MP42/MP42AVFImporter.h @@ -8,9 +8,11 @@ #import #import "MP42FileImporter.h" + @class AVAsset; @interface MP42AVFImporter : MP42FileImporter { +@private AVAsset *_localAsset; } diff --git a/MP42/MP42AVFImporter.m b/MP42/MP42AVFImporter.m index 58c97df..97a10f0 100644 --- a/MP42/MP42AVFImporter.m +++ b/MP42/MP42AVFImporter.m @@ -184,7 +184,7 @@ MP42ChapterTrack *chapters = nil; // Checks if there is a chapter tracks - if ([tracks count]) { + if (tracks.count) { for (NSLocale *locale in availableChapter) { chapters = [[MP42ChapterTrack alloc] init]; NSArray *chapterList = [_localAsset chapterMetadataGroupsWithTitleLocale:locale containingItemsWithCommonKeys:nil]; @@ -670,7 +670,7 @@ } - (void)demux:(id)sender { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; BOOL success = YES; OSStatus err = noErr; @@ -702,8 +702,10 @@ } success = [assetReader startReading]; - if (!success) + + if (!success) { localError = [assetReader error]; + } for (MP42Track *track in _inputTracks) { demuxHelper = track.muxer_helper->demuxer_context; @@ -766,8 +768,9 @@ currentDataLength += sampleSize; } else { // The CMSampleBufferRef contains more than one sample - if (!CMSampleBufferDataIsReady(sampleBuffer)) + if (!CMSampleBufferDataIsReady(sampleBuffer)) { CMSampleBufferMakeDataReady(sampleBuffer); + } // A CMSampleBufferRef can contains an unknown number of samples, check how many needs to be divided to separated MP42SampleBuffers // First get the array with the timings for each sample @@ -918,7 +921,7 @@ AVFDemuxHelper *helper = inputTrack.muxer_helper->demuxer_context; - for (int i = 0; i < helper->editsConstructor.editsCount; i++) { + for (uint64_t i = 0; i < helper->editsConstructor.editsCount; i++) { CMTimeRange timeRange = helper->editsConstructor.edits[i]; CMTime duration = CMTimeConvertScale(timeRange.duration, timescale, kCMTimeRoundingMethod_Default); diff --git a/MP42/MP42AudioConverter.m b/MP42/MP42AudioConverter.m index a6d1741..c192719 100644 --- a/MP42/MP42AudioConverter.m +++ b/MP42/MP42AudioConverter.m @@ -182,14 +182,15 @@ OSStatus EncoderDataProc(AudioConverterRef inAudioConverter, if (!err && cookieSize) { char* cookie = (char *) malloc(cookieSize); UInt8* cookieBuffer; - int size; err = AudioConverterGetProperty(converterEnc, kAudioConverterCompressionMagicCookie, &cookieSize, cookie); if (err) { NSLog(@"err Get Cookie From AudioConverter"); } - ReadESDSDescExt(cookie, &cookieBuffer, &size, 1); - outputMagicCookie = [[NSData dataWithBytes:cookieBuffer length:size] retain]; + + int ESDSsize; + ReadESDSDescExt(cookie, &cookieBuffer, &ESDSsize, 1); + outputMagicCookie = [[NSData dataWithBytes:cookieBuffer length:ESDSsize] retain]; free(cookieBuffer); free(cookie); @@ -199,7 +200,7 @@ OSStatus EncoderDataProc(AudioConverterRef inAudioConverter, SInt64 outputPos = 0; while (1) { - AudioStreamPacketDescription odesc = {0}; + AudioStreamPacketDescription odesc = {0, 0, 0}; // set up output buffer list AudioBufferList fillBufList; @@ -208,8 +209,9 @@ OSStatus EncoderDataProc(AudioConverterRef inAudioConverter, fillBufList.mBuffers[0].mDataByteSize = theOutputBufSize; fillBufList.mBuffers[0].mData = outputBuffer; - while ((sfifo_used(&fifo) < (inputFormat.mBytesPerPacket * encoderFormat.mFramesPerPacket * 4)) && !readerDone) + while ((sfifo_used(&fifo) < (inputFormat.mBytesPerPacket * encoderFormat.mFramesPerPacket * 4)) && !readerDone) { usleep(500); + } // convert data UInt32 ioOutputDataPackets = 1; @@ -401,8 +403,9 @@ OSStatus DecoderDataProc(AudioConverterRef inAudioConverter, hb_sample_t *samples = (hb_sample_t *)malloc(samplesBufferSize); hb_downmix(downmix, samples, downmix_buffer, ioOutputDataPackets); - while (sfifo_space(&fifo) < (samplesBufferSize)) + while (sfifo_space(&fifo) < (samplesBufferSize)) { usleep(5000); + } sfifo_write(&fifo, samples, samplesBufferSize); free(samples); @@ -410,8 +413,9 @@ OSStatus DecoderDataProc(AudioConverterRef inAudioConverter, else { UInt32 inNumBytes = fillBufList.mBuffers[0].mDataByteSize; - while (sfifo_space(&fifo) < inNumBytes) + while (sfifo_space(&fifo) < inNumBytes) { usleep(5000); + } sfifo_write(&fifo, outputBuffer, inNumBytes); } diff --git a/MP42/MP42BitmapSubConverter.m b/MP42/MP42BitmapSubConverter.m index 91f97c1..32d695c 100644 --- a/MP42/MP42BitmapSubConverter.m +++ b/MP42/MP42BitmapSubConverter.m @@ -261,7 +261,7 @@ void FFInitFFmpeg() { if (!sampleBuffer) break; - int ret, got_sub, i; + int ret, got_sub; uint32_t *imageData; BOOL forced = NO; @@ -283,7 +283,7 @@ void FFInitFFmpeg() { continue; } - for (i = 0; i < subtitle.num_rects; i++) { + for (unsigned i = 0; i < subtitle.num_rects; i++) { AVSubtitleRect *rect = subtitle.rects[i]; NSString *text; @@ -447,7 +447,7 @@ void FFInitFFmpeg() { av_freep(&codecData); } if (subtitle.rects) { - for (int i = 0; i < subtitle.num_rects; i++) { + for (unsigned i = 0; i < subtitle.num_rects; i++) { av_freep(&subtitle.rects[i]->pict.data[0]); av_freep(&subtitle.rects[i]->pict.data[1]); av_freep(&subtitle.rects[i]); diff --git a/MP42/MP42CCImporter.h b/MP42/MP42CCImporter.h index 3c70db0..151fc03 100644 --- a/MP42/MP42CCImporter.h +++ b/MP42/MP42CCImporter.h @@ -9,7 +9,5 @@ #import #import "MP42FileImporter.h" -@interface MP42CCImporter : MP42FileImporter { -} - -@end \ No newline at end of file +@interface MP42CCImporter : MP42FileImporter +@end diff --git a/MP42/MP42ChapterTrack.h b/MP42/MP42ChapterTrack.h index 1fa0cb5..6d10be9 100644 --- a/MP42/MP42ChapterTrack.h +++ b/MP42/MP42ChapterTrack.h @@ -35,7 +35,7 @@ NS_ASSUME_NONNULL_BEGIN - (MP42TextSample *)chapterAtIndex:(NSUInteger)index; -- (NSInteger)chapterCount; +- (NSUInteger)chapterCount; - (BOOL)updateFromCSVFile:(NSURL *)URL error:(NSError **)outError; diff --git a/MP42/MP42ChapterTrack.m b/MP42/MP42ChapterTrack.m index 2a261ed..6218225 100644 --- a/MP42/MP42ChapterTrack.m +++ b/MP42/MP42ChapterTrack.m @@ -190,12 +190,13 @@ if (!refTrack) refTrack = 1; - chapterCount = [chapters count]; + chapterCount = chapters.count; if (chapterCount) { // Insert a chapter at time 0 if there isn't one - MP42TextSample * chapter = [chapters objectAtIndex:0]; - if (chapter.timestamp != 0) { + MP42TextSample *firstChapter = chapters.firstObject; + + if (firstChapter.timestamp != 0) { MP42TextSample *st = [[MP42TextSample alloc] init]; st.timestamp = 0; st.title = @"Chapter 0"; @@ -256,9 +257,9 @@ return success; } -- (NSInteger)chapterCount +- (NSUInteger)chapterCount { - return [chapters count]; + return chapters.count; } - (BOOL)exportToURL:(NSURL *)url error:(NSError **)error @@ -281,7 +282,7 @@ - (BOOL)updateFromCSVFile:(NSURL *)URL error:(NSError **)outError { NSArray *csvData = [NSArray arrayWithContentsOfCSVURL:URL]; if (csvData.count == self.chapterCount) { - for (NSInteger i = 0; i < csvData.count; ++i) { + for (NSUInteger i = 0; i < csvData.count; ++i) { NSArray *lineFields = csvData[i]; if (lineFields.count != 2 || [lineFields[0] integerValue] != i + 1) { if (NULL != outError) @@ -289,7 +290,7 @@ return NO; } } - for (NSInteger i = 0; i < csvData.count; ++i) { + for (NSUInteger i = 0; i < csvData.count; ++i) { MP42TextSample *chapter = self.chapters[i]; chapter.title = csvData[i][1]; } diff --git a/MP42/MP42File.m b/MP42/MP42File.m index 869428c..8364b30 100644 --- a/MP42/MP42File.m +++ b/MP42/MP42File.m @@ -500,7 +500,7 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { MP42MediaTypeAudio, MP42MediaTypeSubtitle]; - for (int i = 0; i < [typeToOrganize count]; i++) { + for (NSUInteger i = 0; i < typeToOrganize.count; i++) { [self organizeAlternateGroupsForMediaType:[typeToOrganize objectAtIndex:i] withGroupID:i]; } @@ -582,7 +582,7 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { if (noErr && [[[MP42File alloc] initWithExistingFile:tempURL andDelegate:nil] autorelease]) { // Replace the original file NSURL *result = nil; - noErr = [fileManager replaceItemAtURL:self.URL withItemAtURL:tempURL backupItemName:nil options:0 resultingItemURL:&result error:&error]; + noErr = [fileManager replaceItemAtURL:self.URL withItemAtURL:tempURL backupItemName:nil options:NSFileManagerItemReplacementWithoutDeletingBackupItem resultingItemURL:&result error:&error]; if (noErr) { self.URL = result; } diff --git a/MP42/MP42FileImporter.h b/MP42/MP42FileImporter.h index 26b7156..090a1d7 100644 --- a/MP42/MP42FileImporter.h +++ b/MP42/MP42FileImporter.h @@ -33,6 +33,8 @@ NS_ASSUME_NONNULL_BEGIN CGFloat _progress; int32_t _cancelled; int32_t _done; + +@private dispatch_semaphore_t _doneSem; } @@ -60,8 +62,8 @@ NS_ASSUME_NONNULL_BEGIN - (BOOL)cleanUp:(MP42FileHandle)fileHandle; -@property(readonly) MP42Metadata *metadata; -@property(readonly) NSArray *tracks; +@property(nonatomic, readonly) MP42Metadata *metadata; +@property(nonatomic, readonly) NSArray *tracks; @end diff --git a/MP42/MP42FileImporter.m b/MP42/MP42FileImporter.m index 3add120..d13ac44 100644 --- a/MP42/MP42FileImporter.m +++ b/MP42/MP42FileImporter.m @@ -59,18 +59,15 @@ [[fileURL pathExtension] caseInsensitiveCompare: @"idx"] == NSOrderedSame) self = [MP42VobSubImporter alloc]; #if !__LP64__ - /*else if ([[fileURL pathExtension] caseInsensitiveCompare: @"mov"] == NSOrderedSame) { + else if ([[fileURL pathExtension] caseInsensitiveCompare: @"mov"] == NSOrderedSame) { self = [MP42QTImporter alloc]; - }*/ + } #endif - // If we are on 10.7 or later, use the AVFoundation path - else if (NSClassFromString(@"AVAsset")) { - if ([[fileURL pathExtension] caseInsensitiveCompare: @"m2ts"] == NSOrderedSame || - [[fileURL pathExtension] caseInsensitiveCompare: @"ts"] == NSOrderedSame || - [[fileURL pathExtension] caseInsensitiveCompare: @"mts"] == NSOrderedSame || - [[fileURL pathExtension] caseInsensitiveCompare: @"mov"] == NSOrderedSame) { - self = [MP42AVFImporter alloc]; - } + else if ([[fileURL pathExtension] caseInsensitiveCompare: @"m2ts"] == NSOrderedSame || + [[fileURL pathExtension] caseInsensitiveCompare: @"ts"] == NSOrderedSame || + [[fileURL pathExtension] caseInsensitiveCompare: @"mts"] == NSOrderedSame || + [[fileURL pathExtension] caseInsensitiveCompare: @"mov"] == NSOrderedSame) { + self = [MP42AVFImporter alloc]; } if (self) { @@ -162,7 +159,7 @@ - (BOOL)done { - return _done; + return (_done > 0); } - (void)setDone:(BOOL)status { diff --git a/MP42/MP42H264Importer.h b/MP42/MP42H264Importer.h index a1eed36..c410ae8 100644 --- a/MP42/MP42H264Importer.h +++ b/MP42/MP42H264Importer.h @@ -36,7 +36,8 @@ typedef struct } h264_dpb_t; @interface MP42H264Importer : MP42FileImporter { - FILE* inFile; +@private + FILE *inFile; int64_t _size; NSData *avcC; @@ -46,4 +47,4 @@ typedef struct h264_dpb_t h264_dpb; } -@end \ No newline at end of file +@end diff --git a/MP42/MP42HtmlParser.h b/MP42/MP42HtmlParser.h index 27d9594..e186c4d 100644 --- a/MP42/MP42HtmlParser.h +++ b/MP42/MP42HtmlParser.h @@ -37,11 +37,11 @@ int compare_color(rgba_color c1, rgba_color c2); - (instancetype)initWithStyle:(NSInteger)style type:(NSInteger)type location:(NSUInteger) location color:(rgba_color) color; -@property (readwrite) NSInteger style; -@property (readwrite) rgba_color color; -@property (readwrite) NSInteger type; -@property (readwrite) NSUInteger location; -@property (readwrite) NSUInteger length; +@property (nonatomic, readwrite) NSInteger style; +@property (nonatomic, readwrite) rgba_color color; +@property (nonatomic, readwrite) NSInteger type; +@property (nonatomic, readwrite) NSUInteger location; +@property (nonatomic, readwrite) NSUInteger length; @end @@ -53,9 +53,9 @@ int compare_color(rgba_color c1, rgba_color c2); rgba_color _defaultColor; } -@property (readonly) NSString *text; -@property (readonly) NSArray *styles; -@property (readwrite) rgba_color defaultColor; +@property (nonatomic, readonly) NSString *text; +@property (nonatomic, readonly) NSArray *styles; +@property (nonatomic, readwrite) rgba_color defaultColor; - (instancetype)initWithString:(NSString *)string; - (NSInteger) parseNextTag; diff --git a/MP42/MP42Metadata.m b/MP42/MP42Metadata.m index bd038a7..4686d05 100644 --- a/MP42/MP42Metadata.m +++ b/MP42/MP42Metadata.m @@ -1441,16 +1441,16 @@ static const genreType_t genreType_strings[] = { dataFromPropertyList:iTunMovi format:NSPropertyListXMLFormat_v1_0 errorDescription:nil]; - if ([iTunMovi count]) { - MP4ItmfItemList* list = MP4ItmfGetItemsByMeaning(fileHandle, "com.apple.iTunes", "iTunMOVI"); - if (list) { + if (iTunMovi.count) { + MP4ItmfItemList *moviList = MP4ItmfGetItemsByMeaning(fileHandle, "com.apple.iTunes", "iTunMOVI"); + if (moviList) { uint32_t i; - for (i = 0; i < list->size; i++) { - MP4ItmfItem* item = &list->elements[i]; + for (i = 0; i < moviList->size; i++) { + MP4ItmfItem *item = &moviList->elements[i]; MP4ItmfRemoveItem(fileHandle, item); } } - MP4ItmfItemListFree(list); + MP4ItmfItemListFree(moviList); MP4ItmfItem* newItem = MP4ItmfItemAlloc( "----", 1 ); newItem->mean = strdup( "com.apple.iTunes" ); @@ -1466,15 +1466,15 @@ static const genreType_t genreType_strings[] = { MP4ItmfItemFree(newItem); } else { - MP4ItmfItemList* list = MP4ItmfGetItemsByMeaning(fileHandle, "com.apple.iTunes", "iTunMOVI"); - if (list) { + MP4ItmfItemList* moviList = MP4ItmfGetItemsByMeaning(fileHandle, "com.apple.iTunes", "iTunMOVI"); + if (moviList) { uint32_t i; - for (i = 0; i < list->size; i++) { - MP4ItmfItem* item = &list->elements[i]; + for (i = 0; i < moviList->size; i++) { + MP4ItmfItem* item = &moviList->elements[i]; MP4ItmfRemoveItem(fileHandle, item); } } - MP4ItmfItemListFree(list); + MP4ItmfItemListFree(moviList); } } diff --git a/MP42/MP42MkvImporter.h b/MP42/MP42MkvImporter.h index a792451..10fa1bb 100644 --- a/MP42/MP42MkvImporter.h +++ b/MP42/MP42MkvImporter.h @@ -10,10 +10,11 @@ #import "MP42FileImporter.h" @interface MP42MkvImporter : MP42FileImporter { +@private struct MatroskaFile *_matroskaFile; struct StdIoStream *_ioStream; u_int64_t _fileDuration; } -@end \ No newline at end of file +@end diff --git a/MP42/MP42MkvImporter.m b/MP42/MP42MkvImporter.m index 6437cf5..853f45f 100644 --- a/MP42/MP42MkvImporter.m +++ b/MP42/MP42MkvImporter.m @@ -590,7 +590,6 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t uint32_t Track, FrameSize, FrameFlags; uint8_t *frame = NULL; - MP42Track *track = nil; MatroskaDemuxHelper *demuxHelper = nil; MatroskaSample *frameSample = nil, *currentSample = nil; int64_t offset, minOffset = 0, duration, next_duration; @@ -611,6 +610,8 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t _progress = (StartTime / _fileDuration / 10000); muxer_helper *helper = NULL; + MP42Track *track = nil; + for (MP42Track *fTrack in _inputTracks){ if (fTrack.sourceId == Track) { helper = fTrack.muxer_helper; @@ -643,23 +644,23 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t #ifdef VARIABLE_AUDIO_RATE if (demuxHelper->previousSample) { - uint64_t duration = (sample->timestamp * (double)mkv_TruncFloat(trackInfo->AV.Audio.SamplingFreq) / 1000000000.f) - demuxHelper->current_time; + uint64_t sampleDuration = (sample->timestamp * (double)mkv_TruncFloat(trackInfo->AV.Audio.SamplingFreq) / 1000000000.f) - demuxHelper->current_time; // MKV timestamps are a bit random, try to round them // to make the sample table in the mp4 smaller. // Round aac - if (duration < 1060 && duration > 990) - duration = 1024; + if (sampleDuration < 1060 && sampleDuration > 990) + sampleDuration = 1024; // Round ac3 - if (duration < 1576 && duration > 1500) - duration = 1536; + if (sampleDuration < 1576 && sampleDuration > 1500) + sampleDuration = 1536; - demuxHelper->previousSample->duration = duration; + demuxHelper->previousSample->duration = sampleDuration; [self enqueue:demuxHelper->previousSample]; - demuxHelper->current_time += duration; + demuxHelper->current_time += sampleDuration; } else { demuxHelper->current_time = sample->timestamp * (double)mkv_TruncFloat(trackInfo->AV.Audio.SamplingFreq) / 1000000000.f; } @@ -957,8 +958,7 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t MP4TrackId trackId = track.Id; if (demuxHelper->minDisplayOffset != 0) { - int i; - for (i = 0; i < demuxHelper->samplesWritten; i++) + for (unsigned int i = 0; i < demuxHelper->samplesWritten; i++) MP4SetSampleRenderingOffset(fileHandle, trackId, 1 + i, diff --git a/MP42/MP42Mp4Importer.h b/MP42/MP42Mp4Importer.h index b983021..c85967d 100644 --- a/MP42/MP42Mp4Importer.h +++ b/MP42/MP42Mp4Importer.h @@ -12,7 +12,8 @@ #import "mp4v2.h" @interface MP42Mp4Importer : MP42FileImporter { +@private MP4FileHandle _fileHandle; } -@end \ No newline at end of file +@end diff --git a/MP42/MP42Mp4Importer.m b/MP42/MP42Mp4Importer.m index c9b46a7..d5d89fc 100644 --- a/MP42/MP42Mp4Importer.m +++ b/MP42/MP42Mp4Importer.m @@ -174,8 +174,8 @@ &pictheader, &pictheadersize); NSMutableData *seqData = [[NSMutableData alloc] init]; for (ix = 0 , iy = 0; seqheadersize[ix] != 0; ix++) { - uint16_t temp = seqheadersize[ix] << 8; - [seqData appendBytes:&temp length:sizeof(uint16_t)]; + uint16_t tempSeqSize = seqheadersize[ix] << 8; + [seqData appendBytes:&tempSeqSize length:sizeof(uint16_t)]; [seqData appendBytes:seqheader[ix] length:seqheadersize[ix]]; iy++; free(seqheader[ix]); @@ -188,8 +188,8 @@ NSMutableData *pictData = [[NSMutableData alloc] init]; for (ix = 0, iy = 0; pictheadersize[ix] != 0; ix++) { - uint16_t temp = pictheadersize[ix] << 8; - [pictData appendBytes:&temp length:sizeof(uint16_t)]; + uint16_t tempPictSize = pictheadersize[ix] << 8; + [pictData appendBytes:&tempPictSize length:sizeof(uint16_t)]; [pictData appendBytes:pictheader[ix] length:pictheadersize[ix]]; iy++; free(pictheader[ix]); @@ -231,7 +231,7 @@ } MP4Timestamp currentTime = 1; - MP4Duration duration = MP4GetDuration(_fileHandle); + MP4Duration totalDuration = MP4GetDuration(_fileHandle); MP4Duration timescale = MP4GetTimeScale(_fileHandle); while (tracksDone != tracksNumber) { @@ -282,7 +282,7 @@ } } - _progress = ((CGFloat)currentTime * timescale / duration) * 100; + _progress = ((CGFloat)currentTime * timescale / totalDuration) * 100; currentTime += 3; } diff --git a/MP42/MP42Muxer.m b/MP42/MP42Muxer.m index 84ac10a..b4c99ae 100644 --- a/MP42/MP42Muxer.m +++ b/MP42/MP42Muxer.m @@ -42,10 +42,10 @@ - (BOOL)canAddTrack:(MP42Track *)track { if (isTrackMuxable(track.format)) { - return YES; if ([track isMemberOfClass:[MP42AudioTrack class]]) { // TO-DO Check if we can initialize the audio converter } + return YES; } else { return NO; } @@ -250,10 +250,10 @@ NSInteger vPlacement = [(MP42SubtitleTrack*)track verticalPlacement]; - for (id track in _workingTracks) - if ([track isMemberOfClass:[MP42VideoTrack class]]) { - videoSize.width = [track trackWidth]; - videoSize.height = [track trackHeight]; + for (id workingTrack in _workingTracks) + if ([workingTrack isMemberOfClass:[MP42VideoTrack class]]) { + videoSize.width = [workingTrack trackWidth]; + videoSize.height = [workingTrack trackHeight]; break; } @@ -361,10 +361,10 @@ else if ([track isMemberOfClass:[MP42ClosedCaptionTrack class]]) { NSSize videoSize = [helper->importer sizeForTrack:track]; - for (id track in _workingTracks) - if ([track isMemberOfClass:[MP42VideoTrack class]]) { - videoSize.width = [track trackWidth]; - videoSize.height = [track trackHeight]; + for (id workingTrack in _workingTracks) + if ([workingTrack isMemberOfClass:[MP42VideoTrack class]]) { + videoSize.width = [workingTrack trackWidth]; + videoSize.height = [workingTrack trackHeight]; break; } diff --git a/MP42/MP42PrivateUtilities.m b/MP42/MP42PrivateUtilities.m index 92f3e60..66de703 100644 --- a/MP42/MP42PrivateUtilities.m +++ b/MP42/MP42PrivateUtilities.m @@ -686,17 +686,18 @@ MP4Duration getTrackDuration(MP4FileHandle fileHandle, MP4TrackId trackId) { uint32_t trackEditsCount = MP4GetTrackNumberOfEdits(fileHandle, trackId); MP4Duration duration = 0; - int i = 1; + uint32_t i = 1; - while( i <= trackEditsCount) { + while (i <= trackEditsCount) { duration += MP4GetTrackEditDuration(fileHandle, trackId, i); i++; } - if (duration == 0) + if (duration == 0) { duration = MP4ConvertFromTrackDuration(fileHandle, trackId, MP4GetTrackDuration(fileHandle, trackId), MP4GetTimeScale(fileHandle)); + } return duration; } diff --git a/MP42/MP42QTImporter.h b/MP42/MP42QTImporter.h index e69c2f0..1421ed8 100644 --- a/MP42/MP42QTImporter.h +++ b/MP42/MP42QTImporter.h @@ -12,9 +12,10 @@ #import @interface MP42QTImporter : MP42FileImporter { +@private QTMovie *_sourceFile; } @end -#endif \ No newline at end of file +#endif diff --git a/MP42/MP42Ratings.h b/MP42/MP42Ratings.h index 4a07779..215cc2b 100644 --- a/MP42/MP42Ratings.h +++ b/MP42/MP42Ratings.h @@ -8,22 +8,27 @@ #import +NS_ASSUME_NONNULL_BEGIN + @interface MP42Ratings : NSObject { +@private NSMutableArray *ratingsDictionary; - NSMutableArray *ratings; - NSMutableArray *iTunesCodes; + NSMutableArray *ratings; + NSMutableArray *iTunesCodes; } -@property(readonly) NSArray *ratings; -@property(readonly) NSArray *iTunesCodes; +@property (atomic, readonly) NSArray *ratings; +@property (atomic, readonly) NSArray *iTunesCodes; -+ (MP42Ratings *) defaultManager; ++ (MP42Ratings *)defaultManager; - (void)updateRatingsCountry; -- (NSArray *) ratingsCountries; +- (NSArray *) ratingsCountries; - (NSUInteger) unknownIndex; - (NSUInteger) ratingIndexForiTunesCode:(NSString *)aiTunesCode; - (NSUInteger) ratingIndexForiTunesCountry:(NSString *)aCountry media:(NSString *)aMedia ratingString:(NSString *)aRatingString; @end + +NS_ASSUME_NONNULL_END diff --git a/MP42/MP42Ratings.m b/MP42/MP42Ratings.m index 12f890d..56ed5df 100644 --- a/MP42/MP42Ratings.m +++ b/MP42/MP42Ratings.m @@ -105,7 +105,7 @@ } - (NSUInteger) ratingIndexForiTunesCode:(NSString *)aiTunesCode { - for (int i = 0; i < [iTunesCodes count]; i++) { + for (NSUInteger i = 0; i < [iTunesCodes count]; i++) { if ([[iTunesCodes objectAtIndex:i] isEqualToString:aiTunesCode]) { return i; } @@ -116,7 +116,7 @@ - (NSUInteger) ratingIndexForiTunesCountry:(NSString *)aCountry media:(NSString *)aMedia ratingString:(NSString *)aRatingString { NSString *target1 = [[NSString stringWithFormat:@"%@ %@: %@", aCountry, aMedia, aRatingString] lowercaseString]; NSString *target2 = [[NSString stringWithFormat:@"%@ %@: %@", aCountry, @"movie & TV", aRatingString] lowercaseString]; - for (int i = 0; i < [ratings count]; i++) { + for (NSUInteger i = 0; i < [ratings count]; i++) { if ([[[ratings objectAtIndex:i] lowercaseString] isEqualToString:target1] || [[[ratings objectAtIndex:i] lowercaseString] isEqualToString:target2]) { return i; } diff --git a/MP42/MP42SrtImporter.h b/MP42/MP42SrtImporter.h index 4ba80b7..e085bfd 100644 --- a/MP42/MP42SrtImporter.h +++ b/MP42/MP42SrtImporter.h @@ -12,9 +12,10 @@ @class SBSubSerializer; @interface MP42SrtImporter : MP42FileImporter { +@private SBSubSerializer *_ss; BOOL _verticalPlacement; } -@end \ No newline at end of file +@end diff --git a/MP42/MP42SubUtilities.h b/MP42/MP42SubUtilities.h index 2ac8a6b..7c4a1ac 100644 --- a/MP42/MP42SubUtilities.h +++ b/MP42/MP42SubUtilities.h @@ -72,4 +72,4 @@ typedef struct { int ExtractVobSubPacket(UInt8 *dest, UInt8 *framedSrc, int srcSize, int *usedSrcBytes, int index); ComponentResult ReadPacketControls(UInt8 *packet, UInt32 palette[16], PacketControlData *controlDataOut,BOOL *forced); -Boolean ReadPacketTimes(uint8_t *packet, uint32_t length, uint16_t *startTime, uint16_t *endTime, uint8_t *forced); \ No newline at end of file +Boolean ReadPacketTimes(uint8_t *packet, uint32_t length, uint16_t *startTime, uint16_t *endTime, uint8_t *forced); diff --git a/MP42/MP42SubUtilities.m b/MP42/MP42SubUtilities.m index 409c749..c568365 100644 --- a/MP42/MP42SubUtilities.m +++ b/MP42/MP42SubUtilities.m @@ -68,7 +68,7 @@ static CFComparisonResult CompareLinesByBeginTime(const void *a, const void *b, [lines addObject:line]; } else { CFIndex i = CFArrayBSearchValues((CFArrayRef)lines, CFRangeMake(0, nlines), line, CompareLinesByBeginTime, NULL); - + if (i >= nlines) [lines addObject:line]; else @@ -271,8 +271,8 @@ NSMutableString *STStandardizeStringNewlines(NSString *str) if(str == nil) return nil; NSMutableString *ms = [NSMutableString stringWithString:str]; - [ms replaceOccurrencesOfString:@"\r\n" withString:@"\n" options:0 range:NSMakeRange(0,[ms length])]; - [ms replaceOccurrencesOfString:@"\r" withString:@"\n" options:0 range:NSMakeRange(0,[ms length])]; + [ms replaceOccurrencesOfString:@"\r\n" withString:@"\n" options:NSLiteralSearch range:NSMakeRange(0,[ms length])]; + [ms replaceOccurrencesOfString:@"\r" withString:@"\n" options:NSLiteralSearch range:NSMakeRange(0,[ms length])]; return ms; } @@ -1311,7 +1311,6 @@ Boolean ReadPacketTimes(uint8_t *packet, uint32_t length, uint16_t *startTime, u default: return NO; - break; } } if(i != INT_MAX) diff --git a/MP42/MP42VideoTrack.m b/MP42/MP42VideoTrack.m index a5dfb17..964149a 100644 --- a/MP42/MP42VideoTrack.m +++ b/MP42/MP42VideoTrack.m @@ -85,7 +85,7 @@ if (_Id) { [super writeToFile:fileHandle error:outError]; - if (trackWidth && trackHeight) { + if (trackWidth > 0 && trackHeight > 0) { MP4SetTrackFloatProperty(fileHandle, _Id, "tkhd.width", trackWidth); MP4SetTrackFloatProperty(fileHandle, _Id, "tkhd.height", trackHeight); @@ -146,7 +146,7 @@ } } - return _Id; + return (_Id > 0); } - (NSString *)defaultName { @@ -267,11 +267,11 @@ offsetX = [decoder decodeInt32ForKey:@"offsetX"]; offsetY = [decoder decodeInt32ForKey:@"offsetY"]; - _origProfile = [decoder decodeInt32ForKey:@"origProfile"]; - _origLevel = [decoder decodeInt32ForKey:@"origLevel"]; + _origProfile = [decoder decodeIntForKey:@"origProfile"]; + _origLevel = [decoder decodeIntForKey:@"origLevel"]; - _newProfile = [decoder decodeInt32ForKey:@"newProfile"]; - _newLevel = [decoder decodeInt32ForKey:@"newLevel"]; + _newProfile = [decoder decodeIntForKey:@"newProfile"]; + _newLevel = [decoder decodeIntForKey:@"newLevel"]; return self; } diff --git a/MP42/MP42VobSubImporter.h b/MP42/MP42VobSubImporter.h index 42120ac..e799ce6 100644 --- a/MP42/MP42VobSubImporter.h +++ b/MP42/MP42VobSubImporter.h @@ -9,6 +9,7 @@ #import "MP42FileImporter.h" @interface MP42VobSubImporter : MP42FileImporter { +@private NSArray *_VobSubTracks; } diff --git a/MP42/MP42XMLReader.h b/MP42/MP42XMLReader.h index 6040d21..23139ee 100644 --- a/MP42/MP42XMLReader.h +++ b/MP42/MP42XMLReader.h @@ -8,6 +8,8 @@ #import +NS_ASSUME_NONNULL_BEGIN + @class MP42Metadata; @interface MP42XMLReader : NSObject { @@ -16,6 +18,8 @@ - (instancetype)initWithURL:(NSURL *)url error:(NSError **)error; -@property(readonly) MP42Metadata *mMetadata; +@property (nonatomic, readonly) MP42Metadata *mMetadata; @end + +NS_ASSUME_NONNULL_END diff --git a/MP42/QTKitDecrap.h b/MP42/QTKitDecrap.h index a4cd4db..6621d69 100644 --- a/MP42/QTKitDecrap.h +++ b/MP42/QTKitDecrap.h @@ -3,9 +3,7 @@ // Subler // // Created by Damiano Galassi on 13/12/12. -// Duplicate and fix QTMetadataItem so it can be compiled while targetting 10.6. -// Who knows the reason, it's so easy in Cocoa to check if a class exists at runtime... -// Oh and almost all the constants from QTMetadataItem all broken, @ instead of ©. +// Almost all the constants from QTMetadataItem all broken, @ instead of ©. // Plus define a QTKit costant. #import @@ -30,124 +28,3 @@ extern NSString * const QTTrackLanguageAttribute; // NSNumber (long) } @end - -@interface QTMovie (QTMovie_MetadataReading_10_6_Fix) - -#if (defined(MAC_OS_X_VERSION_10_7)) -/*! - @method commonMetadata - @abstract Returns an NSArray containing QTMetadataItem objects for each common metadata key for which a value for the current locale is available. - @result An NSArray containing QTMetadataItem objects for each common metadata key for which a value for the current locale is available; may be nil if there is no metadata that's appropriately localized. - @discussion The returned metadata may be tagged with default locale information or with no locale information, if that's the best available choice. - */ -- (NSArray *)commonMetadata; - -/*! - @method availableMetadataFormats - @abstract Returns an NSArray containing NSString objects representing the metadata formats available to the receiver. - @result An NSArray containing an NSString objects, each of which represents a metadata format that is available to the receiver. - */ -- (NSArray *)availableMetadataFormats; - -/*! - @method metadataForFormat: - @abstract Returns an NSArray of QTMetadataItem objects having a specified format. - @param format - The metadata format for which items are requested. - @result An NSArray containing all QTMetadataItem objects of the receiver that have the specified format; may be nil if there is no metadata of the specified format. - */ -- (NSArray *)metadataForFormat:(NSString *)format; -#endif - -@end - - -#if (defined(MAC_OS_X_VERSION_10_7)) -/*! - @class QTMetadataItem - @abstract QTMetadataItem represents an item of metadata associated with a QTMovie or QTTrack object. - - @discussion QTMetadataItem objects have keys that accord with the specification of the container format from which they're drawn. - - You can filter arrays of QTMetadataItem objects by locale or by key and keyspace via the category - QTMetadataItem_ArrayFiltering defined below. - */ - -@class QTMetadataItemInternal; - -@interface QTMetadataItem : NSObject -{ - QTMetadataItemInternal *_priv; -} - -/* indicates the key of the metadata item */ -@property (readonly, copy) id key; - -/* indicates the keyspace of the metadata item's key; this will typically be the default keyspace for the metadata container in which the metadata item is stored */ -@property (readonly, copy) NSString *keySpace; - -/* indicates the locale of the metadata item; may be nil if no locale information is available for the metadata item */ -@property (readonly, copy) NSLocale *locale; - -/* indicates the timestamp of the metadata item. */ -@property (readonly) QTTime time; - -/* provides the value of the metadata item */ -@property (readonly, copy) id value; - -/* provides a dictionary of the additional attributes */ -@property (readonly, copy) NSDictionary *extraAttributes; - -@end - - -@interface QTMetadataItem (QTMetadataItem_TypeCoercion) - -/* provides the value of the metadata item as a string; will be nil if the value cannot be represented as a string */ -@property (readonly) NSString *stringValue; - -/* provides the value of the metadata item as an NSNumber. If the metadata item's value can't be coerced to a number, @"numberValue" will be nil. */ -@property (readonly) NSNumber *numberValue; - -/* provides the value of the metadata item as an NSDate. If the metadata item's value can't be coerced to a date, @"dateValue" will be nil. */ -@property (readonly) NSDate *dateValue; - -/* provides the raw bytes of the value of the metadata item */ -@property (readonly) NSData *dataValue; - -@end - - -@interface QTMetadataItem (QTMetadataItem_ArrayFiltering) - -/*! - @method metadataItemsFromArray:withLocale: - @abstract Filters an array of QTMetadataItem objects according to locale. - @param array - An array of QTMetadataItem objects to be filtered by locale. - @param locale - The NSLocale that must be matched for a metadata item to be copied to the output array. - @result An NSArray object containing the metadata items of the specified NSArray that match the specified locale. - */ -+ (NSArray *)metadataItemsFromArray:(NSArray *)array withLocale:(NSLocale *)locale; - -/*! - @method metadataItemsFromArray:withKey:keySpace: - @abstract Filters an array of QTMetadataItem objects according to key and/or keySpace. - @param array - An array of QTMetadataItem objects to be filtered by key and/or keySpace. - @param key - The key that must be matched for a metadata item to be copied to the output array. - The keys will be compared to the keys of the QTMetadataItem objects in the array via [key isEqual:]. - If no filtering according to key is desired, pass nil. - @param keySpace - The keySpace that must be matched for a metadata item to be copied to the output array. - The keySpace will be compared to the keySpaces of the QTMetadataItems in the array via [keySpace isEqualToString:]. - If no filtering according to keySpace is desired, pass nil. - @result An NSArray object containing the metadata items of the specified NSArray that match the specified key and/or keySpace. - */ -+ (NSArray *)metadataItemsFromArray:(NSArray *)array withKey:(id)key keySpace:(NSString *)keySpace; - -@end - -#endif // if (defined(MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7)) \ No newline at end of file diff --git a/MP42/muxer/MatroskaFile.h b/MP42/muxer/MatroskaFile.h index cd8b4d9..3858b2e 100644 --- a/MP42/muxer/MatroskaFile.h +++ b/MP42/muxer/MatroskaFile.h @@ -20,4 +20,4 @@ struct StdIoStream { typedef struct StdIoStream StdIoStream; MatroskaFile *openMatroskaFile(char *filePath, StdIoStream *ioStream); -void closeMatroskaFile(MatroskaFile *matroskaFile, StdIoStream *ioStream); \ No newline at end of file +void closeMatroskaFile(MatroskaFile *matroskaFile, StdIoStream *ioStream); diff --git a/MP42Foundation.xcodeproj/project.pbxproj b/MP42Foundation.xcodeproj/project.pbxproj index 379c6eb..62c5614 100644 --- a/MP42Foundation.xcodeproj/project.pbxproj +++ b/MP42Foundation.xcodeproj/project.pbxproj @@ -1154,32 +1154,35 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++98"; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libstdc++"; - CLANG_ENABLE_OBJC_ARC = NO; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_C_LANGUAGE_STANDARD = c11; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = NO; + GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( "$(inherited)", @@ -1188,8 +1191,8 @@ "$(SRCROOT)/ffmpeg/**", "$(SRCROOT)/Tesseract", ); - MACOSX_DEPLOYMENT_TARGET = 10.6; - ONLY_ACTIVE_ARCH = NO; + MACOSX_DEPLOYMENT_TARGET = 10.7; + ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = ( "-read_only_relocs", suppress, @@ -1204,27 +1207,32 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++98"; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libstdc++"; - CLANG_ENABLE_OBJC_ARC = NO; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_C_LANGUAGE_STANDARD = c11; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = NO; + GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( "$(inherited)", @@ -1233,8 +1241,8 @@ "$(SRCROOT)/ffmpeg/**", "$(SRCROOT)/Tesseract", ); - MACOSX_DEPLOYMENT_TARGET = 10.6; - ONLY_ACTIVE_ARCH = NO; + MACOSX_DEPLOYMENT_TARGET = 10.7; + ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = ( "-read_only_relocs", suppress,