Move some files to ARC.
This commit is contained in:
15 files changed
+112
-263
No files matched your search
@@ -750,7 +750,6 @@ static bool GetFirstHeader(FILE* inFile)
|
||||
*outError = MP42Error(MP42LocalizedString(@"The audio could not be opened.", @"error message"),
|
||||
MP42LocalizedString(@"Data in file doesn't appear to be valid audio.", @"error message"), 100);
|
||||
}
|
||||
[newTrack release];
|
||||
return nil;
|
||||
}
|
||||
|
||||
@@ -763,7 +762,6 @@ static bool GetFirstHeader(FILE* inFile)
|
||||
*outError = MP42Error(MP42LocalizedString(@"The audio could not be opened.", @"error message"),
|
||||
MP42LocalizedString(@"Can't convert profile to mpeg2", @"error message"), 100);
|
||||
}
|
||||
[newTrack release];
|
||||
return nil;
|
||||
}
|
||||
mpegVersion = 1;
|
||||
@@ -793,7 +791,6 @@ static bool GetFirstHeader(FILE* inFile)
|
||||
*outError = MP42Error(MP42LocalizedString(@"The audio could not be opened.", @"error message"),
|
||||
MP42LocalizedString(@"Data in file doesn't appear to be valid audio.", @"error message"), 100);
|
||||
}
|
||||
[newTrack release];
|
||||
return nil;
|
||||
default:
|
||||
break;
|
||||
@@ -821,7 +818,6 @@ static bool GetFirstHeader(FILE* inFile)
|
||||
free(pConfig);
|
||||
|
||||
[self addTrack:newTrack];
|
||||
[newTrack release];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -872,7 +868,6 @@ static bool GetFirstHeader(FILE* inFile)
|
||||
sample->trackId = trackId;
|
||||
|
||||
[self enqueue:sample];
|
||||
[sample release];
|
||||
|
||||
sampleId++;
|
||||
sampleSize = sizeof(sampleBuffer);
|
||||
@@ -892,10 +887,7 @@ static bool GetFirstHeader(FILE* inFile)
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[aacInfo release];
|
||||
fclose(inFile);
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -332,7 +332,6 @@ static bool GetFirstHeader(FILE* inFile)
|
||||
[newTrack setDataLength:[[[[NSFileManager defaultManager] attributesOfItemAtPath:self.fileURL.path error:nil] valueForKey:NSFileSize] unsignedLongLongValue]];
|
||||
|
||||
[self addTrack:newTrack];
|
||||
[newTrack release];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -382,7 +381,6 @@ static bool GetFirstHeader(FILE* inFile)
|
||||
sample->trackId = trackId;
|
||||
|
||||
[self enqueue:sample];
|
||||
[sample release];
|
||||
|
||||
sampleId++;
|
||||
|
||||
@@ -403,10 +401,7 @@ static bool GetFirstHeader(FILE* inFile)
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[ac3Info release];
|
||||
fclose(inFile);
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
||||
+33
-50
@@ -16,7 +16,6 @@
|
||||
#import "mp4v2.h"
|
||||
#import "MP42PrivateUtilities.h"
|
||||
#import "MP42FormatUtilites.h"
|
||||
#import "MP42Track+Muxer.h"
|
||||
#import "MP42Track+Private.h"
|
||||
|
||||
#import "MP42EditListsReconstructor.h"
|
||||
@@ -29,6 +28,7 @@
|
||||
MP42TrackId sourceID;
|
||||
CMTimeScale timescale;
|
||||
CMTimeValue currentTime;
|
||||
MP42CodecType format;
|
||||
|
||||
uint32_t done;
|
||||
|
||||
@@ -39,12 +39,6 @@
|
||||
@end
|
||||
|
||||
@implementation AVFDemuxHelper
|
||||
|
||||
- (void)dealloc {
|
||||
[editsConstructor release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MP42AVFImporter {
|
||||
@@ -62,7 +56,7 @@
|
||||
|
||||
- (FourCharCode)formatForTrack:(AVAssetTrack *)track {
|
||||
FourCharCode result = 0;
|
||||
CMFormatDescriptionRef formatDescription = (CMFormatDescriptionRef)track.formatDescriptions.firstObject;
|
||||
CMFormatDescriptionRef formatDescription = (__bridge CMFormatDescriptionRef)track.formatDescriptions.firstObject;
|
||||
|
||||
if (formatDescription) {
|
||||
FourCharCode code = CMFormatDescriptionGetMediaSubType(formatDescription);
|
||||
@@ -89,7 +83,7 @@
|
||||
|
||||
- (instancetype)initWithURL:(NSURL *)fileURL error:(NSError **)outError {
|
||||
if ((self = [super initWithURL:fileURL])) {
|
||||
_localAsset = [[AVAsset assetWithURL:self.fileURL] retain];
|
||||
_localAsset = [AVAsset assetWithURL:self.fileURL];
|
||||
|
||||
NSArray<AVAssetTrack *> *tracks = [_localAsset tracks];
|
||||
CMTime globaDuration = _localAsset.duration;
|
||||
@@ -118,7 +112,7 @@
|
||||
|
||||
// Retrieves the formatDescription
|
||||
NSArray *formatDescriptions = track.formatDescriptions;
|
||||
CMFormatDescriptionRef formatDescription = (CMFormatDescriptionRef)formatDescriptions.firstObject;
|
||||
CMFormatDescriptionRef formatDescription = (__bridge CMFormatDescriptionRef)formatDescriptions.firstObject;
|
||||
|
||||
if ([track.mediaType isEqualToString:AVMediaTypeVideo]) {
|
||||
|
||||
@@ -380,7 +374,6 @@
|
||||
}
|
||||
|
||||
[self addTrack:newTrack];
|
||||
[newTrack release];
|
||||
}
|
||||
|
||||
[self convertMetadata];
|
||||
@@ -423,7 +416,7 @@
|
||||
[result appendString:name];
|
||||
}
|
||||
|
||||
return [[result copy] autorelease];
|
||||
return [result copy];
|
||||
}
|
||||
|
||||
- (MP42MetadataItem *)metadataItemWithValue:(id)value identifier:(NSString *)identifier
|
||||
@@ -465,7 +458,7 @@
|
||||
MP42MetadataKeyEncodingTool, AVMetadataCommonKeySoftware,
|
||||
nil];
|
||||
|
||||
self.metadata = [[[MP42Metadata alloc] init] autorelease];
|
||||
self.metadata = [[MP42Metadata alloc] init];
|
||||
|
||||
for (NSString *commonKey in commonItemsDict.allKeys) {
|
||||
NSArray<AVMetadataItem *> *items = [AVMetadataItem metadataItemsFromArray:_localAsset.commonMetadata
|
||||
@@ -488,8 +481,6 @@
|
||||
NSImage *imageData = [[NSImage alloc] initWithData:artworkData];
|
||||
MP42Image *image = [[MP42Image alloc] initWithImage:imageData];
|
||||
[self.metadata addMetadataItem:[self metadataItemWithValue:image identifier:MP42MetadataKeyCoverArt]];
|
||||
[image release];
|
||||
[imageData release];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -692,7 +683,7 @@
|
||||
// Prefer the asbd sample rate, naturalTimeScale might not be
|
||||
// the right one if we are reading for .ts
|
||||
if ([assetTrack.mediaType isEqualToString:AVMediaTypeAudio] && assetTrack.naturalTimeScale == 90000) {
|
||||
CMFormatDescriptionRef formatDescription = (CMFormatDescriptionRef)assetTrack.formatDescriptions.firstObject;
|
||||
CMFormatDescriptionRef formatDescription = (__bridge CMFormatDescriptionRef)assetTrack.formatDescriptions.firstObject;
|
||||
|
||||
if (formatDescription) {
|
||||
const AudioStreamBasicDescription *asbd = CMAudioFormatDescriptionGetStreamBasicDescription(formatDescription);
|
||||
@@ -714,7 +705,7 @@
|
||||
- (NSData *)magicCookieForTrack:(MP42Track *)track {
|
||||
|
||||
AVAssetTrack *assetTrack = [_localAsset trackWithTrackID:track.sourceId];
|
||||
CMFormatDescriptionRef formatDescription = (CMFormatDescriptionRef)assetTrack.formatDescriptions.firstObject;
|
||||
CMFormatDescriptionRef formatDescription = (__bridge CMFormatDescriptionRef)assetTrack.formatDescriptions.firstObject;
|
||||
|
||||
if (formatDescription) {
|
||||
|
||||
@@ -736,7 +727,7 @@
|
||||
magicCookie = CFDictionaryGetValue(atoms, @"esds");
|
||||
}
|
||||
|
||||
return (NSData *)magicCookie;
|
||||
return (__bridge NSData *)magicCookie;
|
||||
|
||||
} else if ([assetTrack.mediaType isEqualToString:AVMediaTypeAudio]) {
|
||||
|
||||
@@ -849,7 +840,7 @@
|
||||
[ac3Info appendBytes:&lfeon length:sizeof(uint64_t)];
|
||||
[ac3Info appendBytes:&bit_rate_code length:sizeof(uint64_t)];
|
||||
|
||||
return [ac3Info autorelease];
|
||||
return ac3Info;
|
||||
|
||||
} else if (cookieSizeOut) {
|
||||
return [NSData dataWithBytes:cookieBuffer length:cookieSizeOut];
|
||||
@@ -864,7 +855,7 @@
|
||||
CFDictionaryRef atoms = CFDictionaryGetValue(extentions, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms);
|
||||
CFDataRef magicCookie = CFDictionaryGetValue(atoms, @"vttC");
|
||||
|
||||
return (NSData *)magicCookie;
|
||||
return (__bridge NSData *)magicCookie;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -878,7 +869,7 @@
|
||||
bzero(&result, sizeof(AudioStreamBasicDescription));
|
||||
|
||||
AVAssetTrack *assetTrack = [_localAsset trackWithTrackID:track.sourceId];
|
||||
CMFormatDescriptionRef formatDescription = (CMFormatDescriptionRef)assetTrack.formatDescriptions.firstObject;
|
||||
CMFormatDescriptionRef formatDescription = (__bridge CMFormatDescriptionRef)assetTrack.formatDescriptions.firstObject;
|
||||
|
||||
if (formatDescription) {
|
||||
const AudioStreamBasicDescription *asbd = CMAudioFormatDescriptionGetStreamBasicDescription(formatDescription);
|
||||
@@ -894,20 +885,25 @@
|
||||
}
|
||||
|
||||
- (void)demux {
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
@autoreleasepool {
|
||||
NSError *localError;
|
||||
BOOL success = YES;
|
||||
OSStatus err = noErr;
|
||||
|
||||
CMTimeValue currentTime = 1;
|
||||
|
||||
uint64_t currentDataLength = 0;
|
||||
uint64_t totalDataLength = 0;
|
||||
|
||||
AVFDemuxHelper *demuxHelper = nil;
|
||||
NSError *localError;
|
||||
NSInteger tracksDone = 0;
|
||||
NSInteger tracksNumber = self.inputTracks.count;
|
||||
|
||||
AVAssetReader *assetReader = [[AVAssetReader alloc] initWithAsset:_localAsset error:&localError];
|
||||
AVFDemuxHelper * helpers[tracksNumber];
|
||||
|
||||
success = (assetReader != nil);
|
||||
if (success) {
|
||||
NSUInteger index = 0;
|
||||
for (MP42Track *track in self.inputTracks) {
|
||||
AVAssetReaderOutput *assetReaderOutput = [AVAssetReaderTrackOutput assetReaderTrackOutputWithTrack:[_localAsset trackWithTrackID:track.sourceId]
|
||||
outputSettings:nil];
|
||||
@@ -920,13 +916,17 @@
|
||||
NSLog(@"Unable to add the output to assetReader!");
|
||||
}
|
||||
|
||||
track.muxer_helper->demuxer_context = [[AVFDemuxHelper alloc] init];
|
||||
demuxHelper = track.muxer_helper->demuxer_context;
|
||||
AVFDemuxHelper *demuxHelper = [[AVFDemuxHelper alloc] init];
|
||||
demuxHelper->sourceID = track.sourceId;
|
||||
demuxHelper->timescale = [self timescaleForTrack:track];
|
||||
demuxHelper->format = track.format;
|
||||
demuxHelper->assetReaderOutput = assetReaderOutput;
|
||||
demuxHelper->editsConstructor = [[MP42EditListsReconstructor alloc] init];
|
||||
|
||||
track.demuxerHelper = demuxHelper;
|
||||
helpers[index] = demuxHelper;
|
||||
index += 1;
|
||||
|
||||
totalDataLength += track.dataLength;
|
||||
}
|
||||
}
|
||||
@@ -935,25 +935,17 @@
|
||||
|
||||
if (!success) {
|
||||
localError = [assetReader error];
|
||||
|
||||
[assetReader release];
|
||||
[self setDone];
|
||||
[pool release];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
CMTimeValue currentTime = 1;
|
||||
NSInteger tracksNumber = self.inputTracks.count;
|
||||
NSInteger tracksDone = 0;
|
||||
|
||||
while (tracksDone != tracksNumber) {
|
||||
if (self.isCancelled) {
|
||||
break;
|
||||
}
|
||||
|
||||
for (MP42Track *track in self.inputTracks) {
|
||||
demuxHelper = track.muxer_helper->demuxer_context;
|
||||
for (NSUInteger index = 0; index < tracksNumber; index += 1) {
|
||||
AVFDemuxHelper *demuxHelper = helpers[index];
|
||||
AVAssetReaderOutput *assetReaderOutput = demuxHelper->assetReaderOutput;
|
||||
|
||||
while (demuxHelper->currentTime < demuxHelper->timescale * currentTime && !demuxHelper->done) {
|
||||
@@ -975,7 +967,7 @@
|
||||
BOOL doNotDisplay = NO;
|
||||
CFArrayRef attachmentsArray = CMSampleBufferGetSampleAttachmentsArray(sampleBuffer, NO);
|
||||
if (attachmentsArray) {
|
||||
for (NSDictionary *dict in (NSArray *)attachmentsArray) {
|
||||
for (NSDictionary *dict in (__bridge NSArray *)attachmentsArray) {
|
||||
if (dict[(NSString *)kCMSampleAttachmentKey_NotSync]) {
|
||||
sync = 0;
|
||||
}
|
||||
@@ -993,7 +985,7 @@
|
||||
|
||||
// We have only a sample
|
||||
// or the format is PCM, if so send only a single buffer to improve performance
|
||||
if (samplesNum == 1 || (samplesNum > 1 && track.format == kMP42AudioCodecType_LinearPCM)) {
|
||||
if (samplesNum == 1 || (samplesNum > 1 && demuxHelper->format == kMP42AudioCodecType_LinearPCM)) {
|
||||
|
||||
void *sampleData = malloc(bufferSize);
|
||||
CMBlockBufferCopyDataBytes(buffer, 0, bufferSize, sampleData);
|
||||
@@ -1015,7 +1007,6 @@
|
||||
|
||||
[demuxHelper->editsConstructor addSample:sample];
|
||||
[self enqueue:sample];
|
||||
[sample release];
|
||||
|
||||
currentDataLength += bufferSize;
|
||||
demuxHelper->currentTime = currentOutputTimeStamp.value;
|
||||
@@ -1141,7 +1132,6 @@
|
||||
|
||||
[demuxHelper->editsConstructor addSample:sample];
|
||||
[self enqueue:sample];
|
||||
[sample release];
|
||||
|
||||
currentOutputTimeStamp.value = currentOutputTimeStamp.value + sampleTimingInfo.duration.value;
|
||||
currentDataLength += sampleSize;
|
||||
@@ -1172,7 +1162,6 @@
|
||||
|
||||
[demuxHelper->editsConstructor addSample:sample];
|
||||
demuxHelper->currentTime = currentOutputTimeStamp.value;
|
||||
[sample release];
|
||||
}
|
||||
CFRelease(sampleBuffer);
|
||||
|
||||
@@ -1188,9 +1177,8 @@
|
||||
currentTime += 1;
|
||||
}
|
||||
|
||||
[assetReader release];
|
||||
[self setDone];
|
||||
[pool release];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)cleanUp:(MP4FileHandle)fileHandle {
|
||||
@@ -1202,7 +1190,7 @@
|
||||
|
||||
MP42Track *inputTrack = [self inputTrackWithTrackID:track.sourceId];
|
||||
|
||||
AVFDemuxHelper *helper = inputTrack.muxer_helper->demuxer_context;
|
||||
AVFDemuxHelper *helper = inputTrack.demuxerHelper;
|
||||
MP42EditListsReconstructor *editsConstructor = helper->editsConstructor;
|
||||
|
||||
// Make sure the sample offsets are all positive.
|
||||
@@ -1244,9 +1232,4 @@
|
||||
return @"AVFoundation demuxer";
|
||||
}
|
||||
|
||||
- (void) dealloc {
|
||||
[_localAsset release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -15,7 +15,8 @@
|
||||
#import "MP42AudioEncoder.h"
|
||||
#import "MP42AC3AudioEncoder.h"
|
||||
|
||||
#import "MP42Track+Muxer.h"
|
||||
#import "MP42Track+Private.h"
|
||||
#import "MP42FileImporter.h"
|
||||
#import "MP42FileImporter+Private.h"
|
||||
|
||||
#import <CoreAudio/CoreAudio.h>
|
||||
@@ -36,7 +37,7 @@
|
||||
self = [super init];
|
||||
|
||||
if (self) {
|
||||
NSData *magicCookie = [track.muxer_helper->importer magicCookieForTrack:track];
|
||||
NSData *magicCookie = [track.importer magicCookieForTrack:track];
|
||||
AudioStreamBasicDescription asbd = [self basicDescriptorForTrack:track];
|
||||
UInt32 initialPadding = [self initialPaddingForTrack:track];
|
||||
UInt32 channelLayoutSize = sizeof(AudioChannelLayout);
|
||||
@@ -103,11 +104,11 @@
|
||||
{
|
||||
AudioStreamBasicDescription asbd;
|
||||
bzero(&asbd, sizeof(AudioStreamBasicDescription));
|
||||
asbd.mSampleRate = [track.muxer_helper->importer timescaleForTrack:track];;
|
||||
asbd.mSampleRate = [track.importer timescaleForTrack:track];;
|
||||
asbd.mChannelsPerFrame = track.channels;
|
||||
|
||||
if (track.format == kMP42AudioCodecType_LinearPCM) {
|
||||
AudioStreamBasicDescription temp = [track.muxer_helper->importer audioDescriptionForTrack:track];
|
||||
AudioStreamBasicDescription temp = [track.importer audioDescriptionForTrack:track];
|
||||
if (temp.mFormatID) {
|
||||
asbd = temp;
|
||||
}
|
||||
@@ -144,11 +145,4 @@
|
||||
return sampleRate;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[_decoder release];
|
||||
[_encoder release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -345,6 +345,7 @@ static void configureDescriptors(MP42DecodeContext *context, AVFrame *frame)
|
||||
// Get real channels number and layout
|
||||
int nb_channels = av_get_channel_layout_nb_channels(frame->channel_layout);
|
||||
int sample_rate = frame->sample_rate;
|
||||
int container_sample_rate = context->inputFormat->mSampleRate;
|
||||
|
||||
// Reset the channels per frame and sample rate
|
||||
if (context->inputFormat->mChannelsPerFrame == context->outputFormat->mChannelsPerFrame) {
|
||||
@@ -357,7 +358,9 @@ static void configureDescriptors(MP42DecodeContext *context, AVFrame *frame)
|
||||
sample_rate = 48000;
|
||||
}
|
||||
|
||||
context->outputFormat->mSampleRate = sample_rate;
|
||||
if (sample_rate < container_sample_rate) {
|
||||
context->outputFormat->mSampleRate = sample_rate;
|
||||
}
|
||||
context->outputFormat->mBytesPerPacket = 4 * context->outputFormat->mChannelsPerFrame;
|
||||
context->outputFormat->mBytesPerFrame = context->outputFormat->mBytesPerPacket * context->outputFormat->mFramesPerPacket;
|
||||
|
||||
|
||||
@@ -11,11 +11,13 @@
|
||||
|
||||
#import "MP42FileImporter.h"
|
||||
#import "MP42FileImporter+Private.h"
|
||||
#import "MP42Track.h"
|
||||
#import "MP42Track+Private.h"
|
||||
|
||||
#import "MP42Fifo.h"
|
||||
#import "MP42Sample.h"
|
||||
|
||||
#import "MP42PrivateUtilities.h"
|
||||
#import "MP42Track+Muxer.h"
|
||||
#import "MP42SubtitleTrack.h"
|
||||
|
||||
#import "MP42OCRWrapper.h"
|
||||
@@ -56,8 +58,8 @@
|
||||
|
||||
- (CIContext *)imgContext {
|
||||
if (!_imgContext) {
|
||||
_imgContext = [[CIContext contextWithCGContext:[[NSGraphicsContext currentContext] graphicsPort]
|
||||
options:nil] retain];
|
||||
_imgContext = [CIContext contextWithCGContext:[[NSGraphicsContext currentContext] graphicsPort]
|
||||
options:nil];
|
||||
}
|
||||
return _imgContext;
|
||||
}
|
||||
@@ -106,7 +108,6 @@
|
||||
|
||||
if (sampleBuffer->flags & MP42SampleBufferFlagEndOfFile) {
|
||||
[_outputSamplesBuffer enqueue:sampleBuffer];
|
||||
[sampleBuffer release];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -118,9 +119,6 @@
|
||||
MP42SampleBuffer *subSample = copyEmptySubtitleSample(sampleBuffer->trackId, sampleBuffer->duration, NO);
|
||||
|
||||
[_outputSamplesBuffer enqueue:subSample];
|
||||
[subSample release];
|
||||
|
||||
[sampleBuffer release];
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -156,9 +154,6 @@
|
||||
MP42SampleBuffer *subSample = copyEmptySubtitleSample(sampleBuffer->trackId, sampleBuffer->duration, NO);
|
||||
|
||||
[_outputSamplesBuffer enqueue:subSample];
|
||||
[subSample release];
|
||||
|
||||
[sampleBuffer release];
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -243,8 +238,7 @@
|
||||
}
|
||||
|
||||
[_outputSamplesBuffer enqueue:subSample];
|
||||
[subSample release];
|
||||
|
||||
|
||||
CGImageRelease(cgImage);
|
||||
CGImageRelease(filteredCGImage);
|
||||
CGDataProviderRelease(provider);
|
||||
@@ -255,8 +249,6 @@
|
||||
|
||||
avsubtitle_free(&subtitle);
|
||||
av_packet_unref(&pkt);
|
||||
|
||||
[sampleBuffer release];
|
||||
}
|
||||
}
|
||||
dispatch_semaphore_signal(_done);
|
||||
@@ -273,8 +265,6 @@
|
||||
|
||||
if (sampleBuffer->flags & MP42SampleBufferFlagEndOfFile) {
|
||||
[_outputSamplesBuffer enqueue:sampleBuffer];
|
||||
[sampleBuffer release];
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -291,9 +281,6 @@
|
||||
MP42SampleBuffer *subSample = copyEmptySubtitleSample(sampleBuffer->trackId, sampleBuffer->duration, NO);
|
||||
|
||||
[_outputSamplesBuffer enqueue:subSample];
|
||||
[subSample release];
|
||||
|
||||
[sampleBuffer release];
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -306,7 +293,6 @@
|
||||
if (rect->w == 0 || rect->h == 0) {
|
||||
MP42SampleBuffer *subSample = copyEmptySubtitleSample(sampleBuffer->trackId, sampleBuffer->duration, NO);
|
||||
[_outputSamplesBuffer enqueue:subSample];
|
||||
[subSample release];
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -377,12 +363,9 @@
|
||||
}
|
||||
|
||||
[_outputSamplesBuffer enqueue:subSample];
|
||||
[subSample release];
|
||||
|
||||
avsubtitle_free(&subtitle);
|
||||
av_packet_unref(&pkt);
|
||||
|
||||
[sampleBuffer release];
|
||||
}
|
||||
}
|
||||
dispatch_semaphore_signal(_done);
|
||||
@@ -408,11 +391,9 @@
|
||||
if (avcodec_open2(avContext, avCodec, NULL)) {
|
||||
NSLog(@"Error opening subtitle decoder");
|
||||
av_freep(&avContext);
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
} else {
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
|
||||
@@ -420,7 +401,7 @@
|
||||
_inputSamplesBuffer = [[MP42Fifo alloc] initWithCapacity:20];
|
||||
_done = dispatch_semaphore_create(0);
|
||||
|
||||
srcMagicCookie = [[track.muxer_helper->importer magicCookieForTrack:track] retain];
|
||||
srcMagicCookie = [track.importer magicCookieForTrack:track];
|
||||
|
||||
_ocr = [[MP42OCRWrapper alloc] initWithLanguage:track.language];
|
||||
|
||||
@@ -468,18 +449,6 @@
|
||||
if (codecData) {
|
||||
av_freep(&codecData);
|
||||
}
|
||||
|
||||
[srcMagicCookie release];
|
||||
[_outputSamplesBuffer release];
|
||||
[_inputSamplesBuffer release];
|
||||
|
||||
[decoderThread release];
|
||||
[_ocr release];
|
||||
[_imgContext release];
|
||||
|
||||
dispatch_release(_done);
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -31,7 +31,6 @@
|
||||
newTrack.URL = self.fileURL;
|
||||
|
||||
[self addTrack:newTrack];
|
||||
[newTrack release];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -155,7 +154,6 @@ static int ParseByte(const char *string, UInt8 *byte, Boolean hex)
|
||||
sample.title = [lineArray lastObject];
|
||||
|
||||
[sampleArray addObject:sample];
|
||||
[sample release];
|
||||
}
|
||||
|
||||
for (MP42TextSample *ccSample in sampleArray) {
|
||||
@@ -203,7 +201,6 @@ static int ParseByte(const char *string, UInt8 *byte, Boolean hex)
|
||||
sample->trackId = trackId;
|
||||
|
||||
[self enqueue:sample];
|
||||
[sample release];
|
||||
|
||||
frameDrop += ccSample.timestamp;
|
||||
minutesDrop += frameDrop;
|
||||
@@ -239,13 +236,11 @@ static int ParseByte(const char *string, UInt8 *byte, Boolean hex)
|
||||
sample->trackId = trackId;
|
||||
|
||||
[self enqueue:sample];
|
||||
[sample release];
|
||||
|
||||
|
||||
i++;
|
||||
self.progress = ((CGFloat)i / sampleArray.count) * 100;
|
||||
}
|
||||
|
||||
[sampleArray release];
|
||||
[self setDone];
|
||||
}
|
||||
}
|
||||
|
||||
+14
-41
@@ -8,6 +8,7 @@
|
||||
|
||||
#import "MP42MkvImporter.h"
|
||||
#import "MP42FileImporter+Private.h"
|
||||
#import "MP42Sample.h"
|
||||
|
||||
#import "MP42File.h"
|
||||
#import "MP42SubUtilities.h"
|
||||
@@ -19,7 +20,6 @@
|
||||
|
||||
#import "MP42PrivateUtilities.h"
|
||||
#import "MP42FormatUtilites.h"
|
||||
#import "MP42Track+Muxer.h"
|
||||
#import "MP42Track+Private.h"
|
||||
|
||||
#define SCALE_FACTOR 1000000.f
|
||||
@@ -62,12 +62,6 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[queue release]; queue = nil;
|
||||
[ss release]; ss = nil;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
@end
|
||||
|
||||
static int readData(struct StdIoStream *ioStream, uint64_t pos, uint8_t **data, uint32_t dataSize)
|
||||
@@ -213,8 +207,6 @@ static int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, ui
|
||||
*outError = MP42Error(MP42LocalizedString(@"The movie could not be opened.", @"mkv error message"),
|
||||
MP42LocalizedString(@"The file is not a matroska file.", @"mkv error message"), 100);
|
||||
}
|
||||
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
|
||||
@@ -350,7 +342,6 @@ static int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, ui
|
||||
newTrack.language = [MP42Languages.defaultManager extendedTagForISO_639_2b:@(mkvTrack->Language)];
|
||||
|
||||
[self addTrack:newTrack];
|
||||
[newTrack release];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,7 +373,6 @@ static int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, ui
|
||||
}
|
||||
}
|
||||
[self addTrack:newTrack];
|
||||
[newTrack release];
|
||||
}
|
||||
|
||||
self.metadata = [self readMatroskaMetadata];
|
||||
@@ -402,7 +392,7 @@ static int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, ui
|
||||
|
||||
- (MP42Metadata *)readMatroskaMetadata
|
||||
{
|
||||
MP42Metadata *mkvMetadata = [[[MP42Metadata alloc] init] autorelease];
|
||||
MP42Metadata *mkvMetadata = [[MP42Metadata alloc] init];
|
||||
|
||||
SegmentInfo *segInfo = mkv_GetFileInfo(_matroskaFile);
|
||||
if (segInfo->Title) {
|
||||
@@ -467,8 +457,6 @@ static int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, ui
|
||||
MP42Image *image = [[MP42Image alloc] initWithBytes:data length:attachment->Length type:type];
|
||||
|
||||
[self addMetadataItem:image identifier:MP42MetadataKeyCoverArt metadata:mkvMetadata];
|
||||
|
||||
[image release];
|
||||
}
|
||||
|
||||
free(data);
|
||||
@@ -655,7 +643,7 @@ static NSString * TrackNameToString(TrackInfo *track)
|
||||
aac[1] = 0x90;
|
||||
|
||||
[magicCookie appendBytes:aac length:2];
|
||||
return [magicCookie autorelease];
|
||||
return magicCookie;
|
||||
}
|
||||
else if (!strcmp(trackInfo->CodecID, "A_AC3") || !strcmp(trackInfo->CodecID, "A_EAC3")) {
|
||||
mkv_SetTrackMask(_matroskaFile, ~(1l << track.sourceId));
|
||||
@@ -727,14 +715,14 @@ static NSString * TrackNameToString(TrackInfo *track)
|
||||
}
|
||||
|
||||
if (context) {
|
||||
magicCookie = (NSData *)createCookie_EAC3(context);
|
||||
magicCookie = (__bridge NSData *)createCookie_EAC3(context);
|
||||
free(context);
|
||||
}
|
||||
}
|
||||
|
||||
mkv_Seek(_matroskaFile, 0, 0);
|
||||
|
||||
return [magicCookie autorelease];
|
||||
return magicCookie;
|
||||
}
|
||||
else if (!strcmp(trackInfo->CodecID, "S_VOBSUB")) {
|
||||
char *string = (char *) trackInfo->CodecPrivate;
|
||||
@@ -794,8 +782,7 @@ static NSString * TrackNameToString(TrackInfo *track)
|
||||
// Methods to extract all the samples from the active tracks at the same time
|
||||
- (void)demux
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
@autoreleasepool {
|
||||
uint64_t StartTime, EndTime, FilePos;
|
||||
uint32_t Track, FrameSize, FrameFlags;
|
||||
uint8_t *frame = NULL;
|
||||
@@ -813,21 +800,19 @@ static NSString * TrackNameToString(TrackInfo *track)
|
||||
|
||||
for (MP42Track *track in inputTracks) {
|
||||
TrackMask &= ~(1l << track.sourceId);
|
||||
track.muxer_helper->demuxer_context = [[MatroskaDemuxHelper alloc] init];
|
||||
track.demuxerHelper = [[MatroskaDemuxHelper alloc] init];
|
||||
}
|
||||
|
||||
mkv_SetTrackMask(_matroskaFile, TrackMask);
|
||||
|
||||
while (!mkv_ReadFrame(_matroskaFile, 0, &Track, &StartTime, &EndTime, &FilePos, &FrameSize, &FrameFlags) && !self.isCancelled) {
|
||||
self.progress = (StartTime / _fileDuration / 10000);
|
||||
muxer_helper *helper = NULL;
|
||||
|
||||
MP42Track *track = nil;
|
||||
|
||||
for (MP42Track *fTrack in inputTracks){
|
||||
if (fTrack.sourceId == Track) {
|
||||
helper = fTrack.muxer_helper;
|
||||
demuxHelper = helper->demuxer_context;
|
||||
demuxHelper = fTrack.demuxerHelper;
|
||||
track = fTrack;
|
||||
}
|
||||
}
|
||||
@@ -889,7 +874,6 @@ static NSString * TrackNameToString(TrackInfo *track)
|
||||
demuxHelper->currentTime = sample->decodeTimestamp * (double)mkv_TruncFloat(trackInfo->AV.Audio.SamplingFreq) / 1000000000.f;
|
||||
}
|
||||
|
||||
[demuxHelper->previousSample release];
|
||||
demuxHelper->previousSample = sample;
|
||||
#else
|
||||
[self enqueue:sample];
|
||||
@@ -908,14 +892,14 @@ static NSString * TrackNameToString(TrackInfo *track)
|
||||
}
|
||||
}
|
||||
|
||||
NSString *string = [[[NSString alloc] initWithBytes:frame length:FrameSize encoding:NSUTF8StringEncoding] autorelease];
|
||||
NSString *string = [[NSString alloc] initWithBytes:frame length:FrameSize encoding:NSUTF8StringEncoding];
|
||||
if (!strcmp(trackInfo->CodecID, "S_TEXT/ASS") || !strcmp(trackInfo->CodecID, "S_TEXT/SSA")) {
|
||||
string = StripSSALine(string);
|
||||
}
|
||||
|
||||
if ([string length]) {
|
||||
SBSubLine *sl = [[SBSubLine alloc] initWithLine:string start:StartTime / SCALE_FACTOR end:EndTime / SCALE_FACTOR];
|
||||
[demuxHelper->ss addLine:[sl autorelease]];
|
||||
[demuxHelper->ss addLine:sl];
|
||||
}
|
||||
demuxHelper->samplesWritten++;
|
||||
free(frame);
|
||||
@@ -951,7 +935,6 @@ static NSString * TrackNameToString(TrackInfo *track)
|
||||
}
|
||||
|
||||
[self enqueue:demuxHelper->previousSample];
|
||||
[demuxHelper->previousSample release];
|
||||
|
||||
demuxHelper->previousSample = nextSample;
|
||||
demuxHelper->samplesWritten++;
|
||||
@@ -966,14 +949,12 @@ static NSString * TrackNameToString(TrackInfo *track)
|
||||
sample->trackId = track.sourceId;
|
||||
|
||||
[self enqueue:sample];
|
||||
[sample release];
|
||||
}
|
||||
|
||||
nextSample->duration = (EndTime - StartTime) / SCALE_FACTOR;
|
||||
|
||||
[self enqueue:nextSample];
|
||||
[nextSample release];
|
||||
|
||||
|
||||
demuxHelper->currentTime = EndTime;
|
||||
}
|
||||
}
|
||||
@@ -990,7 +971,6 @@ static NSString * TrackNameToString(TrackInfo *track)
|
||||
frameSample->frameSize = FrameSize;
|
||||
frameSample->frameFlags = FrameFlags;
|
||||
[demuxHelper->queue addObject:frameSample];
|
||||
[frameSample release];
|
||||
|
||||
if ([demuxHelper->queue count] < bufferSize) {
|
||||
continue;
|
||||
@@ -1044,7 +1024,6 @@ static NSString * TrackNameToString(TrackInfo *track)
|
||||
}
|
||||
|
||||
[self enqueue:sample];
|
||||
[sample release];
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
@@ -1054,8 +1033,7 @@ static NSString * TrackNameToString(TrackInfo *track)
|
||||
}
|
||||
|
||||
for (MP42Track *track in inputTracks) {
|
||||
muxer_helper *helper = track.muxer_helper;
|
||||
demuxHelper = helper->demuxer_context;
|
||||
demuxHelper = track.demuxerHelper;
|
||||
|
||||
if (demuxHelper->queue) {
|
||||
TrackInfo *trackInfo = mkv_GetTrackInfo(_matroskaFile, [track sourceId]);
|
||||
@@ -1071,7 +1049,6 @@ static NSString * TrackNameToString(TrackInfo *track)
|
||||
frameSample = [[MatroskaSample alloc] init];
|
||||
frameSample->startTime = lastSample->endTime;
|
||||
[demuxHelper->queue addObject:frameSample];
|
||||
[frameSample release];
|
||||
}
|
||||
currentSample = [demuxHelper->queue objectAtIndex:demuxHelper->buffer];
|
||||
|
||||
@@ -1115,7 +1092,6 @@ static NSString * TrackNameToString(TrackInfo *track)
|
||||
}
|
||||
|
||||
[self enqueue:sample];
|
||||
[sample release];
|
||||
|
||||
demuxHelper->bufferFlush++;
|
||||
if (demuxHelper->bufferFlush >= bufferSize - 1) {
|
||||
@@ -1153,7 +1129,6 @@ static NSString * TrackNameToString(TrackInfo *track)
|
||||
sample->decodeTimestamp = demuxHelper->currentTime;
|
||||
|
||||
[self enqueue:sample];
|
||||
[sample release];
|
||||
|
||||
demuxHelper->samplesWritten++;
|
||||
}
|
||||
@@ -1165,13 +1140,12 @@ static NSString * TrackNameToString(TrackInfo *track)
|
||||
}
|
||||
|
||||
[self enqueue:demuxHelper->previousSample];
|
||||
[demuxHelper->previousSample release];
|
||||
demuxHelper->previousSample = nil;
|
||||
}
|
||||
}
|
||||
|
||||
[self setDone];
|
||||
[pool release];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)cleanUp:(MP4FileHandle)fileHandle
|
||||
@@ -1179,7 +1153,7 @@ static NSString * TrackNameToString(TrackInfo *track)
|
||||
for (MP42Track *track in self.outputsTracks) {
|
||||
MP42Track *inputTrack = [self inputTrackWithTrackID:track.sourceId];
|
||||
|
||||
MatroskaDemuxHelper *demuxHelper = inputTrack.muxer_helper->demuxer_context;
|
||||
MatroskaDemuxHelper *demuxHelper = inputTrack.demuxerHelper;
|
||||
MP4TrackId trackId = track.trackId;
|
||||
|
||||
if (demuxHelper->minDisplayOffset != 0) {
|
||||
@@ -1238,7 +1212,6 @@ static NSString * TrackNameToString(TrackInfo *track)
|
||||
- (void)dealloc
|
||||
{
|
||||
closeMatroskaFile(_matroskaFile, _ioStream);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
||||
+19
-27
@@ -15,11 +15,9 @@
|
||||
|
||||
#import "mp4v2.h"
|
||||
#import "MP42PrivateUtilities.h"
|
||||
#import "MP42Track+Muxer.h"
|
||||
#import "MP42Track+Private.h"
|
||||
|
||||
@interface MP4DemuxHelper : NSObject {
|
||||
@public
|
||||
typedef struct MP4DemuxHelper {
|
||||
MP4TrackId sourceID;
|
||||
|
||||
MP4SampleId currentSampleId;
|
||||
@@ -28,11 +26,7 @@
|
||||
uint64_t timeScale;
|
||||
|
||||
uint32_t done;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation MP4DemuxHelper
|
||||
@end
|
||||
} MP4DemuxHelper;
|
||||
|
||||
@implementation MP42Mp4Importer {
|
||||
@private
|
||||
@@ -49,14 +43,11 @@
|
||||
MP42File *sourceFile = [[MP42File alloc] initWithURL:self.fileURL error:outError];
|
||||
|
||||
if (!sourceFile) {
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
|
||||
[self addTracks:sourceFile.tracks];
|
||||
self.metadata = sourceFile.metadata;
|
||||
|
||||
[sourceFile release];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -110,8 +101,7 @@
|
||||
[ac3Info appendBytes:&lfeon length:sizeof(uint64_t)];
|
||||
[ac3Info appendBytes:&bit_rate_code length:sizeof(uint64_t)];
|
||||
|
||||
return [ac3Info autorelease];
|
||||
|
||||
return ac3Info;
|
||||
}
|
||||
else if (!strcmp(media_data_name, "ec-3")) {
|
||||
if (MP4HaveTrackAtom(_fileHandle, srcTrackId, "mdia.minf.stbl.stsd.ec-3.dec3")) {
|
||||
@@ -161,7 +151,7 @@
|
||||
if (!strcmp(media_data_name, "avc1")) {
|
||||
|
||||
// Extract and rewrite some kind of avcC extradata from the mp4 file.
|
||||
NSMutableData *avcCData = [[[NSMutableData alloc] init] autorelease];
|
||||
NSMutableData *avcCData = [[NSMutableData alloc] init];
|
||||
|
||||
uint8_t configurationVersion = 1;
|
||||
uint8_t AVCProfileIndication;
|
||||
@@ -227,10 +217,8 @@
|
||||
free(pictheadersize);
|
||||
|
||||
magicCookie = [avcCData copy];
|
||||
[seqData release];
|
||||
[pictData release];
|
||||
|
||||
return [magicCookie autorelease];
|
||||
return magicCookie;
|
||||
}
|
||||
else if (!strcmp(media_data_name, "hev1")) {
|
||||
uint8_t *ppValue;
|
||||
@@ -287,19 +275,23 @@
|
||||
|
||||
NSInteger tracksNumber = inputTracks.count;
|
||||
NSInteger tracksDone = 0;
|
||||
MP4DemuxHelper *demuxHelper;
|
||||
|
||||
if (!_fileHandle) {
|
||||
return;
|
||||
}
|
||||
|
||||
MP4DemuxHelper * helpers[tracksNumber];
|
||||
|
||||
NSUInteger index = 0;
|
||||
for (MP42Track *track in inputTracks) {
|
||||
track.muxer_helper->demuxer_context = [[MP4DemuxHelper alloc] init];
|
||||
demuxHelper = track.muxer_helper->demuxer_context;
|
||||
MP4DemuxHelper *demuxHelper = malloc(sizeof(MP4DemuxHelper));
|
||||
demuxHelper->sourceID = track.sourceId;
|
||||
demuxHelper->totalSampleNumber = MP4GetTrackNumberOfSamples(_fileHandle, track.sourceId);
|
||||
demuxHelper->timeScale = MP4GetTrackTimeScale(_fileHandle, track.sourceId);
|
||||
demuxHelper->done = 0;
|
||||
|
||||
helpers[index] = demuxHelper;
|
||||
index += 1;
|
||||
}
|
||||
|
||||
MP4Timestamp currentTime = 1;
|
||||
@@ -311,9 +303,8 @@
|
||||
break;
|
||||
}
|
||||
|
||||
for (MP42Track *track in inputTracks) {
|
||||
muxer_helper *helper = track.muxer_helper;
|
||||
demuxHelper = helper->demuxer_context;
|
||||
for (NSUInteger index = 0; index < tracksNumber; index += 1) {
|
||||
MP4DemuxHelper *demuxHelper = helpers[index];
|
||||
|
||||
if (self.isCancelled) {
|
||||
break;
|
||||
@@ -355,8 +346,7 @@
|
||||
sample->trackId = demuxHelper->sourceID;
|
||||
|
||||
[self enqueue:sample];
|
||||
[sample release];
|
||||
|
||||
|
||||
demuxHelper->currentTime = pStartTime;
|
||||
}
|
||||
}
|
||||
@@ -366,6 +356,10 @@
|
||||
}
|
||||
|
||||
[self setDone];
|
||||
|
||||
for (NSUInteger index = 0; index < tracksNumber; index += 1) {
|
||||
free(helpers[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,8 +411,6 @@
|
||||
if (_fileHandle) {
|
||||
MP4Close(_fileHandle, 0);
|
||||
}
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
||||
+1
-15
@@ -15,7 +15,6 @@
|
||||
|
||||
#import "mp4v2.h"
|
||||
#import "MP42PrivateUtilities.h"
|
||||
#import "MP42Track+Muxer.h"
|
||||
#import "MP42Track+Private.h"
|
||||
|
||||
@implementation MP42SrtImporter {
|
||||
@@ -39,7 +38,7 @@
|
||||
newTrack.format = kMP42SubtitleCodecType_3GText;
|
||||
newTrack.URL = self.fileURL;
|
||||
newTrack.alternateGroup = 2;
|
||||
newTrack.language = getFilenameLanguage((CFStringRef)self.fileURL.path);
|
||||
newTrack.language = getFilenameLanguage((__bridge CFStringRef)self.fileURL.path);
|
||||
|
||||
// Check if a 10.10 only class is available, NSLinguisticTagger crashes on 10.9
|
||||
// if the string contains some characters.
|
||||
@@ -87,7 +86,6 @@
|
||||
if (languageName) {
|
||||
newTrack.language = [MP42Languages.defaultManager extendedTagForLang:languageName];
|
||||
}
|
||||
[locale release];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,9 +105,6 @@
|
||||
MP42LocalizedString(@"The file is not a srt file, or it does not contain any subtitles.", @"srt error message"), 100);
|
||||
}
|
||||
|
||||
[newTrack release];
|
||||
[self release];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
@@ -124,7 +119,6 @@
|
||||
}
|
||||
|
||||
[self addTrack:newTrack];
|
||||
[newTrack release];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -167,7 +161,6 @@
|
||||
}
|
||||
|
||||
[self enqueue:sample];
|
||||
[sample release];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,11 +175,4 @@
|
||||
return @"SRT demuxer";
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[_ss release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -13,6 +13,17 @@
|
||||
|
||||
@dynamic muxer_helper;
|
||||
|
||||
- (id)demuxerHelper {
|
||||
muxer_helper *helper = (muxer_helper *)_helper;
|
||||
return helper->demuxer_context;
|
||||
}
|
||||
|
||||
- (void)setDemuxerHelper:(id)demuxerHelper {
|
||||
[demuxerHelper retain];
|
||||
muxer_helper *helper = (muxer_helper *)_helper;
|
||||
helper->demuxer_context = demuxerHelper;
|
||||
}
|
||||
|
||||
- (MP42FileImporter *)importer
|
||||
{
|
||||
return self.muxer_helper->importer;
|
||||
|
||||
@@ -34,6 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property(nonatomic, readonly) NSMutableDictionary<NSString *, NSNumber *> *updatedProperty;
|
||||
|
||||
@property (nonatomic, readwrite) MP42FileImporter *importer;
|
||||
@property (nonatomic, readwrite) id demuxerHelper;
|
||||
|
||||
- (void *)copy_muxer_helper;
|
||||
- (void *)create_muxer_helper;
|
||||
|
||||
@@ -19,12 +19,6 @@
|
||||
@interface MP42Track ()
|
||||
{
|
||||
NSString *_name;
|
||||
NSString *_language;
|
||||
|
||||
BOOL _enabled;
|
||||
uint64_t _alternateGroup;
|
||||
|
||||
NSTimeInterval _startOffset;
|
||||
}
|
||||
|
||||
@property(nonatomic, readwrite) MP42TrackId trackId;
|
||||
@@ -280,10 +274,6 @@
|
||||
|
||||
}
|
||||
|
||||
- (NSString *)language {
|
||||
return _language;
|
||||
}
|
||||
|
||||
- (void)setLanguage:(NSString *)newLang
|
||||
{
|
||||
_language = [newLang copy];
|
||||
@@ -308,14 +298,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isEnabled {
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
- (uint64_t)alternateGroup {
|
||||
return _alternateGroup;
|
||||
}
|
||||
|
||||
- (void)setAlternateGroup:(uint64_t)newGroup
|
||||
{
|
||||
_alternateGroup = newGroup;
|
||||
@@ -323,10 +305,6 @@
|
||||
_updatedProperty[@"alternate_group"] = @YES;
|
||||
}
|
||||
|
||||
- (NSTimeInterval)startOffset {
|
||||
return _startOffset;
|
||||
}
|
||||
|
||||
- (void)setStartOffset:(NSTimeInterval)newOffset
|
||||
{
|
||||
_startOffset = newOffset;
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
|
||||
#import "mp4v2.h"
|
||||
#import "MP42PrivateUtilities.h"
|
||||
#import "MP42Track+Muxer.h"
|
||||
#import "MP42Track+Private.h"
|
||||
#import "MP42Sample.h"
|
||||
|
||||
@interface SBVobSubSample : NSObject
|
||||
{
|
||||
@@ -68,22 +68,14 @@
|
||||
if(!self)
|
||||
return self;
|
||||
|
||||
privateData = [idxPrivateData retain];
|
||||
language = [lang retain];
|
||||
privateData = [idxPrivateData copy];
|
||||
language = [lang copy];
|
||||
index = trackIndex;
|
||||
samples = [[NSMutableArray alloc] init];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[privateData release];
|
||||
[language release];
|
||||
[samples release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)addSample:(SBVobSubSample *)sample
|
||||
{
|
||||
[samples addObject:sample];
|
||||
@@ -94,7 +86,6 @@
|
||||
{
|
||||
SBVobSubSample *sample = [[SBVobSubSample alloc] initWithTime:time offset:offset];
|
||||
[self addSample:sample];
|
||||
[sample release];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -136,7 +127,7 @@ static NSArray<SBVobSubTrack *> * LoadVobSubSubtitles(NSURL *theDirectory, NSStr
|
||||
|
||||
NSURL *subFileURL = [[nsURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"sub"];
|
||||
|
||||
if([idxContent length]) {
|
||||
if ([idxContent length]) {
|
||||
NSError *nsErr;
|
||||
NSDictionary *attr = [[NSFileManager defaultManager] attributesOfItemAtPath:subFileURL.path error:&nsErr];
|
||||
if (!attr) goto bail;
|
||||
@@ -190,7 +181,6 @@ static NSArray<SBVobSubTrack *> * LoadVobSubSubtitles(NSURL *theDirectory, NSStr
|
||||
|
||||
currentTrack = [[SBVobSubTrack alloc] initWithPrivateData:privateLines language:language andIndex:index];
|
||||
[tracks addObject:currentTrack];
|
||||
[currentTrack release];
|
||||
}
|
||||
break;
|
||||
case VOB_SUB_STATE_READING_DELAY:
|
||||
@@ -211,10 +201,9 @@ static NSArray<SBVobSubTrack *> * LoadVobSubSubtitles(NSURL *theDirectory, NSStr
|
||||
}
|
||||
}
|
||||
|
||||
return [tracks retain];
|
||||
return [tracks copy];
|
||||
}
|
||||
bail:
|
||||
;
|
||||
NSLog(@"Exception occurred while importing VobSub");
|
||||
return nil;
|
||||
}
|
||||
@@ -247,7 +236,6 @@ static NSArray<SBVobSubTrack *> * LoadVobSubSubtitles(NSURL *theDirectory, NSStr
|
||||
newTrack.duration = track->duration;
|
||||
|
||||
[self addTrack:newTrack];
|
||||
[newTrack release];
|
||||
}
|
||||
|
||||
if (!self.tracks.count) {
|
||||
@@ -255,8 +243,6 @@ static NSArray<SBVobSubTrack *> * LoadVobSubSubtitles(NSURL *theDirectory, NSStr
|
||||
*outError = MP42Error(MP42LocalizedString(@"The file could not be opened.", @"vobsub error message"),
|
||||
MP42LocalizedString(@"The file is not a idx file, or it does not contain any subtitles.", @"vobsub error message"), 100);
|
||||
}
|
||||
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
@@ -373,7 +359,6 @@ static NSArray<SBVobSubTrack *> * LoadVobSubSubtitles(NSURL *theDirectory, NSStr
|
||||
sample->trackId = track.sourceId;
|
||||
|
||||
[self enqueue:sample];
|
||||
[sample release];
|
||||
}
|
||||
|
||||
MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init];
|
||||
@@ -388,8 +373,7 @@ static NSArray<SBVobSubTrack *> * LoadVobSubSubtitles(NSURL *theDirectory, NSStr
|
||||
sample->trackId = track.sourceId;
|
||||
|
||||
[self enqueue:sample];
|
||||
[sample release];
|
||||
|
||||
|
||||
lastTime = endTime;
|
||||
|
||||
self.progress = ((i / (CGFloat) sampleCount ) * 100 / tracksNumber) + (tracksDone / (CGFloat) tracksNumber * 100);
|
||||
@@ -406,11 +390,4 @@ static NSArray<SBVobSubTrack *> * LoadVobSubSubtitles(NSURL *theDirectory, NSStr
|
||||
return @"VobSub demuxer";
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[_VobSubTracks release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -140,19 +140,19 @@
|
||||
A9B9C210182391DF00416A4E /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A9B9C20E182391DF00416A4E /* InfoPlist.strings */; };
|
||||
A9B9C212182391DF00416A4E /* MP42Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C211182391DF00416A4E /* MP42Tests.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
A9B9C2661823923200416A4E /* MP42AACImporter.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C21B1823923100416A4E /* MP42AACImporter.h */; };
|
||||
A9B9C2671823923200416A4E /* MP42AACImporter.mm in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C21C1823923100416A4E /* MP42AACImporter.mm */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
A9B9C2671823923200416A4E /* MP42AACImporter.mm in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C21C1823923100416A4E /* MP42AACImporter.mm */; };
|
||||
A9B9C2681823923200416A4E /* MP42AC3Importer.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C21D1823923100416A4E /* MP42AC3Importer.h */; };
|
||||
A9B9C2691823923200416A4E /* MP42AC3Importer.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C21E1823923100416A4E /* MP42AC3Importer.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
A9B9C2691823923200416A4E /* MP42AC3Importer.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C21E1823923100416A4E /* MP42AC3Importer.m */; };
|
||||
A9B9C26A1823923200416A4E /* MP42AudioConverter.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C21F1823923100416A4E /* MP42AudioConverter.h */; };
|
||||
A9B9C26B1823923200416A4E /* MP42AudioConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2201823923100416A4E /* MP42AudioConverter.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
A9B9C26B1823923200416A4E /* MP42AudioConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2201823923100416A4E /* MP42AudioConverter.m */; };
|
||||
A9B9C26C1823923200416A4E /* MP42AudioTrack.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2211823923100416A4E /* MP42AudioTrack.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
A9B9C26D1823923200416A4E /* MP42AudioTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2221823923100416A4E /* MP42AudioTrack.m */; };
|
||||
A9B9C26E1823923200416A4E /* MP42AVFImporter.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2231823923100416A4E /* MP42AVFImporter.h */; };
|
||||
A9B9C26F1823923200416A4E /* MP42AVFImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2241823923100416A4E /* MP42AVFImporter.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
A9B9C26F1823923200416A4E /* MP42AVFImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2241823923100416A4E /* MP42AVFImporter.m */; };
|
||||
A9B9C2701823923200416A4E /* MP42BitmapSubConverter.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2251823923100416A4E /* MP42BitmapSubConverter.h */; };
|
||||
A9B9C2711823923200416A4E /* MP42BitmapSubConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2261823923100416A4E /* MP42BitmapSubConverter.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
A9B9C2711823923200416A4E /* MP42BitmapSubConverter.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2261823923100416A4E /* MP42BitmapSubConverter.m */; };
|
||||
A9B9C2721823923200416A4E /* MP42CCImporter.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2271823923100416A4E /* MP42CCImporter.h */; };
|
||||
A9B9C2731823923200416A4E /* MP42CCImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2281823923100416A4E /* MP42CCImporter.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
A9B9C2731823923200416A4E /* MP42CCImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2281823923100416A4E /* MP42CCImporter.m */; };
|
||||
A9B9C2741823923200416A4E /* MP42ChapterTrack.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2291823923100416A4E /* MP42ChapterTrack.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
A9B9C2751823923200416A4E /* MP42ChapterTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C22A1823923100416A4E /* MP42ChapterTrack.m */; };
|
||||
A9B9C2761823923200416A4E /* MP42ClosedCaptionTrack.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C22B1823923100416A4E /* MP42ClosedCaptionTrack.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
@@ -174,16 +174,16 @@
|
||||
A9B9C2871823923200416A4E /* MP42Metadata.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C23C1823923100416A4E /* MP42Metadata.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
A9B9C2881823923200416A4E /* MP42Metadata.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C23D1823923100416A4E /* MP42Metadata.m */; };
|
||||
A9B9C2891823923200416A4E /* MP42MkvImporter.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C23E1823923100416A4E /* MP42MkvImporter.h */; };
|
||||
A9B9C28A1823923200416A4E /* MP42MkvImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C23F1823923100416A4E /* MP42MkvImporter.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
A9B9C28A1823923200416A4E /* MP42MkvImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C23F1823923100416A4E /* MP42MkvImporter.m */; };
|
||||
A9B9C28B1823923200416A4E /* MP42Mp4Importer.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2401823923100416A4E /* MP42Mp4Importer.h */; };
|
||||
A9B9C28C1823923200416A4E /* MP42Mp4Importer.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2411823923100416A4E /* MP42Mp4Importer.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
A9B9C28C1823923200416A4E /* MP42Mp4Importer.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2411823923100416A4E /* MP42Mp4Importer.m */; };
|
||||
A9B9C28D1823923200416A4E /* MP42Muxer.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2421823923100416A4E /* MP42Muxer.h */; };
|
||||
A9B9C28E1823923200416A4E /* MP42Muxer.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2431823923100416A4E /* MP42Muxer.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
A9B9C28F1823923200416A4E /* MP42OCRWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2441823923100416A4E /* MP42OCRWrapper.h */; };
|
||||
A9B9C2901823923200416A4E /* MP42OCRWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2451823923100416A4E /* MP42OCRWrapper.mm */; };
|
||||
A9B9C2941823923200416A4E /* MP42Sample.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2491823923100416A4E /* MP42Sample.m */; };
|
||||
A9B9C2951823923200416A4E /* MP42SrtImporter.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C24A1823923100416A4E /* MP42SrtImporter.h */; };
|
||||
A9B9C2961823923200416A4E /* MP42SrtImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C24B1823923100416A4E /* MP42SrtImporter.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
A9B9C2961823923200416A4E /* MP42SrtImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C24B1823923100416A4E /* MP42SrtImporter.m */; };
|
||||
A9B9C2971823923200416A4E /* MP42SubtitleTrack.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C24C1823923100416A4E /* MP42SubtitleTrack.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
A9B9C2981823923200416A4E /* MP42SubtitleTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C24D1823923100416A4E /* MP42SubtitleTrack.m */; };
|
||||
A9B9C2991823923200416A4E /* MP42SubUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C24E1823923100416A4E /* MP42SubUtilities.h */; };
|
||||
@@ -195,7 +195,7 @@
|
||||
A9B9C29F1823923200416A4E /* MP42VideoTrack.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2541823923100416A4E /* MP42VideoTrack.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
A9B9C2A01823923200416A4E /* MP42VideoTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2551823923100416A4E /* MP42VideoTrack.m */; };
|
||||
A9B9C2A11823923200416A4E /* MP42VobSubImporter.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2561823923200416A4E /* MP42VobSubImporter.h */; };
|
||||
A9B9C2A21823923200416A4E /* MP42VobSubImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2571823923200416A4E /* MP42VobSubImporter.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
A9B9C2A21823923200416A4E /* MP42VobSubImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2571823923200416A4E /* MP42VobSubImporter.m */; };
|
||||
A9B9C2A31823923200416A4E /* MP42XMLReader.h in Headers */ = {isa = PBXBuildFile; fileRef = A9B9C2581823923200416A4E /* MP42XMLReader.h */; };
|
||||
A9B9C2A41823923200416A4E /* MP42XMLReader.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C2591823923200416A4E /* MP42XMLReader.m */; };
|
||||
A9B9C2A71823923200416A4E /* MatroskaFile.c in Sources */ = {isa = PBXBuildFile; fileRef = A9B9C25D1823923200416A4E /* MatroskaFile.c */; };
|
||||
|
||||
Reference in new issue
Block a user