diff --git a/MP42/FFmpegUtils.h b/MP42/FFmpegUtils.h index 00f9599..30b30a5 100644 --- a/MP42/FFmpegUtils.h +++ b/MP42/FFmpegUtils.h @@ -18,8 +18,8 @@ enum AVCodecID FourCCToCodecID(OSType formatID); OSType CodecIDToFourCC(enum AVCodecID codecID); int remap_layout(AudioChannelLayout *layout, uint64_t in_layout, int count); -int convert_layout_to_av(AudioChannelLayout *layout, UInt32 layoutSize); +uint64_t convert_layout_to_av(AudioChannelLayout *layout, UInt32 layoutSize); -int channel_layout_for_channels(AVCodec *codec, int channels); +uint64_t channel_layout_for_channels(AVCodec *codec, int channels); #endif /* FFmpegUtils_h */ diff --git a/MP42/FFmpegUtils.m b/MP42/FFmpegUtils.m index 1ab775c..7351f19 100644 --- a/MP42/FFmpegUtils.m +++ b/MP42/FFmpegUtils.m @@ -61,7 +61,7 @@ static const struct { { kLinearPCMFormatFlagIsFloat | kLinearPCMFormatFlagIsPacked, 32, AV_CODEC_ID_PCM_F32LE }, { kLinearPCMFormatFlagIsFloat | kLinearPCMFormatFlagIsPacked | kAudioFormatFlagIsBigEndian, 64, AV_CODEC_ID_PCM_F64BE }, { kLinearPCMFormatFlagIsFloat | kLinearPCMFormatFlagIsPacked, 64, AV_CODEC_ID_PCM_F64LE }, - {0, AV_CODEC_ID_NONE } + {0, 0, AV_CODEC_ID_NONE } }; enum AVCodecID ASBDToCodecID(AudioStreamBasicDescription asbd) @@ -230,12 +230,12 @@ static AudioChannelLayout *convert_layout(AudioChannelLayout *layout, UInt32* si return new_layout; } -int convert_layout_to_av(AudioChannelLayout *layout, UInt32 layoutSize) +uint64_t convert_layout_to_av(AudioChannelLayout *layout, UInt32 layoutSize) { AudioChannelLayout *layout_copy = av_malloc(layoutSize); memcpy(layout_copy, layout, layoutSize); uint64_t layout_mask = 0; - int i; + UInt32 i; if (!layout_copy) return AVERROR(ENOMEM); if (!(layout_copy = convert_layout(layout_copy, &layoutSize))) @@ -254,7 +254,7 @@ done: return layout_mask; } -int channel_layout_for_channels(AVCodec *codec, int channels) +uint64_t channel_layout_for_channels(AVCodec *codec, int channels) { const uint64_t *p; uint64_t best_ch_layout = 0; diff --git a/MP42/MP42AACImporter.mm b/MP42/MP42AACImporter.mm index d743a1f..5722186 100644 --- a/MP42/MP42AACImporter.mm +++ b/MP42/MP42AACImporter.mm @@ -824,7 +824,7 @@ static bool GetFirstHeader(FILE* inFile) return self; } -- (NSUInteger)timescaleForTrack:(MP42Track *)track +- (UInt32)timescaleForTrack:(MP42Track *)track { return samplesPerSecond; } diff --git a/MP42/MP42AC3AudioEncoder.h b/MP42/MP42AC3AudioEncoder.h index 35a547e..aa22739 100644 --- a/MP42/MP42AC3AudioEncoder.h +++ b/MP42/MP42AC3AudioEncoder.h @@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) UInt32 outputLayoutSize; @property (nonatomic, readonly) AudioStreamBasicDescription outputFormat; -@property (nonatomic, readonly) NSData *magicCookie; +@property (nonatomic, readonly, nullable) NSData *magicCookie; @end diff --git a/MP42/MP42AC3AudioEncoder.m b/MP42/MP42AC3AudioEncoder.m index 19683f2..d9980b3 100644 --- a/MP42/MP42AC3AudioEncoder.m +++ b/MP42/MP42AC3AudioEncoder.m @@ -297,7 +297,7 @@ MP42_OBJC_DIRECT_MEMBERS } } -- (NSData *)magicCookie +- (nullable NSData *)magicCookie { return _magicCookie; } diff --git a/MP42/MP42AC3Importer.m b/MP42/MP42AC3Importer.m index 56391b0..ac9847a 100644 --- a/MP42/MP42AC3Importer.m +++ b/MP42/MP42AC3Importer.m @@ -336,7 +336,7 @@ static bool GetFirstHeader(FILE* inFile) return self; } -- (NSUInteger)timescaleForTrack:(MP42Track *)track +- (UInt32)timescaleForTrack:(MP42Track *)track { return samplesPerSecond; } @@ -368,18 +368,21 @@ static bool GetFirstHeader(FILE* inFile) int64_t currentSize = 0; while (LoadNextAc3Frame(inFile, &pBuf, &pBufSize, false) && !self.isCancelled) { - MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init]; - void *sampleDataBuffer = malloc(pBufSize); - memcpy(sampleDataBuffer, pBuf, pBufSize); + if (pBufSize < UINT32_MAX) { + MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init]; - sample->data = sampleDataBuffer; - sample->size = pBufSize; - sample->duration = MP4_INVALID_DURATION; - sample->flags |= MP42SampleBufferFlagIsSync; - sample->trackId = trackId; + void *sampleDataBuffer = malloc(pBufSize); + memcpy(sampleDataBuffer, pBuf, pBufSize); - [self enqueue:sample]; + sample->data = sampleDataBuffer; + sample->size = (uint32_t)pBufSize; + sample->duration = MP4_INVALID_DURATION; + sample->flags |= MP42SampleBufferFlagIsSync; + sample->trackId = trackId; + + [self enqueue:sample]; + } sampleId++; diff --git a/MP42/MP42AVFImporter.m b/MP42/MP42AVFImporter.m index 6f23e61..06e4be9 100644 --- a/MP42/MP42AVFImporter.m +++ b/MP42/MP42AVFImporter.m @@ -108,7 +108,8 @@ MP42_OBJC_DIRECT_MEMBERS for (AVTimedMetadataGroup *chapterData in chapterList) { for (AVMetadataItem *item in chapterData.items) { CMTime time = item.time; - [chapters addChapter:[item stringValue] duration:time.value * time.timescale / 1000]; + NSString *title = item.stringValue ? item.stringValue : @""; + [chapters addChapter:title duration:time.value * time.timescale / 1000]; } } } @@ -732,7 +733,7 @@ MP42_OBJC_DIRECT_MEMBERS #pragma mark - Overrides -- (NSUInteger)timescaleForTrack:(MP42Track *)track { +- (UInt32)timescaleForTrack:(MP42Track *)track { AVAssetTrack *assetTrack = [_localAsset trackWithTrackID:track.sourceId]; // Prefer the asbd sample rate, naturalTimeScale might not be @@ -786,9 +787,9 @@ MP42_OBJC_DIRECT_MEMBERS } else if ([assetTrack.mediaType isEqualToString:AVMediaTypeAudio]) { size_t cookieSizeOut; - const void *cookieBuffer = CMAudioFormatDescriptionGetMagicCookie(formatDescription, &cookieSizeOut); // Returns proper Atmos dec3 atom (in macOS 10.14.2), if proper E-AC3 stream, not AC-3-embedded! + const uint8_t *cookie = CMAudioFormatDescriptionGetMagicCookie(formatDescription, &cookieSizeOut); // Returns proper Atmos dec3 atom (in macOS 10.14.2), if proper E-AC3 stream, not AC-3-embedded! - if (cookieBuffer == NULL || cookieSizeOut == 0) { + if (cookie == NULL || cookieSizeOut == 0) { if (code == kAudioFormatMPEG4AAC) { @@ -831,7 +832,7 @@ MP42_OBJC_DIRECT_MEMBERS // Extract DecoderSpecific info UInt8 *buffer; int size; - ReadESDSDescExt((void *)cookieBuffer, &buffer, &size, 0); + ReadESDSDescExt((void *)cookie, &buffer, &size, 0); NSData *magicCookie = [NSData dataWithBytes:buffer length:size]; free(buffer); @@ -843,51 +844,54 @@ MP42_OBJC_DIRECT_MEMBERS if (cookieSizeOut > 48) { // Remove unneeded parts of the cookie, as described in ALACMagicCookieDescription.txt - cookieBuffer += 24; + cookie += 24; cookieSizeOut = cookieSizeOut - 24 - 8; } - return [NSData dataWithBytes:cookieBuffer length:cookieSizeOut]; + return [NSData dataWithBytes:cookie length:cookieSizeOut]; } else if (code == kAudioFormatOpus) { // TODO - return [NSData dataWithBytes:cookieBuffer length:cookieSizeOut]; + return [NSData dataWithBytes:cookie length:cookieSizeOut]; } else if (code == kAudioFormatFLAC) { // TODO - return [NSData dataWithBytes:cookieBuffer length:cookieSizeOut]; + return [NSData dataWithBytes:cookie length:cookieSizeOut]; } else if (code == kAudioFormatEnhancedAC3) { // dec3 atom // remove the atom header - cookieBuffer += 8; + cookie += 8; cookieSizeOut = cookieSizeOut - 8; - NSMutableData *ac3Info = [NSMutableData dataWithBytes:cookieBuffer length:cookieSizeOut]; - MP42AudioTrack *audiotrack = (MP42AudioTrack *)track; - // besides fourCC also the bsid in cookie created by CMAudioFormatDescriptionGetMagicCookie needs to be fixed - NSRange cookieBsidRange = NSMakeRange(2, 1); - uint8_t cookieBsidByte[1]; - [ac3Info getBytes:cookieBsidByte range:cookieBsidRange]; - cookieBsidByte[0] = (cookieBsidByte[0] & 0xC0) | (0x10 << 1); // keep fscod, replace bsid with 0x10. This can happen, if bsid=0x10 frames are embedded as substream inside bsid=0x06 frames. - [ac3Info replaceBytesInRange:cookieBsidRange withBytes:cookieBsidByte length:1]; - // dec3 atom may be already delivered as ETSI TS 103 420 V1.2.1 compliant by CMAudioFormatDescriptionGetMagicCookie(), see above. - UInt8 ec3ExtensionType = EC3Extension_None; - UInt8 complexityIndex = 0; - UInt32 dummy; - readEAC3Config(cookieBuffer, cookieSizeOut, &dummy, &dummy, &ec3ExtensionType, &complexityIndex); - // do not add duplicate ec3ExtensionType & complexityIndex, if already present - if (!ec3ExtensionType && !complexityIndex && (audiotrack.extensionType == kMP42AudioEmbeddedExtension_JOC)) - { - ec3ExtensionType = audiotrack.extensionType; - [ac3Info appendBytes:&ec3ExtensionType length:sizeof(MP42AudioEmbeddedExtension)]; - [ac3Info appendBytes:&complexityIndex length:sizeof(UInt8)]; - } - - return ac3Info; + if (cookieSizeOut < UINT32_MAX) { + NSMutableData *ac3Info = [NSMutableData dataWithBytes:cookie length:cookieSizeOut]; + MP42AudioTrack *audiotrack = (MP42AudioTrack *)track; + // besides fourCC also the bsid in cookie created by CMAudioFormatDescriptionGetMagicCookie needs to be fixed + NSRange cookieBsidRange = NSMakeRange(2, 1); + uint8_t cookieBsidByte[1]; + [ac3Info getBytes:cookieBsidByte range:cookieBsidRange]; + cookieBsidByte[0] = (cookieBsidByte[0] & 0xC0) | (0x10 << 1); // keep fscod, replace bsid with 0x10. This can happen, if bsid=0x10 frames are embedded as substream inside bsid=0x06 frames. + [ac3Info replaceBytesInRange:cookieBsidRange withBytes:cookieBsidByte length:1]; + // dec3 atom may be already delivered as ETSI TS 103 420 V1.2.1 compliant by CMAudioFormatDescriptionGetMagicCookie(), see above. + UInt8 ec3ExtensionType = EC3Extension_None; + UInt8 complexityIndex = 0; + UInt32 dummy; + readEAC3Config(cookie, (uint32_t)cookieSizeOut, &dummy, &dummy, &ec3ExtensionType, &complexityIndex); + // do not add duplicate ec3ExtensionType & complexityIndex, if already present + if (!ec3ExtensionType && !complexityIndex && (audiotrack.extensionType == kMP42AudioEmbeddedExtension_JOC)) + { + ec3ExtensionType = audiotrack.extensionType; + [ac3Info appendBytes:&ec3ExtensionType length:sizeof(MP42AudioEmbeddedExtension)]; + [ac3Info appendBytes:&complexityIndex length:sizeof(UInt8)]; + } + return ac3Info; + } else { + return nil; + } } else if (code == kAudioFormatAC3 || @@ -965,7 +969,7 @@ MP42_OBJC_DIRECT_MEMBERS return ac3Info; } else if (cookieSizeOut) { - return [NSData dataWithBytes:cookieBuffer length:cookieSizeOut]; + return [NSData dataWithBytes:cookie length:cookieSizeOut]; } } @@ -1001,7 +1005,7 @@ MP42_OBJC_DIRECT_MEMBERS return result; } -- (BOOL)audioTrackUsesExplicitEncoderDelay:(MP42Track *)track; +- (BOOL)audioTrackUsesExplicitEncoderDelay:(MP42Track *)track { return YES; } @@ -1013,8 +1017,8 @@ MP42_OBJC_DIRECT_MEMBERS uint64_t currentDataLength = 0; uint64_t totalDataLength = 0; - NSInteger tracksDone = 0; - NSInteger tracksNumber = self.inputTracks.count; + NSUInteger tracksDone = 0; + NSUInteger tracksNumber = self.inputTracks.count; AVAssetReader *assetReader = [[AVAssetReader alloc] initWithAsset:_localAsset error:NULL]; AVFDemuxHelper * helpers[tracksNumber]; @@ -1141,7 +1145,7 @@ MP42_OBJC_DIRECT_MEMBERS // Enqueues the new sample MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init]; sample->data = sampleData; - sample->size = bufferSize; + sample->size = (uint32_t)bufferSize; sample->duration = duration.value; sample->offset = -decodeTimeStamp.value + presentationTimeStamp.value; sample->decodeTimestamp = decodeTimeStamp.value; @@ -1213,23 +1217,23 @@ MP42_OBJC_DIRECT_MEMBERS for (uint64_t i = 0, pos = 0; i < samplesNum; i++) { CMSampleTimingInfo sampleTimingInfo; - CMTime decodeTimeStamp; - CMTime presentationTimeStamp; + CMTime sampleDecodeTimeStamp; + CMTime samplePresentationTimeStamp; size_t sampleSize; // If the size of sample timing array is equal to 1, it means every sample has got the same timing if (timingArrayEntries == 1) { sampleTimingInfo = timingArrayOut[0]; - decodeTimeStamp = sampleTimingInfo.decodeTimeStamp; - decodeTimeStamp.value = decodeTimeStamp.value + ( sampleTimingInfo.duration.value * i); + sampleDecodeTimeStamp = sampleTimingInfo.decodeTimeStamp; + sampleDecodeTimeStamp.value = sampleDecodeTimeStamp.value + (sampleTimingInfo.duration.value * i); - presentationTimeStamp = sampleTimingInfo.presentationTimeStamp; - presentationTimeStamp.value = presentationTimeStamp.value + ( sampleTimingInfo.duration.value * i); + samplePresentationTimeStamp = sampleTimingInfo.presentationTimeStamp; + samplePresentationTimeStamp.value = samplePresentationTimeStamp.value + (sampleTimingInfo.duration.value * i); } else { sampleTimingInfo = timingArrayOut[i]; //decodeTimeStamp = sampleTimingInfo.decodeTimeStamp; - presentationTimeStamp = sampleTimingInfo.presentationTimeStamp; + samplePresentationTimeStamp = sampleTimingInfo.presentationTimeStamp; } // If the size of sample size array is equal to 1, it means every sample has got the same size @@ -1259,16 +1263,15 @@ MP42_OBJC_DIRECT_MEMBERS sample->attachments = (void *)copy; CFDictionaryRef trimStart = CFDictionaryGetValue(sample->attachments, kCMSampleBufferAttachmentKey_TrimDurationAtStart); CMTime trimStartTime = CMTimeMakeFromDictionary(trimStart); - trimStartTime = CMTimeConvertScale(trimStartTime, sampleTimingInfo.duration.value, kCMTimeRoundingMethod_Default); + trimStartTime = CMTimeConvertScale(trimStartTime, currentOutputTimeStamp.timescale, kCMTimeRoundingMethod_Default); currentOutputTimeStamp.value -= trimStartTime.value; - } sample->data = sampleData; - sample->size = sampleSize; + sample->size = (uint32_t)sampleSize; sample->duration = sampleTimingInfo.duration.value; //sample->offset = -decodeTimeStamp.value + presentationTimeStamp.value; - sample->presentationTimestamp = presentationTimeStamp.value; + sample->presentationTimestamp = samplePresentationTimeStamp.value; sample->presentationOutputTimestamp = currentOutputTimeStamp.value; sample->timescale = demuxHelper->timescale; sample->flags |= sync ? MP42SampleBufferFlagIsSync : 0; @@ -1281,7 +1284,7 @@ MP42_OBJC_DIRECT_MEMBERS sample->attachments = (void *)copy; CFDictionaryRef trimEnd = CFDictionaryGetValue(sample->attachments, kCMSampleBufferAttachmentKey_TrimDurationAtEnd); CMTime trimEndTime = CMTimeMakeFromDictionary(trimEnd); - trimEndTime = CMTimeConvertScale(trimEndTime, sampleTimingInfo.duration.value, kCMTimeRoundingMethod_Default); + trimEndTime = CMTimeConvertScale(trimEndTime, currentOutputTimeStamp.timescale, kCMTimeRoundingMethod_Default); currentOutputTimeStamp.value -= trimEndTime.value; } @@ -1301,14 +1304,14 @@ MP42_OBJC_DIRECT_MEMBERS free(sizeArrayOut); } else { - CMTime currentDuration = CMTimeConvertScale(duration, demuxHelper->timescale, kCMTimeRoundingMethod_Default); - CMTime currentTimeStamp = CMTimeConvertScale(presentationTimeStamp, demuxHelper->timescale, kCMTimeRoundingMethod_Default); - CMTime currentOutputTimeStamp = CMTimeConvertScale(presentationOutputTimeStamp, demuxHelper->timescale, kCMTimeRoundingMethod_Default); + CMTime currentSampleDuration = CMTimeConvertScale(duration, demuxHelper->timescale, kCMTimeRoundingMethod_Default); + CMTime currentSampleTimeStamp = CMTimeConvertScale(presentationTimeStamp, demuxHelper->timescale, kCMTimeRoundingMethod_Default); + CMTime currentSampleOutputTimeStamp = CMTimeConvertScale(presentationOutputTimeStamp, demuxHelper->timescale, kCMTimeRoundingMethod_Default); MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init]; - sample->duration = currentDuration.value; - sample->presentationTimestamp = currentTimeStamp.value; - sample->presentationOutputTimestamp = currentOutputTimeStamp.value; + sample->duration = currentSampleDuration.value; + sample->presentationTimestamp = currentSampleTimeStamp.value; + sample->presentationOutputTimestamp = currentSampleOutputTimeStamp.value; sample->timescale = demuxHelper->timescale; sample->flags |= sync ? MP42SampleBufferFlagIsSync : 0; sample->flags |= doNotDisplay ? MP42SampleBufferFlagDoNotDisplay : 0; @@ -1316,7 +1319,7 @@ MP42_OBJC_DIRECT_MEMBERS sample->attachments = (void *)attachments; [demuxHelper->editsConstructor addSample:sample]; - demuxHelper->currentTime = currentOutputTimeStamp.value; + demuxHelper->currentTime = currentSampleOutputTimeStamp.value; } CFRelease(sampleBuffer); @@ -1366,7 +1369,7 @@ MP42_OBJC_DIRECT_MEMBERS AVFDemuxHelper *helper = [self helperWithTrackID:track.sourceId]; MP42EditListsReconstructor *editsConstructor = helper->editsConstructor; - + // Make sure the sample offsets are all positive. if (editsConstructor.minOffset < 0) { MP4SampleId samplesCount = MP4GetTrackNumberOfSamples(fileHandle, trackId); @@ -1374,7 +1377,7 @@ MP42_OBJC_DIRECT_MEMBERS MP4SetSampleRenderingOffset(fileHandle, trackId, 1 + i, - MP4GetSampleRenderingOffset(fileHandle, trackId, 1 + i) - editsConstructor.minOffset); + (int64_t)MP4GetSampleRenderingOffset(fileHandle, trackId, 1 + i) - editsConstructor.minOffset); } } @@ -1439,7 +1442,9 @@ MP42_OBJC_DIRECT_MEMBERS void *sampleData = malloc(bufferSize); CMBlockBufferCopyDataBytes(buffer, 0, bufferSize, sampleData); - analyze_EAC3((void *)&eac3Info, sampleData, bufferSize); + if (bufferSize < UINT32_MAX) { + analyze_EAC3((void *)&eac3Info, sampleData, (uint32_t)bufferSize); + } free(sampleData); count++; @@ -1486,7 +1491,9 @@ MP42_OBJC_DIRECT_MEMBERS pos += sampleSize; } - analyze_EAC3((void *)&eac3Info, sampleData, sampleSize); + if (sampleSize < UINT32_MAX) { + analyze_EAC3((void *)&eac3Info, sampleData, (uint32_t)sampleSize); + } free(sampleData); count++; diff --git a/MP42/MP42AudioConverter.h b/MP42/MP42AudioConverter.h index 1c8f194..c482ada 100644 --- a/MP42/MP42AudioConverter.h +++ b/MP42/MP42AudioConverter.h @@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)addSample:(MP42SampleBuffer *)sample; - (nullable MP42SampleBuffer *)copyEncodedSample; -@property (nonatomic, readonly) NSData *magicCookie; +@property (nonatomic, readonly, nullable) NSData *magicCookie; @property (nonatomic, readonly) double sampleRate; NS_ASSUME_NONNULL_END diff --git a/MP42/MP42AudioConverter.m b/MP42/MP42AudioConverter.m index 5510007..b44ae81 100644 --- a/MP42/MP42AudioConverter.m +++ b/MP42/MP42AudioConverter.m @@ -131,7 +131,7 @@ MP42_OBJC_DIRECT_MEMBERS return [_encoder copyEncodedSample]; } -- (NSData *)magicCookie { +- (nullable NSData *)magicCookie { return _encoder.magicCookie; } diff --git a/MP42/MP42AudioDecoder.h b/MP42/MP42AudioDecoder.h index ae5d7a6..4bbc0fa 100644 --- a/MP42/MP42AudioDecoder.h +++ b/MP42/MP42AudioDecoder.h @@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN mixdownType:(MP42AudioMixdown)mixdownType drc:(float)drc initialPadding:(UInt32)initialPadding - magicCookie:(NSData *)magicCookie + magicCookie:(nullable NSData *)magicCookie error:(NSError * __autoreleasing *)error; @property (nonatomic, readonly, nullable) AudioChannelLayout *inputLayout; diff --git a/MP42/MP42AudioDecoder.m b/MP42/MP42AudioDecoder.m index f53d92e..8f594cb 100644 --- a/MP42/MP42AudioDecoder.m +++ b/MP42/MP42AudioDecoder.m @@ -33,7 +33,7 @@ struct MP42DecodeContext { AudioStreamBasicDescription *outputFormat; enum AVMatrixEncoding matrix_encoding; - int out_layout; + uint64_t out_layout; int drop_samples; @@ -72,7 +72,7 @@ MP42_OBJC_DIRECT_MEMBERS mixdownType:(MP42AudioMixdown)mixdownType drc:(float)drc initialPadding:(UInt32)initialPadding - magicCookie:(NSData *)magicCookie + magicCookie:(nullable NSData *)magicCookie error:(NSError * __autoreleasing *)error { self = [super init]; @@ -101,10 +101,16 @@ MP42_OBJC_DIRECT_MEMBERS av_freep(&_avctx); return nil; } - else { - _avctx->extradata_size = magicCookie.length; + else if (magicCookie.length < UINT32_MAX) { + _avctx->extradata_size = (uint32_t)magicCookie.length; memcpy(_avctx->extradata, magicCookie.bytes, magicCookie.length); } + else + { + NSLog(@"Could not av_malloc extradata"); + av_freep(&_avctx); + return nil; + } } AVDictionary *av_opts = NULL; diff --git a/MP42/MP42AudioEncoder.h b/MP42/MP42AudioEncoder.h index 75a14ea..8391607 100644 --- a/MP42/MP42AudioEncoder.h +++ b/MP42/MP42AudioEncoder.h @@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN @interface MP42AudioEncoder : NSObject -- (instancetype)initWithInputUnit:(id)unit bitRate:(NSUInteger)bitRate error:(NSError * __autoreleasing *)error; +- (instancetype)initWithInputUnit:(id)unit bitRate:(UInt32)bitRate error:(NSError * __autoreleasing *)error; @property (nonatomic, readonly, nullable) AudioChannelLayout *inputLayout; @property (nonatomic, readonly) UInt32 inputLayoutSize; @@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) AudioCodecPrimeInfo primeInfo; -@property (nonatomic, readonly) NSData *magicCookie; +@property (nonatomic, readonly, nullable) NSData *magicCookie; @end diff --git a/MP42/MP42AudioEncoder.m b/MP42/MP42AudioEncoder.m index 3b3ad79..8858520 100644 --- a/MP42/MP42AudioEncoder.m +++ b/MP42/MP42AudioEncoder.m @@ -47,7 +47,7 @@ MP42_OBJC_DIRECT_MEMBERS } @property (nonatomic, readonly) AudioConverterRef encoder; -@property (nonatomic, readonly) NSUInteger bitrate; +@property (nonatomic, readonly) UInt32 bitrate; @property (nonatomic, readonly) NSThread *thread; @property (nonatomic, readonly) MP42Fifo *inputSamplesBuffer; @@ -67,7 +67,7 @@ MP42_OBJC_DIRECT_MEMBERS @synthesize magicCookie = _magicCookie; -- (instancetype)initWithInputUnit:(id)unit bitRate:(NSUInteger)bitRate error:(NSError * __autoreleasing *)error +- (instancetype)initWithInputUnit:(id)unit bitRate:(UInt32)bitRate error:(NSError * __autoreleasing *)error { self = [super init]; if (self) { @@ -92,7 +92,7 @@ MP42_OBJC_DIRECT_MEMBERS #pragma mark - Encoder Init -- (BOOL)initConverterWithBitRate:(NSUInteger)bitrate +- (BOOL)initConverterWithBitRate:(UInt32)bitrate { OSStatus err; AudioStreamBasicDescription outputFormat; @@ -317,7 +317,7 @@ MP42_OBJC_DIRECT_MEMBERS } } -- (NSData *)magicCookie +- (nullable NSData *)magicCookie { return _magicCookie; } diff --git a/MP42/MP42AudioTrack.m b/MP42/MP42AudioTrack.m index 6f399be..3f257fc 100644 --- a/MP42/MP42AudioTrack.m +++ b/MP42/MP42AudioTrack.m @@ -18,7 +18,7 @@ MP42_OBJC_DIRECT_MEMBERS @implementation MP42AudioTrack -- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP4FileHandle)fileHandle +- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(MP42TrackId)trackID fileHandle:(MP4FileHandle)fileHandle { self = [super initWithSourceURL:URL trackID:trackID fileHandle:fileHandle]; @@ -65,7 +65,7 @@ MP42_OBJC_DIRECT_MEMBERS if (audioType == 0xA9) { uint64_t channels_count = 0; MP4GetTrackIntegerProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.mp4a.channels", &channels_count); - _channels = channels_count; + _channels = (UInt32)channels_count; } } else if (MP4HaveTrackAtom(fileHandle, self.trackId, "mdia.minf.stbl.stsd.ac-3.dac3")) { @@ -90,13 +90,13 @@ MP42_OBJC_DIRECT_MEMBERS else if (MP4HaveTrackAtom(fileHandle, self.trackId, "mdia.minf.stbl.stsd.alac")) { uint64_t channels_count = 0; MP4GetTrackIntegerProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.alac.channels", &channels_count); - _channels = channels_count; + _channels = (UInt32)channels_count; } else if (MP4HaveTrackAtom(fileHandle, self.trackId, "mdia.minf.stbl.stsd.twos")) { uint64_t channels_count = 0; MP4GetTrackIntegerProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.twos.channels", &channels_count); - _channels = channels_count; - _channelLayoutTag = getDefaultChannelLayout(channels_count); + _channels = (UInt32)channels_count; + _channelLayoutTag = getDefaultChannelLayout((UInt32)channels_count); } if (MP4HaveTrackAtom(fileHandle, self.trackId, "tref.fall")) { @@ -161,8 +161,9 @@ MP42_OBJC_DIRECT_MEMBERS if (self.updatedProperty[@"fallback"] || !self.muxed) { - if (_fallbackTrack) { - _fallbackTrackId = _fallbackTrack.trackId; + MP42Track *fallbackTrack = _fallbackTrack; + if (fallbackTrack) { + _fallbackTrackId = fallbackTrack.trackId; } if (MP4HaveTrackAtom(fileHandle, self.trackId, "tref.fall") && (_fallbackTrackId == 0)) { @@ -178,8 +179,9 @@ MP42_OBJC_DIRECT_MEMBERS if (self.updatedProperty[@"follows"] || !self.muxed) { - if (_followsTrack) { - _followsTrackId = _followsTrack.trackId; + MP42Track *followsTrack = _followsTrack; + if (followsTrack) { + _followsTrackId = followsTrack.trackId; } if (MP4HaveTrackAtom(fileHandle, self.trackId, "tref.folw") && (_followsTrackId == 0)) { @@ -286,12 +288,12 @@ MP42_OBJC_DIRECT_MEMBERS [coder encodeFloat:_volume forKey:@"volume"]; - [coder encodeInt64:_channels forKey:@"channels"]; - [coder encodeInt64:_channelLayoutTag forKey:@"channelLayoutTag"]; + [coder encodeInt32:_channels forKey:@"channels"]; + [coder encodeInt32:_channelLayoutTag forKey:@"channelLayoutTag"]; - [coder encodeInteger:_extensionType forKey:@"extensionType"]; + [coder encodeInt32:_extensionType forKey:@"extensionType"]; - [coder encodeInt64:_fallbackTrackId forKey:@"fallbackTrackId"]; + [coder encodeInt32:_fallbackTrackId forKey:@"fallbackTrackId"]; } - (id)initWithCoder:(NSCoder *)decoder @@ -301,12 +303,12 @@ MP42_OBJC_DIRECT_MEMBERS if (self) { _volume = [decoder decodeFloatForKey:@"volume"]; - _channels = [decoder decodeInt64ForKey:@"channels"]; - _channelLayoutTag = [decoder decodeInt64ForKey:@"channelLayoutTag"]; + _channels = [decoder decodeInt32ForKey:@"channels"]; + _channelLayoutTag = [decoder decodeInt32ForKey:@"channelLayoutTag"]; - _extensionType = [decoder decodeIntegerForKey:@"extensionType"]; + _extensionType = [decoder decodeInt32ForKey:@"extensionType"]; - _fallbackTrackId = [decoder decodeInt64ForKey:@"fallbackTrackId"]; + _fallbackTrackId = [decoder decodeInt32ForKey:@"fallbackTrackId"]; } return self; diff --git a/MP42/MP42BitmapSubConverter.m b/MP42/MP42BitmapSubConverter.m index 875a439..eaf122d 100644 --- a/MP42/MP42BitmapSubConverter.m +++ b/MP42/MP42BitmapSubConverter.m @@ -59,8 +59,7 @@ MP42_OBJC_DIRECT_MEMBERS - (CIContext *)imgContext { if (!_imgContext) { - _imgContext = [CIContext contextWithCGContext:[[NSGraphicsContext currentContext] CGContext] - options:nil]; + _imgContext = [[CIContext alloc] init]; } return _imgContext; } diff --git a/MP42/MP42CCImporter.m b/MP42/MP42CCImporter.m index 08d2697..7e9c44b 100644 --- a/MP42/MP42CCImporter.m +++ b/MP42/MP42CCImporter.m @@ -37,7 +37,7 @@ MP42_OBJC_DIRECT_MEMBERS return self; } -- (NSUInteger)timescaleForTrack:(MP42Track *)track +- (UInt32)timescaleForTrack:(MP42Track *)track { return 30000; } @@ -229,7 +229,7 @@ static int ParseByte(const char *string, UInt8 *byte, Boolean hex) MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init]; sample->data = bytes; - sample->size = byteCount + 8; + sample->size = (uint32_t)byteCount + 8; sample->duration = sampleDuration * 1001; sample->offset = 0; sample->decodeTimestamp = 0; diff --git a/MP42/MP42ChapterTrack.h b/MP42/MP42ChapterTrack.h index 7480d6a..1822aa2 100644 --- a/MP42/MP42ChapterTrack.h +++ b/MP42/MP42ChapterTrack.h @@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN @interface MP42ChapterTrack : MP42Track -- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP42FileHandle)fileHandle; +- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(MP42TrackId)trackID fileHandle:(MP42FileHandle)fileHandle; + (instancetype)chapterTrackFromFile:(NSURL *)URL; - (NSUInteger)addChapter:(MP42TextSample *)chapter; diff --git a/MP42/MP42ChapterTrack.m b/MP42/MP42ChapterTrack.m index b5453ec..3dccf5d 100644 --- a/MP42/MP42ChapterTrack.m +++ b/MP42/MP42ChapterTrack.m @@ -34,7 +34,7 @@ MP42_OBJC_DIRECT_MEMBERS return self; } -- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP4FileHandle)fileHandle +- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(MP42TrackId)trackID fileHandle:(MP4FileHandle)fileHandle { self = [super initWithSourceURL:URL trackID:trackID fileHandle:fileHandle]; @@ -104,7 +104,7 @@ MP42_OBJC_DIRECT_MEMBERS - (NSString *)defaultName { NSBundle *bundle = [NSBundle bundleForClass:[MP42ChapterTrack class]]; - return NSLocalizedStringFromTableInBundle(@"Chapter Track", @"Localizable", bundle, nil); + return NSLocalizedStringFromTableInBundle(@"Chapter Track", @"Localizable", bundle, @"Default Chapter Track name"); } - (NSUInteger)addChapter:(MP42TextSample *)chapter @@ -198,7 +198,7 @@ MP42_OBJC_DIRECT_MEMBERS refTrack = 1; } - chapterCount = _chapters.count; + chapterCount = (uint32_t)_chapters.count; if (chapterCount) { // Insert a chapter at time 0 if there isn't one @@ -282,7 +282,7 @@ MP42_OBJC_DIRECT_MEMBERS - (BOOL)exportToURL:(NSURL *)url error:(NSError * __autoreleasing *)error { - NSMutableString* file = [[NSMutableString alloc] init]; + NSMutableString *file = [[NSMutableString alloc] init]; NSUInteger x = 0; for (MP42TextSample *chapter in _chapters) { @@ -294,11 +294,11 @@ MP42_OBJC_DIRECT_MEMBERS } - (BOOL)updateFromCSVFile:(NSURL *)URL error:(NSError * __autoreleasing *)outError { - NSArray *csvData = [NSArray arrayWithContentsOfCSVURL:URL]; + NSArray *> *csvData = [NSArray arrayWithContentsOfCSVURL:URL]; if (csvData.count == self.chapterCount) { for (NSUInteger i = 0; i < csvData.count; ++i) { - NSArray *lineFields = csvData[i]; - if (lineFields.count != 2 || [lineFields[0] integerValue] != i + 1) { + NSArray *lineFields = csvData[i]; + if (lineFields.count != 2 || lineFields[0].integerValue != i + 1) { if (NULL != outError) *outError = MP42Error(MP42LocalizedString(@"Invalid chapters CSV file.", @"error message"), MP42LocalizedString(@"The CSV file is not a valid chapters CSV file.", @"error message"), @@ -376,7 +376,7 @@ MP42_OBJC_DIRECT_MEMBERS // // // -+ (nullable NSArray *> *)arrayWithContentsOfCSVURL:(NSURL *)url; ++ (nullable NSArray *> *)arrayWithContentsOfCSVURL:(NSURL *)url { NSString *str1 = STLoadFileWithUnknownEncoding(url); NSMutableString *csvString = STStandardizeStringNewlines(str1); @@ -386,7 +386,7 @@ MP42_OBJC_DIRECT_MEMBERS if ([csvString characterAtIndex:[csvString length]-1] != '\n') [csvString appendFormat:@"%c",'\n']; NSScanner *sc = [NSScanner scannerWithString:csvString]; sc.charactersToBeSkipped = nil; - NSMutableArray *csvArray = [NSMutableArray array]; + NSMutableArray *> *csvArray = [NSMutableArray array]; [csvArray addObject:[NSMutableArray array]]; NSCharacterSet *commaNewlineCS = [NSCharacterSet characterSetWithCharactersInString:@",\n"]; while (sc.scanLocation < csvString.length) { diff --git a/MP42/MP42ConversionSettings.h b/MP42/MP42ConversionSettings.h index 0310fc6..b72f64d 100644 --- a/MP42/MP42ConversionSettings.h +++ b/MP42/MP42ConversionSettings.h @@ -21,11 +21,11 @@ NS_ASSUME_NONNULL_BEGIN @interface MP42AudioConversionSettings : MP42ConversionSettings -+ (instancetype)audioConversionWithBitRate:(NSUInteger)bitrate mixDown:(MP42AudioMixdown)mixDown drc:(float)drc; ++ (instancetype)audioConversionWithBitRate:(UInt32)bitrate mixDown:(MP42AudioMixdown)mixDown drc:(float)drc; -- (instancetype)initWithFormat:(FourCharCode)format bitRate:(NSUInteger)bitRate mixDown:(MP42AudioMixdown)mixDown drc:(float)drc; +- (instancetype)initWithFormat:(FourCharCode)format bitRate:(UInt32)bitRate mixDown:(MP42AudioMixdown)mixDown drc:(float)drc; -@property (nonatomic, readonly) NSUInteger bitRate; +@property (nonatomic, readonly) UInt32 bitRate; @property (nonatomic, readonly) MP42AudioMixdown mixDown; @property (nonatomic, readonly) float drc; diff --git a/MP42/MP42ConversionSettings.m b/MP42/MP42ConversionSettings.m index fca520e..1ad2189 100644 --- a/MP42/MP42ConversionSettings.m +++ b/MP42/MP42ConversionSettings.m @@ -48,14 +48,14 @@ - (void)encodeWithCoder:(NSCoder *)coder { [coder encodeInt:1 forKey:@"MP42ConversionSettingsVersion"]; - [coder encodeInteger:_format forKey:@"format"]; + [coder encodeInt32:_format forKey:@"format"]; } - (id)initWithCoder:(NSCoder *)decoder { self = [super init]; - _format = [decoder decodeIntegerForKey:@"format"]; + _format = [decoder decodeInt32ForKey:@"format"]; return self; } @@ -64,12 +64,12 @@ @implementation MP42AudioConversionSettings -+ (instancetype)audioConversionWithBitRate:(NSUInteger)bitRate mixDown:(MP42AudioMixdown)mixDown drc:(float)drc ++ (instancetype)audioConversionWithBitRate:(UInt32)bitRate mixDown:(MP42AudioMixdown)mixDown drc:(float)drc { return [[MP42AudioConversionSettings alloc] initWithFormat:kMP42AudioCodecType_MPEG4AAC bitRate:bitRate mixDown:mixDown drc:drc]; } -- (instancetype)initWithFormat:(FourCharCode)format bitRate:(NSUInteger)bitRate mixDown:(MP42AudioMixdown)mixDown drc:(float)drc +- (instancetype)initWithFormat:(FourCharCode)format bitRate:(UInt32)bitRate mixDown:(MP42AudioMixdown)mixDown drc:(float)drc { self = [super initWitFormat:format]; if (self) { @@ -104,8 +104,8 @@ - (void)encodeWithCoder:(NSCoder *)coder { - [coder encodeInteger:_bitRate forKey:@"bitRate"]; - [coder encodeInteger:_mixDown forKey:@"mixDownType"]; + [coder encodeInt32:_bitRate forKey:@"bitRate"]; + [coder encodeInt32:_mixDown forKey:@"mixDownType"]; [coder encodeFloat:_drc forKey:@"drc"]; } @@ -113,8 +113,8 @@ { self = [super initWithCoder:decoder]; - _bitRate = [decoder decodeIntegerForKey:@"bitRate"]; - _mixDown = [decoder decodeIntegerForKey:@"mixDownType"]; + _bitRate = [decoder decodeInt32ForKey:@"bitRate"]; + _mixDown = [decoder decodeInt32ForKey:@"mixDownType"]; _drc = [decoder decodeFloatForKey:@"drc"]; return self; diff --git a/MP42/MP42ConverterProtocol.h b/MP42/MP42ConverterProtocol.h index 2897a0b..12ae0cd 100644 --- a/MP42/MP42ConverterProtocol.h +++ b/MP42/MP42ConverterProtocol.h @@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN @protocol MP42ConverterProtocol @optional -- (NSData *)magicCookie; +- (nullable NSData *)magicCookie; @required - (void)addSample:(MP42SampleBuffer *)sample; diff --git a/MP42/MP42File.m b/MP42/MP42File.m index d23826b..ff4986c 100644 --- a/MP42/MP42File.m +++ b/MP42/MP42File.m @@ -161,7 +161,7 @@ MP42_OBJC_DIRECT_MEMBERS return self; } -- (instancetype)initWithURL:(NSURL *)URL error:(NSError * _Nullable *)error { +- (instancetype)initWithURL:(NSURL *)URL error:(NSError * _Nullable __autoreleasing *)error { self = [super init]; if (self) { _URL = [URL fileReferenceURL]; @@ -214,7 +214,7 @@ MP42_OBJC_DIRECT_MEMBERS MP4TrackId chapterId = findChapterTrackId(_fileHandle); MP4TrackId previewsId = findChapterPreviewTrackId(_fileHandle); - for (int i = 0; i< tracksCount; i++) { + for (uint32_t i = 0; i < tracksCount; i++) { id track; MP4TrackId trackId = MP4FindTrackId(_fileHandle, i, 0, 0); const char *type = MP4GetTrackType(_fileHandle, trackId); @@ -477,7 +477,8 @@ MP42_OBJC_DIRECT_MEMBERS if ([track isMemberOfClass:[MP42AudioTrack class]]) { MP42AudioTrack *audioTrack = (MP42AudioTrack *)track; - if (audioTrack.fallbackTrack && ![self.itracks containsObject:audioTrack.fallbackTrack]) { + MP42Track *fallbackTrack = audioTrack.fallbackTrack; + if (fallbackTrack && ![self.itracks containsObject:fallbackTrack]) { audioTrack.fallbackTrack = nil; } } @@ -611,15 +612,17 @@ MP42_OBJC_DIRECT_MEMBERS NSMutableArray *tracks = [NSMutableArray array]; if ([track isKindOfClass:[MP42AudioTrack class]]) { MP42AudioTrack *audioTrack = (MP42AudioTrack *)track; - if (audioTrack.fallbackTrack) { - [tracks addObject:audioTrack.fallbackTrack]; + MP42Track *fallbackTrack = audioTrack.fallbackTrack; + if (fallbackTrack) { + [tracks addObject:fallbackTrack]; } } if ([track isKindOfClass:[MP42SubtitleTrack class]]) { MP42SubtitleTrack *subTrack = (MP42SubtitleTrack *)track; - if (subTrack.forcedTrack) { - [tracks addObject:subTrack.forcedTrack]; + MP42Track *forcedTrack = subTrack.forcedTrack; + if (forcedTrack) { + [tracks addObject:forcedTrack]; } } return tracks; @@ -709,9 +712,9 @@ MP42_OBJC_DIRECT_MEMBERS for (MP42Track *track in subGroup) { if ([track.mediaCharacteristicTags containsObject:@"public.main-program-content"] == NO) { - NSMutableSet *tags = [track.mediaCharacteristicTags mutableCopy]; - [tags addObject:@"public.auxiliary-content"]; - [self setTrack:track mediaCharacteristics:tags]; + NSMutableSet *subGroupTags = [track.mediaCharacteristicTags mutableCopy]; + [subGroupTags addObject:@"public.auxiliary-content"]; + [self setTrack:track mediaCharacteristics:subGroupTags]; } } } @@ -1107,7 +1110,7 @@ MP42_OBJC_DIRECT_MEMBERS MP4SetTrackDisabled(self.fileHandle, jpegTrack); MP4SampleId samplesCount = MP4GetTrackNumberOfSamples(self.fileHandle, chapterTrack.trackId); - NSUInteger idx = 1; + uint32_t idx = 1; for (MP42TextSample *chapterT in chapterTrack.chapters) { if (idx > samplesCount) { @@ -1144,13 +1147,15 @@ MP42_OBJC_DIRECT_MEMBERS imageData = [bitmap representationUsingType:NSBitmapImageFileTypeJPEG properties:@{}]; } - MP4WriteSample(self.fileHandle, - jpegTrack, - imageData.bytes, - imageData.length, - duration, - 0, - true); + if (imageData.length < UINT32_MAX) { + MP4WriteSample(self.fileHandle, + jpegTrack, + imageData.bytes, + (uint32_t)imageData.length, + duration, + 0, + true); + } } MP4RemoveAllTrackReferences(self.fileHandle, "tref.chap", videoTrack.trackId); diff --git a/MP42/MP42FileImporter.h b/MP42/MP42FileImporter.h index 0ce1f75..6c2c178 100644 --- a/MP42/MP42FileImporter.h +++ b/MP42/MP42FileImporter.h @@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Override -- (NSUInteger)timescaleForTrack:(MP42Track *)track; +- (UInt32)timescaleForTrack:(MP42Track *)track; - (NSSize)sizeForTrack:(MP42VideoTrack *)track; - (nullable NSData *)magicCookieForTrack:(MP42Track *)track; - (AudioStreamBasicDescription)audioDescriptionForTrack:(MP42AudioTrack *)track; diff --git a/MP42/MP42FileImporter.m b/MP42/MP42FileImporter.m index 81b7459..8404598 100644 --- a/MP42/MP42FileImporter.m +++ b/MP42/MP42FileImporter.m @@ -81,7 +81,7 @@ static NSArray *_supportedFileFormats; return [[self supportedFileFormats] containsObject:fileType.lowercaseString]; } -- (instancetype)initWithURL:(NSURL *)fileURL error:(NSError * __autoreleasing *)error; +- (instancetype)initWithURL:(NSURL *)fileURL error:(NSError * __autoreleasing *)error { self = nil; @@ -230,7 +230,7 @@ static NSArray *_supportedFileFormats; #pragma mark - Override -- (NSUInteger)timescaleForTrack:(MP42Track *)track +- (UInt32)timescaleForTrack:(MP42Track *)track { @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:[NSString stringWithFormat:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)] @@ -265,7 +265,7 @@ static NSArray *_supportedFileFormats; userInfo:nil]; } -- (BOOL)audioTrackUsesExplicitEncoderDelay:(MP42Track *)track; +- (BOOL)audioTrackUsesExplicitEncoderDelay:(MP42Track *)track { return NO; } diff --git a/MP42/MP42FormatUtilites.mm b/MP42/MP42FormatUtilites.mm index a832056..df690df 100644 --- a/MP42/MP42FormatUtilites.mm +++ b/MP42/MP42FormatUtilites.mm @@ -13,7 +13,7 @@ #import /* write the data to the target adress & then return a pointer which points after the written data */ -uint8_t *write_data(uint8_t *target, uint8_t* data, int32_t data_size) +uint8_t *write_data(uint8_t *target, uint8_t* data, size_t data_size) { if(data_size > 0) memcpy(target, data, data_size); @@ -96,16 +96,16 @@ ComponentResult ReadESDSDescExt(void* descExt, UInt8 **buffer, int *size, int ve } // the esds atom creation is based off of the routines for it in ffmpeg's movenc.c -static unsigned int descrLength(unsigned int len) +static size_t descrLength(size_t len) { int i; for(i=1; len>>(7*i); i++); return len + 1 + i; } -static uint8_t* putDescr(uint8_t *buffer, int tag, unsigned int size) +static uint8_t* putDescr(uint8_t *buffer, int tag, size_t size) { - int i= descrLength(size) - size - 2; + size_t i= descrLength(size) - size - 2; *buffer++ = tag; for(; i>0; i--) *buffer++ = (size>>(7*i)) | 0x80; @@ -131,7 +131,7 @@ static uint8_t* putDescr(uint8_t *buffer, int tag, unsigned int size) uint8_t *CreateEsdsFromSetupData(uint8_t *codecPrivate, size_t vosLen, size_t *esdsLen, int trackID, bool audio, bool write_version) { - int decoderSpecificInfoLen = vosLen ? descrLength(vosLen) : 0; + size_t decoderSpecificInfoLen = vosLen ? descrLength(vosLen) : 0; int versionLen = write_version ? 4 : 0; *esdsLen = versionLen + descrLength(3 + descrLength(13 + decoderSpecificInfoLen) + descrLength(1)); @@ -458,9 +458,9 @@ typedef enum { } DEC3ChanLoc; const uint16_t ff_ac3_dec3_chap_map[16][2] = { - {AC3_CUSTOM_CHANNEL_MAP_LFE , NULL}, + {AC3_CUSTOM_CHANNEL_MAP_LFE , 0}, {AC3_CUSTOM_CHANNEL_MAP_LFE2 , DEC3_CUSTOM_CHANNEL_MAP_LFE2}, - {AC3_CUSTOM_CHANNEL_MAP_LTS_RTS_PAIR , NULL}, + {AC3_CUSTOM_CHANNEL_MAP_LTS_RTS_PAIR , 0}, {AC3_CUSTOM_CHANNEL_MAP_VHC , DEC3_CUSTOM_CHANNEL_MAP_VHC}, {AC3_CUSTOM_CHANNEL_MAP_VHL_VHR_PAIR , DEC3_CUSTOM_CHANNEL_MAP_VHL_VHR_PAIR}, {AC3_CUSTOM_CHANNEL_MAP_LW_RW_PAIR , DEC3_CUSTOM_CHANNEL_MAP_LW_RW_PAIR}, @@ -469,11 +469,11 @@ const uint16_t ff_ac3_dec3_chap_map[16][2] = { {AC3_CUSTOM_CHANNEL_MAP_CS , DEC3_CUSTOM_CHANNEL_MAP_CS}, {AC3_CUSTOM_CHANNEL_MAP_LRS_RRS_PAIR , DEC3_CUSTOM_CHANNEL_MAP_LRS_RRS_PAIR}, {AC3_CUSTOM_CHANNEL_MAP_LC_RC_PAIR , DEC3_CUSTOM_CHANNEL_MAP_LC_RC_PAIR}, - {AC3_CUSTOM_CHANNEL_MAP_RIGHT_SURROUND , NULL}, - {AC3_CUSTOM_CHANNEL_MAP_LEFT_SURROUND , NULL}, - {AC3_CUSTOM_CHANNEL_MAP_RIGHT , NULL}, - {AC3_CUSTOM_CHANNEL_MAP_CENTRE , NULL}, - {AC3_CUSTOM_CHANNEL_MAP_LEFT , NULL}, + {AC3_CUSTOM_CHANNEL_MAP_RIGHT_SURROUND , 0}, + {AC3_CUSTOM_CHANNEL_MAP_LEFT_SURROUND , 0}, + {AC3_CUSTOM_CHANNEL_MAP_RIGHT , 0}, + {AC3_CUSTOM_CHANNEL_MAP_CENTRE , 0}, + {AC3_CUSTOM_CHANNEL_MAP_LEFT , 0}, }; uint16_t ac3_to_dec3_chan_map(uint16_t ac3_chan_loc) { diff --git a/MP42/MP42H264Importer.mm b/MP42/MP42H264Importer.mm index a94d81e..91f27e6 100644 --- a/MP42/MP42H264Importer.mm +++ b/MP42/MP42H264Importer.mm @@ -1355,6 +1355,7 @@ NSData* H264Info(const char *filePath, uint32_t *pic_width, uint32_t *pic_height uint32_t iy = 0; NSMutableData *pictData = [[NSMutableData alloc] init]; + //WTF uint16_t temp = buffersize << 8; [pictData appendBytes:&temp length:sizeof(uint16_t)]; [pictData appendBytes:buffer length:buffersize]; @@ -1422,7 +1423,7 @@ MP42_OBJC_DIRECT_MEMBERS return self; } -- (NSUInteger)timescaleForTrack:(MP42Track *)track +- (UInt32)timescaleForTrack:(MP42Track *)track { framerate_t *framerate; diff --git a/MP42/MP42Languages.m b/MP42/MP42Languages.m index c6d9705..3a45609 100644 --- a/MP42/MP42Languages.m +++ b/MP42/MP42Languages.m @@ -857,7 +857,7 @@ MP42_OBJC_DIRECT_MEMBERS return [self extendedTagForISO_639_2:@(lang->iso639_2)]; } -- (NSString *)extendedTagForQTCode:(NSString *)code; +- (NSString *)extendedTagForQTCode:(NSString *)code { iso639_lang_t *lang = lang_for_qtcode(code.integerValue); if (strlen(lang->iso639_1)) { @@ -868,7 +868,7 @@ MP42_OBJC_DIRECT_MEMBERS } } -- (NSString *)extendedTagForISO_639_1:(NSString *)code; +- (NSString *)extendedTagForISO_639_1:(NSString *)code { iso639_lang_t *lang = lang_for_code_s(code.UTF8String); if (strlen(lang->iso639_1)) { @@ -879,7 +879,7 @@ MP42_OBJC_DIRECT_MEMBERS } } -- (NSString *)extendedTagForISO_639_2:(NSString *)code2; +- (NSString *)extendedTagForISO_639_2:(NSString *)code2 { NSString *code = _ISO_639_2CodeToCode[code2]; if (!code) { diff --git a/MP42/MP42Metadata.m b/MP42/MP42Metadata.m index 5002783..96db7f1 100644 --- a/MP42/MP42Metadata.m +++ b/MP42/MP42Metadata.m @@ -50,7 +50,7 @@ return self; } -- (nullable instancetype)initWithURL:(NSURL *)URL; +- (nullable instancetype)initWithURL:(NSURL *)URL { self = [self init]; if (self) { @@ -814,8 +814,11 @@ [self addMetadataItemWithStringArray:tag identifier:MP42MetadataKeyScreenwriters]; } - if ([tag = dma[@"studio"] length]) { - [self addMetadataItemWithString:tag identifier:MP42MetadataKeyStudio]; + if ((tag = dma[@"studio"]) != nil && [tag isKindOfClass:[NSString class]]) { + NSString *studio = tag; + if (studio.length) { + [self addMetadataItemWithString:tag identifier:MP42MetadataKeyStudio]; + } } } } @@ -940,7 +943,7 @@ MP4TagsSetTVEpisodeID (tags, self.itemsMap[MP42MetadataKeyTVEpisodeID].stringValue.UTF8String); if (self.itemsMap[MP42MetadataKeyTVSeason]) { - const uint32_t value = self.itemsMap[MP42MetadataKeyTVSeason].numberValue.integerValue; + const uint32_t value = self.itemsMap[MP42MetadataKeyTVSeason].numberValue.intValue; MP4TagsSetTVSeason(tags, &value); } else { @@ -948,7 +951,7 @@ } if (self.itemsMap[MP42MetadataKeyTVEpisodeNumber]) { - const uint32_t i = self.itemsMap[MP42MetadataKeyTVEpisodeNumber].numberValue.integerValue; + const uint32_t i = self.itemsMap[MP42MetadataKeyTVEpisodeNumber].numberValue.intValue; MP4TagsSetTVEpisode(tags, &i); } else { @@ -1025,7 +1028,7 @@ } if (self.itemsMap[MP42MetadataKeyAccountCountry]) { - const uint32_t i = self.itemsMap[MP42MetadataKeyAccountCountry].numberValue.integerValue; + const uint32_t i = self.itemsMap[MP42MetadataKeyAccountCountry].numberValue.intValue; MP4TagsSetITunesCountry(tags, &i); } else { @@ -1033,7 +1036,7 @@ } if (self.itemsMap[MP42MetadataKeyContentID]) { - const uint32_t i = self.itemsMap[MP42MetadataKeyContentID].numberValue.integerValue; + const uint32_t i = self.itemsMap[MP42MetadataKeyContentID].numberValue.intValue; MP4TagsSetContentID(tags, &i); } else { @@ -1041,7 +1044,7 @@ } if (self.itemsMap[MP42MetadataKeyGenreID]) { - const uint32_t i = self.itemsMap[MP42MetadataKeyGenreID].numberValue.integerValue; + const uint32_t i = self.itemsMap[MP42MetadataKeyGenreID].numberValue.intValue; MP4TagsSetGenreID(tags, &i); } else { @@ -1049,7 +1052,7 @@ } if (self.itemsMap[MP42MetadataKeyArtistID]) { - const uint32_t i = self.itemsMap[MP42MetadataKeyArtistID].numberValue.integerValue; + const uint32_t i = self.itemsMap[MP42MetadataKeyArtistID].numberValue.intValue; MP4TagsSetArtistID(tags, &i); } else { @@ -1065,7 +1068,7 @@ } if (self.itemsMap[MP42MetadataKeyComposerID]) { - const uint32_t i = self.itemsMap[MP42MetadataKeyComposerID].numberValue.integerValue; + const uint32_t i = self.itemsMap[MP42MetadataKeyComposerID].numberValue.intValue; MP4TagsSetComposerID(tags, &i); } else { @@ -1093,23 +1096,21 @@ artwork = (MP42Image *)artworks[i].value; - if (artwork.data) { - + if (artwork.data && artwork.data.length < UINT32_MAX) { newArtwork.data = (void *)artwork.data.bytes; - newArtwork.size = artwork.data.length; + newArtwork.size = (uint32_t)artwork.data.length; newArtwork.type = (MP4TagArtworkType)artwork.type; } else { - NSArray *representations = artwork.image.representations; if (representations.count) { NSData *bitmapData = [NSBitmapImageRep representationOfImageRepsInArray:representations usingType:NSBitmapImageFileTypePNG properties:@{}]; - if (bitmapData) { + if (bitmapData && bitmapData.length < UINT32_MAX) { newArtwork.data = (void *)bitmapData.bytes; - newArtwork.size = bitmapData.length; + newArtwork.size = (uint32_t)bitmapData.length; newArtwork.type = MP4_ART_PNG; } } @@ -1117,8 +1118,7 @@ if (tags->artworkCount > i) { MP4TagsSetArtwork(tags, i, &newArtwork); - } - else { + } else { MP4TagsAddArtwork(tags, &newArtwork); } } @@ -1154,11 +1154,14 @@ if (ratingString) { data->typeCode = MP4_ITMF_BT_UTF8; - data->valueSize = strlen(ratingString.UTF8String); - data->value = (uint8_t *)malloc(data->valueSize); - memcpy(data->value, ratingString.UTF8String, data->valueSize); + size_t len = strlen(ratingString.UTF8String); + if (len < UINT32_MAX) { + data->valueSize = (uint32_t)len; + data->value = (uint8_t *)malloc(data->valueSize); + memcpy(data->value, ratingString.UTF8String, data->valueSize); - MP4ItmfAddItem(fileHandle, newItem); + MP4ItmfAddItem(fileHandle, newItem); + } } MP4ItmfItemFree(newItem); @@ -1257,9 +1260,11 @@ MP4ItmfData *data = &newItem->dataList.elements[0]; data->typeCode = MP4_ITMF_BT_UTF8; - data->valueSize = [serializedPlist length]; - data->value = (uint8_t*)malloc( data->valueSize ); - memcpy( data->value, [serializedPlist bytes], data->valueSize ); + if (serializedPlist.length < UINT32_MAX) { + data->valueSize = (uint32_t)serializedPlist.length; + data->value = (uint8_t*)malloc(data->valueSize); + memcpy(data->value, serializedPlist.bytes, data->valueSize); + } MP4ItmfAddItem(fileHandle, newItem); MP4ItmfItemFree(newItem); diff --git a/MP42/MP42MetadataItem.m b/MP42/MP42MetadataItem.m index 8d627eb..6597f62 100644 --- a/MP42/MP42MetadataItem.m +++ b/MP42/MP42MetadataItem.m @@ -269,7 +269,7 @@ static NSCalendar *_calendar; [coder encodeObject:_identifier forKey:@"MP42Identifier"]; [coder encodeObject:_value forKey:@"MP42Value"]; - [coder encodeInt:_dataType forKey:@"MP42DataType"]; + [coder encodeInt64:_dataType forKey:@"MP42DataType"]; [coder encodeObject:_extendedLanguageTag forKey:@"MP42LanguageTag"]; } @@ -279,7 +279,7 @@ static NSCalendar *_calendar; _identifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"MP42Identifier"]; _value = [decoder decodeObjectOfClasses:[NSSet setWithObjects:[NSString class], [NSDate class], [NSNumber class], [NSArray class], [MP42Image class], nil] forKey:@"MP42Value"]; - _dataType = [decoder decodeIntForKey:@"MP42DataType"]; + _dataType = [decoder decodeInt64ForKey:@"MP42DataType"]; _extendedLanguageTag = [decoder decodeObjectOfClass:[NSString class] forKey:@"MP42LanguageTag"]; return self; diff --git a/MP42/MP42MetadataUtilities.m b/MP42/MP42MetadataUtilities.m index 936146a..3187cc2 100644 --- a/MP42/MP42MetadataUtilities.m +++ b/MP42/MP42MetadataUtilities.m @@ -144,7 +144,7 @@ static const genreType_t genreType_strings[] = { {126, "dancehall", "Dance Hall" }, {255, "none", "none" }, - {0, "undefined" } // must be last + {0, "undefined", NULL } // must be last }; NSString * genreFromIndex(NSInteger index) diff --git a/MP42/MP42MkvImporter.m b/MP42/MP42MkvImporter.m index 7fde2b1..40f47a4 100644 --- a/MP42/MP42MkvImporter.m +++ b/MP42/MP42MkvImporter.m @@ -45,11 +45,11 @@ MP42_OBJC_DIRECT_MEMBERS NSMutableArray *queue; - uint64_t timescale; + uint32_t timescale; uint64_t currentTime; uint64_t startTime; int64_t minDisplayOffset; - unsigned int buffer, samplesWritten, bufferFlush; + uint32_t buffer, samplesWritten, bufferFlush; MP42SampleBuffer *previousSample; } @@ -68,7 +68,7 @@ MP42_OBJC_DIRECT_MEMBERS @end -static int readData(struct StdIoStream *ioStream, uint64_t pos, uint8_t **data, uint32_t dataSize) +static int readData(struct StdIoStream *ioStream, uint64_t pos, uint8_t **data, size_t dataSize) { if (fseeko(ioStream->fp, pos, SEEK_SET)) { #ifdef DEBUG @@ -218,10 +218,10 @@ MP42_OBJC_DIRECT_MEMBERS return nil; } - NSInteger trackCount = mkv_GetNumTracks(_matroskaFile); + MP42TrackId trackCount = mkv_GetNumTracks(_matroskaFile); NSArray *trackSizes = [self approximatedTrackDataLength]; - for (NSInteger i = 0; i < trackCount; i++) { + for (MP42TrackId i = 0; i < trackCount; i++) { TrackInfo *mkvTrack = mkv_GetTrackInfo(_matroskaFile, i); MP42Track *newTrack = nil; @@ -248,7 +248,7 @@ MP42_OBJC_DIRECT_MEMBERS videoTrack.vertOffD = 1; dar = (AVRational){mkvTrack->AV.Video.DisplayWidth, mkvTrack->AV.Video.DisplayHeight}; - invPixelSize = (AVRational){videoTrack.cleanApertureHeightN, videoTrack.cleanApertureWidthN}; + invPixelSize = (AVRational){(int)videoTrack.cleanApertureHeightN, (int)videoTrack.cleanApertureWidthN}; } else { dar = (AVRational){mkvTrack->AV.Video.DisplayWidth, mkvTrack->AV.Video.DisplayHeight}; @@ -475,7 +475,7 @@ MP42_OBJC_DIRECT_MEMBERS } } - return (mkvMetadata.items.count) ? mkvMetadata : nil; + return mkvMetadata; } - (NSArray *)approximatedTrackDataLength @@ -633,7 +633,7 @@ static NSString * TrackNameToString(TrackInfo *track) return (((double)StartTime) - codecDelay) / SCALE_FACTOR; } -static uint64_t timescale(TrackInfo *trackInfo) +static uint32_t timescale(TrackInfo *trackInfo) { if (trackInfo->Type == TT_VIDEO) { return 100000; @@ -655,7 +655,7 @@ static uint64_t timescale(TrackInfo *trackInfo) return 1000; } -- (NSUInteger)timescaleForTrack:(MP42Track *)track +- (UInt32)timescaleForTrack:(MP42Track *)track { TrackInfo *trackInfo = mkv_GetTrackInfo(_matroskaFile, track.sourceId); return timescale(trackInfo); @@ -788,7 +788,7 @@ static uint64_t timescale(TrackInfo *trackInfo) return nil; } -- (UInt8)streamExtensionTypeForAudioTrack:(MP42AudioTrack *)track mkvTrack:(TrackInfo *)trackInfo +- (MP42AudioEmbeddedExtension)streamExtensionTypeForAudioTrack:(MP42AudioTrack *)track mkvTrack:(TrackInfo *)trackInfo { struct eac3_info *context = NULL; uint8_t mkvpktnum = 0; @@ -876,7 +876,7 @@ static uint64_t timescale(TrackInfo *trackInfo) return result; } -- (BOOL)audioTrackUsesExplicitEncoderDelay:(MP42Track *)track; +- (BOOL)audioTrackUsesExplicitEncoderDelay:(MP42Track *)track { TrackInfo *trackInfo = mkv_GetTrackInfo(_matroskaFile, track.sourceId); return trackInfo->CodecDelay != 0; @@ -891,7 +891,7 @@ static uint64_t timescale(TrackInfo *trackInfo) NSArray *inputTracks = self.inputTracks; - NSInteger tracksNumber = inputTracks.count; + NSUInteger tracksNumber = inputTracks.count; MatroskaDemuxHelper * helpers[self.tracks.count]; for (NSUInteger index = 0; index < tracksNumber; index += 1) { @@ -1092,7 +1092,7 @@ static uint64_t timescale(TrackInfo *trackInfo) } // offset calculation - int64_t offset = currentSample->startTime - demuxHelper->currentTime; + int64_t offset = currentSample->startTime / 10000.0f - demuxHelper->currentTime / 10000.0f; demuxHelper->currentTime += duration; @@ -1102,7 +1102,7 @@ static uint64_t timescale(TrackInfo *trackInfo) sample->size = currentSample->frameSize; sample->timescale = demuxHelper->timescale; sample->duration = duration / 10000.0f; - sample->offset = offset / 10000.0f; + sample->offset = offset; sample->decodeTimestamp = StartTime; sample->flags |= (currentSample->frameFlags & FRAME_KF) ? MP42SampleBufferFlagIsSync : 0; sample->trackId = demuxHelper->sourceID; @@ -1164,7 +1164,7 @@ static uint64_t timescale(TrackInfo *trackInfo) } // offset calculation - int64_t offset = currentSample->startTime - demuxHelper->currentTime; + int64_t offset = currentSample->startTime / 10000.0f - demuxHelper->currentTime / 10000.0f; demuxHelper->currentTime += duration; @@ -1174,7 +1174,7 @@ static uint64_t timescale(TrackInfo *trackInfo) sample->size = currentSample->frameSize; sample->timescale = demuxHelper->timescale; sample->duration = duration / 10000.0f; - sample->offset = offset / 10000.0f; + sample->offset = offset; sample->decodeTimestamp = StartTime; sample->flags |= (currentSample->frameFlags & FRAME_KF) ? MP42SampleBufferFlagIsSync : 0; sample->trackId = demuxHelper->sourceID; @@ -1236,8 +1236,8 @@ static uint64_t timescale(TrackInfo *trackInfo) if (demuxHelper->minDisplayOffset != 0) { - for (unsigned int i = 1; i <= demuxHelper->samplesWritten; i++) { - int64_t correctedOffset = MP4GetSampleRenderingOffset(fileHandle, trackId, i) - demuxHelper->minDisplayOffset; + for (uint32_t i = 1; i <= demuxHelper->samplesWritten; i++) { + int64_t correctedOffset = (int64_t)MP4GetSampleRenderingOffset(fileHandle, trackId, i) - demuxHelper->minDisplayOffset; MP4SetSampleRenderingOffset(fileHandle, trackId, i, diff --git a/MP42/MP42Mp4Importer.m b/MP42/MP42Mp4Importer.m index a53836f..af1c395 100644 --- a/MP42/MP42Mp4Importer.m +++ b/MP42/MP42Mp4Importer.m @@ -22,7 +22,7 @@ typedef struct MP4DemuxHelper { MP4SampleId currentSampleId; uint64_t totalSampleNumber; MP4Timestamp currentTime; - uint64_t timeScale; + uint32_t timeScale; uint32_t done; } MP4DemuxHelper; @@ -36,7 +36,7 @@ typedef struct MP4DemuxHelper { return @[@"mp4", @"m4v", @"m4a", @"m4r"]; } -- (instancetype)initWithURL:(NSURL *)fileURL error:(NSError * __autoreleasing *)outError; +- (instancetype)initWithURL:(NSURL *)fileURL error:(NSError * __autoreleasing *)outError { if ((self = [super initWithURL:fileURL])) { MP42File *sourceFile = [[MP42File alloc] initWithURL:self.fileURL error:outError]; @@ -52,7 +52,7 @@ typedef struct MP4DemuxHelper { return self; } -- (NSUInteger)timescaleForTrack:(MP42Track *)track +- (UInt32)timescaleForTrack:(MP42Track *)track { return MP4GetTrackTimeScale(_fileHandle, track.sourceId); } @@ -279,14 +279,14 @@ typedef struct MP4DemuxHelper { result.mSampleRate = (sample_rate >> 16) + (sample_rate & 0xffff) / 65536.0; result.mFormatID = kAudioFormatLinearPCM; result.mFormatFlags += kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked | kAudioFormatFlagIsBigEndian; - result.mBitsPerChannel = bit_depth; - result.mChannelsPerFrame = channels_count; + result.mBitsPerChannel = (UInt32)bit_depth; + result.mChannelsPerFrame = (UInt32)channels_count; } return result; } -- (BOOL)audioTrackUsesExplicitEncoderDelay:(MP42Track *)track; +- (BOOL)audioTrackUsesExplicitEncoderDelay:(MP42Track *)track { return MP4HaveTrackAtom(_fileHandle, track.sourceId, "mdia.minf.stbl.sgpd"); } @@ -300,8 +300,8 @@ typedef struct MP4DemuxHelper { } NSArray *inputTracks = self.inputTracks; - NSInteger tracksNumber = inputTracks.count; - NSInteger tracksDone = 0; + NSUInteger tracksNumber = inputTracks.count; + NSUInteger tracksDone = 0; MP4DemuxHelper * helpers[tracksNumber]; @@ -413,7 +413,7 @@ typedef struct MP4DemuxHelper { MP4SetTrackIntegerProperty(dstFileHandle, dstTrackId, "tkhd.duration", trackDuration); } else if (MP4GetSampleRenderingOffset(dstFileHandle, dstTrackId, 1)) { - uint32_t firstFrameOffset = MP4GetSampleRenderingOffset(dstFileHandle, dstTrackId, 1); + MP4Duration firstFrameOffset = MP4GetSampleRenderingOffset(dstFileHandle, dstTrackId, 1); MP4Duration editDuration = MP4ConvertFromTrackDuration(_fileHandle, srcTrackId, diff --git a/MP42/MP42Muxer.m b/MP42/MP42Muxer.m index 14f4e1d..f911e24 100644 --- a/MP42/MP42Muxer.m +++ b/MP42/MP42Muxer.m @@ -91,7 +91,7 @@ MP42_OBJC_DIRECT_MEMBERS FourCharCode format = track.format; MP4TrackId dstTrackId = 0; NSData *magicCookie = nil; - NSInteger timeScale = 0; + uint32_t timeScale = 0; if (importer) { magicCookie = [importer magicCookieForTrack:track]; @@ -215,23 +215,23 @@ MP42_OBJC_DIRECT_MEMBERS uint8_t *hvcCAtom = (uint8_t *)magicCookie.bytes; - if ([_options[MP42ForceHvc1] boolValue]) { - force_HEVC_completeness(hvcCAtom, magicCookie.length); + if ([_options[MP42ForceHvc1] boolValue] && magicCookie.length < UINT32_MAX) { + force_HEVC_completeness(hvcCAtom, (uint32_t)magicCookie.length); } // Check whether we can use hvc1 or hev1 fourcc. bool completeness = 0; - if (magicCookie.length && !analyze_HEVC(magicCookie.bytes, magicCookie.length, &completeness)) { + if (magicCookie.length && magicCookie.length < UINT32_MAX && !analyze_HEVC(magicCookie.bytes, (uint32_t)magicCookie.length, &completeness)) { NSSize size = [importer sizeForTrack:(MP42VideoTrack *)track]; dstTrackId = MP4AddH265VideoTrack(_fileHandle, timeScale, MP4_INVALID_DURATION, size.width, size.height, completeness); if (dstTrackId) { if (completeness) { - MP4SetTrackBytesProperty(_fileHandle, dstTrackId, "mdia.minf.stbl.stsd.hvc1.hvcC.content", magicCookie.bytes, magicCookie.length); + MP4SetTrackBytesProperty(_fileHandle, dstTrackId, "mdia.minf.stbl.stsd.hvc1.hvcC.content", magicCookie.bytes, (uint32_t)magicCookie.length); } else { - MP4SetTrackBytesProperty(_fileHandle, dstTrackId, "mdia.minf.stbl.stsd.hev1.hvcC.content", magicCookie.bytes, magicCookie.length); + MP4SetTrackBytesProperty(_fileHandle, dstTrackId, "mdia.minf.stbl.stsd.hev1.hvcC.content", magicCookie.bytes, (uint32_t)magicCookie.length); } [importer setActiveTrack:track]; } @@ -255,10 +255,10 @@ MP42_OBJC_DIRECT_MEMBERS [(MP42VideoTrack*)track width], [(MP42VideoTrack*)track height], MP4_MPEG4_VIDEO_TYPE); - if (magicCookie.length) { + if (magicCookie.length && magicCookie.length < UINT32_MAX) { MP4SetTrackESConfiguration(_fileHandle, dstTrackId, magicCookie.bytes, - magicCookie.length); + (uint32_t)magicCookie.length); } [importer setActiveTrack:track]; @@ -281,10 +281,10 @@ MP42_OBJC_DIRECT_MEMBERS timeScale, 1024, MP4_MPEG4_AUDIO_TYPE); - if (!track.conversionSettings && magicCookie.length) { + if (!track.conversionSettings && magicCookie.length && magicCookie.length < UINT32_MAX) { MP4SetTrackESConfiguration(_fileHandle, dstTrackId, magicCookie.bytes, - magicCookie.length); + (uint32_t)magicCookie.length); } MP4SetTrackWantsRoll(_fileHandle, dstTrackId, [importer audioTrackUsesExplicitEncoderDelay:track]); @@ -332,8 +332,9 @@ MP42_OBJC_DIRECT_MEMBERS else if ([track isMemberOfClass:[MP42AudioTrack class]] && format == kMP42AudioCodecType_AppleLossless) { dstTrackId = MP4AddALACAudioTrack(_fileHandle, timeScale); - if (magicCookie.length) { - MP4SetTrackBytesProperty(_fileHandle, dstTrackId, "mdia.minf.stbl.stsd.alac.alac.AppleLosslessMagicCookie", magicCookie.bytes, magicCookie.length); + if (magicCookie.length && magicCookie.length < UINT32_MAX) { + MP4SetTrackBytesProperty(_fileHandle, dstTrackId, "mdia.minf.stbl.stsd.alac.alac.AppleLosslessMagicCookie", + magicCookie.bytes, (uint32_t)magicCookie.length); } [importer setActiveTrack:track]; @@ -609,11 +610,11 @@ MP42_OBJC_DIRECT_MEMBERS if (track.converter && track.conversionSettings && [track isMemberOfClass:[MP42AudioTrack class]]) { NSData *magicCookie = track.converter.magicCookie; - if (magicCookie) { + if (magicCookie && magicCookie.length < UINT32_MAX) { if (track.conversionSettings.format == kAudioFormatMPEG4AAC) { MP4SetTrackESConfiguration(_fileHandle, track.trackId, magicCookie.bytes, - magicCookie.length); + (uint32_t)magicCookie.length); } else if (track.conversionSettings.format == kAudioFormatAC3) { const uint64_t *ac3Info = (const uint64_t *)magicCookie.bytes; diff --git a/MP42/MP42OCRWrapper.mm b/MP42/MP42OCRWrapper.mm index 8c3cb7a..a7a8bbc 100644 --- a/MP42/MP42OCRWrapper.mm +++ b/MP42/MP42OCRWrapper.mm @@ -22,7 +22,7 @@ public: if (base_path) { path = base_path.fileSystemRepresentation; } else { - path = [[[NSBundle bundleForClass:[MP42OCRWrapper class]] bundlePath] stringByAppendingString:@"/Versions/A/Resources/tessdata/"].fileSystemRepresentation; + path = [[NSBundle bundleForClass:[MP42OCRWrapper class]].bundlePath stringByAppendingString:@"/Versions/A/Resources/tessdata/"].fileSystemRepresentation; } tess_base_api.Init(path, lang.UTF8String, mode); @@ -30,11 +30,15 @@ public: } char * OCRFrame(const unsigned char *image, size_t bytes_per_pixel, size_t bytes_per_line, size_t width, size_t height) { - char *text = tess_base_api.TesseractRect(image, + tess_base_api.SetImage(image, (int)width, (int)height, (int)bytes_per_pixel, (int)bytes_per_line); + tess_base_api.SetSourceResolution(70); + tess_base_api.SetRectangle(0, 0, (int)width, (int)height); + char *text = tess_base_api.GetUTF8Text(); + /*char *text = tess_base_api.TesseractRect(image, (int)bytes_per_pixel, (int)bytes_per_line, 0, 0, - (int)width, (int)height); + (int)width, (int)height);*/ return text; } @@ -86,7 +90,7 @@ MP42_OBJC_DIRECT_MEMBERS return NO; } -- (instancetype)initWithLanguage:(NSString *)language; +- (instancetype)initWithLanguage:(NSString *)language { if ((self = [super init])) { NSString *lang = language; @@ -141,7 +145,7 @@ MP42_OBJC_DIRECT_MEMBERS } } - delete[]string; + delete[] string; return text; } diff --git a/MP42/MP42PreviewGenerator.m b/MP42/MP42PreviewGenerator.m index f9e0d88..ed2d5e7 100644 --- a/MP42/MP42PreviewGenerator.m +++ b/MP42/MP42PreviewGenerator.m @@ -37,7 +37,7 @@ CGFloat offset; MP42Duration assetDuration = CMTimeGetSeconds(asset.duration) * 1000; - for (NSInteger idx = 0; idx < chapters.count; idx++) + for (NSUInteger idx = 0; idx < chapters.count; idx++) { MP42TextSample *chapter = chapters[idx]; diff --git a/MP42/MP42PrivateUtilities.m b/MP42/MP42PrivateUtilities.m index 70d0812..bcac198 100644 --- a/MP42/MP42PrivateUtilities.m +++ b/MP42/MP42PrivateUtilities.m @@ -11,13 +11,13 @@ #import #import #import + #include #include #import "MP42Languages.h" #import "MP42MediaFormat.h" -#include "intreadwrite.h" #include "avcodec.h" NSString * SRTStringFromTime( long long time, long timeScale , const char separator) @@ -57,7 +57,7 @@ int updateTracksCount(MP4FileHandle fileHandle) { MP4TrackId maxTrackId = 0; - for (uint32_t i = 0; i< MP4GetNumberOfTracks(fileHandle, 0, 0); i++ ) + for (MP4TrackId i = 0; i< MP4GetNumberOfTracks(fileHandle, 0, 0); i++ ) if (MP4FindTrackId(fileHandle, i, 0, 0) > maxTrackId) maxTrackId = MP4FindTrackId(fileHandle, i, 0, 0); @@ -69,7 +69,7 @@ void updateMoovDuration(MP4FileHandle fileHandle) MP4TrackId trackId = 0; MP4Duration maxTrackDuration = 0, trackDuration = 0; - for (uint32_t i = 0; i < MP4GetNumberOfTracks(fileHandle, 0, 0); i++ ) { + for (MP4TrackId i = 0; i < MP4GetNumberOfTracks(fileHandle, 0, 0); i++ ) { trackId = MP4FindTrackId(fileHandle, i, 0, 0); MP4GetTrackIntegerProperty(fileHandle, trackId, "tkhd.duration", &trackDuration); if (maxTrackDuration < trackDuration) { @@ -81,8 +81,8 @@ void updateMoovDuration(MP4FileHandle fileHandle) uint64_t getTrackSize(MP4FileHandle fileHandle, MP4TrackId trackId) { - uint64_t i, sampleNum, dataLength; - i = 1; + MP4SampleId i = 1, sampleNum; + uint64_t dataLength; sampleNum = MP4GetTrackNumberOfSamples(fileHandle, trackId); dataLength = 0; @@ -99,12 +99,12 @@ MP4TrackId findChapterTrackId(MP4FileHandle fileHandle) MP4TrackId trackId = 0; uint64_t trackRef; - for (uint32_t i = 0; i< MP4GetNumberOfTracks( fileHandle, 0, 0); i++ ) { + for (MP4TrackId i = 0; i< MP4GetNumberOfTracks( fileHandle, 0, 0); i++ ) { trackId = MP4FindTrackId(fileHandle, i, 0, 0); if (MP4HaveTrackAtom(fileHandle, trackId, "tref.chap")) { MP4GetTrackIntegerProperty(fileHandle, trackId, "tref.chap.entries.trackId", &trackRef); if (trackRef > 0) { - return trackRef; + return (MP4TrackId)trackRef; } } } @@ -124,7 +124,7 @@ MP4TrackId findChapterPreviewTrackId(MP4FileHandle fileHandle) MP4GetTrackIntegerProperty(fileHandle, trackId, "tref.chap.entryCount", &entryCount); if (entryCount > 1 && MP4GetTrackIntegerProperty(fileHandle, trackId, "tref.chap.entries[1].trackId", &trackRef)) if (trackRef > 0) { - return trackRef; + return (MP4TrackId)trackRef; } } } @@ -136,7 +136,7 @@ void removeAllChapterTrackReferences(MP4FileHandle fileHandle) { MP4TrackId trackId = 0; - for (uint32_t i = 0; i< MP4GetNumberOfTracks( fileHandle, 0, 0); i++ ) { + for (MP4TrackId i = 0; i< MP4GetNumberOfTracks( fileHandle, 0, 0); i++ ) { trackId = MP4FindTrackId(fileHandle, i, 0, 0); if (MP4HaveTrackAtom(fileHandle, trackId, "tref.chap")) { MP4RemoveAllTrackReferences(fileHandle, "tref.chap", trackId); @@ -151,7 +151,7 @@ MP4TrackId findFirstVideoTrack(MP4FileHandle fileHandle) if (!trackNumber) { return 0; } - for (uint32_t i = 0; i < trackNumber; i++) { + for (MP4TrackId i = 0; i < trackNumber; i++) { videoTrack = MP4FindTrackId(fileHandle, i, 0, 0); const char *trackType = MP4GetTrackType(fileHandle, videoTrack); if (trackType && !strcmp(trackType, MP4_VIDEO_TRACK_TYPE)) { @@ -567,7 +567,7 @@ int copyTrackEditLists (MP4FileHandle fileHandle, MP4TrackId srcTrackId, MP4Trac if (trackEditCount) MP4SetTrackIntegerProperty(fileHandle, dstTrackId, "tkhd.duration", trackDuration); else { - uint32_t firstFrameOffset = MP4GetSampleRenderingOffset(fileHandle, dstTrackId, 1); + MP4Duration firstFrameOffset = MP4GetSampleRenderingOffset(fileHandle, dstTrackId, 1); MP4Duration editDuration = MP4ConvertFromTrackDuration(fileHandle, srcTrackId, MP4GetTrackDuration(fileHandle, srcTrackId), @@ -642,7 +642,7 @@ int rgb2yuv(int rgb) void *fast_realloc_with_padding(void *ptr, unsigned int *size, unsigned int min_size) { - void *res = ptr; + uint8_t *res = ptr; av_fast_malloc(&res, size, min_size + AV_INPUT_BUFFER_PADDING_SIZE); if (res) memset(res + min_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); return res; @@ -668,14 +668,14 @@ int DecompressZlib(uint8_t **sampleData, uint32_t *sampleSize) goto failed; } pkt_data = newpktdata; - zstream.avail_out = pkt_size - zstream.total_out; + zstream.avail_out = (unsigned int)(pkt_size - zstream.total_out); zstream.next_out = pkt_data + zstream.total_out; if (pkt_data) { result = inflate(&zstream, Z_NO_FLUSH); } else result = Z_MEM_ERROR; } while (result==Z_OK && pkt_size<10000000); - pkt_size = zstream.total_out; + pkt_size = (int)zstream.total_out; inflateEnd(&zstream); if (result != Z_STREAM_END) { if (result == Z_MEM_ERROR) diff --git a/MP42/MP42SSAImporter.m b/MP42/MP42SSAImporter.m index d0ea69e..18ddc33 100644 --- a/MP42/MP42SSAImporter.m +++ b/MP42/MP42SSAImporter.m @@ -84,7 +84,7 @@ MP42_OBJC_DIRECT_MEMBERS return nil; } -- (NSUInteger)timescaleForTrack:(MP42Track *)track +- (UInt32)timescaleForTrack:(MP42Track *)track { return 1000; } diff --git a/MP42/MP42SSAParser.m b/MP42/MP42SSAParser.m index 1afe43d..5c431cb 100644 --- a/MP42/MP42SSAParser.m +++ b/MP42/MP42SSAParser.m @@ -348,9 +348,9 @@ static NSMutableString *STStandardizeStringNewlines(NSString *str) return info; } -- (NSDictionary *)parseStyles:(NSString *)styles +- (NSDictionary *)parseStyles:(NSString *)stylesHeader { - NSScanner *sc = [NSScanner scannerWithString:styles]; + NSScanner *sc = [NSScanner scannerWithString:stylesHeader]; NSMutableArray *formatsArray = [NSMutableArray array]; NSMutableDictionary *stylesDict = [NSMutableDictionary dictionary]; diff --git a/MP42/MP42SampleBuffer.h b/MP42/MP42SampleBuffer.h index df801cf..6bdf933 100644 --- a/MP42/MP42SampleBuffer.h +++ b/MP42/MP42SampleBuffer.h @@ -32,9 +32,9 @@ MP42_OBJC_DIRECT_MEMBERS @interface MP42SampleBuffer : NSObject { @public void *data; - uint64_t size; + uint32_t size; - uint64_t timescale; + uint32_t timescale; uint64_t duration; int64_t offset; @@ -42,7 +42,7 @@ MP42_OBJC_DIRECT_MEMBERS int64_t presentationOutputTimestamp; uint64_t decodeTimestamp; - uint32_t trackId; + MP42TrackId trackId; MP42SampleBufferFlag flags; MP42SampleDepType dependecyFlags; diff --git a/MP42/MP42SecurityAccessToken.m b/MP42/MP42SecurityAccessToken.m index acab353..727938f 100644 --- a/MP42/MP42SecurityAccessToken.m +++ b/MP42/MP42SecurityAccessToken.m @@ -18,7 +18,7 @@ MP42_OBJC_DIRECT_MEMBERS MP42_OBJC_DIRECT_MEMBERS @implementation MP42SecurityAccessToken -- (instancetype)initWithObject:(id)object; +- (instancetype)initWithObject:(id)object { self = [super init]; if (self) { @@ -40,7 +40,7 @@ MP42_OBJC_DIRECT_MEMBERS } } -+ (nullable NSURL *)URLFromBookmark:(NSData *)bookmark bookmarkDataIsStale:(BOOL * _Nullable)isStale error:(NSError **)error ++ (nullable NSURL *)URLFromBookmark:(NSData *)bookmark bookmarkDataIsStale:(BOOL * _Nullable)isStale error:(NSError * __autoreleasing *)error { NSParameterAssert(bookmark); @@ -49,7 +49,7 @@ MP42_OBJC_DIRECT_MEMBERS return url; } -+ (nullable NSData *)bookmarkFromURL:(NSURL *)url options:(NSURLBookmarkCreationOptions)options error:(NSError **)error ++ (nullable NSData *)bookmarkFromURL:(NSURL *)url options:(NSURLBookmarkCreationOptions)options error:(NSError * __autoreleasing *)error { NSParameterAssert(url); @@ -58,7 +58,7 @@ MP42_OBJC_DIRECT_MEMBERS return bookmark; } -+ (nullable NSData *)bookmarkFromURL:(NSURL *)url error:(NSError **)error ++ (nullable NSData *)bookmarkFromURL:(NSURL *)url error:(NSError * __autoreleasing *)error { return [MP42SecurityAccessToken bookmarkFromURL:url options:NSURLBookmarkCreationWithSecurityScope error:error]; } diff --git a/MP42/MP42SrtImporter.m b/MP42/MP42SrtImporter.m index 4db2e69..6103fab 100644 --- a/MP42/MP42SrtImporter.m +++ b/MP42/MP42SrtImporter.m @@ -93,7 +93,7 @@ MP42_OBJC_DIRECT_MEMBERS return nil; } -- (NSUInteger)timescaleForTrack:(MP42Track *)track +- (UInt32)timescaleForTrack:(MP42Track *)track { return 1000; } diff --git a/MP42/MP42SubUtilities.h b/MP42/MP42SubUtilities.h index ef5e0d7..26c1e30 100644 --- a/MP42/MP42SubUtilities.h +++ b/MP42/MP42SubUtilities.h @@ -18,13 +18,13 @@ MP42_OBJC_DIRECT_MEMBERS { @public NSString *line; - unsigned begin_time, end_time; - unsigned no; // line number, used only by SBSubSerializer + uint64_t begin_time, end_time; + uint64_t no; // line number, used only by SBSubSerializer unsigned top; unsigned forced; } -- (instancetype)initWithLine:(NSString *)l start:(unsigned)s end:(unsigned)e; -- (instancetype)initWithLine:(NSString *)l start:(unsigned)s end:(unsigned)e top_pos:(unsigned)p forced:(unsigned)f; +- (instancetype)initWithLine:(NSString *)l start:(uint64_t)s end:(uint64_t)e; +- (instancetype)initWithLine:(NSString *)l start:(uint64_t)s end:(uint64_t)e top_pos:(unsigned)p forced:(unsigned)f; @end MP42_OBJC_DIRECT_MEMBERS @@ -64,7 +64,7 @@ typedef struct { UInt32 duration; } PacketControlData; -int ExtractVobSubPacket(UInt8 *dest, UInt8 *framedSrc, int srcSize, int * _Nullable usedSrcBytes, int index); +int ExtractVobSubPacket(UInt8 *dest, UInt8 *framedSrc, long srcSize, int * _Nullable usedSrcBytes, int index); ComponentResult ReadPacketControls(UInt8 *packet, UInt32 palette[_Nonnull 16], PacketControlData *controlDataOut, BOOL *forced); 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 bd6c495..a43b381 100644 --- a/MP42/MP42SubUtilities.m +++ b/MP42/MP42SubUtilities.m @@ -16,8 +16,8 @@ MP42_OBJC_DIRECT_MEMBERS // input lines, sorted by 1. beginning time 2. original insertion order NSMutableArray *lines; - unsigned last_begin_time, last_end_time; - unsigned linesInput; + uint64_t last_begin_time, last_end_time; + uint64_t linesInput; } -(instancetype)init @@ -54,7 +54,7 @@ static CFComparisonResult CompareLinesByBeginTime(const void *a, const void *b, line->no = linesInput++; - NSUInteger nlines = [lines count]; + NSUInteger nlines = lines.count; if (!nlines || line->begin_time > ((MP42SubLine*)[lines objectAtIndex:nlines-1])->begin_time) { [lines addObject:line]; @@ -74,11 +74,11 @@ static CFComparisonResult CompareLinesByBeginTime(const void *a, const void *b, NSUInteger nlines = [lines count]; MP42SubLine *first = [lines objectAtIndex:0]; NSMutableString *str; - int i; + NSUInteger i; if (!_finished) { if (nlines > 1) { - unsigned maxEndTime = first->end_time; + uint64_t maxEndTime = first->end_time; for (i = 1; i < nlines; i++) { MP42SubLine *l = [lines objectAtIndex:i]; @@ -96,7 +96,7 @@ static CFComparisonResult CompareLinesByBeginTime(const void *a, const void *b, canOutput: str = [NSMutableString stringWithString:first->line]; - unsigned begin_time = last_end_time, end_time = first->end_time; + uint64_t begin_time = last_end_time, end_time = first->end_time; unsigned frcd = first->forced, top_pos = first->top; int deleted = 0; @@ -169,7 +169,7 @@ canOutput: MP42_OBJC_DIRECT_MEMBERS @implementation MP42SubLine --(instancetype)initWithLine:(NSString *)l start:(unsigned)s end:(unsigned)e +-(instancetype)initWithLine:(NSString *)l start:(uint64_t)s end:(uint64_t)e { if ((self = [super init])) { if ([l characterAtIndex:[l length]-1] != '\n') l = [l stringByAppendingString:@"\n"]; @@ -182,7 +182,7 @@ MP42_OBJC_DIRECT_MEMBERS return self; } --(id)initWithLine:(NSString*)l start:(unsigned)s end:(unsigned)e top_pos:(unsigned)p forced:(unsigned)f; +-(id)initWithLine:(NSString*)l start:(uint64_t)s end:(uint64_t)e top_pos:(unsigned)p forced:(unsigned)f { if ((self = [self initWithLine:l start:s end:e])) { top = p; @@ -194,7 +194,7 @@ MP42_OBJC_DIRECT_MEMBERS -(NSString *)description { - return [NSString stringWithFormat:@"\"%@\", from %d s to %d s",[line substringToIndex:[line length]-1],begin_time,end_time]; + return [NSString stringWithFormat:@"\"%@\", from %llu s to %llu s",[line substringToIndex:line.length -1] ,begin_time, end_time]; } @end @@ -882,6 +882,14 @@ MP42SampleBuffer * copySubtitleSample(MP4TrackId subtitleTrackId, NSString *stri stringLength = strlen(string.UTF8String); sampleSize = 2 + (stringLength * sizeof(char)) + styleSize + (forced == 1 ? 8 : 0) + (verticalPlacement == 1 ? 16 : 0); + + if (sampleSize > UINT16_MAX) + { + // Too big for a tx3g sample + free(styleAtom); + return copyEmptySubtitleSample(subtitleTrackId, duration, forced); + } + sampleData = malloc(sampleSize); pos = 2; @@ -924,7 +932,7 @@ MP42SampleBuffer * copySubtitleSample(MP4TrackId subtitleTrackId, NSString *stri MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init]; sample->data = sampleData; - sample->size = sampleSize; + sample->size = (uint32_t)sampleSize; sample->duration = duration; sample->offset = 0; sample->decodeTimestamp = duration; @@ -934,14 +942,25 @@ MP42SampleBuffer * copySubtitleSample(MP4TrackId subtitleTrackId, NSString *stri return sample; } -MP42SampleBuffer* copyEmptySubtitleSample(MP4TrackId subtitleTrackId, MP4Duration duration, BOOL forced) +MP42SampleBuffer * copyEmptySubtitleSample(MP4TrackId subtitleTrackId, MP4Duration duration, BOOL forced) { uint8_t *sampleData = NULL; + size_t sampleSize = 0; + u_int8_t empty[2] = {0,0}; - sampleData = malloc(2); + sampleSize = 2 + (forced == 1 ? 8 : 0); + sampleData = malloc(sampleSize); memcpy(sampleData, empty, 2); + // Add a frcd atom + if (forced) { + u_int8_t forcedAtom[8]; + createForcedAtom(forcedAtom); + + memcpy(sampleData + 2, forcedAtom, 8); + } + MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init]; sample->data = sampleData; sample->size = 2; @@ -955,7 +974,7 @@ MP42SampleBuffer* copyEmptySubtitleSample(MP4TrackId subtitleTrackId, MP4Duratio } /* VobSub related */ -int ExtractVobSubPacket(UInt8 *dest, UInt8 *framedSrc, int srcSize, int *usedSrcBytes, int index) { +int ExtractVobSubPacket(UInt8 *dest, UInt8 *framedSrc, long srcSize, int * _Nullable usedSrcBytes, int index) { int copiedBytes = 0; UInt8 *currentPacket = framedSrc; int packetSize = INT_MAX; @@ -1023,7 +1042,7 @@ int ExtractVobSubPacket(UInt8 *dest, UInt8 *framedSrc, int srcSize, int *usedSrc } // switch (currentPacket[3]) } // while (currentPacket - framedSrc < srcSize) if (usedSrcBytes != NULL) { - *usedSrcBytes = currentPacket - framedSrc; + *usedSrcBytes = (int)(currentPacket - framedSrc); } return copiedBytes; @@ -1124,8 +1143,9 @@ Boolean ReadPacketTimes(uint8_t *packet, uint32_t length, uint16_t *startTime, u int controlOffset = (packet[2] << 8) + packet[3]; while(loop) { - if(controlOffset > length) + if (controlOffset > length) { return NO; + } uint8_t *controlSeq = packet + controlOffset; int32_t i = 4; int32_t end = length - controlOffset; diff --git a/MP42/MP42SubtitleTrack.m b/MP42/MP42SubtitleTrack.m index c0b8590..2d1e736 100644 --- a/MP42/MP42SubtitleTrack.m +++ b/MP42/MP42SubtitleTrack.m @@ -17,7 +17,7 @@ MP42_OBJC_DIRECT_MEMBERS @implementation MP42SubtitleTrack -- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP4FileHandle)fileHandle +- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(MP42TrackId)trackID fileHandle:(MP4FileHandle)fileHandle { self = [super initWithSourceURL:URL trackID:trackID fileHandle:fileHandle]; @@ -52,7 +52,7 @@ MP42_OBJC_DIRECT_MEMBERS if (MP4HaveTrackAtom(fileHandle, self.trackId, "tref.forc")) { uint64_t forcedId = 0; MP4GetTrackIntegerProperty(fileHandle, self.trackId, "tref.forc.entries.trackId", &forcedId); - _forcedTrackId = forcedId; + _forcedTrackId = (MP42TrackId)forcedId; } } @@ -82,8 +82,9 @@ MP42_OBJC_DIRECT_MEMBERS if (self.updatedProperty[@"forced"] || !self.muxed) { - if (self.forcedTrack) { - _forcedTrackId = self.forcedTrack.trackId; + MP42Track *forcedTrack = self.forcedTrack; + if (forcedTrack) { + _forcedTrackId = forcedTrack.trackId; } if (MP4HaveTrackAtom(fileHandle, self.trackId, "tref.forc") && (_forcedTrackId == 0)) { @@ -424,7 +425,7 @@ fail: [coder encodeBool:_someSamplesAreForced forKey:@"someSamplesAreForced"]; [coder encodeBool:_allSamplesAreForced forKey:@"allSamplesAreForced"]; - [coder encodeInt64:_forcedTrackId forKey:@"forcedTrackId"]; + [coder encodeInt32:_forcedTrackId forKey:@"forcedTrackId"]; } - (id)initWithCoder:(NSCoder *)decoder @@ -436,7 +437,7 @@ fail: _someSamplesAreForced = [decoder decodeBoolForKey:@"someSamplesAreForced"]; _allSamplesAreForced = [decoder decodeBoolForKey:@"allSamplesAreForced"]; - _forcedTrackId = [decoder decodeInt64ForKey:@"forcedTrackId"]; + _forcedTrackId = [decoder decodeInt32ForKey:@"forcedTrackId"]; } return self; diff --git a/MP42/MP42TextSubConverter.m b/MP42/MP42TextSubConverter.m index 523eff2..c3230ef 100644 --- a/MP42/MP42TextSubConverter.m +++ b/MP42/MP42TextSubConverter.m @@ -126,7 +126,8 @@ MP42_OBJC_DIRECT_MEMBERS { if (_finished) { if (!_ss.isEmpty) { - CGSize trackSize = CGSizeMake(_track.trackWidth, _track.trackHeight); + MP42SubtitleTrack *track = _track; + CGSize trackSize = CGSizeMake(track.trackWidth, track.trackHeight); MP42SubLine *sl = [_ss getSerializedPacket]; MP42SampleBuffer *sample; diff --git a/MP42/MP42Track+Private.h b/MP42/MP42Track+Private.h index 40c6ecf..d6d8630 100644 --- a/MP42/MP42Track+Private.h +++ b/MP42/MP42Track+Private.h @@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN @interface MP42Track (Private) -- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP42FileHandle)fileHandle; +- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(MP42TrackId)trackID fileHandle:(MP42FileHandle)fileHandle; - (BOOL)writeToFile:(MP42FileHandle)fileHandle error:(NSError * __autoreleasing *)outError; @property(nonatomic, readwrite) MP42TrackId trackId; diff --git a/MP42/MP42Track.m b/MP42/MP42Track.m index 3ff32db..c19b048 100644 --- a/MP42/MP42Track.m +++ b/MP42/MP42Track.m @@ -63,7 +63,7 @@ typedef struct muxer_helper { return self; } -- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP4FileHandle)fileHandle +- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(MP42TrackId)trackID fileHandle:(MP4FileHandle)fileHandle { if ((self = [super init])) { _URL = URL; @@ -381,8 +381,8 @@ typedef struct muxer_helper { [coder encodeObject:_URL forKey:@"sourceURL"]; #endif - [coder encodeInteger:_format forKey:@"format"]; - [coder encodeInteger:_mediaType forKey:@"mediaType"]; + [coder encodeInt32:_format forKey:@"format"]; + [coder encodeInt32:_mediaType forKey:@"mediaType"]; [coder encodeObject:_name forKey:@"name"]; [coder encodeObject:_language forKey:@"language"]; @@ -435,8 +435,8 @@ typedef struct muxer_helper { _URL = [decoder decodeObjectOfClass:[NSURL class] forKey:@"sourceURL"]; } - _format = [decoder decodeIntegerForKey:@"format"]; - _mediaType = [decoder decodeIntegerForKey:@"mediaType"]; + _format = [decoder decodeInt32ForKey:@"format"]; + _mediaType = [decoder decodeInt32ForKey:@"mediaType"]; _name = [decoder decodeObjectOfClass:[NSString class] forKey:@"name"]; _language = [decoder decodeObjectOfClass:[NSString class] forKey:@"language"]; diff --git a/MP42/MP42Utilities.h b/MP42/MP42Utilities.h index 3dffc7b..3ef64b9 100644 --- a/MP42/MP42Utilities.h +++ b/MP42/MP42Utilities.h @@ -21,8 +21,8 @@ NS_ASSUME_NONNULL_BEGIN -NSString * StringFromTime(long long time, long timeScale); -MP42Duration TimeFromString(NSString *SMPTE_string, MP42Duration timeScale); +NSString * StringFromTime(long long time, int32_t timeScale); +MP42Duration TimeFromString(NSString *SMPTE_string, int32_t timeScale); BOOL isTrackMuxable(FourCharCode formatName); BOOL trackNeedConversion(FourCharCode formatName); diff --git a/MP42/MP42Utilities.m b/MP42/MP42Utilities.m index 55f3c29..88b0199 100644 --- a/MP42/MP42Utilities.m +++ b/MP42/MP42Utilities.m @@ -10,11 +10,11 @@ #import "MP42SubUtilities.h" #import -NSString * StringFromTime(long long time, long timeScale) +NSString * StringFromTime(long long time, int32_t timeScale) { NSString *time_string; - int hour, minute, second, frame; - long long result; + int minute, second, frame; + long long result, hour; result = time / timeScale; // second frame = time % timeScale; @@ -27,12 +27,12 @@ NSString * StringFromTime(long long time, long timeScale) result = result / 60; // hour hour = result; - time_string = [NSString stringWithFormat:@"%d:%02d:%02d.%03d", hour, minute, second, frame]; // h:mm:ss.mss + time_string = [NSString stringWithFormat:@"%lld:%02d:%02d.%03d", hour, minute, second, frame]; // h:mm:ss.mss return time_string; } -MP42Duration TimeFromString(NSString *time_string, MP42Duration timeScale) +MP42Duration TimeFromString(NSString *time_string, int32_t timeScale) { return ParseSubTime(time_string.UTF8String, timeScale, NO); } diff --git a/MP42/MP42VideoTrack.m b/MP42/MP42VideoTrack.m index 55d3e1f..8fa1ed9 100644 --- a/MP42/MP42VideoTrack.m +++ b/MP42/MP42VideoTrack.m @@ -15,7 +15,7 @@ MP42_OBJC_DIRECT_MEMBERS @implementation MP42VideoTrack -- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP42FileHandle)fileHandle +- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(MP42TrackId)trackID fileHandle:(MP42FileHandle)fileHandle { self = [super initWithSourceURL:URL trackID:trackID fileHandle:fileHandle]; @@ -65,9 +65,9 @@ MP42_OBJC_DIRECT_MEMBERS MP4GetTrackIntegerProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.*.colr.transferFunctionIndex", &transferCharacteristics); MP4GetTrackIntegerProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.*.colr.matrixIndex", &matrixCoefficients); - _colorPrimaries = colorPrimaries; - _transferCharacteristics = transferCharacteristics; - _matrixCoefficients = matrixCoefficients; + _colorPrimaries = (uint16_t)colorPrimaries; + _transferCharacteristics = (uint16_t)transferCharacteristics; + _matrixCoefficients = (uint16_t)matrixCoefficients; } } } @@ -200,8 +200,10 @@ static uint32_t convertToFixedPoint(CGFloat value) { MP4SetTrackIntegerProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.*.clap.vertOffD", _vertOffD); } else - MP4AddCleanAperture(fileHandle, self.trackId, _cleanApertureWidthN, _cleanApertureWidthD, _cleanApertureHeightN, _cleanApertureHeightD, - _horizOffN, _horizOffD, _vertOffN, _vertOffD); + MP4AddCleanAperture(fileHandle, self.trackId, + (uint32_t)_cleanApertureWidthN, (uint32_t)_cleanApertureWidthD, + (uint32_t)_cleanApertureHeightN, (uint32_t)_cleanApertureHeightD, + (uint32_t)_horizOffN, (uint32_t)_horizOffD, (uint32_t)_vertOffN, (uint32_t)_vertOffD); } if (self.format == kMP42VideoCodecType_H264) { @@ -388,9 +390,9 @@ static uint32_t convertToFixedPoint(CGFloat value) { _trackWidth = [decoder decodeFloatForKey:@"trackWidth"]; _trackHeight = [decoder decodeFloatForKey:@"trackHeight"]; - _colorPrimaries = [decoder decodeInt32ForKey:@"colorPrimaries"]; - _transferCharacteristics = [decoder decodeInt32ForKey:@"transferCharacteristics"]; - _matrixCoefficients = [decoder decodeInt32ForKey:@"matrixCoefficients"]; + _colorPrimaries = (uint16_t)[decoder decodeInt32ForKey:@"colorPrimaries"]; + _transferCharacteristics = (uint16_t)[decoder decodeInt32ForKey:@"transferCharacteristics"]; + _matrixCoefficients = (uint16_t)[decoder decodeInt32ForKey:@"matrixCoefficients"]; _hSpacing = [decoder decodeInt64ForKey:@"hSpacing"]; _vSpacing = [decoder decodeInt64ForKey:@"vSpacing"]; @@ -402,11 +404,11 @@ static uint32_t convertToFixedPoint(CGFloat value) { _transform.tx = [decoder decodeDoubleForKey:@"offsetX"]; _transform.ty = [decoder decodeDoubleForKey:@"offsetY"]; - _origProfile = [decoder decodeIntForKey:@"origProfile"]; - _origLevel = [decoder decodeIntForKey:@"origLevel"]; + _origProfile = (uint8_t)[decoder decodeIntForKey:@"origProfile"]; + _origLevel = (uint8_t)[decoder decodeIntForKey:@"origLevel"]; - _newProfile = [decoder decodeIntForKey:@"newProfile"]; - _newLevel = [decoder decodeIntForKey:@"newLevel"]; + _newProfile = (uint8_t)[decoder decodeIntForKey:@"newProfile"]; + _newLevel = (uint8_t)[decoder decodeIntForKey:@"newLevel"]; } return self; diff --git a/MP42/MP42VobSubImporter.m b/MP42/MP42VobSubImporter.m index a16ec87..c06aaf0 100644 --- a/MP42/MP42VobSubImporter.m +++ b/MP42/MP42VobSubImporter.m @@ -37,7 +37,7 @@ MP42_OBJC_DIRECT_MEMBERS NSString *language; int index; long duration; - NSMutableArray *samples; + NSMutableArray *samples; } - (id)initWithPrivateData:(NSArray *)idxPrivateData language:(NSString *)lang andIndex:(int)trackIndex; @@ -197,8 +197,9 @@ static NSArray * LoadVobSubSubtitles(NSURL *theDirectory, NSStr sscanf(line.UTF8String, "timestamp: %s filepos: %x", timeStr, &position); long time = ParseSubTime(timeStr, 1000, YES); free(timeStr); - if(position > subFileSize) + if (position > subFileSize) { position = subFileSize; + } [currentTrack addSampleTime:time + delay offset:position]; } break; @@ -227,7 +228,7 @@ MP42_OBJC_DIRECT_MEMBERS { if ((self = [super initWithURL:fileURL])) { - NSInteger count = 0; + MP42TrackId count = 0; _VobSubTracks = LoadVobSubSubtitles(self.fileURL.URLByDeletingLastPathComponent, self.fileURL.lastPathComponent); for (SBVobSubTrack *track in _VobSubTracks) { @@ -255,7 +256,7 @@ MP42_OBJC_DIRECT_MEMBERS return self; } -- (NSUInteger)timescaleForTrack:(MP42Track *)track +- (UInt32)timescaleForTrack:(MP42Track *)track { return 1000; } @@ -304,26 +305,28 @@ MP42_OBJC_DIRECT_MEMBERS SBVobSubTrack *vobTrack = [_VobSubTracks objectAtIndex:track.sourceId]; SBVobSubSample *firstSample = nil; - uint32_t lastTime = 0; - int sampleCount = vobTrack->samples.count; + uint64_t lastTime = 0; + NSUInteger sampleCount = vobTrack->samples.count; - for (int i = 0; i < sampleCount && !self.isCancelled; i++) { + for (NSUInteger i = 0; i < sampleCount && !self.isCancelled; i++) { SBVobSubSample *currentSample = [vobTrack->samples objectAtIndex:i]; - int offset = currentSample->fileOffset; - int nextOffset; - if (i == sampleCount - 1) - nextOffset = [subFileData length]; - else - nextOffset = ((SBVobSubSample *)[vobTrack->samples objectAtIndex:i+1])->fileOffset; - int size = nextOffset - offset; - if (size < 0) + long offset = currentSample->fileOffset; + long nextOffset; + if (i == sampleCount - 1) { + nextOffset = subFileData.length; + } else { + nextOffset = [vobTrack->samples objectAtIndex:i+1]->fileOffset; + } + int size = (int)(nextOffset - offset); + if (size < 0) { //Skip samples for which we cannot determine size continue; + } NSData *subData = [subFileData subdataWithRange:NSMakeRange(offset, size)]; uint8_t *extracted = (uint8_t *)malloc(size); //The index here likely should really be track->index, but I'm not sure we can really trust it. - int extractedSize = ExtractVobSubPacket(extracted, (UInt8 *)[subData bytes], size, &size, -1); + int extractedSize = ExtractVobSubPacket(extracted, (UInt8 *)subData.bytes, size, &size, -1); uint16_t startTimestamp, endTimestamp; uint8_t forced; @@ -332,13 +335,13 @@ MP42_OBJC_DIRECT_MEMBERS continue; } - uint32_t startTime = currentSample->timeStamp + startTimestamp; - uint32_t endTime = currentSample->timeStamp + endTimestamp; + uint64_t startTime = currentSample->timeStamp + startTimestamp; + uint64_t endTime = currentSample->timeStamp + endTimestamp; - int duration = endTimestamp - startTimestamp; + uint64_t duration = endTimestamp - startTimestamp; if (duration <= 0 && i < sampleCount - 1) { //Sample with no end duration, use the duration of the next one - endTime = ((SBVobSubSample *)[vobTrack->samples objectAtIndex:i+1])->timeStamp; + endTime = [vobTrack->samples objectAtIndex:i+1]->timeStamp; duration = endTime - startTime; } if (duration <= 0) { diff --git a/MP42/muxer/MatroskaFile.c b/MP42/muxer/MatroskaFile.c index db5e85c..c0d78e9 100644 --- a/MP42/muxer/MatroskaFile.c +++ b/MP42/muxer/MatroskaFile.c @@ -39,7 +39,7 @@ int StdIoRead(StdIoStream *st, uint64_t pos, void *buffer, int count) { st->error = errno; return -1; } - return rd; + return (int)rd; } /* scan for a signature sig(big-endian) starting at file position pos diff --git a/MP42/muxer/audio_resample.c b/MP42/muxer/audio_resample.c index c183e1e..ef7ec08 100644 --- a/MP42/muxer/audio_resample.c +++ b/MP42/muxer/audio_resample.c @@ -254,7 +254,7 @@ int hb_audio_resample(hb_audio_resample_t *resample, av_samples_get_buffer_size(&in_linesize, resample->resample.channels, nsamples, resample->resample.sample_fmt, 0); - int expected_out_samples = av_rescale_rnd(swr_get_delay(resample->avresample, resample->in.sample_rate) + + int expected_out_samples = (int)av_rescale_rnd(swr_get_delay(resample->avresample, resample->in.sample_rate) + nsamples, resample->out.sample_rate, resample->in.sample_rate, AV_ROUND_UP); out_size = av_samples_get_buffer_size(&out_linesize, diff --git a/MP42Foundation.xcodeproj/project.pbxproj b/MP42Foundation.xcodeproj/project.pbxproj index 96984fa..8737d14 100644 --- a/MP42Foundation.xcodeproj/project.pbxproj +++ b/MP42Foundation.xcodeproj/project.pbxproj @@ -880,7 +880,7 @@ A9B9C1E4182391DF00416A4E /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1200; + LastUpgradeCheck = 1220; ORGANIZATIONNAME = "Damiano Galassi"; TargetAttributes = { A910B5A218394E900064028F = { @@ -1166,6 +1166,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = YES; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; @@ -1174,28 +1175,36 @@ CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "compiler-default"; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_UNDEFINED_BEHAVIOR_SANITIZER_INTEGER = YES; CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES; + CLANG_WARN_ASSIGN_ENUM = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_CXX0X_EXTENSIONS = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_FRAMEWORK_INCLUDE_PRIVATE_FROM_PUBLIC = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES; CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES; COPY_PHASE_STRIP = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -1204,13 +1213,21 @@ GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1"; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; + GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; + GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; + GCC_WARN_PEDANTIC = YES; + GCC_WARN_SHADOW = YES; + GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES; - GCC_WARN_UNUSED_FUNCTION = NO; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( @@ -1233,6 +1250,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = YES; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; @@ -1241,28 +1259,36 @@ CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "compiler-default"; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_UNDEFINED_BEHAVIOR_SANITIZER_INTEGER = YES; CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES; + CLANG_WARN_ASSIGN_ENUM = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_CXX0X_EXTENSIONS = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_FRAMEWORK_INCLUDE_PRIVATE_FROM_PUBLIC = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES; CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; @@ -1271,13 +1297,21 @@ GCC_NO_COMMON_BLOCKS = YES; GCC_PREPROCESSOR_DEFINITIONS = ""; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; + GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; + GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; + GCC_WARN_PEDANTIC = YES; + GCC_WARN_SHADOW = YES; + GCC_WARN_STRICT_SELECTOR_MATCH = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES; - GCC_WARN_UNUSED_FUNCTION = NO; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( diff --git a/MP42Foundation.xcodeproj/xcshareddata/xcschemes/MP42Foundation.xcscheme b/MP42Foundation.xcodeproj/xcshareddata/xcschemes/MP42Foundation.xcscheme index d58f152..d7f49bb 100644 --- a/MP42Foundation.xcodeproj/xcshareddata/xcschemes/MP42Foundation.xcscheme +++ b/MP42Foundation.xcodeproj/xcshareddata/xcschemes/MP42Foundation.xcscheme @@ -1,6 +1,6 @@