Add support for hvcE and avcE boxes.
This commit is contained in:
5 files changed
+76
-17
No files matched your search
@@ -331,6 +331,16 @@ MP42_OBJC_DIRECT_MEMBERS
|
|||||||
|
|
||||||
videoTrack.dolbyVision = dv;
|
videoTrack.dolbyVision = dv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CFDataRef dvELConfiguration = CFDictionaryGetValue(atoms, @"hvcE");
|
||||||
|
|
||||||
|
if (!dvELConfiguration) {
|
||||||
|
dvELConfiguration = CFDictionaryGetValue(atoms, @"avcE");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dvELConfiguration) {
|
||||||
|
videoTrack.dolbyVisionELConfiguration = (__bridge NSData *)(dvELConfiguration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-15
@@ -197,27 +197,38 @@ MP42_OBJC_DIRECT_MEMBERS
|
|||||||
|
|
||||||
for (unsigned int xi = 0; xi < bamCount; xi++) {
|
for (unsigned int xi = 0; xi < bamCount; xi++) {
|
||||||
BlockAdditionMapping *blockAddition = &bams[xi];
|
BlockAdditionMapping *blockAddition = &bams[xi];
|
||||||
if (blockAddition->TrackId == i &&
|
|
||||||
(blockAddition->Value == 0x64766343 || blockAddition->Value == 0x664767643 || blockAddition->Value == 0x64767643) &&
|
|
||||||
blockAddition->Length >= 24) {
|
|
||||||
uint8_t *data = malloc(blockAddition->Length);
|
|
||||||
|
|
||||||
if (readData(_ioStream, blockAddition->Position, &data, blockAddition->Length)) {
|
if (blockAddition->TrackId == i) {
|
||||||
MP42DolbyVisionMetadata dv;
|
if ((blockAddition->Value == 'dvcC' ||
|
||||||
|
blockAddition->Value == 0x664767643 ||
|
||||||
|
blockAddition->Value == 'dvvC') &&
|
||||||
|
blockAddition->Length >= 24) {
|
||||||
|
uint8_t *buffer = malloc(blockAddition->Length);
|
||||||
|
|
||||||
dv.versionMajor = data[0];
|
if (readData(_ioStream, blockAddition->Position, &buffer, blockAddition->Length)) {
|
||||||
dv.versionMinor = data[1];
|
MP42DolbyVisionMetadata dv;
|
||||||
|
|
||||||
dv.profile = (data[2] & 0xfe) >> 1;
|
dv.versionMajor = buffer[0];
|
||||||
dv.level = ((data[2] & 0x1) << 7) + ((data[3] & 0xf8) >> 3);
|
dv.versionMinor = buffer[1];
|
||||||
|
|
||||||
dv.rpuPresentFlag = (data[3] & 0x4) >> 2;
|
dv.profile = (buffer[2] & 0xfe) >> 1;
|
||||||
dv.elPresentFlag = (data[3] & 0x2) >> 1;
|
dv.level = ((buffer[2] & 0x1) << 7) + ((buffer[3] & 0xf8) >> 3);
|
||||||
dv.blPresentFlag = data[3] & 0x1;
|
|
||||||
|
|
||||||
dv.blSignalCompatibilityId = (data[4] & 0xf0) >> 4;
|
dv.rpuPresentFlag = (buffer[3] & 0x4) >> 2;
|
||||||
|
dv.elPresentFlag = (buffer[3] & 0x2) >> 1;
|
||||||
|
dv.blPresentFlag = buffer[3] & 0x1;
|
||||||
|
|
||||||
videoTrack.dolbyVision = dv;
|
dv.blSignalCompatibilityId = (buffer[4] & 0xf0) >> 4;
|
||||||
|
|
||||||
|
videoTrack.dolbyVision = dv;
|
||||||
|
free(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (blockAddition->Value == 'hvcE' || blockAddition->Value == 'avcE') {
|
||||||
|
uint8_t *buffer = malloc(blockAddition->Length);
|
||||||
|
if (readData(_ioStream, blockAddition->Position, &buffer, blockAddition->Length)) {
|
||||||
|
videoTrack.dolbyVisionELConfiguration = [NSData dataWithBytesNoCopy:buffer length:blockAddition->Length];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -241,6 +241,11 @@ MP42_OBJC_DIRECT_MEMBERS
|
|||||||
videoTrack.dolbyVision.blPresentFlag,
|
videoTrack.dolbyVision.blPresentFlag,
|
||||||
videoTrack.dolbyVision.blSignalCompatibilityId);
|
videoTrack.dolbyVision.blSignalCompatibilityId);
|
||||||
}
|
}
|
||||||
|
if (videoTrack.dolbyVisionELConfiguration) {
|
||||||
|
MP4SetDolbyVisionELConfiguration(_fileHandle, dstTrackId,
|
||||||
|
videoTrack.dolbyVisionELConfiguration.bytes,
|
||||||
|
(uint32_t)videoTrack.dolbyVisionELConfiguration.length);
|
||||||
|
}
|
||||||
[importer setActiveTrack:track];
|
[importer setActiveTrack:track];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -259,6 +264,12 @@ MP42_OBJC_DIRECT_MEMBERS
|
|||||||
(format == kMP42VideoCodecType_DolbyVisionHEVC || format == kMP42VideoCodecType_DolbyVisionHEVC_PSinBitstream)) {
|
(format == kMP42VideoCodecType_DolbyVisionHEVC || format == kMP42VideoCodecType_DolbyVisionHEVC_PSinBitstream)) {
|
||||||
|
|
||||||
MP42VideoTrack *videoTrack = (MP42VideoTrack *)track;
|
MP42VideoTrack *videoTrack = (MP42VideoTrack *)track;
|
||||||
|
uint8_t *hvcCAtom = (uint8_t *)magicCookie.bytes;
|
||||||
|
|
||||||
|
if ([_options[MP42ForceHvc1] boolValue] && magicCookie.length < UINT32_MAX) {
|
||||||
|
force_HEVC_completeness(hvcCAtom, (uint32_t)magicCookie.length);
|
||||||
|
}
|
||||||
|
|
||||||
bool completeness = 0;
|
bool completeness = 0;
|
||||||
if (magicCookie.length && magicCookie.length < UINT32_MAX && !analyze_HEVC(magicCookie.bytes, (uint32_t)magicCookie.length, &completeness)) {
|
if (magicCookie.length && magicCookie.length < UINT32_MAX && !analyze_HEVC(magicCookie.bytes, (uint32_t)magicCookie.length, &completeness)) {
|
||||||
|
|
||||||
@@ -276,6 +287,11 @@ MP42_OBJC_DIRECT_MEMBERS
|
|||||||
completeness);
|
completeness);
|
||||||
|
|
||||||
if (dstTrackId) {
|
if (dstTrackId) {
|
||||||
|
if (videoTrack.dolbyVisionELConfiguration) {
|
||||||
|
MP4SetDolbyVisionELConfiguration(_fileHandle, dstTrackId,
|
||||||
|
videoTrack.dolbyVisionELConfiguration.bytes,
|
||||||
|
(uint32_t)videoTrack.dolbyVisionELConfiguration.length);
|
||||||
|
}
|
||||||
[importer setActiveTrack:track];
|
[importer setActiveTrack:track];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -27,12 +27,13 @@
|
|||||||
@property(nonatomic, readwrite) uint16_t matrixCoefficients;
|
@property(nonatomic, readwrite) uint16_t matrixCoefficients;
|
||||||
@property(nonatomic, readwrite) uint16_t colorRange;
|
@property(nonatomic, readwrite) uint16_t colorRange;
|
||||||
|
|
||||||
// HDR Mastering Metadata
|
// HDR10 Mastering Metadata
|
||||||
@property(nonatomic, readwrite) MP42MasteringDisplayMetadata mastering;
|
@property(nonatomic, readwrite) MP42MasteringDisplayMetadata mastering;
|
||||||
@property(nonatomic, readwrite) MP42ContentLightMetadata coll;
|
@property(nonatomic, readwrite) MP42ContentLightMetadata coll;
|
||||||
|
|
||||||
// Dolby Vision
|
// Dolby Vision
|
||||||
@property(nonatomic, readwrite) MP42DolbyVisionMetadata dolbyVision;
|
@property(nonatomic, readwrite) MP42DolbyVisionMetadata dolbyVision;
|
||||||
|
@property(nonatomic, readwrite) NSData *dolbyVisionELConfiguration;
|
||||||
|
|
||||||
// Pixel Aspect Ratio
|
// Pixel Aspect Ratio
|
||||||
@property(nonatomic, readwrite) uint64_t hSpacing;
|
@property(nonatomic, readwrite) uint64_t hSpacing;
|
||||||
|
|||||||
+22
-1
@@ -188,6 +188,24 @@ MP42_OBJC_DIRECT_MEMBERS
|
|||||||
_dolbyVision.blPresentFlag = blPresentFlag;
|
_dolbyVision.blPresentFlag = blPresentFlag;
|
||||||
_dolbyVision.blSignalCompatibilityId = blSignalCompatibilityId;
|
_dolbyVision.blSignalCompatibilityId = blSignalCompatibilityId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (MP4HaveTrackAtom(fileHandle, self.trackId, "mdia.minf.stbl.stsd.*.hvcE")) {
|
||||||
|
uint8_t *ppValue;
|
||||||
|
uint32_t pValueSize = 0;
|
||||||
|
MP4GetTrackBytesProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.*.hvcE.HEVCConfig", &ppValue, &pValueSize);
|
||||||
|
if (pValueSize) {
|
||||||
|
_dolbyVisionELConfiguration = [NSData dataWithBytesNoCopy:ppValue length:pValueSize];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (MP4HaveTrackAtom(fileHandle, self.trackId, "mdia.minf.stbl.stsd.*.avcE")) {
|
||||||
|
uint8_t *ppValue;
|
||||||
|
uint32_t pValueSize = 0;
|
||||||
|
MP4GetTrackBytesProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.*.avcE.AVCConfig", &ppValue, &pValueSize);
|
||||||
|
if (pValueSize) {
|
||||||
|
_dolbyVisionELConfiguration = [NSData dataWithBytesNoCopy:ppValue length:pValueSize];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (MP4HaveTrackAtom(fileHandle, self.trackId, "mdia.minf.stbl.stsd.*.clap")) {
|
if (MP4HaveTrackAtom(fileHandle, self.trackId, "mdia.minf.stbl.stsd.*.clap")) {
|
||||||
MP4GetTrackIntegerProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureWidthN", &_cleanApertureWidthN);
|
MP4GetTrackIntegerProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureWidthN", &_cleanApertureWidthN);
|
||||||
MP4GetTrackIntegerProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureWidthD", &_cleanApertureWidthD);
|
MP4GetTrackIntegerProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.*.clap.cleanApertureWidthD", &_cleanApertureWidthD);
|
||||||
@@ -484,7 +502,7 @@ static uint32_t convertToFixedPoint(CGFloat value) {
|
|||||||
if (![summary containsString:@"Dolby Vision"]) {
|
if (![summary containsString:@"Dolby Vision"]) {
|
||||||
[summary appendString:@" Dolby Vision"];
|
[summary appendString:@" Dolby Vision"];
|
||||||
}
|
}
|
||||||
[summary appendFormat:@" %d.%d", _dolbyVision.profile, _dolbyVision.level];
|
[summary appendFormat:@" %d.%d", _dolbyVision.profile, _dolbyVision.blSignalCompatibilityId];
|
||||||
}
|
}
|
||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
@@ -511,6 +529,7 @@ static uint32_t convertToFixedPoint(CGFloat value) {
|
|||||||
copy->_mastering = _mastering;
|
copy->_mastering = _mastering;
|
||||||
copy->_coll = _coll;
|
copy->_coll = _coll;
|
||||||
copy->_dolbyVision = _dolbyVision;
|
copy->_dolbyVision = _dolbyVision;
|
||||||
|
copy->_dolbyVisionELConfiguration = _dolbyVisionELConfiguration;
|
||||||
|
|
||||||
copy->_hSpacing = _hSpacing;
|
copy->_hSpacing = _hSpacing;
|
||||||
copy->_vSpacing = _vSpacing;
|
copy->_vSpacing = _vSpacing;
|
||||||
@@ -594,6 +613,7 @@ static uint32_t convertToFixedPoint(CGFloat value) {
|
|||||||
[coder encodeInt32:_dolbyVision.elPresentFlag forKey:@"DVelPresentFlag"];
|
[coder encodeInt32:_dolbyVision.elPresentFlag forKey:@"DVelPresentFlag"];
|
||||||
[coder encodeInt32:_dolbyVision.blPresentFlag forKey:@"DVblPresentFlag"];
|
[coder encodeInt32:_dolbyVision.blPresentFlag forKey:@"DVblPresentFlag"];
|
||||||
[coder encodeInt32:_dolbyVision.blSignalCompatibilityId forKey:@"DVblSignalCompatibilityId"];
|
[coder encodeInt32:_dolbyVision.blSignalCompatibilityId forKey:@"DVblSignalCompatibilityId"];
|
||||||
|
[coder encodeObject:_dolbyVisionELConfiguration forKey:@"DVELConfiguration"];
|
||||||
|
|
||||||
[coder encodeDouble:_transform.a forKey:@"transformA"];
|
[coder encodeDouble:_transform.a forKey:@"transformA"];
|
||||||
[coder encodeDouble:_transform.b forKey:@"transformB"];
|
[coder encodeDouble:_transform.b forKey:@"transformB"];
|
||||||
@@ -659,6 +679,7 @@ static uint32_t convertToFixedPoint(CGFloat value) {
|
|||||||
_dolbyVision.elPresentFlag = [decoder decodeInt32ForKey:@"DVelPresentFlag"];
|
_dolbyVision.elPresentFlag = [decoder decodeInt32ForKey:@"DVelPresentFlag"];
|
||||||
_dolbyVision.blPresentFlag = [decoder decodeInt32ForKey:@"DVblPresentFlag"];
|
_dolbyVision.blPresentFlag = [decoder decodeInt32ForKey:@"DVblPresentFlag"];
|
||||||
_dolbyVision.blSignalCompatibilityId = [decoder decodeInt32ForKey:@"DVblSignalCompatibilityId"];
|
_dolbyVision.blSignalCompatibilityId = [decoder decodeInt32ForKey:@"DVblSignalCompatibilityId"];
|
||||||
|
_dolbyVisionELConfiguration = [decoder decodeObjectOfClass:[NSData class] forKey:@"DVELConfiguration"];
|
||||||
|
|
||||||
_hSpacing = [decoder decodeInt64ForKey:@"hSpacing"];
|
_hSpacing = [decoder decodeInt64ForKey:@"hSpacing"];
|
||||||
_vSpacing = [decoder decodeInt64ForKey:@"vSpacing"];
|
_vSpacing = [decoder decodeInt64ForKey:@"vSpacing"];
|
||||||
|
|||||||
Reference in new issue
Block a user