Add experimental av1 support.

This commit is contained in:
Damiano Galassi committed 2021-05-31 12:09:29 +02:00
1 parent 453ccdf598
commit e42154278f
6 files changed
+42 -2

No files matched your search

+3
View File
@@ -812,6 +812,9 @@ MP42_OBJC_DIRECT_MEMBERS
else if (code == kCMVideoCodecType_HEVC || code == 'hev1') {
magicCookie = CFDictionaryGetValue(atoms, @"hvcC");
}
else if (code == 'av01') {
magicCookie = CFDictionaryGetValue(atoms, @"av1C");
}
else if (code == kCMVideoCodecType_MPEG4Video) {
magicCookie = CFDictionaryGetValue(atoms, @"esds");
}
+8
View File
@@ -223,6 +223,14 @@ typedef struct MP4DemuxHelper {
free(ppValue);
return magicCookie;
}
else if (!strcmp(media_data_name, "av01")) {
uint8_t *ppValue;
uint32_t pValueSize;
MP4GetTrackBytesProperty(_fileHandle, srcTrackId, "mdia.minf.stbl.stsd.av01.av1C.av1Config", &ppValue, &pValueSize);
magicCookie = [NSData dataWithBytes:ppValue length:pValueSize];
free(ppValue);
return magicCookie;
}
else if (!strcmp(media_data_name, "mp4v")) {
uint8_t *ppConfig; uint32_t pConfigSize;
MP4GetTrackESConfiguration(_fileHandle, srcTrackId, &ppConfig, &pConfigSize);
+24
View File
@@ -247,6 +247,30 @@ MP42_OBJC_DIRECT_MEMBERS
}
}
// AV1 video track
else if ([track isMemberOfClass:[MP42VideoTrack class]] && (format == kMP42VideoCodecType_AV1)) {
if (magicCookie.length && magicCookie.length < UINT32_MAX) {
dstTrackId = MP4AddAV1VideoTrack(_fileHandle, timeScale, MP4_INVALID_DURATION,
((MP42VideoTrack *)track).width, ((MP42VideoTrack *)track).height);
if (dstTrackId) {
MP4SetTrackBytesProperty(_fileHandle, dstTrackId, "mdia.minf.stbl.stsd.av01.av1C.av1Config", magicCookie.bytes, (uint32_t)magicCookie.length);
[importer setActiveTrack:track];
}
else {
[unsupportedTracks addObject:track];
continue;
}
}
else {
[unsupportedTracks addObject:track];
continue;
}
}
// MPEG-4 Visual video track
else if ([track isMemberOfClass:[MP42VideoTrack class]] && format == kMP42VideoCodecType_MPEG4Video) {
MP4SetVideoProfileLevel(_fileHandle, MPEG4_SP_L3);
+3
View File
@@ -228,6 +228,9 @@ FourCharCode getTrackMediaSubType(MP4FileHandle fileHandle, MP4TrackId Id)
else if (!strcmp(dataName, "hev1")) {
return kMP42VideoCodecType_HEVC_PSinBitstream;
}
else if (!strcmp(dataName, "av01")) {
return kMP42VideoCodecType_AV1;
}
else if (!strcmp(dataName, "mp4a")) {
uint8_t audiotype = MP4GetTrackEsdsObjectTypeId(fileHandle, Id);
if (audiotype == MP4_MPEG4_AUDIO_TYPE)
+2 -1
View File
@@ -39,7 +39,8 @@ MP42Duration TimeFromString(NSString *time_string, int32_t timeScale)
BOOL isTrackMuxable(FourCharCode format)
{
FourCharCode supportedFormats[] = {kMP42VideoCodecType_HEVC,
FourCharCode supportedFormats[] = {kMP42VideoCodecType_AV1,
kMP42VideoCodecType_HEVC,
kMP42VideoCodecType_HEVC_PSinBitstream,
kMP42VideoCodecType_H264,
kMP42VideoCodecType_MPEG4Video,
+2 -1
View File
@@ -203,7 +203,8 @@ static uint32_t convertToFixedPoint(CGFloat value) {
free(val);
if ((self.format == kMP42VideoCodecType_H264 || self.format == kMP42VideoCodecType_MPEG4Video
|| self.format == kMP42VideoCodecType_HEVC || self.format == kMP42VideoCodecType_HEVC_PSinBitstream)) {
|| self.format == kMP42VideoCodecType_HEVC || self.format == kMP42VideoCodecType_HEVC_PSinBitstream
|| self.format == kMP42VideoCodecType_AV1)) {
if (self.updatedProperty[@"colr"] || self.muxed == NO) {
if (_colorPrimaries > 0 && _transferCharacteristics > 0 && _matrixCoefficients > 0) {