Preliminary work to read opus a flac thru AVFoundation
This commit is contained in:
1 parent
3e05d0b4f6
commit
abdcc08369
3 files changed
+39
-3
No files matched your search
+1
-1
@@ -106,7 +106,7 @@ static const struct {
|
||||
{ kAudioFormatEnhancedAC3, AV_CODEC_ID_EAC3 },
|
||||
{ 'XiFL', AV_CODEC_ID_FLAC },
|
||||
{ 'XiVs', AV_CODEC_ID_VORBIS },
|
||||
{ 'Opus', AV_CODEC_ID_OPUS },
|
||||
{ 'opus', AV_CODEC_ID_OPUS },
|
||||
{ kAudioFormatAppleLossless, AV_CODEC_ID_ALAC },
|
||||
{ 'DTS ', AV_CODEC_ID_DTS },
|
||||
{ 'trhd', AV_CODEC_ID_TRUEHD },
|
||||
|
||||
+37
-1
@@ -50,7 +50,7 @@
|
||||
|
||||
+ (NSArray<NSString *> *)supportedFileFormats {
|
||||
return @[@"mov", @"qt", @"mp4", @"m4v", @"m4a", @"mp3", @"m2ts", @"ts", @"mts",
|
||||
@"ac3", @"eac3", @"ec3", @"webvtt", @"vtt", @"caf", @"aif", @"aiff", @"aifc", @"wav"];
|
||||
@"ac3", @"eac3", @"ec3", @"webvtt", @"vtt", @"caf", @"aif", @"aiff", @"aifc", @"wav", @"flac"];
|
||||
}
|
||||
|
||||
- (FourCharCode)formatForTrack:(AVAssetTrack *)track {
|
||||
@@ -63,6 +63,9 @@
|
||||
case 'ms \0':
|
||||
result = kMP42AudioCodecType_AC3;
|
||||
break;
|
||||
case 'flac':
|
||||
result = kMP42AudioCodecType_FLAC;
|
||||
break;
|
||||
case 'SRT ':
|
||||
result = kMP42SubtitleCodecType_Text;
|
||||
break;
|
||||
@@ -206,9 +209,15 @@
|
||||
else if (CFEqual(transferFunctions, kCMFormatDescriptionTransferFunction_SMPTE_240M_1995)) {
|
||||
videoTrack.transferCharacteristics = 7;
|
||||
}
|
||||
else if (CFEqual(transferFunctions, CFSTR("SMPTE_ST_2084_PQ"))) { // kCMFormatDescriptionTransferFunction_SMPTE_ST_2084_PQ
|
||||
videoTrack.transferCharacteristics = 16;
|
||||
}
|
||||
else if (CFEqual(transferFunctions, kCMFormatDescriptionTransferFunction_SMPTE_ST_428_1)) {
|
||||
videoTrack.transferCharacteristics = 17;
|
||||
}
|
||||
else if (CFEqual(transferFunctions, CFSTR("ITU_R_2100_HLG"))) { // kCMFormatDescriptionTransferFunction_ITU_R_2100_HLG
|
||||
videoTrack.transferCharacteristics = 18;
|
||||
}
|
||||
}
|
||||
|
||||
CFStringRef YCbCrMatrix = CMFormatDescriptionGetExtension(formatDescription, kCMFormatDescriptionExtension_YCbCrMatrix);
|
||||
@@ -749,6 +758,33 @@
|
||||
return [NSData dataWithBytes:cookieBuffer length:cookieSizeOut];
|
||||
}
|
||||
|
||||
else if (code == 'opus') {
|
||||
// dec3 atom
|
||||
// remove the atom header
|
||||
//cookieBuffer += 9;
|
||||
//cookieSizeOut = cookieSizeOut - 9;
|
||||
|
||||
UInt32 *cookie = (UInt32 *)cookieBuffer;
|
||||
|
||||
for (size_t i = 0; i < cookieSizeOut / 8; i++) {
|
||||
cookie[i] = EndianS32_BtoN(cookie[i]);
|
||||
}
|
||||
|
||||
return [NSData dataWithBytes:cookieBuffer length:cookieSizeOut];
|
||||
}
|
||||
|
||||
else if (code == 'flac') {
|
||||
|
||||
UInt32 *cookie = (UInt32 *)cookieBuffer;
|
||||
|
||||
for (size_t i = 0; i < cookieSizeOut / 8; i++) {
|
||||
cookie[i] = EndianS32_BtoN(cookie[i]);
|
||||
}
|
||||
|
||||
return [NSData dataWithBytes:cookieBuffer length:cookieSizeOut];
|
||||
|
||||
}
|
||||
|
||||
else if (code == kAudioFormatEnhancedAC3) {
|
||||
// dec3 atom
|
||||
// remove the atom header
|
||||
|
||||
@@ -150,7 +150,7 @@ enum : MP42AudioCodecType
|
||||
kMP42AudioCodecType_DTS = 'DTS ',
|
||||
kMP42AudioCodecType_TrueHD = 'trhd',
|
||||
kMP42AudioCodecType_MLP = 'mlp ',
|
||||
kMP42AudioCodecType_Opus = 'Opus',
|
||||
kMP42AudioCodecType_Opus = 'opus',
|
||||
kMP42AudioCodecType_TTA = 'TTA1',
|
||||
|
||||
kMP42AudioCodecType_FairPlay = 'drms',
|
||||
|
||||
Reference in new issue
Block a user