Clean up MP42Track a bit.

This commit is contained in:
Damiano Galassi committed 2016-09-13 12:05:40 +02:00
1 parent fe908428f4
commit 1d100a1db0
20 files changed
+190 -137

No files matched your search

+1
View File
@@ -13,6 +13,7 @@
#import "MP42File.h"
#import "MP42PrivateUtilities.h"
#import "MP42Sample.h"
#import "MP42Track+Private.h"
@implementation MP42AACImporter {
@private
+1
View File
@@ -15,6 +15,7 @@
#import "MP42FormatUtilites.h"
#import "MP42Fifo.h"
#import "MP42Sample.h"
#import "MP42Track+Private.h"
#include <sys/stat.h>
+6 -6
View File
@@ -150,11 +150,11 @@
[super writeToFile:fileHandle error:outError];
}
if (_updatedProperty[@"volume"] || !_muxed) {
if (self.updatedProperty[@"volume"] || !_muxed) {
MP4SetTrackFloatProperty(fileHandle, _trackId, "tkhd.volume", _volume);
}
if (_updatedProperty[@"fallback"] || !_muxed) {
if (self.updatedProperty[@"fallback"] || !_muxed) {
if (_fallbackTrack) {
_fallbackTrackId = _fallbackTrack.trackId;
@@ -171,7 +171,7 @@
}
}
if (_updatedProperty[@"follows"] || !_muxed) {
if (self.updatedProperty[@"follows"] || !_muxed) {
if (_followsTrack) {
_followsTrackId = _followsTrack.trackId;
@@ -195,7 +195,7 @@
{
_volume = newVolume;
_isEdited = YES;
_updatedProperty[@"volume"] = @YES;
self.updatedProperty[@"volume"] = @YES;
}
- (float)volume
@@ -208,7 +208,7 @@
_fallbackTrack = newFallbackTrack;
_fallbackTrackId = 0;
_isEdited = YES;
_updatedProperty[@"fallback"] = @YES;
self.updatedProperty[@"fallback"] = @YES;
}
- (MP42Track *)fallbackTrack
@@ -221,7 +221,7 @@
_followsTrack = newFollowsTrack;
_followsTrackId = 0;
_isEdited = YES;
_updatedProperty[@"follows"] = @YES;
self.updatedProperty[@"follows"] = @YES;
}
- (MP42Track *)followsTrack
+1 -1
View File
@@ -14,7 +14,7 @@
#import "MP42File.h"
#import "MP42Sample.h"
#import "NSString+MP42Additions.h"
#import "MP42Track+Private.h"
@implementation MP42CCImporter
+2 -2
View File
@@ -16,9 +16,9 @@ NS_ASSUME_NONNULL_BEGIN
+ (instancetype)subtitlesConversion;
@property (nonatomic, readonly) FourCharCode format;
@property (nonatomic, readonly) NSUInteger bitRate;
@property (nonatomic, readonly) NSUInteger bitRate;
@property (nonatomic, readonly) NSString *mixDown;
@property (nonatomic, readonly) NSString *mixDown;
@property (nonatomic, readonly) float drc;
@end
+1 -1
View File
@@ -56,7 +56,7 @@ typedef void (^MP42FileProgressHandler)(double progress);
@property(nonatomic, readonly) NSUInteger duration;
/**
* Indicates the size of the file. It can be approximated.
* Indicates the size of the file. It can be an approximation.
*/
@property(nonatomic, readonly) uint64_t dataSize;
+7 -9
View File
@@ -427,14 +427,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
}
}
// FIXME
if (trackNeedConversion(track.format) || track.conversionSettings) {
/*if ([track isMemberOfClass:[MP42AudioTrack class]]) {
track.format = kMP42AudioCodecType_MPEG4AAC;
} else if ([track isMemberOfClass:[MP42SubtitleTrack class]]) {
track.format = kMP42SubtitleCodecType_3GText;
}*/
if (trackNeedConversion(track.format)) {
NSAssert(track.conversionSettings, @"Missing conversion settings");
}
if (track.muxer_helper->importer && track.sourceURL) {
@@ -452,6 +446,10 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
}
}
if ([track isMemberOfClass:[MP42ChapterTrack class]]) {
track.duration = self.duration;
}
[self.itracks addObject:track];
}
@@ -1097,7 +1095,7 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
}
- (void)encodeWithCoder:(NSCoder *)coder {
[coder encodeInt:3 forKey:@"MP42FileVersion"];
[coder encodeInt:4 forKey:@"MP42FileVersion"];
#ifdef SB_SANDBOX
if ([fileURL respondsToSelector:@selector(startAccessingSecurityScopedResource)]) {
+1
View File
@@ -22,6 +22,7 @@
#import "MP42AudioConverter.h"
#import "MP42Track+Muxer.h"
#import "MP42Track+Private.h"
#import <CoreAudio/CoreAudio.h>
+1
View File
@@ -12,6 +12,7 @@
#import "MP42Languages.h"
#import "MP42File.h"
#import "MP42Track+Muxer.h"
#import "MP42Track+Private.h"
#include <sys/stat.h>
+1
View File
@@ -20,6 +20,7 @@
#import "MP42PrivateUtilities.h"
#import "MP42FormatUtilites.h"
#import "MP42Track+Muxer.h"
#import "MP42Track+Private.h"
#define SCALE_FACTOR 1000000.f
+1
View File
@@ -16,6 +16,7 @@
#import "mp4v2.h"
#import "MP42PrivateUtilities.h"
#import "MP42Track+Muxer.h"
#import "MP42Track+Private.h"
@interface MP4DemuxHelper : NSObject {
@public
+1
View File
@@ -20,6 +20,7 @@
#import "MP42FormatUtilites.h"
#import "MP42PrivateUtilities.h"
#import "MP42Track+Muxer.h"
#import "MP42Track+Private.h"
@implementation MP42Muxer
{
+1
View File
@@ -16,6 +16,7 @@
#import "mp4v2.h"
#import "MP42PrivateUtilities.h"
#import "MP42Track+Muxer.h"
#import "MP42Track+Private.h"
@implementation MP42SrtImporter {
@private
+22 -5
View File
@@ -89,7 +89,7 @@
}
}
if (_updatedProperty[@"forced"] || !_muxed) {
if (self.updatedProperty[@"forced"] || !_muxed) {
if (_forcedTrack) {
_forcedTrackId = _forcedTrack.trackId;
@@ -162,7 +162,7 @@
_someSamplesAreForced = value;
_isEdited = YES;
_updatedProperty[@"forcedSubtitles"] = @YES;
self.updatedProperty[@"forcedSubtitles"] = @YES;
}
- (BOOL)allSamplesAreForced {
@@ -174,7 +174,7 @@
_allSamplesAreForced = value;
_isEdited = YES;
_updatedProperty[@"forcedSubtitles"] = @YES;
self.updatedProperty[@"forcedSubtitles"] = @YES;
}
@synthesize forcedTrackId = _forcedTrackId;
@@ -416,7 +416,7 @@ static void insertTagsFromStyleRecord(style_record record, NSMutableString *samp
_forcedTrack = newForcedTrack;
_forcedTrackId = 0;
_isEdited = YES;
_updatedProperty[@"forced"] = @YES;
self.updatedProperty[@"forced"] = @YES;
}
- (MP42Track *)forcedTrack
@@ -424,6 +424,23 @@ static void insertTagsFromStyleRecord(style_record record, NSMutableString *samp
return _forcedTrack;
}
#pragma mark - NSCopying
- (instancetype)copyWithZone:(NSZone *)zone
{
MP42SubtitleTrack *copy = [super copyWithZone:zone];
if (copy) {
copy->_verticalPlacement = _verticalPlacement;
copy->_someSamplesAreForced = _someSamplesAreForced;
copy->_allSamplesAreForced = _allSamplesAreForced;
copy->_forcedTrackId = _forcedTrackId;
}
return copy;
}
#pragma mark - NSSecureCoding
- (void)encodeWithCoder:(NSCoder *)coder
@@ -447,7 +464,7 @@ static void insertTagsFromStyleRecord(style_record record, NSMutableString *samp
_someSamplesAreForced = [decoder decodeBoolForKey:@"someSamplesAreForced"];
_allSamplesAreForced = [decoder decodeBoolForKey:@"allSamplesAreForced"];
_forcedTrackId = (MP4TrackId)[decoder decodeInt64ForKey:@"forcedTrackId"];
_forcedTrackId = [decoder decodeInt64ForKey:@"forcedTrackId"];
return self;
}
+12
View File
@@ -14,6 +14,18 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP42FileHandle)fileHandle;
- (BOOL)writeToFile:(MP42FileHandle)fileHandle error:(NSError **)outError;
@property(nonatomic, readwrite) MP42TrackId trackId;
@property(nonatomic, readwrite) MP42TrackId sourceId;
@property(nonatomic, readwrite, copy) NSURL *sourceURL;
@property(nonatomic, readwrite) FourCharCode format;
@property(nonatomic, readwrite) MP42Duration duration;
@property(nonatomic, readwrite) BOOL muxed;
@property(nonatomic, readonly) NSMutableDictionary<NSString *, NSNumber *> *updatedProperty;
@end
NS_ASSUME_NONNULL_END
+15 -17
View File
@@ -19,45 +19,43 @@ NS_ASSUME_NONNULL_BEGIN
@protected
MP42TrackId _trackId;
NSURL *_sourceURL;
NSURL *_sourceURL;
FourCharCode _format;
MP42MediaType _mediaType;
NSString *_language;
NSString *_extendedLanguageTag;
NSString *_language;
NSString *_extendedLanguageTag;
BOOL _enabled;
BOOL _enabled;
BOOL _isEdited;
BOOL _muxed;
BOOL _isEdited;
BOOL _muxed;
NSMutableDictionary<NSString *, NSNumber *> *_updatedProperty;
void *_helper;
}
@property(nonatomic, readwrite) MP42TrackId trackId;
@property(nonatomic, readwrite) MP42TrackId sourceId;
@property(nonatomic, readonly) MP42TrackId trackId;
@property(nonatomic, readwrite, copy) NSURL *sourceURL;
@property(nonatomic, readwrite) FourCharCode format;
@property(nonatomic, readonly, copy) NSURL *sourceURL;
@property(nonatomic, readonly) FourCharCode format;
@property(nonatomic, readonly) MP42MediaType mediaType;
@property(nonatomic, readwrite, getter=isEnabled) BOOL enabled;
@property(nonatomic, readwrite, copy) NSString *name;
@property(nonatomic, readwrite, copy) NSString *language;
@property(nonatomic, readwrite, copy) NSString *extendedLanguageTag;
@property(nonatomic, readwrite, copy) NSSet<NSString *> *mediaCharacteristicTags;
@property(nonatomic, readwrite, getter=isEnabled) BOOL enabled;
@property(nonatomic, readwrite) uint64_t alternate_group;
@property(nonatomic, readwrite) int64_t startOffset;
@property(nonatomic, readonly) uint32_t timescale;
@property(nonatomic, readonly) uint32_t bitrate;
@property(nonatomic, readwrite) MP42Duration duration;
@property(nonatomic, readonly) uint32_t timescale;
@property(nonatomic, readonly) uint32_t bitrate;
@property(nonatomic, readonly) MP42Duration duration;
@property(nonatomic, readwrite) BOOL isEdited;
@property(nonatomic, readwrite) BOOL muxed;
@property(nonatomic, readonly) BOOL muxed;
@property(nonatomic, readwrite, copy) MP42ConversionSettings *conversionSettings;
+2 -2
View File
@@ -29,10 +29,10 @@
uint64_t _alternate_group;
int64_t _startOffset;
BOOL _needConversion;
uint32_t _timescale;
MP42Duration _duration;
NSMutableDictionary<NSString *, NSNumber *> *_updatedProperty;
}
- (instancetype)init
+1 -1
View File
@@ -9,7 +9,7 @@
#import <Foundation/Foundation.h>
#import "MP42Track.h"
@interface MP42VideoTrack : MP42Track <NSSecureCoding>
@interface MP42VideoTrack : MP42Track <NSSecureCoding, NSCopying>
@property(nonatomic, readwrite) uint64_t width;
@property(nonatomic, readwrite) uint64_t height;
+112 -93
View File
@@ -14,25 +14,24 @@
@implementation MP42VideoTrack
{
uint64_t width, height;
float trackWidth, trackHeight;
uint64_t _width, _height;
float _trackWidth, _trackHeight;
// Pixel Aspect Ratio
uint64_t hSpacing, vSpacing;
uint64_t _hSpacing, _vSpacing;
// Clean Aperture
uint64_t cleanApertureWidthN, cleanApertureWidthD;
uint64_t cleanApertureHeightN, cleanApertureHeightD;
uint64_t horizOffN, horizOffD;
uint64_t vertOffN, vertOffD;
uint64_t _cleanApertureWidthN, _cleanApertureWidthD;
uint64_t _cleanApertureHeightN, _cleanApertureHeightD;
uint64_t _horizOffN, _horizOffD;
uint64_t _vertOffN, _vertOffD;
// Matrix
uint32_t offsetX, offsetY;
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
@@ -42,14 +41,14 @@
if (self) {
if ([self isMemberOfClass:[MP42VideoTrack class]]) {
height = MP4GetTrackVideoHeight(fileHandle, _trackId);
width = MP4GetTrackVideoWidth(fileHandle, _trackId);
_height = MP4GetTrackVideoHeight(fileHandle, _trackId);
_width = MP4GetTrackVideoWidth(fileHandle, _trackId);
}
_mediaType = kMP42MediaType_Video;
MP4GetTrackFloatProperty(fileHandle, _trackId, "tkhd.width", &trackWidth);
MP4GetTrackFloatProperty(fileHandle, _trackId, "tkhd.height", &trackHeight);
MP4GetTrackFloatProperty(fileHandle, _trackId, "tkhd.width", &_trackWidth);
MP4GetTrackFloatProperty(fileHandle, _trackId, "tkhd.height", &_trackHeight);
uint8_t *val;
uint8_t nval[36];
@@ -58,28 +57,28 @@
MP4GetTrackBytesProperty(fileHandle ,_trackId, "tkhd.matrix", &val, &size);
memcpy(nval, val, size);
offsetX = CFSwapInt32BigToHost(ptr32[6]) / 0x10000;
offsetY = CFSwapInt32BigToHost(ptr32[7]) / 0x10000;
_offsetX = CFSwapInt32BigToHost(ptr32[6]) / 0x10000;
_offsetY = CFSwapInt32BigToHost(ptr32[7]) / 0x10000;
free(val);
if (MP4HaveTrackAtom(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.pasp")) {
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.pasp.hSpacing", &hSpacing);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.pasp.vSpacing", &vSpacing);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.pasp.hSpacing", &_hSpacing);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.pasp.vSpacing", &_vSpacing);
}
else {
hSpacing = 1;
vSpacing = 1;
_hSpacing = 1;
_vSpacing = 1;
}
if (MP4HaveTrackAtom(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap")) {
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureWidthN", &cleanApertureWidthN);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureWidthD", &cleanApertureWidthD);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureHeightN", &cleanApertureHeightN);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureHeightD", &cleanApertureHeightD);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.horizOffN", &horizOffN);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.horizOffD", &horizOffD);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.vertOffN", &vertOffN);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.vertOffD", &vertOffD);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureWidthN", &_cleanApertureWidthN);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureWidthD", &_cleanApertureWidthD);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureHeightN", &_cleanApertureHeightN);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureHeightD", &_cleanApertureHeightD);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.horizOffN", &_horizOffN);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.horizOffD", &_horizOffD);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.vertOffN", &_vertOffN);
MP4GetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.vertOffD", &_vertOffD);
}
if (_format == kMP42VideoCodecType_H264) {
@@ -111,9 +110,9 @@
if (_trackId) {
[super writeToFile:fileHandle error:outError];
if (trackWidth > 0 && trackHeight > 0) {
MP4SetTrackFloatProperty(fileHandle, _trackId, "tkhd.width", trackWidth);
MP4SetTrackFloatProperty(fileHandle, _trackId, "tkhd.height", trackHeight);
if (_trackWidth > 0 && _trackHeight > 0) {
MP4SetTrackFloatProperty(fileHandle, _trackId, "tkhd.width", _trackWidth);
MP4SetTrackFloatProperty(fileHandle, _trackId, "tkhd.height", _trackHeight);
uint8_t *val;
uint8_t nval[36];
@@ -122,49 +121,49 @@
MP4GetTrackBytesProperty(fileHandle ,_trackId, "tkhd.matrix", &val, &size);
memcpy(nval, val, size);
ptr32[6] = CFSwapInt32HostToBig(offsetX * 0x10000);
ptr32[7] = CFSwapInt32HostToBig(offsetY * 0x10000);
ptr32[6] = CFSwapInt32HostToBig(_offsetX * 0x10000);
ptr32[7] = CFSwapInt32HostToBig(_offsetY * 0x10000);
MP4SetTrackBytesProperty(fileHandle, _trackId, "tkhd.matrix", nval, size);
free(val);
if (_updatedProperty[@"hSpacing"] || _updatedProperty[@"vSpacing"]) {
if (hSpacing >= 1 && vSpacing >= 1) {
if (self.updatedProperty[@"hSpacing"] || self.updatedProperty[@"vSpacing"]) {
if (_hSpacing >= 1 && _vSpacing >= 1) {
if (MP4HaveTrackAtom(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.pasp")) {
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.pasp.hSpacing", hSpacing);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.pasp.vSpacing", vSpacing);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.pasp.hSpacing", _hSpacing);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.pasp.vSpacing", _vSpacing);
}
else {
MP4AddPixelAspectRatio(fileHandle, _trackId, (uint32_t)hSpacing, (uint32_t)vSpacing);
MP4AddPixelAspectRatio(fileHandle, _trackId, (uint32_t)_hSpacing, (uint32_t)_vSpacing);
}
}
}
if (cleanApertureWidthN >= 1 && cleanApertureHeightN >= 1) {
if (_cleanApertureWidthN >= 1 && _cleanApertureHeightN >= 1) {
if (MP4HaveTrackAtom(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap")) {
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureWidthN", cleanApertureWidthN);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureWidthD", cleanApertureWidthD);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureWidthN", _cleanApertureWidthN);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureWidthD", _cleanApertureWidthD);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureHeightN", cleanApertureHeightN);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureHeightD", cleanApertureHeightD);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureHeightN", _cleanApertureHeightN);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureHeightD", _cleanApertureHeightD);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.horizOffN", horizOffN);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.horizOffD", horizOffD);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.horizOffN", _horizOffN);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.horizOffD", _horizOffD);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.vertOffN", vertOffN);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.vertOffD", vertOffD);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.vertOffN", _vertOffN);
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*.clap.vertOffD", _vertOffD);
}
else
MP4AddCleanAperture(fileHandle, _trackId, cleanApertureWidthN, cleanApertureWidthD, cleanApertureHeightN, cleanApertureHeightD,
horizOffN, horizOffD, vertOffN, vertOffD);
MP4AddCleanAperture(fileHandle, _trackId, _cleanApertureWidthN, _cleanApertureWidthD, _cleanApertureHeightN, _cleanApertureHeightD,
_horizOffN, _horizOffD, _vertOffN, _vertOffD);
}
if (_format == kMP42VideoCodecType_H264) {
if (_updatedProperty[@"profile"]) {
if (self.updatedProperty[@"profile"]) {
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*[0].avcC.AVCProfileIndication", _newProfile);
_origProfile = _newProfile;
}
if (_updatedProperty[@"level"]) {
if (self.updatedProperty[@"level"]) {
MP4SetTrackIntegerProperty(fileHandle, _trackId, "mdia.minf.stbl.stsd.*[0].avcC.AVCLevelIndication", _newLevel);
_origLevel = _newLevel;
}
@@ -175,44 +174,28 @@
return (_trackId > 0);
}
@synthesize width;
@synthesize height;
@synthesize trackWidth;
@synthesize trackHeight;
- (uint64_t)hSpacing {
return hSpacing;
return _hSpacing;
}
- (void)setHSpacing:(uint64_t)newHSpacing
{
hSpacing = newHSpacing;
_hSpacing = newHSpacing;
_isEdited = YES;
_updatedProperty[@"hSpacing"] = @YES;
self.updatedProperty[@"hSpacing"] = @YES;
}
- (uint64_t)vSpacing {
return vSpacing;
return _vSpacing;
}
- (void)setVSpacing:(uint64_t)newVSpacing
{
vSpacing = newVSpacing;
_vSpacing = newVSpacing;
_isEdited = YES;
_updatedProperty[@"vSpacing"] = @YES;
self.updatedProperty[@"vSpacing"] = @YES;
}
@synthesize offsetX;
@synthesize offsetY;
@synthesize cleanApertureHeightD, cleanApertureHeightN, cleanApertureWidthD, cleanApertureWidthN;
@synthesize horizOffD, horizOffN, vertOffD, vertOffN;
@synthesize origProfile = _origProfile;
@synthesize origLevel = _origLevel;
- (uint8_t)newProfile {
return _newProfile;
}
@@ -223,10 +206,10 @@
_isEdited = YES;
if (_newProfile == _origProfile) {
_updatedProperty[@"profile"] = @NO;
self.updatedProperty[@"profile"] = @NO;
}
else {
_updatedProperty[@"profile"] = @YES;
self.updatedProperty[@"profile"] = @YES;
}
}
@@ -240,13 +223,49 @@
_isEdited = YES;
if (_newLevel == _origLevel) {
_updatedProperty[@"level"] = @NO;
self.updatedProperty[@"level"] = @NO;
}
else {
_updatedProperty[@"level"] = @YES;
self.updatedProperty[@"level"] = @YES;
}
}
#pragma mark - NSCopying
- (instancetype)copyWithZone:(NSZone *)zone
{
MP42VideoTrack *copy = [super copyWithZone:zone];
if (copy) {
copy->_width = _width;
copy->_height = _height;
copy->_trackWidth = _trackWidth;
copy->_trackHeight = _trackHeight;
copy->_hSpacing = _hSpacing;
copy->_vSpacing = _vSpacing;
copy->_cleanApertureWidthN = _cleanApertureWidthN;
copy->_cleanApertureWidthD = _cleanApertureWidthD;
copy->_cleanApertureHeightN = _cleanApertureHeightN;
copy->_cleanApertureHeightD = _cleanApertureHeightD;
copy->_horizOffN = _horizOffN;
copy->_horizOffD = _horizOffD;
copy->_vertOffN = _vertOffN;
copy->_vertOffD = _vertOffD;
copy->_offsetX = _offsetX;
copy->_offsetY = _offsetY;
copy->_origLevel = _origLevel;
copy->_origProfile = _origProfile;
copy->_newProfile = _newProfile;
copy->_newLevel = _newLevel;
}
return copy;
}
#pragma mark - NSSecureCoding
- (void)encodeWithCoder:(NSCoder *)coder
@@ -255,17 +274,17 @@
[coder encodeInt:1 forKey:@"MP42VideoTrackVersion"];
[coder encodeInt64:width forKey:@"width"];
[coder encodeInt64:height forKey:@"height"];
[coder encodeInt64:_width forKey:@"width"];
[coder encodeInt64:_height forKey:@"height"];
[coder encodeFloat:trackWidth forKey:@"trackWidth"];
[coder encodeFloat:trackHeight forKey:@"trackHeight"];
[coder encodeFloat:_trackWidth forKey:@"trackWidth"];
[coder encodeFloat:_trackHeight forKey:@"trackHeight"];
[coder encodeInt64:hSpacing forKey:@"hSpacing"];
[coder encodeInt64:vSpacing forKey:@"vSpacing"];
[coder encodeInt64:_hSpacing forKey:@"hSpacing"];
[coder encodeInt64:_vSpacing forKey:@"vSpacing"];
[coder encodeInt32:offsetX forKey:@"offsetX"];
[coder encodeInt32:offsetY forKey:@"offsetY"];
[coder encodeInt32:_offsetX forKey:@"offsetX"];
[coder encodeInt32:_offsetY forKey:@"offsetY"];
[coder encodeInt:_origProfile forKey:@"origProfile"];
[coder encodeInt:_origLevel forKey:@"origLevel"];
@@ -278,17 +297,17 @@
{
self = [super initWithCoder:decoder];
width = [decoder decodeInt64ForKey:@"width"];
height = [decoder decodeInt64ForKey:@"height"];
_width = [decoder decodeInt64ForKey:@"width"];
_height = [decoder decodeInt64ForKey:@"height"];
trackWidth = [decoder decodeFloatForKey:@"trackWidth"];
trackHeight = [decoder decodeFloatForKey:@"trackHeight"];
_trackWidth = [decoder decodeFloatForKey:@"trackWidth"];
_trackHeight = [decoder decodeFloatForKey:@"trackHeight"];
hSpacing = [decoder decodeInt64ForKey:@"hSpacing"];
vSpacing = [decoder decodeInt64ForKey:@"vSpacing"];
_hSpacing = [decoder decodeInt64ForKey:@"hSpacing"];
_vSpacing = [decoder decodeInt64ForKey:@"vSpacing"];
offsetX = [decoder decodeInt32ForKey:@"offsetX"];
offsetY = [decoder decodeInt32ForKey:@"offsetY"];
_offsetX = [decoder decodeInt32ForKey:@"offsetX"];
_offsetY = [decoder decodeInt32ForKey:@"offsetY"];
_origProfile = [decoder decodeIntForKey:@"origProfile"];
_origLevel = [decoder decodeIntForKey:@"origLevel"];
@@ -300,7 +319,7 @@
}
- (NSString *)description {
return [[super description] stringByAppendingFormat:@", %lld x %lld", width, height];
return [[super description] stringByAppendingFormat:@", %lld x %lld", _width, _height];
}
@end
+1
View File
@@ -16,6 +16,7 @@
#import "mp4v2.h"
#import "MP42PrivateUtilities.h"
#import "MP42Track+Muxer.h"
#import "MP42Track+Private.h"
@interface SBVobSubSample : NSObject
{