Enable and fixes more warnings.

This commit is contained in:
Damiano Galassi committed 2020-09-19 14:39:02 +02:00
1 parent 9ed0e2d992
commit 0e421a6eef
56 files changed
+409 -315

No files matched your search

+2 -2
View File
@@ -18,8 +18,8 @@ enum AVCodecID FourCCToCodecID(OSType formatID);
OSType CodecIDToFourCC(enum AVCodecID codecID); OSType CodecIDToFourCC(enum AVCodecID codecID);
int remap_layout(AudioChannelLayout *layout, uint64_t in_layout, int count); 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 */ #endif /* FFmpegUtils_h */
+4 -4
View File
@@ -61,7 +61,7 @@ static const struct {
{ kLinearPCMFormatFlagIsFloat | kLinearPCMFormatFlagIsPacked, 32, AV_CODEC_ID_PCM_F32LE }, { kLinearPCMFormatFlagIsFloat | kLinearPCMFormatFlagIsPacked, 32, AV_CODEC_ID_PCM_F32LE },
{ kLinearPCMFormatFlagIsFloat | kLinearPCMFormatFlagIsPacked | kAudioFormatFlagIsBigEndian, 64, AV_CODEC_ID_PCM_F64BE }, { kLinearPCMFormatFlagIsFloat | kLinearPCMFormatFlagIsPacked | kAudioFormatFlagIsBigEndian, 64, AV_CODEC_ID_PCM_F64BE },
{ kLinearPCMFormatFlagIsFloat | kLinearPCMFormatFlagIsPacked, 64, AV_CODEC_ID_PCM_F64LE }, { kLinearPCMFormatFlagIsFloat | kLinearPCMFormatFlagIsPacked, 64, AV_CODEC_ID_PCM_F64LE },
{0, AV_CODEC_ID_NONE } {0, 0, AV_CODEC_ID_NONE }
}; };
enum AVCodecID ASBDToCodecID(AudioStreamBasicDescription asbd) enum AVCodecID ASBDToCodecID(AudioStreamBasicDescription asbd)
@@ -230,12 +230,12 @@ static AudioChannelLayout *convert_layout(AudioChannelLayout *layout, UInt32* si
return new_layout; 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); AudioChannelLayout *layout_copy = av_malloc(layoutSize);
memcpy(layout_copy, layout, layoutSize); memcpy(layout_copy, layout, layoutSize);
uint64_t layout_mask = 0; uint64_t layout_mask = 0;
int i; UInt32 i;
if (!layout_copy) if (!layout_copy)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
if (!(layout_copy = convert_layout(layout_copy, &layoutSize))) if (!(layout_copy = convert_layout(layout_copy, &layoutSize)))
@@ -254,7 +254,7 @@ done:
return layout_mask; 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; const uint64_t *p;
uint64_t best_ch_layout = 0; uint64_t best_ch_layout = 0;
+1 -1
View File
@@ -824,7 +824,7 @@ static bool GetFirstHeader(FILE* inFile)
return self; return self;
} }
- (NSUInteger)timescaleForTrack:(MP42Track *)track - (UInt32)timescaleForTrack:(MP42Track *)track
{ {
return samplesPerSecond; return samplesPerSecond;
} }
+1 -1
View File
@@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) UInt32 outputLayoutSize; @property (nonatomic, readonly) UInt32 outputLayoutSize;
@property (nonatomic, readonly) AudioStreamBasicDescription outputFormat; @property (nonatomic, readonly) AudioStreamBasicDescription outputFormat;
@property (nonatomic, readonly) NSData *magicCookie; @property (nonatomic, readonly, nullable) NSData *magicCookie;
@end @end
+1 -1
View File
@@ -297,7 +297,7 @@ MP42_OBJC_DIRECT_MEMBERS
} }
} }
- (NSData *)magicCookie - (nullable NSData *)magicCookie
{ {
return _magicCookie; return _magicCookie;
} }
+5 -2
View File
@@ -336,7 +336,7 @@ static bool GetFirstHeader(FILE* inFile)
return self; return self;
} }
- (NSUInteger)timescaleForTrack:(MP42Track *)track - (UInt32)timescaleForTrack:(MP42Track *)track
{ {
return samplesPerSecond; return samplesPerSecond;
} }
@@ -368,18 +368,21 @@ static bool GetFirstHeader(FILE* inFile)
int64_t currentSize = 0; int64_t currentSize = 0;
while (LoadNextAc3Frame(inFile, &pBuf, &pBufSize, false) && !self.isCancelled) { while (LoadNextAc3Frame(inFile, &pBuf, &pBufSize, false) && !self.isCancelled) {
if (pBufSize < UINT32_MAX) {
MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init]; MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init];
void *sampleDataBuffer = malloc(pBufSize); void *sampleDataBuffer = malloc(pBufSize);
memcpy(sampleDataBuffer, pBuf, pBufSize); memcpy(sampleDataBuffer, pBuf, pBufSize);
sample->data = sampleDataBuffer; sample->data = sampleDataBuffer;
sample->size = pBufSize; sample->size = (uint32_t)pBufSize;
sample->duration = MP4_INVALID_DURATION; sample->duration = MP4_INVALID_DURATION;
sample->flags |= MP42SampleBufferFlagIsSync; sample->flags |= MP42SampleBufferFlagIsSync;
sample->trackId = trackId; sample->trackId = trackId;
[self enqueue:sample]; [self enqueue:sample];
}
sampleId++; sampleId++;
+47 -40
View File
@@ -108,7 +108,8 @@ MP42_OBJC_DIRECT_MEMBERS
for (AVTimedMetadataGroup *chapterData in chapterList) { for (AVTimedMetadataGroup *chapterData in chapterList) {
for (AVMetadataItem *item in chapterData.items) { for (AVMetadataItem *item in chapterData.items) {
CMTime time = item.time; 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 #pragma mark - Overrides
- (NSUInteger)timescaleForTrack:(MP42Track *)track { - (UInt32)timescaleForTrack:(MP42Track *)track {
AVAssetTrack *assetTrack = [_localAsset trackWithTrackID:track.sourceId]; AVAssetTrack *assetTrack = [_localAsset trackWithTrackID:track.sourceId];
// Prefer the asbd sample rate, naturalTimeScale might not be // Prefer the asbd sample rate, naturalTimeScale might not be
@@ -786,9 +787,9 @@ MP42_OBJC_DIRECT_MEMBERS
} else if ([assetTrack.mediaType isEqualToString:AVMediaTypeAudio]) { } else if ([assetTrack.mediaType isEqualToString:AVMediaTypeAudio]) {
size_t cookieSizeOut; 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) { if (code == kAudioFormatMPEG4AAC) {
@@ -831,7 +832,7 @@ MP42_OBJC_DIRECT_MEMBERS
// Extract DecoderSpecific info // Extract DecoderSpecific info
UInt8 *buffer; UInt8 *buffer;
int size; int size;
ReadESDSDescExt((void *)cookieBuffer, &buffer, &size, 0); ReadESDSDescExt((void *)cookie, &buffer, &size, 0);
NSData *magicCookie = [NSData dataWithBytes:buffer length:size]; NSData *magicCookie = [NSData dataWithBytes:buffer length:size];
free(buffer); free(buffer);
@@ -843,30 +844,31 @@ MP42_OBJC_DIRECT_MEMBERS
if (cookieSizeOut > 48) { if (cookieSizeOut > 48) {
// Remove unneeded parts of the cookie, as described in ALACMagicCookieDescription.txt // Remove unneeded parts of the cookie, as described in ALACMagicCookieDescription.txt
cookieBuffer += 24; cookie += 24;
cookieSizeOut = cookieSizeOut - 24 - 8; cookieSizeOut = cookieSizeOut - 24 - 8;
} }
return [NSData dataWithBytes:cookieBuffer length:cookieSizeOut]; return [NSData dataWithBytes:cookie length:cookieSizeOut];
} }
else if (code == kAudioFormatOpus) { else if (code == kAudioFormatOpus) {
// TODO // TODO
return [NSData dataWithBytes:cookieBuffer length:cookieSizeOut]; return [NSData dataWithBytes:cookie length:cookieSizeOut];
} }
else if (code == kAudioFormatFLAC) { else if (code == kAudioFormatFLAC) {
// TODO // TODO
return [NSData dataWithBytes:cookieBuffer length:cookieSizeOut]; return [NSData dataWithBytes:cookie length:cookieSizeOut];
} }
else if (code == kAudioFormatEnhancedAC3) { else if (code == kAudioFormatEnhancedAC3) {
// dec3 atom // dec3 atom
// remove the atom header // remove the atom header
cookieBuffer += 8; cookie += 8;
cookieSizeOut = cookieSizeOut - 8; cookieSizeOut = cookieSizeOut - 8;
NSMutableData *ac3Info = [NSMutableData dataWithBytes:cookieBuffer length:cookieSizeOut]; if (cookieSizeOut < UINT32_MAX) {
NSMutableData *ac3Info = [NSMutableData dataWithBytes:cookie length:cookieSizeOut];
MP42AudioTrack *audiotrack = (MP42AudioTrack *)track; MP42AudioTrack *audiotrack = (MP42AudioTrack *)track;
// besides fourCC also the bsid in cookie created by CMAudioFormatDescriptionGetMagicCookie needs to be fixed // besides fourCC also the bsid in cookie created by CMAudioFormatDescriptionGetMagicCookie needs to be fixed
NSRange cookieBsidRange = NSMakeRange(2, 1); NSRange cookieBsidRange = NSMakeRange(2, 1);
@@ -878,7 +880,7 @@ MP42_OBJC_DIRECT_MEMBERS
UInt8 ec3ExtensionType = EC3Extension_None; UInt8 ec3ExtensionType = EC3Extension_None;
UInt8 complexityIndex = 0; UInt8 complexityIndex = 0;
UInt32 dummy; UInt32 dummy;
readEAC3Config(cookieBuffer, cookieSizeOut, &dummy, &dummy, &ec3ExtensionType, &complexityIndex); readEAC3Config(cookie, (uint32_t)cookieSizeOut, &dummy, &dummy, &ec3ExtensionType, &complexityIndex);
// do not add duplicate ec3ExtensionType & complexityIndex, if already present // do not add duplicate ec3ExtensionType & complexityIndex, if already present
if (!ec3ExtensionType && !complexityIndex && (audiotrack.extensionType == kMP42AudioEmbeddedExtension_JOC)) if (!ec3ExtensionType && !complexityIndex && (audiotrack.extensionType == kMP42AudioEmbeddedExtension_JOC))
{ {
@@ -886,8 +888,10 @@ MP42_OBJC_DIRECT_MEMBERS
[ac3Info appendBytes:&ec3ExtensionType length:sizeof(MP42AudioEmbeddedExtension)]; [ac3Info appendBytes:&ec3ExtensionType length:sizeof(MP42AudioEmbeddedExtension)];
[ac3Info appendBytes:&complexityIndex length:sizeof(UInt8)]; [ac3Info appendBytes:&complexityIndex length:sizeof(UInt8)];
} }
return ac3Info; return ac3Info;
} else {
return nil;
}
} }
else if (code == kAudioFormatAC3 || else if (code == kAudioFormatAC3 ||
@@ -965,7 +969,7 @@ MP42_OBJC_DIRECT_MEMBERS
return ac3Info; return ac3Info;
} else if (cookieSizeOut) { } 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; return result;
} }
- (BOOL)audioTrackUsesExplicitEncoderDelay:(MP42Track *)track; - (BOOL)audioTrackUsesExplicitEncoderDelay:(MP42Track *)track
{ {
return YES; return YES;
} }
@@ -1013,8 +1017,8 @@ MP42_OBJC_DIRECT_MEMBERS
uint64_t currentDataLength = 0; uint64_t currentDataLength = 0;
uint64_t totalDataLength = 0; uint64_t totalDataLength = 0;
NSInteger tracksDone = 0; NSUInteger tracksDone = 0;
NSInteger tracksNumber = self.inputTracks.count; NSUInteger tracksNumber = self.inputTracks.count;
AVAssetReader *assetReader = [[AVAssetReader alloc] initWithAsset:_localAsset error:NULL]; AVAssetReader *assetReader = [[AVAssetReader alloc] initWithAsset:_localAsset error:NULL];
AVFDemuxHelper * helpers[tracksNumber]; AVFDemuxHelper * helpers[tracksNumber];
@@ -1141,7 +1145,7 @@ MP42_OBJC_DIRECT_MEMBERS
// Enqueues the new sample // Enqueues the new sample
MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init]; MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init];
sample->data = sampleData; sample->data = sampleData;
sample->size = bufferSize; sample->size = (uint32_t)bufferSize;
sample->duration = duration.value; sample->duration = duration.value;
sample->offset = -decodeTimeStamp.value + presentationTimeStamp.value; sample->offset = -decodeTimeStamp.value + presentationTimeStamp.value;
sample->decodeTimestamp = decodeTimeStamp.value; sample->decodeTimestamp = decodeTimeStamp.value;
@@ -1213,23 +1217,23 @@ MP42_OBJC_DIRECT_MEMBERS
for (uint64_t i = 0, pos = 0; i < samplesNum; i++) { for (uint64_t i = 0, pos = 0; i < samplesNum; i++) {
CMSampleTimingInfo sampleTimingInfo; CMSampleTimingInfo sampleTimingInfo;
CMTime decodeTimeStamp; CMTime sampleDecodeTimeStamp;
CMTime presentationTimeStamp; CMTime samplePresentationTimeStamp;
size_t sampleSize; size_t sampleSize;
// If the size of sample timing array is equal to 1, it means every sample has got the same timing // If the size of sample timing array is equal to 1, it means every sample has got the same timing
if (timingArrayEntries == 1) { if (timingArrayEntries == 1) {
sampleTimingInfo = timingArrayOut[0]; sampleTimingInfo = timingArrayOut[0];
decodeTimeStamp = sampleTimingInfo.decodeTimeStamp; sampleDecodeTimeStamp = sampleTimingInfo.decodeTimeStamp;
decodeTimeStamp.value = decodeTimeStamp.value + ( sampleTimingInfo.duration.value * i); sampleDecodeTimeStamp.value = sampleDecodeTimeStamp.value + (sampleTimingInfo.duration.value * i);
presentationTimeStamp = sampleTimingInfo.presentationTimeStamp; samplePresentationTimeStamp = sampleTimingInfo.presentationTimeStamp;
presentationTimeStamp.value = presentationTimeStamp.value + ( sampleTimingInfo.duration.value * i); samplePresentationTimeStamp.value = samplePresentationTimeStamp.value + (sampleTimingInfo.duration.value * i);
} else { } else {
sampleTimingInfo = timingArrayOut[i]; sampleTimingInfo = timingArrayOut[i];
//decodeTimeStamp = sampleTimingInfo.decodeTimeStamp; //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 // 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; sample->attachments = (void *)copy;
CFDictionaryRef trimStart = CFDictionaryGetValue(sample->attachments, kCMSampleBufferAttachmentKey_TrimDurationAtStart); CFDictionaryRef trimStart = CFDictionaryGetValue(sample->attachments, kCMSampleBufferAttachmentKey_TrimDurationAtStart);
CMTime trimStartTime = CMTimeMakeFromDictionary(trimStart); CMTime trimStartTime = CMTimeMakeFromDictionary(trimStart);
trimStartTime = CMTimeConvertScale(trimStartTime, sampleTimingInfo.duration.value, kCMTimeRoundingMethod_Default); trimStartTime = CMTimeConvertScale(trimStartTime, currentOutputTimeStamp.timescale, kCMTimeRoundingMethod_Default);
currentOutputTimeStamp.value -= trimStartTime.value; currentOutputTimeStamp.value -= trimStartTime.value;
} }
sample->data = sampleData; sample->data = sampleData;
sample->size = sampleSize; sample->size = (uint32_t)sampleSize;
sample->duration = sampleTimingInfo.duration.value; sample->duration = sampleTimingInfo.duration.value;
//sample->offset = -decodeTimeStamp.value + presentationTimeStamp.value; //sample->offset = -decodeTimeStamp.value + presentationTimeStamp.value;
sample->presentationTimestamp = presentationTimeStamp.value; sample->presentationTimestamp = samplePresentationTimeStamp.value;
sample->presentationOutputTimestamp = currentOutputTimeStamp.value; sample->presentationOutputTimestamp = currentOutputTimeStamp.value;
sample->timescale = demuxHelper->timescale; sample->timescale = demuxHelper->timescale;
sample->flags |= sync ? MP42SampleBufferFlagIsSync : 0; sample->flags |= sync ? MP42SampleBufferFlagIsSync : 0;
@@ -1281,7 +1284,7 @@ MP42_OBJC_DIRECT_MEMBERS
sample->attachments = (void *)copy; sample->attachments = (void *)copy;
CFDictionaryRef trimEnd = CFDictionaryGetValue(sample->attachments, kCMSampleBufferAttachmentKey_TrimDurationAtEnd); CFDictionaryRef trimEnd = CFDictionaryGetValue(sample->attachments, kCMSampleBufferAttachmentKey_TrimDurationAtEnd);
CMTime trimEndTime = CMTimeMakeFromDictionary(trimEnd); CMTime trimEndTime = CMTimeMakeFromDictionary(trimEnd);
trimEndTime = CMTimeConvertScale(trimEndTime, sampleTimingInfo.duration.value, kCMTimeRoundingMethod_Default); trimEndTime = CMTimeConvertScale(trimEndTime, currentOutputTimeStamp.timescale, kCMTimeRoundingMethod_Default);
currentOutputTimeStamp.value -= trimEndTime.value; currentOutputTimeStamp.value -= trimEndTime.value;
} }
@@ -1301,14 +1304,14 @@ MP42_OBJC_DIRECT_MEMBERS
free(sizeArrayOut); free(sizeArrayOut);
} }
else { else {
CMTime currentDuration = CMTimeConvertScale(duration, demuxHelper->timescale, kCMTimeRoundingMethod_Default); CMTime currentSampleDuration = CMTimeConvertScale(duration, demuxHelper->timescale, kCMTimeRoundingMethod_Default);
CMTime currentTimeStamp = CMTimeConvertScale(presentationTimeStamp, demuxHelper->timescale, kCMTimeRoundingMethod_Default); CMTime currentSampleTimeStamp = CMTimeConvertScale(presentationTimeStamp, demuxHelper->timescale, kCMTimeRoundingMethod_Default);
CMTime currentOutputTimeStamp = CMTimeConvertScale(presentationOutputTimeStamp, demuxHelper->timescale, kCMTimeRoundingMethod_Default); CMTime currentSampleOutputTimeStamp = CMTimeConvertScale(presentationOutputTimeStamp, demuxHelper->timescale, kCMTimeRoundingMethod_Default);
MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init]; MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init];
sample->duration = currentDuration.value; sample->duration = currentSampleDuration.value;
sample->presentationTimestamp = currentTimeStamp.value; sample->presentationTimestamp = currentSampleTimeStamp.value;
sample->presentationOutputTimestamp = currentOutputTimeStamp.value; sample->presentationOutputTimestamp = currentSampleOutputTimeStamp.value;
sample->timescale = demuxHelper->timescale; sample->timescale = demuxHelper->timescale;
sample->flags |= sync ? MP42SampleBufferFlagIsSync : 0; sample->flags |= sync ? MP42SampleBufferFlagIsSync : 0;
sample->flags |= doNotDisplay ? MP42SampleBufferFlagDoNotDisplay : 0; sample->flags |= doNotDisplay ? MP42SampleBufferFlagDoNotDisplay : 0;
@@ -1316,7 +1319,7 @@ MP42_OBJC_DIRECT_MEMBERS
sample->attachments = (void *)attachments; sample->attachments = (void *)attachments;
[demuxHelper->editsConstructor addSample:sample]; [demuxHelper->editsConstructor addSample:sample];
demuxHelper->currentTime = currentOutputTimeStamp.value; demuxHelper->currentTime = currentSampleOutputTimeStamp.value;
} }
CFRelease(sampleBuffer); CFRelease(sampleBuffer);
@@ -1374,7 +1377,7 @@ MP42_OBJC_DIRECT_MEMBERS
MP4SetSampleRenderingOffset(fileHandle, MP4SetSampleRenderingOffset(fileHandle,
trackId, trackId,
1 + i, 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); void *sampleData = malloc(bufferSize);
CMBlockBufferCopyDataBytes(buffer, 0, bufferSize, sampleData); 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); free(sampleData);
count++; count++;
@@ -1486,7 +1491,9 @@ MP42_OBJC_DIRECT_MEMBERS
pos += sampleSize; pos += sampleSize;
} }
analyze_EAC3((void *)&eac3Info, sampleData, sampleSize); if (sampleSize < UINT32_MAX) {
analyze_EAC3((void *)&eac3Info, sampleData, (uint32_t)sampleSize);
}
free(sampleData); free(sampleData);
count++; count++;
+1 -1
View File
@@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)addSample:(MP42SampleBuffer *)sample; - (void)addSample:(MP42SampleBuffer *)sample;
- (nullable MP42SampleBuffer *)copyEncodedSample; - (nullable MP42SampleBuffer *)copyEncodedSample;
@property (nonatomic, readonly) NSData *magicCookie; @property (nonatomic, readonly, nullable) NSData *magicCookie;
@property (nonatomic, readonly) double sampleRate; @property (nonatomic, readonly) double sampleRate;
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
+1 -1
View File
@@ -131,7 +131,7 @@ MP42_OBJC_DIRECT_MEMBERS
return [_encoder copyEncodedSample]; return [_encoder copyEncodedSample];
} }
- (NSData *)magicCookie { - (nullable NSData *)magicCookie {
return _encoder.magicCookie; return _encoder.magicCookie;
} }
+1 -1
View File
@@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
mixdownType:(MP42AudioMixdown)mixdownType mixdownType:(MP42AudioMixdown)mixdownType
drc:(float)drc drc:(float)drc
initialPadding:(UInt32)initialPadding initialPadding:(UInt32)initialPadding
magicCookie:(NSData *)magicCookie magicCookie:(nullable NSData *)magicCookie
error:(NSError * __autoreleasing *)error; error:(NSError * __autoreleasing *)error;
@property (nonatomic, readonly, nullable) AudioChannelLayout *inputLayout; @property (nonatomic, readonly, nullable) AudioChannelLayout *inputLayout;
+10 -4
View File
@@ -33,7 +33,7 @@ struct MP42DecodeContext {
AudioStreamBasicDescription *outputFormat; AudioStreamBasicDescription *outputFormat;
enum AVMatrixEncoding matrix_encoding; enum AVMatrixEncoding matrix_encoding;
int out_layout; uint64_t out_layout;
int drop_samples; int drop_samples;
@@ -72,7 +72,7 @@ MP42_OBJC_DIRECT_MEMBERS
mixdownType:(MP42AudioMixdown)mixdownType mixdownType:(MP42AudioMixdown)mixdownType
drc:(float)drc drc:(float)drc
initialPadding:(UInt32)initialPadding initialPadding:(UInt32)initialPadding
magicCookie:(NSData *)magicCookie magicCookie:(nullable NSData *)magicCookie
error:(NSError * __autoreleasing *)error error:(NSError * __autoreleasing *)error
{ {
self = [super init]; self = [super init];
@@ -101,10 +101,16 @@ MP42_OBJC_DIRECT_MEMBERS
av_freep(&_avctx); av_freep(&_avctx);
return nil; return nil;
} }
else { else if (magicCookie.length < UINT32_MAX) {
_avctx->extradata_size = magicCookie.length; _avctx->extradata_size = (uint32_t)magicCookie.length;
memcpy(_avctx->extradata, magicCookie.bytes, 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; AVDictionary *av_opts = NULL;
+2 -2
View File
@@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface MP42AudioEncoder : NSObject<MP42AudioUnit> @interface MP42AudioEncoder : NSObject<MP42AudioUnit>
- (instancetype)initWithInputUnit:(id<MP42AudioUnit>)unit bitRate:(NSUInteger)bitRate error:(NSError * __autoreleasing *)error; - (instancetype)initWithInputUnit:(id<MP42AudioUnit>)unit bitRate:(UInt32)bitRate error:(NSError * __autoreleasing *)error;
@property (nonatomic, readonly, nullable) AudioChannelLayout *inputLayout; @property (nonatomic, readonly, nullable) AudioChannelLayout *inputLayout;
@property (nonatomic, readonly) UInt32 inputLayoutSize; @property (nonatomic, readonly) UInt32 inputLayoutSize;
@@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) AudioCodecPrimeInfo primeInfo; @property (nonatomic, readonly) AudioCodecPrimeInfo primeInfo;
@property (nonatomic, readonly) NSData *magicCookie; @property (nonatomic, readonly, nullable) NSData *magicCookie;
@end @end
+4 -4
View File
@@ -47,7 +47,7 @@ MP42_OBJC_DIRECT_MEMBERS
} }
@property (nonatomic, readonly) AudioConverterRef encoder; @property (nonatomic, readonly) AudioConverterRef encoder;
@property (nonatomic, readonly) NSUInteger bitrate; @property (nonatomic, readonly) UInt32 bitrate;
@property (nonatomic, readonly) NSThread *thread; @property (nonatomic, readonly) NSThread *thread;
@property (nonatomic, readonly) MP42Fifo<MP42SampleBuffer *> *inputSamplesBuffer; @property (nonatomic, readonly) MP42Fifo<MP42SampleBuffer *> *inputSamplesBuffer;
@@ -67,7 +67,7 @@ MP42_OBJC_DIRECT_MEMBERS
@synthesize magicCookie = _magicCookie; @synthesize magicCookie = _magicCookie;
- (instancetype)initWithInputUnit:(id<MP42AudioUnit>)unit bitRate:(NSUInteger)bitRate error:(NSError * __autoreleasing *)error - (instancetype)initWithInputUnit:(id<MP42AudioUnit>)unit bitRate:(UInt32)bitRate error:(NSError * __autoreleasing *)error
{ {
self = [super init]; self = [super init];
if (self) { if (self) {
@@ -92,7 +92,7 @@ MP42_OBJC_DIRECT_MEMBERS
#pragma mark - Encoder Init #pragma mark - Encoder Init
- (BOOL)initConverterWithBitRate:(NSUInteger)bitrate - (BOOL)initConverterWithBitRate:(UInt32)bitrate
{ {
OSStatus err; OSStatus err;
AudioStreamBasicDescription outputFormat; AudioStreamBasicDescription outputFormat;
@@ -317,7 +317,7 @@ MP42_OBJC_DIRECT_MEMBERS
} }
} }
- (NSData *)magicCookie - (nullable NSData *)magicCookie
{ {
return _magicCookie; return _magicCookie;
} }
+19 -17
View File
@@ -18,7 +18,7 @@
MP42_OBJC_DIRECT_MEMBERS MP42_OBJC_DIRECT_MEMBERS
@implementation MP42AudioTrack @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]; self = [super initWithSourceURL:URL trackID:trackID fileHandle:fileHandle];
@@ -65,7 +65,7 @@ MP42_OBJC_DIRECT_MEMBERS
if (audioType == 0xA9) { if (audioType == 0xA9) {
uint64_t channels_count = 0; uint64_t channels_count = 0;
MP4GetTrackIntegerProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.mp4a.channels", &channels_count); 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")) { 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")) { else if (MP4HaveTrackAtom(fileHandle, self.trackId, "mdia.minf.stbl.stsd.alac")) {
uint64_t channels_count = 0; uint64_t channels_count = 0;
MP4GetTrackIntegerProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.alac.channels", &channels_count); 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")) { else if (MP4HaveTrackAtom(fileHandle, self.trackId, "mdia.minf.stbl.stsd.twos")) {
uint64_t channels_count = 0; uint64_t channels_count = 0;
MP4GetTrackIntegerProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.twos.channels", &channels_count); MP4GetTrackIntegerProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.twos.channels", &channels_count);
_channels = channels_count; _channels = (UInt32)channels_count;
_channelLayoutTag = getDefaultChannelLayout(channels_count); _channelLayoutTag = getDefaultChannelLayout((UInt32)channels_count);
} }
if (MP4HaveTrackAtom(fileHandle, self.trackId, "tref.fall")) { if (MP4HaveTrackAtom(fileHandle, self.trackId, "tref.fall")) {
@@ -161,8 +161,9 @@ MP42_OBJC_DIRECT_MEMBERS
if (self.updatedProperty[@"fallback"] || !self.muxed) { if (self.updatedProperty[@"fallback"] || !self.muxed) {
if (_fallbackTrack) { MP42Track *fallbackTrack = _fallbackTrack;
_fallbackTrackId = _fallbackTrack.trackId; if (fallbackTrack) {
_fallbackTrackId = fallbackTrack.trackId;
} }
if (MP4HaveTrackAtom(fileHandle, self.trackId, "tref.fall") && (_fallbackTrackId == 0)) { if (MP4HaveTrackAtom(fileHandle, self.trackId, "tref.fall") && (_fallbackTrackId == 0)) {
@@ -178,8 +179,9 @@ MP42_OBJC_DIRECT_MEMBERS
if (self.updatedProperty[@"follows"] || !self.muxed) { if (self.updatedProperty[@"follows"] || !self.muxed) {
if (_followsTrack) { MP42Track *followsTrack = _followsTrack;
_followsTrackId = _followsTrack.trackId; if (followsTrack) {
_followsTrackId = followsTrack.trackId;
} }
if (MP4HaveTrackAtom(fileHandle, self.trackId, "tref.folw") && (_followsTrackId == 0)) { if (MP4HaveTrackAtom(fileHandle, self.trackId, "tref.folw") && (_followsTrackId == 0)) {
@@ -286,12 +288,12 @@ MP42_OBJC_DIRECT_MEMBERS
[coder encodeFloat:_volume forKey:@"volume"]; [coder encodeFloat:_volume forKey:@"volume"];
[coder encodeInt64:_channels forKey:@"channels"]; [coder encodeInt32:_channels forKey:@"channels"];
[coder encodeInt64:_channelLayoutTag forKey:@"channelLayoutTag"]; [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 - (id)initWithCoder:(NSCoder *)decoder
@@ -301,12 +303,12 @@ MP42_OBJC_DIRECT_MEMBERS
if (self) { if (self) {
_volume = [decoder decodeFloatForKey:@"volume"]; _volume = [decoder decodeFloatForKey:@"volume"];
_channels = [decoder decodeInt64ForKey:@"channels"]; _channels = [decoder decodeInt32ForKey:@"channels"];
_channelLayoutTag = [decoder decodeInt64ForKey:@"channelLayoutTag"]; _channelLayoutTag = [decoder decodeInt32ForKey:@"channelLayoutTag"];
_extensionType = [decoder decodeIntegerForKey:@"extensionType"]; _extensionType = [decoder decodeInt32ForKey:@"extensionType"];
_fallbackTrackId = [decoder decodeInt64ForKey:@"fallbackTrackId"]; _fallbackTrackId = [decoder decodeInt32ForKey:@"fallbackTrackId"];
} }
return self; return self;
+1 -2
View File
@@ -59,8 +59,7 @@ MP42_OBJC_DIRECT_MEMBERS
- (CIContext *)imgContext { - (CIContext *)imgContext {
if (!_imgContext) { if (!_imgContext) {
_imgContext = [CIContext contextWithCGContext:[[NSGraphicsContext currentContext] CGContext] _imgContext = [[CIContext alloc] init];
options:nil];
} }
return _imgContext; return _imgContext;
} }
+2 -2
View File
@@ -37,7 +37,7 @@ MP42_OBJC_DIRECT_MEMBERS
return self; return self;
} }
- (NSUInteger)timescaleForTrack:(MP42Track *)track - (UInt32)timescaleForTrack:(MP42Track *)track
{ {
return 30000; return 30000;
} }
@@ -229,7 +229,7 @@ static int ParseByte(const char *string, UInt8 *byte, Boolean hex)
MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init]; MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init];
sample->data = bytes; sample->data = bytes;
sample->size = byteCount + 8; sample->size = (uint32_t)byteCount + 8;
sample->duration = sampleDuration * 1001; sample->duration = sampleDuration * 1001;
sample->offset = 0; sample->offset = 0;
sample->decodeTimestamp = 0; sample->decodeTimestamp = 0;
+1 -1
View File
@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface MP42ChapterTrack : MP42Track <NSSecureCoding> @interface MP42ChapterTrack : MP42Track <NSSecureCoding>
- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP42FileHandle)fileHandle; - (instancetype)initWithSourceURL:(NSURL *)URL trackID:(MP42TrackId)trackID fileHandle:(MP42FileHandle)fileHandle;
+ (instancetype)chapterTrackFromFile:(NSURL *)URL; + (instancetype)chapterTrackFromFile:(NSURL *)URL;
- (NSUInteger)addChapter:(MP42TextSample *)chapter; - (NSUInteger)addChapter:(MP42TextSample *)chapter;
+9 -9
View File
@@ -34,7 +34,7 @@ MP42_OBJC_DIRECT_MEMBERS
return self; 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]; self = [super initWithSourceURL:URL trackID:trackID fileHandle:fileHandle];
@@ -104,7 +104,7 @@ MP42_OBJC_DIRECT_MEMBERS
- (NSString *)defaultName { - (NSString *)defaultName {
NSBundle *bundle = [NSBundle bundleForClass:[MP42ChapterTrack class]]; 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 - (NSUInteger)addChapter:(MP42TextSample *)chapter
@@ -198,7 +198,7 @@ MP42_OBJC_DIRECT_MEMBERS
refTrack = 1; refTrack = 1;
} }
chapterCount = _chapters.count; chapterCount = (uint32_t)_chapters.count;
if (chapterCount) { if (chapterCount) {
// Insert a chapter at time 0 if there isn't one // 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 - (BOOL)exportToURL:(NSURL *)url error:(NSError * __autoreleasing *)error
{ {
NSMutableString* file = [[NSMutableString alloc] init]; NSMutableString *file = [[NSMutableString alloc] init];
NSUInteger x = 0; NSUInteger x = 0;
for (MP42TextSample *chapter in _chapters) { for (MP42TextSample *chapter in _chapters) {
@@ -294,11 +294,11 @@ MP42_OBJC_DIRECT_MEMBERS
} }
- (BOOL)updateFromCSVFile:(NSURL *)URL error:(NSError * __autoreleasing *)outError { - (BOOL)updateFromCSVFile:(NSURL *)URL error:(NSError * __autoreleasing *)outError {
NSArray *csvData = [NSArray arrayWithContentsOfCSVURL:URL]; NSArray<NSArray<NSString *> *> *csvData = [NSArray arrayWithContentsOfCSVURL:URL];
if (csvData.count == self.chapterCount) { if (csvData.count == self.chapterCount) {
for (NSUInteger i = 0; i < csvData.count; ++i) { for (NSUInteger i = 0; i < csvData.count; ++i) {
NSArray *lineFields = csvData[i]; NSArray<NSString *> *lineFields = csvData[i];
if (lineFields.count != 2 || [lineFields[0] integerValue] != i + 1) { if (lineFields.count != 2 || lineFields[0].integerValue != i + 1) {
if (NULL != outError) if (NULL != outError)
*outError = MP42Error(MP42LocalizedString(@"Invalid chapters CSV file.", @"error message"), *outError = MP42Error(MP42LocalizedString(@"Invalid chapters CSV file.", @"error message"),
MP42LocalizedString(@"The CSV file is not a valid 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
// <one> // <one>
// <John said, "Hello there."> // <John said, "Hello there.">
// <three> // <three>
+ (nullable NSArray<NSArray<NSString *> *> *)arrayWithContentsOfCSVURL:(NSURL *)url; + (nullable NSArray<NSArray<NSString *> *> *)arrayWithContentsOfCSVURL:(NSURL *)url
{ {
NSString *str1 = STLoadFileWithUnknownEncoding(url); NSString *str1 = STLoadFileWithUnknownEncoding(url);
NSMutableString *csvString = STStandardizeStringNewlines(str1); NSMutableString *csvString = STStandardizeStringNewlines(str1);
@@ -386,7 +386,7 @@ MP42_OBJC_DIRECT_MEMBERS
if ([csvString characterAtIndex:[csvString length]-1] != '\n') [csvString appendFormat:@"%c",'\n']; if ([csvString characterAtIndex:[csvString length]-1] != '\n') [csvString appendFormat:@"%c",'\n'];
NSScanner *sc = [NSScanner scannerWithString:csvString]; NSScanner *sc = [NSScanner scannerWithString:csvString];
sc.charactersToBeSkipped = nil; sc.charactersToBeSkipped = nil;
NSMutableArray *csvArray = [NSMutableArray array]; NSMutableArray<NSMutableArray<NSString *> *> *csvArray = [NSMutableArray array];
[csvArray addObject:[NSMutableArray array]]; [csvArray addObject:[NSMutableArray array]];
NSCharacterSet *commaNewlineCS = [NSCharacterSet characterSetWithCharactersInString:@",\n"]; NSCharacterSet *commaNewlineCS = [NSCharacterSet characterSetWithCharactersInString:@",\n"];
while (sc.scanLocation < csvString.length) { while (sc.scanLocation < csvString.length) {
+3 -3
View File
@@ -21,11 +21,11 @@ NS_ASSUME_NONNULL_BEGIN
@interface MP42AudioConversionSettings : MP42ConversionSettings <NSCopying, NSSecureCoding> @interface MP42AudioConversionSettings : MP42ConversionSettings <NSCopying, NSSecureCoding>
+ (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) MP42AudioMixdown mixDown;
@property (nonatomic, readonly) float drc; @property (nonatomic, readonly) float drc;
+8 -8
View File
@@ -48,14 +48,14 @@
- (void)encodeWithCoder:(NSCoder *)coder - (void)encodeWithCoder:(NSCoder *)coder
{ {
[coder encodeInt:1 forKey:@"MP42ConversionSettingsVersion"]; [coder encodeInt:1 forKey:@"MP42ConversionSettingsVersion"];
[coder encodeInteger:_format forKey:@"format"]; [coder encodeInt32:_format forKey:@"format"];
} }
- (id)initWithCoder:(NSCoder *)decoder - (id)initWithCoder:(NSCoder *)decoder
{ {
self = [super init]; self = [super init];
_format = [decoder decodeIntegerForKey:@"format"]; _format = [decoder decodeInt32ForKey:@"format"];
return self; return self;
} }
@@ -64,12 +64,12 @@
@implementation MP42AudioConversionSettings @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]; 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]; self = [super initWitFormat:format];
if (self) { if (self) {
@@ -104,8 +104,8 @@
- (void)encodeWithCoder:(NSCoder *)coder - (void)encodeWithCoder:(NSCoder *)coder
{ {
[coder encodeInteger:_bitRate forKey:@"bitRate"]; [coder encodeInt32:_bitRate forKey:@"bitRate"];
[coder encodeInteger:_mixDown forKey:@"mixDownType"]; [coder encodeInt32:_mixDown forKey:@"mixDownType"];
[coder encodeFloat:_drc forKey:@"drc"]; [coder encodeFloat:_drc forKey:@"drc"];
} }
@@ -113,8 +113,8 @@
{ {
self = [super initWithCoder:decoder]; self = [super initWithCoder:decoder];
_bitRate = [decoder decodeIntegerForKey:@"bitRate"]; _bitRate = [decoder decodeInt32ForKey:@"bitRate"];
_mixDown = [decoder decodeIntegerForKey:@"mixDownType"]; _mixDown = [decoder decodeInt32ForKey:@"mixDownType"];
_drc = [decoder decodeFloatForKey:@"drc"]; _drc = [decoder decodeFloatForKey:@"drc"];
return self; return self;
+1 -1
View File
@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
@protocol MP42ConverterProtocol <NSObject> @protocol MP42ConverterProtocol <NSObject>
@optional @optional
- (NSData *)magicCookie; - (nullable NSData *)magicCookie;
@required @required
- (void)addSample:(MP42SampleBuffer *)sample; - (void)addSample:(MP42SampleBuffer *)sample;
+17 -12
View File
@@ -161,7 +161,7 @@ MP42_OBJC_DIRECT_MEMBERS
return self; return self;
} }
- (instancetype)initWithURL:(NSURL *)URL error:(NSError * _Nullable *)error { - (instancetype)initWithURL:(NSURL *)URL error:(NSError * _Nullable __autoreleasing *)error {
self = [super init]; self = [super init];
if (self) { if (self) {
_URL = [URL fileReferenceURL]; _URL = [URL fileReferenceURL];
@@ -214,7 +214,7 @@ MP42_OBJC_DIRECT_MEMBERS
MP4TrackId chapterId = findChapterTrackId(_fileHandle); MP4TrackId chapterId = findChapterTrackId(_fileHandle);
MP4TrackId previewsId = findChapterPreviewTrackId(_fileHandle); MP4TrackId previewsId = findChapterPreviewTrackId(_fileHandle);
for (int i = 0; i< tracksCount; i++) { for (uint32_t i = 0; i < tracksCount; i++) {
id track; id track;
MP4TrackId trackId = MP4FindTrackId(_fileHandle, i, 0, 0); MP4TrackId trackId = MP4FindTrackId(_fileHandle, i, 0, 0);
const char *type = MP4GetTrackType(_fileHandle, trackId); const char *type = MP4GetTrackType(_fileHandle, trackId);
@@ -477,7 +477,8 @@ MP42_OBJC_DIRECT_MEMBERS
if ([track isMemberOfClass:[MP42AudioTrack class]]) { if ([track isMemberOfClass:[MP42AudioTrack class]]) {
MP42AudioTrack *audioTrack = (MP42AudioTrack *)track; 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; audioTrack.fallbackTrack = nil;
} }
} }
@@ -611,15 +612,17 @@ MP42_OBJC_DIRECT_MEMBERS
NSMutableArray *tracks = [NSMutableArray array]; NSMutableArray *tracks = [NSMutableArray array];
if ([track isKindOfClass:[MP42AudioTrack class]]) { if ([track isKindOfClass:[MP42AudioTrack class]]) {
MP42AudioTrack *audioTrack = (MP42AudioTrack *)track; MP42AudioTrack *audioTrack = (MP42AudioTrack *)track;
if (audioTrack.fallbackTrack) { MP42Track *fallbackTrack = audioTrack.fallbackTrack;
[tracks addObject:audioTrack.fallbackTrack]; if (fallbackTrack) {
[tracks addObject:fallbackTrack];
} }
} }
if ([track isKindOfClass:[MP42SubtitleTrack class]]) { if ([track isKindOfClass:[MP42SubtitleTrack class]]) {
MP42SubtitleTrack *subTrack = (MP42SubtitleTrack *)track; MP42SubtitleTrack *subTrack = (MP42SubtitleTrack *)track;
if (subTrack.forcedTrack) { MP42Track *forcedTrack = subTrack.forcedTrack;
[tracks addObject:subTrack.forcedTrack]; if (forcedTrack) {
[tracks addObject:forcedTrack];
} }
} }
return tracks; return tracks;
@@ -709,9 +712,9 @@ MP42_OBJC_DIRECT_MEMBERS
for (MP42Track *track in subGroup) { for (MP42Track *track in subGroup) {
if ([track.mediaCharacteristicTags containsObject:@"public.main-program-content"] == NO) { if ([track.mediaCharacteristicTags containsObject:@"public.main-program-content"] == NO) {
NSMutableSet<NSString *> *tags = [track.mediaCharacteristicTags mutableCopy]; NSMutableSet<NSString *> *subGroupTags = [track.mediaCharacteristicTags mutableCopy];
[tags addObject:@"public.auxiliary-content"]; [subGroupTags addObject:@"public.auxiliary-content"];
[self setTrack:track mediaCharacteristics:tags]; [self setTrack:track mediaCharacteristics:subGroupTags];
} }
} }
} }
@@ -1107,7 +1110,7 @@ MP42_OBJC_DIRECT_MEMBERS
MP4SetTrackDisabled(self.fileHandle, jpegTrack); MP4SetTrackDisabled(self.fileHandle, jpegTrack);
MP4SampleId samplesCount = MP4GetTrackNumberOfSamples(self.fileHandle, chapterTrack.trackId); MP4SampleId samplesCount = MP4GetTrackNumberOfSamples(self.fileHandle, chapterTrack.trackId);
NSUInteger idx = 1; uint32_t idx = 1;
for (MP42TextSample *chapterT in chapterTrack.chapters) { for (MP42TextSample *chapterT in chapterTrack.chapters) {
if (idx > samplesCount) { if (idx > samplesCount) {
@@ -1144,14 +1147,16 @@ MP42_OBJC_DIRECT_MEMBERS
imageData = [bitmap representationUsingType:NSBitmapImageFileTypeJPEG properties:@{}]; imageData = [bitmap representationUsingType:NSBitmapImageFileTypeJPEG properties:@{}];
} }
if (imageData.length < UINT32_MAX) {
MP4WriteSample(self.fileHandle, MP4WriteSample(self.fileHandle,
jpegTrack, jpegTrack,
imageData.bytes, imageData.bytes,
imageData.length, (uint32_t)imageData.length,
duration, duration,
0, 0,
true); true);
} }
}
MP4RemoveAllTrackReferences(self.fileHandle, "tref.chap", videoTrack.trackId); MP4RemoveAllTrackReferences(self.fileHandle, "tref.chap", videoTrack.trackId);
MP4AddTrackReference(self.fileHandle, "tref.chap", chapterTrack.trackId, videoTrack.trackId); MP4AddTrackReference(self.fileHandle, "tref.chap", chapterTrack.trackId, videoTrack.trackId);
+1 -1
View File
@@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Override #pragma mark - Override
- (NSUInteger)timescaleForTrack:(MP42Track *)track; - (UInt32)timescaleForTrack:(MP42Track *)track;
- (NSSize)sizeForTrack:(MP42VideoTrack *)track; - (NSSize)sizeForTrack:(MP42VideoTrack *)track;
- (nullable NSData *)magicCookieForTrack:(MP42Track *)track; - (nullable NSData *)magicCookieForTrack:(MP42Track *)track;
- (AudioStreamBasicDescription)audioDescriptionForTrack:(MP42AudioTrack *)track; - (AudioStreamBasicDescription)audioDescriptionForTrack:(MP42AudioTrack *)track;
+3 -3
View File
@@ -81,7 +81,7 @@ static NSArray<NSString *> *_supportedFileFormats;
return [[self supportedFileFormats] containsObject:fileType.lowercaseString]; return [[self supportedFileFormats] containsObject:fileType.lowercaseString];
} }
- (instancetype)initWithURL:(NSURL *)fileURL error:(NSError * __autoreleasing *)error; - (instancetype)initWithURL:(NSURL *)fileURL error:(NSError * __autoreleasing *)error
{ {
self = nil; self = nil;
@@ -230,7 +230,7 @@ static NSArray<NSString *> *_supportedFileFormats;
#pragma mark - Override #pragma mark - Override
- (NSUInteger)timescaleForTrack:(MP42Track *)track - (UInt32)timescaleForTrack:(MP42Track *)track
{ {
@throw [NSException exceptionWithName:NSInternalInconsistencyException @throw [NSException exceptionWithName:NSInternalInconsistencyException
reason:[NSString stringWithFormat:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)] reason:[NSString stringWithFormat:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)]
@@ -265,7 +265,7 @@ static NSArray<NSString *> *_supportedFileFormats;
userInfo:nil]; userInfo:nil];
} }
- (BOOL)audioTrackUsesExplicitEncoderDelay:(MP42Track *)track; - (BOOL)audioTrackUsesExplicitEncoderDelay:(MP42Track *)track
{ {
return NO; return NO;
} }
+12 -12
View File
@@ -13,7 +13,7 @@
#import <CoreAudio/CoreAudio.h> #import <CoreAudio/CoreAudio.h>
/* write the data to the target adress & then return a pointer which points after the written data */ /* 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) if(data_size > 0)
memcpy(target, data, data_size); 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 // 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; int i;
for(i=1; len>>(7*i); i++); for(i=1; len>>(7*i); i++);
return len + 1 + 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; *buffer++ = tag;
for(; i>0; i--) for(; i>0; i--)
*buffer++ = (size>>(7*i)) | 0x80; *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) 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; int versionLen = write_version ? 4 : 0;
*esdsLen = versionLen + descrLength(3 + descrLength(13 + decoderSpecificInfoLen) + descrLength(1)); *esdsLen = versionLen + descrLength(3 + descrLength(13 + decoderSpecificInfoLen) + descrLength(1));
@@ -458,9 +458,9 @@ typedef enum {
} DEC3ChanLoc; } DEC3ChanLoc;
const uint16_t ff_ac3_dec3_chap_map[16][2] = { 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_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_VHC , DEC3_CUSTOM_CHANNEL_MAP_VHC},
{AC3_CUSTOM_CHANNEL_MAP_VHL_VHR_PAIR , DEC3_CUSTOM_CHANNEL_MAP_VHL_VHR_PAIR}, {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}, {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_CS , DEC3_CUSTOM_CHANNEL_MAP_CS},
{AC3_CUSTOM_CHANNEL_MAP_LRS_RRS_PAIR , DEC3_CUSTOM_CHANNEL_MAP_LRS_RRS_PAIR}, {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_LC_RC_PAIR , DEC3_CUSTOM_CHANNEL_MAP_LC_RC_PAIR},
{AC3_CUSTOM_CHANNEL_MAP_RIGHT_SURROUND , NULL}, {AC3_CUSTOM_CHANNEL_MAP_RIGHT_SURROUND , 0},
{AC3_CUSTOM_CHANNEL_MAP_LEFT_SURROUND , NULL}, {AC3_CUSTOM_CHANNEL_MAP_LEFT_SURROUND , 0},
{AC3_CUSTOM_CHANNEL_MAP_RIGHT , NULL}, {AC3_CUSTOM_CHANNEL_MAP_RIGHT , 0},
{AC3_CUSTOM_CHANNEL_MAP_CENTRE , NULL}, {AC3_CUSTOM_CHANNEL_MAP_CENTRE , 0},
{AC3_CUSTOM_CHANNEL_MAP_LEFT , NULL}, {AC3_CUSTOM_CHANNEL_MAP_LEFT , 0},
}; };
uint16_t ac3_to_dec3_chan_map(uint16_t ac3_chan_loc) { uint16_t ac3_to_dec3_chan_map(uint16_t ac3_chan_loc) {
+2 -1
View File
@@ -1355,6 +1355,7 @@ NSData* H264Info(const char *filePath, uint32_t *pic_width, uint32_t *pic_height
uint32_t iy = 0; uint32_t iy = 0;
NSMutableData *pictData = [[NSMutableData alloc] init]; NSMutableData *pictData = [[NSMutableData alloc] init];
//WTF
uint16_t temp = buffersize << 8; uint16_t temp = buffersize << 8;
[pictData appendBytes:&temp length:sizeof(uint16_t)]; [pictData appendBytes:&temp length:sizeof(uint16_t)];
[pictData appendBytes:buffer length:buffersize]; [pictData appendBytes:buffer length:buffersize];
@@ -1422,7 +1423,7 @@ MP42_OBJC_DIRECT_MEMBERS
return self; return self;
} }
- (NSUInteger)timescaleForTrack:(MP42Track *)track - (UInt32)timescaleForTrack:(MP42Track *)track
{ {
framerate_t *framerate; framerate_t *framerate;
+3 -3
View File
@@ -857,7 +857,7 @@ MP42_OBJC_DIRECT_MEMBERS
return [self extendedTagForISO_639_2:@(lang->iso639_2)]; 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); iso639_lang_t *lang = lang_for_qtcode(code.integerValue);
if (strlen(lang->iso639_1)) { 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); iso639_lang_t *lang = lang_for_code_s(code.UTF8String);
if (strlen(lang->iso639_1)) { 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]; NSString *code = _ISO_639_2CodeToCode[code2];
if (!code) { if (!code) {
+26 -21
View File
@@ -50,7 +50,7 @@
return self; return self;
} }
- (nullable instancetype)initWithURL:(NSURL *)URL; - (nullable instancetype)initWithURL:(NSURL *)URL
{ {
self = [self init]; self = [self init];
if (self) { if (self) {
@@ -814,11 +814,14 @@
[self addMetadataItemWithStringArray:tag identifier:MP42MetadataKeyScreenwriters]; [self addMetadataItemWithStringArray:tag identifier:MP42MetadataKeyScreenwriters];
} }
if ([tag = dma[@"studio"] length]) { if ((tag = dma[@"studio"]) != nil && [tag isKindOfClass:[NSString class]]) {
NSString *studio = tag;
if (studio.length) {
[self addMetadataItemWithString:tag identifier:MP42MetadataKeyStudio]; [self addMetadataItemWithString:tag identifier:MP42MetadataKeyStudio];
} }
} }
} }
}
MP4ItmfItemListFree(list); MP4ItmfItemListFree(list);
} }
@@ -940,7 +943,7 @@
MP4TagsSetTVEpisodeID (tags, self.itemsMap[MP42MetadataKeyTVEpisodeID].stringValue.UTF8String); MP4TagsSetTVEpisodeID (tags, self.itemsMap[MP42MetadataKeyTVEpisodeID].stringValue.UTF8String);
if (self.itemsMap[MP42MetadataKeyTVSeason]) { 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); MP4TagsSetTVSeason(tags, &value);
} }
else { else {
@@ -948,7 +951,7 @@
} }
if (self.itemsMap[MP42MetadataKeyTVEpisodeNumber]) { 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); MP4TagsSetTVEpisode(tags, &i);
} }
else { else {
@@ -1025,7 +1028,7 @@
} }
if (self.itemsMap[MP42MetadataKeyAccountCountry]) { 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); MP4TagsSetITunesCountry(tags, &i);
} }
else { else {
@@ -1033,7 +1036,7 @@
} }
if (self.itemsMap[MP42MetadataKeyContentID]) { 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); MP4TagsSetContentID(tags, &i);
} }
else { else {
@@ -1041,7 +1044,7 @@
} }
if (self.itemsMap[MP42MetadataKeyGenreID]) { 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); MP4TagsSetGenreID(tags, &i);
} }
else { else {
@@ -1049,7 +1052,7 @@
} }
if (self.itemsMap[MP42MetadataKeyArtistID]) { 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); MP4TagsSetArtistID(tags, &i);
} }
else { else {
@@ -1065,7 +1068,7 @@
} }
if (self.itemsMap[MP42MetadataKeyComposerID]) { 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); MP4TagsSetComposerID(tags, &i);
} }
else { else {
@@ -1093,23 +1096,21 @@
artwork = (MP42Image *)artworks[i].value; artwork = (MP42Image *)artworks[i].value;
if (artwork.data) { if (artwork.data && artwork.data.length < UINT32_MAX) {
newArtwork.data = (void *)artwork.data.bytes; newArtwork.data = (void *)artwork.data.bytes;
newArtwork.size = artwork.data.length; newArtwork.size = (uint32_t)artwork.data.length;
newArtwork.type = (MP4TagArtworkType)artwork.type; newArtwork.type = (MP4TagArtworkType)artwork.type;
} }
else { else {
NSArray<NSImageRep *> *representations = artwork.image.representations; NSArray<NSImageRep *> *representations = artwork.image.representations;
if (representations.count) { if (representations.count) {
NSData *bitmapData = [NSBitmapImageRep representationOfImageRepsInArray:representations NSData *bitmapData = [NSBitmapImageRep representationOfImageRepsInArray:representations
usingType:NSBitmapImageFileTypePNG properties:@{}]; usingType:NSBitmapImageFileTypePNG properties:@{}];
if (bitmapData) { if (bitmapData && bitmapData.length < UINT32_MAX) {
newArtwork.data = (void *)bitmapData.bytes; newArtwork.data = (void *)bitmapData.bytes;
newArtwork.size = bitmapData.length; newArtwork.size = (uint32_t)bitmapData.length;
newArtwork.type = MP4_ART_PNG; newArtwork.type = MP4_ART_PNG;
} }
} }
@@ -1117,8 +1118,7 @@
if (tags->artworkCount > i) { if (tags->artworkCount > i) {
MP4TagsSetArtwork(tags, i, &newArtwork); MP4TagsSetArtwork(tags, i, &newArtwork);
} } else {
else {
MP4TagsAddArtwork(tags, &newArtwork); MP4TagsAddArtwork(tags, &newArtwork);
} }
} }
@@ -1154,12 +1154,15 @@
if (ratingString) { if (ratingString) {
data->typeCode = MP4_ITMF_BT_UTF8; data->typeCode = MP4_ITMF_BT_UTF8;
data->valueSize = strlen(ratingString.UTF8String); size_t len = strlen(ratingString.UTF8String);
if (len < UINT32_MAX) {
data->valueSize = (uint32_t)len;
data->value = (uint8_t *)malloc(data->valueSize); data->value = (uint8_t *)malloc(data->valueSize);
memcpy(data->value, ratingString.UTF8String, data->valueSize); memcpy(data->value, ratingString.UTF8String, data->valueSize);
MP4ItmfAddItem(fileHandle, newItem); MP4ItmfAddItem(fileHandle, newItem);
} }
}
MP4ItmfItemFree(newItem); MP4ItmfItemFree(newItem);
@@ -1257,9 +1260,11 @@
MP4ItmfData *data = &newItem->dataList.elements[0]; MP4ItmfData *data = &newItem->dataList.elements[0];
data->typeCode = MP4_ITMF_BT_UTF8; data->typeCode = MP4_ITMF_BT_UTF8;
data->valueSize = [serializedPlist length]; if (serializedPlist.length < UINT32_MAX) {
data->value = (uint8_t*)malloc( data->valueSize ); data->valueSize = (uint32_t)serializedPlist.length;
memcpy( data->value, [serializedPlist bytes], data->valueSize ); data->value = (uint8_t*)malloc(data->valueSize);
memcpy(data->value, serializedPlist.bytes, data->valueSize);
}
MP4ItmfAddItem(fileHandle, newItem); MP4ItmfAddItem(fileHandle, newItem);
MP4ItmfItemFree(newItem); MP4ItmfItemFree(newItem);
+2 -2
View File
@@ -269,7 +269,7 @@ static NSCalendar *_calendar;
[coder encodeObject:_identifier forKey:@"MP42Identifier"]; [coder encodeObject:_identifier forKey:@"MP42Identifier"];
[coder encodeObject:_value forKey:@"MP42Value"]; [coder encodeObject:_value forKey:@"MP42Value"];
[coder encodeInt:_dataType forKey:@"MP42DataType"]; [coder encodeInt64:_dataType forKey:@"MP42DataType"];
[coder encodeObject:_extendedLanguageTag forKey:@"MP42LanguageTag"]; [coder encodeObject:_extendedLanguageTag forKey:@"MP42LanguageTag"];
} }
@@ -279,7 +279,7 @@ static NSCalendar *_calendar;
_identifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"MP42Identifier"]; _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"]; _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"]; _extendedLanguageTag = [decoder decodeObjectOfClass:[NSString class] forKey:@"MP42LanguageTag"];
return self; return self;
+1 -1
View File
@@ -144,7 +144,7 @@ static const genreType_t genreType_strings[] = {
{126, "dancehall", "Dance Hall" }, {126, "dancehall", "Dance Hall" },
{255, "none", "none" }, {255, "none", "none" },
{0, "undefined" } // must be last {0, "undefined", NULL } // must be last
}; };
NSString * genreFromIndex(NSInteger index) NSString * genreFromIndex(NSInteger index)
+18 -18
View File
@@ -45,11 +45,11 @@ MP42_OBJC_DIRECT_MEMBERS
NSMutableArray<MatroskaSample *> *queue; NSMutableArray<MatroskaSample *> *queue;
uint64_t timescale; uint32_t timescale;
uint64_t currentTime; uint64_t currentTime;
uint64_t startTime; uint64_t startTime;
int64_t minDisplayOffset; int64_t minDisplayOffset;
unsigned int buffer, samplesWritten, bufferFlush; uint32_t buffer, samplesWritten, bufferFlush;
MP42SampleBuffer *previousSample; MP42SampleBuffer *previousSample;
} }
@@ -68,7 +68,7 @@ MP42_OBJC_DIRECT_MEMBERS
@end @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)) { if (fseeko(ioStream->fp, pos, SEEK_SET)) {
#ifdef DEBUG #ifdef DEBUG
@@ -218,10 +218,10 @@ MP42_OBJC_DIRECT_MEMBERS
return nil; return nil;
} }
NSInteger trackCount = mkv_GetNumTracks(_matroskaFile); MP42TrackId trackCount = mkv_GetNumTracks(_matroskaFile);
NSArray<NSNumber *> *trackSizes = [self approximatedTrackDataLength]; NSArray<NSNumber *> *trackSizes = [self approximatedTrackDataLength];
for (NSInteger i = 0; i < trackCount; i++) { for (MP42TrackId i = 0; i < trackCount; i++) {
TrackInfo *mkvTrack = mkv_GetTrackInfo(_matroskaFile, i); TrackInfo *mkvTrack = mkv_GetTrackInfo(_matroskaFile, i);
MP42Track *newTrack = nil; MP42Track *newTrack = nil;
@@ -248,7 +248,7 @@ MP42_OBJC_DIRECT_MEMBERS
videoTrack.vertOffD = 1; videoTrack.vertOffD = 1;
dar = (AVRational){mkvTrack->AV.Video.DisplayWidth, mkvTrack->AV.Video.DisplayHeight}; 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 { else {
dar = (AVRational){mkvTrack->AV.Video.DisplayWidth, mkvTrack->AV.Video.DisplayHeight}; 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<NSNumber *> *)approximatedTrackDataLength - (NSArray<NSNumber *> *)approximatedTrackDataLength
@@ -633,7 +633,7 @@ static NSString * TrackNameToString(TrackInfo *track)
return (((double)StartTime) - codecDelay) / SCALE_FACTOR; return (((double)StartTime) - codecDelay) / SCALE_FACTOR;
} }
static uint64_t timescale(TrackInfo *trackInfo) static uint32_t timescale(TrackInfo *trackInfo)
{ {
if (trackInfo->Type == TT_VIDEO) { if (trackInfo->Type == TT_VIDEO) {
return 100000; return 100000;
@@ -655,7 +655,7 @@ static uint64_t timescale(TrackInfo *trackInfo)
return 1000; return 1000;
} }
- (NSUInteger)timescaleForTrack:(MP42Track *)track - (UInt32)timescaleForTrack:(MP42Track *)track
{ {
TrackInfo *trackInfo = mkv_GetTrackInfo(_matroskaFile, track.sourceId); TrackInfo *trackInfo = mkv_GetTrackInfo(_matroskaFile, track.sourceId);
return timescale(trackInfo); return timescale(trackInfo);
@@ -788,7 +788,7 @@ static uint64_t timescale(TrackInfo *trackInfo)
return nil; return nil;
} }
- (UInt8)streamExtensionTypeForAudioTrack:(MP42AudioTrack *)track mkvTrack:(TrackInfo *)trackInfo - (MP42AudioEmbeddedExtension)streamExtensionTypeForAudioTrack:(MP42AudioTrack *)track mkvTrack:(TrackInfo *)trackInfo
{ {
struct eac3_info *context = NULL; struct eac3_info *context = NULL;
uint8_t mkvpktnum = 0; uint8_t mkvpktnum = 0;
@@ -876,7 +876,7 @@ static uint64_t timescale(TrackInfo *trackInfo)
return result; return result;
} }
- (BOOL)audioTrackUsesExplicitEncoderDelay:(MP42Track *)track; - (BOOL)audioTrackUsesExplicitEncoderDelay:(MP42Track *)track
{ {
TrackInfo *trackInfo = mkv_GetTrackInfo(_matroskaFile, track.sourceId); TrackInfo *trackInfo = mkv_GetTrackInfo(_matroskaFile, track.sourceId);
return trackInfo->CodecDelay != 0; return trackInfo->CodecDelay != 0;
@@ -891,7 +891,7 @@ static uint64_t timescale(TrackInfo *trackInfo)
NSArray<MP42Track *> *inputTracks = self.inputTracks; NSArray<MP42Track *> *inputTracks = self.inputTracks;
NSInteger tracksNumber = inputTracks.count; NSUInteger tracksNumber = inputTracks.count;
MatroskaDemuxHelper * helpers[self.tracks.count]; MatroskaDemuxHelper * helpers[self.tracks.count];
for (NSUInteger index = 0; index < tracksNumber; index += 1) { for (NSUInteger index = 0; index < tracksNumber; index += 1) {
@@ -1092,7 +1092,7 @@ static uint64_t timescale(TrackInfo *trackInfo)
} }
// offset calculation // offset calculation
int64_t offset = currentSample->startTime - demuxHelper->currentTime; int64_t offset = currentSample->startTime / 10000.0f - demuxHelper->currentTime / 10000.0f;
demuxHelper->currentTime += duration; demuxHelper->currentTime += duration;
@@ -1102,7 +1102,7 @@ static uint64_t timescale(TrackInfo *trackInfo)
sample->size = currentSample->frameSize; sample->size = currentSample->frameSize;
sample->timescale = demuxHelper->timescale; sample->timescale = demuxHelper->timescale;
sample->duration = duration / 10000.0f; sample->duration = duration / 10000.0f;
sample->offset = offset / 10000.0f; sample->offset = offset;
sample->decodeTimestamp = StartTime; sample->decodeTimestamp = StartTime;
sample->flags |= (currentSample->frameFlags & FRAME_KF) ? MP42SampleBufferFlagIsSync : 0; sample->flags |= (currentSample->frameFlags & FRAME_KF) ? MP42SampleBufferFlagIsSync : 0;
sample->trackId = demuxHelper->sourceID; sample->trackId = demuxHelper->sourceID;
@@ -1164,7 +1164,7 @@ static uint64_t timescale(TrackInfo *trackInfo)
} }
// offset calculation // offset calculation
int64_t offset = currentSample->startTime - demuxHelper->currentTime; int64_t offset = currentSample->startTime / 10000.0f - demuxHelper->currentTime / 10000.0f;
demuxHelper->currentTime += duration; demuxHelper->currentTime += duration;
@@ -1174,7 +1174,7 @@ static uint64_t timescale(TrackInfo *trackInfo)
sample->size = currentSample->frameSize; sample->size = currentSample->frameSize;
sample->timescale = demuxHelper->timescale; sample->timescale = demuxHelper->timescale;
sample->duration = duration / 10000.0f; sample->duration = duration / 10000.0f;
sample->offset = offset / 10000.0f; sample->offset = offset;
sample->decodeTimestamp = StartTime; sample->decodeTimestamp = StartTime;
sample->flags |= (currentSample->frameFlags & FRAME_KF) ? MP42SampleBufferFlagIsSync : 0; sample->flags |= (currentSample->frameFlags & FRAME_KF) ? MP42SampleBufferFlagIsSync : 0;
sample->trackId = demuxHelper->sourceID; sample->trackId = demuxHelper->sourceID;
@@ -1236,8 +1236,8 @@ static uint64_t timescale(TrackInfo *trackInfo)
if (demuxHelper->minDisplayOffset != 0) { if (demuxHelper->minDisplayOffset != 0) {
for (unsigned int i = 1; i <= demuxHelper->samplesWritten; i++) { for (uint32_t i = 1; i <= demuxHelper->samplesWritten; i++) {
int64_t correctedOffset = MP4GetSampleRenderingOffset(fileHandle, trackId, i) - demuxHelper->minDisplayOffset; int64_t correctedOffset = (int64_t)MP4GetSampleRenderingOffset(fileHandle, trackId, i) - demuxHelper->minDisplayOffset;
MP4SetSampleRenderingOffset(fileHandle, MP4SetSampleRenderingOffset(fileHandle,
trackId, trackId,
i, i,
+9 -9
View File
@@ -22,7 +22,7 @@ typedef struct MP4DemuxHelper {
MP4SampleId currentSampleId; MP4SampleId currentSampleId;
uint64_t totalSampleNumber; uint64_t totalSampleNumber;
MP4Timestamp currentTime; MP4Timestamp currentTime;
uint64_t timeScale; uint32_t timeScale;
uint32_t done; uint32_t done;
} MP4DemuxHelper; } MP4DemuxHelper;
@@ -36,7 +36,7 @@ typedef struct MP4DemuxHelper {
return @[@"mp4", @"m4v", @"m4a", @"m4r"]; 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])) { if ((self = [super initWithURL:fileURL])) {
MP42File *sourceFile = [[MP42File alloc] initWithURL:self.fileURL error:outError]; MP42File *sourceFile = [[MP42File alloc] initWithURL:self.fileURL error:outError];
@@ -52,7 +52,7 @@ typedef struct MP4DemuxHelper {
return self; return self;
} }
- (NSUInteger)timescaleForTrack:(MP42Track *)track - (UInt32)timescaleForTrack:(MP42Track *)track
{ {
return MP4GetTrackTimeScale(_fileHandle, track.sourceId); return MP4GetTrackTimeScale(_fileHandle, track.sourceId);
} }
@@ -279,14 +279,14 @@ typedef struct MP4DemuxHelper {
result.mSampleRate = (sample_rate >> 16) + (sample_rate & 0xffff) / 65536.0; result.mSampleRate = (sample_rate >> 16) + (sample_rate & 0xffff) / 65536.0;
result.mFormatID = kAudioFormatLinearPCM; result.mFormatID = kAudioFormatLinearPCM;
result.mFormatFlags += kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked | kAudioFormatFlagIsBigEndian; result.mFormatFlags += kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked | kAudioFormatFlagIsBigEndian;
result.mBitsPerChannel = bit_depth; result.mBitsPerChannel = (UInt32)bit_depth;
result.mChannelsPerFrame = channels_count; result.mChannelsPerFrame = (UInt32)channels_count;
} }
return result; return result;
} }
- (BOOL)audioTrackUsesExplicitEncoderDelay:(MP42Track *)track; - (BOOL)audioTrackUsesExplicitEncoderDelay:(MP42Track *)track
{ {
return MP4HaveTrackAtom(_fileHandle, track.sourceId, "mdia.minf.stbl.sgpd"); return MP4HaveTrackAtom(_fileHandle, track.sourceId, "mdia.minf.stbl.sgpd");
} }
@@ -300,8 +300,8 @@ typedef struct MP4DemuxHelper {
} }
NSArray<MP42Track *> *inputTracks = self.inputTracks; NSArray<MP42Track *> *inputTracks = self.inputTracks;
NSInteger tracksNumber = inputTracks.count; NSUInteger tracksNumber = inputTracks.count;
NSInteger tracksDone = 0; NSUInteger tracksDone = 0;
MP4DemuxHelper * helpers[tracksNumber]; MP4DemuxHelper * helpers[tracksNumber];
@@ -413,7 +413,7 @@ typedef struct MP4DemuxHelper {
MP4SetTrackIntegerProperty(dstFileHandle, dstTrackId, "tkhd.duration", trackDuration); MP4SetTrackIntegerProperty(dstFileHandle, dstTrackId, "tkhd.duration", trackDuration);
} }
else if (MP4GetSampleRenderingOffset(dstFileHandle, dstTrackId, 1)) { else if (MP4GetSampleRenderingOffset(dstFileHandle, dstTrackId, 1)) {
uint32_t firstFrameOffset = MP4GetSampleRenderingOffset(dstFileHandle, dstTrackId, 1); MP4Duration firstFrameOffset = MP4GetSampleRenderingOffset(dstFileHandle, dstTrackId, 1);
MP4Duration editDuration = MP4ConvertFromTrackDuration(_fileHandle, MP4Duration editDuration = MP4ConvertFromTrackDuration(_fileHandle,
srcTrackId, srcTrackId,
+15 -14
View File
@@ -91,7 +91,7 @@ MP42_OBJC_DIRECT_MEMBERS
FourCharCode format = track.format; FourCharCode format = track.format;
MP4TrackId dstTrackId = 0; MP4TrackId dstTrackId = 0;
NSData *magicCookie = nil; NSData *magicCookie = nil;
NSInteger timeScale = 0; uint32_t timeScale = 0;
if (importer) { if (importer) {
magicCookie = [importer magicCookieForTrack:track]; magicCookie = [importer magicCookieForTrack:track];
@@ -215,23 +215,23 @@ MP42_OBJC_DIRECT_MEMBERS
uint8_t *hvcCAtom = (uint8_t *)magicCookie.bytes; uint8_t *hvcCAtom = (uint8_t *)magicCookie.bytes;
if ([_options[MP42ForceHvc1] boolValue]) { if ([_options[MP42ForceHvc1] boolValue] && magicCookie.length < UINT32_MAX) {
force_HEVC_completeness(hvcCAtom, magicCookie.length); force_HEVC_completeness(hvcCAtom, (uint32_t)magicCookie.length);
} }
// Check whether we can use hvc1 or hev1 fourcc. // Check whether we can use hvc1 or hev1 fourcc.
bool completeness = 0; 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]; NSSize size = [importer sizeForTrack:(MP42VideoTrack *)track];
dstTrackId = MP4AddH265VideoTrack(_fileHandle, timeScale, MP4_INVALID_DURATION, size.width, size.height, completeness); dstTrackId = MP4AddH265VideoTrack(_fileHandle, timeScale, MP4_INVALID_DURATION, size.width, size.height, completeness);
if (dstTrackId) { if (dstTrackId) {
if (completeness) { 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 { 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]; [importer setActiveTrack:track];
} }
@@ -255,10 +255,10 @@ MP42_OBJC_DIRECT_MEMBERS
[(MP42VideoTrack*)track width], [(MP42VideoTrack*)track height], [(MP42VideoTrack*)track width], [(MP42VideoTrack*)track height],
MP4_MPEG4_VIDEO_TYPE); MP4_MPEG4_VIDEO_TYPE);
if (magicCookie.length) { if (magicCookie.length && magicCookie.length < UINT32_MAX) {
MP4SetTrackESConfiguration(_fileHandle, dstTrackId, MP4SetTrackESConfiguration(_fileHandle, dstTrackId,
magicCookie.bytes, magicCookie.bytes,
magicCookie.length); (uint32_t)magicCookie.length);
} }
[importer setActiveTrack:track]; [importer setActiveTrack:track];
@@ -281,10 +281,10 @@ MP42_OBJC_DIRECT_MEMBERS
timeScale, timeScale,
1024, MP4_MPEG4_AUDIO_TYPE); 1024, MP4_MPEG4_AUDIO_TYPE);
if (!track.conversionSettings && magicCookie.length) { if (!track.conversionSettings && magicCookie.length && magicCookie.length < UINT32_MAX) {
MP4SetTrackESConfiguration(_fileHandle, dstTrackId, MP4SetTrackESConfiguration(_fileHandle, dstTrackId,
magicCookie.bytes, magicCookie.bytes,
magicCookie.length); (uint32_t)magicCookie.length);
} }
MP4SetTrackWantsRoll(_fileHandle, dstTrackId, [importer audioTrackUsesExplicitEncoderDelay:track]); MP4SetTrackWantsRoll(_fileHandle, dstTrackId, [importer audioTrackUsesExplicitEncoderDelay:track]);
@@ -332,8 +332,9 @@ MP42_OBJC_DIRECT_MEMBERS
else if ([track isMemberOfClass:[MP42AudioTrack class]] && format == kMP42AudioCodecType_AppleLossless) { else if ([track isMemberOfClass:[MP42AudioTrack class]] && format == kMP42AudioCodecType_AppleLossless) {
dstTrackId = MP4AddALACAudioTrack(_fileHandle, dstTrackId = MP4AddALACAudioTrack(_fileHandle,
timeScale); timeScale);
if (magicCookie.length) { if (magicCookie.length && magicCookie.length < UINT32_MAX) {
MP4SetTrackBytesProperty(_fileHandle, dstTrackId, "mdia.minf.stbl.stsd.alac.alac.AppleLosslessMagicCookie", magicCookie.bytes, magicCookie.length); MP4SetTrackBytesProperty(_fileHandle, dstTrackId, "mdia.minf.stbl.stsd.alac.alac.AppleLosslessMagicCookie",
magicCookie.bytes, (uint32_t)magicCookie.length);
} }
[importer setActiveTrack:track]; [importer setActiveTrack:track];
@@ -609,11 +610,11 @@ MP42_OBJC_DIRECT_MEMBERS
if (track.converter && track.conversionSettings && [track isMemberOfClass:[MP42AudioTrack class]]) { if (track.converter && track.conversionSettings && [track isMemberOfClass:[MP42AudioTrack class]]) {
NSData *magicCookie = track.converter.magicCookie; NSData *magicCookie = track.converter.magicCookie;
if (magicCookie) { if (magicCookie && magicCookie.length < UINT32_MAX) {
if (track.conversionSettings.format == kAudioFormatMPEG4AAC) { if (track.conversionSettings.format == kAudioFormatMPEG4AAC) {
MP4SetTrackESConfiguration(_fileHandle, track.trackId, MP4SetTrackESConfiguration(_fileHandle, track.trackId,
magicCookie.bytes, magicCookie.bytes,
magicCookie.length); (uint32_t)magicCookie.length);
} }
else if (track.conversionSettings.format == kAudioFormatAC3) { else if (track.conversionSettings.format == kAudioFormatAC3) {
const uint64_t *ac3Info = (const uint64_t *)magicCookie.bytes; const uint64_t *ac3Info = (const uint64_t *)magicCookie.bytes;
+9 -5
View File
@@ -22,7 +22,7 @@ public:
if (base_path) { if (base_path) {
path = base_path.fileSystemRepresentation; path = base_path.fileSystemRepresentation;
} else { } 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); 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 * 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_pixel,
(int)bytes_per_line, (int)bytes_per_line,
0, 0, 0, 0,
(int)width, (int)height); (int)width, (int)height);*/
return text; return text;
} }
@@ -86,7 +90,7 @@ MP42_OBJC_DIRECT_MEMBERS
return NO; return NO;
} }
- (instancetype)initWithLanguage:(NSString *)language; - (instancetype)initWithLanguage:(NSString *)language
{ {
if ((self = [super init])) { if ((self = [super init])) {
NSString *lang = language; NSString *lang = language;
@@ -141,7 +145,7 @@ MP42_OBJC_DIRECT_MEMBERS
} }
} }
delete[]string; delete[] string;
return text; return text;
} }
+1 -1
View File
@@ -37,7 +37,7 @@
CGFloat offset; CGFloat offset;
MP42Duration assetDuration = CMTimeGetSeconds(asset.duration) * 1000; 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]; MP42TextSample *chapter = chapters[idx];
+14 -14
View File
@@ -11,13 +11,13 @@
#import <string.h> #import <string.h>
#import <CoreAudio/CoreAudio.h> #import <CoreAudio/CoreAudio.h>
#import <CoreMedia/CMTime.h> #import <CoreMedia/CMTime.h>
#include <zlib.h> #include <zlib.h>
#include <bzlib.h> #include <bzlib.h>
#import "MP42Languages.h" #import "MP42Languages.h"
#import "MP42MediaFormat.h" #import "MP42MediaFormat.h"
#include "intreadwrite.h"
#include "avcodec.h" #include "avcodec.h"
NSString * SRTStringFromTime( long long time, long timeScale , const char separator) NSString * SRTStringFromTime( long long time, long timeScale , const char separator)
@@ -57,7 +57,7 @@ int updateTracksCount(MP4FileHandle fileHandle)
{ {
MP4TrackId maxTrackId = 0; 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) if (MP4FindTrackId(fileHandle, i, 0, 0) > maxTrackId)
maxTrackId = MP4FindTrackId(fileHandle, i, 0, 0); maxTrackId = MP4FindTrackId(fileHandle, i, 0, 0);
@@ -69,7 +69,7 @@ void updateMoovDuration(MP4FileHandle fileHandle)
MP4TrackId trackId = 0; MP4TrackId trackId = 0;
MP4Duration maxTrackDuration = 0, trackDuration = 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); trackId = MP4FindTrackId(fileHandle, i, 0, 0);
MP4GetTrackIntegerProperty(fileHandle, trackId, "tkhd.duration", &trackDuration); MP4GetTrackIntegerProperty(fileHandle, trackId, "tkhd.duration", &trackDuration);
if (maxTrackDuration < trackDuration) { if (maxTrackDuration < trackDuration) {
@@ -81,8 +81,8 @@ void updateMoovDuration(MP4FileHandle fileHandle)
uint64_t getTrackSize(MP4FileHandle fileHandle, MP4TrackId trackId) uint64_t getTrackSize(MP4FileHandle fileHandle, MP4TrackId trackId)
{ {
uint64_t i, sampleNum, dataLength; MP4SampleId i = 1, sampleNum;
i = 1; uint64_t dataLength;
sampleNum = MP4GetTrackNumberOfSamples(fileHandle, trackId); sampleNum = MP4GetTrackNumberOfSamples(fileHandle, trackId);
dataLength = 0; dataLength = 0;
@@ -99,12 +99,12 @@ MP4TrackId findChapterTrackId(MP4FileHandle fileHandle)
MP4TrackId trackId = 0; MP4TrackId trackId = 0;
uint64_t trackRef; 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); trackId = MP4FindTrackId(fileHandle, i, 0, 0);
if (MP4HaveTrackAtom(fileHandle, trackId, "tref.chap")) { if (MP4HaveTrackAtom(fileHandle, trackId, "tref.chap")) {
MP4GetTrackIntegerProperty(fileHandle, trackId, "tref.chap.entries.trackId", &trackRef); MP4GetTrackIntegerProperty(fileHandle, trackId, "tref.chap.entries.trackId", &trackRef);
if (trackRef > 0) { if (trackRef > 0) {
return trackRef; return (MP4TrackId)trackRef;
} }
} }
} }
@@ -124,7 +124,7 @@ MP4TrackId findChapterPreviewTrackId(MP4FileHandle fileHandle)
MP4GetTrackIntegerProperty(fileHandle, trackId, "tref.chap.entryCount", &entryCount); MP4GetTrackIntegerProperty(fileHandle, trackId, "tref.chap.entryCount", &entryCount);
if (entryCount > 1 && MP4GetTrackIntegerProperty(fileHandle, trackId, "tref.chap.entries[1].trackId", &trackRef)) if (entryCount > 1 && MP4GetTrackIntegerProperty(fileHandle, trackId, "tref.chap.entries[1].trackId", &trackRef))
if (trackRef > 0) { if (trackRef > 0) {
return trackRef; return (MP4TrackId)trackRef;
} }
} }
} }
@@ -136,7 +136,7 @@ void removeAllChapterTrackReferences(MP4FileHandle fileHandle)
{ {
MP4TrackId trackId = 0; 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); trackId = MP4FindTrackId(fileHandle, i, 0, 0);
if (MP4HaveTrackAtom(fileHandle, trackId, "tref.chap")) { if (MP4HaveTrackAtom(fileHandle, trackId, "tref.chap")) {
MP4RemoveAllTrackReferences(fileHandle, "tref.chap", trackId); MP4RemoveAllTrackReferences(fileHandle, "tref.chap", trackId);
@@ -151,7 +151,7 @@ MP4TrackId findFirstVideoTrack(MP4FileHandle fileHandle)
if (!trackNumber) { if (!trackNumber) {
return 0; return 0;
} }
for (uint32_t i = 0; i < trackNumber; i++) { for (MP4TrackId i = 0; i < trackNumber; i++) {
videoTrack = MP4FindTrackId(fileHandle, i, 0, 0); videoTrack = MP4FindTrackId(fileHandle, i, 0, 0);
const char *trackType = MP4GetTrackType(fileHandle, videoTrack); const char *trackType = MP4GetTrackType(fileHandle, videoTrack);
if (trackType && !strcmp(trackType, MP4_VIDEO_TRACK_TYPE)) { if (trackType && !strcmp(trackType, MP4_VIDEO_TRACK_TYPE)) {
@@ -567,7 +567,7 @@ int copyTrackEditLists (MP4FileHandle fileHandle, MP4TrackId srcTrackId, MP4Trac
if (trackEditCount) if (trackEditCount)
MP4SetTrackIntegerProperty(fileHandle, dstTrackId, "tkhd.duration", trackDuration); MP4SetTrackIntegerProperty(fileHandle, dstTrackId, "tkhd.duration", trackDuration);
else { else {
uint32_t firstFrameOffset = MP4GetSampleRenderingOffset(fileHandle, dstTrackId, 1); MP4Duration firstFrameOffset = MP4GetSampleRenderingOffset(fileHandle, dstTrackId, 1);
MP4Duration editDuration = MP4ConvertFromTrackDuration(fileHandle, MP4Duration editDuration = MP4ConvertFromTrackDuration(fileHandle,
srcTrackId, srcTrackId,
MP4GetTrackDuration(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 *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); av_fast_malloc(&res, size, min_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (res) memset(res + min_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); if (res) memset(res + min_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
return res; return res;
@@ -668,14 +668,14 @@ int DecompressZlib(uint8_t **sampleData, uint32_t *sampleSize)
goto failed; goto failed;
} }
pkt_data = newpktdata; 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; zstream.next_out = pkt_data + zstream.total_out;
if (pkt_data) { if (pkt_data) {
result = inflate(&zstream, Z_NO_FLUSH); result = inflate(&zstream, Z_NO_FLUSH);
} else } else
result = Z_MEM_ERROR; result = Z_MEM_ERROR;
} while (result==Z_OK && pkt_size<10000000); } while (result==Z_OK && pkt_size<10000000);
pkt_size = zstream.total_out; pkt_size = (int)zstream.total_out;
inflateEnd(&zstream); inflateEnd(&zstream);
if (result != Z_STREAM_END) { if (result != Z_STREAM_END) {
if (result == Z_MEM_ERROR) if (result == Z_MEM_ERROR)
+1 -1
View File
@@ -84,7 +84,7 @@ MP42_OBJC_DIRECT_MEMBERS
return nil; return nil;
} }
- (NSUInteger)timescaleForTrack:(MP42Track *)track - (UInt32)timescaleForTrack:(MP42Track *)track
{ {
return 1000; return 1000;
} }
+2 -2
View File
@@ -348,9 +348,9 @@ static NSMutableString *STStandardizeStringNewlines(NSString *str)
return info; return info;
} }
- (NSDictionary<NSString *, MP42SSAStyle *> *)parseStyles:(NSString *)styles - (NSDictionary<NSString *, MP42SSAStyle *> *)parseStyles:(NSString *)stylesHeader
{ {
NSScanner *sc = [NSScanner scannerWithString:styles]; NSScanner *sc = [NSScanner scannerWithString:stylesHeader];
NSMutableArray<NSString *> *formatsArray = [NSMutableArray array]; NSMutableArray<NSString *> *formatsArray = [NSMutableArray array];
NSMutableDictionary<NSString *, MP42SSAStyle *> *stylesDict = [NSMutableDictionary dictionary]; NSMutableDictionary<NSString *, MP42SSAStyle *> *stylesDict = [NSMutableDictionary dictionary];
+3 -3
View File
@@ -32,9 +32,9 @@ MP42_OBJC_DIRECT_MEMBERS
@interface MP42SampleBuffer : NSObject { @interface MP42SampleBuffer : NSObject {
@public @public
void *data; void *data;
uint64_t size; uint32_t size;
uint64_t timescale; uint32_t timescale;
uint64_t duration; uint64_t duration;
int64_t offset; int64_t offset;
@@ -42,7 +42,7 @@ MP42_OBJC_DIRECT_MEMBERS
int64_t presentationOutputTimestamp; int64_t presentationOutputTimestamp;
uint64_t decodeTimestamp; uint64_t decodeTimestamp;
uint32_t trackId; MP42TrackId trackId;
MP42SampleBufferFlag flags; MP42SampleBufferFlag flags;
MP42SampleDepType dependecyFlags; MP42SampleDepType dependecyFlags;
+4 -4
View File
@@ -18,7 +18,7 @@ MP42_OBJC_DIRECT_MEMBERS
MP42_OBJC_DIRECT_MEMBERS MP42_OBJC_DIRECT_MEMBERS
@implementation MP42SecurityAccessToken @implementation MP42SecurityAccessToken
- (instancetype)initWithObject:(id<MP42SecurityScope>)object; - (instancetype)initWithObject:(id<MP42SecurityScope>)object
{ {
self = [super init]; self = [super init];
if (self) { 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); NSParameterAssert(bookmark);
@@ -49,7 +49,7 @@ MP42_OBJC_DIRECT_MEMBERS
return url; 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); NSParameterAssert(url);
@@ -58,7 +58,7 @@ MP42_OBJC_DIRECT_MEMBERS
return bookmark; 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]; return [MP42SecurityAccessToken bookmarkFromURL:url options:NSURLBookmarkCreationWithSecurityScope error:error];
} }
+1 -1
View File
@@ -93,7 +93,7 @@ MP42_OBJC_DIRECT_MEMBERS
return nil; return nil;
} }
- (NSUInteger)timescaleForTrack:(MP42Track *)track - (UInt32)timescaleForTrack:(MP42Track *)track
{ {
return 1000; return 1000;
} }
+5 -5
View File
@@ -18,13 +18,13 @@ MP42_OBJC_DIRECT_MEMBERS
{ {
@public @public
NSString *line; NSString *line;
unsigned begin_time, end_time; uint64_t begin_time, end_time;
unsigned no; // line number, used only by SBSubSerializer uint64_t no; // line number, used only by SBSubSerializer
unsigned top; unsigned top;
unsigned forced; unsigned forced;
} }
- (instancetype)initWithLine:(NSString *)l start:(unsigned)s end:(unsigned)e; - (instancetype)initWithLine:(NSString *)l start:(uint64_t)s end:(uint64_t)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 top_pos:(unsigned)p forced:(unsigned)f;
@end @end
MP42_OBJC_DIRECT_MEMBERS MP42_OBJC_DIRECT_MEMBERS
@@ -64,7 +64,7 @@ typedef struct {
UInt32 duration; UInt32 duration;
} PacketControlData; } 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); 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); Boolean ReadPacketTimes(uint8_t *packet, uint32_t length, uint16_t *startTime, uint16_t *endTime, uint8_t *forced);
+35 -15
View File
@@ -16,8 +16,8 @@ MP42_OBJC_DIRECT_MEMBERS
// input lines, sorted by 1. beginning time 2. original insertion order // input lines, sorted by 1. beginning time 2. original insertion order
NSMutableArray<MP42SubLine *> *lines; NSMutableArray<MP42SubLine *> *lines;
unsigned last_begin_time, last_end_time; uint64_t last_begin_time, last_end_time;
unsigned linesInput; uint64_t linesInput;
} }
-(instancetype)init -(instancetype)init
@@ -54,7 +54,7 @@ static CFComparisonResult CompareLinesByBeginTime(const void *a, const void *b,
line->no = linesInput++; line->no = linesInput++;
NSUInteger nlines = [lines count]; NSUInteger nlines = lines.count;
if (!nlines || line->begin_time > ((MP42SubLine*)[lines objectAtIndex:nlines-1])->begin_time) { if (!nlines || line->begin_time > ((MP42SubLine*)[lines objectAtIndex:nlines-1])->begin_time) {
[lines addObject:line]; [lines addObject:line];
@@ -74,11 +74,11 @@ static CFComparisonResult CompareLinesByBeginTime(const void *a, const void *b,
NSUInteger nlines = [lines count]; NSUInteger nlines = [lines count];
MP42SubLine *first = [lines objectAtIndex:0]; MP42SubLine *first = [lines objectAtIndex:0];
NSMutableString *str; NSMutableString *str;
int i; NSUInteger i;
if (!_finished) { if (!_finished) {
if (nlines > 1) { if (nlines > 1) {
unsigned maxEndTime = first->end_time; uint64_t maxEndTime = first->end_time;
for (i = 1; i < nlines; i++) { for (i = 1; i < nlines; i++) {
MP42SubLine *l = [lines objectAtIndex:i]; MP42SubLine *l = [lines objectAtIndex:i];
@@ -96,7 +96,7 @@ static CFComparisonResult CompareLinesByBeginTime(const void *a, const void *b,
canOutput: canOutput:
str = [NSMutableString stringWithString:first->line]; 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; unsigned frcd = first->forced, top_pos = first->top;
int deleted = 0; int deleted = 0;
@@ -169,7 +169,7 @@ canOutput:
MP42_OBJC_DIRECT_MEMBERS MP42_OBJC_DIRECT_MEMBERS
@implementation MP42SubLine @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 ((self = [super init])) {
if ([l characterAtIndex:[l length]-1] != '\n') l = [l stringByAppendingString:@"\n"]; if ([l characterAtIndex:[l length]-1] != '\n') l = [l stringByAppendingString:@"\n"];
@@ -182,7 +182,7 @@ MP42_OBJC_DIRECT_MEMBERS
return self; 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])) { if ((self = [self initWithLine:l start:s end:e])) {
top = p; top = p;
@@ -194,7 +194,7 @@ MP42_OBJC_DIRECT_MEMBERS
-(NSString *)description -(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 @end
@@ -882,6 +882,14 @@ MP42SampleBuffer * copySubtitleSample(MP4TrackId subtitleTrackId, NSString *stri
stringLength = strlen(string.UTF8String); stringLength = strlen(string.UTF8String);
sampleSize = 2 + (stringLength * sizeof(char)) + styleSize + (forced == 1 ? 8 : 0) + (verticalPlacement == 1 ? 16 : 0); 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); sampleData = malloc(sampleSize);
pos = 2; pos = 2;
@@ -924,7 +932,7 @@ MP42SampleBuffer * copySubtitleSample(MP4TrackId subtitleTrackId, NSString *stri
MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init]; MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init];
sample->data = sampleData; sample->data = sampleData;
sample->size = sampleSize; sample->size = (uint32_t)sampleSize;
sample->duration = duration; sample->duration = duration;
sample->offset = 0; sample->offset = 0;
sample->decodeTimestamp = duration; sample->decodeTimestamp = duration;
@@ -934,14 +942,25 @@ MP42SampleBuffer * copySubtitleSample(MP4TrackId subtitleTrackId, NSString *stri
return sample; return sample;
} }
MP42SampleBuffer* copyEmptySubtitleSample(MP4TrackId subtitleTrackId, MP4Duration duration, BOOL forced) MP42SampleBuffer * copyEmptySubtitleSample(MP4TrackId subtitleTrackId, MP4Duration duration, BOOL forced)
{ {
uint8_t *sampleData = NULL; uint8_t *sampleData = NULL;
size_t sampleSize = 0;
u_int8_t empty[2] = {0,0}; u_int8_t empty[2] = {0,0};
sampleData = malloc(2); sampleSize = 2 + (forced == 1 ? 8 : 0);
sampleData = malloc(sampleSize);
memcpy(sampleData, empty, 2); 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]; MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init];
sample->data = sampleData; sample->data = sampleData;
sample->size = 2; sample->size = 2;
@@ -955,7 +974,7 @@ MP42SampleBuffer* copyEmptySubtitleSample(MP4TrackId subtitleTrackId, MP4Duratio
} }
/* VobSub related */ /* 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; int copiedBytes = 0;
UInt8 *currentPacket = framedSrc; UInt8 *currentPacket = framedSrc;
int packetSize = INT_MAX; int packetSize = INT_MAX;
@@ -1023,7 +1042,7 @@ int ExtractVobSubPacket(UInt8 *dest, UInt8 *framedSrc, int srcSize, int *usedSrc
} // switch (currentPacket[3]) } // switch (currentPacket[3])
} // while (currentPacket - framedSrc < srcSize) } // while (currentPacket - framedSrc < srcSize)
if (usedSrcBytes != NULL) { if (usedSrcBytes != NULL) {
*usedSrcBytes = currentPacket - framedSrc; *usedSrcBytes = (int)(currentPacket - framedSrc);
} }
return copiedBytes; 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]; int controlOffset = (packet[2] << 8) + packet[3];
while(loop) while(loop)
{ {
if(controlOffset > length) if (controlOffset > length) {
return NO; return NO;
}
uint8_t *controlSeq = packet + controlOffset; uint8_t *controlSeq = packet + controlOffset;
int32_t i = 4; int32_t i = 4;
int32_t end = length - controlOffset; int32_t end = length - controlOffset;
+7 -6
View File
@@ -17,7 +17,7 @@
MP42_OBJC_DIRECT_MEMBERS MP42_OBJC_DIRECT_MEMBERS
@implementation MP42SubtitleTrack @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]; self = [super initWithSourceURL:URL trackID:trackID fileHandle:fileHandle];
@@ -52,7 +52,7 @@ MP42_OBJC_DIRECT_MEMBERS
if (MP4HaveTrackAtom(fileHandle, self.trackId, "tref.forc")) { if (MP4HaveTrackAtom(fileHandle, self.trackId, "tref.forc")) {
uint64_t forcedId = 0; uint64_t forcedId = 0;
MP4GetTrackIntegerProperty(fileHandle, self.trackId, "tref.forc.entries.trackId", &forcedId); 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.updatedProperty[@"forced"] || !self.muxed) {
if (self.forcedTrack) { MP42Track *forcedTrack = self.forcedTrack;
_forcedTrackId = self.forcedTrack.trackId; if (forcedTrack) {
_forcedTrackId = forcedTrack.trackId;
} }
if (MP4HaveTrackAtom(fileHandle, self.trackId, "tref.forc") && (_forcedTrackId == 0)) { if (MP4HaveTrackAtom(fileHandle, self.trackId, "tref.forc") && (_forcedTrackId == 0)) {
@@ -424,7 +425,7 @@ fail:
[coder encodeBool:_someSamplesAreForced forKey:@"someSamplesAreForced"]; [coder encodeBool:_someSamplesAreForced forKey:@"someSamplesAreForced"];
[coder encodeBool:_allSamplesAreForced forKey:@"allSamplesAreForced"]; [coder encodeBool:_allSamplesAreForced forKey:@"allSamplesAreForced"];
[coder encodeInt64:_forcedTrackId forKey:@"forcedTrackId"]; [coder encodeInt32:_forcedTrackId forKey:@"forcedTrackId"];
} }
- (id)initWithCoder:(NSCoder *)decoder - (id)initWithCoder:(NSCoder *)decoder
@@ -436,7 +437,7 @@ fail:
_someSamplesAreForced = [decoder decodeBoolForKey:@"someSamplesAreForced"]; _someSamplesAreForced = [decoder decodeBoolForKey:@"someSamplesAreForced"];
_allSamplesAreForced = [decoder decodeBoolForKey:@"allSamplesAreForced"]; _allSamplesAreForced = [decoder decodeBoolForKey:@"allSamplesAreForced"];
_forcedTrackId = [decoder decodeInt64ForKey:@"forcedTrackId"]; _forcedTrackId = [decoder decodeInt32ForKey:@"forcedTrackId"];
} }
return self; return self;
+2 -1
View File
@@ -126,7 +126,8 @@ MP42_OBJC_DIRECT_MEMBERS
{ {
if (_finished) { if (_finished) {
if (!_ss.isEmpty) { if (!_ss.isEmpty) {
CGSize trackSize = CGSizeMake(_track.trackWidth, _track.trackHeight); MP42SubtitleTrack *track = _track;
CGSize trackSize = CGSizeMake(track.trackWidth, track.trackHeight);
MP42SubLine *sl = [_ss getSerializedPacket]; MP42SubLine *sl = [_ss getSerializedPacket];
MP42SampleBuffer *sample; MP42SampleBuffer *sample;
+1 -1
View File
@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface MP42Track (Private) @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; - (BOOL)writeToFile:(MP42FileHandle)fileHandle error:(NSError * __autoreleasing *)outError;
@property(nonatomic, readwrite) MP42TrackId trackId; @property(nonatomic, readwrite) MP42TrackId trackId;
+5 -5
View File
@@ -63,7 +63,7 @@ typedef struct muxer_helper {
return self; 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])) { if ((self = [super init])) {
_URL = URL; _URL = URL;
@@ -381,8 +381,8 @@ typedef struct muxer_helper {
[coder encodeObject:_URL forKey:@"sourceURL"]; [coder encodeObject:_URL forKey:@"sourceURL"];
#endif #endif
[coder encodeInteger:_format forKey:@"format"]; [coder encodeInt32:_format forKey:@"format"];
[coder encodeInteger:_mediaType forKey:@"mediaType"]; [coder encodeInt32:_mediaType forKey:@"mediaType"];
[coder encodeObject:_name forKey:@"name"]; [coder encodeObject:_name forKey:@"name"];
[coder encodeObject:_language forKey:@"language"]; [coder encodeObject:_language forKey:@"language"];
@@ -435,8 +435,8 @@ typedef struct muxer_helper {
_URL = [decoder decodeObjectOfClass:[NSURL class] forKey:@"sourceURL"]; _URL = [decoder decodeObjectOfClass:[NSURL class] forKey:@"sourceURL"];
} }
_format = [decoder decodeIntegerForKey:@"format"]; _format = [decoder decodeInt32ForKey:@"format"];
_mediaType = [decoder decodeIntegerForKey:@"mediaType"]; _mediaType = [decoder decodeInt32ForKey:@"mediaType"];
_name = [decoder decodeObjectOfClass:[NSString class] forKey:@"name"]; _name = [decoder decodeObjectOfClass:[NSString class] forKey:@"name"];
_language = [decoder decodeObjectOfClass:[NSString class] forKey:@"language"]; _language = [decoder decodeObjectOfClass:[NSString class] forKey:@"language"];
+2 -2
View File
@@ -21,8 +21,8 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
NSString * StringFromTime(long long time, long timeScale); NSString * StringFromTime(long long time, int32_t timeScale);
MP42Duration TimeFromString(NSString *SMPTE_string, MP42Duration timeScale); MP42Duration TimeFromString(NSString *SMPTE_string, int32_t timeScale);
BOOL isTrackMuxable(FourCharCode formatName); BOOL isTrackMuxable(FourCharCode formatName);
BOOL trackNeedConversion(FourCharCode formatName); BOOL trackNeedConversion(FourCharCode formatName);
+5 -5
View File
@@ -10,11 +10,11 @@
#import "MP42SubUtilities.h" #import "MP42SubUtilities.h"
#import <AudioToolbox/AudioToolbox.h> #import <AudioToolbox/AudioToolbox.h>
NSString * StringFromTime(long long time, long timeScale) NSString * StringFromTime(long long time, int32_t timeScale)
{ {
NSString *time_string; NSString *time_string;
int hour, minute, second, frame; int minute, second, frame;
long long result; long long result, hour;
result = time / timeScale; // second result = time / timeScale; // second
frame = time % timeScale; frame = time % timeScale;
@@ -27,12 +27,12 @@ NSString * StringFromTime(long long time, long timeScale)
result = result / 60; // hour result = result / 60; // hour
hour = result; 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; 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); return ParseSubTime(time_string.UTF8String, timeScale, NO);
} }
+15 -13
View File
@@ -15,7 +15,7 @@
MP42_OBJC_DIRECT_MEMBERS MP42_OBJC_DIRECT_MEMBERS
@implementation MP42VideoTrack @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]; 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.transferFunctionIndex", &transferCharacteristics);
MP4GetTrackIntegerProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.*.colr.matrixIndex", &matrixCoefficients); MP4GetTrackIntegerProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.*.colr.matrixIndex", &matrixCoefficients);
_colorPrimaries = colorPrimaries; _colorPrimaries = (uint16_t)colorPrimaries;
_transferCharacteristics = transferCharacteristics; _transferCharacteristics = (uint16_t)transferCharacteristics;
_matrixCoefficients = matrixCoefficients; _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); MP4SetTrackIntegerProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.*.clap.vertOffD", _vertOffD);
} }
else else
MP4AddCleanAperture(fileHandle, self.trackId, _cleanApertureWidthN, _cleanApertureWidthD, _cleanApertureHeightN, _cleanApertureHeightD, MP4AddCleanAperture(fileHandle, self.trackId,
_horizOffN, _horizOffD, _vertOffN, _vertOffD); (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) { if (self.format == kMP42VideoCodecType_H264) {
@@ -388,9 +390,9 @@ static uint32_t convertToFixedPoint(CGFloat value) {
_trackWidth = [decoder decodeFloatForKey:@"trackWidth"]; _trackWidth = [decoder decodeFloatForKey:@"trackWidth"];
_trackHeight = [decoder decodeFloatForKey:@"trackHeight"]; _trackHeight = [decoder decodeFloatForKey:@"trackHeight"];
_colorPrimaries = [decoder decodeInt32ForKey:@"colorPrimaries"]; _colorPrimaries = (uint16_t)[decoder decodeInt32ForKey:@"colorPrimaries"];
_transferCharacteristics = [decoder decodeInt32ForKey:@"transferCharacteristics"]; _transferCharacteristics = (uint16_t)[decoder decodeInt32ForKey:@"transferCharacteristics"];
_matrixCoefficients = [decoder decodeInt32ForKey:@"matrixCoefficients"]; _matrixCoefficients = (uint16_t)[decoder decodeInt32ForKey:@"matrixCoefficients"];
_hSpacing = [decoder decodeInt64ForKey:@"hSpacing"]; _hSpacing = [decoder decodeInt64ForKey:@"hSpacing"];
_vSpacing = [decoder decodeInt64ForKey:@"vSpacing"]; _vSpacing = [decoder decodeInt64ForKey:@"vSpacing"];
@@ -402,11 +404,11 @@ static uint32_t convertToFixedPoint(CGFloat value) {
_transform.tx = [decoder decodeDoubleForKey:@"offsetX"]; _transform.tx = [decoder decodeDoubleForKey:@"offsetX"];
_transform.ty = [decoder decodeDoubleForKey:@"offsetY"]; _transform.ty = [decoder decodeDoubleForKey:@"offsetY"];
_origProfile = [decoder decodeIntForKey:@"origProfile"]; _origProfile = (uint8_t)[decoder decodeIntForKey:@"origProfile"];
_origLevel = [decoder decodeIntForKey:@"origLevel"]; _origLevel = (uint8_t)[decoder decodeIntForKey:@"origLevel"];
_newProfile = [decoder decodeIntForKey:@"newProfile"]; _newProfile = (uint8_t)[decoder decodeIntForKey:@"newProfile"];
_newLevel = [decoder decodeIntForKey:@"newLevel"]; _newLevel = (uint8_t)[decoder decodeIntForKey:@"newLevel"];
} }
return self; return self;
+23 -20
View File
@@ -37,7 +37,7 @@ MP42_OBJC_DIRECT_MEMBERS
NSString *language; NSString *language;
int index; int index;
long duration; long duration;
NSMutableArray *samples; NSMutableArray<SBVobSubSample *> *samples;
} }
- (id)initWithPrivateData:(NSArray *)idxPrivateData language:(NSString *)lang andIndex:(int)trackIndex; - (id)initWithPrivateData:(NSArray *)idxPrivateData language:(NSString *)lang andIndex:(int)trackIndex;
@@ -197,8 +197,9 @@ static NSArray<SBVobSubTrack *> * LoadVobSubSubtitles(NSURL *theDirectory, NSStr
sscanf(line.UTF8String, "timestamp: %s filepos: %x", timeStr, &position); sscanf(line.UTF8String, "timestamp: %s filepos: %x", timeStr, &position);
long time = ParseSubTime(timeStr, 1000, YES); long time = ParseSubTime(timeStr, 1000, YES);
free(timeStr); free(timeStr);
if(position > subFileSize) if (position > subFileSize) {
position = subFileSize; position = subFileSize;
}
[currentTrack addSampleTime:time + delay offset:position]; [currentTrack addSampleTime:time + delay offset:position];
} }
break; break;
@@ -227,7 +228,7 @@ MP42_OBJC_DIRECT_MEMBERS
{ {
if ((self = [super initWithURL:fileURL])) { if ((self = [super initWithURL:fileURL])) {
NSInteger count = 0; MP42TrackId count = 0;
_VobSubTracks = LoadVobSubSubtitles(self.fileURL.URLByDeletingLastPathComponent, self.fileURL.lastPathComponent); _VobSubTracks = LoadVobSubSubtitles(self.fileURL.URLByDeletingLastPathComponent, self.fileURL.lastPathComponent);
for (SBVobSubTrack *track in _VobSubTracks) { for (SBVobSubTrack *track in _VobSubTracks) {
@@ -255,7 +256,7 @@ MP42_OBJC_DIRECT_MEMBERS
return self; return self;
} }
- (NSUInteger)timescaleForTrack:(MP42Track *)track - (UInt32)timescaleForTrack:(MP42Track *)track
{ {
return 1000; return 1000;
} }
@@ -304,26 +305,28 @@ MP42_OBJC_DIRECT_MEMBERS
SBVobSubTrack *vobTrack = [_VobSubTracks objectAtIndex:track.sourceId]; SBVobSubTrack *vobTrack = [_VobSubTracks objectAtIndex:track.sourceId];
SBVobSubSample *firstSample = nil; SBVobSubSample *firstSample = nil;
uint32_t lastTime = 0; uint64_t lastTime = 0;
int sampleCount = vobTrack->samples.count; 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]; SBVobSubSample *currentSample = [vobTrack->samples objectAtIndex:i];
int offset = currentSample->fileOffset; long offset = currentSample->fileOffset;
int nextOffset; long nextOffset;
if (i == sampleCount - 1) if (i == sampleCount - 1) {
nextOffset = [subFileData length]; nextOffset = subFileData.length;
else } else {
nextOffset = ((SBVobSubSample *)[vobTrack->samples objectAtIndex:i+1])->fileOffset; nextOffset = [vobTrack->samples objectAtIndex:i+1]->fileOffset;
int size = nextOffset - offset; }
if (size < 0) int size = (int)(nextOffset - offset);
if (size < 0) {
//Skip samples for which we cannot determine size //Skip samples for which we cannot determine size
continue; continue;
}
NSData *subData = [subFileData subdataWithRange:NSMakeRange(offset, size)]; NSData *subData = [subFileData subdataWithRange:NSMakeRange(offset, size)];
uint8_t *extracted = (uint8_t *)malloc(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. //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; uint16_t startTimestamp, endTimestamp;
uint8_t forced; uint8_t forced;
@@ -332,13 +335,13 @@ MP42_OBJC_DIRECT_MEMBERS
continue; continue;
} }
uint32_t startTime = currentSample->timeStamp + startTimestamp; uint64_t startTime = currentSample->timeStamp + startTimestamp;
uint32_t endTime = currentSample->timeStamp + endTimestamp; uint64_t endTime = currentSample->timeStamp + endTimestamp;
int duration = endTimestamp - startTimestamp; uint64_t duration = endTimestamp - startTimestamp;
if (duration <= 0 && i < sampleCount - 1) { if (duration <= 0 && i < sampleCount - 1) {
//Sample with no end duration, use the duration of the next one //Sample with no end duration, use the duration of the next one
endTime = ((SBVobSubSample *)[vobTrack->samples objectAtIndex:i+1])->timeStamp; endTime = [vobTrack->samples objectAtIndex:i+1]->timeStamp;
duration = endTime - startTime; duration = endTime - startTime;
} }
if (duration <= 0) { if (duration <= 0) {
+1 -1
View File
@@ -39,7 +39,7 @@ int StdIoRead(StdIoStream *st, uint64_t pos, void *buffer, int count) {
st->error = errno; st->error = errno;
return -1; return -1;
} }
return rd; return (int)rd;
} }
/* scan for a signature sig(big-endian) starting at file position pos /* scan for a signature sig(big-endian) starting at file position pos
+1 -1
View File
@@ -254,7 +254,7 @@ int hb_audio_resample(hb_audio_resample_t *resample,
av_samples_get_buffer_size(&in_linesize, av_samples_get_buffer_size(&in_linesize,
resample->resample.channels, nsamples, resample->resample.channels, nsamples,
resample->resample.sample_fmt, 0); 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); nsamples, resample->out.sample_rate, resample->in.sample_rate, AV_ROUND_UP);
out_size = av_samples_get_buffer_size(&out_linesize, out_size = av_samples_get_buffer_size(&out_linesize,
+37 -3
View File
@@ -880,7 +880,7 @@
A9B9C1E4182391DF00416A4E /* Project object */ = { A9B9C1E4182391DF00416A4E /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 1200; LastUpgradeCheck = 1220;
ORGANIZATIONNAME = "Damiano Galassi"; ORGANIZATIONNAME = "Damiano Galassi";
TargetAttributes = { TargetAttributes = {
A910B5A218394E900064028F = { A910B5A218394E900064028F = {
@@ -1166,6 +1166,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
@@ -1174,28 +1175,36 @@
CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "compiler-default"; CLANG_CXX_LIBRARY = "compiler-default";
CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_ARC = YES;
CLANG_UNDEFINED_BEHAVIOR_SANITIZER_INTEGER = YES;
CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES; CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES;
CLANG_WARN_ASSIGN_ENUM = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES; CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_CXX0X_EXTENSIONS = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_FRAMEWORK_INCLUDE_PRIVATE_FROM_PUBLIC = YES;
CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_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_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES; ENABLE_TESTABILITY = YES;
@@ -1204,13 +1213,21 @@
GCC_OPTIMIZATION_LEVEL = 0; GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1"; GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; 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_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = 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_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES;
GCC_WARN_UNUSED_FUNCTION = NO; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
@@ -1233,6 +1250,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
@@ -1241,28 +1259,36 @@
CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "compiler-default"; CLANG_CXX_LIBRARY = "compiler-default";
CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_ARC = YES;
CLANG_UNDEFINED_BEHAVIOR_SANITIZER_INTEGER = YES;
CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES; CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES;
CLANG_WARN_ASSIGN_ENUM = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES; CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_CXX0X_EXTENSIONS = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_FRAMEWORK_INCLUDE_PRIVATE_FROM_PUBLIC = YES;
CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_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_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES;
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO; ENABLE_NS_ASSERTIONS = NO;
@@ -1271,13 +1297,21 @@
GCC_NO_COMMON_BLOCKS = YES; GCC_NO_COMMON_BLOCKS = YES;
GCC_PREPROCESSOR_DEFINITIONS = ""; GCC_PREPROCESSOR_DEFINITIONS = "";
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; 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_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = 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_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES;
GCC_WARN_UNUSED_FUNCTION = NO; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "1200" LastUpgradeVersion = "1220"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "1200" LastUpgradeVersion = "1220"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"