diff --git a/MP42/MP42AACImporter.mm b/MP42/MP42AACImporter.mm index 5e6ad2a..0538b39 100644 --- a/MP42/MP42AACImporter.mm +++ b/MP42/MP42AACImporter.mm @@ -864,8 +864,7 @@ static bool GetFirstHeader(FILE* inFile) sample->size = sampleSize; sample->duration = MP4_INVALID_DURATION; sample->offset = 0; - sample->timestamp = 0; - sample->isSync = 1; + sample->flags |= MP42SampleBufferFlagIsSync; sample->trackId = trackId; [self enqueue:sample]; diff --git a/MP42/MP42AC3Importer.m b/MP42/MP42AC3Importer.m index 558df60..f4e75a7 100644 --- a/MP42/MP42AC3Importer.m +++ b/MP42/MP42AC3Importer.m @@ -374,8 +374,7 @@ static bool GetFirstHeader(FILE* inFile) sample->size = sampleSize; sample->duration = MP4_INVALID_DURATION; sample->offset = 0; - sample->timestamp = 0; - sample->isSync = 1; + sample->flags |= MP42SampleBufferFlagIsSync; sample->trackId = trackId; [self enqueue:sample]; diff --git a/MP42/MP42AVFImporter.m b/MP42/MP42AVFImporter.m index b1b4353..35eb320 100644 --- a/MP42/MP42AVFImporter.m +++ b/MP42/MP42AVFImporter.m @@ -418,14 +418,14 @@ @"Encoding Tool", AVMetadataCommonKeySoftware, nil]; - _metadata = [[MP42Metadata alloc] init]; + self.metadata = [[[MP42Metadata alloc] init] autorelease]; for (NSString *commonKey in commonItemsDict.allKeys) { NSArray *items = [AVMetadataItem metadataItemsFromArray:_localAsset.commonMetadata withKey:commonKey keySpace:AVMetadataKeySpaceCommon]; if (items.count) { - [_metadata setTag:items.lastObject.value forKey:commonItemsDict[commonKey]]; + [self.metadata setTag:items.lastObject.value forKey:commonItemsDict[commonKey]]; } } @@ -439,7 +439,7 @@ if ([artworkData isKindOfClass:[NSData class]]) { NSImage *image = [[NSImage alloc] initWithData:artworkData]; - [_metadata.artworks addObject:[[[MP42Image alloc] initWithImage:image] autorelease]]; + [self.metadata.artworks addObject:[[[MP42Image alloc] initWithImage:image] autorelease]]; [image release]; } } @@ -523,7 +523,7 @@ for (NSString *itunesKey in itunesMetadataDict.allKeys) { items = [AVMetadataItem metadataItemsFromArray:itunesMetadata withKey:itunesKey keySpace:AVMetadataKeySpaceiTunes]; if (items.count) { - [_metadata setTag:items.lastObject.value forKey:itunesMetadataDict[itunesKey]]; + [self.metadata setTag:items.lastObject.value forKey:itunesMetadataDict[itunesKey]]; } } @@ -569,7 +569,7 @@ for (NSString *qtKey in quicktimeMetadataDict.allKeys) { items = [AVMetadataItem metadataItemsFromArray:quicktimeMetadata withKey:qtKey keySpace:AVMetadataKeySpaceQuickTimeUserData]; if (items.count) { - [_metadata setTag:items.lastObject.value forKey:quicktimeMetadataDict[qtKey]]; + [self.metadata setTag:items.lastObject.value forKey:quicktimeMetadataDict[qtKey]]; } } } @@ -602,7 +602,7 @@ for (NSString *qtUserDataKey in quicktimeUserDataMetadataDict.allKeys) { items = [AVMetadataItem metadataItemsFromArray:quicktimeUserDataMetadata withKey:qtUserDataKey keySpace:AVMetadataKeySpaceQuickTimeUserData]; if (items.count) { - [_metadata setTag:items.lastObject.value forKey:quicktimeUserDataMetadataDict[qtUserDataKey]]; + [self.metadata setTag:items.lastObject.value forKey:quicktimeUserDataMetadataDict[qtUserDataKey]]; } } } @@ -862,10 +862,10 @@ sample->presentationTimestamp = presentationTimeStamp.value; sample->presentationOutputTimestamp = currentOutputTimeStamp.value; sample->timescale = duration.timescale; - sample->isSync = sync; + sample->flags |= sync ? MP42SampleBufferFlagIsSync : 0; + sample->flags |= doNotDisplay ? MP42SampleBufferFlagDoNotDisplay : 0; sample->trackId = track.sourceId; sample->attachments = (void *)attachments; - sample->doNotDisplay = doNotDisplay; if (sample->offset < demuxHelper->minDisplayOffset) { demuxHelper->minDisplayOffset = sample->offset; @@ -995,9 +995,9 @@ sample->presentationTimestamp = presentationTimeStamp.value; sample->presentationOutputTimestamp = presentationTimeStamp.value; sample->timescale = sampleTimingInfo.duration.timescale; - sample->isSync = sync; + sample->flags |= sync ? MP42SampleBufferFlagIsSync : 0; + sample->flags |= doNotDisplay ? MP42SampleBufferFlagDoNotDisplay : 0; sample->trackId = track.sourceId; - sample->doNotDisplay = doNotDisplay; if (attachmentsSent == NO) { sample->attachments = (void *)attachments; diff --git a/MP42/MP42AudioDecoder.m b/MP42/MP42AudioDecoder.m index 3e6e133..5eaa873 100644 --- a/MP42/MP42AudioDecoder.m +++ b/MP42/MP42AudioDecoder.m @@ -255,7 +255,7 @@ static AVPacket * packetFromSampleBuffer(MP42SampleBuffer *sample) AVPacket *pkt = av_packet_alloc(); pkt->data = sample->data; pkt->size = sample->size; - pkt->pts = sample->timestamp; + pkt->pts = sample->decodeTimestamp; pkt->dts = AV_NOPTS_VALUE; return pkt; diff --git a/MP42/MP42AudioEncoder.m b/MP42/MP42AudioEncoder.m index 044bed6..cd5cabe 100644 --- a/MP42/MP42AudioEncoder.m +++ b/MP42/MP42AudioEncoder.m @@ -403,8 +403,10 @@ static MP42SampleBuffer *encode(AudioConverterRef encoder, AudioFileIO *afio) sample->size = fillBufList.mBuffers[0].mDataByteSize; sample->duration = 1024; - sample->timestamp = afio->outputPos * 1024; - sample->isSync = YES; + sample->decodeTimestamp = afio->outputPos * 1024; + sample->presentationTimestamp = sample->decodeTimestamp; + sample->presentationOutputTimestamp = sample->decodeTimestamp; + sample->flags |= MP42SampleBufferFlagIsSync; afio->outputPos += ioOutputDataPackets; diff --git a/MP42/MP42CCImporter.m b/MP42/MP42CCImporter.m index 8e4d4b4..bf15c01 100644 --- a/MP42/MP42CCImporter.m +++ b/MP42/MP42CCImporter.m @@ -194,8 +194,8 @@ static int ParseByte(const char *string, UInt8 *byte, Boolean hex) sample->size = 8; sample->duration = ccSample.timestamp *= 1001; sample->offset = 0; - sample->timestamp = 0; - sample->isSync = 1; + sample->decodeTimestamp = 0; + sample->flags |= MP42SampleBufferFlagIsSync; sample->trackId = trackId; [self enqueue:sample]; @@ -228,8 +228,8 @@ static int ParseByte(const char *string, UInt8 *byte, Boolean hex) sample->size = byteCount + 8; sample->duration = sampleDuration * 1001; sample->offset = 0; - sample->timestamp = 0; - sample->isSync = 1; + sample->decodeTimestamp = 0; + sample->flags |= MP42SampleBufferFlagIsSync; sample->trackId = trackId; [self enqueue:sample]; diff --git a/MP42/MP42EditListsReconstructor.m b/MP42/MP42EditListsReconstructor.m index c0f262c..555d9c3 100644 --- a/MP42/MP42EditListsReconstructor.m +++ b/MP42/MP42EditListsReconstructor.m @@ -132,7 +132,7 @@ [self endEditListAtTime:editEnd empty:YES]; } - BOOL shouldStartNewEdit = trimStart || (sample->doNotDisplay == NO && _editOpen == NO); + BOOL shouldStartNewEdit = trimStart || ((sample->flags & MP42SampleBufferFlagDoNotDisplay) == NO && _editOpen == NO); if (shouldStartNewEdit) { // Close the current edit list @@ -166,7 +166,7 @@ _currentTime += sample->duration; - BOOL shouldEndEdit = trimEnd || (sample->doNotDisplay == YES && _editOpen == YES); + BOOL shouldEndEdit = trimEnd || ((sample->flags & MP42SampleBufferFlagDoNotDisplay) == YES && _editOpen == YES); if (shouldEndEdit) { CMTime editEnd = CMTimeMake(_currentTime, _timescale); diff --git a/MP42/MP42FileImporter+Private.h b/MP42/MP42FileImporter+Private.h index c243f02..a35dbb2 100644 --- a/MP42/MP42FileImporter+Private.h +++ b/MP42/MP42FileImporter+Private.h @@ -13,10 +13,14 @@ NS_ASSUME_NONNULL_BEGIN +@class MP42SampleBuffer; + @interface MP42FileImporter (Private) - (instancetype)initWithURL:(NSURL *)fileURL; +@property(nonatomic, readwrite) MP42Metadata *metadata; + - (void)addTrack:(MP42Track *)track; - (void)addTracks:(NSArray *)tracks; diff --git a/MP42/MP42FileImporter.h b/MP42/MP42FileImporter.h index 1c30b33..4c206a9 100644 --- a/MP42/MP42FileImporter.h +++ b/MP42/MP42FileImporter.h @@ -10,15 +10,11 @@ NS_ASSUME_NONNULL_BEGIN -@class MP42SampleBuffer; @class MP42Metadata; @class MP42Track; @interface MP42FileImporter : NSObject { @protected - NSInteger _chapterId; - MP42Metadata *_metadata; - double _progress; int32_t _cancelled; } diff --git a/MP42/MP42FileImporter.m b/MP42/MP42FileImporter.m index 0f8f69c..84a3987 100644 --- a/MP42/MP42FileImporter.m +++ b/MP42/MP42FileImporter.m @@ -122,7 +122,7 @@ static NSArray *_supportedFileFormats; [track.muxer_helper->converter release]; } - [_metadata release], _metadata = nil; + [_metadata release]; [_tracksArray release], _tracksArray = nil; [_inputTracks release], _inputTracks = nil; [_outputsTracks release], _outputsTracks = nil; @@ -162,7 +162,11 @@ static NSArray *_supportedFileFormats; return [[_outputsTracks copy] autorelease]; } -@synthesize metadata = _metadata; +- (void)setMetadata:(MP42Metadata * _Nonnull)metadata +{ + _metadata = [metadata retain]; +} + @synthesize tracks = _tracksArray; - (NSUInteger)timescaleForTrack:(MP42Track *)track diff --git a/MP42/MP42H264Importer.mm b/MP42/MP42H264Importer.mm index b470a6a..f81c4f9 100644 --- a/MP42/MP42H264Importer.mm +++ b/MP42/MP42H264Importer.mm @@ -1499,9 +1499,7 @@ NSData* H264Info(const char *filePath, uint32_t *pic_width, uint32_t *pic_height sample->data = sampleData; sample->size = nal_buffer_size; sample->duration = mp4FrameDuration; - sample->offset = 0; - sample->timestamp = 0; - sample->isSync = nal_is_sync; + sample->flags = nal_is_sync ? MP42SampleBufferFlagIsSync : 0; sample->trackId = trackId; [self enqueue:sample]; @@ -1588,9 +1586,7 @@ NSData* H264Info(const char *filePath, uint32_t *pic_width, uint32_t *pic_height sample->data = sampleData; sample->size = nal_buffer_size; sample->duration = mp4FrameDuration; - sample->offset = 0; - sample->timestamp = 0; - sample->isSync = nal_is_sync; + sample->flags = nal_is_sync ? MP42SampleBufferFlagIsSync : 0; sample->trackId = trackId; [self enqueue:sample]; diff --git a/MP42/MP42MkvImporter.m b/MP42/MP42MkvImporter.m index dd2a80e..08c55d6 100644 --- a/MP42/MP42MkvImporter.m +++ b/MP42/MP42MkvImporter.m @@ -298,7 +298,7 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t free(trackSizes); - _metadata = [[self readMatroskaMetadata] retain]; + self.metadata = [self readMatroskaMetadata]; } return self; @@ -677,15 +677,15 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t sample->size = FrameSize; sample->duration = MP4_INVALID_DURATION; sample->offset = 0; - sample->timestamp = StartTime; - sample->isSync = YES; + sample->decodeTimestamp = StartTime; + sample->flags |= MP42SampleBufferFlagIsSync; sample->trackId = track.sourceId; #define VARIABLE_AUDIO_RATE 1 #ifdef VARIABLE_AUDIO_RATE if (demuxHelper->previousSample) { - uint64_t sampleDuration = (sample->timestamp * (double)mkv_TruncFloat(trackInfo->AV.Audio.SamplingFreq) / 1000000000.f) - demuxHelper->currentTime; + uint64_t sampleDuration = (sample->decodeTimestamp * (double)mkv_TruncFloat(trackInfo->AV.Audio.SamplingFreq) / 1000000000.f) - demuxHelper->currentTime; // MKV timestamps are a bit random, try to round them // to make the sample table in the mp4 smaller. @@ -710,7 +710,7 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t demuxHelper->currentTime += sampleDuration; } else { - demuxHelper->currentTime = sample->timestamp * (double)mkv_TruncFloat(trackInfo->AV.Audio.SamplingFreq) / 1000000000.f; + demuxHelper->currentTime = sample->decodeTimestamp * (double)mkv_TruncFloat(trackInfo->AV.Audio.SamplingFreq) / 1000000000.f; } [demuxHelper->previousSample release]; @@ -748,10 +748,10 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t nextSample->duration = 0; nextSample->offset = 0; - nextSample->timestamp = StartTime; + nextSample->decodeTimestamp = StartTime; nextSample->data = frame; nextSample->size = FrameSize; - nextSample->isSync = YES; + nextSample->flags |= MP42SampleBufferFlagIsSync; nextSample->trackId = track.sourceId; // PGS are usually stored with just the start time, and blank samples to fill the gaps @@ -760,18 +760,18 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t demuxHelper->previousSample = [[MP42SampleBuffer alloc] init]; demuxHelper->previousSample->duration = StartTime / SCALE_FACTOR; demuxHelper->previousSample->offset = 0; - demuxHelper->previousSample->timestamp = StartTime; - demuxHelper->previousSample->isSync = YES; + demuxHelper->previousSample->decodeTimestamp = StartTime; + demuxHelper->previousSample->flags |= MP42SampleBufferFlagIsSync; demuxHelper->previousSample->trackId = track.sourceId; } else { - if (nextSample->timestamp < demuxHelper->previousSample->timestamp) { + if (nextSample->decodeTimestamp < demuxHelper->previousSample->decodeTimestamp) { // Out of order samples? swap the next with the previous MP42SampleBuffer *temp = nextSample; nextSample = demuxHelper->previousSample; demuxHelper->previousSample = temp; } - demuxHelper->previousSample->duration = (nextSample->timestamp - demuxHelper->previousSample->timestamp) / SCALE_FACTOR; + demuxHelper->previousSample->duration = (nextSample->decodeTimestamp - demuxHelper->previousSample->decodeTimestamp) / SCALE_FACTOR; } [self enqueue:demuxHelper->previousSample]; @@ -786,7 +786,7 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t sample->duration = (StartTime - demuxHelper->currentTime) / SCALE_FACTOR; sample->size = 2; sample->data = calloc(1, 2); - sample->isSync = YES; + sample->flags |= MP42SampleBufferFlagIsSync; sample->trackId = track.sourceId; [self enqueue:sample]; @@ -845,8 +845,8 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t sample->size = currentSample->frameSize; sample->duration = duration / 10000.0f; sample->offset = offset / 10000.0f; - sample->timestamp = StartTime; - sample->isSync = currentSample->frameFlags & FRAME_KF; + sample->decodeTimestamp = StartTime; + sample->flags |= (currentSample->frameFlags & FRAME_KF) ? MP42SampleBufferFlagIsSync : 0; sample->trackId = track.sourceId; demuxHelper->samplesWritten++; @@ -919,8 +919,8 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t sample->size = currentSample->frameSize; sample->duration = duration / 10000.0f; sample->offset = offset / 10000.0f; - sample->timestamp = StartTime; - sample->isSync = currentSample->frameFlags & FRAME_KF; + sample->decodeTimestamp = StartTime; + sample->flags |= (currentSample->frameFlags & FRAME_KF) ? MP42SampleBufferFlagIsSync : 0; sample->trackId = track.sourceId; demuxHelper->samplesWritten++; @@ -970,7 +970,7 @@ int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, uint64_t } demuxHelper->currentTime += sample->duration; - sample->timestamp = demuxHelper->currentTime; + sample->decodeTimestamp = demuxHelper->currentTime; [self enqueue:sample]; [sample release]; diff --git a/MP42/MP42Mp4Importer.m b/MP42/MP42Mp4Importer.m index 68026e0..eeea18e 100644 --- a/MP42/MP42Mp4Importer.m +++ b/MP42/MP42Mp4Importer.m @@ -51,7 +51,7 @@ } [self addTracks:sourceFile.tracks]; - _metadata = [sourceFile.metadata retain]; + self.metadata = sourceFile.metadata; [sourceFile release]; } @@ -326,8 +326,8 @@ sample->size = numBytes; sample->duration = duration; sample->offset = renderingOffset; - sample->timestamp = pStartTime; - sample->isSync = isSyncSample; + sample->decodeTimestamp = pStartTime; + sample->flags |= isSyncSample ? MP42SampleBufferFlagIsSync : 0; sample->trackId = track.sourceId; [self enqueue:sample]; diff --git a/MP42/MP42Muxer.m b/MP42/MP42Muxer.m index dffbb9b..bb859b5 100644 --- a/MP42/MP42Muxer.m +++ b/MP42/MP42Muxer.m @@ -503,6 +503,7 @@ // Iterate the tracks array and mux the samples for (MP42Track *track in _workingTracks) { MP42SampleBuffer *sampleBuffer = nil; + MP42TrackId trackId = track.trackId; for (int i = 0; i < 100 && (sampleBuffer = [track copyNextSample]) != nil; i++) { @@ -511,10 +512,10 @@ track.muxer_helper->done = 1; } - else if (!MP4WriteSample(_fileHandle, track.trackId, + else if (!MP4WriteSample(_fileHandle, trackId, sampleBuffer->data, sampleBuffer->size, sampleBuffer->duration, sampleBuffer->offset, - sampleBuffer->isSync)) { + sampleBuffer->flags & MP42SampleBufferFlagIsSync)) { _cancelled = YES; } diff --git a/MP42/MP42Sample.h b/MP42/MP42Sample.h index 401bfe5..59763f5 100644 --- a/MP42/MP42Sample.h +++ b/MP42/MP42Sample.h @@ -9,7 +9,10 @@ #import typedef NS_OPTIONS(NSUInteger, MP42SampleBufferFlag) { - MP42SampleBufferFlagEndOfFile = 1 << 0, + MP42SampleBufferFlagEndOfFile = 1 << 0, + MP42SampleBufferFlagIsSync = 1 << 1, + MP42SampleBufferFlagIsForced = 1 << 2, + MP42SampleBufferFlagDoNotDisplay = 1 << 3 }; @interface MP42SampleBuffer : NSObject { @@ -23,16 +26,12 @@ typedef NS_OPTIONS(NSUInteger, MP42SampleBufferFlag) { int64_t presentationTimestamp; int64_t presentationOutputTimestamp; - uint64_t timestamp; + uint64_t decodeTimestamp; uint32_t trackId; - BOOL isSync; - BOOL isForced; - BOOL doNotDisplay; - - void *attachments; uint16_t flags; + void *attachments; } @end diff --git a/MP42/MP42SubUtilities.m b/MP42/MP42SubUtilities.m index 59903d3..24d95f3 100644 --- a/MP42/MP42SubUtilities.m +++ b/MP42/MP42SubUtilities.m @@ -1063,8 +1063,8 @@ MP42SampleBuffer * copySubtitleSample(MP4TrackId subtitleTrackId, NSString *stri sample->size = sampleSize; sample->duration = duration; sample->offset = 0; - sample->timestamp = duration; - sample->isSync = true; + sample->decodeTimestamp = duration; + sample->flags |= MP42SampleBufferFlagIsSync; sample->trackId = subtitleTrackId; return sample; @@ -1083,8 +1083,8 @@ MP42SampleBuffer* copyEmptySubtitleSample(MP4TrackId subtitleTrackId, MP4Duratio sample->size = 2; sample->duration = duration; sample->offset = 0; - sample->timestamp = duration; - sample->isSync = true; + sample->decodeTimestamp = duration; + sample->flags |= MP42SampleBufferFlagIsSync; sample->trackId = subtitleTrackId; return sample; diff --git a/MP42/MP42SubtitleTrack.m b/MP42/MP42SubtitleTrack.m index 7dbba09..822098f 100644 --- a/MP42/MP42SubtitleTrack.m +++ b/MP42/MP42SubtitleTrack.m @@ -31,9 +31,13 @@ _mediaType = MP42MediaTypeSubtitle; if (![_format isEqualToString:MP42SubtitleFormatVobSub]) { + uint64_t width, height; - MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.tx3g.defTextBoxBottom", &height); MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.tx3g.defTextBoxRight", &width); + MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.tx3g.defTextBoxBottom", &height); + + self.width = width; + self.height = height; uint64_t displayFlags = 0; MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.tx3g.displayFlags", &displayFlags); @@ -104,9 +108,13 @@ } if (_isEdited && !_muxed) { + float trackWidth, trackHeight; MP4GetTrackFloatProperty(fileHandle, _trackId, "tkhd.width", &trackWidth); MP4GetTrackFloatProperty(fileHandle, _trackId, "tkhd.height", &trackHeight); + self.trackWidth = trackWidth; + self.trackHeight = trackHeight; + uint8_t *val; uint8_t nval[36]; uint32_t *ptr32 = (uint32_t*) nval; @@ -114,8 +122,8 @@ MP4GetTrackBytesProperty(fileHandle ,_trackId, "tkhd.matrix", &val, &size); memcpy(nval, val, size); - offsetX = CFSwapInt32BigToHost(ptr32[6]) / 0x10000; - offsetY = CFSwapInt32BigToHost(ptr32[7]) / 0x10000; + self.offsetX = CFSwapInt32BigToHost(ptr32[6]) / 0x10000; + self.offsetY = CFSwapInt32BigToHost(ptr32[7]) / 0x10000; free(val); [super writeToFile:fileHandle error:outError]; @@ -127,8 +135,8 @@ } if (![_format isEqualToString:MP42SubtitleFormatVobSub]) { - MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.tx3g.defTextBoxBottom", trackHeight); - MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.tx3g.defTextBoxRight", trackWidth); + MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.tx3g.defTextBoxBottom", self.trackHeight); + MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.tx3g.defTextBoxRight", self.trackWidth); uint32_t displayFlags = 0; if (_verticalPlacement) diff --git a/MP42/MP42Track.h b/MP42/MP42Track.h index a765c1a..abe15d6 100644 --- a/MP42/MP42Track.h +++ b/MP42/MP42Track.h @@ -17,7 +17,6 @@ NS_ASSUME_NONNULL_BEGIN @interface MP42Track : NSObject { @protected MP42TrackId _trackId; - MP42TrackId _sourceId; NSURL *_sourceURL; NSString *_format; @@ -34,19 +33,10 @@ NS_ASSUME_NONNULL_BEGIN BOOL _muxed; BOOL _needConversion; - uint64_t _size; uint32_t _timescale; - uint32_t _bitrate; MP42Duration _duration; NSMutableDictionary *_updatedProperty; - - @private - NSSet *_mediaCharacteristicTags; - - uint64_t _alternate_group; - int64_t _startOffset; - void *_helper; } diff --git a/MP42/MP42Track.m b/MP42/MP42Track.m index 2732946..b29dc2d 100644 --- a/MP42/MP42Track.m +++ b/MP42/MP42Track.m @@ -17,6 +17,17 @@ #import "MP42Track+Muxer.h" @implementation MP42Track +{ + MP42TrackId _sourceId; + + uint64_t _size; + uint32_t _bitrate; + + NSSet *_mediaCharacteristicTags; + + uint64_t _alternate_group; + int64_t _startOffset; +} - (instancetype)init { diff --git a/MP42/MP42VideoTrack.h b/MP42/MP42VideoTrack.h index f2c7b13..ea75bcb 100644 --- a/MP42/MP42VideoTrack.h +++ b/MP42/MP42VideoTrack.h @@ -9,27 +9,7 @@ #import #import "MP42Track.h" -@interface MP42VideoTrack : MP42Track { -@protected - uint64_t width, height; - float trackWidth, trackHeight; - - // Pixel Aspect Ratio - uint64_t hSpacing, vSpacing; - - // Clean Aperture - uint64_t cleanApertureWidthN, cleanApertureWidthD; - uint64_t cleanApertureHeightN, cleanApertureHeightD; - uint64_t horizOffN, horizOffD; - uint64_t vertOffN, vertOffD; - - // Matrix - uint32_t offsetX, offsetY; - - // H.264 profile - uint8_t _origProfile, _origLevel; - uint8_t _newProfile, _newLevel; -} +@interface MP42VideoTrack : MP42Track @property(nonatomic, readwrite) uint64_t width; @property(nonatomic, readwrite) uint64_t height; diff --git a/MP42/MP42VideoTrack.m b/MP42/MP42VideoTrack.m index cdaa778..44610c5 100644 --- a/MP42/MP42VideoTrack.m +++ b/MP42/MP42VideoTrack.m @@ -13,6 +13,27 @@ #import @implementation MP42VideoTrack +{ + uint64_t width, height; + float trackWidth, trackHeight; + + // Pixel Aspect Ratio + uint64_t hSpacing, vSpacing; + + // Clean Aperture + uint64_t cleanApertureWidthN, cleanApertureWidthD; + uint64_t cleanApertureHeightN, cleanApertureHeightD; + uint64_t horizOffN, horizOffD; + uint64_t vertOffN, vertOffD; + + // Matrix + uint32_t offsetX, offsetY; + + // H.264 profile + uint8_t _origProfile, _origLevel; + uint8_t _newProfile, _newLevel; + +} - (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP42FileHandle)fileHandle { @@ -93,7 +114,6 @@ if (trackWidth > 0 && trackHeight > 0) { MP4SetTrackFloatProperty(fileHandle, _trackId, "tkhd.width", trackWidth); - MP4SetTrackFloatProperty(fileHandle, _trackId, "tkhd.height", trackHeight); uint8_t *val; diff --git a/MP42/MP42VobSubImporter.m b/MP42/MP42VobSubImporter.m index 3f12c4a..6a27f3b 100644 --- a/MP42/MP42VobSubImporter.m +++ b/MP42/MP42VobSubImporter.m @@ -364,8 +364,10 @@ static NSArray * LoadVobSubSubtitles(NSURL *theDirectory, NSStr sample->data = calloc(1, 2); sample->duration = startTime - lastTime; sample->offset = 0; - sample->timestamp = startTime; - sample->isSync = YES; + sample->presentationTimestamp = startTime; + sample->presentationOutputTimestamp = startTime; + sample->decodeTimestamp = startTime; + sample->flags |= MP42SampleBufferFlagIsSync; sample->trackId = track.sourceId; [self enqueue:sample]; @@ -377,8 +379,10 @@ static NSArray * LoadVobSubSubtitles(NSURL *theDirectory, NSStr sample->size = size; sample->duration = duration; sample->offset = 0; - sample->timestamp = startTime; - sample->isSync = YES; + sample->presentationTimestamp = startTime; + sample->presentationOutputTimestamp = startTime; + sample->decodeTimestamp = startTime; + sample->flags |= MP42SampleBufferFlagIsSync; sample->trackId = track.sourceId; [self enqueue:sample];